Adding Items to the Raven Navigation Graph
Most games include items an agent can pick up and use in some way.
These items can be added as nodes to the navigation graph, enabling the
path planning AI to easily search for the items and plan paths to them.
Where there are multiple instances of the same item, the AI can use the
navgraph to quickly determine which is the least costly to reach.
Remember back in Chapter 5 I showed you an example of a graph node
class designed specifically for use with navigation graphs? Just in case
your memory is as poor as mine, here’s the listing again:
template <class extra_info = void*>
class NavGraphNode : public GraphNode
//the node's position
//often you will want a navgraph node to contain additional information.
//(for example a node might represent the position of an item type
//such as health, thereby enabling a search algorithm to search a graph
//for that item type)
void SetPos(Vector2D NewPosition);
void SetExtraInfo(extra_info info);
/* EXTRANEOUS DETAIL OMMITTED */
This is the node class used by the Raven navigation graph. As mentioned in
the previous chapter, item types in Raven are derived from the
class. When a giver-trigger is added to a map using the map editor, a graph
node is also added. That node’s
m_ExtraInfo member is assigned a pointer
to the item it’s twinned with, thereby enabling a modified search algorithm
Practical Path Planning | 341
The Raven Navigation Graph