Fix softlock with switch out moves used on player

This commit is contained in:
Flashfyre 2024-03-28 00:05:48 -04:00
parent 211d8d3636
commit 2cc38ac2cb
2 changed files with 7 additions and 2 deletions

View File

@ -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();

View File

@ -2057,7 +2057,7 @@ export class PlayerPokemon extends Pokemon {
return true;
}
switchOut(batonPass: boolean): Promise<void> {
switchOut(batonPass: boolean, removeFromField: boolean = false): Promise<void> {
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);
});