Waypoints
In this tutorial we are going to make an NPC walk through a number of waypoints. I am going to assume that you know how to create an NPC (if not go here).

The first thing we need to do is to place our NPC in an area, so go to the Blueprints - Creatures and then select the NPC. Move the cursor over to the area preview and click where you want your NPC:

Now with the NPC selected, right click on it and then select Create Waypoint:

and you will then see a yellow flag in front of your NPC:

If you click on the flag and look at the properties have a look at the tag of the waypoing. My NPC tag is blacksmith and the first waypoints tag is WP_blacksmith_01, so a waypoint will always start with WP_Tag of NPC_waypoint number. Move the first waypoint away from the NPC (you will see why in a moment) and with the NPC selected, create another waypoint. Take a look at the properties of the waypoint and in particular the tag, you will see that it is now 02. Move this tag to its location and then repeat the process till you have enough waypoints for your NPC to travel where you want it to travel.

As you can see above I have create a simple path for the NPC to follow, you can now test it.

If you change the tag of the NPC then the NPC will not walk those waypoints. For example if I change my NPC tag from blacksmith to baker then I will need to change all the waypoints so that the NPC still walks around the house. To do this select all the waypoints (hold down the shift key and click on each waypoint) and then right click and then left click on Create Waypoint Set. You will see a Create Waypoint Set dialog box and you just need to add baker after the WP_:

You can see near the bottom that the waypoints will change to WP_baker_01, WP_baker_02 and so on. This will allow our newly tagged NPC (baker) to walk the 4 waypoints again.

You may find that the waypoints are too predictable and you may want your NPC to travel to the different waypoint in a more random fashion (i.e. instead of walking to waypoint 1,2,3,4,1,2,3,4 you may want the NPC to walk total random waypoints 1,4,3,2,3,4,5,2, etc). To do this you are going to have to add the following script (thanks to Charles Mead from Obsidian):

#include "ginc_wp"

void main()
{
int iCurrentWP = GetCurrentWaypoint();// the waypoint we just arrived at
int iNextWP = iCurrentWP+1;
if (iCurrentWP>4)
iNextWP = 1;
SetNextWaypoint(iNextWP);
}

Add this to the NPC heartbeat script and it will walk to random waypoints.