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

[Solved] Trigger breaks when clearing leak

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
Hi,

So this trigger worked completely fine until today, where it seems to have had a fit and doesn't work properly. Throughout lots of testing I've worked out that if I clean the location leak of "TempPoint2" the trigger no longer works, it looses the "Sprint_Point" somehow which screws up the mana cost. I've taken out the custom script to clean the leak and it works, I'm assuming I'll need to put it back in?? Any ideas?

  • Periodic Sprint Check
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Sprint_LoopIndex) from 1 to Sprint_MaxIndex, do (Actions)
        • Loop - Actions
          • Set TempPoint2 = (Position of Sprint_Unit[Sprint_LoopIndex])
          • Cinematic - Ping minimap for (All players) at Sprint_Point[Sprint_LoopIndex] for 1.00 seconds
          • Set TempReal = (Distance between TempPoint2 and Sprint_Point[Sprint_LoopIndex])
          • Set TempReal = (TempReal / 25.00)
          • Custom script: call RemoveLocation(udg_Sprint_Point[udg_Sprint_LoopIndex])
          • Set Sprint_Point[Sprint_LoopIndex] = TempPoint2
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Sprint_Unit[Sprint_LoopIndex] is alive) Equal to True
              • (Mana of Sprint_Unit[Sprint_LoopIndex]) Greater than or equal to TempReal
            • Then - Actions
              • Unit - Set mana of Sprint_Unit[Sprint_LoopIndex] to ((Mana of Sprint_Unit[Sprint_LoopIndex]) - TempReal)
            • Else - Actions
              • Unit - Remove Spell Book (Sprint) from Sprint_Unit[Sprint_LoopIndex]
              • Unit - Remove Sprint buff from Sprint_Unit[Sprint_LoopIndex]
              • Unit - Remove Sprint (Immolation) buff from Sprint_Unit[Sprint_LoopIndex]
              • Custom script: call RemoveLocation(udg_Sprint_Point[udg_Sprint_LoopIndex])
              • Set Sprint_Point[Sprint_LoopIndex] = Sprint_Point[Sprint_MaxIndex]
              • Set Sprint_Unit[Sprint_LoopIndex] = Sprint_Unit[Sprint_MaxIndex]
              • Set Sprint_MaxIndex = (Sprint_MaxIndex - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Sprint_MaxIndex Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
                  • Set Sprint_LoopIndex = (Sprint_LoopIndex - 1)
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Set Sprint_Point[Sprint_LoopIndex] = TempPoint2 means that Sprint_Point[Sprint_LoopIndex] is the same point as TempPoint2. If you remove it, both are removed.
it is similar to:
Set Unit1 = Triggering Unit
Set Unit2 = Unit1
Remove Unit1

Unit2 is removed as well, as it is the same unit

To clear the leak you only have to remove one obviously.
In general if clearing leaks cause your trigger to no longer work, you are doing something wrong, as the point/group or whatever leak you are trying to clear is still used and should not be destroyed yet. You have to destroy it later.

As long as you clear Sprint_Point[Sprint_LoopIndex], you don't have to worry about TempPoint2 in this trigger.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Oh I didn't know that, thought as I was getting them twice I'd have to clear it twice. Well you learn something new every day! Thanks!
This is because it is a reference to an object being stored in the variable and not the object itself. If it was the object itself there would not be any problems with leaks as all memory required would be allocated and managed by the variable.
 
Status
Not open for further replies.
Top