From 0737827bbc047f95f48a9defe17c3f4399442785 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Fri, 19 Apr 2024 20:08:09 +0100 Subject: [PATCH] Implement Toxic Debris --- src/data/ability.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 16eb729e1db..4af4f3a45ac 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -10,6 +10,7 @@ import { BattlerTagType } from "./enums/battler-tag-type"; import { StatusEffect, getStatusEffectDescriptor, getStatusEffectHealText } from "./status-effect"; import { Gender } from "./gender"; import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, RecoilAttr, StatusMoveTypeImmunityAttr, FlinchAttr, allMoves } from "./move"; +import { ArenaTagSide } from "./arena-tag"; import { ArenaTagType } from "./enums/arena-tag-type"; import { Stat } from "./pokemon-stat"; import { PokemonHeldItemModifier } from "../modifier/modifier"; @@ -545,6 +546,29 @@ export class PostDefendStatChangeAbAttr extends PostDefendAbAttr { } } +export class PostDefendApplyArenaTrapTagAbAttr extends PostDefendAbAttr { + private condition: PokemonDefendCondition; + private tagType: ArenaTrapTag; + + constructor(condition: PokemonDefendCondition, tagType: ArenaTagType) { + super(true); + + this.condition = condition; + this.tagType = tagType; + } + + applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { + if (this.condition(pokemon, attacker, move.getMove())) { + const tag = pokemon.scene.arena.getTag(this.tagType) as ArenaTrapTag; + if (!pokemon.scene.arena.getTag(this.tagType) || tag.layers < tag.maxLayers) { + pokemon.scene.arena.addTag(this.tagType, 0, undefined, pokemon.id, pokemon.isPlayer() ? ArenaTagSide.ENEMY : ArenaTagSide.PLAYER); + return true; + } + } + return false; + } +} + export class PostDefendApplyBattlerTagAbAttr extends PostDefendAbAttr { private condition: PokemonDefendCondition; private tagType: BattlerTagType; @@ -3098,7 +3122,9 @@ export function initAbilities() { .attr(MovePowerBoostAbAttr, (user, target, move) => move.hasFlag(MoveFlags.SLICING_MOVE), 1.5), new Ability(Abilities.SUPREME_OVERLORD, "Supreme Overlord (N)", "When the Pokémon enters a battle, its Attack and Sp. Atk stats are slightly boosted for each of the allies in its party that have already been defeated.", 9), new Ability(Abilities.COSTAR, "Costar (N)", "When the Pokémon enters a battle, it copies an ally's stat changes.", 9), - new Ability(Abilities.TOXIC_DEBRIS, "Toxic Debris (N)", "Scatters poison spikes at the feet of the opposing team when the Pokémon takes damage from physical moves.", 9), + new Ability(Abilities.TOXIC_DEBRIS, "Toxic Debris", "Scatters poison spikes at the feet of the opposing team when the Pokémon takes damage from physical moves.", 9) + .attr(PostDefendApplyArenaTrapTagAbAttr, (target, user, move) => move.category === MoveCategory.PHYSICAL, ArenaTagType.TOXIC_SPIKES) + .bypassFaint(), new Ability(Abilities.ARMOR_TAIL, "Armor Tail", "The mysterious tail covering the Pokémon's head makes opponents unable to use priority moves against the Pokémon or its allies.", 9) .attr(FieldPriorityMoveImmunityAbAttr) .ignorable(),