Jump to content

LocalPathFinder


Recommended Posts

Posted

You can pass flags to it after filtering through getMap().getRegion().getClippingPlanes()[myPosition.getZ()].getTileFlags();

        int[][] originalFlags = getMap().getRegion().getClippingPlanes()[self.myPosition().getZ()].getTileFlags();
        int[][] modifiedFlags = new int[originalFlags.length][originalFlags.length];
        pathFinder = new LocalPathFinder(getBot());
       
        for (int x = 0; x < originalFlags.length; x++) {
            for (int y = 0; y < originalFlags.length; y++) {
                int originalFlag = originalFlags[x][y];
                /* modify originalFlag flag here */     
                modifiedFlags[x][y] = originalFlag;
            }
        }
        pathFinder.findPath(targetPosition, modifiedFlags);
  • Like 1
Posted

 

You can pass flags to it after filtering through getMap().getRegion().getClippingPlanes()[myPosition.getZ()].getTileFlags();

        int[][] originalFlags = getMap().getRegion().getClippingPlanes()[self.myPosition().getZ()].getTileFlags();
        int[][] modifiedFlags = new int[originalFlags.length][originalFlags.length];
        pathFinder = new LocalPathFinder(getBot());
       
        for (int x = 0; x < originalFlags.length; x++) {
            for (int y = 0; y < originalFlags.length; y++) {
                int originalFlag = originalFlags[x][y];
                /* modify originalFlag flag here */     
                modifiedFlags[x][y] = originalFlag;
            }
        }
        pathFinder.findPath(targetPosition, modifiedFlags);

Could you give me an example of modifiedflag for ignoring object ?

Posted (edited)

1 = cannot enter from west

2 = cannot enter from east

4 = cannot enter from north

8 = cannot enter from south

Cannot enter from west and east = 1 | 2

Cannot enter from west, east and north = 1 | 2 | 4

etc smile.png

 

So all i have to do is loop through object, get their position and change their flags to 0 to ignore those tiles?

Edited by Ayylmao420
Posted (edited)

Be careful when setting flags to zero though, the pathfinder will see it as a tile that can be accessed from all directions, so might end up generating a unwalkable path

Alright, thanks for the help guys.

 

EDIT:/

I just figured out that for some reason when i do this;

	        for (RS2Object object : getObjects().getAll()) {
	        	if (object.getName().equals("Large door")) {
	        		modifiedFlags[object.getLocalX()][object.getLocalY()] = 0;
	        	}
	        }

It'll work for doors, gates but for some reason it doesn't work with large doors, any ideas ?

Edited by Ayylmao420

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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