- Joined
- May 24, 2016
- Messages
- 339
I want to know your opinion - are these functions okay? I only use AddEffectTimeToUnit when want to make effect when it cant be instant destroyed.
Code:
function DestroyEffectTimeToUnit takes nothing returns nothing
local integer id = GetHandleId(GetExpiredTimer())
local real time = LoadReal(Hash,id,2)
if time <= 0. or GetWidgetLife(LoadUnitHandle(Hash,id,3)) <= 0. then
call DestroyEffect(LoadEffectHandle(Hash,id,1))
call DestroyTimer(GetExpiredTimer())
call FlushChildHashtable(Hash,id)
endif
call SaveReal(Hash,id,2,time - .2)
endfunction
function AddEffectTimeToUnit takes string eff,unit u,string attach,real time returns nothing
local timer t = CreateTimer()
call SaveEffectHandle(Hash,GetHandleId(t),1,AddSpecialEffectTarget(eff,u,attach))
call SaveReal(Hash,GetHandleId(t),2,time)
call SaveUnitHandle(Hash,GetHandleId(t),3,u)
call TimerStart(t,.2,true, function DestroyEffectTimeToUnit)
set t = null
endfunction
function DestroyEffectTimeToPoint takes nothing returns nothing
call DestroyEffect(LoadEffectHandle(Hash,GetHandleId(GetExpiredTimer()),1))
call DestroyTimer(GetExpiredTimer())
call FlushChildHashtable(Hash,GetHandleId(GetExpiredTimer()))
endfunction
function AddEffectTimeToPoint takes string eff, real x, real y,real time returns nothing
local timer t = CreateTimer()
call SaveEffectHandle(Hash,GetHandleId(t),1,AddSpecialEffect(eff,x,y))
call TimerStart(t,time,false, function DestroyEffectTimeToPoint)
set t = null
endfunction