SRL Archive - Reflection Development

WebWalk - A quick look


Drakan

2011-06-04 14:20:36

As many of you know Markus and I have both been trying to find out the best way to implement a web walking system into Reflection-2. I have been working non-stop for the last 3-4 days, with the help of many people in IRC (namely dgby and others), and have a base system to work off of now. This web walker is unlike the one of markus's as it uses the collision map to walk the best path while avoiding objects, WITHOUT the need for pre-coded paths. While it's not perfect right now, It definitely is a start. Heres a video of the walker going from Lumbridge to Draynor bank.

View Video

Now this obviously isn't flawless. If there is a huge wall in the way (I.E. port sarim to draynor bank), It's going to run into it and stop. However, my thoughts are to put together an array of nodes around the runescape map in safe spots where it won't get itself stuck. This way it is a happy medium of precoded paths and dynamic walking.

My thoughts on how it would walk is as follows:
  1. If distance from current spot to final spot is less than the distance to the nearest node then walk directly to destination without using nodes.
  2. If the nearest node is closer, then find the shortest path from the nearest node to the node closest to the destination tile
  3. Walk from the current spot to the nearest node
  4. Walk from node to node until it gets to the node closest to the destination
  5. Walk from that node to the destination tile.

I think this will end up being the best way to go about doing this, and It is easy to record these nodes as well. Tell me your thoughts/ideas/feedback/criticism/concerns! Thanks for reading!

Markus

2011-06-04 16:25:29

Something like this was what I was thinking about, too. We can only get the collision map of the current region we are in, thus we need to use known nodes to walk to the correct region and use the map afterwards.
Benefit: we only need 3 or 4 nodes per region (one in every corner or something like that)? This first fixes/works around the blatant errors we got atm regarding the crashing of the stupid plugin -.-' when there are too many nodes, makes an easier to manage implementation, and last but not least: most code is already done! We only need to get a few good nodes per region (someone take it upon oneself to adjust a worldmap to show rectangles of regions??) and the scripter can then dynamically walk to the right place.
Drags: we can use Webber (jfgi) to get the nodes. Not that much work at all!
After that is done, we can do the more high-level stuff (walk to closest bank) and make the ultimate script like this:

program reflectionscript
{$i reflection/reflection.simba}
begin
repeat
R_WebWalkTo(VEM_MINE);
while not R_InvFull do
R_ClickAndWaitUntilAnimationDone(OBJECT_ROCK_IRON)
R_WebWalkToClosestBank;
nextplayer(true);
until false.
end.
Edit: Point 2, 3 and 4 are already implemented in my version and it'll be easy to adjust so 1 and 5 are taken into account, so we only need to grab a few nodes and adjust that small part of code! :D

Gu3st...

2011-06-04 17:05:59

Save a bitmap of the collisionmaps of the chunks of runescape to a folder (auto-updating as you walk), and have it calculate which chunks you have to walk on in order for you to walk to the desired location.
This would make it possible to walk from falador bank to ardougne bank because the script would know it would have to walk to the chunk where the falador gate is and open it before continue walking.

Markus

2011-06-04 17:08:04

^ waaaaay to complex. You know how many tiles there are in just one region? Already a good 10840. A large piece of F2P would give you well over 90000 tiles which would take a bit long to calculate, compared to Drags' method.

Gu3st...

2011-06-04 17:14:15

From: Markus
^ waaaaay to complex. You know how many tiles there are in just one region? Already a good 10840. A large piece of F2P would give you well over 90000 tiles which would take a bit long to calculate, compared to Drags' method.
Then make a grid, say every forth tile or so then connect the tiles to each other, and check if any of the tiles have some un-walkable tiles between them. if they do then un-connect those tiles and *voila!* you turned 10840 into "10840 div 16" tiles

E: 677 tiles for each chunk, meaning 677b for each chunk

Boreas

2011-06-04 17:53:39

I like it.

How many nodes can your A*/Dijkstra/whatever handle in a reasonable amount of time? What's the biggest collision map you can process in a reasonable amount of time? How many of those are needed to make up the F2P world? And F2P+P2P?

If those answers are small-small-large-large, you may want to make a 2D (or even 3D) web, like highways and small roads.

Drakan

2011-06-04 17:59:50

Here is the beauty of this function guys. It generates the path on the fly. What does this mean? It can cross planes without even needing nodes. It loads the entire plane collision map in 250~ms and the dijkstra stuff is a whopping 0ms per call (using a plugin). However that being said, this can be dangerous since it's not really looking into the future when walking the path, it just starts going in the general direction, hence the need for nodes to walk to first.

So it's not that we need nodes in each plane, we need nodes in the main walking places. Aka have nodes lead up to roads, then following roads to the destination where we know it is safe to walk. But my main point markus is that it detects when we entered a new plane and loads the collision map for that plane, which only takes 250ms and it does that WHILE it's walking so it doesn't pause. I'm working on cleaning the code now so I can get it out there and yall can take a look.

Boreas

2011-06-04 18:35:54

Ah nice. So pretty much highways between towns are all that's needed?

Drakan

2011-06-04 18:46:48

From: Boreas
Ah nice. So pretty much highways between towns are all that's needed?


Essentially. With this we dont have a need for as many nodes, but the nodes would be more towards getting the character out of areas where it might get trapped. Aka lumbridge with all its many walls and things of that sort.

Gu3st...

2011-06-04 20:07:57

From: drags111
Essentially. With this we dont have a need for as many nodes, but the nodes would be more towards getting the character out of areas where it might get trapped. Aka lumbridge with all its many walls and things of that sort.
We could use the collision map & tile-grid system idea I posted earlier for those areas

Method

2011-06-04 20:32:17

Building a global collision map using the map and landscape data in the cache seems to me to be a much better solution. The only problem with this approach is that it requires you to visit each region at least once (and probably after they update) to grab the XTEA key used to decrypt the landscape data for that region. However, you can use the data to build your own collision map and then find a path using that.

Of course, you'll also need to account for opening doors, traversing between planes, teleporting, etc. by inserting nodes in a graph of sorts. However, I think this approach would be much more efficient and effective than building a giant database of tiles that connect different areas of the map.

Drakan

2011-06-04 21:05:06

From: Method
The way Jacmob and I had talked about implementing a global walking system was by building a global collision map using the map and landscape data in the cache. The only problem with this approach is that it requires you to visit each region at least once (and probably after they update) to grab the XTEA key used to decrypt the landscape data for that region. However, you can use the data to build your own collision map and then find a path using that.

Of course, you'll also need to account for opening doors, traversing between planes, teleporting, etc. by inserting nodes in a graph of sorts. However, I think this approach would be much more efficient and effective than building a giant database of tiles that connect different areas of the map.


Yes very good idea, pyroryan was suggesting the same thing as well, and he was going to look into it. As far as doors and stuff goes, I have an idea for that as well, but it definitely isn't as advanced. It would deal more with hardcoding nodes for those. Ex: if Node.IsDoor() then open it and keep going. But yah I'm sure your way would be much more efficient. I for one don't have a members account to even go everywhere :P.

Iamadam

2011-06-05 06:51:21

Just to put in my oar, it is crucial you think about the _best_ way of doing this.
It needs to be expandable to the point that it could handle doors/etc. It also needs to be easily up-datable in case landscapes change subtly. Spend the time thinking about how to do it well :)