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;
|
bool _ownerCanHaveThreatList;
|
||||||
|
|
||||||
public bool NeedClientUpdate;
|
public bool NeedClientUpdate;
|
||||||
|
bool _needThreatClearUpdate;
|
||||||
uint _updateTimer;
|
uint _updateTimer;
|
||||||
List<ThreatReference> _sortedThreatList = new();
|
List<ThreatReference> _sortedThreatList = new();
|
||||||
Dictionary<ObjectGuid, ThreatReference> _myThreatListEntries = new();
|
Dictionary<ObjectGuid, ThreatReference> _myThreatListEntries = new();
|
||||||
@@ -73,18 +74,35 @@ namespace Game.Combat
|
|||||||
|
|
||||||
public void Update(uint tdiff)
|
public void Update(uint tdiff)
|
||||||
{
|
{
|
||||||
if (!CanHaveThreatList() || IsThreatListEmpty(true))
|
if (!CanHaveThreatList())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_updateTimer <= tdiff)
|
if (_updateTimer <= tdiff)
|
||||||
{
|
{
|
||||||
UpdateVictim();
|
if (_needThreatClearUpdate)
|
||||||
|
{
|
||||||
|
SendClearAllThreatToClients();
|
||||||
|
_needThreatClearUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsThreatListEmpty(true))
|
||||||
|
UpdateVictim();
|
||||||
|
|
||||||
_updateTimer = THREAT_UPDATE_INTERVAL;
|
_updateTimer = THREAT_UPDATE_INTERVAL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_updateTimer -= tdiff;
|
_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()
|
public Unit GetCurrentVictim()
|
||||||
{
|
{
|
||||||
if (_currentVictimRef == null || _currentVictimRef.ShouldBeOffline())
|
if (_currentVictimRef == null || _currentVictimRef.ShouldBeOffline())
|
||||||
|
|||||||
@@ -466,6 +466,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
UpdateMovementCapabilities();
|
UpdateMovementCapabilities();
|
||||||
|
|
||||||
|
GetThreatManager().Update(diff);
|
||||||
|
|
||||||
switch (m_deathState)
|
switch (m_deathState)
|
||||||
{
|
{
|
||||||
case DeathState.JustRespawned:
|
case DeathState.JustRespawned:
|
||||||
@@ -541,8 +543,6 @@ namespace Game.Entities
|
|||||||
if (!IsAlive())
|
if (!IsAlive())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GetThreatManager().Update(diff);
|
|
||||||
|
|
||||||
if (_spellFocusInfo.Delay != 0)
|
if (_spellFocusInfo.Delay != 0)
|
||||||
{
|
{
|
||||||
if (_spellFocusInfo.Delay <= diff)
|
if (_spellFocusInfo.Delay <= diff)
|
||||||
@@ -1071,6 +1071,8 @@ namespace Game.Entities
|
|||||||
{
|
{
|
||||||
base.AtEngage(target);
|
base.AtEngage(target);
|
||||||
|
|
||||||
|
GetThreatManager().ResetUpdateTimer();
|
||||||
|
|
||||||
if (!HasFlag(CreatureStaticFlags2.AllowMountedCombat))
|
if (!HasFlag(CreatureStaticFlags2.AllowMountedCombat))
|
||||||
Dismount();
|
Dismount();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user