From 2d3287937fbe536dac8f5dafbdf53a572ebad4cb Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Fri, 4 Dec 2026 03:22:50 +0800 Subject: [PATCH] feat(launcher): add Bot parameters tuning page for ground AI and lineup weights Extend readLauncherTuning/writeLauncherTuning and launcher IPC schemas to read, validate, and atomically persist battle.botPoolLimitPerType and nested ground-ai.jsonc overrides (including mode, vehicle class lineupWeights, spawn loadout, and all advanced ground AI sections). Add a dedicated Bot parameters section under Tuning with collapsible groups, bilingual labels, cross-field validation, and per-section reset. Verified with root/launcher typecheck, electron-vite build, 904-key locale parity check, and temp-dir read/write/reset round-trip. --- .../src/renderer/src/i18n/locales/en.json | 217 ++++++++++++ .../src/renderer/src/i18n/locales/zh-CN.json | 217 ++++++++++++ .../src/pages/tuning/BotTuningPanel.tsx | 267 +++++++++++++++ .../renderer/src/pages/tuning/TuningPage.tsx | 41 ++- .../src/pages/tuning/bot-tuning-fields.ts | 316 ++++++++++++++++++ .../src/renderer/src/shell/navigation.ts | 2 +- .../src/renderer/src/styles/pages.css | 66 ++++ apps/launcher/src/shared/schemas/tuning.ts | 223 +++++++++++- apps/server/src/index.ts | 2 +- apps/server/src/tuning/ground-ai-tuning.ts | 17 +- apps/server/src/tuning/launcher-tuning.ts | 78 ++++- .../patcher/src/ground-ai/ground-ai-config.ts | 6 +- packages/patcher/src/index.ts | 2 + 13 files changed, 1432 insertions(+), 22 deletions(-) create mode 100644 apps/launcher/src/renderer/src/pages/tuning/BotTuningPanel.tsx create mode 100644 apps/launcher/src/renderer/src/pages/tuning/bot-tuning-fields.ts diff --git a/apps/launcher/src/renderer/src/i18n/locales/en.json b/apps/launcher/src/renderer/src/i18n/locales/en.json index 26b69ff..1185887 100644 --- a/apps/launcher/src/renderer/src/i18n/locales/en.json +++ b/apps/launcher/src/renderer/src/i18n/locales/en.json @@ -458,6 +458,7 @@ "sections": { "rewards": "Rewards", "battle": "Battles", + "bots": "Bot parameters", "newProfile": "New saves", "research": "Research" }, @@ -469,6 +470,7 @@ "smallTeamsMaxPlayers": "Small teams player limit", "brSpreadMrank": "Matchmaking BR range", "subModeChance": "Sub-mode probability", + "botPoolLimitPerType": "AI vehicle pool limit per type", "tankBotRespawns": "AI tank respawns", "airBotRespawns": "AI aircraft respawns", "strikeUcavSpawnScore": "Strike UCAV spawn points", @@ -483,6 +485,221 @@ "highestRank": "Highest rank", "treeOrder": "Research tree order" }, + "expandAll": "Expand all advanced", + "collapseAll": "Collapse advanced", + "botModeHint": "Custom ground AI is experimental and under active tuning. Switch to Stock AI if you run into issues. Changes take effect on the next launch.", + "botStockNotice": "Stock AI is active: custom ground AI scripts are not packed, and lineup weights / custom AI parameters below are ignored (respawn counts and pool limit still apply).", + "botModes": { + "full": "Full custom AI (default, experimental)", + "fire": "Perception & fire control only (stock movement)", + "drive": "Commander & driving only (stock aiming/firing)", + "stock": "Stock AI (disable custom ground AI)" + }, + "botDriveModes": { + "vehicle_phys": "Physics control (vehicle_phys)", + "movesys": "Stock move system (movesys)" + }, + "botSteer": { + "normal": "Normal (1)", + "inverted": "Inverted (-1)" + }, + "botGroups": { + "general": "General & mode", + "lineupWeights": "Ground AI vehicle class weights", + "loadout": "Ground AI spawn ammunition", + "commander": "Commander & role quotas", + "macro": "Macro capture & SPAA", + "stateMachine": "Hull state machine & repair", + "perception": "Visual perception & exposure", + "tactics": "Situational awareness & memory", + "estimation": "Lead estimation & aim bias", + "fireControl": "Fire control & fire gate", + "navigation": "Driving & navigation", + "crowd": "Spacing & crowd dispersal", + "terrain": "Terrain & ridge limits", + "runtime": "Tick cadence & diagnostics" + }, + "botGroupHints": { + "general": "AI mode selection, respawn limits and candidate pool size", + "lineupWeights": "Relative pick weights by tank class (active outside Stock mode)", + "loadout": "Ready-rack carry count and primary/secondary shell split", + "commander": "Role percentages by game mode, flank lanes, rally and recall", + "macro": "Opening split, cap occupancy, death zones and SPAA positioning", + "stateMachine": "Short halts, reload cover retreat, angling, repositioning and repair", + "perception": "Foliage transparency, exposure accumulation and decay", + "tactics": "Vision range, audio detection, radio sharing and target memory", + "estimation": "Sample-based velocity lead, exit watch and natural shot spread", + "fireControl": "Range bands, speed gates, barrel settle and ballistic safety", + "navigation": "Drive backend, corner braking, pivot turns and unstick reverse", + "crowd": "Personal space and ally cluster dispersal", + "terrain": "Climb/drop slope limits, water depth and ridge peek caps", + "runtime": "Script update intervals and telemetry logging" + }, + "botFields": { + "mode": "Ground AI mode", + "lineupWeights": { + "mediumTank": "Medium / MBT weight", + "heavyTank": "Heavy tank weight", + "tankDestroyer": "Tank destroyer weight", + "lightTank": "Light tank weight", + "spaa": "SPAA weight", + "other": "Other ground vehicles weight" + }, + "loadout": { + "lowReadyRackThreshold": "Low ready-rack top-up threshold", + "topUpAmmoCount": "Top-up target shell count", + "primaryAmmoPct": "Primary anti-armor shell share", + "secondaryMinRounds": "Minimum secondary HE / HEAT rounds", + "penetrationCompareDistM": "Penetration comparison distance" + }, + "commander": { + "rebalanceSec": "Role rebalance interval", + "roleHoldSec": "Minimum role hold duration", + "bttlAssaultPct": "Battle mode assault share", + "bttlFlankPct": "Battle mode flank share", + "bttlOverwatchPct": "Battle mode overwatch share", + "conqAssaultPct": "Conquest assault share", + "conqFlankPct": "Conquest flank share", + "conqHoldDefendPct": "Conquest hold defend share", + "conqHoldOverwatchPct": "Conquest hold overwatch share", + "domAssaultPct": "Domination assault share", + "domMaxDefendersPerCap": "Domination max defenders per cap", + "overwatchStandOffM": "Overwatch stand-off distance", + "flankStandOffM": "Flank stand-off distance", + "spaaFollowOffsetM": "SPAA follow offset behind push", + "flankMaxLengthRatio": "Flank lane max length ratio", + "flankMinSeparationM": "Flank lane min lateral separation", + "rallyProgressFrac": "Rally point progress fraction (0.1–0.75)", + "rallyWaitSec": "Rally max wait duration", + "rallyMinFrac": "Rally minimum ready fraction", + "rallyRadiusM": "Rally area radius", + "recallSafeHoldSec": "Recall safe hold before resuming attack" + }, + "macro": { + "openingSplitSec": "Opening lane split duration", + "capMaxInsiders": "Max friendly bots inside one cap", + "recaptureMinBots": "Min bots sent to recapture", + "recaptureMaxBots": "Max bots sent to recapture", + "capStickyBonusM": "Current cap distance hysteresis", + "deathZoneRadiusM": "Death zone radius", + "deathZoneTtlSec": "Death zone memory lifetime", + "deathZoneMinKills": "Min deaths to mark death zone", + "spaaRearOffsetM": "SPAA rear position offset", + "spaaRelocateSec": "SPAA relocate interval", + "enemySpawnAvoidM": "Enemy spawn avoidance distance" + }, + "stateMachine": { + "preaimAngleDeg": "Moving pre-aim angle threshold", + "shortHaltMaxSec": "Short halt max duration", + "shortHaltCooldownSec": "Short halt cooldown", + "turnLaunchSpeedMps": "Turn launch target speed", + "coverMinDistM": "Cover search min distance", + "coverMaxDistM": "Cover search max distance", + "coverRetreatBudgetSec": "Reload cover retreat max duration", + "reloadAdvanceAngleDeg": "Reload zigzag advance angle", + "hullAngleTriggerDeg": "Hull angling trigger angle", + "hullAngleTargetDeg": "Target hull angling offset", + "maxTotalHaltSec": "Max cumulative halt before reposition", + "stalemateMissShots": "Ineffective shots before reposition", + "stalemateNoShotHalts": "No-shot halts before reposition", + "repositionMinMoveM": "Min move to unlock short halt", + "repositionStepM": "Flank reposition step distance", + "repairSafeEnemyDistM": "Safe enemy distance for repair" + }, + "perception": { + "foliageTransparency": "Foliage transparency factor", + "nearSpotRangeM": "Close fast-spot distance", + "firingSpotRangeM": "Enemy firing reveal distance", + "fastSpotSec": "Fast exposure spot time", + "normalSpotSec": "Normal exposure spot time", + "farSpotSec": "Long-range exposure spot time", + "decayPerSec": "Exposure decay rate per second", + "frontConeHalfDeg": "Forward vision cone half-angle", + "peripheralCloseM": "Close peripheral spot distance" + }, + "tactics": { + "visionRangeM": "Max visual detection range", + "visionFovDeg": "Vision field of view", + "peripheralRangeM": "Peripheral detection range", + "engineAudioRangeM": "Engine audio hearing range", + "shotAudioRangeM": "Gunshot audio hearing range", + "radioShareRangeM": "Allied radio sharing range", + "memoryTtlSec": "Lost target memory duration", + "targetStickinessSec": "Target focus stickiness duration", + "peekCooldownSec": "Peek-and-shoot cooldown" + }, + "estimation": { + "watchMinSec": "Min exit watch duration", + "watchMaxSec": "Max exit watch duration", + "velSampleMinSpanSec": "Min velocity sample time span", + "velStableSpanSec": "Stable velocity convergence span", + "velJumpResetMps": "Sudden speed change reset threshold", + "baseAimSigmaM": "Base aim spread sigma", + "leadErrorFrac": "Lead estimation error fraction", + "maxBiasM": "Max per-opportunity aim bias" + }, + "fireControl": { + "maxEngageRangeM": "Max engagement range", + "closeRangeM": "Close range band threshold", + "midRangeM": "Mid range band threshold", + "longRangeM": "Long range band threshold", + "midSlowSpeedRatio": "Mid-range fire-on-move speed ratio", + "midSlowMaxMps": "Mid-range fire-on-move speed cap", + "stopSpeedMaxMps": "Stopped speed threshold", + "longRangeWindowSec": "Long-range clear LOS window", + "baseAlignDeg": "Base gun alignment tolerance", + "closeHitRadiusM": "Close-range hit acceptance radius", + "barrelSettleDegSec": "Max barrel angular rate to settle", + "closeSettleHoldSec": "Close-range settle hold time", + "settleHoldSec": "Standard settle hold time", + "unstabilizedStopSpeedMps": "Unstabilized stop speed cap", + "stabilizedCreepSpeedMps": "Stabilized creep fire speed cap", + "friendlyCorridorM": "Friendly fire corridor width", + "ballisticStepMaxM": "Ballistic occlusion step length", + "ballisticSweepRadiusM": "Ballistic sphere sweep radius", + "maxPreFireChecksPerTick": "Max detailed fire checks per tick" + }, + "navigation": { + "driveMode": "Vehicle drive backend", + "maxPhysBots": "Max physics-controlled bots", + "steerSign": "Steering input polarity", + "deadEchoSec": "Dead-echo detection timeout", + "controlTimeoutSec": "Native control release timeout", + "cornerBrakeAccel": "Corner braking deceleration", + "pivotAngleDeg": "Neutral pivot turn angle threshold", + "stuckWindowSec": "Stuck detection window", + "stuckMinMoveM": "Stuck min movement distance", + "unstickReverseSec": "Unstick reverse duration", + "tacticalReverseDistM": "Tactical reverse max distance", + "tacticalReverseMaxSec": "Tactical reverse max duration" + }, + "crowd": { + "personalSpaceM": "Personal spacing distance", + "clusterRadiusM": "Ally cluster detection radius", + "clusterMaxAllies": "Max allies before dispersing", + "disperseStepM": "Dispersal step distance", + "disperseHoldSec": "Dispersal order hold time" + }, + "terrain": { + "maxClimbSlopeDeg": "Max climbable slope angle", + "maxDropSlopeDeg": "Max drop slope angle", + "maxWaterDepthM": "Max fordable water depth", + "collisionMarginM": "Obstacle collision margin", + "crestLookaheadM": "Ridge crest lookahead distance", + "ridgeMaxDwellSec": "Max ridge dwell duration", + "ridgeMaxShots": "Max shots from ridge" + }, + "cadence": { + "maxBots": "Max scripted AI bots", + "macroTickSec": "Commander update interval", + "tacticsTickSec": "Tactics & fire control interval", + "navTickSec": "Navigation & driving interval" + }, + "diagnostics": { + "telemetry": "Enable AI telemetry logs", + "telemetryIntervalSec": "Telemetry logging interval" + } + }, "shared": "These settings apply to all saves in this client.", "nextLaunch": "Changes take effect the next time the local server starts.", "reset": "Restore defaults for this section", diff --git a/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json b/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json index d32c09a..42f9efd 100644 --- a/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json +++ b/apps/launcher/src/renderer/src/i18n/locales/zh-CN.json @@ -458,6 +458,7 @@ "sections": { "rewards": "收益", "battle": "对局", + "bots": "Bot 参数", "newProfile": "新存档", "research": "研发" }, @@ -469,6 +470,7 @@ "smallTeamsMaxPlayers": "小规模模式人数上限", "brSpreadMrank": "匹配范围", "subModeChance": "附加模式概率", + "botPoolLimitPerType": "每类载具 AI 候选池上限", "tankBotRespawns": "AI 坦克重生次数", "airBotRespawns": "AI 飞机重生次数", "strikeUcavSpawnScore": "打击无人机所需出生点数", @@ -483,6 +485,221 @@ "highestRank": "最高等级", "treeOrder": "研发树顺序" }, + "expandAll": "展开全部高级项", + "collapseAll": "折叠高级项", + "botModeHint": "新版陆战 AI 处于实验调优阶段;若遇到异常可切回「原版 AI」。修改会在下次启动游戏重建数据包时生效。", + "botStockNotice": "当前为「原版 AI」模式:不注入自定义陆战 AI 脚本,下方出车权重与自定义 AI 参数不会生效(重生次数与候选池上限仍生效)。", + "botModes": { + "full": "完整新版 AI(默认,实验性)", + "fire": "仅火控与感知(原版移动)", + "drive": "仅指挥与机动(原版瞄准开火)", + "stock": "原版 AI(停用自定义陆战 AI)" + }, + "botDriveModes": { + "vehicle_phys": "物理操控(vehicle_phys)", + "movesys": "原版移动系统(movesys)" + }, + "botSteer": { + "normal": "正向(1)", + "inverted": "反向(-1)" + }, + "botGroups": { + "general": "基础与模式", + "lineupWeights": "陆战 AI 出车权重", + "loadout": "陆战 AI 出生携弹", + "commander": "指挥层与分路配额", + "macro": "宏观占点与防空", + "stateMachine": "单车状态机与掩体维修", + "perception": "视觉感知与曝光", + "tactics": "态势感知与目标记忆", + "estimation": "目击测速与瞄准偏差", + "fireControl": "火控与开火许可", + "navigation": "机动与寻路控制", + "crowd": "编队间距与避让", + "terrain": "地形与棱线约束", + "runtime": "运行频率与诊断" + }, + "botGroupHints": { + "general": "AI 模式切换、重生次数与候选载具池", + "lineupWeights": "各类地面载具相对抽取权重(非原版模式生效)", + "loadout": "待发架携弹量与主/副弹种分配", + "commander": "各模式进攻 / 侧翼 / 架枪比例、集结与回防", + "macro": "开局分兵、占点人数、死亡区规避与防空站位", + "stateMachine": "短停预算、装填回缩、摆角、换位与受损维修", + "perception": "植被透光、曝光累计速度与衰减", + "tactics": "视距、听觉发现范围、电台共享与记忆时长", + "estimation": "本车目击测速、守出口时长与自然散布", + "fireControl": "距离分档、车速门槛、稳定等待与弹道防误伤", + "navigation": "底层驱动方式、转向刹车与脱困倒车", + "crowd": "友军安全间距与扎堆疏散", + "terrain": "爬坡 / 下坡角度、涉水深度与探头限制", + "runtime": "脚本刷新间隔与调试遥测日志" + }, + "botFields": { + "mode": "陆战 AI 模式", + "lineupWeights": { + "mediumTank": "中型坦克 / 主战坦克权重", + "heavyTank": "重型坦克权重", + "tankDestroyer": "坦克歼击车权重", + "lightTank": "轻型坦克权重", + "spaa": "自行防空车权重", + "other": "其他地面载具权重" + }, + "loadout": { + "lowReadyRackThreshold": "低待发架补弹阈值(发)", + "topUpAmmoCount": "补弹目标总数(发)", + "primaryAmmoPct": "主穿甲弹携带占比", + "secondaryMinRounds": "副高爆 / 破甲弹最少发数", + "penetrationCompareDistM": "弹种穿深对比距离" + }, + "commander": { + "rebalanceSec": "角色重分配周期", + "roleHoldSec": "角色最短保持时间", + "bttlAssaultPct": "坚守模式进攻占比", + "bttlFlankPct": "坚守模式侧翼占比", + "bttlOverwatchPct": "坚守模式架枪占比", + "conqAssaultPct": "征服模式进攻占比", + "conqFlankPct": "征服模式侧翼占比", + "conqHoldDefendPct": "征服持点防守占比", + "conqHoldOverwatchPct": "征服持点架枪占比", + "domAssaultPct": "制霸模式进攻占比", + "domMaxDefendersPerCap": "制霸单点最多守点车数", + "overwatchStandOffM": "架枪掩护距点距离", + "flankStandOffM": "侧翼包抄距点距离", + "spaaFollowOffsetM": "防空车跟随主攻偏移距离", + "flankMaxLengthRatio": "侧路最大绕行倍率", + "flankMinSeparationM": "侧路最小横向间距", + "rallyProgressFrac": "集结点推进比例(0.1–0.75)", + "rallyWaitSec": "集结最长等待时间", + "rallyMinFrac": "集结出发最低成队比例", + "rallyRadiusM": "集结点判定半径", + "recallSafeHoldSec": "点位安全后恢复进攻延迟" + }, + "macro": { + "openingSplitSec": "开局分兵持续时间", + "capMaxInsiders": "单占领圈内最多进入车数", + "recaptureMinBots": "抢点 / 回防最少抽调车数", + "recaptureMaxBots": "抢点 / 回防最多抽调车数", + "capStickyBonusM": "当前目标点距离粘性加成", + "deathZoneRadiusM": "高危死亡区半径", + "deathZoneTtlSec": "高危死亡区记忆时长", + "deathZoneMinKills": "触发死亡区最少阵亡数", + "spaaRearOffsetM": "防空车后方阵位距离", + "spaaRelocateSec": "防空车换位周期", + "enemySpawnAvoidM": "敌方出生点规避距离" + }, + "stateMachine": { + "preaimAngleDeg": "行进预瞄角度阈值", + "shortHaltMaxSec": "单次短停最长时间", + "shortHaltCooldownSec": "短停冷却时间", + "turnLaunchSpeedMps": "甩弯起步目标车速", + "coverMinDistM": "掩体搜索最小距离", + "coverMaxDistM": "掩体搜索最大距离", + "coverRetreatBudgetSec": "装填回缩掩体最长用时", + "reloadAdvanceAngleDeg": "装填折线跃进偏角", + "hullAngleTriggerDeg": "触发车体摆角阈值", + "hullAngleTargetDeg": "车体目标摆角", + "maxTotalHaltSec": "累计停留强制换位上限", + "stalemateMissShots": "无伤害连射触发换位发数", + "stalemateNoShotHalts": "未开火短停触发换位次数", + "repositionMinMoveM": "换位解锁短停最小位移", + "repositionStepM": "侧翼换位步进距离", + "repairSafeEnemyDistM": "维修安全敌距阈值" + }, + "perception": { + "foliageTransparency": "植被透光系数", + "nearSpotRangeM": "近距快速发现距离", + "firingSpotRangeM": "敌车开火暴露距离", + "fastSpotSec": "近距 / 开火曝光用时", + "normalSpotSec": "常规曝光用时", + "farSpotSec": "远距曝光用时", + "decayPerSec": "失联曝光每秒衰减率", + "frontConeHalfDeg": "前向主视锥半角", + "peripheralCloseM": "近身余光发现距离" + }, + "tactics": { + "visionRangeM": "最大视觉索敌距离", + "visionFovDeg": "视野总张角", + "peripheralRangeM": "外围余光索敌距离", + "engineAudioRangeM": "引擎声听觉距离", + "shotAudioRangeM": "炮声听觉距离", + "radioShareRangeM": "友军电台报点共享距离", + "memoryTtlSec": "目标失联记忆时长", + "targetStickinessSec": "目标锁定粘性时长", + "peekCooldownSec": "探头射击冷却时间" + }, + "estimation": { + "watchMinSec": "失联守出口最短时长", + "watchMaxSec": "失联守出口最长时长", + "velSampleMinSpanSec": "测速最小采样跨度", + "velStableSpanSec": "测速稳定收敛跨度", + "velJumpResetMps": "急刹 / 变速重置阈值", + "baseAimSigmaM": "基础瞄准散布标准差", + "leadErrorFrac": "提前量误差比例", + "maxBiasM": "单次射击最大偏移上限" + }, + "fireControl": { + "maxEngageRangeM": "最大交战开火距离", + "closeRangeM": "近距交战分界距离", + "midRangeM": "中距交战分界距离", + "longRangeM": "远距交战分界距离", + "midSlowSpeedRatio": "中距行进射击最高车速比", + "midSlowMaxMps": "中距行进射击最高车速", + "stopSpeedMaxMps": "停稳判定最高车速", + "longRangeWindowSec": "远距连续射界观察窗", + "baseAlignDeg": "主炮对准允许角误差", + "closeHitRadiusM": "近距命中判定半径", + "barrelSettleDegSec": "炮管稳定最大角速度", + "closeSettleHoldSec": "近距稳定保持时间", + "settleHoldSec": "常规稳定保持时间", + "unstabilizedStopSpeedMps": "无稳定器停稳车速上限", + "stabilizedCreepSpeedMps": "带稳定器慢速射击上限", + "friendlyCorridorM": "友军弹道禁射走廊宽度", + "ballisticStepMaxM": "弹道硬遮挡检测步长", + "ballisticSweepRadiusM": "弹道扫掠半径", + "maxPreFireChecksPerTick": "每帧精查开火预算上限" + }, + "navigation": { + "driveMode": "车体驱动模式", + "maxPhysBots": "物理接管最大 AI 车数", + "steerSign": "转向输入方向", + "deadEchoSec": "无响应回声判定时长", + "controlTimeoutSec": "原生控制超时归还时长", + "cornerBrakeAccel": "弯道减速制动强度", + "pivotAngleDeg": "原地中性转向角度阈值", + "stuckWindowSec": "卡死检测窗口时长", + "stuckMinMoveM": "卡死判定最小位移", + "unstickReverseSec": "脱困倒车持续时长", + "tacticalReverseDistM": "战术倒车最大距离", + "tacticalReverseMaxSec": "战术倒车最长时长" + }, + "crowd": { + "personalSpaceM": "单车安全个人空间", + "clusterRadiusM": "扎堆检测半径", + "clusterMaxAllies": "扎堆允许最多友车数", + "disperseStepM": "疏散移动步距", + "disperseHoldSec": "疏散指令保持时长" + }, + "terrain": { + "maxClimbSlopeDeg": "最大允许爬坡角度", + "maxDropSlopeDeg": "最大允许下坡角度", + "maxWaterDepthM": "最大允许涉水深度", + "collisionMarginM": "障碍物碰撞安全余量", + "crestLookaheadM": "山脊棱线前瞻距离", + "ridgeMaxDwellSec": "棱线最长停留时长", + "ridgeMaxShots": "棱线最多射击发数" + }, + "cadence": { + "maxBots": "脚本托管最大 AI 车数", + "macroTickSec": "指挥层刷新间隔", + "tacticsTickSec": "战术与火控刷新间隔", + "navTickSec": "寻路与驾驶刷新间隔" + }, + "diagnostics": { + "telemetry": "输出 AI 诊断遥测日志", + "telemetryIntervalSec": "遥测日志输出间隔" + } + }, "shared": "这些数值适用于此客户端的全部存档。", "nextLaunch": "更改将在下次启动本地服务器时生效。", "reset": "恢复本页默认值", diff --git a/apps/launcher/src/renderer/src/pages/tuning/BotTuningPanel.tsx b/apps/launcher/src/renderer/src/pages/tuning/BotTuningPanel.tsx new file mode 100644 index 0000000..371a91f --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/tuning/BotTuningPanel.tsx @@ -0,0 +1,267 @@ +import { useState, type FormEvent, type ReactNode } from 'react'; +import { useTranslation } from 'react-i18next'; +import { + GROUND_AI_DRIVE_MODES, + GROUND_AI_MODES, + TuningPatchSchema, + type GroundAiTuningValues, + type TuningPatch, + type TuningView, +} from '@shared/schemas/tuning.ts'; +import { Row } from '../../components/Row.tsx'; +import { + ALL_BOT_FIELDS, + BOT_TUNING_GROUPS, + readBotFieldValue, + type BotFieldSpec, +} from './bot-tuning-fields.ts'; + +type DraftMap = Record; + +interface Props { + readonly data: TuningView; + readonly saving: boolean; + readonly onSave: (patch: TuningPatch) => Promise; +} + +function toInputValue(value: string | number | boolean): string | boolean { + return typeof value === 'boolean' ? value : String(value); +} + +function mergeSection>( + base: T, + patch: { readonly [K in keyof T]?: T[K] | undefined } | undefined, +): T { + if (!patch) return base; + const next: Record = { ...base }; + for (const [key, value] of Object.entries(patch)) { + if (value !== undefined) next[key] = value; + } + return next as T; +} + +function hasValidCrossFieldRules(effective: GroundAiTuningValues, patch: TuningPatch['groundAi']): boolean { + if (!patch) return true; + const cmd = mergeSection(effective.commander, patch.commander); + if (cmd.bttlAssaultPct + cmd.bttlFlankPct + cmd.bttlOverwatchPct > 100) return false; + if (cmd.conqAssaultPct + cmd.conqFlankPct > 100) return false; + if (cmd.conqHoldDefendPct + cmd.conqHoldOverwatchPct > 100) return false; + const macro = mergeSection(effective.macro, patch.macro); + if (macro.recaptureMaxBots < macro.recaptureMinBots) return false; + const sm = mergeSection(effective.stateMachine, patch.stateMachine); + if (sm.coverMaxDistM <= sm.coverMinDistM) return false; + const est = mergeSection(effective.estimation, patch.estimation); + if (est.watchMaxSec < est.watchMinSec || est.velStableSpanSec <= est.velSampleMinSpanSec) return false; + const fc = mergeSection(effective.fireControl, patch.fireControl); + if (fc.midRangeM <= fc.closeRangeM || fc.longRangeM <= fc.midRangeM) return false; + return true; +} + +export function BotTuningPanel({ data, saving, onSave }: Props) { + const { t, i18n } = useTranslation(); + const [draft, setDraft] = useState({}); + const [message, setMessage] = useState<'invalid' | 'saved' | null>(null); + const [openGroups, setOpenGroups] = useState>(() => + Object.fromEntries(BOT_TUNING_GROUPS.map((group) => [group.id, group.defaultOpen])), + ); + + const format = new Intl.NumberFormat(i18n.language); + const activeMode = String(draft['groundAi.mode'] ?? data.effective.groundAi.mode); + const allOpen = BOT_TUNING_GROUPS.every((group) => openGroups[group.id]); + + const set = (id: string, value: string | boolean): void => { + setMessage(null); + setDraft((previous) => ({ ...previous, [id]: value })); + }; + + const toggleAllGroups = (): void => { + const nextState = !allOpen; + setOpenGroups(Object.fromEntries(BOT_TUNING_GROUPS.map((group) => [group.id, nextState]))); + }; + + const reset = (): void => { + setMessage(null); + setDraft(Object.fromEntries( + ALL_BOT_FIELDS.map((spec) => [spec.id, toInputValue(readBotFieldValue(data.defaults, spec))]), + )); + }; + + const fieldLabel = (spec: BotFieldSpec): string => { + if (spec.kind === 'flatInt') return t(`tuning.fields.${spec.id}`); + if (spec.kind === 'groundAiMode') return t('tuning.botFields.mode'); + return t(`tuning.botFields.${spec.section}.${spec.field}`); + }; + + const defaultLabel = (spec: BotFieldSpec): string => { + const value = readBotFieldValue(data.defaults, spec); + if (spec.kind === 'groundAiMode') return t(`tuning.botModes.${value}`); + if (spec.kind === 'driveMode') return t(`tuning.botDriveModes.${value}`); + if (spec.kind === 'steerSign') return value === 1 ? t('tuning.botSteer.normal') : t('tuning.botSteer.inverted'); + if (typeof value === 'boolean') return t(value ? 'tuning.on' : 'tuning.off'); + const formatted = format.format(Number(value)); + const unit = 'unit' in spec && spec.unit ? ` ${spec.unit}` : ''; + return `${formatted}${unit}`; + }; + + const renderEditor = (spec: BotFieldSpec): ReactNode => { + const active = draft[spec.id] ?? toInputValue(readBotFieldValue(data.effective, spec)); + const label = fieldLabel(spec); + + if (spec.kind === 'bool') { + return ( + set(spec.id, event.target.checked)} + /> + ); + } + if (spec.kind === 'groundAiMode') { + return ( + + ); + } + if (spec.kind === 'driveMode') { + return ( + + ); + } + if (spec.kind === 'steerSign') { + return ( + + ); + } + const isInt = spec.kind === 'int' || spec.kind === 'flatInt'; + const unit = 'unit' in spec ? spec.unit : undefined; + return ( +
+ set(spec.id, event.target.value)} + /> + {unit && {unit}} +
+ ); + }; + + const submit = (event: FormEvent): void => { + event.preventDefault(); + const rawPatch: Record = {}; + const groundAiPatch: Record = {}; + + for (const spec of ALL_BOT_FIELDS) { + if (!(spec.id in draft)) continue; + const raw = draft[spec.id]; + if (spec.kind === 'flatInt') { + rawPatch[spec.id] = raw === '' ? NaN : Number(raw); + } else if (spec.kind === 'groundAiMode') { + groundAiPatch['mode'] = raw; + } else { + const parsed = spec.kind === 'bool' || spec.kind === 'driveMode' + ? raw + : (raw === '' ? NaN : Number(raw)); + const sectionObj = (groundAiPatch[spec.section] as Record | undefined) ?? {}; + sectionObj[spec.field] = parsed; + groundAiPatch[spec.section] = sectionObj; + } + } + if (Object.keys(groundAiPatch).length > 0) rawPatch['groundAi'] = groundAiPatch; + + const result = TuningPatchSchema.safeParse(rawPatch); + if (!result.success || !hasValidCrossFieldRules(data.effective.groundAi, result.data.groundAi)) { + setMessage('invalid'); + return; + } + setMessage(null); + onSave(result.data).then(() => { + setDraft({}); + setMessage('saved'); + }).catch(() => undefined); + }; + + return ( +
+
+

{t('tuning.botModeHint')}

+ +
+ {activeMode === 'stock' && ( +

{t('tuning.botStockNotice')}

+ )} + {BOT_TUNING_GROUPS.map((group) => ( +
{ + const isOpen = event.currentTarget.open; + setOpenGroups((prev) => (prev[group.id] === isOpen ? prev : { ...prev, [group.id]: isOpen })); + }} + > + + {t(`tuning.botGroups.${group.id}`)} + {t(`tuning.botGroupHints.${group.id}`)} + +
+ {group.fields.map((spec) => ( + + {renderEditor(spec)} + + ))} +
+
+ ))} +
+ + +
+ {message &&

{t(`tuning.${message}`)}

} +
+ ); +} diff --git a/apps/launcher/src/renderer/src/pages/tuning/TuningPage.tsx b/apps/launcher/src/renderer/src/pages/tuning/TuningPage.tsx index aa32d0e..22ae10b 100644 --- a/apps/launcher/src/renderer/src/pages/tuning/TuningPage.tsx +++ b/apps/launcher/src/renderer/src/pages/tuning/TuningPage.tsx @@ -1,20 +1,22 @@ import { useEffect, useState, type FormEvent, type ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; import type { InstallRecord } from '@shared/schemas/install.ts'; -import { AUTO_TARGET_PICKS, TuningPatchSchema, type TuningValues, type TuningView } from '@shared/schemas/tuning.ts'; +import { AUTO_TARGET_PICKS, TuningPatchSchema, type TuningPatch, type TuningValues, type TuningView } from '@shared/schemas/tuning.ts'; import { Row } from '../../components/Row.tsx'; import { Sheet } from '../../components/Sheet.tsx'; import { ipcInvoke } from '../../ipc.ts'; import type { TuningSection } from '../../shell/navigation.ts'; +import { BotTuningPanel } from './BotTuningPanel.tsx'; -type Field = keyof TuningValues; +type SimpleSection = Exclude; +type Field = Exclude; type Draft = Partial>; const fields = { rewards: ['rewardMultiplierSilverLions', 'rewardMultiplierResearchPoints', 'friendlyKillPenaltyMul'], - battle: ['maxPlayers', 'smallTeamsMaxPlayers', 'brSpreadMrank', 'subModeChance', 'tankBotRespawns', 'airBotRespawns', 'strikeUcavSpawnScore', 'nuclearEscalationStrategicBombers'], + battle: ['maxPlayers', 'smallTeamsMaxPlayers', 'brSpreadMrank', 'subModeChance', 'strikeUcavSpawnScore', 'nuclearEscalationStrategicBombers'], newProfile: ['silverLions', 'goldenEagles'], research: ['preferLineSuccessor', 'autoTargetPick'], -} as const satisfies Record; +} as const satisfies Record; interface Props { readonly copy: InstallRecord; @@ -34,7 +36,6 @@ export function TuningPage({ copy, section, onError }: Props) { const [saving, setSaving] = useState(false); const [message, setMessage] = useState<'invalid' | 'saved' | null>(null); const title = t(`tuning.sections.${section}`); - const sectionFields: readonly Field[] = fields[section]; useEffect(() => { let mounted = true; @@ -46,6 +47,30 @@ export function TuningPage({ copy, section, onError }: Props) { if (!data) return

{t('tuning.loading')}

; const loaded = data; + + const savePatch = async (patch: TuningPatch): Promise => { + setSaving(true); + try { + const next = await ipcInvoke('tuning:update', { copyId: copy.id, patch }); + setData(next); + } catch (error) { + onError(error); + throw error; + } finally { + setSaving(false); + } + }; + + if (section === 'bots') { + return ( + +

{t('tuning.shared')}

+ +
+ ); + } + + const sectionFields: readonly Field[] = fields[section]; const format = new Intl.NumberFormat(i18n.language); const set = (field: Field, value: string | boolean): void => { setMessage(null); @@ -110,13 +135,11 @@ export function TuningPage({ copy, section, onError }: Props) { setMessage('invalid'); return; } - setSaving(true); setMessage(null); - ipcInvoke('tuning:update', { copyId: copy.id, patch: result.data }).then((next) => { - setData(next); + savePatch(result.data).then(() => { setDraft({}); setMessage('saved'); - }).catch(onError).finally(() => setSaving(false)); + }).catch(() => undefined); }; return ( diff --git a/apps/launcher/src/renderer/src/pages/tuning/bot-tuning-fields.ts b/apps/launcher/src/renderer/src/pages/tuning/bot-tuning-fields.ts new file mode 100644 index 0000000..b163615 --- /dev/null +++ b/apps/launcher/src/renderer/src/pages/tuning/bot-tuning-fields.ts @@ -0,0 +1,316 @@ +import type { GroundAiTuningValues, TuningValues } from '@shared/schemas/tuning.ts'; + +export type FlatBotFieldKey = 'tankBotRespawns' | 'airBotRespawns' | 'botPoolLimitPerType'; +export type GroundAiSectionKey = Exclude; + +export type BotFieldSpec = + | { + readonly id: FlatBotFieldKey; + readonly kind: 'flatInt'; + readonly min: number; + readonly max: number; + readonly unit?: string; + } + | { + readonly id: 'groundAi.mode'; + readonly kind: 'groundAiMode'; + } + | { + readonly id: `groundAi.${GroundAiSectionKey}.${string}`; + readonly section: GroundAiSectionKey; + readonly field: string; + readonly kind: 'int' | 'number' | 'bool' | 'driveMode' | 'steerSign'; + readonly min?: number; + readonly max?: number; + readonly unit?: string; + }; + +export interface BotTuningGroup { + readonly id: string; + readonly defaultOpen: boolean; + readonly customOnly?: boolean; + readonly fields: readonly BotFieldSpec[]; +} + +function num( + section: GroundAiSectionKey, + field: string, + min: number, + max: number, + unit?: string, +): BotFieldSpec { + return { + id: `groundAi.${section}.${field}`, + section, + field, + kind: 'number', + min, + max, + ...(unit ? { unit } : {}), + }; +} + +function int( + section: GroundAiSectionKey, + field: string, + min: number, + max: number, + unit?: string, +): BotFieldSpec { + return { + id: `groundAi.${section}.${field}`, + section, + field, + kind: 'int', + min, + max, + ...(unit ? { unit } : {}), + }; +} + +export const BOT_TUNING_GROUPS: readonly BotTuningGroup[] = [ + { + id: 'general', + defaultOpen: true, + fields: [ + { id: 'groundAi.mode', kind: 'groundAiMode' }, + { id: 'tankBotRespawns', kind: 'flatInt', min: 1, max: 10 }, + { id: 'airBotRespawns', kind: 'flatInt', min: 1, max: 10 }, + { id: 'botPoolLimitPerType', kind: 'flatInt', min: 4, max: 200 }, + ], + }, + { + id: 'lineupWeights', + defaultOpen: true, + customOnly: true, + fields: [ + num('lineupWeights', 'mediumTank', 0.01, 10), + num('lineupWeights', 'heavyTank', 0.01, 10), + num('lineupWeights', 'tankDestroyer', 0.01, 10), + num('lineupWeights', 'lightTank', 0.01, 10), + num('lineupWeights', 'spaa', 0.01, 10), + num('lineupWeights', 'other', 0.01, 10), + ], + }, + { + id: 'loadout', + defaultOpen: true, + customOnly: true, + fields: [ + int('loadout', 'lowReadyRackThreshold', 1, 60), + int('loadout', 'topUpAmmoCount', 4, 80), + int('loadout', 'primaryAmmoPct', 50, 100, '%'), + int('loadout', 'secondaryMinRounds', 0, 20), + int('loadout', 'penetrationCompareDistM', 100, 2000, 'm'), + ], + }, + { + id: 'commander', + defaultOpen: false, + customOnly: true, + fields: [ + num('commander', 'rebalanceSec', 1, 30, 's'), + num('commander', 'roleHoldSec', 0, 120, 's'), + int('commander', 'bttlAssaultPct', 0, 100, '%'), + int('commander', 'bttlFlankPct', 0, 100, '%'), + int('commander', 'bttlOverwatchPct', 0, 100, '%'), + int('commander', 'conqAssaultPct', 0, 100, '%'), + int('commander', 'conqFlankPct', 0, 100, '%'), + int('commander', 'conqHoldDefendPct', 0, 100, '%'), + int('commander', 'conqHoldOverwatchPct', 0, 100, '%'), + int('commander', 'domAssaultPct', 0, 100, '%'), + int('commander', 'domMaxDefendersPerCap', 0, 4), + num('commander', 'overwatchStandOffM', 25, 350, 'm'), + num('commander', 'flankStandOffM', 25, 300, 'm'), + num('commander', 'spaaFollowOffsetM', 40, 500, 'm'), + num('commander', 'flankMaxLengthRatio', 1.05, 3), + num('commander', 'flankMinSeparationM', 15, 200, 'm'), + num('commander', 'rallyProgressFrac', 0.1, 0.75), + num('commander', 'rallyWaitSec', 3, 60, 's'), + num('commander', 'rallyMinFrac', 0.25, 1), + num('commander', 'rallyRadiusM', 15, 140, 'm'), + num('commander', 'recallSafeHoldSec', 3, 60, 's'), + ], + }, + { + id: 'macro', + defaultOpen: false, + customOnly: true, + fields: [ + num('macro', 'openingSplitSec', 0, 180, 's'), + int('macro', 'capMaxInsiders', 1, 8), + int('macro', 'recaptureMinBots', 1, 8), + int('macro', 'recaptureMaxBots', 1, 12), + num('macro', 'capStickyBonusM', 0, 800, 'm'), + num('macro', 'deathZoneRadiusM', 10, 250, 'm'), + num('macro', 'deathZoneTtlSec', 5, 300, 's'), + int('macro', 'deathZoneMinKills', 1, 16), + num('macro', 'spaaRearOffsetM', 40, 600, 'm'), + num('macro', 'spaaRelocateSec', 5, 180, 's'), + num('macro', 'enemySpawnAvoidM', 60, 600, 'm'), + ], + }, + { + id: 'stateMachine', + defaultOpen: false, + customOnly: true, + fields: [ + num('stateMachine', 'preaimAngleDeg', 1, 30, '°'), + num('stateMachine', 'shortHaltMaxSec', 0.5, 12, 's'), + num('stateMachine', 'shortHaltCooldownSec', 0.5, 20, 's'), + num('stateMachine', 'turnLaunchSpeedMps', 0.5, 6, 'm/s'), + num('stateMachine', 'coverMinDistM', 2, 30, 'm'), + num('stateMachine', 'coverMaxDistM', 6, 80, 'm'), + num('stateMachine', 'coverRetreatBudgetSec', 1.5, 20, 's'), + num('stateMachine', 'reloadAdvanceAngleDeg', 0, 45, '°'), + num('stateMachine', 'hullAngleTriggerDeg', 15, 75, '°'), + num('stateMachine', 'hullAngleTargetDeg', 0, 35, '°'), + num('stateMachine', 'maxTotalHaltSec', 3, 40, 's'), + int('stateMachine', 'stalemateMissShots', 1, 8), + int('stateMachine', 'stalemateNoShotHalts', 1, 6), + num('stateMachine', 'repositionMinMoveM', 5, 80, 'm'), + num('stateMachine', 'repositionStepM', 15, 120, 'm'), + num('stateMachine', 'repairSafeEnemyDistM', 30, 400, 'm'), + ], + }, + { + id: 'perception', + defaultOpen: false, + customOnly: true, + fields: [ + num('perception', 'foliageTransparency', 0.001, 1), + num('perception', 'nearSpotRangeM', 20, 250, 'm'), + num('perception', 'firingSpotRangeM', 150, 1500, 'm'), + num('perception', 'fastSpotSec', 0.05, 1.5, 's'), + num('perception', 'normalSpotSec', 0.1, 3, 's'), + num('perception', 'farSpotSec', 0.3, 6, 's'), + num('perception', 'decayPerSec', 0.2, 10), + num('perception', 'frontConeHalfDeg', 10, 90, '°'), + num('perception', 'peripheralCloseM', 30, 250, 'm'), + ], + }, + { + id: 'tactics', + defaultOpen: false, + customOnly: true, + fields: [ + num('tactics', 'visionRangeM', 200, 3500, 'm'), + num('tactics', 'visionFovDeg', 40, 180, '°'), + num('tactics', 'peripheralRangeM', 30, 800, 'm'), + num('tactics', 'engineAudioRangeM', 10, 250, 'm'), + num('tactics', 'shotAudioRangeM', 50, 1200, 'm'), + num('tactics', 'radioShareRangeM', 50, 1500, 'm'), + num('tactics', 'memoryTtlSec', 1, 45, 's'), + num('tactics', 'targetStickinessSec', 0.5, 20, 's'), + num('tactics', 'peekCooldownSec', 1, 30, 's'), + ], + }, + { + id: 'estimation', + defaultOpen: false, + customOnly: true, + fields: [ + num('estimation', 'watchMinSec', 0.5, 10, 's'), + num('estimation', 'watchMaxSec', 1, 15, 's'), + num('estimation', 'velSampleMinSpanSec', 0.05, 2, 's'), + num('estimation', 'velStableSpanSec', 0.2, 6, 's'), + num('estimation', 'velJumpResetMps', 1, 20, 'm/s'), + num('estimation', 'baseAimSigmaM', 0, 2, 'm'), + num('estimation', 'leadErrorFrac', 0, 1), + num('estimation', 'maxBiasM', 0, 6, 'm'), + ], + }, + { + id: 'fireControl', + defaultOpen: false, + customOnly: true, + fields: [ + num('fireControl', 'maxEngageRangeM', 150, 3000, 'm'), + num('fireControl', 'closeRangeM', 30, 250, 'm'), + num('fireControl', 'midRangeM', 100, 600, 'm'), + num('fireControl', 'longRangeM', 300, 1500, 'm'), + num('fireControl', 'midSlowSpeedRatio', 0.1, 1), + num('fireControl', 'midSlowMaxMps', 1, 15, 'm/s'), + num('fireControl', 'stopSpeedMaxMps', 0.1, 2, 'm/s'), + num('fireControl', 'longRangeWindowSec', 1, 15, 's'), + num('fireControl', 'baseAlignDeg', 0.1, 3, '°'), + num('fireControl', 'closeHitRadiusM', 0.25, 2.2, 'm'), + num('fireControl', 'barrelSettleDegSec', 0.2, 12, '°/s'), + num('fireControl', 'closeSettleHoldSec', 0.02, 0.5, 's'), + num('fireControl', 'settleHoldSec', 0.05, 1.5, 's'), + num('fireControl', 'unstabilizedStopSpeedMps', 0.1, 3, 'm/s'), + num('fireControl', 'stabilizedCreepSpeedMps', 1.5, 15, 'm/s'), + num('fireControl', 'friendlyCorridorM', 1, 10, 'm'), + num('fireControl', 'ballisticStepMaxM', 5, 80, 'm'), + num('fireControl', 'ballisticSweepRadiusM', 0.02, 0.5, 'm'), + int('fireControl', 'maxPreFireChecksPerTick', 1, 16), + ], + }, + { + id: 'navigation', + defaultOpen: false, + customOnly: true, + fields: [ + { id: 'groundAi.navigation.driveMode', section: 'navigation', field: 'driveMode', kind: 'driveMode' }, + int('navigation', 'maxPhysBots', 0, 64), + { id: 'groundAi.navigation.steerSign', section: 'navigation', field: 'steerSign', kind: 'steerSign' }, + num('navigation', 'deadEchoSec', 0.3, 10, 's'), + num('navigation', 'controlTimeoutSec', 0.3, 10, 's'), + num('navigation', 'cornerBrakeAccel', 0.5, 8), + num('navigation', 'pivotAngleDeg', 25, 150, '°'), + num('navigation', 'stuckWindowSec', 1, 15, 's'), + num('navigation', 'stuckMinMoveM', 0.5, 10, 'm'), + num('navigation', 'unstickReverseSec', 0.8, 10, 's'), + num('navigation', 'tacticalReverseDistM', 10, 90, 'm'), + num('navigation', 'tacticalReverseMaxSec', 2, 25, 's'), + ], + }, + { + id: 'crowd', + defaultOpen: false, + customOnly: true, + fields: [ + num('crowd', 'personalSpaceM', 6, 40, 'm'), + num('crowd', 'clusterRadiusM', 12, 80, 'm'), + int('crowd', 'clusterMaxAllies', 1, 10), + num('crowd', 'disperseStepM', 8, 65, 'm'), + num('crowd', 'disperseHoldSec', 1, 15, 's'), + ], + }, + { + id: 'terrain', + defaultOpen: false, + customOnly: true, + fields: [ + num('terrain', 'maxClimbSlopeDeg', 10, 42, '°'), + num('terrain', 'maxDropSlopeDeg', 8, 40, '°'), + num('terrain', 'maxWaterDepthM', 0.2, 2.5, 'm'), + num('terrain', 'collisionMarginM', 0.05, 2, 'm'), + num('terrain', 'crestLookaheadM', 8, 80, 'm'), + num('terrain', 'ridgeMaxDwellSec', 2, 60, 's'), + int('terrain', 'ridgeMaxShots', 1, 10), + ], + }, + { + id: 'runtime', + defaultOpen: false, + customOnly: true, + fields: [ + int('cadence', 'maxBots', 1, 64), + num('cadence', 'macroTickSec', 0.1, 5, 's'), + num('cadence', 'tacticsTickSec', 0.05, 2, 's'), + num('cadence', 'navTickSec', 0.05, 2, 's'), + { id: 'groundAi.diagnostics.telemetry', section: 'diagnostics', field: 'telemetry', kind: 'bool' }, + num('diagnostics', 'telemetryIntervalSec', 0.5, 60, 's'), + ], + }, +]; + +export const ALL_BOT_FIELDS: readonly BotFieldSpec[] = BOT_TUNING_GROUPS.flatMap((group) => group.fields); + +export function readBotFieldValue(values: TuningValues, spec: BotFieldSpec): string | number | boolean { + if (spec.kind === 'flatInt') return values[spec.id]; + if (spec.kind === 'groundAiMode') return values.groundAi.mode; + const section = values.groundAi[spec.section] as Record; + return section[spec.field]!; +} diff --git a/apps/launcher/src/renderer/src/shell/navigation.ts b/apps/launcher/src/renderer/src/shell/navigation.ts index e435cbe..d7b8556 100644 --- a/apps/launcher/src/renderer/src/shell/navigation.ts +++ b/apps/launcher/src/renderer/src/shell/navigation.ts @@ -8,7 +8,7 @@ export type PageId = (typeof PAGES)[number]; export const SAVE_SECTIONS = ['list', 'overview', 'battles', 'vehicles', 'official', 'backup'] as const; export type SaveSection = (typeof SAVE_SECTIONS)[number]; -export const TUNING_SECTIONS = ['rewards', 'battle', 'newProfile', 'research'] as const; +export const TUNING_SECTIONS = ['rewards', 'battle', 'bots', 'newProfile', 'research'] as const; export type TuningSection = (typeof TUNING_SECTIONS)[number]; export const MODS_SECTIONS = ['list', 'presets'] as const; diff --git a/apps/launcher/src/renderer/src/styles/pages.css b/apps/launcher/src/renderer/src/styles/pages.css index 4a88bf8..00d4dd0 100644 --- a/apps/launcher/src/renderer/src/styles/pages.css +++ b/apps/launcher/src/renderer/src/styles/pages.css @@ -832,3 +832,69 @@ font-size: 12px; word-break: break-all; } + +/* ===== Tuning: Bot parameters ===== */ +.tuning-toolbar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + margin: 8px 0 12px; + flex-wrap: wrap; +} + +.tuning-toolbar .small { + margin: 0; +} + +.tuning-group { + margin-bottom: 10px; + border: 1px solid var(--line); + border-radius: var(--radius); + background: rgba(12, 16, 19, 0.56); +} + +.tuning-group-summary { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 12px; + padding: 10px 14px; + cursor: pointer; + list-style: none; + font: 600 14px var(--font-display); + letter-spacing: 0.04em; + color: var(--white); +} + +.tuning-group-summary::-webkit-details-marker { + display: none; +} + +.tuning-group-summary::before { + content: '▸'; + display: inline-block; + margin-right: 8px; + color: var(--text-dim); + transition: transform 120ms ease; +} + +.tuning-group[open] > .tuning-group-summary::before { + transform: rotate(90deg); +} + +.tuning-group-summary small { + font: 400 12px var(--font-ui); + letter-spacing: 0; + color: var(--text-dim); + margin-left: auto; +} + +.tuning-group-body { + padding: 0 14px 8px; + border-top: 1px solid var(--line); +} + +.tuning-actions { + margin-top: 14px; +} diff --git a/apps/launcher/src/shared/schemas/tuning.ts b/apps/launcher/src/shared/schemas/tuning.ts index 6eb1ad4..514846f 100644 --- a/apps/launcher/src/shared/schemas/tuning.ts +++ b/apps/launcher/src/shared/schemas/tuning.ts @@ -1,6 +1,221 @@ import { z } from 'zod'; export const AUTO_TARGET_PICKS = ['lowestRank', 'highestRank', 'treeOrder'] as const; +export const GROUND_AI_MODES = ['stock', 'fire', 'drive', 'full'] as const; +export const GROUND_AI_DRIVE_MODES = ['vehicle_phys', 'movesys'] as const; + +const GroundAiLoadoutSchema = z.object({ + lowReadyRackThreshold: z.number().int().min(1).max(60), + topUpAmmoCount: z.number().int().min(4).max(80), + primaryAmmoPct: z.number().int().min(50).max(100), + secondaryMinRounds: z.number().int().min(0).max(20), + penetrationCompareDistM: z.number().int().min(100).max(2000), +}); + +const GroundAiLineupWeightsSchema = z.object({ + spaa: z.number().min(0.01).max(10), + lightTank: z.number().min(0.01).max(10), + tankDestroyer: z.number().min(0.01).max(10), + heavyTank: z.number().min(0.01).max(10), + mediumTank: z.number().min(0.01).max(10), + other: z.number().min(0.01).max(10), +}); + +const GroundAiCadenceSchema = z.object({ + maxBots: z.number().int().min(1).max(64), + macroTickSec: z.number().min(0.1).max(5), + tacticsTickSec: z.number().min(0.05).max(2), + navTickSec: z.number().min(0.05).max(2), +}); + +const GroundAiCommanderSchema = z.object({ + rebalanceSec: z.number().min(1).max(30), + roleHoldSec: z.number().min(0).max(120), + bttlAssaultPct: z.number().int().min(0).max(100), + bttlFlankPct: z.number().int().min(0).max(100), + bttlOverwatchPct: z.number().int().min(0).max(100), + conqAssaultPct: z.number().int().min(0).max(100), + conqFlankPct: z.number().int().min(0).max(100), + conqHoldDefendPct: z.number().int().min(0).max(100), + conqHoldOverwatchPct: z.number().int().min(0).max(100), + domAssaultPct: z.number().int().min(0).max(100), + domMaxDefendersPerCap: z.number().int().min(0).max(4), + overwatchStandOffM: z.number().min(25).max(350), + flankStandOffM: z.number().min(25).max(300), + spaaFollowOffsetM: z.number().min(40).max(500), + flankMaxLengthRatio: z.number().min(1.05).max(3), + flankMinSeparationM: z.number().min(15).max(200), + rallyProgressFrac: z.number().min(0.1).max(0.75), + rallyWaitSec: z.number().min(3).max(60), + rallyMinFrac: z.number().min(0.25).max(1), + rallyRadiusM: z.number().min(15).max(140), + recallSafeHoldSec: z.number().min(3).max(60), +}); + +const GroundAiMacroSchema = z.object({ + openingSplitSec: z.number().min(0).max(180), + capMaxInsiders: z.number().int().min(1).max(8), + recaptureMinBots: z.number().int().min(1).max(8), + recaptureMaxBots: z.number().int().min(1).max(12), + capStickyBonusM: z.number().min(0).max(800), + deathZoneRadiusM: z.number().min(10).max(250), + deathZoneTtlSec: z.number().min(5).max(300), + deathZoneMinKills: z.number().int().min(1).max(16), + spaaRearOffsetM: z.number().min(40).max(600), + spaaRelocateSec: z.number().min(5).max(180), + enemySpawnAvoidM: z.number().min(60).max(600), +}); + +const GroundAiCrowdSchema = z.object({ + personalSpaceM: z.number().min(6).max(40), + clusterRadiusM: z.number().min(12).max(80), + clusterMaxAllies: z.number().int().min(1).max(10), + disperseStepM: z.number().min(8).max(65), + disperseHoldSec: z.number().min(1).max(15), +}); + +const GroundAiTerrainSchema = z.object({ + maxClimbSlopeDeg: z.number().min(10).max(42), + maxDropSlopeDeg: z.number().min(8).max(40), + maxWaterDepthM: z.number().min(0.2).max(2.5), + collisionMarginM: z.number().min(0.05).max(2), + crestLookaheadM: z.number().min(8).max(80), + ridgeMaxDwellSec: z.number().min(2).max(60), + ridgeMaxShots: z.number().int().min(1).max(10), +}); + +const GroundAiNavigationSchema = z.object({ + driveMode: z.enum(GROUND_AI_DRIVE_MODES), + maxPhysBots: z.number().int().min(0).max(64), + steerSign: z.union([z.literal(1), z.literal(-1)]), + deadEchoSec: z.number().min(0.3).max(10), + controlTimeoutSec: z.number().min(0.3).max(10), + cornerBrakeAccel: z.number().min(0.5).max(8), + pivotAngleDeg: z.number().min(25).max(150), + stuckWindowSec: z.number().min(1).max(15), + stuckMinMoveM: z.number().min(0.5).max(10), + unstickReverseSec: z.number().min(0.8).max(10), + tacticalReverseDistM: z.number().min(10).max(90), + tacticalReverseMaxSec: z.number().min(2).max(25), +}); + +const GroundAiPerceptionSchema = z.object({ + foliageTransparency: z.number().min(0.001).max(1), + nearSpotRangeM: z.number().min(20).max(250), + firingSpotRangeM: z.number().min(150).max(1500), + fastSpotSec: z.number().min(0.05).max(1.5), + normalSpotSec: z.number().min(0.1).max(3), + farSpotSec: z.number().min(0.3).max(6), + decayPerSec: z.number().min(0.2).max(10), + frontConeHalfDeg: z.number().min(10).max(90), + peripheralCloseM: z.number().min(30).max(250), +}); + +const GroundAiStateMachineSchema = z.object({ + preaimAngleDeg: z.number().min(1).max(30), + shortHaltMaxSec: z.number().min(0.5).max(12), + shortHaltCooldownSec: z.number().min(0.5).max(20), + turnLaunchSpeedMps: z.number().min(0.5).max(6), + coverMinDistM: z.number().min(2).max(30), + coverMaxDistM: z.number().min(6).max(80), + coverRetreatBudgetSec: z.number().min(1.5).max(20), + reloadAdvanceAngleDeg: z.number().min(0).max(45), + hullAngleTriggerDeg: z.number().min(15).max(75), + hullAngleTargetDeg: z.number().min(0).max(35), + maxTotalHaltSec: z.number().min(3).max(40), + stalemateMissShots: z.number().int().min(1).max(8), + stalemateNoShotHalts: z.number().int().min(1).max(6), + repositionMinMoveM: z.number().min(5).max(80), + repositionStepM: z.number().min(15).max(120), + repairSafeEnemyDistM: z.number().min(30).max(400), +}); + +const GroundAiTacticsSchema = z.object({ + visionRangeM: z.number().min(200).max(3500), + visionFovDeg: z.number().min(40).max(180), + peripheralRangeM: z.number().min(30).max(800), + engineAudioRangeM: z.number().min(10).max(250), + shotAudioRangeM: z.number().min(50).max(1200), + radioShareRangeM: z.number().min(50).max(1500), + memoryTtlSec: z.number().min(1).max(45), + targetStickinessSec: z.number().min(0.5).max(20), + peekCooldownSec: z.number().min(1).max(30), +}); + +const GroundAiEstimationSchema = z.object({ + watchMinSec: z.number().min(0.5).max(10), + watchMaxSec: z.number().min(1).max(15), + velSampleMinSpanSec: z.number().min(0.05).max(2), + velStableSpanSec: z.number().min(0.2).max(6), + velJumpResetMps: z.number().min(1).max(20), + baseAimSigmaM: z.number().min(0).max(2), + leadErrorFrac: z.number().min(0).max(1), + maxBiasM: z.number().min(0).max(6), +}); + +const GroundAiFireControlSchema = z.object({ + maxEngageRangeM: z.number().min(150).max(3000), + closeRangeM: z.number().min(30).max(250), + midRangeM: z.number().min(100).max(600), + longRangeM: z.number().min(300).max(1500), + midSlowSpeedRatio: z.number().min(0.1).max(1), + midSlowMaxMps: z.number().min(1).max(15), + stopSpeedMaxMps: z.number().min(0.1).max(2), + longRangeWindowSec: z.number().min(1).max(15), + baseAlignDeg: z.number().min(0.1).max(3), + closeHitRadiusM: z.number().min(0.25).max(2.2), + barrelSettleDegSec: z.number().min(0.2).max(12), + closeSettleHoldSec: z.number().min(0.02).max(0.5), + settleHoldSec: z.number().min(0.05).max(1.5), + unstabilizedStopSpeedMps: z.number().min(0.1).max(3), + stabilizedCreepSpeedMps: z.number().min(1.5).max(15), + friendlyCorridorM: z.number().min(1).max(10), + ballisticStepMaxM: z.number().min(5).max(80), + ballisticSweepRadiusM: z.number().min(0.02).max(0.5), + maxPreFireChecksPerTick: z.number().int().min(1).max(16), +}); + +const GroundAiDiagnosticsSchema = z.object({ + telemetry: z.boolean(), + telemetryIntervalSec: z.number().min(0.5).max(60), +}); + +export const GroundAiTuningSchema = z.object({ + mode: z.enum(GROUND_AI_MODES), + loadout: GroundAiLoadoutSchema, + lineupWeights: GroundAiLineupWeightsSchema, + cadence: GroundAiCadenceSchema, + commander: GroundAiCommanderSchema, + macro: GroundAiMacroSchema, + crowd: GroundAiCrowdSchema, + terrain: GroundAiTerrainSchema, + navigation: GroundAiNavigationSchema, + perception: GroundAiPerceptionSchema, + stateMachine: GroundAiStateMachineSchema, + tactics: GroundAiTacticsSchema, + estimation: GroundAiEstimationSchema, + fireControl: GroundAiFireControlSchema, + diagnostics: GroundAiDiagnosticsSchema, +}); + +export const GroundAiTuningPatchSchema = z.object({ + mode: z.enum(GROUND_AI_MODES).optional(), + loadout: GroundAiLoadoutSchema.partial().optional(), + lineupWeights: GroundAiLineupWeightsSchema.partial().optional(), + cadence: GroundAiCadenceSchema.partial().optional(), + commander: GroundAiCommanderSchema.partial().optional(), + macro: GroundAiMacroSchema.partial().optional(), + crowd: GroundAiCrowdSchema.partial().optional(), + terrain: GroundAiTerrainSchema.partial().optional(), + navigation: GroundAiNavigationSchema.partial().optional(), + perception: GroundAiPerceptionSchema.partial().optional(), + stateMachine: GroundAiStateMachineSchema.partial().optional(), + tactics: GroundAiTacticsSchema.partial().optional(), + estimation: GroundAiEstimationSchema.partial().optional(), + fireControl: GroundAiFireControlSchema.partial().optional(), + diagnostics: GroundAiDiagnosticsSchema.partial().optional(), +}); + export const TuningValuesSchema = z.object({ rewardMultiplierSilverLions: z.number().min(0).max(100), rewardMultiplierResearchPoints: z.number().min(0).max(100), @@ -9,6 +224,7 @@ export const TuningValuesSchema = z.object({ smallTeamsMaxPlayers: z.number().int().min(2).max(64), brSpreadMrank: z.number().int().min(0).max(12), subModeChance: z.number().min(0).max(1), + botPoolLimitPerType: z.number().int().min(4).max(200), tankBotRespawns: z.number().int().min(1).max(10), airBotRespawns: z.number().int().min(1).max(10), strikeUcavSpawnScore: z.number().int().min(1).max(10000), @@ -17,9 +233,14 @@ export const TuningValuesSchema = z.object({ goldenEagles: z.number().int().min(0).max(0x7fffffff), preferLineSuccessor: z.boolean(), autoTargetPick: z.enum(AUTO_TARGET_PICKS), + groundAi: GroundAiTuningSchema, +}); +export const TuningPatchSchema = TuningValuesSchema.omit({ groundAi: true }).partial().extend({ + groundAi: GroundAiTuningPatchSchema.optional(), }); -export const TuningPatchSchema = TuningValuesSchema.partial(); export const TuningViewSchema = z.object({ defaults: TuningValuesSchema, effective: TuningValuesSchema }); +export type GroundAiTuningValues = z.output; +export type GroundAiTuningPatch = z.output; export type TuningValues = z.output; export type TuningPatch = z.output; export type TuningView = z.output; diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 220442d..98f14d5 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -12,5 +12,5 @@ export { listSaveAvatars, readSaveAvatar } from './saves/save-avatars.ts'; export { importOfficialBackup, previewOfficialBackup } from './saves/import/official-backup.ts'; export { prepareTransferredProfile } from './saves/transferred-profile.ts'; export { loadGroundAiTuning, type GroundAiTuning } from './tuning/ground-ai-tuning.ts'; -export { readLauncherTuning, writeLauncherTuning, type LauncherTuningPatch } from './tuning/launcher-tuning.ts'; +export { readLauncherTuning, writeLauncherTuning, type GroundAiTuningPatch, type LauncherTuningPatch } from './tuning/launcher-tuning.ts'; export { multiVehiclePackIds } from './store/store-pack-ids.ts'; diff --git a/apps/server/src/tuning/ground-ai-tuning.ts b/apps/server/src/tuning/ground-ai-tuning.ts index 1d65238..d33218b 100644 --- a/apps/server/src/tuning/ground-ai-tuning.ts +++ b/apps/server/src/tuning/ground-ai-tuning.ts @@ -2,7 +2,13 @@ * Typed, range-validated reader for `tuning/ground-ai.jsonc`. */ import type { DiscoveredMod } from '@wto/mods'; -import { GROUND_AI_MODES, type GroundAiConfig, type GroundAiMode } from '@wto/patcher'; +import { + GROUND_AI_DRIVE_MODES, + GROUND_AI_MODES, + type GroundAiConfig, + type GroundAiDriveMode, + type GroundAiMode, +} from '@wto/patcher'; import type { TankLineupWeights } from '../battle/battle-ranks.ts'; import { tuningFiles } from './tuning-loader.ts'; import { TuningError, type TuningReader } from './tuning-reader.ts'; @@ -12,8 +18,6 @@ export interface GroundAiTuning extends GroundAiConfig { readonly lineupWeights: TankLineupWeights; } -const DRIVE_MODES = new Set(['vehicle_phys', 'movesys']); - export function loadGroundAiTuning( dataFolder: string | null, report: (line: string) => void, @@ -170,9 +174,10 @@ function readTerrainSection(terrain: TuningReader): GroundAiTuning['terrain'] { } function readNavigationSection(nav: TuningReader): GroundAiTuning['navigation'] { - const driveMode = nav.string('driveMode'); - if (!DRIVE_MODES.has(driveMode)) { - throw new TuningError(`tuning file ground-ai.jsonc: navigation.driveMode must be "vehicle_phys" or "movesys" (found "${driveMode}")`); + const driveModeRaw = nav.string('driveMode'); + const driveMode = GROUND_AI_DRIVE_MODES.find((candidate): candidate is GroundAiDriveMode => candidate === driveModeRaw); + if (driveMode === undefined) { + throw new TuningError(`tuning file ground-ai.jsonc: navigation.driveMode must be "vehicle_phys" or "movesys" (found "${driveModeRaw}")`); } const steerSign = nav.number('steerSign', { min: -1, max: 1 }); if (steerSign !== 1 && steerSign !== -1) { diff --git a/apps/server/src/tuning/launcher-tuning.ts b/apps/server/src/tuning/launcher-tuning.ts index b8ff816..dec11b9 100644 --- a/apps/server/src/tuning/launcher-tuning.ts +++ b/apps/server/src/tuning/launcher-tuning.ts @@ -6,6 +6,7 @@ import { readBattleTuning } from '../battle/battle-tuning.ts'; import { readNewProfileTuning } from '../profile/new-profile-tuning.ts'; import { readResearchTuning } from '../research/research-tuning.ts'; import { writeFileAtomic } from '../storage/atomic-file.ts'; +import { readGroundAiTuning, type GroundAiTuning } from './ground-ai-tuning.ts'; import { tuningFiles, type TuningFiles } from './tuning-loader.ts'; import { TuningError } from './tuning-reader.ts'; @@ -14,6 +15,7 @@ function values(files: TuningFiles) { const economy = readBattleEconomyTuning(files.read('battle-economy')); const newProfile = readNewProfileTuning(files.read('new-profile')).startingBalance; const research = readResearchTuning(files.read('research')); + const groundAi = readGroundAiTuning(files.read('ground-ai')); return { rewardMultiplierSilverLions: battle.rewardMultiplierSilverLions, rewardMultiplierResearchPoints: battle.rewardMultiplierResearchPoints, @@ -22,6 +24,7 @@ function values(files: TuningFiles) { smallTeamsMaxPlayers: battle.smallTeamsMaxPlayers, brSpreadMrank: battle.brSpreadMrank, subModeChance: battle.subModeChance, + botPoolLimitPerType: battle.botPoolLimitPerType, tankBotRespawns: battle.tankBotRespawns, airBotRespawns: battle.airBotRespawns, strikeUcavSpawnScore: battle.strikeUcavSpawnScore, @@ -30,11 +33,27 @@ function values(files: TuningFiles) { goldenEagles: newProfile.goldenEagles, preferLineSuccessor: research.preferLineSuccessor, autoTargetPick: research.autoTargetPick, + groundAi, }; } type Editable = ReturnType; -export type LauncherTuningPatch = { [K in keyof Editable]?: Editable[K] | undefined }; +type FlatKey = Exclude; +type GroundAiSectionKey = Exclude; + +export type GroundAiTuningPatch = { + readonly mode?: GroundAiTuning['mode'] | undefined; +} & { + readonly [S in GroundAiSectionKey]?: { + readonly [K in keyof GroundAiTuning[S]]?: GroundAiTuning[S][K] | undefined; + } | undefined; +}; + +export type LauncherTuningPatch = { + readonly [K in FlatKey]?: Editable[K] | undefined; +} & { + readonly groundAi?: GroundAiTuningPatch | undefined; +}; const fileOf = { rewardMultiplierSilverLions: 'battle', @@ -44,6 +63,7 @@ const fileOf = { smallTeamsMaxPlayers: 'battle', brSpreadMrank: 'battle', subModeChance: 'battle', + botPoolLimitPerType: 'battle', tankBotRespawns: 'battle', airBotRespawns: 'battle', strikeUcavSpawnScore: 'battle', @@ -52,7 +72,7 @@ const fileOf = { goldenEagles: 'new-profile', preferLineSuccessor: 'research', autoTargetPick: 'research', -} as const satisfies Record; +} as const satisfies Record; interface OverrideFile { readonly path: string; @@ -68,6 +88,11 @@ export function writeLauncherTuning(dataFolder: string, patch: LauncherTuningPat const { defaults, effective } = readLauncherTuning(dataFolder); const changes = new Map(); for (const key of Object.keys(patch) as Array) { + if (key === 'groundAi') { + const groundPatch = patch.groundAi; + if (groundPatch) applyGroundAiPatch(dataFolder, groundPatch, defaults.groundAi, effective.groundAi, changes); + continue; + } if (!Object.hasOwn(fileOf, key)) throw new TuningError(`Unknown launcher tuning field ${key}`); const value = patch[key]; if (value === undefined || value === effective[key]) continue; @@ -102,6 +127,55 @@ export function writeLauncherTuning(dataFolder: string, patch: LauncherTuningPat return { defaults, effective: updated }; } +function applyGroundAiPatch( + dataFolder: string, + patch: GroundAiTuningPatch, + defaults: GroundAiTuning, + effective: GroundAiTuning, + changes: Map, +): void { + let file = changes.get('ground-ai'); + const ensureFile = (): OverrideFile => { + if (!file) { + file = readOverride(join(dataFolder, 'tuning', 'ground-ai.jsonc')); + changes.set('ground-ai', file); + } + return file; + }; + + for (const key of Object.keys(patch) as Array) { + if (!Object.hasOwn(defaults, key)) throw new TuningError(`Unknown ground AI tuning field ${key}`); + if (key === 'mode') { + const nextMode = patch.mode; + if (nextMode === undefined || nextMode === effective.mode) continue; + const target = ensureFile(); + if (nextMode === defaults.mode) delete target.fields['mode']; + else target.fields['mode'] = nextMode; + continue; + } + const sectionPatch = patch[key]; + if (!sectionPatch) continue; + const sectionDefaults = defaults[key] as Record; + const sectionEffective = effective[key] as Record; + for (const field of Object.keys(sectionPatch)) { + if (!Object.hasOwn(sectionDefaults, field)) { + throw new TuningError(`Unknown ground AI tuning field ${key}.${field}`); + } + const value = (sectionPatch as Record)[field]; + if (value === undefined || value === sectionEffective[field]) continue; + const target = ensureFile(); + const existing = target.fields[key]; + const sectionObj: Record = existing !== null && typeof existing === 'object' && !Array.isArray(existing) + ? { ...(existing as Record) } + : {}; + if (value === sectionDefaults[field]) delete sectionObj[field]; + else sectionObj[field] = value; + if (Object.keys(sectionObj).length > 0) target.fields[key] = sectionObj; + else delete target.fields[key]; + } + } +} + function readOverride(path: string): OverrideFile { let previous: string; try { diff --git a/packages/patcher/src/ground-ai/ground-ai-config.ts b/packages/patcher/src/ground-ai/ground-ai-config.ts index afdbdc4..9c9a70b 100644 --- a/packages/patcher/src/ground-ai/ground-ai-config.ts +++ b/packages/patcher/src/ground-ai/ground-ai-config.ts @@ -12,6 +12,8 @@ */ export const GROUND_AI_MODES = ['stock', 'fire', 'drive', 'full'] as const; export type GroundAiMode = (typeof GROUND_AI_MODES)[number]; +export const GROUND_AI_DRIVE_MODES = ['vehicle_phys', 'movesys'] as const; +export type GroundAiDriveMode = (typeof GROUND_AI_DRIVE_MODES)[number]; export interface GroundAiLoadoutConfig { readonly lowReadyRackThreshold: number; @@ -83,9 +85,9 @@ export interface GroundAiConfig { readonly ridgeMaxShots: number; }; readonly navigation: { - readonly driveMode: string; + readonly driveMode: GroundAiDriveMode; readonly maxPhysBots: number; - readonly steerSign: number; + readonly steerSign: 1 | -1; readonly deadEchoSec: number; readonly controlTimeoutSec: number; readonly cornerBrakeAccel: number; diff --git a/packages/patcher/src/index.ts b/packages/patcher/src/index.ts index dff2b03..f44934a 100644 --- a/packages/patcher/src/index.ts +++ b/packages/patcher/src/index.ts @@ -68,9 +68,11 @@ export { } from './ground-ai/game-pack.ts'; export { compileGroundAiConfigDas, + GROUND_AI_DRIVE_MODES, GROUND_AI_MODES, isGroundAiActive, type GroundAiConfig, + type GroundAiDriveMode, type GroundAiLoadoutConfig, type GroundAiMode, } from './ground-ai/ground-ai-config.ts';