Jump to content
• Advertisement

Closer to a number without hitting it

This topic is 2556 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Share on other sites
Advertisement
http://en.wikipedia.org/wiki/Asymptote
http://en.wikipedia.org/wiki/Diminishing_returns

I think these will get you on the right track.

Share this 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

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,
 f(x) = 50 * 2 / pi * arctan(x) ; 

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

Here is a gaph.

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

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5
• Advertisement

• 14
• 29
• 13
• 11
• 11
• Forum Statistics

• Total Topics
631774
• Total Posts
3002287
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!