I can't figure it out. The below trigger works, once. Then it doesn't work again. What it does is when a certain unit dies, it heals all units around it. Simple, but it only works one time, then won't fire again. Can anyone see what I'm doing wrong?
Edit: I ran some tests with text messages, to see what's all working. Everything is working correctly, the dummy is being created for every instance of timer tick, the ability is being added, but maybe heal is not being cast? I'm so confused and I have other "spells" that suffer the same issue that target multiple units from a group. Like, mass sleep, mass shackle, mass bloodlust, etc.. all work only one during the game and use a similar trigger like the one above but only work one time...
Edit2: I replaced using heal with holy light now it works everytime, so I guess my issue is resolved.
JASS:
struct dispurse
group toheal = CreateGroup()
player owner
timer t = CreateTimer()
method onDestroy takes nothing returns nothing
call DestroyGroup(.toheal)
call PauseTimer(.t)
call FlushHandleLocals(.t)
call DestroyTimer(.t)
endmethod
endstruct
function HealDispurseCond takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit())=='eC38' or GetUnitTypeId(GetTriggerUnit())=='e00P'
endfunction
function HealDispurseHeal takes nothing returns nothing
local timer t = GetExpiredTimer()
local dispurse data = dispurse(GetHandleInt(t,"struct"))
local unit u = FirstOfGroup(data.toheal)
local unit v
local player p
local real x
local real y
set p = GetOwningPlayer(u)
if CountUnitsInGroup(data.toheal) > 0 then
if IsPlayerAlly(data.owner, p) then
set x = GetUnitX(u)
set y = GetUnitY(u)
set v = CreateUnit(data.owner, 'h062', x, y, 270)
call UnitAddAbility(v, 'A06E')
call IssueTargetOrder(v, "heal", u)
call UnitApplyTimedLife(v, 'BTLF', 1)
endif
call GroupRemoveUnit(data.toheal, u)
else
call data.destroy()
endif
set t = null
set u = null
set v = null
set p = null
endfunction
function HealDispurse takes nothing returns nothing
local dispurse data = dispurse.create()
local unit u = GetDyingUnit()
local player p = GetOwningPlayer(u)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
call GroupEnumUnitsInRange(data.toheal, x, y, 500, null)
set data.owner = p
call SetHandleInt(data.t, "struct", data)
call TimerStart(data.t, .01, true, function HealDispurseHeal)
set u = null
set p = null
endfunction
function InitTrig_HealDispurse takes nothing returns nothing
local integer i = 6
set gg_trg_HealDispurse = CreateTrigger()
loop
exitwhen i > 11
call TriggerRegisterPlayerUnitEvent(gg_trg_HealDispurse, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
set i = i + 1
endloop
call TriggerAddCondition(gg_trg_HealDispurse, Condition(function HealDispurseCond))
call TriggerAddAction(gg_trg_HealDispurse, function HealDispurse)
endfunction
Edit: I ran some tests with text messages, to see what's all working. Everything is working correctly, the dummy is being created for every instance of timer tick, the ability is being added, but maybe heal is not being cast? I'm so confused and I have other "spells" that suffer the same issue that target multiple units from a group. Like, mass sleep, mass shackle, mass bloodlust, etc.. all work only one during the game and use a similar trigger like the one above but only work one time...
Edit2: I replaced using heal with holy light now it works everytime, so I guess my issue is resolved.
Last edited: