aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2020-05-21 12:48:09 +0000
committerGitHub <noreply@github.com>2020-05-21 14:48:09 +0200
commit247564a7ab7dc6f640bb8f4fd32c30ffdc9076d2 (patch)
tree477ab996f78ebcfb63a07efc8be590067d1260da
parent6b9a14ca940a2104a89cfadf07978a2759acb47a (diff)
Core/Creature: Allow to disable HP regen in Raids even if the target is unreachable (#24646)
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp31
-rw-r--r--src/server/game/Entities/Creature/Creature.h8
-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, 9 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 72aa452a4fb..9a6c9db819f 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -815,8 +815,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);
@@ -2844,6 +2860,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());
+}
+
bool Creature::SetWalk(bool enable)
{
if (!Unit::SetWalk(enable))
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index bf90eb90528..a33a09b227c 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -284,13 +284,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 92551cf92e7..93f1b919dab 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -767,6 +767,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 3765fb81e3a..24338a7eee3 100644
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -177,6 +177,7 @@ enum WorldBoolConfigs
CONFIG_CACHE_DATA_QUERIES,
CONFIG_CHECK_GOBJECT_LOS,
CONFIG_RESPAWN_DYNAMIC_ESCORTNPC,
+ CONFIG_REGEN_HP_CANNOT_REACH_TARGET_IN_RAID,
BOOL_CONFIG_VALUE_COUNT
};
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index fa0ddf42a79..998f40cbaca 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -1785,6 +1785,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
+
+#
###################################################################################################
###################################################################################################