Line of sight in Hearthtable
Walls, doors, secret doors and lights decide what each player's tokens can see and where they can walk. The server works all of this out. A player's browser receives only the tokens, pins and drawings their tokens can see, so a changed browser or a look at the page's data shows nothing more.
Where walls come from
- A map you bring in. A Universal VTT file (
.dd2vtt,.uvtt), a Foundry scene or a Watabou dungeon carries its walls, doors, secret doors and lights. When you put the map on the table from the library, they come with it, and Walls block sight is switched on for that scene. See Bringing in maps. - Drawn by the GM. Pick Wall or Door in the map tools and drag from one end to the other. Ends snap to grid corners when the grid snaps.
Click a wall or door on the map (with Move picked) to open its menu. From there you can open, close, lock or unlock a door, reveal a secret door, make a door secret again, or remove the wall.
Sight on a scene
Open Who sees what and find Line of sight. Each scene has its own settings:
| Setting | What it does |
|---|---|
| Off | Players see the whole map, as before. Walls can still stop tokens. |
| Walls block sight | Each token sees as far as its range, up to the walls and closed doors. |
| Walls and lights | As above, but past a token's dark range it sees only lit places. |
| Walls stop players' tokens | A player's token stops just short of a wall or closed door. A GM's moves always go through. |
| Remember explored areas | Places a chair has seen stay on its map, dimmed. Pins and drawings there stay. Tokens there show only while in sight. Forget what everyone explored clears it. |
Each chair has two ranges, in grid squares. Sees is how far its tokens see at all (0 means no limit). Sees in the dark is how far they see without light, which matters only in Walls and lights. Lights are added from the same panel and drawn on the GM's map as dashed circles.
Doors
- A player can open or close an unlocked door when one of their tokens is next to it, with nothing in between. Otherwise they get "Move your token next to the door first."
- A locked door looks closed to players. Trying it says "This door is locked." Only a GM locks and unlocks doors.
- A secret door is a wall to players. It isn't drawn, isn't named, and can't be opened, until the GM picks Reveal. From then on it's an ordinary door.
- Windows block movement but not sight. Low walls (terrain lines) are drawn for the GM and block nothing.
What each view receives
| View | Receives |
|---|---|
| A player's chair | Its own tokens always. Other tokens only while one of its tokens sees them. Pins and drawings it sees now or has explored. The polygons to draw and the doors in view. Never a wall, a secret door or a hidden token. |
| A covering player | The covered chair's view, the same as that chair's own: never more. |
| The table view (watchers, the Broadcast view) | What the party sees together: every token a player moves, each with its chair's ranges. Never more than the players together see. |
| Preview as (GMs) | Exactly what that chair, or the table, receives. |
| A blind chair | Nothing, as before. |
Initiative follows sight too. A combatant whose token a view can't see keeps its place in the order but shows as "Someone out of sight", with no conditions, until a token there sees it. An entry the GM marks hidden never shows. An entry with no token (one the GM typed in) shows by its name.
Fog and line of sight work together: a place under fog stays hidden even in sight.
Painted maps
A scene made in the map painter gets its walls from the painting. When the map is saved with Save & play, its walls, doors, windows and secret doors replace the scene's painted walls, and objects marked Blocks sight add their outlines. Walls you drew by hand on the scene with the Wall and Door tools stay as they are.
- A painted wall's id starts with
pw:. A door keeps the same id while its wall is unchanged, so whether it is open, shut or locked carries over a save. - Opening a door at the table changes only the scene's live sight; the painted map isn't saved again.
- Low walls (fences, hedges, rubble) are drawn on the map but stop neither sight nor movement.
- A painted scene's grid is set from the map, so walls lie exactly on the squares tokens snap to.
A painted map holds up to 4,500 sight walls, inside the scene's limit below.
Limits and speed
A scene holds up to 5,000 walls and 300 lights, and one change adds at most 1,000 walls. Sight is recalculated only when something it depends on changes: a token moving, a door opening, a wall or light changing, or a scene switching. Results are cached per chair. A 200-wall map with 8 chairs stays within a few milliseconds a move on the server, which a benchmark test checks.
For developers
The geometry is packages/tabletop-engine/src/sight.ts, copied byte for byte to the server
(packages/server/src/lib/tabletop/engine/sight.ts). The table applies it in packages/server/src/lib/tabletop/sight.ts.
The ops are sight.set, wall.add, wall.update, wall.remove, light.add, light.remove and door.set; players
may send only door.set. The tests are the golden and fuzz tests in packages/tabletop-engine/test/sight.test.ts,
the gate and benchmark in packages/server/src/lib/tabletop/sight.test.ts, and the visibility gates in
routes/tabletop.visibility.test.ts and routes/tabletopMaps.visibility.test.ts.