saw792
Is known to say things. That is all.
- Reaction score
- 280
ResetSingleCooldown
By saw792
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(), 039;A000039;)
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.