Lightstalker
New Member
- Reaction score
- 55
For some reason, the BASICATK unit is not moving. However, the BJDebugMsg displays its name correctly.
Code:
Code:
JASS:
scope AttackMovement initializer Init
globals
group TEMPGROUP = CreateGroup()
group TEMPGROUP2 = CreateGroup()
endglobals
private function UnitIsDummy takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == BASICATK
endfunction
private function UnitIsEnemy takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetFilterUnit())) == true
endfunction
private function Callback takes nothing returns nothing
local unit u = GetEnumUnit()
local unit enemy = null
local real angle = GetUnitFacing(u)
local real x = GetUnitX(u) + 20.0 * Cos(angle * bj_DEGTORAD)
local real y = GetUnitY(u) + 20.0 * Sin(angle * bj_DEGTORAD)
call BJDebugMsg(GetUnitName(u))
call SetUnitPosition(u, x, y)
call GroupEnumUnitsInRange(TEMPGROUP2, GetUnitX(u), GetUnitY(u), 150.0, Condition(function UnitIsEnemy))
loop
set enemy = FirstOfGroup(TEMPGROUP2)
exitwhen enemy == null
call UnitDamageTarget(u, enemy, 250.0, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
call RemoveUnit(u)
call GroupRemoveUnit(TEMPGROUP2, enemy)
endloop
set u = null
endfunction
private function Actions takes nothing returns nothing
call GroupEnumUnitsInRect(TEMPGROUP, MAPENTIRE, Condition(function UnitIsDummy))
call ForGroup(TEMPGROUP, function Callback)
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.15625, true)
call TriggerAddAction(t, function Actions)
endfunction
endscope