aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2020-05-21 12:48:09 +0000
committerShauren <shauren.trinity@gmail.com>2022-01-06 16:12:51 +0100
commit07863a7a6817dbb16fbd740130149bf727a6a136 (patch)
tree0b940ae8158195fd35fa75c748d007bebf87dca2
parent876d9f52ec930c7a92ffeffc17e6ae5d6ac9aa3f (diff)
Core/Creature: Allow to disable HP regen in Raids even if the target is unreachable (#24646)
(cherry picked from commit 247564a7ab7dc6f640bb8f4fd32c30ffdc9076d2)
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp31
-rw-r--r--src/server/game/Entities/Creature/Creature.h2
-rw-r--r--src/server/game/World/World.cpp2
-rw-r--r--src/server/game/World/World.h1
-rw-r--r--src/server/worldserver/worldserver.conf.dist8
5 files changed, 41 insertions, 3 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index cbb84b3684c..bf364fca4c6 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -864,8 +864,24 @@ void Creature::Update(uint32 diff)
if (m_regenTimer == 0)
{
- if (!IsInEvadeMode() && (!IsEngaged() || IsPolymorphed() || CanNotReachTarget())) // regenerate health if not in combat or if polymorphed
- RegenerateHealth();
+ if (!IsInEvadeMode())
+ {
+ // regenerate health if not in combat or if polymorphed)
+ if (!IsEngaged() || IsPolymorphed())
+ RegenerateHealth();
+ else if (CanNotReachTarget())
+ {
+ // regenerate health if cannot reach the target and the setting is set to do so.
+ // this allows to disable the health regen of raid bosses if pathfinding has issues for whatever reason
+ if (sWorld->getBoolConfig(CONFIG_REGEN_HP_CANNOT_REACH_TARGET_IN_RAID) || !GetMap()->IsRaid())
+ {
+ RegenerateHealth();
+ TC_LOG_DEBUG("entities.unit.chase", "RegenerateHealth() enabled because Creature cannot reach the target. Detail: %s", GetDebugInfo().c_str());
+ }
+ else
+ TC_LOG_DEBUG("entities.unit.chase", "RegenerateHealth() disabled even if the Creature cannot reach the target. Detail: %s", GetDebugInfo().c_str());
+ }
+ }
if (GetPowerType() == POWER_ENERGY)
Regenerate(POWER_ENERGY);
@@ -3080,6 +3096,17 @@ float Creature::GetPetChaseDistance() const
return range;
}
+void Creature::SetCannotReachTarget(bool cannotReach)
+{
+ if (cannotReach == m_cannotReachTarget)
+ return;
+ m_cannotReachTarget = cannotReach;
+ m_cannotReachTimer = 0;
+
+ if (cannotReach)
+ TC_LOG_DEBUG("entities.unit.chase", "Creature::SetCannotReachTarget() called with true. Details: %s", GetDebugInfo().c_str());
+}
+
float Creature::GetAggroRange(Unit const* target) const
{
// Determines the aggro range for creatures (usually pets), used mainly for aggressive pet target selection.
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 292ecd2196f..d6a28371954 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -297,7 +297,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const;
float GetPetChaseDistance() const;
- void SetCannotReachTarget(bool cannotReach) { if (cannotReach == m_cannotReachTarget) return; m_cannotReachTarget = cannotReach; m_cannotReachTimer = 0; }
+ void SetCannotReachTarget(bool cannotReach);
bool CanNotReachTarget() const { return m_cannotReachTarget; }
void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); }
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index e7fc2ac484c..52655e381ce 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -862,6 +862,8 @@ void World::LoadConfigSettings(bool reload)
/// @todo Add MonsterSight (with meaning) in worldserver.conf or put them as define
m_float_configs[CONFIG_SIGHT_MONSTER] = sConfigMgr->GetFloatDefault("MonsterSight", 50.0f);
+ m_bool_configs[CONFIG_REGEN_HP_CANNOT_REACH_TARGET_IN_RAID] = sConfigMgr->GetBoolDefault("Creature.RegenHPCannotReachTargetInRaid", true);
+
if (reload)
{
uint32 val = sConfigMgr->GetIntDefault("GameType", 0);
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index a6a5cf411bb..abdbf386020 100644
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -192,6 +192,7 @@ enum WorldBoolConfigs
CONFIG_GAME_OBJECT_CHECK_INVALID_POSITION,
CONFIG_CHECK_GOBJECT_LOS,
CONFIG_RESPAWN_DYNAMIC_ESCORTNPC,
+ CONFIG_REGEN_HP_CANNOT_REACH_TARGET_IN_RAID,
CONFIG_CHARACTER_CREATING_DISABLE_ALLIED_RACE_ACHIEVEMENT_REQUIREMENT,
BOOL_CONFIG_VALUE_COUNT
};
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index cc9f0e20157..ebeca9832a8 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -1839,6 +1839,14 @@ Creature.MovingStopTimeForPlayer = 180000
MonsterSight = 50.000000
#
+# Creature.RegenHPCannotReachTargetInRaid
+# Description: Regenerates HP for Creatures in Raids if they cannot reach the target.
+# Default: 1 - (Enabled)
+# 0 - (Disabled)
+
+Creature.RegenHPCannotReachTargetInRaid = 1
+
+#
###################################################################################################
###################################################################################################