Automatically reload bar if shown while already out, fix specific abilities

This commit is contained in:
Dean 2025-02-22 23:13:29 -08:00
parent cf91b9f2ed
commit 4ae240ca7b
4 changed files with 24 additions and 13 deletions

View File

@ -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,
}),
);
}
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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;
}
}