fix(Core/Creature): Respawning mobs missing aggro "grace period" (#4893)

This commit is contained in:
Wojciech Nosal
2021-03-21 15:19:35 +01:00
committed by GitHub
parent edd6d65fb2
commit e06d30e686
2 changed files with 8 additions and 1 deletions

View File

@@ -1791,7 +1791,7 @@ void Creature::Respawn(bool force)
//Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState();
}
m_respawnedTime = time(nullptr);
// xinef: relocate notifier, fixes npc appearing in corpse position after forced respawn (instead of spawn)
m_last_notify_position.Relocate(-5000.0f, -5000.0f, -5000.0f, 0.0f);
UpdateObjectVisibility(false);
@@ -2276,6 +2276,12 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode())
return false;
// cannot attack if is during 5 second grace period, unless being attacked
if ((time(nullptr) - m_respawnedTime) < 5 && victim->getAttackers().empty())
{
return false;
}
if (!IS_PLAYER_GUID(GetCharmerOrOwnerGUID()))
{
if (GetMap()->IsDungeon())

View File

@@ -769,6 +769,7 @@ protected:
/// Timers
time_t m_corpseRemoveTime; // (msecs)timer for death or corpse disappearance
time_t m_respawnTime; // (secs) time of next respawn
time_t m_respawnedTime; // (secs) time when creature respawned
uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
float m_wanderDistance;