W!†A_cRaft
Ultra Cool Member
- Reaction score
- 28
I am trying to make an ON-attack triggered spell.
When a unit attacks it stores the attacker and attacked unit to hash
Creates a trigger that registers an even Unit (target) takes damage
than check if the attacker is the on who damaged it
check if the target has Poison arrow buff (in order to determin was the damage done by an attack)
check is the damage done >1
and than execute the trigger.
I ran into a problem where, to be more specific after the whole thing is done the trigger will still stay and i dont know if it causes leaks or not, but it will be useless to have the thing checked every time those two units exchange damage. So i need to destroy a trigger i created in it's actions function, how do i do that? How do i refer to the trigger who's actions im doing?
Look at the trigger below.
When a unit attacks it stores the attacker and attacked unit to hash
Creates a trigger that registers an even Unit (target) takes damage
than check if the attacker is the on who damaged it
check if the target has Poison arrow buff (in order to determin was the damage done by an attack)
check is the damage done >1
and than execute the trigger.
I ran into a problem where, to be more specific after the whole thing is done the trigger will still stay and i dont know if it causes leaks or not, but it will be useless to have the thing checked every time those two units exchange damage. So i need to destroy a trigger i created in it's actions function, how do i do that? How do i refer to the trigger who's actions im doing?
Look at the trigger below.
JASS:
function ondamaged takes nothing returns nothing
call SaveBoolean(udg_hash, GetHandleId(GetEventDamageSource()), StringHash("bool"), true)
call UnitRemoveAbility(GetEventDamageSource(), 039;A00A039;) //poison string
call UnitRemoveAbility(GetEventDamageSource(), 039;A00B039;) //sphere
call UnitRemoveAbility(GetEventDamageSource(), 039;A001039;) //sphere
call UnitRemoveAbility(GetEventDamageSource(), 039;A009039;) //+damage ability
//here i need to despose of everything that is unnecessary, i dont know how.
endfunction
function damagecheck takes nothing returns boolean
local unit u = LoadUnitHandle(udg_hash, GetHandleId(GetTriggerUnit()), StringHash("attacker"))
local unit target = LoadUnitHandle(udg_hash, GetHandleId(GetTriggerUnit()), StringHash("self"))
if (GetEventDamage() >= 1.0) then
if(GetEventDamageSource() == u) then
if(GetUnitAbilityLevel(target, 039;B003039;) >=1) then
return true
else
endif
else
endif
else
endif
return false
endfunction
function Trig_Attacked_Actions takes nothing returns nothing
local trigger t
local boolean bool = LoadBoolean(udg_hash, GetHandleId(GetAttacker()), StringHash("bool"))
if (not(bool)) then
call SaveUnitHandle(udg_hash, GetHandleId(GetTriggerUnit()), StringHash("attacker"), GetAttacker())
call SaveUnitHandle(udg_hash, GetHandleId(GetTriggerUnit()), StringHash("self"), GetTriggerUnit())
set t = CreateTrigger()
call TriggerRegisterUnitEvent(t, GetTriggerUnit(), EVENT_UNIT_DAMAGED)
call TriggerAddCondition(t, Condition(function damagecheck))
call TriggerAddAction(t, function ondamaged)
else
endif
endfunction
//===========================================================================
function InitTrig_Attacked takes nothing returns nothing
set gg_trg_Attacked = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Attacked, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddAction( gg_trg_Attacked, function Trig_Attacked_Actions )
endfunction