Open Route 30 with map trainers and multi-Pokémon trainer battles

Map trainers run the ROM's TalkToTrainerScript and SeenByTrainerScript.
_CheckTrainerBattle runs before tile events at the end of each step and
on idle ticks; TrainerWalkToPlayer builds wMovementBuffer natively, and
writeobjectxy keeps the trainer where it stopped. The interpreter gains
the trainer header commands, wRunningTrainerBattleScript and hidden
items (HiddenItemScript).

Trainers with several Pokémon send out the next one through
EnemyPartyMonEntrance and FindMonInOTPartyToSwitchIntoBattle, including
its BattleRandom fallback. AI_SwitchOrTryItem, CheckAbleToSwitch and
AI_Switch are translated with their original bugs, and wPlayerUsedMoves
is recorded. The Shift-mode switch offer, trainer items, Pursuit on a
switch, Perish Song and Spikes remain refused.

Route 30 and its Berry house are enabled; Mr. Pokémon's house and
Route 31 stay closed. A refused trainer sighting does not restart until
the player moves, so a rollback cannot trap the player in view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sébastien QUEROLandClaude Opus 5.5 committed 2026-09-24 14:36:54 +02:00
1 parent 0d1bedb3b1
commit e00dfab42e
18 files changed
+1156 -62

No files matched your search

+31
View File
@@ -195,3 +195,34 @@ tests; native and reference builds; reference, release and vendor checks;
Next (unchanged): Smart AI before the rival, or trainer sight lines and
normal trainer-object scripts for Route 30's Youngster and Bug Catcher.
## Route 30 trainers: 2026-09-24
Chose option 2 from the review above: trainer sight lines and trainer-object
scripts. Both Route 30 trainers have two Pokémon, so the increment also ports
the trainer's send-out and switch AI. Route 30 and its Berry house are now
enabled in production.
- World: `_CheckTrainerBattle` at step end (before warps, coordinate events and
encounters) and on idle ticks; `TalkToTrainer` for `OBJECTTYPE_TRAINER`;
`BGEVENT_ITEM` hidden items. A refused sighting is not restarted until the
player moves (native safeguard against a rollback loop).
- Interpreter: `loadtemptrainer`, `trainertext`, `trainerflagaction`,
`scripttalkafter`, `endifjustbattled`, `checkjustbattled`, `writeobjectxy`,
`encountermusic`, `loadmem wRunningTrainerBattleScript`, `readmem
wHiddenItemID`, and callasm `TrainerWalkToPlayer`/`SetMemEvent`.
`applymovementlasttalked wMovementBuffer` decodes the native buffer.
- Battle: multi-Pokémon trainer parties (`HandleEnemyMonFaint`,
`EnemyPartyMonEntrance`, `FindMonInOTPartyToSwitchIntoBattle` with its
`BattleRandom` fallback), `AI_SwitchOrTryItem`/`CheckAbleToSwitch`/`AI_Switch`
with the original type-matchup, `e`-carry and quarter-HP bugs, and
`wPlayerUsedMoves`. `BattleTrainer` now requires `switchFlags`.
- Stress (local, not committed): 1,080 Route 30 battles; the only refusal was
Chikorita's Reflect at level 12 (`screen`), a pre-existing gap.
Final checks: 160 unit tests with the local ROM; 44 Chromium/WebKit browser
tests including the Route 30 sighting through the UI; native and reference
builds; reference, release and vendor checks; `git diff --check`. Not committed.
Next: Mr. Pokémon's house (Oak, Pokédex, Mystery Egg) and the return to Elm;
Reflect/Light Screen; then Smart AI before the rival. Joey (after the Egg)
needs `askforphonenumber` and the phone standard scripts.