• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Destroying Lightning Effects Without Conflict

Status
Not open for further replies.
Level 8
Joined
Aug 15, 2010
Messages
216
Hello Brothers,
Today i wanted to state a big problem of my map making hobby , i wanted to add some spice to my map, and this happened, you see :
when a unit "Overloads" with an ability in my map, It turns On a lightning effect trigger and sets vals as casting unit and target,
like this :
every 0.05 seconds of the game
set integerlightning[1] = integerlightning[1] +1
... goes on till integer lightning 5
set lightning point [1] = to position of casting unit with offset
set lightning point [2] = to position of target of casting unit with offset (vals made in the activation trigger)
create lightning effect using this two points
set lightningeffect [integerlightning [1]] = last created lightning effect
and keep this up for 5 times, each time setting the effect to a different array of the integer.
turn off this trigger
turn on lightning destroy
in the next trigger (this is lightning destroy) :
every 0.20 second of game
destroy lightning effect : doing this for lightningeffect 1 to 5
and then i reduce each of the integer lightnings by 1, and then i turn of the trigger.
but the problem is the lightnings wont destroy, they just hang in there forever!
and also, i did this becuase if i used waits, multipile players using the spells and overload, could go into conflict. help me make this brothers, thanks
 
Level 8
Joined
Aug 15, 2010
Messages
216
Gee thanks bro, i didnt know how to post triggers acually. well here is the crit strike (activation) trigger

  • STORMCRIT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Lava Lash 1 (Neutral Hostile)
          • (Ability being cast) Equal to Lava Lash 2 (Neutral Hostile)
          • (Ability being cast) Equal to Lava Lash 3 (Neutral Hostile)
          • (Ability being cast) Equal to Lava Lash 4 (Neutral Hostile)
          • (Ability being cast) Equal to Storm Lash (Neutral Hostile)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Target unit of ability being cast) has buff Static Shocked ) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Lava Lash 1 (Neutral Hostile)
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 6.00 damage of attack type Spells and damage type Normal
              • Floating Text - Create floating text that reads |c000080C0ZAP|r above (Target unit of ability being cast) with Z offset (Random real number between 1.00 and 4.00), using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to (Random real number between 200.00 and 300.00) towards (Random real number between 60.00 and 120.00) degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
              • Set OverloadChance = (ELEMASTERYLVL[(Player number of (Owner of (Casting unit)))] x 2)
              • Set OverallChance = (Random integer number between 1 and 100)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • OverallChance Less than or equal to OverloadChance
                • Then - Actions
                  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 12.00 damage of attack type Spells and damage type Normal
                  • Floating Text - Create floating text that reads |c000080C0Overload!... above (Target unit of ability being cast) with Z offset 4.00, using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                  • Floating Text - Set the velocity of (Last created floating text) to 300.00 towards 90.00 degrees
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
                  • Set LightningUnit[1] = (Triggering unit)
                  • Set LightningUnit[2] = (Target unit of ability being cast)
                  • Trigger - Turn on Lightning <gen>
                • Else - Actions
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Target unit of ability being cast) has buff Static Shocked ) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Lava Lash 2 (Neutral Hostile)
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 9.00 damage of attack type Spells and damage type Normal
              • Floating Text - Create floating text that reads |c000080C0ZAP|r above (Target unit of ability being cast) with Z offset (Random real number between 1.00 and 4.00), using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to (Random real number between 200.00 and 300.00) towards (Random real number between 60.00 and 120.00) degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
              • Set OverloadChance = (ELEMASTERYLVL[(Player number of (Owner of (Casting unit)))] x 2)
              • Set OverallChance = (Random integer number between 1 and 100)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • OverallChance Less than or equal to OverloadChance
                • Then - Actions
                  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 18.00 damage of attack type Spells and damage type Normal
                  • Floating Text - Create floating text that reads |c000080C0Overload!... above (Target unit of ability being cast) with Z offset 4.00, using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                  • Floating Text - Set the velocity of (Last created floating text) to 300.00 towards 90.00 degrees
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
                  • Set LightningUnit[1] = (Triggering unit)
                  • Set LightningUnit[2] = (Target unit of ability being cast)
                  • Trigger - Turn on Lightning <gen>
                • Else - Actions
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Target unit of ability being cast) has buff Static Shocked ) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Lava Lash 3 (Neutral Hostile)
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 12.00 damage of attack type Spells and damage type Normal
              • Floating Text - Create floating text that reads |c000080C0ZAP|r above (Target unit of ability being cast) with Z offset (Random real number between 1.00 and 4.00), using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to (Random real number between 200.00 and 300.00) towards (Random real number between 60.00 and 120.00) degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
              • Set OverloadChance = (ELEMASTERYLVL[(Player number of (Owner of (Casting unit)))] x 2)
              • Set OverallChance = (Random integer number between 1 and 100)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • OverallChance Less than or equal to OverloadChance
                • Then - Actions
                  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 24.00 damage of attack type Spells and damage type Normal
                  • Floating Text - Create floating text that reads |c000080C0Overload!... above (Target unit of ability being cast) with Z offset 4.00, using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                  • Floating Text - Set the velocity of (Last created floating text) to 300.00 towards 90.00 degrees
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
                  • Set LightningUnit[1] = (Triggering unit)
                  • Set LightningUnit[2] = (Target unit of ability being cast)
                  • Trigger - Turn on Lightning <gen>
                • Else - Actions
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Target unit of ability being cast) has buff Static Shocked ) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Lava Lash 4 (Neutral Hostile)
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 15.00 damage of attack type Spells and damage type Normal
              • Floating Text - Create floating text that reads |c000080C0ZAP|r above (Target unit of ability being cast) with Z offset (Random real number between 1.00 and 4.00), using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to (Random real number between 200.00 and 300.00) towards (Random real number between 60.00 and 120.00) degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
              • Set OverloadChance = (ELEMASTERYLVL[(Player number of (Owner of (Casting unit)))] x 2)
              • Set OverallChance = (Random integer number between 1 and 100)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • OverallChance Less than or equal to OverloadChance
                • Then - Actions
                  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 30.00 damage of attack type Spells and damage type Normal
                  • Floating Text - Create floating text that reads |c000080C0Overload!... above (Target unit of ability being cast) with Z offset 4.00, using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                  • Floating Text - Set the velocity of (Last created floating text) to 300.00 towards 90.00 degrees
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
                  • Set LightningUnit[1] = (Triggering unit)
                  • Set LightningUnit[2] = (Target unit of ability being cast)
                  • Trigger - Turn on Lightning <gen>
                • Else - Actions
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Target unit of ability being cast) has buff Static Shocked ) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Storm Lash (Neutral Hostile)
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 12.00 damage of attack type Spells and damage type Normal
              • Floating Text - Create floating text that reads |c000080C0ZARCH|r above (Target unit of ability being cast) with Z offset (Random real number between 1.00 and 4.00), using font size 24.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to (Random real number between 200.00 and 300.00) towards (Random real number between 60.00 and 120.00) degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
              • Sound - Play PurgeTarget1 <gen>
              • Set OverloadChance = (ELEMASTERYLVL[(Player number of (Owner of (Casting unit)))] x 1)
              • Set OverallChance = (Random integer number between 1 and 100)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • OverallChance Less than or equal to OverloadChance
                • Then - Actions
                  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 40.00 damage of attack type Spells and damage type Normal
                  • Floating Text - Create floating text that reads |c000080C0Overload!... above (Target unit of ability being cast) with Z offset 4.00, using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
                  • Floating Text - Set the velocity of (Last created floating text) to 300.00 towards 90.00 degrees
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 0.50 seconds
                  • Set LightningUnit[1] = (Triggering unit)
                  • Set LightningUnit[2] = (Target unit of ability being cast)
                  • Trigger - Turn on Lightning <gen>
                • Else - Actions
            • Else - Actions
        • Else - Actions
The loop :

  • Lightning
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set LightningInteger[1] = (LightningInteger[1] + 1)
      • Set LightningInteger[2] = (LightningInteger[2] + 1)
      • Set LightningInteger[3] = (LightningInteger[3] + 1)
      • Set LightningInteger[4] = (LightningInteger[4] + 1)
      • Set LightningInteger[5] = (LightningInteger[5] + 1)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[1]] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[2]] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[3]] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[4]] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[5]] = (Last created lightning effect)
      • Trigger - Turn on Lightning Destroy <gen>
      • Trigger - Turn off (This trigger)
finally the destruction trigger :

  • Lightning Destroy
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Lightning - Destroy LightningEffect[LightningInteger[1]]
      • Lightning - Destroy LightningEffect[LightningInteger[2]]
      • Lightning - Destroy LightningEffect[LightningInteger[3]]
      • Lightning - Destroy LightningEffect[LightningInteger[4]]
      • Lightning - Destroy LightningEffect[LightningInteger[5]]
      • Set LightningInteger[1] = 0
      • Set LightningInteger[2] = 0
      • Set LightningInteger[3] = 0
      • Set LightningInteger[4] = 0
      • Set LightningInteger[5] = 0
      • Trigger - Turn off (This trigger)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
That is a really big trigger.

First anything used twice or more should be stored into a variable and the variable should be used. Example: target unit of ability being cast

You leak a lot of locations in your lightning trigger.

You should look at my tutorial things a GUIer should know it will help you to code more efficiently.

I'm not sure why you are using so many lightning arrays. Can you please explain exactly what this trigger should do
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
What death wrote.

The first trigger
It is very inefficiently done. It can be simplified and mathematically calculated. Also what death wrote - store Target unit of ability being cast and triggering/casting unit into variable at the start of the trigger and then check everything by using those variables instead

The second trigger
This trigger is not really needed, because it runs only once per ability, thus it does not require a loop event (run every 0,01 second). It could be add into the first trigger actually, but if you want it in the second trigger, then instead of "trigger - turn on loop trigger" in the first trigger, use the action "trigger - run loop trigger"
Also, the second trigger leaks a lot of locations and could be really simplified by using loop action "For each integer from X to Y".

The problem is in this second trigger, mainly these lines:
  • Set LightningEffect[LightningInteger[1]] = (Last created lightning effect)
  • Set LightningEffect[LightningInteger[2]] = (Last created lightning effect)
  • Set LightningEffect[LightningInteger[3]] = (Last created lightning effect)
  • Set LightningEffect[LightningInteger[4]] = (Last created lightning effect)
  • Set LightningEffect[LightningInteger[5]] = (Last created lightning effect)
The thing is that the index for LightningEffect is a number and all integer variables start with the number 0.

So what you did in your loop trigger is that you set "LightningInteger[1 -> 5] + 1". Since all integer variables start with value 0, all these integers have now number value 1.

This is what happens in actions:
set integer[1] = integer[1] + 1 => it has value 1 now
set integer[2] = integer[2] + 1 => also value 1
set integer[3] = integer[3] + 1 => value 1
set integer[4] = integer[4] + 1 => value 1
set integer[5] = integer[5] + 1 => value 1

Then you set
Set LightningEffect[LightningInteger[1]] = (Last created lightning effect)
....
Set LightningEffect[LightningInteger[5]] = (Last created lightning effect)

Now if we convert those LightningInteger[1 - 5] variables into number values they have, we get this:
Set LightningEffect[1] = (Last created lightning effect)
....
Set LightningEffect[1] = (Last created lightning effect)

Since all integers 1-5 have same value, you end up saving 5 different lightnings into the same array layer - layer 1.


The third trigger
You set all integers to 0, that's not how MUI works.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
For the indexing part - look here: http://www.hiveworkshop.com/forums/...-gui-user-should-know-233242/#Section 2 Ch 12

The difference between "turn on trigger" and "run trigger" is that run trigger will fire the trigger, while "turn on" waits until the event and condition requirements have been met. Time loops like yours are usually used when you want to run the trigger X times, not just once.

As for the first trigger: Is "Lava Lash 1" the name of the ability in the object editor? If so, is there a reason why you don't simply have Lava Lash ability which has 4 levels?
 
Level 8
Joined
Aug 15, 2010
Messages
216
there are 4 lava lashes in the object editor, each of them has to crit specific, and overload specific, thats why the first trigger is so long.
btw, can you write and example of two lightning effects built and destroyed with index? so i can learn indexing with example :D i'm kinda dumb i cant understand your tutorial, specially , where the hell did [tempint] come from and what the hell is for integer do actions :S. ah hell, i might just quit mapping, it not for people with less iq than 25 it seems.

so, after reading the tutorial, and not understanding it, i tried to pave a way myself.
  • Lightning
    • Events
    • Conditions
    • Actions
      • Set LightningInteger[1] = (LightningInteger[1] + 1)
      • Set LightningInteger[2] = (LightningInteger[2] + 2)
      • Set LightningInteger[3] = (LightningInteger[3] + 3)
      • Set LightningInteger[4] = (LightningInteger[4] + 4)
      • Set LightningInteger[5] = (LightningInteger[5] + 5)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[1]] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[2]] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[3]] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[4]] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set LightningEffect[LightningInteger[5]] = (Last created lightning effect)
      • Trigger - Turn on Lightning Destroy <gen>
      • Trigger - Turn off (This trigger)
and
  • Lightning Destroy
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Lightning - Destroy LightningEffect[LightningInteger[1]]
      • Lightning - Destroy LightningEffect[LightningInteger[2]]
      • Lightning - Destroy LightningEffect[LightningInteger[3]]
      • Lightning - Destroy LightningEffect[LightningInteger[4]]
      • Lightning - Destroy LightningEffect[LightningInteger[5]]
      • Set LightningInteger[1] = (LightningInteger[1] - 1)
      • Set LightningInteger[2] = (LightningInteger[2] - 2)
      • Set LightningInteger[3] = (LightningInteger[3] - 3)
      • Set LightningInteger[4] = (LightningInteger[4] - 4)
      • Set LightningInteger[5] = (LightningInteger[5] - 5)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LightningInteger[1] Less than or equal to 0
          • LightningInteger[2] Less than or equal to 0
          • LightningInteger[3] Less than or equal to 0
          • LightningInteger[4] Less than or equal to 0
          • LightningInteger[5] Less than or equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
it gets cleared enough, but i think if two players use the spell at the same time, it will bug, any suggestions?
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
Well, I'll start with the loop integer actions.
It's this:
  • For each (Integer Integer_var) from 1 to 10, do (Actions)
    • Loop - Actions
This can be found in action menu as "for each interger variable" (it's in -General- submenu). Note - there are 3 types of this action - "For each Integer A"; "For each Integer B" and "For each Integer variable" - use this 3rd one, as the Integer A and Integer B options are not as efficient.

What "For each integer loop" does is it runs the action in the loop X times, each time the integer will have number equal to the number of the loop.
e.g. you have "For each integer_var from 1 to 5" - this loop will run 5 times, the first time it runs, integer_var will have value 1, the 3rd time it runs, it will have value 3, 4th time value 4, etc.

Good thing is you don't have to write number in the "1 to 5" as number of times it runs, you can also use another integer variable - like this: "For each integer_var from 1 to Int"

This actions is useful when you want to execute same actions with mathematical consecution.
I'll show example a bit below.

-------
For the indexing:
  • Actions
    • Set Max_Index = (Max_Index + 1)
    • Set LightningArray[Max_Index] = (Last created lightning effect)
    • -------- ----------------------- --------
    • Set Max_Index = (Max_Index + 1)
    • Set LightningArray[Max_Index] = (Last created lightning effect)
Max_Index is integer variable.

Now for deindexing:
  • Actions
    • Lightning - Destroy LightningArray[2]
    • Set LightningArray[2] = LightningArray[Max_Index]
    • Set Max_Index = (Max_Index - 1)
For the sake of explaning this, I just outright destroyed LightningArray[2], since I couldn't think of any scenario which would not be overly complicated.

Basically, for indexing you need 1 integer variable, which keeps check of how many instances are currently active - in my case that's the "Max_Index" variable. Every time a new instance is run, you increase that index by 1, every time an instance has ended, you decrease it by 1

------
Now if you look at the indexing trigger I posted above, it can be simplified using the loop actions - like this:
  • For each (Integer LoopInt) from 1 to 2, do (Actions)
    • Loop - Actions
      • Set Max_Index = (Max_Index + 1)
      • Set LightningArray[Max_Index] = (Last created lightning effect)
This will run 2 times, since I wrote "from 1 to 2" and it will 2 times execute actions in it.
 
Level 8
Joined
Aug 15, 2010
Messages
216
wow, you are the best my friend, thank you, i will try this one at once, i'll keep you posted, thank you, you helped me a lot! i wish i could repay this somehow.

Edit, so i wrote the trigger, (sorry i didnt simplified it using your trick, i just wanted to see if it works real fast :D) and here it is :
  • Lightning
    • Events
    • Conditions
    • Actions
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set Max_Index = (MaxIndex + 1)
      • Set LightningEffect[Max_Index] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set Max_Index = (MaxIndex + 1)
      • Set LightningEffect[Max_Index] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set Max_Index = (MaxIndex + 1)
      • Set LightningEffect[Max_Index] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set Max_Index = (MaxIndex + 1)
      • Set LightningEffect[Max_Index] = (Last created lightning effect)
      • Set Lightningpoint[1] = ((Position of LightningUnit[2]) offset by ((Random real number between 10.00 and 20.00), (Random real number between 10.00 and 20.00)))
      • Set Lightningpoint[2] = ((Position of LightningUnit[1]) offset by ((Random real number between 10.00 and 400.00), (Random real number between 10.00 and 400.00)))
      • Lightning - Create a Chain Lightning - Primary lightning effect from source Lightningpoint[1] to target Lightningpoint[2]
      • Set Max_Index = (MaxIndex + 1)
      • Set LightningEffect[Max_Index] = (Last created lightning effect)
      • Trigger - Run Lightning Destroy <gen> (checking conditions)
      • Trigger - Turn off (This trigger)
and this as the second :
  • Lightning Destroy
    • Events
    • Conditions
    • Actions
      • Lightning - Destroy LightningEffect[1]
      • Set LightningEffect[1] = LightningEffect[MaxIndex]
      • Set Max_Index = (MaxIndex - 1)
      • Lightning - Destroy LightningEffect[2]
      • Set LightningEffect[2] = LightningEffect[MaxIndex]
      • Set Max_Index = (MaxIndex - 1)
      • Lightning - Destroy LightningEffect[3]
      • Set LightningEffect[3] = LightningEffect[MaxIndex]
      • Set Max_Index = (MaxIndex - 1)
      • Lightning - Destroy LightningEffect[4]
      • Set LightningEffect[4] = LightningEffect[MaxIndex]
      • Set Max_Index = (MaxIndex - 1)
      • Lightning - Destroy LightningEffect[5]
      • Set LightningEffect[5] = LightningEffect[MaxIndex]
      • Set Max_Index = (MaxIndex - 1)
i know i sound dumb, i look dumb, i am dumb, but, what the hell, the lightnings wont disappear! :vw_wtf:
can you simply correct this trigger?

Edit : sorry i bother you so much brother. i'm srsly dumb, you can leave me be if you like, i'll just get past the trigger.
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
Do all lightnings remain? I presume only 2-3 out of the 5 remain, am I right? In the second trigger destroy lightning[1] every time you destroy lightning.

In the first trigger where you create lightnings, you still leak a lot of locations.


Anyway, I think I simplified the first long trigger, it should work as intended
  • Crit
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Target unit of ability being cast) has buff Static Shocked) Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Lava Lash 1
          • (Ability being cast) Equal to Lava Lash 2
          • (Ability being cast) Equal to Lava Lash 3
          • (Ability being cast) Equal to Lava Lash 4
          • (Ability being cast) Equal to Storm Lash
    • Actions
      • Set Ability_used = (Ability being cast)
      • Set Caster = (Triggering unit)
      • Set Target = (Target unit of ability being cast)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Ability_used Equal to Storm Lash
        • Then - Actions
          • Set dmg = 20.00
          • Set text = |c000080C0ZARCH|r
          • Set OverloadChance = (ELEMASTERYLVL[(Player number of (Owner of Caster))] x 1)
          • Sound - Play No sound
          • Unit - Cause Caster to damage Target, dealing 12.00 damage of attack type Spells and damage type Normal
        • Else - Actions
          • -------- since the ability used is not Storm Lash, we know it's one of those Lava Lash abilities --------
          • -------- the line below takes the 11th letter in the ability's name and converts it into integer --------
          • Set int = (Integer((Substring((Name of Ability_used), 11, 11))))
          • -------- Each Lava Lash deals 3 base dmg + 3 * (level of Lava Lash). --------
          • -------- We found the level from the ability name - from "int" variable --------
          • -------- and we use the calculation 3 + (3 * int) to get correct dmg --------
          • Set dmg = (3.00 + (3.00 x (Real(int))))
          • Set text = |c000080C0ZAP|r
          • Set OverloadChance = (ELEMASTERYLVL[(Player number of (Owner of Caster))] x 2)
          • Unit - Cause Caster to damage Target, dealing dmg damage of attack type Spells and damage type Normal
      • -------- ----------------------- --------
      • Floating Text - Create floating text that reads text above Target with Z offset (Random real number between 1.00 and 4.00), using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Set FloatTxt = (Last created floating text)
      • Floating Text - Set the velocity of FloatTxt to (Random real number between 200.00 and 300.00) towards (Random real number between 60.00 and 120.00) degrees
      • Floating Text - Change FloatTxt: Disable permanence
      • Floating Text - Change the lifespan of FloatTxt to 0.50 seconds
      • Custom script: set udg_FloatTxt = null
      • -------- ----------------------- --------
      • Set OverallChance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • OverallChance Less than or equal to OverloadChance
        • Then - Actions
          • Unit - Cause Caster to damage Target, dealing (2.00 x dmg) damage of attack type Spells and damage type Normal
          • -------- ----------------------- --------
          • Floating Text - Create floating text that reads |c000080C0Overload! above Target with Z offset 4.00, using font size 12.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set FloatTxt = (Last created floating text)
          • Floating Text - Set the velocity of FloatTxt to 300.00 towards 90.00 degrees
          • Floating Text - Change FloatTxt: Disable permanence
          • Floating Text - Change the lifespan of FloatTxt to 0.50 seconds
          • Custom script: set udg_FloatTxt = null
          • -------- ----------------------- --------
          • Set LightningUnit[1] = Caster
          • Set LightningUnit[2] = Target
          • Trigger - Run Loop <gen> (checking conditions)
        • Else - Actions
      • -------- ----------------------- --------
      • -------- ----------------------- --------
      • Set Caster = No unit
      • Set Target = No unit
      • Set text = <Empty String>
Caster and Target = unit variables
Ability_used = ability variable
text = string variable
dmg = real variable
int = integer variable
FloatTxt = floating text variable

Note: As I wrote in one of those comments, to determine dmg from Lava Lash, I take the 11th letter and use it in calculation - e.g. "Lava Lash 1" - the 1 is the 11th letter. If you change the name, change also which letter you look for, else the converted number will be 0 or may crash your game.
 
Status
Not open for further replies.
Top