Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toxic fix #596

Merged
merged 4 commits into from
Aug 27, 2024
Merged

Toxic fix #596

merged 4 commits into from
Aug 27, 2024

Conversation

noobscrub27
Copy link
Contributor

@noobscrub27 noobscrub27 commented Jan 11, 2024

Fixed several bugs:

  • End of turn damage is now considered on the first turn.
  • A pokemon that was KO'd by a move but would have healed above 0HP at the end of the turn is now considered KO'd.
  • Toxic damage works now.
  • Neutralizing Gas now negates end of turn healing and damage caused by abilities.

I also changed the way OHKOs are displayed when end of turn damage comes into play. For example, if a move isn't a guaranteed OHKO before end of turn damage, but has a higher chance to OHKO after end of turn damage, the chance to OHKO after end of turn damage is displayed separately. This is for cases where someone's pokemon outspeeds their opponent's pokemon, but their opponent can OHKO and the player wants to see how likely it is for them to KO their opponent before they get attacked. Here's an example: 0 SpA Ivysaur Weather Ball (100 BP Fire) vs. 0 HP / 252 SpD Abomasnow in Sun: 316-376 (98.4 - 117.1%) -- 87.5% chance to OHKO (guaranteed OHKO after poison damage)

Copy link
Collaborator

@thejetou thejetou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, these changes are appreciated but a few requests:

  • Remove the .vs/ files
  • Please write tests for this. EOT code is hard to work with so it would be great for sanity's sake

Also, can you elaborate on what 'End of turn damage is now considered on the first turn' means?

@noobscrub27
Copy link
Contributor Author

Hi, thanks for the response!
In hindsight I could have done more to explain myself. By end of turn damage being considered on the first turn, I mean that when calculating damage, if the defender would lose health at the end the turn due to a status condition, it currently only starts counting this on the second turn.
As an example, this Mew is poisoned and seeded. It's level 30 with no HP IVs or EVs so it has exactly 100 HP. A level 99 Chansey's Seismic Toss should OHKO after hazards are accounted for, but the calculator thinks its a 2HKO.
image
And for toxic damage, not only is damage not applied on the first turn, the counter doesn't increase either.
Here's an example with a level 82 Chansey using Seismic Toss against a Pokemon with 200 Max HP:
image
This is listed as a 3HKO, but it's actually a 2HKO. This is how it should play out:

  1. Seismic Toss: 200 - 82 = 118
  2. Toxic damage (toxic count 1): 118 - 12 = 106
  3. Seismic Toss: 106 - 82 = 24
  4. Toxic damage (toxic count 2): 24 - 25 = -1 (2HKO)

This is how it the calculator does it currently:

  1. Seismic Toss: 200 - 82 = 118
  2. (EOT damage is skipped and the toxic count does not increase)
  3. Seismic Toss: 118 - 82 = 36
  4. Toxic damage (toxic count 1): 36 - 12 = 24
  5. Seismic Toss: 24 - 82 = -58 (3HKO)

This is my first pull request so please be patient if I make any mistakes. Things are pretty busy in my life right now, but I'm going to do my best to fix this soon.

@thejetou
Copy link
Collaborator

thejetou commented Mar 6, 2024

Thanks, your explanation clears it up.

This is my first pull request so please be patient if I make any mistakes. Things are pretty busy in my life right now, but I'm going to do my best to fix this soon.

Don't worry, get to it whenever you can. If you have any questions feel free to ask in #calc-dev in the Dev Discord Server and I'll help you out.

fixed toxic damage
oops there was a bug but its fixed now
Delete .vs directory
added .vs to gitignore
added .vs to gitignore for real this time maybe
updated desc.ts
Revert "updated desc.ts"
This reverts commit 9055601.

fixed a bug in predictTotal, and updated the code to match upstream
@noobscrub27
Copy link
Contributor Author

noobscrub27 commented Jul 31, 2024

The rebase is finished. I added some new tests. The tests I added are for generations 3-9.
Here are the tests I wrote:

  • KOed Pokemon don't receive HP recovery after 5+ turns
  • KOed Pokemon don't receive HP recovery after 1-4 turns
  • EoT damage is calculated correctly after 5+ turns
  • EoT damage is calculated correctly after 1-4 turns
  • EoT damage is calculated correctly on the first turn

The reason tests for 1-4HKOs are separate from tests for 5+HKOs is because the calculateKOChance function is used for the former and predictTotal is used for the latter. I also included some tests to ensure that in cases where a defender heals more at the end of the turn than they would lose (holding leftovers, receiving leech seed, etc.), they don't have their HP increased past 0 if the initial hit would have KOed.
Let me know if I should add any more tests, or remove some that I added. I put them all in the Multi-Gen section for now.
It's also worth noting that there are some issues with generation 1-2 EoT that my code doesn't address, namely the interactions between toxic and leech seed. This is something that I want to get around to at some point but I'm gonna be honest this has taken me a lot longer than I expected it to already so I'm gonna have to see it goes because early gen mechanics can be kind of a handful to work with. The calc handles toxic differently than it does other sources of EoT healing/damage, so I'm expecting having it work with leech seed would require the code for leech seed to be rewritten. This gets more complicated when you consider that the amount of healing a defender receives from the attacker's leech seed would also need to be changed.

Copy link
Collaborator

@thejetou thejetou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will merge on Monday. Sorry for the delay.

@noobscrub27
Copy link
Contributor Author

No need to apologize. Thanks for all the help!

@thejetou thejetou merged commit dbad94c into smogon:master Aug 27, 2024
2 checks passed
@thejetou
Copy link
Collaborator

Great work, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants