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

[Spell] Reducing Ability Cooldown

Status
Not open for further replies.
Level 11
Joined
May 7, 2008
Messages
300
This sometimes works and sometimes it doesn't, depending on which Hero Casts which type of spell.

The goal of the trigger is to reduce the cooldown on whatever the ability has been cast to current cooldown of the spell -1.5s or -3s.

the 0.00 seconds is there cause if that's not inside the trigger it won't trigger at all :S

  • Emerald Staff CD Reduction
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r) Equal to True
              • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r (|cff008000Cursed Knight|r)) Equal to True
        • Then - Actions
          • Wait 0.00 seconds
          • Unit - For Unit (Triggering unit), start cooldown of ability (Ability being cast) " over "((Ability Cooldown Remaining of (Triggering unit) for ability (Ability being cast)..) - 1.50) seconds.
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r)) Equal to True
                  • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r / |cff008000Cursed Knight|r)) Equal to True
            • Then - Actions
              • Wait 0.00 seconds
              • Unit - For Unit (Triggering unit), start cooldown of ability (Ability being cast) " over "((Ability Cooldown Remaining of (Triggering unit) for ability (Ability being cast)..) - 3.00) seconds.
            • Else - Actions
 
Level 11
Joined
May 7, 2008
Messages
300
what kind of heroes and spells does it not work with? is there some kind of causality that you noticed? can you give an example of some spells that don't work?

Well I'd try to compose the list of all the abilities, but that would take way too long :(

Instead I created this test map for you to see, even the basic wc3 spells are janky when it comes to this

 
Level 38
Joined
Feb 27, 2007
Messages
4,951
Isn’t there a set remaining cooldown action instead of what you’re doing to restart it?

The issue is that “ability being cast” functions like a global variable after the wait (source: Event Response Myths). It’s also not possible to reset cooldown and mana cost in a Starts the Effect of an Ability trigger because when that event fires the cd/mana cost are not yet spent. You must delay very slightly in order for it to be actually on cooldown. Normally you would do this with a 0.00 timeout timer, NOT a wait. Which will basically solve your problem of it not working for some spells since there won’t be time to overwrite the Ability Being Cast global.
 
Level 11
Joined
May 7, 2008
Messages
300
Isn’t there a set remaining cooldown action instead of what you’re doing to restart it?

The issue is that “ability being cast” functions like a global variable after the wait (source: Event Response Myths). It’s also not possible to reset cooldown and mana cost in a Starts the Effect of an Ability trigger because when that event fires the cd/mana cost are not yet spent. You must delay very slightly in order for it to be actually on cooldown. Normally you would do this with a 0.00 timeout timer, NOT a wait. Which will basically solve your problem of it not working for some spells since there won’t be time to overwrite the Ability Being Cast global.

Great point Pyrogasm, I didn't even though that fully through.

I think I get what you're trying to say, this is what I have so far;

EDIT: Hm, doesn't seem to work :(

EDIT2: I think I got it working (check spoiler 2)


OLD (DOES NOT WORK)

  • Emerald Staff CD Reduction
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r) Equal to True
              • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r (|cff008000Cursed Knight|r)) Equal to True
        • Then - Actions
          • Set VariableSet Emerald_Unit = (Triggering unit)
          • Set VariableSet Emerald_Staff = (Ability being cast)
          • Set VariableSet Emerald_Integer = (Level of Emerald_Staff for Emerald_Unit)
          • Set VariableSet Emerald_Staff_CD = (Ability Cooldown Remaining of Emerald_Unit for ability Emerald_Staff..)
          • -------- --------
          • Countdown Timer - Start Emerald_Timer as a One-shot timer that will expire in 0.00 seconds
          • -------- --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r)) Equal to True
                  • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r / |cff008000Cursed Knight|r)) Equal to True
            • Then - Actions
              • Set VariableSet Emerald_Unit = (Triggering unit)
              • Set VariableSet Emerald_Staff = (Ability being cast)
              • Set VariableSet Emerald_Integer = (Level of Emerald_Staff for Emerald_Unit)
              • Set VariableSet Emerald_Staff_CD = (Ability Cooldown Remaining of (Triggering unit) for ability Emerald_Staff..)
              • -------- --------
              • Countdown Timer - Start Emerald_Upgraded_Timer as a One-shot timer that will expire in 0.00 seconds
              • -------- --------
            • Else - Actions
  • Emerald Staff Normal Timer
    • Events
      • Time - Emerald_Timer expires
    • Conditions
    • Actions
      • Unit - For Unit Emerald_Unit, Set cooldown of ability Emerald_Staff, Level: (Emerald_Integer - 1) to (Emerald_Staff_CD - 1.50)
  • Emerald Staff Upgraded Timer
    • Events
      • Time - Emerald_Upgraded_Timer expires
    • Conditions
    • Actions
      • Unit - For Unit Emerald_Unit, Set cooldown of ability Emerald_Staff, Level: (Emerald_Integer - 1) to (Emerald_Staff_CD - 3.00)



NEW (WORKS, I THINK)

  • Emerald Staff CD Reduction
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r) Equal to True
              • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r (|cff008000Cursed Knight|r)) Equal to True
        • Then - Actions
          • Set VariableSet Emerald_Unit = (Triggering unit)
          • Set VariableSet Emerald_Staff = (Ability being cast)
          • -------- --------
          • Set VariableSet Emerald_Staff_Amount = 1.50
          • Set VariableSet Emerald_Staff_CD = ((Ability Cooldown Remaining of Emerald_Unit for ability Emerald_Staff..) - Emerald_Staff_Amount)
          • -------- --------
          • Countdown Timer - Start Emerald_Timer as a One-shot timer that will expire in 0.00 seconds
          • -------- --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r)) Equal to True
                  • ((Triggering unit) has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r / |cff008000Cursed Knight|r)) Equal to True
            • Then - Actions
              • Set VariableSet Emerald_Unit = (Triggering unit)
              • Set VariableSet Emerald_Staff = (Ability being cast)
              • -------- --------
              • Set VariableSet Emerald_Staff_Amount = 3.00
              • Set VariableSet Emerald_Integer = (Level of Emerald_Staff for Emerald_Unit)
              • Set VariableSet Emerald_Staff_CD = ((Ability Cooldown of Emerald_Unit for ability Emerald_Staff, Level: (Emerald_Integer - 1).) - Emerald_Staff_Amount)
              • -------- --------
              • Countdown Timer - Start Emerald_Upgraded_Timer as a One-shot timer that will expire in 0.00 seconds
              • -------- --------
            • Else - Actions
  • Emerald Staff Normal Timer
    • Events
      • Time - Emerald_Timer expires
    • Conditions
    • Actions
      • Unit - For Unit Emerald_Unit, start cooldown of ability Emerald_Staff " over "Emerald_Staff_CD seconds.
  • Emerald Staff Upgraded Timer
    • Events
      • Time - Emerald_Upgraded_Timer expires
    • Conditions
    • Actions
      • Unit - For Unit Emerald_Unit, start cooldown of ability Emerald_Staff " over "Emerald_Staff_CD seconds.
 
Last edited:
Level 38
Joined
Feb 27, 2007
Messages
4,951
I see I did not read clearly enough and thought you wanted to reset the cooldown, not reduce the time remaining. The action in your above post sets the actual value of the cooldown for future casts instead of altering the current remaining cooldown, which is not what you want. The way you had it before is what you should be doing. The triggers can be simplified:

  • Emerald Staff CD Reduction
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet Emerald_Unit = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Emerald_Unit has an item of type |cffff8080Emerald Staff|r) Equal to True
              • (Emerald_Unit has an item of type |cffff8080Emerald Staff|r (|cff008000Cursed Knight|r)) Equal to True
        • Then - Actions
          • Set VariableSet Emerald_Staff_Reduction = 1.5
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Emerald_Unit has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r)) Equal to True
                  • (Emerald_Unit has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r / |cff008000Cursed Knight|r)) Equal to True
            • Then - Actions
              • Set VariableSet Emerald_Staff_Reduction = 3.00
            • Else - Actions
              • Skip Remaining Actions
      • Set VariableSet Emerald_Staff = (Ability being cast)
      • Set VariableSet Emerald_Staff_CD = ((Ability Cooldown Remaining of Emerald_Unit for ability Emerald_Staff..) - Emerald_Staff_Reduction)
      • Countdown Timer - Start Emerald_Timer as a One-shot timer that will expire in 0.00 seconds
  • Emerald Staff Timer
    • Events
      • Time - Emerald_Timer expires
    • Conditions
    • Actions
      • Unit - For Unit Emerald_Unit, start cooldown of ability Emerald_Staff " over " Emerald_Staff_CD seconds.
 
Level 11
Joined
May 7, 2008
Messages
300
I see I did not read clearly enough and thought you wanted to reset the cooldown, not reduce the time remaining. The action in your above post sets the actual value of the cooldown for future casts instead of altering the current remaining cooldown, which is not what you want. The way you had it before is what you should be doing. The triggers can be simplified:

  • Emerald Staff CD Reduction
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet Emerald_Unit = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Emerald_Unit has an item of type |cffff8080Emerald Staff|r) Equal to True
              • (Emerald_Unit has an item of type |cffff8080Emerald Staff|r (|cff008000Cursed Knight|r)) Equal to True
        • Then - Actions
          • Set VariableSet Emerald_Staff_Reduction = 1.5
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Emerald_Unit has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r)) Equal to True
                  • (Emerald_Unit has an item of type |cffff8080Emerald Staff|r (|cffd45e19Enhanced|r / |cff008000Cursed Knight|r)) Equal to True
            • Then - Actions
              • Set VariableSet Emerald_Staff_Reduction = 3.00
            • Else - Actions
              • Skip Remaining Actions
      • Set VariableSet Emerald_Staff = (Ability being cast)
      • Set VariableSet Emerald_Staff_CD = ((Ability Cooldown Remaining of Emerald_Unit for ability Emerald_Staff..) - Emerald_Staff_Reduction)
      • Countdown Timer - Start Emerald_Timer as a One-shot timer that will expire in 0.00 seconds
  • Emerald Staff Timer
    • Events
      • Time - Emerald_Timer expires
    • Conditions
    • Actions
      • Unit - For Unit Emerald_Unit, start cooldown of ability Emerald_Staff " over " Emerald_Staff_CD seconds.

Excellent, thank you very much, this works nicely!


One thing I would like to point out is that unfortunately the 0.00 timer won't work on every spell, due to the fact that some spells of mine have casting time which apparently prevents the triggered Cooldown Reduction.

To resolve this I had to set Expiration timer to 0.01s or even to 0.10s.

Although, considering that only one user can have this item at any given time in my map, I think I should be fine in that department (hopefully).
 
Last edited:
Level 38
Joined
Feb 27, 2007
Messages
4,951
some spells of mine have casting time which apparently prevents the triggered reduction
The SPELL_EFFECT event should only fire after the full cast time has gone off, which is the instant before the spell goes on cooldown and takes mana away. Do you instead mean that they are channeled spells? If so you can use "finishes casting" to detect a full length channel and "stops casting" to detect when its interrupted early.
 
Level 11
Joined
May 7, 2008
Messages
300
The SPELL_EFFECT event should only fire after the full cast time has gone off, which is the instant before the spell goes on cooldown and takes mana away. Do you instead mean that they are channeled spells? If so you can use "finishes casting" to detect a full length channel and "stops casting" to detect when its interrupted early.

Yeah I guess you're right. The spell that did not work properly with this trigger was actually a modified Blizzard spell.

I guess it would be easier to just replace the modified channel (blizzard) spell with something else (like Silence).

Or I can use your suggestion and detect the start of the spell cast with the provided 2 methods above. :)
 
Last edited:
Status
Not open for further replies.
Top