From 91563f05cb991ef9d4e24b6295f314ceba4cb3df Mon Sep 17 00:00:00 2001 From: N0VAN0M4LY <224130499+N0VAN0M4LY@users.noreply.github.com> Date: Sat, 28 Nov 2026 20:33:54 +0800 Subject: [PATCH] Take the LocalMP battle outcome when the battle is left The MissionResult HUD event did not reach the scripts before the battle was left (a nuclear win in game still settled as not won): the HUD can hold the result back (2.61.0.37 0x183edc0, delay at Hud +0xb8). The eventbus event onQuitToDebriefing, however, is raised both on the fade to the debriefing after the battle ends and when leaving from the menu, while the mission still exists; the stock debriefing gathers its result on it too. Record the end time, the closing life and the outcome there, from the mission status (success / fail; a running battle records no outcome), and drop the MissionResult subscription. Checked with check-gui; not yet verified in game. --- .../record-local-battle-awards/replace.nut | 40 ++++++------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/gui-patches/battle/record-local-battle-awards/replace.nut b/gui-patches/battle/record-local-battle-awards/replace.nut index 271dee9..dec89ff 100644 --- a/gui-patches/battle/record-local-battle-awards/replace.nut +++ b/gui-patches/battle/record-local-battle-awards/replace.nut @@ -160,43 +160,29 @@ function wtoOnLocalMpNuclearStrike(_ev) { wtoSendLiveFact("strike", strike) } -// The battle ends for the local player: close the open life and keep the end time, which the -// settlement report needs after the mission has been left (the mission is unloaded before the -// debriefing, so its time and status are gone by then). The first end counts. -function wtoEndBattleRecord() { - let { ndbExists, ndbWrite } = require("nestdb") - if (!ndbExists(["wto", "activeBattle"]) || ndbExists(["wto", "battleLog", "sessionEnd"])) - return false - wtoCloseBattleLife(false) - ndbWrite(["wto", "battleLog", "sessionEnd"], require("mission").get_mission_time()) - return true -} - -// AcesMission::endFinally raises this HUD event with the result for the local player's team on -// every end of the battle (tickets, nuclear strike, empty team), while the mission still exists. -// The end that follows on its own (FadeToDebriefing) raises no script event. -function wtoOnMissionResult(ev) { - let { GO_WIN, GO_FAIL } = require("guiMission") - let result = ev?.resultNum - if (result != GO_WIN && result != GO_FAIL) - return - if (wtoEndBattleRecord()) - require("nestdb").ndbWrite(["wto", "battleLog", "outcome"], result == GO_WIN ? "win" : "lose") -} - function wtoSubscribeBattleAwards() { let { g_hud_event_manager } = require("%scripts/hud/hudEventManager.nut") g_hud_event_manager.subscribe("wtoLocalMpExpEvent", wtoOnLocalMpExpEvent) g_hud_event_manager.subscribe("LocalPlayerAlive", wtoOnLocalPlayerAlive) g_hud_event_manager.subscribe("LocalPlayerDead", wtoOnLocalPlayerDead) g_hud_event_manager.subscribe("HudMessage", wtoOnHudMessage) - g_hud_event_manager.subscribe("MissionResult", wtoOnMissionResult) g_hud_event_manager.subscribe("wtoLocalMpNuclearStrike", wtoOnLocalMpNuclearStrike) } -// Leaving the battle from the menu before it has ended. +// The local player leaves the battle, after its end (the fade to the debriefing) or from the menu +// before it. The mission still exists here and is unloaded before the debriefing opens, so this is +// where the settlement report gets the end time and the outcome, as the stock debriefing gathers +// its result on this event (debriefingFull.nut). Leaving a running battle records no outcome. function wtoOnQuitToDebriefing(_p) { - wtoEndBattleRecord() + let { ndbExists, ndbWrite } = require("nestdb") + if (!ndbExists(["wto", "activeBattle"]) || ndbExists(["wto", "battleLog", "sessionEnd"])) + return + wtoCloseBattleLife(false) + ndbWrite(["wto", "battleLog", "sessionEnd"], require("mission").get_mission_time()) + let guiMis = require("guiMission") + let status = guiMis.get_mission_status() + if (status == guiMis.MISSION_STATUS_SUCCESS || status == guiMis.MISSION_STATUS_FAIL) + ndbWrite(["wto", "battleLog", "outcome"], status == guiMis.MISSION_STATUS_SUCCESS ? "win" : "lose") } wtoSubscribeBattleAwards()