From 95456ab5d8bd623481d315ae55dfbb44b45ba9f5 Mon Sep 17 00:00:00 2001 From: Golrag Date: Thu, 14 Dec 2017 16:56:30 +0100 Subject: Core/Entities: Some changes to LoS z checking & MotionMaster::MoveJumpTo (PR #20970) - Use Midsection height for LoS checking. - Changed MotionMaster::MoveJumpTo to use correct z. This change also makes sure the _owner will jump towards the given angle. Instead of jumping to a unintended angle if the first one is not in LoS. --- src/server/game/Entities/Object/Object.cpp | 12 +++++++++--- src/server/game/Entities/Object/Object.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/server/game/Entities/Object') diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 1a94b420b4c..51b2b2503bc 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1217,7 +1217,7 @@ bool WorldObject::IsWithinDistInMap(WorldObject const* obj, float dist2compare, Position WorldObject::GetHitSpherePointFor(Position const& dest) const { - G3D::Vector3 vThis(GetPositionX(), GetPositionY(), GetPositionZ()); + G3D::Vector3 vThis(GetPositionX(), GetPositionY(), GetPositionZ() + GetMidsectionHeight()); G3D::Vector3 vObj(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ()); G3D::Vector3 contactPoint = vThis + (vObj - vThis).directionOrZero() * std::min(dest.GetExactDist(GetPosition()), GetCombatReach()); @@ -1230,11 +1230,14 @@ bool WorldObject::IsWithinLOS(float ox, float oy, float oz, LineOfSightChecks ch { float x, y, z; if (GetTypeId() == TYPEID_PLAYER) + { GetPosition(x, y, z); + z += GetMidsectionHeight(); + } else GetHitSpherePointFor({ ox, oy, oz }, x, y, z); - return GetMap()->isInLineOfSight(x, y, z + 2.0f, ox, oy, oz + 2.0f, GetPhaseMask(), checks, ignoreFlags); + return GetMap()->isInLineOfSight(x, y, z, ox, oy, oz, GetPhaseMask(), checks, ignoreFlags); } return true; @@ -1247,9 +1250,12 @@ bool WorldObject::IsWithinLOSInMap(WorldObject const* obj, LineOfSightChecks che float x, y, z; if (obj->GetTypeId() == TYPEID_PLAYER) + { obj->GetPosition(x, y, z); + z += GetMidsectionHeight(); + } else - obj->GetHitSpherePointFor(GetPosition(), x, y, z); + obj->GetHitSpherePointFor({ GetPositionX(), GetPositionY(), GetPositionZ() + GetMidsectionHeight() }, x, y, z); return IsWithinLOS(x, y, z, checks, ignoreFlags); } diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 2d94496e20b..cbbc452e591 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -442,6 +442,8 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation virtual float GetStationaryO() const { return GetOrientation(); } float GetFloorZ() const; + virtual float GetCollisionHeight() const { return 0.0f; } + float GetMidsectionHeight() const { return GetCollisionHeight() / 2.0f; } protected: std::string m_name; -- cgit v1.2.3