Narrow the LocalMP native bridge to documented engine gaps
- Scoreboard scores come from the local service: BattleEconomy missionScores() writes the official mission scores into the stock mission block customScoreParams, which the client copies into MissionSettings+0x6d8 without reading it; local_mp_scores.c reads them with DataBlock::getReal. The hardcoded scores and the death score go. - countActivePlayers already counts players with a living vehicle; the only LocalMP gap is its filter skipping bots (MPlayer+0x1d8 bit 7). A one-byte exe patch drops that filter bit instead of a rewrite hook. - ucavLaunch returns early on a host; an exe patch skips that return instead of clearing the global host flag around the call. - onBecameDead no longer runs with isLocalMP cleared: that only queued an EventOnPlayerDeath stock LocalMP skips on purpose, and broke the local player id remap inside the function. - The host chat object keeps its two-field layout, now documented from the host chat handler that reads it.
This commit is contained in:
1 parent
901f504dc6
commit
c17c3d3384
17 files changed
+216
-120
No files matched your search
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
import type { BattleEconomyData, EconomyDifficulty, VehicleEconomy } from '../game-data/datasets/battle-economy.ts';
|
||||
import type { ModeDifficulty } from '../game-modes/catalogue/game-mode-declaration.ts';
|
||||
import type { BattleEconomyTuning, ScoredEvent, VictimGroup } from './battle-economy-tuning.ts';
|
||||
import { SCORED_EVENTS, VICTIM_GROUPS, type BattleEconomyTuning, type ScoredEvent, type VictimGroup } from './battle-economy-tuning.ts';
|
||||
|
||||
/** EXP_EVENT_* codes the LocalMP host reports (gui.vromfs.bin globalScripts/expEventConsts.nut). */
|
||||
export const ExpEvent = {
|
||||
@@ -177,6 +177,23 @@ export class BattleEconomy {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The scoreboard score of each combat event, for the mission settings block customScoreParams
|
||||
* that the native LocalMP bridge reads (native/wto-net/src/local_mp_scores.c lists the keys):
|
||||
* the official mission scores of tuning/battle-economy.jsonc, and aiKillK for victims that are
|
||||
* not players, as in the rewards.
|
||||
*/
|
||||
missionScores(): Readonly<Record<string, number>> {
|
||||
const scores: Record<string, number> = {};
|
||||
for (const group of VICTIM_GROUPS) {
|
||||
for (const event of SCORED_EVENTS) scores[`wtoScore_${event}_${group}`] = this.#tuning.eventScores[group][event];
|
||||
scores[`wtoScore_capture_${group}`] = this.#tuning.captureZoneScore[group];
|
||||
}
|
||||
scores.wtoScore_damagePerPoint = this.#tuning.navalDamageScorePerPoint;
|
||||
scores.wtoScore_aiMul = this.data.aiKillK;
|
||||
return scores;
|
||||
}
|
||||
|
||||
#score(code: number, group: VictimGroup): number | undefined {
|
||||
const scored = (event: ScoredEvent): number => this.#tuning.eventScores[group][event];
|
||||
switch (code) {
|
||||
|
||||
@@ -30,7 +30,12 @@ const VERSUS_SWITCHES: readonly string[] = [
|
||||
'allowSpare', 'isLimitedAmmo', 'allowUseArtillerySupport', 'isBotsAllowed', 'autoBalance',
|
||||
];
|
||||
|
||||
export function battleMissionSettings(plan: BattleLaunchPlan): BlkBlock {
|
||||
/**
|
||||
* `scores`: the scoreboard score table (BattleEconomy.missionScores) for the native LocalMP bridge,
|
||||
* written into the stock mission block customScoreParams, which the client copies into its
|
||||
* MissionSettings without reading it (native/wto-net/src/local_mp_scores.c).
|
||||
*/
|
||||
export function battleMissionSettings(plan: BattleLaunchPlan, scores: Readonly<Record<string, number>>): BlkBlock {
|
||||
const settings = emptyBlock();
|
||||
copyMissionParams(settings, plan);
|
||||
if (plan.level !== undefined) setParam(settings, 'level', text(plan.level));
|
||||
@@ -57,6 +62,8 @@ export function battleMissionSettings(plan: BattleLaunchPlan): BlkBlock {
|
||||
setParam(settings, 'maxBots', integer(plan.maxBots));
|
||||
|
||||
addPersistentSpawnCosts(settings, plan.extraBattleSlots);
|
||||
const scoreParams = ensureBlock(settings, 'customScoreParams');
|
||||
for (const [name, value] of Object.entries(scores)) setParam(scoreParams, name, real(value));
|
||||
for (const name of ['ranks', 'forcedRanks']) {
|
||||
const ranks = ensureBlock(settings, name);
|
||||
setParam(ranks, 'min', integer(plan.minMrank));
|
||||
@@ -129,3 +136,7 @@ function integer(value: number): BlkValue {
|
||||
function flag(value: boolean): BlkValue {
|
||||
return { type: 'bool', value };
|
||||
}
|
||||
|
||||
function real(value: number): BlkValue {
|
||||
return { type: 'real', value };
|
||||
}
|
||||
@@ -32,11 +32,15 @@ export interface BattleLaunchNotify extends Record<string, unknown> {
|
||||
readonly battle: Readonly<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
export function battleLaunchNotify(plan: BattleLaunchPlan, awards: BannerParams): BattleLaunchNotify {
|
||||
export function battleLaunchNotify(
|
||||
plan: BattleLaunchPlan,
|
||||
awards: BannerParams,
|
||||
scores: Readonly<Record<string, number>>,
|
||||
): BattleLaunchNotify {
|
||||
return {
|
||||
from: 'wto_battle',
|
||||
func: 'launch',
|
||||
mission: toWire(battleMissionSettings(plan)),
|
||||
mission: toWire(battleMissionSettings(plan, scores)),
|
||||
lobby: {
|
||||
game_mode_id: plan.modeId,
|
||||
game_mode_name: plan.modeName,
|
||||
|
||||
@@ -110,7 +110,7 @@ function handleEnqueue(
|
||||
setImmediate(() => {
|
||||
if (!deps.sessions.isPending(userId, launch.sessionId)) return;
|
||||
deps.sessions.clearPending(userId, launch.sessionId);
|
||||
deps.notifyLaunch(userId, battleLaunchNotify(launch, awards));
|
||||
deps.notifyLaunch(userId, battleLaunchNotify(launch, awards, deps.economy.missionScores()));
|
||||
});
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
// x eventScore / referenceScore(victim group)
|
||||
// Research Points = eventScore x expMul(own vehicle) x RP class factor(victim)
|
||||
// both x aiKillK when the victim is not a player.
|
||||
// The same mission scores (x aiKillK for non-player victims) are the scoreboard score: they go to
|
||||
// the client in the mission settings block customScoreParams (BattleEconomy.missionScores) and the
|
||||
// native LocalMP bridge adds them on the scoreboard.
|
||||
{
|
||||
// Destroyed-unit classes (warpoints.blk / rank.blk units{} keys) by victim group; any class not
|
||||
// listed counts as "ground".
|
||||
|
||||
Reference in new issue
Block a user