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

Skill cooldown reduce Help

Status
Not open for further replies.
Level 7
Joined
Oct 6, 2022
Messages
135
Hello guys, can I ask how to reduce the skills cooldown for everytime the unit cast that skill that reduces the cooldown of the skills.
If the caster didn't cast that skill within seconds, the skills cooldown would return to normal.

Hope anyone could help me with it, thanks in advance
 
This should work, but it will only work on one unit. If you need it to work on multiple units (MUI), it will be slightly more complicated.

You need two triggers. The first one triggers when the unit casts the spell and reduces the cooldown of each affected ability. I put 5 seconds here. You need to loop through the levels of the skill so that each gets affected. If I'm not mistaken and the GUI version works differently, you have to be careful, because the cooldown setting function takes indices from 0 to maximum level -1. So, for a standard hero skill, you would have to loop from 0 to 2.

Then you start a timer that resets the cooldowns when it expires and you do the same thing on your second trigger. It put 15 seconds on the timer here. The timer resets when the unit uses the ability again, so it should have the behavior you're going for.

  • Events
    • Unit - (yourUnit) Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to (yourCooldownReducingAbility)
  • Actions
    • Set VariableSet cooldownReduceAmount = (cooldownReduceAmount + 5)
    • For each (Integer A) from 0 to 2, do (Actions)
      • Loop - Actions
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility1), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility1), Level: (Integer A) - 5.)
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility2), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility2), Level: (Integer A) - 5.)
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility3), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility3), Level: (Integer A) - 5.)
    • Countdown Timer - Start cooldownResetTimer as a One-shot timer that will expire in 15.00 seconds
  • Events
    • Time - cooldownResetTimer expires
  • Conditions
  • Actions
    • For each (Integer A) from 0 to 2, do (Actions)
      • Loop - Actions
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility1), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility1), Level: (Integer A) + cooldownReduceAmount.)
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility2), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility2), Level: (Integer A) + cooldownReduceAmount.)
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility3), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility3), Level: (Integer A) + cooldownReduceAmount.)
    • Set VariableSet cooldownReduceAmount = 0
 
Level 7
Joined
Oct 6, 2022
Messages
135
This should work, but it will only work on one unit. If you need it to work on multiple units (MUI), it will be slightly more complicated.

You need two triggers. The first one triggers when the unit casts the spell and reduces the cooldown of each affected ability. I put 5 seconds here. You need to loop through the levels of the skill so that each gets affected. If I'm not mistaken and the GUI version works differently, you have to be careful, because the cooldown setting function takes indices from 0 to maximum level -1. So, for a standard hero skill, you would have to loop from 0 to 2.

Then you start a timer that resets the cooldowns when it expires and you do the same thing on your second trigger. It put 15 seconds on the timer here. The timer resets when the unit uses the ability again, so it should have the behavior you're going for.

  • Events
    • Unit - (yourUnit) Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to (yourCooldownReducingAbility)
  • Actions
    • Set VariableSet cooldownReduceAmount = (cooldownReduceAmount + 5)
    • For each (Integer A) from 0 to 2, do (Actions)
      • Loop - Actions
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility1), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility1), Level: (Integer A) - 5.)
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility2), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility2), Level: (Integer A) - 5.)
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility3), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility3), Level: (Integer A) - 5.)
    • Countdown Timer - Start cooldownResetTimer as a One-shot timer that will expire in 15.00 seconds
  • Events
    • Time - cooldownResetTimer expires
  • Conditions
  • Actions
    • For each (Integer A) from 0 to 2, do (Actions)
      • Loop - Actions
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility1), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility1), Level: (Integer A) + cooldownReduceAmount.)
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility2), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility2), Level: (Integer A) + cooldownReduceAmount.)
        • Unit - For Unit (yourUnit), Set cooldown of ability (affectedAbility3), Level: (Integer A) to (Ability Cooldown of (yourUnit) for ability (affectedAbility3), Level: (Integer A) + cooldownReduceAmount.)
    • Set VariableSet cooldownReduceAmount = 0
Should I leave those "Integer A" or I should also change it?
 
Level 7
Joined
Jun 1, 2009
Messages
104
I must warn you, better use a custom integer than Blizz' InregerA.
If there is more than one trigger using Blizzard's default InregerA variable - weird things can happen.

I've got a headache for a week some time ago, trying to understand why TF triggers loop ain't working (For Loop - IntegerA counted only to 1 sometimes).
Blizz' IntegerA is a global variable, so one trigger may reset it during another trigger loop.
 
When you have complicated scripts, this can easily happen and is a good reason to not reuse the same loop integer multiple times in those cases. However, this has nothing to do specifically with the Blizzard's default loop integers.

In the above case, I see no threat that a bug like that would occur.
 
Level 39
Joined
Feb 27, 2007
Messages
5,011
What's the solution to to it?
Ensure that no trigger in your map that uses an Integer loop can cause any other trigger with the same Integer loop to activate while the ‘first’ loop is executing.

For example: if trigger X runs when units enter the map and uses an Int A loop, creating trigger Y that uses an Int A loop to spawn units on the map will be an issue. If trigger Y uses an Int A loop but doesn’t spawn the units until after the loop has completed then there would be no conflict.
 
Level 7
Joined
Jun 1, 2009
Messages
104
What's the solution to to it?
Each trigger with
  • For each (Integer X) from 1 to 10, do (Actions)
    • Loop - Actions
should have its personal integer X.

Yup, this could leave your map with lots of integers, but otherwise - prepare for unexpected glitches.

Ofc, you can use the same integer X in multiple triggers, but you must be 200% sure they won't run at the same time!
 
Status
Not open for further replies.
Top