fix(battle): grant the modifications required by support plane presets
The respawn screen showed an empty loadout for the nuclear carrier: a preset is listed only when shop_is_weapon_available passes (2.61.0.37 0x17a38a0 -> 0x912d20 -> 0x90f2c0 / 0x9662f0), which needs every reqModification of the preset and of its sum_weapons to be a bought modification of the unit in the profile. The forced preset of f_16a_block_15_adf_killstreak carries bombguns_us_b61_30kt with reqModification us_500lb_mk82, and the player never owns that unit. Derive the modifications of each missionSupportPlane unit's forced preset from wpcost.blk and keep them in every profile as owned, in the profile refresh. Only those killstreak units are touched. Checked with typecheck and a run over the stock data (30 records, the F-16 one included); not yet verified in game.
This commit is contained in:
1 parent
394091e518
commit
37efa804bb
2 files changed
+55
-1
No files matched your search
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* The modifications the mission support planes' forced presets need (gameplay.blk
|
||||
* missionSupportPlane <country>{ unitName weapon }, e.g. f_16a_block_15_adf_killstreak with
|
||||
* f_16a_block_15_adf_killstreak_b61_30kt_nt, whose bombguns_us_b61_30kt has reqModification
|
||||
* us_500lb_mk82 in wpcost.blk), kept in every profile as owned.
|
||||
*
|
||||
* The respawn screen lists a preset only when shop_is_weapon_available passes (aces.exe 2.61.0.37
|
||||
* 0x17a38a0 -> 0x912d20 -> 0x90f2c0 / 0x9662f0): every reqModification of the preset and of the
|
||||
* weapons in its sum_weapons must be a bought modification of the unit in the profile; the unit's
|
||||
* killStreak flag adds a condition but does not lift this one. Without the records the support
|
||||
* plane's loadout box is empty. The player never owns these units, so online the server has to
|
||||
* provide the records (inferred; not observed).
|
||||
*/
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
import type { BattleSpawnRulesData } from '../game-data/datasets/battle-spawn-rules.ts';
|
||||
import { ownsModification, writeModificationRecord } from '../profile/profile-modifications.ts';
|
||||
import type { EquipmentCatalogue } from './equipment-catalogue.ts';
|
||||
|
||||
export interface SupportPlaneModification {
|
||||
readonly vehicle: string;
|
||||
readonly modification: string;
|
||||
}
|
||||
|
||||
export function supportPlaneModifications(
|
||||
rules: Pick<BattleSpawnRulesData, 'supportPlanes'>,
|
||||
catalogue: EquipmentCatalogue,
|
||||
): readonly SupportPlaneModification[] {
|
||||
const seen = new Set<string>();
|
||||
const out: SupportPlaneModification[] = [];
|
||||
for (const presets of Object.values(rules.supportPlanes)) {
|
||||
for (const preset of presets) {
|
||||
for (const { unitName, weapon } of Object.values(preset.units)) {
|
||||
for (const modification of catalogue.weapon(unitName, weapon)?.requires ?? []) {
|
||||
const key = `${unitName}/${modification}`;
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
out.push({ vehicle: unitName, modification });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export function grantSupportPlaneModifications(profile: BlkBlock, grants: readonly SupportPlaneModification[]): void {
|
||||
for (const { vehicle, modification } of grants) {
|
||||
if (ownsModification(profile, vehicle, modification)) continue;
|
||||
writeModificationRecord(profile, vehicle, modification, { silverLionsSpent: 0, goldenEaglesSpent: 0, enabled: true, count: 1 });
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
* Assemble the players' profiles with the rules they depend on, the same way for the local
|
||||
* service and for the save editor (save-cli.ts): static data from the dataset cache, the
|
||||
* save store with its format upgrades, and clan membership, research, and modification state
|
||||
* and the free repair over time (repair/repair-over-time.ts) kept up to date and persisted on
|
||||
* (with the modifications the mission support planes' presets need) and the free repair over time (repair/repair-over-time.ts) kept up to date and persisted on
|
||||
* every read or write.
|
||||
*/
|
||||
import type { AccountStore } from './accounts/account-store.ts';
|
||||
@@ -17,6 +17,8 @@ import type { GameFiles } from './game-data/game-files.ts';
|
||||
import { removeExpiredItems } from './items/item-expiry.ts';
|
||||
import { EquipmentCatalogue } from './modifications/equipment-catalogue.ts';
|
||||
import { refreshModuleState } from './modifications/module-state.ts';
|
||||
import { grantSupportPlaneModifications, supportPlaneModifications } from './modifications/support-plane-modifications.ts';
|
||||
import { battleSpawnRules } from './game-data/datasets/battle-spawn-rules.ts';
|
||||
import { trimUserLogs } from './profile/profile-trophies-log.ts';
|
||||
import { PlayerProfiles } from './profile/player-profiles.ts';
|
||||
import { profileUpgrades } from './profile/profile-upgrades.ts';
|
||||
@@ -57,12 +59,14 @@ export function setUpProfiles(
|
||||
const research = loadResearchRules(datasets, tuning.research, vehicles);
|
||||
const equipment = new EquipmentCatalogue(datasets.load(vehicleEquipment));
|
||||
const repair = new RepairRules(datasets.load(vehicleRepair), research.techTree);
|
||||
const supportPlaneGrants = supportPlaneModifications(datasets.load(battleSpawnRules), equipment);
|
||||
const saves = new SaveStore(dataFolder, profileUpgrades(startingContent));
|
||||
const profiles = new PlayerProfiles(saves, gameFiles, startingContent, (profile, userId) => {
|
||||
const account = sync?.accounts.byUserId(userId);
|
||||
if (account && sync) sync.clans.syncProfile(profile, account);
|
||||
refreshResearchState(profile, research);
|
||||
refreshModuleState(profile, equipment);
|
||||
grantSupportPlaneModifications(profile, supportPlaneGrants);
|
||||
removeExpiredItems(profile, serverTimeNow());
|
||||
repairVehiclesOverTime(profile, repair, serverTimeNow());
|
||||
trimUserLogs(profile, tuning.limits.userLogsKept);
|
||||
|
||||
Reference in new issue
Block a user