From 9273b4930d929cd9c8fb67466ea2501e8ffb8bf4 Mon Sep 17 00:00:00 2001 From: innerthunder <168692175+innerthunder@users.noreply.github.com> Date: Fri, 15 Nov 2024 08:56:05 -0800 Subject: [PATCH] [Beta][P1] Fix crash when resetting Commanded Dondozo before Trainer battles (#4873) * Add failsafe to Commander remove anim * Commanded tag saves Tatsu form on reload --- src/data/battler-tags.ts | 5 +++++ src/phases/pokemon-anim-phase.ts | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 5c6d9d66b7c..28ab5ff2a4f 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -2158,6 +2158,11 @@ export class CommandedTag extends BattlerTag { pokemon.scene.triggerPokemonBattleAnim(pokemon, PokemonAnimType.COMMANDER_REMOVE); } } + + override loadTag(source: BattlerTag | any): void { + super.loadTag(source); + this._tatsugiriFormKey = source._tatsugiriFormKey; + } } /** diff --git a/src/phases/pokemon-anim-phase.ts b/src/phases/pokemon-anim-phase.ts index ad0be34af7d..eb5431cbc56 100644 --- a/src/phases/pokemon-anim-phase.ts +++ b/src/phases/pokemon-anim-phase.ts @@ -312,6 +312,10 @@ export class PokemonAnimPhase extends BattlePhase { // Note: unlike the other Commander animation, this is played through the // Dondozo instead of the Tatsugiri. const tatsugiri = this.pokemon.getAlly(); + if (isNullOrUndefined(tatsugiri)) { + console.warn("Aborting COMMANDER_REMOVE anim: Tatsugiri is undefined"); + return this.end(); + } const tatsuSprite = this.scene.addPokemonSprite( tatsugiri,