Core/Combat: reset the ThreatManager update interval upon engaging the creature and move ThreatClear packet sending into the update cycle to mimic retail behavior
Port From (https://github.com/TrinityCore/TrinityCore/commit/24bda9c73dcd89d4da4e871e00fd83a24b8275d2)
This commit is contained in:
@@ -20,6 +20,7 @@ namespace Game.Combat
|
||||
bool _ownerCanHaveThreatList;
|
||||
|
||||
public bool NeedClientUpdate;
|
||||
bool _needThreatClearUpdate;
|
||||
uint _updateTimer;
|
||||
List<ThreatReference> _sortedThreatList = new();
|
||||
Dictionary<ObjectGuid, ThreatReference> _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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called from Creature::AtEngage
|
||||
/// should not be called from anywhere else
|
||||
/// </summary>
|
||||
public void ResetUpdateTimer()
|
||||
{
|
||||
_updateTimer = THREAT_UPDATE_INTERVAL;
|
||||
}
|
||||
|
||||
public Unit GetCurrentVictim()
|
||||
{
|
||||
if (_currentVictimRef == null || _currentVictimRef.ShouldBeOffline())
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user