From 2cc38ac2cb0c84ae26a73bf2f8cf30cc5956ecc4 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 28 Mar 2024 00:05:48 -0400 Subject: [PATCH] Fix softlock with switch out moves used on player --- src/data/move.ts | 2 +- src/field/pokemon.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index b73cccc89d9..78f85c25eb9 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -2096,7 +2096,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { return resolve(false); const switchOutTarget = this.user ? user : target; if (switchOutTarget instanceof PlayerPokemon) { - (switchOutTarget as PlayerPokemon).switchOut(this.batonPass).then(() => resolve(true)); + (switchOutTarget as PlayerPokemon).switchOut(this.batonPass, true).then(() => resolve(true)); return; } else if (user.scene.currentBattle.battleType) { switchOutTarget.resetTurnData(); diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index ce606b97f75..ad2ca877d9f 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2057,7 +2057,7 @@ export class PlayerPokemon extends Pokemon { return true; } - switchOut(batonPass: boolean): Promise { + switchOut(batonPass: boolean, removeFromField: boolean = false): Promise { return new Promise(resolve => { this.resetTurnData(); this.resetSummonData(); @@ -2067,6 +2067,11 @@ export class PlayerPokemon extends Pokemon { this.scene.ui.setMode(Mode.PARTY, PartyUiMode.FAINT_SWITCH, this.getFieldIndex(), (slotIndex: integer, option: PartyOption) => { if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, this.getFieldIndex(), slotIndex, false, batonPass)); + if (removeFromField) { + this.setVisible(false); + this.scene.field.remove(this); + this.scene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true); + } this.scene.ui.setMode(Mode.MESSAGE).then(() => resolve()); }, PartyUiHandler.FilterNonFainted); });