From 87d3646a8363caa4ef03031f61dd56c416fa9193 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 22 Feb 2022 19:49:05 -0500 Subject: [PATCH] Core/Creature: Allow to disable HP regen in Raids even if the target is unreachable Port From (https://github.com/TrinityCore/TrinityCore/commit/07863a7a6817dbb16fbd740130149bf727a6a136) --- Source/Framework/Constants/SharedConst.cs | 1 + Source/Game/Entities/Creature/Creature.cs | 28 +++++++++++++++++++---- Source/Game/Server/WorldConfig.cs | 2 ++ Source/WorldServer/WorldServer.conf.dist | 8 +++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Source/Framework/Constants/SharedConst.cs b/Source/Framework/Constants/SharedConst.cs index 8ca619ec7..f094896f0 100644 --- a/Source/Framework/Constants/SharedConst.cs +++ b/Source/Framework/Constants/SharedConst.cs @@ -1666,6 +1666,7 @@ namespace Framework.Constants RateXpBoost, RateXpQuest, RealmZone, + RegenHpCannotReachTargetInRaid, ResetDuelCooldowns, ResetDuelHealthMana, RespawnDynamicEscortNpc, diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index 0f1f09c86..2cb51b752 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -590,8 +590,24 @@ namespace Game.Entities if (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 (WorldConfig.GetBoolValue(WorldCfg.RegenHpCannotReachTargetInRaid) || !GetMap().IsRaid()) + { + RegenerateHealth(); + Log.outDebug(LogFilter.Unit, $"RegenerateHealth() enabled because Creature cannot reach the target. Detail: {GetDebugInfo()}"); + } + else + Log.outDebug(LogFilter.Unit, $"RegenerateHealth() disabled even if the Creature cannot reach the target. Detail: {GetDebugInfo()}"); + } + } if (GetPowerType() == PowerType.Energy) Regenerate(PowerType.Energy); @@ -2800,15 +2816,19 @@ namespace Game.Entities return range; } - public void SetCannotReachTarget(bool cannotReach) + bool CanNotReachTarget() { return m_cannotReachTarget; } + + void SetCannotReachTarget(bool cannotReach) { if (cannotReach == m_cannotReachTarget) return; m_cannotReachTarget = cannotReach; m_cannotReachTimer = 0; + + if (cannotReach) + Log.outDebug(LogFilter.Unit, $"Creature::SetCannotReachTarget() called with true. Details: {GetDebugInfo()}"); } - bool CanNotReachTarget() { return m_cannotReachTarget; } public float GetAggroRange(Unit target) { diff --git a/Source/Game/Server/WorldConfig.cs b/Source/Game/Server/WorldConfig.cs index f6747c2b5..de7324427 100644 --- a/Source/Game/Server/WorldConfig.cs +++ b/Source/Game/Server/WorldConfig.cs @@ -312,6 +312,8 @@ namespace Game /// @todo Add MonsterSight (with meaning) in worldserver.conf or put them as define Values[WorldCfg.SightMonster] = GetDefaultValue("MonsterSight", 50.0f); + Values[WorldCfg.RegenHpCannotReachTargetInRaid] = GetDefaultValue("Creature.RegenHPCannotReachTargetInRaid", true); + if (reload) { int val = GetDefaultValue("GameType", 0); diff --git a/Source/WorldServer/WorldServer.conf.dist b/Source/WorldServer/WorldServer.conf.dist index d2f0dfe88..a4d74e303 100644 --- a/Source/WorldServer/WorldServer.conf.dist +++ b/Source/WorldServer/WorldServer.conf.dist @@ -1708,6 +1708,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 + # ###################################################################################################