Files
WT-Offline/patches/gui/battle/available-local-backups/replace-availability.nut
T
N0VAN0M4LYandduduyagame 3282320fb7 fix(battle): show and debit confirmed backup vehicles
Use the signed i64 profile encoding identified in PR #13. Make attached backups selectable in LocalMP after the daily quota, and debit backups only after the engine confirms the selected slot entered play.

Record the stock daily allowance once per room and slot. Settle owned backups using the confirmed spawn facts and keep repeat settlement from charging the same battle again.

Verified server and launcher types, MSVC compilation, three client builds for patch and Quirrel checks, and a temporary 2.61.0.58 build. In-game acceptance is pending.

Co-authored-by: duduyagame <[email protected]>
2026-12-04 06:24:34 +08:00

20 lines
841 B
Plaintext

// null means stock slot handling. An empty string means the local slot cannot use a backup.
function getWtoBackupSource(slot, unit) {
let vehicles = require("nestdb").ndbTryRead(["wto", "activeBattle"])?.backups?.vehicles
if (vehicles == null || unit == null || !(unit.name in vehicles) || !is_bit_set(getBrokenSlotsMask(), slot))
return null
if (isSpareAircraftInSlot(slot) || is_bit_set(getDisabledByMatchingSlotsMask(), slot))
return ""
if (hasDailyFreeSpares())
return "daily"
if (vehicles[unit.name] > 0)
return "vehicle"
return getUniversalSparesForUnit(unit).len() > 0 ? "item" : ""
}
function canRespawnWithUniversalSpares(crew, unit) {
let wtoSource = getWtoBackupSource(crew.idInCountry, unit)
if (wtoSource != null)
return wtoSource != ""
if (!hasFeature("ActivateUniversalSpareInBattle"))