Пример #1
0
 public static bool Approach(Location location, int distance)
 {
     var timeout = new Ticker(6000);
     double num2 = location.DistanceToSelf;
     MoveHelper.StopMove();
     location.Face();
     FlyingEngine.Navigator.Start();
     FlyingEngine.Navigator.SetDestination(location);
     while (location.DistanceToSelf2D > distance)
     {
         if (timeout.IsReady)
         {
             FlyingEngine.Navigator.Stop();
             return false;
         }
         if (location.DistanceToSelf < num2)
         {
             num2 = location.DistanceToSelf;
             timeout.Reset();
         }
         if (location.DistanceToSelf < distance)
         {
             FlyingEngine.Navigator.Stop();
         }
         Thread.Sleep(10);
     }
     FlyingEngine.Navigator.Stop();
     Descent();
     return true;
 }
Пример #2
0
 /// <summary>
 ///   Moves in 3D
 /// </summary>
 /// <param name = "targetCoord">The target coord.</param>
 /// <param name="zMaxAvoidiance"></param>
 public static void Move3D(Location targetCoord, int zMaxAvoidiance)
 {
     var targetGLoc = new Location(targetCoord.X, targetCoord.Y, targetCoord.Z);
     if (!targetCoord.IsFacing(0.3f))
     {
         targetGLoc.Face();
     }
     if (targetCoord.Z - ObjectManager.MyPlayer.Location.Z > zMaxAvoidiance) //go up
     {
         KeyHelper.ReleaseKey("X");
         KeyHelper.PressKey("Space");
     }
     else if (targetCoord.Z - ObjectManager.MyPlayer.Location.Z < -zMaxAvoidiance) //go down
     {
         KeyHelper.ReleaseKey("Space");
         KeyHelper.PressKey("X");
     }
     else
     {
         KeyHelper.ReleaseKey("Space");
         KeyHelper.ReleaseKey("X");
     }
 }
Пример #3
0
 /// <summary>
 ///   Moves to the location
 /// </summary>
 /// <param name = "targetObject">The target object.</param>
 /// <param name = "distance">The distance.</param>
 /// <param name = "continueMove"></param>
 /// <param name = "breakOnCombat"></param>
 /// <returns></returns>
 public static bool MoveToLoc(Location targetObject, double distance, bool continueMove, bool breakOnCombat)
 {
     Location oldPos = ObjectManager.MyPlayer.Location;
     var timer = new Ticker(1000*1.1);
     var timerWaypoint = new Ticker(1000*30);
     int stuck = 0;
     while (targetObject.DistanceToSelf > distance && !timerWaypoint.IsReady)
     {
         targetObject.Face();
         Forwards(true);
         if (ObjectManager.MyPlayer.Location.GetDistanceTo(oldPos) > 1)
         {
             oldPos = ObjectManager.MyPlayer.Location;
             timer.Reset();
         }
         if (breakOnCombat && ObjectManager.GetAttackers.Count != 0 && ObjectManager.ShouldDefend)
         {
             Forwards(false);
             return false;
         }
         Forwards(true);
         if (ObjectManager.MyPlayer.Location.GetDistanceTo(oldPos) < 1 && timer.IsReady)
         {
             if (stuck > 3)
                 return false;
             Logging.Write("[Move]I am stuck " + stuck);
             switch (stuck)
             {
                 case 0:
                     Forwards(false);
                     Forwards(true);
                     Thread.Sleep(50);
                     Jump();
                     Thread.Sleep(800);
                     break;
                 case 1:
                     Forwards(false);
                     Forwards(true);
                     StrafeLeft(true);
                     Thread.Sleep(800);
                     break;
                 case 2:
                     Forwards(false);
                     Forwards(true);
                     StrafeLeft(true);
                     Thread.Sleep(800);
                     break;
                 case 3:
                     Forwards(false);
                     Forwards(true);
                     StrafeRight(true);
                     Thread.Sleep(800);
                     break;
             }
             Thread.Sleep(200);
             stuck++;
             ReleaseKeys();
             Thread.Sleep(500);
             timer.Reset();
         }
         Thread.Sleep(10);
     }
     if (timerWaypoint.IsReady && targetObject.DistanceToSelf > distance)
     {
         Logging.Write("Approach: " + targetObject + " failed");
         Forwards(false);
         return false;
     }
     if (!continueMove)
     {
         Forwards(false);
         ReleaseKeys();
     }
     targetObject.Face();
     return true;
 }