fix(modifications): grant custom-slot weapon containers and support unit weapons
This commit is contained in:
1 parent
62da2e3038
commit
388dc9d9d7
4 files changed
+97
-37
No files matched your search
@@ -54,6 +54,10 @@ export interface WeaponFacts {
|
||||
readonly requires: readonly string[];
|
||||
/** maxCount; 0 when the preset is not bought by the piece. */
|
||||
readonly maxCount: number;
|
||||
/** True for `isWeaponForCustomSlot` single-weapon containers referenced by `sum_weapons`. */
|
||||
readonly forCustomSlot?: boolean;
|
||||
/** `sum_weapons` container names referenced by a selectable preset. */
|
||||
readonly sumWeapons?: readonly string[];
|
||||
}
|
||||
|
||||
export interface VehicleEquipment {
|
||||
@@ -74,7 +78,7 @@ interface GlobalModificationMeta {
|
||||
|
||||
export const vehicleEquipment: Dataset<readonly VehicleEquipment[]> = {
|
||||
id: 'vehicle-equipment',
|
||||
version: 3,
|
||||
version: 4,
|
||||
extract: (source) => {
|
||||
const modMeta = readGlobalModificationMeta(source.readBlk('char.vromfs.bin', MODIFICATIONS_CONFIG));
|
||||
return source.readBlk('char.vromfs.bin', VEHICLE_ECONOMY).blocks.map((vehicle) => equipmentOf(vehicle, modMeta));
|
||||
@@ -141,14 +145,17 @@ function weaponsOf(weaponsBlock: BlkBlock | undefined): WeaponFacts[] {
|
||||
containerRequires.set(entry.name, stringList(entry, 'reqModification'));
|
||||
}
|
||||
}
|
||||
return weaponsBlock.blocks
|
||||
.filter((entry) => boolField(entry, 'isWeaponForCustomSlot') !== true)
|
||||
.map((entry) => weaponOf(entry, containerRequires));
|
||||
// Keep `isWeaponForCustomSlot` container blocks too: native `shop_is_weapon_purchased`
|
||||
// (aces.exe 0x15562f0 -> 0x913570) checks every `sum_weapons` container against `profile.weapons{}`.
|
||||
return weaponsBlock.blocks.map((entry) => weaponOf(entry, containerRequires));
|
||||
}
|
||||
|
||||
function weaponOf(entry: BlkBlock, containerRequires: ReadonlyMap<string, readonly string[]>): WeaponFacts {
|
||||
const forCustomSlot = boolField(entry, 'isWeaponForCustomSlot') === true;
|
||||
const requires = [...stringList(entry, 'reqModification')];
|
||||
const sumWeapons: string[] = [];
|
||||
for (const param of findBlock(entry, 'sum_weapons')?.params ?? []) {
|
||||
if (!sumWeapons.includes(param.name)) sumWeapons.push(param.name);
|
||||
for (const req of containerRequires.get(param.name) ?? []) {
|
||||
if (!requires.includes(req)) requires.push(req);
|
||||
}
|
||||
@@ -159,5 +166,7 @@ function weaponOf(entry: BlkBlock, containerRequires: ReadonlyMap<string, readon
|
||||
goldenEagles: numberField(entry, 'costGold') ?? 0,
|
||||
requires,
|
||||
maxCount: numberField(entry, 'maxCount') ?? 0,
|
||||
...(forCustomSlot ? { forCustomSlot: true } : {}),
|
||||
...(sumWeapons.length > 0 ? { sumWeapons } : {}),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user