fix(Core/Pathfinding): Creatures regen health, spells LOD (#4509)

This commit is contained in:
Footman
2021-02-10 02:37:05 +03:00
committed by GitHub
parent 98a61b71e5
commit 522eb9a7e4
12 changed files with 132 additions and 115 deletions

View File

@@ -641,7 +641,7 @@ void Creature::Update(uint32 diff)
// regenerate health if not in combat or if polymorphed)
if (!IsInCombat() || IsPolymorphed())
RegenerateHealth();
else if (CanNotReachTarget())
else if (IsNotReachableAndNeedRegen())
{
// 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
@@ -666,7 +666,7 @@ void Creature::Update(uint32 diff)
if (CanNotReachTarget() && !IsInEvadeMode() && !GetMap()->IsRaid())
{
m_cannotReachTimer += diff;
if (m_cannotReachTimer >= (sWorld->getIntConfig(CONFIG_NPC_EVADE_IF_NOT_REACHABLE)*IN_MILLISECONDS) && IsAIEnabled)
if (IsNotReachable() && IsAIEnabled)
{
AI()->EnterEvadeMode();
}

View File

@@ -688,6 +688,8 @@ public:
void SetCannotReachTarget(bool cannotReach);
[[nodiscard]] bool CanNotReachTarget() const { return m_cannotReachTarget; }
[[nodiscard]] bool IsNotReachable() const { return (m_cannotReachTimer >= (sWorld->getIntConfig(CONFIG_NPC_EVADE_IF_NOT_REACHABLE) * IN_MILLISECONDS)) && m_cannotReachTarget; }
[[nodiscard]] bool IsNotReachableAndNeedRegen() const { return (m_cannotReachTimer >= (sWorld->getIntConfig(CONFIG_NPC_REGEN_TIME_IF_NOT_REACHABLE_IN_RAID) * IN_MILLISECONDS)) && m_cannotReachTarget; }
void SetPosition(float x, float y, float z, float o);
void SetPosition(const Position& pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }

View File

@@ -553,7 +553,7 @@ void Unit::UpdateSplinePosition()
void Unit::DisableSpline()
{
m_movementInfo.RemoveMovementFlag(MovementFlags(MOVEMENTFLAG_SPLINE_ENABLED | MOVEMENTFLAG_FORWARD));
m_movementInfo.RemoveMovementFlag(MovementFlags(MOVEMENTFLAG_SPLINE_ENABLED | MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_BACKWARD));
movespline->_Interrupt();
}
@@ -13685,6 +13685,7 @@ void Unit::setDeathState(DeathState s, bool despawn)
// remove aurastates allowing special moves
ClearAllReactives();
ClearDiminishings();
GetMotionMaster()->Clear(false);
GetMotionMaster()->MoveIdle();
@@ -15894,6 +15895,10 @@ void Unit::StopMoving()
if (movespline->Finalized())
return;
// Update position now since Stop does not start a new movement that can be updated later
if (movespline->HasStarted())
UpdateSplinePosition();
Movement::MoveSplineInit init(this);
init.Stop();
}