From 277335419344b64bdaf1a4b68c89c43058b4f8a8 Mon Sep 17 00:00:00 2001 From: Dean <69436131+emdeann@users.noreply.github.com> Date: Tue, 1 Apr 2025 23:56:19 -0700 Subject: [PATCH] [Bug][Hotfix] Fix various ability flyouts not disappearing (#5614) * Add hide phases for rogue ability showing * Hide ability bar on game over * Hide ability bar in TurnEndPhase --- src/battle-scene.ts | 19 ++++++++++++------- src/data/arena-tag.ts | 5 +++-- src/data/battler-tags.ts | 5 +++-- src/data/moves/move.ts | 5 +++-- src/field/arena.ts | 3 --- src/phases/game-over-phase.ts | 2 ++ src/phases/hide-ability-phase.ts | 23 ++++------------------- src/phases/move-effect-phase.ts | 3 +++ src/phases/move-phase.ts | 16 ++++++++++------ src/phases/show-ability-phase.ts | 2 +- src/phases/turn-end-phase.ts | 2 ++ 11 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 7ab96566ef5..a759cbb84c2 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -167,7 +167,7 @@ import { ExpGainsSpeed } from "#enums/exp-gains-speed"; import { BattlerTagType } from "#enums/battler-tag-type"; import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#app/data/balance/starters"; import { StatusEffect } from "#enums/status-effect"; -import { globalScene, initGlobalScene } from "#app/global-scene"; +import { initGlobalScene } from "#app/global-scene"; import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; import { HideAbilityPhase } from "#app/phases/hide-ability-phase"; import { timedEventManager } from "./global-event-manager"; @@ -2665,7 +2665,7 @@ export default class BattleScene extends SceneBase { case "mystery_encounter_delibirdy": // Firel Delibirdy return 82.28; case "title_afd": // Andr06 - PokéRogue Title Remix (AFD) - return 47.660; + return 47.66; case "battle_rival_3_afd": // Andr06 - Final N Battle Remix (AFD) return 49.147; } @@ -2937,14 +2937,19 @@ export default class BattleScene extends SceneBase { * @param show Whether to show or hide the bar */ public queueAbilityDisplay(pokemon: Pokemon, passive: boolean, show: boolean): void { - this.unshiftPhase( - show - ? new ShowAbilityPhase(pokemon.getBattlerIndex(), passive) - : new HideAbilityPhase(pokemon.getBattlerIndex(), passive), - ); + this.unshiftPhase(show ? new ShowAbilityPhase(pokemon.getBattlerIndex(), passive) : new HideAbilityPhase()); this.clearPhaseQueueSplice(); } + /** + * Hides the ability bar if it is currently visible + */ + public hideAbilityBar(): void { + if (this.abilityBar.isVisible()) { + this.unshiftPhase(new HideAbilityPhase()); + } + } + /** * Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order) */ diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index 8f1d6b09a73..871f622f70a 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -28,7 +28,6 @@ import { BattlerTagType } from "#enums/battler-tag-type"; import { Moves } from "#enums/moves"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase"; -import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { CommonAnimPhase } from "#app/phases/common-anim-phase"; @@ -1160,9 +1159,11 @@ class TailwindTag extends ArenaTag { ); } // Raise attack by one stage if party member has WIND_RIDER ability + // TODO: Ability displays should be handled by the ability if (pokemon.hasAbility(Abilities.WIND_RIDER)) { - globalScene.unshiftPhase(new ShowAbilityPhase(pokemon.getBattlerIndex())); + globalScene.queueAbilityDisplay(pokemon, false, true); globalScene.unshiftPhase(new StatStageChangePhase(pokemon.getBattlerIndex(), true, [Stat.ATK], 1, true)); + globalScene.queueAbilityDisplay(pokemon, false, false); } } } diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index c391c4010b8..546dbb4a3db 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -30,7 +30,6 @@ import { CommonAnimPhase } from "#app/phases/common-anim-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MovePhase } from "#app/phases/move-phase"; import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase"; -import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; import type { StatStageChangeCallback } from "#app/phases/stat-stage-change-phase"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import i18next from "#app/plugins/i18n"; @@ -1901,12 +1900,14 @@ export class TruantTag extends AbilityBattlerTag { if (lastMove && lastMove.move !== Moves.NONE) { (globalScene.getCurrentPhase() as MovePhase).cancel(); - globalScene.unshiftPhase(new ShowAbilityPhase(pokemon.id, passive)); + // TODO: Ability displays should be handled by the ability + globalScene.queueAbilityDisplay(pokemon, passive, true); globalScene.queueMessage( i18next.t("battlerTags:truantLapse", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), }), ); + globalScene.queueAbilityDisplay(pokemon, passive, false); } return true; diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 8204f13fcca..80e8f2dae55 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -106,7 +106,6 @@ import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { SwitchPhase } from "#app/phases/switch-phase"; import { SwitchSummonPhase } from "#app/phases/switch-summon-phase"; -import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; import { SpeciesFormChangeRevertWeatherFormTrigger } from "../pokemon-forms"; import type { GameMode } from "#app/game-mode"; import { applyChallenges, ChallengeType } from "../challenge"; @@ -1924,7 +1923,9 @@ export class PartyStatusCureAttr extends MoveEffectAttr { pokemon.resetStatus(); pokemon.updateInfo(); } else { - globalScene.unshiftPhase(new ShowAbilityPhase(pokemon.id, pokemon.getPassiveAbility()?.id === this.abilityCondition)); + // TODO: Ability displays should be handled by the ability + globalScene.queueAbilityDisplay(pokemon, pokemon.getPassiveAbility()?.id === this.abilityCondition, true); + globalScene.queueAbilityDisplay(pokemon, pokemon.getPassiveAbility()?.id === this.abilityCondition, false); } } } diff --git a/src/field/arena.ts b/src/field/arena.ts index 4f243789567..cf48647e45e 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -40,7 +40,6 @@ import { TrainerType } from "#enums/trainer-type"; import { Abilities } from "#enums/abilities"; import { SpeciesFormChangeRevertWeatherFormTrigger, SpeciesFormChangeWeatherTrigger } from "#app/data/pokemon-forms"; import { CommonAnimPhase } from "#app/phases/common-anim-phase"; -import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; import { WeatherType } from "#enums/weather-type"; import { FieldEffectModifier } from "#app/modifier/modifier"; @@ -378,7 +377,6 @@ export class Arena { const isCherrimWithFlowerGift = p.hasAbility(Abilities.FLOWER_GIFT) && p.species.speciesId === Species.CHERRIM; if (isCastformWithForecast || isCherrimWithFlowerGift) { - new ShowAbilityPhase(p.getBattlerIndex()); globalScene.triggerPokemonFormChange(p, SpeciesFormChangeWeatherTrigger); } }); @@ -395,7 +393,6 @@ export class Arena { p.hasAbility(Abilities.FLOWER_GIFT, false, true) && p.species.speciesId === Species.CHERRIM; if (isCastformWithForecast || isCherrimWithFlowerGift) { - new ShowAbilityPhase(p.getBattlerIndex()); return globalScene.triggerPokemonFormChange(p, SpeciesFormChangeRevertWeatherFormTrigger); } }); diff --git a/src/phases/game-over-phase.ts b/src/phases/game-over-phase.ts index 2090592367d..f105b625cc8 100644 --- a/src/phases/game-over-phase.ts +++ b/src/phases/game-over-phase.ts @@ -45,6 +45,8 @@ export class GameOverPhase extends BattlePhase { start() { super.start(); + globalScene.hideAbilityBar(); + // Failsafe if players somehow skip floor 200 in classic mode if (globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex > 200) { this.isVictory = true; diff --git a/src/phases/hide-ability-phase.ts b/src/phases/hide-ability-phase.ts index 0745b3f832a..142bb4b251d 100644 --- a/src/phases/hide-ability-phase.ts +++ b/src/phases/hide-ability-phase.ts @@ -1,27 +1,12 @@ import { globalScene } from "#app/global-scene"; -import type { BattlerIndex } from "#app/battle"; -import { PokemonPhase } from "./pokemon-phase"; - -export class HideAbilityPhase extends PokemonPhase { - private passive: boolean; - - constructor(battlerIndex: BattlerIndex, passive = false) { - super(battlerIndex); - - this.passive = passive; - } +import { Phase } from "#app/phase"; +export class HideAbilityPhase extends Phase { start() { super.start(); - const pokemon = this.getPokemon(); - - if (pokemon) { - globalScene.abilityBar.hide().then(() => { - this.end(); - }); - } else { + globalScene.abilityBar.hide().then(() => { this.end(); - } + }); } } diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index 995684f8c03..bd1c9caad96 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -69,6 +69,7 @@ import type { Phase } from "#app/phase"; import { ShowAbilityPhase } from "./show-ability-phase"; import { MovePhase } from "./move-phase"; import { MoveEndPhase } from "./move-end-phase"; +import { HideAbilityPhase } from "#app/phases/hide-ability-phase"; export class MoveEffectPhase extends PokemonPhase { public move: PokemonMove; @@ -326,12 +327,14 @@ export class MoveEffectPhase extends PokemonPhase { ? getMoveTargets(target, move.id).targets : [user.getBattlerIndex()]; if (!isReflecting) { + // TODO: Ability displays should be handled by the ability queuedPhases.push( new ShowAbilityPhase( target.getBattlerIndex(), target.getPassiveAbility().hasAttr(ReflectStatusMoveAbAttr), ), ); + queuedPhases.push(new HideAbilityPhase()); } queuedPhases.push( diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index f8edaa56981..e04f48c2880 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -42,7 +42,6 @@ import { CommonAnimPhase } from "#app/phases/common-anim-phase"; import { MoveChargePhase } from "#app/phases/move-charge-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; import { NumberHolder } from "#app/utils"; import { Abilities } from "#enums/abilities"; import { ArenaTagType } from "#enums/arena-tag-type"; @@ -535,11 +534,16 @@ export class MovePhase extends BattlePhase { if (this.pokemon.hasAbilityWithAttr(BlockRedirectAbAttr)) { redirectTarget.value = currentTarget; - globalScene.unshiftPhase( - new ShowAbilityPhase( - this.pokemon.getBattlerIndex(), - this.pokemon.getPassiveAbility().hasAttr(BlockRedirectAbAttr), - ), + // TODO: Ability displays should be handled by the ability + globalScene.queueAbilityDisplay( + this.pokemon, + this.pokemon.getPassiveAbility().hasAttr(BlockRedirectAbAttr), + true, + ); + globalScene.queueAbilityDisplay( + this.pokemon, + this.pokemon.getPassiveAbility().hasAttr(BlockRedirectAbAttr), + false, ); } diff --git a/src/phases/show-ability-phase.ts b/src/phases/show-ability-phase.ts index 1b3c6dde568..8097af33fe0 100644 --- a/src/phases/show-ability-phase.ts +++ b/src/phases/show-ability-phase.ts @@ -35,7 +35,7 @@ export class ShowAbilityPhase extends PokemonPhase { // If the bar is already out, hide it before showing the new one if (globalScene.abilityBar.isVisible()) { - globalScene.unshiftPhase(new HideAbilityPhase(this.battlerIndex, this.passive)); + globalScene.unshiftPhase(new HideAbilityPhase()); globalScene.unshiftPhase(new ShowAbilityPhase(this.battlerIndex, this.passive)); return this.end(); } diff --git a/src/phases/turn-end-phase.ts b/src/phases/turn-end-phase.ts index 836647fbfb4..ddfc0955508 100644 --- a/src/phases/turn-end-phase.ts +++ b/src/phases/turn-end-phase.ts @@ -28,6 +28,8 @@ export class TurnEndPhase extends FieldPhase { globalScene.currentBattle.incrementTurn(); globalScene.eventTarget.dispatchEvent(new TurnEndEvent(globalScene.currentBattle.turn)); + globalScene.hideAbilityBar(); + const handlePokemon = (pokemon: Pokemon) => { if (!pokemon.switchOutStatus) { pokemon.lapseTags(BattlerTagLapseType.TURN_END);