You are on page 1of 2

Explaining Waypoints and Walkwaypoints

Intended Audience:
By David Gaider
[Printer Friendly / Syntax Highlight]
A waypoint is an invisible object that is placed in an area to mark a specific location. It
has its own tag (which you can set when it is created) and can optionally be made into a
'map note' (one could be labeled 'General Store', for instance, and in the mini-map an icon
would appear where it was located... if the player moved his cursor over that icon it
would display its label).
The generic AI that comes with NWN is set up so that you can get creatures you set down
to walk a circuit of these waypoints automatically.
How is this done? It all has to do with the tag you assign to the waypoint. Take the tag of
the creature(s) you want to use the waypoint... add the prefix "WP_" and the suffix
"_0X"... and the creature will automatically begin walking them in that order.
Example:
I have an NPC guard who I have given the tag "GUARD". I lay down four waypoints
which form his patrol circuit. I give them the tags "WP_GUARD_01",
"WP_GUARD_02", "WP_GUARD_03" and "WP_GUARD_04".
According to the default AI, when the game started he would proceed to the nearest
waypoint (whether it is "WP_GUARD_01" or not) and then move to the next waypoint in
numerical order. He keeps going, in order, pausing 1 second at each one. Once he got to
"WP_GUARD_04" he would start back to "WP_GUARD_01". If he saw anything hostile,
he would move to attack... and, once the combat was over, he would return to his patrol.
The above is the simplest use of the waypoints, of course... there are many other ways to
tweak it. There are likely a few questions right off the bat that might arise:
1. If I used a lot of waypoints for my NPC's, there could be a LOT of waypoints on the
screen!
One waypoint doesn't only have to serve one creature... it serves one creature tag. More
than one creature can have the same tag, if you wish.
There are also four different colored appearances that you can set on the waypoints to
distinguish them from each other.
Even so, you could have quite a few in any given area, depending on what you were
doing. Fortunately waypoints don't run scripts or take up any graphics processing power
by their existence. If they get in the way of you seeing things in the toolset, there is a
button which allows you to screen them out of view (there are buttons for other things,
too, if you don't wish to view objects, creatures, items or whatever).

2. It sounds like a lot of work to re-name all the tags on those waypoints.
You could edit each waypoint and change its tag if you wanted to. Fortunately you can
hold down the SHIFT key and select the waypoints in the order you want them... then
right-click the mouse button and select 'Create Set'. If you provide the tag name
('WP_GUARD' in the above example), it will automatically change their tags and add on
the numbered suffixes for you.
3. What if I want part of the circuit to cross an area transition... like going into a house
or something?
This works fine. I suspect you would have to have a regular area transition created by the
wizard (the ones in triggers and doorways), however... not a transition that you scripted
yourself.
I recently creating a peasant who walked four waypoints, two of them being in another
area (inside a house). I then planted a house tile in the main area and connected the two
with a door. He left the door open after he used it the first time, but otherwise it worked
fine.
More Advanced Uses
Posts: Instead of walking waypoints, you can assign a creature to a 'post'. Lay down a
single waypoint with the prefix 'POST_' added to the creature's name.
The creature will then remain at his post. If he moves from it to engage in combat, he will
return to it as soon as he is done.
Day/Night Activities: In the generic OnSpawn script, you can uncomment a command
called 'SetSpawnInCondition (NW_FLAG_DAY_NIGHT_POSTING)'. This will tell the
creature to differentiate between night and day.
How does this affect waypoints? Well, you can give a creature a different set of
waypoints to walk (or a different post) in the day and night by changing the prefix of
your waypoints:
day waypoint: prefix "WP_"
night waypoint: prefix "WN_"
day post: prefix "POST_"
night post: prefix "NIGHT_"
So you could set up the guard in the example to walk his waypoints during the day. Then,
if that flag was uncommented in the OnSpawn script, you could set a "NIGHT_GUARD"
waypoint in his barracks that he would return to that spot when it was dark.
One thing to remember is that when you make any changes to the OnSpawn script, make
sure you save it under a different name before compiling... else you'll make a global
change that will affect every creature in your module.

You might also like