ModernUO/Distribution/Data
Kamron Batman e7f85d404d
feat: Adds independent think/move clocks for creature AI to fix speed (#2591)
Splits creature speed into two clocks so movement pace can be tuned without touching reaction time:

- **Think clock** — `ActiveSpeed`/`PassiveSpeed`/`CurrentSpeed`: seconds per AI decision. Unchanged in meaning, storage, and cadence.
- **Move clock** — `ActiveMoveSpeed`/`PassiveMoveSpeed` (+ resolved `CurrentMoveSpeed`): seconds per step. `0` = inherit the matching think value.

### How

- Move speeds come from optional `activeMove`/`passiveMove` in `npc-speeds.json`, are `[props`-tunable per instance (set `0` to re-inherit), and serialize (BaseCreature v22).
- `SetSpeed()` keeps its legacy one-clock semantics — sets the think clock **and clears move overrides** — so existing callers cannot half-configure a creature. `SetMoveSpeed()`/`ClearMoveSpeed()` configure movement explicitly; `ScaleMoveSpeed()` scales overrides for buffs.
- `CurrentMoveSpeed` is derived by classifying `CurrentSpeed`: a verbatim active/passive think value maps to the matching move value; a bespoke pace written directly (mount boosts, follow sprint) stays fused to both clocks. External `CurrentSpeed` writers need no changes.
- `AITimer` schedules the earlier of the two deadlines. Decisions run at the think cadence exactly as before; while a pursuit/investigation is live, the timer also wakes when the movement budget elapses and advances one step with no decisions. Steps no longer snap to the think grid, so any step delay paces smoothly on the 8ms wheel. A blocked creature schedules no move wakes.
- The movement budget is RunUO's `m_NextMove` accumulate-and-clamp at a full step, so long-run pacing averages `CurrentMoveSpeed` exactly.

### Behavior changes

- **`npc-speeds.json` buckets get RunUO `TransformMoveDelay`-parity move values**: creatures step at RunUO pace while thinking/reacting at current speed. The situational +0.1/+0.2 offsets are deliberately omitted.
- **Existing saves migrate on load**: a pre-v22 creature whose think speeds still match its npc-speeds entry (never hand-tuned) adopts the table's move values — worlds and pets pick up the new pacing without a respawn. Tuned creatures keep movement inheriting their think clock.
- **Paragons scale movement by `SpeedBuff` (1.2x)**: RunUO had no deliberate policy here — dividing by 1.2 knocked most speeds off `TransformMoveDelay`'s exact-equality table (raw pass-through, 2x+ faster), while 0.3/0.6 creatures landed back on it for ~1.33x. This applies the uniform 1.2x the buff always claimed. UnConvert snaps speeds back to exact table values within 1e-4 — /1.2 then ×1.2 drifts 0.45 and 0.9 by an ulp, which would read as hand-tuned (and defeat a future skip-table-conformant-values serialization pass); tuned speeds keep.
- **Herding paces the movement clock**: the old `CurrentSpeed` getter hack is gone. A herded creature walks at a fixed 0.3s/step — RunUO's forced pace, without its `TransformMoveDelay` inflation to 0.6 — so herding is never penalized by a slow creature. Thinking is untouched, and `CheckHerding` walks through `MoveToPoint`, so herded creatures path around obstacles.
- **Badly-hurt slowdown now inflates the step delay only** (RunUO parity), computed from the base each step. Previously it wrote `CurrentSpeed = CurrentSpeed + 0.05..0.15` back on every successful step — compounding unboundedly while hurt and slowing decisions too.
- Removes the vestigial `MoveSpeedMod` (never read, written, or serialized).
- With no bucket or per-instance move values, both clocks carry identical values and creatures pace as before.

### Testing

- Full suite passes (1557, including 12 new `MoveSpeedTests`: resolution classes, `SetSpeed` clearing, `0`-re-inherit, v22 round-trip with exact-consumption check, save migration adopt/skip, buff scale/snap, herding).
- In-game verified via local diagnostics build (per-step budget tracing): steady 700ms step cadence on a 0.3s think grid with one-step catch-up after idle, think grid unperturbed by move wakes.
2026-08-23 10:19:59 -07:00
..
Bulk Orders Fixes more line ending issues (#267) 2020-09-27 13:54:56 -07:00
commands feat: Adds Network Packet Documentation (#2302) 2026-01-01 17:52:56 -08:00
Components Fixes more line ending issues (#267) 2020-09-27 13:54:56 -07:00
Decoration feat: Adds rope teleporter for New Haven Mines (#2439) 2026-05-03 17:23:31 -07:00
Items feat: Adds item graphic size to Bounds.bin and makes item graphic offset available to gumps (#2115) 2025-02-10 19:31:39 -08:00
Locations fix(admin): Fixes Tokuno Go Locations (#602) 2021-05-15 19:07:28 -07:00
Professions fix: Updates professions & new player gargish equipment (#819) 2021-10-16 10:48:58 -07:00
Spawns refactor(spawners): replace DynamicJson with typed SpawnerDto records (#2505) 2026-06-25 23:24:45 -07:00
assemblies.json fix: Fixes assembly loading. (#759) 2021-09-03 23:35:44 -07:00
bodyTable.cfg Fixes more line ending issues (#267) 2020-09-27 13:54:56 -07:00
categorization.json fix: Fixes NPE in champ titles (#1434) 2023-07-28 00:39:10 -07:00
containers.cfg Fixes more line ending issues (#267) 2020-09-27 13:54:56 -07:00
expansions.json fix: Fixes expansions.json to correctly reflect name of supported feature flags (#1471) 2023-08-25 11:55:36 -07:00
map-definitions.json fix(core): Moves map definitions and cleans up loading maps, regions, and tiles (#431) 2021-01-25 11:05:52 -08:00
MLQuests.cfg Fixes more line ending issues (#267) 2020-09-27 13:54:56 -07:00
names.json Updates Data to JSON (#159) 2020-06-19 13:53:18 -07:00
npc-speeds.json feat: Adds independent think/move clocks for creature AI to fix speed (#2591) 2026-08-23 10:19:59 -07:00
pageresponse.cfg Fixes more line ending issues (#267) 2020-09-27 13:54:56 -07:00
regions.json fix: Fix unguarded/termur regions in regions.json (#1723) 2024-04-07 13:30:35 -07:00
shrink.json fix(shrink): Changes shrink table to use json (#446) 2021-02-03 16:58:50 -08:00
signs.cfg Fixes more line ending issues (#267) 2020-09-27 13:54:56 -07:00
skills.json fix(throwing): grant Str/Dex stat gains for the Throwing skill (#2514) 2026-07-02 23:07:36 -07:00
teleporters.json fix: Update Hythloth teleport locations in Felucca and Trammel to new coordinates to prevent looping and stuck. (#2012) 2024-12-17 08:59:36 -08:00
treasure.cfg Fixes more line ending issues (#267) 2020-09-27 13:54:56 -07:00