続いて同じく次のスクリプトを上書き

○戦闘で全滅した際にスイッチ0001番をONにする処理
BattleManager.updateBattleEnd = function() {
if (this.isBattleTest()) {
AudioManager.stopBgm();
SceneManager.exit();
} else if (!this._escaped && $gameParty.isAllDead()) {
if (this._canLose) {
$gameParty.reviveBattleMembers();
$gameSwitches.setValue(1, true); // 追加部分
SceneManager.pop();
} else {
SceneManager.goto(Scene_Gameover);
}
} else {
SceneManager.pop();
}
this._phase = "";
};

次に敵グループのバトルイベントで

条件:ターン 1+0*X
中身:変数の操作:#001 敗北イベントID = 1

ここでの敗北イベントIDは敵によって変える。