# get farthest (or minimum distance) visible main screen tile in a given direction?

## Recommended Posts

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?

##### Share on other sites

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
##### Share on other sites

If you have movement path found

```LocalPathFinder pathFinder = new LocalPathFinder(scp.bot);
```

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:)

##### Share on other sites

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
##### Share on other sites

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.

##### Share on other sites

Are you doing barrows tunnel traversal without a path finding algo ?

##### Share on other sites

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

##### Share on other sites

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)

##### Share on other sites

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.

##### Share on other sites

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
##### Share on other sites

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
##### Share on other sites

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.