diff --git a/src/data/ability.ts b/src/data/ability.ts index 8f0698e38b9..2e325a6249c 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -44,6 +44,7 @@ import { MoveEndPhase } from "#app/phases/move-end-phase"; import { PokemonAnimType } from "#enums/pokemon-anim-type"; import { StatusEffect } from "#enums/status-effect"; import { WeatherType } from "#enums/weather-type"; +import { HideAbilityPhase } from "#app/phases/hide-ability-phase"; export class Ability implements Localizable { public id: Abilities; @@ -4881,32 +4882,32 @@ async function applyAbAttrsInternal( globalScene.setPhaseQueueSplice(); + if (attr.showAbility && !simulated) { + queueShowAbility(pokemon, passive); + } + const message = attr.getTriggerMessage(pokemon, ability.name, args); + if (message) { + if (!simulated) { + globalScene.queueMessage(message); + } + } + messages.push(message!); + let result = applyFunc(attr, passive); // TODO Remove this when promises get reworked if (result instanceof Promise) { result = await result; } if (result) { + globalScene.phaseQueue; + queueHideAbility(pokemon, passive); + if (pokemon.summonData && !pokemon.summonData.abilitiesApplied.includes(ability.id)) { pokemon.summonData.abilitiesApplied.push(ability.id); } if (pokemon.battleData && !simulated && !pokemon.battleData.abilitiesApplied.includes(ability.id)) { pokemon.battleData.abilitiesApplied.push(ability.id); } - if (attr.showAbility && !simulated) { - if (showAbilityInstant) { - globalScene.abilityBar.showAbility(pokemon, passive); - } else { - queueShowAbility(pokemon, passive); - } - } - const message = attr.getTriggerMessage(pokemon, ability.name, args); - if (message) { - if (!simulated) { - globalScene.queueMessage(message); - } - } - messages.push(message!); } } globalScene.clearPhaseQueueSplice(); @@ -5299,6 +5300,11 @@ function queueShowAbility(pokemon: Pokemon, passive: boolean): void { globalScene.clearPhaseQueueSplice(); } +function queueHideAbility(pokemon: Pokemon, passive: boolean): void { + globalScene.unshiftPhase(new HideAbilityPhase(pokemon.id, passive)); + globalScene.clearPhaseQueueSplice(); +} + /** * Sets the ability of a Pokémon as revealed. * diff --git a/src/phases/hide-ability-phase.ts b/src/phases/hide-ability-phase.ts new file mode 100644 index 00000000000..9d0276406d7 --- /dev/null +++ b/src/phases/hide-ability-phase.ts @@ -0,0 +1,27 @@ +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: boolean = false) { + super(battlerIndex); + + this.passive = passive; + } + + start() { + super.start(); + + const pokemon = this.getPokemon(); + + if (pokemon) { + globalScene.abilityBar.hide().then(() => { + this.end(); + }); + } else { + this.end(); + } + } +} diff --git a/src/ui/ability-bar.ts b/src/ui/ability-bar.ts index 2c62ab36d1e..602bf1ec87f 100644 --- a/src/ui/ability-bar.ts +++ b/src/ui/ability-bar.ts @@ -41,7 +41,6 @@ export default class AbilityBar extends Phaser.GameObjects.Container { startTween(config: any, text?: string): Promise { this.setVisible(true); - this.shown = true; if (text) { this.abilityBarText.setText(text); } @@ -73,11 +72,11 @@ export default class AbilityBar extends Phaser.GameObjects.Container { }, text); } - hide(): void { - this.startTween({ + hide(): Promise { + return this.startTween({ targets: this, x: -91, - duration: 500, + duration: 200, ease: "Sine.easeIn", onComplete: () => { this.setVisible(false);