Guest Apogee Posted June 1, 2014 Share Posted June 1, 2014 (edited) Is this deprecated? .____. What's the new alternative? -Please- tell me i don't have to bother with WalkingEvent's Edited June 1, 2014 by Bitter Link to comment Share on other sites More sharing options...
Swizzbeat Posted June 1, 2014 Share Posted June 1, 2014 (edited) import org.osbot.rs07.api.map.Position; import org.osbot.rs07.input.mouse.MiniMapTileDestination; import org.osbot.rs07.script.Script; /** * Created with IntelliJ IDEA * User: Anthony * Date: 5/31/2014 */ public class Walker { private final Script sI; public Walker(final Script sI) { this.sI = sI; } public boolean walkPath(final Position[] path) throws InterruptedException { return walkPath(path, 3); } public boolean walkPath(final Position[] path, int skipDist) throws InterruptedException { final Position nextTile = getNextTile(path, skipDist); if (nextTile != null) { if (sI.map.canReach(nextTile)) { clickMiniMapPosition(nextTile); } else { handleObstacleForPosition(nextTile); } } return path[path.length - 1].distance(sI.myPlayer()) < skipDist; } private Position getNextTile(final Position path[], int skipDist) { int dist = -1, closest = -1; for (int i = path.length - 1; i >= 0; i--) { Position tile = path[i]; int d = sI.map.distance(tile); if (d < dist || dist == -1) { dist = d; closest = i; } } int feasibleTileIndex = -1; for (int i = closest; i < path.length; i++) { if (sI.map.distance(path[i]) <= skipDist) { feasibleTileIndex = i; } else { break; } } return (feasibleTileIndex == -1) ? null : path[feasibleTileIndex]; } public Position[] reversePath(final Position[] path) { Position[] reversedPath = new Position[path.length]; for (int i = 0; i < reversedPath.length; i++) { reversedPath[i] = path[path.length - i - 1]; } return reversedPath; } private boolean clickMiniMapPosition(final Position position) throws InterruptedException { return sI.mouse.click(new MiniMapTileDestination(sI.bot, position)); } private boolean handleObstacleForPosition(final Position position) { return sI.doorHandler.handleNextObstacle(position); } } I ported over a walking snippet I had laying around. Haven't tested it yet so it may need some tweaking. Edited June 1, 2014 by Swizzbeat Link to comment Share on other sites More sharing options...
Guest Apogee Posted June 1, 2014 Share Posted June 1, 2014 import org.osbot.rs07.api.map.Position; import org.osbot.rs07.input.mouse.MiniMapTileDestination; import org.osbot.rs07.script.Script; /** * Created with IntelliJ IDEA * User: Anthony * Date: 5/31/2014 */ public class Walker { private final Script sI; public Walker(final Script sI) { this.sI = sI; } public boolean walkPath(final Position[] path) throws InterruptedException { return walkPath(path, 3); } public boolean walkPath(final Position[] path, int skipDist) throws InterruptedException { final Position nextTile = getNextTile(path, skipDist); if (nextTile != null) { if (sI.map.canReach(nextTile)) { clickMiniMapPosition(nextTile); } else { handleObstacleForPosition(nextTile); } } return path[path.length - 1].distance(sI.myPlayer()) < skipDist; } private Position getNextTile(final Position path[], int skipDist) { int dist = -1, closest = -1; for (int i = path.length - 1; i >= 0; i--) { Position tile = path[i]; int d = sI.map.distance(tile); if (d < dist || dist == -1) { dist = d; closest = i; } } int feasibleTileIndex = -1; for (int i = closest; i < path.length; i++) { if (sI.map.distance(path[i]) <= skipDist) { feasibleTileIndex = i; } else { break; } } return (feasibleTileIndex == -1) ? null : path[feasibleTileIndex]; } public Position[] reversePath(final Position[] path) { Position[] reversedPath = new Position[path.length]; for (int i = 0; i < reversedPath.length; i++) { reversedPath[i] = path[path.length - i - 1]; } return reversedPath; } private boolean clickMiniMapPosition(final Position position) throws InterruptedException { return sI.mouse.click(new MiniMapTileDestination(sI.bot, position)); } private boolean handleObstacleForPosition(final Position position) { return sI.doorHandler.handleNextObstacle(position); } } Thanks swizz. I'll try to pick this apart until i understand most of the mapping api. Link to comment Share on other sites More sharing options...
Eliot Posted June 1, 2014 Share Posted June 1, 2014 Check this out: MiniMapTileDestination(Bot bot, Position position) Creates an instance of this mouse destination for a tile displayed on the minimap. Link to comment Share on other sites More sharing options...
Botre Posted June 1, 2014 Share Posted June 1, 2014 You need to make the mouse move to a minimap mouse estination Link to comment Share on other sites More sharing options...
Joseph Posted June 1, 2014 Share Posted June 1, 2014 Look in the map or local walking class Link to comment Share on other sites More sharing options...
PolishCivil Posted June 1, 2014 Share Posted June 1, 2014 1 tile is 4x4 pixels The green rect is where we usually click on map, except red run button cuz it will turn on run instead walk.Your player is always on center of this minimap, so my green thing is 150x154 (~38x~39 in tiles).So your max clickable distance on this map from player is 38/2 = 19 in tiles width and 19,5 in tiles height.So if you want to click on minimap your distance to dest cant be more than ~19 (safest one is 14 cuz it excludes run button).The other way is to make ellipse around minimap: So the code will looks like: And then you loop positions while they are on map or otherwise if you are looping starting from fahrest ones. 1 Link to comment Share on other sites More sharing options...
Th3 Posted June 2, 2014 Share Posted June 2, 2014 1 tile is 4x4 pixels The green rect is where we usually click on map, except red run button cuz it will turn on run instead walk. Your player is always on center of this minimap, so my green thing is 150x154 (~38x~39 in tiles). So your max clickable distance on this map from player is 38/2 = 19 in tiles width and 19,5 in tiles height. So if you want to click on minimap your distance to dest cant be more than ~19 (safest one is 14 cuz it excludes run button). The other way is to make ellipse around minimap: So the code will looks like: And then you loop positions while they are on map or otherwise if you are looping starting from fahrest ones. Why no polygon instead? Link to comment Share on other sites More sharing options...
PolishCivil Posted June 3, 2014 Share Posted June 3, 2014 Why no polygon instead? Cuz i love ellipses. 1 Link to comment Share on other sites More sharing options...