adc Posted July 4, 2014 Share Posted July 4, 2014 (edited) I was just wondering if anyone could show me an efficient method to either get the farthest main screen tile or a main screen tile at a minimum distance, specifically in a given direction? Edited July 4, 2014 by adc Link to comment Share on other sites More sharing options...
Botre Posted July 4, 2014 Share Posted July 4, 2014 Load region Add all visible tiles to a list Grab the biggest or smallest (or a mixture of both if you want a most distant inter-cardinal direction position) x and y coordinates I'm curious what you need this for :p 1 Link to comment Share on other sites More sharing options...
darkxor Posted July 4, 2014 Share Posted July 4, 2014 If you have movement path found LocalPathFinder pathFinder = new LocalPathFinder(scp.bot); LinkedList<Position> path = pathFinder.findPath(entity); you can just check its tiles for visibility from index 0 to 20 for example. new MainScreenTileDestination(bot, path.get(i)).isVisible() If you need specific direction, you can ray-trace the line:) Link to comment Share on other sites More sharing options...
Swizzbeat Posted July 4, 2014 Share Posted July 4, 2014 I'm pretty sure the game map is 16 by 16, so the farthest position to the right would be: new Position(myPosition.getX() + 16, myPosition().getY(), myPosition().getZ()); Farthest position below: new Position(myPosition().getX(), myPosition().getY() - 16, myPosition().getZ()); etc... 1 Link to comment Share on other sites More sharing options...
adc Posted July 4, 2014 Author Share Posted July 4, 2014 Load region Add all visible tiles to a list Grab the biggest or smallest (or a mixture of both if you want a most distant inter-cardinal direction position) x and y coordinates I'm curious what you need this for I'm pretty sure the game map is 16 by 16, so the farthest position to the right would be: new Position(myPosition.getX() + 16, myPosition().getY(), myPosition().getZ()); Farthest position below: new Position(myPosition().getX(), myPosition().getY() - 16, myPosition().getZ()); etc... Oh hey, perfect, this is exactly what I need For some reason I overlooked this, thinking I'd need something more complex. Link to comment Share on other sites More sharing options...
Botre Posted July 4, 2014 Share Posted July 4, 2014 Are you doing barrows tunnel traversal without a path finding algo ? Link to comment Share on other sites More sharing options...
adc Posted July 4, 2014 Author Share Posted July 4, 2014 Are you doing barrows tunnel traversal without a path finding algo ? I originally tried using a simple A*-type algorithm, but I encountered the problem of rooms being too far to load. Because of this, there's no way to determine a path unless you're already in the center of the catacombs, making it pretty much useless :P So my solution is this: (for data I have an enum that stores room areas, as well as Point[]s that possible doors reside at) analyze current room's number of openable doors if viable doors < 2, that means there's only one possible path; follow that path to the next room if viable doors = 2, there's two paths. If one of the paths leads to the previous room, forget it and use the other path. if said other path leads to a blacklisted door, blacklist the current room as well. if viable doors > 2, prioritize in this order: 1) doors that lead to the chest 2) doors that lead to short tunnels 3) whatever is left (doors that lead to long tunnels) if a room has only 1 door and it's not the ladder room or chest room, blacklist it It works pretty okay so far Link to comment Share on other sites More sharing options...
Botre Posted July 4, 2014 Share Posted July 4, 2014 I originally tried using a simple A*-type algorithm, but I encountered the problem of rooms being too far to load. Because of this, there's no way to determine a path unless you're already in the center of the catacombs, making it pretty much useless You could just go to the center once and store all the required data once in a class though (as you would do for a webwalker). So my solution is this: (for data I have an enum that stores room areas, as well as Point[]s that possible doors reside at) analyze current room's number of openable doors if viable doors < 2, that means there's only one possible path; follow that path to the next room if viable doors = 2, there's two paths. If one of the paths leads to the previous room, forget it and use the other path. if said other path leads to a blacklisted door, blacklist the current room as well. if viable doors > 2, prioritize in this order: 1) doors that lead to the chest 2) doors that lead to short tunnels 3) whatever is left (doors that lead to long tunnels) if a room has only 1 door and it's not the ladder room or chest room, blacklist it It works pretty okay so far If it works then that's all that matters I guess x) Link to comment Share on other sites More sharing options...
adc Posted July 4, 2014 Author Share Posted July 4, 2014 You could just go to the center once and store all the required data once in a class though (as you would do for a webwalker). Actually, I tried. the problem is that every time you spawn a new tunnel path (every chest run at barrows), you'd have to be able to check whether each door on a given path is openable. When I tried doing this via getActions.contains("Open"), unloaded doors return true whether they're actually openable or not, meaning it couldn't determine a path, since A* (and pathfinding in general afaik) obtains its path from the end point to the beginning. Link to comment Share on other sites More sharing options...
Botre Posted July 4, 2014 Share Posted July 4, 2014 Actually, I tried. the problem is that every time you spawn a new tunnel path (every chest run at barrows), you'd have to be able to check whether each door on a given path is openable. When I tried doing this via getActions.contains("Open"), unloaded doors return true whether they're actually openable or not, meaning it couldn't determine a path, since A* (and pathfinding in general afaik) obtains its path from the end point to the beginning. You can get the openable doors via config(s) tho, without having the doors loaded. 2 Link to comment Share on other sites More sharing options...
adc Posted July 4, 2014 Author Share Posted July 4, 2014 You can get the openable doors via config(s) tho, without having the doors loaded. ..... Looks like I'm going to be testing two methods of pathfinding for this script then. Fuck. 1 Link to comment Share on other sites More sharing options...
Swizzbeat Posted July 4, 2014 Share Posted July 4, 2014 Why do you guys make this so complex? If you can get the doors you need to open via configs, you can literally just run around the perimeter until the door is reachable. Finding the next position to walk to is ezpz as you can just find the farthest walkable tile in your game region and walk to it. Link to comment Share on other sites More sharing options...