View Single Post
  #1  
Old 04-08-2002, 01:52 AM
Malevolent
Hill Giant
 
Join Date: Mar 2002
Posts: 171
Default Roamers, Roaming, and the like

I believe I've a simple way to achieve the roaming effect in a zone. I haven't sat down to actually hack this in, so I'm not sure what the produced behavior will look like, but the theory I have in the back of my head seems to suggest to me that it will work. I know this topic has been discussed before, so take this as one other viewpoint.

First, a NPC will need to have two flags. One to indicate whether or not it can roam, and then two what kind of roaming pattern it uses. Then, in Process, after the mob has returned to their homepoint and is not attacking we need to add something of this flavor:

where CanRoam() is boolean property get from the header and GetRoamType is a series of #defs that I'll mention here in a sec.

If (this->CanRoam())
RoamType(this->CastToMob());

Each mob also has the following exclusive properties:

Get/Set:
* roam_x
* roam_y
* roam_z

These are passed into the RoamType validator.

A mob can only be doing one Roaming pattern at a time. Here are the basic starter set of patterns that I think would be useful to prove the utility of this theory:

#define ELIPSE 0
#define SQUARE 1
#define CIRCLE 2
#define LINE 3

The RoamType validator itself need not be complex.

if (mob == 0) return;

switch(this->GetRoamType) {
case ELIPSE: //dostuff break;
case SQUARE: //dostuff break;
case CIRCLE: //dostuff break;
case LINE: //dostuff default: break;
}

Then each case structure evaluates the next position x,y,z that the mob should move to given their ultimate destination, and their current destination.

The update for the mob will be processed each time ::Process() is invoked and previous steps (attacking, walking home) evaluate properly. The advantages to this approach versus the pathpoint setup I've discussed on here already is that one only needs to load one end destination point and not a series of way points. The disadvantage is lack of precision, but, this limitation could be overcome by having more complicated roam patterns defined.

--MV
Reply With Quote