Core/Spells: merged a radius calculation from 3.3.5 that covers the attempted fix from last commit
This commit is contained in:
1 parent
0d46b893fc
commit
0f32e2d263
4 files changed
+27
-16
No files matched your search
@@ -1409,24 +1409,24 @@ bool WorldObject::IsInMap(const WorldObject* obj) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist, bool isInBoundaryRadius /*= false*/) const
|
||||
bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist) const
|
||||
{
|
||||
return IsInDist(x, y, z, dist + isInBoundaryRadius ? GetBoundaryRadius() : GetCombatReach());
|
||||
return IsInDist(x, y, z, dist);
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist3d(const Position* pos, float dist, bool isInBoundaryRadius /*= false*/) const
|
||||
bool WorldObject::IsWithinDist3d(const Position* pos, float dist) const
|
||||
{
|
||||
return IsInDist(pos, dist + isInBoundaryRadius ? GetBoundaryRadius() : GetCombatReach());
|
||||
return IsInDist(pos, dist);
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist2d(float x, float y, float dist, bool isInBoundaryRadius /*= false*/) const
|
||||
bool WorldObject::IsWithinDist2d(float x, float y, float dist) const
|
||||
{
|
||||
return IsInDist2d(x, y, dist + isInBoundaryRadius ? GetBoundaryRadius() : GetCombatReach());
|
||||
return IsInDist2d(x, y, dist);
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist2d(const Position* pos, float dist, bool isInBoundaryRadius /*= false*/) const
|
||||
bool WorldObject::IsWithinDist2d(const Position* pos, float dist) const
|
||||
{
|
||||
return IsInDist2d(pos, dist + isInBoundaryRadius ? GetBoundaryRadius() : GetCombatReach());
|
||||
return IsInDist2d(pos, dist);
|
||||
}
|
||||
|
||||
bool WorldObject::IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D /*= true*/) const
|
||||
|
||||
@@ -285,7 +285,6 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
void GetContactPoint(WorldObject const* obj, float &x, float &y, float &z, float distance2d = CONTACT_DISTANCE) const;
|
||||
|
||||
virtual float GetCombatReach() const { return 0.0f; } // overridden (only) in Unit
|
||||
virtual float GetBoundaryRadius() const { return 0.0f; } // overridden (only) in Unit
|
||||
void UpdateGroundPositionZ(float x, float y, float &z) const;
|
||||
void UpdateAllowedPositionZ(float x, float y, float &z) const;
|
||||
|
||||
@@ -330,10 +329,10 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
|
||||
bool IsSelfOrInSameMap(WorldObject const* obj) const;
|
||||
bool IsInMap(WorldObject const* obj) const;
|
||||
bool IsWithinDist3d(float x, float y, float z, float dist, bool isInBoundaryRadius = false) const;
|
||||
bool IsWithinDist3d(Position const* pos, float dist, bool isInBoundaryRadius = false) const;
|
||||
bool IsWithinDist2d(float x, float y, float dist, bool isInBoundaryRadius = false) const;
|
||||
bool IsWithinDist2d(Position const* pos, float dist, bool isInBoundaryRadius = false) const;
|
||||
bool IsWithinDist3d(float x, float y, float z, float dist) const;
|
||||
bool IsWithinDist3d(Position const* pos, float dist) const;
|
||||
bool IsWithinDist2d(float x, float y, float dist) const;
|
||||
bool IsWithinDist2d(Position const* pos, float dist) const;
|
||||
// use only if you will sure about placing both object at same map
|
||||
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const;
|
||||
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const;
|
||||
|
||||
@@ -1006,7 +1006,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
bool CanDualWield() const { return m_canDualWield; }
|
||||
virtual void SetCanDualWield(bool value) { m_canDualWield = value; }
|
||||
float GetCombatReach() const override { return m_floatValues[UNIT_FIELD_COMBATREACH]; }
|
||||
float GetBoundaryRadius() const override { return m_floatValues[UNIT_FIELD_BOUNDINGRADIUS]; }
|
||||
float GetBoundaryRadius() const { return m_floatValues[UNIT_FIELD_BOUNDINGRADIUS]; }
|
||||
bool IsWithinCombatRange(Unit const* obj, float dist2compare) const;
|
||||
bool IsWithinMeleeRange(Unit const* obj) const;
|
||||
bool IsWithinBoundaryRadius(const Unit* obj) const;
|
||||
|
||||
@@ -7952,8 +7952,20 @@ WorldObjectSpellAreaTargetCheck::WorldObjectSpellAreaTargetCheck(float range, Po
|
||||
|
||||
bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target)
|
||||
{
|
||||
if (!target->IsWithinDist3d(_position, _range, true) && !(target->ToGameObject() && target->ToGameObject()->IsInRange(_position->GetPositionX(), _position->GetPositionY(), _position->GetPositionZ(), _range)))
|
||||
return false;
|
||||
if (target->ToGameObject())
|
||||
{
|
||||
// isInRange including the dimension of the GO
|
||||
bool isInRange = target->ToGameObject()->IsInRange(_position->GetPositionX(), _position->GetPositionY(), _position->GetPositionZ(), _range);
|
||||
if (!isInRange)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isInsideCylinder = target->IsWithinDist2d(_position, _range) && std::abs(target->GetPositionZ() - _position->GetPositionZ()) <= _range;
|
||||
if (!isInsideCylinder)
|
||||
return false;
|
||||
}
|
||||
|
||||
return WorldObjectSpellTargetCheck::operator ()(target);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user