// How to install?
//----------------------------------
// Copy the code in the map header
// Copy the variable "TimedSFXHash"
// If you do not want to copy,simply create a new variable with this name "TimedSFXHash"
// Variable Type is: "hashtable"
// That's it.
// Very simply.
//----------------------------------
// How to use this system?
//----------------------------------
// For example:
//----------------------------------
// If you want to use a static or non-static effect at points X,Y
// For example, suppose that x = GetSpellTargetX() and y = GetSpellTargetY()
// or that x = GetUnitX(your unit) and y = GetUnitY(your unit)
// In this case we should call this function
// "AddStaticTimedSFX" or "AddNonStaticTimedSFX"
// call AddStaticTimedSFX(modelPath,yourunit,timeinterval,durationofeffect,x,y)
// call AddNonStaticTimedSFX(modelPath,yourunit,timeinterval,durationofeffect,x,y)
// Explanation:
// (modelPath)
// "Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorTarget.mdl"
// (yourunit)
// GetTriggerUnit(),GetFilterUnit(),GetEnumUnit(),GetAttacker()...and so on
// (timeinterval)
// 0.03,0.04,0.05...bla,bla...and so on
// (durationofeffect)
// 1.00,2.00,3.00 or 1.5+(1.5*level)...and so on
// (x)
// GetSpellTargetX() or GetUnitX(yourunit)
// (y)
// GetSpellTargetY() or GetUnitY(yourunit)
// A few simple examples:
// local
// call AddStaticTimedSFX(modelPath,yourunit,timeinterval,durationofeffect,GetSpellTargetX(),GetSpellTargetY())
// global
// call AddStaticTimedSFX(udg_modelPath,udg_yourunit,udg_timeinterval,udg_durationofeffect,GetSpellTargetX(),GetSpellTargetY())
// func
// call AddStaticTimedSFX(modelPath(),yourunit(),timeinterval(),durationofeffect(),GetSpellTargetX(),GetSpellTargetY())
// directly
// call AddStaticTimedSFX("Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorTarget.mdl",GetTriggerUnit(),0.03125,3.00,GetSpellTargetX(),GetSpellTargetY())
// As for other functions,all based on the same principle
// call AddStaticTimedSFXTarget(yourmodelPath,yourunit,yourattachpoint,youttimerint,yourdurationofeffect)
// call AddNonStaticTimedSFXTarget(yourmodelPath,yourunit,yourattachpoint,youttimerint,yourdurationofeffect)
// call AddStaticTimedSFXLoc(yourmodelPath,yourunit,timeinterval,durationofeffect,yourlocation)
// call AddNonStaticTimedSFXLoc(yourmodelPath,yourunit,timeinterval,durationofeffect,yourlocation)
//--------------------------------------------------------
// Static Non-Static Special Effect Timed System
//--------------------------------------------------------
function TimedSFXSystemTimer takes nothing returns nothing
local timer t=GetExpiredTimer()
local integer id=GetHandleId(t)
local boolean nonstatic=LoadBoolean(udg_TimedSFXHash,id,0)
local boolean whichEffect=LoadBoolean(udg_TimedSFXHash,id,1)
local string modelPath=LoadStr(udg_TimedSFXHash,id,2)
local real x=LoadReal(udg_TimedSFXHash,id,3)
local real y=LoadReal(udg_TimedSFXHash,id,4)
local unit u=LoadUnitHandle(udg_TimedSFXHash,id,5)
local string pointPath=LoadStr(udg_TimedSFXHash,id,6)
local real effectduration=LoadReal(udg_TimedSFXHash,id,7)
local effect sfx=LoadEffectHandle(udg_TimedSFXHash,id,8)
local real timesec=LoadReal(udg_TimedSFXHash,id,9)
if(effectduration<=0.00) or IsUnitType(u,UNIT_TYPE_DEAD) then
call DestroyEffect(sfx)
call FlushChildHashtable(udg_TimedSFXHash,id)
call PauseTimer(t)
call DestroyTimer(t)
else
call SaveReal(udg_TimedSFXHash,id,7,effectduration-timesec)
if nonstatic then
if whichEffect then
call DestroyEffect(AddSpecialEffect(modelPath,x,y))
else
call DestroyEffect(AddSpecialEffectTarget(modelPath,u,pointPath))
endif
endif
endif
set t=null
set u=null
set sfx=null
endfunction
function RegisterTimedSFXSystem takes string modelPath,unit u,string pointPath,real timesec,real dur,real x,real y,boolean nonststic,boolean whichEffect returns nothing
local timer t=CreateTimer()
local integer id=GetHandleId(t)
local effect sfx
if nonststic then
call SaveBoolean(udg_TimedSFXHash,id,0,nonststic)
if whichEffect then
call SaveBoolean(udg_TimedSFXHash,id,1,whichEffect)
endif
else
if whichEffect then
set sfx=AddSpecialEffect(modelPath,x,y)
call SaveAgentHandle(udg_TimedSFXHash,id,8,sfx)
set sfx=null
else
call SaveAgentHandle(udg_TimedSFXHash,id,8,AddSpecialEffectTarget(modelPath,u,pointPath))
endif
endif
call SaveStr(udg_TimedSFXHash,id,2,modelPath)
call SaveReal(udg_TimedSFXHash,id,3,x)
call SaveReal(udg_TimedSFXHash,id,4,y)
call SaveReal(udg_TimedSFXHash,id,7,dur)
call SaveAgentHandle(udg_TimedSFXHash,id,5,u)
call SaveStr(udg_TimedSFXHash,id,6,pointPath)
call SaveReal(udg_TimedSFXHash,id,9,timesec)
call TimerStart(t,timesec,true,function TimedSFXSystemTimer)
set t=null
endfunction
function AddStaticTimedSFX takes string s,unit u,real t,real r,real x,real y returns nothing
call RegisterTimedSFXSystem(s,u,null,t,r,x,y,false,true)
endfunction
function AddNonStaticTimedSFX takes string s,unit u,real t,real r,real x,real y returns nothing
call RegisterTimedSFXSystem(s,u,null,t,r,x,y,true,true)
endfunction
function AddStaticTimedSFXTarget takes string s,unit u,string s1,real t,real r returns nothing
call RegisterTimedSFXSystem(s,u,s1,t,r,0.00,0.00,false,false)
endfunction
function AddNonStaticTimedSFXTarget takes string s,unit u,string s1,real t,real r returns nothing
call RegisterTimedSFXSystem(s,u,s1,t,r,0.00,0.00,true,false)
endfunction
function AddStaticTimedSFXLoc takes string s,unit u,real t,real r,location l returns nothing
call RegisterTimedSFXSystem(s,u,null,t,r,GetLocationX(l),GetLocationY(l),false,true)
endfunction
function AddNonStaticTimedSFXLoc takes string s,unit u,real t,real r,location l returns nothing
call RegisterTimedSFXSystem(s,u,null,t,r,GetLocationX(l),GetLocationY(l),true,true)
endfunction