package EventHandling trigger castTrig trigger evalTrig conditionfunc array conds unit array casters int count = 0 public function unit.registerCastEvent( conditionfunc c ) castTrig.registerUnitEvent(this, EVENT_UNIT_SPELL_EFFECT) conds[count] = c casters[count] = this count++ public function unit.unregisterCastEvent() for i = 0 to count if casters[i] == this for j = i to count - 1 conds[j] = conds[j+1] casters[j] = casters[j+1] i-- count-- function evaluateEvent() returns boolean var caster = GetSpellAbilityUnit() debugPrint(caster.getName(), 2) for i = 0 to count-1 debugPrint(i.toString(), 2) if casters[i] == caster evalTrig.addCondition(conds[i]) evalTrig.evaluate() evalTrig.clearConditions() return false init castTrig = CreateTrigger() castTrig.addCondition( Condition(function evaluateEvent) ) evalTrig = CreateTrigger()