Jump to content

Trainer escape glitch: Difference between revisions

→‎Initial steps of the glitch: Added some technical explanation. It may be strange to put it after just the initial steps of the glitch, but there are too many possible variants of this glitch that I don't think there is any other good position.
>Sherkel
mNo edit summary
>Bbbbbbbbba
(→‎Initial steps of the glitch: Added some technical explanation. It may be strange to put it after just the initial steps of the glitch, but there are too many possible variants of this glitch that I don't think there is any other good position.)
Line 54:
#Move left/right or north/south so that you're in that Trainer's field of vision. If you can't, try another position or another Trainer.
#Do not move, then Fly, Teleport, Dig, or Escape Rope away. Your destination to make this glitch desirable should be where a Trainer that walks up to you is within reasonable walking distance.
 
===Technical explanation===
The main purpose of the initial steps of the glitch is to put the [[meta-map script]] ID for the map the player escapes from into an inconsistent state. Maps with trainer battles usually have at least three pieces of meta-map scripts:
* CheckFightingMapTrainers
* DisplayEnemyTrainerTextAndStartBattle
* EndTrainerBattle
(Sometimes the actual meta-map scripts may be different, but will usually call those functions before or after handling some special cases.)
 
Normally, the meta-map script ID will point to CheckFightingMapTrainers. It is changed to DisplayEnemyTrainerTextAndStartBattle when the "!" mark appears on the trainer, at which point the player's overworld controls should have already been disabled. However:
* After the player chooses an escape item or move from the Start menu, the meta-map script is run for one more frame. If a trainer has just been loaded, they will notice the player on that frame, advancing the meta-map script ID just before the player warps away. <!-- TODO: The exact timing of things. -->
* If the player blacks out in battle, the meta-map script is run for one more frame, which usually either is EndTrainerBattle (because the player blacked out in a trainer battle) and resets the meta-map script ID, or does nothing. However, in the death-warp method, the trainer will notice the player on that frame, advancing the meta-map script ID just before the player warps away.
In either case, the meta-map script ID is left pointing to DisplayEnemyTrainerTextAndStartBattle, setting up an encounter for when the player returns to the route. But since that encounter doesn't immediately happen after CheckFightingMapTrainers sets the relevant data, those data can be overwritten, resulting in an encounter that is controllable to some extent.
 
==Special stat encounter==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.