- Joined
- Sep 19, 2006
- Messages
- 152
Small question: is it better to use a condition to filter out possibles for a trigger event, or better to use a filter and avoid the condition altogether?
Feel free to point out any other improvements which might be made in these triggers.
Feel free to point out any other improvements which might be made in these triggers.
JASS:
Version #1
function HeroesDeath_Condition01 takes nothing returns boolean
local unit u = GetDyingUnit ()
local boolean b = IsUnitIllusion (u) == false and IsUnitType (u, UNIT_TYPE_HERO)
//
set u = null
return b
endfunction
function HeroesDeath_Action01 takes nothing returns nothing
local unit d = GetDyingUnit ()
local unit k = GetKillingUnit ()
x
x
x
set d = null
set k = null
endfunction
function InitTrig_HeroesDeath takes nothing returns nothing
local integer q = 0
set gg_trg_HeroesDeath = CreateTrigger ()
loop
exitwhen q > 11
call TriggerRegisterPlayerUnitEvent (gg_trg_HeroesDeath, Player (q), EVENT_PLAYER_UNIT_DEATH, null)
set q = q + 1
endloop
call TriggerAddCondition (gg_trg_HeroesDeath, Condition (function HeroesDeath_Condition01))
call TriggerAddAction (gg_trg_HeroesDeath, function HeroesDeath_Action01)
endfunction
Version #2
function HeroesDeath_Filter01 takes nothing returns boolean
local unit u = GetFilterUnit ()
local boolean b = IsUnitIllusion (u) == false and IsUnitType (u, UNIT_TYPE_HERO)
//
set u = null
return b
endfunction
function HeroesDeath_Action01 takes nothing returns nothing
local unit d = GetDyingUnit ()
local unit k = GetKillingUnit ()
x
x
x
set d = null
set k = null
endfunction
function InitTrig_HeroesDeath takes nothing returns nothing
local integer q = 0
set gg_trg_HeroesDeath = CreateTrigger ()
loop
exitwhen q > 11
call TriggerRegisterPlayerUnitEvent (gg_trg_HeroesDeath, Player (q), EVENT_PLAYER_UNIT_DEATH, Filter (function HeroesDeath_Filter01))
set q = q + 1
endloop
call TriggerAddAction (gg_trg_HeroesDeath, function HeroesDeath_Action01)
endfunction