Source AI
This document will provide an overview of how to implement and manage AI in your Source game or map.
Introduction
AI stands for Artificial Intelligence (Wikipedia) and controls the behaviour of all but the simplest of NPC actions. Source's AI is not to be confused with Half-Life 2's implementation of it: it is very powerful and very clever. Simply place an AI controlled entity into a map and it will have a good chunk of it's features in place without any other actions. Place some info_node entities too and you've got fully functional AI characters who will use your map to hide, flank, flush out and assault. On top of this basic framework comes scripted and semi-scripted behaviour to add extra punch.
Basics: info_node
Create an interesting map, place some AI entities in it, and run it. Don't kill them straight away but turn on mat_wireframe and watch their actions as you move around. You'll see them, more or less, run straight at you and shoot. This is because they have no bearings in the world other than your position.
Leave the game and lay down info_node entities across the map (what is the optimum density?) then recompile, turn on developer 1 if it isn't already and do the same as last time. You should now see them group and attack together if they need to, seek cover, throw grenades at far more suitable times, try to walk around you and more - all because you added a few nodes. With developer 1 you can see a console message whenever any of this happens.
This alone has fully set up your AI for a map. There's far more too it than that, though.
Moving AI: path_corner
There are two ways to forcibly move AI: through path_corner entities or choreography. Choreography goes beyond the scope of this document and will be ignored. We shall instead focus on path_corners, which are simple: make one, name it, then shift+drag it to create the next path_corner in the chain.
To manually make a chain (or link one up in a circle), edit the 'Next stop target' property. Note that the 'Train Speed' values are obsolete unless you are making a path for a func_train.
Once you have the path laid out, go to your AI entity and set 'Target Path Corner' to the path_corner you want it to enter at.
Note that the example map does not have any info_nodes. They are not needed to have AI follow a path.
More soon
- -)