Skip to content

feat: runtime route generation from spawn data, plus approach/facing/stuck fixes - #828

Merged
Xian55 merged 11 commits into
devfrom
feat/generated-routes
Aug 9, 2026
Merged

Xian55 merged 11 commits into
devfrom
feat/generated-routes

Conversation

@Xian55

@Xian55 Xian55 commented Aug 9, 2026 •

Copy link
Copy Markdown
Owner

Runtime route generation, and the combat fixes found while testing it

Two things in one pack. The headline feature is routes built at runtime from spawn data
instead of hand-recorded waypoint files. The rest are movement and combat fixes that
surfaced while grinding on those routes — several of them are their own bug, so they are
separate commits.

The problem the feature solves

A class profile had to name a recorded waypoint file. That file went stale the moment the
character outlevelled the zone it was drawn for, so profiles were rewritten every couple of
levels — usually just because the trainer had new spells and the old route no longer
matched where the character should be.

PathSettings.Generate replaces the filename with a query:

"Generate": {
  "Subzone": "Ammen Vale",
  "Mobs": "Name:Vale Moth || Name:Volatile Mutation",
  "Focus": "Balanced",
  "Mode": "Wander"
}

The route is built from where those mobs actually stand, in the running client's own spawn
data. Wander re-samples anchors every lap, so movement no longer traces the same line —
which also makes it look far less mechanical.

Combined with PathsFilenames, one profile now covers levels 1–10 for every race of a
class: eight starting-zone groups, each keyed on Race, and the character matches the one
it belongs in.

Full design writeup: docs/generated-routes-design.md.

Commits

commit what it brings main files
feat(Path) route generation core — spawn polygon, sampling, connectivity, seeding RouteGenerator · SpawnPolygon · RouteSeed · NavmeshConnectivity · RouteGenSettings
feat(Frontend) route generator page, preview a query on the Leaflet map RouteGeneratorPage.razor
feat(CoreTests) routegen harness — render a whole profile with no game running Test_RouteGen · CoreTests/CLAUDE.md
feat(ClassConfig) PathsFilenames groups + the eight starting zones PathSettings · Json/path/
feat(Json) nine 1–10 class profiles Json/class/
feat(Navigation) SparseWaypoints so generated legs get pathfound Navigation
fix(Approach) melee overshoot, probe blocking, target zig-zag ApproachThrottle · ApproachTargetGoal · PullTargetGoal
fix(Combat) recover from ERR_BADATTACKFACING instead of giving up ReactCastError
fix(StuckDetector) rate limit the pre-ladder jump StuckDetector
fix(Input) hold jump to surface while drowning ConfigurableInput
feat(Requirement) RangedWeapon: — tells arrows from bullets RequirementFactory · README

New starting-zone PathSettings groups

Eight group files under Json/path/, each a bare PathSettings array pulled in by name
rather than pasted into every profile that levels there:

group zone subzone
1-8_Human_Northshire.json Elwynn Forest Northshire Valley / Vineyards
1-8_Draenei_AmmenVale.json Azuremyst Isle Ammen Vale
1-8_NightElf_Teldrassil.json Teldrassil Shadowglen
1-8_DwarfGnome_Coldridge.json Dun Morogh Coldridge Valley
1-8_OrcTroll_ValleyOfTrials.json Durotar Valley of Trials
1-8_Undead_Deathknell.json Tirisfal Glades Deathknell
1-8_Tauren_RedCloudMesa.json Mulgore Red Cloud Mesa
1-8_BloodElf_SunstriderIsle.json Eversong Woods Sunstrider Isle

Each has three tiers — Level < 3, < 5, < 8 — with the mob filter narrowing as the
character grows, and every entry keyed on Race. A profile lists all eight and the
character simply never matches the seven it does not belong in, so one file serves every
race of a class.

Mob names were checked against creatures.json and the map spawn tables rather than typed
from memory. That caught real errors: Wretched Zombie has zero spawns on its map,
Burning Blade Neophyte is level 9-10, Bristleback Thornweaver is level 18-19. It also
caught Camp Narache, the obvious choice for Tauren, holding exactly one spawn — the
camp is the village, the mobs are on Red Cloud Mesa around it, which holds 216. That
one would have looked fine in a log and been useless in game.

Name: is a substring match, which matters more than it looks: Name:Mottled Boar also
catches Dire (6-7) and Elder (8-9), and Name:Bristleback catches Thornweaver at 18.
The level guards on those entries are load-bearing, not decoration.

New 1-10 class profiles

Nine profiles, one per class, replacing the per-level ladder — this is what removes the
rewrite-every-two-levels problem:

Warrior ·
Warlock ·
Mage ·
Priest ·
Rogue ·
Hunter ·
Paladin ·
Shaman ·
Druid

Death Knight is out of scope; it starts at 55.

Each amalgamates the existing low-level profiles for that class and gates every ability
trained after level 1 on a Spell:SPELL_* id array, so an untrained spell is skipped and
the same file works at level 1 and level 10. Each carries a header comment listing the key
bindings it expects.

Building them surfaced two things worth calling out:

  • Paladin — Paladin_10.json builds its whole rotation on Seal of the Crusader, which
    is not trained until 22. Copied as-is, a level 1 paladin would have had no seal at
    all. Rebuilt around Seal of Righteousness.
  • Priest — combat Power Word: Shield was gated on SPELL_RANK_PAIN and on low mana.
    Shielding keyed to mana and gated on an unrelated spell looks like a copy-paste slip;
    changed to the shield spell and low health. Flag it if that was deliberate.

Hunter additionally restocks ammunition, which needed the new RangedWeapon: requirement —
a bow and a crossbow eat arrows, a gun eats bullets, and nothing in the expression language
could previously tell them apart. There is a money gate on the vendor trip so the bot does
not walk to a merchant it cannot pay.

Relates to #827

Two independent faults, both reproduced from the reporter's own log.

The warlock half is the real bug in that report. ReactCastError was firing and
failing:

Unable to react to ERR_BADATTACKFACING - Fast turn with Interact -422.4484ms
React to ERR_BADATTACKFACING - Fast turn with Interact 358.9413ms
Unable to react to ERR_BADATTACKFACING - Fast turn with Interact -565.7295ms

Same code, three outcomes. The settle window was SpellQueueTimeMs — capped at 400 ms by
the CVar — while one sample costs 4 addon frames. At ~100 ms a frame the first sample eats
the whole budget, so the method can only ever time out. Success was decided by frame
latency, not by anything the player did. On failure it then inferred success from "the
direction changed"
, which is true precisely while a turn is unfinished, and so skipped the
180° fallback in the one state that needs it. CombatGoal logging Turning too fast!
straight after each error confirms it: mid-spin, not stuck.

The warrior half — on top of the mob, in combat, never turning — is the approach
overshoot, fixed separately.

Worth being explicit for the reporter: the addon version in that issue is the template
default, so it is not evidence of anything, and "lag" was their inference rather than an
observation. The mechanism turned out to be addon frame latency against a fixed sample
budget, which is why it felt like lag.

Measured

Same 9-minute grind, before and after:

before after
Approach presses flat ~400 ms min 412 ms, median 1037 ms, none under 200 ms
Jump presses ~70 ms for 45 s straight 71 total, min gap 768 ms, median 7.1 s
Target zig-zag A→B→A across re-entries 24 probes, min spacing 7.9 s, none
Facing errors 3, two unrecovered 0

122 kills, no Too long time, no blacklist losses.

Verification

  • Solution builds clean in Release.
  • All nine class profiles load through HeadlessServer --loadonly, which exercises the real
    ClassConfiguration.Initialise — requirement expressions compiled, Usable:/CanRun:
    resolved to named KeyActions (that one throws, so it would be a startup crash), and
    PathsFilenames groups read off disk.
  • Route generation verified against the baked navmesh for all eight starting zones — every
    tier resolves with real spawns, from 39 up to 293.
  • Spell id chains read out of Json/dbc/wrath/spells.json, not from memory. That table
    repeats player spell names on mob abilities, so the noise clusters were filtered rather
    than taken wholesale.

Known limits, deliberately not fixed here

  • Bar bindings still have to match the profile. Spell: gating fixes anything trained
    after level 1, but nothing can stop a wrongly-bound key for an ability known at level 1
    — the bot presses the key and casts whatever is actually there. Those entries carry a
    Cooldown so it degrades to a slow retry instead of a hard loop. ActionBarSlotValidator
    already detects the mismatch and only logs it; turning that into a gate is a separate
    change.
  • Food/Drink on = and -. A hunter session shows 42 × Cast failed due CurrentActionNotDetected and no successful eat. README already warns that main-bar slots
    11/12 are keyboard-layout dependent. The profiles inherit the existing convention;
    rebinding them is a follow-up.
  • NO PLAN - nothing runnable, 19× in one session — in combat with no target, right
    after a loot and ClearTarget. Recovers on its own. Possibly a remaining hole from
    d96e1121.
  • Loot reports failure when a fully-looted corpse stops being targetable, even though the
    loot succeeded. Cosmetic in the log, but the early return skips CheckForCanGather, so a
    skinnable corpse can be missed.

Generated paths

23_Sunstrider_Isle_Wander 3_Ammen_Vale_Loop 4_Ammen_Vale_Wander 5_Ammen_Vale_Wander 6_Shadowglen_Wander 7_Shadowglen_Wander 8_Shadowglen_Wander 9_Coldridge_Valley_Wander 10_Coldridge_Valley_Wander 11_Coldridge_Valley_Wander 12_Valley_of_Trials_Wander 13_Valley_of_Trials_Wander 14_Valley_of_Trials_Wander 15_Deathknell_Wander 16_Deathknell_Wander 17_Deathknell_Wander 18_Red_Cloud_Mesa_Wander 19_Red_Cloud_Mesa_Wander 20_Red_Cloud_Mesa_Wander 21_Sunstrider_Isle_Wander 22_Sunstrider_Isle_Wander

🤖 Generated with Claude Code

Xian55 added 11 commits August 9, 2026 14:35
A class profile has had to name a hand-recorded waypoint file, so a route
went stale the moment the character outlevelled the zone it was drawn for.
Profiles were rewritten every couple of levels for that reason alone.

PathSettings.Generate replaces the filename with a query over the running
client's NPC spawn data - zone or subzone, a mob expression in creature
scope, and a mode. The route is built at runtime from where the selected
mobs actually stand:

  SpawnPolygon      cell occupancy mask at AreaGrid resolution, dilated and
                    cluster-pruned - concave for free, so an L-shaped valley
                    does not route through the abbey in the middle
  RouteGenerator    Wander re-samples anchors every lap so the bot never
                    retraces a line; Loop builds one 2-opt tour over density
                    peaks as a drop-in for a recorded file
  NavmeshConnectivity  keeps the route on one walkable component, so a stop
                    across a lake is discarded rather than swum to
  RouteSeed         splitmix64 rather than HashCode.Combine, which is seeded
                    per process and so reproduced a route only within one
                    session

CreatureRequirementFactory gives the mob filter its own expression scope -
the subject is a candidate creature row, not the player, so Level means the
creature's and PlayerLevel means yours.

See docs/generated-routes-design.md.
Tries a Generate query against the running client and draws the result on
the Leaflet map before it is committed to a profile - spawn spread, chosen
stops and the walked line. Iterating on a mob filter otherwise meant editing
json and restarting the bot to see what it produced.
Builds every Generate path in a class profile from Json/ plus the baked
navmesh, with the player stubbed - no client, no login. Renders each over
the game's own minimap tiles so "does this cross the river" is answerable
while iterating on a mob filter.

  --profile   every generated path in a class json, in profile order
  --seed      fixed by default so two runs are comparable; "random" to vary
  --output    where to write; --svg is kept as a warned alias
  --format    svg (default), png or webp

All three formats share RouteLayout - the zoom search and the world-to-pixel
flip are the fiddly part, and a second copy in the raster path would drift
into two pictures of the same route that disagree.

Reports spacing, vertical spread and a spawn/route hash per path, so a
change that was meant to be a refactor can be shown not to move the route.
A profile had to paste its whole Paths array inline, so the same starting
zone was duplicated into every class that levels there.

PathsFilenames names group files under Json/path/, each a bare PathSettings
array, appended after any inline Paths in listed order - order matters, it
sets each route goal cost through FollowRouteGoal.COST_OFFSET.

Ships the eight starting zones as groups, keyed on Race so a profile can
list all of them and the character matches the one it belongs in. Every
mob name was checked against creatures.json and the map spawn tables rather
than typed from memory, which is how Tauren ended up on Red Cloud Mesa: Camp
Narache is the village and holds one spawn, the mesa around it holds 216.

ResolvePathGroups is public and callable without Initialise, because tooling
that reads Paths off a deserialized profile would otherwise see only the
inline entries and silently render nothing.
Nine profiles replacing the per-level ladder, each pulling in all eight
starting-zone groups so the same file serves every race of that class.

Level spanning is done with "Spell:SPELL_x" id arrays - do I know it - not
with WhenUsable. WhenUsable only reads the usable bit of the slot a key maps
to; it cannot tell the slot holds a different spell. A Blood Elf paladin has
Arcane Torrent on slot 5, which is always usable, so a WhenUsable-only gate
fired, cast the racial, never satisfied "!Blessing of Might" and retried
forever.

Ids rather than names because names drift: Blessing of Protection became
Hand of Protection, and Seal of the Crusader was dropped outright - a name
gate silently never matches where the id chain still does. Every chain was
read out of Json/dbc/wrath/spells.json; that table repeats player spell
names on mob abilities, so the noise clusters were filtered rather than
taken wholesale.

Known limit: this cannot save an ability known at level 1 from a wrong
binding. Those carry a Cooldown so a mis-bound bar degrades to a slow retry
instead of a hard loop, but the bars still have to match.
Interact-with-target is not a nudge. One press starts a continuous run that
the client finishes on its own, keeping the player facing the target the
whole way. The bot treated it as a nudge and re-pressed every time the key
cooldown cleared - roughly 2.5 times a second for the entire chase. Each
press restarts the run, and one landing in the final yards restarts a run
toward a mob the player is already standing on, so a warrior or rogue walks
through and past it. Ranged classes never noticed; their goal exits 20 yards
out.

ApproachThrottle presses only when a press changes something: when nothing
is carrying the player forward, and on a keepalive whose rate depends on
whether the target moved. Movement is read from the player facing, which the
interact run keeps pointed at the target - a mob that circles drifts the
bearing and earns a prompt re-aim, one standing still gets the slow rate.
Measured over a 9 minute run: minimum gap 412ms, median 1037ms, nothing
under 200ms, against a flat ~400ms before.

Also here, in the same goals:

- The closer-target probe blocked the loop while it waited for the addon to
  publish the swapped target. It is a state machine now, arming a deadline
  and picking it up on a later tick.
- That probe traded targets on every goal re-entry, so two mobs at similar
  distance swapped places forever and the bot closed on both and pulled
  neither. A gain margin plus a short-lived memory of the mob just walked
  away from settles it.
- PullTargetGoal keeps its Approach cooldown as a method-level rate limiter.
  It also gates the stuck detector below it, which jumps on every call, and
  PressJump honours no cooldown of its own.

Relates to #827 - the warrior half, where the bot ends up on top of the mob.
Reported in #827: in combat, on top of the mob, never turning to face it,
dead. The attached warlock log shows the recovery firing and failing.

  Unable to react to ERR_BADATTACKFACING - Fast turn with Interact -422.4484ms
  React to ERR_BADATTACKFACING - Fast turn with Interact 358.9413ms
  Unable to react to ERR_BADATTACKFACING - Fast turn with Interact -565.7295ms

Same code, three outcomes, and the negatives are AfterEquals timing out.
Two faults compounded:

The settle window was SpellQueueTimeMs, capped at 400ms by the CVar, while
one sample costs updateCount addon frames. At ~100ms a frame the first
sample eats the whole budget, so the loop exits before it can compare and
the method can only return negative. Success or failure was decided by frame
latency, not by anything the player did. Budget is taken from what a sample
actually costs now.

On failure it then inferred success from "the direction changed" - which is
true precisely while a turn is unfinished, so it set turnedWithInteract and
skipped the 180 degree fallback in the one state that needs it. A timeout
now falls through to the fallback.

Confirmed by CombatGoal logging "Turning too fast!" straight after each
facing error: the character was mid-spin, not stuck.
45 seconds of Spacebar at ~70ms in one session - the character pogo-jumping
in place, which reads from outside as a stuck key.

The branch below UNSTUCK_AFTER_MS presses jump on every call and logs
nothing. It never escalated because a spline advances its lookahead each
tick and re-seeds SetTargetLocation with it, which Resets attemptTime, so
UnstuckMs restarts before it can reach the threshold. The ladder sat at
attempt 0 forever and the jump fired every frame.

Exactly the failure the comment in Navigation already predicted. Gated on
the Jump key cooldown, so it cannot fire at frame rate whoever resets the
clock. Next session: 71 presses, minimum gap 768ms, median 7.1s.
Four goals pressed jump on every tick while Drowning, with no cooldown, and
CombatGoal returned straight after - so a drowning fight was 14 seconds of
Spacebar at frame rate and no abilities at all.

Tapping is also the wrong action: holding is what makes a swimming character
ascend, so the spam was both loud and ineffective. PressJumpAscend holds the
key once via PressFixed, which posts the key-up after waiting on the token
handle - cancellation shortens the hold, it never skips the release.
A hunter runs out of ammo and has to restock, but which ammo depends on
whether the ranged slot holds a bow, a crossbow or a gun - and nothing in
the expression language could see that. An ammo vendor entry had to hardcode
one item id and was wrong for half the weapons.

RangedWeapon:<subclass> reads the equipped ranged item and compares its
ItemWeaponSubclass. Bow, Gun, Crossbow, Thrown, Wand and the rest; an
unknown name throws at profile load rather than never matching.

README updated - the requirement language is user-facing API.
RefillRouteToNextWaypoint skips pathfinding for a hop about as long as the
route own point spacing - sound for a recorded route of hundreds of points
a few yards apart.

A generated route is anchors, not a traced path. Eight of them across a
subzone give an average spacing around 60 yards, so a 100 yard leg counted
as trivial and the bot walked it blind through whatever stood in the way.
SparseWaypoints pins the threshold to OutDoorMinDistance instead, and the
caller supplying such a route sets it.

Also surfaces StuckDetector.IsUnreachable so a destination that has resisted
every unstuck attempt can be abandoned rather than retried forever.
@Xian55 Xian55 added documentation Improvements or additions to documentation bugfix This pull request fixes an issue. refactor This ticket concerns the possible simplification of code/data. enhancement This pull request implements a new feature. ai Artificial Intelligence tool has been contributed. labels Aug 9, 2026
@Xian55
Xian55 merged commit c2df2d0 into dev Aug 9, 2026
1 check passed
@Xian55
Xian55 deleted the feat/generated-routes branch September 14, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Artificial Intelligence tool has been contributed. bugfix This pull request fixes an issue. documentation Improvements or additions to documentation enhancement This pull request implements a new feature. refactor This ticket concerns the possible simplification of code/data.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bot unable to autoattack/shoot/cast spell at mob due to facing wrong direction

1 participant