aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp6
-rw-r--r--src/server/game/Movement/PathGenerator.cpp10
2 files changed, 15 insertions, 1 deletions
diff --git a/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp
index 0e22919e155..9cd58ee0f82 100644
--- a/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp
@@ -44,7 +44,11 @@ static bool PositionOkay(Unit* owner, Unit* target, Optional<float> minDistance,
return false;
if (maxDistance && distSq > square(*maxDistance))
return false;
- return !angle || angle->IsAngleOkay(target->GetRelativeAngle(owner));
+ if (angle && !angle->IsAngleOkay(target->GetRelativeAngle(owner)))
+ return false;
+ if (!owner->IsWithinLOSInMap(target))
+ return false;
+ return true;
}
static void DoMovementInform(Unit* owner, Unit* target)
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp
index 33e6f786c75..f179579b5e3 100644
--- a/src/server/game/Movement/PathGenerator.cpp
+++ b/src/server/game/Movement/PathGenerator.cpp
@@ -927,6 +927,7 @@ void PathGenerator::ShortenPathUntilDist(G3D::Vector3 const& target, float dist)
return;
size_t i = _pathPoints.size()-1;
+ float x, y, z, collisionHeight = _sourceUnit->GetCollisionHeight();
// find the first i s.t.:
// - _pathPoints[i] is still too close
// - _pathPoints[i-1] is too far away
@@ -937,6 +938,15 @@ void PathGenerator::ShortenPathUntilDist(G3D::Vector3 const& target, float dist)
if ((_pathPoints[i-1] - target).squaredLength() >= distSq)
break; // bingo!
+ // check if the shortened path is still in LoS with the target
+ _sourceUnit->GetHitSpherePointFor({ _pathPoints[i - 1].x, _pathPoints[i - 1].y, _pathPoints[i - 1].z + collisionHeight }, x, y, z);
+ if (!_sourceUnit->GetMap()->isInLineOfSight(_sourceUnit->GetPhaseShift(), x, y, z, _pathPoints[i - 1].x, _pathPoints[i - 1].y, _pathPoints[i - 1].z + collisionHeight, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::Nothing))
+ {
+ // whenver we find a point that is not in LoS anymore, simply use last valid path
+ _pathPoints.resize(i + 1);
+ return;
+ }
+
if (!--i)
{
// no point found that fulfills the condition