Implement priority sorting of classes for macroer
This commit is contained in:
@@ -24,18 +24,34 @@ function shared.Macroer.Init()
|
||||
|
||||
---@param stinkies table<string, stinky>
|
||||
local function FixMacro(stinkies)
|
||||
local priorityMap = {}
|
||||
for priority, className in ipairs(Heimdall_Data.config.macroer.priority) do
|
||||
priorityMap[className] = priority
|
||||
end
|
||||
local minPriority = #Heimdall_Data.config.macroer.priority + 1
|
||||
|
||||
local sortedStinkies = {}
|
||||
for _, stinky in pairs(stinkies) do
|
||||
table.insert(sortedStinkies, stinky)
|
||||
end
|
||||
|
||||
table.sort(sortedStinkies, function(a, b)
|
||||
local aPriority = priorityMap[a.class] or minPriority
|
||||
local bPriority = priorityMap[b.class] or minPriority
|
||||
return aPriority < bPriority
|
||||
end)
|
||||
|
||||
local lines = {}
|
||||
for name, info in pairs(stinkies) do
|
||||
if info.seenAt > GetTime() - 600 then
|
||||
print(string.format("Macroing %s", name))
|
||||
lines[#lines + 1] = string.format("/tar %s", name)
|
||||
for _, stinky in pairs(sortedStinkies) do
|
||||
if stinky.seenAt > GetTime() - 600 then
|
||||
print(string.format("Macroing %s", stinky.name))
|
||||
lines[#lines + 1] = string.format("/tar %s", stinky.name)
|
||||
end
|
||||
end
|
||||
|
||||
local idx = FindOrCreateMacro("HeimdallTarget")
|
||||
local body = strjoin("\n", unpack(lines))
|
||||
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
|
||||
print("Updated macro")
|
||||
end
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
@@ -53,9 +69,9 @@ function shared.Macroer.Init()
|
||||
doUpdate = true
|
||||
end
|
||||
end
|
||||
local name, class = string.match(msg, "I see (Hostile) (.+)/(%w+) of")
|
||||
local name, class = string.match(msg, "I see (Hostile) ([^ -/]+)-?%w*/(%w+) of")
|
||||
if not name then
|
||||
name, class = string.match(msg, "^(.+) of class (%w+)")
|
||||
name, class = string.match(msg, "^([^ -/]+)-?%w* of class (%w+)")
|
||||
end
|
||||
if name then
|
||||
name = strtrim(name)
|
||||
@@ -74,14 +90,19 @@ function shared.Macroer.Init()
|
||||
|
||||
hooksecurefunc("JumpOrAscendStart", function()
|
||||
FixMacro({
|
||||
["茶杯鸭跳芭蕾"] = {
|
||||
name = "茶杯鸭跳芭蕾",
|
||||
["Paladin"] = {
|
||||
name = "Paladin",
|
||||
class = "Paladin",
|
||||
seenAt = GetTime(),
|
||||
},
|
||||
["Asen"] = {
|
||||
name = "Asen",
|
||||
class = "Warlock",
|
||||
["Rogue"] = {
|
||||
name = "Rogue",
|
||||
class = "Rogue",
|
||||
seenAt = GetTime(),
|
||||
},
|
||||
["Priest"] = {
|
||||
name = "Priest",
|
||||
class = "Priest",
|
||||
seenAt = GetTime(),
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user