Atlasプレビュー
しくみ

赤・青:宙に浮いた戦闘(ミュウのバグ)

トレーナーに見つかった瞬間にマップを離れると、戻ったとき前の戦闘の残りから相手が決まる。

A trainer sees you, the map remembers a battle must start

Each map keeps its own step counter. At step 0 the game looks for a trainer who sees the player. When it finds one, it shows the exclamation mark, makes the trainer walk up and moves the map to the next step: 'show the trainer's text and start the battle'.

Meanwhile it only blocks the D-pad: the other buttons are still read. If the player leaves the map at that moment, with Fly or Teleport from the menu, that map's counter stays on 'start the battle'. It is stored with the map and does not go back to 0 on its own.

Sources : pokered home/trainers.asm : CheckFightingMapTrainers (« ld a, PAD_CTRL_PAD / ld [wJoyIgnore], a », « inc [hl] » sur wCurMapScript) ; scripts/Route24.asm : wRoute24CurScript, Route24_ScriptPointers (DisplayEnemyTrainerTextAndStartBattle)

On return: the menu opens by itself, then a battle starts

Back on the map, the game resumes at the stored step. It has to show the text of the trainer who was walking up, whose number it reads from a variable. But on the other maps, as long as no trainer saw you, that variable was reset to 0.

The game therefore shows text number 0, and text number 0 is the Start menu: it opens by itself. As soon as it is closed, the rest of the step runs: set up the opponent, then start the battle.

Sources : pokered home/trainers.asm : DisplayEnemyTrainerTextAndStartBattle (« ld a, [wSpriteIndex] / call DisplayTextID »), CheckFightingMapTrainers (« xor a / ld [wSpriteIndex], a ») ; home/text_script.asm : « dict TEXT_START_MENU, DisplayStartMenu » ; constants/text_constants.asm : TEXT_START_MENU EQU $00

The opponent is read from the leftovers of the last battle

To set up the opponent, the game reads two bytes: the engaged trainer's class and their team number. Those two bytes share their place in memory with battle data. The first is also the low byte of the last opposing Pokémon's Special (its value without modifiers).

The second is that same Pokémon's Attack stage, 7 when nothing changed it. After another battle they no longer describe a trainer. If the first byte is below 200, the game takes it as the internal number of a wild Pokémon, and the second byte as its level.

A last opponent with a Special of 21 gives internal number 21: Mew, at level 7. From 200 up, a trainer of the matching class appears.

Each move that lowers that last opponent's Attack removes one stage: six Growls take the stage from 7 to 1, and the Pokémon appears at level 1.

Sources : pokered ram/wram.asm : UNION (wEnemyMonUnmodifiedSpecial, wEnemyMonAttackMod / « ds 30 », wEngagedTrainerClass, wEngagedTrainerSet) ; home/trainers.asm : InitBattleEnemyParameters (« cp OPP_ID_OFFSET ») ; constants/trainer_constants.asm : OPP_ID_OFFSET EQU 200 ; constants/pokemon_constants.asm : « const MEW ; $15 » ; data/pokemon/dex_order.asm