- Joined
- Feb 3, 2009
- Messages
- 3,292
Does anyone know why the bellow trigger always fires 2x for each death, I made a debug message and for each death the word checking was written twice which means the trigger runs 2x for every death.
JASS:
scope OrbOfDarkness initializer InitTrig_Orb_of_Darkness
private function Conditions takes nothing returns boolean
call BJDebugMsg("checking")
return GetUnitTypeId(GetTriggerUnit()) == 'H06J'
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit d
local location l = GetUnitLoc(u)
local group g
local boolean rev = true
local real t = 1.0
local real t2 = 30.0
set d = CreateUnitAtLoc(GetOwningPlayer(u), 'h06N', l, 0.0)
call UnitApplyTimedLife(d, 'Bpos', t2 + 3.0)
loop
exitwhen t2 <= 1
if IsUnitDeadBJ(d) == true then
set t2 = 1
set rev = false
endif
set t2 = t2 - t
call TriggerSleepAction(t)
endloop
if (rev == true) then
call ReviveHeroLoc(u, l, true)
call SetUnitManaPercentBJ(u, 100)
endif
call RemoveLocation(l)
call DestroyGroup(g)
set u = null
set d = null
endfunction
//===========================================================================
function InitTrig_Orb_of_Darkness takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( t, Condition( function Conditions ) )
call TriggerAddAction( t, function Actions )
endfunction
endscope