#How to reduce the current cooldown of charge abilities?

1 messages · Page 1 of 1 (latest)

near sonnet
#

for i = 0, parent:GetAbilityCount() - 1 do local ability = parent:GetAbilityByIndex(i) if ability and ability:GetCooldownTimeRemaining() > 0 then local currentCooldown = ability:GetCooldownTimeRemaining() local cooldownReduction = 1 local newCooldown = math.max(0, currentCooldown - cooldownReduction) ability:EndCooldown() if newCooldown > 0 then ability:StartCooldown(newCooldown) end end end
I'm using this method to reduce the cooldown of some abilities, but it seems not working for charge-based abilities. GetCooldownTimeRemaining also cannot get the correct value for them.

fierce venture
#

There are no api (at least that im aware of). EndCooldown started affect charges only recently according to #1325834282387771422 message

waxen vapor
#

the answer is very classically valve in that the answer is "go fuck urself"

waxen vapor
#

however, you can probably do the following:
get current ability charges GetCurrentAbilityCharges
refresh all charges with RefreshCharges (this also inherently ends the cooldown and if it doesn't u can just call endcooldown)
set charges to curr-1 with SetCurrentAbilityCharges

near sonnet
#

Oh thanks. That's a bad news🥲

fierce venture
#

You can also implement custom charges yourself with any api you want. There is working charges implementation in moddota site that lack only modern ui support (you can reuse that ui for your charges).
This will also force you to use this custom charges only and rewrite all valve charge based abilities used to support all your features
I did that myself when i wanted working flat cdr for charges based abilities 🥲

#

With that approach you can also override valve charges related api to use your api so not very much code should be affected

near sonnet
#

I'm planning to create a dummy unit that will cast a modified version of Chakra Magic (with custom KV values) on the hero

fierce venture
near sonnet
fierce venture