January 21, 20179 yr Is there any way i could use LocalPathFinder to find a path to target by ignoring obstacles etc ?
January 21, 20179 yr 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);
January 21, 20179 yr Author 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 ?
January 21, 20179 yr Could you give me an example of modifiedflag for ignoring object ? 0 is a walkable tile flag
January 21, 20179 yr 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
January 21, 20179 yr Author 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, 20179 yr by Ayylmao420
January 21, 20179 yr 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;
January 21, 20179 yr 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
January 21, 20179 yr Author 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, 20179 yr by Ayylmao420
Create an account or sign in to comment