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

View File

@@ -70,6 +70,7 @@ local function init()
---@field doWhisper boolean ---@field doWhisper boolean
---@field notifyChannel string ---@field notifyChannel string
---@field zoneOverride string? ---@field zoneOverride string?
---@field duelThrottle number
--- Data --- --- Data ---
---@class HeimdallMessengerData ---@class HeimdallMessengerData
@@ -147,6 +148,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),
}, },
whisperNotify = data.GetOrDefault(Heimdall_Data, { "config", "whisperNotify" }, { whisperNotify = data.GetOrDefault(Heimdall_Data, { "config", "whisperNotify" }, {
"Extazyk", "Extazyk",