diff options
| author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2020-05-21 12:48:09 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-21 14:48:09 +0200 |
| commit | 247564a7ab7dc6f640bb8f4fd32c30ffdc9076d2 (patch) | |
| tree | 477ab996f78ebcfb63a07efc8be590067d1260da /src/server/game/Entities/Creature | |
| parent | 6b9a14ca940a2104a89cfadf07978a2759acb47a (diff) | |
Core/Creature: Allow to disable HP regen in Raids even if the target is unreachable (#24646)
Diffstat (limited to 'src/server/game/Entities/Creature')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 31 | ||||
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 8 |
2 files changed, 30 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); } |
