Okay, what a shame... tried some things on my end as well, and I actually got the menu where you can select "retry", but still nothing happens.
Easy reset battle effect? (Items revert too)
RPG Maker MZ SupportAh the eternal VisuStella compatibility problem...
I made a tiny plugin that does the job by relying on Skills formula. Just put
And now this skill will have the special effect of restarting the battle.
I made a tiny plugin that does the job by relying on Skills formula. Just put
restart_battle as the skill's formula:And now this skill will have the special effect of restarting the battle.
JavaScript:
(() => {
// New method to reset a battle
Scene_Battle.prototype.reset = function() {
if (BattleManager._preBattleData) {
globalThis.$gameParty = JsonEx.parse(BattleManager._preBattleData.gameParty);
globalThis.$gameActors = JsonEx.parse(BattleManager._preBattleData.gameActors);
}
BattleManager.setup($gameTroop._troopId, BattleManager._canEscape, BattleManager._canLose, false);
this.initialize();
this.create();
this.start();
}
// When a battle is starting, save gameParty and gameActors state, unless this
// method is called during a Battle reset (thus the 4th argument)
const BattleManager_setup = BattleManager.setup;
BattleManager.setup = function(troopId, canEscape, canLose, firstIteration = true) {
BattleManager_setup.call(this, troopId, canEscape, canLose);
if (firstIteration) {
BattleManager._preBattleData = {
gameParty: JsonEx.stringify($gameParty),
gameActors: JsonEx.stringify($gameActors)
};
}
};
// When processing a battle turn, check for special actions
const BattleManager_processTurn = BattleManager.processTurn;
BattleManager.processTurn = function() {
const subject = this._subject;
const action = subject.currentAction();
if (!action) {
return BattleManager_processTurn.call(this);
}
const item = action.item();
const formula = item.damage.formula;
switch (formula) {
case 'restart_battle':
SceneManager._scene.reset();
break;
default:
BattleManager_processTurn.call(this);
break;
}
}
})();
@Jobhob Did this plugin work for you?
After that I put it above visumz plugins, and this skill stopped crashing, but then I suddenly got crash from turn end?
It's neat, but I guess it could use some tinkering
Intersting... I confirm the plugin should be after VisuMZ because if another plugin tries to process a skill's formula and that formula happens to be
Let me see what could have gone wrong here. It says it's trying to read property "damage" of null. Which means at some point you made an action of which the
restart_battle, it will deal NaN damage.Let me see what could have gone wrong here. It says it's trying to read property "damage" of null. Which means at some point you made an action of which the
item() (skill/item) was null. I didn't think that was possible so I didn't do any checks. I'll add some error management to fallback on the default behaviour when that happens.Original thread: https://forums.rpgmakerweb.com/threads/easy-reset-battle-effect-items-revert-too.163880/