feat(ground-ai)!: replace layer switches with complete modes
Ground AI layers could be enabled in any combination, including ones the scripts cannot run (fire control without perception disabled stock aiming and never fired). The configuration now selects one of four complete modes: stock, fire (stock movement, custom fire permission), drive (custom orders and driving, stock firing) and full. The build derives the compiled layer constants from the mode, and an unknown mode is rejected at load time. The offline tank class weights for the AI bot pool move from code into tuning/ground-ai.jsonc (lineupWeights). They apply only when a custom mode is active; stock mode keeps the stock weight of 1 for every vehicle. Verified root and launcher type checks, mode-to-constant compilation for all four modes, rejection of an unknown mode, bot pool weights in stock and custom modes, and temporary 2.61.0.58 game copy builds in full mode (15 script modules packed) and stock mode (no game pack written). BREAKING CHANGE: ground-ai.jsonc drops "enabled" and "layers". Override files set "mode" to "stock", "fire", "drive" or "full" instead.
This commit is contained in:
1 parent
885e3bbb5d
commit
5e521295a3
8 files changed
+117
-51
No files matched your search
@@ -23,7 +23,7 @@ import {
|
||||
type GamePackResult,
|
||||
type GroundAiBuildInputs,
|
||||
} from './ground-ai/game-pack.ts';
|
||||
import { isGroundAiActive } from './ground-ai/ground-ai-config.ts';
|
||||
import { groundAiOwnsMovement, isGroundAiActive } from './ground-ai/ground-ai-config.ts';
|
||||
import { rebuildGuiPack } from './gui-pack.ts';
|
||||
import { rebuildMainPack } from './main-pack.ts';
|
||||
import { collectModAddonMounts, type ModAddonMount } from './mods/addon-register.ts';
|
||||
@@ -130,7 +130,7 @@ export function buildGameCopy(inputs: GameCopyInputs): GameCopyBuild {
|
||||
|
||||
const executable = patchExecutableWithMods(inputs.stock.executable, folders.exe, enabledMods);
|
||||
const stockImage = new PeImage(inputs.stock.executable);
|
||||
const customGroundDrive = groundAiActive && inputs.groundAi?.config.layers.navigation &&
|
||||
const customGroundDrive = groundAiActive && inputs.groundAi !== undefined && groundAiOwnsMovement(inputs.groundAi.config) &&
|
||||
inputs.groundAi.config.navigation.driveMode === 'vehicle_phys';
|
||||
const nativeDefinitions = loadNativeModules(folders.native)
|
||||
.filter((module) => customGroundDrive || module.module !== 'local_mp_ground_ai');
|
||||
|
||||
@@ -3,14 +3,18 @@
|
||||
* build-time daScript constant compilation (`game/wtoai/wto_ai_config_common.das`).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Which parts of the ground AI replace stock behavior. Each mode is a complete combination:
|
||||
* - `stock`: stock tankBot moves, aims and fires; no scripts are packed.
|
||||
* - `fire`: stock movement and destinations; custom perception and fire permission.
|
||||
* - `drive`: custom team orders and driving; stock aiming and firing (debugging).
|
||||
* - `full`: every custom layer.
|
||||
*/
|
||||
export const GROUND_AI_MODES = ['stock', 'fire', 'drive', 'full'] as const;
|
||||
export type GroundAiMode = (typeof GROUND_AI_MODES)[number];
|
||||
|
||||
export interface GroundAiConfig {
|
||||
readonly enabled: boolean;
|
||||
readonly layers: {
|
||||
readonly macro: boolean;
|
||||
readonly tactics: boolean;
|
||||
readonly navigation: boolean;
|
||||
readonly fireControl: boolean;
|
||||
};
|
||||
readonly mode: GroundAiMode;
|
||||
readonly cadence: {
|
||||
readonly maxBots: number;
|
||||
readonly macroTickSec: number;
|
||||
@@ -88,9 +92,17 @@ export interface GroundAiConfig {
|
||||
}
|
||||
|
||||
export function isGroundAiActive(config: GroundAiConfig | undefined): boolean {
|
||||
if (!config || !config.enabled) return false;
|
||||
const { macro, tactics, navigation, fireControl } = config.layers;
|
||||
return macro || tactics || navigation || fireControl;
|
||||
return config !== undefined && config.mode !== 'stock';
|
||||
}
|
||||
|
||||
/** True when custom team orders and driving replace stock movement. */
|
||||
export function groundAiOwnsMovement(config: GroundAiConfig): boolean {
|
||||
return config.mode === 'drive' || config.mode === 'full';
|
||||
}
|
||||
|
||||
/** True when custom perception and fire permission replace stock aiming and firing. */
|
||||
export function groundAiOwnsFire(config: GroundAiConfig): boolean {
|
||||
return config.mode === 'fire' || config.mode === 'full';
|
||||
}
|
||||
|
||||
type DasEntry = readonly [name: string, kind: 'bool' | 'int' | 'float' | 'string', value: boolean | number | string];
|
||||
@@ -112,12 +124,15 @@ export function compileGroundAiConfigDas(config: GroundAiConfig): string {
|
||||
}
|
||||
|
||||
function collectConfigEntries(c: GroundAiConfig): readonly DasEntry[] {
|
||||
const movement = groundAiOwnsMovement(c);
|
||||
const fire = groundAiOwnsFire(c);
|
||||
return [
|
||||
['WTO_AI_ENABLED', 'bool', c.enabled],
|
||||
['WTO_AI_LAYER_MACRO', 'bool', c.layers.macro],
|
||||
['WTO_AI_LAYER_TACTICS', 'bool', c.layers.tactics],
|
||||
['WTO_AI_LAYER_NAVIGATION', 'bool', c.layers.navigation],
|
||||
['WTO_AI_LAYER_FIRE_CONTROL', 'bool', c.layers.fireControl],
|
||||
['WTO_AI_ENABLED', 'bool', isGroundAiActive(c)],
|
||||
['WTO_AI_LAYER_MACRO', 'bool', movement],
|
||||
// Perception runs inside the tactics layer, so every custom mode keeps it on.
|
||||
['WTO_AI_LAYER_TACTICS', 'bool', movement || fire],
|
||||
['WTO_AI_LAYER_NAVIGATION', 'bool', movement],
|
||||
['WTO_AI_LAYER_FIRE_CONTROL', 'bool', fire],
|
||||
['WTO_AI_MAX_TRACKED_BOTS', 'int', c.cadence.maxBots],
|
||||
['WTO_AI_MACRO_TICK_SEC', 'float', c.cadence.macroTickSec],
|
||||
['WTO_AI_TACTICS_TICK_SEC', 'float', c.cadence.tacticsTickSec],
|
||||
|
||||
@@ -68,8 +68,10 @@ export {
|
||||
} from './ground-ai/game-pack.ts';
|
||||
export {
|
||||
compileGroundAiConfigDas,
|
||||
GROUND_AI_MODES,
|
||||
isGroundAiActive,
|
||||
type GroundAiConfig,
|
||||
type GroundAiMode,
|
||||
} from './ground-ai/ground-ai-config.ts';
|
||||
export { rebuildGuiPack, type AppliedGuiPatch, type GuiPackResult } from './gui-pack.ts';
|
||||
export { loadGuiPatches, type GuiScriptEdit, type GuiScriptPatch, type GuiScriptVariant } from './gui-patch-definition.ts';
|
||||
|
||||
Reference in new issue
Block a user