Extra Stats + Varied Levelups

So basically here is what I am wanting to achieve. I want to add 4 stats to my game, Strength (STR), Vitality (VIT), Spirit (SPI), and Intellegence (INT). When a character levels, instead of having a set number it goes up per level, I want some form of variance.

I want to be able to set a range per class that any of these 4 stats can increase per level. Now with that I dont want any of MVs default stats to increase by the parameters in the database. I want it so that ATK is equal to STR, DEF is equal to a formula based on VIT and AGI, MAT is based on INT and MDF is based on SPI. AGI and LUK can increase by a range per level.

The way I want HP to work is that it will by default go up by a small set range, but if you gain any points of VIT on this level, you gain, say, 10 extra points of HP per point of VIT that level. Same with MP and INT. Itll go up a small set range but any points of INT will give say 5 extra points of MP per level.

If you need any extra details I can provide whatever you need. I don't know enough JS to do this myself, so I hope someone knows how to do this.

Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/extra-stats-varied-levelups.116179/