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.
76 lines
3.1 KiB
Plaintext
76 lines
3.1 KiB
Plaintext
matchingApiFunc("match.enqueue", cb, params)
|
|
}
|
|
|
|
// WTOffline: rebuild a DataBlock sent by the local service as { p = [[name, type, value]], b = [[name, node]] }.
|
|
// The type ("t", "i", "r", "b") travels with each value because the engine reads ints and reals with typed getters.
|
|
function wtoBlkFromWire(blk, node) {
|
|
foreach (param in (node?.p ?? [])) {
|
|
let [name, kind, value] = param
|
|
blk[name] <- kind == "i" ? value.tointeger()
|
|
: kind == "r" ? value.tofloat()
|
|
: kind == "b" ? value == true
|
|
: value.tostring()
|
|
}
|
|
foreach (child in (node?.b ?? []))
|
|
wtoBlkFromWire(blk.addNewBlock(child[0]), child[1])
|
|
return blk
|
|
}
|
|
|
|
// WTOffline: start a local battle pushed by the local service (mrpc.generic_notify, from = "wto_battle").
|
|
// The service sends the complete mission settings; the client hosts the battle as a LocalMP session.
|
|
function onWtoBattleNotify(ev) {
|
|
if (ev?.func != "launch" || isInFlight())
|
|
return
|
|
let DataBlock = require("DataBlock")
|
|
let { ndbWrite, ndbExists, ndbDelete } = require("nestdb")
|
|
let guiMis = require("guiMission")
|
|
let { set_game_mode } = require("mission")
|
|
let { GM_DOMINATION } = require("%globalScripts/gameModeNativeConsts.nut")
|
|
let { reset_cur_mission_mode } = require("%appGlobals/ranks_common_shared.nut")
|
|
let { notifyQueueLeave } = require("%scripts/queue/queueManager.nut")
|
|
let destroySessionScripted = require("%scripts/matchingRooms/destroySessionScripted.nut")
|
|
let { invalidateCrewsList } = require("%scripts/slotbar/crewsList.nut")
|
|
let { guiStartFlight } = require("%scripts/missions/startMissionsList.nut")
|
|
let { currentCampaignMission } = require("%scripts/missions/missionsStates.nut")
|
|
let lobbyStates = require("%scripts/matchingRooms/lobbyStates.nut")
|
|
let { setSessionLobbySettings, switchSessionLobbyStatus } = require("%scripts/matchingRooms/sessionLobbyManager.nut")
|
|
|
|
notifyQueueLeave({})
|
|
destroySessionScripted("on start wto local battle")
|
|
ndbWrite(["wto", "activeBattle"], ev.battle)
|
|
if (ndbExists(["wto", "battleLog"]))
|
|
ndbDelete(["wto", "battleLog"])
|
|
invalidateCrewsList(true)
|
|
|
|
let misBlk = wtoBlkFromWire(DataBlock(), ev.mission)
|
|
misBlk._gameMode = GM_DOMINATION
|
|
let lobby = ev.lobby
|
|
lobby.mission._gameMode <- GM_DOMINATION
|
|
|
|
currentCampaignMission.set(misBlk.name)
|
|
set_game_mode(GM_DOMINATION)
|
|
setSessionLobbySettings(lobby, true, false)
|
|
switchSessionLobbyStatus(lobbyStates.IN_SESSION)
|
|
reset_cur_mission_mode()
|
|
guiMis.select_training_mission(misBlk)
|
|
reset_cur_mission_mode()
|
|
guiStartFlight()
|
|
}
|
|
|
|
// WTOffline: forget the battle record when the session ends outside a battle (left before loading).
|
|
require("%sqStdLibs/helpers/subscriptions.nut").addListenersWithoutEnv({
|
|
SessionDestroyed = function(_p) {
|
|
if (!isInFlight()) {
|
|
let { ndbExists, ndbDelete } = require("nestdb")
|
|
if (ndbExists(["wto", "activeBattle"])) {
|
|
ndbDelete(["wto", "activeBattle"])
|
|
require("%scripts/slotbar/crewsList.nut").invalidateCrewsList(true)
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
require("%scripts/matching/serviceNotifications/mrpc.nut").mnSubscribe("wto_battle", onWtoBattleNotify)
|
|
|
|
matchingRpcSubscribe("match.notify_clusters_changed", onClustersChanged)
|