I think a small plugin might be the easiest way to do this. It can read each actor’s growth straight from their class, so the same item works for every actor even if they grow differently.
Make a new text file in your project’s js/plugins folder named LevelGrowthItems.js and paste this in. Then add it in the Plugin Manager below your Yanfly plugins:
/*:
* @plugindesc Items with <Level Growth> in their note give the target one level's worth of stat growth.
*/
(function() {
function levelGrowth(actor) {
var level = actor._level;
var high = Math.min(level + 1, actor.maxLevel());
var low = high - 1;
for (var i = 2; i < 8; i++) {
actor._level = high;
var gain = actor.paramBase(i);
actor._level = low;
gain -= actor.paramBase(i);
actor._level = level;
actor.addParam(i, gain);
}
}
var _testApply = Game_Action.prototype.testApply;
Game_Action.prototype.testApply = function(target) {
if (this.item().meta['Level Growth'] && target.isActor()) {
return this.isForDeadFriend() === target.isDead();
}
return _testApply.call(this, target);
};
var _apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
_apply.call(this, target);
if (this.item().meta['Level Growth'] && target.isActor() && target.result().isHit()) {
levelGrowth(target);
this.makeSuccess(target);
}
};
})();
Next, put <Level Growth> in the item’s note box and set its scope to 1 Ally. When it’s used, the actor gains the Attack, Defense, M. Attack, M. Defense, Agility and Luck they would get from their next level up. To include Max HP and Max MP too, change i = 2 to i = 0.
it’s nice, but is there a version where it can be applied through a common event? (incase you got like a ton of these and i am using input number event to add each one of these)
also yeah, include all stats as well.
example: input number is 125, making a variable be 125, so that effect is repeated 125 times
This version includes Max HP and Max MP and adds a script call you can use from a common event. Replace everything in LevelGrowthItems.js with it:
/*:
* @plugindesc Level up stat growth from <Level Growth> items or a script call.
*/
(function() {
Game_Actor.prototype.gainLevelGrowth = function(times) {
if (times === undefined) times = 1;
var level = this._level;
var high = Math.min(level + 1, this.maxLevel());
var low = high - 1;
for (var i = 0; i < 8; i++) {
this._level = high;
var gain = this.paramBase(i);
this._level = low;
gain -= this.paramBase(i);
this._level = level;
this.addParam(i, gain * times);
}
};
var _testApply = Game_Action.prototype.testApply;
Game_Action.prototype.testApply = function(target) {
if (this.item().meta['Level Growth'] && target.isActor()) {
return this.isForDeadFriend() === target.isDead();
}
return _testApply.call(this, target);
};
var _apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
_apply.call(this, target);
if (this.item().meta['Level Growth'] && target.isActor() && target.result().isHit()) {
target.gainLevelGrowth(1);
this.makeSuccess(target);
}
};
})();
Then in your common event, after the Input Number, add a Script command with this line. Change the 1 to the ID of the variable your Input Number saves to:
$gameParty.targetActor() is whoever got picked when the item was used from the menu. So on the item I’d add a Common Event effect that calls your common event, and set Scope to 1 Ally and Occasion to Menu Screen. Take <Level Growth> off its note too so it doesn’t add an extra level’s worth on top. I’d also set Consumable to No and let the common event take them away with a Change Items that decreases by that same variable.
If you’d rather run the common event from somewhere else, like an NPC, swap $gameParty.targetActor() for $gameActors.actor(1) with the actor’s ID in place of the 1.