TDW Experience Curve Customization

TDW Experience Curve Customization
Version 1.0
by wrigty12
[For RPGMaker MZ]
​

Description:
Define and set custom experience curves for individual classes, using JS Code instead of the default EXP Curve Generator!

Functionality:
You can compose a list of different EXP Curves. Then, you link each Class to any of your defined EXP Curves.

Everything is built out in the Plugin Parameters.

Some example defaults (you may recognize them from a certain monster-catching game):
Spoiler: Code
n = actor level
Code:
(6/5)*Math.pow(n,3) - 15*Math.pow(n,2) + 100*n - 140;
Code:
if (n <= 50) { (Math.pow(n,3)*(100-n))/50 }
else if (n <= 68) { (Math.pow(n,3)*(150-n))/100 }
else if (n <= 98) { (Math.pow(n,3)*((1911-10n)/3))/50 }
else if (n <= 100) { (Math.pow(n,3)*(160-n))/100 };

Plugin:


Credits:
wrigty12

Terms:
Feel free to use in any way you like. No credit required, unless you feel like it!
is there a way to list exact custom values per level with this plug? could I do something like

if (n <= 1) {0}
else if (n = 2) {1000}
else if (n = 3) {2000}
else if (n = 4) {4000};

and so on?
is there a way to list exact custom values per level with this plug? could I do something like

if (n <= 1) {0}
else if (n = 2) {1000}
else if (n = 3) {2000}
else if (n = 4) {4000};

and so on?
You can try
Code:
if (n <= 1) {0}
else { Math.pow(2,n-2)*1000 };

This is a pretty fantastic tool, because it gives you the freedom to define whatever curves you want, and that includes curves used in most final fantasy games. An example:
JavaScript:
const a = 0.1;
const b = 4.2;
const c = 6.1;
const d = 1.4;
const e = -11.4;
if (n >= 2) {
    Math.floor(a*Math.pow(n,4) + b*Math.pow(n,3) + c*Math.pow(n,2) + d*n + e);
} else { 0 }

Which should give you FF XII's Exp curve. For FF9's Exp curve, the coefficients are [0.0625, 0.625, 2.3125, 3.5, -6]
You can try
Code:
if (n <= 1) {0}
else { Math.pow(2,n-2)*1000 };

This is a pretty fantastic tool, because it gives you the freedom to define whatever curves you want, and that includes curves used in most final fantasy games. An example:
JavaScript:
const a = 0.1;
const b = 4.2;
const c = 6.1;
const d = 1.4;
const e = -11.4;
if (n >= 2) {
    Math.floor(a*Math.pow(n,4) + b*Math.pow(n,3) + c*Math.pow(n,2) + d*n + e);
} else { 0 }

Which should give you FF XII's Exp curve. For FF9's Exp curve, the coefficients are [0.0625, 0.625, 2.3125, 3.5, -6]
That’s great thank you
What if I wanted to mimic the experience tables of D&D 5E? It’s not the same formula through the whole chart…what would be the best way to do that if possible?

[TABLE]
[TR]
[TD]0[/TD]
[TD]1[/TD]
[TD]+2[/TD]
[/TR]
[TR]
[TD]300[/TD]
[TD]2[/TD]
[TD]+2[/TD]
[/TR]
[TR]
[TD]900[/TD]
[TD]3[/TD]
[TD]+2[/TD]
[/TR]
[TR]
[TD]2,700[/TD]
[TD]4[/TD]
[TD]+2[/TD]
[/TR]
[TR]
[TD]6,500[/TD]
[TD]5[/TD]
[TD]+3[/TD]
[/TR]
[TR]
[TD]14,000[/TD]
[TD]6[/TD]
[TD]+3[/TD]
[/TR]
[TR]
[TD]23,000[/TD]
[TD]7[/TD]
[TD]+3[/TD]
[/TR]
[TR]
[TD]34,000[/TD]
[TD]8[/TD]
[TD]+3[/TD]
[/TR]
[TR]
[TD]48,000[/TD]
[TD]9[/TD]
[TD]+4[/TD]
[/TR]
[TR]
[TD]64,000[/TD]
[TD]10[/TD]
[TD]+4[/TD]
[/TR]
[TR]
[TD]85,000[/TD]
[TD]11[/TD]
[TD]+4[/TD]
[/TR]
[TR]
[TD]100,000[/TD]
[TD]12[/TD]
[TD]+4[/TD]
[/TR]
[TR]
[TD]120,000[/TD]
[TD]13[/TD]
[TD]+5[/TD]
[/TR]
[TR]
[TD]140,000[/TD]
[TD]14[/TD]
[TD]+5[/TD]
[/TR]
[TR]
[TD]165,000[/TD]
[TD]15[/TD]
[TD]+5[/TD]
[/TR]
[TR]
[TD]195,000[/TD]
[TD]16[/TD]
[TD]+5[/TD]
[/TR]
[TR]
[TD]225,000[/TD]
[TD]17[/TD]
[TD]+6[/TD]
[/TR]
[TR]
[TD]265,000[/TD]
[TD]18[/TD]
[TD]+6[/TD]
[/TR]
[TR]
[TD]305,000[/TD]
[TD]19[/TD]
[TD]+6[/TD]
[/TR]
[TR]
[TD]355,000[/TD]
[TD]20[/TD]
[TD]+6[/TD]
[/TR]
[/TABLE]
Luckily for you, there is a thread that discusses exactly your question. The answer is no, there is no simple exp curve that exists that fits the one found in D&D 5e. Your best bet is an approximation.
Luckily for you, there is a thread that discusses exactly your question. The answer is no, there is no simple exp curve that exists that fits the one found in D&D 5e. Your best bet is an approximation.
what if we wanted to hotwire the code in RPGMZ

Game_Actor.prototype.expForLevel = function(level) {
const c = this.currentClass();
const basis = c.expParams[0];
const extra = c.expParams[1];
const acc_a = c.expParams[2];
const acc_b = c.expParams[3];
return Math.round(
(basis * Math.pow(level - 1, 0.9 + acc_a / 250) * level * (level + 1)) /
(6 + Math.pow(level, 2) / 50 / acc_b) +
(level - 1) * extra
);
};

I think this shows how the 4 exp curve parameters plug into a function and return a rounded number. (I know barely nothing about code, took java in uni like 20 years ago)

couldn't we edit this with an elaborate function or even a huge 18 part polynomial that specifies a function for each level? if so how could we write that? or does it have to be written as a plugin?

I found:

XP=3.78254−134.593+2572.62−10699+10703
(x = level)
//this one is kinda close and I would settle for it

and if we wanted to get really nuts:
= 5819.55617814588−11856.710519967924+7153.19883219845092−398.552306730863623−1105.50944976046434+462.037335636928455−80.1427241437545216+6.20817014863516017−0.0694807701750850278−0.0162669811688017579+0.001655841713526189210+0.00006929632522616226711−0.000002717501943454439712+0.00000007064616657107387713−0.000000009515025937074542314+0.0000000002860443690645643515+0.00000000001267049131951151616−0.0000000000003295626766704682217−0.00000000000002015189023656628318+0.0000000000000005646444777139672019y= 5819.55617814588−11856.710519967924x+7153.1988321984509x2−398.55230673086362x3−1105.5094497604643x4+462.03733563692845x5−80.142724143754521x6+6.2081701486351601x7−0.069480770175085027x8−0.016266981168801757x9+0.0016558417135261892x10+0.000069296325226162267x11−0.0000027175019434544397x12+0.000000070646166571073877x13−0.0000000095150259370745423x14+0.00000000028604436906456435x15+0.000000000012670491319511516x16−0.00000000000032956267667046822x17−0.000000000000020151890236566283x18+0.00000000000000056464447771396720x19

or is there anyway to just code in a chart with exp per level?
what if we wanted to hotwire the code in RPGMZ

Game_Actor.prototype.expForLevel = function(level) {
const c = this.currentClass();
const basis = c.expParams[0];
const extra = c.expParams[1];
const acc_a = c.expParams[2];
const acc_b = c.expParams[3];
return Math.round(
(basis * Math.pow(level - 1, 0.9 + acc_a / 250) * level * (level + 1)) /
(6 + Math.pow(level, 2) / 50 / acc_b) +
(level - 1) * extra
);
};

I think this shows how the 4 exp curve parameters plug into a function and return a rounded number. (I know barely nothing about code, took java in uni like 20 years ago)

couldn't we edit this with an elaborate function or even a huge 18 part polynomial that specifies a function for each level? if so how could we write that? or does it have to be written as a plugin?

I found:

XP=3.78254−134.593+2572.62−10699+10703
(x = level)
//this one is kinda close and I would settle for it

and if we wanted to get really nuts:
= 5819.55617814588−11856.710519967924+7153.19883219845092−398.552306730863623−1105.50944976046434+462.037335636928455−80.1427241437545216+6.20817014863516017−0.0694807701750850278−0.0162669811688017579+0.001655841713526189210+0.00006929632522616226711−0.000002717501943454439712+0.00000007064616657107387713−0.000000009515025937074542314+0.0000000002860443690645643515+0.00000000001267049131951151616−0.0000000000003295626766704682217−0.00000000000002015189023656628318+0.0000000000000005646444777139672019y= 5819.55617814588−11856.710519967924x+7153.1988321984509x2−398.55230673086362x3−1105.5094497604643x4+462.03733563692845x5−80.142724143754521x6+6.2081701486351601x7−0.069480770175085027x8−0.016266981168801757x9+0.0016558417135261892x10+0.000069296325226162267x11−0.0000027175019434544397x12+0.000000070646166571073877x13−0.0000000095150259370745423x14+0.00000000028604436906456435x15+0.000000000012670491319511516x16−0.00000000000032956267667046822x17−0.000000000000020151890236566283x18+0.00000000000000056464447771396720x19

or is there anyway to just code in a chart with exp per level?
Sometimes, the KISS rule applies to stuff like this. What do you want to accomplish by having the exp curve be a polynomial function of degree 18? For most practical uses, you only really need a polynomial function of up to degree 4 to define an exp curve, and if you really need to adjust specific level thresholds, you can just bake the values into an exp table and adjust the individual exp per level thresholds.

And if you need the exp count to be quantized to a nice round number, you can try dividing the formula by the quantize value, either floor, round or ceiling the result, and then multiply it back up by the same quantize value. So something like:
JavaScript:
g(n) = Math.round( f(n)/50 ) * 50;
Where f(n) is the polynomial function, will give you g(n), a quantized exp value evaluated from f(n) and then rounded to the nearest 50. This is probably the approach you'd want to mimic the D&D 5e curve, since there is a common factor of 100 across all of the values, and from level 5 onwards, a common factor of 500. Just one caveat though, from levels 2-4 the function is exactly 300*3^(n-2), so you'd want to focus on finding a best fit curve for levels 5-20.
Sometimes, the KISS rule applies to stuff like this. What do you want to accomplish by having the exp curve be a polynomial function of degree 18? For most practical uses, you only really need a polynomial function of up to degree 4 to define an exp curve, and if you really need to adjust specific level thresholds, you can just bake the values into an exp table and adjust the individual exp per level thresholds.

And if you need the exp count to be quantized to a nice round number, you can try dividing the formula by the quantize value, either floor, round or ceiling the result, and then multiply it back up by the same quantize value. So something like:
JavaScript:
g(n) = Math.round( f(n)/50 ) * 50;
Where f(n) is the polynomial function, will give you g(n), a quantized exp value evaluated from f(n) and then rounded to the nearest 50. This is probably the approach you'd want to mimic the D&D 5e curve, since there is a common factor of 100 across all of the values, and from level 5 onwards, a common factor of 500. Just one caveat though, from levels 2-4 the function is exactly 300*3^(n-2), so you'd want to focus on finding a best fit curve for levels 5-20.
So you’re saying figuring out a number to plug in to each integer of the curve (basis, extra, acc_a, and acc_b) and adjust the original formula so that it yields the result?

You see I thought it would need a much simpler function too, but the drop at around 12th level really throws things for a loop. If I could get say the first 4 and last 4 experience amounts per level pretty much dead on to what D&D5E table is, I would be happy enough with that. I also just thought of dividing everything by 10 and living with that lol.

I know HIME has an Exp table plugin but it’s never worked for me. We can’t edit the actual curve table inside of RPGMZ (like we can for parameters) can we?
So you’re saying figuring out a number to plug in to each integer of the curve (basis, extra, acc_a, and acc_b) and adjust the original formula so that it yields the result?

You see I thought it would need a much simpler function too, but the drop at around 12th level really throws things for a loop. If I could get say the first 4 and last 4 experience amounts per level pretty much dead on to what D&D5E table is, I would be happy enough with that. I also just thought of dividing everything by 10 and living with that lol.

I know HIME has an Exp table plugin but it’s never worked for me. We can’t edit the actual curve table inside of RPGMZ (like we can for parameters) can we?
Well, this is the thread for the custom exp formula plugin, so we should be discussing formulae and approaches to generating your exp curve. After some fiddling, I came up with this JS code that will help you get as close to your desired values as possible. It gives the right values for Levels [1-5];[11-20], with close enough values given for Levels [6-10]
Code:
const a = 3.786;
const b = -134.3;
const c = 2572.6;
const d = -10824;
const e = 10703;
var quantVal = 500;
  if (n >= 5) {
    var polyFunc = a * Math.pow(n, 4) + b * Math.pow(n, 3) + c * Math.pow(n, 2) + d * n + e;
    if (n >= 6) { quantVal *= 2;}
    if (n >= 11) { quantVal *= 5;}
    Math.round(polyFunc/quantVal)*quantVal;
  } else if (n >= 2 && n < 5 ) {
    300 * Math.pow(3,n-2);
  } else {
    0;
  }
Well, this is the thread for the custom exp formula plugin, so we should be discussing formulae and approaches to generating your exp curve. After some fiddling, I came up with this JS code that will help you get as close to your desired values as possible. It gives the right values for Levels [1-5];[11-20], with close enough values given for Levels [6-10]
Code:
const a = 3.786;
const b = -134.3;
const c = 2572.6;
const d = -10824;
const e = 10703;
var quantVal = 500;
  if (n >= 5) {
    var polyFunc = a * Math.pow(n, 4) + b * Math.pow(n, 3) + c * Math.pow(n, 2) + d * n + e;
    if (n >= 6) { quantVal *= 2;}
    if (n >= 11) { quantVal *= 5;}
    Math.round(polyFunc/quantVal)*quantVal;
  } else if (n >= 2 && n < 5 ) {
    300 * Math.pow(3,n-2);
  } else {
    0;
  }
That’s great thanks so much!

Original thread: https://forums.rpgmakerweb.com/threads/tdw-experience-curve-customization.127146/