Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private boolean walkPath(final Tile[] path) {
- boolean a = false;
- final Tile next = getNext(path);
- final Tile start = getStart(path);
- final Tile dest = Walking.getDestination();
- final Tile myTile = Players.getLocal().getPosition();
- if ((dest == null || Calculations.distance(myTile, dest) < 6 || Calculations
- .distance(next, Walking.getDestination()) > 3)) {
- if (!Walking.walk(next)) {
- if (Walking.walk(start)) {
- Time.sleep(500);
- a = true;
- } else {
- walkTile(getClosestTileOnMap(next));
- Time.sleep(500);
- }
- } else {
- Time.sleep(500);
- a = true;
- }
- }
- return a;
- }
- private Tile getClosestTileOnMap(final Tile tile) {
- if (Game.isLoggedIn()) {
- final Tile loc = Players.getLocal().getPosition();
- final Tile walk = new Tile((loc.getX() + tile.getX()) / 2,
- (loc.getY() + tile.getY()) / 2, Game.getPlane());
- return Calculations.distance(loc, walk) < 15 ? walk
- : getClosestTileOnMap(walk);
- }
- return tile;
- }
- private boolean walkTile(final Tile tile) {
- if ((Walking.getDestination() == null || (Calculations.distance(Players
- .getLocal().getPosition(), Walking.getDestination()) < 6 && Calculations
- .distance(tile, Walking.getDestination()) > 3))) {
- Time.sleep(500);
- if (tile.isOnScreen()) {
- return tile.click(true);
- } else if (Calculations.distance(Players.getLocal().getPosition(),
- tile) < 15) {
- return Walking.walk(tile);
- } else {
- return walkTile(getClosestTileOnMap(tile));
- }
- }
- return false;
- }
- private Tile getStart(final Tile[] tiles) {
- return tiles[0];
- }
- private Tile getNext(final Tile[] tiles) {
- for (int i = tiles.length - 1; i >= 0; --i) {
- if (Calculations.distance(Players.getLocal().getPosition(),
- tiles[i]) < 15) {
- return tiles[i];
- }
- }
- return null;
- }
Add Comment
Please, Sign In to add comment