This commit is contained in:
2026-02-12 15:09:07 -05:00
parent dd2d7a3abe
commit c320e8d993
13 changed files with 9168 additions and 30 deletions

View File

@@ -11,7 +11,7 @@ Usage:
node tools/ggs-dist-cli.js apply --profile <file> [--out <file>]
Commands:
extract Build a full firearm/attachment spawn catalog from GaelGunStore.
extract Build a full firearm/attachment/magazine spawn catalog from GaelGunStore.
apply Convert a webapp profile JSON into Lua used by the B42 mod patcher.
`.trim());
}
@@ -117,6 +117,26 @@ function normalizeItemType(item) {
return trimmed.includes(".") ? trimmed : `Base.${trimmed}`;
}
function isMagazineType(itemType) {
const s = String(itemType || "").toLowerCase();
if (!s) {
return false;
}
if (s.startsWith("base.clip_")) {
return true;
}
if (s.includes("magazine")) {
return true;
}
if (s.includes("drum")) {
return true;
}
if (s.includes("clip")) {
return true;
}
return false;
}
function buildCatalog(ggsRoot) {
const cwd = process.cwd();
const firearmScriptsDir = path.join(ggsRoot, "media", "scripts", "Firearms");
@@ -137,12 +157,24 @@ function buildCatalog(ggsRoot) {
const attachments = collectItemTypesFromScripts(attachmentScriptsDir);
const firearmSet = new Set(firearms);
const attachmentSet = new Set(attachments);
const magazineSet = new Set();
const lootEntries = parseLootEntries(lootLuaPath);
const perItemLoot = new Map();
const allLists = new Set();
const allItems = new Set([...firearms, ...attachments]);
for (const entry of lootEntries) {
const normalized = normalizeItemType(entry.item);
if (!normalized) {
continue;
}
if (isMagazineType(normalized)) {
magazineSet.add(normalized);
allItems.add(normalized);
}
}
for (const entry of lootEntries) {
const normalized = normalizeItemType(entry.item);
if (!normalized) {
@@ -171,6 +203,8 @@ function buildCatalog(ggsRoot) {
let category = "unknown";
if (firearmSet.has(itemType)) {
category = "firearm";
} else if (magazineSet.has(itemType)) {
category = "magazine";
} else if (attachmentSet.has(itemType)) {
category = "attachment";
}
@@ -202,6 +236,7 @@ function buildCatalog(ggsRoot) {
counts: {
firearms: firearms.length,
attachments: attachments.length,
magazines: magazineSet.size,
totalItems: items.length,
placementRows: lootEntries.length,
distributionLists: allLists.size,
@@ -296,7 +331,7 @@ function commandExtract(args) {
console.log(`Extracted catalog: ${outPath}`);
console.log(
`Items=${catalog.counts.totalItems}, Firearms=${catalog.counts.firearms}, Attachments=${catalog.counts.attachments}, Lists=${catalog.counts.distributionLists}`
`Items=${catalog.counts.totalItems}, Firearms=${catalog.counts.firearms}, Attachments=${catalog.counts.attachments}, Magazines=${catalog.counts.magazines}, Lists=${catalog.counts.distributionLists}`
);
}