daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Jan 13th, 2018 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private static Vector3 _lastDesination = new Vector3(0, 0, 0);
  2. private static DateTime _startMoving = new DateTime();
  3. private static float _distanceToTravel = 0;
  4. private static int _stuckLevel = 0;
  5.  
  6. private static void StuckCheck(Vector3 destination)
  7. {
  8.     if (destination.Distance(_lastDesination) > 10)
  9.     {
  10.         _lastDesination = destination;
  11.         _startMoving = DateTime.Now;
  12.         _distanceToTravel = GigaRift.Me.Location.Distance(destination);
  13.         _stuckLevel = 0;
  14.     }
  15.     else
  16.     {
  17.         TimeSpan movementDuration = DateTime.Now - _startMoving;
  18.  
  19.         if (movementDuration.Seconds > 5 && Math.Abs(_distanceToTravel - GigaRift.Me.Location.Distance(destination)) < 5)
  20.         {
  21.             // obviously this needs to be in a stuck handler...
  22.             Logging.Write("Stuck.");
  23.  
  24.             switch (_stuckLevel)
  25.             {
  26.                 case 1:
  27.                     Logging.WriteDiagnostic("Jump forward.");
  28.                     InputManager.KeyDown(System.Windows.Forms.Keys.W);
  29.                     InputManager.PressKey(System.Windows.Forms.Keys.Space);
  30.                     InputManager.KeyUp(System.Windows.Forms.Keys.W);
  31.                     InputManager.KeyDown(System.Windows.Forms.Keys.W);
  32.                     InputManager.PressKey(System.Windows.Forms.Keys.Space);
  33.                     InputManager.KeyUp(System.Windows.Forms.Keys.W);
  34.                     break;
  35.  
  36.                 case 2:
  37.                     Logging.WriteDiagnostic("Jump left.");
  38.                     InputManager.KeyDown(System.Windows.Forms.Keys.Q);
  39.                     InputManager.PressKey(System.Windows.Forms.Keys.Space);
  40.                     InputManager.KeyUp(System.Windows.Forms.Keys.Q);
  41.                     InputManager.KeyDown(System.Windows.Forms.Keys.Q);
  42.                     InputManager.PressKey(System.Windows.Forms.Keys.Space);
  43.                     InputManager.KeyUp(System.Windows.Forms.Keys.Q);
  44.                     break;
  45.  
  46.                 case 3:
  47.                     Logging.WriteDiagnostic("Jump right.");
  48.                     InputManager.KeyDown(System.Windows.Forms.Keys.E);
  49.                     InputManager.PressKey(System.Windows.Forms.Keys.Space);
  50.                     InputManager.KeyUp(System.Windows.Forms.Keys.E);
  51.                     InputManager.KeyDown(System.Windows.Forms.Keys.E);
  52.                     InputManager.PressKey(System.Windows.Forms.Keys.Space);
  53.                     InputManager.KeyUp(System.Windows.Forms.Keys.E);
  54.                     break;
  55.  
  56.                 case 4:
  57.                     Logging.WriteDiagnostic("Jump forward again.");
  58.                     InputManager.KeyDown(System.Windows.Forms.Keys.W);
  59.                     InputManager.PressKey(System.Windows.Forms.Keys.Space);
  60.                     InputManager.KeyUp(System.Windows.Forms.Keys.W);
  61.                     InputManager.KeyDown(System.Windows.Forms.Keys.W);
  62.                     InputManager.PressKey(System.Windows.Forms.Keys.Space);
  63.                     InputManager.KeyUp(System.Windows.Forms.Keys.W);
  64.                     break;
  65.                 case 5:
  66.                     Logging.WriteDiagnostic("Stuck for 30 seconds.  Exit application.");
  67.                     Application.Exit();
  68.                     break;
  69.  
  70.             };
  71.             _stuckLevel++;
  72.             _startMoving = DateTime.Now;
  73.         }
  74.     }
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top