diff --git a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts index 934fc1b805b..fa445d75d4f 100644 --- a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts +++ b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts @@ -582,7 +582,13 @@ function doPokemonTradeSequence(scene: BattleScene, tradedPokemon: PlayerPokemon receivedPokemonTintSprite.setTintFill(getPokeballTintColor(receivedPokemon.pokeball)); [ tradedPokemonSprite, tradedPokemonTintSprite ].map(sprite => { - sprite.play(tradedPokemon.getSpriteKey(true)); + const spriteKey = tradedPokemon.getSpriteKey(true); + try { + sprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } + sprite.setPipeline(scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(tradedPokemon.getTeraType()) }); sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", tradedPokemon.getSpriteKey()); @@ -597,7 +603,13 @@ function doPokemonTradeSequence(scene: BattleScene, tradedPokemon: PlayerPokemon }); [ receivedPokemonSprite, receivedPokemonTintSprite ].map(sprite => { - sprite.play(receivedPokemon.getSpriteKey(true)); + const spriteKey = receivedPokemon.getSpriteKey(true); + try { + sprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } + sprite.setPipeline(scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(tradedPokemon.getTeraType()) }); sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", receivedPokemon.getSpriteKey()); diff --git a/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts b/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts index fcadb101817..424ba15f811 100644 --- a/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts +++ b/src/data/mystery-encounters/utils/encounter-transformation-sequence.ts @@ -54,7 +54,13 @@ export function doPokemonTransformationSequence(scene: BattleScene, previousPoke pokemonEvoTintSprite.setTintFill(0xFFFFFF); [ pokemonSprite, pokemonTintSprite, pokemonEvoSprite, pokemonEvoTintSprite ].map(sprite => { - sprite.play(previousPokemon.getSpriteKey(true)); + const spriteKey = previousPokemon.getSpriteKey(true); + try { + sprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } + sprite.setPipeline(scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(previousPokemon.getTeraType()) }); sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", previousPokemon.getSpriteKey()); @@ -69,7 +75,13 @@ export function doPokemonTransformationSequence(scene: BattleScene, previousPoke }); [ pokemonEvoSprite, pokemonEvoTintSprite ].map(sprite => { - sprite.play(transformPokemon.getSpriteKey(true)); + const spriteKey = transformPokemon.getSpriteKey(true); + try { + sprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } + sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", transformPokemon.getSpriteKey()); sprite.setPipelineData("shiny", transformPokemon.shiny); diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index c22c755fc6e..6aa4bd46a68 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3741,8 +3741,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { setFrameRate(frameRate: integer) { this.scene.anims.get(this.getBattleSpriteKey()).frameRate = frameRate; - this.getSprite().play(this.getBattleSpriteKey()); - this.getTintSprite()?.play(this.getBattleSpriteKey()); + try { + this.getSprite().play(this.getBattleSpriteKey()); + } catch (err: unknown) { + console.error(`Failed to play animation for ${this.getBattleSpriteKey()}`, err); + } + try { + this.getTintSprite()?.play(this.getBattleSpriteKey()); + } catch (err: unknown) { + console.error(`Failed to play animation for ${this.getBattleSpriteKey()}`, err); + } } tint(color: number, alpha?: number, duration?: integer, ease?: string) { diff --git a/src/phases/egg-hatch-phase.ts b/src/phases/egg-hatch-phase.ts index d45c580228c..803fd478fd4 100644 --- a/src/phases/egg-hatch-phase.ts +++ b/src/phases/egg-hatch-phase.ts @@ -330,7 +330,12 @@ export class EggHatchPhase extends Phase { this.scene.validateAchv(achvs.HATCH_SHINY); } this.eggContainer.setVisible(false); - this.pokemonSprite.play(this.pokemon.getSpriteKey(true)); + const spriteKey = this.pokemon.getSpriteKey(true); + try { + this.pokemonSprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } this.pokemonSprite.setPipelineData("ignoreTimeTint", true); this.pokemonSprite.setPipelineData("spriteKey", this.pokemon.getSpriteKey()); this.pokemonSprite.setPipelineData("shiny", this.pokemon.shiny); diff --git a/src/phases/evolution-phase.ts b/src/phases/evolution-phase.ts index 36bd3b7bd81..76e521c9b3d 100644 --- a/src/phases/evolution-phase.ts +++ b/src/phases/evolution-phase.ts @@ -105,7 +105,13 @@ export class EvolutionPhase extends Phase { this.scene.ui.add(this.evolutionOverlay); [ this.pokemonSprite, this.pokemonTintSprite, this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { - sprite.play(this.pokemon.getSpriteKey(true)); + const spriteKey = this.pokemon.getSpriteKey(true); + try { + sprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } + sprite.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(this.pokemon.getTeraType()) }); sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", this.pokemon.getSpriteKey()); @@ -130,7 +136,13 @@ export class EvolutionPhase extends Phase { this.pokemon.getPossibleEvolution(this.evolution).then(evolvedPokemon => { [ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { - sprite.play(evolvedPokemon.getSpriteKey(true)); + const spriteKey = evolvedPokemon.getSpriteKey(true); + try { + sprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } + sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", evolvedPokemon.getSpriteKey()); sprite.setPipelineData("shiny", evolvedPokemon.shiny); diff --git a/src/phases/form-change-phase.ts b/src/phases/form-change-phase.ts index 410163a70e4..b042cd98294 100644 --- a/src/phases/form-change-phase.ts +++ b/src/phases/form-change-phase.ts @@ -39,7 +39,13 @@ export class FormChangePhase extends EvolutionPhase { this.pokemon.getPossibleForm(this.formChange).then(transformedPokemon => { [ this.pokemonEvoSprite, this.pokemonEvoTintSprite ].map(sprite => { - sprite.play(transformedPokemon.getSpriteKey(true)); + const spriteKey = transformedPokemon.getSpriteKey(true); + try { + sprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } + sprite.setPipelineData("ignoreTimeTint", true); sprite.setPipelineData("spriteKey", transformedPokemon.getSpriteKey()); sprite.setPipelineData("shiny", transformedPokemon.shiny); diff --git a/src/phases/quiet-form-change-phase.ts b/src/phases/quiet-form-change-phase.ts index 6c84c0d1a8a..c9e5bec845d 100644 --- a/src/phases/quiet-form-change-phase.ts +++ b/src/phases/quiet-form-change-phase.ts @@ -43,7 +43,12 @@ export class QuietFormChangePhase extends BattlePhase { const getPokemonSprite = () => { const sprite = this.scene.addPokemonSprite(this.pokemon, this.pokemon.x + this.pokemon.getSprite().x, this.pokemon.y + this.pokemon.getSprite().y, "pkmn__sub"); sprite.setOrigin(0.5, 1); - sprite.play(this.pokemon.getBattleSpriteKey()).stop(); + const spriteKey = this.pokemon.getBattleSpriteKey(); + try { + sprite.play(spriteKey).stop(); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } sprite.setPipeline(this.scene.spritePipeline, { tone: [ 0.0, 0.0, 0.0, 0.0 ], hasShadow: false, teraColor: getTypeRgb(this.pokemon.getTeraType()) }); [ "spriteColors", "fusionSpriteColors" ].map(k => { if (this.pokemon.summonData?.speciesForm) { @@ -81,7 +86,12 @@ export class QuietFormChangePhase extends BattlePhase { this.pokemon.setVisible(false); this.pokemon.changeForm(this.formChange).then(() => { pokemonFormTintSprite.setScale(0.01); - pokemonFormTintSprite.play(this.pokemon.getBattleSpriteKey()).stop(); + const spriteKey = this.pokemon.getBattleSpriteKey(); + try { + pokemonFormTintSprite.play(spriteKey).stop(); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } pokemonFormTintSprite.setVisible(true); this.scene.tweens.add({ targets: pokemonTintSprite, diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 2e05f3de4c1..63ef6155fbc 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -321,8 +321,12 @@ export default class SummaryUiHandler extends UiHandler { this.numberText.setText(Utils.padInt(this.pokemon.species.speciesId, 4)); this.numberText.setColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD)); this.numberText.setShadowColor(this.getTextColor(!this.pokemon.isShiny() ? TextStyle.SUMMARY : TextStyle.SUMMARY_GOLD, true)); - - this.pokemonSprite.play(this.pokemon.getSpriteKey(true)); + const spriteKey = this.pokemon.getSpriteKey(true); + try { + this.pokemonSprite.play(spriteKey); + } catch (err: unknown) { + console.error(`Failed to play animation for ${spriteKey}`, err); + } this.pokemonSprite.setPipelineData("teraColor", getTypeRgb(this.pokemon.getTeraType())); this.pokemonSprite.setPipelineData("ignoreTimeTint", true); this.pokemonSprite.setPipelineData("spriteKey", this.pokemon.getSpriteKey());