Last updated with AmiWind v0.0.67-dev2 (18 November 2026).
- Summary
- How Morrowind does it
- How OpenMW does it
- How Quake does it
- What AmiWind does today
- Grid on CHIM collision (measured)
- Options for AmiWind on the Amiga
- Recommendation and staged plan
- Wander packages, compiled (v0.0.54)
- Travel packages, from the scripts (v0.0.57)
Investigation, 9 October 2026 (maintainer request). How Morrowind, OpenMW and Quake move their characters around, what AmiWind does today, what the options cost on a 68040, and a staged plan. The CHIM side (where the walkable graph lives in the world format, budgets and gates) is in CHIM NPC pathfinding.
Status: design and measurement. No engine or QuakeC change has been made. Every number below is an aggregate measured from the maintainer's own master files or from builder output; no record is copied. Emulator and cycle figures are relative or estimated, as stated at each one.
- Morrowind stores a small graph per cell, not a mesh. Each cell may carry
one path grid (record
PGRD): points with positions and links between them. On Vvardenfell (Morrowind.esm) 1,194 of 2,538 cells have one: 1,060 of 1,134 interiors (93 %) but only 134 of 1,404 exteriors (10 %). The island holds 41,745 points and 54,888 links; a grid has 24 points at the median and 246 at most. Grids never link to the next cell. - Most outdoor actors stand where there is no grid. 4,597 of the 5,082 exterior levelled-creature spawn points, and 492 placed exterior actors, are in cells without a path grid. Any outdoor hostile needs a method that works without Morrowind's data.
- OpenMW builds a navigation mesh at run time with Recast/Detour from the collision shapes, joins the loaded cells, adds the path grid links into it, and falls back to an A* over the cell's grid only when the mesh fails.
- Quake has no map of the level at all: a monster turns toward its enemy, tries a step, and picks another of eight directions when blocked. Cheap, stairs included, but walls and dead ends lose it.
- AmiWind today: only the two scripted opening guards walk (ship escort and dock guard), with a breadth-first route over the original path grid and the player's own step code. Every other NPC stands, idles, turns and greets.
- Recommendation (the ladder): (1) Quake-style chase on the player's step code, which already climbs every flight the stair gate passes; (2) a stuck check with a short local probe; (3) path-grid routing on a small stored walkable graph, only when the target is out of sight or the NPC is stuck, with a fixed node budget per frame. No navmesh. The stored graph costs about 0.1 MB for the island's exterior grids plus an estimated 0.6 MB at most for generated graphs in the cells Morrowind left without one.
A path grid belongs to one cell (interior by name, exterior by grid coordinates) and holds, little-endian:
| Subrecord | Contents |
|---|---|
NAME |
cell name (an exterior grid may carry the cell's or the region's name) |
DATA (12 bytes) |
i32 grid x, i32 grid y (0, 0 for interiors), u16 granularity, u16 point count |
PGRP (16 bytes per point) |
i32 x, y, z (exterior points relative to the cell's corner), u8 flags (1 = generated by the editor), u8 link count, 2 bytes padding |
PGRC (4 bytes per link) |
target point index for each link, the points' links in point order |
Public format references: the OpenMW loader
(components/esm3/loadpgrd.hpp)
and the UESP file format page.
Our measurement confirms the layout on the maintainer's data: every grid's point
count matches its PGRP size, 133 of the 134 exterior grids lie inside
their cell's 8,192-unit square, and every link is stored both ways (0 one-way
links island-wide). Granularity is the editor's sampling step when it
generates a grid (1,024 units for 737 grids, 256 for 265); 89 % of all points
carry the "generated" flag, so most grids came out of the editor's generator
and were then edited by hand.
Each actor carries an ordered list of behaviour packages (subrecords AI_W wander,
AI_T travel, AI_F follow, AI_E escort, AI_A activate) plus its behaviour
settings (AIDT: hello, fight, flee, alarm). Wander gives a distance, a
duration, an hour and eight idle weights; the actor picks destinations among
the cell's grid points within that distance of where it started, walks there
and plays idles. Travel, escort and follow move toward a point or an actor.
Combat chases the target.
What is certain from the data:
- The graph is per cell and has no links across cell borders. On Vvardenfell 754 exterior points lie within 256 units of a cell edge, 596 of them facing a cell that has its own grid; nothing joins them.
- A cell without a grid gives an actor nothing to route on.
How the original engine searched the grid and handled cell borders is thinly documented in public sources. OpenMW's reimplementation (below) is the best public reference: an A* over the current cell's grid, with straight lines where there is no grid. Players know the visible result: actors stuck on rocks and corners, unable to reach a player standing on a ledge or a rock.
Tool: tools/path_grid_stats.py (reads the
masters read-only, prints aggregates only; test tests/test_path_grid_stats.py).
Morrowind.esm (Vvardenfell), in Morrowind units (AmiWind units are a quarter):
| Interiors | Exteriors | All | |
|---|---|---|---|
| Cells | 1,134 | 1,404 | 2,538 |
| Cells with a path grid | 1,060 | 134 | 1,194 |
| Points | 34,513 | 7,232 | 41,745 |
| Links (undirected) | 44,908 | 9,980 | 54,888 |
| Points per grid: median / p90 / p99 / max | 23 / 73 / 142 / 217 | 47 / 104 / 239 / 246 | 24 / 80 / 147 / 246 |
| Grids in more than one connected part | 208 | 68 | 276 |
| Link length: median / p99 / max | 258 / 724 / 4,887 | 428 / 1,176 / 1,959 | 277 / 906 / 4,887 |
| Links longer than 1,024 units (one CHIM chunk) | 58 | 235 | 293 |
| Bytes as stored in the master | 911,832 | 195,580 | 1,107,412 |
| Bytes as a compact graph (7 bytes per point, 1-2 per link end) | 331,407 | 70,584 | 401,991 |
Points per grid, all grids: 2-8 points: 277 grids; 9-16: 189; 17-32: 233; 33-64: 300; 65-128: 166; 129-256: 29. The largest exterior grids are town cells (Balmora 246 points, Ald-ruhn 239); the largest interiors are tombs and sewers (217 at most).
A local patch (the points within a radius of a point, what a search around one actor touches): within 512 units median 6, max 60; within 1,024 units median 14, p99 72, max 113; within 2,048 units median 31, max 157.
Actors on Vvardenfell:
| Interiors | Exteriors | |
|---|---|---|
| Placed NPCs and creatures | 3,007 | 899 |
| Levelled-creature spawn points | 1,270 | 5,082 |
| Cells with placed actors | 913 | 372 |
| ... of which without a path grid | 26 (41 actors) | 266 (492 actors) |
| Levelled spawn points in cells without a grid | 39 | 4,597 |
Packages of placed actors: wander 3,753, travel 168, follow 69, none 89. Wander distance: median 128 units (32 AmiWind units), p75 512, p90 1,000, p99 2,000, max 10,000; 778 actors wander with distance 0 (stand in place).
With Tribunal and Bloodmoon merged (later masters win): 2,887 cells, 1,386 grids (148 exterior), 53,771 points, 77,999 links, largest grid 855 points (compact graph 548,947 bytes). Tribunal adds 89 interior grids; Bloodmoon 14 exterior and 89 interior grids.
The three towns AmiWind ships or previews (3 x 3 exterior cells around the town's centre cell, interiors by name):
| Area | Exterior cells with a grid | Exterior points / links | Largest exterior grid | Interiors with a grid | Interior points / links |
|---|---|---|---|---|---|
| Seyda Neen | 2 of 9 | 106 / 159 | 95 | 13 of 13 | 109 / 107 |
| Balmora | 5 of 9 | 395 / 665 | 246 | 42 of 42 | 701 / 819 |
| Vivec, Arena canton | 8 of 9 | 759 / 813 | 211 | 9 of 9 | 469 / 597 |
OpenMW 0.51.0 (source read from the release tree; paths relative to the OpenMW repository):
- Navigation mesh, built at run time (
components/detournavigator/, the recastnavigation library). The input is the physics collision of objects, the terrain heightfield of each loaded exterior cell, water, doors as two-way off-mesh links and every path grid link as an off-mesh link. The mesh is cut into tiles (128 voxels of 0.2 x 34 units, about 870 units a tile) around the player, about 17 tiles in radius (maxTilesNumber1,024). Actor limits match the player: climb 34 units, slope 46 degrees. Tiles are built on a background thread and cached in memory (256 MiB cap by default) and on disk (navmesh.db, 2 GiB cap). Settings:[Navigator]infiles/settings-default.cfg, documented indocs/source/reference/modding/settings/navigator.rst. - Path search (
apps/openmw/mwmechanics/pathfinding.cpp): a Detour polygon path with string pulling first; if that fails, again with the grid links allowed; then an A* over the current cell's grid (Manhattan heuristic, start and end at the nearest connected points, connected parts precomputed per cell); then a straight line. - Wander (
aiwander.cpp): destinations are the cell's grid points within the wander distance that connect to the nearest point; with too few points, a random navmesh point near the start. It avoids water and occupied spots. - Stuck handling (
obstacle.cpp): an actor that moved less than half its expected distance over 1.5 s is stuck and tries up to seven evasion directions, one second each; next to a usable door it opens it. The actor reacts every 0.25 s; a direct shortcut is tried when the target is in sight. - Cell borders: grids are never linked across cells; outdoors the navmesh joins the loaded cells, and actors near the edge of the loaded area pause.
The design point for us: OpenMW needs the navmesh because the grids alone give the clumsy original behaviour. Its costs (a background builder thread, hundreds of megabytes of tile cache, Detour queries per actor) are far beyond an Amiga; the idea we keep is "grid links plus a fallback".
AmiQuake (engine/aga/src) keeps id's monster movement unchanged apart from the step height:
SV_movestep(sv_move.c): move the box, lift it bySTEPSIZE, trace it down2 x STEPSIZEwith the entity's hull, refuse starting in solid or stepping off a drop, thenSV_CheckBottomtests the four bottom corners (no corner may hang more thanSTEPSIZEbelow the centre). AmiWind setSTEPSIZEto 8.5 units (34 Morrowind units), the player's step.SV_StepDirection,SV_NewChaseDir,SV_MoveToGoal(QuakeC builtin 67,movetogoal) andPF_walkmove(builtin 32): turn toward the goal, step; when blocked, try the diagonal toward the enemy, then the two axis directions toward it, then the old direction, then all eight 45-degree directions in a random sense, and only then turn around. One chance in four per step to re-pick even when not blocked. A blocked monster can thus try up to about eleven steps in one think.- id's QuakeC (not part of AmiWind's progs) drives this from
ai_walk/ai_runevery 0.1 s; patrols follow chains ofpath_cornerentities (each names the next; touching one sets the next goal).
Strengths: no data, no search, stairs and slopes handled by the same step trace as the player. Weaknesses: greedy; a wall between monster and player, a U-shaped dead end or a door off to the side defeats it. Cost: one step is about six hull traces (measured below on a CHIM frame), so a fully blocked think can cost some sixty.
No wander, patrol, follow or combat movement exists. Two actors move, both in the opening, both native C (not QuakeC):
- Ship escort (
aw_intro.c, the "original name/escort script adapter"):AW_IntroTicksteps a state machine that sends intro role 2 to goals taken from the original CharGen scripts' travel targets. - Dock guard (
aw_opening.c): role 5 walks a fixed route and stops when the player comes close, as the original wander package does. - Routing (
aw_nav.c):AW_NavStartfinds the grid points nearest the actor and the goal and runs a breadth-first search;AW_NavStepwalks at 22 units/s, cuts corners when a hull trace is clear, steers ±30/60/90 degrees around blocks, waits for the player, and gives up after 5 s blocked or 8 s without progress. One walker at a time, at most 128 points and 512 links. - Grids: the builder converts exactly two path grids, the prison ship's
(
tools/prepare_intro.py,id1/intro/prison.awn) and Seyda Neen's exterior grids (tools/prepare_character.py,id1/intro/seyda.awn, two grids of 95 and 11 points, no links invented between cells). - Step code (
aw_walk.c):AW_ActorStepmoves an actor with the player's walk (AW_WalkPlayer, aroundSV_WalkMove): step up 8.5 units, floor normal at leastAW_WALKABLE_Z0.69 (46 degrees), no step off a ledge. Its comment records why: Quake's corner test refused parts of the ship the player can walk. - Everyone else (
engine/aga/qc/world.qc):aw_npcisMOVETYPE_NONE, snapped to the ground once (AW_NPCFloor, builtin 80, using the builder's baked ground fit fromtools/actor_grounding.py), then idles, turns toward the player and greets. The progs declare neitherwalkmovenormovetogoal, although the engine still has both builtins. - Packages:
src/mwad/npc.pydecodesAIDTand the wander package (distance, duration, hour, idles) and keeps the others in order; nothing reaches the maps yet (runtime_wanderingis always false).
See also the NPC cell traversal requirement and roadmap (planned NPC steps: walk poses, path-grid routes inside the wander radius, suspension while greeting).
Morrowind's grid points and links were placed for Morrowind's collision.
Before trusting them on ours, a private probe put every exterior point and
link of two CHIM worlds (format 0.5, builder output) onto the frame's
standing-hull collision, with the same offline tracer the stair gate uses
(chim.collision.FrameScene). Each link was walked in 8-unit steps twice:
with the player-style step that AW_ActorStep uses, and with Quake's
SV_movestep (corner test included).
| Frame | Points on walkable collision | Points inside solid | Links walked, player step | Links walked, SV_movestep |
|---|---|---|---|---|
| Balmora | 393 of 395 (22 more than 8 units off the grid height) | 2 | 642 of 662 (97 %) | 610 of 662 (92 %) |
| Seyda Neen | 104 of 106 (3 off, 1 of them on a steep face) | 2 | 144 of 156 (92 %) | 134 of 156 (86 %) |
(3 links in each frame have an end inside solid and were not walked.) So the
player step walks more of the original routes than Quake's monster step,
confirming the comment in aw_walk.c; and a few percent of the links need a
builder repair (a moved point or an inserted one). Each probe ran in under a
minute on one core.
Trace work per step (offline tracer, clipnode visits counted; the engine's
SV_RecursiveHullCheck does comparable work, but these are counts, not
cycles):
| Frame | Player step: traces, visits | SV_movestep: traces, visits |
16-way fan of 32-unit traces: visits per trace, median / p90 / mean |
|---|---|---|---|
| Balmora | 2.6, 250 | 6.0, 685 | 48 / 179 / 544 |
| Seyda Neen | 3.1, 1,022 | 6.0, 968 | 171 / 3,040 / 2,003 |
The means are dominated by a tail of traces that graze many planes (the same fan lifted by one step was not cheaper). The tail is registered as CHIM-TRACE-TAIL-33.
Budget reality: Balmora on CHIM draws about one frame per second on a 50 MHz 68040 (cycle-exact emulation, relative). Navigation must be a small fraction of that, spread over frames, and only for actors near the player. Cycle figures below are estimates (about 80 cycles per clipnode visit, 500 per trace set-up, 400 per placed hull entered; to be replaced by an engine counter on the cycle-exact preset, stage 1 below).
| Option | What | Memory (island) | CPU per use (50 MHz 040, estimate) | Covers gridless cells | Fits CHIM streaming |
|---|---|---|---|---|---|
| A | Morrowind grids as compact node graphs stored once per CHIM sector, search on demand | exterior grids about 0.1 MB on disk, interiors about 0.5 MB with their maps; a few KB resident | A* over a 256-unit patch: 0.1 ms median, 0.9 ms worst | no (10 % of exterior cells have a grid) | yes: streams with its sector |
| B | Quake chase (greedy steps, re-pick on block) plus path_corner-style routes for scripted walks |
none | one step 0.5 ms (Balmora) to 1.8 ms (Seyda Neen) | yes | nothing to stream |
| C | Baked navmesh polygons (as OpenMW) built offline by the builder | estimate tens of MB island-wide (polygons, links, detail heights per tile); Recast as a new builder dependency | polygon search plus string pulling: several times A* over a graph | yes | yes, but large |
| D | Hybrid (the ladder): B always; a stuck check with a short probe; A on a graph that the builder also generates where Morrowind has no grid | A plus at most about 0.6 MB generated (estimate) | B per step; probe 1.7-15 ms (Balmora); A* as A | yes | yes |
Details:
- A, graphs. 7 bytes per point plus 1-2 per link end today (the CHIM layout uses 8 and 2, see the CHIM page). A* with integer coordinates and a small binary heap is estimated at about 400 cycles per expanded point; the 1,024-unit patch has 14 points at the median and 113 at most, the largest whole exterior grid 246. A search finishes in one frame with a budget of about 64 points, or over two or three frames for the biggest grids.
- B, Quake. Works everywhere, but cannot get around a building to a
player out of sight.
path_cornerchains are what the opening already does with the original travel targets; for town wander they would duplicate what the grid already says. - C, navmesh. The best paths, but the bytes, the builder dependency and the run-time polygon queries all go the wrong way on a 68040; the gain over D is smoother paths in open terrain, where B already works.
- D, hybrid. Each layer only runs when the cheaper one failed: the chase costs one step per think, the probe only runs when stuck, the search only when the target is out of sight or the probe failed.
Collision: all actors trace with the standing hull (hull 1, the player's
14.64-unit box; tools/player_hull.py), so a passage open to the player is
open to an NPC and vice versa, and the stair rule (risers up to 8.5 units
become walkable treads) applies to NPCs for free. The builder's graph gate
(CHIM page) walks every link with the same step on the same collision.
Cross-cell, cross-chunk and doors: grids are stitched by the builder where a walk across the border passes (596 exterior border points face a gridded cell); CHIM links address points in neighbouring sectors directly, so a path crosses chunk and cell borders without a special case. Inside a cell, a door is a flagged point: the NPC opens it (the door's collision changes) and goes on. Load doors (to and from interiors) follow the traversal rules: hostiles normally stop at the exit; followers and escorts may pass. How companions are taken through a load door (OpenMW's rules: a follow package aimed at the player, within 800 Morrowind units, arriving at the door's destination) and how a follower survives an AmiWind map change: followers across doors and cells.
Option D, built as a ladder that starts with what Quake already gives us (maintainer direction, 9 October 2026). Every stage has a measurement before it is called done, a regression test, and the full gate.
- Quake chase with stair climbing. NPCs move with
AW_ActorStep(the player's step: 8.5-unit step, 0.69 slope limit), driven by Quake's chase logic (SV_StepDirection/SV_NewChaseDirorder of directions), from QuakeC through a new builtin (for exampleaw_walkmove(yaw, dist)), sincewalkmove/movetogoaluseSV_movestep's stricter corner test. Every flight that passes the stair gate is then climbable by NPCs too. Missing today: the builtin and its QuakeC declarations, walk poses for town residents (only the opening actors have them), more than one walker,MOVETYPE_STEP/ground flags for residents, and any hostile behaviour. Measure: an engine trace counter (traces, clipnode visits, cycles) per step on the cycle-exact preset at fixed Balmora and Seyda Neen poses; links of the original grids walked by the engine (the probe above predicts 97 % and 92 %). - Stuck check and local probe. Stuck = less than half the expected
progress over about 1.5 s (as OpenMW). Then (a) a fan of 8-16 short hull
traces around the NPC, picking the open direction that best reduces the
distance to the target or opens a line of sight (a wider
SV_NewChaseDir); (b) if that fails, a tiny flood fill (about 8 x 8 step-sized cells, classified by traces, breadth-first to the cell nearest the target). Only when stuck, only near the player, spread over one or two frames; needs no grid. Cost estimate: a 16-way fan 1.7 ms (median) to 15 ms (mean) in Balmora, 5-52 ms in Seyda Neen; the flood fill is about twelve fans, so it stays rare (at most one per NPC every few seconds). Measure: cycles per probe and probes per second on the cycle-exact preset. - Grid routing on a local patch. When the target is out of sight or the NPC is stuck or kited: an A* on the stored walkable graph around NPC and target (a few hundred units), the target's position as goal, a fixed node budget per frame; follow the route until the target is in sight, then back to stage 1. If the patch has no path (the target on a rock or ledge), the NPC switches behaviour (ranged attack, back off, wait at a sensible spot) instead of grinding into a wall. The graph comes from the path grids where they exist and from the builder's own generator elsewhere. Measure: A* expansions and cycles per search, resident bytes, gate results.
- Packages and borders. Wander inside the authored distance on grid points, travel, escort and follow; doors; actors handed across chunk and cell borders by the traversal rules. Measure: actors moving at once at fixed poses, frame time before and after.
Stage 1 and 2 need no new data and can start with the first combat work; stage 3 needs the CHIM graph format and gate.
Since v0.0.54-dev1 (console chim actors ambient on; on by default since v0.0.57, not saved;
chim actors ambient off keeps every actor standing; on and off answer what they do and whether
id1/npc-ambient.lut was loaded, with its actors and resident bytes) residents follow
their original Wander package (NPC-WANDER-NOT-EXECUTED-35). The rules are the
original's as OpenMW 0.51 implements them (apps/openmw/mwmechanics/aiwander.cpp, pathgrid.cpp); our own code.
At build time (tools/ambient_lut.py, one cached unit, id1/npc-ambient.lut, format AWAM1): for every placed
actor whose first package is Wander, its allowed destinations are the grid points of its cell within the wander
distance of its start that lie in the same strongly connected part of the grid as the point closest to it (links are
one-way as stored). With exactly one such point, its start and points part way along that point's links are added;
with none (no grid, or nothing in reach) it walks now and then to a random spot near its start. Every route between
two destinations is the grid's cheapest (Manhattan costs, as OpenMW's A*) and is stored as a next-hop table, so the
engine never searches. Points are offsets from the actor's own placement, in engine units, so the engine needs no
world or cell coordinates. A script's AIWander that names an actor (159 placements) widens the compile radius to
its distance; the compiled scripts' AIWander (with aw_mwscript 1) sets the same package at run time. The idle choice is compiled too: each idle Idle2..Idle9 rolls 0..100 and the highest roll at or under
its chance wins, all of it only with the chance fIdleChanceMultiplier (0.75); the builder stores the exact
distribution of that roll (at 1 % steps) as one cumulative table per distinct set of chances, so the engine draws
one number.
Measured on the maintainer's Morrowind.esm (27 October 2026): 3,738 placed actors with a Wander package first
(79 start with Travel or Follow, 89 have none; those stand); 1,802 walk grid routes, 1,167 walk the occasional
spot near their start, 769 stand (distance 0); 85 distinct idle tables. The whole table is 945,000 bytes: the rows
(105 KB) and idle tables (1.4 KB) stay in memory; an actor's points and routes (33 bytes at the median, 6.7 KB at
most) are read from the file when it first comes near the player. Seyda Neen's actors take 9.9 KB of the file,
Balmora's 40 KB. The stage takes about 5 s on one core.
In the engine (engine/aga/src/aw_ambient.c): a small state machine per actor within OpenMW's processing range
(7,168 original units) of the player: choose (an idle, played once from the actor's animation table, or with no
idle walk to a random other destination), walk the route at the original walk speed, arrive within 64 original
units, choose again. Decisions every 0.25 s (OpenMW's reaction time), steps every think (0.1 s; chim actors ambient think S), one
step trace set per walking actor per think, nothing for idle or far actors. A greeting pauses the walk; combat
owns a fighting actor and the package resumes after; ten failed steps in a row end a walk; an idle actor far from
all its destinations walks back. chim actors ambient prints the counters and cost, chim actors ambient list the actors, chim actors ambient steplog on one line per failed step (where, which way,
what the standing hull met, and a walker that starts its step inside solid) (no console command or
variable of its own: the resident registry budget).
A walker inside solid (AMBIENT-UNSTUCK-FLOOD-61, v0.0.61): every step runs Quake's stuck search first (the
player's walk, sv_phys.c SV_CheckStuck: up to 164 position tests, the developer message "Unstuck."). A walker
snapped onto ground that touches a steep face can test as inside solid (Quake's plane precision); its step into the
face then fails, and the failed step puts it back where it stood, so before v0.0.61 every following step of that walk
searched again (ten searches a walk). Now a failed step that started inside solid settles the walker once on the
clear spot the search finds (one unit aside or a few units up at most, aw_walk.c AW_ActorSettle), so its next
steps start clear. chim actors ambient settle on is the default (written into id1/default-game.cfg); chim actors ambient settle off
gives the old behaviour back for comparison. chim actors ambient prints the stuck searches of the residents' steps
(and per second), how many were settled, their position tests, and the searches of every body since the counters'
reset; chim actors ambient list prints each resident's own count. chim actors ambient put SLOT X Y Z [GX GY]
puts the resident of a list slot at a point (map units) and, with a goal, walks it straight there, so a spot can be
checked on purpose. In a forced test on the Seyda Neen residents, 106 searches and 1,758 position tests fell to 9 and
336 (minus 81 percent); the cause was a resident's standing box at the foot of a steep face, and the face itself is
unchanged. The measurements are in docs/performance/FRAME-WAITS.md.
Since v0.0.66 the search leaves other bodies out, and two bodies that overlap walk apart as the original's actors
do: a resident standing inside the player (or the player inside it) is not stuck and its steps away are taken
(PLAYER_MOVEMENT.md, bodies that overlap).
Doors (v0.0.66, WANDER-DOOR-RULE-66). Wanderers keep off doors as the original's do. The rules are
OpenMW 0.51's (apps/openmw/mwmechanics/aiwander.cpp onIdleStatePerFrameActions and evadeObstacles,
obstacle.cpp proximityToDoor / getNearbyDoor), our own code in engine/aga/src/aw_ambient.c:
- A door ahead is a door within the given distance of the actor and no more than 60 degrees off the way it faces; heights are left out, as the original flattens both points. A door that is opening, closing or standing open does not count, nor does a disabled one. The doors are the place's load doors at their references' positions (the focus table's door rows of the room, or of the 3 x 3 exterior cells around the player) and the map's ordinary hinged doors. OpenMW asks only the doors of the actor's own cell; outdoors this asks the 3 x 3 cells, so a door just across a cell border counts too.
- An idle wanderer on its routes is checked every 1.5 seconds while it plays an idle (as before, the first check of
an idle comes at its first think when the last check is older). With a door ahead within 1.6 times the activation
distance (
iMaxActivateDist192, so 307 original units, 77 map units), or far from every allowed destination as before, it walks on to another destination at once. A resident with wander distance 0 stands as before, and one that only walks now and then to a spot near its start goes back to its roll, as in OpenMW. - A walker on its routes that gets stuck (ten failed steps; one for a flyer) with a door ahead within the activation distance (192 original units, 48 map units) drops its destination and the allowed destinations its route still passes after the waypoint it walks to, and walks to another destination at once. The destination itself stays while fewer than three others would be left, and with fewer than two left the package wanders near its start, as in OpenMW. Dropped destinations stay dropped while the package runs (OpenMW does not give them back either). Travel, follow and escort packages end a stuck walk as before.
- The switch:
chim actors ambient doors onis the default (written intoid1/default-game.cfg);chim actors ambient doors offgives the old behaviour back (no door rule). No console variable of its own.chim actors ambientprints the doors of the place, the checks and doors tested, and how many idle residents were sent on and stuck walkers rerouted. - Cost: one pass over the place's doors per check, no file read, no search. Counted from the v0.0.66-dev10 build's tables (not measured in game): outdoors the largest 3 x 3 window holds 100 load doors (around Vivec), Seyda Neen's 23, the median window 5; a room at most 19 load doors, the median one; outdoors at most 4 hinged doors in one cell. Memory: a list of the place's load door rows (512 bytes) and six counters; no bytes per resident.
Seen before the rule: the Seyda Neen guard (128967) stopped by the street door of the Census and Excise Office
(113833), and the player arriving through that door came out inside him (DOOR-ARRIVAL-INSIDE-ACTOR-66); in the
v0.0.66-dev10 opening journey Fargoth (fargoth, reference 128964) stood by the same door, 55 map units from its
reference, and 12 of the journey's 13 aims at the door went to him. Fixed in source, to be confirmed in play. Kept by
tests/aga_ambient_test.c (a door ahead, the idle check, a stuck walker's dropped destinations) and
tests/test_ambient_lut.py.
After a loaded game (v0.0.67, WANDER-DOOR-AFTER-LOAD-67). A package's compiled points are offsets from the
actor's placement (its reference's position), so the engine adds them to where the placement put the actor. A loaded
game spawns the place's actors at their placements and then moves each one its saved row names, and the residents'
packages start in either order around that move. Before v0.0.67 two things went wrong. A package started after the
move added its routes to the saved spot, so every destination lay off the path grid by the actor's saved offset. A
package started before the move (at the placement) kept the walk it had begun there, so after the move the actor went
on from the saved spot toward a waypoint chosen at the placement. In the v0.0.67-dev2 opening journey that walk took
Fargoth from his saved spot toward his grid point by the Census and Excise Office's street door, where the player
stood; the player stopped him 15 units short of it, and he stood by the door through all thirteen of the journey's aims
at it. Now the actor spawner tells the package where each actor was placed before a saved row moves it
(aw_actors.c SpawnOne and ApplyLoaded, aw_ambient.c AW_AmbientPlacedAt): the routes stay at the placement, a
walk begun before the move ends, and the package's current destination is the allowed one nearest where the actor
stands. In a session from that journey's quicksave, 11 of the 17 residents the save moved had started their package
before the move and 6 after; Fargoth stood at his saved spot by his grid point there, 160 units from the door. This is
the original's behaviour as
OpenMW 0.51 states it: the Wander package keeps its start position in the saved game (aiwander.cpp
mInitialActorPosition, written and read with the package) and takes the allowed position closest to the actor as its
current one (setCurrentPositionToClosestAllowedPosition), so a loaded wanderer walks on along the same routes and the
door rule above applies to it as before the save. A script's package for an actor without compiled routes still
wanders near the spot it starts on. Memory: 16 bytes an entity (9,600 bytes); no file read. chim actors ambient list
prints each actor's route start (home), and chim actors ambient counts the placements told, the packages started
away from their placement and the running ones given the destination where their actor stands. Kept by
tests/aga_ambient_test.c (Fargoth's compiled package as the v0.0.67-dev2 build has it) and tests/test_ambient_lut.py.
Not done yet (said so, not invented): occupied destinations (flyers and swimmers move since v0.0.57, below); the time of day is kept but unused (OpenMW reads it nowhere either); a package set by a script keeps the spawn position as its start; the walk speed is the actor record's Speed attribute (50 only for an actor without a record); baked models without an Idle2..Idle9 group only walk; packages other than Wander; the package is not saved.
Levelled creatures (v0.0.57). Most wild creatures are not placed by name: the cell holds a levelled list (6,352
references, 5,082 outdoors) and the engine rolls the creature when the cell joins. In OpenMW 0.51 the picked creature
is an ordinary reference of that creature and runs its own record's packages (apps/openmw/mwclass/creaturelevlist.cpp,
apps/openmw/mwclass/creature.cpp); every creature the island's lists can give starts with Wander (86 creatures).
Until v0.0.56 the table held placed actors only, so these creatures stood still. Now every levelled reference has a
routes row compiled at the largest Wander distance its list can give, and every creature such a list can give has its
package (distance, duration, idles, flags); when the picked creature comes near, the engine joins the two. The table
grew to 10,176 rows and 1.75 MB on disk; the engine no longer keeps the rows in memory: only the first key of every
32 rows (about 2.5 KB) and the idle tables stay resident, and a lookup reads one block of 896 bytes. An actor found
absent is remembered, so it costs no second read.
Aggro on sight (v0.0.57). A creature this module moves also runs OpenMW's engage check
(apps/openmw/mwmechanics/actors.cpp engageCombat, every second give or take a quarter): when its Fight plus the
distance bias (iFightDistanceBase - fFightDistanceMultiplier x distance, mwmechanics/combat.cpp) reaches 100 and it
sees the player, it attacks and chases with the combat layer (AW_CombatAggro, the same rule as the combat
playground's aggro mode, see Combat). A creature whose Fight cannot reach 100 even at distance 0 is never
checked again; the rating is worked out from the kept Fight before any file is read. At most four fight at once (the
combat layer's slots); a fifth waits for its next check. Creatures only: an NPC's disposition toward the player is not
modelled yet. chim actors ambient aggro off turns it off (not saved); chim actors ambient prints the checks.
Flying creatures (v0.0.57). Cliff racers and other creatures whose record says they fly (and not walk) wander
too. As in OpenMW 0.51 (apps/openmw/mwmechanics/aiwander.cpp: a pure flying creature takes a straight path, its
random spot near the start lies at the start's height, and one failed step ends the walk), they fly straight to
each destination with no floor test and no gravity: the standing hull is swept toward the target in three
dimensions. They are never put on the ground: the creature library gives a flyer aw_ground_mode 1 from its record's
flags, so the spawn keeps the placed height. On the routes of a cell's path grid a flyer heads for the grid points
themselves, as OpenMW's does. A flyer that fights chases the same way: OpenMW lets an actor that can move up and
down shortcut straight to its target (apps/openmw/mwmechanics/aipackage.cpp pathTo), so the combat layer sweeps a
flying fighter straight toward the player's height instead of taking the walkers' ground route, and it no longer
flees as "cannot reach you" (COMBAT-FLYER-FLEES-57).
Swimming creatures (v0.0.57). Slaughterfish and dreugh swim the same straight way, and as in OpenMW
(aiwander.cpp: path grids do not cover water, so swimmers ignore them; a water creature's random spot must lie in
water) they pick a random spot near their start at the start's depth, take it only when it is in water, and never
step out of the water. A fighting swimmer chases the same straight way and waits at the shore when the player is
on land (it never leaves the water).
Since v0.0.57 a script's AITravel X Y Z moves the actor on the same compiled routes as its Wander package
(AW_AmbientTravel in engine/aga/src/aw_ambient.c, a public entry the wander code can use too). The rules are
OpenMW 0.51's (apps/openmw/mwmechanics/aitravel.cpp), our own code: a target more than 7168 original units away
does not start the package (isWithinMaxRange); the actor walks its routes from the point nearest it to the
destination nearest the target, then straight to the target; it never crosses a door (the routes are one cell's or
one room's); it has arrived within the walk's arrival distance (64 original units), and a walk stuck for the usual
number of steps also ends the package. The scripts' GetCurrentAIPackage then reads 1 (Travel) and
GetAIPackageDone reads 1 once it arrived; a fight pauses it and the actor goes on straight to the target after.
An actor without compiled routes walks straight there. Not yet: OpenMW's two seconds of waiting near the end before
it calls the travel done, and travel into another cell. Kept by tests/aga_ambient_test.c (the route ends and the
range).
AIFollow (v0.0.57, the same module, AW_AmbientFollow; rules from OpenMW 0.51 aifollow.cpp, our own code): the
follow distance is 64 original units plus the target's half width plus twice the actor's; the package becomes active
only once the target is within that distance plus 384 units and in sight (checked every half second); then the actor
walks toward the target while it is farther than the distance (30 units of hysteresis between moving and
stopping) and stands facing it when near. A duration in game hours ends it, and so does reaching the final point
when one is given; GetCurrentAIPackage reads 3. Not yet: crossing doors with the target (OpenMW moves a follower
only at a teleport door within 800 units, out of view), running when far behind, and the order of several followers.
The console's aw_mwscript_status call aifollow makes the actor under the crosshair follow the player.