diff options
Diffstat (limited to 'src')
5 files changed, 20 insertions, 9 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 2ba3b4e8c06..183eddfcae4 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -373,7 +373,7 @@ bool Unit::haveOffhandWeapon() const void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath, bool forceDestination) { Movement::MoveSplineInit init(*this); - init.MoveTo(x,y,z); + init.MoveTo(x, y, z, generatePath, forceDestination); init.SetVelocity(speed); init.Launch(); } diff --git a/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.cpp index 4894b5eb841..3172deb210e 100644 --- a/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.cpp @@ -443,6 +443,8 @@ void PathFinderMovementGenerator::BuildPointPath(const float *startPoint, const for (uint32 i = 0; i < pointCount; ++i) m_pathPoints[i] = Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]); + NormalizePath(); + // first point is always our current location - we need the next one setActualEndPosition(m_pathPoints[pointCount-1]); @@ -469,6 +471,12 @@ void PathFinderMovementGenerator::BuildPointPath(const float *startPoint, const sLog->outDebug(LOG_FILTER_MAPS, "++ PathFinderMovementGenerator::BuildPointPath path type %d size %d poly-size %d\n", m_type, pointCount, m_polyLength); } +void PathFinderMovementGenerator::NormalizePath() +{ + for (uint32 i = 0; i < m_pathPoints.size(); ++i) + m_sourceUnit->UpdateAllowedPositionZ(m_pathPoints[i].x, m_pathPoints[i].y, m_pathPoints[i].z); +} + void PathFinderMovementGenerator::BuildShortcut() { sLog->outDebug(LOG_FILTER_MAPS, "++ BuildShortcut :: making shortcut\n"); @@ -482,6 +490,8 @@ void PathFinderMovementGenerator::BuildShortcut() m_pathPoints[0] = getStartPosition(); m_pathPoints[1] = getActualEndPosition(); + NormalizePath(); + m_type = PATHFIND_SHORTCUT; } diff --git a/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.h b/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.h index f4edd1a1789..5dd2ad82a0a 100644 --- a/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.h @@ -98,6 +98,8 @@ class PathFinderMovementGenerator void setStartPosition(Vector3 point) { m_startPosition = point; } void setEndPosition(Vector3 point) { m_actualEndPosition = point; m_endPosition = point; } void setActualEndPosition(Vector3 point) { m_actualEndPosition = point; } + + void NormalizePath(); void clear() { diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index 1680bfeb1d4..766fe0b8032 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -79,11 +79,7 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner) owner.AddUnitState(UNIT_STATE_CHASE); Movement::MoveSplineInit init(owner); - if (!i_target->IsInWater()) - init.MovebyPath(i_path->getPath()); - else - init.MoveTo(i_target->GetPositionX(), i_target->GetPositionY(), i_target->GetPositionZ(), false, false); - + init.MovebyPath(i_path->getPath()); init.SetWalk(((D*)this)->EnableWalking()); init.Launch(); } @@ -128,6 +124,9 @@ bool TargetedMovementGeneratorMedium<T,D>::Update(T &owner, const uint32 & time_ D::_clearUnitStateMove(owner); return true; } + + if (owner.GetTypeId() == TYPEID_UNIT && !i_target->isInAccessiblePlaceFor((const Creature*)&owner)) + return false; // prevent movement while casting spells with cast time or channel time if (owner.HasUnitState(UNIT_STATE_CASTING)) diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h index 4efde66fcd5..740914c59db 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.h +++ b/src/server/game/Movement/Spline/MoveSplineInit.h @@ -84,10 +84,10 @@ namespace Movement */ void MovebyPath(const PointsArray& path, int32 pointId = 0); - /* Initializes simple A to B mition, A is current unit's position, B is destination + /* Initializes simple A to B motion, A is current unit's position, B is destination */ - void MoveTo(const Vector3& destination, bool generatePath = false, bool forceDestination = false); - void MoveTo(float x, float y, float z, bool generatePath = false, bool forceDestination = false); + void MoveTo(const Vector3& destination, bool generatePath = true, bool forceDestination = false); + void MoveTo(float x, float y, float z, bool generatePath = true, bool forceDestination = false); /* Sets Id of fisrt point of the path. When N-th path point will be done ILisener will notify that pointId + N done * Needed for waypoint movement where path splitten into parts |