• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Does this leak anywhere?

Status
Not open for further replies.
Level 5
Joined
Jan 17, 2014
Messages
131
Hi everyone. Can you please look at my triggers and tell me if something leaks. Thank you in advance.

  • Earth Shield Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 16, do (Actions)
        • Loop - Actions
          • Player - Disable Earth Shield Buff Holder (ivo) for (Player((Integer A)))
  • Earth Shield Start Units
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Trigger - Add to Earth Shield <gen> the event (Unit - (Picked unit) Takes damage))
  • Earth Shield New Units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Earth Shield <gen> the event (Unit - (Triggering unit) Takes damage)
  • Earth Shield Cast 1 Target
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Earth Shield (ivo)
    • Actions
      • For each (Integer A) from 1 to 16, do (Actions)
        • Loop - Actions
          • If ((Target unit of ability being cast) Equal to ES_Cast_Target[(Integer A)]) then do (Set ES_Cast_Target[(Integer A)] = No unit) else do (Do nothing)
      • For each (Integer A) from 1 to 16, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to (Player((Integer A)))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Earth Shield Buff (ivo) for ES_Cast_Target[(Integer A)]) Greater than or equal to 1
                • Then - Actions
                  • Unit - Remove Earth Shield Buff Holder (ivo) from ES_Cast_Target[(Integer A)]
                  • Unit - Remove Earth Shield (ivo) buff from ES_Cast_Target[(Integer A)]
                • Else - Actions
                  • Do nothing
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Earth Shield Buff (ivo) for (Target unit of ability being cast)) Greater than or equal to 1
                • Then - Actions
                  • Unit - Remove Earth Shield Buff Holder (ivo) from (Target unit of ability being cast)
                  • Unit - Remove Earth Shield (ivo) buff from (Target unit of ability being cast)
                • Else - Actions
                  • Do nothing
              • Set ES_Cast_Target[(Integer A)] = (Target unit of ability being cast)
              • Unit - Add Earth Shield Buff Holder (ivo) to ES_Cast_Target[(Integer A)]
              • Unit - Set level of Earth Shield Buff (ivo) for ES_Cast_Target[(Integer A)] to 10
              • Unit - Remove Earth Shield (ivo) buff from ES_Cast_Target[(Integer A)]
            • Else - Actions
              • Do nothing
  • Earth Shield
    • Events
    • Conditions
      • (Level of Earth Shield Buff (ivo) for (Triggering unit)) Greater than or equal to 1
      • (Damage taken) Greater than 0.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Earth Shield Buff (ivo) for (Triggering unit)) Greater than 1
        • Then - Actions
          • Set ES_Chance = (Random integer number between 1 and 5)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ES_Chance Equal to 5
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Life of (Triggering unit)) Greater than (Damage taken)
                • Then - Actions
                  • Set ES_Index = (ES_Index + 1)
                  • Set ES_Heal_Target[ES_Index] = (Triggering unit)
                  • If ((Earth Shield Timer <gen> is on) Equal to False) then do (Trigger - Turn on Earth Shield Timer <gen>) else do (Do nothing)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Life of (Triggering unit)) Less than or equal to (Damage taken)
                    • Then - Actions
                      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Human\Heal\HealTarget.mdl
                      • Set ES_Special_Effect_Index = (ES_Special_Effect_Index + 1)
                      • Set ES_Special_Effect[ES_Special_Effect_Index] = (Last created special effect)
                      • Set ES_Special_Effect_Timer[ES_Special_Effect_Index] = 4.00
                      • If ((Earth Shield Special Effect Destroyer <gen> is on) Equal to False) then do (Trigger - Turn on Earth Shield Special Effect Destroyer <gen>) else do (Do nothing)
                      • Unit - Set life of (Triggering unit) to ((Percentage life of (Triggering unit)) + 10.00)%
                      • Unit - Decrease level of Earth Shield Buff (ivo) for (Triggering unit)
                      • Unit - Remove Earth Shield (ivo) buff from (Triggering unit)
                    • Else - Actions
                      • Do nothing
            • Else - Actions
              • Do nothing
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Earth Shield Buff (ivo) for (Triggering unit)) Equal to 1
            • Then - Actions
              • Set ES_Chance = (Random integer number between 1 and 5)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ES_Chance Equal to 5
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Life of (Triggering unit)) Greater than (Damage taken)
                    • Then - Actions
                      • Set ES_Index = (ES_Index + 1)
                      • Set ES_Heal_Target[ES_Index] = (Triggering unit)
                      • If ((Earth Shield Timer <gen> is on) Equal to False) then do (Trigger - Turn on Earth Shield Timer <gen>) else do (Do nothing)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Life of (Triggering unit)) Less than or equal to (Damage taken)
                        • Then - Actions
                          • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Human\Heal\HealTarget.mdl
                          • Set ES_Special_Effect_Index = (ES_Special_Effect_Index + 1)
                          • Set ES_Special_Effect[ES_Special_Effect_Index] = (Last created special effect)
                          • Set ES_Special_Effect_Timer[ES_Special_Effect_Index] = 4.00
                          • If ((Earth Shield Special Effect Destroyer <gen> is on) Equal to False) then do (Trigger - Turn on Earth Shield Special Effect Destroyer <gen>) else do (Do nothing)
                          • Unit - Set life of (Triggering unit) to ((Percentage life of (Triggering unit)) + 10.00)%
                          • Unit - Remove Earth Shield Buff Holder (ivo) from (Triggering unit)
                          • Unit - Remove Earth Shield (ivo) buff from (Triggering unit)
                        • Else - Actions
                          • Do nothing
                • Else - Actions
                  • Do nothing
            • Else - Actions
              • Do nothing
  • Earth Shield Timer
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer ES_Integer) from 1 to ES_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Earth Shield Buff (ivo) for ES_Heal_Target[ES_Integer]) Greater than 1
            • Then - Actions
              • Special Effect - Create a special effect attached to the origin of ES_Heal_Target[ES_Integer] using Abilities\Spells\Human\Heal\HealTarget.mdl
              • Set ES_Special_Effect_Index = (ES_Special_Effect_Index + 1)
              • Set ES_Special_Effect[ES_Special_Effect_Index] = (Last created special effect)
              • Set ES_Special_Effect_Timer[ES_Special_Effect_Index] = 4.00
              • If ((Earth Shield Special Effect Destroyer <gen> is on) Equal to False) then do (Trigger - Turn on Earth Shield Special Effect Destroyer <gen>) else do (Do nothing)
              • Unit - Set life of ES_Heal_Target[ES_Integer] to ((Percentage life of ES_Heal_Target[ES_Integer]) + 10.00)%
              • Unit - Decrease level of Earth Shield Buff (ivo) for ES_Heal_Target[ES_Integer]
              • Unit - Remove Earth Shield (ivo) buff from ES_Heal_Target[ES_Integer]
              • Set ES_Heal_Target[ES_Integer] = ES_Heal_Target[ES_Index]
              • Set ES_Index = (ES_Index - 1)
              • Set ES_Integer = (ES_Integer - 1)
              • If (ES_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Earth Shield Buff (ivo) for ES_Heal_Target[ES_Integer]) Equal to 1
                • Then - Actions
                  • Special Effect - Create a special effect attached to the origin of ES_Heal_Target[ES_Integer] using Abilities\Spells\Human\Heal\HealTarget.mdl
                  • Set ES_Special_Effect_Index = (ES_Special_Effect_Index + 1)
                  • Set ES_Special_Effect[ES_Special_Effect_Index] = (Last created special effect)
                  • Set ES_Special_Effect_Timer[ES_Special_Effect_Index] = 4.00
                  • If ((Earth Shield Special Effect Destroyer <gen> is on) Equal to False) then do (Trigger - Turn on Earth Shield Special Effect Destroyer <gen>) else do (Do nothing)
                  • Unit - Set life of ES_Heal_Target[ES_Integer] to ((Percentage life of ES_Heal_Target[ES_Integer]) + 10.00)%
                  • Unit - Remove Earth Shield Buff Holder (ivo) from ES_Heal_Target[ES_Integer]
                  • Unit - Remove Earth Shield (ivo) buff from ES_Heal_Target[ES_Integer]
                  • Set ES_Heal_Target[ES_Integer] = ES_Heal_Target[ES_Index]
                  • Set ES_Index = (ES_Index - 1)
                  • Set ES_Integer = (ES_Integer - 1)
                  • If (ES_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
                • Else - Actions
                  • Do nothing
  • Earth Shield Special Effect Destroyer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer ES_Special_Effect_Integer) from 1 to ES_Special_Effect_Index, do (Actions)
        • Loop - Actions
          • Set ES_Special_Effect_Timer[ES_Special_Effect_Integer] = (ES_Special_Effect_Timer[ES_Special_Effect_Integer] - 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ES_Special_Effect_Timer[ES_Special_Effect_Integer] Equal to 0.00
            • Then - Actions
              • Special Effect - Destroy ES_Special_Effect[ES_Special_Effect_Integer]
              • Set ES_Special_Effect[ES_Integer] = ES_Special_Effect[ES_Special_Effect_Index]
              • Set ES_Special_Effect_Timer[ES_Special_Effect_Integer] = ES_Special_Effect_Timer[ES_Special_Effect_Index]
              • Set ES_Special_Effect_Index = (ES_Special_Effect_Index - 1)
              • Set ES_Special_Effect_Integer = (ES_Special_Effect_Integer - 1)
              • If (ES_Special_Effect_Index Equal to 0) then do (Trigger - Turn off (This trigger)) else do (Do nothing)
            • Else - Actions
              • Do nothing
 
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Trigger - Add to Earth Shield <gen> the event (Unit - (Picked unit) Takes damage))
^Leak.

I'm not sure if you leak effects. Didn't read in detail.
If you can ensure you destroy all effects created on unit you don't leak.

  • Time - Every 0.00 seconds of game time
Don't do. It's to resource consuming. I don't know if you can even play the map, if conditions are true.

Don't use "Do nothing" action. It just does nothing, and you never need it.

I advice you to read this: http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/memory-leaks-263410/#post2661133
 
Level 5
Joined
Jan 17, 2014
Messages
131
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Trigger - Add to Earth Shield <gen> the event (Unit - (Picked unit) Takes damage))
^Leak.

I'm not sure if you leak effects. Didn't read in detail.
If you can ensure you destroy all effects created on unit you don't leak.

  • Time - Every 0.00 seconds of game time
Don't do. It's to resource consuming. I don't know if you can even play the map, if conditions are true.

Don't use "Do nothing" action. It just does nothing, and you never need it.

I advice you to read this: http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/memory-leaks-263410/#post2661133

1. Special Effects are destroyed after a few seconds.
2. "Time - Every 0.00 seconds" - This trigger turns on to run once, then it goes back off until it needs to be turned on again. It's not instantly on.
3. "Pick up units" Can I fix that by making it a variable and then destroy it?
 
Status
Not open for further replies.
Top