Add debug options
Add debug buttons Add combatalerter debug
This commit is contained in:
59
Heimdall.lua
59
Heimdall.lua
@@ -2,11 +2,6 @@ local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
|
||||
-- TODO: Implement counting kills and display on whosniffer
|
||||
-- Take last N seconds of combatlog into account ie. count who does damage to who
|
||||
-- Maybe even make an alert when someone does too much damage to someone else...
|
||||
-- But that would not be trivial as of now, I can't think of a way to do it sensibly
|
||||
|
||||
local function init()
|
||||
---@class Heimdall_Data
|
||||
---@field config HeimdallConfig
|
||||
@@ -41,6 +36,7 @@ local function init()
|
||||
---@field StinkyTracker InitTable
|
||||
---@field CombatAlerter InitTable
|
||||
---@field Config InitTable
|
||||
---@field Sniffer InitTable
|
||||
|
||||
--- Config ---
|
||||
---@class HeimdallConfig
|
||||
@@ -58,12 +54,14 @@ local function init()
|
||||
---@field commander HeimdallCommanderConfig
|
||||
---@field stinkyTracker HeimdallStinkyTrackerConfig
|
||||
---@field combatAlerter HeimdallCombatAlerterConfig
|
||||
---@field sniffer HeimdallSnifferConfig
|
||||
---@field whisperNotify table<string, string>
|
||||
---@field stinkies table<string, boolean>
|
||||
---@field agents table<string, string>
|
||||
|
||||
---@class HeimdallSpotterConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field everyone boolean
|
||||
---@field hostile boolean
|
||||
---@field alliance boolean
|
||||
@@ -74,6 +72,7 @@ local function init()
|
||||
|
||||
---@class HeimdallWhoConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field ignored table<string, boolean>
|
||||
---@field notifyChannel string
|
||||
---@field ttl number
|
||||
@@ -82,10 +81,12 @@ local function init()
|
||||
|
||||
---@class HeimdallMessengerConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field interval number
|
||||
|
||||
---@class HeimdallDeathReporterConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field throttle number
|
||||
---@field doWhisper boolean
|
||||
---@field notifyChannel string
|
||||
@@ -94,6 +95,7 @@ local function init()
|
||||
|
||||
---@class HeimdallInviterConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field listeningChannel string
|
||||
---@field keyword string
|
||||
---@field allAssist boolean
|
||||
@@ -105,43 +107,62 @@ local function init()
|
||||
|
||||
---@class HeimdallDuelerConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field declineOther boolean
|
||||
|
||||
---@class HeimdallBullyConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
|
||||
|
||||
---@class HeimdallAgentTrackerConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field masterChannel string
|
||||
|
||||
|
||||
---@class HeimdallEmoterConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field masterChannel string
|
||||
---@field prefix string
|
||||
|
||||
---@class HeimdallEchoerConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field masterChannel string
|
||||
---@field prefix string
|
||||
|
||||
---@class HeimdallMacroerConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field priority string[]
|
||||
|
||||
---@class HeimdallCommanderConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field masterChannel string
|
||||
---@field commander string
|
||||
---@field commands table<string, boolean>
|
||||
|
||||
---@class HeimdallStinkyTrackerConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field masterChannel string
|
||||
|
||||
---@class HeimdallCombatAlerterConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field masterChannel string
|
||||
|
||||
---@class HeimdallSnifferConfig
|
||||
---@field enabled boolean
|
||||
---@field debug boolean
|
||||
---@field notifyChannel string
|
||||
---@field throttle number
|
||||
---@field zoneOverride string?
|
||||
---@field stinky boolean
|
||||
|
||||
--- Data ---
|
||||
---@class HeimdallMessengerData
|
||||
---@field queue table<string, Message>
|
||||
@@ -186,6 +207,7 @@ local function init()
|
||||
Heimdall_Data.config = {
|
||||
spotter = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "debug" }, false),
|
||||
everyone = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "everyone" }, false),
|
||||
hostile = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "hostile" }, true),
|
||||
alliance = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "alliance" }, true),
|
||||
@@ -196,6 +218,7 @@ local function init()
|
||||
},
|
||||
who = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "who", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "who", "debug" }, false),
|
||||
ignored = shared.GetOrDefault(Heimdall_Data, { "config", "who", "ignored" }, {}),
|
||||
notifyChannel = shared.GetOrDefault(Heimdall_Data, { "config", "who", "notifyChannel" }, "Agent"),
|
||||
ttl = shared.GetOrDefault(Heimdall_Data, { "config", "who", "ttl" }, 20),
|
||||
@@ -211,10 +234,12 @@ local function init()
|
||||
},
|
||||
messenger = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "enabled" }, true),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "debug" }, false),
|
||||
interval = shared.GetOrDefault(Heimdall_Data, { "config", "messenger", "interval" }, 0.2),
|
||||
},
|
||||
deathReporter = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "debug" }, false),
|
||||
throttle = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "throttle" }, 10),
|
||||
doWhisper = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "doWhisper" }, true),
|
||||
notifyChannel = shared.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "notifyChannel" }, "Agent"),
|
||||
@@ -225,6 +250,7 @@ local function init()
|
||||
stinkies = shared.GetOrDefault(Heimdall_Data, { "config", "stinkies" }, {}),
|
||||
inviter = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "debug" }, false),
|
||||
listeningChannel = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "listeningChannel" }, "Agent"),
|
||||
keyword = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "keyword" }, "+"),
|
||||
allAssist = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "allAssist" }, false),
|
||||
@@ -236,44 +262,67 @@ local function init()
|
||||
},
|
||||
dueler = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "debug" }, false),
|
||||
declineOther = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "declineOther" }, false),
|
||||
},
|
||||
bully = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "bully", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "bully", "debug" }, false) ,
|
||||
},
|
||||
agentTracker = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "debug" }, false),
|
||||
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "agentTracker", "masterChannel" }, "Agent"),
|
||||
},
|
||||
emoter = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "debug" }, false),
|
||||
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "masterChannel" }, "Agent"),
|
||||
prefix = shared.GetOrDefault(Heimdall_Data, { "config", "emoter", "prefix" }, ""),
|
||||
},
|
||||
echoer = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "debug" }, false),
|
||||
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "masterChannel" }, "Agent"),
|
||||
prefix = shared.GetOrDefault(Heimdall_Data, { "config", "echoer", "prefix" }, ""),
|
||||
},
|
||||
macroer = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "macroer", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "macroer", "debug" }, false),
|
||||
priority = shared.GetOrDefault(Heimdall_Data, { "config", "macroer", "priority" }, {}),
|
||||
},
|
||||
agents = shared.GetOrDefault(Heimdall_Data, { "config", "agents" }, {}),
|
||||
commander = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "debug" }, false),
|
||||
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "masterChannel" }, "Agent"),
|
||||
commander = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "commander" }, "Heimdállr"),
|
||||
commands = shared.GetOrDefault(Heimdall_Data, { "config", "commander", "commands" }, {}),
|
||||
},
|
||||
stinkyTracker = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "debug" }, false),
|
||||
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "masterChannel" }, "Agent"),
|
||||
},
|
||||
combatAlerter = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "debug" }, false),
|
||||
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "masterChannel" }, "Agent"),
|
||||
},
|
||||
messageDelegator = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "debug" }, false),
|
||||
delegates = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "delegates" }, {}),
|
||||
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "masterChannel" }, "Agent"),
|
||||
},
|
||||
sniffer = {
|
||||
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "enabled" }, false),
|
||||
debug = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "debug" }, false),
|
||||
notifyChannel = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "notifyChannel" }, "Agent"),
|
||||
throttle = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "throttle" }, 10),
|
||||
zoneOverride = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "zoneOverride" }, nil),
|
||||
stinky = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "stinky" }, true),
|
||||
},
|
||||
}
|
||||
|
||||
shared.raceMap = {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "AgentTracker"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.AgentTracker = {}
|
||||
@@ -9,29 +10,78 @@ function shared.AgentTracker.Init()
|
||||
local channelRosterFrame = CreateFrame("Frame")
|
||||
channelRosterFrame:RegisterEvent("CHANNEL_ROSTER_UPDATE")
|
||||
channelRosterFrame:SetScript("OnEvent", function(self, event, index)
|
||||
if not Heimdall_Data.config.agentTracker.enabled then return end
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: Received event: %s", ModuleName, event))
|
||||
shared.dumpTable(Heimdall_Data.config.agentTracker)
|
||||
end
|
||||
if not Heimdall_Data.config.agentTracker.enabled then
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: AgentTracker disabled", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
local name = GetChannelDisplayInfo(index)
|
||||
if name ~= Heimdall_Data.config.agentTracker.masterChannel then return end
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: Processing channel: %s", ModuleName, name))
|
||||
end
|
||||
if name ~= Heimdall_Data.config.agentTracker.masterChannel then
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: Channel is not master channel: %s", ModuleName, name))
|
||||
end
|
||||
return
|
||||
end
|
||||
local count = select(5, GetChannelDisplayInfo(index))
|
||||
for i = 1, count do
|
||||
local name = GetChannelRosterInfo(index, i)
|
||||
if name then
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: Tracking agent in channel: %s", ModuleName, name))
|
||||
end
|
||||
Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S")
|
||||
end
|
||||
end
|
||||
--shared.dumpTable(Heimdall_Data.config.agents)
|
||||
end)
|
||||
|
||||
local agentTrackerChannelSniffer = CreateFrame("Frame")
|
||||
agentTrackerChannelSniffer:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
agentTrackerChannelSniffer:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
if not Heimdall_Data.config.agentTracker.enabled then return end
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: Received event: %s", ModuleName, event))
|
||||
shared.dumpTable(Heimdall_Data.config.agentTracker)
|
||||
end
|
||||
if not Heimdall_Data.config.agentTracker.enabled then
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: AgentTracker disabled", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
local channelId = select(6, ...)
|
||||
local channelname = GetChannelName(channelId)
|
||||
if not channelname then return end
|
||||
if channelname ~= Heimdall_Data.config.who.notifyChannel then return end
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: Processing message from: %s", ModuleName, sender))
|
||||
end
|
||||
if not channelname then
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: No channel name found", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
if channelname ~= Heimdall_Data.config.who.notifyChannel then
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: Message not in notify channel: %s", ModuleName, channelname))
|
||||
end
|
||||
return
|
||||
end
|
||||
local agentName = sender
|
||||
if not agentName then return end
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: Tracking agent from message: %s", ModuleName, agentName))
|
||||
end
|
||||
if not agentName then
|
||||
if Heimdall_Data.config.agentTracker.debug then
|
||||
print(string.format("%s: No agent name found", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
Heimdall_Data.config.agents[agentName] = date("%Y-%m-%dT%H:%M:%S")
|
||||
end)
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "CombatAlerter"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.CombatAlerter = {}
|
||||
@@ -9,17 +10,33 @@ function shared.CombatAlerter.Init()
|
||||
local combatAlerterFrame = CreateFrame("Frame")
|
||||
combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||
combatAlerterFrame:SetScript("OnEvent", function(self, event, ...)
|
||||
if Heimdall_Data.config.combatAlerter.debug then
|
||||
print(string.format("%s: Received event: %s", ModuleName, event))
|
||||
shared.dumpTable(Heimdall_Data.config.combatAlerter)
|
||||
end
|
||||
if not Heimdall_Data.config.combatAlerter.enabled then return end
|
||||
local destination, err = CLEUParser.GetDestName(...)
|
||||
if err then return end
|
||||
if Heimdall_Data.config.combatAlerter.debug then
|
||||
print(string.format("%s: Destination: %s", ModuleName, destination))
|
||||
end
|
||||
if destination ~= UnitName("player") then return end
|
||||
local source, err = CLEUParser.GetSourceName(...)
|
||||
if Heimdall_Data.config.combatAlerter.debug then
|
||||
print(string.format("%s: Source: %s", ModuleName, source))
|
||||
end
|
||||
if err then source = "unknown" end
|
||||
|
||||
if shared.stinkyTracker.stinkies and shared.stinkyTracker.stinkies[source] then
|
||||
if Heimdall_Data.config.combatAlerter.debug then
|
||||
print(string.format("%s: Alerted status for %s: %s", ModuleName, source, alerted[source]))
|
||||
end
|
||||
if alerted[source] then return end
|
||||
alerted[source] = true
|
||||
local x, y = GetPlayerMapPosition("player")
|
||||
if Heimdall_Data.config.combatAlerter.debug then
|
||||
print(string.format("%s: Player position: %2.2f,%2.2f", ModuleName, x, y))
|
||||
end
|
||||
---@type Message
|
||||
local msg = {
|
||||
channel = "CHANNEL",
|
||||
@@ -30,6 +47,10 @@ function shared.CombatAlerter.Init()
|
||||
x * 100, y * 100
|
||||
),
|
||||
}
|
||||
if Heimdall_Data.config.combatAlerter.debug then
|
||||
print(string.format("%s: Message:", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
end
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
end)
|
||||
@@ -37,11 +58,11 @@ function shared.CombatAlerter.Init()
|
||||
local combatTriggerFrame = CreateFrame("Frame")
|
||||
combatTriggerFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
combatTriggerFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
-- We want to only alert once per target per combat encounter
|
||||
-- Even a small throttle would probably spam too much here
|
||||
-- ....but maybe we can call it a 120 second throttle or something?
|
||||
-- We will see
|
||||
combatTriggerFrame:SetScript("OnEvent", function(self, event, ...)
|
||||
if Heimdall_Data.config.combatAlerter.debug then
|
||||
print(string.format("%s: Received event: %s", ModuleName, event))
|
||||
shared.dumpTable(Heimdall_Data.config.combatAlerter)
|
||||
end
|
||||
alerted = {}
|
||||
end)
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Commander"
|
||||
|
||||
local helpMessages = {
|
||||
ru = {
|
||||
@@ -86,6 +87,9 @@ function shared.Commander.Init()
|
||||
player.stinky and "(!!!!)" or "")
|
||||
end
|
||||
end
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: ret = %s", ModuleName, strjoin(", ", unpack(ret))))
|
||||
end
|
||||
return ret
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
@@ -111,6 +115,9 @@ function shared.Commander.Init()
|
||||
for class, count in pairs(ret) do
|
||||
text[#text + 1] = string.format("%s: %d", class, count)
|
||||
end
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: ret = %s", ModuleName, strjoin(", ", unpack(text))))
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
@@ -124,6 +131,7 @@ function shared.Commander.Init()
|
||||
return text
|
||||
end
|
||||
local function CountClassPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: CountClassPartitionedStinkies", ModuleName)) end
|
||||
local res = CountClassPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then
|
||||
return { "No stinkies found" }
|
||||
@@ -131,6 +139,7 @@ function shared.Commander.Init()
|
||||
return res
|
||||
end
|
||||
local function WhoPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: WhoPartitionedStinkies", ModuleName)) end
|
||||
local res = WhoPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then
|
||||
return { "No stinkies found" }
|
||||
@@ -138,23 +147,33 @@ function shared.Commander.Init()
|
||||
return res
|
||||
end
|
||||
local function CountPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: CountPartitionedStinkies", ModuleName)) end
|
||||
local res = CountPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then
|
||||
return { "No stinkies found" }
|
||||
end
|
||||
return res
|
||||
end
|
||||
local function HelpRu() return helpMessages.ru end
|
||||
local function HelpEn() return helpMessages.en end
|
||||
local function HelpRu()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: HelpRu", ModuleName)) end
|
||||
return helpMessages.ru
|
||||
end
|
||||
local function HelpEn()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: HelpEn", ModuleName)) end
|
||||
return helpMessages.en
|
||||
end
|
||||
local groupInviteFrame = CreateFrame("Frame")
|
||||
groupInviteFrame:SetScript("OnEvent", function(self, event, ...)
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: OnEvent", ModuleName)) end
|
||||
AcceptGroup()
|
||||
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
|
||||
C_Timer.NewTimer(0.1, function()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: Click", ModuleName)) end
|
||||
_G["StaticPopup1Button1"]:Click()
|
||||
end, 1)
|
||||
end)
|
||||
local function JoinGroup()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: JoinGroup", ModuleName)) end
|
||||
groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST")
|
||||
C_Timer.NewTimer(10, function()
|
||||
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
|
||||
@@ -162,11 +181,13 @@ function shared.Commander.Init()
|
||||
return { "+" }
|
||||
end
|
||||
local function LeaveGroup()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: LeaveGroup", ModuleName)) end
|
||||
LeaveParty()
|
||||
return {}
|
||||
end
|
||||
---@param target string
|
||||
local function FollowTarget(target)
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: FollowTarget: %s", ModuleName, target)) end
|
||||
if not target then return end
|
||||
FollowUnit(target)
|
||||
return {}
|
||||
@@ -191,20 +212,36 @@ function shared.Commander.Init()
|
||||
local commanderChannelFrame = CreateFrame("Frame")
|
||||
commanderChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: OnEvent", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.commander)
|
||||
end
|
||||
if not Heimdall_Data.config.commander.enabled then return end
|
||||
local channelId = select(6, ...)
|
||||
local _, channelname = GetChannelName(channelId)
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: channelname = %s", ModuleName, channelname))
|
||||
end
|
||||
if channelname ~= Heimdall_Data.config.commander.masterChannel then return end
|
||||
sender = string.match(sender, "^[^-]+")
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: sender = %s", ModuleName, sender))
|
||||
end
|
||||
|
||||
for _, command in ipairs(commands) do
|
||||
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: command.keywordRe = %s: %s", ModuleName, command.keywordRe, tostring(enabled)))
|
||||
end
|
||||
if enabled and
|
||||
(not command.commanderOnly
|
||||
or (command.commanderOnly
|
||||
and sender == Heimdall_Data.config.commander.commander)) then
|
||||
if msg:match(command.keywordRe) then
|
||||
local messages = command.callback({ strsplit(" ", msg) })
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: messages = %s", ModuleName, strjoin(", ", unpack(messages))))
|
||||
end
|
||||
for _, message in ipairs(messages) do
|
||||
---@type Message
|
||||
local msg = {
|
||||
|
@@ -521,7 +521,14 @@ function shared.Config.Init()
|
||||
configFrame:Add(spotterConfigFrame, 5, 3)
|
||||
|
||||
local title = CreateFancyText("HeimdallSpotterConfigTitle", spotterConfigFrame.frame, "Spotter", { r, g, b, a })
|
||||
spotterConfigFrame:Add(title, 1, 12)
|
||||
spotterConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallSpotterConfigDebugButton",
|
||||
spotterConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.spotter.debug = not Heimdall_Data.config.spotter.debug
|
||||
return Heimdall_Data.config.spotter.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.spotter.debug)
|
||||
spotterConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallSpotterConfigEnableButton",
|
||||
spotterConfigFrame.frame, "Enabled", function()
|
||||
@@ -617,7 +624,14 @@ function shared.Config.Init()
|
||||
configFrame:Add(whoerConfigFrame, 9, 3)
|
||||
|
||||
local title = CreateFancyText("HeimdallWhoerConfigTitle", whoerConfigFrame.frame, "Whoer", { r, g, b, a })
|
||||
whoerConfigFrame:Add(title, 1, 12)
|
||||
whoerConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallWhoerConfigDebugButton",
|
||||
whoerConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.who.debug = not Heimdall_Data.config.who.debug
|
||||
return Heimdall_Data.config.who.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.who.debug)
|
||||
whoerConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallWhoerConfigEnableButton",
|
||||
whoerConfigFrame.frame, "Enabled", function()
|
||||
@@ -694,7 +708,14 @@ function shared.Config.Init()
|
||||
|
||||
local title = CreateFancyText("HeimdallMessengerConfigTitle", messengerConfigFrame.frame, "Messenger",
|
||||
{ r, g, b, a })
|
||||
messengerConfigFrame:Add(title, 1, 12)
|
||||
messengerConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallMessengerConfigDebugButton",
|
||||
messengerConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.messenger.debug = not Heimdall_Data.config.messenger.debug
|
||||
return Heimdall_Data.config.messenger.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.messenger.debug)
|
||||
messengerConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallMessengerConfigEnableButton",
|
||||
messengerConfigFrame.frame, "Enabled", function()
|
||||
@@ -731,7 +752,14 @@ function shared.Config.Init()
|
||||
local title = CreateFancyText("HeimdallDeathReporterConfigTitle", deathReporterConfigFrame.frame,
|
||||
"Death Reporter",
|
||||
{ r, g, b, a })
|
||||
deathReporterConfigFrame:Add(title, 1, 12)
|
||||
deathReporterConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallDeathReporterConfigDebugButton",
|
||||
deathReporterConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.deathReporter.debug = not Heimdall_Data.config.deathReporter.debug
|
||||
return Heimdall_Data.config.deathReporter.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.deathReporter.debug)
|
||||
deathReporterConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallDeathReporterConfigEnableButton",
|
||||
deathReporterConfigFrame.frame, "Enabled", function()
|
||||
@@ -819,7 +847,14 @@ function shared.Config.Init()
|
||||
configFrame:Add(inviterConfigFrame, 7, 3)
|
||||
|
||||
local title = CreateFancyText("HeimdallInviterConfigTitle", inviterConfigFrame.frame, "Inviter", { r, g, b, a })
|
||||
inviterConfigFrame:Add(title, 1, 12)
|
||||
inviterConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallInviterConfigDebugButton",
|
||||
inviterConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.inviter.debug = not Heimdall_Data.config.inviter.debug
|
||||
return Heimdall_Data.config.inviter.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.inviter.debug)
|
||||
inviterConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallInviterConfigEnableButton",
|
||||
inviterConfigFrame.frame, "Enabled", function()
|
||||
@@ -935,7 +970,14 @@ function shared.Config.Init()
|
||||
configFrame:Add(duelerConfigFrame, 2, 3)
|
||||
|
||||
local title = CreateFancyText("HeimdallDuelerConfigTitle", duelerConfigFrame.frame, "Dueler", { r, g, b, a })
|
||||
duelerConfigFrame:Add(title, 1, 12)
|
||||
duelerConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallDuelerConfigDebugButton",
|
||||
duelerConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.dueler.debug = not Heimdall_Data.config.dueler.debug
|
||||
return Heimdall_Data.config.dueler.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.dueler.debug)
|
||||
duelerConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallInviterConfigEnableButton",
|
||||
duelerConfigFrame.frame, "Enabled", function()
|
||||
@@ -964,7 +1006,15 @@ function shared.Config.Init()
|
||||
|
||||
local title = CreateFancyText("HeimdallAgentTrackerConfigTitle", agentTrackerConfigFrame.frame, "Agent Tracker",
|
||||
{ r, g, b, a })
|
||||
agentTrackerConfigFrame:Add(title, 1, 12)
|
||||
agentTrackerConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallAgentTrackerConfigDebugButton",
|
||||
agentTrackerConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.agentTracker.debug = not Heimdall_Data.config.agentTracker.debug
|
||||
return Heimdall_Data.config.agentTracker.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.agentTracker.debug)
|
||||
agentTrackerConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallAgentTrackerConfigEnableButton",
|
||||
agentTrackerConfigFrame.frame, "Enabled", function()
|
||||
@@ -1001,7 +1051,14 @@ function shared.Config.Init()
|
||||
local title = CreateFancyText("HeimdallStinkyTrackerConfigTitle", stinkyTrackerConfigFrame.frame,
|
||||
"Stinky Tracker",
|
||||
{ r, g, b, a })
|
||||
stinkyTrackerConfigFrame:Add(title, 1, 12)
|
||||
stinkyTrackerConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallStinkyTrackerConfigDebugButton",
|
||||
stinkyTrackerConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.stinkyTracker.debug = not Heimdall_Data.config.stinkyTracker.debug
|
||||
return Heimdall_Data.config.stinkyTracker.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.stinkyTracker.debug)
|
||||
stinkyTrackerConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallStinkyTrackerConfigEnableButton",
|
||||
stinkyTrackerConfigFrame.frame, "Enabled", function()
|
||||
@@ -1037,7 +1094,14 @@ function shared.Config.Init()
|
||||
|
||||
local title = CreateFancyText("HeimdallEmoterConfigTitle", emoterConfigFrame.frame, "Emoter",
|
||||
{ r, g, b, a })
|
||||
emoterConfigFrame:Add(title, 1, 12)
|
||||
emoterConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallEmoterConfigDebugButton",
|
||||
emoterConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.emoter.debug = not Heimdall_Data.config.emoter.debug
|
||||
return Heimdall_Data.config.emoter.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.emoter.debug)
|
||||
emoterConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallEmoterConfigEnableButton",
|
||||
emoterConfigFrame.frame, "Enabled", function()
|
||||
@@ -1088,7 +1152,14 @@ function shared.Config.Init()
|
||||
|
||||
local title = CreateFancyText("HeimdallEchoerConfigTitle", echoerConfigFrame.frame, "Echoer",
|
||||
{ r, g, b, a })
|
||||
echoerConfigFrame:Add(title, 1, 12)
|
||||
echoerConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallEchoerConfigDebugButton",
|
||||
echoerConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.echoer.debug = not Heimdall_Data.config.echoer.debug
|
||||
return Heimdall_Data.config.echoer.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.echoer.debug)
|
||||
echoerConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallEmoterConfigEnableButton",
|
||||
echoerConfigFrame.frame, "Enabled", function()
|
||||
@@ -1139,7 +1210,14 @@ function shared.Config.Init()
|
||||
|
||||
local title = CreateFancyText("HeimdallCommanderConfigTitle", commanderConfigFrame.frame, "Commander",
|
||||
{ r, g, b, a })
|
||||
commanderConfigFrame:Add(title, 1, 12)
|
||||
commanderConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallCommanderConfigDebugButton",
|
||||
commanderConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.commander.debug = not Heimdall_Data.config.commander.debug
|
||||
return Heimdall_Data.config.commander.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.commander.debug)
|
||||
commanderConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallCommanderConfigEnableButton",
|
||||
commanderConfigFrame.frame, "Enabled", function()
|
||||
@@ -1199,7 +1277,14 @@ function shared.Config.Init()
|
||||
|
||||
local title = CreateFancyText("HeimdallMacroerConfigTitle", macroerConfigFrame.frame, "Macroer",
|
||||
{ r, g, b, a })
|
||||
macroerConfigFrame:Add(title, 1, 12)
|
||||
macroerConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallMacroerConfigDebugButton",
|
||||
macroerConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.macroer.debug = not Heimdall_Data.config.macroer.debug
|
||||
return Heimdall_Data.config.macroer.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.macroer.debug)
|
||||
macroerConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallCommanderConfigEnableButton",
|
||||
macroerConfigFrame.frame, "Enabled", function()
|
||||
@@ -1230,7 +1315,14 @@ function shared.Config.Init()
|
||||
local title = CreateFancyText("HeimdallCombatAlerterConfigTitle", combatAlerterConfigFrame.frame,
|
||||
"Combat Alerter",
|
||||
{ r, g, b, a })
|
||||
combatAlerterConfigFrame:Add(title, 1, 12)
|
||||
combatAlerterConfigFrame:Add(title, 1, 8)
|
||||
local debugButton = CreateBasicButton("HeimdallCombatAlerterConfigDebugButton",
|
||||
combatAlerterConfigFrame.frame, "Debug", function()
|
||||
Heimdall_Data.config.combatAlerter.debug = not Heimdall_Data.config.combatAlerter.debug
|
||||
return Heimdall_Data.config.combatAlerter.debug
|
||||
end)
|
||||
debugButton:UpdateColor(Heimdall_Data.config.combatAlerter.debug)
|
||||
combatAlerterConfigFrame:Add(debugButton, 1, 4)
|
||||
|
||||
local enableButton = CreateBasicButton("HeimdallCombatAlerterConfigEnableButton",
|
||||
combatAlerterConfigFrame.frame, "Enabled", function()
|
||||
@@ -1304,7 +1396,7 @@ function shared.Config.Init()
|
||||
stinkiesConfigFrame:Add(stinkies, 16, 12)
|
||||
end
|
||||
|
||||
configFrame.frame:Hide()
|
||||
--configFrame.frame:Hide()
|
||||
print("Heimdall - Config loaded")
|
||||
end
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "DeathReporter"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.DeathReporter = {}
|
||||
@@ -14,20 +15,31 @@ function shared.DeathReporter.Init()
|
||||
---@param destination string
|
||||
---@param spellName string
|
||||
local function RegisterDeath(source, destination, spellName)
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("%s: RegisterDeath", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.deathReporter)
|
||||
end
|
||||
if not Heimdall_Data.config.deathReporter.enabled then return end
|
||||
if recentDeaths[destination]
|
||||
and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("%s: Throttled death report for %s", ModuleName, destination))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if recentDuels[destination]
|
||||
and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination))
|
||||
end
|
||||
return
|
||||
end
|
||||
if recentDuels[source]
|
||||
and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -35,12 +47,18 @@ function shared.DeathReporter.Init()
|
||||
C_Timer.NewTimer(3, function()
|
||||
if recentDuels[destination]
|
||||
and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination))
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("Cancelling death reports for %s and %s because of recent duel", source,
|
||||
destination))
|
||||
end
|
||||
return
|
||||
end
|
||||
if recentDuels[source]
|
||||
and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
|
||||
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination))
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("Cancelling death reports for %s and %s because of recent duel", source,
|
||||
destination))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -48,12 +66,18 @@ function shared.DeathReporter.Init()
|
||||
if zone == nil or zone == "" then
|
||||
zone = string.format("%s (%s)", GetZoneText(), GetSubZoneText())
|
||||
end
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("%s: zone = %s", ModuleName, zone))
|
||||
end
|
||||
|
||||
local text = string.format("%s killed %s with %s in %s",
|
||||
tostring(source),
|
||||
tostring(destination),
|
||||
tostring(spellName),
|
||||
tostring(zone))
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("%s: text = %s", ModuleName, text))
|
||||
end
|
||||
|
||||
---@type Message
|
||||
local msg = {
|
||||
@@ -61,6 +85,10 @@ function shared.DeathReporter.Init()
|
||||
data = Heimdall_Data.config.deathReporter.notifyChannel,
|
||||
message = text,
|
||||
}
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("%s: msg =", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
end
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
|
||||
if Heimdall_Data.config.deathReporter.doWhisper then
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Dueler"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Dueler = {}
|
||||
@@ -8,14 +9,26 @@ function shared.Dueler.Init()
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("DUEL_REQUESTED")
|
||||
frame:SetScript("OnEvent", function(self, event, sender)
|
||||
if Heimdall_Data.config.dueler.debug then
|
||||
print(string.format("%s: OnEvent", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.dueler)
|
||||
end
|
||||
if not Heimdall_Data.config.dueler.enabled then return end
|
||||
if Heimdall_Data.config.dueler.debug then
|
||||
print(string.format("%s: sender = %s", ModuleName, sender))
|
||||
shared.dumpTable(Heimdall_Data.config.agents)
|
||||
end
|
||||
local allow = Heimdall_Data.config.agents[sender]
|
||||
if allow then
|
||||
print("Heimdall - Dueler - Accepting duel from " .. sender)
|
||||
if Heimdall_Data.config.dueler.debug then
|
||||
print(string.format("%s: Accepting duel from %s", ModuleName, sender))
|
||||
end
|
||||
AcceptDuel()
|
||||
else
|
||||
if Heimdall_Data.config.dueler.autoDecline then
|
||||
print("Heimdall - Dueler - Auto declining duel from " .. sender)
|
||||
if Heimdall_Data.config.dueler.debug then
|
||||
print(string.format("%s: Auto declining duel from %s", ModuleName, sender))
|
||||
end
|
||||
CancelDuel()
|
||||
end
|
||||
end
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Echoer"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Echoer = {}
|
||||
@@ -8,25 +9,23 @@ function shared.Echoer.Init()
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
if Heimdall_Data.config.echoer.debug then
|
||||
print(string.format("%s: OnEvent", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.echoer)
|
||||
end
|
||||
if not Heimdall_Data.config.echoer.enabled then return end
|
||||
|
||||
local channelId = select(6, ...)
|
||||
local channelname = ""
|
||||
---@type any[]
|
||||
local channels = { GetChannelList() }
|
||||
for i = 1, #channels, 2 do
|
||||
---@type number
|
||||
local id = channels[i]
|
||||
---@type string
|
||||
local name = channels[i + 1]
|
||||
if id == channelId then
|
||||
channelname = name
|
||||
local _, channelname = GetChannelName(channelId)
|
||||
if Heimdall_Data.config.echoer.debug then
|
||||
print(string.format("%s: channelname = %s", ModuleName, channelname))
|
||||
end
|
||||
end
|
||||
|
||||
if channelname ~= Heimdall_Data.config.echoer.masterChannel then return end
|
||||
|
||||
if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then
|
||||
if Heimdall_Data.config.echoer.debug then
|
||||
print(string.format("%s: msg = %s", ModuleName, msg))
|
||||
end
|
||||
local msg = string.sub(msg, string.len(Heimdall_Data.config.echoer.prefix) + 1)
|
||||
SendChatMessage(msg, "SAY")
|
||||
end
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Emoter"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Emoter = {}
|
||||
@@ -8,25 +9,23 @@ function shared.Emoter.Init()
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
if Heimdall_Data.config.emoter.debug then
|
||||
print(string.format("%s: OnEvent", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.emoter)
|
||||
end
|
||||
if not Heimdall_Data.config.emoter.enabled then return end
|
||||
|
||||
local channelId = select(6, ...)
|
||||
local channelname = ""
|
||||
---@type any[]
|
||||
local channels = { GetChannelList() }
|
||||
for i = 1, #channels, 2 do
|
||||
---@type number
|
||||
local id = channels[i]
|
||||
---@type string
|
||||
local name = channels[i + 1]
|
||||
if id == channelId then
|
||||
channelname = name
|
||||
local _, channelname = GetChannelName(channelId)
|
||||
if Heimdall_Data.config.emoter.debug then
|
||||
print(string.format("%s: channelname = %s", ModuleName, channelname))
|
||||
end
|
||||
end
|
||||
|
||||
if channelname ~= Heimdall_Data.config.emoter.masterChannel then return end
|
||||
|
||||
if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then
|
||||
if Heimdall_Data.config.emoter.debug then
|
||||
print(string.format("%s: msg = %s", ModuleName, msg))
|
||||
end
|
||||
local emote = string.sub(msg, string.len(Heimdall_Data.config.emoter.prefix) + 1)
|
||||
DoEmote(emote)
|
||||
end
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Inviter"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Inviter = {}
|
||||
@@ -9,16 +10,34 @@ function shared.Inviter.Init()
|
||||
local updateTimer = nil
|
||||
|
||||
local function FixGroup()
|
||||
if not IsInRaid() then ConvertToRaid() end
|
||||
if Heimdall_Data.config.inviter.allAssist then SetEveryoneIsAssistant() end
|
||||
--shared.dumpTable(Heimdall_Data.config.inviter)
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: FixGroup", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.inviter)
|
||||
end
|
||||
if not IsInRaid() then
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: Not in raid", ModuleName))
|
||||
end
|
||||
ConvertToRaid()
|
||||
end
|
||||
if Heimdall_Data.config.inviter.allAssist then
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: Setting everyone to assistant", ModuleName))
|
||||
end
|
||||
SetEveryoneIsAssistant()
|
||||
end
|
||||
if Heimdall_Data.config.inviter.agentsAssist then
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: Setting agents to assistant", ModuleName))
|
||||
end
|
||||
--shared.dumpTable(Heimdall_Data.config.agents)
|
||||
for name, _ in pairs(Heimdall_Data.config.agents) do
|
||||
if UnitInParty(name)
|
||||
and not UnitIsGroupLeader(name)
|
||||
and not UnitIsRaidOfficer(name) then
|
||||
print("Promoting " .. name .. " to assistant")
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: Promoting %s to assistant", ModuleName, name))
|
||||
end
|
||||
PromoteToAssistant(name, true)
|
||||
end
|
||||
end
|
||||
@@ -32,12 +51,25 @@ function shared.Inviter.Init()
|
||||
---But that is currently not trivial and would require some work
|
||||
---Since I'm the only one currently using this - I don't care where the buttons are
|
||||
local function OverlayKickButtonElvUI(name)
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: OverlayKickButtonElvUI", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.inviter)
|
||||
end
|
||||
for group = 1, 8 do
|
||||
for player = 1, 5 do
|
||||
local button = _G[string.format("ElvUF_RaidGroup%dUnitButton%d", group, player)]
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: button = %s", ModuleName, button))
|
||||
end
|
||||
|
||||
local unitName = button and button.unit and UnitName(button.unit)
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: unitName = %s", ModuleName, unitName))
|
||||
end
|
||||
if unitName == name then
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: unitName == name", ModuleName))
|
||||
end
|
||||
local overlayButton = framePool[button.unit] or
|
||||
CreateFrame("Button",
|
||||
string.format("HeimdallKickButton%s", button.unit, button, "SecureActionButtonTemplate"))
|
||||
@@ -110,6 +142,11 @@ function shared.Inviter.Init()
|
||||
local inviterGroupFrame = CreateFrame("Frame")
|
||||
inviterGroupFrame:RegisterEvent("GROUP_ROSTER_UPDATE")
|
||||
inviterGroupFrame:SetScript("OnEvent", function(self, event, ...)
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: OnEvent", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.inviter)
|
||||
print(string.format("%s: event = %s", ModuleName, UnitIsGroupLeader("player")))
|
||||
end
|
||||
if not Heimdall_Data.config.inviter.enabled then return end
|
||||
if not UnitIsGroupLeader("player") then return end
|
||||
|
||||
@@ -120,23 +157,20 @@ function shared.Inviter.Init()
|
||||
local inviterChannelFrame = CreateFrame("Frame")
|
||||
inviterChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: OnEvent", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.inviter)
|
||||
end
|
||||
if not Heimdall_Data.config.inviter.enabled then return end
|
||||
local channelId = select(6, ...)
|
||||
local channelname = ""
|
||||
---@type any[]
|
||||
local channels = { GetChannelList() }
|
||||
for i = 1, #channels, 2 do
|
||||
---@type number
|
||||
local id = channels[i]
|
||||
---@type string
|
||||
local name = channels[i + 1]
|
||||
if id == channelId then
|
||||
channelname = name
|
||||
end
|
||||
end
|
||||
|
||||
local _, channelname = GetChannelName(channelId)
|
||||
if channelname ~= Heimdall_Data.config.inviter.listeningChannel then return end
|
||||
if msg == Heimdall_Data.config.inviter.keyword then InviteUnit(sender) end
|
||||
if msg == Heimdall_Data.config.inviter.keyword then
|
||||
if Heimdall_Data.config.inviter.debug then
|
||||
print(string.format("%s: Inviting %s", ModuleName, sender))
|
||||
end
|
||||
InviteUnit(sender)
|
||||
end
|
||||
end)
|
||||
|
||||
print("Heimdall - Inviter loaded")
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Macroer"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Macroer = {}
|
||||
@@ -11,22 +12,37 @@ function shared.Macroer.Init()
|
||||
---@field seenAt number
|
||||
---@field hostile boolean
|
||||
|
||||
---@type table<string, stinky>
|
||||
local recentStinkies = {}
|
||||
|
||||
local function FindOrCreateMacro(macroName)
|
||||
if Heimdall_Data.config.macroer.debug then
|
||||
print(string.format("%s: FindOrCreateMacro", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.macroer)
|
||||
end
|
||||
local idx = GetMacroIndexByName(macroName)
|
||||
if idx == 0 then
|
||||
if Heimdall_Data.config.macroer.debug then
|
||||
print(string.format("%s: Creating macro", ModuleName))
|
||||
end
|
||||
CreateMacro(macroName, "INV_Misc_QuestionMark", "")
|
||||
end
|
||||
idx = GetMacroIndexByName(macroName)
|
||||
if Heimdall_Data.config.macroer.debug then
|
||||
print(string.format("%s: idx = %s", ModuleName, idx))
|
||||
end
|
||||
return idx
|
||||
end
|
||||
|
||||
---@param stinkies table<string, stinky>
|
||||
local function FixMacro(stinkies)
|
||||
if Heimdall_Data.config.macroer.debug then
|
||||
print(string.format("%s: FixMacro", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.macroer)
|
||||
end
|
||||
if not Heimdall_Data.config.macroer.enabled then return end
|
||||
if InCombatLockdown() then return end
|
||||
if Heimdall_Data.config.macroer.debug then
|
||||
print(string.format("%s: InCombatLockdown", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.macroer)
|
||||
end
|
||||
local priorityMap = {}
|
||||
for priority, className in ipairs(Heimdall_Data.config.macroer.priority) do
|
||||
priorityMap[className] = priority
|
||||
@@ -60,6 +76,10 @@ function shared.Macroer.Init()
|
||||
end
|
||||
|
||||
shared.stinkyTracker.stinkies:onChange(function(value)
|
||||
if Heimdall_Data.config.macroer.debug then
|
||||
print(string.format("%s: onChange", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.macroer)
|
||||
end
|
||||
FixMacro(value)
|
||||
end)
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Messenger"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Messenger = {}
|
||||
@@ -24,7 +25,9 @@ function shared.Messenger.Init()
|
||||
local function FindOrJoinChannel(channelName, password)
|
||||
local channelId = GetChannelName(channelName)
|
||||
if channelId == 0 then
|
||||
print("Channel", tostring(channelName), "not found, joining")
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel %s not found, joining", ModuleName, channelName))
|
||||
end
|
||||
if password then
|
||||
JoinPermanentChannel(channelName, password)
|
||||
else
|
||||
@@ -32,6 +35,9 @@ function shared.Messenger.Init()
|
||||
end
|
||||
end
|
||||
channelId = GetChannelName(channelName)
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel %s found, id = %s", ModuleName, channelName, channelId))
|
||||
end
|
||||
return channelId
|
||||
end
|
||||
|
||||
@@ -40,6 +46,10 @@ function shared.Messenger.Init()
|
||||
if not shared.messenger.queue then shared.messenger.queue = {} end
|
||||
if not shared.messenger.ticker then
|
||||
local function DoMessage()
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: DoMessage", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.messenger)
|
||||
end
|
||||
if not Heimdall_Data.config.messenger.enabled then return end
|
||||
---@type Message
|
||||
local message = shared.messenger.queue[1]
|
||||
@@ -48,13 +58,19 @@ function shared.Messenger.Init()
|
||||
if not message.channel or message.channel == "" then return end
|
||||
|
||||
if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then
|
||||
--print("Channel presented as string:", message.data)
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel presented as string: %s", ModuleName, message.data))
|
||||
end
|
||||
local channelId = GetChannelName(message.data)
|
||||
if channelId == 0 then
|
||||
print(string.format("Channel not found, joining %s", message.data))
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel not found, joining %s", ModuleName, message.data))
|
||||
end
|
||||
channelId = FindOrJoinChannel(message.data)
|
||||
end
|
||||
--print("Channel resolved to id", channelId)
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Channel resolved to id %s", ModuleName, channelId))
|
||||
end
|
||||
message.data = tostring(channelId)
|
||||
end
|
||||
|
||||
@@ -65,6 +81,10 @@ function shared.Messenger.Init()
|
||||
SendChatMessage(message.message, message.channel, nil, message.data)
|
||||
end
|
||||
local function Tick()
|
||||
if Heimdall_Data.config.messenger.debug then
|
||||
print(string.format("%s: Tick", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.messenger)
|
||||
end
|
||||
DoMessage()
|
||||
shared.messenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.messenger.interval, Tick, 1)
|
||||
end
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Spotter"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.Spotter = {}
|
||||
@@ -27,15 +28,34 @@ function shared.Spotter.Init()
|
||||
---@return boolean
|
||||
---@return string? error
|
||||
local function ShouldNotify(unit, name, faction, hostile)
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: ShouldNotify", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.spotter)
|
||||
end
|
||||
if Heimdall_Data.config.agents[name] then return false end
|
||||
if Heimdall_Data.config.spotter.stinky then
|
||||
if Heimdall_Data.config.stinkies[name] then return true end
|
||||
if Heimdall_Data.config.stinkies[name] then
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Stinky found in config", ModuleName))
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
if Heimdall_Data.config.spotter.alliance then
|
||||
if faction == "Alliance" then return true end
|
||||
if faction == "Alliance" then
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Alliance", ModuleName))
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
if Heimdall_Data.config.spotter.hostile then
|
||||
if hostile then return true end
|
||||
if hostile then
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Hostile", ModuleName))
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
return Heimdall_Data.config.spotter.everyone
|
||||
end
|
||||
@@ -43,14 +63,24 @@ function shared.Spotter.Init()
|
||||
---@param unit string
|
||||
---@return string?
|
||||
local function NotifySpotted(unit)
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: NotifySpotted", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.spotter)
|
||||
end
|
||||
if not unit then return string.format("Could not find unit %s", tostring(unit)) end
|
||||
if not UnitIsPlayer(unit) then return nil end
|
||||
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: UnitIsPlayer", ModuleName))
|
||||
end
|
||||
local name = UnitName(unit)
|
||||
if not name then return string.format("Could not find name for unit %s", tostring(unit)) end
|
||||
|
||||
local time = GetTime()
|
||||
if throttleTable[name] and time - throttleTable[name] < Heimdall_Data.config.spotter.throttleTime then
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Throttled %s", ModuleName, tostring(name)))
|
||||
end
|
||||
return string.format("Throttled %s", tostring(name))
|
||||
end
|
||||
throttleTable[name] = time
|
||||
@@ -59,19 +89,37 @@ function shared.Spotter.Init()
|
||||
if not race then return string.format("Could not find race for unit %s", tostring(unit)) end
|
||||
local faction = shared.raceMap[race]
|
||||
if not faction then return string.format("Could not find faction for race %s", tostring(race)) end
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Faction %s", ModuleName, tostring(faction)))
|
||||
end
|
||||
|
||||
local hostile = UnitCanAttack("player", unit)
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Hostile %s", ModuleName, tostring(hostile)))
|
||||
end
|
||||
local doNotify = ShouldNotify(unit, name, faction, hostile)
|
||||
if not doNotify then return string.format("Not notifying for %s", tostring(name)) end
|
||||
|
||||
local hp = UnitHealth(unit)
|
||||
if not hp then return string.format("Could not find hp for unit %s", tostring(unit)) end
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: HP %s", ModuleName, tostring(hp)))
|
||||
end
|
||||
|
||||
|
||||
local maxHp = UnitHealthMax(unit)
|
||||
if not maxHp then return string.format("Could not find maxHp for unit %s", tostring(unit)) end
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: MaxHP %s", ModuleName, tostring(maxHp)))
|
||||
end
|
||||
|
||||
|
||||
local class = UnitClass(unit)
|
||||
if not class then return string.format("Could not find class for unit %s", tostring(unit)) end
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Class %s", ModuleName, tostring(class)))
|
||||
end
|
||||
|
||||
|
||||
local location = Heimdall_Data.config.spotter.zoneOverride
|
||||
if not location or location == "" then
|
||||
@@ -79,10 +127,18 @@ function shared.Spotter.Init()
|
||||
if not zone then return string.format("Could not find zone for unit %s", tostring(unit)) end
|
||||
local subzone = GetSubZoneText()
|
||||
if not subzone then subzone = "" end
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Zone %s", ModuleName, tostring(zone)))
|
||||
print(string.format("%s: Subzone %s", ModuleName, tostring(subzone)))
|
||||
end
|
||||
location = string.format("%s (%s)", zone, subzone)
|
||||
end
|
||||
|
||||
local x, y = GetPlayerMapPosition("player")
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: X %s", ModuleName, tostring(x)))
|
||||
print(string.format("%s: Y %s", ModuleName, tostring(y)))
|
||||
end
|
||||
local stinky = Heimdall_Data.config.stinkies[name] or false
|
||||
local text = string.format("I see (%s) %s/%s %s of race %s (%s) with health %s/%s at %s (%2.2f, %2.2f)",
|
||||
hostile and "Hostile" or "Friendly",
|
||||
@@ -95,6 +151,10 @@ function shared.Spotter.Init()
|
||||
FormatHP(maxHp),
|
||||
location,
|
||||
x * 100, y * 100)
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Text %s", ModuleName, tostring(text)))
|
||||
end
|
||||
|
||||
|
||||
---@type Message
|
||||
local msg = {
|
||||
@@ -102,7 +162,10 @@ function shared.Spotter.Init()
|
||||
data = Heimdall_Data.config.spotter.notifyChannel,
|
||||
message = text
|
||||
}
|
||||
--shared.dumpTable(msg)
|
||||
if Heimdall_Data.config.spotter.debug then
|
||||
print(string.format("%s: Inserting message into queue", ModuleName))
|
||||
shared.dumpTable(msg)
|
||||
end
|
||||
table.insert(shared.messenger.queue, msg)
|
||||
end
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "StinkyTracker"
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
shared.StinkyTracker = {}
|
||||
@@ -13,6 +14,9 @@ function shared.StinkyTracker.Init()
|
||||
---@param msg string
|
||||
---@return table<string, stinky>
|
||||
local function ParseWho(msg)
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Parsing who message: %s", ModuleName, msg))
|
||||
end
|
||||
local stinkies = {}
|
||||
for name, class in string.gmatch(msg, whoRegex) do
|
||||
stinkies[name] = {
|
||||
@@ -21,16 +25,26 @@ function shared.StinkyTracker.Init()
|
||||
seenAt = GetTime(),
|
||||
hostile = true
|
||||
}
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Found stinky in who: %s/%s", ModuleName, name, class))
|
||||
end
|
||||
end
|
||||
return stinkies
|
||||
end
|
||||
|
||||
local seeRegex = "I see %((%w+)%) ([^ -/]+)-?%w*/(%w+)"
|
||||
---@param msg string
|
||||
---@return table<string, stinky>
|
||||
local function ParseSee(msg)
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Parsing see message: %s", ModuleName, msg))
|
||||
end
|
||||
local stinkies = {}
|
||||
local aggression, name, class = string.match(msg, seeRegex)
|
||||
if not name or not class then
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: No valid stinky found in see message", ModuleName))
|
||||
end
|
||||
return stinkies
|
||||
end
|
||||
local stinky = {
|
||||
@@ -40,19 +54,29 @@ function shared.StinkyTracker.Init()
|
||||
hostile = aggression == "Hostile"
|
||||
}
|
||||
stinkies[name] = stinky
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Found stinky in see: %s/%s (%s)", ModuleName, name, class, aggression))
|
||||
end
|
||||
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)
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Parsing arrived message: %s", ModuleName, msg))
|
||||
end
|
||||
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
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: No valid stinky found in arrived message", ModuleName))
|
||||
end
|
||||
return stinkies
|
||||
end
|
||||
local stinky = {
|
||||
@@ -62,45 +86,85 @@ function shared.StinkyTracker.Init()
|
||||
hostile = true
|
||||
}
|
||||
stinkies[name] = stinky
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Found stinky in arrived: %s/%s", ModuleName, name, class))
|
||||
end
|
||||
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.stinkyTracker.enabled then return end
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Received event: %s", ModuleName, event))
|
||||
end
|
||||
if not Heimdall_Data.config.stinkyTracker.enabled then
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: StinkyTracker disabled", ModuleName))
|
||||
end
|
||||
return
|
||||
end
|
||||
local channelId = select(6, ...)
|
||||
local _, channelname = GetChannelName(channelId)
|
||||
if channelname ~= Heimdall_Data.config.stinkyTracker.masterChannel then return end
|
||||
if channelname ~= Heimdall_Data.config.stinkyTracker.masterChannel then
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Message not in master channel: %s", ModuleName, channelname))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if string.find(msg, "^who:") then
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Processing who message", ModuleName))
|
||||
end
|
||||
local whoStinkies = ParseWho(msg)
|
||||
for name, stinky in pairs(whoStinkies) do
|
||||
if stinky.hostile then
|
||||
shared.stinkyTracker.stinkies[name] = stinky
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Added stinky from who: %s", ModuleName, name))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if string.find(msg, "^I see") then
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Processing see message", ModuleName))
|
||||
end
|
||||
local seeStinkies = ParseSee(msg)
|
||||
for name, stinky in pairs(seeStinkies) do
|
||||
if stinky.hostile then
|
||||
shared.stinkyTracker.stinkies[name] = stinky
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Added stinky from see: %s", ModuleName, name))
|
||||
end
|
||||
end
|
||||
if not stinky.hostile then
|
||||
shared.stinkyTracker.stinkies[name] = nil
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Removed stinky from see: %s", ModuleName, name))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if string.find(msg, " and guild ") then
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Processing arrived message", ModuleName))
|
||||
end
|
||||
local arrivedStinkies = ParseArrived(msg)
|
||||
for name, stinky in pairs(arrivedStinkies) do
|
||||
shared.stinkyTracker.stinkies[name] = stinky
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Added stinky from arrived: %s", ModuleName, name))
|
||||
end
|
||||
end
|
||||
end
|
||||
for name, stinky in pairs(shared.stinkyTracker.stinkies) do
|
||||
if Heimdall_Data.config.agents[name] then
|
||||
shared.stinkyTracker.stinkies[name] = nil
|
||||
if Heimdall_Data.config.stinkyTracker.debug then
|
||||
print(string.format("%s: Removed agent stinky: %s", ModuleName, name))
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
Reference in New Issue
Block a user