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>
|
---@param stinkies table<string, stinky>
|
||||||
local function FixMacro(stinkies)
|
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 = {}
|
local lines = {}
|
||||||
for name, info in pairs(stinkies) do
|
for _, stinky in pairs(sortedStinkies) do
|
||||||
if info.seenAt > GetTime() - 600 then
|
if stinky.seenAt > GetTime() - 600 then
|
||||||
print(string.format("Macroing %s", name))
|
print(string.format("Macroing %s", stinky.name))
|
||||||
lines[#lines + 1] = string.format("/tar %s", name)
|
lines[#lines + 1] = string.format("/tar %s", stinky.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local idx = FindOrCreateMacro("HeimdallTarget")
|
local idx = FindOrCreateMacro("HeimdallTarget")
|
||||||
local body = strjoin("\n", unpack(lines))
|
local body = strjoin("\n", unpack(lines))
|
||||||
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
|
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
|
||||||
print("Updated macro")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local frame = CreateFrame("Frame")
|
local frame = CreateFrame("Frame")
|
||||||
@@ -53,9 +69,9 @@ function shared.Macroer.Init()
|
|||||||
doUpdate = true
|
doUpdate = true
|
||||||
end
|
end
|
||||||
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
|
if not name then
|
||||||
name, class = string.match(msg, "^(.+) of class (%w+)")
|
name, class = string.match(msg, "^([^ -/]+)-?%w* of class (%w+)")
|
||||||
end
|
end
|
||||||
if name then
|
if name then
|
||||||
name = strtrim(name)
|
name = strtrim(name)
|
||||||
@@ -74,14 +90,19 @@ function shared.Macroer.Init()
|
|||||||
|
|
||||||
hooksecurefunc("JumpOrAscendStart", function()
|
hooksecurefunc("JumpOrAscendStart", function()
|
||||||
FixMacro({
|
FixMacro({
|
||||||
["茶杯鸭跳芭蕾"] = {
|
["Paladin"] = {
|
||||||
name = "茶杯鸭跳芭蕾",
|
name = "Paladin",
|
||||||
class = "Paladin",
|
class = "Paladin",
|
||||||
seenAt = GetTime(),
|
seenAt = GetTime(),
|
||||||
},
|
},
|
||||||
["Asen"] = {
|
["Rogue"] = {
|
||||||
name = "Asen",
|
name = "Rogue",
|
||||||
class = "Warlock",
|
class = "Rogue",
|
||||||
|
seenAt = GetTime(),
|
||||||
|
},
|
||||||
|
["Priest"] = {
|
||||||
|
name = "Priest",
|
||||||
|
class = "Priest",
|
||||||
seenAt = GetTime(),
|
seenAt = GetTime(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user