I did this to make an efficient code for removing effects over a period of time.
System Script:Code
library EffectOverTime
globals
private constant real Tick = 0.1
private timer Tim = CreateTimer()
private integer array Er
private integer Total = 0
endglobals
private struct Effect
effect StoredEffect
real Counter = 0
real CounterMax = 0
static method ExecuteEffect takes nothing returns nothing
local Effect dat
local integer i = 0
loop
exitwhen i >= Total
set dat = Er[i]
if dat.Counter >= dat.CounterMax then
set Total = Total - 1
set Er[i] = Er[Total]
set i = i - 1
call dat.destroy()
else
set dat.Counter = dat.Counter + Tick
endif
set i = i + 1
endloop
if Total == 0 then
call PauseTimer(Tim)
endif
endmethod
static method create takes effect StoringEffect, real Time returns Effect
local Effect dat = Effect.allocate()
set dat.StoredEffect = StoringEffect
set dat.CounterMax = Time - Tick
if Total == 0 then
call TimerStart(Tim, Tick, true, function Effect.ExecuteEffect)
endif
set Er[Total] = dat
set Total = Total + 1
return dat
endmethod
method onDestroy takes nothing returns nothing
call DestroyEffect(.StoredEffect)
set .StoredEffect = null
endmethod
endstruct
function DestroyEffectTimed takes effect StoringEffect, real Time returns nothing
call Effect.create(StoringEffect, Time)
endfunction
endlibrary
Ok if you find any bugs with it or ways of improvement, please reply.
Example map: DestroyEffectTimed.w3x