From c00ccca3fc1d2b68abbf49f5ce64810d47fe63e0 Mon Sep 17 00:00:00 2001 From: Ice Date: Mon, 29 Apr 2024 23:21:13 -0500 Subject: [PATCH] Add Eerie Spell --- src/data/move.ts | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 30c97a1ac8d..f7ccb618a4e 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -3322,13 +3322,30 @@ export class CopyMoveAttr extends OverrideMoveEffectAttr { } export class ReducePpMoveAttr extends MoveEffectAttr { + public reduction: integer + public causesMoveToFail: boolean + + constructor(reduction: integer, causesMoveToFail: boolean) { + super(false, MoveEffectTrigger.POST_APPLY); + + this.reduction = reduction; + this.causesMoveToFail = causesMoveToFail; + } + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - // Null checks can be skipped due to condition function const lastMove = target.getLastXMoves().find(() => true); + if (!lastMove) { + return false; + } const movesetMove = target.getMoveset().find(m => m.moveId === lastMove.move); const lastPpUsed = movesetMove.ppUsed; - movesetMove.ppUsed = Math.min(movesetMove.ppUsed + 4, movesetMove.getMovePp()); - user.scene.queueMessage(`It reduced the PP of ${getPokemonMessage(target, `'s\n${movesetMove.getName()} by ${movesetMove.ppUsed - lastPpUsed}!`)}`); + if (!lastMove || lastPpUsed < 1) { + return false; + } + else { + movesetMove.ppUsed = Math.min(movesetMove.ppUsed + this.reduction, movesetMove.getMovePp()); + user.scene.queueMessage(`It reduced the PP of ${getPokemonMessage(target, `'s\n${movesetMove.getName()} by ${movesetMove.ppUsed - lastPpUsed}!`)}`); + } return true; } @@ -3340,6 +3357,7 @@ export class ReducePpMoveAttr extends MoveEffectAttr { const movesetMove = target.getMoveset().find(m => m.moveId === lastMove.move); return !!movesetMove?.getPpRatio(); } + if (!this.causesMoveToFail) {return true;} return false; }; } @@ -4213,7 +4231,7 @@ export function initMoves() { new AttackMove(Moves.REVERSAL, Type.FIGHTING, MoveCategory.PHYSICAL, -1, 100, 15, -1, 0, 2) .attr(LowHpPowerAttr), new StatusMove(Moves.SPITE, Type.GHOST, 100, 10, -1, 0, 2) - .attr(ReducePpMoveAttr), + .attr(ReducePpMoveAttr, 4, true), new AttackMove(Moves.POWDER_SNOW, Type.ICE, MoveCategory.SPECIAL, 40, 100, 25, 10, 0, 2) .attr(StatusEffectAttr, StatusEffect.FREEZE) .target(MoveTarget.ALL_NEAR_ENEMIES), @@ -5966,7 +5984,7 @@ export function initMoves() { .target(MoveTarget.ALL_NEAR_ENEMIES), new AttackMove(Moves.EERIE_SPELL, Type.PSYCHIC, MoveCategory.SPECIAL, 80, 100, 5, 100, 0, 8) .soundBased() - .partial(), + .attr(ReducePpMoveAttr, 3, false), new AttackMove(Moves.DIRE_CLAW, Type.POISON, MoveCategory.PHYSICAL, 80, 100, 15, 50, 0, 8) .attr(StatusEffectAttr, StatusEffect.POISON) .attr(StatusEffectAttr, StatusEffect.PARALYSIS)