Problem
Player obtains 5 points per level up to level 80 with a maximum of 400. There are 5 stats to be distributed to and no maximum limit to how much you can add to a stat.
- Strength
- Endurance
- Intelligence
- Agility
- Luck - Grants critical chance and critical damage
I would like to implement a diminishing return equation on let's say Luck. For critical chance, I do not wish for the player to be able to hit 100% critical chance.
There will be a ceiling to which it will reach as the increasingly decreasing growth reaches towards 0 per point added.
Example if the maximum critical chance I want the player to have is 40%, Each point into luck will increase critical chance lesser and lesser, until the critical chance reaches around 40%. By which 1 luck will give a very very miniscule amount.
Any solutions? Thank you and your help is greatly appreciated!
Answer
You want to start with an asymptotic function. That is, one that starts at a number a
and approaches another number b
, but never actually reaches it. It's probably going to be easiest if a = 0
and b = 1
. You'll take this equation, input the number of stat points (Luck points) the character has, and get the actual stat value (Crit Chance) as the output.
A very simple example is y = x / (x + n)
where n
is some positive constant. Here x
is your input, where you feed in the number of stat points, and y
is your output, where you get the final stat value.
For n = 5
check out what it looks like:
When you feed in x = 0
you get y = 0
, but no matter how big an x
you put in, y
never quite reaches 1. Perfect.
Now, you can tune this to your hearts desire. You can multiply by a scale factor to set the 'cap' to whatever you want. y = a * x / (x + 5)
. If you want the cap to be 40%, multiply by .4. y = .4 * x / (x + n)
. Now when you feed in x
's, y
will increase but it will never quite reach .4.
Adjust n
to set how fast or slow the equation ramps up. n = 100
is going to increase a lot slower than n = 5
:
You can solve this equation for n
if you know you want the stat value you want to reach at a specific number stat points. Let's say the character should have 35% Crit Chance at 100 points of Luck. Solving .35 = .4 * 100 / (100 + n)
for n
yields n = 14.29
.
These numbers don't have to be raw constants either. Maybe other stats go into calculating the values of n
. Maybe some characters have different n
's so they scale better in their 'preferred' stat.
If you want a curve that's shaped differently or is more complex, there are many other examples of asymptotic functions you could use as well. I'll leave you to explore that as you wish.
No comments:
Post a Comment