Warcraft III resources & community, 2003–2006 · archived

AddTimedLightning

not rated
Submitted by KaTTaNaExecution0 downloads
Creates a lighting bolt between two points. It will last for 'duration' seconds, then smoothly fade out over 'fadetime' seconds.
When the bolt has faded out it will be destroyed so there are no leaks.
NOTE: This code requires the Local Handle Vars.

Source

//************************************************************
//
// For more JASS scripts, visit us at http://www.wc3JASS.com
//
//============================================================

function AddTimedLightning_Fade takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local lightning li = GetHandleLightning(t, "lightning")
    local real time = GetHandleReal(t, "time")
    local real d = 0.1/time
    local real r = GetLightningColorR(li)
    local real g = GetLightningColorG(li)
    local real b = GetLightningColorB(li)
    local real a = GetLightningColorA(li)-d
    call SetLightningColor(li, r, g, b, a)
    if a <= 0 then
        call DestroyLightning(li)
        call FlushHandleLocals(t)
        call DestroyTimer(t)
    endif
endfunction

function AddTimedLightning_StartFade takes nothing returns nothing
    call TimerStart(GetExpiredTimer(), 0.1, true, function AddTimedLightning_Fade)
endfunction

function AddTimedLightning takes string Code, real x1, real y1, real x2, real y2, real duration, real fadetime returns lightning
    local timer t = CreateTimer()
    local lightning li = AddLightning(Code, true, x1, y1, x2, y2)
    call SetHandleHandle(t, "lightning", li)
    call SetHandleReal(t, "time", fadetime)
    call TimerStart(t, duration, false, function AddTimedLightning_StartFade)
    return li
endfunction


function AddTimedLightningEx takes string Code, real x1, real y1, real z1, real x2, real y2, real z2, real duration, real fadetime returns lightning
    local timer t = CreateTimer()
    local lightning li = AddLightningEx(Code, true, x1, y1, z1, x2, y2, z2)
    call SetHandleHandle(t, "lightning", li)
    call SetHandleReal(t, "time", fadetime)
    call TimerStart(t, duration, false, function AddTimedLightning_StartFade)
    return li
endfunction

Comments

6
Nice!!! :) :) :)
Thanks Blade, but what else can you expect when it's made by a guy from Denmark?
(Yeah, I'm from Denmark as well)

Skål i skuret Blade, pas godt på dig selv.
JA... Hvad ellers kan man forvente? Godt spørgsmål!... :D

Og skål og i lige måde herfra... :D
Thanks Blade, but what else can you expect when it's made by a guy from Denmark? :D
(Yeah, I'm from Denmark as well)

Skål i skuret Blade, pas godt på dig selv. :D
5/5... VERY GOOD... And forget my first comment... I don't know what I've been doing there, since I said such stupid things... It could be done without handles, but not this good...
Sounds awsome and useful... I'll try it at once...

~Daelin
Looks very good... I'll test it soon... :D

But I guess you could have done it without using the handle vars... :D

Anyways look good...