Boosters (rateBooster items) now add to the settled battle as the stock client and the official wiki describe: each booster adds its percent of the base reward; boosters stack per event type and personal / all-allies group with the client's calc_public_boost factors; a battle uses one battle of a booster plus one per spentInSessionTimeMin span, and a booster with R battles left covers the first R spans; kill, ground kill and assist boosters add only to that event and end after their kill count. The debriefing table gets the booster columns, the session log lists affectedBoosters, the research breakdown carries boosterExpTotal, progress is saved and used-up boosters are removed with an EULT_REMOVE_ITEM log. The active wager now moves with each battle that meets its active conditions (lineup rank range, random battle, mission postfix): a stage when its win condition holds (battle won, players killed, or the listed battle awards, hidden ones included), otherwise a failed battle. It ends at maxWins or maxFails and pays a x stake x stages^b + c of the reached stage. Each counted battle logs EULT_CHARD_AWARD in the battle's room and the session log lists affectedWagers, which the stock debriefing shows. Hidden battle awards are now judged (not shown or logged) so wagers can name them; awards of mode missionsWon are supported, and "unlocks" awards honour num. The new GUI patch battle/match-settled-battle-room-logs matches the settled battle's logs by room id in isUserlogVisible, the one filter all "this battle's logs" queries use; it replaces the two per-call edits in use-settled-debriefing-stats. Not yet verified in game.
125 lines
4.8 KiB
TypeScript
125 lines
4.8 KiB
TypeScript
/**
|
|
* Dataset: the battle awards ("streaks") of char.vromfs.bin config/unlocks.blk (implementation notes "3e").
|
|
*
|
|
* unlockable{ id:t type:t="streak" hidden:b isAfterFlight:b isMultiStage:b
|
|
* amount_warpoints:i|ip3 amount_exp:i|ip3 reward of a single-stage award
|
|
* wpA:p3 wpB:p3 expA:p3 expB:p3 reward terms of a multi-stage award
|
|
* stage{ param:i amount_warpoints amount_exp } first stage of a multi-stage award
|
|
* mode{ type:t <mode parameters> condition{ type:t <condition parameters> } ... }
|
|
* }
|
|
*
|
|
* Three-value parameters (p3 / ip3) are per difficulty: arcade, realistic, simulator. Hidden
|
|
* awards are kept and flagged: the stock client does not show them (scripts/unlocks
|
|
* isUnlockVisible), but wagers name some of them as win conditions (hidden_win_streak ...).
|
|
* Online the battle server evaluates these definitions; battle/battle-streaks.ts does it offline.
|
|
*/
|
|
import type { BlkBlock, BlkValue } from '@wto/blk';
|
|
import type { Dataset } from './dataset.ts';
|
|
|
|
export type StreakValue = string | number | boolean;
|
|
|
|
/** Every parameter of a block by name, repeated names in order; three-value parameters spread. */
|
|
export type StreakParams = Readonly<Record<string, readonly StreakValue[]>>;
|
|
|
|
export interface StreakCondition {
|
|
readonly type: string;
|
|
readonly params: StreakParams;
|
|
}
|
|
|
|
export interface StreakMode {
|
|
readonly type: string;
|
|
readonly params: StreakParams;
|
|
readonly conditions: readonly StreakCondition[];
|
|
}
|
|
|
|
export type PerDifficulty = readonly [number, number, number];
|
|
|
|
export interface StreakDefinition {
|
|
readonly id: string;
|
|
readonly hidden: boolean;
|
|
readonly afterFlight: boolean;
|
|
readonly multiStage: boolean;
|
|
readonly wp: PerDifficulty;
|
|
readonly exp: PerDifficulty;
|
|
readonly stage?: { readonly param: number; readonly wp: PerDifficulty; readonly exp: PerDifficulty };
|
|
readonly wpA: PerDifficulty;
|
|
readonly wpB: PerDifficulty;
|
|
readonly expA: PerDifficulty;
|
|
readonly expB: PerDifficulty;
|
|
readonly mode?: StreakMode;
|
|
}
|
|
|
|
export const battleStreaks: Dataset<readonly StreakDefinition[]> = {
|
|
id: 'battle-streaks',
|
|
version: 2,
|
|
extract: (source) => source.readBlk('char.vromfs.bin', 'config/unlocks.blk').blocks
|
|
.filter((block) => block.name === 'unlockable')
|
|
.flatMap((block): StreakDefinition[] => {
|
|
const params = paramsOf(block);
|
|
const id = params.id?.[0];
|
|
if (params.type?.[0] !== 'streak' || typeof id !== 'string') return [];
|
|
const stage = block.blocks.find((child) => child.name === 'stage');
|
|
const stageParams = stage && paramsOf(stage);
|
|
const stageParam = stageParams?.param?.[0];
|
|
const mode = block.blocks.find((child) => child.name === 'mode');
|
|
return [{
|
|
id,
|
|
hidden: params.hidden?.[0] === true,
|
|
afterFlight: params.isAfterFlight?.[0] === true,
|
|
multiStage: params.isMultiStage?.[0] === true,
|
|
wp: perDifficulty(params.amount_warpoints),
|
|
exp: perDifficulty(params.amount_exp),
|
|
...(stageParams && typeof stageParam === 'number'
|
|
? { stage: { param: stageParam, wp: perDifficulty(stageParams.amount_warpoints), exp: perDifficulty(stageParams.amount_exp) } }
|
|
: {}),
|
|
wpA: perDifficulty(params.wpA),
|
|
wpB: perDifficulty(params.wpB),
|
|
expA: perDifficulty(params.expA),
|
|
expB: perDifficulty(params.expB),
|
|
...(mode ? { mode: unlockModeOf(mode) } : {}),
|
|
}];
|
|
}),
|
|
};
|
|
|
|
/** An unlock mode block: its type, parameters and condition{} children (also used by wagers). */
|
|
export function unlockModeOf(block: BlkBlock): StreakMode {
|
|
const params = paramsOf(block);
|
|
return {
|
|
type: String(params.type?.[0] ?? ''),
|
|
params,
|
|
conditions: block.blocks.filter((child) => child.name === 'condition').map((condition) => {
|
|
const conditionParams = paramsOf(condition);
|
|
return { type: String(conditionParams.type?.[0] ?? ''), params: conditionParams };
|
|
}),
|
|
};
|
|
}
|
|
|
|
function paramsOf(block: BlkBlock): Record<string, StreakValue[]> {
|
|
const out: Record<string, StreakValue[]> = {};
|
|
for (const param of block.params) (out[param.name] ??= []).push(...valuesOf(param.value));
|
|
return out;
|
|
}
|
|
|
|
function valuesOf(value: BlkValue): StreakValue[] {
|
|
switch (value.type) {
|
|
case 'string':
|
|
case 'int':
|
|
case 'real':
|
|
case 'bool':
|
|
return [value.value];
|
|
case 'point3':
|
|
case 'ipoint3':
|
|
return [...value.value];
|
|
default:
|
|
return [];
|
|
}
|
|
}
|
|
|
|
/** An int applies to every difficulty; a three-value parameter is per difficulty; missing is 0. */
|
|
function perDifficulty(values: readonly StreakValue[] | undefined): PerDifficulty {
|
|
const numbers = (values ?? []).filter((value): value is number => typeof value === 'number');
|
|
if (numbers.length >= 3) return [numbers[0]!, numbers[1]!, numbers[2]!];
|
|
const single = numbers[0] ?? 0;
|
|
return [single, single, single];
|
|
}
|