diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 6b60457a9..c26c50589 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1975,8 +1975,8 @@ void Creature::setDeathState(DeathState state, bool despawn) if (state == DeathState::JustDied) { m_corpseRemoveTime = GameTime::GetGameTime().count() + m_corpseDelay; - GetMap()->ApplyDynamicModeRespawnScaling(this, m_respawnDelay); - m_respawnTime = GameTime::GetGameTime().count() + m_respawnDelay + m_corpseDelay; + uint32 dynamicRespawnDelay = GetMap()->ApplyDynamicModeRespawnScaling(this, m_respawnDelay); + m_respawnTime = GameTime::GetGameTime().count() + dynamicRespawnDelay + m_corpseDelay; // always save boss respawn time at death to prevent crash cheating if (GetMap()->IsDungeon() || isWorldBoss() || GetCreatureTemplate()->rank >= CREATURE_ELITE_ELITE) diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 9ed685f9e..6c942d576 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -897,8 +897,8 @@ void GameObject::Update(uint32 diff) return; } - GetMap()->ApplyDynamicModeRespawnScaling(this, m_respawnDelayTime); - m_respawnTime = GameTime::GetGameTime().count() + m_respawnDelayTime; + uint32 dynamicRespawnDelay = GetMap()->ApplyDynamicModeRespawnScaling(this, m_respawnDelayTime); + m_respawnTime = GameTime::GetGameTime().count() + dynamicRespawnDelay; // if option not set then object will be saved at grid unload if (GetMap()->IsDungeon()) diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 33e4a8a2c..5d9579c4a 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2658,38 +2658,40 @@ void Map::SendObjectUpdates() } } -void Map::ApplyDynamicModeRespawnScaling(WorldObject const* obj, uint32& respawnDelay) const +uint32 Map::ApplyDynamicModeRespawnScaling(WorldObject const* obj, uint32 respawnDelay) const { ASSERT(obj->GetMap() == this); float rate = sWorld->getFloatConfig(obj->IsGameObject() ? CONFIG_RESPAWN_DYNAMICRATE_GAMEOBJECT : CONFIG_RESPAWN_DYNAMICRATE_CREATURE); if (rate == 1.0f) - return; + return respawnDelay; // No instanced maps (dungeons, battlegrounds, arenas etc.) if (obj->GetMap()->Instanceable()) - return; + return respawnDelay; // No quest givers or world bosses if (Creature const* creature = obj->ToCreature()) - if (creature->IsQuestGiver() || creature->isWorldBoss()) - return; + if (creature->IsQuestGiver() || creature->isWorldBoss() + || (creature->GetCreatureTemplate()->rank == CREATURE_ELITE_RARE) + || (creature->GetCreatureTemplate()->rank == CREATURE_ELITE_RAREELITE)) + return respawnDelay; auto it = _zonePlayerCountMap.find(obj->GetZoneId()); if (it == _zonePlayerCountMap.end()) - return; + return respawnDelay; uint32 const playerCount = it->second; if (!playerCount) - return; + return respawnDelay; double const adjustFactor = rate / playerCount; if (adjustFactor >= 1.0) // nothing to do here - return; + return respawnDelay; uint32 const timeMinimum = sWorld->getIntConfig(obj->IsGameObject() ? CONFIG_RESPAWN_DYNAMICMINIMUM_GAMEOBJECT : CONFIG_RESPAWN_DYNAMICMINIMUM_CREATURE); if (respawnDelay <= timeMinimum) - return; + return respawnDelay; - respawnDelay = std::max(std::ceil(respawnDelay * adjustFactor), timeMinimum); + return std::max(std::ceil(respawnDelay * adjustFactor), timeMinimum); } void Map::DelayedUpdate(const uint32 t_diff) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 8763590e5..54f8d7c2c 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -595,7 +595,7 @@ public: [[nodiscard]] time_t GetInstanceResetPeriod() const { return _instanceResetPeriod; } void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone); - void ApplyDynamicModeRespawnScaling(WorldObject const* obj, uint32& respawnDelay) const; + [[nodiscard]] uint32 ApplyDynamicModeRespawnScaling(WorldObject const* obj, uint32 respawnDelay) const; TaskScheduler _creatureRespawnScheduler;