From 922904504225c4d1f61dc48472a7db3f930694e3 Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Thu, 3 Dec 2026 17:34:59 +0800 Subject: [PATCH] feat(ground-ai): add exposure perception and single ballistic fire gate 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. --- apps/server/src/tuning/ground-ai-tuning.ts | 32 +++ apps/server/tuning/ground-ai.jsonc | 30 ++- game-ai/ground/wto_ai_combat_types_common.das | 97 +++++++++ game-ai/ground/wto_ai_fire_common.das | 180 +++++++--------- game-ai/ground/wto_ai_fire_gate_common.das | 199 ++++++++++++++++++ game-ai/ground/wto_ai_perceive_common.das | 152 +++++++++---- game-ai/ground/wto_ai_runtime.das | 12 +- game-ai/ground/wto_ai_sight_common.das | 126 +++++++++++ game-ai/ground/wto_ai_specs_common.das | 45 +++- game-ai/ground/wto_ai_types_common.das | 46 +--- .../patcher/src/ground-ai/ground-ai-config.ts | 42 ++++ 11 files changed, 759 insertions(+), 202 deletions(-) create mode 100644 game-ai/ground/wto_ai_combat_types_common.das create mode 100644 game-ai/ground/wto_ai_fire_gate_common.das create mode 100644 game-ai/ground/wto_ai_sight_common.das diff --git a/apps/server/src/tuning/ground-ai-tuning.ts b/apps/server/src/tuning/ground-ai-tuning.ts index c47e208..ce70b4c 100644 --- a/apps/server/src/tuning/ground-ai-tuning.ts +++ b/apps/server/src/tuning/ground-ai-tuning.ts @@ -39,6 +39,7 @@ export function readGroundAiTuning(reader: TuningReader): GroundAiTuning { crowd: readCrowdSection(reader.object('crowd')), terrain: readTerrainSection(reader.object('terrain')), navigation: readNavigationSection(reader.object('navigation')), + perception: readPerceptionSection(reader.object('perception')), tactics: readTacticsSection(reader.object('tactics')), fireControl: readFireControlSection(reader.object('fireControl')), diagnostics: { @@ -174,6 +175,20 @@ function readNavigationSection(nav: TuningReader): GroundAiTuning['navigation'] }; } +function readPerceptionSection(perc: TuningReader): GroundAiTuning['perception'] { + return { + foliageTransparency: perc.number('foliageTransparency', { min: 0.001, max: 1.0 }), + nearSpotRangeM: perc.number('nearSpotRangeM', { min: 20, max: 250 }), + firingSpotRangeM: perc.number('firingSpotRangeM', { min: 150, max: 1500 }), + fastSpotSec: perc.number('fastSpotSec', { min: 0.05, max: 1.5 }), + normalSpotSec: perc.number('normalSpotSec', { min: 0.1, max: 3.0 }), + farSpotSec: perc.number('farSpotSec', { min: 0.3, max: 6.0 }), + decayPerSec: perc.number('decayPerSec', { min: 0.2, max: 10.0 }), + frontConeHalfDeg: perc.number('frontConeHalfDeg', { min: 10, max: 90 }), + peripheralCloseM: perc.number('peripheralCloseM', { min: 30, max: 250 }), + }; +} + function readTacticsSection(tactics: TuningReader): GroundAiTuning['tactics'] { return { visionRangeM: tactics.number('visionRangeM', { min: 200, max: 3500 }), @@ -189,14 +204,31 @@ function readTacticsSection(tactics: TuningReader): GroundAiTuning['tactics'] { } function readFireControlSection(fc: TuningReader): GroundAiTuning['fireControl'] { + const closeRangeM = fc.number('closeRangeM', { min: 30, max: 250 }); + const midRangeM = fc.number('midRangeM', { min: 100, max: 600 }); + const longRangeM = fc.number('longRangeM', { min: 300, max: 1500 }); + if (midRangeM <= closeRangeM || longRangeM <= midRangeM) { + throw new TuningError('tuning file ground-ai.jsonc: fireControl ranges must satisfy closeRangeM < midRangeM < longRangeM'); + } return { maxEngageRangeM: fc.number('maxEngageRangeM', { min: 150, max: 3000 }), + closeRangeM, + midRangeM, + longRangeM, + midSlowSpeedRatio: fc.number('midSlowSpeedRatio', { min: 0.1, max: 1.0 }), + midSlowMaxMps: fc.number('midSlowMaxMps', { min: 1.0, max: 15.0 }), + stopSpeedMaxMps: fc.number('stopSpeedMaxMps', { min: 0.1, max: 2.0 }), + longRangeWindowSec: fc.number('longRangeWindowSec', { min: 1.0, max: 15.0 }), baseAlignDeg: fc.number('baseAlignDeg', { min: 0.1, max: 3.0 }), closeHitRadiusM: fc.number('closeHitRadiusM', { min: 0.25, max: 2.2 }), barrelSettleDegSec: fc.number('barrelSettleDegSec', { min: 0.2, max: 12.0 }), + closeSettleHoldSec: fc.number('closeSettleHoldSec', { min: 0.02, max: 0.5 }), settleHoldSec: fc.number('settleHoldSec', { min: 0.05, max: 1.5 }), unstabilizedStopSpeedMps: fc.number('unstabilizedStopSpeedMps', { min: 0.1, max: 3.0 }), stabilizedCreepSpeedMps: fc.number('stabilizedCreepSpeedMps', { min: 1.5, max: 15.0 }), friendlyCorridorM: fc.number('friendlyCorridorM', { min: 1.0, max: 10.0 }), + ballisticStepMaxM: fc.number('ballisticStepMaxM', { min: 5.0, max: 80.0 }), + ballisticSweepRadiusM: fc.number('ballisticSweepRadiusM', { min: 0.02, max: 0.5 }), + maxPreFireChecksPerTick: fc.int('maxPreFireChecksPerTick', { min: 1, max: 16 }), }; } diff --git a/apps/server/tuning/ground-ai.jsonc b/apps/server/tuning/ground-ai.jsonc index bbb507e..5334a2e 100644 --- a/apps/server/tuning/ground-ai.jsonc +++ b/apps/server/tuning/ground-ai.jsonc @@ -95,6 +95,19 @@ "tacticalReverseMaxSec": 9.5 }, + // Exposure-based visual perception (offline values; foliageTransparency matches stock infantry AI). + "perception": { + "foliageTransparency": 0.01, + "nearSpotRangeM": 90.0, + "firingSpotRangeM": 650.0, + "fastSpotSec": 0.25, + "normalSpotSec": 0.60, + "farSpotSec": 1.45, + "decayPerSec": 1.5, + "frontConeHalfDeg": 30.0, + "peripheralCloseM": 100.0 + }, + "tactics": { "visionRangeM": 1250.0, "visionFovDeg": 115.0, @@ -108,14 +121,25 @@ }, "fireControl": { - "maxEngageRangeM": 1350.0, + "maxEngageRangeM": 1250.0, + "closeRangeM": 100.0, + "midRangeM": 300.0, + "longRangeM": 800.0, + "midSlowSpeedRatio": 0.45, + "midSlowMaxMps": 5.5, + "stopSpeedMaxMps": 0.45, + "longRangeWindowSec": 4.0, "baseAlignDeg": 0.42, "closeHitRadiusM": 0.85, "barrelSettleDegSec": 1.8, - "settleHoldSec": 0.2, + "closeSettleHoldSec": 0.08, + "settleHoldSec": 0.20, "unstabilizedStopSpeedMps": 0.45, "stabilizedCreepSpeedMps": 5.5, - "friendlyCorridorM": 3.2 + "friendlyCorridorM": 3.2, + "ballisticStepMaxM": 25.0, + "ballisticSweepRadiusM": 0.12, + "maxPreFireChecksPerTick": 2 }, "diagnostics": { diff --git a/game-ai/ground/wto_ai_combat_types_common.das b/game-ai/ground/wto_ai_combat_types_common.das new file mode 100644 index 0000000..52f8456 --- /dev/null +++ b/game-ai/ground/wto_ai_combat_types_common.das @@ -0,0 +1,97 @@ +// Zero-heap POD types for perception exposure, shell ballistics profiles, and fire control. +options indenting = 2 +options no_global_heap = true +module wto_ai_combat_types_common shared + +require ecs + +let public WTO_MAX_EXPOSURE_TRACKS = 8 +let public WTO_MAX_SHELL_PROFILES = 12 + +let public WTO_BLOCK_NONE = 0 +let public WTO_BLOCK_TERRAIN = 1 +let public WTO_BLOCK_OBJECT = 2 +let public WTO_BLOCK_WRECK = 3 +let public WTO_BLOCK_VEHICLE = 4 +let public WTO_BLOCK_SMOKE = 5 +let public WTO_BLOCK_FOLIAGE = 6 + +let public WTO_DENY_OK = 0 +let public WTO_DENY_NO_TARGET = 1 +let public WTO_DENY_NOT_READY = 2 +let public WTO_DENY_SPEED = 3 +let public WTO_DENY_LONG_WINDOW = 4 +let public WTO_DENY_AIM_ERR = 5 +let public WTO_DENY_SETTLE = 6 +let public WTO_DENY_BUDGET = 7 +let public WTO_DENY_MUZZLE_HARD = 8 +let public WTO_DENY_ARC_HARD = 9 +let public WTO_DENY_FRIENDLY = 10 +let public WTO_DENY_MULTI_GUN = 11 + +[safe_when_uninitialized] +struct public WtoShellProfile + nameHash : uint = 0u + speedMps : float = 880.0 + dragCx : float = 0.35 + massKg : float = 10.0 + caliberM : float = 0.09 + +[safe_when_uninitialized] +struct public WtoPerceiveState + targetEid : EntityId = INVALID_ENTITY_ID + targetIsAir : bool = false + hasClearLos : bool = false + visiblePointCount : int = 0 + goodLosSec : float = 0.0 + visibleAimPt : float3 = float3(0.0, 0.0, 0.0) + knownPos : float3 = float3(0.0, 0.0, 0.0) + smoothedVel : float3 = float3(0.0, 0.0, 0.0) + lastSeenAt : float = -100.0 + lockedEid : EntityId = INVALID_ENTITY_ID + lockedUntil : float = -100.0 + alertYawRad : float = 0.0 + alertUntil : float = -100.0 + lastDamagedAt : float = -100.0 + lastHitYawRad : float = 0.0 + lastOffenderEid : EntityId = INVALID_ENTITY_ID + lastRadioSentAt : float = -100.0 + expEids : EntityId[8] + expScore : float[8] + expGoodLosSec : float[8] + +[safe_when_uninitialized] +struct public WtoFireState + turretNo : int = -1 + gunReady : bool = false + reloading : bool = false + gunDamaged : bool = false + loadedBulletIdx : int = -1 + activeSpeedMps : float = 880.0 + activeDragCx : float = 0.35 + activeMassKg : float = 10.0 + activeCaliberM : float = 0.09 + pitchBlocked : bool = false + pitchClampSec : float = 0.0 + cmdYawDeg : float = 0.0 + cmdPitchDeg : float = 0.0 + curYawDeg : float = 0.0 + curPitchDeg : float = 0.0 + prevPitchDeg : float = 0.0 + servoInit : bool = false + prevBarrelDir : float3 = float3(1.0, 0.0, 0.0) + prevBarrelAt : float = -100.0 + barrelOmegaDegSec : float = 0.0 + settleHoldSec : float = 0.0 + lastAligned : bool = false + lastAimErrDeg : float = 0.0 + lastShotAt : float = -100.0 + prevLoadedAmmo : int = -1 + pendingShotConfirm : bool = false + pendingShotAt : float = -100.0 + lastDenyReason : int = 0 + lastDenyBlock : int = 0 + lastDenyLogAt : float = -100.0 + shotCount : int = 0 + shotErrSumDeg : float = 0.0 + maxShotErrDeg : float = 0.0 diff --git a/game-ai/ground/wto_ai_fire_common.das b/game-ai/ground/wto_ai_fire_common.das index 659b48d..9b73569 100644 --- a/game-ai/ground/wto_ai_fire_common.das +++ b/game-ai/ground/wto_ai_fire_common.das @@ -1,11 +1,5 @@ -// Deterministic custom fire-control & ballistics actuator: -// - Keeps stock C++ ground inaccuracy ("attack_target" sway & target list bloat) locked out via -// "dont_aim", yielding only for SPAA vs aircraft or missile-only vehicles; -// - Reads authoritative `gun.isReadyToShoot`, `gun.currentLoadedAmmoCount`, and live muzzle -// `weapon_calcShootTm` transform (`gunTm[3]` muzzle position, `gunTm[0]` barrel vector); -// - Solves ballistic elevation & smoothed velocity lead via `Ballistics::calculate_arc_low_start_dir`; -// - Enforces strict barrel angular-velocity settle (`settleHoldSec`) + friendly corridor safety -// before triggering `unit_single_shot`. +// Turret servo, active loaded-shell inspection, and ballistic aim solver. +// All ground weapon firing goes exclusively through wto_fire_gate_try_shoot. options indenting = 2 options no_global_heap = true module wto_ai_fire_common shared @@ -13,6 +7,7 @@ module wto_ai_fire_common shared require ecs require app require math +require strings require DagorMath require Mission require Unit @@ -22,9 +17,9 @@ require Ballistics require %game.utils.utils_common require %appGame.wtoai.wto_ai_config_common require %appGame.wtoai.wto_ai_math_common +require %appGame.wtoai.wto_ai_combat_types_common require %appGame.wtoai.wto_ai_types_common -require %appGame.wtoai.wto_ai_terrain_common -require %appGame.wtoai.wto_ai_world_common +require %appGame.wtoai.wto_ai_fire_gate_common [never_inline] def private wto_world_to_hull_deg(worldDir, hullFwd, hullUp, hullLeft : float3; @@ -52,7 +47,34 @@ def private wto_hull_deg_to_world(yawDeg, pitchDeg : float; hullFwd, hullUp, hul return l > 1.0e-5 ? (dir / l) : hullFwd [never_inline] -def private wto_inspect_primary_weapon(unit : Unit const?; var fc : WtoFireState&) +def private wto_sync_active_shell(gun : WTGun const?; spec : WtoVehicleSpec const&; var fc : WtoFireState&) + if gun == null + return + let chosenIdx = int(gun.chosenBulletType) + if fc.loadedBulletIdx == chosenIdx && fc.activeSpeedMps > 80.0 + return + fc.loadedBulletIdx = chosenIdx + fc.activeSpeedMps = spec.muzzleSpeedMps + fc.activeDragCx = spec.shellDragCx + fc.activeMassKg = spec.shellMassKg + fc.activeCaliberM = spec.shellCaliberM + if chosenIdx >= 0 && chosenIdx < length(gun.properties.bulletSets) + assume bs = gun.properties.bulletSets[chosenIdx] + if length(bs.bullet) > 0 && bs.bullet[0] != null + let bName = bs.bullet[0].getName + if !empty(bName) + let h = ecs_hash(bName) + for i in range(spec.shellCount) + if spec.shells[i].nameHash == h + fc.activeSpeedMps = spec.shells[i].speedMps + fc.activeDragCx = spec.shells[i].dragCx + fc.activeMassKg = spec.shells[i].massKg + fc.activeCaliberM = spec.shells[i].caliberM + return + +[never_inline] +def private wto_inspect_primary_weapon(unit : Unit const?; now : float; + spec : WtoVehicleSpec const&; var fc : WtoFireState&) fc.turretNo = -1 fc.gunReady = false fc.reloading = false @@ -61,12 +83,21 @@ def private wto_inspect_primary_weapon(unit : Unit const?; var fc : WtoFireState return var anyGun = false var anyAlive = false - var anyLoaded = false + var anyReserve = false + var totalLoaded = 0 foreach_primary_gun(unit.weap.Weapons) <| $(weapon) - if weapon == null || weapon.isDummyGun || weapon.prop.launcher + if weapon == null || weapon.isDummyGun return let gun = as_gun(weapon) if gun == null + if weapon.prop.launcher && weapon.countBullets > 0 + anyGun = true + anyAlive = true + anyReserve = true + if fc.turretNo < 0 + fc.turretNo = weapon.turretNo + fc.gunReady = true + totalLoaded += weapon.countBullets return anyGun = true if gun.isInoperable @@ -74,49 +105,33 @@ def private wto_inspect_primary_weapon(unit : Unit const?; var fc : WtoFireState anyAlive = true if fc.turretNo < 0 fc.turretNo = weapon.turretNo + wto_sync_active_shell(gun, spec, fc) if gun.isReadyToShoot fc.gunReady = true + totalLoaded += max(0, gun.currentLoadedAmmoCount) if gun.currentLoadedAmmoCount > 0 || gun.currentBulletSet.bulletsCount > 0 || weapon.countBullets > 0 - anyLoaded = true + anyReserve = true fc.gunDamaged = anyGun && !anyAlive - fc.reloading = anyAlive && !fc.gunReady && anyLoaded + fc.reloading = anyAlive && !fc.gunReady && anyReserve + if fc.pendingShotConfirm + if (fc.prevLoadedAmmo >= 0 && totalLoaded < fc.prevLoadedAmmo) || !fc.gunReady + fc.shotCount++ + fc.pendingShotConfirm = false + elif (now - fc.pendingShotAt) > 0.35 + fc.pendingShotConfirm = false + fc.prevLoadedAmmo = totalLoaded [never_inline] -def private wto_friendly_corridor_clear(world : WtoWorldSnap const&; selfEid : EntityId; - army : int; muzzlePos, aimPos : float3) : bool - let delta = aimPos - muzzlePos - let segLen = length(delta) - if segLen < 4.0 - return true - let dir = delta / segLen - for i in range(world.unitCount) - assume u = world.units[i] - if !u.isAlive || !u.isGround || u.army != army || u.eid == selfEid - continue - let core = u.pos + float3(0.0, 1.3, 0.0) - let along = dot(core - muzzlePos, dir) - if along <= 1.5 || along >= segLen - 1.5 - continue - let clearR = WTO_AI_FC_FRIENDLY_CORRIDOR_M + u.halfWid - if length_sq(core - (muzzlePos + dir * along)) < clearR * clearR - return false - return true - -[never_inline] -def private wto_solve_ballistic_aim(muzzlePos : float3; myVel : float3; slot : WtoBotSlot const&; - tgtPos : float3; var outAimPt, outWishDir : float3&) : float - // Prefer center-of-mass (+1.25m); shift up to turret (+1.85m) when lower hull is terrain-masked! - var aimPt = tgtPos + float3(0.0, 1.25, 0.0) - if !wto_terrain_los_clear(muzzlePos, aimPt) - aimPt = tgtPos + float3(0.0, 1.88, 0.0) - let rawDist = length(aimPt - muzzlePos) - let dragLoss = clamp(slot.spec.shellDragCx * 0.00011 * rawDist, 0.0, 0.28) - let vEff = max(180.0, slot.spec.muzzleSpeedMps * (1.0 - dragLoss)) - var leadPt = aimPt +def private wto_solve_ballistic_aim(muzzlePos, myVel : float3; slot : WtoBotSlot const&; + aimBase : float3; var outAimPt, outWishDir : float3&) : float + let rawDist = length(aimBase - muzzlePos) + let dragLoss = clamp(slot.fire.activeDragCx * 0.00011 * rawDist, 0.0, 0.28) + let vEff = max(120.0, slot.fire.activeSpeedMps * (1.0 - dragLoss)) + var leadPt = aimBase for _iter in range(2) let tof = clamp(length(leadPt - muzzlePos) / vEff, 0.0, 3.2) - let selfComp = slot.spec.hasVertStab ? (myVel * (tof * 0.15)) : float3(0.0, 0.0, 0.0) - leadPt = aimPt + slot.perceive.smoothedVel * tof - selfComp + let selfComp = myVel * (tof * 0.85) + leadPt = aimBase + slot.perceive.smoothedVel * tof - selfComp outAimPt = leadPt var arcDir = float3(0.0, 0.0, 0.0) if calculate_arc_low_start_dir(muzzlePos, leadPt, vEff, arcDir) && length_sq(arcDir) > 0.25 @@ -148,7 +163,7 @@ def private wto_sample_turret_muzzle(unit : Unit const?; turretNo : int; return false [never_inline] -def private wto_drive_turret_and_sample_barrel(var unit : Unit?; dt : float; now : float; +def private wto_drive_turret_and_sample_barrel(var unit : Unit?; dt, now : float; wishYawDeg, wishPitchDeg : float; var slot : WtoBotSlot&; var outMuzzlePos, outLiveDir : float3&) @@ -173,10 +188,10 @@ def private wto_drive_turret_and_sample_barrel(var unit : Unit?; dt : float; now fc.pitchClampSec = max(0.0, fc.pitchClampSec - dtStep * 2.5) if fc.pitchClampSec <= 0.05 fc.pitchBlocked = false - let maxYawStep = max(24.0, slot.spec.turretYawSpd * 1.35) * dtStep - let maxPitchStep = max(10.0, slot.spec.turretPitchSpd * 1.45) * dtStep - let yawDelta = clamp(wto_wrap_deg(wishYawDeg - fc.curYawDeg), -maxYawStep * 3.0, maxYawStep * 3.0) - let pitchDelta = clamp(wishPitchDeg - fc.curPitchDeg, -maxPitchStep * 3.0, maxPitchStep * 3.0) + let maxYawStep = max(24.0, slot.spec.turretYawSpd * 1.1) * dtStep + let maxPitchStep = max(10.0, slot.spec.turretPitchSpd * 1.1) * dtStep + let yawDelta = clamp(wto_wrap_deg(wishYawDeg - fc.curYawDeg), -maxYawStep, maxYawStep) + let pitchDelta = clamp(wishPitchDeg - fc.curPitchDeg, -maxPitchStep, maxPitchStep) fc.cmdYawDeg = wto_wrap_deg(fc.curYawDeg + yawDelta) fc.cmdPitchDeg = clamp(fc.curPitchDeg + pitchDelta, slot.spec.minPitchDeg - 2.0, slot.spec.maxPitchDeg + 2.0) turret.yawLim = fc.cmdYawDeg @@ -195,57 +210,21 @@ def private wto_drive_turret_and_sample_barrel(var unit : Unit?; dt : float; now fc.prevBarrelDir = outLiveDir fc.prevBarrelAt = now -[never_inline] -def private wto_try_delegate_stock_fire(var unit : Unit?; var gm : IGroundModel?; slot : WtoBotSlot const&) : bool - if !slot.tactics.spaaYieldAir && !(slot.spec.isPureLauncher && slot.perceive.hasClearLos && !!slot.perceive.targetEid) - return false - if gm != null - *gm |> set_check_visibility_target(true) - *gm |> set_ignore_stop_for_fire(slot.tactics.spaaYieldAir) - if slot.spec.isPureLauncher - var tgtU = get_unit_by_eid(slot.perceive.targetEid) - if tgtU != null && tgtU.isAlive - add_unit_for_target(*gm, tgtU) - set_unit_attack_type(unit, "attack_target") - return true - -[never_inline] -def private wto_try_pull_trigger(world : WtoWorldSnap const&; var unit : Unit?; - now, dt, distToTgt : float; muzzlePos, aimPt, liveDir, wishDir : float3; - var slot : WtoBotSlot&) - assume fc = slot.fire - let aimErrDeg = acos(clamp(dot(liveDir, wishDir), -1.0, 1.0)) * WTO_RAD_TO_DEG - fc.lastAimErrDeg = aimErrDeg - let allowErrDeg = clamp(atan2(WTO_AI_FC_CLOSE_HIT_RADIUS_M, max(distToTgt, 6.0)) * WTO_RAD_TO_DEG, WTO_AI_FC_BASE_ALIGN_DEG, 2.4) - let chassisStable = slot.spec.hasVertStab || length(unit.vel) <= WTO_AI_FC_UNSTAB_STOP_MPS || distToTgt < 22.0 - let settled = aimErrDeg <= allowErrDeg && fc.barrelOmegaDegSec <= WTO_AI_FC_BARREL_SETTLE_DEG_SEC && chassisStable - fc.lastAligned = settled - fc.settleHoldSec = settled ? (fc.settleHoldSec + clamp(dt, 0.005, 0.10)) : max(0.0, fc.settleHoldSec - dt * 2.0) - - let minCadence = slot.spec.isAutocannonBelt ? 0.12 : 0.65 - if !fc.gunReady || fc.settleHoldSec < WTO_AI_FC_SETTLE_HOLD_SEC || (now - fc.lastShotAt) < minCadence - return - if wto_terrain_hard_ray(muzzlePos, liveDir, min(distToTgt - 1.5, 45.0)) < min(distToTgt - 2.0, 42.0) - return - if !wto_friendly_corridor_clear(world, slot.eid, slot.army, muzzlePos, aimPt) - return - unit_single_shot(unit, int(WeaponTriggerGroups.TRIGGER_GROUP_PRIMARY)) - fc.lastShotAt = now - fc.shotCount++ - fc.shotErrSumDeg += aimErrDeg - fc.maxShotErrDeg = max(fc.maxShotErrDeg, aimErrDeg) - if !slot.spec.isAutocannonBelt - fc.settleHoldSec = 0.0 - [never_inline] def public wto_fire_update(world : WtoWorldSnap const&; var unit : Unit?; - now, dt : float; var slot : WtoBotSlot&) + now, dt : float; var slot : WtoBotSlot&; var fireBudget : int&) if !WTO_AI_LAYER_FIRE_CONTROL || unit == null || unit.weap == null return - if wto_try_delegate_stock_fire(unit, as_gm(unit), slot) + // SPAA vs aircraft only delegates to stock air-target fire control (never ground targets). + if slot.tactics.spaaYieldAir + var gm = as_gm(unit) + if gm != null + *gm |> set_check_visibility_target(true) + *gm |> set_ignore_stop_for_fire(true) + set_unit_attack_type(unit, "attack_target") return set_unit_attack_type(unit, "dont_aim") - wto_inspect_primary_weapon(unit, slot.fire) + wto_inspect_primary_weapon(unit, now, slot.spec, slot.fire) var muzzlePos = unit.pos + float3(0.0, 1.95, 0.0) var liveBarrelDir = unit.unitTm[0] let _preSample = wto_sample_turret_muzzle(unit, slot.fire.turretNo, muzzlePos, liveBarrelDir) @@ -257,7 +236,7 @@ def public wto_fire_update(world : WtoWorldSnap const&; var unit : Unit?; let engageValid = (slot.perceive.hasClearLos && !!slot.perceive.targetEid && !slot.perceive.targetIsAir && !(slot.spec.role == WTO_ROLE_SPAA && slot.tactics.posture == WTO_POSTURE_RETREAT)) if engageValid - distToTgt = wto_solve_ballistic_aim(muzzlePos, unit.vel, slot, slot.perceive.knownPos, aimPt, wishWorldDir) + distToTgt = wto_solve_ballistic_aim(muzzlePos, unit.vel, slot, slot.perceive.visibleAimPt, aimPt, wishWorldDir) elif !!slot.perceive.targetEid && (now - slot.perceive.lastSeenAt) <= WTO_AI_TACTICS_MEMORY_TTL_SEC wishWorldDir = normalize((slot.perceive.knownPos + float3(0.0, 1.4, 0.0)) - muzzlePos) elif now < slot.perceive.alertUntil @@ -271,4 +250,5 @@ def public wto_fire_update(world : WtoWorldSnap const&; var unit : Unit?; slot.fire.settleHoldSec = 0.0 slot.fire.lastAligned = false return - wto_try_pull_trigger(world, unit, now, dt, distToTgt, muzzlePos, aimPt, liveBarrelDir, wishWorldDir, slot) + let distXZ = sqrt(wto_xz_dist_sq(unit.pos, slot.perceive.knownPos)) + wto_fire_gate_try_shoot(world, unit, now, dt, distXZ, muzzlePos, aimPt, liveBarrelDir, wishWorldDir, slot, fireBudget) diff --git a/game-ai/ground/wto_ai_fire_gate_common.das b/game-ai/ground/wto_ai_fire_gate_common.das new file mode 100644 index 0000000..96e1356 --- /dev/null +++ b/game-ai/ground/wto_ai_fire_gate_common.das @@ -0,0 +1,199 @@ +// Single fire-permission gate for every ground weapon (main cannon, launcher, SPAA self-defense). +// Every shot must pass visual confirmation, weapon readiness, distance-tier speed limits, +// 800 m continuous LOS window, aim settle, frame pre-fire budget, muzzle hard-ray, drag-integrated +// ballistic trajectory sweep, predicted friendly corridor, and multi-barrel group validation. +options indenting = 2 +options no_global_heap = true +module wto_ai_fire_gate_common shared + +require ecs +require math +require DagorMath +require Mission +require Unit +require Weapon +require %game.utils.utils_common +require %appGame.wtoai.wto_ai_config_common +require %appGame.wtoai.wto_ai_math_common +require %appGame.wtoai.wto_ai_combat_types_common +require %appGame.wtoai.wto_ai_types_common +require %appGame.wtoai.wto_ai_sight_common + +[never_inline] +def private wto_gate_friendly_segment_clear(world : WtoWorldSnap const&; selfEid : EntityId; + army : int; p0, p1 : float3; tMid : float) : bool + let delta = p1 - p0 + let segLen = length(delta) + if segLen < 0.2 + return true + let dir = delta / segLen + for i in range(world.unitCount) + assume u = world.units[i] + if !u.isAlive || !u.isGround || u.army != army || u.eid == selfEid + continue + let predPos = u.pos + u.vel * tMid + float3(0.0, 1.3, 0.0) + let along = clamp(dot(predPos - p0, dir), 0.0, segLen) + let clearR = WTO_AI_FC_FRIENDLY_CORRIDOR_M + u.halfWid + if length_sq(predPos - (p0 + dir * along)) < clearR * clearR + return false + return true + +[never_inline] +def private wto_gate_check_ballistic_arc(world : WtoWorldSnap const&; + selfEid, targetEid : EntityId; army : int; + muzzlePos, liveDir, carrierVel, aimPt : float3; + speedMps, dragCx, massKg, caliberM : float; + var outBlock : int&) : int + let toAim = aimPt - muzzlePos + let targetDist = length(toAim) + if targetDist < 1.5 + return WTO_DENY_OK + let toAimDir = toAim / targetDist + let area = 0.25 * WTO_PI * caliberM * caliberM + let dragK = 0.5 * 1.225 * dragCx * area / max(0.1, massKg) + var cur = muzzlePos + var vel = liveDir * max(80.0, speedMps) + carrierVel + var t = 0.0 + var traveled = 0.0 + for step in range(64) + let spd = length(vel) + if spd < 20.0 + return WTO_DENY_AIM_ERR + let remain = max(0.5, targetDist - traveled) + let segWant = min(WTO_AI_FC_BALLISTIC_STEP_M, remain) + let dt = clamp(segWant / spd, 0.004, 0.14) + let accel = float3(0.0, -9.81, 0.0) - vel * (dragK * spd) + var next = cur + vel * dt + accel * (0.5 * dt * dt) + let nextProj = dot(next - muzzlePos, toAimDir) + let isLast = nextProj >= targetDist - 0.5 + if isLast && nextProj > targetDist && length_sq(next - cur) > 0.01 + let curProj = dot(cur - muzzlePos, toAimDir) + let frac = clamp((targetDist - curProj) / max(0.01, nextProj - curProj), 0.0, 1.0) + next = lerp(cur, next, frac) + let trimS = step == 0 ? 0.35 : 0.0 + let trimE = isLast ? 0.65 : 0.0 + let blk = wto_sight_hard_segment_blocked(world, selfEid, targetEid, cur, next, WTO_AI_FC_BALLISTIC_SWEEP_R_M, trimS, trimE) + if blk != WTO_BLOCK_NONE + outBlock = blk + return WTO_DENY_ARC_HARD + if !wto_gate_friendly_segment_clear(world, selfEid, army, cur, next, t + dt * 0.5) + return WTO_DENY_FRIENDLY + traveled += length(next - cur) + cur = next + vel = vel + accel * dt + t += dt + if isLast + let missTol = max(3.2, targetDist * 0.012) + if length_sq(cur - aimPt) > missTol * missTol + return WTO_DENY_AIM_ERR + return WTO_DENY_OK + return WTO_DENY_AIM_ERR + +[never_inline] +def private wto_gate_check_barrel(world : WtoWorldSnap const&; unit : Unit const?; + slot : WtoBotSlot const&; muzzlePos, liveDir, aimPt : float3; + var outBlock : int&) : int + let straightBlk = wto_sight_hard_segment_blocked(world, slot.eid, slot.perceive.targetEid, muzzlePos, aimPt, 0.05, 0.35, 0.65) + if straightBlk != WTO_BLOCK_NONE + outBlock = straightBlk + return WTO_DENY_MUZZLE_HARD + return wto_gate_check_ballistic_arc(world, slot.eid, slot.perceive.targetEid, slot.army, + muzzlePos, liveDir, unit.vel, aimPt, + slot.fire.activeSpeedMps, slot.fire.activeDragCx, slot.fire.activeMassKg, slot.fire.activeCaliberM, outBlock) + +[never_inline] +def private wto_gate_check_all_primary_guns(world : WtoWorldSnap const&; unit : Unit const?; + slot : WtoBotSlot const&; primaryMuzzle, primaryDir, aimPt : float3; + var outBlock : int&) : int + let primaryRes = wto_gate_check_barrel(world, unit, slot, primaryMuzzle, primaryDir, aimPt, outBlock) + if primaryRes != WTO_DENY_OK + return primaryRes + if unit == null || unit.weap == null + return WTO_DENY_OK + for tIdx, turret in iter_range(unit.weap.turret), unit.weap.turret + if tIdx == slot.fire.turretNo || int(turret.triggerGroupNo) != int(WeaponTriggerGroups.TRIGGER_GROUP_PRIMARY) + continue + let weapon = get_weapon(unit.weap.Weapons, int(turret.triggerNo), int(turret.weaponIndex)) + if weapon == null || weapon.isDummyGun + continue + var gunTm : float3x4 + weapon_calcShootTm(weapon, unit.unitTm, gunTm) + if length_sq(gunTm[0]) <= 0.25 + continue + let secRes = wto_gate_check_barrel(world, unit, slot, gunTm[3], normalize(gunTm[0]), aimPt, outBlock) + if secRes != WTO_DENY_OK + return secRes == WTO_DENY_FRIENDLY ? WTO_DENY_FRIENDLY : WTO_DENY_MULTI_GUN + return WTO_DENY_OK + +[never_inline] +def private wto_gate_speed_allowed(distXZ, measuredSpeed : float; spec : WtoVehicleSpec const&) : bool + if distXZ > WTO_AI_FC_MID_RANGE_M + return measuredSpeed <= WTO_AI_FC_STOP_SPEED_MAX_MPS + if distXZ > WTO_AI_FC_CLOSE_RANGE_M + let slowCap = min(spec.vMaxFwd * WTO_AI_FC_MID_SLOW_RATIO, WTO_AI_FC_MID_SLOW_MAX_MPS) + return measuredSpeed <= slowCap + return true + +[never_inline] +def private wto_gate_log_deny(now, distXZ, measuredSpeed : float; reason, blk : int; var slot : WtoBotSlot&) + assume fc = slot.fire + let changed = fc.lastDenyReason != reason || fc.lastDenyBlock != blk + fc.lastDenyReason = reason + fc.lastDenyBlock = blk + if WTO_AI_DIAG_TELEMETRY && reason >= WTO_DENY_SPEED && (changed || (now - fc.lastDenyLogAt) >= 4.0) + fc.lastDenyLogAt = now + print("WTO_AI|DENY|eid={uint(slot.eid)}|reason={reason}|block={blk}|dist={distXZ}|spd={measuredSpeed}\n") + +[never_inline] +def public wto_fire_gate_try_shoot(world : WtoWorldSnap const&; var unit : Unit?; + now, dt, distXZ : float; muzzlePos, aimPt, liveDir, wishDir : float3; + var slot : WtoBotSlot&; var fireBudget : int&) + assume fc = slot.fire + let aimErrDeg = acos(clamp(dot(liveDir, wishDir), -1.0, 1.0)) * WTO_RAD_TO_DEG + fc.lastAimErrDeg = aimErrDeg + let measuredSpeed = length(unit.vel) + let speedOk = wto_gate_speed_allowed(distXZ, measuredSpeed, slot.spec) + let allowErrDeg = clamp(atan2(WTO_AI_FC_CLOSE_HIT_RADIUS_M, max(distXZ, 6.0)) * WTO_RAD_TO_DEG, WTO_AI_FC_BASE_ALIGN_DEG, 2.4) + let settled = aimErrDeg <= allowErrDeg && fc.barrelOmegaDegSec <= WTO_AI_FC_BARREL_SETTLE_DEG_SEC && speedOk + fc.lastAligned = settled + fc.settleHoldSec = settled ? (fc.settleHoldSec + clamp(dt, 0.005, 0.10)) : max(0.0, fc.settleHoldSec - dt * 2.0) + + let minCadence = slot.spec.isAutocannonBelt ? 0.12 : 0.65 + if !fc.gunReady || (now - fc.lastShotAt) < minCadence + wto_gate_log_deny(now, distXZ, measuredSpeed, WTO_DENY_NOT_READY, WTO_BLOCK_NONE, slot) + return + if !speedOk + wto_gate_log_deny(now, distXZ, measuredSpeed, WTO_DENY_SPEED, WTO_BLOCK_NONE, slot) + return + if distXZ > WTO_AI_FC_LONG_RANGE_M && (slot.perceive.goodLosSec < WTO_AI_FC_LONG_WINDOW_SEC || slot.perceive.visiblePointCount < 2) + wto_gate_log_deny(now, distXZ, measuredSpeed, WTO_DENY_LONG_WINDOW, WTO_BLOCK_NONE, slot) + return + if aimErrDeg > allowErrDeg + wto_gate_log_deny(now, distXZ, measuredSpeed, WTO_DENY_AIM_ERR, WTO_BLOCK_NONE, slot) + return + let reqHold = distXZ <= WTO_AI_FC_CLOSE_RANGE_M ? WTO_AI_FC_CLOSE_SETTLE_HOLD_SEC : WTO_AI_FC_SETTLE_HOLD_SEC + if fc.settleHoldSec < reqHold + wto_gate_log_deny(now, distXZ, measuredSpeed, WTO_DENY_SETTLE, WTO_BLOCK_NONE, slot) + return + if fireBudget <= 0 + wto_gate_log_deny(now, distXZ, measuredSpeed, WTO_DENY_BUDGET, WTO_BLOCK_NONE, slot) + return + fireBudget-- + var blk = WTO_BLOCK_NONE + let gateRes = wto_gate_check_all_primary_guns(world, unit, slot, muzzlePos, liveDir, aimPt, blk) + if gateRes != WTO_DENY_OK + wto_gate_log_deny(now, distXZ, measuredSpeed, gateRes, blk, slot) + return + + unit_single_shot(unit, int(WeaponTriggerGroups.TRIGGER_GROUP_PRIMARY)) + fc.lastShotAt = now + fc.pendingShotConfirm = true + fc.pendingShotAt = now + fc.lastDenyReason = WTO_DENY_OK + fc.lastDenyBlock = WTO_BLOCK_NONE + fc.shotErrSumDeg += aimErrDeg + fc.maxShotErrDeg = max(fc.maxShotErrDeg, aimErrDeg) + if !slot.spec.isAutocannonBelt + fc.settleHoldSec = 0.0 + if WTO_AI_DIAG_TELEMETRY + print("WTO_AI|SHOT|eid={uint(slot.eid)}|tgt={uint(slot.perceive.targetEid)}|dist={distXZ}|spd={measuredSpeed}|v0={fc.activeSpeedMps}|err={aimErrDeg}\n") diff --git a/game-ai/ground/wto_ai_perceive_common.das b/game-ai/ground/wto_ai_perceive_common.das index 966aa97..6c3774d 100644 --- a/game-ai/ground/wto_ai_perceive_common.das +++ b/game-ai/ground/wto_ai_perceive_common.das @@ -1,6 +1,5 @@ -// 6-channel no-wallhack perception: foliage-filtered visual LOS, close engine & gunfire audio, -// team radio sharing, hit retaliation alert, frozen visual memory, strong target stickiness, -// smoothed target velocity, and fanned-out radio hunting bearings. +// Exposure-integrated visual perception with strict foliage/smoke/hard occlusion, +// directional-only audio/hit/radio clues, and frozen last-seen memory. options indenting = 2 options no_global_heap = true module wto_ai_perceive_common shared @@ -9,46 +8,71 @@ require ecs require math require %appGame.wtoai.wto_ai_config_common require %appGame.wtoai.wto_ai_math_common +require %appGame.wtoai.wto_ai_combat_types_common require %appGame.wtoai.wto_ai_types_common require %appGame.wtoai.wto_ai_terrain_common +require %appGame.wtoai.wto_ai_sight_common require %appGame.wtoai.wto_ai_world_common [never_inline] -def private wto_check_visual_enemy(myEye, lookDir : float3; cosHalfFov : float; - enemy : WtoUnitSnap const&; var outDist : float&) : bool - let aimMid = enemy.pos + float3(0.0, enemy.isAir ? 0.0 : 1.35, 0.0) - let delta = aimMid - myEye - let dist = length(delta) - outDist = dist - let maxRange = enemy.isAir ? 2600.0 : WTO_AI_TACTICS_VISION_RANGE_M - if dist > maxRange || dist < 1.0 - return false - let dirXZ = wto_xz_normalize(delta, lookDir) - let inCone = dot(dirXZ, lookDir) >= cosHalfFov - let inPeriph = dist <= WTO_AI_TACTICS_PERIPHERAL_RANGE_M - if !inCone && !inPeriph && !enemy.isAir - return false - if wto_terrain_los_clear(myEye, aimMid) - return true - if !enemy.isAir && dist <= 900.0 - let aimTurret = enemy.pos + float3(0.0, 2.05, 0.0) - if wto_terrain_los_clear(myEye, aimTurret) - return true - return false +def private wto_exp_find_or_alloc(var p : WtoPerceiveState&; eid : EntityId) : int + var freeIdx = -1 + var minIdx = 0 + var minScore = 2.0 + for i in range(WTO_MAX_EXPOSURE_TRACKS) + if p.expEids[i] == eid + return i + if !p.expEids[i] && freeIdx < 0 + freeIdx = i + if p.expScore[i] < minScore + minScore = p.expScore[i] + minIdx = i + let dst = freeIdx >= 0 ? freeIdx : minIdx + p.expEids[dst] = eid + p.expScore[dst] = 0.0 + p.expGoodLosSec[dst] = 0.0 + return dst + +[never_inline] +def private wto_exp_decay_all(world : WtoWorldSnap const&; dt : float; var p : WtoPerceiveState&) + let decay = WTO_AI_PERC_DECAY_PER_SEC * dt + for i in range(WTO_MAX_EXPOSURE_TRACKS) + if !p.expEids[i] + continue + let uIdx = wto_world_find_unit(world, p.expEids[i]) + if uIdx < 0 || !world.units[uIdx].isAlive + p.expEids[i] = INVALID_ENTITY_ID + p.expScore[i] = 0.0 + p.expGoodLosSec[i] = 0.0 + continue + p.expScore[i] = max(0.0, p.expScore[i] - decay) + if p.expScore[i] <= 0.001 + p.expEids[i] = INVALID_ENTITY_ID + p.expScore[i] = 0.0 + p.expGoodLosSec[i] = 0.0 + +[never_inline] +def private wto_spot_fill_time(dist : float; cosAngle : float; isShooting : bool; visCount : int) : float + let cosFront = cos(WTO_AI_PERC_FRONT_CONE_DEG * WTO_DEG_TO_RAD) + var t = WTO_AI_PERC_FAR_SPOT_SEC + if dist < WTO_AI_PERC_NEAR_SPOT_M || (isShooting && dist < WTO_AI_PERC_FIRING_SPOT_M) + t = WTO_AI_PERC_FAST_SPOT_SEC + elif dist <= 550.0 && cosAngle >= cosFront + t = WTO_AI_PERC_NORMAL_SPOT_SEC + if visCount >= 3 + t *= 0.85 + return max(0.08, t) [never_inline] def private wto_update_audio_and_radio_alerts(world : WtoWorldSnap const&; now : float; myPos : float3; var slot : WtoBotSlot&) assume p = slot.perceive - // Priority A: Recent hit retaliation alert (never reveals hidden position, only direction). + // Priority A: Recent hit direction captured at impact time (never reveals hidden true position). if (now - p.lastDamagedAt) <= 4.0 && !!p.lastOffenderEid - let offIdx = wto_world_find_unit(world, p.lastOffenderEid) - if offIdx >= 0 && world.units[offIdx].army != slot.army - let d = world.units[offIdx].pos - myPos - p.alertYawRad = atan2(d.z, d.x) - p.alertUntil = now + 4.5 - return - // Priority B: Close enemy engine / cannon audio. + p.alertYawRad = p.lastHitYawRad + p.alertUntil = now + 4.5 + return + // Priority B: Close enemy engine / cannon sound direction clue. var bestAudioDist = 1.0e9 for i in range(world.unitCount) assume u = world.units[i] @@ -64,7 +88,7 @@ def private wto_update_audio_and_radio_alerts(world : WtoWorldSnap const&; now : p.alertUntil = now + 3.2 if bestAudioDist < 1.0e8 return - // Priority C: Friendly radio spot alert bearing. + // Priority C: Friendly radio spot direction clue (alert only, never enables firing). let radioSq = wto_sq(WTO_AI_TACTICS_RADIO_SHARE_M) for r in range(WTO_MAX_RADIO) assume sp = world.radioSpots[r] @@ -75,19 +99,45 @@ def private wto_update_audio_and_radio_alerts(world : WtoWorldSnap const&; now : return [never_inline] -def private wto_select_best_visual_enemy(world : WtoWorldSnap const&; now : float; - myEye, lookDir : float3; slot : WtoBotSlot const&) : int +def private wto_scan_visual_exposure(world : WtoWorldSnap const&; now, dt : float; + myEye, lookDir : float3; var slot : WtoBotSlot&; + var outBestIdx, outVisCount : int&; + var outGoodLosSec : float&; var outAimPt : float3&) assume p = slot.perceive let cosHalfFov = cos(0.5 * WTO_AI_TACTICS_VISION_FOV_DEG * WTO_DEG_TO_RAD) let isSpaa = slot.spec.role == WTO_ROLE_SPAA - var bestIdx = -1 + let decay = WTO_AI_PERC_DECAY_PER_SEC * dt var bestScore = 1.0e9 + outBestIdx = -1 + outVisCount = 0 + outGoodLosSec = 0.0 for i in range(world.unitCount) assume u = world.units[i] if !u.isAlive || u.army == slot.army || (u.isAir && !isSpaa) continue - var dist = 0.0 - if !wto_check_visual_enemy(myEye, lookDir, cosHalfFov, u, dist) + let delta = u.pos - myEye + let dist = length(delta) + let maxRange = u.isAir ? 2600.0 : WTO_AI_TACTICS_VISION_RANGE_M + if dist > maxRange || dist < 1.0 + continue + let dirXZ = wto_xz_normalize(delta, lookDir) + let cosAng = dot(dirXZ, lookDir) + let inFov = cosAng >= cosHalfFov || (dist <= WTO_AI_PERC_PERIPH_CLOSE_M && cosAng >= 0.0) + if !inFov && !u.isAir + continue + let maxSamples = dist > WTO_AI_FC_LONG_RANGE_M ? 2 : 4 + var samplePt = u.pos + float3(0.0, 1.3, 0.0) + let vis = wto_sight_check_target_samples(world, slot.eid, myEye, u, maxSamples, samplePt) + if vis <= 0 + for k in range(WTO_MAX_EXPOSURE_TRACKS) + if p.expEids[k] == u.eid + p.expGoodLosSec[k] = 0.0 + continue + let tIdx = wto_exp_find_or_alloc(p, u.eid) + let fillSec = wto_spot_fill_time(dist, cosAng, u.isShooting, vis) + p.expScore[tIdx] = clamp(p.expScore[tIdx] + decay + dt / fillSec, 0.0, 1.0) + p.expGoodLosSec[tIdx] = vis >= 2 ? (p.expGoodLosSec[tIdx] + dt) : 0.0 + if p.expScore[tIdx] < 0.999 continue var score = dist - (u.isAir && isSpaa ? 900.0 : 0.0) if u.eid == p.lockedEid && now < p.lockedUntil @@ -100,8 +150,10 @@ def private wto_select_best_visual_enemy(world : WtoWorldSnap const&; now : floa score -= 180.0 if score < bestScore bestScore = score - bestIdx = i - return bestIdx + outBestIdx = i + outVisCount = vis + outGoodLosSec = p.expGoodLosSec[tIdx] + outAimPt = samplePt [never_inline] def public wto_perceive_update(var world : WtoWorldSnap&; now, dt : float; @@ -113,13 +165,21 @@ def public wto_perceive_update(var world : WtoWorldSnap&; now, dt : float; let worldYaw = atan2(hullFwd.z, hullFwd.x) - slot.fire.curYawDeg * WTO_DEG_TO_RAD lookDir = float3(cos(worldYaw), 0.0, sin(worldYaw)) - let bestIdx = wto_select_best_visual_enemy(world, now, myEye, lookDir, slot) + wto_exp_decay_all(world, dt, p) + var bestIdx = -1 + var visCount = 0 + var goodLosSec = 0.0 + var aimPt = myPos + wto_scan_visual_exposure(world, now, dt, myEye, lookDir, slot, bestIdx, visCount, goodLosSec, aimPt) if bestIdx >= 0 assume tgt = world.units[bestIdx] let sameTarget = p.targetEid == tgt.eid p.targetEid = tgt.eid p.targetIsAir = tgt.isAir p.hasClearLos = true + p.visiblePointCount = visCount + p.goodLosSec = goodLosSec + p.visibleAimPt = aimPt p.knownPos = tgt.pos let alpha = sameTarget ? clamp(dt * 6.0, 0.18, 0.65) : 1.0 p.smoothedVel = sameTarget ? lerp(p.smoothedVel, tgt.vel, alpha) : tgt.vel @@ -132,15 +192,17 @@ def public wto_perceive_update(var world : WtoWorldSnap&; now, dt : float; wto_world_broadcast_radio(world, slot.army, tgt.eid, tgt.pos, now) return + // Lost visual confirmation: immediately revoke LOS, zero velocity lead, freeze knownPos. p.hasClearLos = false - p.smoothedVel *= 0.5 - if !!p.targetEid && (now - p.lastSeenAt) > WTO_AI_TACTICS_MEMORY_TTL_SEC + p.visiblePointCount = 0 + p.goodLosSec = 0.0 + p.smoothedVel = float3(0.0, 0.0, 0.0) + let tgtIdx = wto_world_find_unit(world, p.targetEid) + if !!p.targetEid && (tgtIdx < 0 || !world.units[tgtIdx].isAlive || (now - p.lastSeenAt) > WTO_AI_TACTICS_MEMORY_TTL_SEC) p.targetEid = INVALID_ENTITY_ID p.lockedEid = INVALID_ENTITY_ID wto_update_audio_and_radio_alerts(world, now, myPos, slot) -// Compute a fanned-out hunting anchor toward a team radio spot so multiple bots pincer from -// spread-out angles instead of converging onto the exact same coordinate. [never_inline] def public wto_perceive_pick_hunt_pos(world : WtoWorldSnap const&; army : int; eid : EntityId; myPos : float3; now : float; var outPos : float3&) : bool diff --git a/game-ai/ground/wto_ai_runtime.das b/game-ai/ground/wto_ai_runtime.das index 796480b..67bd9bb 100644 --- a/game-ai/ground/wto_ai_runtime.das +++ b/game-ai/ground/wto_ai_runtime.das @@ -22,6 +22,7 @@ require %game.events require %game.unit.unit_events require %appGame.wtoai.wto_ai_config_common require %appGame.wtoai.wto_ai_order_common +require %appGame.wtoai.wto_ai_combat_types_common require %appGame.wtoai.wto_ai_types_common require %appGame.wtoai.wto_ai_specs_common require %appGame.wtoai.wto_ai_world_common @@ -39,6 +40,7 @@ var private g_last_world_frame : float = -1.0 var private g_next_cmd_at : float = 0.0 var private g_cmd_dirty : bool = true var private g_last_zone_ver : int = -1 +var private g_fire_budget : int = 0 var private g_next_diag_at : float = 0.0 def private wto_any_layer_active() : bool @@ -189,16 +191,19 @@ def wto_ai_unit_cleanup_es(evt : Event; eid : EntityId) g_cmd_dirty = true [es(tag=server)] -def wto_ai_unit_damage_es(evt : EventUnitDamage; eid : EntityId) +def wto_ai_unit_damage_es(evt : EventUnitDamage; eid : EntityId; unit__ref : UnitRef) if !wto_any_layer_active() || !WTO_AI_LAYER_TACTICS return let idx = wto_find_slot(eid) let offEid = evt.offender.eid - if idx < 0 || !offEid || offEid == eid + let u = unit__ref.unit + if idx < 0 || u == null || !offEid || offEid == eid return let offUnitIdx = wto_world_find_unit(g_world, offEid) if offUnitIdx >= 0 && g_world.units[offUnitIdx].army == g_bots[idx].army return + let imp = evt.pos - u.pos + g_bots[idx].perceive.lastHitYawRad = (imp.x * imp.x + imp.z * imp.z) > 0.04 ? atan2(imp.z, imp.x) : atan2(u.unitTm[0].z, u.unitTm[0].x) g_bots[idx].perceive.lastDamagedAt = float(get_app().usefulTotalTime) g_bots[idx].perceive.lastOffenderEid = offEid @@ -209,6 +214,7 @@ def wto_ai_world_tick_es(act : UpdateStageInfoAct) if abs(act.curTime - g_last_world_frame) <= 1.0e-4 return g_last_world_frame = act.curTime + g_fire_budget = WTO_AI_FC_MAX_CHECKS_PER_TICK let now = float(get_app().usefulTotalTime) if g_world.valid && now < g_world.time - 1.0 wto_reset_runtime() @@ -257,7 +263,7 @@ def wto_ai_pipeline_es(act : UpdateStageInfoAct; eid : EntityId; var unit__ref : if now >= slot.nextNavAt slot.nextNavAt = now + WTO_AI_NAV_TICK_SEC wto_nav_update(g_world, now, unit.pos, unit.unitTm[0], slot) - wto_fire_update(g_world, unit, now, act.dt, slot) + wto_fire_update(g_world, unit, now, act.dt, slot, g_fire_budget) [es(tag=server, after=wto_ai_pipeline_es)] def wto_ai_phys_tick_es(act : UpdateStageInfoAct; eid : EntityId; var unit__ref : UnitRef&; diff --git a/game-ai/ground/wto_ai_sight_common.das b/game-ai/ground/wto_ai_sight_common.das new file mode 100644 index 0000000..efa53bd --- /dev/null +++ b/game-ai/ground/wto_ai_sight_common.das @@ -0,0 +1,126 @@ +// Scene visibility, foliage transparency, smoke, and strict hard-occlusion queries. +// Completely separate from driving's soft-obstacle avoidance in wto_ai_terrain_common. +options indenting = 2 +options no_global_heap = true +module wto_ai_sight_common shared + +require ecs +require math +require DagorMath +require Dacoll +require RendInst +require PhysMat +require SmokeOccluder +require %appGame.wtoai.wto_ai_config_common +require %appGame.wtoai.wto_ai_math_common +require %appGame.wtoai.wto_ai_combat_types_common +require %appGame.wtoai.wto_ai_types_common + +let private SIGHT_TERRAIN_MASK = ETF_LMESH | ETF_HEIGHTMAP | ETF_STRUCTURES | ETF_FRT + +[never_inline] +def private wto_seg_hits_box_xz(p0, segDir : float3; segLen : float; + boxPos : float3; halfLen, halfWid, heightM : float) : bool + let rad = max(halfLen, halfWid) * 0.88 + let center = boxPos + float3(0.0, heightM * 0.5, 0.0) + let rel = center - p0 + let along = dot(rel, segDir) + if along < 0.25 || along > segLen - 0.25 + return false + let closest = p0 + segDir * along + let dy = abs(closest.y - center.y) + if dy > heightM * 0.55 + 0.35 + return false + let dx = closest.x - center.x + let dz = closest.z - center.z + return (dx * dx + dz * dz) <= rad * rad + +[never_inline] +def public wto_sight_units_block_segment(world : WtoWorldSnap const&; + selfEid, targetEid : EntityId; + p0, segDir : float3; segLen : float) : int + for w in range(world.wreckCount) + assume wr = world.wrecks[w] + if wr.eid != selfEid && wr.eid != targetEid + if wto_seg_hits_box_xz(p0, segDir, segLen, wr.pos, wr.halfLen, wr.halfWid, 2.2) + return WTO_BLOCK_WRECK + for i in range(world.unitCount) + assume u = world.units[i] + if !u.isAlive || !u.isGround || u.eid == selfEid || u.eid == targetEid + continue + if wto_seg_hits_box_xz(p0, segDir, segLen, u.pos, u.halfLen, u.halfWid, 2.3) + return WTO_BLOCK_VEHICLE + return WTO_BLOCK_NONE + +[never_inline] +def public wto_sight_hard_segment_blocked(world : WtoWorldSnap const&; + selfEid, targetEid : EntityId; + fromPos, toPos : float3; + sweepRadius : float; trimStartM, trimEndM : float) : int + let delta = toPos - fromPos + let fullLen = length(delta) + if fullLen <= trimStartM + trimEndM + 0.2 + return WTO_BLOCK_NONE + let dir = delta / fullLen + var p0 = fromPos + dir * trimStartM + let traceLen = fullLen - trimStartM - trimEndM + if rayhit_normalized(p0, dir, traceLen, SIGHT_TERRAIN_MASK, PHYSMAT_INVALID) + return WTO_BLOCK_TERRAIN + if rayhit_normalized(p0, dir, traceLen, ETF_RI, PHYSMAT_INVALID) + return WTO_BLOCK_OBJECT + if rayhit_normalized(p0, dir, traceLen, ETF_RI_PHYS, PHYSMAT_INVALID) + return WTO_BLOCK_OBJECT + if sweepRadius > 0.02 + var s1 = p0 + dir * traceLen + var queryOut = ShapeQueryOutput() + if sphere_cast(p0, s1, sweepRadius, queryOut) + return WTO_BLOCK_OBJECT + return wto_sight_units_block_segment(world, selfEid, targetEid, p0, dir, traceLen) + +[never_inline] +def public wto_sight_visual_clear(world : WtoWorldSnap const&; + selfEid, targetEid : EntityId; + eyePos, targetPt : float3) : int + let delta = targetPt - eyePos + let dist = length(delta) + if dist <= 1.2 + return WTO_BLOCK_NONE + let dir = delta / dist + let traceLen = max(0.4, dist - 1.1) + var p0 = eyePos + var p1 = targetPt + if rayhit_smoke_occluders(p0, p1) + return WTO_BLOCK_SMOKE + let aimMat = get_material_id("aimRay") + if rayhit_normalized(p0, dir, traceLen, ETF_ALL, aimMat) + return WTO_BLOCK_TERRAIN + if traceTransparencyRayRIGenNormalized(p0, dir, traceLen, WTO_AI_PERC_FOLIAGE_TRANS) + return WTO_BLOCK_FOLIAGE + return wto_sight_units_block_segment(world, selfEid, targetEid, p0, dir, traceLen) + +[never_inline] +def public wto_sight_check_target_samples(world : WtoWorldSnap const&; + selfEid : EntityId; eyePos : float3; + tgt : WtoUnitSnap const&; maxSamples : int; + var outBestPt : float3&) : int + if tgt.isAir + outBestPt = tgt.pos + return wto_sight_visual_clear(world, selfEid, tgt.eid, eyePos, tgt.pos) == WTO_BLOCK_NONE ? 2 : 0 + let fwd = wto_xz_normalize(tgt.hullFwd, float3(1.0, 0.0, 0.0)) + let left = float3(-fwd.z, 0.0, fwd.x) + let sideOff = max(0.75, tgt.halfWid * 0.72) + var pts : float3[4] + pts[0] = tgt.pos + float3(0.0, 1.15, 0.0) + pts[1] = tgt.pos + float3(0.0, 1.95, 0.0) + pts[2] = tgt.pos + left * sideOff + float3(0.0, 1.25, 0.0) + pts[3] = tgt.pos - left * sideOff + float3(0.0, 1.25, 0.0) + let count = clamp(maxSamples, 1, 4) + var vis = 0 + var picked = false + for s in range(count) + if wto_sight_visual_clear(world, selfEid, tgt.eid, eyePos, pts[s]) == WTO_BLOCK_NONE + if !picked + outBestPt = pts[s] + picked = true + vis++ + return vis diff --git a/game-ai/ground/wto_ai_specs_common.das b/game-ai/ground/wto_ai_specs_common.das index 996bddd..28c5c53 100644 --- a/game-ai/ground/wto_ai_specs_common.das +++ b/game-ai/ground/wto_ai_specs_common.das @@ -17,6 +17,7 @@ require HeavyVehicleModel require Weapon require %game.utils.utils_common require %appGame.wtoai.wto_ai_math_common +require %appGame.wtoai.wto_ai_combat_types_common require %appGame.wtoai.wto_ai_types_common [never_inline] @@ -65,6 +66,35 @@ def private wto_parse_turret_limits(turretBlk : DataBlock const?; var spec : Wto if maxPitch > 1.0 spec.maxPitchDeg = clamp(maxPitch, 8.0, 88.0) +[never_inline] +def private wto_record_shell_block(bBlk : DataBlock const&; var spec : WtoVehicleSpec&; isDefault : bool) + let spd = bBlk |> datablock_getReal("speed", 0.0) + if spd <= 80.0 || spd >= 2600.0 + return + let cx = clamp(bBlk |> datablock_getReal("Cx", 0.35), 0.05, 1.5) + let mass = clamp(bBlk |> datablock_getReal("mass", 10.0), 0.05, 250.0) + let rawCal = bBlk |> datablock_getReal("ballisticCaliber", 0.0) + let cal = clamp(rawCal > 0.002 ? rawCal : bBlk |> datablock_getReal("caliber", 0.09), 0.005, 0.4) + if isDefault && spec.shellCount == 0 + spec.muzzleSpeedMps = spd + spec.shellDragCx = cx + spec.shellMassKg = mass + spec.shellCaliberM = cal + let bName = bBlk |> datablock_getStr("bulletName", "") + if empty(bName) || spec.shellCount >= WTO_MAX_SHELL_PROFILES + return + let h = ecs_hash(bName) + for i in range(spec.shellCount) + if spec.shells[i].nameHash == h + return + let idx = spec.shellCount + spec.shells[idx].nameHash = h + spec.shells[idx].speedMps = spd + spec.shells[idx].dragCx = cx + spec.shells[idx].massKg = mass + spec.shells[idx].caliberM = cal + spec.shellCount = idx + 1 + [never_inline] def private wto_parse_weapon_blk(weapBlkPath : string; var spec : WtoVehicleSpec&) if empty(weapBlkPath) || find(weapBlkPath, "dummy_weapon") >= 0 @@ -76,17 +106,12 @@ def private wto_parse_weapon_blk(weapBlkPath : string; var spec : WtoVehicleSpec if isRocket && !isCannon return spec.isAutocannonBelt = isBelt - var bestSpd = 0.0 - var bestCx = spec.shellDragCx + spec.shellCount = 0 datablock_for_each_block(wBlk, "bullet") <| $(bBlk) - let spd = bBlk |> datablock_getReal("speed", 0.0) - let cx = bBlk |> datablock_getReal("Cx", 0.35) - if spd > bestSpd && spd < 2400.0 - bestSpd = spd - bestCx = clamp(cx, 0.05, 1.5) - if bestSpd > 80.0 - spec.muzzleSpeedMps = bestSpd - spec.shellDragCx = bestCx + wto_record_shell_block(bBlk, spec, true) + datablock_for_each_block(wBlk) <| $(subBlk) + datablock_for_each_block(subBlk, "bullet") <| $(bBlk) + wto_record_shell_block(bBlk, spec, false) [never_inline] def private wto_parse_unit_blk(className : string; isLightTag : bool; var spec : WtoVehicleSpec&) : bool diff --git a/game-ai/ground/wto_ai_types_common.das b/game-ai/ground/wto_ai_types_common.das index e2c1d1b..67aadb4 100644 --- a/game-ai/ground/wto_ai_types_common.das +++ b/game-ai/ground/wto_ai_types_common.das @@ -5,6 +5,7 @@ module wto_ai_types_common shared require ecs require %appGame.wtoai.wto_ai_order_common +require %appGame.wtoai.wto_ai_combat_types_common let public WTO_MAX_BOTS = 64 let public WTO_MAX_UNITS = 96 @@ -46,6 +47,10 @@ struct public WtoVehicleSpec turretPitchSpd : float = 8.0 muzzleSpeedMps : float = 880.0 shellDragCx : float = 0.35 + shellMassKg : float = 10.0 + shellCaliberM : float = 0.09 + shellCount : int = 0 + shells : WtoShellProfile[12] isAutocannonBelt : bool = false isPureLauncher : bool = false halfLen : float = 3.4 @@ -152,22 +157,6 @@ struct public WtoCrowdSummary minPairDistM : float = 999.0 disperseEvents : int = 0 -[safe_when_uninitialized] -struct public WtoPerceiveState - targetEid : EntityId = INVALID_ENTITY_ID - targetIsAir : bool = false - hasClearLos : bool = false - knownPos : float3 = float3(0.0, 0.0, 0.0) - smoothedVel : float3 = float3(0.0, 0.0, 0.0) - lastSeenAt : float = -100.0 - lockedEid : EntityId = INVALID_ENTITY_ID - lockedUntil : float = -100.0 - alertYawRad : float = 0.0 - alertUntil : float = -100.0 - lastDamagedAt : float = -100.0 - lastOffenderEid : EntityId = INVALID_ENTITY_ID - lastRadioSentAt : float = -100.0 - [safe_when_uninitialized] struct public WtoTacticsState posture : int = 0 @@ -245,31 +234,6 @@ struct public WtoDriveState prevStr : float = 0.0 lastVFwd : float = 0.0 -[safe_when_uninitialized] -struct public WtoFireState - turretNo : int = -1 - gunReady : bool = false - reloading : bool = false - gunDamaged : bool = false - pitchBlocked : bool = false - pitchClampSec : float = 0.0 - cmdYawDeg : float = 0.0 - cmdPitchDeg : float = 0.0 - curYawDeg : float = 0.0 - curPitchDeg : float = 0.0 - prevPitchDeg : float = 0.0 - servoInit : bool = false - prevBarrelDir : float3 = float3(1.0, 0.0, 0.0) - prevBarrelAt : float = -100.0 - barrelOmegaDegSec : float = 0.0 - settleHoldSec : float = 0.0 - lastAligned : bool = false - lastAimErrDeg : float = 0.0 - lastShotAt : float = -100.0 - shotCount : int = 0 - shotErrSumDeg : float = 0.0 - maxShotErrDeg : float = 0.0 - [safe_when_uninitialized] struct public WtoBotSlot used : bool = false diff --git a/packages/patcher/src/ground-ai/ground-ai-config.ts b/packages/patcher/src/ground-ai/ground-ai-config.ts index ecb4e1a..bfb17a2 100644 --- a/packages/patcher/src/ground-ai/ground-ai-config.ts +++ b/packages/patcher/src/ground-ai/ground-ai-config.ts @@ -81,6 +81,17 @@ export interface GroundAiConfig { readonly tacticalReverseDistM: number; readonly tacticalReverseMaxSec: number; }; + readonly perception: { + readonly foliageTransparency: number; + readonly nearSpotRangeM: number; + readonly firingSpotRangeM: number; + readonly fastSpotSec: number; + readonly normalSpotSec: number; + readonly farSpotSec: number; + readonly decayPerSec: number; + readonly frontConeHalfDeg: number; + readonly peripheralCloseM: number; + }; readonly tactics: { readonly visionRangeM: number; readonly visionFovDeg: number; @@ -94,13 +105,24 @@ export interface GroundAiConfig { }; readonly fireControl: { readonly maxEngageRangeM: number; + readonly closeRangeM: number; + readonly midRangeM: number; + readonly longRangeM: number; + readonly midSlowSpeedRatio: number; + readonly midSlowMaxMps: number; + readonly stopSpeedMaxMps: number; + readonly longRangeWindowSec: number; readonly baseAlignDeg: number; readonly closeHitRadiusM: number; readonly barrelSettleDegSec: number; + readonly closeSettleHoldSec: number; readonly settleHoldSec: number; readonly unstabilizedStopSpeedMps: number; readonly stabilizedCreepSpeedMps: number; readonly friendlyCorridorM: number; + readonly ballisticStepMaxM: number; + readonly ballisticSweepRadiusM: number; + readonly maxPreFireChecksPerTick: number; }; readonly diagnostics: { readonly telemetry: boolean; @@ -204,6 +226,15 @@ function collectConfigEntries(c: GroundAiConfig): readonly DasEntry[] { ['WTO_AI_NAV_UNSTICK_REV_SEC', 'float', c.navigation.unstickReverseSec], ['WTO_AI_NAV_TAC_REV_DIST_M', 'float', c.navigation.tacticalReverseDistM], ['WTO_AI_NAV_TAC_REV_MAX_SEC', 'float', c.navigation.tacticalReverseMaxSec], + ['WTO_AI_PERC_FOLIAGE_TRANS', 'float', c.perception.foliageTransparency], + ['WTO_AI_PERC_NEAR_SPOT_M', 'float', c.perception.nearSpotRangeM], + ['WTO_AI_PERC_FIRING_SPOT_M', 'float', c.perception.firingSpotRangeM], + ['WTO_AI_PERC_FAST_SPOT_SEC', 'float', c.perception.fastSpotSec], + ['WTO_AI_PERC_NORMAL_SPOT_SEC', 'float', c.perception.normalSpotSec], + ['WTO_AI_PERC_FAR_SPOT_SEC', 'float', c.perception.farSpotSec], + ['WTO_AI_PERC_DECAY_PER_SEC', 'float', c.perception.decayPerSec], + ['WTO_AI_PERC_FRONT_CONE_DEG', 'float', c.perception.frontConeHalfDeg], + ['WTO_AI_PERC_PERIPH_CLOSE_M', 'float', c.perception.peripheralCloseM], ['WTO_AI_TACTICS_VISION_RANGE_M', 'float', c.tactics.visionRangeM], ['WTO_AI_TACTICS_VISION_FOV_DEG', 'float', c.tactics.visionFovDeg], ['WTO_AI_TACTICS_PERIPHERAL_RANGE_M', 'float', c.tactics.peripheralRangeM], @@ -214,13 +245,24 @@ function collectConfigEntries(c: GroundAiConfig): readonly DasEntry[] { ['WTO_AI_TACTICS_STICKY_SEC', 'float', c.tactics.targetStickinessSec], ['WTO_AI_TACTICS_PEEK_COOLDOWN_SEC', 'float', c.tactics.peekCooldownSec], ['WTO_AI_FC_MAX_RANGE_M', 'float', c.fireControl.maxEngageRangeM], + ['WTO_AI_FC_CLOSE_RANGE_M', 'float', c.fireControl.closeRangeM], + ['WTO_AI_FC_MID_RANGE_M', 'float', c.fireControl.midRangeM], + ['WTO_AI_FC_LONG_RANGE_M', 'float', c.fireControl.longRangeM], + ['WTO_AI_FC_MID_SLOW_RATIO', 'float', c.fireControl.midSlowSpeedRatio], + ['WTO_AI_FC_MID_SLOW_MAX_MPS', 'float', c.fireControl.midSlowMaxMps], + ['WTO_AI_FC_STOP_SPEED_MAX_MPS', 'float', c.fireControl.stopSpeedMaxMps], + ['WTO_AI_FC_LONG_WINDOW_SEC', 'float', c.fireControl.longRangeWindowSec], ['WTO_AI_FC_BASE_ALIGN_DEG', 'float', c.fireControl.baseAlignDeg], ['WTO_AI_FC_CLOSE_HIT_RADIUS_M', 'float', c.fireControl.closeHitRadiusM], ['WTO_AI_FC_BARREL_SETTLE_DEG_SEC', 'float', c.fireControl.barrelSettleDegSec], + ['WTO_AI_FC_CLOSE_SETTLE_HOLD_SEC', 'float', c.fireControl.closeSettleHoldSec], ['WTO_AI_FC_SETTLE_HOLD_SEC', 'float', c.fireControl.settleHoldSec], ['WTO_AI_FC_UNSTAB_STOP_MPS', 'float', c.fireControl.unstabilizedStopSpeedMps], ['WTO_AI_FC_STAB_CREEP_MPS', 'float', c.fireControl.stabilizedCreepSpeedMps], ['WTO_AI_FC_FRIENDLY_CORRIDOR_M', 'float', c.fireControl.friendlyCorridorM], + ['WTO_AI_FC_BALLISTIC_STEP_M', 'float', c.fireControl.ballisticStepMaxM], + ['WTO_AI_FC_BALLISTIC_SWEEP_R_M', 'float', c.fireControl.ballisticSweepRadiusM], + ['WTO_AI_FC_MAX_CHECKS_PER_TICK', 'int', c.fireControl.maxPreFireChecksPerTick], ['WTO_AI_DIAG_TELEMETRY', 'bool', c.diagnostics.telemetry], ['WTO_AI_DIAG_INTERVAL_SEC', 'float', c.diagnostics.telemetryIntervalSec], ];