• 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 to decrease ability cooldown

Level 13
Joined
Sep 25, 2013
Messages
717
This trigger works at least half the time. It is meant to decrease the cooldown of the "frostbolt" ability when used on non-hero units to 4 seconds. When used on hero units this cooldown reduction shouldn't occur and the ability should have default cooldown of 12 seconds. For some reason when using this ability on heroes, the trigger sets the cooldown to 4 seconds even though that should only occur when targeting non-hero units. I am baffled.

  • Frost Bolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt (Saruman)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is A Hero) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Frostbolt (Saruman) for (Triggering unit)) Equal to 1
            • Then - Actions
              • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 0 to 4.00
              • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 60.00)
              • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Frostbolt (Saruman) for (Triggering unit)) Equal to 2
                • Then - Actions
                  • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 1 to 4.00
                  • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 60.00)
                  • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                  • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                  • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Frostbolt (Saruman) for (Triggering unit)) Equal to 3
                    • Then - Actions
                      • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 2 to 4.00
                      • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 60.00)
                      • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                      • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
                    • Else - Actions
        • Else - Actions
 
Last edited:
Level 14
Joined
Jan 10, 2023
Messages
248
I haven't tested, but I think the solution would be replacing these actions:
  • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 0 to 4.00
  • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 1 to 4.00
  • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 2 to 4.00
This is the action I think you want:
  • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
The difference is that the one I shared sets the cooldown this time only while the one you are using permanently changes the ability' cooldown for that unit. When the ability levels up, it is no longer 4.00 seconds on the cooldown (for that level) until the ability is cast on a hero again.

Also, you don't need to worry about the level unless that 4.00 seconds is going to change with each level or any of the other things will change, like the mana refund or the floating text, so you won't need the conditional hierarchy:
  • Frost Bolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt (Saruman)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is A Hero) Equal to False
        • Then - Actions
          • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 60.00)
          • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
        • Else - Actions
If you did need to change those values depending on the level, then I would use the conditional statements per level as you have done, but still use the action I shared:
  • Frost Bolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt (Saruman)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is A Hero) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Frostbolt (Saruman) for (Triggering unit)) Equal to 1
            • Then - Actions
              • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
              • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 60.00)
              • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Frostbolt (Saruman) for (Triggering unit)) Equal to 2
                • Then - Actions
                  • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "3.50 seconds.
                  • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 65.00)
                  • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                  • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                  • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Frostbolt (Saruman) for (Triggering unit)) Equal to 3
                    • Then - Actions
                      • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "3.00 seconds.
                      • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 70.00)
                      • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                      • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
                    • Else - Actions
        • Else - Actions
 
Level 13
Joined
Sep 25, 2013
Messages
717
When cast on a non-hero unit the very first time, does it get the correct 4.00 second cooldown?
It always works when casting on a non-hero unit, but when casting on a hero it half the time gets set to the 4 second cooldown even though that should only occur when casting on non-hero units. I wasn't very clear on my post about the problem, sorry about that
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,875
It always works when casting on a non-hero unit, but when casting on a hero it half the time gets set to the 4 second cooldown even though that should only occur when casting on non-hero units. I wasn't very clear on my post about the problem, sorry about that
It's a permanent change. You need to set it back to 12.00 when it targets a Hero.

But what Tristronic said about Starting the cooldown manually makes more sense as a proper solution.

Default cooldown is always = 12.00 seconds.
When targeting a Hero -> Do nothing, the default cooldown will be used.
When targeting a non-Hero -> Force it on cooldown starting at 4.00 seconds.

There's a big difference between these two Actions:
  • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 0 to 4.00
  • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
 
Level 13
Joined
Sep 25, 2013
Messages
717
I haven't tested, but I think the solution would be replacing these actions:
  • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 0 to 4.00
  • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 1 to 4.00
  • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 2 to 4.00
This is the action I think you want:
  • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
The difference is that the one I shared sets the cooldown this time only while the one you are using permanently changes the ability' cooldown for that unit. When the ability levels up, it is no longer 4.00 seconds on the cooldown (for that level) until the ability is cast on a hero again.

Also, you don't need to worry about the level unless that 4.00 seconds is going to change with each level or any of the other things will change, like the mana refund or the floating text, so you won't need the conditional hierarchy:
  • Frost Bolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt (Saruman)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is A Hero) Equal to False
        • Then - Actions
          • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 60.00)
          • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
        • Else - Actions
If you did need to change those values depending on the level, then I would use the conditional statements per level as you have done, but still use the action I shared:
  • Frost Bolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt (Saruman)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is A Hero) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Frostbolt (Saruman) for (Triggering unit)) Equal to 1
            • Then - Actions
              • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
              • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 60.00)
              • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Frostbolt (Saruman) for (Triggering unit)) Equal to 2
                • Then - Actions
                  • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "3.50 seconds.
                  • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 65.00)
                  • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                  • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                  • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Frostbolt (Saruman) for (Triggering unit)) Equal to 3
                    • Then - Actions
                      • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "3.00 seconds.
                      • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 70.00)
                      • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
                      • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
                    • Else - Actions
        • Else - Actions
I had the same thoughts as you on this. I had tried this other action that you have pointed out but it doesn't do anything strangely. Like, when targeting a non-hero unit it doesn't start the cooldown at 4 seconds. I'll keep fiddling with it and see if I can figure something out. Thank you for helping though!
 
Level 13
Joined
Sep 25, 2013
Messages
717
It's a permanent change. You need to set it back to 12.00 when it targets a Hero.

But what Tristronic said about Starting the cooldown manually makes more sense as a proper solution.

Default cooldown is always = 12.00 seconds.
When targeting a Hero -> Do nothing, the default cooldown will be used.
When targeting a non-Hero -> Force it on cooldown starting at 4.00 seconds.

There's a big difference between these two Actions:
  • Unit - For Unit (Triggering unit), Set cooldown of ability Frostbolt (Saruman), Level: 0 to 4.00
  • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
Thats a good idea about simply reverting the cooldown back to 12 seconds when targeting a hero. I'll try that!
 
Level 14
Joined
Jan 10, 2023
Messages
248
I had the same thoughts as you on this. I had tried this other action that you have pointed out but it doesn't do anything strangely. Like, when targeting a non-hero unit it doesn't start the cooldown at 4 seconds. I'll keep fiddling with it and see if I can figure something out. Thank you for helping though!
I overlooked that when you start the effect of an ability, it hasn't yet started its cooldown, this would work if you add a wait for 0.00 seconds before setting the cooldown:
  • Frost Bolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt (Saruman)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is A Hero) Equal to False
        • Then - Actions
          • Wait 0.00 seconds
          • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 60.00)
          • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
        • Else - Actions
 
Level 13
Joined
Sep 25, 2013
Messages
717
I overlooked that when you start the effect of an ability, it hasn't yet started its cooldown, this would work if you add a wait for 0.00 seconds before setting the cooldown:
  • Frost Bolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frostbolt (Saruman)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is A Hero) Equal to False
        • Then - Actions
          • Wait 0.00 seconds
          • Unit - For Unit (Triggering unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
          • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 60.00)
          • Floating Text - Create floating text that reads +60 above (Triggering unit) with Z offset -100.00, using font size 10.00, color (30.00%, 50.00%, 100.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards 90.00 degrees
        • Else - Actions
AH! I never use waits cause I figure that even with 0.00 seconds it still wouldn't be mui, so this is surprising to me! I will try it, thank you!
 
Level 14
Joined
Jan 10, 2023
Messages
248
You should be safe in this case because we are using "triggering unit" (safe because it is a native "GetTriggeringUnit()" function) and when we use "last created floating text" there is no wait between the references. It is normally not safe to do a wait between creating something and using its respective "last created..." variable because it is a "last created" VARIABLE that could have been reset since we created the object we might think it would reference.
 
Level 24
Joined
Feb 27, 2019
Messages
833
Theres an alternative method to delay actions by using a timer. Its much faster than a wait, unless per heaps one is using LUA but I dont know.
  • Unit Group - Add (Triggering unit) to FB_FrameGroup.
  • Countdown Timer - Start FB_FrameTimer as a One-shot timer that will expire in 0.00 seconds
  • Frost Bolt CD
    • Events
      • Time - FB_FrameTimer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in FB_FrameGroup and do (Actions)
        • Loop - Actions
          • Unit - For Unit (Picked unit), start cooldown of ability Frostbolt (Saruman) " over "4.00 seconds.
          • Unit Group - Remove (Picked unit) from FB_FrameGroup.
 
Top