oreo is right
because both have a wait inside of them before any of the effects are destroyed, its very possible that the trigger will run again
think of last created floating text or last created lightning effect as a variable made by the game (just like the variables you make, except you can't directly touch this one) that is set whenever you make the matching handle type (handles are pretty much anything that isn't number related - special effects, floating text, units etc). most handles have a "last created" variable like this, but none of these are arrays - ie...
there can only be one "last created"
an important part of triggers is making them MUI, which means Multi User Instanceable. i'm sure you've run into the problem where you can make something that works really well for one person, but as soon as you bring another person into the mix trying to use the same effect - it all falls apart.
you have a few ways to fix the leak
the easiest is turning it off and on like oreo said, although this doesn't really fix the effect to work perfectly (as is won't run in close succession), it will fix the leaks.
if you wanted the leaks gone and the effect to still display every time you'd have to store the handles in an array, but this leads to the problem of when to periodically clear the array. you could maybe clear the handles that belong to the single trigger from the array, but i can't think of any easy (or really even any hard) ways to do that.
i'd probably attach the effects to a timer and then just have the timer destroy them after.
i think you'd need JASS to do it, and the way i think i'd do it would use vJASS
something like
have a struct for each effect type with enough variables to store all the effects created
then have a method to destroy/clear all those variables
then have the create method of the struct define those variables and start a one shot timer which is attached to the above method
then destroy/release the timer
ie
- Code:
-
struct UnitAttacked
private effect e1
private effect e2
private lightning l1
private timer t = CreateTimer()
private method DestroyEffects takes nothing returns nothing
call DestroyEffect(e1)
call DestroyEffect(e2)
call DestroyLightning(l1)
call DestroyTimer(t)
set e1 = null
set e2 = null
set l1 = null
set t = null
endmethod
public method create takes effect ue1, effect ue2, lightning ul1, real waittime returns UnitAttacked
local UnitAttacked UA = UnitAttacked.allocate()
call TimerStart(UA.t, waittime, false, function DestroyEffects)
//altho it might be:
//call TimerStart(UA.t, waittime, false, function UA.DestroyEffects)
return UA
endmethod
endstruct
also for the first screen shot you posted, the first special effect (not lightning) will never get destroyed. its place as last created effect is being overwritten by the next one you make in the same trigger. you could get around this by making a temp variable that holds it, but this'll have the same problems as you already have with the last created and the wait timer.