jojobear13 / shinpokered

Mostly-vanilla hack of Pokémon Red/Blue focused on bugfixes and trainer ai
210 stars 42 forks source link

Mimic on switching opponent has unintended(?) effects #244

Closed DiabloStorm closed 1 year ago

DiabloStorm commented 1 year ago

Mimic attempts to copy the movepool of the switched-to pokemon (ok)

the move chosen replaces the 2nd move slot and not mimic. (perhaps matching the moveslot of opponent?)

you can then use mimic again on the switched-to pokemon which is glitched out as a blank sprite for a moment and gain another move.

no mimic moves were learned permanently when tested by forfeiting battle. (ok)

jojobear13 commented 1 year ago

Fixed in 81f16765ef0862f77e1f61ec3e7d149bc6be197f.

Interesting observation. Mimic must have been implemented at a later stage in the game's development. It relies on the fact that, in the vanilla game, the AI opponent executes its switch on its own turn instead of before the player uses a move. It specifically does not preserve the 'A' register or reload the background tiles from the buffer because it assumes that any switching by the AI will happen after mimic executes. That's why giving enemy switching priority was causing issues.

DiabloStorm commented 1 year ago

So, another problem with messing with the order of operations? What was the solution you went with?

in the vanilla game, the AI opponent executes its switch on its own turn instead of before the player uses a move.

does this tie in with #252 ? ...Because it almost certainly sounds like it.

jojobear13 commented 1 year ago

Yes, it's an issue with Red's order of operations with the AI being a little funky. But unlike issue 252, this has more to do with the order of execution instead of decision-making.

The solution was actually pretty easy once I was able to map out and understand how everything flows. The biggest one was to save the screen tiles to the buffer as part of the Mimic effect. The second was to back-up the current menu item value (which is used for slotting the mimic'ed move into the correct position) while the opponent switches.