PDA

View Full Version : Pathing questions


jbb
05-25-2003, 05:53 AM
First of all I had a few improvements to the output prints. I'd tidied up a few and made some a bit more useful. Didn't do much. But then had big problems doing a cvs update last week (I think the repository changed a lot!) and managed to delete all my changes while trying to fix my local copy. No big deal. I didn't lose anything very useful.

Anyway, instead I decided to look how pathing worked. It looked like when you attack something it always heads directly to you regardless of geography. So I looked at the code and it's clear that there is only code to do that.

So I was wondering why? Is it simply that nobody has had time to write anything better yet? Is someone working on improving it?


My thought was that it should be fairly simple to define a list of xyz coordinates for path points for a zone, and then a list of pairs of path points that a mob is allowed to travel between.

And then when a mob is attacked and wants to get from A to B and and the closest path points to A and B are two different points to get the mob to travel along the lines between path points as defined in the 2nd table.

That would seen to result in movement similar to EQlive now and would be fairly quick and easy to get working. So I was wondering why nobody has done this? Is it harder than it looks? Is anyone working on this kind of thing? Or have I missed something major?

Bigpull
05-25-2003, 10:28 PM
It's good practice to keep a pristine cvsdir and a working copy, as you just saw.

Anyways.. Pathing is all there, whats missing is either manual grid entrys or a system to fully parse the .map files and attach Mobs to a grid "region" based on on the area of the zone they're in. The latter is prefered as it's needed for fear pathing aswell

jbb
05-25-2003, 10:30 PM
Ok, thanks for advice.

I see code to implement pathing for mobs walking around but it doesn't look like there is any to pick the best route to get to a thing they want to attack?

Have I missed that?

jbb
05-26-2003, 07:37 PM
When you say ".map files" do you mean the maps that come with the game? If you do I think that would be really really hard to come up with proper paths for mobs from this.

As an experiment I wrote some code so that when you attacked a mob in west freeport it would attempt to find a route to the player using a hard coded network of pathing points including going up onto the walkways around the entrance and back into a few of the buildings actually using the doors. It seemed to work quite well and feel similar to the offical servers. Of course you'd need a few hundred pathing points to cover all of west freeport. I just did about 50 close to the entrance, but it seems to work well.

Edgar1898
05-27-2003, 01:49 AM
Thats interesting, I was going to attempt to do the same thing, although I was also going to add blanket areas (large areas in open zones with no obstables in between, where a mob can roam freely). Post what you have so far, I would like to get this done but I dont want to code something thats already done, that would be a waste of time :/

jbb
05-27-2003, 02:20 AM
My code is very simple - and has hand coded coordinates for the gate area of freeportw hard coded into the MobAI.cpp file rather than a database. And it does a big recursive search through the links between the path points so wouldn't scale very well but I know how to improve that but haven't had any time, but I'll post what I've got anyway (but it won't be until later on today when I get home)

If you want to have a try you should be able to make a character on my server (It's called Jbb Test Server) or something. Start in freportw zone. Stand in the middle of the bridge over the gate and annoy one of the guards below. They should run round and up towards where you are. I've only put in any paths as far as the nfreeport zone and a little way into the city.

And the mob is supposed to detect when it's already at the closest pathing point to it's target and revert back to heading directly for it - But I seem to have broken that in the latest code.

Edgar1898
05-27-2003, 05:06 AM
I'm going to make a table to contain the paths so far I have:

Table Pathing
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| type | bigint(20) | | PRI | NULL | auto_increment |
| zone | varchar(20) | | | NULL | |
| p1x | float | | | 0 | |
| p1y | float | | | 0 | |
| p1z | float | | | 0 | |
| p2x | float | | | 0 | |
| p2y | float | | | 0 | |
| p2z | float | | | 0 | |
| p3x | float | | | 0 | |
| p3y | float | | | 0 | |
| p3z | float | | | 0 | |
| p4x | float | | | 0 | |
| p4y | float | | | 0 | |
| p4z | float | | | 0 | |
+-------+-------------+------+-----+---------+----------------+

Where type is the type of the path (1 being a point, 2 being a wide open grid) and p2-p4 are only used if type is 2. (4 points of the square) This will be loaded at spawn time and all spawns will use it. Then, adding wander mobs will be trivial, you can just tell the mob how far to wander. Let me know what you think, if any db fields need to be added/changed.

jbb
05-27-2003, 06:45 AM
Well I stored two "tables". The first one was
(id, zone, x, y, z)

and the 2nd contained connections between pathing points that a mob can move between.

(zone, first_id, second_id)

As I said, I'd only done a quick hack and the tables were just arrays in the source code but I'll upload what I've got later.

Edgar1898
05-27-2003, 06:51 AM
hmm mobs that fly will have to be flagged as such so they will ignore the pathing, otherwise we will have a bat that runs up the stairs :P

jbb
05-27-2003, 06:54 AM
Hmm, but bats *do* fly up the stairs in normal eq. They just seem to have a hight offset

Edgar1898
05-27-2003, 06:57 AM
they do? so if a player cast a spell on a bat on live, the bat would fly to the stairs, go up the stairs, down the ledge and then attack the player?

Trumpcard
05-27-2003, 07:04 AM
I believe they do, I think they follow the same pathing... If I remember correctly (and it's been a long time), it worked this way when I would kite flying mobs... They'll still path exactly the same way as a ground mob...

Edgar1898
05-27-2003, 07:09 AM
Hmm I never seemed to notice that :P seems wierd that a flying mob couldnt just fly over the small ledge and attack :roll:

DeletedUser
05-27-2003, 11:53 AM
Well.. they don't actually fly. They just look like their flying, because the only visibility of a mob is the top part of it. If you change your model to your bat, you still have your legs, you just can't seem them.

And the past week I was fighting sol b bats on live, they'll even "jump" into the lava which is where the kobolds and things go to run when they are low on health

jbb
05-27-2003, 10:57 PM
I tried to post a copy of my modified MobAI.cpp here but it won't let me add an attachment and it's too big to put in the message.

So I've linked to a copy of MobAi.cpp here (http://www.jb99.com/mobai.cpp)

Please note that this is just code I was playing about with to see if I could get anything working and certainly not of a quality for using for anything real. I only posted it in case it's useful to anyone. It probably won't compile without the changes to some other files too which I'll try to sort out and do properly soon.


Most of the new code (there isn't much) and the hacked freeport entrance path point table is at the top. I modified AI_process() to call DoMovement() instead of just heading towards the target directly.