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

Cooldown Reduction

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
Hi,

I'm trying to make a trigger that reduces the cooldown of abilities when cast by a Hero, but it doesn't seem to be working. The text message reads correctly but it doesn't actually reduce... My test has a spell on 30 second cooldown and when cast the text reads 20 seconds but I have timed it and it's still 30 seconds! What am I doing wrong?? I think the event might be the problem?? Also I can't work out how to post it as a trigger so a code will have to do...

Code:
Hero Spell Cooldown
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Set VariableSet TempUnit = (Triggering unit)
        Set VariableSet TempAbilityCode = (Ability being cast)
        Set VariableSet TempInt = (Level of TempAbilityCode for TempUnit)
        Set VariableSet TempReal = (1.00 + ((Real((Intelligence of TempUnit (Include bonuses)))) / 200.00))
        Unit - For Unit TempUnit, start cooldown of ability (Ability being cast) " over "((Ability: (Unit: TempUnit's Ability with Ability Code: TempAbilityCode)'s Real Level Field Cooldown ('acdn'), of Level: TempInt) / TempReal) seconds.
        Game - Display to (All players) the text: (String((Ability Cooldown Remaining of TempUnit for ability TempAbilityCode..)))

EDIT - I have just tried "unit begins casting" and it works, but spells obviously don't actual get cast before they are put on cooldown... any ideas of how to make this work??
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
The Level field is indexed starting at 0. Meaning "Level: 0" is actually "Level: 1". So your TempInt variable should take this into consideration and subtract 1:
  • Set VariableSet TempInt = ((Level of TempAbilityCode for TempUnit) - 1)

If the problem persists, try resetting the cooldown of the ability before starting it again.
 
Last edited:
Level 13
Joined
Oct 16, 2010
Messages
731
Thanks, it still didn't work even after resetting the cooldown, so I've added a 0.01 wait at the start and this seems to have solved it!

Code:
Hero Spell Cooldown
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Wait 0.01 seconds
        Set VariableSet TempUnit = (Triggering unit)
        Set VariableSet TempAbilityCode = (Ability being cast)
        Set VariableSet TempInt = ((Level of TempAbilityCode for TempUnit) - 1)
        Set VariableSet TempReal = (1.00 + ((Real((Intelligence of TempUnit (Include bonuses)))) / 200.00))
        Unit - For Unit TempUnit, end cooldown of ability TempAbilityCode
        Unit - For Unit TempUnit, start cooldown of ability TempAbilityCode " over "((Ability: (Unit: TempUnit's Ability with Ability Code: TempAbilityCode)'s Real Level Field Cooldown ('acdn'), of Level: TempInt) / TempReal) seconds.
        Game - Display to (All players) the text: (String((Ability Cooldown Remaining of TempUnit for ability TempAbilityCode..)))
 
Status
Not open for further replies.
Top