Implement bonkdetector
This commit is contained in:
15
Heimdall.lua
15
Heimdall.lua
@@ -38,6 +38,7 @@ local function init()
|
|||||||
---@field Config InitTable
|
---@field Config InitTable
|
||||||
---@field Sniffer InitTable
|
---@field Sniffer InitTable
|
||||||
---@field MinimapTagger InitTable
|
---@field MinimapTagger InitTable
|
||||||
|
---@field BonkDetector InitTable
|
||||||
|
|
||||||
--- Config ---
|
--- Config ---
|
||||||
---@class HeimdallConfig
|
---@class HeimdallConfig
|
||||||
@@ -56,6 +57,7 @@ local function init()
|
|||||||
---@field stinkyTracker HeimdallStinkyTrackerConfig
|
---@field stinkyTracker HeimdallStinkyTrackerConfig
|
||||||
---@field combatAlerter HeimdallCombatAlerterConfig
|
---@field combatAlerter HeimdallCombatAlerterConfig
|
||||||
---@field sniffer HeimdallSnifferConfig
|
---@field sniffer HeimdallSnifferConfig
|
||||||
|
---@field bonkDetector HeimdallBonkDetectorConfig
|
||||||
---@field whisperNotify table<string, string>
|
---@field whisperNotify table<string, string>
|
||||||
---@field stinkies table<string, boolean>
|
---@field stinkies table<string, boolean>
|
||||||
---@field agents table<string, string>
|
---@field agents table<string, string>
|
||||||
@@ -193,6 +195,12 @@ local function init()
|
|||||||
---@field helpSoundThrottle number
|
---@field helpSoundThrottle number
|
||||||
---@field helpTextureFile string
|
---@field helpTextureFile string
|
||||||
|
|
||||||
|
---@class HeimdallBonkDetectorConfig
|
||||||
|
---@field enabled boolean
|
||||||
|
---@field debug boolean
|
||||||
|
---@field notifyChannel string
|
||||||
|
---@field throttle number
|
||||||
|
|
||||||
--- Data ---
|
--- Data ---
|
||||||
---@class HeimdallMessengerData
|
---@class HeimdallMessengerData
|
||||||
---@field queue table<string, Message>
|
---@field queue table<string, Message>
|
||||||
@@ -393,6 +401,12 @@ local function init()
|
|||||||
stinkies = shared.GetOrDefault(Heimdall_Data, { "config", "stinkies" }, {}),
|
stinkies = shared.GetOrDefault(Heimdall_Data, { "config", "stinkies" }, {}),
|
||||||
scale = shared.GetOrDefault(Heimdall_Data, { "config", "scale" }, 1),
|
scale = shared.GetOrDefault(Heimdall_Data, { "config", "scale" }, 1),
|
||||||
locale = shared.GetOrDefault(Heimdall_Data, { "config", "locale" }, "en"),
|
locale = shared.GetOrDefault(Heimdall_Data, { "config", "locale" }, "en"),
|
||||||
|
bonkDetector = {
|
||||||
|
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "enabled" }, false),
|
||||||
|
debug = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "debug" }, false),
|
||||||
|
notifyChannel = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "notifyChannel" }, "Agent"),
|
||||||
|
throttle = shared.GetOrDefault(Heimdall_Data, { "config", "bonkDetector", "throttle" }, 5),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
shared.raceMap = {
|
shared.raceMap = {
|
||||||
@@ -491,6 +505,7 @@ local function init()
|
|||||||
shared.CombatAlerter.Init()
|
shared.CombatAlerter.Init()
|
||||||
shared.Config.Init()
|
shared.Config.Init()
|
||||||
shared.MinimapTagger.Init()
|
shared.MinimapTagger.Init()
|
||||||
|
shared.BonkDetector.Init()
|
||||||
print("Heimdall loaded!")
|
print("Heimdall loaded!")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -26,4 +26,5 @@ Modules/StinkyTracker.lua
|
|||||||
Modules/CombatAlerter.lua
|
Modules/CombatAlerter.lua
|
||||||
Modules/MinimapTagger.lua
|
Modules/MinimapTagger.lua
|
||||||
Modules/Config.lua
|
Modules/Config.lua
|
||||||
|
Modules/BonkDetector.lua
|
||||||
Heimdall.lua
|
Heimdall.lua
|
||||||
83
Modules/BonkDetector.lua
Normal file
83
Modules/BonkDetector.lua
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
local addonname, shared = ...
|
||||||
|
---@cast shared HeimdallShared
|
||||||
|
---@cast addonname string
|
||||||
|
local ModuleName = "BonkDetector"
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line: missing-fields
|
||||||
|
shared.BonkDetector = {}
|
||||||
|
function shared.BonkDetector.Init()
|
||||||
|
---@type table<string, number>
|
||||||
|
local lastReportTime = {}
|
||||||
|
|
||||||
|
local frame = CreateFrame("Frame")
|
||||||
|
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||||
|
frame:SetScript("OnEvent", function(self, event, ...)
|
||||||
|
if Heimdall_Data.config.bonkDetector.debug then
|
||||||
|
print(string.format("[%s] Combat log event received", ModuleName))
|
||||||
|
end
|
||||||
|
if not Heimdall_Data.config.bonkDetector.enabled then
|
||||||
|
if Heimdall_Data.config.bonkDetector.debug then
|
||||||
|
print(string.format("[%s] Module disabled, ignoring combat event", ModuleName))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local source, err = CLEUParser.GetSourceName(...)
|
||||||
|
if err then
|
||||||
|
if Heimdall_Data.config.bonkDetector.debug then
|
||||||
|
print(string.format("[%s] Error getting source name: %s", ModuleName, err))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local destination, err = CLEUParser.GetDestName(...)
|
||||||
|
if err then
|
||||||
|
if Heimdall_Data.config.bonkDetector.debug then
|
||||||
|
print(string.format("[%s] Error getting destination name: %s", ModuleName, err))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local subevent = select(2, ...)
|
||||||
|
if not subevent:find("_DAMAGE") then
|
||||||
|
if Heimdall_Data.config.bonkDetector.debug then
|
||||||
|
print(string.format("[%s] Not a damage event, ignoring: %s", ModuleName, subevent))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local currentTime = GetTime()
|
||||||
|
local throttle = Heimdall_Data.config.bonkDetector.throttle
|
||||||
|
|
||||||
|
if lastReportTime[source] and (currentTime - lastReportTime[source]) < throttle then
|
||||||
|
if Heimdall_Data.config.bonkDetector.debug then
|
||||||
|
local timeLeft = throttle - (currentTime - lastReportTime[source])
|
||||||
|
print(string.format("[%s] Damage report throttled for %s (%.1f seconds remaining)",
|
||||||
|
ModuleName, source, timeLeft))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
lastReportTime[source] = currentTime
|
||||||
|
|
||||||
|
if Heimdall_Data.config.bonkDetector.debug then
|
||||||
|
print(string.format("[%s] Processing damage event - Source: %s, Target: %s, Type: %s",
|
||||||
|
ModuleName, source, destination, subevent))
|
||||||
|
end
|
||||||
|
|
||||||
|
local notifyChannel = Heimdall_Data.config.bonkDetector.notifyChannel
|
||||||
|
local msg = string.format("%s hit %s (%s)", source, destination, subevent)
|
||||||
|
if Heimdall_Data.config.bonkDetector.debug then
|
||||||
|
print(string.format("[%s] Queueing message to Agent channel: %s", ModuleName, msg))
|
||||||
|
end
|
||||||
|
---@type Message
|
||||||
|
local message = {
|
||||||
|
channel = "CHANNEL",
|
||||||
|
data = notifyChannel,
|
||||||
|
message = msg,
|
||||||
|
}
|
||||||
|
table.insert(shared.messenger.queue, message)
|
||||||
|
end)
|
||||||
|
|
||||||
|
print("[Heimdall] BonkDetector loaded")
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user