Jump to content

Saffron Gym glitch: Difference between revisions

Added explanation.
>Bbbbbbbbba
(→‎Infinite rematch exploit: Thanks for entrpntr for testing the behavior with non-Sabrina trainers.)
>Bbbbbbbbba
(Added explanation.)
Line 29:
 
{{YouTube|_XTVUo9kWKw|Exarion}}
 
==Explanation==
When the player enters a gym, or returns to its overworld map from a battle, on the first overworld frame the game loads the names of the city and the gym leader to be shown on the gym statue. This is done by a function call in the gym's map script.<ref>[https://github.com/pret/pokered/blob/71090c13497946b739cd13f80d31ee13b464e9e6/scripts/SaffronGym.asm#L5 The function call to load the names of the city and the gym leader]</ref> However, in Japanese Red and Green only, and in Saffron Gym only, this "call" instruction is erroneously replaced by a "jp" instruction. This means that, on the first overworld frame, the meta-map script is skipped.
 
Normally, the meta-map script ID immediately after a trainer battle in the gym is either 2 (EndTrainerBattle) or 3 (special script for ending the gym leader battle), and both serve some important purposes:
* If the player won, the meta-map script will set the flag for beating the trainer. In the case of the gym leader battle, it will also give out the badge and TM award, and set the flags for beating the gym and for beating everyone else in the gym.
* No matter whether the player won or lost, the meta-map script will reset the meta-map script ID to 0, so that it would not execute again.
Therefore it is important that this meta-map script executes before the player can talk to the trainer again or death-warp away. In particular, when the player blacks out, the game executes the map script for exactly one more overworld frame, precisely for this purpose.
 
However, due to the flaw in the map script of Saffron Gym, it fails to call the meta-map script the first time. Therefore:
* If the player won, the player gets the chance to talk to the same trainer again before the meta-map script sets the "trainer beaten" flag. Therefore the player can rematch trainers indefinitely.
* If the player lost, the player will death-warp away before the meta-map script could reset to 0. Since the meta-map script determines whether the player lost by checking whether wIsInBattle is 0xFF, and wIsInBattle is reset to 0 after the player death-warps, the next time the player enters the gym, the meta-map script will execute and erroneously believe that the player has won.
 
==Trivia==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.