Help me with a math problem

I’m creating a kind of buff for my game in which I have the following buffs, Range, Damage and Cooldown (spd atk). the range and damage buff math is easy but on the cooldown I get lost. I will leave an example of my code, there is also a buff resist which is how much the buff can affect that troop.

local TotalBuff = 200 --Accumulated buff
local ThisResist = 100 -- 100 he will receive the full buff, 200 he will receive half
local buffeffectiveness = (TotalBuff/ThisResist)

-- -- Example of mathematics I use if it is range or damage (works perfectly)
local MyDamage = 100
local some = MyDamage * Amount
MyDamage  = math.clamp(MyDamage +some,0,math.huge)

I want help putting together the math for the cooldown case. for example, if my speed attack was 0.5s and I had a 100% buff it would go to 0.2s and so on. It seems like something simple but in practice I’m not able to solve it

2 Likes

You would probably just want to decrease the cooldown somehow. For example, you could try dividing it by the buff amount.

To achieve your example, you could just do (0.5-(0.3 x 100%)) or basically something like (cooldown-(0.6 x cooldown x buff))