smogon / damage-calc

Pokemon games damage calculator
https://calc.pokemonshowdown.com
MIT License
384 stars 364 forks source link

In Gen 4, the combination Klutz + Iron Ball is not properly handled #560

Closed UnderscorePoY closed 11 months ago

UnderscorePoY commented 1 year ago

Bulbapedia and this code comment agree that when a Pokémon with Klutz holds an Iron Ball, the speed drop should still be applied. This is not the case with the current implementation, as shown in this image : 2023-07-12 15_31_40-Pokémon Damage Calculator — Mozilla Firefox

shrianshChari commented 1 year ago

What does it look like when you remove the Klutz ability?

UnderscorePoY commented 1 year ago

The Iron Ball speed drop is properly applied.

2023-07-12 21_44_55-Pokémon Damage Calculator — Mozilla Firefox

UnderscorePoY commented 1 year ago

I suspect the issue comes from the fact that checkItem gets rid of the item entirely if Klutz is the Ability. Since checkItem is common to all generations, one might want to keep track of the old item near the start of calculateDPP and compare with it on this line.

shrianshChari commented 1 year ago

That line appears to deal with the grounding effect of Iron Ball, which according to Bulbapedia, gets ignored by Klutz. In other words, Klutz allows the speed to be halved still, but doesn't allow the Pokemon to be grounded. However, this line and this line might have something to do with how the damage calc handles the speed of the Pokemon.

UnderscorePoY commented 1 year ago

You're right, i linked you to a completely wrong reference, sorry about this. Your second link is the checkItem function that is common to all generations. Probably not being modified, due to possible side effects in the other calculators split per generation. Your first link is indeed where the speed drop is supposed to be applied, but since checkItem was already called previously and discards the item even in the case of an Iron Ball, the item is gone. Thus the drop is not put inside speedMods.