diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 94584ef26..24dee9f9d 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -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()) diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 124074ffc..d4dcbc3f5 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -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;