MZ Keeping a percentage of stats on class change.

Again, I have not seen this ingame so I figured I might ask, is there a plugin out there that would allow me to do this:
So in my game, there are 4 classes this character can choose from, when he changes classes he is reverted to level 1, but when this happens, I would like the character to keep a % of his stats(lets say 10%) that he had before he changed classes, so if he had 900 hp, he would keep 90 HP + the hp of the level 1 class. I hope this is possible and makes sense.
try this as a plugin and it should make it so that your actors retain 10% of the base stats had before their most recent class change.

Code:
(() => {
var actorBaseParam = Game_Actor.prototype.paramBase
Game_Actor.prototype.paramBase = function(paramId) {
    return actorBaseParam.call(this, paramId) + (this._classChangeParams ? this._classChangeParams[paramId]/10 : 0)
};

var actorChangeClass = Game_Actor.prototype.changeClass
Game_Actor.prototype.changeClass = function(classId, keepExp) {
    this._classChangeParams = []
    this.currentClass().params.forEach(param => this._classChangeParams.push(param[this._level]))
    actorChangeClass.call(this, classId, keepExp)
};
})();
try this as a plugin and it should make it so that your actors retain 10% of the base stats had before their most recent class change.

Code:
(() => {
var actorBaseParam = Game_Actor.prototype.paramBase
Game_Actor.prototype.paramBase = function(paramId) {
    return actorBaseParam.call(this, paramId) + (this._classChangeParams ? this._classChangeParams[paramId]/10 : 0)
};

var actorChangeClass = Game_Actor.prototype.changeClass
Game_Actor.prototype.changeClass = function(classId, keepExp) {
    this._classChangeParams = []
    this.currentClass().params.forEach(param => this._classChangeParams.push(param[this._level]))
    actorChangeClass.call(this, classId, keepExp)
};
})();
Just confirmed, it works, nicely done, but does this take any 'temporary' effects that may grant stat boosts into consideration(It shouldn't)? I don't want my players exploiting passives or equipping gear just to get better stats when they swap.
but does this take any 'temporary' effects that may grant stat boosts into consideration
nope. I figured that you might have wanted it to not.
for actors, what the engine refers to as their "base parameters" is the stats for their class at their current level. the only stats the plugin uses and adjusts are those. gear, states, buffs, and grow parameter effects are not counted

Original thread: https://forums.rpgmakerweb.com/threads/keeping-a-percentage-of-stats-on-class-change.175314/