Help! why the enemy stop moving and attacking!
I create some units to attack my main hero.
but when i moving my main hero left <-> right around many times , the created enemys stop moving and attacking ,they seems to be suspend!
how can i make them moving and attacking again!
Thanks!
[v 1.32.9]
I create some units to attack my main hero.
but when i moving my main hero left <-> right around many times , the created enemys stop moving and attacking ,they seems to be suspend!
how can i make them moving and attacking again!
Thanks!
[v 1.32.9]
JASS:
library startInit initializer init_function
globals
private unit mainHero
private group enemyG
endglobals
private function oderUnit_attack takes nothing returns nothing
local unit u = GetEnumUnit()
local real x =GetUnitX(mainHero)
local real y =GetUnitY(mainHero)
if IsUnitType(u, UNIT_TYPE_DEAD) then
call GroupRemoveUnit(enemyG , u )
else
call IssuePointOrder( u , "attack" ,x , y )
// call IssuePointOrder( u , "attack" ,x , y )
// call IssuePointOrderLoc( u , "attack" , l )
endif
endfunction
private function startOderUnit takes nothing returns nothing
call ForGroup(enemyG ,function oderUnit_attack )
endfunction
private function createEnemy takes nothing returns nothing
local unit u
local real x = GetUnitX(mainHero)
local real y = GetUnitY(mainHero)
local location l = Location(x , y)
set u = CreateUnit(Player(5),'Hmkg',3000,3000,0)
call SetUnitAcquireRange(u, 2000.00)
call RemoveGuardPosition(u)
// call GroupAddUnit( enemyG,u)
// call IssuePointOrder( u , "attack" ,x , y )
call IssuePointOrderLoc( u , "attack" ,l )
call RemoveLocation(l)
// call BJDebugMsg(R2S(x) + " , " + R2S(y))
set u = null
set l = null
endfunction
private function createHero takes nothing returns nothing
set mainHero = CreateUnit(Player(0) , 'Hmkg' ,0 , 0 , 0 )
endfunction
private function initMap takes nothing returns nothing
call FogMaskEnableOff()
call FogEnableOff()
call SetCameraFieldForPlayer(Player(0), CAMERA_FIELD_TARGET_DISTANCE, 2200.00, 0)
call SetMapName("testMap")
call SetMapDescription("testMap")
call SetPlayers(5)
call SetTeams(5)
call BJDebugMsg("testMap inited!")
endfunction
private function init_function takes nothing returns nothing
local timer timer_createEnemy = CreateTimer()
local timer timer_oderEnemy = CreateTimer()
set enemyG = CreateGroup()
call initMap()
call createHero()
call createEnemy()
call TimerStart( timer_createEnemy , 0.5 , true , function createEnemy)
// call TimerStart( timer_oderEnemy , 0.03 , true , function startOderUnit)
endfunction
endlibrary