Woody Posted June 4, 2015 Share Posted June 4, 2015 I want to map the walkable tiles in the current region and save them in a list, to use them as nodes for web walking. Anyone got an idea? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted June 4, 2015 Share Posted June 4, 2015 (edited) You can get a 2d array of tile flags by XClippingPlane[] planes = getMap().getRegion().getClippingPlanes(); each plane has a getTileFlags() getter for the int[][] array of flags (index by local coordinates). I'm not sure what the flag values are, but it should be fairly simple to debug Edited June 4, 2015 by FrostBug 1 Quote Link to comment Share on other sites More sharing options...
Mysteryy Posted June 4, 2015 Share Posted June 4, 2015 You can get a 2d array of tile flags by XClippingPlane[] planes = getMap().getRegion().getClippingPlanes(); each plane has a getTileFlags() getter for the int[][] array of flags (index by local coordinates). I'm not sure what the flag values are, but it should be fairly simple to debug You can do this but it wont be totally accurate. Some tiles will say they are not walkable when they actually are, because some of the flags are shared on walkable tiles and non walkable tiles. (If I remember correctly) It will almost work, but you will end up missing some tiles ultimately. 1 Quote Link to comment Share on other sites More sharing options...
Woody Posted June 4, 2015 Author Share Posted June 4, 2015 You can get a 2d array of tile flags by XClippingPlane[] planes = getMap().getRegion().getClippingPlanes(); each plane has a getTileFlags() getter for the int[][] array of flags (index by local coordinates). I'm not sure what the flag values are, but it should be fairly simple to debug For now I just need walkable tiles on plane 0 (surface). So planes will contain both x and y value? If I was to use getRegion().getTiles(), would it return non walkable tiles aswell? You can do this but it wont be totally accurate. Some tiles will say they are not walkable when they actually are, because some of the flags are shared on walkable tiles and non walkable tiles. (If I remember correctly) It will almost work, but you will end up missing some tiles ultimately. Well, as for trying this for the first time, missing some tiles will not be a big issue. Quote Link to comment Share on other sites More sharing options...
Mysteryy Posted June 4, 2015 Share Posted June 4, 2015 For now I just need walkable tiles on plane 0 (surface). So planes will contain both x and y value? If I was to use getRegion().getTiles(), would it return non walkable tiles aswell? Well, as for trying this for the first time, missing some tiles will not be a big issue. It will be if you are making a web. Consider a tile that contains a door. When that door is closed, the tile is not walkable. That means that using clipping flags, you will see that tile as non walkable. You could argue that you can check objects on the tile, see if they are something that can be overcome, and yes you could do that. But objects such as doors, gates, etc. are not the only things that behave in that way. Flags are a bit wonky. I suggest just using clipping flags to paint the different tiles values/type and you can see for yourself how clipping behaves. Quote Link to comment Share on other sites More sharing options...
Woody Posted June 4, 2015 Author Share Posted June 4, 2015 It will be if you are making a web. Consider a tile that contains a door. When that door is closed, the tile is not walkable. That means that using clipping flags, you will see that tile as non walkable. You could argue that you can check objects on the tile, see if they are something that can be overcome, and yes you could do that. But objects such as doors, gates, etc. are not the only things that behave in that way. Flags are a bit wonky. I suggest just using clipping flags to paint the different tiles values/type and you can see for yourself how clipping behaves. I see your point. As for the painting, how do you paint nodes and print the world map, like this: Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted June 4, 2015 Share Posted June 4, 2015 (edited) Here: static final int UNWALKABLE = 256 | 0x200000 | 0x40000; public static boolean isWalkable(int flag) { return (flag & (UNWALKABLE)) == 0; } XClippingPlane[] clippingPlanes = script.client.accessor.getClippingPlanes(); int[][] map = clippingPlanes[script.myPlayer().getZ()].getTileFlags(); Now just loop through all tiles and check them Khaleesi You can do this but it wont be totally accurate. Some tiles will say they are not walkable when they actually are, because some of the flags are shared on walkable tiles and non walkable tiles. (If I remember correctly) It will almost work, but you will end up missing some tiles ultimately. Not true, if you use the right values the shared flags won't matter. A tile where a door is on is always walkable. but you'll have to check other flags if you can pass from 1 tile to another. Example fence: you can stand on both tiles, 1 tile will hold info if the tile is blocked north,east,south,west. Khaleesi Edited June 4, 2015 by Khaleesi Quote Link to comment Share on other sites More sharing options...
Mysteryy Posted June 4, 2015 Share Posted June 4, 2015 I see your point. As for the painting, how do you paint nodes and print the world map, like this: Havent worked on mine in a long time but this is what mine looks like: That is just using java gui basics. You just need an image of the map and your web data to draw on top of the map. I used a scroll pane to fit the map in a smaller gui. Dont worry about drawing it yet, i would suggest that you learn one thing at a time. Once you understand it and think you have it how you want it, then move on to the next task. Drawing the map wasnt a priority for me, I didnt do it for a long time. :p Here: static final int UNWALKABLE = 256 | 0x200000 | 0x40000; public static boolean isWalkable(int flag) { return (flag & (UNWALKABLE)) == 0; } XClippingPlane[] clippingPlanes = script.client.accessor.getClippingPlanes(); int[][] map = clippingPlanes[script.myPlayer().getZ()].getTileFlags(); Now just loop through all tiles and check them Khaleesi Not true, if you use the right values the shared flags won't matter. Check above , this will be 100% accurate I am not sure, like I said it has been a long time since I really messed with it. I made that thing over a year ago. Once the client comes back up I will see if I can find my old project that painted the flags. 1 Quote Link to comment Share on other sites More sharing options...
Woody Posted June 4, 2015 Author Share Posted June 4, 2015 Here: static final int UNWALKABLE = 256 | 0x200000 | 0x40000; public static boolean isWalkable(int flag) { return (flag & (UNWALKABLE)) == 0; } XClippingPlane[] clippingPlanes = script.client.accessor.getClippingPlanes(); int[][] map = clippingPlanes[script.myPlayer().getZ()].getTileFlags(); Now just loop through all tiles and check them Khaleesi I might be dumb, but what do you mean with "just loop through all tiles and check them" Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted June 4, 2015 Share Posted June 4, 2015 (edited) I might be dumb, but what do you mean with "just loop through all tiles and check them" Here: static final int UNWALKABLE = 256 | 0x200000 | 0x40000; public static boolean isWalkable(int flag) { return (flag & (UNWALKABLE)) == 0; } XClippingPlane[] clippingPlanes = script.client.accessor.getClippingPlanes(); int[][] map = clippingPlanes[script.myPlayer().getZ()].getTileFlags(); for(int i = 0; i < map.length;i++){ for(int j = 0; j < map[i].length; j++){ if(isWalkable(map[i][j])) //store in list? } } Could be typos in it, typed quickly in here. That's what you wanted to do right? Khaleesi Edited June 4, 2015 by Khaleesi Quote Link to comment Share on other sites More sharing options...
Mysteryy Posted June 4, 2015 Share Posted June 4, 2015 Here: static final int UNWALKABLE = 256 | 0x200000 | 0x40000; public static boolean isWalkable(int flag) { return (flag & (UNWALKABLE)) == 0; } XClippingPlane[] clippingPlanes = script.client.accessor.getClippingPlanes(); int[][] map = clippingPlanes[script.myPlayer().getZ()].getTileFlags(); for(int i = 0; i < map.length;i++){ for(int j = 0; j < map[i].length; j++){ if(isWalkable(map[i][j])) //store in list? } } Could be typos in it, typed quickly in here. That's what you wanted to do right? Khaleesi Oh now I remember the main reason that I didnt just use clipping flags. A tile can be walkable but not reachable. I cant remember what I did exactly but I think I made a web cleaner that went through and checked for isolated sections in my web that were generated, but cant actually be reached from other parts of the web and it would delete them. 1 Quote Link to comment Share on other sites More sharing options...
Woody Posted June 4, 2015 Author Share Posted June 4, 2015 Here: static final int UNWALKABLE = 256 | 0x200000 | 0x40000; public static boolean isWalkable(int flag) { return (flag & (UNWALKABLE)) == 0; } XClippingPlane[] clippingPlanes = script.client.accessor.getClippingPlanes(); int[][] map = clippingPlanes[script.myPlayer().getZ()].getTileFlags(); for(int i = 0; i < map.length;i++){ for(int j = 0; j < map[i].length; j++){ if(isWalkable(map[i][j])) //store in list? } } Could be typos in it, typed quickly in here. That's what you wanted to do right? Khaleesi Oh yea.. Now I get it. Thank you! 1 Quote Link to comment Share on other sites More sharing options...
Woody Posted June 6, 2015 Author Share Posted June 6, 2015 (edited) Here: static final int UNWALKABLE = 256 | 0x200000 | 0x40000; public static boolean isWalkable(int flag) { return (flag & (UNWALKABLE)) == 0; } XClippingPlane[] clippingPlanes = script.client.accessor.getClippingPlanes(); int[][] map = clippingPlanes[script.myPlayer().getZ()].getTileFlags(); for(int i = 0; i < map.length;i++){ for(int j = 0; j < map[i].length; j++){ if(isWalkable(map[i][j])) //store in list? } } Could be typos in it, typed quickly in here. That's what you wanted to do right? Khaleesi This is what I have ArrayList<Integer> walkableTiles = new ArrayList<Integer>(); @Override public int onLoop() throws InterruptedException { XClippingPlane[] planes = map.getRegion().getClippingPlanes(); int[][] map = planes[myPlayer().getZ()].getTileFlags(); for(int x = 0; x < map.length; x++) { for(int y = 0; y < map[x].length; y++) { if(isWalkable(map[x][y])) { walkableTiles.add(map[x][y]); } } } return 5000; } public void onExit() { try { BufferedWriter writer = new BufferedWriter ( new FileWriter(".\\positions.txt")); for(int i = 0; i < walkableTiles.size(); i++) { writer.write(""+walkableTiles.get(i)); writer.newLine(); } } catch (IOException e) { e.printStackTrace(); } } When I look at the text file, there are mostly zeros and some other values that doesn't look like tile positions... I've tested some other methods and experimented with it, but I get the same all the time. What's wrong? Edited June 6, 2015 by Woody Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted June 6, 2015 Share Posted June 6, 2015 (edited) This is what I have ArrayList<Integer> walkableTiles = new ArrayList<Integer>(); @Override public int onLoop() throws InterruptedException { XClippingPlane[] planes = map.getRegion().getClippingPlanes(); int[][] map = planes[myPlayer().getZ()].getTileFlags(); for(int x = 0; x < map.length; x++) { for(int y = 0; y < map[x].length; y++) { if(isWalkable(map[x][y])) { walkableTiles.add(map[x][y]); } } } return 5000; } public void onExit() { try { BufferedWriter writer = new BufferedWriter ( new FileWriter(".\\positions.txt")); for(int i = 0; i < walkableTiles.size(); i++) { writer.write(""+walkableTiles.get(i)); writer.newLine(); } } catch (IOException e) { e.printStackTrace(); } } When I look at the text file, there are mostly zeros and some other values that doesn't look like tile positions... I've tested some other methods and experimented with it, but I get the same all the time. What's wrong? You are saving the flags of the tiles. Not even the tile itself... This adds a flag of a tile to the list. walkableTiles.add(map[x][y]) basicly pointless, since you don't even know which tile it is afterwards. You want to save the tiles itself. ArrayList<Position> walkableTiles = new ArrayList<Position>(); Try to figure out how to get the global x and y yourself out of the locals x and y Khaleesi Edited June 6, 2015 by Khaleesi Quote Link to comment Share on other sites More sharing options...
Woody Posted June 6, 2015 Author Share Posted June 6, 2015 You are saving the flags of the tiles. Not even the tile itself... This adds a flag of a tile to the list. walkableTiles.add(map[x][y]) basicly pointless, since you don't even know which tile it is afterwards. You want to save the tiles itself. ArrayList<Position> walkableTiles = new ArrayList<Position>(); Try to figure out how to get the global x and y yourself out of the locals x and y Khaleesi Lol, shame on me... So with map[x][y] I can find the flag's tile? Quote Link to comment Share on other sites More sharing options...