doshidak / showdex

Pokémon Showdown extension that harnesses the power of parabolic calculus to strategically extract your opponents' Elo.
GNU Affero General Public License v3.0
104 stars 18 forks source link

hazards are always calc'd, even if the Pokémon is already switched in #25

Closed doshidak closed 2 years ago

doshidak commented 2 years ago

Reported by: Runoisch

Hazards are always included in the damage calculations, even if the Pokémon is already switched-in, resulting in inaccurate damage ranges.

doshidak commented 2 years ago

Hopefully fixed.

Only hazards that deal damage, i.e., Spikes and Stealth Rock, are ignored if the selected Pokémon in the Calcdex is also active on the field. Otherwise, they will be provided to the damage calculator, which should correctly account for the gen's specific mechanics, such as the Pokémon's typings (e.g., Flying), abilities (e.g., Levitate), and items (e.g., Air Balloon).

(Side note: Stealth Rock places levitating stones, according to its entry on Bulbapedia, which affects Flying types, Levitate & Air Balloon [unlike Spikes]. When the Calcdex reports hazards, the damage calculator will apply Stealth Rock damage for these affected Pokémon.)

Consider the following Gen 8 OU battle with Stealth Rock and 2 layers of Spikes on both sides:

showdown-battle-scene-hazards

When the selected Pokémon are also active on the field, hazard damages are not applied:

showdex-active-no-hazards

When switching P2's selected Pokémon, hazard damages are applied only to the P2 Pokémon since it's not active:

showdex-p2-switched-hazards

After switching both player's selected Pokémon, hazard damages are applied since they're both not active:

showdex-switched-hazards

Actually found that the damage calculator does not apply hazard damages to the move's damage range (as the range refers to damage output from the move itself), but rather, only changes the NHKO value (including the probability, if applicable).

Will close this via reference on the next PR.