Files
WT-Offline/gui-patches/battle/pass-spawn-modifications-blk/patch.json
T
N0VAN0M4LY b260d2899e chore(battle): snapshot the LocalMP rework baseline
Records the uncommitted battle-session work exactly as it was left
(local service matchmaking, settlement, chat, native LocalMP hooks,
battle gui/exe patches) so the following review and rework commits
show every correction as a diff against this state.

This commit is not reviewed and is known to be incomplete: in-game
testing reported wrong settlement rewards, single-country teams,
missing random/fixed supplement slots, misattributed hit messages and
other regressions. Do not merge this branch before the rework lands.
2026-11-28 03:15:47 +08:00

12 lines
6.4 KiB
JSON

{
"id": "battle/pass-spawn-modifications-blk",
"title": "Pass enabled modifications, spaded extra-slot loadout, and unit reward rates on LocalMP spawn",
"file": "scripts/respawn/respawn.nut",
"reason": "Forward enabled/disabled modifications, forced presets for extra battle slots, class-scaled warpoints/wpcost rates, and silent-preview state through requestAircraftAndWeaponWithSlots for LocalMP.",
"features": ["modifications-loadout", "local-battle"],
"edit": {
"find": " function requestAircraftAndWeapon(requestData) {\r\n if (this.requestInProgress)\r\n return\r\n\r\n set_aircraft_accepted_cb(this, this.aircraftAcceptedCb);\r\n let _taskId = requestAircraftAndWeaponWithSpare(requestData, requestData.idInCountry,\r\n requestData.respBaseId, requestData.spareUid)\r\n if (_taskId < 0)\r\n set_aircraft_accepted_cb(null, null);\r\n else {\r\n this.requestInProgress = true\r\n this.showTaskProgressBox(loc(\"charServer/purchase0\"), function() { this.requestInProgress = false })\r\n\r\n this.lastRequestData = requestData\r\n }\r\n }\r\n\r\n function requestChangeUnitSilent() {\r\n let unit = this.getCurSlotUnit()\r\n if (!unit?.isHuman() || !this.canChangeAircraft || this.isApplyPressed) {\r\n this.isSilentRequestPending = false\r\n return\r\n }\r\n this.isSilentRequestPending = this.requestInProgress || !canRequestAircraftNow()\r\n if (this.isSilentRequestPending)\r\n return\r\n\r\n let requestData = this.getSelectedRequestData(true)\r\n if (!requestData)\r\n return\r\n\r\n set_aircraft_accepted_cb(this, this.silentAircraftAcceptedCb);\r\n let _taskId = requestAircraftAndWeaponWithSpare(requestData, requestData.idInCountry,\r\n requestData.respBaseId, requestData.spareUid)\r\n if (_taskId < 0)\r\n set_aircraft_accepted_cb(null, null);\r\n else {\r\n this.requestInProgress = true\r\n this.lastRequestData = requestData\r\n }\r\n }",
"replace": " function sendWtoAircraftAndWeaponRequest(requestData, isSilent = false) {\r\n let wtoNdb = require(\"nestdb\")\r\n if (!wtoNdb.ndbExists([\"wto\", \"activeBattle\"]))\r\n return requestAircraftAndWeaponWithSpare(requestData, requestData.idInCountry,\r\n requestData.respBaseId, requestData.spareUid)\r\n let wtoBattle = wtoNdb.ndbTryRead([\"wto\", \"activeBattle\"])\r\n let wtoGuiRespawn = require(\"guiRespawn\")\r\n let wtoChardRes = require(\"chardResearch\")\r\n let wtoBlkGetters = require(\"blkGetters\")\r\n let wtoUnitName = requestData?.name ?? \"\"\r\n local wtoExtraSlot = null\r\n foreach (slot in (wtoBattle?.extraBattleSlots ?? [])) {\r\n if (slot?.unitName == wtoUnitName) {\r\n wtoExtraSlot = slot\r\n break\r\n }\r\n }\r\n if ((wtoExtraSlot?.forceWeapon ?? \"\") != \"\")\r\n requestData.weapon = wtoExtraSlot.forceWeapon\r\n let wtoIsSpaded = wtoExtraSlot?.spaded == true\r\n let wtoUnit = getAircraftByName(wtoUnitName) ?? this.getCurSlotUnit()\r\n let wtoEnabledMods = []\r\n let wtoDisabledMods = []\r\n foreach (wtoMod in (wtoUnit?.getModifications() ?? [])) {\r\n let wtoModName = wtoMod?.name ?? \"\"\r\n if (wtoModName == \"\")\r\n continue\r\n if (wtoIsSpaded || wtoChardRes.shopIsModificationEnabled(wtoUnitName, wtoModName))\r\n wtoEnabledMods.append(wtoModName)\r\n else if (wtoChardRes.shopIsModificationPurchased(wtoUnitName, wtoModName))\r\n wtoDisabledMods.append(wtoModName)\r\n }\r\n let wtoEdiff = this.getCurrentEdiff()\r\n let wtoDiffRem = wtoEdiff >= 0 ? (wtoEdiff % 3) : 1\r\n let wtoDiffSuffix = wtoDiffRem == 0 ? \"Arcade\" : wtoDiffRem == 1 ? \"Historical\" : \"Simulation\"\r\n let wtoUnitCost = get_wpcost_blk()?[wtoUnitName]\r\n let wtoWarBlk = wtoBlkGetters.get_warpoints_blk()\r\n let wtoBlk = DataBlock()\r\n wtoBlk.enabledMods = \";\".join(wtoEnabledMods)\r\n wtoBlk.disabledMods = \";\".join(wtoDisabledMods)\r\n wtoBlk.isSilentPreview = isSilent ? \"1\" : \"0\"\r\n if (wtoUnitCost != null && wtoWarBlk != null) {\r\n let wtoClassKillMul = wtoWarBlk.units[wtoUnitCost.unitClass].tofloat()\r\n let wtoRewardMul = wtoUnitCost[$\"rewardMul{wtoDiffSuffix}\"].tofloat()\r\n wtoBlk.wpPerKill = (wtoWarBlk.aKill.tofloat() * wtoClassKillMul * wtoWarBlk.wpMultiplier.tofloat() * wtoRewardMul).tofloat()\r\n wtoBlk.expMul = wtoUnitCost.expMul.tofloat()\r\n wtoBlk.battleTimeAward = wtoUnitCost[$\"battleTimeAward{wtoDiffSuffix}\"].tofloat()\r\n wtoBlk.aiKillK = wtoWarBlk.aiKillK.tofloat()\r\n wtoBlk.winK = wtoWarBlk.winK.tofloat()\r\n }\r\n if (!isSilent && (requestData?.spareUid ?? \"\") != \"\" && wtoUnitName != \"\") {\r\n let prevSpares = wtoBattle?.usedSpares ?? {}\r\n prevSpares[wtoUnitName] <- (prevSpares?[wtoUnitName] ?? 0) + 1\r\n wtoBattle.usedSpares <- prevSpares\r\n wtoNdb.ndbWrite([\"wto\", \"activeBattle\"], wtoBattle)\r\n }\r\n return wtoGuiRespawn.requestAircraftAndWeaponWithSlots(requestData, requestData.idInCountry,\r\n requestData.respBaseId, requestData.spareUid, wtoBlk, DataBlock())\r\n }\r\n\r\n function requestAircraftAndWeapon(requestData) {\r\n if (this.requestInProgress)\r\n return\r\n\r\n set_aircraft_accepted_cb(this, this.aircraftAcceptedCb);\r\n let _taskId = this.sendWtoAircraftAndWeaponRequest(requestData, false)\r\n if (_taskId < 0)\r\n set_aircraft_accepted_cb(null, null);\r\n else {\r\n this.requestInProgress = true\r\n this.showTaskProgressBox(loc(\"charServer/purchase0\"), function() { this.requestInProgress = false })\r\n\r\n this.lastRequestData = requestData\r\n }\r\n }\r\n\r\n function requestChangeUnitSilent() {\r\n let unit = this.getCurSlotUnit()\r\n if (!unit?.isHuman() || !this.canChangeAircraft || this.isApplyPressed) {\r\n this.isSilentRequestPending = false\r\n return\r\n }\r\n this.isSilentRequestPending = this.requestInProgress || !canRequestAircraftNow()\r\n if (this.isSilentRequestPending)\r\n return\r\n\r\n let requestData = this.getSelectedRequestData(true)\r\n if (!requestData)\r\n return\r\n\r\n set_aircraft_accepted_cb(this, this.silentAircraftAcceptedCb);\r\n let _taskId = this.sendWtoAircraftAndWeaponRequest(requestData, true)\r\n if (_taskId < 0)\r\n set_aircraft_accepted_cb(null, null);\r\n else {\r\n this.requestInProgress = true\r\n this.lastRequestData = requestData\r\n }\r\n }"
}
}