Guest Apogee Posted June 1, 2014 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
Swizzbeat Posted June 1, 2014 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
Guest Apogee Posted June 1, 2014 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.
Eliot Posted June 1, 2014 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.
Botre Posted June 1, 2014 Posted June 1, 2014 You need to make the mouse move to a minimap mouse estination
PolishCivil Posted June 1, 2014 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
Th3 Posted June 2, 2014 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?