Port Headbutt and Rock Smash encounters

Facing a Headbutt tree asks to HEADBUTT it, and HEADBUTT from the party
menu skips the question. ShakeHeadbuttTree shakes the tree as a sprite over
grass, then TreeMonEncounter scores the facing tile against the trainer ID
and draws from the map's common or rare tree table. A Pokémon that falls
fights as BATTLETYPE_TREE: "fell out of the tree!", and the time of day's
AsleepTreeMons species start asleep.

Smashable rocks run SmashRockScript, and ROCK SMASH from the party menu
acts on the facing rock; after the rock breaks, RockMonEncounter gives the
map's rock set a 40% chance of a wild battle.

Closes #26

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sébastien QUEROLandClaude Opus 5.5 committed 2026-10-02 12:20:13 +02:00
1 parent ee55d344af
commit f259163da9
18 files changed
+789 -36

No files matched your search

+50 -1
View File
@@ -1,6 +1,6 @@
# Recovered Claude session
Latest continuation: see **Mom's bank and her purchases: 2026-10-01**
Latest continuation: see **Headbutt and Rock Smash: 2026-10-02**
at the end of this file. Earlier sections are historical snapshots.
Recovered on 2026-09-23 from the local Claude Code transcript
@@ -1039,3 +1039,52 @@ Teleport then Fly was checked once in Chromium and WebKit.
Not made into cards, because they can be automated: emulator comparisons
of the flight paths and of the Teleport/Dig warps through the reference
harness.
## Headbutt and Rock Smash: 2026-10-02
Resumed with "continue the plan" on a clean tree after `ee55d34`, taking
board card #26.
- `src/game/scripts/treemons.ts`: `treeMonEncounter` (`TreeMonEncounter`
with `GetTreeMonSet`, `GetTreeMons`, `GetTreeScore` and `GetTreeMon`,
including the rare table after the common one), `rockMonEncounter`
(`RockMonEncounter`'s 40%) and `treeScore`, all read from the ROM's
`TreeMonMaps`, `RockMonMaps` and `TreeMons`.
- Interpreter: `callasm` runs `TreeMonEncounter` (facing tile in
`wPlayerMapX/Y` coordinates, +4), `RockMonEncounter`, `HasRockSmash`
(sets `wCurPartyMon`) and `ShakeHeadbuttTree` (a `headbutt` effect after
the text). A `tempWild` local stands for `wTempWildMonSpecies`/
`wCurPartyLevel`: `randomwildmon` reads it, `readmem wTempWildMonSpecies`
answers from it, and the battle clears it with the tree battle type, as
`CleanUpBattleRAM` does. The `battle` effect gained `tree`.
- World: facing a tree runs `AskHeadbuttScript`; HEADBUTT and ROCK SMASH
from the party menu queue `HeadbuttFromMenuScript` and
`RockSmashFromMenuScript`, the latter with the rock as `hLastTalked`
(`MenuFieldMove.lastTalked`). Talking to a rock already ran
`SmashRockScript`. The `headbutt` effect lasts 20 ticks
(`HEADBUTT_TICKS`) and `world.headbuttTree` gives the renderer the square
and frames; objects do not move meanwhile.
- Battle: `BATTLETYPE_TREE` (`tree` option) prints
`PokemonFellFromTreeText` and puts the time of day's `AsleepTreeMons`
species to sleep for `TREEMON_SLEEP_TURNS` (`CheckSleepingTreeMon`). The
skipped cry is not presented anyway.
- Renderer: tile $05 over the tree's four tiles for 36 frames, and the
`HeadbuttTreeGFX` sprite in `PAL_OW_TREE` with the frameset's timing
(three video frames a step, frame 2 mirrored on every other pass). Checked
in Chromium with close-up screenshots across the shake.
- New profile entries (OVERWORLD, BATTLE, `RAM.tempWildMonSpecies`) and
constants (`BATTLETYPE_TREE`, `TREEMON_SLEEP_TURNS`, `NUM_TREEMON_SETS`),
all verified by `check:reference`.
Checks: 435 unit tests with the local ROM (434 passed, 1 skipped; 135
passed, 300 skipped without it; new `tests/headbutt-rock-smash.test.ts`,
and the Rock Smash test in `tests/overworld-rom.test.ts` now smashes the
rock and meets a Krabby); 123 Chromium/WebKit browser tests passed, 19
skipped intentionally (a new Headbutt flow with a "headbutt" fixture room
below a Route 29 tree); native and reference builds; reference, vendor and
release checks; `git diff --check`. No emulator comparison of the tree
scores or the shake; no CI or physical-device run. Unreachable in normal
play so far: no open map has rocks, and Headbutt (the Ilex Forest tutor)
and Rock Smash (a TM on Route 36) are not obtainable yet.
Next: the remaining field items, MAIL and pack reordering (board #27).