From 1e7c329928d422d098167f936530d0d0ea63b41c Mon Sep 17 00:00:00 2001 From: Reldnahc Date: Tue, 30 Apr 2024 11:38:24 -0500 Subject: [PATCH] Implement move wish (#323) * implement wish move * Serene grace implementation idea * only do the thingy if it actually gets effected. * Revert "only do the thingy if it actually gets effected." This reverts commit 4b084658d26d0aa4d38bdd18f8f051dbc3ca11a3. * Revert "Serene grace implementation idea" This reverts commit 4dd2504bc7cdf3d9ce4ea52c1c680dfc50f01adc. * Fixes for Wish implementation --------- Co-authored-by: Flashfyre --- src/data/arena-tag.ts | 31 +++++++++++++++++++++++++++++-- src/data/enums/arena-tag-type.ts | 1 + src/data/move.ts | 4 ++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index bb76a9880b3..a879c68d4ce 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -1,10 +1,10 @@ import { Arena } from "../field/arena"; import { Type } from "./type"; import * as Utils from "../utils"; -import { MoveCategory, StatChangeAttr, allMoves } from "./move"; +import { MoveCategory, allMoves } from "./move"; import { getPokemonMessage } from "../messages"; import Pokemon, { HitResult, PokemonMove } from "../field/pokemon"; -import { MoveEffectPhase, StatChangePhase } from "../phases"; +import { MoveEffectPhase, PokemonHealPhase, StatChangePhase} from "../phases"; import { StatusEffect } from "./status-effect"; import { BattlerIndex } from "../battle"; import { Moves } from "./enums/moves"; @@ -146,6 +146,31 @@ class AuroraVeilTag extends WeakenMoveScreenTag { } } +class WishTag extends ArenaTag { + private battlerIndex: BattlerIndex; + private triggerMessage: string; + private healHp: number; + + constructor(turnCount: integer, sourceId: integer, side: ArenaTagSide) { + super(ArenaTagType.WISH, turnCount, Moves.WISH, sourceId, side); + } + + onAdd(arena: Arena): void { + const user = arena.scene.getPokemonById(this.sourceId); + this.battlerIndex = user.getBattlerIndex(); + this.triggerMessage = getPokemonMessage(user, '\'s wish\ncame true!'); + this.healHp = Math.max(Math.floor(user.getMaxHp() / 2), 1); + } + + onRemove(arena: Arena): void { + const target = arena.scene.getField()[this.battlerIndex]; + if (target?.isActive(true)) { + arena.scene.queueMessage(this.triggerMessage); + arena.scene.unshiftPhase(new PokemonHealPhase(target.scene, target.getBattlerIndex(), this.healHp, null, true, false)); + } + } +} + export class WeakenMoveTypeTag extends ArenaTag { private weakenedType: Type; @@ -472,6 +497,8 @@ export function getArenaTag(tagType: ArenaTagType, turnCount: integer, sourceMov case ArenaTagType.FUTURE_SIGHT: case ArenaTagType.DOOM_DESIRE: return new DelayedAttackTag(tagType, sourceMove, sourceId, targetIndex); + case ArenaTagType.WISH: + return new WishTag(turnCount, sourceId, side); case ArenaTagType.STEALTH_ROCK: return new StealthRockTag(sourceId, side); case ArenaTagType.STICKY_WEB: diff --git a/src/data/enums/arena-tag-type.ts b/src/data/enums/arena-tag-type.ts index cc08ca4fdcf..8478b6f3f57 100644 --- a/src/data/enums/arena-tag-type.ts +++ b/src/data/enums/arena-tag-type.ts @@ -8,6 +8,7 @@ export enum ArenaTagType { MIST = "MIST", FUTURE_SIGHT = "FUTURE_SIGHT", DOOM_DESIRE = "DOOM_DESIRE", + WISH = "WISH", STEALTH_ROCK = "STEALTH_ROCK", STICKY_WEB = "STICKY_WEB", TRICK_ROOM = "TRICK_ROOM", diff --git a/src/data/move.ts b/src/data/move.ts index a95ce9c91f4..565c3b24125 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4493,8 +4493,8 @@ export function initMoves() { .attr(AbilityCopyAttr), new SelfStatusMove(Moves.WISH, Type.NORMAL, -1, 10, -1, 0, 3) .triageMove() - .unimplemented(), - new SelfStatusMove(Moves.ASSIST, Type.NORMAL, -1, 20, -1, 0, 3) + .attr(AddArenaTagAttr, ArenaTagType.WISH, 2, true), + new SelfStatusMove(Moves.ASSIST, Type.NORMAL, -1, 20, -1, 0, 3) .attr(RandomMovesetMoveAttr, true) .ignoresVirtual(), new SelfStatusMove(Moves.INGRAIN, Type.GRASS, -1, 20, -1, 0, 3)