From cdff4ff1dc8fe629d7b201b30d4e7b4f70152e47 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Thu, 12 Dec 2024 20:11:23 +0100 Subject: [PATCH] Make duel detection maybe a bit better --- DeathReporter.lua | 19 ++++++++++++++++++- Heimdall.lua | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/DeathReporter.lua b/DeathReporter.lua index 64f36d3..ca98f44 100644 --- a/DeathReporter.lua +++ b/DeathReporter.lua @@ -12,6 +12,8 @@ function data.DeathReporter.Init() ---@type table local recentDeaths = {} ---@type table + local recentDuels = {} + ---@type table 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) diff --git a/Heimdall.lua b/Heimdall.lua index 9de3369..15eb964 100644 --- a/Heimdall.lua +++ b/Heimdall.lua @@ -70,6 +70,7 @@ local function init() ---@field doWhisper boolean ---@field notifyChannel string ---@field zoneOverride string? + ---@field duelThrottle number --- Data --- ---@class HeimdallMessengerData @@ -147,6 +148,7 @@ local function init() doWhisper = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "doWhisper" }, true), notifyChannel = data.GetOrDefault(Heimdall_Data, { "config", "deathReporter", "notifyChannel" }, "Agent"), 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" }, { "Extazyk",