{
  "format": "wa1-module",
  "formatVersion": 1,
  "author": null,
  "class": "All",
  "globalName": "SuperDPS",
  "spellQueueWindow": 250,
  "name": "官方一键辅助 - 动态宏精简版",
  "initCode": "-- 事件合并读取候选；只在脱战时更新变化的宏，保留仍在使用的槽位。\nlocal slots, active, entries = {}, {}, {}\nlocal dirty, queued, notified, announce = true, false, false, false\nlocal checks, count = 0, 0\nlocal schedule\n-- 只扫描一次预设；缺少占用信息时拒绝猜测，避免旧客户端覆盖只有正文的宏。\nlocal firstSlot, capacity, available, reservedNames = 1, 0, {}, {}\nlocal compatible = true\nfor slot, row in pairs(SuperDPS.DynamicSlots) do\n    if row.name and row.name ~= \"\" then reservedNames[row.name] = true end\n    if slot >= 1 and slot <= 105 then\n        if type(row.occupied) ~= \"boolean\" then compatible = false end\n        if row.occupied then firstSlot = math.max(firstSlot, slot + 1) end\n    end\nend\nfor slot = firstSlot, 105 do\n    local row = SuperDPS.DynamicSlots[slot]\n    if row and row.occupied == false and row.key and row.key ~= \"\" then\n        available[slot], capacity = true, capacity + 1\n    end\nend\nlocal function macroName(name)\n    while reservedNames[name] do name = name .. \"_\" end\n    return name\nend\n\nlocal function baseSpell(id)\n    id = SuperDPS.SN(id, \"assist.spell\")\n    if type(id) ~= \"number\" or id <= 0 then return 0 end\n    local base = SuperDPS.SN(C_Spell.GetBaseSpell(id), \"assist.base\")\n    return type(base) == \"number\" and base > 0 and base or 0\nend\n\nlocal function request(slot, name, body)\n    local entry = entries[slot]\n    if entry and entry.name == name and entry.body == body then return end\n    entries[slot] = {name = name, body = body, sentName = entry and entry.sentName}\n    announce = true\nend\n\nlocal function refresh()\n    if InCombatLockdown() then return end\n    if not compatible then\n        error(\"请更新客户端并重新生成插件：缺少预设宏占用信息\")\n    end\n    if dirty then\n        if not (C_AssistedCombat and C_AssistedCombat.GetRotationSpells\n            and C_Spell and C_Spell.GetBaseSpell and C_Spell.GetSpellName) then\n            active = {}\n            return\n        end\n        local wanted, order, used, nextSlots = {}, {}, {}, {}\n        for _, id in ipairs(C_AssistedCombat.GetRotationSpells()) do\n            local base = baseSpell(id)\n            local name = base > 0 and SuperDPS.SN(C_Spell.GetSpellName(base), \"assist.name\")\n            if type(name) == \"string\" and name ~= \"\" and not wanted[base] then\n                wanted[base] = \"/cast \" .. name\n                order[#order + 1] = base\n            end\n        end\n        if #order > capacity then\n            active = {}\n            error(\"辅助宏槽位不足：需要\" .. #order .. \"个，预设宏之后可用\" .. capacity .. \"个\")\n        end\n        -- 先保留仍在使用的槽位，再回收移出的技能；旧宏改为无动作正文。\n        for base, slot in pairs(slots) do\n            if wanted[base] then\n                nextSlots[base], used[slot] = slot, true\n            else\n                request(slot, macroName(\"assist_empty_\" .. slot), \"/stopmacro\")\n            end\n        end\n        local free = firstSlot\n        for _, base in ipairs(order) do\n            local slot = nextSlots[base]\n            if not slot then\n                while not available[free] or used[free] do free = free + 1 end\n                slot = free\n                nextSlots[base], used[slot] = slot, true\n            end\n            request(slot, macroName(\"a\" .. base), wanted[base])\n        end\n        slots, count, active = nextSlots, #order, {}\n        dirty, checks = false, 0\n    end\n    -- 先释放已提交的旧名称，避免连续切换列表时跨槽位名称冲突。\n    for slot, entry in pairs(entries) do\n        if entry.sentName and entry.sentName ~= entry.name then\n            if InCombatLockdown() then return end\n            local emptyName = macroName(\"assist_empty_\" .. slot)\n            SuperDPS.SetMacro(slot, emptyName, \"/stopmacro\")\n            entry.sentName = emptyName\n        end\n    end\n    local ready = true\n    for slot, entry in pairs(entries) do\n        if not entry.ready then\n            if InCombatLockdown() then return end\n            entry.ready = SuperDPS.SetMacro(slot, entry.name, entry.body)\n            entry.sentName = entry.name\n            ready = entry.ready and ready\n        end\n    end\n    -- 仅公布已写入的宏；客户端仍通过完整快照和新鲜度校验后执行。\n    active = {}\n    for base, slot in pairs(slots) do\n        if entries[slot].ready then active[base] = slot end\n    end\n    if ready then\n        if announce and (notified or count > 0) then\n            local label = notified and \"辅助宏更新完毕\" or \"辅助宏初始化完毕\"\n            SuperDPS.Print(label .. \"（\" .. count .. \" 个），请等待客户端同步\")\n            notified = true\n        end\n        announce = false\n    elseif checks < 20 then\n        checks = checks + 1\n        schedule(0.3)\n    end\nend\n\nschedule = function(delay)\n    if queued or InCombatLockdown() then return end\n    queued = true\n    C_Timer.After(delay or 0.1, function()\n        queued = false\n        local ok, err = pcall(refresh)\n        if not ok then\n            active, dirty = {}, true\n            SuperDPS.Print(\"辅助宏更新失败：\" .. tostring(err))\n        end\n    end)\nend\n\nSuperDPS.AssistMacro = function()\n    if not (C_AssistedCombat and C_AssistedCombat.GetNextCastSpell\n        and C_Spell and C_Spell.GetBaseSpell) then return 0 end\n    return active[baseSpell(C_AssistedCombat.GetNextCastSpell())] or 0\nend\n\nlocal frame = CreateFrame(\"Frame\")\nfor _, event in ipairs({\"PLAYER_LOGIN\", \"PLAYER_ENTERING_WORLD\", \"SPELLS_CHANGED\",\n    \"PLAYER_SPECIALIZATION_CHANGED\", \"PLAYER_REGEN_ENABLED\"}) do\n    frame:RegisterEvent(event)\nend\nframe:SetScript(\"OnEvent\", function(_, event, unit)\n    if event ~= \"PLAYER_SPECIALIZATION_CHANGED\" or unit == \"player\" then\n        dirty, checks = true, 0\n        schedule()\n    end\nend)\nschedule()\n",
  "macros": [
    {
      "index": 1,
      "name": "",
      "macro": ""
    },
    {
      "index": 2,
      "name": "",
      "macro": ""
    },
    {
      "index": 3,
      "name": "",
      "macro": ""
    },
    {
      "index": 4,
      "name": "",
      "macro": ""
    },
    {
      "index": 5,
      "name": "",
      "macro": ""
    },
    {
      "index": 6,
      "name": "",
      "macro": ""
    },
    {
      "index": 7,
      "name": "",
      "macro": ""
    },
    {
      "index": 8,
      "name": "",
      "macro": ""
    },
    {
      "index": 9,
      "name": "",
      "macro": ""
    },
    {
      "index": 10,
      "name": "",
      "macro": ""
    },
    {
      "index": 11,
      "name": "",
      "macro": ""
    },
    {
      "index": 12,
      "name": "",
      "macro": ""
    },
    {
      "index": 13,
      "name": "",
      "macro": ""
    },
    {
      "index": 14,
      "name": "",
      "macro": ""
    },
    {
      "index": 15,
      "name": "",
      "macro": ""
    },
    {
      "index": 16,
      "name": "",
      "macro": ""
    },
    {
      "index": 17,
      "name": "",
      "macro": ""
    },
    {
      "index": 18,
      "name": "",
      "macro": ""
    },
    {
      "index": 19,
      "name": "",
      "macro": ""
    },
    {
      "index": 20,
      "name": "",
      "macro": ""
    },
    {
      "index": 21,
      "name": "",
      "macro": ""
    },
    {
      "index": 22,
      "name": "",
      "macro": ""
    },
    {
      "index": 23,
      "name": "",
      "macro": ""
    },
    {
      "index": 24,
      "name": "",
      "macro": ""
    },
    {
      "index": 25,
      "name": "",
      "macro": ""
    },
    {
      "index": 26,
      "name": "",
      "macro": ""
    },
    {
      "index": 27,
      "name": "",
      "macro": ""
    },
    {
      "index": 28,
      "name": "",
      "macro": ""
    },
    {
      "index": 29,
      "name": "",
      "macro": ""
    },
    {
      "index": 30,
      "name": "",
      "macro": ""
    },
    {
      "index": 31,
      "name": "",
      "macro": ""
    },
    {
      "index": 32,
      "name": "",
      "macro": ""
    },
    {
      "index": 33,
      "name": "",
      "macro": ""
    },
    {
      "index": 34,
      "name": "",
      "macro": ""
    },
    {
      "index": 35,
      "name": "",
      "macro": ""
    },
    {
      "index": 36,
      "name": "",
      "macro": ""
    },
    {
      "index": 37,
      "name": "",
      "macro": ""
    },
    {
      "index": 38,
      "name": "",
      "macro": ""
    },
    {
      "index": 39,
      "name": "",
      "macro": ""
    },
    {
      "index": 40,
      "name": "",
      "macro": ""
    },
    {
      "index": 41,
      "name": "",
      "macro": ""
    },
    {
      "index": 42,
      "name": "",
      "macro": ""
    },
    {
      "index": 43,
      "name": "",
      "macro": ""
    },
    {
      "index": 44,
      "name": "",
      "macro": ""
    },
    {
      "index": 45,
      "name": "",
      "macro": ""
    },
    {
      "index": 46,
      "name": "",
      "macro": ""
    },
    {
      "index": 47,
      "name": "",
      "macro": ""
    },
    {
      "index": 48,
      "name": "",
      "macro": ""
    },
    {
      "index": 49,
      "name": "",
      "macro": ""
    },
    {
      "index": 50,
      "name": "",
      "macro": ""
    },
    {
      "index": 51,
      "name": "",
      "macro": ""
    },
    {
      "index": 52,
      "name": "",
      "macro": ""
    },
    {
      "index": 53,
      "name": "",
      "macro": ""
    },
    {
      "index": 54,
      "name": "",
      "macro": ""
    },
    {
      "index": 55,
      "name": "",
      "macro": ""
    },
    {
      "index": 56,
      "name": "",
      "macro": ""
    },
    {
      "index": 57,
      "name": "",
      "macro": ""
    },
    {
      "index": 58,
      "name": "",
      "macro": ""
    },
    {
      "index": 59,
      "name": "",
      "macro": ""
    },
    {
      "index": 60,
      "name": "",
      "macro": ""
    },
    {
      "index": 61,
      "name": "",
      "macro": ""
    },
    {
      "index": 62,
      "name": "",
      "macro": ""
    },
    {
      "index": 63,
      "name": "",
      "macro": ""
    },
    {
      "index": 64,
      "name": "",
      "macro": ""
    },
    {
      "index": 65,
      "name": "",
      "macro": ""
    },
    {
      "index": 66,
      "name": "",
      "macro": ""
    },
    {
      "index": 67,
      "name": "",
      "macro": ""
    },
    {
      "index": 68,
      "name": "",
      "macro": ""
    },
    {
      "index": 69,
      "name": "",
      "macro": ""
    },
    {
      "index": 70,
      "name": "",
      "macro": ""
    },
    {
      "index": 71,
      "name": "",
      "macro": ""
    },
    {
      "index": 72,
      "name": "",
      "macro": ""
    },
    {
      "index": 73,
      "name": "",
      "macro": ""
    },
    {
      "index": 74,
      "name": "",
      "macro": ""
    },
    {
      "index": 75,
      "name": "",
      "macro": ""
    },
    {
      "index": 76,
      "name": "",
      "macro": ""
    },
    {
      "index": 77,
      "name": "",
      "macro": ""
    },
    {
      "index": 78,
      "name": "",
      "macro": ""
    },
    {
      "index": 79,
      "name": "",
      "macro": ""
    },
    {
      "index": 80,
      "name": "",
      "macro": ""
    },
    {
      "index": 81,
      "name": "",
      "macro": ""
    },
    {
      "index": 82,
      "name": "",
      "macro": ""
    },
    {
      "index": 83,
      "name": "",
      "macro": ""
    },
    {
      "index": 84,
      "name": "",
      "macro": ""
    },
    {
      "index": 85,
      "name": "",
      "macro": ""
    },
    {
      "index": 86,
      "name": "",
      "macro": ""
    },
    {
      "index": 87,
      "name": "",
      "macro": ""
    },
    {
      "index": 88,
      "name": "",
      "macro": ""
    },
    {
      "index": 89,
      "name": "",
      "macro": ""
    },
    {
      "index": 90,
      "name": "",
      "macro": ""
    },
    {
      "index": 91,
      "name": "",
      "macro": ""
    },
    {
      "index": 92,
      "name": "",
      "macro": ""
    },
    {
      "index": 93,
      "name": "",
      "macro": ""
    },
    {
      "index": 94,
      "name": "",
      "macro": ""
    },
    {
      "index": 95,
      "name": "",
      "macro": ""
    },
    {
      "index": 96,
      "name": "",
      "macro": ""
    },
    {
      "index": 97,
      "name": "",
      "macro": ""
    },
    {
      "index": 98,
      "name": "",
      "macro": ""
    },
    {
      "index": 99,
      "name": "",
      "macro": ""
    },
    {
      "index": 100,
      "name": "",
      "macro": ""
    },
    {
      "index": 101,
      "name": "",
      "macro": ""
    },
    {
      "index": 102,
      "name": "",
      "macro": ""
    },
    {
      "index": 103,
      "name": "",
      "macro": ""
    },
    {
      "index": 104,
      "name": "",
      "macro": ""
    },
    {
      "index": 105,
      "name": "",
      "macro": ""
    },
    {
      "index": 106,
      "name": "",
      "macro": ""
    },
    {
      "index": 107,
      "name": "",
      "macro": ""
    },
    {
      "index": 108,
      "name": "",
      "macro": ""
    },
    {
      "index": 109,
      "name": "",
      "macro": ""
    },
    {
      "index": 110,
      "name": "",
      "macro": ""
    },
    {
      "index": 111,
      "name": "",
      "macro": ""
    },
    {
      "index": 112,
      "name": "",
      "macro": ""
    },
    {
      "index": 113,
      "name": "",
      "macro": ""
    },
    {
      "index": 114,
      "name": "",
      "macro": ""
    },
    {
      "index": 115,
      "name": "",
      "macro": ""
    },
    {
      "index": 116,
      "name": "",
      "macro": ""
    },
    {
      "index": 117,
      "name": "",
      "macro": ""
    },
    {
      "index": 118,
      "name": "",
      "macro": ""
    },
    {
      "index": 119,
      "name": "",
      "macro": ""
    },
    {
      "index": 120,
      "name": "",
      "macro": ""
    },
    {
      "index": 121,
      "name": "",
      "macro": ""
    },
    {
      "index": 122,
      "name": "",
      "macro": ""
    },
    {
      "index": 123,
      "name": "",
      "macro": ""
    },
    {
      "index": 124,
      "name": "",
      "macro": ""
    },
    {
      "index": 125,
      "name": "",
      "macro": ""
    },
    {
      "index": 126,
      "name": "",
      "macro": ""
    },
    {
      "index": 127,
      "name": "",
      "macro": ""
    },
    {
      "index": 128,
      "name": "",
      "macro": ""
    },
    {
      "index": 129,
      "name": "",
      "macro": ""
    },
    {
      "index": 130,
      "name": "",
      "macro": ""
    },
    {
      "index": 131,
      "name": "",
      "macro": ""
    },
    {
      "index": 132,
      "name": "",
      "macro": ""
    },
    {
      "index": 133,
      "name": "",
      "macro": ""
    },
    {
      "index": 134,
      "name": "",
      "macro": ""
    },
    {
      "index": 135,
      "name": "",
      "macro": ""
    },
    {
      "index": 136,
      "name": "",
      "macro": ""
    },
    {
      "index": 137,
      "name": "",
      "macro": ""
    },
    {
      "index": 138,
      "name": "",
      "macro": ""
    },
    {
      "index": 139,
      "name": "",
      "macro": ""
    },
    {
      "index": 140,
      "name": "",
      "macro": ""
    },
    {
      "index": 141,
      "name": "",
      "macro": ""
    },
    {
      "index": 142,
      "name": "",
      "macro": ""
    },
    {
      "index": 143,
      "name": "",
      "macro": ""
    },
    {
      "index": 144,
      "name": "",
      "macro": ""
    },
    {
      "index": 145,
      "name": "",
      "macro": ""
    },
    {
      "index": 146,
      "name": "",
      "macro": ""
    },
    {
      "index": 147,
      "name": "",
      "macro": ""
    },
    {
      "index": 148,
      "name": "",
      "macro": ""
    },
    {
      "index": 149,
      "name": "",
      "macro": ""
    },
    {
      "index": 150,
      "name": "",
      "macro": ""
    }
  ],
  "props": [
    {
      "index": 1,
      "name": "AssistMacro",
      "mode": "custom",
      "code": "return SuperDPS.AssistMacro()"
    }
  ],
  "luaScripts": [
    {
      "index": 1,
      "id": 639219867096391302,
      "name": "official",
      "code": "local slot = Prop(\"AssistMacro\")\nif slot > 0 then Macro(slot) end"
    }
  ],
  "propLibrary": []
}
