From 4d0883fbb26fad0b525a6a71780cdce2df657bea Mon Sep 17 00:00:00 2001 From: arColm Date: Sat, 27 Apr 2024 13:08:18 -0400 Subject: [PATCH] Implement Poison Puppeteer --- src/data/ability.ts | 20 +++++++++++++++++++- src/data/move.ts | 9 ++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 0ff03ed67..75ccbf5ff 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -22,6 +22,7 @@ import i18next, { Localizable } from "#app/plugins/i18n.js"; import { Command } from "../ui/command-ui-handler"; import Battle from "#app/battle.js"; import { ability } from "#app/locales/en/ability.js"; +import { Species } from "./enums/species"; export class Ability implements Localizable { public id: Abilities; @@ -1730,6 +1731,23 @@ export class ProtectStatAbAttr extends PreStatChangeAbAttr { } } +export class ConfusionOnStatusEffectAbAttr extends PostAttackAbAttr { + private effects: StatusEffect[]; + + constructor(...effects: StatusEffect[]) { + super(); + + this.effects = effects; + } + + applyPostAttack(pokemon: Pokemon, passive: boolean, defender: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { + if(this.effects.indexOf(args[0]) > -1 && !defender.isFainted()) { + return defender.addTag(BattlerTagType.CONFUSED, pokemon.randSeedInt(3,2), move.moveId, defender.id); + } + return false; + } +} + export class PreSetStatusAbAttr extends AbAttr { applyPreSetStatus(pokemon: Pokemon, passive: boolean, effect: StatusEffect, cancelled: Utils.BooleanHolder, args: any[]): boolean | Promise { return false; @@ -3849,6 +3867,6 @@ export function initAbilities() { new Ability(Abilities.POISON_PUPPETEER, 9) .attr(UncopiableAbilityAbAttr) .attr(UnswappableAbilityAbAttr) - .unimplemented(), + .conditionalAttr(pokemon => pokemon.species.speciesId===Species.PECHARUNT,ConfusionOnStatusEffectAbAttr,StatusEffect.POISON,StatusEffect.TOXIC) ); } diff --git a/src/data/move.ts b/src/data/move.ts index 3c99ad8c1..ec335fa81 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -12,7 +12,7 @@ import * as Utils from "../utils"; import { WeatherType } from "./weather"; import { ArenaTagSide, ArenaTrapTag } from "./arena-tag"; import { ArenaTagType } from "./enums/arena-tag-type"; -import { UnswappableAbilityAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, NoTransformAbilityAbAttr, BlockRecoilDamageAttr, BlockOneHitKOAbAttr, IgnoreContactAbAttr, MaxMultiHitAbAttr, applyAbAttrs, BlockNonDirectDamageAbAttr, applyPreSwitchOutAbAttrs, PreSwitchOutAbAttr, applyPostDefendAbAttrs, PostDefendContactApplyStatusEffectAbAttr, MoveAbilityBypassAbAttr, ReverseDrainAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr } from "./ability"; +import { UnswappableAbilityAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, NoTransformAbilityAbAttr, BlockRecoilDamageAttr, BlockOneHitKOAbAttr, IgnoreContactAbAttr, MaxMultiHitAbAttr, applyAbAttrs, BlockNonDirectDamageAbAttr, applyPreSwitchOutAbAttrs, PreSwitchOutAbAttr, applyPostDefendAbAttrs, PostDefendContactApplyStatusEffectAbAttr, MoveAbilityBypassAbAttr, ReverseDrainAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr, applyPostAttackAbAttrs, ConfusionOnStatusEffectAbAttr } from "./ability"; import { Abilities } from "./enums/abilities"; import { allAbilities } from './ability'; import { PokemonHeldItemModifier } from "../modifier/modifier"; @@ -1155,8 +1155,11 @@ export class StatusEffectAttr extends MoveEffectAttr { else return false; } - if (!pokemon.status || (pokemon.status.effect === this.effect && move.chance < 0)) - return pokemon.trySetStatus(this.effect, true, user, this.cureTurn); + if (!pokemon.status || (pokemon.status.effect === this.effect && move.chance < 0) + && pokemon.trySetStatus(this.effect, true, user, this.cureTurn)) { + applyPostAttackAbAttrs(ConfusionOnStatusEffectAbAttr, user, target, new PokemonMove(move.id), null,this.effect); + return true; + } } return false; }