From be81a3130251f6c9960c2ba991a7b2c009069835 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Thu, 9 Jan 2025 10:55:32 +0100 Subject: [PATCH] Code format --- Modules/AgentTracker.lua | 54 +++++++++++++++++++------------------ Modules/CLEUParser.lua | 2 +- Modules/CombatAlerter.lua | 46 +++++++++++++++++--------------- Modules/Commander.lua | 39 ++++++++++++++++----------- Modules/DeathReporter.lua | 56 +++++++++++++++++++++------------------ Modules/Dueler.lua | 13 ++++----- Modules/Echoer.lua | 36 ++++++++++++------------- Modules/Emoter.lua | 36 ++++++++++++------------- Modules/Inviter.lua | 25 +++++++++++++++++ Modules/Macroer.lua | 8 +++--- Modules/Messenger.lua | 50 +++++++++++++++------------------- Modules/Sniffer.lua | 12 ++++----- Modules/Spotter.lua | 41 ++++++++++++++-------------- Modules/StinkyTracker.lua | 42 ++++++++++++++++------------- Modules/Whoer.lua | 45 ++++++++++++++++--------------- 15 files changed, 274 insertions(+), 231 deletions(-) diff --git a/Modules/AgentTracker.lua b/Modules/AgentTracker.lua index b6fe630..cbfd0ce 100644 --- a/Modules/AgentTracker.lua +++ b/Modules/AgentTracker.lua @@ -13,27 +13,27 @@ function shared.AgentTracker.Init() if Heimdall_Data.config.agentTracker.debug then print(string.format("[%s] Channel roster update received", ModuleName)) end - if not Heimdall_Data.config.agentTracker.enabled then + if not Heimdall_Data.config.agentTracker.enabled then if Heimdall_Data.config.agentTracker.debug then print(string.format("[%s] Module disabled, ignoring roster update", ModuleName)) end - return + return end local name = GetChannelDisplayInfo(index) - if Heimdall_Data.config.agentTracker.debug then - print(string.format("[%s] Processing channel update: %s (index: %d)", ModuleName, name or "nil", index)) + if Heimdall_Data.config.agentTracker.debug then + print(string.format("[%s] Processing channel update: %s (index: %d)", ModuleName, name or "nil", index)) end - if name ~= Heimdall_Data.config.agentTracker.masterChannel then + if name ~= Heimdall_Data.config.agentTracker.masterChannel then if Heimdall_Data.config.agentTracker.debug then print(string.format("[%s] Ignoring non-master channel: %s", ModuleName, name or "nil")) end - return + return end local count = select(5, GetChannelDisplayInfo(index)) if Heimdall_Data.config.agentTracker.debug then print(string.format("[%s] Processing %d members in channel", ModuleName, count)) end - + local newAgents = 0 for i = 1, count do local name = GetChannelRosterInfo(index, i) @@ -44,11 +44,12 @@ function shared.AgentTracker.Init() newAgents = newAgents + 1 end if Heimdall_Data.config.agentTracker.debug then - print(string.format("[%s] %s agent: %s", ModuleName, isNewAgent and "Added new" or "Updated existing", name)) + print(string.format("[%s] %s agent: %s", ModuleName, isNewAgent and "Added new" or "Updated existing", + name)) end end end - + if Heimdall_Data.config.agentTracker.debug then print(string.format("[%s] Roster update complete - Added %d new agents", ModuleName, newAgents)) end @@ -57,36 +58,37 @@ function shared.AgentTracker.Init() local agentTrackerChannelSniffer = CreateFrame("Frame") agentTrackerChannelSniffer:RegisterEvent("CHAT_MSG_CHANNEL") agentTrackerChannelSniffer:SetScript("OnEvent", function(self, event, msg, sender, ...) --- if Heimdall_Data.config.agentTracker.debug then --- print(string.format("[%s] Channel message received from: %s", ModuleName, sender)) --- end - if not Heimdall_Data.config.agentTracker.enabled then --- if Heimdall_Data.config.agentTracker.debug then --- print(string.format("[%s] Module disabled, ignoring channel message", ModuleName)) --- end - return + -- if Heimdall_Data.config.agentTracker.debug then + -- print(string.format("[%s] Channel message received from: %s", ModuleName, sender)) + -- end + if not Heimdall_Data.config.agentTracker.enabled then + -- if Heimdall_Data.config.agentTracker.debug then + -- print(string.format("[%s] Module disabled, ignoring channel message", ModuleName)) + -- end + return end - + local channelId = select(6, ...) local _, channelname = GetChannelName(channelId) - if channelname ~= Heimdall_Data.config.agentTracker.masterChannel then --- if Heimdall_Data.config.agentTracker.debug then --- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname)) --- end - return + if channelname ~= Heimdall_Data.config.agentTracker.masterChannel then + -- if Heimdall_Data.config.agentTracker.debug then + -- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname)) + -- end + return end if Heimdall_Data.config.agentTracker.debug then print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) shared.dumpTable(Heimdall_Data.config.agentTracker) end - + sender = string.match(sender, "^[^-]+") local isNewAgent = not Heimdall_Data.config.agents[sender] Heimdall_Data.config.agents[sender] = date("%Y-%m-%dT%H:%M:%S") - + if Heimdall_Data.config.agentTracker.debug then - print(string.format("[%s] %s agent from message: %s", ModuleName, isNewAgent and "Added new" or "Updated existing", sender)) + print(string.format("[%s] %s agent from message: %s", ModuleName, + isNewAgent and "Added new" or "Updated existing", sender)) end end) diff --git a/Modules/CLEUParser.lua b/Modules/CLEUParser.lua index cd782f9..144e85d 100644 --- a/Modules/CLEUParser.lua +++ b/Modules/CLEUParser.lua @@ -1289,4 +1289,4 @@ frame:RegisterEvent("GUILD_ROSTER_UPDATE") frame:SetScript("OnEvent", function(self, event, ...) Init() end) -Init() \ No newline at end of file +Init() diff --git a/Modules/CombatAlerter.lua b/Modules/CombatAlerter.lua index 4818c8f..c66a183 100644 --- a/Modules/CombatAlerter.lua +++ b/Modules/CombatAlerter.lua @@ -13,58 +13,60 @@ function shared.CombatAlerter.Init() if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Combat log event received", ModuleName)) end - if not Heimdall_Data.config.combatAlerter.enabled then + if not Heimdall_Data.config.combatAlerter.enabled then if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Module disabled, ignoring combat event", ModuleName)) end - return + return end - + local destination, err = CLEUParser.GetDestName(...) - if err then + if err then if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Error getting destination: %s", ModuleName, err)) end - return + return end - - if Heimdall_Data.config.combatAlerter.debug then - print(string.format("[%s] Combat event destination: %s", ModuleName, destination)) + + if Heimdall_Data.config.combatAlerter.debug then + print(string.format("[%s] Combat event destination: %s", ModuleName, destination)) end - - if destination ~= UnitName("player") then + + if destination ~= UnitName("player") then if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Ignoring event - not targeted at player", ModuleName)) end - return + return end - + local source, err = CLEUParser.GetSourceName(...) - if err then + if err then if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Error getting source, using 'unknown': %s", ModuleName, err)) end - source = "unknown" + source = "unknown" end - if Heimdall_Data.config.combatAlerter.debug then - print(string.format("[%s] Combat event source: %s", ModuleName, source)) + if Heimdall_Data.config.combatAlerter.debug then + print(string.format("[%s] Combat event source: %s", ModuleName, source)) end if shared.stinkyTracker.stinkies and shared.stinkyTracker.stinkies[source] then if Heimdall_Data.config.combatAlerter.debug then - print(string.format("[%s] Source is tracked stinky: %s (Already alerted: %s)", ModuleName, source, tostring(alerted[source] or false))) + print(string.format("[%s] Source is tracked stinky: %s (Already alerted: %s)", ModuleName, source, + tostring(alerted[source] or false))) end if alerted[source] then return end - + alerted[source] = true local x, y = GetPlayerMapPosition("player") local zone, subZone = GetZoneText(), GetSubZoneText() - + if Heimdall_Data.config.combatAlerter.debug then - print(string.format("[%s] Player location: %s/%s at %.2f,%.2f", ModuleName, zone, subZone, x * 100, y * 100)) + print(string.format("[%s] Player location: %s/%s at %.2f,%.2f", ModuleName, zone, subZone, x * 100, + y * 100)) end - + ---@type Message local msg = { channel = "CHANNEL", @@ -75,7 +77,7 @@ function shared.CombatAlerter.Init() x * 100, y * 100 ), } - + if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Queuing alert message: '%s'", ModuleName, msg.message)) end diff --git a/Modules/Commander.lua b/Modules/Commander.lua index 29f2906..3a9056f 100644 --- a/Modules/Commander.lua +++ b/Modules/Commander.lua @@ -131,7 +131,10 @@ function shared.Commander.Init() return text end local function CountClassPartitionedStinkies() - if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName)) end + if Heimdall_Data.config.commander.debug then + print(string.format("[%s] Executing: CountClassPartitionedStinkies", + ModuleName)) + end local res = CountClassPartitioned(HeimdallStinkies) if #res == 0 then return { "No stinkies found" } @@ -139,7 +142,10 @@ function shared.Commander.Init() return res end local function WhoPartitionedStinkies() - if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName)) end + if Heimdall_Data.config.commander.debug then + print(string.format("[%s] Executing: WhoPartitionedStinkies", + ModuleName)) + end local res = WhoPartitioned(HeimdallStinkies) if #res == 0 then return { "No stinkies found" } @@ -147,7 +153,10 @@ function shared.Commander.Init() return res end local function CountPartitionedStinkies() - if Heimdall_Data.config.commander.debug then print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName)) end + if Heimdall_Data.config.commander.debug then + print(string.format("[%s] Executing: CountPartitionedStinkies", + ModuleName)) + end local res = CountPartitioned(HeimdallStinkies) if #res == 0 then return { "No stinkies found" } @@ -212,21 +221,21 @@ 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] Event received", ModuleName)) --- shared.dumpTable(Heimdall_Data.config.commander) --- end - if not Heimdall_Data.config.commander.enabled then --- if Heimdall_Data.config.commander.debug then --- print(string.format("[%s] Module disabled, ignoring event", ModuleName)) --- end - return + -- if Heimdall_Data.config.commander.debug then + -- print(string.format("[%s] Event received", ModuleName)) + -- shared.dumpTable(Heimdall_Data.config.commander) + -- end + if not Heimdall_Data.config.commander.enabled then + -- if Heimdall_Data.config.commander.debug then + -- print(string.format("[%s] Module disabled, ignoring event", ModuleName)) + -- end + return end local channelId = select(6, ...) local _, channelname = GetChannelName(channelId) --- if Heimdall_Data.config.commander.debug then --- print(string.format("[%s] Channel received: %s", ModuleName, channelname)) --- end + -- if Heimdall_Data.config.commander.debug then + -- print(string.format("[%s] Channel received: %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 diff --git a/Modules/DeathReporter.lua b/Modules/DeathReporter.lua index 3a77854..0c05da6 100644 --- a/Modules/DeathReporter.lua +++ b/Modules/DeathReporter.lua @@ -16,21 +16,21 @@ function shared.DeathReporter.Init() ---@param spellName string local function RegisterDeath(source, destination, spellName) if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Processing death event - Source: %s, Target: %s, Spell: %s", + print(string.format("[%s] Processing death event - Source: %s, Target: %s, Spell: %s", ModuleName, source, destination, spellName)) end - - if not Heimdall_Data.config.deathReporter.enabled then + + if not Heimdall_Data.config.deathReporter.enabled then if Heimdall_Data.config.deathReporter.debug then print(string.format("[%s] Module disabled, ignoring death event", ModuleName)) end - return + return end - + if recentDeaths[destination] and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle then if Heimdall_Data.config.deathReporter.debug then local timeLeft = Heimdall_Data.config.deathReporter.throttle - (GetTime() - recentDeaths[destination]) - print(string.format("[%s] Death report throttled for %s (%.1f seconds remaining)", + print(string.format("[%s] Death report throttled for %s (%.1f seconds remaining)", ModuleName, destination, timeLeft)) end return @@ -38,14 +38,16 @@ function shared.DeathReporter.Init() if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Ignoring death report - Recent duel detected for target: %s", ModuleName, destination)) + print(string.format("[%s] Ignoring death report - Recent duel detected for target: %s", ModuleName, + 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("[%s] Ignoring death report - Recent duel detected for source: %s", ModuleName, source)) + print(string.format("[%s] Ignoring death report - Recent duel detected for source: %s", ModuleName, + source)) end return end @@ -54,27 +56,29 @@ function shared.DeathReporter.Init() print(string.format("[%s] Recording death for %s", ModuleName, destination)) end recentDeaths[destination] = GetTime() - + C_Timer.NewTimer(3, function() if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, destination)) + print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, + 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("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, source)) + print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName, + source)) end return end if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Sending death report - %s killed %s with %s", + print(string.format("[%s] Sending death report - %s killed %s with %s", ModuleName, source, destination, spellName)) end - + ---@type Message local msg = { channel = "CHANNEL", @@ -132,12 +136,12 @@ function shared.DeathReporter.Init() if Heimdall_Data.config.deathReporter.debug then print(string.format("[%s] Received system message: %s", ModuleName, msg)) end - - if not Heimdall_Data.config.deathReporter.enabled then + + if not Heimdall_Data.config.deathReporter.enabled then if Heimdall_Data.config.deathReporter.debug then print(string.format("[%s] Module disabled, ignoring event", ModuleName)) end - return + return end if event == "DUEL_REQUESTED" then @@ -159,21 +163,21 @@ function shared.DeathReporter.Init() local subevent = select(2, ...) if subevent ~= "PARTY_KILL" and subevent ~= "UNIT_DIED" then return end - + local source, err = CLEUParser.GetSourceName(...) - if err then + if err then if Heimdall_Data.config.deathReporter.debug then print(string.format("[%s] Error getting source: %s", ModuleName, err)) end - return + return end - + local destination, err = CLEUParser.GetDestName(...) - if err then + if err then if Heimdall_Data.config.deathReporter.debug then print(string.format("[%s] Error getting destination: %s", ModuleName, err)) end - return + return end if Heimdall_Data.config.deathReporter.debug then @@ -182,12 +186,12 @@ function shared.DeathReporter.Init() local spellId = CLEUParser.GetSpellId(...) local spellName = GetSpellInfo(spellId) or "Unknown Spell" - + RegisterDeath(source, destination, spellName) end) if Heimdall_Data.config.deathReporter.debug then - print(string.format("[%s] Module initialized with throttle: %.1fs, duel throttle: %.1fs", + print(string.format("[%s] Module initialized with throttle: %.1fs, duel throttle: %.1fs", ModuleName, Heimdall_Data.config.deathReporter.throttle, Heimdall_Data.config.deathReporter.duelThrottle)) end print("[Heimdall] DeathReporter loaded") diff --git a/Modules/Dueler.lua b/Modules/Dueler.lua index 7f9e8df..e15c275 100644 --- a/Modules/Dueler.lua +++ b/Modules/Dueler.lua @@ -12,17 +12,17 @@ function shared.Dueler.Init() if Heimdall_Data.config.dueler.debug then print(string.format("[%s] Duel request received from: %s", ModuleName, sender)) end - if not Heimdall_Data.config.dueler.enabled then + if not Heimdall_Data.config.dueler.enabled then if Heimdall_Data.config.dueler.debug then print(string.format("[%s] Module disabled, ignoring duel request", ModuleName)) end - return + return end - + if Heimdall_Data.config.dueler.debug then print(string.format("[%s] Checking if sender '%s' is in agents list", ModuleName, sender)) end - + local allow = Heimdall_Data.config.agents[sender] if allow then if Heimdall_Data.config.dueler.debug then @@ -30,7 +30,7 @@ function shared.Dueler.Init() end AcceptDuel() else - if Heimdall_Data.config.dueler.autoDecline then + if Heimdall_Data.config.dueler.declineOther then if Heimdall_Data.config.dueler.debug then print(string.format("[%s] Auto-declining duel from untrusted sender: %s", ModuleName, sender)) end @@ -44,7 +44,8 @@ function shared.Dueler.Init() end) if Heimdall_Data.config.dueler.debug then - print(string.format("[%s] Module initialized with auto-decline: %s", ModuleName, tostring(Heimdall_Data.config.dueler.autoDecline))) + print(string.format("[%s] Module initialized with auto-decline: %s", ModuleName, + tostring(Heimdall_Data.config.dueler.declineOther))) end print("[Heimdall] Dueler loaded") end diff --git a/Modules/Echoer.lua b/Modules/Echoer.lua index b49d0d5..9144765 100644 --- a/Modules/Echoer.lua +++ b/Modules/Echoer.lua @@ -9,28 +9,28 @@ 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] Channel message received from: %s", ModuleName, sender)) --- end - - if not Heimdall_Data.config.echoer.enabled then --- if Heimdall_Data.config.echoer.debug then --- print(string.format("[%s] Module disabled, ignoring message", ModuleName)) --- end - return + -- if Heimdall_Data.config.echoer.debug then + -- print(string.format("[%s] Channel message received from: %s", ModuleName, sender)) + -- end + + if not Heimdall_Data.config.echoer.enabled then + -- if Heimdall_Data.config.echoer.debug then + -- print(string.format("[%s] Module disabled, ignoring message", ModuleName)) + -- end + return end local channelId = select(6, ...) local _, channelname = GetChannelName(channelId) --- if Heimdall_Data.config.echoer.debug then --- print(string.format("[%s] Processing message from channel: %s", ModuleName, channelname)) --- end - - if channelname ~= Heimdall_Data.config.echoer.masterChannel then - if Heimdall_Data.config.echoer.debug then - print(string.format("[%s] Ignoring message from non-master channel", ModuleName)) - end - return + -- if Heimdall_Data.config.echoer.debug then + -- print(string.format("[%s] Processing message from channel: %s", ModuleName, channelname)) + -- end + + if channelname ~= Heimdall_Data.config.echoer.masterChannel then + -- if Heimdall_Data.config.echoer.debug then + -- print(string.format("[%s] Ignoring message from non-master channel", ModuleName)) + -- end + return end if Heimdall_Data.config.echoer.debug then print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) diff --git a/Modules/Emoter.lua b/Modules/Emoter.lua index bd89915..6033dc3 100644 --- a/Modules/Emoter.lua +++ b/Modules/Emoter.lua @@ -9,28 +9,28 @@ 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] Channel message received from: %s", ModuleName, sender)) --- end - - if not Heimdall_Data.config.emoter.enabled then --- if Heimdall_Data.config.emoter.debug then --- print(string.format("[%s] Module disabled, ignoring message", ModuleName)) --- end - return + -- if Heimdall_Data.config.emoter.debug then + -- print(string.format("[%s] Channel message received from: %s", ModuleName, sender)) + -- end + + if not Heimdall_Data.config.emoter.enabled then + -- if Heimdall_Data.config.emoter.debug then + -- print(string.format("[%s] Module disabled, ignoring message", ModuleName)) + -- end + return end local channelId = select(6, ...) local _, channelname = GetChannelName(channelId) --- if Heimdall_Data.config.emoter.debug then --- print(string.format("[%s] Processing message from channel: %s", ModuleName, channelname)) --- end - - if channelname ~= Heimdall_Data.config.emoter.masterChannel then --- if Heimdall_Data.config.emoter.debug then --- print(string.format("[%s] Ignoring message from non-master channel", ModuleName)) --- end - return + -- if Heimdall_Data.config.emoter.debug then + -- print(string.format("[%s] Processing message from channel: %s", ModuleName, channelname)) + -- end + + if channelname ~= Heimdall_Data.config.emoter.masterChannel then + -- if Heimdall_Data.config.emoter.debug then + -- print(string.format("[%s] Ignoring message from non-master channel", ModuleName)) + -- end + return end if Heimdall_Data.config.emoter.debug then print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) diff --git a/Modules/Inviter.lua b/Modules/Inviter.lua index 0b3b425..e0e59d4 100644 --- a/Modules/Inviter.lua +++ b/Modules/Inviter.lua @@ -192,6 +192,31 @@ function shared.Inviter.Init() end end) + if Heimdall_Data.config.inviter.debug then + print(string.format("[%s] Module initialized - All assist: %s, Agents assist: %s", + ModuleName, + tostring(Heimdall_Data.config.inviter.allAssist), + tostring(Heimdall_Data.config.inviter.agentsAssist))) + end + print("[Heimdall] Inviter loaded") + einviterChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL") + inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) + -- if Heimdall_Data.config.inviter.debug then + -- print(string.format("[%s] Chat message received: %s", ModuleName, msg)) + -- shared.dumpTable(Heimdall_Data.config.inviter) + -- end + if not Heimdall_Data.config.inviter.enabled then return end + local channelId = select(6, ...) + local _, channelname = GetChannelName(channelId) + if channelname ~= Heimdall_Data.config.inviter.listeningChannel then return 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) + if Heimdall_Data.config.inviter.debug then print(string.format("[%s] Module initialized - All assist: %s, Agents assist: %s", ModuleName, diff --git a/Modules/Macroer.lua b/Modules/Macroer.lua index 4e3436f..ee12599 100644 --- a/Modules/Macroer.lua +++ b/Modules/Macroer.lua @@ -35,17 +35,17 @@ function shared.Macroer.Init() if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies)) end - if not Heimdall_Data.config.macroer.enabled then + if not Heimdall_Data.config.macroer.enabled then if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module disabled, skipping macro update", ModuleName)) end - return + return end - if InCombatLockdown() then + if InCombatLockdown() then if Heimdall_Data.config.macroer.debug then print(string.format("[%s] In combat, skipping macro update", ModuleName)) end - return + return end local priorityMap = {} diff --git a/Modules/Messenger.lua b/Modules/Messenger.lua index e9675e3..04a01a9 100644 --- a/Modules/Messenger.lua +++ b/Modules/Messenger.lua @@ -11,17 +11,6 @@ function shared.Messenger.Init() ---@field channel string ---@field data string - local function GetChannelId(channelName) - local channels = { GetChannelList() } - for i = 1, #channels, 2 do - local id = channels[i] - local name = channels[i + 1] - if name == channelName then - return id - end - end - end - local function FindOrJoinChannel(channelName, password) local channelId = GetChannelName(channelName) if channelId == 0 then @@ -49,36 +38,37 @@ function shared.Messenger.Init() if Heimdall_Data.config.messenger.debug then print(string.format("[%s] Processing message queue", ModuleName)) end - if not Heimdall_Data.config.messenger.enabled then + if not Heimdall_Data.config.messenger.enabled then if Heimdall_Data.config.messenger.debug then print(string.format("[%s] Module disabled, skipping message processing", ModuleName)) end - return + return end ---@type Message local message = shared.messenger.queue[1] - if not message then + if not message then if Heimdall_Data.config.messenger.debug then print(string.format("[%s] Message queue empty", ModuleName)) end - return + return end - if not message.message or message.message == "" then + if not message.message or message.message == "" then if Heimdall_Data.config.messenger.debug then print(string.format("[%s] Invalid message: empty content", ModuleName)) end - return + return end - if not message.channel or message.channel == "" then + if not message.channel or message.channel == "" then if Heimdall_Data.config.messenger.debug then print(string.format("[%s] Invalid message: no channel specified", ModuleName)) end - return + return end if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then if Heimdall_Data.config.messenger.debug then - print(string.format("[%s] Processing channel message: '%s' to '%s'", ModuleName, message.message, message.data)) + print(string.format("[%s] Processing channel message: '%s' to '%s'", ModuleName, message.message, + message.data)) end local channelId = GetChannelName(message.data) if channelId == 0 then @@ -94,27 +84,28 @@ function shared.Messenger.Init() end table.remove(shared.messenger.queue, 1) - if not message.message or message.message == "" then + if not message.message or message.message == "" then if Heimdall_Data.config.messenger.debug then print(string.format("[%s] Skipping empty message", ModuleName)) end - return + return end - if not message.channel or message.channel == "" then + if not message.channel or message.channel == "" then if Heimdall_Data.config.messenger.debug then print(string.format("[%s] Skipping message with no channel", ModuleName)) end - return + return end - if not message.data or message.data == "" then + if not message.data or message.data == "" then if Heimdall_Data.config.messenger.debug then print(string.format("[%s] Skipping message with no data", ModuleName)) end - return + return end - + if Heimdall_Data.config.messenger.debug then - print(string.format("[%s] Sending message: '%s' to %s:%s", ModuleName, message.message, message.channel, message.data)) + print(string.format("[%s] Sending message: '%s' to %s:%s", ModuleName, message.message, message.channel, + message.data)) end SendChatMessage(message.message, message.channel, nil, message.data) end @@ -130,7 +121,8 @@ function shared.Messenger.Init() end if Heimdall_Data.config.messenger.debug then - print(string.format("[%s] Module initialized with interval: %s", ModuleName, Heimdall_Data.config.messenger.interval)) + print(string.format("[%s] Module initialized with interval: %s", ModuleName, + Heimdall_Data.config.messenger.interval)) end print("[Heimdall] Messenger loaded") end diff --git a/Modules/Sniffer.lua b/Modules/Sniffer.lua index 317dc98..3dd5942 100644 --- a/Modules/Sniffer.lua +++ b/Modules/Sniffer.lua @@ -48,32 +48,32 @@ function shared.Sniffer.Init() if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Received event: %s", ModuleName, event)) end - if not Heimdall_Data.config.sniffer.enabled then + if not Heimdall_Data.config.sniffer.enabled then if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module disabled, ignoring event", ModuleName)) end - return + return end local source, err = CLEUParser.GetSourceName(...) if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Processing source: %s", ModuleName, source)) end - if err then + if err then if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Error parsing source: %s", ModuleName, err)) end - return + return end SmellStinky(source) local destination, err = CLEUParser.GetDestName(...) if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Processing destination: %s", ModuleName, destination)) end - if err then + if err then if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Error parsing destination: %s", ModuleName, err)) end - return + return end SmellStinky(destination) end) diff --git a/Modules/Spotter.lua b/Modules/Spotter.lua index dc6b914..d0ad6a4 100644 --- a/Modules/Spotter.lua +++ b/Modules/Spotter.lua @@ -31,14 +31,14 @@ function shared.Spotter.Init() if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Checking notification criteria for %s (%s)", ModuleName, name, faction)) end - - if Heimdall_Data.config.agents[name] then + + if Heimdall_Data.config.agents[name] then if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Skipping agent: %s", ModuleName, name)) end - return false + return false end - + if Heimdall_Data.config.spotter.stinky then if Heimdall_Data.config.stinkies[name] then if Heimdall_Data.config.spotter.debug then @@ -47,7 +47,7 @@ function shared.Spotter.Init() return true end end - + if Heimdall_Data.config.spotter.alliance then if faction == "Alliance" then if Heimdall_Data.config.spotter.debug then @@ -56,7 +56,7 @@ function shared.Spotter.Init() return true end end - + if Heimdall_Data.config.spotter.hostile then if hostile then if Heimdall_Data.config.spotter.debug then @@ -65,9 +65,10 @@ function shared.Spotter.Init() return true end end - + if Heimdall_Data.config.spotter.debug then - print(string.format("[%s] Using everyone setting: %s", ModuleName, tostring(Heimdall_Data.config.spotter.everyone))) + print(string.format("[%s] Using everyone setting: %s", ModuleName, + tostring(Heimdall_Data.config.spotter.everyone))) end return Heimdall_Data.config.spotter.everyone end @@ -78,13 +79,13 @@ function shared.Spotter.Init() if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Processing spotted unit: %s", ModuleName, unit)) end - + if not unit then return string.format("Could not find unit %s", tostring(unit)) end - if not UnitIsPlayer(unit) then + if not UnitIsPlayer(unit) then if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Ignoring non-player unit: %s", ModuleName, unit)) end - return nil + return nil end local name = UnitName(unit) @@ -115,13 +116,13 @@ function shared.Spotter.Init() if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Player %s is %s", ModuleName, name, hostile and "hostile" or "friendly")) end - + local doNotify = ShouldNotify(unit, name, faction, hostile) - if not doNotify then + if not doNotify then if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Skipping notification for %s", ModuleName, name)) end - return string.format("Not notifying for %s", tostring(name)) + return string.format("Not notifying for %s", tostring(name)) end local hp = UnitHealth(unit) @@ -151,7 +152,7 @@ function shared.Spotter.Init() if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Player %s coordinates: %.2f, %.2f", ModuleName, name, x * 100, y * 100)) 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", @@ -185,18 +186,18 @@ function shared.Spotter.Init() if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Event received: %s for unit: %s", ModuleName, event, unit or "target")) end - - if not Heimdall_Data.config.spotter.enabled then + + if not Heimdall_Data.config.spotter.enabled then if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Module disabled, ignoring event", ModuleName)) end - return + return end - + if event == "UNIT_TARGET" then unit = "target" end - + local err = NotifySpotted(unit) if err then if Heimdall_Data.config.spotter.debug then diff --git a/Modules/StinkyTracker.lua b/Modules/StinkyTracker.lua index 259f8fa..54afc2b 100644 --- a/Modules/StinkyTracker.lua +++ b/Modules/StinkyTracker.lua @@ -26,12 +26,13 @@ function shared.StinkyTracker.Init() hostile = true } if Heimdall_Data.config.stinkyTracker.debug then - print(string.format("[%s] Found hostile player: %s (%s) at %s", ModuleName, name, class, date("%H:%M:%S", time()))) + print(string.format("[%s] Found hostile player: %s (%s) at %s", ModuleName, name, class, + date("%H:%M:%S", time()))) end end return stinkies end - + local seeRegex = "I see %((%w+)%) ([^ -/]+)-?%w*/(%w+)" ---@param msg string ---@return table @@ -55,11 +56,12 @@ function shared.StinkyTracker.Init() } stinkies[name] = stinky if Heimdall_Data.config.stinkyTracker.debug then - print(string.format("[%s] Found stinky in SEE: %s (%s) - %s at %s", ModuleName, name, class, aggression, date("%H:%M:%S", time()))) + print(string.format("[%s] Found stinky in SEE: %s (%s) - %s at %s", ModuleName, name, class, aggression, + date("%H:%M:%S", time()))) end return stinkies end - + local arrivedRegex = "([^ -/]+)-?%w* of class (%w+)" local arrivedRegexAlt = "([^ -/]+)-?%w* %(!!!!%) of class (%w+)" ---@param msg string @@ -95,22 +97,22 @@ function shared.StinkyTracker.Init() local frame = CreateFrame("Frame") frame:RegisterEvent("CHAT_MSG_CHANNEL") frame:SetScript("OnEvent", function(self, event, msg, sender, ...) --- if Heimdall_Data.config.stinkyTracker.debug then --- print(string.format("[%s] Event received: %s from %s", ModuleName, event, sender)) --- end - if not Heimdall_Data.config.stinkyTracker.enabled then --- if Heimdall_Data.config.stinkyTracker.debug then --- print(string.format("[%s] Module disabled, ignoring event", ModuleName)) --- end - return + -- if Heimdall_Data.config.stinkyTracker.debug then + -- print(string.format("[%s] Event received: %s from %s", ModuleName, event, sender)) + -- end + if not Heimdall_Data.config.stinkyTracker.enabled then + -- if Heimdall_Data.config.stinkyTracker.debug then + -- print(string.format("[%s] Module disabled, ignoring event", ModuleName)) + -- end + return end local channelId = select(6, ...) local _, channelname = GetChannelName(channelId) - if channelname ~= Heimdall_Data.config.stinkyTracker.masterChannel then --- if Heimdall_Data.config.stinkyTracker.debug then --- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname)) --- end - return + if channelname ~= Heimdall_Data.config.stinkyTracker.masterChannel then + -- if Heimdall_Data.config.stinkyTracker.debug then + -- print(string.format("[%s] Ignoring message from non-master channel: %s", ModuleName, channelname)) + -- end + return end if Heimdall_Data.config.stinkyTracker.debug then print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) @@ -129,7 +131,8 @@ function shared.StinkyTracker.Init() if stinky.hostile then shared.stinkyTracker.stinkies[name] = stinky if Heimdall_Data.config.stinkyTracker.debug then - print(string.format("[%s] Added hostile stinky from WHO: %s (%s)", ModuleName, name, stinky.class)) + print(string.format("[%s] Added hostile stinky from WHO: %s (%s)", ModuleName, name, stinky + .class)) end end end @@ -146,7 +149,8 @@ function shared.StinkyTracker.Init() if stinky.hostile then shared.stinkyTracker.stinkies[name] = stinky if Heimdall_Data.config.stinkyTracker.debug then - print(string.format("[%s] Added hostile stinky from SEE: %s (%s)", ModuleName, name, stinky.class)) + print(string.format("[%s] Added hostile stinky from SEE: %s (%s)", ModuleName, name, stinky + .class)) end end if not stinky.hostile then diff --git a/Modules/Whoer.lua b/Modules/Whoer.lua index 5639cbc..07cbd76 100644 --- a/Modules/Whoer.lua +++ b/Modules/Whoer.lua @@ -135,21 +135,21 @@ function shared.Whoer.Init() if Heimdall_Data.config.who.debug then print(string.format("[%s] Processing notification for player: %s", ModuleName, player.name)) end - - if not Heimdall_Data.config.who.enabled then + + if not Heimdall_Data.config.who.enabled then if Heimdall_Data.config.who.debug then print(string.format("[%s] Module disabled, skipping notification", ModuleName)) end - return + return end - - if not player then + + if not player then if Heimdall_Data.config.who.debug then print(string.format("[%s] Error: Cannot notify for nil player", ModuleName)) end - return string.format("Cannot notify for nil player %s", tostring(player)) + return string.format("Cannot notify for nil player %s", tostring(player)) end - + if not Heimdall_Data.config.who.zoneNotifyFor[player.zone] then if Heimdall_Data.config.who.debug then print(string.format("[%s] Skipping notification - Zone '%s' not in notify list", ModuleName, player.zone)) @@ -161,7 +161,7 @@ function shared.Whoer.Init() if Heimdall_Data.config.who.debug then print(string.format("[%s] Queuing channel notification: '%s'", ModuleName, text)) end - + ---@type Message local msg = { channel = "CHANNEL", @@ -172,7 +172,8 @@ function shared.Whoer.Init() if Heimdall_Data.config.who.doWhisper then if Heimdall_Data.config.who.debug then - print(string.format("[%s] Processing whisper notifications for %d recipients", ModuleName, #Heimdall_Data.config.whisperNotify)) + print(string.format("[%s] Processing whisper notifications for %d recipients", ModuleName, + #Heimdall_Data.config.whisperNotify)) end for _, name in pairs(Heimdall_Data.config.whisperNotify) do ---@type Message @@ -275,14 +276,14 @@ function shared.Whoer.Init() if Heimdall_Data.config.who.debug then print(string.format("[%s] WHO list update received", ModuleName)) end - - if not Heimdall_Data.config.who.enabled then + + if not Heimdall_Data.config.who.enabled then if Heimdall_Data.config.who.debug then print(string.format("[%s] Module disabled, ignoring WHO update", ModuleName)) end - return + return end - + ---@type WHOQuery? local query = lastQuery if not query then @@ -302,7 +303,7 @@ function shared.Whoer.Init() if Heimdall_Data.config.who.debug then print(string.format("[%s] Processing result %d/%d: %s/%s/%s", ModuleName, i, results, name, class, zone)) end - + local continue = false ---@type WHOFilter[] local filters = query.filters @@ -315,12 +316,12 @@ function shared.Whoer.Init() break end end - - if Heimdall_Data.config.who.ignored[name] then + + if Heimdall_Data.config.who.ignored[name] then if Heimdall_Data.config.who.debug then print(string.format("[%s] Ignoring blacklisted player: %s", ModuleName, name)) end - continue = true + continue = true end if not continue then @@ -330,7 +331,7 @@ function shared.Whoer.Init() if Heimdall_Data.config.who.debug then print(string.format("[%s] New player detected: %s (%s) in %s", ModuleName, name, class, zone)) end - + player = Player.new(name, guild, race, class, zone) if not Heimdall_Data.who then Heimdall_Data.who = {} end if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end @@ -338,14 +339,14 @@ function shared.Whoer.Init() if existing then if Heimdall_Data.config.who.debug then - print(string.format("[%s] Found existing data for %s - Last seen: %s, Count: %d", + print(string.format("[%s] Found existing data for %s - Last seen: %s, Count: %d", ModuleName, name, existing.lastSeen or "never", existing.seenCount or 0)) end player.lastSeen = existing.lastSeen or "never" player.firstSeen = existing.firstSeen or "never" player.seenCount = existing.seenCount or 0 end - + if player.firstSeen == "never" then player.firstSeen = timestamp if Heimdall_Data.config.who.debug then @@ -359,6 +360,9 @@ function shared.Whoer.Init() print(string.format("[%s] Player %s marked as stinky!", ModuleName, name)) end player.stinky = true + --PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master") + else + --PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master") end local err = Notify(player) @@ -432,4 +436,3 @@ function shared.Whoer.Init() print("Heimdall - Whoer loaded") end -