1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Just can't find the leak [MUI]

Discussion in 'Triggers & Scripts' started by DoomBlade, Aug 21, 2019.

  1. DoomBlade

    DoomBlade

    Joined:
    Feb 5, 2018
    Messages:
    21
    Resources:
    0
    Resources:
    0
    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)
     
  2. Cespie

    Cespie

    Joined:
    May 21, 2019
    Messages:
    344
    Resources:
    0
    Resources:
    0
    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.
     
  3. DoomBlade

    DoomBlade

    Joined:
    Feb 5, 2018
    Messages:
    21
    Resources:
    0
    Resources:
    0
    • 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: Aug 21, 2019
  4. Cespie

    Cespie

    Joined:
    May 21, 2019
    Messages:
    344
    Resources:
    0
    Resources:
    0
    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. :)