I’m trying to make a multiplier that’s increasing and caps at 1.5x for when a player health gets below 50.
This is the formula I’m trying to use.
(1 + (HP/ 50) * 0.2)
If you’re trying to cap it, you can look into math.min.
E.g. math.min((1 + (HP / 50) * 0.2), 1.5)
will return 1.5 at most
math.max(1.5 * (maxHP- HP) / maxHP, 1.0)
123123123123
Multiplier still returns a lower number when health is lower which I don’t want.
I tried using this but it returns 1
always
My mistake, I thought you meant you wanted to clamp it below 1.5.
In that case, use math.max
like azqjanna suggested.
I tried using that formula it works and it decreased but it only returns 1.4x
)
math.max((1.5 - (HP / 50) * 0.1), 1)
For more detailed basically I want the multiplier to between 1 (default value for when above or equal to 50) and decreased to 1.1 at lowest hp.
Yeah but maxHP being 50 since the formula won’t work unless the health is equal or lower to 50.
What do you mean by this?
123123123
Basically like Smash Rage, where the multiplier is increased as the player health is increased, expect I’m doing this when the player health IS decreased, growing to maximum value to 1.1x
“It has a slightly altered formula, which is 1 + [(Power - 35)/115 * 0.1]
. As a result, while it still takes effect past 35% and caps at 150%, it grows at a slower rate, and its maximum possible multiplier is now 1.1× (down from 1.15×).”
I can use math.clamp to maximum value to 1.1x if needed;
Does the one I posted not do that?
It always returns 1 regardless like I said, I tried using clamps, but it does opposite and only increases as health is increasing.
math.clamp((1 + (HP / 50) * 0.1),1,1.5)
Why are you multiplying it by 0.1?
Can you draw on the graph I posted what you want it to look like?
It’s like your graph but only starts at 50 and slowly grows to 1.5 (or 1.1) as health is decreasing from 50 to 1 (smallest possible health)
This does do that though? The multiplier is 1.5 when health is 0, 1.25 when its 25, and 1.0 when its 50 or higher.
Note that this is a different formula from the one I initially posted, this one lets you tweak it better.
That’s exactly what I want, but utilizing the formula you posted always returns 1 when I replace maxHP
with 50 or higher and HP
the HP
This is not the same formula. You’d have to write it like this:
print(math.max((1.5 * 50 - 40) / 50, 1.0))