{ "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 }" } }