On returning from a stock training mission, the client reports the outcome in cln_update under missionAwards while sending an empty pveProgress block. Because the local server did not record this completion, the hangar repeated tutorial prompts after restart and never credited first-completion rewards. Add a cached training-missions dataset (config/mislist.blk, config/pve_awards.blk, config/unlocks.blk), pure completion rules in TrainingCatalogue, and missionAwards parsing in clientUpdateAction. Completed tutorials now persist pveProgress/missions and grant per-mission decals, the shared first-basic-tutorial Golden Eagles unlock, and per-difficulty first-win Silver Lions once per account during cln_update before replying. Credit to duduyagame for identifying the cln_update missionAwards reporting flow and stock reward definitions (PR #6). Checks: root `npm run typecheck` passed; verified training-missions dataset extraction/caching and TrainingCatalogue idempotency against read-only stock 2.61.0.37 files in a temporary data folder. In-game acceptance pending on an isolated client copy. Co-authored-by: duduyagame <[email protected]>
41 lines
2.0 KiB
TypeScript
41 lines
2.0 KiB
TypeScript
/**
|
|
* Mission completion in the profile: which difficulties the player has completed a mission
|
|
* on (tutorials and other single-player missions).
|
|
*
|
|
* pveProgress{
|
|
* missions{
|
|
* "tutorial/tutorialB_takeoff_and_landing"{ diff_0:b=yes diff_1:b=yes diff_2:b=yes }
|
|
* }
|
|
* }
|
|
*
|
|
* Read by the client's profile serializer (aces.exe 2.61.0.37 0x92bd40: "pveProgress" ->
|
|
* "missions", one sub-block per mission, 0x92f090), each entry by 0x92f7d0:
|
|
* onlineDiff:i, singleDiff:i optional, -1 when missing
|
|
* timesCompleted:i, timesPlayed:i optional, 0 when missing
|
|
* diff_0:b, diff_1:b, diff_2:b completed on arcade, historical, simulator
|
|
* The entry's name is the mission's full name, "<chapter>/<mission>", the key that the
|
|
* script function get_mission_progress (0x179c900 -> 0xebad60) looks up. It returns the
|
|
* highest difficulty completed (0, 1, 2), or 3 or more when there is none.
|
|
*/
|
|
import { ensureBlock, findBlock, findParam, setParam, type BlkBlock } from '@wto/blk';
|
|
|
|
const PVE_PROGRESS = 'pveProgress';
|
|
const MISSIONS = 'missions';
|
|
const DIFFICULTIES = [0, 1, 2] as const;
|
|
|
|
export function hasCompletedMissionDifficulty(profile: BlkBlock, fullMissionName: string, difficulty: 0 | 1 | 2): boolean {
|
|
const pve = findBlock(profile, PVE_PROGRESS);
|
|
const missions = pve && findBlock(pve, MISSIONS);
|
|
const mission = missions && findBlock(missions, fullMissionName);
|
|
const flag = mission && findParam(mission, `diff_${difficulty}`)?.value;
|
|
return flag?.type === 'bool' && flag.value;
|
|
}
|
|
|
|
/** Record the mission as completed on every difficulty up to and including `highest` (0, 1 or 2). */
|
|
export function recordMissionCompleted(profile: BlkBlock, fullMissionName: string, highest: 0 | 1 | 2): void {
|
|
const entry = ensureBlock(ensureBlock(ensureBlock(profile, PVE_PROGRESS), MISSIONS), fullMissionName);
|
|
for (const difficulty of DIFFICULTIES) {
|
|
if (difficulty <= highest) setParam(entry, `diff_${difficulty}`, { type: 'bool', value: true });
|
|
}
|
|
}
|