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

[Trigger] Cooldown Reduction Aura. Is it possible?

Level 14
Joined
Jul 19, 2007
Messages
772
I would really like to have an aura in my map that reduces the spell cooldown of all friendly units affected by the aura by 15/25/35/45%. I have no idéa how to do this. I know there is some systems for cooldown reduction but is it possible to make an aura of it?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
This can be done on version 1.31+. Here's a rough idea with triggers that I'm writing from memory:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Triggering unit has AuraBuff) Equal to True
  • Actions
    • Set Variable AuraFactor = (0.05 + (0.10 x Level of Aura))
    • Start cooldown of ability being cast = Cooldown of ability being cast x (1.00 - AuraFactor)
AuraFactor is a Real variable set to 0.15/0.25/0.35/0.45 depending on the level of the Aura.

Unfortunately, there's no function to get the Level of a Buff which is really stupid. So you'll need to figure out how to get the Level of the Aura.

This can be done by giving the Aura different Buff Types at each Level so you can differentiate between them:
  • Actions
    • If (Triggering unit has AuraBuff (Lvl 1)) Equal to True then Set Variable AuraFactor = 0.15
    • If (Triggering unit has AuraBuff (Lvl 2)) Equal to True then Set Variable AuraFactor = 0.25
    • If (Triggering unit has AuraBuff (Lvl 3)) Equal to True then Set Variable AuraFactor = 0.35
    • If (Triggering unit has AuraBuff (Lvl 4)) Equal to True then Set Variable AuraFactor = 0.45
    • Start cooldown of ability being cast = Cooldown of ability being cast x (1.00 - AuraFactor)
 
Level 14
Joined
Jul 19, 2007
Messages
772
This can be done on version 1.31+. Here's a rough idea with triggers that I'm writing from memory:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Triggering unit has AuraBuff) Equal to True
  • Actions
    • Set Variable AuraFactor = (0.05 + (0.10 x Level of Aura))
    • Start cooldown of ability being cast = Cooldown of ability being cast x (1.00 - AuraFactor)
AuraFactor is a Real variable set to 0.15/0.25/0.35/0.45 depending on the level of the Aura.

Unfortunately, there's no function to get the Level of a Buff which is really stupid. So you'll need to figure out how to get the Level of the Aura.

This can be done by giving the Aura different Buff Types at each Level so you can differentiate between them:
  • Actions
    • If (Triggering unit has AuraBuff (Lvl 1)) Equal to True then Set Variable AuraFactor = 0.15
    • If (Triggering unit has AuraBuff (Lvl 2)) Equal to True then Set Variable AuraFactor = 0.25
    • If (Triggering unit has AuraBuff (Lvl 3)) Equal to True then Set Variable AuraFactor = 0.35
    • If (Triggering unit has AuraBuff (Lvl 4)) Equal to True then Set Variable AuraFactor = 0.45
    • Start cooldown of ability being cast = Cooldown of ability being cast x (1.00 - AuraFactor)
Hmm but what about if an unit/hero has a spell already on cooldown and then enters the aura and get the aura buff, will the cooldown of that spell instantly be faster or will it only happen if the spell is casted during it has the aura buff? Would you mind making a spellpack for me?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
No, the cooldown won't instantly be faster. The Event is "whenever a unit casts an ability" so the Actions will only occur when that happens. Speeding up the cooldown dynamically like that adds some complications that I'm not really in the mood to try and get to work - I would just avoid that mechanic.

Perhaps someone else would be willing to make the spellpack, I'm busy at the moment.
 
Level 14
Joined
Jul 19, 2007
Messages
772
No, the cooldown won't instantly be faster. The Event is "whenever a unit casts an ability" so the Actions will only occur when that happens. Speeding up the cooldown dynamically like that adds some complications that I'm not really in the mood to try and get to work - I would just avoid that mechanic.

Perhaps someone else would be willing to make the spellpack, I'm busy at the moment.
Oh ok. Thanks anyway. Well I'm pretty sure it can be done by using chopinski's Cooldown Reduction system Cooldown Reduction [vJASS][LUA] because it has a option of allow cooldown reduction of all spells when picking up an item so then it should also be able to be fixed if an unit has a specific buff. But the question is, how? I do not even dare try myself because I understand nothing about JASS...
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
I can almost guarantee that his implementation of Cooldown Reduction is essentially the same as mine. The concept of speeding up cooldowns that are already active is not how Cooldown Reduction in any popular RPG has ever worked and isn't a commonly sought after feature. But maybe he has both mechanics, that'd be pretty cool.

You don't need to know Jass either, just how to call the functions that the system provides. Usually at the top of the code it shows you everything YOU need to know, the rest of the code is the "system" which you never need to look at or touch. The creators of these systems try to keep it as simple as possible for the user. You often only need to Set a few variables and run a single line of Custom Script or Trigger to get things going.
 
Level 14
Joined
Jul 19, 2007
Messages
772
I can almost guarantee that his implementation of Cooldown Reduction is essentially the same as mine. The concept of speeding up cooldowns that are already active is not how Cooldown Reduction in any popular RPG has ever worked and isn't a commonly sought after feature. But maybe he has both mechanics, that'd be pretty cool.

You don't need to know Jass either, just how to call the functions that the system provides. Usually at the top of the code it shows you everything YOU need to know, the rest of the code is the "system" which you never need to look at or touch. The creators of these systems try to keep it as simple as possible for the user. You often only need to Set a few variables and run a single line of Custom Script or Trigger to get things going.
Hmm maybe I have to stick with your triggers then but it would be really nice if it could reduce cooldowns of already active spells too...
 
Level 14
Joined
Jul 19, 2007
Messages
772
  • Actions
    • If (Triggering unit has AuraBuff (Lvl 1)) Equal to True then Set Variable AuraFactor = 0.15
    • If (Triggering unit has AuraBuff (Lvl 2)) Equal to True then Set Variable AuraFactor = 0.25
    • If (Triggering unit has AuraBuff (Lvl 3)) Equal to True then Set Variable AuraFactor = 0.35
    • If (Triggering unit has AuraBuff (Lvl 4)) Equal to True then Set Variable AuraFactor = 0.45
    • Start cooldown of ability being cast = Cooldown of ability being cast x (1.00 - AuraFactor)
I don't find "Start cooldown of ability being cast". Where can I find it?
 
Level 14
Joined
Jul 19, 2007
Messages
772
It's only on 1.31+

Just type "cooldown", or "start", or "ability" in the Searchbar and you should find it.
Well I have 1.36 so I guess it's not working then? I made it like this but I guess it's not right...
  • Heroic Aura Cooldown Reduction
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (((Triggering unit) has buff Heroic Aura (lvl1)) Equal to True) then do (Set VariableSet AuraFactor = 0.15) else do (Do nothing)
      • If (((Triggering unit) has buff Heroic Aura (lvl2)) Equal to True) then do (Set VariableSet AuraFactor = 0.25) else do (Do nothing)
      • If (((Triggering unit) has buff Heroic Aura (lvl3)) Equal to True) then do (Set VariableSet AuraFactor = 0.35) else do (Do nothing)
      • If (((Triggering unit) has buff Heroic Aura (lvl4)) Equal to True) then do (Set VariableSet AuraFactor = 0.45) else do (Do nothing)
      • Unit - For Unit (Triggering unit), start cooldown of ability (Ability being cast) " over "(1.00 - AuraFactor) seconds.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Like in my example, you need to set the cooldown to be equal to the current cooldown * (1.00 - AuraFactor).
  • Unit - For Unit (Triggering unit), start cooldown of ability (Ability being cast) " over "((Cooldown of (Ability being cast)) x (1.00 - AuraFactor)) seconds.
You're setting the cooldown to (1.00 - AuraFactor) which is either 0.85, 0.75, 0.65, or 0.55 seconds.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Well I have 1.36 so I guess it's not working then? I made it like this but I guess it's not right...
  • Heroic Aura Cooldown Reduction
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (((Triggering unit) has buff Heroic Aura (lvl1)) Equal to True) then do (Set VariableSet AuraFactor = 0.15) else do (Do nothing)
      • If (((Triggering unit) has buff Heroic Aura (lvl2)) Equal to True) then do (Set VariableSet AuraFactor = 0.25) else do (Do nothing)
      • If (((Triggering unit) has buff Heroic Aura (lvl3)) Equal to True) then do (Set VariableSet AuraFactor = 0.35) else do (Do nothing)
      • If (((Triggering unit) has buff Heroic Aura (lvl4)) Equal to True) then do (Set VariableSet AuraFactor = 0.45) else do (Do nothing)
      • Unit - For Unit (Triggering unit), start cooldown of ability (Ability being cast) " over "(1.00 - AuraFactor) seconds.
It turns out you need to wait until the next game frame to adjust the cooldown properly. Here's a demo map with it working. It's using the GST system that I made which allows you to easily use Timers in GUI.

Long story short, we're Waiting 0.01 seconds before starting the cooldown. But Waits are imprecise so I'm using a Timer instead.
 

Attachments

  • Cooldown Aura 1.w3m
    32.4 KB · Views: 2
Last edited:
Level 14
Joined
Jul 19, 2007
Messages
772
It turns out you need to wait until the next game frame to adjust the cooldown properly. Here's a demo map with it working. It's using the GST system that I made which allows you to easily use Timers in GUI.

Long story short, we're Waiting 0.01 seconds before starting the cooldown. But Waits are imprecise so I'm using a Timer instead.
Ah now it seems to be working like I wanted it. Thank you! Btw will the cooldown of items also be affected or is it only for spells?
 
Top