fix(Core/FleeingMovementGenerator): Prevent fleeing players from moving off cliffs (#22462)
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
parent
a88c058ef0
commit
7712c2a973
3 changed files with 9 additions and 8 deletions
|
|
@ -144,6 +144,9 @@ void FleeingMovementGenerator<T>::SetTargetLocation(T* owner)
|
|||
bool result = _path->CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
|
||||
if (!result || (_path->GetPathType() & PathType(PATHFIND_NOPATH | PATHFIND_SHORTCUT | PATHFIND_FARFROMPOLY | PATHFIND_NOT_USING_PATH)))
|
||||
{
|
||||
if (_fleeTargetGUID)
|
||||
++_invalidPathsCount;
|
||||
|
||||
_timer.Reset(100);
|
||||
return;
|
||||
}
|
||||
|
|
@ -152,15 +155,13 @@ void FleeingMovementGenerator<T>::SetTargetLocation(T* owner)
|
|||
if (_path->getPathLength() < MIN_PATH_LENGTH)
|
||||
{
|
||||
if (_fleeTargetGUID)
|
||||
{
|
||||
++_shortPathsCount;
|
||||
}
|
||||
++_invalidPathsCount;
|
||||
|
||||
_timer.Reset(100);
|
||||
return;
|
||||
}
|
||||
|
||||
_shortPathsCount = 0;
|
||||
_invalidPathsCount = 0;
|
||||
|
||||
Movement::MoveSplineInit init(owner);
|
||||
init.MovebyPath(_path->GetPath());
|
||||
|
|
@ -175,7 +176,7 @@ void FleeingMovementGenerator<T>::GetPoint(T* owner, Position& position)
|
|||
float casterDistance = 0.f;
|
||||
float casterAngle = 0.f;
|
||||
Unit* fleeTarget = nullptr;
|
||||
if (_shortPathsCount < 5)
|
||||
if (_invalidPathsCount < 5)
|
||||
fleeTarget = ObjectAccessor::GetUnit(*owner, _fleeTargetGUID);
|
||||
|
||||
if (fleeTarget)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ template<class T>
|
|||
class FleeingMovementGenerator : public MovementGeneratorMedium< T, FleeingMovementGenerator<T> >
|
||||
{
|
||||
public:
|
||||
explicit FleeingMovementGenerator(ObjectGuid fleeTargetGUID) : _path(nullptr), _fleeTargetGUID(fleeTargetGUID), _timer(0), _interrupt(false), _shortPathsCount(0) { }
|
||||
explicit FleeingMovementGenerator(ObjectGuid fleeTargetGUID) : _path(nullptr), _fleeTargetGUID(fleeTargetGUID), _timer(0), _interrupt(false), _invalidPathsCount(0) { }
|
||||
|
||||
MovementGeneratorType GetMovementGeneratorType() override { return FLEEING_MOTION_TYPE; }
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ class FleeingMovementGenerator : public MovementGeneratorMedium< T, FleeingMovem
|
|||
ObjectGuid _fleeTargetGUID;
|
||||
TimeTracker _timer;
|
||||
bool _interrupt;
|
||||
uint8 _shortPathsCount;
|
||||
uint8 _invalidPathsCount;
|
||||
};
|
||||
|
||||
class TimedFleeingMovementGenerator : public FleeingMovementGenerator<Creature>
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ void PathGenerator::BuildPointPath(const float* startPoint, const float* endPoin
|
|||
}
|
||||
|
||||
// Special case with start and end positions very close to each other
|
||||
if (_polyLength == 1 && pointCount == 1)
|
||||
if (_polyLength == 1 && pointCount == 1 && !(dtResult & DT_SLOPE_TOO_STEEP))
|
||||
{
|
||||
// First point is start position, append end position
|
||||
dtVcopy(&pathPoints[1 * VERTEX_SIZE], endPoint);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue