From f2c35e36ef53140690a23a3cc7b55b31a73bc29e Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 5 Jul 2023 13:03:51 -0400 Subject: [PATCH] Add failsafe for held item on nonexistent Pokemon --- src/battle-scene.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index c27fbb328..7ed05637e 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -898,6 +898,11 @@ export default class BattleScene extends Phaser.Scene { player = true; return new Promise(resolve => { const modifiers = player ? this.modifiers : this.enemyModifiers as PersistentModifier[]; + for (let m = 0; m < modifiers.length; m++) { + const modifier = modifiers[m]; + if (modifier instanceof PokemonHeldItemModifier && !this.getPokemonById((modifier as PokemonHeldItemModifier).pokemonId)) + modifiers.splice(m--, 1); + } for (let modifier of modifiers) { if (modifier instanceof PersistentModifier) (modifier as PersistentModifier).virtualStackCount = 0;