Sign in to follow this  
rpiller

Closer to a number without hitting it

Recommended Posts

Hey, so not a big math guy here but was wondering how I would calculate the following scenario.

Let's say I have an RPG and I want armor reduction to max out at 50%. Each level I give the player a certain amount of points to spend in various stats, armor being one of them. I want each point they spend in armor to get them closer to the 50% max but never actually hit it. What would the formula be for that and what would my factors to adjust the jump in % per point be?

Thanks!

Share this post


Link to post
Share on other sites
Thanks, that lead me to http://lostsouls.org/grimoire_diminishing_returns which is a pretty cool site that explains this really well, and more geared toward games.

Share this post


Link to post
Share on other sites
How about using arctan(x), it has an asyptote at pi/2 so if you want to cap it off at 50, you can scale it,
[code]
f(x) = 50 * 2 / pi * arctan(x) ;
[/code]

But the problem with that is that it will converge fast, so you can further scale it like so:
[code]
f(x) = 50 * 2 / pi * arctan(x / RATE ) ; //higher the rate slower it converges to 50, lower the rate faster it converges.
[/code]

Here is a gaph.
[img]http://img833.imageshack.us/img833/2180/screenshot20110723at115.png[/img]

The following are the equations for the above colored graph.
f(x) = 50 * 2 / pi * atan(x / 1 ); //black
f(x) = 50 * 2 / pi * atan(x / 10 ) //red
f(x) = 50 * 2 / pi * atan(x / 20 ) //blue
f(x) = 50 * 2 / pi * atan(x / 40 ) //green
f(x) = 50 * 2 / pi * atan(x / 100 ) //orange

You can do something similar off that line.

You can see, for example looking at the blue graph, at level 30 your armor resistance will be a little above 30, and at level 50, it will be a little less than 40, and so on.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this