# Sliding scale for secondary stats

So, I’m designing a game where Crit Chance is based on a Prowess Stat but want it to have a sliding scale with diminishing returns and for some reason the math is escaping me. The max value for Crit Chance would be 40%. The min value of Prowess would be 1 but there is no ceiling.

You can adapt basically any function with a horizontal asymptote. Here are a few options:

// hyperbolic
critChance = maxChance * (1 - 1/(rate * prowess + 1))

// arc tangent
critChance = maxChance * atan(rate * prowess) * 2/PI

// exponential
critChance = maxChance * (1 - exp(-rate * prowess))


These behave similarly, and all reach toward a max of maxChance as prowess increases toward infinity - they just differ in how steeply they rise initially, and how gradually they brake as they approach that cap.

rate in all three is a parameter you can use to control the steepness of the early part of the curve / how quickly it starts to plateau. In this chart, I've plotted the three versions with rate tuned so they all pass through the point (15, 25%) to get an apples-to-apples look at how they compare:

If you want to tune the rate so the curve passes through a given (prowess, critChance) pair, the formulas for that are:

// hyperbolic
rate = (1/(1 - critChance/maxChance) - 1) / prowess

// arc tangent
rate = tan(critChance * PI / (2 * maxChance)) / prowess

// exponential
rate = ln(1 - critChance/maxChance) / prowess


I've shared a version of these formulas as a Google Sheets workbook you can play with here - see the "Diminishing Returns" tab. You can set the Min Output to zero if you want zero stat to map to zero chance, as shown above.