QBots Posted September 29, 2013 Posted September 29, 2013 (edited) This class is simple, yet effective walking. I use it in my private scripts and it has yet to fail me. import org.osbot.script.Script; import org.osbot.script.rs2.map.Position; import java.awt.*; public class Walk { private Script script; //static public Position[] Path; private int[] distance; public Walk(Script s) { script = s; } Position[] CreatePath(int[][] path) { Position[] returnpath = new Position[path.length]; for(int i = 0; i < path.length; i++) { returnpath[i] = new Position(path[i][0], path[i][1], 0); } //Path = returnpath.clone(); return returnpath; } static int current = 0; boolean getNext(Position[] Path, boolean isCircle) { if(Path[current].distance(script.myPosition()) > 50 || current > Path.length || !script.canReach(Path[current])) { current = 0; } if(current == Path.length-1 && isCircle) { script.log("Reseting path"); current = 0; return true; } if(current+1 < Path.length && Path[current+1].distance(script.myPosition()) < 15) { current += 1; return true; } for(int i = current; i < Path.length; i++) { if(script.canReach(Path[i]) && i > current && Path[i].distance(script.client.getMyPlayer().getPosition()) < 16) { if(i+1 < Path.length && script.canReach(Path[i+1]) && Path[i+1].distance(script.myPosition()) < 16) current = i+1; else current = i; script.log("Current: "+current); script.log("Distance to current: "+Path[i].distance(script.myPosition())); } } return true; } public void WalkPath(Position[] path, boolean isCircle) throws InterruptedException { if(!script.isRunning() && script.client.getRunEnergy() > 50) { script.setRunning(true); } if(getNext(path, isCircle)) { script.walkMiniMap(path[current]); } } } Setting up this script is simple: Walk walker = new Walk(this); int[][] OuterAbyssPath = { {3017, 4823}, {3017, 4825}, {3017, 4827}, removed }; onLoop() { walker.WalkPath(walker.CreatePath(OuterAbyssPath),true); return 100; } Edited September 29, 2013 by QBots
Mystere Posted September 29, 2013 Posted September 29, 2013 Nice to see people contribute to community of Osbot ^^ Thanks
Joseph Posted September 29, 2013 Posted September 29, 2013 (edited) thanks, im try it out. edit- in this path, can you walk reverse? Edited September 29, 2013 by josedpay
QBots Posted September 29, 2013 Author Posted September 29, 2013 thanks, im try it out. edit- in this path, can you walk reverse? Ehrm, no but a reverse function is easy to write.
Dualshotty Posted October 1, 2013 Posted October 1, 2013 Looks good, I'm going to try it out, but what is the line that says "removed" after you give the coordinates for?
QBots Posted October 1, 2013 Author Posted October 1, 2013 Looks good, I'm going to try it out, but what is the line that says "removed" after you give the coordinates for? The rest of the tiles.
Mysteryy Posted October 2, 2013 Posted October 2, 2013 This is great. I was about to write my own walking methods then I was like hmm, lets see if anyone is nice enough to share theirs. Thanks man, its working great, im implementing it in a script now!
QBots Posted October 24, 2013 Author Posted October 24, 2013 Any feedback on how it works mysteryy? ;)
Joseph Posted October 24, 2013 Posted October 24, 2013 (edited) I'm getting an error, because I'm trying to implement your walking class, but when I add Walk walk = new Walk(this); I get an error for the word "this" Edited October 24, 2013 by josedpay
pitoluwa Posted November 19, 2013 Posted November 19, 2013 anyone else tested it? It comes to the end point and then goes there and back, in infinite loop...
beastlymaul Posted November 20, 2013 Posted November 20, 2013 anyone else tested it? It comes to the end point and then goes there and back, in infinite loop... I suggest not using this, there's other methods which are more efficient, plus the 2d array isn't really necessary, just adds potential confusion/problems.
pitoluwa Posted November 20, 2013 Posted November 20, 2013 anyone else tested it? It comes to the end point and then goes there and back, in infinite loop... I suggest not using this, there's other methods which are more efficient, plus the 2d array isn't really necessary, just adds potential confusion/problems. could you link me another in PM? I can't find anything else