Core/Creature: Implement aggro grace period
Port From (https://github.com/TrinityCore/TrinityCore/commit/26d1337461114506ca57e2265d3dc5e96fd08f82)
This commit is contained in:
@@ -69,6 +69,8 @@ namespace Game.Entities
|
||||
bool triggerJustAppeared;
|
||||
bool m_respawnCompatibilityMode;
|
||||
|
||||
bool _aggroGracePeriodExpired;
|
||||
|
||||
public uint[] m_spells = new uint[SharedConst.MaxCreatureSpells];
|
||||
|
||||
// Timers
|
||||
|
||||
@@ -638,6 +638,16 @@ namespace Game.Entities
|
||||
|
||||
// Creatures with CREATURE_STATIC_FLAG_2_FORCE_PARTY_MEMBERS_INTO_COMBAT periodically force party members into combat
|
||||
ForcePartyMembersIntoCombat();
|
||||
|
||||
// creatures should only attack surroundings initially after heartbeat has passed or until attacked
|
||||
if (!_aggroGracePeriodExpired)
|
||||
{
|
||||
_aggroGracePeriodExpired = true;
|
||||
|
||||
// trigger MoveInLineOfSight
|
||||
CreatureAggroGracePeriodExpiredNotifier notifier = new(this);
|
||||
Cell.VisitAllObjects(this, notifier, GetVisibilityRange());
|
||||
}
|
||||
}
|
||||
|
||||
public void Regenerate(PowerType power)
|
||||
@@ -1080,6 +1090,8 @@ namespace Game.Entities
|
||||
{
|
||||
base.AtEngage(target);
|
||||
|
||||
_aggroGracePeriodExpired = true;
|
||||
|
||||
GetThreatManager().ResetUpdateTimer();
|
||||
|
||||
if (!HasFlag(CreatureStaticFlags2.AllowMountedCombat))
|
||||
@@ -1680,6 +1692,8 @@ namespace Game.Entities
|
||||
|
||||
void SetInteractSpellId(int interactSpellId) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.InteractSpellID), interactSpellId); }
|
||||
|
||||
public bool IsAggroGracePeriodExpired() { return _aggroGracePeriodExpired; }
|
||||
|
||||
public void OverrideSparringHealthPct(List<float> healthPct)
|
||||
{
|
||||
_sparringHealthPct = healthPct.SelectRandom();
|
||||
@@ -2148,6 +2162,7 @@ namespace Game.Entities
|
||||
ai.Reset();
|
||||
|
||||
triggerJustAppeared = true;
|
||||
_aggroGracePeriodExpired = false;
|
||||
|
||||
uint poolid = GetCreatureData() != null ? GetCreatureData().poolId : 0;
|
||||
if (poolid != 0)
|
||||
|
||||
Reference in New Issue
Block a user