From 67d8ec1d42037049a1da8a5f395a9ffe8bff96c6 Mon Sep 17 00:00:00 2001 From: flx-sta <50131232+flx-sta@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:33:30 -0700 Subject: [PATCH] [P1 Bug] Fix freeze after replacing first pokemon (#4427) * 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 * chore: fix typo Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> --------- Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> --- src/field/pokemon.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 21deb3790e1..871c7160cc2 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -4901,6 +4901,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 pokemon's 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 @@ -4918,6 +4919,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);