From e053ead67cbe4c19aeadb9d61ae5bb791c7a0411 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Sun, 25 May 2025 13:37:52 -0500 Subject: [PATCH] [Bug] Fix crash caused by switching in a transformed pokemon (#5864) * Force reset summon data and load assets prior to switch in * Update src/phases/switch-summon-phase.ts --- src/phases/switch-summon-phase.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/phases/switch-summon-phase.ts b/src/phases/switch-summon-phase.ts index a063b6e6863..3e9cc7718f1 100644 --- a/src/phases/switch-summon-phase.ts +++ b/src/phases/switch-summon-phase.ts @@ -124,6 +124,12 @@ export class SwitchSummonPhase extends SummonPhase { const switchedInPokemon: Pokemon | undefined = party[this.slotIndex]; this.lastPokemon = this.getPokemon(); + // Defensive programming: Overcome the bug where the summon data has somehow not been reset + // prior to switching in a new Pokemon. + // Force the switch to occur and load the assets for the new pokemon, ignoring override. + switchedInPokemon.resetSummonData(); + switchedInPokemon.loadAssets(true); + applyPreSummonAbAttrs(PreSummonAbAttr, switchedInPokemon); applyPreSwitchOutAbAttrs(PreSwitchOutAbAttr, this.lastPokemon); if (!switchedInPokemon) { @@ -131,6 +137,7 @@ export class SwitchSummonPhase extends SummonPhase { return; } + if (this.switchType === SwitchType.BATON_PASS) { // If switching via baton pass, update opposing tags coming from the prior pokemon (this.player ? globalScene.getEnemyField() : globalScene.getPlayerField()).forEach((enemyPokemon: Pokemon) =>