tracker: sticky selection and Ctrl+Home walk-to; walltones: conventional volume

Tracker selection now survives a rescan. The scan is rebuilt every turn and
both lists are distance-sorted, so holding a bare index meant one step by the
player silently re-pointed the selection at a different rat. The tracker now
remembers identity instead -- the actor table for creatures, coordinates for
tiles -- and re-derives the indices in reanchor() after each rescan. Selection
is dropped only when the thing genuinely stops being reported (out of FoV,
killed, picked up), and the existing clamp then falls back to the nearest.

Ctrl+Home walks to the selection, reusing the exact shape of the game's own
click-to-path in ingame.mousepressed: calculatePathFromPlayer, then either
bufferInput or playerInput for a one-step path. Interruptions and threatened-
player truncation therefore behave the way a mouse click does. Most things
worth tracking stand on impassable tiles, which calculatePathFromPlayer refuses
outright, so we fall back to the cheapest of the 8 neighbours and say "next to"
rather than "to". Guarded on states.getCurrent() == "ingame": elsewhere the
input buffer belongs to another state and feeding it moves would be a bug.

Wall tones now follow the usual proximity convention -- a near wall is loud,
one out at radius is quiet. It was inverted, which read backwards in play since
a nearby wall is the more urgent fact. config.louderWhenFurther still flips it.

Testbed covers both: selection identity across a forced rescan, and that
Ctrl+Home moves the player without breaking out of the map.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Accessibility Mod
2026-08-02 01:00:25 +02:00
co-authored by Claude Opus 5
parent 6380998376
commit 81a209b600
5 changed files with 293 additions and 21 deletions
+30 -3
View File
@@ -140,6 +140,7 @@ and by Talon at the keyboard (wall tones).
| `PageUp` / `PageDown` | Tracker: previous / next **kind** |
| `Shift+PageUp` / `Shift+PageDown` | Tracker: previous / next **instance** |
| `Home` | Tracker: distance, direction and path length to current instance |
| `Ctrl+Home` | Tracker: walk to current instance (the left-click path) |
| `'` | Health and active effects |
| `,` | Current selected action |
@@ -178,9 +179,9 @@ even while the camera is panned away.
Step detection **polls** `playerActor.x/y` each frame instead of hooking movement
— free, and covers walking, pathing, portals and pushes by construction.
⚠ `config.louderWhenFurther = true` as requested, but this inverts the usual
convention (proximity cues normally get louder as you approach, and a near wall is
the more urgent fact). Flip the flag in `walltones.lua` if it reads backwards.
Volume follows the usual proximity convention: a near wall is loud
(`nearVolume`), one out at `radius` is quiet (`farVolume`). Set
`config.louderWhenFurther = true` in `walltones.lua` to invert it.
Respects `FoV`/`rememberedFoV` — never leaks unseen map geometry.
@@ -319,6 +320,32 @@ remembered. The tracker never reveals what a sighted player couldn't see.
misleading indoors: a chest 3 tiles north through a wall can be 20 steps away.
Uses the game's own `calculatePathFromPlayer`.
**`Ctrl+Home` walks there.** The game does support click-to-path: `ingame.mousepressed`
(`states/ingame.lua:661`) builds `calculatePathFromPlayer(cursorX, cursorY)` and
feeds it to `level.bufferInput("move", path, ingame)`, or to `playerInput` directly
when the path is one step. `tracker.walkToSelection` reuses that exact shape with
the tracker's selected tile in place of the cursor, so interruptions, threatened-
player truncation and animation skipping all behave the way a mouse click does.
Two wrinkles, both handled:
* `calculatePathFromPlayer` returns nil for an impassable target, and most things
worth tracking (creatures, chests, beds) are impassable. We fall back to the
cheapest of the 8 neighbouring tiles and say "walking next to X".
* Guard on `states.getCurrent() == "ingame"`. In a menu or observe mode the input
buffer belongs to a different state, and handing it moves would be a bug.
Note `require("states/ingame")` with a slash — that is the module key `states.lua`
uses, and requiring `states.ingame` would load a *second* copy of the state.
**Selection is sticky across rescans.** The scan is rebuilt every turn and both
lists are sorted by distance, so holding a bare index means one step by the player
silently re-points the selection at a different rat. The tracker instead remembers
identity — the actor table for creatures, coordinates for tiles — and re-derives
the indices in `reanchor()` after each rescan. Selection is dropped only when the
thing stops being reported at all (out of FoV, killed, picked up); the existing
clamp then falls back to the nearest.
#### ⚠ Correction to D4 — `tryInteract` is NOT a clean "worth tracking" signal
`wall` carries a **flavour-only** `tryInteractFunction` ("You touch the wall.
It's cold and rough."), so flag-first classification promoted every wall segment