From 0e84343b15872081880e2c31149a051a9412ed38 Mon Sep 17 00:00:00 2001 From: shayebeadlingkl Date: Sun, 21 Apr 2024 14:37:58 -0400 Subject: [PATCH] implements cursed body --- src/data/ability.ts | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 16eb729e1db..f876f7f525d 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -745,6 +745,36 @@ export class PostDefendAbilityGiveAbAttr extends PostDefendAbAttr { } } +export class PostDefendMoveDisableAbAttr extends PostDefendAbAttr { + private chance: integer; + private attacker: Pokemon; + private move: PokemonMove; + + constructor(chance: integer) { + super(); + + this.chance = chance; + } + + applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean { + if (!attacker.summonData.disabledMove) { + if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && (this.chance === -1 || pokemon.randSeedInt(100) < this.chance)) { + this.attacker = attacker; + this.move = move; + + attacker.summonData.disabledMove = move.moveId; + attacker.summonData.disabledTurns = 4; + return true; + } + } + return false; + } + + getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { + return getPokemonMessage(this.attacker, `'s ${this.move.getName()}\nwas disabled!`); + } +} + export class PostStatChangeStatChangeAbAttr extends PostStatChangeAbAttr { private condition: PokemonStatChangeCondition; private statsToChange: BattleStat[]; @@ -2651,7 +2681,8 @@ export function initAbilities() { .attr(BattleStatMultiplierAbAttr, BattleStat.ATK, 0.5) .attr(BattleStatMultiplierAbAttr, BattleStat.SPATK, 0.5) .condition((pokemon) => pokemon.getHpRatio() <= 0.5), - new Ability(Abilities.CURSED_BODY, "Cursed Body (N)", "May disable a move used on the Pokémon.", 5), + new Ability(Abilities.CURSED_BODY, "Cursed Body", "May disable a move used on the Pokémon.", 5) + .attr(PostDefendMoveDisableAbAttr, 100), new Ability(Abilities.HEALER, "Healer (N)", "Sometimes heals an ally's status condition.", 5), new Ability(Abilities.FRIEND_GUARD, "Friend Guard (N)", "Reduces damage done to allies.", 5) .ignorable(),