aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Object
diff options
context:
space:
mode:
authorGolrag <Golrag@users.noreply.github.com>2017-12-14 16:56:30 +0100
committerfunjoker <funjoker109@gmail.com>2021-03-15 20:17:31 +0100
commitfe362cf2c9d5c71db4698480ce26cb35dbc58f28 (patch)
treeee322a201886df019ba4f9b0cd31eca0814beb59 /src/server/game/Entities/Object
parent2313343227b9415a08a0efc1e95cced9e308ef9d (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. (cherry picked from commit 95456ab5d8bd623481d315ae55dfbb44b45ba9f5)
Diffstat (limited to 'src/server/game/Entities/Object')
-rw-r--r--src/server/game/Entities/Object/Object.cpp12
-rw-r--r--src/server/game/Entities/Object/Object.h2
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 22970a8950e..118169837d3 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -1084,7 +1084,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());
@@ -1097,11 +1097,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(GetPhaseShift(), x, y, z + 2.0f, ox, oy, oz + 2.0f, checks, ignoreFlags);
+ return GetMap()->isInLineOfSight(GetPhaseShift(), x, y, z, ox, oy, oz, checks, ignoreFlags);
}
return true;
@@ -1114,9 +1117,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 7f247ad3cb0..c49f029e82b 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -586,6 +586,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; }
virtual uint16 GetAIAnimKitId() const { return 0; }
virtual uint16 GetMovementAnimKitId() const { return 0; }