diff --git a/Source/Game/Combat/ThreatManager.cs b/Source/Game/Combat/ThreatManager.cs index 1987349f9..2d0fb9630 100644 --- a/Source/Game/Combat/ThreatManager.cs +++ b/Source/Game/Combat/ThreatManager.cs @@ -20,6 +20,7 @@ namespace Game.Combat bool _ownerCanHaveThreatList; public bool NeedClientUpdate; + bool _needThreatClearUpdate; uint _updateTimer; List _sortedThreatList = new(); Dictionary _myThreatListEntries = new(); @@ -73,18 +74,35 @@ namespace Game.Combat public void Update(uint tdiff) { - if (!CanHaveThreatList() || IsThreatListEmpty(true)) + if (!CanHaveThreatList()) return; if (_updateTimer <= tdiff) { - UpdateVictim(); + if (_needThreatClearUpdate) + { + SendClearAllThreatToClients(); + _needThreatClearUpdate = false; + } + + if (!IsThreatListEmpty(true)) + UpdateVictim(); + _updateTimer = THREAT_UPDATE_INTERVAL; } else _updateTimer -= tdiff; } + /// + /// called from Creature::AtEngage + /// should not be called from anywhere else + /// + public void ResetUpdateTimer() + { + _updateTimer = THREAT_UPDATE_INTERVAL; + } + public Unit GetCurrentVictim() { if (_currentVictimRef == null || _currentVictimRef.ShouldBeOffline()) diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index 50005b2cb..7af141495 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -466,6 +466,8 @@ namespace Game.Entities UpdateMovementCapabilities(); + GetThreatManager().Update(diff); + switch (m_deathState) { case DeathState.JustRespawned: @@ -541,8 +543,6 @@ namespace Game.Entities if (!IsAlive()) break; - GetThreatManager().Update(diff); - if (_spellFocusInfo.Delay != 0) { if (_spellFocusInfo.Delay <= diff) @@ -1071,6 +1071,8 @@ namespace Game.Entities { base.AtEngage(target); + GetThreatManager().ResetUpdateTimer(); + if (!HasFlag(CreatureStaticFlags2.AllowMountedCombat)) Dismount();