Is the simple task of walking to a tile using OSBot frustrating to anyone else? Maybe I'm using the wrong walking method that everyone else uses but my bots often just stand around when telling it to walk to a tile. I think this is because OSBot will not move if you tell it to walk to a tile that isn't in the loaded area or if the tile is unreachable. I've tried walk(), walkExact(), walkMinimap(), walkMainScreen() and I think they all require a loaded and reachable tile. Is there a reason for this? It's frustrating and I've resorted to using paths for everything which is annoying. I don't know about everyone else, but I'm used to the ability of specifying any tile and having the bot actually move towards it.
So here's a simple method that takes a step in the direction of the specified tile even if it's unreachable or unloaded. Using it in the script's loop will cause it to repeatedly take steps until it reaches the destination tile. It walks in a straight line so maybe it's not the best in terms of bot detection.
public boolean blindWalk(Position position) {
final int STEP_SIZE = 15;
Player myPlayer = client.getMyPlayer();
try {
if (position.distance(myPlayer.getPosition()) < STEP_SIZE) {
return client.moveMouseTo(new MinimapTileDestination(bot, position), false, true, false);
}
int myX = myPlayer.getX();
int myY = myPlayer.getY();
int posX = position.getX();
int posY = position.getY();
double deltaX = Math.abs(posX - myX);
double deltaY = Math.abs(posY - myY);
double angle = Math.atan(deltaY / deltaX);
int xModifier = posX < myX ? -1 : 1;
int yModifier = posY < myY ? -1 : 1;
Position newPosition = new Position(myX + (int)(Math.cos(angle) * STEP_SIZE) * xModifier, myY + (int)(Math.sin(angle) * STEP_SIZE) * yModifier, 0);
return client.moveMouseTo(new MinimapTileDestination(bot, newPosition), false, true, false);
}
catch (Exception e) {
return false;
}
}