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

This commit is contained in:
Giacomo Pozzoni
2020-05-21 12:48:09 +00:00
committed by GitHub
parent 6b9a14ca94
commit 247564a7ab
5 changed files with 41 additions and 9 deletions

View File

@@ -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))

View File

@@ -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); }

View File

@@ -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);

View File

@@ -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
};

View File

@@ -1784,6 +1784,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
#
###################################################################################################