waaaks!
Zinctified
- Reaction score
- 255
In the first thread I posted, I posted about stopping the locust swarm by killing the dummy unit, now I solved the problem, but it still has problems, the dummy kinda uses the spell twice, or maybe 2 dummies are created, because when I deactivated the immolation based spell, it kills the created dummy unit, but looks like there's another dummy unit remaining and still following my hero, but was not killed by the trigger.
I really don't have any idea why does the trigger created two units, it also has weird issues like if I removed the line that sets the global boolean back to false at the same instance the struct and timer was destroyed, it was like creating only 1 dummy. I need this global boolean to check if the spell was deactivated.
EDIT:
updated the code, now working correctly, but with the debug message I added, it really is acting weird, it posted two "start", I'll show you how does it look like:
I really don't have any idea why does the trigger created two units, it also has weird issues like if I removed the line that sets the global boolean back to false at the same instance the struct and timer was destroyed, it was like creating only 1 dummy. I need this global boolean to check if the spell was deactivated.
JASS:
scope LocustSwarm initializer init
globals
private constant integer spell = 039;A01R039;
private constant integer dspell = 039;A01U039;
private boolean array done
endglobals
private struct data
unit c
unit u
endstruct
private function con takes nothing returns boolean
return GetUnitAbilityLevel(GetLearningUnit(),spell) == 1
endfunction
private function callback takes nothing returns boolean
local timer t = GetExpiredTimer()
local data d = GetTimerData(t)
call SetUnitX(d.u,GetUnitX(d.c))
call SetUnitY(d.u,GetUnitY(d.c))
call BJDebugMsg("running")
if done[GetUnitId(d.c)] then
call KillUnit(d.u)
set d.u = null
call ReleaseTimer(t)
call d.destroy()
call BJDebugMsg("destroyed")
endif
set t = null
return true
endfunction
private function act2 takes nothing returns boolean
local unit c = GetTriggerUnit()
local timer t = NewTimer()
local integer l = GetUnitAbilityLevel(c,spell)
local data d = data.create()
set d.c = c
if GetIssuedOrderId() == OrderId("immolation") then
set done[GetUnitId(c)] = false
set d.u = CreateUnit(GetOwningPlayer(c),039;e006039;,GetUnitX(c),GetUnitY(c),0.0)
call UnitAddAbility(d.u,dspell)
call SetUnitAbilityLevel(d.u,dspell,l)
call IssueImmediateOrder(d.u,"locustswarm")
call TimerStart(t,0.035,true,function callback)
call SetTimerData(t,d)
call BJDebugMsg("start")
elseif GetIssuedOrderId() == OrderId("unimmolation") then
set done[GetUnitId(c)] = true
call BJDebugMsg("done")
endif
set c = null
set t = null
return true
endfunction
private function act takes nothing returns nothing
local trigger t = CreateTrigger()
local unit c = GetLearningUnit()
call TriggerRegisterUnitEvent( t, c, EVENT_UNIT_ISSUED_ORDER )
call TriggerAddAction(t,function act2)
set c = null
set t = null
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call XE_PreloadAbility(dspell)
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t,Condition(function con))
call TriggerAddAction(t,function act)
endfunction
endscope
EDIT:
updated the code, now working correctly, but with the debug message I added, it really is acting weird, it posted two "start", I'll show you how does it look like:
even though the 2 dummy units are successfully killed, the spell is not yet fixed, for I want only an exact number of locusts when the spell is activated, I don't want to double them, also I want to learn how to fix this for future use, thanks!start
start
running
running
running
running
running
running
running
running
done
done
running
destroyed
running
destroyed