Make duel detection maybe a bit better

This commit is contained in:
2024-12-12 20:11:23 +01:00
parent f773457e54
commit cdff4ff1dc
2 changed files with 20 additions and 1 deletions

View File

@@ -12,6 +12,8 @@ function data.DeathReporter.Init()
---@type table<string, number>
local recentDeaths = {}
---@type table<string, number>
local recentDuels = {}
---@type table<string, number>
local notifyTimers = {}
---@param source string
@@ -23,8 +25,20 @@ function data.DeathReporter.Init()
and GetTime() - recentDeaths[destination] < data.config.deathReporter.throttle then
return
end
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
recentDeaths[destination] = GetTime()
local timer = C_Timer.NewTimer(1, function()
local timer = C_Timer.NewTimer(3, function()
local zone = data.config.deathReporter.zoneOverride
if not zone then
zone = string.format("%s (%s)", GetZoneText(), GetSubZoneText())
@@ -86,6 +100,9 @@ function data.DeathReporter.Init()
print(string.format("Cancelling death reports for %s and %s", source, destination))
if notifyTimers[source] then notifyTimers[source]:Cancel() end
if notifyTimers[destination] then notifyTimers[destination]:Cancel() end
local now = GetTime()
recentDuels[source] = now
recentDuels[destination] = now
end
end)