Price LocalMP battle rewards in the local service
The LocalMP host has no battle server, and the previous bridge filled the gap by computing money in the client: the native ledger wrote invented amounts into SessionStatsNet, the spawn patch derived reward rates from warpoints.blk, and the settlement patch summed and rescaled the result. Rewards came out as zero or several orders of magnitude too high. Now the client reports facts and the local service prices them. Native (wto_ws.dll): - local_mp_ledger.c is removed together with its SessionStatsNet offsets and four signatures (43 -> 39). - local_mp_awards.c raises the HUD script event wtoLocalMpExpEvent for every combat event of the local player (event code, victim expClass and name, player or AI victim, friendly, naval damage). The DataBlock helpers and the HUD event queue are resolved from call sites inside GameSaveData::addScoreMessage, which already has a signature. GUI patches: - record-local-battle-awards records events and lives in nestdb and raises the stock InBattleReward banner from launch-time parameters. - report-local-battle-settlement sends only facts and rebuilds the debriefing from the settled table; failures show the stock error box. - use-settled-debriefing-stats makes gatherDebriefingResult read that table instead of the empty stat_get_exp(). - pass-spawn-modifications-blk no longer computes economy factors. Local service: - battle-economy dataset reads every reward factor from wpcost.blk, warpoints.blk and rank.blk; tuning/battle-economy.jsonc holds the mission score per event with its source (official values where published, otherwise marked). - battle-economy.ts is the single pricing function, shared by the banner parameters and the settlement; battle-rewards.ts adds battle time, timed award, win/defeat bonus, activity, premium account, talisman, skill bonus and free research points; the debriefing table has the stat_get_exp() layout and travels in EULT_SESSION_RESULT. - Crews earn skill points from the battle's research points. - A battle left before it ends counts as a defeat. Verified: npm run typecheck, check-gui (35 patches), check-patches, check-offsets, native build. Not yet run in game.
This commit is contained in:
1 parent
b1392c0512
commit
7f570c85c3
39 files changed
+1488
-1128
No files matched your search
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* Dataset: the battle reward factors the game files carry (implementation notes "3d").
|
||||
*
|
||||
* char.vromfs.bin config/wpcost.blk, per vehicle:
|
||||
* unitClass, expMul, rewardMul<Arcade|Historical|Simulation>, battleTimeAward<...>, timedAward<...>
|
||||
* char.vromfs.bin config/warpoints.blk:
|
||||
* aKill (Silver Lions of a reference kill), aiKillK, winK, defeatK, wpMultiplier (premium account),
|
||||
* units{} (Silver Lions factor by the destroyed unit's expClass)
|
||||
* char.vromfs.bin config/rank.blk:
|
||||
* xpMultiplier (premium account), goldPlaneExpMul (premium vehicle / talisman),
|
||||
* expForVictoryVersusPerSec, expForPlayingVersusPerSec, crew_exp_mul_<difficulty>, denominateFreeExp,
|
||||
* units{} (Research Points factor by the destroyed unit's expClass),
|
||||
* ExpSkillBonus{<economic name>{BonusLevel<N>{bonusPercent, kills|damage}}}
|
||||
*
|
||||
* The stock client shows the same factors on the vehicle card (gui.vromfs.bin scripts/airinfo.nut,
|
||||
* reward formula: expMul x (1 + premium + talisman), rewardMul x (1 + premium)).
|
||||
*/
|
||||
import type { BlkBlock } from '@wto/blk';
|
||||
import { blockAt, numberField, stringField } from './blk-fields.ts';
|
||||
import type { Dataset } from './dataset.ts';
|
||||
|
||||
export type EconomyDifficulty = 'arcade' | 'historical' | 'simulation';
|
||||
|
||||
const DIFFICULTY_SUFFIX: Readonly<Record<EconomyDifficulty, string>> = {
|
||||
arcade: 'Arcade',
|
||||
historical: 'Historical',
|
||||
simulation: 'Simulation',
|
||||
};
|
||||
|
||||
export interface VehicleEconomy {
|
||||
readonly unitClass: string;
|
||||
readonly expMul: number;
|
||||
readonly rewardMul: Readonly<Record<EconomyDifficulty, number>>;
|
||||
readonly battleTimeAward: Readonly<Record<EconomyDifficulty, number>>;
|
||||
readonly timedAward: Readonly<Record<EconomyDifficulty, number>>;
|
||||
}
|
||||
|
||||
export interface SkillBonusLevel {
|
||||
readonly level: number;
|
||||
readonly bonusPercent: number;
|
||||
/** Kills needed, or naval damage needed when `metric` is "damage". */
|
||||
readonly threshold: number;
|
||||
readonly metric: 'kills' | 'damage';
|
||||
}
|
||||
|
||||
export interface BattleEconomyData {
|
||||
readonly vehicles: Readonly<Record<string, VehicleEconomy>>;
|
||||
readonly killSilverLions: number;
|
||||
readonly aiKillK: number;
|
||||
readonly winK: number;
|
||||
readonly defeatK: number;
|
||||
readonly premiumSilverLionsMul: number;
|
||||
readonly premiumResearchMul: number;
|
||||
readonly talismanResearchMul: number;
|
||||
readonly silverLionsClassFactors: Readonly<Record<string, number>>;
|
||||
readonly researchClassFactors: Readonly<Record<string, number>>;
|
||||
readonly researchPerSecondWin: number;
|
||||
readonly researchPerSecondPlaying: number;
|
||||
readonly crewExpMul: Readonly<Record<EconomyDifficulty, number>>;
|
||||
readonly freeResearchDivisor: number;
|
||||
readonly skillBonus: Readonly<Record<string, readonly SkillBonusLevel[]>>;
|
||||
}
|
||||
|
||||
export const battleEconomy: Dataset<BattleEconomyData> = {
|
||||
id: 'battle-economy',
|
||||
version: 1,
|
||||
extract: (source) => {
|
||||
const wpcost = source.readBlk('char.vromfs.bin', 'config/wpcost.blk');
|
||||
const warpoints = source.readBlk('char.vromfs.bin', 'config/warpoints.blk');
|
||||
const rank = source.readBlk('char.vromfs.bin', 'config/rank.blk');
|
||||
const required = (block: BlkBlock, file: string, name: string): number => {
|
||||
const value = numberField(block, name);
|
||||
if (value === undefined) throw new Error(`${file}: ${name} is missing`);
|
||||
return value;
|
||||
};
|
||||
return {
|
||||
vehicles: Object.fromEntries(wpcost.blocks.map((vehicle) => [vehicle.name, vehicleEconomy(vehicle)])),
|
||||
killSilverLions: required(warpoints, 'warpoints.blk', 'aKill'),
|
||||
aiKillK: required(warpoints, 'warpoints.blk', 'aiKillK'),
|
||||
winK: required(warpoints, 'warpoints.blk', 'winK'),
|
||||
defeatK: required(warpoints, 'warpoints.blk', 'defeatK'),
|
||||
premiumSilverLionsMul: required(warpoints, 'warpoints.blk', 'wpMultiplier'),
|
||||
premiumResearchMul: required(rank, 'rank.blk', 'xpMultiplier'),
|
||||
talismanResearchMul: required(rank, 'rank.blk', 'goldPlaneExpMul'),
|
||||
silverLionsClassFactors: numberMap(blockAt(warpoints, 'units')),
|
||||
researchClassFactors: numberMap(blockAt(rank, 'units')),
|
||||
researchPerSecondWin: required(rank, 'rank.blk', 'expForVictoryVersusPerSec'),
|
||||
researchPerSecondPlaying: required(rank, 'rank.blk', 'expForPlayingVersusPerSec'),
|
||||
crewExpMul: {
|
||||
arcade: required(rank, 'rank.blk', 'crew_exp_mul_arcade'),
|
||||
historical: required(rank, 'rank.blk', 'crew_exp_mul_historical'),
|
||||
simulation: required(rank, 'rank.blk', 'crew_exp_mul_simulation'),
|
||||
},
|
||||
freeResearchDivisor: required(rank, 'rank.blk', 'denominateFreeExp'),
|
||||
skillBonus: skillBonusTable(blockAt(rank, 'ExpSkillBonus')),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
function vehicleEconomy(vehicle: BlkBlock): VehicleEconomy {
|
||||
const perDifficulty = (prefix: string, fallback: number): Record<EconomyDifficulty, number> => ({
|
||||
arcade: numberField(vehicle, `${prefix}${DIFFICULTY_SUFFIX.arcade}`) ?? fallback,
|
||||
historical: numberField(vehicle, `${prefix}${DIFFICULTY_SUFFIX.historical}`) ?? fallback,
|
||||
simulation: numberField(vehicle, `${prefix}${DIFFICULTY_SUFFIX.simulation}`) ?? fallback,
|
||||
});
|
||||
return {
|
||||
unitClass: stringField(vehicle, 'unitClass') ?? '',
|
||||
expMul: numberField(vehicle, 'expMul') ?? 1,
|
||||
// The client reads a missing rewardMul as 1.0 (scripts/unit/unit.nut getWpRewardMulList).
|
||||
rewardMul: perDifficulty('rewardMul', 1),
|
||||
battleTimeAward: perDifficulty('battleTimeAward', 0),
|
||||
timedAward: perDifficulty('timedAward', 0),
|
||||
};
|
||||
}
|
||||
|
||||
function numberMap(block: BlkBlock | undefined): Record<string, number> {
|
||||
return Object.fromEntries((block?.params ?? []).flatMap((param) =>
|
||||
param.value.type === 'real' || param.value.type === 'int' ? [[param.name, param.value.value]] : []));
|
||||
}
|
||||
|
||||
function skillBonusTable(block: BlkBlock | undefined): Record<string, SkillBonusLevel[]> {
|
||||
return Object.fromEntries((block?.blocks ?? []).map((event) => [
|
||||
event.name,
|
||||
event.blocks.flatMap((level): SkillBonusLevel[] => {
|
||||
const index = /^BonusLevel(\d+)$/.exec(level.name)?.[1];
|
||||
const bonusPercent = numberField(level, 'bonusPercent');
|
||||
const kills = numberField(level, 'kills');
|
||||
const damage = numberField(level, 'damage');
|
||||
if (index === undefined || bonusPercent === undefined || (kills === undefined && damage === undefined)) return [];
|
||||
return [{
|
||||
level: Number(index),
|
||||
bonusPercent,
|
||||
threshold: kills ?? damage ?? 0,
|
||||
metric: kills !== undefined ? 'kills' : 'damage',
|
||||
}];
|
||||
}).sort((a, b) => a.level - b.level),
|
||||
]));
|
||||
}
|
||||
Reference in new issue
Block a user