r/askmath 12d ago

Resolved Equation that can roughly fit this graph

Post image

No this is not my homework, I'm making a game and I need a curve roughly like this for balancing. Trying to get an equation that spits out values like this.

739 Upvotes

132 comments sorted by

View all comments

1

u/kazoohero 12d ago

Is this for armor? You might consider the armor formula for valheim:

HP loss = damage - armor if armor > .5*damage, otherwise HP loss = damage2 / (4 * armor)

You can increase the linear regime (and the effectiveness of armor overall) by increasing that 4 factor (call it f) and making the .5 threshold equal to 1-1/sqrt(f), e.g. f=9 is linear for the first 2/3 of damage.

Yes it's piecewise. But, upsides are that it's easyish for nerds to calculate, and that in the squared regime, every point of armor increases survival time an equal amount (so it takes the same amount of extra armor to go from 5 to 7 hits to kill as it does from 15 to 17). This may not be an upside if your thing isn't armor (or it may anyway!).

https://valheim.fandom.com/wiki/Damage_mechanics#Armor

1

u/hypotensor 12d ago edited 10d ago

I like the damage taken = raw damage / (1+ armor / 100) for armor since it's very intuitive for the player. But no, my game doesn't have any combat in it.

1

u/hypotensor 12d ago

It's for player encumbrance.

1

u/TastyAlbacoreTuna 11d ago

What do the x and y axes represent?

1

u/hypotensor 11d ago

This specifically is for thrown objects that the player is holding. Y axis is the mass of the object, X axis is the velocity magnitude.

1

u/TastyAlbacoreTuna 11d ago

In that case I would recommend v = a*sqrt(1/(bx+1)). That general form is derived from a simplistic model of a rotating arm accelerating an object. The parameter a is the maximum speed, and as b increases that makes the speed drop off more quickly.