fix(equipment): correct modification status and persist weapon presets

Write modStatus in modsResearch so the client recognizes purchasable
modifications. Persist ownership and initial equipment state for free
modifications and quantities for free weapon presets.

Persist preset inventory in the weapon records and handle cln_buy_weapon
using the maximum quantity extracted from the game data.
This commit is contained in:
N0VAN0M4LY committed 2026-11-25 02:44:16 +08:00
1 parent 743efbbd39
commit 1e7dc2447f
8 files changed
+200 -23

No files matched your search

@@ -8,6 +8,8 @@
* reqModification:t (repeated) maxCount:i ammoCount:i ... } }
* Ammunition and expendables are modifications too (tier 0, maxCount, ammoCount).
* weapons{ <preset>{ value:i costGold:i maxCount:i reqModification:t ... } }
* Paid presets (bombs, rockets) are bought by the piece, up to maxCount; the rest are free,
* custom_presets (the custom preset slots) among them.
* spare{ value:i costGold:i }
*
* Only what the file says is recorded; what it means is the rules layer's (modifications/).
@@ -38,10 +40,13 @@ export interface ModificationFacts {
readonly ammunition: boolean;
}
export interface PriceFacts {
export interface WeaponFacts {
readonly name: string;
/** value: silver lions per piece. */
readonly silverLions: number;
readonly goldenEagles: number;
/** maxCount; 0 when the preset is not bought by the piece. */
readonly maxCount: number;
}
export interface VehicleEquipment {
@@ -49,14 +54,14 @@ export interface VehicleEquipment {
/** needBuyToOpenNextInTier1..4 (index 0 = tier 1). */
readonly tierRequirements: readonly number[];
readonly modifications: readonly ModificationFacts[];
readonly weapons: readonly PriceFacts[];
readonly weapons: readonly WeaponFacts[];
/** spare; absent when the vehicle has no spare price. */
readonly spare?: { readonly silverLions: number; readonly goldenEagles: number };
}
export const vehicleEquipment: Dataset<readonly VehicleEquipment[]> = {
id: 'vehicle-equipment',
version: 1,
version: 2,
extract: (source) => source.readBlk('char.vromfs.bin', VEHICLE_ECONOMY).blocks.map(equipmentOf),
};
@@ -68,7 +73,7 @@ function equipmentOf(vehicle: BlkBlock): VehicleEquipment {
vehicle: vehicle.name,
tierRequirements,
modifications: (findBlock(vehicle, 'modifications')?.blocks ?? []).map(modificationOf),
weapons: (findBlock(vehicle, 'weapons')?.blocks ?? []).map(priceOf),
weapons: (findBlock(vehicle, 'weapons')?.blocks ?? []).map(weaponOf),
...(spare ? { spare: { silverLions: numberField(spare, 'value') ?? 0, goldenEagles: numberField(spare, 'costGold') ?? 0 } } : {}),
};
}
@@ -87,6 +92,11 @@ function modificationOf(modification: BlkBlock): ModificationFacts {
};
}
function priceOf(entry: BlkBlock): PriceFacts {
return { name: entry.name, silverLions: numberField(entry, 'value') ?? 0, goldenEagles: numberField(entry, 'costGold') ?? 0 };
function weaponOf(entry: BlkBlock): WeaponFacts {
return {
name: entry.name,
silverLions: numberField(entry, 'value') ?? 0,
goldenEagles: numberField(entry, 'costGold') ?? 0,
maxCount: numberField(entry, 'maxCount') ?? 0,
};
}