Files
WT-Offline/gui-patches/battle/populate-random-spawn-units-state/patch.json
T
N0VAN0M4LY 6a189513b0 Snapshot unreviewed LocalMP battle work as 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
1.5 KiB
JSON

{
"id": "battle/populate-random-spawn-units-state",
"title": "Populate local player's random_units state block in LocalMP sessions",
"file": "scripts/miscustomrules/rulebase.nut",
"reason": "Online servers replicate random_units candidate lists into MPlayer custom state; populating get_user_custom_state from activeBattle.randomUnits enables native dice icons, group titles, BR ranges, and hover candidate tooltips on slotbarview.",
"features": ["J-本地对局", "K-战局任务加载"],
"edit": {
"find": " function getMyStateBlk() {\r\n return get_user_custom_state(userIdInt64.get(), false)\r\n }",
"replace": " function getMyStateBlk() {\r\n let wtoUid = userIdInt64.get()\r\n local wtoStateBlk = get_user_custom_state(wtoUid, false)\r\n let { ndbTryRead } = require(\"nestdb\")\r\n let wtoRandom = ndbTryRead([\"wto\", \"activeBattle\"])?.randomUnits\r\n if (wtoRandom == null || wtoRandom.len() == 0)\r\n return wtoStateBlk\r\n if (wtoStateBlk == null)\r\n wtoStateBlk = get_user_custom_state(wtoUid, true) ?? DataBlock()\r\n if (wtoStateBlk?.random_units == null) {\r\n let wtoRuBlk = wtoStateBlk.addNewBlock(\"random_units\")\r\n foreach (wtoGroupName, wtoUnits in wtoRandom) {\r\n if (wtoUnits == null || wtoUnits.len() == 0)\r\n continue\r\n let wtoGroupBlk = wtoRuBlk.addNewBlock(wtoGroupName)\r\n foreach (wtoUnitName in wtoUnits)\r\n wtoGroupBlk[wtoUnitName] = true\r\n }\r\n }\r\n return wtoStateBlk\r\n }"
}
}