Takes main's mounted gun traverse limits, capture and hit feedback,
LocalMP air AI sync, mod tech tree insertions and launcher changes.
Conflicts resolved:
- wto_ai_runtime.das: fire update runs before navigation, as on main,
so a hull-aim request is driven in the same frame; navigation keeps
the navmesh state and slot arguments of this branch.
- wto_ai_nav_common.das: main's wto_try_hull_aim replaces the old
limited-traverse pivot and uses this branch's drive command helper
and stuck-watch reset.
- build.ps1 and local_mp_internal.h: keep both sides' sources and
declarations.
A bot pressed against the same wreck or stopped vehicle backed off,
planned the same path again and drove into it once more, every few
seconds for minutes, because a contact reset the stuck watch and left
no trace for path searches.
A second contact within pathFollow.contactRepeatSec near the same
place now marks the body for path searches and switches the passing
side; after unstickMaxAttempts repeats the bot gives its order up and
the place is avoided like any other unreachable spot. NAV_CONTACT logs
the repeat count and the body position.
First in-game run of the path follower on Berlin and Poland showed whole
teams queueing on one road, bots ramming stopped teammates and wrecks,
bots clipping building corners, bots sliding into the Poland river and
the same bot getting stuck at the same spot dozens of times.
Native engine (native/wto-nav):
- Team traffic: a bot's finished path counts for its team for
trafficHoldSec; the team's later searches pay trafficCostPerPath more
per counted path through a polygon (up to trafficCostMaxMul), so
teammates spread over parallel routes. A slot's previous path stops
counting when it asks for a new one.
- Path corners are moved up to cornerOffsetM away from the edge they
turn around, when the mesh allows both legs; off-mesh link endpoints
stay put.
- path_request takes the team; load_map takes the new settings;
get_stats reports live traffic paths and moved corners.
Bake (tools/navgen):
- Water deeper than navBake.maxFordDepthM (0.9 m, was a fixed 0.6 m)
is a wall before erosion, so walkable ground keeps the tier radius
from it, plus deepWaterMarginM on banks lower than
deepWaterBankHeightM above the water line. Quays and ramps above it
keep only the radius. The preview marks deep water from the terrain.
Ground AI scripts:
- The lookahead point is pulled back along the path until the mesh
allows the straight line to it, so corners are no longer cut through
buildings.
- New traffic module replaces the fixed sideways step: hull length and
width along the heading; stopped vehicles, wrecks and parked players
are passed on the side with room, or the bot stops short and after
blockWaitSec marks the spot and plans again; moving traffic ahead is
followed; oncoming traffic is passed in the open and in narrow
passages the bigger vehicle goes first. Wrecks carry their heading.
- A hull pressed against a vehicle or wreck backs off after
contactReverseSec instead of the full stuck window.
- Jams and confirmed obstacles cost far more, and a given-up place is
all but closed (giveUpRadiusM, giveUpCostMul), so replanning leaves
instead of returning to it.
Tuning: navEngine trafficCostPerPath, trafficCostMaxMul, trafficHoldSec,
cornerOffsetM; pathFollow stationarySpeedMps, passMarginM, passSpeedMps,
blockWaitSec, blockTtlSec, contactGapM, contactReverseSec, giveUpRadiusM,
giveUpCostMul; avoidShiftM removed; jamCostMul 4 -> 12, rubbleCostMul
8 -> 25; navBake maxFordDepthM, deepWaterMarginM, deepWaterBankHeightM
(bake only). Launcher fields and en/zh-CN labels updated (978/978 keys).
Checked: root and launcher typecheck, MSVC build with no warnings in
project code, check-patches for 2.61.0.58 and 2.61.0.60, rebake of
avg_berlin, avg_poland and avg_hurtgen (all spawn-to-zone pairs still
connected on every tier), offline run on the new avg_poland pack (eight
same-team paths spread over different roads, traffic released after
the hold time, corners moved, pump within budget), isolated game copy
build. daScript compilation and in-battle behaviour still need the
in-game run.
Read the selected gun mount limits from the vehicle data and constrain its aiming commands. Send out-of-traverse aim requests to the chassis driver and require alignment before firing.
Verified type checks, executable patch checks and builds on 2.61.0.37 and 2.61.0.64, and guarded daScript initialization on 2.61.0.64. In-battle acceptance remains pending.
Native engine (native/wto-nav):
- Path searches are queued per slot and advanced with Detour's sliced
search inside a per-frame time budget (navEngine.pathBudgetMsPerFrame),
so a 4 km search no longer stalls a frame. The synchronous find_path
op is gone.
- The battle's pack is read on a background thread when the mission
finishes loading (prefetch); load_map only takes the result.
- New mesh queries: probe (surface, flags, room to the mesh edge),
raycast, nearest walkable point, and dynamic cost circles for wrecks,
jams and fresh obstacles that later searches route around.
Ground AI scripts:
- route picks the mesh tier by vehicle width and the cost filter by
tracked or wheeled, plans on goal change, drift off the corridor, a
timer or reported obstacles, and falls back to the stock road mesh
only when the battle decided on the fallback.
- follow steers at a speed-scaled lookahead point and brakes ahead of
sharp corners, narrow passages and the destination.
- avoid casts rays from both front hull corners that drive through
objects the bake marks crushable, follows slower traffic, steps aside
or yields by size priority in narrow passages.
- unstick escalates deterministically: back up along the corridor, mark
a jam and replan, then log the spot and hand the order back.
- Flank lanes are built through the queued searches; rallies are not
released while their lanes are still being built.
- Removed the 9-arc forward probing, 7-arc reverse probing, 145 m
straight shortcuts, 165 m snapping and random sideways detours.
Tuning: new pathFollow section, navEngine.goalSnapRadiusM and
pathBudgetMsPerFrame, navBake.crushableMaxRiExtraHp passed to the
scripts; retired navigation.cornerBrakeAccel, stuckWindowSec,
stuckMinMoveM and unstickReverseSec. Launcher fields and en/zh-CN labels
updated.
Checked: root and launcher typecheck, MSVC build with no warnings in
project code, check-patches for 2.61.0.58 and 2.61.0.60, offline engine
run on avg_poland (prefetch, sliced searches within budget, slot
replacement, dynamic costs), isolated game copy build. daScript
compilation and in-battle behaviour still need the in-game run.
Statically link upstream Detour into wto_ws.dll with a navigation engine
(native/wto-nav) that loads one .wtonav pack per battle, reads the level
file's eVER fingerprint and answers path queries through a cost filter
that multiplies chokepoint polygons. Start and goal points that do not
sit on the ground are retried over the mesh's height range.
The ground AI script talks to it through call_mission_action("wtoNav")
with load_map, unload_map, find_path and get_stats. Requests are string
parameters; replies use the DataBlock setters local_mp_awards already
resolves, with coordinates as centimetre ints, so no new native site is
needed. The local server writes the battle level into customBots
wtoLevel, and the build writes the pack folder as nav.dir in wto_ws.cfg
(build-game-copy.ts --map-nav).
The first load_map of a battle decides it once: loaded, fallback to the
script's own navigation, or refused when navEngine.allowFallback is off,
in which case bots do not plan or drive. A fingerprint mismatch is
logged and the pack is still used. The script proves the round trip
with one path per team at battle start and logs query statistics.
Add the navEngine, navCostsTracked and navCostsWheeled tuning sections
through the server reader, generated daScript constants and the
launcher's bot tuning page in both languages.
Verified with root and launcher type checks, MSVC builds without
warnings in project code, check-patches 14/14 on 2.61.0.58 and
2.61.0.60, native module resolution 14/14 on 2.61.0.37, .58, .60 and
.64, a scratch game copy build packing 29 ground AI modules, and an
offline run of the engine: all three maps load with matching
fingerprints and every spawn-to-capture path on every tier succeeds.
Share a distance-based speed cap between tactics and the fire gate.
Brake toward it and try a short halt when speed or aim keeps blocking
a ready shot.
Measure tracking drift relative to the aim direction and use the
close-range alignment window for quick shots. Expose the controls in
the launcher and record measured and permitted speeds in diagnostics.
Verified both TypeScript typechecks, 2.61.0.58 and 2.61.0.60 patch
checks and builds, and daScript loading in the guarded 2.61.0.58 client.
Replace per-bot mid-battle movement handback to stock AI with a clean
binary startup gate:
- Locate Unit::setBehaviorTree (ground_ai_set_beh_tree: .37 0x4e89b0,
.58 0x4e8f60) in patches/native/local_mp_ground_ai.jsonc and hook it
in native/wto-net/src/local_mp_ground_ai.c.
- Announce readiness from [init] in wto_ai_runtime.das via
wtoGroundAiScriptReady once the ground AI scripts finish compiling
cleanly with custom movement enabled. When announced, hook_set_beh_tree
suppresses attaching "tankBot" to LocalMP bot tanks and keeps their
MoveSystem.inactive pinned to 1 for the life of the vehicle, ending
all tug-of-war (external_inactive_reset) with stock AI.
- If scripts fail to compile, are missing, or mode is "stock" / "fire",
ownMovement stays 0 and stock tankBot runs untouched.
- Remove per-bot handback, timeout release, and the now-obsolete
navigation.returnToStockOnFailure config plumbing; on genuine script
failure a bot halts in place and logs DRIVE_FAIL instead of silently
switching to stock. Also initialize newly spawned bot ticks to run on
frame 0 to eliminate spawn-frame invalid_drive_cmd noise.
Verified MSVC build of wto_ws.dll (0 warnings in project C sources), root
and launcher type checks, native module resolution on both 2.61.0.37 and
2.61.0.58 (0 failures), isolated 2.61.0.58 startup confirming 12/12
LocalMP modules installed, wto_ai_runtime.das loaded in 213 ms (0 compile
errors), and "ground AI script ready (ownMovement=1; stock tankBot
disabled)" in wto_ws.log.
BREAKING CHANGE: removes navigation.returnToStockOnFailure from
tuning/ground-ai.jsonc; stock tankBot is now controlled strictly by
whether the custom ground AI script loaded with custom movement enabled.
Select realistic ready-rack dual-shell loadouts for AI tanks on the local
server, inject them natively on bot spawn, and switch between anti-armor
and soft-target shells in battle:
- Add the loadout section to tuning/ground-ai.jsonc (lowReadyRackThreshold,
topUpAmmoCount, primaryAmmoPct, secondaryMinRounds,
penetrationCompareDistM), validated in ground-ai-tuning.ts.
- Add the tank-bot-ammo v2 dataset (apps/server/src/game-data/datasets/
tank-bot-ammo.ts) reading primary cannon weapon name, capacity,
firstStage/autoLoad shell ready-rack counts (excluding separate charges),
and selectable shell modifications (using Lanz-Odermatt kinetic fields,
cumulativeDamage, armorpower, and transitive reqModification chains).
- Add selectBotTankLoadouts (apps/server/src/battle/bot-tank-loadouts.ts):
carry ready-rack count when >= 15 (top up to 22 when smaller or absent,
clamped to gun capacity), skip SPAA/belt autocannons, pick highest-tier
APFSDS/anti-armor primary (~80%) plus HE/HESH/HEAT secondary (~20%, min
3 rounds) when available, and attach required addModification entries and
per-tank wtoAmmo_<unit> strings to customBots when mode != stock.
- Hook Unit::changeAircraft (already located dynamically on .37 and .58) in
native/wto-net/src/local_mp_loadout.c to assign the 24-byte
ChangeUnitReflection.bullets entries via bullet_vec_assign for LocalMP
bot spawns (async == 0, non-local bot MPlayer), leaving player spawns
untouched.
- Track soft-target vs anti-armor shell classes in wto_ai_specs_common.das
and write gun.nextBulletType in wto_ai_fire_common.das to queue HE/HESH
against light/narrow targets and APFSDS/AP against MBTs/heavy armor.
Verified MSVC build of wto_ws.dll (0 warnings in project C sources), root
and launcher type checks, 14/14 check-patches on 2.61.0.58, 12/12 LocalMP
module installation, clean daScript load (wto_ai_runtime.das loaded in
211 ms, 0 compile errors), and real 2.61.0.58 loadout selection on
cn_ztz_96a (18 APFSDS + 4 HE), germ_leopard_2a4 (12 DM23 + 3 HEATFS),
ussr_t_80bvm (22 3BM60 + 6 HE), us_m1a2_abrams (14 M829A2 + 4 HEAT-MP),
ussr_t_34_1941 (18 APHEBC + 4 HE), and ussr_zsu_23_4 (stock belt kept).
Live battle acceptance begins in Step 9.
Complete the team commander layer with validated flank routes, coordinated
rally launches, dynamic cap recall, and air-threat-responsive SPAA:
- Add flank, rally, and recall parameters to the commander section of
tuning/ground-ai.jsonc (flankMaxLengthRatio, flankMinSeparationM,
rallyProgressFrac, rallyWaitSec, rallyMinFrac, rallyRadiusM,
recallSafeHoldSec), validated in ground-ai-tuning.ts and compiled into
WTO_AI_CMD_* constants.
- Add wto_ai_lanes_common.das:
- Lazily build and cache per-(team, cap) center and left/right flank
lanes using two-segment navmesh find_path_ex; reject flanks exceeding
1.6x center path length or closer than 45 m to the center midpoint.
- Stage offensive groups at the 40% rally point along their lane and
launch once 2/3 of the group arrives or 25 s elapse, resetting on cap
ownership flips.
- Track enemy ground count and contested state on friendly caps,
holding recall active until safe for 15 s; track enemy aircraft
presence for team SPAA intel.
- Split mode planners and recall demand overrides into
wto_ai_commander_plans_common.das; pull (enemies + 1) nearest support
or reserve bots to defend contested friendly caps while always keeping
at least one offensive assault bot.
- Update wto_ai_commander_anchors_common.das so SPAA follows behind the
actual Assault group centroid and checks upward open-sky clearance when
enemy aircraft are active.
- Wire WtoTaskOrder lane/relay/rally fields into wto_ai_route_common.das
(replacing unvalidated wing relays and preserving corridor turning
corners), wto_ai_tactics_common.das (rally staging hold), and
wto_ai_runtime.das (1 s rally release check).
Verified root and launcher type checks, isolated 2.61.0.58 build (27
ground AI modules packed), and clean in-engine daScript compilation/load
(wto_ai_runtime.das loaded in 183 ms, 0 compile errors). Live battle
acceptance deferred until the full pipeline is wired.
Replace direct reads of true enemy velocity with an own-sight sample
estimator, add 2-5 s last-seen exit watching, and sample bounded aiming
bias once per shooting opportunity:
- Add the estimation section to tuning/ground-ai.jsonc (watchMinSec,
watchMaxSec, velSampleMinSpanSec, velStableSpanSec, velJumpResetMps,
baseAimSigmaM, leadErrorFrac, maxBiasM), validated in
ground-ai-tuning.ts and compiled into WTO_AI_EST_* constants.
- Add wto_ai_estimate_common.das:
- Maintain a 6-sample timestamped ring buffer from each bot's own
visual sightings; compute smoothed observed velocity and convergence
quality, dropping quality and re-seeding bias on sudden braking/turns
or target switches.
- On LOS loss from an active ground engagement, freeze watchPos at the
last-seen exit point, clear observed velocity, and draw one random
2-5 s watch duration; stationary overwatch/defend bots hold their
post while watching, whereas pushing/retreating bots keep moving
while keeping their turret on the exit.
- Compute lead from observed velocity and loaded-shell flight time,
sampling one bounded bias vector per shooting opportunity (target,
shot count, state, 12 m position cell) that narrows as observation
quality improves and still passes the single fire-permission gate.
Verified root and launcher type checks, isolated 2.61.0.58 build (25
ground AI modules packed), and clean in-engine daScript compilation/load
(wto_ai_runtime.das loaded in 184 ms, 0 compile errors). Live battle
acceptance deferred until the full pipeline is wired.
Complete the single-vehicle tactical loop for reload survival, stalemate
breaking, and vehicle damage repair:
- Add cover, reload, hull-angle, stalemate, reposition, and repair-cover
parameters to tuning/ground-ai.jsonc, validated in ground-ai-tuning.ts
and compiled into WTO_AI_SM_* constants.
- Add wto_ai_cover_common.das: continuously record the last hard-concealed
hull position before peeking, and evaluate 9 cover candidates around
the tank (with enemy-clearance scoring when searching for a repair
cover).
- Add wto_ai_tactics_actions_common.das and wire wto_ai_tactics_common.das:
- Damage retreat & repair (plan 6.1): when gun is inoperable while
mobile, retreat to an enemy-free cover and send
EventRepairSystemRequestRepair(repair=true) once safe; when engine or
tracks immobilize the chassis, halt in place, request repair, and keep
gun self-defense active; stay halted while
repair_system_remaining_repair_time > 0.
- 3-way reload action: pull back into remembered/nearby cover (up to 6 s
budget, uninterrupted by flashes/new orders) -> zigzag advance at
+/-18 deg when pushing without cover -> angle hull front +/-15 deg
when side-exposed >30 deg with pivot room.
- Stalemate reposition: confirm outgoing effective damage via
EventUnitDamage (uint(hpFixed) < uint(prevHpFixed)) and enemy death;
trigger lateral reposition after 2 no-effect shots, 2 no-shot halts,
or 12 s cumulative halt time, unlocking short-halt only after 20 m
progress or reaching the new position.
- Split periodic telemetry out of wto_ai_runtime.das into
wto_ai_diag_common.das to keep every module under 300 lines.
Verified root and launcher type checks, isolated 2.61.0.58 build (24
ground AI modules packed), and clean in-engine daScript compilation/load
(wto_ai_runtime.das loaded in 228 ms, 0 compile errors). Live battle
acceptance deferred until the full pipeline is wired.
Replace the legacy tactics posture heuristics with an explicit per-bot
hull state machine driven by WtoTaskOrder and the 100/300/800 m distance
tiers, and fix chassis steering bugs:
- Add the stateMachine section to tuning/ground-ai.jsonc (preaimAngleDeg,
shortHaltMaxSec, shortHaltCooldownSec, turnLaunchSpeedMps), validated in
ground-ai-tuning.ts and compiled into WTO_AI_SM_* constants.
- Replace WTO_POSTURE_* with the unified WTO_STATE_* hull state enum in
wto_ai_types_common.das and decouple wto_perceive_update into
wto_ai_runtime.das so perception runs independently of hull tactics.
- Rewrite wto_ai_tactics_common.das as a priority-arbitrated state
machine: safety/SPAA -> ridge withdrawal -> active SHORT_HALT budget
(3 s limit with cooldown on timeout) -> crowd dispersion -> distance-tier
combat (RUN_AND_GUN <=100 m and high-urgency 100-300 m slow-move-fire;
PREAIM keeping the hull moving while gun reloads or turret error >8 deg;
SHORT_HALT only when ready and permitted by order.maxStopRangeM / 800 m
4 s window; RELOAD_ADVANCE when reloading away from cover) -> MARCH.
Log every state transition with reason, distance and speed.
- Fix the inverted neutral-pivot condition in wto_ai_drive_common.das,
add 2nd-gear straight-launch before full steering when turning with
open front clearance, and use full throttle when accelerating to target
speed so the automatic gearbox upshifts cleanly.
Verified root and launcher type checks, isolated 2.61.0.58 build (21
ground AI modules packed), and clean in-engine daScript compilation/load
(wto_ai_runtime.das loaded in 195 ms, 0 compile errors). Live battle
acceptance deferred until the full pipeline is wired.
Replace the old foliage-ignoring LOS check and 45 m pre-fire ray with
separate vision/hard-occlusion queries, exposure-integrated spotting, and
a single fire-permission gate for every ground weapon:
- Add perception and fire-gate distance/ballistics/budget parameters to
tuning/ground-ai.jsonc, validated in ground-ai-tuning.ts and compiled
into wto_ai_config_common.das.
- Extract wto_ai_combat_types_common.das and add wto_ai_sight_common.das:
visual checks use smoke occluders, ETF_ALL with aimRay material,
traceTransparencyRayRIGenNormalized foliage transparency, and vehicle/
wreck checks; hard-occlusion checks test terrain/structures plus both
ETF_RI and ETF_RI_PHYS without skipping soft foliage, plus swept
sphere_cast and wreck/vehicle bounds along the full shot distance.
- Rewrite wto_ai_perceive_common.das with per-target exposure integration
(fast/normal/far fill times and occlusion decay), 4-point visibility
sampling with continuous >=2-point LOS tracking for the 800 m 4-second
window, frozen last-seen coordinates with zeroed velocity on LOS loss,
and impact-time hit direction (no live offender lookup).
- Record per-shell ballistics profiles (speed, Cx, mass, ballisticCaliber)
in wto_ai_specs_common.das and sync the currently loaded shell from
gun.chosenBulletType / bulletSets at runtime.
- Add wto_ai_fire_gate_common.das as the sole ground trigger exit: checks
visual lock, weapon readiness, distance-tier measured chassis speed
limits (100/300/800 m), 800 m 4-second window, aim settle, per-frame
check budget, straight muzzle hard-ray, drag-integrated ballistic arc
sweep, predicted friendly corridor, and every barrel in the primary
trigger group. Confirm real shot departure from loaded ammo/readiness,
remove the pure-launcher stock bypass and add_unit_for_target leak, and
log exact deny/shot reasons.
Verified root and launcher type checks, isolated 2.61.0.58 build (21
ground AI modules packed), and clean in-engine daScript compilation/load
(wto_ai_runtime.das loaded in 186 ms, 0 compile errors). Live battle
acceptance deferred until the full pipeline is wired.
Replace the per-bot greedy cap scorer (wto_ai_macro_common.das) with a
whole-team commander and explicit task order contract, and fix the world,
spec, and navigation bugs found during the codebase audit:
- Classify ground battle modes (bttl, conq, dom) in multiplayer-missions
v5 from mislist.blk categories (with suffix fallback for event maps) and
emit wtoGroundMode in customRules/customBots.
- Add the commander section to tuning/ground-ai.jsonc with range and sum
validation, compiled into WTO_AI_CMD_* constants.
- Split zone/mode/spawn refresh into wto_ai_world_zones_common.das and fix
four world snapshot bugs: stop double-recording deaths in wreck scans
and deduplicate with a ring cursor, refresh units before spawn fallback
while retrying real respawn points, fall back battleCenter to spawns
when capCount is 0, and relax cap radius clamping to 10..180 m.
- Fix limited-traverse yaw overwrite in wto_ai_specs_common.das and
compute pivot turn angle against wishDir in wto_ai_nav_common.das.
- Introduce WtoTaskOrder (wto_ai_order_common.das) and whole-team
commander v1 (wto_ai_commander_common.das +
wto_ai_commander_anchors_common.das): mode-aware role quotas (Bttl,
Conq, Dom), deterministic distance + vehicle-suitability matching,
20-second role hysteresis, separate total-assigned vs cap-insider
counters, frontline-relative SPAA anchors, EventZoneCaptured immediate
rebalance, and per-team WTO_AI|CMD telemetry.
Verified root and launcher type checks, multiplayer-missions v5 dataset
extraction (1140 missions with Bttl/Conq/Dom classification), isolated
2.61.0.58 build (18 ground AI modules packed), and clean in-engine
daScript compilation/load (wto_ai_runtime.das loaded in 155 ms, 0 compile
errors). Live battle tuning and acceptance deferred until the full
pipeline is wired.
Address two issues found in the first isolated 2.61.0.58 live runs and add
a test switch to disable silent fallback to stock movement:
- Add navigation.returnToStockOnFailure in tuning/ground-ai.jsonc (default
true), compiled into WTO_AI_NAV_RETURN_TO_STOCK and written to wto_ws.cfg
as ground_ai_return_to_stock=0 when disabled. When false, failed or
timed-out bots keep stock movement paused, brake in place and log the
failure once instead of silently handing control back to stock tankBot.
- Allow holdMs=0 release actions even after local_mp_is_host() flips false
during mission unload, add eid=0 bulk release on wto_reset_runtime(), and
match slots by eid rather than live owner lookup so match exit cleans up
the native control table immediately.
- Stop releasing drive ownership when a vehicle is immobilized by damage or
repair; brake in place and pause the echo watchdog instead, avoiding the
1-second release/re-acquire flapping observed during combat. Log exact
release reasons and back off for 1 second if MoveSystem.inactive is
cleared externally.
Verified MSVC build of wto_ws.dll (0 warnings in project C sources), root
and launcher type checks, 14/14 check-patches on 2.61.0.58, and a temporary
2.61.0.58 game copy build confirming ground_ai_return_to_stock=0 in
wto_ws.cfg and 15 packed daScript modules. Live battle re-check pending.
Grant custom physics control per LocalMP bot and let the native layer release it when the script stops renewing control. Verified both TypeScript checks, the MSVC build, native resolution and check-patches on .37 and .58, and isolated .58 script loading.