Trainer escape glitch
|Bulbapedia also has an article about Trainer escape glitch.|
|PRAMA Initiative a également une page sur Trainer escape glitch.|
The Trainer escape glitch, also known as the Trainer-Fly glitch or Mew glitch (though the Mew glitch just refers to using the Trainer escape glitch to encounter Mew) is a glitch in Pokémon Red, Blue and Yellow (as well as the Japanese versions) that usually involves the player escaping from a "long-range Trainer".
It is most commonly used to force an encounter with a Pokémon or Trainer based on the last Special stat of the opponent in memory.
In Japan, the glitch is often referred to as fifth's method (Japanese: fifth法), named after "fifthヽ(´ー｀)ノ◆Fi3PJTZKLQ" who found it and posted about it on 2ch. It has also been referred to as Special encounter glitch (Japanese: とくしゅエンカウント).
A long-range Trainer is a Trainer who can be forced one tile off-screen from the first tile adjacent to them, and who will walk up to the player and challenge them to a battle when they appear.
The player doesn't actually have to use a long-range Trainer; there are two alternatives to using one for the glitch.
1. The player can exploit the Rival's effect caused by certain glitch items to allow the player to escape from not just long-range Trainers.
2. The player can exploit a death-warp, in which they receive a wild encounter in the grass or in a cave within a Trainer's vision and black out.
Initial steps of the glitch
Before performing this glitch, the player will need to have a long-range Trainer that they haven't beaten before, or a Trainer that can have a "!" mark over their head if they have an item that causes the Rival's effect, or to have not yet beaten the final Bug Catcher in Viridian Forest.
Additionally, at least one available Trainer that walks up to you from a route other than the long-range Trainer is recommended to make this glitch desirable, but this is not needed if you have access to the Elite Four and can beat them (see the unlimited Trainer escape glitch section for more information).
Perhaps the most commonly used long-range Trainers are a Jr. Trainer♂ on Route 24 (north of Cerulean City) and a Gambler on Route 8 (left of Lavender Town/east of Saffron City). See the screenshots below:
You will need a Pokémon with Fly, Teleport, Dig, or an Escape Rope if it is possible to use it in the place where the Trainer is.
Once you've chosen a long-range Trainer or one of the Trainers you can escape from using the RIVAL's effect, or decided to use the Viridian Forest wild encounter method, follow these steps:
Long-range Trainer method
The long-range Trainer method involves opening the Start menu while walking up to a Trainer who is initially off the screen (known as a "long-range Trainer") but is forced on the screen after the Start menu was opened. The player then uses Fly, Teleport, or an Escape Rope to escape from the original location before the battle begins.
- Make it so that the long-range Trainer is one tile off the screen, and that you can walk into their range of sight.
- While taking a step toward them, hold down the Start button to open the menu and delay the Trainer from walking up to you until the menu is closed.
- Leave the area using Fly, Teleport, Dig, or an Escape Rope. Your destination to make this glitch desirable should be where a Trainer that walks up to you is within reasonable walking distance, unless you want to pull off the Elite Four method of the unlimited Trainer escape glitch.
The death-warp method (documented by Vimgur) is notable for being a method in which the player's Start menu isn't disabled and the A/B buttons aren't partially disabled. This enables a Special stat encounter without the player having to fight another Trainer or change boxes (see the relevant section), although the player may need to be guided by the Pewter City museum NPC or push a Strength boulder if the trainer needed to walk up to the player, and also may need to flash the Start menu to prevent unwanted text box ID matching.
The death-warp involves the player blacking out in the grass or in a cave within a Trainer's vision. This can cause the "!" mark to appear but the battle will never begin.
- Have the black-out location set to a place close to a death-warp Trainer by healing at a Pokémon Center close to the death-warp Trainer prior to the glitch (optional, but useful if the player doesn't have the move Fly to return).
- Enter a location where there is a Trainer in the tall grass or a cave which the player hasn't defeated yet. Examples include the last Trainer in Viridian Forest on the way to Pewter City, two Bug Catchers on Route 6, as well as two Youngsters and a Gambler on Route 11.
- Save the game one step out of the Trainer's vision and step into the tall grass, aiming to get an encounter. If you do not get an encounter, reset the game and repeat this step until you do.
Delayed battle glitch
Sometimes (specifically via the Fossil Pokémaniac in Mt. Moon), a sub-glitch of the death-warp known as the delayed battle glitch can be activated if the player immediately returns to the original Trainer. It causes the battle to restart again immediately after blacking out.
Rival's effect method
- Face away from the "!" mark Trainer and use the Rival's effect causing item, then close the menus. Your sprite and the Trainer's sprite should disappear.
- 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.
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:
(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.
- 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
A highly popular use of the Trainer escape glitch is the Special stat encounter part of it in which the last Special stat of the opponent in memory determines an encounter at the original location that the player escaped from.
This trick can be performed after completing one of the Trainer escape methods above in the 'initial steps of the glitch' section and may temporarily remove the ability to open the start menu.
There are two obstacles that usually need to be cleared before a Special stat encounter could work, as documented by Háčky.
- Bit 0 of $CD60 needs to be unset. This bit is set when a Trainer spots the player and when it is set disables the Start menu, and partially disables the A and B buttons except for certain actions like using a PC. There is no known method to clear the following obstacle without clearing this one either beforehand or in the process (except by cheating or utilizing other glitches).
- Bit 0 of $D730 needs to be unset. This bit is set while a Trainer walks up to the player and is supposed to be cleared when they finish walking. The map script DisplayEnemyTrainerTextAndStartBattle will wait for this bit to clear before actually displaying the text box and starting the fight.
After completing the long-range Trainer or Rival's effect method, there are two ways to enable Special stat encounter.
1. Encounter a Trainer that walks up to you, and either win or lose to them. This will bring the ability to use the start menu back and is enough to get the Special stat encounter to work. Wild Pokémon can be encountered afterwards (including a Ditto) to obtain the desired Special stat.
- If you don't let them walk at least one step to you, the game will freeze, because bit 0 of $D730 makes the game think the trainer should be walking up to you anyway.
2. Change boxes (saving the game in the process) and reset the game, which will unset bit 0 of $CD60, allowing the player to use the Start menu or talk with NPCs. From here on, a few methods to unset bit 0 of $D730 exist:
- Defeat the Elite Four and watch the end of the credits. After the credits finish and the player reloads the save file, the foe's Special stat in memory will become zero. This does not result in a battle with an 'M (00) or 3TrainerPoké₽, so if the player wants to encounter a Pokémon they must have last encountered a Pokémon (either via a wild battle or Trainer) with a Special stat which is not 0.
- Be guided by the Pewter Museum NPC in Pewter City.
- Move a boulder with Strength, such as the one in the warden's house in Fuchsia City.
In the death-warp trick, a Special stat encounter will be enabled immediately after blacking out to the Trainer if the Trainer didn't have to walk up to the player, or after being guided by the Pewter Museum NPC/pushing a Strength boulder if the Trainer did have to walk up to the player.
When a Special stat encounter is enabled, upon returning to the route you escaped from the Trainer, a text box will pop up and after closing it you will encounter a Pokémon that had the Special stat of the last Pokémon in memory.
Its level depends on the attack stage of the opponent, which is 7 by default, but can be lowered through the use of Growl, by 1 stage at a time.
The attack stage can also be increased to 8 through the use of an X Attack or rose up to 9 through Swords Dance if you use have Ditto transform via the Ditto trick (described below). Once the Ditto transforms, it can also get boosted attack stages by using Swords Dance itself, up to 13 (+6), and the attack stage can still be lowered with Growls.
If the Special stat encounter doesn't work, make sure that the start menu is the last text box opened in memory before returning to the route and try encountering a wild Pokémon after encountering the Trainer.
All Trainer Pokémon yields
As Trainer Pokémon have minimum DVs and no stat experience by default, a certain Pokémon belonging to a Trainer will always load the same Special stat into memory.
See this image by wwwxxyy and Ryumaster for a full list of Trainer Pokémon yields. Note that it is extremely large.
The Mew trick or 'Mew glitch' is a specific variation of the Special stat encounter part of the Trainer escape glitch that allows you to fight and capture a level 7 Mew. In fact, because of this, Mew is often associated with the Trainer escape glitch.
1. The player must not have beaten any of these trainers who are circled in the picture.
2. Go in front of the Gambler shown in the picture. The player must approach him from in front of the house, then Fly quickly before the player is seen by him.
3. Fly to Cerulean City, then go and battle the Youngster in the maze to Bill's house (in the north). Make sure he walks up to the player, as if the player goes too close to him or directly talks to him, the game will lock up.
4. Fly to Lavender Town.
5. Walk back to the route to the left.
6. Press B when the menu pops up.
7. Mew will appear, at level 7.
The Ditto trick (also known as 'Mew glitch method #4', even though Mew is not the only Pokémon that can be encountered with it) is one of the most useful glitches in the first generation of the main series Pokémon games, and it can be used to obtain non-freezing glitch Pokémon with index numbers greater than hex:00 but lower than hex:C8 (dec:200), because index numbers that are 200 or greater bring up Trainers (see the Encountering Trainers section for more information).
This glitch takes advantage of Ditto's Transform instead of requiring that specific Trainers be encountered.
For this glitch you'll need to prepare a Pokémon with the Special stat modulo 256 of the Pokémon or Trainer you want (see the Big HEX List to see what special stats give which Pokémon or Trainers by choosing a decimal index number).
Modulo 256 means that the index numbers loop back to 0 after 255, so a Special stat of 257 would give Rhydon, the Pokémon with an index number of 01, and so forth.
After following one of the methods in the above "initial steps of the glitch" method except for the Viridian Forest blackout method and then following most of the steps (returning to the route you flew away from is excluded for the moment) described in the "Special stat encounter" method, you should go encounter Ditto and have it transform into the Pokémon with your desired Special stat.
In Pokémon Red and Blue, Ditto can be found on the route east of Fuschia City and in the Unknown Dungeon, while in Yellow, Ditto can be found in the Pokemon Mansion on Cinnabar Island, or in the Unknown Dungeon.
After the Ditto transforms into your Pokémon with the desired Special stat, run away or defeat the Ditto. Then go back (this is easiest with Fly) to the place where you escaped from the Trainer, without encountering any Pokémon or Trainers on the way, and make sure that the start menu is the last text box in memory. The Pokémon that you encounter will have an index number that is the same as your Pokémon's Special stat, but Special stats modulo 256 between (inclusively) 200 and 255 will turn into Trainers.
As mentioned above, trying to encounter a Pokémon with an index number (Special stat modulo 256) greater than 199 will bring up a Trainer. See the Big HEX List for possible Trainers, but note that the group of Trainers noted as causing the ZZAZZ glitch is not entirely accurate. See the ZZAZZ glitch article for Trainers that can cause the ZZAZZ glitch for a neutral attack stage.
The attack stage of the Ditto equates to the roster number of the Trainer you encounter. For example, if one wanted to encounter Prof. Oak's first roster, they would need the Ditto to transform into a Pokémon with a Special stat of 226 and then use Growl six times. To encounter his second roster, the player would have to use Growl five times, and so forth. Prof. Oak's fourth and beyond rosters are rosters from later Trainer classes, firstly, the Scientist.
If this value was too high, you'd encounter glitch teams, but this is impossible for this Trainer through the Ditto trick. It is possible to encounter glitch teams through the Ditto trick for Trainers like Agatha (Special 246) or Lance (Special 247) though, who are near the end of the Trainer classes and only have one valid roster each.
Getting Pokémon at level 100 with this trick
- Main article: Experience underflow glitch
The level of the Pokémon encountered through the Special stat encounter is equal to the Attack modifier (not the stat itself) of the last enemy Pokémon at the conclusion of the battle.
Stat modifiers start at 7, hence why most Pokémon reported from the Trainer escape glitch are at level 7. The range of stat modifiers is from 1 to 13.
In addition, Pokémon with a "Medium Slow" growth rate (Mew and all 3-stage evolutionary lines excluding Butterfree, Beedrill, and Dragonite), due to a bug in the algorithm (1.2L3 - 15L2 + 100L - 140) used to calculate these Pokémon's experience points, have negative experience at levels below 2 (-140 at level 0, -54 at level 1). However, since level values are read as unsigned (i.e. non-negative) integers, this actually equates to a rather large positive number (16,777,076 and 16,777,162, respectively).
If this Pokémon gains enough experience in battle to stay below 1 (i.e. less than 54), the game will recalculate its level based on experience, forcing the Pokémon to level 100, the maximum level that can be attained in battle.
Level 100 Pokémon before Brock (Red/Blue)
This death-warp trick is only possible if you haven't beaten the final Bug Catcher in Viridian Forest.
It is the only known way to get level 100 Pokémon before Brock in Pokémon Red and Blue without trading, grinding for an extremely long time, or skipping Brock (see skip Pewter Gym), because a long-range Trainer in Viridian Forest is present in Pokémon Yellow but not in Pokémon Red and Blue.
- Have your black out location set to Viridian City or Pallet Town. If you need to, heal your Pokémon at the Pokémon Center/your house to set the black out location.
- Get your Pokémon poisoned by a Weedle, but have enough health to be able to get to the Trainer as shown in the picture below. (Having your Pokémon poisoned isn't necessary for the glitch, but will increase the success rate, because you need to black out from a wild encounter later, and wild Pokémon encountered in Viridian Forest may not have an offensive move.)
- Save the game a tile away south of him, and hope that you encounter a wild Pokémon in his field of vision. If you don't succeed, reset the game and try again.
- Black out from the encounter.
- After ending up at the black out location set in the first step, encounter a (wild) Pokémon (one that will result in a wild medium-slow growth Pokémon later), and lower its Attack six times with Growl.
After performing the steps above, the Special stat encounter or text box ID matching (described below) part of the glitch will be activated for a level 1 wild Pokémon. Since Pokémon in wild encounters have random DVs the player will not necessarily find a wild medium-slow growth Pokémon, however Blue's second Pokémon in the first Route 22 battle will either give Gengar or Nidoqueen (both medium-slow growth rate Pokémon), depending on which starter the player chose.[clarification needed]
Level 100 Pokémon before Brock (Yellow)
This long-range Trainer trick is only possible if you haven't beaten the long-range Trainer in Viridian Forest, who is the last second-to-last Trainer on the path that leads to the end of the forest.
It is the only known way to get level 100 Pokémon before Brock in Pokémon Yellow without trading or grinding for an extremely long time.
- Purchase an Escape Rope at Pewter City's Poké Mart, and optionally Potions to survive a level 9 Diglett.
- Heal at the Pewter City Pokémon Center and leave the Jr. Trainer♂ in Brock's gym as an available Trainer.
- Go back to the long-range Trainer in Viridian Forest and escape from them using an Escape Rope (see long-range Trainer method) to warp back to Viridian City.
- Battle the Jr. Trainer♂ in Brock's gym and use Growl six times on his level 9 Diglett, then black out to him without defeating the Diglett.
- Return to Viridian Forest and a level 1 Gengar will appear, which can be caught and leveled up to 100 using the experience underflow glitch.
Going up and down the stairs infinitely
- Main article: Going up and down the stairs infinitely glitch
This glitch was documented by LanceAndMissingno. The glitch occurs with Special stat encounter message boxes (and possibly other text boxes) for when the player enters a map on the same tile as a staircase. This causes the player to automatically go up and down the stairs infinitely.
- Main article: Remove Snorlax glitch
Removing Snorlax is a sub-glitch of the Trainer escape glitch that lets the player remove one of the two Snorlax without the Poké Flute, which can be pulled off by accessing the route that the Snorlax is on in the middle of the Special stat encounter glitch.
See the main article for more information.
Stopping spinning tiles from working
This effect was documented by LanceAndMissingNo. If the player uses the Trainer escape glitch on a floor where there are spinning tiles, the spinning tiles will stop working, allowing you to walk around the floor by yourself.
Encounter as a Pokémon Tower Ghost
If the encounter is set up in Pokémon Tower and the player doesn't own a Silph Scope, it will appear as a Ghost (provided that it is not a Trainer).
This technique has a number of applications over a normal encounter; for example Pokédex flags will still be set, so the usually unstable MissingNo. in English Yellow will enable item duplication with no involvement of its unstable sprite. Furthermore, if the expanded inventory is used to change item 33 (the current map (D35E/D)) to a non-Pokémon Tower map, the glitch Pokémon can be captured.
The glitch sprite can be reenabled if the player performs the summary glitch to see a Ghost without a Silph Scope, and for bad sprites, memory corruption will take place again; such as sound bank corruption for Yellow MissingNo.
Infinite Trainer escape glitch
If you lose to the Trainer you battle after flying away, that Trainer will not be used up, and neither will the Trainer you flew away from, meaning that the glitch can be repeated an unlimited number of times as long as you have one spare Trainer that can walk up to you other than the Elite Four and Blue. It is a good idea to use only a low-level Pokémon with Fly.
If you have no available Trainers that can walk up to you, the player can change boxes after flying away, reset the game, and then defeat the Elite Four and Blue. Then, the player can encounter the Ditto and get the Pokémon they want. Encountering no Pokémon after the player is sent back to Pallet Town will not let the player encounter any Pokémon; the start menu will pop up if it was the last message box, but no Pokémon will appear.
This method can be pulled off without any Trainer at all and on routes without long-range Trainers (as long as at least one Trainer is present on the map). It also doesn't require a Pokémon with Fly, Teleport, Dig, or an Escape Rope.
- A stack of 255 items
- Access to Cerulean City
For the method on how to obtain a stack of 255 items, see this article.
WARNING: It is NOT recommended to have any items in your PC except two cheap items.
- Deposit the 255 items in your PC.
- Have your first PC slots as follows: Cheap item 1 x??, Cheap item 2 x??, Items x255.
- Toss/withdraw the first item [Number of items in your PC -2] times.
- Swap item slots 1 and 2 twice.
- Item 1's quantity should be 0.
- WARNING: from now onwards, do NOT mess up with items beyond the 50th, as you may corrupt your save file!
- Scroll to item number 100, which should be "j." x00 ("x." x00 in Yellow).
- Toss 255 of it to turn it into "j." x01 ("x." x01 in Yellow).
- Perform the glitch normally using the Mew/Ditto/text box matching method, and go north of Cerulean City to get the encounter (do not forget to flash the START menu).
Alternatively, if the player tossed Master Ball x255 in the PC, swapping the resulting Master Ball x00 with the "j." x00 ("x." x00 in Yellow) will trigger the encounter on Route 8 instead of Route 24. Swapping Master Ball x01 will trigger encounters in both routes (separately).
Text box ID matching
After performing the initial steps of the Trainer escape glitch and beating or losing to a Trainer that will walk up to you, the text box you get after returning to the route is the same ID as the last text box in memory (this can be viewed by checking the memory address CF13). For text boxes other than the start menu (00), you may get glitched text and/or error codes after returning to the route, and some of these bring up an undefeated Trainer or freeze the game.
If the equivalent text box brought up an undefeated Trainer, it may cause the walking lag glitch (see the article for steps).
Route 11 glitch Poké Mart
- Main article: Route 11 glitch Poké Mart
Using text box matching with the Vermilion Harbor sign (Red/Blue)/Vermilion Gym sign (Yellow), specific Trainers defeated and left undefeated on Route 11 and after obtaining the Itemfinder from Professor Oak's aide, it is possible for the player to access a Poké Mart on Route 11 which sells 128 items including glitch items. This trick was documented by TheZZAZZGlitch.
Sea Route 21 arbitrary text box
- Main article: Sea Route 21 0x44 text box glitch
Loading the hex:44 text box on Route 21 (via the shelves of Pokémon goods in Cinnabar Poké Mart) executes arbitrary text code from D2C3 in WRAM (the fifth character of the second Pokémon's nickname). This can be manipulated to run arbitrary code; for example with Super Glitch and the expanded party one can convert items in the inventory into Pokémon nicknames and abuse this to obtain Mew as a gift Pokémon via the 08 text function (run ASM following the 08). This trick was documented by Torchickens.
Glitch meta-map script activation
- Main article: Glitch meta-map script activation
Glitch meta-map script activation often causes walking lag, with possible random sound effects being played or freezes (depending on your coordinates) when you return to the route you escaped from a Trainer (after following the finite or infinite Special stat encounter glitch).
It may be caused by text box matching dialog for an undefeated Trainer and defeating them, or the following method:
1. Perform the 'fly away' part of the Trainer escape glitch.
2. Change boxes and reset the game.
3. Return to the original route where the player flew away and defeat any Trainer.
Ultimately it can also be used as a setup for arbitrary code execution.
Trade NPC Pokémon and resulting Pokémon
When you talk to a trade NPC after enabling a potential Special stat encounter (so an instant encounter when you return to the route you escaped from), it will change the Pokémon you encounter to be no longer based on the Special stat, but rather, the identifiers of the fifth and sixth characters (including end name markers) of the trade Pokémon's nickname (CD2D and CD2E) (in fact, CD2D is also wEngagedTrainerClass and CD2E is wEngagedTrainerSet), but encountering a wild Pokémon or Trainer afterwards will 'overwrite' the Pokémon to be based on the enemy's Special stat again.
This trick does not work in the Japanese Pokémon Red/Green/Blue.
The player does not have to make a trade, and the glitch will work even if the trade has been done.
The fifth character controls the species, and the sixth character controls the level. It is possible to obtain certain Pokémon over level 100 this way. Below are the possible encounters.
To get other encounters, the player may also be able to modify CD2D and CD2E with Brock Fly.
- Route 2 - Abra for Mr. Mime (MARCEL): Level 139 Snorlax
- Route 5 - Nidoran♂ for Nidoran♀ (SPOT): Level 80 Missingno. (50h, Dec: 80)
- Route 11 - Nidorino for Nidorina (TERRY): Level 80 Starmie
- Route 18 - Slowbro for Lickitung (MARC): Level 80 Missingno. (50h, Dec: 80)
- Cerulean City - Poliwhirl for Jynx (LOLA): Level 80 Missingno. (50h, Dec: 80)
- Vermilion City - Spearow for Farfetch'd (DUX): Level 80 Missingno. (50h, Dec: 80)
- Cinnabar Island - Raichu for Electrode (DORIS): Level 80 Missingno. (92h, Dec: 146)
- Cinnabar Island - Venonat for Tangela (CRINKLES): Level 139 Kingler
- Cinnabar Island - Ponyta for Seel (SAILOR): Level 145 Clefable
- Route 2 - Clefairy for Mr. Mime (MILES): Level 80 Missingno. (92h, Dec: 146)
- Route 5 - Cubone for Machoke (RICKY): Level 80 Starmie
- Route 11 - Lickitung for Dugtrio (GURIO): Level 80 Clefable
- Route 18 - Tangela for Parasect (SPIKE): Level 80 Snorlax
- Cinnabar Lab - Golduck for Rhydon (BUFFY): Level 80 Starmie
- Cinnabar Lab - Growlithe for Dewgong (CEZANNE): Level 141 Electrode
- Cinnabar Lab - Kangaskhan for Muk (STICKY): Level 152 Kingler
Specifically for Special stat encounter, the disabled Start menu, and prevented battles, Háčky provided the following explanations.
"When a Trainer spots you, the game loads the Trainer class into $CD2D and team number into $CD2E, and sets a map script that will have the Trainer give his/her dialogue and start the battle. When you leave the map, the current script for that map is saved, and will be run again when you re-enter that map.
In battle, $CD0F–CD1F are used to store the stats and stat modifiers of your active Pokémon, and $CD23–CD33 are used for the enemy Pokémon. This data consists of the Pokémon’s level and unmodified stats (HP, Attack, Defense, Speed, Special), followed by the modifier stages for Attack, Defense, Speed, Special, Accuracy, and Evasion. Thus, $CD2D is the lower byte (big-endian) of the enemy’s Special stat, and $CD2E is its Attack modifier. When you return to the map where you began the glitch, the map script will read these values and start a battle against whatever Pokémon or Trainer they indicate."
"Bit 0 of $CD60 is set when the Trainer spots you, and disables the Start menu and so on. It’s cleared when you win a Trainer battle, when you black out (either in- or out-of-battle), or when you save and reset.
Bit 0 of $D730 is set when an NPC starts walking, and is cleared when they’re done walking. When a Trainer spots you, the battle won’t start until this is cleared, though you can still battle Trainers by talking to them (once you can talk to them, by clearing $CD60). This is why it’s necessary to fight another Trainer who can walk up to you, or to challenge the Elite Four, which clears this flag when Prof. Oak is done walking in the ending cutscene.
Actually, it seems there’s a way to make this glitch work without fighting a Trainer at all: after using the PC to save the game and reset (as in the Elite Four method, clearing $CD60), fly to Pewter City and ask the guy next to the Poké Mart to escort you to the museum. That walking NPC will clear $D730 when he’s done, allowing the battle to start when you return to the map with the long-range Trainer."