From eea0f4b3ee38df166e5d1b22ac6df35dd3d1dcaf Mon Sep 17 00:00:00 2001 From: MokaStitcher Date: Sun, 20 Oct 2024 21:55:15 +0200 Subject: [PATCH] revert fix for Keldeo crashes + implement fix suggestion from PR #4619 --- src/field/pokemon.ts | 5 ++++- src/phases/encounter-phase.ts | 7 ------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 14abbc6f38f..7a3d44bf36d 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2189,7 +2189,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.moveset.push(new PokemonMove(movePool[index][0], 0, 0)); } - this.scene.triggerPokemonFormChange(this, SpeciesFormChangeMoveLearnedTrigger); + // Trigger FormChange, except for enemy Pokemon during Mystery Encounters, to avoid crashes + if (this.isPlayer() || !this.scene.currentBattle.isBattleMysteryEncounter() || !this.scene.currentBattle.mysteryEncounter) { + this.scene.triggerPokemonFormChange(this, SpeciesFormChangeMoveLearnedTrigger); + } } trySelectMove(moveIndex: integer, ignorePp?: boolean): boolean { diff --git a/src/phases/encounter-phase.ts b/src/phases/encounter-phase.ts index eaffb383c60..b7071c4cc6f 100644 --- a/src/phases/encounter-phase.ts +++ b/src/phases/encounter-phase.ts @@ -36,7 +36,6 @@ import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; import { getGoldenBugNetSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { Biome } from "#enums/biome"; import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; export class EncounterPhase extends BattlePhase { private loaded: boolean; @@ -385,12 +384,6 @@ export class EncounterPhase extends BattlePhase { encounter.onVisualsStart(this.scene); } - // Clear any lingering QuietFormChangePhases which can be inadvertently added by certain wild Pokemon forms - let phaseRemoved: boolean = true; - while (phaseRemoved) { - phaseRemoved = this.scene.tryRemoveUnshiftedPhase(phase => phase instanceof QuietFormChangePhase); - } - const doEncounter = () => { const doShowEncounterOptions = () => { this.scene.ui.clearText();