mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-07 08:52:17 +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 i18next, { Localizable } from "#app/plugins/i18n.js";
|
||||||
import { Command } from "../ui/command-ui-handler";
|
import { Command } from "../ui/command-ui-handler";
|
||||||
import Battle from "#app/battle.js";
|
import Battle from "#app/battle.js";
|
||||||
|
import { ability } from "#app/locales/en/ability.js";
|
||||||
|
|
||||||
export class Ability implements Localizable {
|
export class Ability implements Localizable {
|
||||||
public id: Abilities;
|
public id: Abilities;
|
||||||
@ -2353,13 +2354,9 @@ export class IncreasePpAbAttr extends AbAttr { }
|
|||||||
|
|
||||||
export class ForceSwitchOutImmunityAbAttr extends AbAttr {
|
export class ForceSwitchOutImmunityAbAttr extends AbAttr {
|
||||||
apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
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;
|
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 {
|
export class ReduceBerryUseThresholdAbAttr extends AbAttr {
|
||||||
|
@ -326,6 +326,13 @@ export default class Move implements Localizable {
|
|||||||
return true;
|
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 {
|
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||||
let score = 0;
|
let score = 0;
|
||||||
|
|
||||||
@ -422,6 +429,10 @@ export abstract class MoveAttr {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFailedText(user: Pokemon, target: Pokemon, move: Move, cancelled: Utils.BooleanHolder): string | null {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2935,15 +2946,8 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||||
return new Promise(resolve => {
|
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
|
// 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
|
//Apply effects before switch out i.e. poison point, flame body, etc
|
||||||
applyPostDefendAbAttrs(PostDefendContactApplyStatusEffectAbAttr, target, user, new PokemonMove(move.id), null);
|
applyPostDefendAbAttrs(PostDefendContactApplyStatusEffectAbAttr, target, user, new PokemonMove(move.id), null);
|
||||||
return resolve(false);
|
return resolve(false);
|
||||||
@ -3000,11 +3004,19 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
return (user, target, move) => (move.category !== MoveCategory.STATUS || this.getSwitchOutCondition()(user, target, move));
|
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 {
|
getSwitchOutCondition(): MoveConditionFunc {
|
||||||
return (user, target, move) => {
|
return (user, target, move) => {
|
||||||
const switchOutTarget = (this.user ? user : target);
|
const switchOutTarget = (this.user ? user : target);
|
||||||
const player = switchOutTarget instanceof PlayerPokemon;
|
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 (!player && !user.scene.currentBattle.battleType) {
|
||||||
if (this.batonPass)
|
if (this.batonPass)
|
||||||
return false;
|
return false;
|
||||||
|
@ -2277,17 +2277,20 @@ export class MovePhase extends BattlePhase {
|
|||||||
|
|
||||||
// Assume conditions affecting targets only apply to moves with a single target
|
// 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 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()))
|
if (success && this.scene.arena.isMoveWeatherCancelled(this.move.getMove()))
|
||||||
success = false;
|
success = false;
|
||||||
else if (success && this.scene.arena.isMoveTerrainCancelled(this.pokemon, this.move.getMove())) {
|
else if (success && this.scene.arena.isMoveTerrainCancelled(this.pokemon, this.move.getMove())) {
|
||||||
success = false;
|
success = false;
|
||||||
|
if (failedText == null)
|
||||||
failedText = getTerrainBlockMessage(targets[0], this.scene.arena.terrain.terrainType);
|
failedText = getTerrainBlockMessage(targets[0], this.scene.arena.terrain.terrainType);
|
||||||
}
|
}
|
||||||
if (success)
|
if (success)
|
||||||
this.scene.unshiftPhase(this.getEffectPhase());
|
this.scene.unshiftPhase(this.getEffectPhase());
|
||||||
else {
|
else {
|
||||||
this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual });
|
this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual });
|
||||||
|
if (!cancelled.value)
|
||||||
this.showFailedText(failedText);
|
this.showFailedText(failedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user