//************************************************************************************
//*
//*
//* TIMED EFFECT
//*
//* by: ALMIA
//*
//*
//************************************************************************************
//*
//* Creates timed effects
//*
//************************************************************************************
//*
//* Requires:
//*
//* Linked List Table = http://www.hiveworkshop.com/forums/spells-569/linked-list-table-v1-3-a-230076/
//*
//************************************************************************************
//*
//* CODE API
//*
//* function TimedEffectPeriodic takes nothing returns nothing
//*
//* - Periodic function of system
//*
//* function CreateTimedEffectOnUnit takes string mdl, unit target, string attach, real duration returns nothing
//*
//* - Creates timed effect on unit
//*
//* function CreateTimedEffectOnLoc takes string mdl, real x, real y, real duration returns nothing
//*
//* - Creates timed effect on location(via coords)
//*
//************************************************************************************
//*
//* Variables
//*
//* TS_List = integer
//* TS_Unit = unit array
//* TS_Timer = timer
//* TS_Effect = special effect array
//* TS_Duration = real array
//* TS_Count = integer
//*
//************************************************************************************
function TimedEffectPeriodic takes nothing returns nothing
local integer i = GetFirstIndexFromLinkedList(udg_TS_List)
loop
exitwhen 0 == i
if 0 < udg_TS_Duration[i] then
set udg_TS_Duration[i] = udg_TS_Duration[i] - 0.03125
else
call DestroyEffect(udg_TS_Effect[i])
call RecycleIndexFromLinkedList(udg_TS_List, i)
set udg_TS_Effect[i] = null
set udg_TS_Unit[i] = null
set udg_TS_Count = udg_TS_Count - 1
if 0 == udg_TS_Count then
call PauseTimer(udg_TS_Timer)
endif
endif
set i = GetNextIndexFromLinkedList(udg_TS_List, i)
endloop
endfunction
//************************************************************************************
function CreateTimedEffectOnUnit takes string mdl, unit target, string attach, real duration returns nothing
local integer i = GetNewIndexFromLinkedList(udg_TS_List)
set udg_TS_Effect[i] = AddSpecialEffectTarget(mdl, target, attach)
set udg_TS_Unit[i] = target
set udg_TS_Duration[i] = duration
set udg_TS_Count = udg_TS_Count + 1
if 1 == udg_TS_Count then
call TimerStart(udg_TS_Timer, 0.03125, true, function TimedEffectPeriodic)
endif
endfunction
//************************************************************************************
function CreateTimedEffectOnLoc takes string mdl, real x, real y, real duration returns nothing
local integer i = GetNewIndexFromLinkedList(udg_TS_List)
set udg_TS_Effect[i] = AddSpecialEffect(mdl, x, y)
set udg_TS_Duration[i] = duration
set udg_TS_Count = udg_TS_Count + 1
if 1 == udg_TS_Count then
call TimerStart(udg_TS_Timer, 0.03125, true, function TimedEffectPeriodic)
endif
endfunction
//************************************************************************************
function InitTrig_Timed_Effect takes nothing returns nothing
set udg_TS_List = CreateLinkedList()
endfunction