From 4ae240ca7b49fe383a3076afa2e678489f49d643 Mon Sep 17 00:00:00 2001 From: Dean Date: Sat, 22 Feb 2025 23:13:29 -0800 Subject: [PATCH] Automatically reload bar if shown while already out, fix specific abilities --- src/data/ability.ts | 13 ------------- src/phases/pokemon-transform-phase.ts | 9 +++++++++ src/phases/show-ability-phase.ts | 8 ++++++++ src/ui/ability-bar.ts | 7 +++++++ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index cc337d3d56f..4c3ea528e59 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1219,9 +1219,6 @@ export class MoveEffectChanceMultiplierAbAttr extends AbAttr { * [1]: {@linkcode Moves } Move used by the ability user. */ override apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): void { - // Disable showAbility during getTargetBenefitScore - this.showAbility = args[4]; - (args[0] as Utils.NumberHolder).value *= this.chanceMultiplier; (args[0] as Utils.NumberHolder).value = Math.min((args[0] as Utils.NumberHolder).value, 100); } @@ -2450,10 +2447,6 @@ export class PostSummonCopyAbilityAbAttr extends PostSummonAbAttr { private target: Pokemon; private targetAbilityName: string; - constructor() { - super(false); // Displaying ability changes should be handled by ab swap function - } - override canApplyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { const targets = pokemon.getOpponents(); if (!targets.length) { @@ -2624,12 +2617,6 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr { globalScene.unshiftPhase(new PokemonTransformPhase(pokemon.getBattlerIndex(), target.getBattlerIndex(), true)); - globalScene.queueMessage( - i18next.t("abilityTriggers:postSummonTransform", { - pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), - targetName: target.name, - }), - ); } } diff --git a/src/phases/pokemon-transform-phase.ts b/src/phases/pokemon-transform-phase.ts index d67f758b1fd..5b67b7902af 100644 --- a/src/phases/pokemon-transform-phase.ts +++ b/src/phases/pokemon-transform-phase.ts @@ -5,6 +5,8 @@ import { EFFECTIVE_STATS, BATTLE_STATS } from "#enums/stat"; import { PokemonMove } from "#app/field/pokemon"; import { globalScene } from "#app/global-scene"; import { PokemonPhase } from "./pokemon-phase"; +import { getPokemonNameWithAffix } from "#app/messages"; +import i18next from "i18next"; /** * Transforms a Pokemon into another Pokemon on the field. @@ -63,6 +65,13 @@ export class PokemonTransformPhase extends PokemonPhase { globalScene.playSound("battle_anims/PRSFX- Transform"); } + globalScene.queueMessage( + i18next.t("abilityTriggers:postSummonTransform", { + pokemonNameWithAffix: getPokemonNameWithAffix(user), + targetName: target.name, + }), + ); + promises.push( user.loadAssets(false).then(() => { user.playAnim(); diff --git a/src/phases/show-ability-phase.ts b/src/phases/show-ability-phase.ts index debdc7440a7..3d0b8844e7f 100644 --- a/src/phases/show-ability-phase.ts +++ b/src/phases/show-ability-phase.ts @@ -2,6 +2,7 @@ import { globalScene } from "#app/global-scene"; import type { BattlerIndex } from "#app/battle"; import { PokemonPhase } from "./pokemon-phase"; import { getPokemonNameWithAffix } from "#app/messages"; +import { HideAbilityPhase } from "#app/phases/hide-ability-phase"; export class ShowAbilityPhase extends PokemonPhase { private passive: boolean; @@ -28,6 +29,13 @@ export class ShowAbilityPhase extends PokemonPhase { start() { super.start(); + // 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 ShowAbilityPhase(this.battlerIndex, this.passive)); + return this.end(); + } + if (!this.pokemonOnField) { return this.end(); } diff --git a/src/ui/ability-bar.ts b/src/ui/ability-bar.ts index 49e0829a2d3..3021ecda64d 100644 --- a/src/ui/ability-bar.ts +++ b/src/ui/ability-bar.ts @@ -11,11 +11,13 @@ export default class AbilityBar extends Phaser.GameObjects.Container { private abilityBarText: Phaser.GameObjects.Text; private player: boolean; private screenRight: number; // hold screenRight in case size changes between show and hide + private shown: boolean; constructor() { super(globalScene, barWidth, baseY); this.abilityBars = []; this.player = true; + this.shown = false; } setup(): void { @@ -39,6 +41,7 @@ export default class AbilityBar extends Phaser.GameObjects.Container { public override setVisible(value: boolean): this { this.abilityBars[+this.player].setVisible(value); + this.shown = value; return this; } @@ -99,4 +102,8 @@ export default class AbilityBar extends Phaser.GameObjects.Container { } }); } + + public isVisible(): boolean { + return this.shown; + } }