From b7913e2a820f3dd02141b70fa9d4137920d00043 Mon Sep 17 00:00:00 2001 From: JackSmith5202 Date: Sat, 6 Apr 2024 18:55:02 -0400 Subject: [PATCH] Implement Sticky Web --- src/data/arena-tag.ts | 37 +++++++++++++++++++++++++++++--- src/data/enums/arena-tag-type.ts | 1 + src/data/move.ts | 3 ++- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index 25570f84f7a..2f6305862d8 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -1,15 +1,16 @@ import { Arena } from "../field/arena"; import { Type } from "./type"; import * as Utils from "../utils"; -import { MoveCategory, allMoves } from "./move"; +import { MoveCategory, StatChangeAttr, allMoves } from "./move"; import { getPokemonMessage } from "../messages"; import Pokemon, { HitResult, PokemonMove } from "../field/pokemon"; -import { MoveEffectPhase } from "../phases"; +import { MoveEffectPhase, StatChangePhase } from "../phases"; import { StatusEffect } from "./status-effect"; import { BattlerIndex } from "../battle"; import { Moves } from "./enums/moves"; import { ArenaTagType } from "./enums/arena-tag-type"; -import { BlockNonDirectDamageAbAttr, applyAbAttrs } from "./ability"; +import { BlockNonDirectDamageAbAttr, ProtectStatAbAttr, applyAbAttrs } from "./ability"; +import { BattleStat } from "./battle-stat"; export enum ArenaTagSide { BOTH, @@ -392,6 +393,34 @@ class StealthRockTag extends ArenaTrapTag { } } +class StickyWebTag extends ArenaTrapTag { + constructor(sourceId: integer, side: ArenaTagSide) { + super(ArenaTagType.STICKY_WEB, Moves.STICKY_WEB, sourceId, side, 1); + } + + onAdd(arena: Arena): void { + super.onAdd(arena); + + const source = arena.scene.getPokemonById(this.sourceId); + arena.scene.queueMessage(`A ${this.getMoveName()} has been laid out on the ground around the opposing team!`); + } + + activateTrap(pokemon: Pokemon): boolean { + if (pokemon.isGrounded()) { + const cancelled = new Utils.BooleanHolder(false); + applyAbAttrs(ProtectStatAbAttr, pokemon, cancelled); + if (!cancelled.value) { + pokemon.scene.queueMessage(`The opposing ${pokemon.name} was caught in a sticky web!`); + const statLevels = new Utils.NumberHolder(-1); + pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), false, [BattleStat.SPD], statLevels.value)); + } + } + + return false; + } + +} + export class TrickRoomTag extends ArenaTag { constructor(turnCount: integer, sourceId: integer) { super(ArenaTagType.TRICK_ROOM, turnCount, Moves.TRICK_ROOM, sourceId); @@ -443,6 +472,8 @@ export function getArenaTag(tagType: ArenaTagType, turnCount: integer, sourceMov return new DelayedAttackTag(tagType, sourceMove, sourceId, targetIndex); case ArenaTagType.STEALTH_ROCK: return new StealthRockTag(sourceId, side); + case ArenaTagType.STICKY_WEB: + return new StickyWebTag(sourceId, side); case ArenaTagType.TRICK_ROOM: return new TrickRoomTag(turnCount, sourceId); case ArenaTagType.GRAVITY: diff --git a/src/data/enums/arena-tag-type.ts b/src/data/enums/arena-tag-type.ts index ab6d28caa38..cc08ca4fdcf 100644 --- a/src/data/enums/arena-tag-type.ts +++ b/src/data/enums/arena-tag-type.ts @@ -9,6 +9,7 @@ export enum ArenaTagType { FUTURE_SIGHT = "FUTURE_SIGHT", DOOM_DESIRE = "DOOM_DESIRE", STEALTH_ROCK = "STEALTH_ROCK", + STICKY_WEB = "STICKY_WEB", TRICK_ROOM = "TRICK_ROOM", GRAVITY = "GRAVITY", REFLECT = "REFLECT", diff --git a/src/data/move.ts b/src/data/move.ts index ebb9288fc7f..f552e601743 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4176,7 +4176,8 @@ export function initMoves() { new AttackMove(Moves.BELCH, "Belch (P)", Type.POISON, MoveCategory.SPECIAL, 120, 90, 10, "The user lets out a damaging belch at the target. The user must eat a held Berry to use this move.", -1, 0, 6), new StatusMove(Moves.ROTOTILLER, "Rototiller (N)", Type.GROUND, -1, 10, "Tilling the soil, the user makes it easier for plants to grow. This raises the Attack and Sp. Atk stats of Grass-type Pokémon.", 100, 0, 6) .target(MoveTarget.ALL), - new StatusMove(Moves.STICKY_WEB, "Sticky Web (N)", Type.BUG, -1, 20, "The user weaves a sticky net around the opposing team, which lowers their Speed stats upon switching into battle.", -1, 0, 6) + new StatusMove(Moves.STICKY_WEB, "Sticky Web", Type.BUG, -1, 20, "The user weaves a sticky net around the opposing team, which lowers their Speed stats upon switching into battle.", -1, 0, 6) + .attr(AddArenaTrapTagAttr, ArenaTagType.STICKY_WEB) .target(MoveTarget.ENEMY_SIDE), new AttackMove(Moves.FELL_STINGER, "Fell Stinger (P)", Type.BUG, MoveCategory.PHYSICAL, 50, 100, 25, "When the user knocks out a target with this move, the user's Attack stat rises drastically.", -1, 0, 6), new AttackMove(Moves.PHANTOM_FORCE, "Phantom Force", Type.GHOST, MoveCategory.PHYSICAL, 90, 100, 10, "The user vanishes somewhere, then strikes the target on the next turn. This move hits even if the target protects itself.", -1, 0, 6)