• 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.

[Trigger] Lightning == BAD (know a fix?)

Status
Not open for further replies.
Level 4
Joined
Jun 10, 2007
Messages
46
So when I was working on my awesome map, I was considering adding a lightning effect that arcs across the map, and anything that is hit by it takes massive damage.

I can handle the math easily,what my problem relies upon is that fact that lightning seems to cause the game to crash.

Does anybody know what to do to clean up lightning/ handle whatever memory leaks might be formed by such a trigger?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
I doubt not destroying one lightning would crash the game.
And destroying it would also remove it.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
1 memory leak, not 1 at a time, just 1 will not cause the game to crash.
Problem is somewhere else.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
If we are guessing, here is my guess(random):
Giving engineering upgrade based skills to units will crash the game.
My point:
Until he gives us info one guess is as good as another.
 
Level 4
Joined
Jun 10, 2007
Messages
46
I'll get some code up here in a second.

It's not occuring suddenly, what it's doing is that after the trigger has run, generating god knows how many lightning effects, the game crashes. I tried to catch all teh variables and destroy them, but it doesn't seem to fix the problem.
 
Level 4
Joined
Jun 10, 2007
Messages
46
Long Post

Alright, here's the code I'm using.

  • WARP FIELDS Lightning
    • Events
      • Time - Every 9.00 seconds of game time
    • Conditions
    • Actions
      • -------- The math I'm using is in another trigger and does not cause errors, I have checked. --------
      • Set Loc = (Random point in WARP FIELDS <gen>)
      • Set Loc2 = (Random point in WARP FIELDS <gen>)
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Loc to target Loc2
      • Set WARPLightning = (Last created lightning effect)
      • Wait 1.00 seconds
      • Custom script: call RemoveLocation(udg_Loc)
      • Set Loc = Loc2
      • Set Loc2 = (Random point in WARP FIELDS <gen>)
      • Lightning - Move WARPLightning to source Loc and target Loc2
      • Wait 1.00 seconds
      • Custom script: call RemoveLocation(udg_Loc)
      • Set Loc = Loc2
      • Set Loc2 = (Random point in WARP FIELDS <gen>)
      • Lightning - Move WARPLightning to source Loc and target Loc2
      • Wait 1.00 seconds
      • Custom script: call RemoveLocation(udg_Loc)
      • Set Loc = Loc2
      • Set Loc2 = (Random point in WARP FIELDS <gen>)
      • Lightning - Move WARPLightning to source Loc and target Loc2
      • Wait 1.00 seconds
      • Custom script: call RemoveLocation(udg_Loc)
      • Set Loc = Loc2
      • Set Loc2 = (Random point in WARP FIELDS <gen>)
      • Lightning - Move WARPLightning to source Loc and target Loc2
      • Wait 1.00 seconds
      • Custom script: call RemoveLocation(udg_Loc)
      • Set Loc = Loc2
      • Set Loc2 = (Random point in WARP FIELDS <gen>)
      • Lightning - Move WARPLightning to source Loc and target Loc2
      • Wait 1.00 seconds
      • Custom script: call RemoveLocation(udg_Loc)
      • Set Loc = Loc2
      • Set Loc2 = (Random point in WARP FIELDS <gen>)
      • Lightning - Move WARPLightning to source Loc and target Loc2
      • Wait 1.00 seconds
      • Custom script: call RemoveLocation(udg_Loc)
      • Set Loc = Loc2
      • Set Loc2 = (Random point in WARP FIELDS <gen>)
      • Lightning - Move WARPLightning to source Loc and target Loc2
      • Wait 1.00 seconds
      • Custom script: call RemoveLocation(udg_Loc)
      • Custom script: call RemoveLocation(udg_Loc2)
      • Lightning - Destroy WARPLightning
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
  • WARP FIELDS Lightning
    • Events
      • Time - Every 11.00 seconds of game time
    • Conditions
    • Actions
    • Set Loc = (Random point in WARP FIELDS <gen>)
    • Do Multiple ActionsFor each (Integer A) from 1 to 8, do (Actions)
      • Loop - Actions
        • Set Loc2 = (Random point in WARP FIELDS <gen>)
        • Lightning - Create a Chain Lightning - Primary lightning effect from source Loc to target Loc2
        • Set WARPLightning = (Last created lightning effect)
        • Custom script: call RemoveLocation(udg_Loc)
        • Set Loc = Loc2
        • Wait 1.00 seconds
        • Lightning - Destroy WARPLightning
      • Custom script: call RemoveLocation(udg_Loc)
It is more compact this way ;)
 
Last edited:
Level 4
Joined
Jun 10, 2007
Messages
46
You don't need to remove udg_Loc2 at the end.

Well, remember that memory leaks are caused by unused memory LOCATIONS, not just unused variables.

Kind of a definition difference. Basically, you DO have to delete the location before you reassign the variable, even if you're doing it in the same trigger.

Incidentally, I tried setting the periodic time higher, and the problem went away. I don't suppose anybody could diagnose this? I'm going to try a new system for the arcs, try to streamline it so it works properly, and is easier to read, I'll post my new code later when I'm done.
 
Level 4
Joined
Jun 10, 2007
Messages
46
New Code

Okay, my new code is alot more edit-friendly. It is separated into two triggers, but it is MUCH simpler.

  • WARP FIELDS Lightning Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set LightningLoc[0] = (Random point in WARP FIELDS <gen>)
      • Set LightningLoc[1] = (Random point in WARP FIELDS <gen>)
      • Lightning - Create a Mana Flare lightning effect from source LightningLoc[0] to target LightningLoc[1]
      • Set WARPLightning = (Last created lightning effect)
      • Custom script: call RemoveLocation(udg_LightningLoc[0])
  • WARP FIELDS Lightning
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set LightningLoc[0] = LightningLoc[1]
      • Set LightningLoc[1] = (Random point in WARP FIELDS <gen>)
      • Lightning - Move WARPLightning to source LightningLoc[0] and target LightningLoc[1]
      • Custom script: call RemoveLocation(udg_LightningLoc[0])
This thing didn't fail even after letting it run a long time, so I feel confident that it will work in the long run. So if anybody sees something wrong with it, I'd like to know.
 
Status
Not open for further replies.
Top