wraithseeker
Tired.
- Reaction score
- 122
JASS:
library TargetTimedEffects requires TimerUtils
private struct data
effect EFFECT
timer t
static method create takes nothing returns data
local data d = data.allocate()
set d.t = NewTimer()
return d
endmethod
method onDestroy takes nothing returns nothing
call DestroyEffect(this.EFFECT)
call ReleaseTimer(.t)
set .EFFECT = null
set .t = null
endmethod
endstruct
private function DestroyEffects takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
call d.destroy()
endfunction
function StartTimedEffects takes string EFFECT,unit target, string Attachpoint,real TIME returns nothing
local data d = data.create()
call SetTimerData(d.t,d)
call TimerStart(d.t,TIME,false,function DestroyEffects)
set d.EFFECT = AddSpecialEffectTarget(EFFECT,target,Attachpoint)
endfunction
endlibrary
I know many people have done this before but I needed one for attaching a effect to a target and haven't found one so I decided to put it up here as a snippet.
Can you all tell me how to improve on it more? I null the struct members for safety, used Tyrand3_Max handle counter and saw handles going by like 800 up when I do a loop of 800 and found out that after nulling, 400 handles go down.