Advertisement

How Do I Calculate the Exponential Curve For Each Level Stat?

Started by May 26, 2022 09:12 PM
1 comment, last by JoeJ 2 years, 6 months ago

Im trying to use HTML5 and some Javascript to determine the values each Character State between Level 1 and 99 for things like HP and STR. Trouble is I do not remember the math behind this for Exponential Curves!

I need to be able to handle 3 Variables. Level 1 value, Level 99 value, and a “Rate” (slow medium fast).

When Rate is set to “Medium”, its just Linear:

Then using the slider to adjust how much the “Curve” is, end up with results that look like this:

The slider looks like it has about 10 increments on it. I have NO CLUE what the values in there are.

How would I generate the values for each level between 1 and 99 given these things? Also, the stats for MaxHP and STR, AGI vary in their scope, where HP is like 500 to 9999, but for attributes like STR it ranges from about 50 to 999, not 9999.

A little help please?

Some examples:

Probably you want to slide the exponent between something like 0.5 and 2,

but also lerp between both curves of the upper and lower 3 examples (click on the fx(x,t) in front of the expressions to enable the graphs in the applet).

Which would give something like this:

float t = [some input 0…1]
float s = 1.f - t;
float expA = 0.5f + t * 1.5f;
float expB = 2.f - t * 1.5f;
// eventually swap A and B - not sure
float f0 = pow(t, expB);
float f1 = 1.f - pow(s, expA);
float f = f0 * t + f1 * s; // eventually swap 0 and 1
float final = 500 + f * (10000-500);

There may be a simpler way.

This topic is closed to new replies.

Advertisement