Jump to content

creating area and path


Joseph

Recommended Posts

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:

 

RM7Hnhv.png

Edited by TheSaint
  • Like 1
Link to comment
Share on other sites

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));
        }
    }
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...