|
我把下面加到了一个人做的AI脚本里
脚本没意义其他问题
但是我加了我这段以后电脑运行这段AI就会出问题
只采矿其他什么事都没做
boolean huichen = false
group grp = CreateGroup()
unit u = null
real r1 = 0
real r2 = 0
integer index = 0
integer i = 6
function UnitUseItemPointLoc takes unit whichUnit, item whichItem, location loc returns boolean
return UnitUseItemPoint(whichUnit, whichItem, GetLocationX(loc), GetLocationY(loc))
endfunction
function GetPlayerStartLocationLoc takes player whichPlayer returns location
return GetStartLocationLoc(GetPlayerStartLocation(whichPlayer))
endfunction
function tp takes nothing returns nothing
call GroupEnumUnitsInRange(grp,0,0,999999,null)
loop
set u=FirstOfGroup(grp)
exitwhen u==null
if GetOwningPlayer(u)==ai_player and ((IsUnitType(u, UNIT_TYPE_HERO)) then
set r1=GetUnitState(u,UNIT_STATE_LIFE)
set r2=GetUnitState(u,UNIT_STATE_MAX_LIFE)
if r1/r2<=0.2 and (( CaptainInCombat(true) )or (not CaptainIsHome())) then
loop
exitwhen index>=6
if ((GetItemTypeId(UnitItemInSlot(u , index)) == 'stwp')) then
set i=index
endif
set index=index+1
endloop
if i!=6 and huicheng==false then
call ClearCaptainTargets()
call CaptainGoHome()
set loc=GetPlayerStartLocationLoc(ai_player)
call UnitUseItemPointLoc( u, UnitItemInSlot(u,i),loc )
call RemoveLocation(loc)
set huicheng = true
endif
set index=0
set i=6
endif
endif
call GroupRemoveUnit(grp,u)
endloop
if huicheng==true then
call Sleep(4)
set huicheng=false
endif
endfunction
function nc takes nothing returns nothing
loop
call tp()
call Sleep(0.3)
endloop
endfunction
然后在主函数里 call StartThread( function nc ) 了
|
|