Warcraft III resources & community, 2003–2006 · archived

AddAttachedLightningEx

not rated
Submitted by Nantuko_HuskFunctions0 downloads
Adds a lightning attached to the 2 units given as parameters.

The difference with the other functions of it's type is that this one,returns the lighning.
You treat it as a normal lightning,change colors etc , move it ( no sense , it is attached ),with the difference that you MUST destroy it with the function I made for it.
Else it will crash the game.

Source

function DestroyAttachedLightning takes lightning bolt returns nothing
    local timer t = GetHandleTimer ( bolt , "timer" )

    call FlushHandleLocals ( t )
    call PauseTimer ( t )
    call DestroyTimer ( t )
    call FlushHandleLocals ( bolt )
    call DestroyLightning ( bolt )

    set t = null

endfunction


function AddAttachedLightningEx_Child takes nothing returns nothing
    local timer t = GetExpiredTimer ( )
    local unit from = GetHandleUnit ( t , "from" )
    local unit to = GetHandleUnit ( t , "to" )

    call MoveLightning ( GetHandleLightning ( t , "li" ) , GetHandleBoolean ( t , "chkvis" ) , GetUnitX ( from ) ,GetUnitY ( from ) , GetUnitX ( to ) , GetUnitY ( to ) )

    set t = null
    set from = null
    set to = null
endfunction

function AddAttachedLightningEx takes string codename , boolean chkvis , unit from , real z1 , unit to , real z2 returns lightning
    local lightning li = AddLightningEx ( codename , chkvis , GetUnitX ( from ) , GetUnitY ( from ) , z1 , GetUnitX ( to ) , GetUnitY ( to ) , z2 )
    local timer t = CreateTimer ( )
    local integer i

    call SetHandleHandle ( t , "li" , li )
    call SetHandleHandle ( t , "from" , from )
    call SetHandleHandle ( t , "to" , to )
    call SetHandleHandle ( li , "timer" , t )
    call TimerStart ( t , 0.05 , true , function AddAttachedLightningEx_Child )

    set i = H2I ( li )
    set t = null
    set li = null

    return i
    return null
endfunction

Comments

2
Hmm,you should mention that this function uses the Handle Sys.
Did you know that I love someone here...