mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-07 00:42:16 +02:00
moves: add custom fail text, fix animation issues with Guard Dog/Roar
This commit is contained in:
parent
88d43c09b8
commit
f10cce7d3a
@ -21,6 +21,7 @@ import { Abilities } from "./enums/abilities";
|
||||
import i18next, { Localizable } from "#app/plugins/i18n.js";
|
||||
import { Command } from "../ui/command-ui-handler";
|
||||
import Battle from "#app/battle.js";
|
||||
import { ability } from "#app/locales/en/ability.js";
|
||||
|
||||
export class Ability implements Localizable {
|
||||
public id: Abilities;
|
||||
@ -2353,13 +2354,9 @@ export class IncreasePpAbAttr extends AbAttr { }
|
||||
|
||||
export class ForceSwitchOutImmunityAbAttr extends AbAttr {
|
||||
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||
cancelled.value = true;
|
||||
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` can't be switched out!`))
|
||||
return true;
|
||||
}
|
||||
|
||||
getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string {
|
||||
return getPokemonMessage(pokemon, `'s ${abilityName} prevents it from being switched out!`)
|
||||
}
|
||||
}
|
||||
|
||||
export class ReduceBerryUseThresholdAbAttr extends AbAttr {
|
||||
|
@ -326,6 +326,13 @@ export default class Move implements Localizable {
|
||||
return true;
|
||||
}
|
||||
|
||||
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
|
||||
let failedText = null;
|
||||
for (let attr of this.attrs)
|
||||
failedText = attr.getFailedText(user, target, move, cancelled);
|
||||
return failedText;
|
||||
}
|
||||
|
||||
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||
let score = 0;
|
||||
|
||||
@ -422,6 +429,10 @@ export abstract class MoveAttr {
|
||||
return null;
|
||||
}
|
||||
|
||||
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||
return 0;
|
||||
}
|
||||
@ -2934,16 +2945,9 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
|
||||
const cancelled = new Utils.BooleanHolder(false);
|
||||
if (!this.user)
|
||||
applyAbAttrs(ForceSwitchOutImmunityAbAttr, target, cancelled)
|
||||
|
||||
if ((!this.user && target.isMax()) || cancelled.value)
|
||||
return resolve(false);
|
||||
|
||||
// Check if the move category is not STATUS or if the switch out condition is not met
|
||||
if (move.category !== MoveCategory.STATUS && !this.getSwitchOutCondition()(user, target, move)) {
|
||||
if (!this.getCondition()(user, target, move)) {
|
||||
//Apply effects before switch out i.e. poison point, flame body, etc
|
||||
applyPostDefendAbAttrs(PostDefendContactApplyStatusEffectAbAttr, target, user, new PokemonMove(move.id), null);
|
||||
return resolve(false);
|
||||
@ -3000,10 +3004,18 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
return (user, target, move) => (move.category !== MoveCategory.STATUS || this.getSwitchOutCondition()(user, target, move));
|
||||
}
|
||||
|
||||
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
|
||||
applyAbAttrs(ForceSwitchOutImmunityAbAttr, target, cancelled);
|
||||
return null;
|
||||
}
|
||||
|
||||
getSwitchOutCondition(): MoveConditionFunc {
|
||||
return (user, target, move) => {
|
||||
const switchOutTarget = (this.user ? user : target);
|
||||
const player = switchOutTarget instanceof PlayerPokemon;
|
||||
|
||||
if (!this.user && move.category == MoveCategory.STATUS && (target.hasAbilityWithAttr(ForceSwitchOutImmunityAbAttr) || target.isMax()))
|
||||
return false;
|
||||
|
||||
if (!player && !user.scene.currentBattle.battleType) {
|
||||
if (this.batonPass)
|
||||
|
@ -2277,18 +2277,21 @@ export class MovePhase extends BattlePhase {
|
||||
|
||||
// Assume conditions affecting targets only apply to moves with a single target
|
||||
let success = this.move.getMove().applyConditions(this.pokemon, targets[0], this.move.getMove());
|
||||
let failedText = null;
|
||||
let cancelled = new Utils.BooleanHolder(true);
|
||||
let failedText = this.move.getMove().getFailedText(this.pokemon, targets[0], this.move.getMove(), cancelled);
|
||||
if (success && this.scene.arena.isMoveWeatherCancelled(this.move.getMove()))
|
||||
success = false;
|
||||
else if (success && this.scene.arena.isMoveTerrainCancelled(this.pokemon, this.move.getMove())) {
|
||||
success = false;
|
||||
failedText = getTerrainBlockMessage(targets[0], this.scene.arena.terrain.terrainType);
|
||||
if (failedText == null)
|
||||
failedText = getTerrainBlockMessage(targets[0], this.scene.arena.terrain.terrainType);
|
||||
}
|
||||
if (success)
|
||||
this.scene.unshiftPhase(this.getEffectPhase());
|
||||
else {
|
||||
this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual });
|
||||
this.showFailedText(failedText);
|
||||
if (!cancelled.value)
|
||||
this.showFailedText(failedText);
|
||||
}
|
||||
|
||||
this.end();
|
||||
|
Loading…
Reference in New Issue
Block a user