protected override void DoEnter(WowPlayer Entity) { //if travel path is not defined then generate from location points if (TravelPath == null) { //get current and destination as ppather locations var currentLocation = new Location(Entity.Location.X, Entity.Location.Y, Entity.Location.Z); var destinationLocation = new Location(Destination.X, Destination.Y, Destination.Z); //calculate and store travel path TravelPath = ProcessManager.Caronte.CalculatePath(currentLocation, destinationLocation); //TravelPath.locations = new List<Location>(TravelPath.locations.Distinct<Location>()); } //if there are locations then set first waypoint if (TravelPath.locations.Count > 0) { CurrentWaypoint = TravelPath.RemoveFirst(); //Entity.Face(new Vector3D(CurrentWaypoint.X, CurrentWaypoint.Y, CurrentWaypoint.Z)); _LastDistance = WaypointVector3DHelper.Vector3DToLocation(Entity.Location).GetDistanceTo(CurrentWaypoint); //if the distance to the next waypoint is less then 1f, use the get next waypoint method if (_LastDistance < 3f) { CurrentWaypoint = GetNextWayPoint(); _LastDistance = WaypointVector3DHelper.Vector3DToLocation(Entity.Location).GetDistanceTo(CurrentWaypoint); } } }
protected override void DoExecute(WowPlayer Entity) { //on execute, first verify we have a waypoit to follow, else exit if (CurrentWaypoint == null) { Exit(Entity); return; } //verify we are moving, if we aren't then start moving if (!Entity.IsMoving()) { Entity.MoveForward(); } //get distances to waypoint float fDistance = MathFuncs.GetDistance( WaypointVector3DHelper.LocationToVector3D(CurrentWaypoint), Entity.Location, false); //if distance is growing instead of shrinking them face again if (fDistance > _LastDistance) { Entity.Face(new Vector3D(CurrentWaypoint.X, CurrentWaypoint.Y, CurrentWaypoint.Z)); } //if distance to current waypoint is less then / equal to our tolerance, then move to the next waypoint if it exists, else stop/finish. if (fDistance <= Tolerance) { //if another waypoint exists, then switch to it if (TravelPath.GetFirst() != null) { CurrentWaypoint = TravelPath.RemoveFirst(); Entity.Face(new Vector3D(CurrentWaypoint.X, CurrentWaypoint.Y, CurrentWaypoint.Z)); } else { Exit(Entity); Finish(Entity); } } _LastDistance = fDistance; }
protected override void DoEnter(WowPlayer Entity) { //if travel path is not defined then generate from location points if (TravelPath == null) { //get current and destination as ppather locations Location currentLocation = new Location(Entity.Location.X, Entity.Location.Y, Entity.Location.Z); Location destinationLocation = new Location(Destination.X, Destination.Y, Destination.Z); //calculate and store travel path TravelPath = ProcessManager.Caronte.CalculatePath(currentLocation, destinationLocation); } //if there are locations then set first waypoint if (TravelPath.locations.Count > 0) { CurrentWaypoint = TravelPath.RemoveFirst(); Entity.Face(new Vector3D(CurrentWaypoint.X, CurrentWaypoint.Y, CurrentWaypoint.Z)); _LastDistance = WaypointVector3DHelper.Vector3DToLocation(Entity.Location).GetDistanceTo(CurrentWaypoint); } }
protected Location GetNextWayPoint() { Location Next = null; //get the next waypoint // The only criteria is that the next waypoint be at least 3 yards away from current // if all fail then skip to end while (TravelPath.GetFirst() != null) { //get next waypoint and remove it from the list at the same time Next = TravelPath.RemoveFirst(); //check distance to the waypoint float distance = CurrentWaypoint.GetDistanceTo(Next); //if distance greater then 3f then return this waypoint if (distance > 10f) { break; } } return(Next); }