mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-29 19:52:27 +02:00
Use leaveField everywhere
This commit is contained in:
parent
b922e94d0b
commit
e60939ec04
@ -148,7 +148,7 @@ export const DancingLessonsEncounter: MysteryEncounter =
|
|||||||
|
|
||||||
// Adds a real Pokemon sprite to the field (required for the animation)
|
// Adds a real Pokemon sprite to the field (required for the animation)
|
||||||
globalScene.getEnemyParty().forEach(enemyPokemon => {
|
globalScene.getEnemyParty().forEach(enemyPokemon => {
|
||||||
globalScene.field.remove(enemyPokemon, true);
|
enemyPokemon.leaveField(true, true, true);
|
||||||
});
|
});
|
||||||
globalScene.currentBattle.enemyParty = [ oricorio ];
|
globalScene.currentBattle.enemyParty = [ oricorio ];
|
||||||
globalScene.field.add(oricorio);
|
globalScene.field.add(oricorio);
|
||||||
|
@ -229,7 +229,7 @@ function handleLoseMinigame() {
|
|||||||
// End the battle
|
// End the battle
|
||||||
if (wobbuffet) {
|
if (wobbuffet) {
|
||||||
wobbuffet.hideInfo();
|
wobbuffet.hideInfo();
|
||||||
globalScene.field.remove(wobbuffet);
|
wobbuffet.leaveField();
|
||||||
}
|
}
|
||||||
transitionMysteryEncounterIntroVisuals(true, true);
|
transitionMysteryEncounterIntroVisuals(true, true);
|
||||||
globalScene.currentBattle.enemyParty = [];
|
globalScene.currentBattle.enemyParty = [];
|
||||||
@ -278,7 +278,7 @@ function handleNextTurn() {
|
|||||||
|
|
||||||
// End the battle
|
// End the battle
|
||||||
wobbuffet.hideInfo();
|
wobbuffet.hideInfo();
|
||||||
globalScene.field.remove(wobbuffet);
|
wobbuffet.leaveField();
|
||||||
globalScene.currentBattle.enemyParty = [];
|
globalScene.currentBattle.enemyParty = [];
|
||||||
globalScene.currentBattle.mysteryEncounter!.doContinueEncounter = undefined;
|
globalScene.currentBattle.mysteryEncounter!.doContinueEncounter = undefined;
|
||||||
leaveEncounterWithoutBattle(isHealPhase);
|
leaveEncounterWithoutBattle(isHealPhase);
|
||||||
|
@ -575,7 +575,7 @@ function onGameOver() {
|
|||||||
ease: "Sine.easeIn",
|
ease: "Sine.easeIn",
|
||||||
scale: 0.5,
|
scale: 0.5,
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
globalScene.field.remove(pokemon, true);
|
pokemon.leaveField(true, true, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig):
|
|||||||
}
|
}
|
||||||
|
|
||||||
globalScene.getEnemyParty().forEach(enemyPokemon => {
|
globalScene.getEnemyParty().forEach(enemyPokemon => {
|
||||||
globalScene.field.remove(enemyPokemon, true);
|
enemyPokemon.leaveField(true, true, true);
|
||||||
});
|
});
|
||||||
battle.enemyParty = [];
|
battle.enemyParty = [];
|
||||||
battle.double = doubleBattle;
|
battle.double = doubleBattle;
|
||||||
@ -809,7 +809,7 @@ export function transitionMysteryEncounterIntroVisuals(hide: boolean = true, des
|
|||||||
globalScene.field.remove(introVisuals, true);
|
globalScene.field.remove(introVisuals, true);
|
||||||
|
|
||||||
enemyPokemon.forEach(pokemon => {
|
enemyPokemon.forEach(pokemon => {
|
||||||
globalScene.field.remove(pokemon, true);
|
pokemon.leaveField(true, true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
globalScene.currentBattle.mysteryEncounter!.introVisuals = undefined;
|
globalScene.currentBattle.mysteryEncounter!.introVisuals = undefined;
|
||||||
|
@ -592,7 +592,7 @@ export async function catchPokemon(pokemon: EnemyPokemon, pokeball: Phaser.GameO
|
|||||||
};
|
};
|
||||||
const removePokemon = () => {
|
const removePokemon = () => {
|
||||||
if (pokemon) {
|
if (pokemon) {
|
||||||
globalScene.field.remove(pokemon, true);
|
pokemon.leaveField(true, true, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const addToParty = (slotIndex?: number) => {
|
const addToParty = (slotIndex?: number) => {
|
||||||
@ -695,7 +695,7 @@ export async function doPokemonFlee(pokemon: EnemyPokemon): Promise<void> {
|
|||||||
scale: pokemon.getSpriteScale(),
|
scale: pokemon.getSpriteScale(),
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
pokemon.setVisible(false);
|
pokemon.setVisible(false);
|
||||||
globalScene.field.remove(pokemon, true);
|
pokemon.leaveField(true, true, true);
|
||||||
showEncounterText(i18next.t("battle:pokemonFled", { pokemonName: pokemon.getNameToRender() }), null, 600, false)
|
showEncounterText(i18next.t("battle:pokemonFled", { pokemonName: pokemon.getNameToRender() }), null, 600, false)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
resolve();
|
resolve();
|
||||||
@ -723,7 +723,7 @@ export function doPlayerFlee(pokemon: EnemyPokemon): Promise<void> {
|
|||||||
scale: pokemon.getSpriteScale(),
|
scale: pokemon.getSpriteScale(),
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
pokemon.setVisible(false);
|
pokemon.setVisible(false);
|
||||||
globalScene.field.remove(pokemon, true);
|
pokemon.leaveField(true, true, true);
|
||||||
showEncounterText(i18next.t("battle:playerFled", { pokemonName: pokemon.getNameToRender() }), null, 600, false)
|
showEncounterText(i18next.t("battle:playerFled", { pokemonName: pokemon.getNameToRender() }), null, 600, false)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -4118,9 +4118,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
* @param hideInfo Indicates if this should also play the animation to hide the Pokemon's
|
* @param hideInfo Indicates if this should also play the animation to hide the Pokemon's
|
||||||
* info container.
|
* info container.
|
||||||
*/
|
*/
|
||||||
leaveField(clearEffects: boolean = true, hideInfo: boolean = true) {
|
leaveField(clearEffects: boolean = true, hideInfo: boolean = true, destroy: boolean = false) {
|
||||||
this.resetSprite();
|
this.resetSprite();
|
||||||
this.resetTurnData();
|
this.resetTurnData();
|
||||||
|
globalScene.getField(true).filter(p => p !== this).forEach(p => p.removeTagsBySourceId(this.id));
|
||||||
|
|
||||||
if (clearEffects) {
|
if (clearEffects) {
|
||||||
this.destroySubstitute();
|
this.destroySubstitute();
|
||||||
this.resetSummonData(); // this also calls `resetBattleSummonData`
|
this.resetSummonData(); // this also calls `resetBattleSummonData`
|
||||||
@ -4128,10 +4130,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
if (hideInfo) {
|
if (hideInfo) {
|
||||||
this.hideInfo();
|
this.hideInfo();
|
||||||
}
|
}
|
||||||
|
// Trigger abilities that activate upon leaving the field
|
||||||
applyPreLeaveFieldAbAttrs(PreLeaveFieldAbAttr, this);
|
applyPreLeaveFieldAbAttrs(PreLeaveFieldAbAttr, this);
|
||||||
globalScene.field.remove(this);
|
|
||||||
this.setSwitchOutStatus(true);
|
this.setSwitchOutStatus(true);
|
||||||
globalScene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true);
|
globalScene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true);
|
||||||
|
globalScene.field.remove(this, destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy(): void {
|
destroy(): void {
|
||||||
|
@ -241,11 +241,10 @@ export class AttemptCapturePhase extends PokemonPhase {
|
|||||||
};
|
};
|
||||||
const removePokemon = () => {
|
const removePokemon = () => {
|
||||||
globalScene.addFaintedEnemyScore(pokemon);
|
globalScene.addFaintedEnemyScore(pokemon);
|
||||||
globalScene.getPlayerField().filter(p => p.isActive(true)).forEach(playerPokemon => playerPokemon.removeTagsBySourceId(pokemon.id));
|
|
||||||
pokemon.hp = 0;
|
pokemon.hp = 0;
|
||||||
pokemon.trySetStatus(StatusEffect.FAINT);
|
pokemon.trySetStatus(StatusEffect.FAINT);
|
||||||
globalScene.clearEnemyHeldItemModifiers();
|
globalScene.clearEnemyHeldItemModifiers();
|
||||||
globalScene.field.remove(pokemon, true);
|
pokemon.leaveField(true, true, true);
|
||||||
};
|
};
|
||||||
const addToParty = (slotIndex?: number) => {
|
const addToParty = (slotIndex?: number) => {
|
||||||
const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex);
|
const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex);
|
||||||
|
@ -181,9 +181,7 @@ export class FaintPhase extends PokemonPhase {
|
|||||||
y: pokemon.y + 150,
|
y: pokemon.y + 150,
|
||||||
ease: "Sine.easeIn",
|
ease: "Sine.easeIn",
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
pokemon.resetSprite();
|
|
||||||
pokemon.lapseTags(BattlerTagLapseType.FAINT);
|
pokemon.lapseTags(BattlerTagLapseType.FAINT);
|
||||||
globalScene.getField(true).filter(p => p !== pokemon).forEach(p => p.removeTagsBySourceId(pokemon.id));
|
|
||||||
|
|
||||||
pokemon.y -= 150;
|
pokemon.y -= 150;
|
||||||
pokemon.trySetStatus(StatusEffect.FAINT);
|
pokemon.trySetStatus(StatusEffect.FAINT);
|
||||||
@ -193,7 +191,7 @@ export class FaintPhase extends PokemonPhase {
|
|||||||
globalScene.addFaintedEnemyScore(pokemon as EnemyPokemon);
|
globalScene.addFaintedEnemyScore(pokemon as EnemyPokemon);
|
||||||
globalScene.currentBattle.addPostBattleLoot(pokemon as EnemyPokemon);
|
globalScene.currentBattle.addPostBattleLoot(pokemon as EnemyPokemon);
|
||||||
}
|
}
|
||||||
globalScene.field.remove(pokemon);
|
pokemon.leaveField();
|
||||||
this.end();
|
this.end();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user