Core/Creature: Allow to disable HP regen in Raids even if the target is unreachable

Port From (https://github.com/TrinityCore/TrinityCore/commit/07863a7a6817dbb16fbd740130149bf727a6a136)
This commit is contained in:
hondacrx
2022-02-22 19:49:05 -05:00
parent db46b39a93
commit 87d3646a83
4 changed files with 35 additions and 4 deletions
@@ -1666,6 +1666,7 @@ namespace Framework.Constants
RateXpBoost, RateXpBoost,
RateXpQuest, RateXpQuest,
RealmZone, RealmZone,
RegenHpCannotReachTargetInRaid,
ResetDuelCooldowns, ResetDuelCooldowns,
ResetDuelHealthMana, ResetDuelHealthMana,
RespawnDynamicEscortNpc, RespawnDynamicEscortNpc,
+24 -4
View File
@@ -590,8 +590,24 @@ namespace Game.Entities
if (RegenTimer == 0) if (RegenTimer == 0)
{ {
if (!IsInEvadeMode() && (!IsEngaged() || IsPolymorphed() || CanNotReachTarget())) // regenerate health if not in combat or if polymorphed if (!IsInEvadeMode())
RegenerateHealth(); {
// 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) if (GetPowerType() == PowerType.Energy)
Regenerate(PowerType.Energy); Regenerate(PowerType.Energy);
@@ -2800,15 +2816,19 @@ namespace Game.Entities
return range; return range;
} }
public void SetCannotReachTarget(bool cannotReach) bool CanNotReachTarget() { return m_cannotReachTarget; }
void SetCannotReachTarget(bool cannotReach)
{ {
if (cannotReach == m_cannotReachTarget) if (cannotReach == m_cannotReachTarget)
return; return;
m_cannotReachTarget = cannotReach; m_cannotReachTarget = cannotReach;
m_cannotReachTimer = 0; 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) public float GetAggroRange(Unit target)
{ {
+2
View File
@@ -312,6 +312,8 @@ namespace Game
/// @todo Add MonsterSight (with meaning) in worldserver.conf or put them as define /// @todo Add MonsterSight (with meaning) in worldserver.conf or put them as define
Values[WorldCfg.SightMonster] = GetDefaultValue("MonsterSight", 50.0f); Values[WorldCfg.SightMonster] = GetDefaultValue("MonsterSight", 50.0f);
Values[WorldCfg.RegenHpCannotReachTargetInRaid] = GetDefaultValue("Creature.RegenHPCannotReachTargetInRaid", true);
if (reload) if (reload)
{ {
int val = GetDefaultValue("GameType", 0); int val = GetDefaultValue("GameType", 0);
+8
View File
@@ -1708,6 +1708,14 @@ Creature.MovingStopTimeForPlayer = 180000
MonsterSight = 50.000000 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
# #
################################################################################################### ###################################################################################################