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

Chain Lightning that won't cause game crush

Status
Not open for further replies.
I try to create an ability that throw a lightning effect at 2 enemies, but each time I cast the spell the game crushes, I don't know if I should have posted it in Request or in Help Zone, what I need is to know how to create lightning effect from a unit into 2 other units, dealing damage like Forked Lightning but chaos type instead of spells, without causing a game crush.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Almia said:
Could you post it? +rep if you do
He knows you meant "crash" and not "crush" (you always say "crush" when you actually mean "crash").

Also, you're not being specific. We can guess, but it might not be what you want. Next time, be more specific!
He did create an easy system to create a timed lightning bolt between 2 locations though (don't you even try to mention "huge system/lag").
It's the GUI-version of Maker's system.

That's basically all your need for what you want to do.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Do games have love life?
No but by the sounds of things they are very prone to being crushed by something or other. Probably by a newer game I am guessing.

Hehe, you say that but I have no idea what not 100% improved in it.
There is some procedural coupling in it. A large part of Chaos L trigger is same actions duplicated twice. One could argue that in the case of JASS this is "loop unwinding/in-lining" and thus an optimization but as far as good programming practice goes this is very bad.

The reason for this is two parts of the trigger are meant to behave identically (same procedure) but are not coupled to do so. To alter the procedure would require the change being recreated twice for each instance of the procedure which in turn increases the chance of an error being made (where the change is not replicated exactly). In real programming it also may produce considerably larger code but this is not a concern in JASS. For these reasons professional programmers try and avoid situations of procedural coupling using object orientated programming techniques or even simple functions.

There are a ton of optimizations that could be done recreating the triggers in JASS but those can largely be ignored unless performance of your map is a problem. One optimization you may be able to do in GUI is to store function return results in temporary global variables (variables who are not used for persistent storage and which you interact atomically with). Access to a global variable with a short name is generally faster than function and native calls.
 
No but by the sounds of things they are very prone to being crushed by something or other. Probably by a newer game I am guessing.


There is some procedural coupling in it. A large part of Chaos L trigger is same actions duplicated twice. One could argue that in the case of JASS this is "loop unwinding/in-lining" and thus an optimization but as far as good programming practice goes this is very bad.

The reason for this is two parts of the trigger are meant to behave identically (same procedure) but are not coupled to do so. To alter the procedure would require the change being recreated twice for each instance of the procedure which in turn increases the chance of an error being made (where the change is not replicated exactly). In real programming it also may produce considerably larger code but this is not a concern in JASS. For these reasons professional programmers try and avoid situations of procedural coupling using object orientated programming techniques or even simple functions.

There are a ton of optimizations that could be done recreating the triggers in JASS but those can largely be ignored unless performance of your map is a problem. One optimization you may be able to do in GUI is to store function return results in temporary global variables (variables who are not used for persistent storage and which you interact atomically with). Access to a global variable with a short name is generally faster than function and native calls.
Yea.
Well, I'm not really sure what keeps on crAshing my game, but it seems that the lightning indeed causes crAsh.
At the moment, I store booleAn (with A) that set if there was another unit and by that, a need to make extra lightning, to avoid lightning that hit middle of map. The extra check is helping but the game still crAAAsh on me, dunno why.
  • Chaos Ligtning
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chaos Lightning (Q)
    • Actions
      • Set real = 0.00
      • Set real = (Load 2 of (Key (Triggering unit)) from Hash_Lightning)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • real Not equal to 0.00
        • Then - Actions
          • Set lightning = (Load 1 of (Key (Triggering unit)) in Hash_Lightning)
          • Lightning - Destroy lightning
          • Set lightning = (Load 5 of (Key (Triggering unit)) in Hash_Lightning)
          • Lightning - Destroy lightning
          • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in Hash_Lightning
        • Else - Actions
      • Set real = (Real((50 + ((Level of (Ability being cast) for (Triggering unit)) x 50))))
      • Set p = (Position of (Triggering unit))
      • Set p2 = (Position of (Target unit of ability being cast))
      • Lightning - Create a Chain Lightning - Secondary lightning effect from source p to target p2
      • Hashtable - Save Handle Of(Last created lightning effect) as 1 of (Key (Triggering unit)) in Hash_Lightning
      • Hashtable - Save Handle Of(Target unit of ability being cast) as 4 of (Key (Triggering unit)) in Hash_Lightning
      • Hashtable - Save True as 3 of (Key (Triggering unit)) in Hash_Lightning
      • Set unit = No unit
      • Set ug = (Units within 500.00 of p2 matching ((((((Matching unit) is alive) Equal to True) and ((Level of Uneffected (spell immunity) for (Matching unit)) Equal to 0)) and ((Matching unit) Not equal to (Target unit of ability being cast))) and ((((Matching unit) belo
      • Set unit = (Random unit from ug)
      • Custom script: call DestroyGroup(udg_ug)
      • Custom script: call RemoveLocation(udg_p)
      • Custom script: call RemoveLocation(udg_p2)
      • Unit - Cause UndetectableDummy[(Player number of (Owner of (Triggering unit)))] to damage (Target unit of ability being cast), dealing real damage of attack type Chaos and damage type Normal
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • unit Not equal to No unit
        • Then - Actions
          • Set real = (Real((50 + ((Level of (Ability being cast) for (Triggering unit)) x 50))))
          • Set p = (Position of (Triggering unit))
          • Set p2 = (Position of unit)
          • Lightning - Create a Chain Lightning - Secondary lightning effect from source p to target p2
          • Hashtable - Save Handle Of(Last created lightning effect) as 5 of (Key (Triggering unit)) in Hash_Lightning
          • Hashtable - Save Handle Ofunit as 6 of (Key (Triggering unit)) in Hash_Lightning
          • Hashtable - Save True as 7 of (Key (Triggering unit)) in Hash_Lightning
          • Custom script: call RemoveLocation(udg_p)
          • Custom script: call RemoveLocation(udg_p2)
          • Unit - Cause UndetectableDummy[(Player number of (Owner of (Triggering unit)))] to damage unit, dealing real damage of attack type Chaos and damage type Normal
        • Else - Actions
          • Hashtable - Save False as 7 of (Key (Triggering unit)) in Hash_Lightning
      • Hashtable - Save 2.00 as 2 of (Key (Triggering unit)) in Hash_Lightning
      • Unit Group - Add (Triggering unit) to ChaoLightningGroup
      • Trigger - Turn on Chaos L <gen>
  • Chaos L
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ChaoLightningGroup and do (Actions)
        • Loop - Actions
          • Set real = (Load 2 of (Key (Picked unit)) from Hash_Lightning)
          • Set Boolean = (Load 3 of (Key (Picked unit)) from Hash_Lightning)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Boolean Not equal to False
            • Then - Actions
              • Set unit = (Load 4 of (Key (Picked unit)) in Hash_Lightning)
              • Set lightning = (Load 1 of (Key (Picked unit)) in Hash_Lightning)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • unit Equal to No unit
                      • ((Picked unit) is dead) Equal to True
                      • real Less than or equal to 0.00
                • Then - Actions
                  • Lightning - Destroy lightning
                  • Hashtable - Save False as 3 of (Key (Picked unit)) in Hash_Lightning
                • Else - Actions
                  • Set p = (Position of (Picked unit))
                  • Set p2 = (Position of unit)
                  • Lightning - Move lightning to source p and target p2
                  • Lightning - Change color of lightning to ((Random real number between 0.00 and 1.00) (Random real number between 0.00 and 1.00) (Random real number between 0.00 and 1.00)) with 1.00 alpha
                  • Custom script: call RemoveLocation(udg_p)
                  • Custom script: call RemoveLocation(udg_p2)
            • Else - Actions
          • Set Boolean_2 = (Load 7 of (Key (Picked unit)) from Hash_Lightning)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Boolean_2 Not equal to False
            • Then - Actions
              • Set unit = (Load 6 of (Key (Picked unit)) in Hash_Lightning)
              • Set lightning = (Load 5 of (Key (Picked unit)) in Hash_Lightning)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • unit Equal to No unit
                      • real Less than or equal to 0.00
                      • ((Picked unit) is dead) Equal to True
                • Then - Actions
                  • Lightning - Destroy lightning
                  • Hashtable - Save False as 7 of (Key (Picked unit)) in Hash_Lightning
                • Else - Actions
                  • Set p = (Position of (Picked unit))
                  • Set p2 = (Position of unit)
                  • Lightning - Move lightning to source p and target p2
                  • Lightning - Change color of lightning to ((Random real number between 0.00 and 1.00) (Random real number between 0.00 and 1.00) (Random real number between 0.00 and 1.00)) with 1.00 alpha
                  • Custom script: call RemoveLocation(udg_p)
                  • Custom script: call RemoveLocation(udg_p2)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • real Less than or equal to 0.00
                      • And - All (Conditions) are true
                        • Conditions
                          • Boolean Equal to False
                          • Boolean_2 Equal to False
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from ChaoLightningGroup
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Hash_Lightning
                • Else - Actions
            • Else - Actions
          • Set real = (real - 0.10)
          • Hashtable - Save real as 2 of (Key (Picked unit)) in Hash_Lightning
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (ChaoLightningGroup is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
the game still crAAAsh on me, dunno why.
Start by limiting the causes. Does it crash on cast or on loop? Does it crash if all lightning parts are disabled? Maybe the crash is caused by hashtable interactions of incorrect/null type (although those should have been fixed, I remember how easy it was to crash the game using them when they were being beta-tested).
 
Status
Not open for further replies.
Top