/** * The modifications the mission support planes' forced presets need (gameplay.blk * missionSupportPlane { 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, catalogue: EquipmentCatalogue, ): readonly SupportPlaneModification[] { const seen = new Set(); 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 }); } }