From d135591b756256e9b5781ffa0b09d145508d4375 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 24 Oct 2023 08:34:52 -0400 Subject: [PATCH] Fix crash when playing weather animation before a trainer battle --- src/data/battle-anims.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index 63b86f320..81f2c2752 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -330,7 +330,9 @@ class AnimTimedAddBgEvent extends AnimTimedBgEvent { moveAnim.bgSprite.setScale(1.25); moveAnim.bgSprite.setAlpha(this.opacity / 255); scene.field.add(moveAnim.bgSprite); - scene.field.moveBelow(moveAnim.bgSprite as Phaser.GameObjects.GameObject, scene.getEnemyPokemon() || scene.getPlayerPokemon()); + const fieldPokemon = scene.getEnemyPokemon() || scene.getPlayerPokemon(); + if (fieldPokemon?.isOnField()) + scene.field.moveBelow(moveAnim.bgSprite as Phaser.GameObjects.GameObject, fieldPokemon); scene.tweens.add({ targets: moveAnim.bgSprite,