• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] LightningEX Destroy Help

Status
Not open for further replies.
Level 14
Joined
Nov 18, 2007
Messages
1,084
JASS:
function Trig_Thunder_Test_Actions takes nothing returns nothing
    local lightning thunder1
    local lightning thunder2
    local real x
    local real y
    set x = GetUnitX(udg_Test)
    set y = GetUnitX(udg_Test)
    call AddLightningEx( "CLPB", true, x, y, 2000.00, x, y, 0.00 )
    set thunder1 = GetLastCreatedLightningBJ()
    call AddLightningEx( "CLSB", true, x, y, 2000.00, x, y, 0.00 )
    set thunder2 = GetLastCreatedLightningBJ()
    call AddSpecialEffectTargetUnitBJ( "origin", udg_Test, "Abilities\\Weapons\\Bolt\\BoltImpact.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call PolledWait( 1.00 )
    call DestroyLightningBJ(thunder1)
    call DestroyLightningBJ(thunder2)
endfunction

//===========================================================================
function InitTrig_Thunder_Test takes nothing returns nothing
    set gg_trg_Thunder_Test = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Thunder_Test, Player(0), "-thunder", true )
    call TriggerAddAction( gg_trg_Thunder_Test, function Trig_Thunder_Test_Actions )
endfunction

Okay, something's wrong with this, and I'm not sure what it is since I'm new to Jass. The lightning never gets destroyed, but it does get created. Does anyone what's wrong?
 
Level 11
Joined
Aug 25, 2006
Messages
971
JASS:
function DestroyLightningBJ takes lightning whichBolt returns boolean
    return DestroyLightning(whichBolt)
endfunction
Kill the middle man. Remove the BJ infront of the DestroyLightning function.


The problem is that GetLastCreatedUnitBJ()/GetLastCreatedEffectBJ()/GetLastCreatedLightningBJ() doesn't work so will [in jass] so do this:
JASS:
function Trig_Thunder_Test_Actions takes nothing returns nothing
    local lightning thunder1
    local lightning thunder2
    local real x
    local real y
    set x = GetUnitX(udg_Test)
    set y = GetUnitY(udg_Test) //Fixed a bug that had both of these say GetUnitX
    set thunder1 = AddLightningEx( "CLPB", true, x, y, 2000.00, x, y, 0.00 ) //Killed another middle man(bj)
    set thunder2 = AddLightningEx( "CLSB", true, x, y, 2000.00, x, y, 0.00 )
    call DestroyEffect( AddSpecialEffectTarget( "origin", udg_Test, "Abilities\\Weapons\\Bolt\\BoltImpact.mdl" ) ) //Killed several more middle men
    call PolledWait( 1.00 )
    call DestroyLightning(thunder1)
    call DestroyLightning(thunder2)
    set thunder1 = null
    set thunder2 = null //Just a small leak fix
endfunction

//===========================================================================
function InitTrig_Thunder_Test takes nothing returns nothing
    set gg_trg_Thunder_Test = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Thunder_Test, Player(0), "-thunder", true )
    call TriggerAddAction( gg_trg_Thunder_Test, function Trig_Thunder_Test_Actions )
endfunction
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
You could just do
Code:
   local real x = GetUnitX(udg_Test)
   local real y = GetUnitY(udg_Test)
(and yet again the JASS tags are making me nuts ! ARGGGGG)


I also read in one of the tut's you gave me that its better (didn't explain why) to declare the value of variables like that and not declare the variables and later on the value.
 
Level 11
Joined
Aug 25, 2006
Messages
971
True it saves a few (or less) miliseconds to do it that way.
JASS:
function Trig_Thunder_Test_Actions takes nothing returns nothing
    local real x = GetUnitX(udg_Test) //Fixed a bug that had both of these say GetUnitX
    local real y = GetUnitY(udg_Test) //Some more very small optimization  
    local lightning thunder1 = AddLightningEx( "CLPB", true, x, y, 2000.00, x, y, 0.00 ) //Killed another middle man(bj)
    local lightning thunder2 = AddLightningEx( "CLSB", true, x, y, 2000.00, x, y, 0.00 )
    call DestroyEffect( AddSpecialEffectTarget( "origin", udg_Test, "Abilities\\Weapons\\Bolt\\BoltImpact.mdl" ) ) //Killed several more middle men
    call PolledWait( 1.00 )
    call DestroyLightning(thunder1)
    call DestroyLightning(thunder2)
    set thunder1 = null
    set thunder2 = null //Just a small leak fix
endfunction

//===========================================================================
function InitTrig_Thunder_Test takes nothing returns nothing
    set gg_trg_Thunder_Test = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Thunder_Test, Player(0), "-thunder", true )
    call TriggerAddAction( gg_trg_Thunder_Test, function Trig_Thunder_Test_Actions )
endfunction
 
Status
Not open for further replies.
Top