Zappa Posted September 21, 2013 Posted September 21, 2013 (edited) Put this just after your class extends script declaration (replace names and coordinates with your own): ArrayList<Position> toMine = new ArrayList(); public static Position[] MinePos = { new Position(2845, 2961, 0), new Position(2831, 2969, 0), new Position(2827, 2981, 0), new Position(2823, 2998, 0) }; Put this in your onStart(); statement: loadPath(this.toMine, MinePos); Put this after your onStart(); statement: private void doWalk(ArrayList<Position> posList) throws InterruptedException { for (Iterator localIterator = posList.iterator(); localIterator .hasNext(); this.client.getMyPlayer().isMoving()) { Position pos = (Position) localIterator.next(); walkMiniMap(pos); sleep(1300 + random(600)); } } private void loadPath(ArrayList<Position> list, Position[] pos) { for (Position path : pos) list.add(path); } Put this wherever you want to execute the walk: try { doWalk(this.toMine); } catch (Exception localException) { } Edited September 28, 2013 by Zappa 2
Jordan Posted September 28, 2013 Posted September 28, 2013 I've been thinking of making a script and I might use this is thats all good w/you?
Zappa Posted September 28, 2013 Author Posted September 28, 2013 I've been thinking of making a script and I might use this is thats all good w/you? Yea man! That is why it is in the snippet section!
Cory Posted October 16, 2013 Posted October 16, 2013 This is a pretty bad path walking implementation... 1. - only supports 1 way walking 2. - only works if you start from the first position in the path 3. - you end up storing the exact same path twice... pointless? Something along the lines of; /** * * Walks through an array of tiles to reach the destination * * @param reverse whether we're going through the tiles in reverse. * @param distance the distance threshold of the destination. * @param path the tiles that we wish to traverse through * @return whether the tiles has been traversed (1), whether the tiles are currently being traversed (0), whether there was an error traversing a tile (-1) or whether the tiles cannot be traversed (-2). * @throws InterruptedException */ public int walk(boolean reverse, int distance, Position... path) throws InterruptedException { if(distance(path[path.length-1]) <= distance && !reverse) return 1; if(distance(path[0]) <= distance && reverse) return 1; for(int i = reverse ? 0 : path.length-1; reverse ? i < path.length : i >= 0; i += reverse ? 1 : -1) { if(path[i] == null || distance(path[i]) <= distance) return -1; if((distance(path[i]) <= 18) || i == (reverse ? path.length-1 : 0)) { if(!canReach(path[i])) { if(doorHandler.handleNextObstacle(path[i]) == -1) return -2; } else walk(path[i]); return 0; } } return -2; } Would be much better.
Zappa Posted October 16, 2013 Author Posted October 16, 2013 This is a pretty bad path walking implementation... 1. - only supports 1 way walking 2. - only works if you start from the first position in the path 3. - you end up storing the exact same path twice... pointless? Something along the lines of; /** * * Walks through an array of tiles to reach the destination * * @param reverse whether we're going through the tiles in reverse. * @param distance the distance threshold of the destination. * @param path the tiles that we wish to traverse through * @return whether the tiles has been traversed (1), whether the tiles are currently being traversed (0), whether there was an error traversing a tile (-1) or whether the tiles cannot be traversed (-2). * @throws InterruptedException */ public int walk(boolean reverse, int distance, Position... path) throws InterruptedException { if(distance(path[path.length-1]) <= distance && !reverse) return 1; if(distance(path[0]) <= distance && reverse) return 1; for(int i = reverse ? 0 : path.length-1; reverse ? i < path.length : i >= 0; i += reverse ? 1 : -1) { if(path[i] == null || distance(path[i]) <= distance) return -1; if((distance(path[i]) <= 18) || i == (reverse ? path.length-1 : 0)) { if(!canReach(path[i])) { if(doorHandler.handleNextObstacle(path[i]) == -1) return -2; } else walk(path[i]); return 0; } } return -2; } Would be much better. Yea, this post is old. I have learned a lot since then haha. I basically made that when I first started scripting.