• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Event fires 2x

Status
Not open for further replies.
Level 22
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
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Hmm maybe it's because of your initializer, vJass one and GUI one together i don't know how Jasshelper handle that, but it probably creates 2 initializers.

Anyway it's really a bad practive to use a such name for a vJass initializer.
Just use a private one spelled "init", or "onInit", something that makes sense.
 
Status
Not open for further replies.
Top