Ayylmao420 Posted January 21, 2017 Share Posted January 21, 2017 Is there any way i could use LocalPathFinder to find a path to target by ignoring obstacles etc ? Quote Link to comment Share on other sites More sharing options...
Abuse Posted January 21, 2017 Share Posted January 21, 2017 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); 1 Quote Link to comment Share on other sites More sharing options...
Ayylmao420 Posted January 21, 2017 Author Share Posted January 21, 2017 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 ? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted January 21, 2017 Share Posted January 21, 2017 Could you give me an example of modifiedflag for ignoring object ? 0 is a walkable tile flag 2 Quote Link to comment Share on other sites More sharing options...
Abuse Posted January 21, 2017 Share Posted January 21, 2017 Could you give me an example of modifiedflag for ignoring object ? 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 1 Quote Link to comment Share on other sites More sharing options...
Ayylmao420 Posted January 21, 2017 Author Share Posted January 21, 2017 (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 So all i have to do is loop through object, get their position and change their flags to 0 to ignore those tiles? Edited January 21, 2017 by Ayylmao420 Quote Link to comment Share on other sites More sharing options...
FrostBug Posted January 21, 2017 Share Posted January 21, 2017 So all i have to do is loop through object, get their position and change their flags to 0 to ignore those tiles? Pretty much, yes. I think you should be able to do: modifiedFlags[objToRemove.getLocalY()][objToRemove.getLocalX()] = 0; 1 Quote Link to comment Share on other sites More sharing options...
Abuse Posted January 21, 2017 Share Posted January 21, 2017 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 1 Quote Link to comment Share on other sites More sharing options...
Ayylmao420 Posted January 21, 2017 Author Share Posted January 21, 2017 (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 January 21, 2017 by Ayylmao420 Quote Link to comment Share on other sites More sharing options...