Guest User

Untitled

a guest
Jul 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. private boolean walkPath(final Tile[] path) {
  2. boolean a = false;
  3. final Tile next = getNext(path);
  4. final Tile start = getStart(path);
  5. final Tile dest = Walking.getDestination();
  6. final Tile myTile = Players.getLocal().getPosition();
  7. if ((dest == null || Calculations.distance(myTile, dest) < 6 || Calculations
  8. .distance(next, Walking.getDestination()) > 3)) {
  9. if (!Walking.walk(next)) {
  10. if (Walking.walk(start)) {
  11. Time.sleep(500);
  12. a = true;
  13. } else {
  14. walkTile(getClosestTileOnMap(next));
  15. Time.sleep(500);
  16. }
  17. } else {
  18. Time.sleep(500);
  19. a = true;
  20. }
  21. }
  22. return a;
  23. }
  24.  
  25. private Tile getClosestTileOnMap(final Tile tile) {
  26. if (Game.isLoggedIn()) {
  27. final Tile loc = Players.getLocal().getPosition();
  28. final Tile walk = new Tile((loc.getX() + tile.getX()) / 2,
  29. (loc.getY() + tile.getY()) / 2, Game.getPlane());
  30. return Calculations.distance(loc, walk) < 15 ? walk
  31. : getClosestTileOnMap(walk);
  32. }
  33. return tile;
  34. }
  35.  
  36. private boolean walkTile(final Tile tile) {
  37. if ((Walking.getDestination() == null || (Calculations.distance(Players
  38. .getLocal().getPosition(), Walking.getDestination()) < 6 && Calculations
  39. .distance(tile, Walking.getDestination()) > 3))) {
  40. Time.sleep(500);
  41. if (tile.isOnScreen()) {
  42. return tile.click(true);
  43. } else if (Calculations.distance(Players.getLocal().getPosition(),
  44. tile) < 15) {
  45. return Walking.walk(tile);
  46. } else {
  47. return walkTile(getClosestTileOnMap(tile));
  48. }
  49. }
  50. return false;
  51. }
  52.  
  53. private Tile getStart(final Tile[] tiles) {
  54. return tiles[0];
  55. }
  56.  
  57. private Tile getNext(final Tile[] tiles) {
  58. for (int i = tiles.length - 1; i >= 0; --i) {
  59. if (Calculations.distance(Players.getLocal().getPosition(),
  60. tiles[i]) < 15) {
  61. return tiles[i];
  62. }
  63. }
  64. return null;
  65. }
Add Comment
Please, Sign In to add comment