OneLuckyDuck Posted June 28, 2014 Share Posted June 28, 2014 Right now I've a Position array to my destination and am iterating through it and using localwalker to walk to that tile. However, it will walk that path in reverse after finishing. Link to comment Share on other sites More sharing options...
Botre Posted June 28, 2014 Share Posted June 28, 2014 localWalker is shit 1 Link to comment Share on other sites More sharing options...
Khaleesi Posted June 28, 2014 Share Posted June 28, 2014 localWalker is shit I know xD Which method you use to walk ? Link to comment Share on other sites More sharing options...
Botre Posted June 28, 2014 Share Posted June 28, 2014 I know xD Which method you use to walk ? Not my greatest snippet :p public static boolean traversePath(Script script, Position[] path, boolean reversed, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat, long timeout) throws InterruptedException { Timer timer = new Timer(); while (!reversed ? script.map.distance(path[path.length - 1]) > 4 : script.map.distance(path[0]) > 4 && timer.getElapsed() < timeout) { PathWalkMethods.runManager(script, toggleRunOnAt, toggleRunOffAt, toggleRunOnInCombat); Position bestPosition = null; int attempts = 0; if (!reversed) { for (int i = 1; i < path.length; i++) { if (script.map.canReach(path[i])) { MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO if (mmtd != null && mmtd.isVisible()) { bestPosition = path[i]; } } } } else { for (int i = path.length - 1; i > 0; i--) { if (script.map.canReach(path[i])) { MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO if (mmtd != null && mmtd.isVisible()) { bestPosition = path[i]; } } } } if (bestPosition != null) { script.mouse.click(new MiniMapTileDestination(script.bot, bestPosition)); int failsafe = 0; while (failsafe < 10 && script.myPlayer().getPosition().distance(bestPosition) > 2) { MethodProvider.sleep(600); failsafe++; if (script.myPlayer().isMoving()) { failsafe = 0; } } return true; } else { attempts++; if (attempts > 5) { return false; } script.camera.moveYaw(script.camera.getYawAngle() + MethodProvider.random(60,80)); } } return true; } public static void runManager(Script script, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat) { if (script.settings.getRunEnergy() >= toggleRunOnAt || (toggleRunOnInCombat ? script.settings.getRunEnergy() > 0 && script.myPlayer().isUnderAttack() : false)) { script.settings.setRunning(true); } if (script.settings.getRunEnergy() <= toggleRunOffAt && (toggleRunOnInCombat ? !script.myPlayer().isUnderAttack() : true)) { script.settings.setRunning(false); } } Link to comment Share on other sites More sharing options...
todamach Posted June 28, 2014 Share Posted June 28, 2014 try tu use something like: if p = length of the array, break it Link to comment Share on other sites More sharing options...
Botre Posted June 28, 2014 Share Posted June 28, 2014 try tu use something like: if p = length of the array, break it Not needed with the kind of for loop he used. Link to comment Share on other sites More sharing options...
todamach Posted June 28, 2014 Share Posted June 28, 2014 well, but it traverses back. doesny that mean that loop oterates back to zero? Link to comment Share on other sites More sharing options...
Khaleesi Posted June 28, 2014 Share Posted June 28, 2014 Not my greatest snippet public static boolean traversePath(Script script, Position[] path, boolean reversed, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat, long timeout) throws InterruptedException { Timer timer = new Timer(); while (!reversed ? script.map.distance(path[path.length - 1]) > 4 : script.map.distance(path[0]) > 4 && timer.getElapsed() < timeout) { PathWalkMethods.runManager(script, toggleRunOnAt, toggleRunOffAt, toggleRunOnInCombat); Position bestPosition = null; int attempts = 0; if (!reversed) { for (int i = 1; i < path.length; i++) { if (script.map.canReach(path[i])) { MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO if (mmtd != null && mmtd.isVisible()) { bestPosition = path[i]; } } } } else { for (int i = path.length - 1; i > 0; i--) { if (script.map.canReach(path[i])) { MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO if (mmtd != null && mmtd.isVisible()) { bestPosition = path[i]; } } } } if (bestPosition != null) { script.mouse.click(new MiniMapTileDestination(script.bot, bestPosition)); int failsafe = 0; while (failsafe < 10 && script.myPlayer().getPosition().distance(bestPosition) > 2) { MethodProvider.sleep(600); failsafe++; if (script.myPlayer().isMoving()) { failsafe = 0; } } return true; } else { attempts++; if (attempts > 5) { return false; } script.camera.moveYaw(script.camera.getYawAngle() + MethodProvider.random(60,80)); } } return true; } public static void runManager(Script script, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat) { if (script.settings.getRunEnergy() >= toggleRunOnAt || (toggleRunOnInCombat ? script.settings.getRunEnergy() > 0 && script.myPlayer().isUnderAttack() : false)) { script.settings.setRunning(true); } if (script.settings.getRunEnergy() <= toggleRunOffAt && (toggleRunOnInCombat ? !script.myPlayer().isUnderAttack() : true)) { script.settings.setRunning(false); } } Well thats very good How do you walk to something without a path? Because thats mainly my weak point ... localwalker and map.walk are all bit glitchy and 90% of the time doesn't walk to something you want any ideas? Link to comment Share on other sites More sharing options...
todamach Posted June 28, 2014 Share Posted June 28, 2014 Khaleesi, have you tried osbot pathFinder ? i use iy for walking when i only have one point Link to comment Share on other sites More sharing options...
Botre Posted June 28, 2014 Share Posted June 28, 2014 Well thats very good How do you walk to something without a path? Because thats mainly my weak point ... localwalker and map.walk are all bit glitchy and 90% of the time doesn't walk to something you want any ideas? You'd have to write a pathfinding algorithm. http://en.wikipedia.org/wiki/Pathfinding Haven't ever needed a custom pathfinding method myself, but I might write on just for challenge of it ;D Link to comment Share on other sites More sharing options...
Khaleesi Posted June 28, 2014 Share Posted June 28, 2014 (edited) You'd have to write a pathfinding algorithm. http://en.wikipedia.org/wiki/Pathfinding Haven't ever needed a custom pathfinding method myself, but I might write on just for challenge of it ;D Ow I'll write that fast, not too hard xD hehe -_- Edited June 28, 2014 by Khaleesi 1 Link to comment Share on other sites More sharing options...
OneLuckyDuck Posted June 28, 2014 Author Share Posted June 28, 2014 Not my greatest snippet public static boolean traversePath(Script script, Position[] path, boolean reversed, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat, long timeout) throws InterruptedException { Timer timer = new Timer(); while (!reversed ? script.map.distance(path[path.length - 1]) > 4 : script.map.distance(path[0]) > 4 && timer.getElapsed() < timeout) { PathWalkMethods.runManager(script, toggleRunOnAt, toggleRunOffAt, toggleRunOnInCombat); Position bestPosition = null; int attempts = 0; if (!reversed) { for (int i = 1; i < path.length; i++) { if (script.map.canReach(path[i])) { MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO if (mmtd != null && mmtd.isVisible()) { bestPosition = path[i]; } } } } else { for (int i = path.length - 1; i > 0; i--) { if (script.map.canReach(path[i])) { MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO if (mmtd != null && mmtd.isVisible()) { bestPosition = path[i]; } } } } if (bestPosition != null) { script.mouse.click(new MiniMapTileDestination(script.bot, bestPosition)); int failsafe = 0; while (failsafe < 10 && script.myPlayer().getPosition().distance(bestPosition) > 2) { MethodProvider.sleep(600); failsafe++; if (script.myPlayer().isMoving()) { failsafe = 0; } } return true; } else { attempts++; if (attempts > 5) { return false; } script.camera.moveYaw(script.camera.getYawAngle() + MethodProvider.random(60,80)); } } return true; } public static void runManager(Script script, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat) { if (script.settings.getRunEnergy() >= toggleRunOnAt || (toggleRunOnInCombat ? script.settings.getRunEnergy() > 0 && script.myPlayer().isUnderAttack() : false)) { script.settings.setRunning(true); } if (script.settings.getRunEnergy() <= toggleRunOffAt && (toggleRunOnInCombat ? !script.myPlayer().isUnderAttack() : true)) { script.settings.setRunning(false); } } It works as well as i need it to, thank you! Link to comment Share on other sites More sharing options...
Swizzbeat Posted June 28, 2014 Share Posted June 28, 2014 Khaleesi, have you tried osbot pathFinder ? i use iy for walking when i only have one point That only works for your current region (think it's like 72 tiles?). You'd have to write a pathfinding algorithm. http://en.wikipedia.org/wiki/Pathfinding Haven't ever needed a custom pathfinding method myself, but I might write on just for challenge of it ;D You also need map data. Link to comment Share on other sites More sharing options...
Botre Posted June 28, 2014 Share Posted June 28, 2014 That only works for your current region (think it's like 72 tiles?). You also need map data. 104 tiles, no ? Link to comment Share on other sites More sharing options...
Swizzbeat Posted June 28, 2014 Share Posted June 28, 2014 104 tiles, no ? Yeah that must be it. Idk haven't worked with the map in awhile. Link to comment Share on other sites More sharing options...