• 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 Spell Template

This map contains a single chain spell which is easy configurable, even if your a beginning coder.

Variable are:
- Missile Speed
- Bounce Range (the maximum range that the missile will search a new target to bounce to)
- Number of Bounces
- Maximum Hits (how much times a unit may be hit by the same bounce spell, warcraft default is 1)
- Missile Type (a unit that is created in the Object Editor)
- Ability type (the one that is casted every time the bounce hits)
- The conditions that a unit must meet to be aquired as the next target (example: currently it only picks enemy units)

Code (map example is a Storm Bolt chain)

  • Chain Storm Bolt Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chain Storm Bolt
    • Actions
      • -------- Setup Variables --------
      • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [Missile Speed, Bounce Range, Number of Bounces and how many times the same unit may be hit during one chain.] --------
      • Set SpellBounceRange = 400.00
      • Set SpellBounceSpeed = 800.00
      • Set SpellNumberBounces = (2 + (2 x (Level of Chain Storm Bolt for (Casting unit))))
      • Set SpellMaximumNumberHits = 1
      • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [Missile Speed, Bounce Range, Number of Bounces and how many times the same unit may be hit during one chain.] --------
      • -------- Spell Effect Create Dummy Unit With Model --------
      • Set TemporaryPoint[1] = (Position of (Casting unit))
      • Set TemporaryPoint[2] = (Position of (Target unit of ability being cast))
      • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [The Missile Type, which is a unit.] --------
      • Unit - Create 1 Storm Bolt Missile for (Owner of (Casting unit)) at TemporaryPoint[1] facing TemporaryPoint[2]
      • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [The Missile Type, which is a unit.] --------
      • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [Select the right Loop Trigger.] --------
      • If ((PowerChainGroup is empty) Equal to True) then do (Trigger - Turn on Chain Storm Bolt Loop <gen>) else do (Do nothing)
      • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [Select the right Loop Trigger.] --------
      • Unit Group - Add (Last created unit) to PowerChainGroup
      • -------- Save Variables --------
      • Hashtable - Save SpellBounceRange as 0 of (Key (Last created unit)) in PowerChainHash
      • Hashtable - Save SpellBounceSpeed as 1 of (Key (Last created unit)) in PowerChainHash
      • Hashtable - Save SpellNumberBounces as 2 of (Key (Last created unit)) in PowerChainHash
      • Hashtable - Save Handle Of(Target unit of ability being cast) as 3 of (Key (Last created unit)) in PowerChainHash
      • Hashtable - Save (Level of Chain Storm Bolt for (Casting unit)) as 4 of (Key (Last created unit)) in PowerChainHash
      • Hashtable - Save SpellMaximumNumberHits as 5 of (Key (Last created unit)) in PowerChainHash
      • Hashtable - Save (Key (Last created unit)) as 6 of (Key (Last created unit)) in PowerChainHash
      • -------- Clean up --------
      • Custom script: call RemoveLocation (udg_TemporaryPoint[2])
      • Custom script: call RemoveLocation (udg_TemporaryPoint[1])
  • Chain Storm Bolt Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in PowerChainGroup) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in PowerChainGroup and do (Actions)
            • Loop - Actions
              • -------- Load Variables --------
              • Set SpellBounceSpeed = (Load 1 of (Key (Picked unit)) from PowerChainHash)
              • Set SpellNumberBounces = (Load 2 of (Key (Picked unit)) from PowerChainHash)
              • Set TemporaryTarget = (Load 3 of (Key (Picked unit)) in PowerChainHash)
              • Set TemporaryKeyTarget = (Load 3 of (Key (Picked unit)) in PowerChainHash)
              • Set TemporaryKeySpell = (Load 6 of (Key (Picked unit)) from PowerChainHash)
              • -------- Spell Effect Move Bouncing Missile --------
              • Set TemporaryPoint[1] = (Position of (Picked unit))
              • Set TemporaryPoint[2] = (Position of TemporaryTarget)
              • Set TemporaryPoint[3] = (TemporaryPoint[1] offset by (0.02 x SpellBounceSpeed) towards (Angle from TemporaryPoint[1] to TemporaryPoint[2]) degrees)
              • Unit - Move (Picked unit) instantly to TemporaryPoint[3], facing TemporaryPoint[2]
              • Custom script: call RemoveLocation (udg_TemporaryPoint[3])
              • Custom script: call RemoveLocation (udg_TemporaryPoint[1])
              • Set TemporaryPoint[1] = (Position of (Picked unit))
              • -------- Collision Of Unit And Bouncing Missile --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between TemporaryPoint[1] and TemporaryPoint[2]) Less than or equal to (SpellBounceSpeed / 70.00)
                • Then - Actions
                  • Custom script: call RemoveLocation (udg_TemporaryPoint[1])
                  • Custom script: call RemoveLocation (udg_TemporaryPoint[2])
                  • -------- Spell Hit --------
                  • Set TemporaryPoint[1] = (Position of TemporaryTarget)
                  • Unit - Create 1 Caster for (Owner of (Picked unit)) at TemporaryPoint[1] facing TemporaryPoint[1]
                  • Unit - Add Storm Bolt (Dummy Spell) to (Last created unit)
                  • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [Ability casted against every unit in the chain, and the right cast order.] --------
                  • Unit - Set level of Storm Bolt (Dummy Spell) for (Last created unit) to (Load 4 of (Key (Picked unit)) from PowerChainHash)
                  • Unit - Order (Last created unit) to Neutral - Firebolt TemporaryTarget
                  • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [Ability casted against every unit in the chain, and the right cast order.] --------
                  • Unit - Add a 0.10 second Generic expiration timer to (Last created unit)
                  • Custom script: call RemoveLocation (udg_TemporaryPoint[1])
                  • -------- Save Variables On Target Unit --------
                  • Hashtable - Save ((Load TemporaryKeySpell of (Key TemporaryKeyTarget) from PowerChainHash) + 1) as TemporaryKeySpell of (Key TemporaryKeyTarget) in PowerChainHash
                  • -------- Decrease Bounces --------
                  • Set SpellNumberBounces = (SpellNumberBounces - 1)
                  • -------- Bounce On When More Units Can Be Hit --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SpellNumberBounces Greater than 0
                    • Then - Actions
                      • -------- Load Variables --------
                      • Set SpellMaximumNumberHits = (Load 5 of (Key (Picked unit)) from PowerChainHash)
                      • Set SpellBounceRange = (Load 0 of (Key (Picked unit)) from PowerChainHash)
                      • -------- Spell Effect --------
                      • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [The conditions that a unit must meet to be aquired as the next target] --------
                      • Set TemporaryGroup[1] = (Units within SpellBounceRange of (Position of (Picked unit)) matching (((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and (SpellMaximumNumberHits Greater than (Load TemporaryKeySpell of (Key (Matching unit)
                      • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [The conditions that a unit must meet to be aquired as the next target] --------
                      • Set TemporaryGroup[2] = (Random 1 units from TemporaryGroup[1])
                      • -------- New Unit To Bounce To Found --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in TemporaryGroup[2]) Greater than 0
                        • Then - Actions
                          • -------- Make This Unit The New Target --------
                          • Unit Group - Pick every unit in TemporaryGroup[2] and do (Actions)
                            • Loop - Actions
                              • Set TemporaryTarget = (Picked unit)
                          • Custom script: call DestroyGroup (udg_TemporaryGroup[2])
                          • Custom script: call DestroyGroup (udg_TemporaryGroup[1])
                          • Set TemporaryPoint[1] = (Position of (Picked unit))
                          • Set TemporaryPoint[2] = (Position of TemporaryTarget)
                          • -------- New Dummy Unit --------
                          • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [The Missile Type, which is a unit.] --------
                          • Unit - Create 1 Storm Bolt Missile for (Owner of (Picked unit)) at TemporaryPoint[1] facing TemporaryPoint[2]
                          • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [The Missile Type, which is a unit.] --------
                          • Unit Group - Add (Last created unit) to PowerChainGroup
                          • -------- Save Variables --------
                          • Hashtable - Save SpellBounceRange as 0 of (Key (Last created unit)) in PowerChainHash
                          • Hashtable - Save SpellBounceSpeed as 1 of (Key (Last created unit)) in PowerChainHash
                          • Hashtable - Save SpellNumberBounces as 2 of (Key (Last created unit)) in PowerChainHash
                          • Hashtable - Save Handle OfTemporaryTarget as 3 of (Key (Last created unit)) in PowerChainHash
                          • Hashtable - Save (Load 4 of (Key (Picked unit)) from PowerChainHash) as 4 of (Key (Last created unit)) in PowerChainHash
                          • Hashtable - Save SpellMaximumNumberHits as 5 of (Key (Last created unit)) in PowerChainHash
                          • Hashtable - Save (Load 6 of (Key (Picked unit)) from PowerChainHash) as 6 of (Key (Last created unit)) in PowerChainHash
                          • -------- Clean up --------
                          • Custom script: call RemoveLocation (udg_TemporaryPoint[2])
                          • Custom script: call RemoveLocation (udg_TemporaryPoint[1])
                        • Else - Actions
                          • Custom script: call DestroyGroup (udg_TemporaryGroup[2])
                          • Custom script: call DestroyGroup (udg_TemporaryGroup[1])
                          • -------- Clean Up Units That Were Hit --------
                          • Set TemporaryGroup[1] = (Units in (Playable map area) matching ((Load TemporaryKeySpell of (Key (Matching unit)) from PowerChainHash) Not equal to 0))
                          • Unit Group - Pick every unit in TemporaryGroup[1] and do (Actions)
                            • Loop - Actions
                              • Hashtable - Save 0 as TemporaryKeySpell of (Key (Picked unit)) in PowerChainHash
                          • Custom script: call DestroyGroup (udg_TemporaryGroup[1])
                    • Else - Actions
                      • -------- Clean Up Units That Were Hit --------
                      • Set TemporaryGroup[1] = (Units in (Playable map area) matching ((Load TemporaryKeySpell of (Key (Matching unit)) from PowerChainHash) Not equal to 0))
                      • Unit Group - Pick every unit in TemporaryGroup[1] and do (Actions)
                        • Loop - Actions
                          • Hashtable - Save 0 as TemporaryKeySpell of (Key (Picked unit)) in PowerChainHash
                      • Custom script: call DestroyGroup (udg_TemporaryGroup[1])
                  • -------- Remove Old Dummy Unit --------
                  • Unit - Kill (Picked unit)
                  • Unit Group - Remove (Picked unit) from PowerChainGroup
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in PowerChainHash
                • Else - Actions
                  • Custom script: call RemoveLocation (udg_TemporaryPoint[1])
                  • Custom script: call RemoveLocation (udg_TemporaryPoint[2])
        • Else - Actions
          • Trigger - Turn off (This trigger)
I'm not asking for any credits, just copy the code when you like it ;).
Contents

[GUI] Chain Spell Template (Map)

Reviews
13:53, 16th Jun 2010 TriggerHappy: Would be ideal if you used arrays instead of creating multiple variables for locations. Appeared to be leakless and MUI.

Moderator

M

Moderator

13:53, 16th Jun 2010
TriggerHappy:

Would be ideal if you used arrays instead of creating multiple variables for locations.
Appeared to be leakless and MUI.
 
Level 2
Joined
Jul 21, 2009
Messages
21
Ok if you dont want to put the triggers in your description so i do it.

  • Chain Storm Bolt Cast
    • Ereignisse
      • Einheit - A unit Startet den Effekt einer Fähigkeit
    • Bedingungen
      • (Ability being cast) Gleich Chain Storm Bolt
    • Aktionen
      • -------- Setup Variables --------
      • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [Missile Speed, Bounce Range, Number of Bounces and how many times the same unit may be hit during one chain.] --------
      • Set SpellBounceRange = 400.00
      • Set SpellBounceSpeed = 800.00
      • Set SpellNumberBounces = (2 + (2 x (Level of Chain Storm Bolt for (Casting unit))))
      • Set SpellMaximumNumberHits = 1
      • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [Missile Speed, Bounce Range, Number of Bounces and how many times the same unit may be hit during one chain.] --------
      • -------- Spell Effect Create Dummy Unit With Model --------
      • Set TemporaryPoint1 = (Position of (Casting unit))
      • Set TemporaryPoint2 = (Position of (Target unit of ability being cast))
      • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [The Missile Type, which is a unit.] --------
      • Einheit - Create 1 Storm Bolt Missile for (Owner of (Casting unit)) at TemporaryPoint1 facing TemporaryPoint2
      • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [The Missile Type, which is a unit.] --------
      • Einheitengruppe - Add (Last created unit) to PowerChainGroup
      • -------- Save Variables --------
      • Hashtabelle - Save SpellBounceRange as 0 of (Key (Last created unit)) in PowerChainHash
      • Hashtabelle - Save SpellBounceSpeed as 1 of (Key (Last created unit)) in PowerChainHash
      • Hashtabelle - Save SpellNumberBounces as 2 of (Key (Last created unit)) in PowerChainHash
      • Hashtabelle - Save Handle Of(Target unit of ability being cast) as 3 of (Key (Last created unit)) in PowerChainHash
      • Hashtabelle - Save (Level of Chain Storm Bolt for (Casting unit)) as 4 of (Key (Last created unit)) in PowerChainHash
      • Hashtabelle - Save SpellMaximumNumberHits as 5 of (Key (Last created unit)) in PowerChainHash
      • Hashtabelle - Save (Key (Last created unit)) as 6 of (Key (Last created unit)) in PowerChainHash
      • -------- Clean up --------
      • Custom script: call RemoveLocation (udg_TemporaryPoint2)
      • Custom script: call RemoveLocation (udg_TemporaryPoint1)
  • Chain Storm Bolt Loop
    • Ereignisse
      • Zeit - Every 0.02 seconds of game time
    • Bedingungen
      • (Number of units in PowerChainGroup) Größer als 0
    • Aktionen
      • Einheitengruppe - Pick every unit in PowerChainGroup and do (Actions)
        • Schleifen - Aktionen
          • -------- Load Variables --------
          • Set SpellBounceSpeed = (Load 1 of (Key (Picked unit)) from PowerChainHash)
          • Set SpellNumberBounces = (Load 2 of (Key (Picked unit)) from PowerChainHash)
          • Set TemporaryTarget = (Load 3 of (Key (Picked unit)) in PowerChainHash)
          • Set TemporaryKeyTarget = (Load 3 of (Key (Picked unit)) in PowerChainHash)
          • Set TemporaryKeySpell = (Load 6 of (Key (Picked unit)) from PowerChainHash)
          • -------- Spell Effect Move Bouncing Missile --------
          • Set TemporaryPoint1 = (Position of (Picked unit))
          • Set TemporaryPoint2 = (Position of TemporaryTarget)
          • Set TemporaryPoint3 = (TemporaryPoint1 offset by (0.02 x SpellBounceSpeed) towards (Angle from TemporaryPoint1 to TemporaryPoint2) degrees)
          • Einheit - Move (Picked unit) instantly to TemporaryPoint3, facing TemporaryPoint2
          • Custom script: call RemoveLocation (udg_TemporaryPoint3)
          • Custom script: call RemoveLocation (udg_TemporaryPoint1)
          • Set TemporaryPoint1 = (Position of (Picked unit))
          • -------- Collision Of Unit And Bouncing Missile --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Bedingungen
              • (Distance between TemporaryPoint1 and TemporaryPoint2) Kleiner gleich 10.00
            • 'THEN'-Aktionen
              • Custom script: call RemoveLocation (udg_TemporaryPoint1)
              • Custom script: call RemoveLocation (udg_TemporaryPoint2)
              • -------- Spell Hit --------
              • Set TemporaryPoint1 = (Position of TemporaryTarget)
              • Einheit - Create 1 Caster for (Owner of (Picked unit)) at TemporaryPoint1 facing TemporaryPoint1
              • Einheit - Add Storm Bolt (Dummy Spell) to (Last created unit)
              • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [Ability casted against every unit in the chain, and the right cast order.] --------
              • Einheit - Set level of Storm Bolt (Dummy Spell) for (Last created unit) to (Load 4 of (Key (Picked unit)) from PowerChainHash)
              • Einheit - Order (Last created unit) to Neutral - 'Feuerblitz' TemporaryTarget
              • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [Ability casted against every unit in the chain, and the right cast order.] --------
              • Einheit - Add a 0.10 second Standard expiration timer to (Last created unit)
              • Custom script: call RemoveLocation (udg_TemporaryPoint1)
              • -------- Save Variables On Target Unit --------
              • Hashtabelle - Save ((Load TemporaryKeySpell of (Key TemporaryKeyTarget) from PowerChainHash) + 1) as TemporaryKeySpell of (Key TemporaryKeyTarget) in PowerChainHash
              • -------- Decrease Bounces --------
              • Set SpellNumberBounces = (SpellNumberBounces - 1)
              • -------- Bounce On When More Units Can Be Hit --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Bedingungen
                  • SpellNumberBounces Größer als 0
                • 'THEN'-Aktionen
                  • -------- Load Variables --------
                  • Set SpellMaximumNumberHits = (Load 5 of (Key (Picked unit)) from PowerChainHash)
                  • Set SpellBounceRange = (Load 0 of (Key (Picked unit)) from PowerChainHash)
                  • -------- Spell Effect --------
                  • Set TemporaryGroup1 = (Units within SpellBounceRange of (Position of (Picked unit)) matching (((((Matching unit) is alive) Gleich True) and ((((Matching unit) is Ein Gebäude) Gleich False) and (SpellMaximumNumberHits Größer als (Load TemporaryKeySpell of (Key (Matching unit)) f
                  • Set TemporaryGroup2 = (Random 1 units from TemporaryGroup1)
                  • -------- New Unit To Bounce To Found --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Bedingungen
                      • (Number of units in TemporaryGroup2) Größer als 0
                    • 'THEN'-Aktionen
                      • -------- Make This Unit The New Target --------
                      • Einheitengruppe - Pick every unit in TemporaryGroup2 and do (Actions)
                        • Schleifen - Aktionen
                          • Set TemporaryTarget = (Picked unit)
                      • Set TemporaryPoint1 = (Position of (Picked unit))
                      • Set TemporaryPoint2 = (Position of TemporaryTarget)
                      • -------- New Dummy Unit --------
                      • -------- ----------------------------------------------------------------------------------------------------EDIT UNDER [The Missile Type, which is a unit.] --------
                      • Einheit - Create 1 Storm Bolt Missile for (Owner of (Picked unit)) at TemporaryPoint1 facing TemporaryPoint2
                      • -------- ----------------------------------------------------------------------------------------------------EDIT ABOVE [The Missile Type, which is a unit.] --------
                      • Einheitengruppe - Add (Last created unit) to PowerChainGroup
                      • -------- Save Variables --------
                      • Hashtabelle - Save SpellBounceRange as 0 of (Key (Last created unit)) in PowerChainHash
                      • Hashtabelle - Save SpellBounceSpeed as 1 of (Key (Last created unit)) in PowerChainHash
                      • Hashtabelle - Save SpellNumberBounces as 2 of (Key (Last created unit)) in PowerChainHash
                      • Hashtabelle - Save Handle OfTemporaryTarget as 3 of (Key (Last created unit)) in PowerChainHash
                      • Hashtabelle - Save (Load 4 of (Key (Picked unit)) from PowerChainHash) as 4 of (Key (Last created unit)) in PowerChainHash
                      • Hashtabelle - Save SpellMaximumNumberHits as 5 of (Key (Last created unit)) in PowerChainHash
                      • Hashtabelle - Save (Load 6 of (Key (Picked unit)) from PowerChainHash) as 6 of (Key (Last created unit)) in PowerChainHash
                      • -------- Clean up --------
                      • Custom script: call RemoveLocation (udg_TemporaryPoint2)
                      • Custom script: call RemoveLocation (udg_TemporaryPoint1)
                    • 'ELSE'-Aktionen
                      • -------- Clean Up Units That Were Hit --------
                      • Set TemporaryGroup1 = (Units in (Playable map area) matching ((Load TemporaryKeySpell of (Key (Matching unit)) from PowerChainHash) Ungleich 0))
                      • Einheitengruppe - Pick every unit in TemporaryGroup1 and do (Actions)
                        • Schleifen - Aktionen
                          • Hashtabelle - Save 0 as TemporaryKeySpell of (Key (Picked unit)) in PowerChainHash
                      • Custom script: call DestroyGroup (udg_TemporaryGroup1)
                  • Custom script: call DestroyGroup (udg_TemporaryGroup2)
                  • Custom script: call DestroyGroup (udg_TemporaryGroup1)
                • 'ELSE'-Aktionen
                  • -------- Clean Up Units That Were Hit --------
                  • Set TemporaryGroup1 = (Units in (Playable map area) matching ((Load TemporaryKeySpell of (Key (Matching unit)) from PowerChainHash) Ungleich 0))
                  • Einheitengruppe - Pick every unit in TemporaryGroup1 and do (Actions)
                    • Schleifen - Aktionen
                      • Hashtabelle - Save 0 as TemporaryKeySpell of (Key (Picked unit)) in PowerChainHash
                  • Custom script: call DestroyGroup (udg_TemporaryGroup1)
              • -------- Remove Old Dummy Unit --------
              • Einheit - Kill (Picked unit)
              • Einheitengruppe - Remove (Picked unit) from PowerChainGroup
              • Hashtabelle - Clear all child hashtables of child (Key (Picked unit)) in PowerChainHash
            • 'ELSE'-Aktionen
          • Custom script: call RemoveLocation (udg_TemporaryPoint1)
          • Custom script: call RemoveLocation (udg_TemporaryPoint2)
The idea is good and the triggers have no leaks or make over problems so you get 5/5 from me. :thumbs_up:
 
Level 9
Joined
Oct 31, 2009
Messages
121
First of all, Thanks gods I'm not alone who uses the Hashtables.

Now triggers.
I can see that your loop trigger's interval is too short (MIN interval should be 0.03).
You HAVE to turn your loop trigger off sometime. With many loop-triggers it will start lagging very soon.
I'd suggest to use this in the Cast trigger
  • If ((PowerChainGroup is empty) Equal to True) then do (Trigger - Turn on Chain Storm Bolt Loop <gen>) else do (Do nothing)
  • Unit Group - Add (Triggering unit) to PowerChainGroup
and this in the Loop trigger
  • If ((PowerChainGroup is empty) Equal to True) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
to turn this on/off.

Instead of many Location variables you could simply use arrayed one.
 
Top