authorblues / bizhawk-shuffler-2

A script to randomly shuffle between games played in Bizhawk, with plugins to enhance the experience
MIT License
58 stars 21 forks source link

MMDS: Prevent spurious swaps during MMX5 boss rush #42

Closed kalimag closed 3 years ago

kalimag commented 3 years ago

MMX5 sets the player health to 0 after exiting a stage, and restores it when entering a new stage. During the final boss rush, the transitions are quick and health stays at 0 for a single frame, which hits an edge case in generic_swap. HP at 0 fulfills currhp < prevhp and starts data.hpcountdown, but when hpcountdown reaches 0 health is back at its max value and fulfills currhp > minhp, swapping even though the life count hasn't decreased. This happens at the beginning and end of each boss rush fight.

https://github.com/authorblues/bizhawk-shuffler-2/blob/1f37b9719474275ebf44f8c0653bdda589e27e93/plugins/megaman-damage-shuffler.lua#L88-L100

It would probably be better to address this in generic_swap, either by not triggering hpcountdown if currhp is 0, or by making sure currhp is still decreased when hpcountdown reaches 0, but I don't want to have to test that a potential fix doesn't break any other game using generic_swap, so this PR works around it with a gmode that seems to reliably indicate gameplay.