Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static Vector3 _lastDesination = new Vector3(0, 0, 0);
- private static DateTime _startMoving = new DateTime();
- private static float _distanceToTravel = 0;
- private static int _stuckLevel = 0;
- private static void StuckCheck(Vector3 destination)
- {
- if (destination.Distance(_lastDesination) > 10)
- {
- _lastDesination = destination;
- _startMoving = DateTime.Now;
- _distanceToTravel = GigaRift.Me.Location.Distance(destination);
- _stuckLevel = 0;
- }
- else
- {
- TimeSpan movementDuration = DateTime.Now - _startMoving;
- if (movementDuration.Seconds > 5 && Math.Abs(_distanceToTravel - GigaRift.Me.Location.Distance(destination)) < 5)
- {
- // obviously this needs to be in a stuck handler...
- Logging.Write("Stuck.");
- switch (_stuckLevel)
- {
- case 1:
- Logging.WriteDiagnostic("Jump forward.");
- InputManager.KeyDown(System.Windows.Forms.Keys.W);
- InputManager.PressKey(System.Windows.Forms.Keys.Space);
- InputManager.KeyUp(System.Windows.Forms.Keys.W);
- InputManager.KeyDown(System.Windows.Forms.Keys.W);
- InputManager.PressKey(System.Windows.Forms.Keys.Space);
- InputManager.KeyUp(System.Windows.Forms.Keys.W);
- break;
- case 2:
- Logging.WriteDiagnostic("Jump left.");
- InputManager.KeyDown(System.Windows.Forms.Keys.Q);
- InputManager.PressKey(System.Windows.Forms.Keys.Space);
- InputManager.KeyUp(System.Windows.Forms.Keys.Q);
- InputManager.KeyDown(System.Windows.Forms.Keys.Q);
- InputManager.PressKey(System.Windows.Forms.Keys.Space);
- InputManager.KeyUp(System.Windows.Forms.Keys.Q);
- break;
- case 3:
- Logging.WriteDiagnostic("Jump right.");
- InputManager.KeyDown(System.Windows.Forms.Keys.E);
- InputManager.PressKey(System.Windows.Forms.Keys.Space);
- InputManager.KeyUp(System.Windows.Forms.Keys.E);
- InputManager.KeyDown(System.Windows.Forms.Keys.E);
- InputManager.PressKey(System.Windows.Forms.Keys.Space);
- InputManager.KeyUp(System.Windows.Forms.Keys.E);
- break;
- case 4:
- Logging.WriteDiagnostic("Jump forward again.");
- InputManager.KeyDown(System.Windows.Forms.Keys.W);
- InputManager.PressKey(System.Windows.Forms.Keys.Space);
- InputManager.KeyUp(System.Windows.Forms.Keys.W);
- InputManager.KeyDown(System.Windows.Forms.Keys.W);
- InputManager.PressKey(System.Windows.Forms.Keys.Space);
- InputManager.KeyUp(System.Windows.Forms.Keys.W);
- break;
- case 5:
- Logging.WriteDiagnostic("Stuck for 30 seconds. Exit application.");
- Application.Exit();
- break;
- };
- _stuckLevel++;
- _startMoving = DateTime.Now;
- }
- }
- }
Add Comment
Please, Sign In to add comment