Core/MMaps: Do not allow creatures that cant fly to take off the land, even when building shorcut paths.

This commit is contained in:
Subv committed 2012-08-22 17:47:58 -05:00
1 parent 4273690478
commit c3f75cdf1d
5 files changed
+20 -9

No files matched your search

+1 -1
View File
@@ -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();
}
@@ -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;
}
@@ -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()
{
@@ -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))
@@ -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