From 1a5e92b3fbe5ca802ec23b1dfc38aec4bc76fb57 Mon Sep 17 00:00:00 2001 From: shrianshChari <30420527+shrianshChari@users.noreply.github.com> Date: Sat, 7 Oct 2023 12:24:19 -0400 Subject: [PATCH] Gen 4: Fix Klutz not dropping Speed from Iron Ball (#562) In Generation 4, if a Pokemon with the ability Klutz holds an Iron Ball it should still get its Speed dropped. However, Klutz Pokemon holding an Iron Ball won't be grounded. Fixes #560 --- calc/src/mechanics/gen4.ts | 5 +++-- calc/src/mechanics/util.ts | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/calc/src/mechanics/gen4.ts b/calc/src/mechanics/gen4.ts index cfb52c01b..fbcc2da6f 100644 --- a/calc/src/mechanics/gen4.ts +++ b/calc/src/mechanics/gen4.ts @@ -144,8 +144,9 @@ export function calculateDPP( let typeEffectiveness = type1Effectiveness * type2Effectiveness; - // Iron Ball ignores Klutz in generation 4 - if (typeEffectiveness === 0 && move.hasType('Ground') && defender.hasItem('Iron Ball')) { + // Klutz doesn't let Iron Ball ground in generation 4 + if (typeEffectiveness === 0 && move.hasType('Ground') && + (defender.hasItem('Iron Ball') && !defender.hasAbility('Klutz'))) { if (type1Effectiveness === 0) { type1Effectiveness = 1; } else if (defender.types[1] && type2Effectiveness === 0) { diff --git a/calc/src/mechanics/util.ts b/calc/src/mechanics/util.ts index 4476dce4d..816ad6388 100644 --- a/calc/src/mechanics/util.ts +++ b/calc/src/mechanics/util.ts @@ -184,9 +184,11 @@ export function checkForecast(pokemon: Pokemon, weather?: Weather) { } export function checkItem(pokemon: Pokemon, magicRoomActive?: boolean) { + // Pokemon with Klutz still get their speed dropped in generation 4 + if (pokemon.gen.num === 4 && pokemon.hasItem('Iron Ball')) return; if ( pokemon.hasAbility('Klutz') && !EV_ITEMS.includes(pokemon.item!) || - magicRoomActive + magicRoomActive ) { pokemon.item = '' as ItemName; }