Joseph Posted June 1, 2013 Posted June 1, 2013 how would i declare an Area, Path, and how would i make my player follow the path to the new area.
TheSaint Posted June 1, 2013 Posted June 1, 2013 (edited) how would i declare an Area, Path, and how would i make my player follow the path to the new area. I can't help you with pathing as I haven't looked into it, but creating an area is pretty simple. At the beginning of the script where you declare your global variables: public static Area anArea = new Area(2519, 3578, 2522, 3581); Make sure you import Area. As for how to know when your player is or is not in that area: if (anArea.contains(this.client.getMyPlayer())) { //in area //code } else { //not in area //code } Here's a visual representation of the area which that code would create: Edited June 1, 2013 by TheSaint 1
Joseph Posted June 1, 2013 Author Posted June 1, 2013 (edited) Thank you. Edited June 1, 2013 by josedpay
jelknab Posted June 1, 2013 Posted June 1, 2013 this is how I walk: public void WalkTo(String Location) throws InterruptedException { Position Pos = null; Position [] WalkPath = {}; int Radius = 8; int distance = 1000; if (Location.equals("bank")) { Pos = new Position(3271, 3167, 0); WalkPath = new Position [] { new Position(3304, 3148, 0), new Position(3282, 3151, 0), new Position(3270, 3167, 0) }; } if (Location.equals("house")) { WalkPath = new Position [] { new Position(3282, 3151, 0), new Position(3304, 3148, 0), new Position(3321, 3142, 0) }; } for (int I=0; I < WalkPath.length; I++) { if (myPlayer().getPosition().distance(WalkPath[I]) <= 2 && I < WalkPath.length-1) { Pos = WalkPath[I+1]; } else if (distance > myPlayer().getPosition().distance(WalkPath[I])) { distance = myPlayer().getPosition().distance(WalkPath[I]); Pos = WalkPath[I]; } } while (myPlayer().getPosition().distance(Pos) > 1) { distance = myPlayer().getPosition().distance(Pos); if (distance < 8) { Radius = distance; } int x = myPlayer().getPosition().getX(); assert Pos != null; int x1 = Pos.getX(); int y = myPlayer().getPosition().getY(); int y1 = Pos.getY(); double pureX = ((double) (x1 - x) / distance) * Radius; int dirX = (int)pureX; double pureY = ((double) (y1 - y) / distance) * Radius; int dirY = (int)pureY; walkMiniMap(new Position(x + dirX, y + dirY, 0)); WaitWalking(); } } public void WaitWalking() throws InterruptedException { sleep(random(150, 250)); while (myPlayer().isMoving()) { sleep(random(50, 150)); } }