I did this years ago and tweaked a bit for OSBot, some still has RS3 information, but how does the walking look
public class Navigation {
public static Script ourBot;
public Navigation(Script scriptInstance) {
ourBot = scriptInstance;
}
public enum Lodes {
Lumbridge(17);
private int id;
public int getInterfaceID(){
return id;
}
Lodes(int interfaceid) {
id = interfaceid;
}
}
final static int lodestoneInt = 1092;
final static int homeTelePortInterface = 1465;
static final int UNWALKABLE = 256 | 0x200000 | 0x40000;
public static boolean isWalkable(int flag) {
return (flag & (UNWALKABLE)) == 0;
}
//static NavPath nullNav = new NavPath();
public boolean posReach(Collection<Position> reachableCords, Position t){
Collection<Position> p = reachableCords;
for (Position c : p) {
//if(t.getX()==c.getX() && t.getY()==c.getY()){
//debug("Can reach: "+t);
// return t.isReachable();
//}
if(c.equals(t))
return true;
}
return false;
}
public boolean stepTowardsPoint(Player local, Position point, boolean forceSteps){
XClippingPlane[] clippingPlanes = ourBot.client.accessor.getClippingPlanes();
int[][] map = clippingPlanes[ourBot.myPlayer().getZ()].getTileFlags();
ourBot.client.accessor.getCurrentRegion().getTiles().toString();
ArrayList<Position> reachablePositions = new ArrayList<Position>();
ArrayList<Position> allTiles = new ArrayList<Position>();
int localX = local.getPosition().getLocalX(ourBot.bot);
int localY = local.getPosition().getLocalY(ourBot.bot);
for(int i = 0; i < map.length;i++){
for(int j = 0; j < map[i].length; j++){
if((i>(localX-20) && i<(localX+20)) && (j>(localY-20) && j<(localY+20)))
if(isWalkable(map[i][j]))
reachablePositions.add(new Position(i,j,ourBot.myPlayer().getZ()));
}
}
if(reachablePositions.size()>0) {
for(int x=-20;x<20;x++) {
for(int y=-20;y<20;y++) {
Position tPos = new Position(local.getX()+x,local.getY()+y,ourBot.myPlayer().getZ());
if(tPos.isOnMiniMap(ourBot.bot)) {
if(reachablePositions.size()>0) {
localX = tPos.getLocalX(ourBot.bot);
localY = tPos.getLocalY(ourBot.bot);
Position tLocalG = new Position(localX,localY,0);
if(reachablePositions.contains(tLocalG))
allTiles.add(tPos);
}
}
}
}
}
reachablePositions = allTiles;
ourBot.log(allTiles.toString());
int z = 2;
if(z==1)
return false;
Position bestTile = null;
if(posReach(reachablePositions, point)){
double bestDist = 999;
for(Position coord : reachablePositions){
if(!coord.equals(point))
coord = coord.translate(Script.random(-2,2), Script.random(-2,2)); //This adds differences
int tempDist = (int) coord.distance(point);
if(coord.distance(point)<=bestDist){
boolean isOnMap = coord.isOnMiniMap(ourBot.bot);
if(isOnMap){
bestTile = coord;
bestDist = tempDist;
}
}
}
} else if(forceSteps){ //Force
double bestDist = 999;
for(Position coord : reachablePositions){
coord = coord.translate(Script.random(-2,2), Script.random(-2,2));
int tempDist = (int) coord.distance(point);
if(coord.distance(point)<=bestDist){
boolean isOnMap = coord.isOnMiniMap(ourBot.bot);
if(isOnMap){
bestTile = coord;
bestDist = tempDist;
}
}
}
}
if(bestTile != null){
return ourBot.map.walking.walk(bestTile) && Sleep.sleepUntil(() -> (!local.isMoving()), 2000);
}
return false;
}