feat(ground-ai): load baked navigation packs in battle

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.
This commit is contained in:
N0VAN0M4LY committed 2026-12-05 16:39:26 +08:00
1 parent 21ab1084a6
commit e0a344708d
23 files changed
+1280 -14

No files matched your search

@@ -131,6 +131,8 @@ function customBotsBlock(plan: BattleLaunchPlan): BlkBlock {
setParam(bots, 'wtoTeamACountries', text(plan.countriesAllies.join(';')));
setParam(bots, 'wtoTeamBCountries', text(plan.countriesAxis.join(';')));
if (plan.mission.groundMode !== undefined) setParam(bots, 'wtoGroundMode', text(plan.mission.groundMode));
// The battle's level file: the ground AI loads its navigation pack by this name (native local_mp_nav.c).
if (plan.level !== undefined) setParam(bots, 'wtoLevel', text(plan.level));
if (plan.maxRespawns === UNLIMITED_RESPAWNS) setParam(bots, 'wtoUnlimitedRespawns', text('1'));
setParam(bots, 'numBotRespawnsInMultiSlot', integer(plan.airBotRespawns));
setParam(bots, 'numTankBotRespawnsInMultiSlot', integer(plan.tankBotRespawns));
@@ -8,6 +8,7 @@ import {
type GroundAiConfig,
type GroundAiDriveMode,
type GroundAiMode,
type GroundAiNavCosts,
} from '@wto/patcher';
import type { TankLineupWeights } from '../battle/battle-ranks.ts';
import { tuningFiles } from './tuning-loader.ts';
@@ -44,6 +45,9 @@ export function readGroundAiTuning(reader: TuningReader): GroundAiTuning {
crowd: readCrowdSection(reader.object('crowd')),
terrain: readTerrainSection(reader.object('terrain')),
navigation: readNavigationSection(reader.object('navigation')),
navEngine: readNavEngineSection(reader.object('navEngine')),
navCostsTracked: readNavCosts(reader.object('navCostsTracked')),
navCostsWheeled: readNavCosts(reader.object('navCostsWheeled')),
perception: readPerceptionSection(reader.object('perception')),
stateMachine: readStateMachineSection(reader.object('stateMachine')),
tactics: readTacticsSection(reader.object('tactics')),
@@ -173,6 +177,28 @@ function readTerrainSection(terrain: TuningReader): GroundAiTuning['terrain'] {
};
}
function readNavEngineSection(engine: TuningReader): GroundAiTuning['navEngine'] {
return {
enabled: engine.bool('enabled'),
allowFallback: engine.bool('allowFallback'),
snapRadiusM: engine.number('snapRadiusM', { min: 2, max: 40 }),
};
}
function readNavCosts(costs: TuningReader): GroundAiNavCosts {
const read = (key: keyof GroundAiNavCosts) => costs.number(key, { min: 0.1, max: 20 });
return {
road: read('road'),
bridge: read('bridge'),
ground: read('ground'),
rough: read('rough'),
forest: read('forest'),
crushable: read('crushable'),
shallowWater: read('shallowWater'),
chokepoint: read('chokepoint'),
};
}
function readNavigationSection(nav: TuningReader): GroundAiTuning['navigation'] {
const driveModeRaw = nav.string('driveMode');
const driveMode = GROUND_AI_DRIVE_MODES.find((candidate): candidate is GroundAiDriveMode => candidate === driveModeRaw);
+36
View File
@@ -134,6 +134,42 @@
"tacticalReverseMaxSec": 9.5
},
// Baked navigation packs (tools/navgen), loaded once per battle by the native engine.
"navEngine": {
"enabled": true,
// When the battle's pack is missing or broken: true keeps the script's own navigation for the
// whole battle, false leaves the bots standing so the problem shows (testing). Decided once at
// battle start, never in the middle of a battle.
"allowFallback": true,
// Farthest a path's start or goal may lie from the mesh.
"snapRadiusM": 12.0
},
// Path cost multipliers per surface for tracked vehicles; chokepoint multiplies the surface cost
// of passages narrower than navBake.chokepointMaxWidthVehicles.
"navCostsTracked": {
"road": 0.75,
"bridge": 0.9,
"ground": 1.0,
"rough": 1.65,
"forest": 2.1,
"crushable": 2.4,
"shallowWater": 2.6,
"chokepoint": 1.8
},
// The same for wheeled vehicles.
"navCostsWheeled": {
"road": 0.55,
"bridge": 0.75,
"ground": 1.15,
"rough": 3.2,
"forest": 2.8,
"crushable": 3.5,
"shallowWater": 4.0,
"chokepoint": 2.2
},
// Exposure-based visual perception (offline values; foliageTransparency matches stock infantry AI).
"perception": {
"foliageTransparency": 0.01,