- Joined
- Nov 25, 2008
- Messages
- 1,309
This little two-function script creates a lightning effect from two points (given as x/y values) and fades it out over the next second. It uses a trigger and polledwait to fade. As far as I know all leaks are cleaned.
JASS:
function Bolt_Child takes nothing returns nothing
local lightning l=bj_lastCreatedLightning
local real a=1
loop
call PolledWait(0.25)
set alpha=a-0.25
exitwhen a<=0
call SetLightningColor(l,1,1,1,a)
endloop
call DestroyLightning(l)
set l=null
endfunction
function AddBolt takes string style,real x1,real y1,real x2,real y2 returns nothing
local lightning l=AddLightning(style,true,x1,y1,x2,y2)
local trigger t=CreateTrigger()
set bj_lastCreatedLightning=l
call TriggerAddAction(t,function Bolt_Child)
call TriggerExecute(t)
call DestroyTrigger(t)
//Call RemoveLightning(l) [This line accually causes WC3 to crash, or it did for me]
set t=null
set l=null
endfunction