Rework macroer to use the new stinkytracker

This commit is contained in:
2025-01-06 01:42:46 +01:00
parent 85a28bc7ca
commit aff3e83bab
2 changed files with 6 additions and 98 deletions

View File

@@ -357,17 +357,17 @@ local function init()
return input return input
end end
shared.Whoer.Init()
shared.Messenger.Init() shared.Messenger.Init()
shared.StinkyTracker.Init()
shared.AgentTracker.Init()
shared.Whoer.Init()
shared.Spotter.Init() shared.Spotter.Init()
shared.DeathReporter.Init() shared.DeathReporter.Init()
shared.Inviter.Init() shared.Inviter.Init()
shared.Dueler.Init() shared.Dueler.Init()
shared.Bully.Init() shared.Bully.Init()
shared.AgentTracker.Init()
shared.Macroer.Init() shared.Macroer.Init()
shared.Commander.Init() shared.Commander.Init()
shared.StinkyTracker.Init()
shared.CombatAlerter.Init() shared.CombatAlerter.Init()
print("Heimdall loaded!") print("Heimdall loaded!")
end end

View File

@@ -42,7 +42,7 @@ function shared.Macroer.Init()
return aPriority > bPriority return aPriority > bPriority
end) end)
local lines = {"/targetenemy"} local lines = { "/targetenemy" }
for _, stinky in pairs(sortedStinkies) do for _, stinky in pairs(sortedStinkies) do
if stinky.seenAt > GetTime() - 600 then if stinky.seenAt > GetTime() - 600 then
print(string.format("Macroing %s", stinky.name)) print(string.format("Macroing %s", stinky.name))
@@ -55,100 +55,8 @@ function shared.Macroer.Init()
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body) EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
end end
local whoRegex = "([^ -/]+)-?%w*/(%w+)" shared.stinkyTracker.stinkies:onChange(function(value)
---@param msg string FixMacro(value)
---@return table<string, stinky>
local function ParseWho(msg)
local stinkies = {}
for name, class in string.gmatch(msg, whoRegex) do
stinkies[name] = {
name = name,
class = class,
seenAt = GetTime(),
hostile = true
}
end
return stinkies
end
local seeRegex = "I see %((%w+)%) ([^ -/]+)-?%w*/(%w+)"
---@param msg string
---@return table<string, stinky>
local function ParseSee(msg)
local stinkies = {}
local aggression, name, class = string.match(msg, seeRegex)
if not name or not class then
return stinkies
end
local stinky = {
name = name,
class = class,
seenAt = GetTime(),
hostile = aggression == "Hostile"
}
stinkies[name] = stinky
return stinkies
end
local arrivedRegex = "([^ -/]+)-?%w* of class (%w+)"
local arrivedRegexAlt = "([^ -/]+)-?%w* %(!!!!%) of class (%w+)"
---@param msg string
---@return table<string, stinky>
local function ParseArrived(msg)
local stinkies = {}
local name, class = string.match(msg, arrivedRegex)
if not name or not class then
name, class = string.match(msg, arrivedRegexAlt)
end
if not name or not class then
return stinkies
end
local stinky = {
name = name,
class = class,
seenAt = GetTime(),
hostile = true
}
return stinkies
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
if not Heimdall_Data.config.macroer.enabled then
return
end
local doUpdate = false
if string.find(msg, "^who:") then
local whoStinkies = ParseWho(msg)
for name, stinky in pairs(whoStinkies) do
if stinky.hostile then
recentStinkies[name] = stinky
doUpdate = true
end
end
end
if string.find(msg, "^I see") then
local seeStinkies = ParseSee(msg)
for name, stinky in pairs(seeStinkies) do
if stinky.hostile then
recentStinkies[name] = stinky
doUpdate = true
end
if not stinky.hostile then
recentStinkies[name] = nil
doUpdate = true
end
end
end
if string.find(msg, " and guild ") then
local arrivedStinkies = ParseArrived(msg)
for name, stinky in pairs(arrivedStinkies) do
recentStinkies[name] = stinky
doUpdate = true
end
end
if doUpdate then
FixMacro(recentStinkies)
end
end) end)
print("Heimdall - Macroer loaded") print("Heimdall - Macroer loaded")