boolean isDebug=true
unit mHero = null
constant integer SMART=851971 //右键单击
constant integer STOP=851972 //停止
constant integer ATTACK=851983 //攻击
constant integer ATTACKGROUND=851984 //攻击地面
constant integer MOVE=851986 //移动
constant integer PATROL=851990 //巡逻
constant integer HOLD=851993 //保持原位
function printf takes string msg returns nothing
if isDebug then
call DisplayTextToPlayer(GetLocalPlayer(),0,0,msg)
endif
endfunction
function selectHero takes nothing returns unit
local unit u = null
local group g = CreateGroup()
call GroupEnumUnitsOfPlayer(g,ai_player,null)
loop
set u = FirstOfGroup(g)
exitwhen u==null
if IsUnitType(u,UNIT_TYPE_HERO) and not IsUnitIllusion(u) then
return u
endif
call GroupRemoveUnit(g,u)
endloop
call RemoveUnit(u)
set u=null
return null
endfunction
//为玩家2创建守鹤
function CreateUnitById takes player playerId,integer unitId returns nothing
call CreateUnit(playerId,unitId,3600,3300,90)
endfunction
function gotoRandomLoc takes nothing returns nothing
local location loc = null
loop
set mHero = selectHero()
exitwhen mHero==null
set loc = Location(GetRandomReal(-4000,4000),GetRandomReal(-4000,4000))
call Sleep(10)
call IssuePointOrderByIdLoc(mHero,'attack',loc) //这边出错,因为没定义attack ---851983
call RemoveLocation(loc)set loc = null
endloop
endfunction
function main takes nothing returns nothing
call printf("Init AI>>>")
call InitAI()//初始化AI
call Sleep(10)
call CreateUnitById(ai_player,'H002')
call Sleep(1.0)
call selectHero()
call StartThread(function gotoRandomLoc)
endfunction