When a unit casts a spell (based on shadow dagger with 0 init. damage) i use this function to spawn a dummy and give it an order:
This leaves a leak. I use this trigger to detect leaks:
So, how can i remove a leak left on a spell cast?
JASS:
local unit u
local integer l
local location loc
set loc = GetUnitLoc(GetSpellTargetUnit())
set l = GetUnitAbilityLevel(GetSpellAbilityUnit(),'A026')
call UnitDamageTarget(GetSpellAbilityUnit(),GetSpellTargetUnit(),50+(25*(l-1)),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_METAL_LIGHT_SLICE)
set u = CreateUnitAtLoc(GetOwningPlayer(GetSpellAbilityUnit()),'h002',loc,0)//dummy
call UnitAddAbility(u,'A028')//frost nova
call SetUnitAbilityLevel(u,'A028',l)
call IssueTargetOrder(u,"frostnova",GetSpellTargetUnit())
call TriggerSleepAction(0.5)
call UnitRemoveAbility(u,'A028')
call RemoveUnit (u)
call RemoveLocation(loc)
set u = null
set loc = null
JASS:
function Trig_check_Actions takes nothing returns nothing
local timer Timer = CreateTimer()
local string S
local integer i = 0
if udg_i_test < GetHandleId(Timer) then // != <
set S = ("|cffaaaaaa [Test] H: " + I2S(GetHandleId(Timer) - 1048500) + "|r")
call DisplayTextToPlayer(Player(0), 0, 0, S)
set S = null
set udg_i_test = GetHandleId(Timer)
endif
call DestroyTimer(Timer)
set Timer = null
endfunction
function InitTrig_check takes nothing returns nothing
set gg_trg_check = CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_check, 0.1, true)
call TriggerAddAction(gg_trg_check, function Trig_check_Actions)
endfunction