Let's say I have a character with a number of stats. I want a function to calculate the current effective value of my character's attack after some number of debuffs are applied, with each debuff being more punishing than the last. The number of debuffs can be from 0 to 4.
The opposite case is easy: I use a logarithmic function to calculate the diminishing returns of applying more than one buff to a stat. Logic says that I should use an exponential function to handle the debuffs, but I can't quite figure out a function that works as intended.
Let's call the function calculateStat(baseValue, numberOfDebuffs)
. We'll say that one of my character's stats has a base value of 100. Here are the expected outputs of the function:
calculateStat(100, 0) = 100 // pretty obvious
calculateStat(100, 1) = 90 // a flat 10% decrease; let's call this 'a'
calculateStat(100, 2) = b ; b < 80 // b should be less than 80% of the base value
calculateStat(100, 3) = c ; a-b < b-c // the difference between b and c should be larger than the difference between a and b
calculateStat(100, 4) = d ; d ~= 0, b-c < c-d
Since there are only five possible values for numberOfDebuffs
I've considered simply making this a piecewise function with some rough approximations for each value, but I'd rather have something more elegant that "just works" for each of the values if possible.
My problem with exponential functions like calculateStat(baseValue, numberOfDebuffs) = baseValue - baseValue * (0.1) ^ (1/numberOfDebuffs)
is that it doesn't work for numberOfDebuffs = 0
, and it trends too quickly towards 0 to start with. The difference between 1 and 2 is greater than the difference between 2 and 3, which is the opposite behavior of what I want to achieve.
I'm not great at math, so there may be a very obvious solution that I'm missing.