Some thoughts on setting up zone movement points
Entre development thoughts on movement.
When I think of pathing points, I think of a collection of points in a zone that mobs follow giving the illusion of movement. Perhaps this could at some later point even be scripted, such that SPAWN 0 AT TIME T MOVE TO X1, Y1, Z1 AT TIME T+10 MOVE TO X2,Y2,Z2 but scripting is a later thing. Right now, unless the active build has it, I don't see any movement code of this nature built in yet. So I'm going to put out some thoughts on it, as I haven't had a chance to sit down and do it. I was thinking that a zone needs to have a collection of path points, and that within a zone there are two kinds of movement: spawngroup based movement (e.g., a group of goblin peons in RE that walk about) or spawn based movement (e.g., mooto in misty). I was thinking that there need be only a few points setup for the mob, and that the pathfind algorithm will move the mob from point a to point b at time interval (movement_timer, which is already defined in the code, but is more concerned with attack). Therefore, there needs to be a way to determine what the next movement point needs to be (which might be helpful later for triggers), along with coordinate information, and a relation to the spawn2 table. With all the above in mind, I have the following mysql SQL (not all SQL is the same ;o) table: Code:
CREATE TABLE path_points( This table will then have all the necessary data. The next step, I'm thinking, would be to put in the necessary code to buffer the table contents when the zone loads. But we also need a structure to contain all the data from the table. struct PathPoint { float x; // x location to move to float y; // y location to move to float z; // z location to move to int step; // step (a) in linear sequence of (a) int spawnid; // id of the spawn }; Now the entity object will need to be aware of what the last step it took was, so a quick property of Get/Set LastStep would be necessary. Now the pathpoints need to be loaded. I'm thinking a linked list that has at least the following signature: Public: PathPoint* MovementPoints(float x, float y, float z, int step, int spawnid); And then the linked list should be stuck into the zone class, such that the zone can do the movement checks every so often, which might be best defined by one of the existing timers or perhaps a new one, so that people might be able to control how often this occurs (for slower machines) or -1 to turn it off completely. Next, the actual check comes up. An iteration loop of the zone movementpoints with and another nested loop of the npcs, or maybe any entity? But I'm pretty sure only one of the derived classes has the x,y SendTo() method (which will need to be changed to an overload version x,y,z). I'm going to dip into some pseudo code now :) Code:
if (timer-says-do-movement-for-zone) |
A few minor deviations from the original and most of what I have up there seems to be working, aside from a couple (small) problems.
Does anyone know how to get the optimal z-coordinate of an entity? Right now I have the queen klaknak walking about in space. Talk about floating bugs! <G> The other problem seems to be the pure drain that it takes on the server to do this. A fully populated zone, erm, kinda grinds slowly to a hault. Is there a way to spawn an npc_type directly? -ST |
Code Snippets
According to my tests, stuff moves across the screen. While a bit rough, it gets the job done (for now). This will put together a data structure that allows one to setup a way to move npc types around a zone. Currently, the data is not persistent and only loads the points when the zone is booted. Is there really a good reason to make persistent pathing points? Anyway, here is the code, hope it helps!
database structure: Code:
Code:
/////////////////////// Code:
/////////////////////////////// Changes to npc.cpp Code:
////////////////////////////// Code:
Code:
SetPathPointStep(0); //always start out at step 0 for a new npc Code:
public: --MV (formerly known as ScotchTape) |
Malevolent Experience: PathPoints User Lookup
I was curious where the npc was heading off to, so I built into client.cpp a small filter that gives you an update as to what the npc is up to. In the future, maybe one could lookup a particular step #? I'm open to some ideas on this.
Code:
//Malevolent --MV |
Try joining that chat room. i'm sure the Dev's would love to see some more of your code...
|
Quote:
I'll likely be popping in there sometime this week. I don't want to be reinventing the wheel with what ever is going to be included in 2.6/7. --MV |
ehh i'm sure u can contribute something hehe.. thats what opensource is for!
|
I've been holding back but.. your ideas are very well organised ScotchTape, good work there. Also Malevolent, your code is very nice, but alass I have tried it myself.
|
Ah well, so long as the npcs move now. Its all good, it gave me a chance to figure out the design of the emu codebase the good way (which happens to be the hard way:).
I think I best join that chat then before embarking on the next round of AI that I've been wanting to stash in the codebase. --MV |
Malevolent, man.. I love you! You really should hang out in the #EQEmu. lol. Everyone there probably loves you. You got the Animal Instinct code and this.. Dang.. You rock, man. :) I haven't added the code to my own yet, but I have a feeling it'll work. lol.
|
All times are GMT -4. The time now is 05:55 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.