Rework duel detectioner
The prevoius implementation was so stupid...
This commit is contained in:
@@ -13,8 +13,6 @@ function data.DeathReporter.Init()
|
|||||||
local recentDeaths = {}
|
local recentDeaths = {}
|
||||||
---@type table<string, number>
|
---@type table<string, number>
|
||||||
local recentDuels = {}
|
local recentDuels = {}
|
||||||
---@type table<string, number>
|
|
||||||
local notifyTimers = {}
|
|
||||||
|
|
||||||
---@param source string
|
---@param source string
|
||||||
---@param destination string
|
---@param destination string
|
||||||
@@ -38,7 +36,18 @@ function data.DeathReporter.Init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
recentDeaths[destination] = GetTime()
|
recentDeaths[destination] = GetTime()
|
||||||
local timer = C_Timer.NewTimer(3, function()
|
C_Timer.NewTimer(3, function()
|
||||||
|
if recentDuels[destination]
|
||||||
|
and GetTime() - recentDuels[destination] < data.config.deathReporter.duelThrottle then
|
||||||
|
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if recentDuels[source]
|
||||||
|
and GetTime() - recentDuels[source] < data.config.deathReporter.duelThrottle then
|
||||||
|
print(string.format("Cancelling death reports for %s and %s because of recent duel", source, destination))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local zone = data.config.deathReporter.zoneOverride
|
local zone = data.config.deathReporter.zoneOverride
|
||||||
if not zone then
|
if not zone then
|
||||||
zone = string.format("%s (%s)", GetZoneText(), GetSubZoneText())
|
zone = string.format("%s (%s)", GetZoneText(), GetSubZoneText())
|
||||||
@@ -68,9 +77,7 @@ function data.DeathReporter.Init()
|
|||||||
table.insert(data.messenger.queue, msg)
|
table.insert(data.messenger.queue, msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
notifyTimers[destination] = nil
|
|
||||||
end)
|
end)
|
||||||
notifyTimers[destination] = timer
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local cleuFrame = CreateFrame("Frame")
|
local cleuFrame = CreateFrame("Frame")
|
||||||
@@ -97,9 +104,7 @@ function data.DeathReporter.Init()
|
|||||||
systemMessageFrame:SetScript("OnEvent", function(self, event, msg)
|
systemMessageFrame:SetScript("OnEvent", function(self, event, msg)
|
||||||
local source, destination = string.match(msg, "(.+) has defeated (.+) in a duel")
|
local source, destination = string.match(msg, "(.+) has defeated (.+) in a duel")
|
||||||
if source and destination then
|
if source and destination then
|
||||||
print(string.format("Cancelling death reports for %s and %s", source, destination))
|
print(string.format("Detected duel between %s and %s", source, destination))
|
||||||
if notifyTimers[source] then notifyTimers[source]:Cancel() end
|
|
||||||
if notifyTimers[destination] then notifyTimers[destination]:Cancel() end
|
|
||||||
local now = GetTime()
|
local now = GetTime()
|
||||||
recentDuels[source] = now
|
recentDuels[source] = now
|
||||||
recentDuels[destination] = now
|
recentDuels[destination] = now
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ local addonname, data = ...
|
|||||||
-- Take last N seconds of combatlog into account ie. count who does damage to who
|
-- 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...
|
-- 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
|
-- But that would not be trivial as of now, I can't think of a way to do it sensibly
|
||||||
|
-- TODO: Implement auto grouping via agent, maybe find "+" or something
|
||||||
|
|
||||||
local function init()
|
local function init()
|
||||||
---@class Heimdall_Data
|
---@class Heimdall_Data
|
||||||
@@ -148,7 +149,7 @@ local function init()
|
|||||||
doWhisper = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "doWhisper" }, true),
|
doWhisper = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "doWhisper" }, true),
|
||||||
notifyChannel = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "notifyChannel" }, "Agent"),
|
notifyChannel = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "notifyChannel" }, "Agent"),
|
||||||
zoneOverride = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "zoneOverride" }, nil),
|
zoneOverride = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "zoneOverride" }, nil),
|
||||||
duelThrottle = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "duelThrottle" }, 2),
|
duelThrottle = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "duelThrottle" }, 5),
|
||||||
},
|
},
|
||||||
whisperNotify = data.GetOrDefault(Heimdall_Data, { "config", "whisperNotify" }, {
|
whisperNotify = data.GetOrDefault(Heimdall_Data, { "config", "whisperNotify" }, {
|
||||||
"Extazyk",
|
"Extazyk",
|
||||||
|
|||||||
Reference in New Issue
Block a user