[P1] Fix crash when newly aquired Pokemon are sent in battle (#4835)
This commit is contained in:
parent
265b3cb938
commit
44a68a91ba
|
@ -305,7 +305,7 @@ async function showWobbuffetHealthBar(scene: BattleScene) {
|
|||
scene.field.add(wobbuffet);
|
||||
|
||||
const playerPokemon = scene.getPlayerPokemon() as Pokemon;
|
||||
if (playerPokemon?.visible) {
|
||||
if (playerPokemon?.isOnField()) {
|
||||
scene.field.moveBelow(wobbuffet, playerPokemon);
|
||||
}
|
||||
// Show health bar and trigger cry
|
||||
|
|
|
@ -5113,7 +5113,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`.
|
||||
* 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
|
||||
|
@ -5131,14 +5131,14 @@ 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);
|
||||
}
|
||||
|
||||
// Hide the Pokemon since it is not on the field
|
||||
newPokemon.setVisible(false);
|
||||
|
||||
ret = newPokemon;
|
||||
this.scene.triggerPokemonFormChange(newPokemon, SpeciesFormChangeActiveTrigger, true);
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ export class EncounterPhase extends BattlePhase {
|
|||
this.scene.field.add(enemyPokemon);
|
||||
battle.seenEnemyPartyMemberIds.add(enemyPokemon.id);
|
||||
const playerPokemon = this.scene.getPlayerPokemon();
|
||||
if (playerPokemon?.visible) {
|
||||
if (playerPokemon?.isOnField()) {
|
||||
this.scene.field.moveBelow(enemyPokemon as Pokemon, playerPokemon);
|
||||
}
|
||||
enemyPokemon.tint(0, 0.5);
|
||||
|
|
|
@ -140,7 +140,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
|||
this.scene.field.add(pokemon);
|
||||
if (!this.player) {
|
||||
const playerPokemon = this.scene.getPlayerPokemon() as Pokemon;
|
||||
if (playerPokemon?.visible) {
|
||||
if (playerPokemon?.isOnField()) {
|
||||
this.scene.field.moveBelow(pokemon, playerPokemon);
|
||||
}
|
||||
this.scene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id);
|
||||
|
@ -193,7 +193,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
|
|||
this.scene.field.add(pokemon);
|
||||
if (!this.player) {
|
||||
const playerPokemon = this.scene.getPlayerPokemon() as Pokemon;
|
||||
if (playerPokemon?.visible) {
|
||||
if (playerPokemon?.isOnField()) {
|
||||
this.scene.field.moveBelow(pokemon, playerPokemon);
|
||||
}
|
||||
this.scene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id);
|
||||
|
|
Loading…
Reference in New Issue