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

Fix Switch AI Bug: AI never switching out when it could be OHKO'd #5089

Merged
merged 3 commits into from
Aug 7, 2024

Conversation

Pawkkie
Copy link
Collaborator

@Pawkkie Pawkkie commented Aug 4, 2024

Description

Egg found this bug and reported it on Discord here. Basically the HasBadOdds switch check, which is enabled with Smart Switching, should trigger a switch out 50% of the time if the AI's mon can be KO'd and it has a good switchin candidate in its party. This was never triggering.

On investigation, it seems there was just an oversight in #4760 , where the damageTaken variable was removed and replaced by a dmg variable, but maxDamageTaken was still referring to damageTaken to update itself, which was always zero and never changed.

This PR fixes this issue, changes the HasBadOdds 50% chance of failure to use RandomPercentage with the RNG_AI_HASBADODDS tag instead of the more opaque modulo, and writes a test to make sure we don't accidentally reintroduce the bug with a future refactor. It also removes the Smart Switching flag from one of the Smart Mon Choices tests that would otherwise be affected by failing 50% of the time due to RNG, when the test has nothing to do with evaluating switch out decisions and is instead meant to ensure an infinite loop doesn't exist in Smart Mon Choices' hits to KO calculation.

Issue(s) that this PR fixes

Fixed before issue made heck yeah

People who collaborated with me in this PR

Egg found the bug! :D

Discord contact info

@Pawkkie

@Pawkkie Pawkkie changed the title Fix Switch AI Bug: AI never switching out when it should be OHKO'd Fix Switch AI Bug: AI never switching out when it could be OHKO'd Aug 4, 2024
@Pawkkie Pawkkie added category: battle-ai Pertains to Battle Engine Upgrade's AI bugfix Bugfixes labels Aug 4, 2024
@AlexOn1ine AlexOn1ine merged commit 9f845a7 into rh-hideout:master Aug 7, 2024
1 check passed
@Pawkkie Pawkkie deleted the fix-switch-ai-bug branch October 1, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bugfixes category: battle-ai Pertains to Battle Engine Upgrade's AI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants