From a8528e67053a677c9922bfc5aad00d3a2b6bd016 Mon Sep 17 00:00:00 2001 From: flx-sta <50131232+flx-sta@users.noreply.github.com> Date: Wed, 25 Sep 2024 08:52:08 -0700 Subject: [PATCH] fix: new pokemon not being hidden initially When switching the active pokemon (slot 1) with the new one, the new ones visibility is `true` causing a crash with animation frames --- src/field/pokemon.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 14f93809414..47bdc8ad731 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -4899,6 +4899,7 @@ export class EnemyPokemon extends Pokemon { /** * Add a new pokemon to the player's party (at `slotIndex` if set). + * If the first slot is replaced, the new pokemons visibility will be set to `false`. * @param pokeballType the type of pokeball the pokemon was caught with * @param slotIndex an optional index to place the pokemon in the party * @returns the pokemon that was added or null if the pokemon could not be added @@ -4916,6 +4917,9 @@ export class EnemyPokemon extends Pokemon { const newPokemon = this.scene.addPlayerPokemon(this.species, this.level, this.abilityIndex, this.formIndex, this.gender, this.shiny, this.variant, this.ivs, this.nature, this); if (Utils.isBetween(slotIndex, 0, PLAYER_PARTY_MAX_SIZE - 1)) { + if (slotIndex === 0) { + newPokemon.setVisible(false); // Hide if replaced with first pokemon + } party.splice(slotIndex, 0, newPokemon); } else { party.push(newPokemon);