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

Just can't find the leak [MUI]

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
After casting the ability 2 times it just doesn't work. At first the location wasn't stored in an array so thought it was the issue, but it did not fix it so I am out of ideas.
  • Healing Surge
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Healing Surge (Level 1)
    • Actions
      • Set HealingSurge_Temp = (HealingSurge_Temp + 1)
      • Set HealingSurge_Caster[HealingSurge_Temp] = (Triggering unit)
      • Set HealingSurge_Target[HealingSurge_Temp] = (Target unit of ability being cast)
      • Set HealingSurge_TempPoint[HealingSurge_Temp] = (Position of HealingSurge_Target[HealingSurge_Temp])
      • Set HealingSurge_Count[HealingSurge_Temp] = 10
      • Unit - Create 1 Dummy Unit for (Owner of HealingSurge_Caster[HealingSurge_Temp]) at HealingSurge_TempPoint[HealingSurge_Temp] facing Default building facing degrees
      • Set TempDummy = (Last created unit)
      • Unit - Add a 1.00 second Generic expiration timer to TempDummy
      • Unit - Add Healing Surge Initial Cast (Dummy Cast, Heal) to TempDummy
      • Unit - Order TempDummy to Human Priest - Heal HealingSurge_Target[HealingSurge_Temp]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HealingSurge_Temp Equal to 1
        • Then - Actions
          • Trigger - Turn on Healing Surge Effect <gen>
        • Else - Actions
  • Healing Surge Effect
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer HealingSurge_LoopInteger) from 1 to HealingSurge_Temp, do (Actions)
        • Loop - Actions
          • Set HealingSurge_Count[HealingSurge_LoopInteger] = (HealingSurge_Count[HealingSurge_LoopInteger] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HealingSurge_Count[HealingSurge_LoopInteger] Greater than or equal to 0
            • Then - Actions
              • Set HealingSurge_TempPoint[HealingSurge_LoopInteger] = (Position of HealingSurge_Target[HealingSurge_LoopInteger])
              • Unit - Create 1 Dummy Unit for (Owner of HealingSurge_Caster[HealingSurge_LoopInteger]) at HealingSurge_TempPoint[HealingSurge_LoopInteger] facing Default building facing degrees
              • Set TempDummy = (Last created unit)
              • Unit - Add a 1.00 second Generic expiration timer to TempDummy
              • Unit - Add Healing Surge Tick (Dummy Cast) to TempDummy
              • Unit - Order TempDummy to Human Paladin - Holy Light HealingSurge_Target[HealingSurge_LoopInteger]
              • Custom script: call RemoveLocation (udg_HealingSurge_TempPoint[udg_HealingSurge_LoopInteger])
            • Else - Actions
              • Set HealingSurge_Caster[HealingSurge_LoopInteger] = HealingSurge_Caster[HealingSurge_Temp]
              • Set HealingSurge_Target[HealingSurge_LoopInteger] = HealingSurge_Target[HealingSurge_Temp]
              • Set HealingSurge_Count[HealingSurge_LoopInteger] = HealingSurge_Count[HealingSurge_Temp]
              • Set HealingSurge_LoopInteger = (HealingSurge_LoopInteger - 1)
              • Set HealingSurge_Temp = (HealingSurge_Temp - 1)
              • Custom script: call RemoveLocation (udg_HealingSurge_TempPoint[udg_HealingSurge_Temp])
              • Trigger - Turn off (This trigger)
 
Level 8
Joined
May 21, 2019
Messages
435
There's a lot going on in these triggers, and I'm not certain that most of it is strictly speaking necessary.
The first thing that catches my eye is HealingSurge_Temp.
You increment it by +1 when the ability is cast, which makes it seem like "Temp" is your index for the ability cast, but then you only turn on the periodic if Temp is equal to 1. In the periodic trigger, you are decrementing Temp by -1, regardless of its current value. This means, that when the ability is cast the first time, Temp becomes 1. Then when it's cast the second time before the first loop finishes, it becomes 2, but no new loop is started. This means that once the first cast finishes its count, it turns off the periodic trigger, the second cast will not finish its loops, and your Temp variable is now "1".

So, that leaves you with the second cast being cut short on its count, and a temp variable that is now 1.
So, when you cast the spell a third time, the temp variable is set to 2. However, this means that the first variable will no longer turn on the periodic trigger, as the temp is not equal to 1, but 2... on your 4th cast... it will be 3... and so on... the periodic will never run again.

Try this for a solution:
At the very end of the second trigger, make a new "If" block, with the condition "If HealingSurge_Temp = 0", and then throw the "turn off this trigger" into that. This will prevent the periodic trigger from turning itself off, while there are still active loops running, and thus prevent it from locking itself out.
 
Level 12
Joined
Feb 5, 2018
Messages
521
Try this for a solution:
At the very end of the second trigger, make a new "If" block, with the condition "If HealingSurge_Temp = 0", and then throw the "turn off this trigger" into that. This will prevent the periodic trigger from turning itself off, while there are still active loops running, and thus prevent it from locking itself out.

  • Healing Surge Effect
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer HealingSurge_LoopInteger) from 1 to HealingSurge_Temp, do (Actions)
        • Loop - Actions
          • Set HealingSurge_Count[HealingSurge_LoopInteger] = (HealingSurge_Count[HealingSurge_LoopInteger] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HealingSurge_Count[HealingSurge_LoopInteger] Greater than or equal to 0
            • Then - Actions
              • Set HealingSurge_TempPoint[HealingSurge_LoopInteger] = (Position of HealingSurge_Target[HealingSurge_LoopInteger])
              • Unit - Create 1 Dummy Unit for (Owner of HealingSurge_Caster[HealingSurge_LoopInteger]) at HealingSurge_TempPoint[HealingSurge_LoopInteger] facing Default building facing degrees
              • Set TempDummy = (Last created unit)
              • Unit - Add a 1.00 second Generic expiration timer to TempDummy
              • Unit - Add Healing Surge Tick (Dummy Cast) to TempDummy
              • Unit - Order TempDummy to Human Paladin - Holy Light HealingSurge_Target[HealingSurge_LoopInteger]
              • Custom script: call RemoveLocation (udg_HealingSurge_TempPoint[udg_HealingSurge_LoopInteger])
            • Else - Actions
              • Set HealingSurge_Caster[HealingSurge_LoopInteger] = HealingSurge_Caster[HealingSurge_Temp]
              • Set HealingSurge_Target[HealingSurge_LoopInteger] = HealingSurge_Target[HealingSurge_Temp]
              • Set HealingSurge_Count[HealingSurge_LoopInteger] = HealingSurge_Count[HealingSurge_Temp]
              • Set HealingSurge_LoopInteger = (HealingSurge_LoopInteger - 1)
              • Set HealingSurge_Temp = (HealingSurge_Temp - 1)
              • Custom script: call RemoveLocation (udg_HealingSurge_TempPoint[udg_HealingSurge_Temp])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HealingSurge_Temp Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
SOLVED, thanks for help! =)
+Rep :)
 
Last edited:
Level 8
Joined
May 21, 2019
Messages
435
SOLVED, thanks for help! =)
+Rep :)
Glad it worked. :)
On a minor note, if you drag the new "If" block up underneath the "else" block above it, the if block will only run when a count expires, rather than once every second. It's a minor thing that isn't going to impact performance at all, but I figured I'd let you know for future scenarios, in which the optimisation might be significant. :)
 
Status
Not open for further replies.
Top