Award the nuclear strike in LocalMP battles

Online the battle server gives killStreak_bomber_nuclear_success (mode
killStreakNuclearSuccess, 10000 SL) when a player's nuclear bomb
explodes; the LocalMP host has no battle server, so the award was never
given.

The native nuke module now remembers whether the local player launched
the instant-win bomb and, when it explodes, raises the HUD script event
wtoLocalMpNuclearStrike. The battle record keeps it as a strike, sends
it live (wto_battle.fact kind "strike") and reports it after the battle
(strikes{}); the local service awards killStreakNuclearSuccess once per
strike, live as the award banner and in the settlement.

Checked with typecheck, check-gui, check-offsets and the native build;
not yet verified in game.
This commit is contained in:
N0VAN0M4LY committed 2026-11-28 19:03:24 +08:00
1 parent 28aa6ec971
commit 6ab941a086
9 files changed
+72 -14

No files matched your search

+15
View File
@@ -81,6 +81,21 @@ void local_mp_report_award_event(const LocalMpAwardEvent *ev)
fn_blk_dtor(blk);
}
/* The fact behind the award killStreak_bomber_nuclear_success, which online the battle server
* judges itself; the event carries no fields. */
void local_mp_report_nuclear_strike(void)
{
__declspec(align(16)) uint8_t blk[LMP_BLK_SIZE];
uint8_t *gsd = g_game_save_data ? *g_game_save_data : NULL;
if (gsd == NULL || fn_hud_notify_script == NULL)
return;
memset(blk, 0, sizeof(blk));
fn_blk_ctor(blk);
fn_hud_notify_script(gsd + g_hud_queue_off, LMP_NUCLEAR_STRIKE_EVENT_NAME, blk);
fn_blk_dtor(blk);
}
static void *call_target(uint8_t *score_msg, size_t call_off)
{
return local_mp_resolve_rip(score_msg + call_off, 1, 5);
+3
View File
@@ -12,6 +12,8 @@
/* HUD script event raised for each combat event of the local player (local_mp_awards.c). */
#define LMP_AWARD_EVENT_NAME "wtoLocalMpExpEvent"
/* HUD script event raised when the local player's instant-win bomb explodes (local_mp_nuke.c). */
#define LMP_NUCLEAR_STRIKE_EVENT_NAME "wtoLocalMpNuclearStrike"
typedef char *(__fastcall *LmpGetPlayerCountryFn)(uint8_t *mis, int32_t pid, char *buf, int32_t buf_size);
typedef void (__fastcall *LmpSetPlayerGuiStateFn)(int32_t player_id, int32_t state);
@@ -62,6 +64,7 @@ void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int is_si
/* Combat event reporting to the GUI scripts (local_mp_awards.c). */
void local_mp_report_award_event(const LocalMpAwardEvent *ev);
void local_mp_report_nuclear_strike(void);
const char *local_mp_unit_exp_class(const uint8_t *unit);
/* Mission scores of combat events from the mission settings (local_mp_scores.c). */
+18 -11
View File
@@ -14,7 +14,9 @@
* 2. Projectile explosion 0xbe7c00: the host's shell update passes the launch record's flag as
* its 8th argument (movzx eax, byte [r15+0x70] at 0x2fd778, call at 0x2fd7c3); with the flag
* set it plays the nuclear explosion (flag 0x7bf4958+0x2be2, camera type 0x17 at 0xbe97e6) and
* nothing else. The remembered team becomes the winner.
* nothing else. The remembered team becomes the winner; a bomb of the local player is also
* reported to the scripts (LMP_NUCLEAR_STRIKE_EVENT_NAME), the fact of the award
* killStreak_bomber_nuclear_success that online the battle server gives.
* 3. Domination logic cta_logic_action (0x11bc400, the mp_update_trig action registered at
* 0x11ba558): before it runs, the loser's mission variable mpTi1 / mpTi2 (tickets of team 1 / 2,
* looked up at 0x11bd1c7) is set to 0. The stock logic then ends the battle as on tickets:
@@ -38,24 +40,22 @@ static ShellLaunchFn orig_shell_launch;
static ShellExplodeFn orig_shell_explode;
static LogicActionFn orig_cta_logic;
/* Team of the last launched instant-win bomb, and the team that won with it (0 = none). */
/* Team of the last launched instant-win bomb and whether the local player launched it, and the
* team that won with it (0 = none). */
static volatile uint8_t g_bomb_team;
static volatile uint8_t g_bomb_is_local;
static volatile uint8_t g_winner_team;
static uint8_t *g_logic_ctx;
static uint8_t owner_team(const uint8_t *unit)
static const uint8_t *owner_mplayer(const uint8_t *unit)
{
const uint8_t *mp;
if (unit == NULL)
return 0;
mp = *(uint8_t *const *)(unit + LMP_UNIT_OFF_MPLAYER);
return mp != NULL ? mp[LMP_MP_OFF_TEAM] : 0;
return unit != NULL ? *(const uint8_t *const *)(unit + LMP_UNIT_OFF_MPLAYER) : NULL;
}
static void __fastcall hook_shell_launch(void **launch, void *a2, uint8_t *owner, void *a4, uint64_t a5, uint64_t a6)
{
const uint8_t *record;
const uint8_t *mp;
uint8_t team;
orig_shell_launch(launch, a2, owner, a4, a5, a6);
@@ -64,12 +64,14 @@ static void __fastcall hook_shell_launch(void **launch, void *a2, uint8_t *owner
record = (const uint8_t *)launch[LMP_SHELL_LAUNCH_IDX_RECORD];
if (record == NULL || record[LMP_SHELL_REC_OFF_INSTANT_WIN] != 1)
return;
team = owner_team(owner);
mp = owner_mplayer(owner);
team = mp != NULL ? mp[LMP_MP_OFF_TEAM] : 0;
if (team != 1 && team != 2)
return;
if (g_bomb_team != team)
log_line("local_mp: instant-win bomb launched by team %u", (unsigned)team);
g_bomb_team = team;
g_bomb_is_local = local_mp_is_local_mplayer(mp) ? 1 : 0;
}
static void __fastcall hook_shell_explode(void *a1, uint64_t a2, void *a3, void *a4, void *a5, void *a6,
@@ -80,7 +82,11 @@ static void __fastcall hook_shell_explode(void *a1, uint64_t a2, void *a3, void
return;
g_winner_team = g_bomb_team;
g_bomb_team = 0;
log_line("local_mp: nuclear explosion, team %u wins", (unsigned)g_winner_team);
log_line("local_mp: nuclear explosion, team %u wins%s", (unsigned)g_winner_team,
g_bomb_is_local ? " (local player's bomb)" : "");
if (g_bomb_is_local)
local_mp_report_nuclear_strike();
g_bomb_is_local = 0;
}
static int *mission_int_var(uint8_t *ctx, const char *name)
@@ -106,6 +112,7 @@ static uint64_t __fastcall hook_cta_logic(uint8_t *ctx, void *a2, void *a3, void
/* A new mission: nothing launched or won in the previous one carries over. */
g_logic_ctx = ctx;
g_bomb_team = 0;
g_bomb_is_local = 0;
g_winner_team = 0;
}
if (ctx != NULL && g_winner_team != 0 && local_mp_is_host()) {