[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>
This commit is contained in:
flx-sta 2024-09-25 19:33:30 -07:00 committed by GitHub
parent 029d26b4c9
commit 67d8ec1d42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 0 deletions

View File

@ -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);