Core/Movegen: Fix logic in WaypointMovementGenerator<Creature>::StartMove

This commit is contained in:
Chaplain
2012-01-15 21:25:03 +03:00
parent f203da224e
commit 6bb48a2a87

View File

@@ -84,6 +84,7 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
// Inform script
MovementInform(creature);
creature.UpdateWaypointID(i_currentNode);
Stop(i_path->at(i_currentNode)->delay);
}
@@ -94,13 +95,11 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature &creature)
if (Stopped())
return true;
const WaypointData *node = i_path->at(i_currentNode);
if (m_isArrivalDone)
{
if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
{
creature.SetHomePosition(node->x, node->y, node->z, creature.GetOrientation());
creature.SetHomePosition(i_path->at(i_currentNode)->x, i_path->at(i_currentNode)->y, i_path->at(i_currentNode)->z, creature.GetOrientation());
creature.GetMotionMaster()->Initialize();
return false;
}
@@ -108,6 +107,8 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature &creature)
i_currentNode = (i_currentNode+1) % i_path->size();
}
const WaypointData *node = i_path->at(i_currentNode);
m_isArrivalDone = false;
creature.AddUnitState(UNIT_STAT_ROAMING_MOVE);