Fix Evading issue

This commit is contained in:
郑佩茹
2022-08-18 13:46:22 -06:00
parent 32c6babdb7
commit bbd283598d
6 changed files with 47 additions and 38 deletions

View File

@@ -3494,26 +3494,35 @@ bool Creature::IsMovementPreventedByCasting() const
return false;
}
bool Creature::SetCannotReachTarget()
void Creature::SetCannotReachTarget(ObjectGuid const& cannotReach)
{
return SetCannotReachTarget(true);
}
bool Creature::SetCannotReachTarget(bool cannotReach, bool isChase /*= true*/)
if (cannotReach == m_cannotReachTarget)
{
if (!isChase || !Unit::SetCannotReachTarget(cannotReach))
{
return false;
return;
}
m_cannotReachTarget = cannotReach;
m_cannotReachTimer = 0;
if (cannotReach)
{
LOG_DEBUG("entities.unit", "Creature::SetCannotReachTarget() called with true. Details: {}", GetDebugInfo());
}
}
return true;
bool Creature::CanNotReachTarget() const
{
return m_cannotReachTarget;
}
bool Creature::IsNotReachableAndNeedRegen() const
{
if (CanNotReachTarget())
{
return m_cannotReachTimer >= (sWorld->getIntConfig(CONFIG_NPC_REGEN_TIME_IF_NOT_REACHABLE_IN_RAID) * IN_MILLISECONDS);
}
return false;
}
time_t Creature::GetLastDamagedTime() const

View File

@@ -310,10 +310,9 @@ public:
return m_charmInfo->GetCharmSpell(pos)->GetAction();
}
bool SetCannotReachTarget();
bool SetCannotReachTarget(bool cannotReach, bool isChase = true) override;
[[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 SetCannotReachTarget(ObjectGuid const& target = ObjectGuid::Empty);
[[nodiscard]] bool CanNotReachTarget() const;
[[nodiscard]] bool IsNotReachableAndNeedRegen() const;
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

@@ -212,7 +212,6 @@ Unit::Unit(bool isWorldObject) : WorldObject(isWorldObject),
m_vehicleKit(nullptr),
m_unitTypeMask(UNIT_MASK_NONE),
m_HostileRefMgr(this),
m_cannotReachTarget(false),
m_comboTarget(nullptr),
m_comboPoints(0)
{
@@ -20787,18 +20786,6 @@ bool Unit::CanRestoreMana(SpellInfo const* spellInfo) const
return false;
}
bool Unit::SetCannotReachTarget(bool cannotReach, bool /*isChase = true*/)
{
if (cannotReach == m_cannotReachTarget)
{
return false;
}
m_cannotReachTarget = cannotReach;
return true;
}
bool Unit::IsInDisallowedMountForm() const
{
if (SpellInfo const* transformSpellInfo = sSpellMgr->GetSpellInfo(getTransForm()))
@@ -20864,3 +20851,18 @@ std::string Unit::GetDebugInfo() const
<< " Class: " << std::to_string(getClass());
return sstr.str();
}
void Unit::SetCannotReachTargetUnit(bool cannotReach, bool isChase)
{
if (cannotReach == m_cannotReachTarget)
{
return;
}
m_cannotReachTarget = cannotReach;
}
bool Unit::CanNotReachTarget() const
{
return m_cannotReachTarget;
}

View File

@@ -2428,10 +2428,11 @@ public:
[[nodiscard]] bool CanRestoreMana(SpellInfo const* spellInfo) const;
virtual bool SetCannotReachTarget(bool cannotReach, bool isChase = true);
[[nodiscard]] bool CanNotReachTarget() const { return m_cannotReachTarget; }
std::string GetDebugInfo() const override;
void SetCannotReachTargetUnit(bool target, bool isChase);
[[nodiscard]] bool CanNotReachTarget() const;
bool m_cannotReachTarget;
protected:
explicit Unit (bool isWorldObject);
@@ -2513,8 +2514,6 @@ protected:
bool IsAlwaysDetectableFor(WorldObject const* seer) const override;
bool _instantCast;
bool m_cannotReachTarget;
private:
bool IsTriggeredAtSpellProcEvent(Unit* victim, Aura* aura, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry const*& spellProcEvent, ProcEventInfo const& eventInfo);
bool HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggeredByAura, SpellInfo const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown, Spell const* spellProc = nullptr);