Say how close an NPC has to be placed to be talked to
Some checks failed
libakgl CI Build / cmake_build (push) Failing after 21s
libakgl CI Build / performance (push) Failing after 22s
libakgl CI Build / memory_check (push) Failing after 17s
libakgl CI Build / mutation_test (push) Failing after 18s

A reader drew their own town, put the elder 115 pixels from anywhere the player
could stand, and spent the rest of their time looking for the bug in
jrpg_cmhf_talk. There is no bug: the handler finds nobody within TALK_RANGE and
returns success, which is indistinguishable from the game not being wired up.

The chapter stated the constant and not what it means in the editor.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KzBDV2fqgnUAcqCKqKvc71
This commit is contained in:
2026-08-02 09:36:25 -04:00
parent 6e97d27e49
commit cf0142ea85

View File

@@ -962,6 +962,13 @@ range, otherwise do nothing.
#define TALK_RANGE 64.0f
```
**Place your NPCs with that number in mind.** The distance is measured between the two
actors' positions, and both sprites are 32 pixels, so 64 is two sprite widths — close, by
design. An NPC parked behind a building or across a wall from anywhere the player can stand
is an NPC the player can see and never talk to, and nothing reports that: the handler finds
nobody in range and returns success. If a conversation will not open, print the distance
before you go looking at the code.
```c excerpt=examples/jrpg/world.c
#define TOWNSFOLK_COUNT (sizeof(TOWNSFOLK) / sizeof(TOWNSFOLK[0]))
```