set i=1
loop
exitwhen i>5
call DestroyLightning(LoadLightningHandle(HT,k,i+84) )
set i=i+1
endloop
set i=1
loop
exitwhen i>5
call DestroyLightning(LoadLightningHandle(HT,k,i+89) )
set i=i+1
endloop
call DestroyTimer(t)
call DestroyTimer(s)
call DestroyTimer(c)
call FlushChildHashtable(HT,k)
call FlushChildHashtable(HT,GetHandleId(s))
set c=null
set t=null
set s=null
endfunction
function StormCast takes nothing returns nothing
local unit u=GetTriggerUnit()
local real x=GetSpellTargetX()
local real y=GetSpellTargetY()
local real z=LightningHeight
local timer t=CreateTimer()
local integer k=GetHandleId(t)
local timer m=CreateTimer()
local integer p=GetHandleId(m)
local timer s=CreateTimer()
local timer b=CreateTimer()
local timer e=CreateTimer()
local integer i=1
local lightning array l
local real a=0
call TimerStart(t,0.25,true,function ObjectDamage)
call SaveUnitHandle(HT,k,1,u)
call SaveReal(HT,k,2,x)
call SaveReal(HT,k,3,y)
call SaveReal(HT,k,4,z)
call TimerStart(m,0.05,true,function PolePull)
call SaveUnitHandle(HT,p,1,u)
call SaveReal(HT,p,2,x)
call SaveReal(HT,p,3,y)
call TimerStart(s,10,false,function StormEnd)
call SaveTimerHandle(HT,GetHandleId(s),1,t)
call TimerStart(b,9,false,function CastRebound)
call SaveTimerHandle(HT,GetHandleId(b),1,m)
call SaveReal(HT,GetHandleId(b),2,x)
call SaveReal(HT,GetHandleId(b),3,y)
call SaveUnitHandle(HT,GetHandleId(b),4,u)
call TimerStart(e,1,true,function LightningMovement)