Jump to content

Best way to traverse a "dungeon"


Butters

Recommended Posts

So I was wondering what's best way/algorithm/technique to walk around in an area, where webwalker doesn't have any information about it.

A nice example would probably be the Draynor mansion basement area (from Ernest the Chicken).

latest?cb=20170719032122

A-F are levers which change which doors (marked by numbers) can be opened or not.

Given that I can fetch the position of levers with something as simple as

Position leverPos = objects.closest("Lever D").getPosition();

What would be the best way to WALK to this given object position meeting the criteria below:
1) If the path is blocked by a door (which can be opened) - open it and continue

2) Handle only those obstacles that are needed, eg. If I wanna go from lever A to lever E, I need to go through doors 1 7 6. If I start not from lever A, then shouldn't try to go through previous doors.

Maybe there's something I could use in OSBot to add links to my script without writing the whole logic behind walking and obstacle handling?

Basically, my question is what is the best way to map an area which webwalker doesn't know of, and how to handle obstacles gong to any position in the given area inteligently.

  • Sad 1
Link to comment
Share on other sites

Damn are people really this spoiled by web walking? This room is a puzzle (I know you are talking in general), I would literally have to write in code that solves the puzzle for the scripters. Our API is enough spoonfeed, just don't be lazy and use "door.interact()".

/endrant

Nothing personal but damn man!

Edit: If you are particularly lazy take a look at the DoorHandler API, ugh.

  • Like 2
Link to comment
Share on other sites

Just now, Juggles said:

Use configs to go in order and open each door if you cant reach the lever.
Time consuming? Yes. But not difficult to code yourself :P 

Well he knows that, he's talking about web walking in general not reaching niche areas. The solution is just simply writing in the interaction code; I really hate when people use web walking to solve the interactions for them.

Link to comment
Share on other sites

3 minutes ago, Alek said:

Damn are people really this spoiled by web walking? This room is a puzzle (I know you are talking in general), I would literally have to write in code that solves the puzzle for the scripters. Our API is enough spoonfeed, just don't be lazy and use "door.interact()".

/endrant

Nothing personal but damn man!

Edit: If you are particularly lazy take a look at the DoorHandler API, ugh.

Thanks :D 

In my mind the problem is a little more complex than "interact with a obstacle if I can't reach the desired position", but more like "FIND the best path to a given position while handling a number of obstacles TOWARDS that position".

Still need a hint on how to do this from scratch.

Btw thanks for mentioning DoorHandler, seems like it has everything I need.

Looks like my question can be rephrased as "how does DoorHandler.generatePath() work?"

  • Like 1
Link to comment
Share on other sites

11 minutes ago, nosepicker said:

Thanks :D 

In my mind the problem is a little more complex than "interact with a obstacle if I can't reach the desired position", but more like "FIND the best path to a given position while handling a number of obstacles TOWARDS that position".

Still need a hint on how to do this from scratch.

Btw thanks for mentioning DoorHandler, seems like it has everything I need.

Looks like my question can be rephrased as "how does DoorHandler.generatePath() work?"

It's been a while but I believe there is a method to generate the path ignoring interactable objects (such as doors). The class is some old stuff and it's one of the very few classes I've ever touched. In that case, it should be exactly what you're looking for. I think it does interactions for you, but I'm not sure. 

  • Like 1
Link to comment
Share on other sites

4 minutes ago, Alek said:

It's been a while but I believe there is a method to generate the path ignoring interactable objects (such as doors). The class is some old stuff and it's one of the very few classes I've ever touched. In that case, it should be exactly what you're looking for. I think it does interactions for you, but I'm not sure. 

Will test it out, thanks.

Still wanna know how people do this without the spoonfed stuff.

For example you recently said that you added links for Stronghold in your slayer script which later ended up being added to webwalker (version 151 or 152).

Used DoorHandler or something more fancy?

Link to comment
Share on other sites

3 hours ago, nosepicker said:

 

Still wanna know how people do this without the spoonfed stuff.

It depends on how complex and large the dungeon is.

If it's tiny, and only consisted of gates / doors like in your example, using DoorHandler would probably suffice like Alek suggested.

If the dungeon is super complex, consisting of multiple levels, different types of obstacles, etc. then you would probably be wanting to write your own path finding and traversing code. You could use a pre-existing path finding algorithm such as A*.

Edited by Explv
  • Like 1
Link to comment
Share on other sites

1 hour ago, Explv said:

It depends on how complex and large the dungeon is.

If it's tiny, and only consisted of gates / doors like in your example, using DoorHandler would probably suffice like Alek suggested.

If the dungeon is super complex, consisting of multiple levels, different types of obstacles, etc. then you would probably be wanting to write your own path finding and traversing code. You could use a pre-existing path finding algorithm such as A*.

Thanks for the info.

I've been playing around with DoorHandler and can't seem to make it work. Either I'm using it wrong or it doesn't support something.

Situation screenshot below. Circled area is Lever D, player standing by the door, which has option "Open". Need to go past the door.

PewmIrA.png

Code used (for debugging) and trying to find out what doesn't work. "s" is reference to Script:

private void interactWithLever(String leverName, BooleanSupplier sleepUntil) {
		RS2Object lever = s.objects.closest(f -> f.getName().equals(leverName) && f.hasAction("Pull"));
		if (lever != null) {
			s.log("Lever: " + leverName + " is present");
			if (!s.map.canReach(lever)) {
				s.log("Cannot reach lever " + leverName);
				s.log("DoorHandler: Can reach or open: " + s.doorHandler.canReachOrOpen(lever));
				s.log("DoorHandler: Obstacle count: " + s.doorHandler.getObstacles().size());
				s.log("DoorHandler: Handled next object: " + s.doorHandler.handleNextObstacle(lever));
			} else {
				s.log("Interacting with lever");
				interactInMaze(lever, "Pull", sleepUntil);
			}
		}
	}

Output:

[INFO][Bot #1][01/10 02:58:16 PM]: Lever: Lever D is present
[INFO][Bot #1][01/10 02:58:16 PM]: Cannot reach lever Lever D
[INFO][Bot #1][01/10 02:58:16 PM]: DoorHandler: Can reach or open: false
[INFO][Bot #1][01/10 02:58:16 PM]: DoorHandler: Obstacle count: 0
[INFO][Bot #1][01/10 02:58:16 PM]: DoorHandler: Handled next object: false

Output loops forever.

Clearly for whatever reason DoorHandler doesn't find the obstacles. Am I using it wrong or what?

Additionally, if I do s.doorHandler.generatePath(lever) I get a NullPointer (refference to script is good and etc).

If anyone has any ideas, they're greatly appreciated :)

 

Link to comment
Share on other sites

23 minutes ago, nosepicker said:

Thanks for the info.

I've been playing around with DoorHandler and can't seem to make it work. Either I'm using it wrong or it doesn't support something.

Situation screenshot below. Circled area is Lever D, player standing by the door, which has option "Open". Need to go past the door.

PewmIrA.png

Code used (for debugging) and trying to find out what doesn't work. "s" is reference to Script:


private void interactWithLever(String leverName, BooleanSupplier sleepUntil) {
		RS2Object lever = s.objects.closest(f -> f.getName().equals(leverName) && f.hasAction("Pull"));
		if (lever != null) {
			s.log("Lever: " + leverName + " is present");
			if (!s.map.canReach(lever)) {
				s.log("Cannot reach lever " + leverName);
				s.log("DoorHandler: Can reach or open: " + s.doorHandler.canReachOrOpen(lever));
				s.log("DoorHandler: Obstacle count: " + s.doorHandler.getObstacles().size());
				s.log("DoorHandler: Handled next object: " + s.doorHandler.handleNextObstacle(lever));
			} else {
				s.log("Interacting with lever");
				interactInMaze(lever, "Pull", sleepUntil);
			}
		}
	}

Output:


[INFO][Bot #1][01/10 02:58:16 PM]: Lever: Lever D is present
[INFO][Bot #1][01/10 02:58:16 PM]: Cannot reach lever Lever D
[INFO][Bot #1][01/10 02:58:16 PM]: DoorHandler: Can reach or open: false
[INFO][Bot #1][01/10 02:58:16 PM]: DoorHandler: Obstacle count: 0
[INFO][Bot #1][01/10 02:58:16 PM]: DoorHandler: Handled next object: false

Output loops forever.

Clearly for whatever reason DoorHandler doesn't find the obstacles. Am I using it wrong or what?

Additionally, if I do s.doorHandler.generatePath(lever) I get a NullPointer (refference to script is good and etc).

If anyone has any ideas, they're greatly appreciated :)

 

 

I don't see any obvious issues with your code.

If DoorHandler doesn't work, you will need to write your own solution

Link to comment
Share on other sites

10 minutes ago, Ayylmao420 said:

if can't reach lever, interact with closest door to the lever that your player can reach ?

What if it needs to go though X number of doors in a "non direct" pattern?

I have a few solutions in mind, but all of them are ugly and might fail on some occasions. Really want to find a universal way for this.

Btw had a hunch that maybe DoorHandler is failing, cause the Lever tile is unwalkable. Tested with a walkable tile in the dungeon - still nop.

Link to comment
Share on other sites

24 minutes ago, nosepicker said:

What if it needs to go though X number of doors in a "non direct" pattern?

I have a few solutions in mind, but all of them are ugly and might fail on some occasions. Really want to find a universal way for this.

Btw had a hunch that maybe DoorHandler is failing, cause the Lever tile is unwalkable. Tested with a walkable tile in the dungeon - still nop.

https://www.google.com/search?q=shortest+path+algorithm+java

https://www.google.com/search?q=shortest+path+algorithm+java

https://www.google.com/search?q=shortest+path+algorithm+java

 

Create a "graph" connecting rooms to each each other. Each node on the graph is a room, each link is an obstacle e.g. a Gate

When you want to walk from room A to room B, find the shortest path in your graph from room A to room B, then traverse the path.

Considering this looks like a one-off maze puzzle thing, i'm sure you could get by with a hackier solution, but it would likely not be as robust or elegant.

I wrote some code for Arceuus house library that makes use of a graph & shortest path algorithm. I can probably share it with you once I am at home if you are still stuck.

Edited by Explv
  • Like 2
Link to comment
Share on other sites

4 minutes ago, withoutidols said:

RS2Object lever = s.objects.closest(f -> f.getName().equals(leverName) && s.getMap().canReach(f) && f.hasAction("Pull"));

Let me know if this change does anything

Well it would change something. lever would then be null, seeing as the player cannot reach it???

I'm not sure you understand the original question.

He wants to know how to navigate Draynor Manor Basement without web walking (as web walking does not support it)

Edited by Explv
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...