• 🏆 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!

[Trigger] Energy system bug

Status
Not open for further replies.
Level 7
Joined
Sep 19, 2012
Messages
204
Hey guys...i started building a new map. I wanted to create a game where you need to Power your Buildings. I am not that good in triggering this big things so i used the mana system from ap0calypse...
It works pretty good. but when a unit dies the lightning connecting the two buildings doesnt disappear, unless BOTH buildings are destroyed. :ogre_rage:

is there a way to stop this when ONE of the buildings gets destroyed?
 
Level 7
Joined
Sep 19, 2012
Messages
204
  • Power I Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set PowerTable = (Last created hashtable)
  • Power I Init Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Transfer Energy
    • Actions
      • Set PowerInteger = (Load 0 of (Key (Triggering unit)) from PowerTable)
      • Set PowerTempBoolean = False
      • For each (Integer PowerLoopInt) from 1 to PowerInteger, do (Actions)
        • Loop - Actions
          • Set PowerTableUnit = (Load 0 of (Key (Load PowerLoopInt of (Key (Triggering unit)) in PowerTable)) in PowerTable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target unit of ability being cast) Equal to PowerTableUnit
            • Then - Actions
              • Lightning - Destroy (Load 2 of (Key (Load PowerLoopInt of (Key (Triggering unit)) in PowerTable)) in PowerTable)
              • Unit Group - Remove (Load PowerLoopInt of (Key (Triggering unit)) in PowerTable) from PowerDummies
              • Hashtable - Clear all child hashtables of child (Key (Load PowerLoopInt of (Key (Triggering unit)) in PowerTable)) in (Last created hashtable)
              • Unit - Remove (Load PowerLoopInt of (Key (Triggering unit)) in (Last created hashtable)) from the game
              • Hashtable - Save (PowerInteger - 1) as 0 of (Key (Triggering unit)) in PowerTable
              • Set PowerTempBoolean = True
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in PowerDummies) Equal to 0
                • Then - Actions
                  • Trigger - Turn off Power I Mana Drain <gen>
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PowerTempBoolean Equal to True
                • Then - Actions
                  • Hashtable - Save Handle Of(Load PowerLoopInt of (Key (Triggering unit)) in PowerTable) as (PowerLoopInt - 1) of (Key (Triggering unit)) in PowerTable
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PowerInteger Equal to 4
          • PowerTempBoolean Equal to False
        • Then - Actions
          • Set PowerTableUnit = (Load 1 of (Key (Triggering unit)) in PowerTable)
          • Set PowerTempGroup = (Units in (Playable map area) matching ((Matching unit) Equal to PowerTableUnit))
          • Unit Group - Add PowerTableUnit to PowerTempGroup
          • Unit Group - Pick every unit in PowerTempGroup and do (Actions)
            • Loop - Actions
              • Lightning - Destroy (Load 2 of (Key (Picked unit)) in PowerTable)
              • Unit Group - Remove (Picked unit) from PowerDummies
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in (Last created hashtable)
              • Unit - Remove (Picked unit) from the game
          • Custom script: call DestroyGroup(udg_PowerTempGroup)
          • Hashtable - Save Handle Of(Load 2 of (Key (Triggering unit)) in PowerTable) as 1 of (Key (Triggering unit)) in PowerTable
          • Hashtable - Save Handle Of(Load 3 of (Key (Triggering unit)) in PowerTable) as 2 of (Key (Triggering unit)) in PowerTable
          • Hashtable - Save Handle Of(Load 4 of (Key (Triggering unit)) in PowerTable) as 3 of (Key (Triggering unit)) in PowerTable
          • Set PowerLoc[1] = (Position of (Triggering unit))
          • Set PowerLoc[2] = (Position of (Target unit of ability being cast))
          • Unit - Create 1 Hashtable Saver for (Owner of (Triggering unit)) at PowerLoc[1] facing Default building facing degrees
          • Unit Group - Add (Last created unit) to PowerDummies
          • Hashtable - Save Handle Of(Last created unit) as 4 of (Key (Triggering unit)) in PowerTable
          • Lightning - Create a Drain Mana lightning effect from source PowerLoc[1] to target PowerLoc[2]
          • Hashtable - Save Handle Of(Target unit of ability being cast) as 0 of (Key (Last created unit)) in PowerTable
          • Hashtable - Save Handle Of(Triggering unit) as 1 of (Key (Last created unit)) in PowerTable
          • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Last created unit)) in PowerTable
          • Custom script: call RemoveLocation(udg_PowerLoc[1])
          • Custom script: call RemoveLocation(udg_PowerLoc[2])
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PowerTempBoolean Equal to False
            • Then - Actions
              • Set PowerLoc[1] = (Position of (Triggering unit))
              • Set PowerLoc[2] = (Position of (Target unit of ability being cast))
              • Unit - Create 1 Hashtable Saver for (Owner of (Triggering unit)) at PowerLoc[1] facing Default building facing degrees
              • Unit Group - Add (Last created unit) to PowerDummies
              • Hashtable - Save Handle Of(Last created unit) as (PowerInteger + 1) of (Key (Triggering unit)) in PowerTable
              • Hashtable - Save (PowerInteger + 1) as 0 of (Key (Triggering unit)) in PowerTable
              • Lightning - Create a Drain Mana lightning effect from source PowerLoc[1] to target PowerLoc[2]
              • Hashtable - Save Handle Of(Target unit of ability being cast) as 0 of (Key (Last created unit)) in PowerTable
              • Hashtable - Save Handle Of(Triggering unit) as 1 of (Key (Last created unit)) in PowerTable
              • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Last created unit)) in PowerTable
              • Custom script: call RemoveLocation(udg_PowerLoc[1])
              • Custom script: call RemoveLocation(udg_PowerLoc[2])
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PowerTempBoolean Equal to False
          • (Power I Mana Drain <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Power I Mana Drain <gen>
        • Else - Actions
  • Power I Mana Drain
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PowerDummies and do (Actions)
        • Loop - Actions
          • Set PowerUnit[1] = (Load 0 of (Key (Picked unit)) in PowerTable)
          • Set PowerUnit[2] = (Load 1 of (Key (Picked unit)) in PowerTable)
          • Set PowerReal[1] = (Mana of PowerUnit[1])
          • Set PowerReal[2] = (Mana of PowerUnit[2])
          • Set PowerReal[3] = 5.00
          • Lightning - Destroy (Load 2 of (Key (Picked unit)) in PowerTable)
          • Set PowerLoc[1] = (Position of PowerUnit[2])
          • Set PowerLoc[2] = (Position of PowerUnit[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PowerReal[1] Greater than ((Max mana of PowerUnit[1]) - PowerReal[3])
            • Then - Actions
              • Unit - Set mana of PowerUnit[1] to (Max mana of PowerUnit[1])
              • Unit - Set mana of PowerUnit[2] to ((Mana of PowerUnit[2]) - ((Max mana of PowerUnit[1]) - PowerReal[1]))
              • Lightning - Create a Mana Burn lightning effect from source PowerLoc[1] to target PowerLoc[2]
              • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Picked unit)) in PowerTable
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PowerReal[2] Less than PowerReal[3]
                • Then - Actions
                  • Unit - Set mana of PowerUnit[1] to (PowerReal[1] + PowerReal[2])
                  • Unit - Set mana of PowerUnit[2] to 0.00
                  • Lightning - Create a Spirit Link lightning effect from source PowerLoc[1] to target PowerLoc[2]
                  • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Picked unit)) in PowerTable
                • Else - Actions
                  • Unit - Set mana of PowerUnit[1] to (PowerReal[1] + PowerReal[3])
                  • Unit - Set mana of PowerUnit[2] to (PowerReal[2] - PowerReal[3])
                  • Lightning - Create a Drain Mana lightning effect from source PowerLoc[1] to target PowerLoc[2]
                  • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Picked unit)) in PowerTable
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of PowerUnit[1]) Equal to (Unit-type of PowerUnit[2])
            • Then - Actions
              • Lightning - Destroy (Load 2 of (Key (Picked unit)) in PowerTable)
              • Lightning - Create a Finger of Death lightning effect from source PowerLoc[1] to target PowerLoc[2]
              • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Picked unit)) in PowerTable
            • Else - Actions
          • Custom script: call RemoveLocation(udg_PowerLoc[1])
          • Custom script: call RemoveLocation(udg_PowerLoc[2])
Here you go...there are 3 triggers...

EDIT: thanks didnt know how to post this as text ^^
 
Last edited:
Level 7
Joined
Sep 19, 2012
Messages
204
...ok still couldnt figure out why this thing doesnt go away....

and i found another part...the spell to activate the connection has a maximum range, but once the connection is there, my unit can walk away and the connections doesnt get interrupted...

im happy that it works in general, but it would be cool if someone could help me fix the problems ^^
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Umm yea it is hard for me to read all these things but, if nobody is answering I want suggest something.

Last part of last trigger, there is a condition
  • If - Conditions
    • (Unit-type of PowerUnit[1]) Equal to (Unit-type of PowerUnit[2])
change this to

  • If - Conditions
    • (Unit-type of PowerUnit[1]) Equal to (Unit-type of PowerUnit[2]) or (PowerUnit[1] is dead equal to true) or (PowerUnit[2] is dead equal to true)
 
Level 7
Joined
Sep 19, 2012
Messages
204
Umm yea it is hard for me to read all these things but, if nobody is answering I want suggest something.

Last part of last trigger, there is a condition
  • If - Conditions
    • (Unit-type of PowerUnit[1]) Equal to (Unit-type of PowerUnit[2])
change this to

  • If - Conditions
    • (Unit-type of PowerUnit[1]) Equal to (Unit-type of PowerUnit[2]) or (PowerUnit[1] is dead equal to true) or (PowerUnit[2] is dead equal to true)

I tried it and it did nothing....another idea? ^^

EDIT: I hope Finally i posted my code correctly XD
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Ok suggestion 2, change last trigger's first part.

  • Power I Mana Drain
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PowerDummies and do (Actions)
        • Loop - Actions
          • Set PowerUnit[1] = (Load 0 of (Key (Picked unit)) in PowerTable)
          • Set PowerUnit[2] = (Load 1 of (Key (Picked unit)) in PowerTable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PowerUnit[1] is alive equal to false) or (PowerUnit[2] is alive equal to false)
            • Then - Actions
              • Lightning - Destroy (Load 2 of (Key (Picked unit)) in PowerTable)
              • Hashtable - Clear all child hashtables of child (Key (Picked Unit)) in PowerTable
              • Unit Group - remove (Picked unit) from PowerDummies
              • Skip remeaning actions
            • Else - Actions
          • Set PowerReal[1] = (Mana of PowerUnit[1])
          • Set PowerReal[2] = (Mana of PowerUnit[2])
          • Set PowerReal[3] = 5.00
          • Lightning - Destroy (Load 2 of (Key (Picked unit)) in PowerTable)
          • Set PowerLoc[1] = (Position of PowerUnit[2])
          • Set PowerLoc[2] = (Position of PowerUnit[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PowerReal[1] Greater than ((Max mana of PowerUnit[1]) - PowerReal[3])
            • Then - Actions
              • Unit - Set mana of PowerUnit[1] to (Max mana of PowerUnit[1])
              • Unit - Set mana of PowerUnit[2] to ((Mana of PowerUnit[2]) - ((Max mana of PowerUnit[1]) - PowerReal[1]))
              • Lightning - Create a Mana Burn lightning effect from source PowerLoc[1] to target PowerLoc[2]
              • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Picked unit)) in PowerTable
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PowerReal[2] Less than PowerReal[3]
                • Then - Actions
                  • Unit - Set mana of PowerUnit[1] to (PowerReal[1] + PowerReal[2])
                  • Unit - Set mana of PowerUnit[2] to 0.00
                  • Lightning - Create a Spirit Link lightning effect from source PowerLoc[1] to target PowerLoc[2]
                  • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Picked unit)) in PowerTable
                • Else - Actions
                  • Unit - Set mana of PowerUnit[1] to (PowerReal[1] + PowerReal[3])
                  • Unit - Set mana of PowerUnit[2] to (PowerReal[2] - PowerReal[3])
                  • Lightning - Create a Drain Mana lightning effect from source PowerLoc[1] to target PowerLoc[2]
                  • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Picked unit)) in PowerTable
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of PowerUnit[1]) Equal to (Unit-type of PowerUnit[2])
            • Then - Actions
              • Lightning - Destroy (Load 2 of (Key (Picked unit)) in PowerTable)
              • Lightning - Create a Finger of Death lightning effect from source PowerLoc[1] to target PowerLoc[2]
              • Hashtable - Save Handle Of(Last created lightning effect) as 2 of (Key (Picked unit)) in PowerTable
            • Else - Actions
          • Custom script: call RemoveLocation(udg_PowerLoc[1])
          • Custom script: call RemoveLocation(udg_PowerLoc[2])
 
Status
Not open for further replies.
Top