Dreamliner Posted February 19, 2014 Share Posted February 19, 2014 (edited) public void walkTowardPosition(Position p) throws InterruptedException { if (this.myPlayer().getPosition().distance(p) > 15) { int d = random(12, 16); double scale = (double) d / this.myPlayer().getPosition().distance(p); Position mypos = this.myPosition(); int dx = p.getX() - mypos.getX(), dy = p.getY() - mypos.getY(); int x = mypos.getX() + (int) (dx * scale), y = mypos.getY() + (int) (dy * scale); Position dest = new Position(x, y, mypos.getZ()); MouseDestination md = new MinimapTileDestination(this.bot, dest); if (!this.client.getDestination().equals(dest)) { this.client.moveMouseTo(md, false, true, false); } if (this.myPlayer().isMoving()) { int degrees = (int) Math.atan2(dy, dx); this.client.rotateCameraToAngle(degrees); } sleep(random(600, 1200)); } else { MouseDestination md = new MinimapTileDestination(this.bot, p); if (!this.client.getDestination().equals(p)) { this.client.moveMouseTo(md, false, true, false); } } }I found myself needing to check for objects while I was walking (performance reasons) so I created this.Basically it projects your position on a straight line and tries to traverse it in increments of 12-16 tile intervals (size of minimap) Works pretty flawlessly. Edit: it may be confusing, but this must be called a bunch of times to work. It basically clicks in the spot on the minimap that it calculates when it's called. Edited February 19, 2014 by dreamliner Link to comment Share on other sites More sharing options...
Meditation4u Posted February 19, 2014 Share Posted February 19, 2014 Nice work!! Link to comment Share on other sites More sharing options...