bool SetNextWaypoint(uint pointId, bool setPosition, bool resetWaypointsOnFail) { if (!WaypointList.Empty()) { WaypointList.Clear(); } FillPointMovementListForCreature(); if (WaypointList.Empty()) { return(false); } int size = WaypointList.Count; Escort_Waypoint waypoint; do { waypoint = WaypointList.First(); WaypointList.RemoveAt(0); if (waypoint.Id == pointId) { if (setPosition) { me.UpdatePosition(waypoint.X, waypoint.Y, waypoint.Z, me.GetOrientation()); } CurrentWPIndex = 0; return(true); } }while (!WaypointList.Empty()); // we failed. // we reset the waypoints in the start; if we pulled any, reset it again if (resetWaypointsOnFail && size != WaypointList.Count) { if (!WaypointList.Empty()) { WaypointList.Clear(); } FillPointMovementListForCreature(); } return(false); }