Snippet ResetSingleCooldown

saw792

Is known to say things. That is all.
Reaction score
280
ResetSingleCooldown
By saw792

Ever wondered why there isn't a function to reset the cooldown of a single ability? Well now there is.

JASS:
function ResetSingleCooldown takes unit u, integer abilid returns boolean
  local integer i = GetUnitAbilityLevel(u, abilid)
  if i > 0 then
    call UnitRemoveAbility(u, abilid)
    call UnitAddAbility(u, abilid)
    call SetUnitAbilityLevel(u, abilid, i)
    return true
  endif
  return false
endfunction


You can either call it directly or use the boolean to check that the unit has the ability at the same time. Example:
JASS:
call ResetSingleCooldown(GetTriggerUnit(), 'A000')


If this bugs out for some reason with triggered spells or passives or something let me know. As far as I know it shouldn't make a difference to spells that use a skill learning event as having the ability added doesn't actually count as learning it.

This isn't super innovative or anything, but I'm sure somebody will find it useful.
 

wraithseeker

Tired.
Reaction score
122
it would be nice to provide a test map other then that for me I don't see any much problem <3

Although I have to ask is it really true that you have to remove and add and then set the ability level of the ability to "refresh" it? Isn't there a better way?

Other then that + REP.
 

saw792

Is known to say things. That is all.
Reaction score
280
Test map is useless in my opinion. It's just a small snippet, there isn't really much to test. It works, that I can tell you.

You have two options when resetting cooldowns: You use the native that resets all cooldowns, or you do what I did.
 

wraithseeker

Tired.
Reaction score
122
Is it only me or are resources that are submitted going off? I seen many spells not getting approved over a month already.

Also you could add a special effect function which is easy to show that the unit has refreshed his cooldown.
And also to make it some effects are attachable like left ,right, origin, overhead.


It would be like
JASS:

Call ResetSingleCooldown(GetTriggerUnit(),&#039;A000&#039;,&quot;YourEffect&quot;,IsAttached?(True),Left)


I know you can do it :D
 

saw792

Is known to say things. That is all.
Reaction score
280
Or I could not, since that would miss the point entirely of it being a snippet. It's not exactly difficult to call the function and then add a special effect on the unit you just reset.

EDIT: Mmk. I searched but it didn't come up. Graveyard for me.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
You sir, are a ninja.
I was just thinking of writing one of these today...
I had to go out to return a bunch of gifts with the girlfriend though :( !

Good job nonetheless.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
It's lame because if you try to reset the cooldown when the spell have an effect, the effect will be removed.
But there is not other way ...
 

Romek

Super Moderator
Reaction score
963
I thought this was obvious enough that it didn't even need to be submitted.
I've used something like this a few times before.

Anyway, it's here already.
 

Leazy

You can change this now in User CP.
Reaction score
50
This won't work if the spell is inside a spell book?
 

Romek

Super Moderator
Reaction score
963
It stores the level of the ability.
Then removes the ability.
Then re-adds the ability.
And finally, sets the level of the ability to the stored one.
 

D.V.D

Make a wish
Reaction score
73
O, I thought this did something totally different, like making the cooldown sstart. Thanks Romek.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top