feat(battle): grant the nuclear strike award in LocalMP
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:
1 parent
8494269c55
commit
bc6b137a6a
9 files changed
+72
-14
No files matched your search
@@ -11,6 +11,7 @@ export interface LiveBattleLog {
|
||||
readonly events: ReportedCombatEvent[];
|
||||
readonly lives: BattleLife[];
|
||||
readonly feed: FeedKill[];
|
||||
readonly nuclearStrikes: number[];
|
||||
/** Keys of the awards already announced (battle-streaks.ts AwardedStreak.key). */
|
||||
readonly announced: Set<string>;
|
||||
}
|
||||
@@ -26,7 +27,7 @@ export class BattleLiveLogs {
|
||||
of(sessionId: string): LiveBattleLog {
|
||||
let log = this.#logs.get(sessionId);
|
||||
if (!log) {
|
||||
log = { events: [], lives: [], feed: [], announced: new Set() };
|
||||
log = { events: [], lives: [], feed: [], nuclearStrikes: [], announced: new Set() };
|
||||
this.#logs.set(sessionId, log);
|
||||
while (this.#logs.size > this.#maxRetained) this.#logs.delete(this.#logs.keys().next().value!);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
* players{ p{ id:i team:i score:i kills:i groundKills:i humanKills:i navalKills:i aiKills:i
|
||||
* aiGroundKills:i aiNavalKills:i assists:i deaths:i } ... }
|
||||
* the final scoreboard
|
||||
* strikes{ s{ time:r } ... } explosions of the local player's
|
||||
* nuclear bombs (native local_mp_nuke.c)
|
||||
* spares{ <unit>:i ... } backup vehicles used
|
||||
*/
|
||||
import { findBlock, type BlkBlock } from '@wto/blk';
|
||||
@@ -79,6 +81,8 @@ export interface BattleReport {
|
||||
readonly events: readonly ReportedCombatEvent[];
|
||||
readonly feed: readonly FeedKill[];
|
||||
readonly players: readonly ScoreboardPlayer[];
|
||||
/** Mission times at which the local player's nuclear bombs exploded. */
|
||||
readonly nuclearStrikes: readonly number[];
|
||||
readonly usedSpares: Readonly<Record<string, number>>;
|
||||
}
|
||||
|
||||
@@ -134,6 +138,7 @@ export function parseBattleReport(payload: BlkBlock): BattleReport | undefined {
|
||||
team: intOf(block, 'team'),
|
||||
...Object.fromEntries(SCOREBOARD_FIELDS.map((field) => [field, Math.max(0, intOf(block, field))])) as Record<(typeof SCOREBOARD_FIELDS)[number], number>,
|
||||
})),
|
||||
nuclearStrikes: (findBlock(payload, 'strikes')?.blocks ?? []).map((block) => realOf(block, 'time')).sort((a, b) => a - b),
|
||||
usedSpares: parseSpareMap(findBlock(payload, 'spares')),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
* (not those limited by battle rating, e.g. heroic_punisher)
|
||||
* unlocks `num` of the listed awards earned in the battle (all when
|
||||
* num is missing, as scripts unlocksConditions.nut counts)
|
||||
* killStreakNuclearSuccess each explosion of the local player's nuclear bomb
|
||||
* (killStreak_bomber_nuclear_success)
|
||||
* Not supported (the facts are not reported): finalBlow, lastManStanding, killWithoutHit,
|
||||
* hitWithoutDeath, killWithoutMiss, landings, scout / repair / extinguish help, squad awards,
|
||||
* kill-streak support vehicles, shell interception, specified naval damage, event missions; and
|
||||
* other kill-streak support vehicles, shell interception, specified naval damage, event missions; and
|
||||
* any award with a condition on weapon, distance, head shot, scouting, death reason, offender
|
||||
* flags, unit tags or the awards' platform-free "customOnline" / "mission". Their awards are
|
||||
* never given.
|
||||
@@ -46,6 +48,8 @@ export interface StreakFacts {
|
||||
readonly events: readonly ReportedCombatEvent[];
|
||||
readonly lives: readonly BattleLife[];
|
||||
readonly feed: readonly FeedKill[];
|
||||
/** Mission times at which the local player's nuclear bombs exploded. */
|
||||
readonly nuclearStrikes: readonly number[];
|
||||
readonly localPlayerId: number;
|
||||
readonly localTeam: number;
|
||||
/** The final scoreboard; absent while the battle runs (after-battle awards are then skipped). */
|
||||
@@ -167,6 +171,9 @@ export function evaluateStreaks(definitions: readonly StreakDefinition[], facts:
|
||||
case 'missionsWon':
|
||||
if (facts.outcome === 'win') award(def, facts.sessionEnd, 1);
|
||||
break;
|
||||
case 'killStreakNuclearSuccess':
|
||||
for (const time of facts.nuclearStrikes) award(def, time, 1);
|
||||
break;
|
||||
case 'firstKill': {
|
||||
const first = facts.feed.find((k) => k.killerTeam !== k.victimTeam);
|
||||
if (first && first.killer === facts.localPlayerId) award(def, first.time, 1);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* "event": time:f unit:s code:i expClass:s victim:s victimIsPlayer:b friendly:b modifier:s damage:i
|
||||
* "life": unit:s start:f end:f died:b
|
||||
* "kill": time:f killer:i killerTeam:i victim:i victimTeam:i
|
||||
* "strike": time:f the local player's nuclear bomb exploded
|
||||
* answer: { streaks: [{ id:s stage:i (-1 = single-stage) stageParam:i wp:i exp:i }] }
|
||||
*/
|
||||
import type { BattleLiveLogs } from '../battle/battle-live-log.ts';
|
||||
@@ -34,9 +35,10 @@ export function battleLiveRequests(deps: BattleLiveDependencies): Array<[string,
|
||||
events: log.events,
|
||||
lives: log.lives,
|
||||
feed: log.feed,
|
||||
nuclearStrikes: log.nuclearStrikes,
|
||||
localPlayerId: int(p.localPlayerId, -1),
|
||||
localTeam: int(p.localTeam, 0),
|
||||
sessionEnd: Math.max(0, ...log.lives.map((life) => life.end), ...log.events.map((e) => e.time)),
|
||||
sessionEnd: Math.max(0, ...log.lives.map((life) => life.end), ...log.events.map((e) => e.time), ...log.nuclearStrikes),
|
||||
}, session);
|
||||
const fresh = awarded.filter((streak) => !streak.hidden && !log.announced.has(streak.key));
|
||||
for (const streak of fresh) log.announced.add(streak.key);
|
||||
@@ -62,6 +64,9 @@ function recordFact(log: ReturnType<BattleLiveLogs['of']>, p: Readonly<Record<st
|
||||
case 'kill':
|
||||
log.feed.push({ time: num(p.time), killer: int(p.killer, -1), killerTeam: int(p.killerTeam, 0), victim: int(p.victim, -1), victimTeam: int(p.victimTeam, 0) });
|
||||
return true;
|
||||
case 'strike':
|
||||
log.nuclearStrikes.push(num(p.time));
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user