From 890bccdc3498260867687d34f9d7ed4ec76d17c6 Mon Sep 17 00:00:00 2001 From: Lynn Date: Sat, 10 Sep 2022 19:54:05 +0200 Subject: [PATCH] More robust combat check, and don't check inside bgs either --- .luacheckrc | 1 + QueueTools.lua | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index ebe9501..226129f 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -42,6 +42,7 @@ globals = { 'PromoteToLeader', 'SendChatMessage', 'Settings', + 'UnitAffectingCombat', 'UnitClass', 'UnitDebuff', 'UnitExists', diff --git a/QueueTools.lua b/QueueTools.lua index 484e91a..b04ce1d 100644 --- a/QueueTools.lua +++ b/QueueTools.lua @@ -34,8 +34,8 @@ local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo local UnitClass = UnitClass local UnitDebuff = UnitDebuff local UnitGUID = UnitGUID +local UnitAffectingCombat = UnitAffectingCombat local GetTime = GetTime -local InCombatLockdown = InCombatLockdown local IsShiftKeyDown = IsShiftKeyDown local SendChatMessage = SendChatMessage local RAID_CLASS_COLORS = RAID_CLASS_COLORS @@ -598,7 +598,7 @@ function Module:OnEnable() Private.DetectBattlegroundEntryAfterConfirm, } - if not InCombatLockdown() then self:PLAYER_REGEN_ENABLED() end + Private.UpdateAuraTracking() self:RefreshConfig() @@ -697,6 +697,8 @@ function Private.DetectBattlegroundExit(previousState, newState) Private.TriggerStateUpdates() ForEachPlayerData(function(data) data.battlegroundStatus = BattlegroundStatus.Nothing end) + + Private.UpdateAuraTracking() end function Private.DetectQueuePause(previousState, newState, mapName) @@ -786,6 +788,8 @@ function Private.DetectBattlegroundEntryAfterConfirm(previousState, newState) if newState.status ~= QueueStatus.Active then return end ForEachPlayerData(function(data) data.battlegroundStatus = BattlegroundStatus.Nothing end) + + Private.UpdateAuraTracking() end function Module:UPDATE_BATTLEFIELD_STATUS(_, queueId) @@ -807,12 +811,27 @@ function Module:RefreshConfig() Private.ScheduleSendSyncData() end +function Private.UpdateAuraTracking() + if UnitAffectingCombat('player') then + return Module:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED') + end + + for _, state in pairs(Memory.queueState) do + if state.status == QueueStatus.Active then + return Module:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED') + end + end + + -- only track outside of combat and outside of battlegrounds + Module:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') +end + function Module:PLAYER_REGEN_ENABLED() - self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') + Private.UpdateAuraTracking() end function Module:PLAYER_REGEN_DISABLED() - self:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED') + Private.UpdateAuraTracking() end function Module:COMBAT_LOG_EVENT_UNFILTERED()