feat(battle): wire Nuclear Escalation launch and airfield cooldowns
Connect Air Realistic sub-mode 103 (Nuclear Escalation) mission launch settings and LocalMP respawn/airfield-cooldown handling: - Server: support mode-level maxRespawns (UNLIMITED_RESPAWNS = -2) and per-mode missionRuleKeys so Nuclear Escalation forwards customHUD, stage thresholds, useSpawnDelay, afterRespawnDelaySec, and battle display flags from the stock missions; reject queues when no candidate mode is eligible for the lineup; disable spares and emit wtoUnlimitedRespawns for unlimited-respawn modes. - Native: keep slots usable when wtoUnlimitedRespawns is set and emit wtoLocalMpAirfieldSpawn with the unit name and spawn base ID when the local player actually enters pilot control. - GUI patches: track confirmed LocalMP airfield departures in scripts/respawn/respawnbases.nut and feed the computed per-base delays into scripts/respawn/respawn.nut slot countdowns and spawn checks. Stage-unlocked dedicated event aircraft allocation by faction and room BR is not yet wired and remains pending research. Verified with root and launcher typechecks, check-patches and check-gui on 2.61.0.37 and 2.61.0.58, and native wto_ws.dll build; pending in-game verification.
This commit is contained in:
1 parent
646be7afb9
commit
f1ec034994
24 files changed
+240
-24
No files matched your search
@@ -10,7 +10,7 @@ import type { BattleSpawnRulesData } from '../game-data/datasets/battle-spawn-ru
|
||||
import type { MissionHeader } from '../game-data/datasets/multiplayer-missions.ts';
|
||||
import type { CatalogueVehicle } from '../game-data/datasets/vehicle-catalogue.ts';
|
||||
import type { GameModes, OfferedGameMode } from '../game-modes/game-modes.ts';
|
||||
import { MISSION_DIFFICULTY, SINGLE_SPAWN } from '../game-modes/mode-definition.ts';
|
||||
import { MISSION_DIFFICULTY, SINGLE_SPAWN, modeMaxRespawns } from '../game-modes/mode-definition.ts';
|
||||
import { serverTimeNow, serverTimeToUnixSeconds } from '../profile/server-time.ts';
|
||||
import { selectBattleCoalitions, type CoalitionPairing } from './battle-coalitions.ts';
|
||||
import { selectExtraBattleSlots, type ExtraBattleSlot } from './battle-extra-slots.ts';
|
||||
@@ -51,6 +51,7 @@ export interface BattleLaunchPlan {
|
||||
readonly missionName: string;
|
||||
/** The mission as the game describes it, including the parameters copied into the mission settings. */
|
||||
readonly mission: MissionHeader;
|
||||
readonly missionRuleKeys: readonly string[];
|
||||
readonly missionFile: string;
|
||||
readonly missionType: string;
|
||||
readonly level?: string;
|
||||
@@ -68,6 +69,7 @@ export interface BattleLaunchPlan {
|
||||
readonly maxMrank: number;
|
||||
readonly maxPlayers: number;
|
||||
readonly maxBots: number;
|
||||
readonly maxRespawns?: number;
|
||||
readonly tankBotRespawns: number;
|
||||
readonly airBotRespawns: number;
|
||||
readonly useTankBots: boolean;
|
||||
@@ -164,7 +166,7 @@ export class BattleMatchmaker {
|
||||
const pool = candidates.filter((mode) => isModeEligibleForLineup(
|
||||
mode.declaration, input.slotVehicles, input.selectedSlot?.unitName, this.#vehiclesByName, input.mrankDeltas,
|
||||
));
|
||||
if (pool.length === 0) return candidates.find((mode) => mode.declaration.multiSlot !== false);
|
||||
if (pool.length === 0) return undefined;
|
||||
const classics = pool.filter((mode) => !mode.declaration.tag);
|
||||
const subModes = pool.filter((mode) => Boolean(mode.declaration.tag));
|
||||
if (subModes.length > 0 && classics.length > 0) {
|
||||
@@ -189,6 +191,7 @@ export class BattleMatchmaker {
|
||||
const desiredPlayers = declaration.isSmallTeams ? this.#tuning.smallTeamsMaxPlayers : this.#tuning.maxPlayers;
|
||||
const maxPlayers = Math.min(desiredPlayers, maxSlotsForMission(mission, desiredPlayers));
|
||||
const maxBots = Math.min(this.#tuning.maxBots, Math.max(1, maxPlayers - 1));
|
||||
const maxRespawns = modeMaxRespawns(declaration);
|
||||
const missionLocName = resolveMissionLocName(mission);
|
||||
const environment = declaration.environmentOverride ?? mission.environment;
|
||||
const session = this.#sessions.create({
|
||||
@@ -224,6 +227,7 @@ export class BattleMatchmaker {
|
||||
economicName: declaration.economicName,
|
||||
missionName: mission.name,
|
||||
mission,
|
||||
missionRuleKeys: declaration.missionRuleKeys ?? [],
|
||||
missionFile: mission.path,
|
||||
missionType: mission.type ?? 'domination',
|
||||
...(mission.level !== undefined ? { level: mission.level } : {}),
|
||||
@@ -241,6 +245,7 @@ export class BattleMatchmaker {
|
||||
maxMrank,
|
||||
maxPlayers,
|
||||
maxBots,
|
||||
...(maxRespawns === undefined ? {} : { maxRespawns }),
|
||||
tankBotRespawns: this.#tuning.tankBotRespawns,
|
||||
airBotRespawns: declaration.multiSlot === false ? SINGLE_SPAWN : this.#tuning.airBotRespawns,
|
||||
useTankBots: allowedSet.has('tank'),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* difficulty. `_gameMode` is left to the client, which takes it from its own native constants.
|
||||
*/
|
||||
import { emptyBlock, ensureBlock, setParam, appendParam, type BlkBlock, type BlkParam, type BlkValue } from '@wto/blk';
|
||||
import { SINGLE_SPAWN } from '../game-modes/mode-definition.ts';
|
||||
import { UNLIMITED_RESPAWNS } from '../game-modes/mode-definition.ts';
|
||||
import type { ExtraBattleSlot } from './battle-extra-slots.ts';
|
||||
import type { BattleLaunchPlan } from './battle-matchmaker.ts';
|
||||
import type { CustomBotsPool } from './battle-ranks.ts';
|
||||
@@ -62,9 +62,9 @@ export function battleMissionSettings(plan: BattleLaunchPlan, scores: Readonly<R
|
||||
for (const name of VERSUS_SWITCHES) setParam(settings, name, flag(true));
|
||||
// The native in-flight rearm request and its receiver both require unlimited reserve ammunition.
|
||||
setParam(settings, 'isLimitedAmmo', flag(plan.modeName !== 'air_arcade'));
|
||||
setParam(settings, 'allowSpare', flag(!plan.selectedSlot));
|
||||
setParam(settings, 'allowSpare', flag(!plan.selectedSlot && plan.maxRespawns !== UNLIMITED_RESPAWNS));
|
||||
if (plan.maxRespawns !== undefined) setParam(settings, 'maxRespawns', integer(plan.maxRespawns));
|
||||
if (plan.selectedSlot) {
|
||||
setParam(settings, 'maxRespawns', integer(SINGLE_SPAWN));
|
||||
setParam(settings, 'ctaInstantDecreaseTicketsWhenNoRespawn', flag(true));
|
||||
// The native mission loader reads the AI limit at the top level, after its bots.blk default.
|
||||
setParam(settings, 'numBotRespawns', integer(plan.airBotRespawns));
|
||||
@@ -90,14 +90,15 @@ export function battleMissionSettings(plan: BattleLaunchPlan, scores: Readonly<R
|
||||
}
|
||||
|
||||
function copyMissionParams(settings: BlkBlock, plan: BattleLaunchPlan): void {
|
||||
const wanted = new Set([...LOCALIZATION_KEYS, ...RULE_KEYS]);
|
||||
const ruleKeys = new Set([...RULE_KEYS, ...plan.missionRuleKeys]);
|
||||
const wanted = new Set([...LOCALIZATION_KEYS, ...ruleKeys]);
|
||||
const copy = (params: readonly BlkParam[] | undefined, keys: ReadonlySet<string>): void => {
|
||||
for (const param of params ?? []) {
|
||||
if (keys.has(param.name)) setParam(settings, param.name, param.value);
|
||||
}
|
||||
};
|
||||
copy(plan.mission.missionParams, wanted);
|
||||
copy(plan.mission.difficultyParams[plan.difficulty], new Set(RULE_KEYS));
|
||||
copy(plan.mission.difficultyParams[plan.difficulty], ruleKeys);
|
||||
}
|
||||
|
||||
/** Fixed spawn costs of extra slots, read back by the spawn score respondents (customSpawnScore). */
|
||||
@@ -117,6 +118,7 @@ function customBotsBlock(plan: BattleLaunchPlan): BlkBlock {
|
||||
setParam(bots, 'wtoPlayerTeam', text(String(plan.playerTeam)));
|
||||
setParam(bots, 'wtoTeamACountries', text(plan.countriesAllies.join(';')));
|
||||
setParam(bots, 'wtoTeamBCountries', text(plan.countriesAxis.join(';')));
|
||||
if (plan.maxRespawns === UNLIMITED_RESPAWNS) setParam(bots, 'wtoUnlimitedRespawns', text('1'));
|
||||
setParam(bots, 'numBotRespawnsInMultiSlot', integer(plan.airBotRespawns));
|
||||
setParam(bots, 'numTankBotRespawnsInMultiSlot', integer(plan.tankBotRespawns));
|
||||
setParam(bots, 'numBotRespawnsInVersus', integer(plan.airBotRespawns));
|
||||
|
||||
@@ -50,6 +50,10 @@ export interface GameModeDeclaration {
|
||||
* `true`; `false` for single-slot modes (`air_realistic` and its `small_teams_` sub-mode).
|
||||
*/
|
||||
readonly multiSlot?: boolean;
|
||||
/** Stock maxRespawns value when this mode specifies its own respawn count. */
|
||||
readonly maxRespawns?: number;
|
||||
/** Additional scalar settings the local host needs from this mode's missions. */
|
||||
readonly missionRuleKeys?: readonly string[];
|
||||
/** False for modes whose native weapon rules replace combat presets. Defaults to true. */
|
||||
readonly allowBotAircraftLoadouts?: boolean;
|
||||
/** Minimum `mrank` exposed on the parent mode for Night Battles (`scripts/events/eventinfo.nut:134-136`). */
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
* AB/RB get Enduring Confrontation; Ground AB and Air AB get none);
|
||||
* - `queueEvent.nut` includes or excludes its `gameModeId` in `match.enqueue` `game_modes_list`.
|
||||
*/
|
||||
import { UNLIMITED_RESPAWNS } from '../mode-definition.ts';
|
||||
import type { GameModeDeclaration } from './game-mode-declaration.ts';
|
||||
import {
|
||||
AIR_REALISTIC_MISSIONS,
|
||||
@@ -69,6 +70,15 @@ export const SUB_GAME_MODES: readonly GameModeDeclaration[] = [
|
||||
displayType: 'random_battle',
|
||||
allowedCraftMinMrank: { aircraft: MIN_MRANK_NUCLEAR_ESCALATION },
|
||||
minQueueMrank: MIN_MRANK_NUCLEAR_ESCALATION,
|
||||
maxRespawns: UNLIMITED_RESPAWNS,
|
||||
// mission_settings.mission in mis.vromfs.bin gamedata/missions/cta/planes/nuclear_escalation/.
|
||||
missionRuleKeys: [
|
||||
'customHUD', 'nuclearEscalationStage1', 'nuclearEscalationStage2', 'nuclearEscalationStage3',
|
||||
'useSpawnDelay', 'afterRespawnDelaySec', 'overrideMaxActiveUnitsWeight', 'scheduleBasedGmUpdateMaxInterval',
|
||||
'disableFallingTrees', 'alwaysSendAllyGMData', 'isAlwaysShowCollectiveDetectedUnits', 'useAIForCollectiveDetection',
|
||||
'allowToChooseHUDIconPreset', 'showAIKilllog', 'showUnitTooltipOnMap', 'disableMfdForPrevgenConsoles',
|
||||
'clientReplayMaxSizeMb', 'timeToLoseInstantDetection', 'showTacticalMapCellSize',
|
||||
],
|
||||
requiredClass: 'aircraft',
|
||||
allowedClasses: ['aircraft'],
|
||||
missions: NUCLEAR_ESCALATION_MISSIONS,
|
||||
|
||||
@@ -41,8 +41,13 @@ export const MISSION_DIFFICULTY: Readonly<Record<ModeDifficulty, string>> = {
|
||||
simulator: 'hardcore',
|
||||
};
|
||||
|
||||
// globals/missions/respawnCountModes.nut: RESPAWN_COUNT_MODE.SINGLE_SPAWN.
|
||||
// globals/missions/respawnCountModes.nut: RESPAWN_COUNT_MODE.
|
||||
export const SINGLE_SPAWN = 1;
|
||||
export const UNLIMITED_RESPAWNS = -2;
|
||||
|
||||
export function modeMaxRespawns(mode: GameModeDeclaration): number | undefined {
|
||||
return mode.maxRespawns ?? (mode.multiSlot === false ? SINGLE_SPAWN : undefined);
|
||||
}
|
||||
|
||||
export type ModeDefinition = Readonly<Record<string, unknown>>;
|
||||
|
||||
@@ -50,6 +55,7 @@ export function buildModeDefinition(mode: GameModeDeclaration, missions: readonl
|
||||
countries: readonly string[], missionRanks?: MissionRotationRanks): ModeDefinition {
|
||||
const minTeamSize = mode.teamSizeOverride?.min ?? 1;
|
||||
const maxTeamSize = mode.teamSizeOverride?.max ?? teamSize(mode, missions);
|
||||
const maxRespawns = modeMaxRespawns(mode);
|
||||
const team = {
|
||||
countries: [...countries],
|
||||
allowedCrafts: mode.allowedClasses.map((unitClass) => {
|
||||
@@ -83,7 +89,7 @@ export function buildModeDefinition(mode: GameModeDeclaration, missions: readonl
|
||||
teamB: structuredClone(team),
|
||||
mission_decl: {
|
||||
difficulty: MISSION_DIFFICULTY[mode.difficulty],
|
||||
...(mode.multiSlot === false ? { maxRespawns: SINGLE_SPAWN } : {}),
|
||||
...(maxRespawns === undefined ? {} : { maxRespawns }),
|
||||
missions_list: Object.fromEntries(missions.map((mission) => {
|
||||
const ranges = missionRanks?.byMission.get(mission.name);
|
||||
return [mission.name, ranges?.length === 1 ? { enableIf: ranges[0] } : {}];
|
||||
|
||||
@@ -16,7 +16,6 @@ import type { BlkBlock, BlkValue } from '@wto/blk';
|
||||
import type { BannerParams } from '../battle/battle-economy.ts';
|
||||
import type { BattleLaunchPlan } from '../battle/battle-matchmaker.ts';
|
||||
import { battleMissionSettings } from '../battle/battle-mission-settings.ts';
|
||||
import { SINGLE_SPAWN } from '../game-modes/mode-definition.ts';
|
||||
|
||||
type WireParam = readonly [name: string, type: 't' | 'i' | 'r' | 'b', value: string | number | boolean];
|
||||
|
||||
@@ -52,7 +51,7 @@ export function battleLaunchNotify(
|
||||
mission: {
|
||||
name: plan.missionName,
|
||||
difficulty: plan.difficulty,
|
||||
...(plan.selectedSlot ? { maxRespawns: SINGLE_SPAWN } : {}),
|
||||
...(plan.maxRespawns === undefined ? {} : { maxRespawns: plan.maxRespawns }),
|
||||
},
|
||||
},
|
||||
battle: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Reports the local player's combat events to the GUI scripts.
|
||||
* Reports the local player's combat events and confirmed airfield departures to the GUI scripts.
|
||||
*
|
||||
* Online, the battle server prices every combat event and sends it to the client
|
||||
* (packet 0xb03d -> GameSaveData::addScoreMessage), which raises the HUD script event
|
||||
@@ -95,6 +95,21 @@ void local_mp_report_nuclear_strike(void)
|
||||
fn_blk_dtor(blk);
|
||||
}
|
||||
|
||||
void local_mp_report_airfield_spawn(const char *unit_name, int32_t base_id)
|
||||
{
|
||||
__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 || unit_name == NULL || base_id < 0)
|
||||
return;
|
||||
memset(blk, 0, sizeof(blk));
|
||||
fn_blk_ctor(blk);
|
||||
fn_blk_set_str(blk, "unitName", unit_name);
|
||||
blk_set_int(blk, "baseId", base_id);
|
||||
fn_hud_notify_script(gsd + LMP_GSD_OFF_HUD_QUEUE, "wtoLocalMpAirfieldSpawn", blk);
|
||||
fn_blk_dtor(blk);
|
||||
}
|
||||
|
||||
int install_local_mp_award_hooks(void)
|
||||
{
|
||||
g_game_save_data = (uint8_t **)g_lmp.game_save_data;
|
||||
|
||||
@@ -132,10 +132,10 @@ typedef struct LocalMpModule {
|
||||
} LocalMpModule;
|
||||
|
||||
static const LocalMpModule MODULES[] = {
|
||||
{ "local_mp_awards", install_local_mp_award_hooks },
|
||||
{ "local_mp_players", install_local_mp_player_hooks },
|
||||
{ "local_mp_loadout", install_local_mp_loadout_hooks },
|
||||
{ "local_mp_actions", install_local_mp_action_hooks },
|
||||
{ "local_mp_awards", install_local_mp_award_hooks },
|
||||
{ "local_mp_scores", install_local_mp_score_reader },
|
||||
{ "local_mp_kills", install_local_mp_kill_hooks },
|
||||
{ "local_mp_events", install_local_mp_event_hooks },
|
||||
|
||||
@@ -58,11 +58,12 @@ char *local_mp_strdup(const char *s);
|
||||
const char *local_mp_unit_name(const uint8_t *unit);
|
||||
|
||||
/* Player state & slot tracking notifications shared with loadout module. */
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int is_silent);
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int32_t base_id, int is_silent);
|
||||
|
||||
/* Combat event reporting to the GUI scripts (local_mp_awards.c). */
|
||||
/* Local player events sent to the GUI scripts (local_mp_awards.c). */
|
||||
void local_mp_report_award_event(const LocalMpAwardEvent *ev);
|
||||
void local_mp_report_nuclear_strike(void);
|
||||
void local_mp_report_airfield_spawn(const char *unit_name, int32_t base_id);
|
||||
|
||||
/* A destroyed unit that is some player's mission support unit: its reference is freed once the
|
||||
* player has been given back control (local_mp_support.c). */
|
||||
|
||||
@@ -189,7 +189,7 @@ static void __fastcall hook_sem_change_aircraft_send(
|
||||
mplayer[LMP_MP_OFF_GUI_STATE] != LMP_GUI_STATE_CA_READY)
|
||||
g_lmp_set_player_gui_state((int32_t)mplayer[LMP_MP_OFF_PID], LMP_GUI_STATE_CA_READY);
|
||||
|
||||
local_mp_players_queue_spawn(req_slot_id, req_spare_type, is_silent);
|
||||
local_mp_players_queue_spawn(req_slot_id, req_spare_type, req_base_id, is_silent);
|
||||
log_line("local_mp: configured unit='%s' weapon='%s' slot=%d silent=%d",
|
||||
unit_name ? unit_name : "", weapon_name ? weapon_name : "", (int)req_slot_id, is_silent);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,14 @@ static int g_accept_pending = 0;
|
||||
static int g_respawn_dispatched = 0;
|
||||
static int32_t g_pending_slot_id = -1;
|
||||
static int32_t g_pending_spare_type = -1;
|
||||
static int32_t g_pending_base_id = -1;
|
||||
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int is_silent)
|
||||
void local_mp_players_queue_spawn(int32_t slot_id, int32_t spare_type, int32_t base_id, int is_silent)
|
||||
{
|
||||
if (!is_silent || g_pending_slot_id < 0) {
|
||||
g_pending_slot_id = slot_id;
|
||||
g_pending_spare_type = spare_type;
|
||||
g_pending_base_id = base_id;
|
||||
}
|
||||
if (!is_silent)
|
||||
g_respawn_dispatched = 0;
|
||||
@@ -113,7 +115,17 @@ static void __fastcall hook_mplayer_init_from_matching(uint8_t *mplayer, uint8_t
|
||||
orig_mplayer_init_matching(mplayer, info, uid);
|
||||
}
|
||||
|
||||
static void consume_pending_slot_if_spawned(uint8_t *mplayer)
|
||||
static int has_unlimited_respawns(void)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
if (g_local_mp_mission_settings == NULL || g_lmp_datablock_get_str == NULL)
|
||||
return 0;
|
||||
value = g_lmp_datablock_get_str(g_local_mp_mission_settings + LMP_MIS_OFF_CUSTOM_BOTS, "wtoUnlimitedRespawns", "0");
|
||||
return value != NULL && strcmp(value, "1") == 0;
|
||||
}
|
||||
|
||||
static void finish_pending_spawn(uint8_t *mplayer)
|
||||
{
|
||||
const char *hero_name;
|
||||
|
||||
@@ -131,7 +143,9 @@ static void consume_pending_slot_if_spawned(uint8_t *mplayer)
|
||||
|
||||
if (g_pending_slot_id >= 0 && g_pending_slot_id < 32) {
|
||||
uint32_t bit = 1u << (uint32_t)g_pending_slot_id;
|
||||
if (g_pending_spare_type < 0)
|
||||
if (has_unlimited_respawns())
|
||||
local_mp_report_airfield_spawn(hero_name, g_pending_base_id);
|
||||
else if (g_pending_spare_type < 0)
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_BROKEN_SLOTS_MASK) |= bit;
|
||||
else
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_USED_SPARES_MASK) |= bit;
|
||||
@@ -140,6 +154,7 @@ static void consume_pending_slot_if_spawned(uint8_t *mplayer)
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_BROKEN_SLOTS_MASK),
|
||||
*(uint32_t *)(mplayer + LMP_MP_OFF_USED_SPARES_MASK));
|
||||
g_pending_slot_id = -1;
|
||||
g_pending_base_id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,12 +168,13 @@ static void __fastcall hook_gui_state_update(uint8_t *gui_state_obj, float dt)
|
||||
g_accept_pending = 0;
|
||||
g_respawn_dispatched = 0;
|
||||
g_pending_slot_id = -1;
|
||||
g_pending_base_id = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
bind_ai_mplayer_units();
|
||||
mplayer = g_local_mp_mplayer ? *g_local_mp_mplayer : NULL;
|
||||
consume_pending_slot_if_spawned(mplayer);
|
||||
finish_pending_spawn(mplayer);
|
||||
|
||||
if (g_accept_pending && gui_state_obj != NULL) {
|
||||
uint8_t *econ_state = local_mp_econ_state();
|
||||
@@ -185,7 +201,7 @@ static int64_t __fastcall hook_do_respawn_player(void *app)
|
||||
g_respawn_dispatched = 1;
|
||||
|
||||
result = orig_do_respawn(app);
|
||||
consume_pending_slot_if_spawned(mplayer);
|
||||
finish_pending_spawn(mplayer);
|
||||
bind_ai_mplayer_units();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
function getPerBaseRespawnDelays(respawnBasesList, unitName) {
|
||||
local baseDelays = {}
|
||||
if ((get_current_mission_info_cached()?.afterRespawnDelaySec ?? 0) <= 0)
|
||||
return baseDelays
|
||||
foreach (spawn in respawnBasesList)
|
||||
if (isPerBaseDelayRow(spawn))
|
||||
baseDelays[spawn.id] <- get_slot_delay(unitName, spawn.id)
|
||||
return baseDelays
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function onEventLoadingStateChange(_p) {
|
||||
if (!isInFlight())
|
||||
this.resetSelectedBase()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Track successful departures by aircraft and airfield for the stock respawn base list.
|
||||
// The LocalMP host has the actual spawn result. The local matching service only starts the mission.
|
||||
// The stock delay getters read a flight server snapshot, so the LocalMP departure event supplies it.
|
||||
{
|
||||
"id": "battle/track-local-airfield-departures",
|
||||
"title": "Track LocalMP departures for airfield respawn delays",
|
||||
"features": ["K-Spawn score and respawns"],
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"file": "scripts/respawn/respawnbases.nut",
|
||||
"edits": [
|
||||
{ "find": "find-delays.nut", "replace": "replace-delays.nut" },
|
||||
{ "find": "find-loading.nut", "replace": "replace-loading.nut" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
wtoAirfieldDepartures = {}
|
||||
|
||||
function hasLocalRespawnDelays() {
|
||||
return this.wtoAirfieldDepartures.len() > 0
|
||||
}
|
||||
|
||||
function getLocalRespawnDelay(unitName, spawn) {
|
||||
if (unitName == null || spawn == null || !isPerBaseDelayRow(spawn))
|
||||
return null
|
||||
let departedAt = this.wtoAirfieldDepartures?[unitName]?[spawn.id]
|
||||
if (departedAt == null)
|
||||
return null
|
||||
let delay = get_current_mission_info_cached()?.afterRespawnDelaySec ?? 0
|
||||
let elapsed = (require("dagor.time").get_time_msec() - departedAt) / 1000
|
||||
return max(0, delay - elapsed.tointeger())
|
||||
}
|
||||
|
||||
function getPerBaseRespawnDelays(respawnBasesList, unitName) {
|
||||
local baseDelays = {}
|
||||
if ((get_current_mission_info_cached()?.afterRespawnDelaySec ?? 0) <= 0)
|
||||
return baseDelays
|
||||
foreach (spawn in respawnBasesList)
|
||||
if (isPerBaseDelayRow(spawn))
|
||||
baseDelays[spawn.id] <- this.getLocalRespawnDelay(unitName, spawn) ?? get_slot_delay(unitName, spawn.id)
|
||||
return baseDelays
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
function onLocalAirfieldSpawn(event) {
|
||||
let { unitName, baseId } = event
|
||||
let departures = this.wtoAirfieldDepartures?[unitName] ?? {}
|
||||
departures[baseId] <- require("dagor.time").get_time_msec()
|
||||
this.wtoAirfieldDepartures[unitName] <- departures
|
||||
}
|
||||
|
||||
function onEventHudEventManagerReset(_p) {
|
||||
let { g_hud_event_manager } = require("%scripts/hud/hudEventManager.nut")
|
||||
g_hud_event_manager.subscribe("wtoLocalMpAirfieldSpawn", this.onLocalAirfieldSpawn, this)
|
||||
}
|
||||
|
||||
function onEventLoadingStateChange(_p) {
|
||||
if (!isInFlight()) {
|
||||
this.resetSelectedBase()
|
||||
this.wtoAirfieldDepartures.clear()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
let crewId = crew.idInCountry
|
||||
let syncRecvTime = getSpawnDelayTimesRecvTime()
|
||||
let prevState = this.lastRespawnBaseLockState
|
||||
@@ -0,0 +1,22 @@
|
||||
let respawnBaseId = this.curRespawnBase?.id ?? 0
|
||||
let syncRecvTime = getSpawnDelayTimesRecvTime()
|
||||
foreach (crew in crews) {
|
||||
let idInCountry = crew.idInCountry
|
||||
let cacheKey = $"{idInCountry}_{respawnBaseId}"
|
||||
let curSlotDelay = get_slot_delay_by_slot(idInCountry, respawnBaseId)
|
||||
local slotDelayChanged = false
|
||||
if (!(cacheKey in this.slotDelayDataCached)) {
|
||||
this.slotDelayDataCached[cacheKey] <- {
|
||||
slotDelay = curSlotDelay
|
||||
updateTime = curSlotDelay >= 0 ? syncRecvTime : 0
|
||||
}
|
||||
slotDelayChanged = curSlotDelay >= 0
|
||||
}
|
||||
else {
|
||||
let slotDelayData = this.slotDelayDataCached[cacheKey]
|
||||
if (slotDelayData.slotDelay != curSlotDelay) {
|
||||
slotDelayData.slotDelay = curSlotDelay
|
||||
slotDelayData.updateTime = syncRecvTime
|
||||
slotDelayChanged = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
let slotDelay = this.getInterpolatedSlotDelay(crew.idInCountry, this.curRespawnBase.id)
|
||||
if (slotDelay > 0) {
|
||||
@@ -0,0 +1,19 @@
|
||||
// Feed LocalMP airfield delays into the stock slot countdown and base lock refresh.
|
||||
// The local matching service does not receive the flight server's per-slot delay snapshots.
|
||||
// The spawn button and base list need the host departure times to apply the same delay.
|
||||
{
|
||||
"id": "battle/use-local-airfield-respawn-delay",
|
||||
"title": "Use LocalMP airfield delays in the respawn screen",
|
||||
"features": ["K-Spawn score and respawns"],
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.58",
|
||||
"file": "scripts/respawn/respawn.nut",
|
||||
"edits": [
|
||||
{ "find": "find-spawn-check.nut", "replace": "replace-spawn-check.nut" },
|
||||
{ "find": "find-slot-delay.nut", "replace": "replace-slot-delay.nut" },
|
||||
{ "find": "find-base-refresh.nut", "replace": "replace-base-refresh.nut" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
let crewId = crew.idInCountry
|
||||
let wtoHasDelays = "hasLocalRespawnDelays" in respawnBases && respawnBases.hasLocalRespawnDelays()
|
||||
let syncRecvTime = wtoHasDelays ? (get_time_msec() / 1000).tointeger() : getSpawnDelayTimesRecvTime()
|
||||
let prevState = this.lastRespawnBaseLockState
|
||||
@@ -0,0 +1,27 @@
|
||||
let respawnBaseId = this.curRespawnBase?.id ?? 0
|
||||
let syncRecvTime = getSpawnDelayTimesRecvTime()
|
||||
let wtoHasDelays = "hasLocalRespawnDelays" in respawnBases && respawnBases.hasLocalRespawnDelays()
|
||||
foreach (crew in crews) {
|
||||
let idInCountry = crew.idInCountry
|
||||
let cacheKey = $"{idInCountry}_{respawnBaseId}"
|
||||
let wtoDelay = wtoHasDelays
|
||||
? respawnBases.getLocalRespawnDelay(getCrewUnit(crew)?.name, this.curRespawnBase)
|
||||
: null
|
||||
let curSlotDelay = wtoDelay ?? get_slot_delay_by_slot(idInCountry, respawnBaseId)
|
||||
let slotRecvTime = wtoDelay == null ? syncRecvTime : get_time_msec()
|
||||
local slotDelayChanged = false
|
||||
if (!(cacheKey in this.slotDelayDataCached)) {
|
||||
this.slotDelayDataCached[cacheKey] <- {
|
||||
slotDelay = curSlotDelay
|
||||
updateTime = curSlotDelay >= 0 ? slotRecvTime : 0
|
||||
}
|
||||
slotDelayChanged = curSlotDelay >= 0
|
||||
}
|
||||
else {
|
||||
let slotDelayData = this.slotDelayDataCached[cacheKey]
|
||||
if (slotDelayData.slotDelay != curSlotDelay) {
|
||||
slotDelayData.slotDelay = curSlotDelay
|
||||
slotDelayData.updateTime = slotRecvTime
|
||||
slotDelayChanged = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
let wtoDelay = "getLocalRespawnDelay" in respawnBases
|
||||
? respawnBases.getLocalRespawnDelay(unit.name, this.curRespawnBase)
|
||||
: null
|
||||
let slotDelay = wtoDelay ?? this.getInterpolatedSlotDelay(crew.idInCountry, this.curRespawnBase.id)
|
||||
if (slotDelay > 0) {
|
||||
@@ -1,10 +1,11 @@
|
||||
// In-battle award events (native/wto-net/src/local_mp_awards.c): the stock InBattleReward HUD event
|
||||
// and the facts sent to the local server for awards.
|
||||
// Without it: no reward banners and no battle awards in LocalMP battles.
|
||||
// and the facts sent to the local server for awards. Also reports confirmed airfield departures
|
||||
// for the LocalMP respawn UI, which otherwise expects the flight server to send cooldown records.
|
||||
{
|
||||
"module": "local_mp_awards",
|
||||
"features": [
|
||||
"L-Battle awards"
|
||||
"L-Battle awards",
|
||||
"K-Spawn score and respawns"
|
||||
],
|
||||
"requires": [
|
||||
"local_mp_core"
|
||||
|
||||
Reference in new issue
Block a user