[Trigger] Destroy Lightning crashes game after Load

deepstrasz

Map Reviewer
Level 57
Joined
Jun 4, 2009
Messages
16,308
Hello hivers!
The World Editor isn't too friendly when it comes to Lightning triggers. Every time I Save a game when some Lightning effects are in course/action and then Load and do an action that destroys them it results in instantly crashing the game. After Loading the game the lightning effects don't even appear anymore.

Now I've searched the forums but didn't find a suitable fix, at least not one for my understanding since I do not know programming at all and just use the help of the editor's sentence based triggers.

Here you have the triggers:
  • RT Frozen Statue Cr8
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Create --------
      • Unit - Create 1 Frozen Statue for Neutral Passive at (Center of RTFrozenStatue <gen>) facing 270.00 degrees
      • Set RTFrozenStatue = (Last created unit)
      • -------- Animation Freeze --------
      • Animation - Change RTFrozenStatue's animation speed to 0.00% of its original speed
      • -------- Transparency --------
      • Animation - Change RTFrozenStatue's vertex coloring to (100.00%, 100.00%, 100.00%) with 75.00% transparency
  • RTFZ Charge Timer
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RTPengSwitchON Equal to True
        • Then - Actions
          • -------- Statue Charge Timer --------
          • Countdown Timer - Start RTStatueTimer as a One-shot timer that will expire in 10.00 seconds
          • Set RTStatueTimer = (Last started timer)
          • Countdown Timer - Create a timer window for RTStatueTimer with title Statue Charge:
          • Set RTStatueTimerWindow = (Last created timer window)
          • -------- Lasers ON --------
          • Lightning - Create a Mana Flare lightning effect from source (Center of RTCrystal1 <gen>) to target (Center of RTFrozenStatue <gen>)
          • Set RTCrystalLaser1 = (Last created lightning effect)
          • Lightning - Create a Mana Flare lightning effect from source (Center of RTCrystal2 <gen>) to target (Center of RTFrozenStatue <gen>)
          • Set RTCrystalLaser2 = (Last created lightning effect)
          • -------- Lasers Sound Loop --------
          • Sound - Play MagicLariatLoop1 <gen> at 100.00% volume, located at (Center of RTCrystal1 <gen>) with Z offset 0.00
          • Set RTCrystalLaser1Sound = (Last played sound)
          • Sound - Play MagicLariatLoop1 <gen> at 100.00% volume, located at (Center of RTCrystal2 <gen>) with Z offset 0.00
          • Set RTCrystalLaser2Sound = (Last played sound)
          • -------- Run Charge Steps --------
          • Trigger - Run RTFZ Charge Steps <gen> (checking conditions)
        • Else - Actions
          • Do nothing
  • RTFZ Charge Steps
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RTPengSwitchON Equal to True
        • Then - Actions
          • Wait 1.00 seconds
        • Else - Actions
          • Do nothing
  • RTFZ Charge Timer Expires
    • Events
      • Time - RTStatueTimer expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RTPengSwitchON Equal to True
        • Then - Actions
          • -------- Timer OFF --------
          • Countdown Timer - Destroy RTStatueTimerWindow
          • -------- Lasers OFF --------
          • Lightning - Destroy RTCrystalLaser1
          • Lightning - Destroy RTCrystalLaser2
          • -------- Lasers Mute --------
          • Sound - Destroy RTCrystalLaser1Sound
          • Sound - Destroy RTCrystalLaser2Sound
        • Else - Actions
          • Do nothing
  • RTFZ Charge Timer Cancel
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RTPengSwitchON Equal to False
        • Then - Actions
          • -------- Timer OFF --------
          • Countdown Timer - Destroy RTStatueTimerWindow
          • -------- Lasers OFF --------
          • Lightning - Destroy RTCrystalLaser1
          • Lightning - Destroy RTCrystalLaser2
          • -------- Lasers Mute --------
          • Sound - Destroy RTCrystalLaser1Sound
          • Sound - Destroy RTCrystalLaser2Sound
        • Else - Actions
          • Do nothing
I had no idea until today that the Hive has a way of transforming text into an actual image of the triggers from the editor. I am impressed. My blessings to whomever did this program.
 
Last edited:
When does RTFZ Charge Timer Cancel run? Chances are that you are destroying the lightning twice. Destroying a lightning handle that has already been destroyed will crash the map.

Usually I'll work around this by assigning the variable to null after I destroy it, and check if it is not null before I destroy it (this way, you won't get crashes). I mean, it is not a good habit to have things being destroyed twice anyway (you might want to take a further look at your code), but at least it won't crash.

Wherever you have "Destroy lightning", use a structure like this:
  • Custom script: if udg_RTCrystalLaser1 != null then
  • Lightning - Destroy RTCrystalLaser1
  • Custom script: endif
  • Custom script: if udg_RTCrystalLaser2 != null then
  • Lightning - Destroy RTCrystalLaser2
  • Custom script: endif
  • Custom script: set udg_RTCrystalLaser1 = null
  • Custom script: set udg_RTCrystalLaser2 = null
The custom script may seem confusing. The only part you need to focus on is the variable names, which are essentially 1:1 with the GUI names except that it has udg_ before it. Keep in mind that spacing/capitalization matters, so be sure to copy it exactly as it is.

Here is the logic behind it:
The first time we destroy a lightning, the variable is not null (it points to those lightning objects you created). After we destroy it via the trigger, we assign the variables to null. This acts like a message--it represents that the object has already been destroyed.
 

deepstrasz

Map Reviewer
Level 57
Joined
Jun 4, 2009
Messages
16,308
When does RTFZ Charge Timer Cancel run?
Thank you for helping!
Yeah... hadn't realized not posting the whole thing. Sorry. Here you go:
  • RTPenguin Switch On Item
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Triggering unit) Equal to IllidanShrinked
              • (Item-type of (Item being manipulated)) Equal to Frozen Penguin
        • Then - Actions
          • Wait 0.10 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Item being manipulated) is in RTPenguinSwitch <gen>) Equal to True
            • Then - Actions
              • -------- Switch Pressed --------
              • Set RTPengSwitchON = True
              • Animation - Play RTPengSwitch's death animation
              • -------- Lowering Switch Sound --------
              • Sound - Play Switch <gen> at 100.00% volume, located at (Center of RTPenguinSwitch <gen>) with Z offset 0.00
              • -------- Statue Charge --------
              • Trigger - Run RTFZ Charge Timer <gen> (checking conditions)
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
  • RTPenguin Switch Off Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Triggering unit) Equal to IllidanShrinked
              • (Item-type of (Item being manipulated)) Equal to Frozen Penguin
              • RTPengSwitchON Equal to True
        • Then - Actions
          • Wait until (((Item being manipulated) is in RTPenguinSwitch <gen>) Equal to False), checking every 0.10 seconds
          • -------- Switch Unpressed Var --------
          • Set RTPengSwitchON = False
          • -------- Statue Discharge --------
          • Trigger - Run RTFZ Charge Timer Cancel <gen> (checking conditions)
          • -------- Switch Unpressed Animation --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (RTPenguinSwitch <gen> contains IllidanShrinked) Equal to False
            • Then - Actions
              • Animation - Play RTPengSwitch's stand animation
              • -------- Lowering Switch Sound --------
              • Sound - Play Switch <gen> at 100.00% volume, located at (Center of RTPenguinSwitch <gen>) with Z offset 0.00
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
  • RTPenguin Switch OnOff Illidan
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • -------- Illidan On Switch --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (RTPenguinSwitch <gen> contains IllidanShrinked) Equal to True
              • RTPengSwitchON Equal to False
        • Then - Actions
          • -------- Switch Pressed --------
          • Animation - Play RTPengSwitch's death animation
          • -------- Lowering Switch Sound --------
          • Sound - Play Switch <gen> at 100.00% volume, located at (Center of RTPenguinSwitch <gen>) with Z offset 0.00
        • Else - Actions
          • Do nothing
      • -------- Illidan Off Switch --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (RTPenguinSwitch <gen> contains IllidanShrinked) Equal to False
              • RTPengSwitchON Equal to False
        • Then - Actions
          • -------- Switch Up --------
          • Animation - Play RTPengSwitch's stand animation
        • Else - Actions
          • Do nothing
The interesting part is that it only happens after I Load the game and the lasers are in place. The game doesn't have an option to store them as other triggers so basically that's the game and editor's issue.

Well it's going to take me a while to figure the custom script out as I'm not familiar with it at all. I'll also try a way around that first, trying to use invisible units that cast either finger of death, chain lightning or drain mana/life.

Edit: using invisible units that cast Finger of Death seems to disable the crash issue but does not solve the disappearance of the spell's lightning effect after Load. I think I'll have to try darwin's solution by storing variables before Save and reactivating them after Load. This is going to be a real pain though since there are basically 6 lightning effects that will have to be stored as so many possibilities (while one is active and another is not and so on...).
I'm going to report my progress.

Edit 2.0: i can't get the spell to loop. The only way to keep the lightning on is to increase the graphic effect duration to a maximum of 300 seconds which does not disappear using the Remove Buff trigger. Still the lightning disappears after Load. Aerial Shackles worked better in the looping field but it cancelled the target's Aerial Shackles for a further lightning effect.

Edit 2.5: well looping works by using a Run Trigger cycle. If I can get this to work without using Custom Script then at least, the World Editor would be good at something.

Edit 3.0: Alrighty! Hopefully this is it. Now even after Load the lightning effects are bound to appear because the trigger cycles force the units to constantly cast Finger of Death unless some variables become False.

Here it is, in case anyone will need/want to do this without Custom Script:
  • Rune Pattern Done and Laser Start
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RTLaserPattern Equal to 17
        • Then - Actions
          • -------- Creation of Laser Shooting Units --------
          • Unit - Create 1 Lightning (Red) for Neutral Hostile at (Center of RTMagneticPole1 <gen>) facing Default building facing degrees
          • Set RTRedLaserCaster1 = (Last created unit)
          • Unit - Create 1 Lightning (Red) for Neutral Hostile at (Center of RTMagneticPole2 <gen>) facing Default building facing degrees
          • Set RTRedLaserCaster2 = (Last created unit)
          • Unit - Create 1 Lightning (Red) for Neutral Hostile at (Center of RTMagneticPole3 <gen>) facing Default building facing degrees
          • Set RTRedLaserCaster3 = (Last created unit)
          • Unit - Create 1 Lightning (Red) for Neutral Hostile at (Center of RTMagneticPole4 <gen>) facing Default building facing degrees
          • Set RTRedLaserCaster4 = (Last created unit)
          • Unit - Create 1 Lightning (Red) for Neutral Hostile at (Center of RTGenToPole2a <gen>) facing Default building facing degrees
          • Set RTRedLaserCasterGen2a = (Last created unit)
          • Unit - Create 1 Lightning (Red) for Neutral Hostile at (Center of RTGenToPole3a <gen>) facing Default building facing degrees
          • Set RTRedLaserCasterGen3a = (Last created unit)
          • -------- Generator & Poles Lasers Cr8 --------
          • -------- Gnerator to Pole 2 Danger --------
          • Set RTLightningGeneratorToPole2 = True
          • Trigger - Run Laser Gen to Pole 2 Cycle <gen> (checking conditions)
          • -------- Gnerator to Pole 3 Danger --------
          • Set RTLightningGeneratorToPole3 = True
          • Trigger - Run Laser Gen to Pole 3 Cycle <gen> (checking conditions)
          • -------- Pole 2 to Pole 3 Danger --------
          • Set RTLightningPole2ToPole3 = True
          • Trigger - Run Laser Pole 2 to Pole 3 Cycle <gen> (checking conditions)
          • -------- Pole 1 to Pole 2 Danger --------
          • Set RTLightningPole1ToPole2 = True
          • Trigger - Run Laser Pole 1 to Pole 2 Cycle <gen> (checking conditions)
          • -------- Pole 3 to Pole 4 Danger --------
          • Set RTLightningPole3ToPole4 = True
          • Trigger - Run Laser Pole 3 to Pole 4 Cycle <gen> (checking conditions)
          • -------- Pole 4 to Pole 1 Danger --------
          • Set RTLightningPole4ToPole1 = True
          • Trigger - Run Laser Pole 4 to Pole 1 Cycle <gen> (checking conditions)
        • Else - Actions
          • Do nothing
  • Laser Gen to Pole 2 Cycle
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RTLightningGeneratorToPole2 Equal to True
        • Then - Actions
          • Unit - Order RTRedLaserCasterGen2a to Special Archimonde - Finger Of Death RTRedLaserCaster2
          • Wait 0.10 seconds
          • Trigger - Run Laser Gen to Pole 2 Cycle <gen> (checking conditions)
        • Else - Actions
          • Do nothing
You get the idea. The rest are basically copy paste of this one.
If you have something to add please do write, especially if you think these triggers are flawed. Thanks.

Sorry if I made anyone waste time. I'll come back to you if anything bad happens :D

Edit 3.5: This seems to be working for me so I guess this thread was solved.
 
Last edited:
Top