diff options
| author | Golrag <Golrag@users.noreply.github.com> | 2017-12-14 16:56:30 +0100 |
|---|---|---|
| committer | Treeston <treeston.mmoc@gmail.com> | 2017-12-14 16:56:30 +0100 |
| commit | 95456ab5d8bd623481d315ae55dfbb44b45ba9f5 (patch) | |
| tree | be170006070e1ec52c101f323692cf75a47f4bff /src/server/game/Entities/Object | |
| parent | 16739c6260ac22ef4c56bd1589f244b459e485af (diff) | |
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.
Diffstat (limited to 'src/server/game/Entities/Object')
| -rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 12 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Object.h | 2 |
2 files changed, 11 insertions, 3 deletions
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; |
