Implement combatalerter
This commit is contained in:
@@ -5,5 +5,45 @@ local addonname, shared = ...
|
|||||||
---@diagnostic disable-next-line: missing-fields
|
---@diagnostic disable-next-line: missing-fields
|
||||||
shared.CombatAlerter = {}
|
shared.CombatAlerter = {}
|
||||||
function shared.CombatAlerter.Init()
|
function shared.CombatAlerter.Init()
|
||||||
|
local alerted = {}
|
||||||
|
local combatAlerterFrame = CreateFrame("Frame")
|
||||||
|
combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||||
|
combatAlerterFrame:SetScript("OnEvent", function(self, event, ...)
|
||||||
|
if not Heimdall_Data.config.combatAlerter.enabled then return end
|
||||||
|
local destination, err = CLEUParser.GetDestName(...)
|
||||||
|
if err then return end
|
||||||
|
if destination ~= UnitName("player") then return end
|
||||||
|
local source, err = CLEUParser.GetSourceName(...)
|
||||||
|
if err then source = "unknown" end
|
||||||
|
|
||||||
|
if shared.stinkyTracker.stinkies and shared.stinkyTracker.stinkies[source] then
|
||||||
|
if alerted[source] then return end
|
||||||
|
alerted[source] = true
|
||||||
|
local x, y = GetPlayerMapPosition("player")
|
||||||
|
---@type Message
|
||||||
|
local msg = {
|
||||||
|
channel = "CHANNEL",
|
||||||
|
data = Heimdall_Data.config.combatAlerter.masterChannel,
|
||||||
|
message = string.format("%s is attacking me in %s(%s) at %.2f,%.2f ",
|
||||||
|
source,
|
||||||
|
GetZoneText(), GetSubZoneText(),
|
||||||
|
x, y
|
||||||
|
),
|
||||||
|
}
|
||||||
|
table.insert(shared.messenger.queue, msg)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
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, ...)
|
||||||
|
alerted = {}
|
||||||
|
end)
|
||||||
|
|
||||||
print("Heimdall - CombatAlerter loaded")
|
print("Heimdall - CombatAlerter loaded")
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user