feat(patcher,server): wire ground AI tuning, bot weights, and pack build

Add ground-ai.jsonc tuning validation, realistic tank class weights for
customBots pools, on-demand game.vromfs.bin / ailist.blk injection in
@wto/patcher, and launcher/CLI build integration while keeping all
ground AI layers disabled by default in shipped configuration.
This commit is contained in:
N0VAN0M4LY committed 2026-12-03 12:07:30 +08:00
1 parent 18637cf1ff
commit 4ac3484f56
17 files changed
+836 -75

No files matched your search

+31 -5
View File
@@ -20,6 +20,7 @@ import { editPackBlks } from './pack-edit.ts';
export const ENGINE_SETTINGS_PATH = 'config/settings.blk';
export const GUI_CONFIG_PATH = 'config/gui.blk';
export const AI_LIST_PATH = 'gamedata/ai/ailist.blk';
const NETWORK_BLOCK = 'network';
/**
@@ -34,9 +35,15 @@ export const EXTRA_STORE_BUNDLE_GUIDS: ReadonlyArray<readonly [entitlement: stri
export const EXTRA_STORE_BUNDLE_GUID_MAP: Readonly<Record<string, string>> = Object.fromEntries(EXTRA_STORE_BUNDLE_GUIDS);
export interface MainPackOptions {
/** Replace stock tankBot behavior children with `success` so custom chassis control owns steering. */
readonly yieldStockTankDrive?: boolean;
}
export interface MainPackResult {
readonly pack: Uint8Array;
readonly addresses: readonly AddressChange[];
readonly yieldedStockTankDrive: boolean;
}
export function rebuildMainPack(
@@ -44,12 +51,13 @@ export function rebuildMainPack(
endpoint: LocalEndpoint,
extraBundles: ReadonlyArray<readonly [string, string]> = [],
extraAddonFolders: readonly string[] = [],
options: MainPackOptions = {},
): MainPackResult {
let addresses: AddressChange[] = [];
const pack = editPackBlks(stockPack, [
const edits = [
{
path: ENGINE_SETTINGS_PATH,
edit: (root) => {
edit: (root: BlkBlock) => {
const network = findBlock(root, NETWORK_BLOCK);
if (!network) throw new Error(`${ENGINE_SETTINGS_PATH} has no "${NETWORK_BLOCK}" block; this game build differs from the verified ones`);
addresses = redirectAddresses(network, endpoint, [NETWORK_BLOCK]);
@@ -58,10 +66,15 @@ export function rebuildMainPack(
},
{
path: GUI_CONFIG_PATH,
edit: (root) => registerStoreBundleGuids(root, [...EXTRA_STORE_BUNDLE_GUIDS, ...extraBundles]),
edit: (root: BlkBlock) => registerStoreBundleGuids(root, [...EXTRA_STORE_BUNDLE_GUIDS, ...extraBundles]),
},
]);
return { pack, addresses };
...(options.yieldStockTankDrive ? [{
path: AI_LIST_PATH,
edit: (root: BlkBlock) => yieldTankBotBehaviorTree(root),
}] : []),
];
const pack = editPackBlks(stockPack, edits);
return { pack, addresses, yieldedStockTankDrive: options.yieldStockTankDrive === true };
}
function registerStoreBundleGuids(guiRoot: BlkBlock, bundles: ReadonlyArray<readonly [string, string]>): void {
@@ -70,3 +83,16 @@ function registerStoreBundleGuids(guiRoot: BlkBlock, bundles: ReadonlyArray<read
setParam(guidBlock, entitlement, { type: 'string', value: guid });
}
}
function yieldTankBotBehaviorTree(aiRoot: BlkBlock): void {
const matches = aiRoot.blocks.filter((block) =>
block.name === 'selector' &&
block.params.some((param) => param.name === 'name' && param.value.type === 'string' && param.value.value === 'tankBot'),
);
if (matches.length !== 1) {
throw new Error(`expected 1 "tankBot" selector in ${AI_LIST_PATH}, found ${matches.length}`);
}
const tankBot = matches[0]!;
tankBot.blocks.length = 0;
tankBot.blocks.push({ name: 'success', params: [], blocks: [] });
}