HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How do you reset the cooldown for only 1 ability?

06-26-2006, 03:04 AM#1
darkwulfv
I know there's a trigger for resetting all of a unit's cooldowns, but how do I reset it for just one? (I may not need this if this trigger stops the cooldown from happening in the first place)
Trigger:
Untitled Trigger 002
Collapse Events
Unit - A unit Begins casting an ability
Collapse Conditions
(Ability being cast) Equal to Werewolf
(In-game time of day) Greater than or equal to 6.00
(In-game time of day) Less than 18.00
Collapse Actions
Unit - Order (Triggering unit) to Stop
Game - Display to (Owner of (Triggering unit)), at offset (0.00, 0.00) the text: You cannot cast thi...
06-26-2006, 03:14 AM#2
Naakaloh
Remove the ability and add it back. This should work, I don't believe there is any other method.
06-26-2006, 03:19 AM#3
darkwulfv
Ok I thought of that, wasn't sure though.
06-26-2006, 06:30 AM#4
aquilla
You could create a unit when it becomes night, and make the ability require it. Othervise I think Pause, Order stop, Unpause should be enough. Not sure if the remove/readd thing works
06-26-2006, 09:35 AM#5
Fulla
Yea im pretty sure if you remove then readd the same ability, the cooldown is still stored in memory somehow.

Can always replace it with a dummy ability, i.e. spell1/spell2 which do same thing, but you switch between them.
06-26-2006, 10:00 AM#6
Rising_Dusk
Cooldown is stored to a unit.
I've tried it before and the cooldown remains.

There really is no wasy way to do it.
06-26-2006, 10:10 AM#7
Jazradel
It's pretty simple.

You just remove every ability the unit has that you want to remain cooling down, then use the reset cooldown trigger, then readd them. It won't reset the cooldown of abilities of the unit doesn't have.
06-26-2006, 10:29 AM#8
Freakazoid
In this case, just add 1 second casting time, and it's donel. No need to reset the cooldown since you use "Unit begins casting ability" event.
06-26-2006, 10:39 AM#9
Captain Griffen
Quote:
Cooldown is stored to a unit.
I've tried it before and the cooldown remains.

There really is no wasy way to do it.

Wrong. It does NOT store it to the unit. I just tested it, and removing it and readding it resets the cooldown.
06-26-2006, 11:01 AM#10
PipeDream
- If you don't do the requirement thing, you may find this useful: http://www.wc3jass.com/viewtopic.php?t=239
- You could add a level to the spell with zero cooldown and the effect only the simerror and use this level at night.
- Resetting cooldown arbitrarily is difficult. I think it may be possible with a level with no cooldown that is learned for a time. I'm pretty sure when a user learns the ability the new cooldown comes into effect immediately (?) But I haven't been able to mimic this after spell cast. Maybe hero level juggling and SelectHeroSkill can do it.

Edit:
Haha, what the hell. Naakaloh's method works fine. Damn you guys. It's even in the jass vault http://www.wc3jass.com/viewtopic.php?t=2056
06-26-2006, 01:04 PM#11
Rising_Dusk
Are you serious?
Is this a recent thing or is my WE just hating on me again?

So something like this would work then?
Collapse JASS:
function ResetAbilCooldown takes unit tgt, integer abilId returns nothing
    local integer lvl = GetUnitAbilityLevel(tgt, abilId)
    call UnitRemoveAbility(tgt, abilId)
    call UnitAddAbility(tgt, abilId)
    call SetUnitAbilityLevel(tgt, abilID, lvl)
endfunction

Then, while we're on the topic of cooldowns...
Is there any way to INCREASE the cooldown of a spell by X seconds without using Engineering Upgrade?
06-26-2006, 01:09 PM#12
Captain Griffen
Use a unit requirement and trigger the cooldown that way.

EDIT: If you want it MUI, then remove the ability, add a new one with a requirement that cannot be achieve, then swap them around again when you want it cooled down.
06-26-2006, 01:11 PM#13
PipeDream
If all the effects are triggered, remove/add to reset cooldown then set the level and order it with spell trigger disabled.
06-26-2006, 01:27 PM#14
Rising_Dusk
So what you're all saying to the best of my understanding (I think you both could use to be a bit more clear) is that what I just made and is below will work.
I am attempting to do this without making any Object Editor stuff, IE making it all triggered.

Collapse JASS:
function ResetAbilCooldown takes unit tgt, integer abilId returns nothing
    local integer lvl = GetUnitAbilityLevel(tgt, abilId)
    call UnitRemoveAbility(tgt, abilId)
    call UnitAddAbility(tgt, abilId)
    call SetUnitAbilityLevel(tgt, abilID, lvl)
endfunction

function SetAbilityCooldown_Update takes nothing returns nothing
    local player p = GetPlayer(GetExpiredTimer(), "SAC_Player")
    call SetPlayerAbilityAvailable(p, abilId, true)
    set p = null
endfunction

function SetAbilityCooldown takes unit tgt, integer abilId, real duration, timer CreateMeATimer returns nothing
    local integer lvl = GetUnitAbilityLevel(tgt, abilId)
    local player p = GetOwningPlayer(tgt)
    call ResetAbilCooldown(tgt, abilId)
    call SetPlayerAbilityAvailable(p, abilId, false)
    call SetHandle(CreateMeATimer, "SAC_Player", p)
    call TimerStart(CreateMeATimer, duration, false, function SetAbilCooldown_Update)
    set p = null
endfunction

Then I would call it this way....

Collapse JASS:
call SetAbilityCooldown(SomeUnit, 'A000', 6.0, CreateTimer())
06-26-2006, 01:57 PM#15
PipeDream
- setting players to null is extraneous. shameless self reference
- Should probably destroy timer in callback
- Not multiinstanceable with respect to multiple units and multiple calls
- Should be fine for you. I might change the first argument to player to make the above clear.