Jump to content

LocalPathFinder


Ayylmao420

Recommended Posts

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

 

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 ?

Link to comment
Share on other sites

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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