NextBot is an AI system used by several multiplayer Source Engine games. The system can be used for not only bots, as its name implies, but it can also be used for entities which are not controlled by the player.
The NextBot system is not featured in any public version of the Source SDK. The documentation provided here is mostly based on certain console commands (most prominently
nb_debug) and an official PDF regarding Left 4 Dead's AI.
The differences between an NPC and a NextBot
Although Source NPCs (such as those from Half-Life 2) and NextBots are both used for AI, it is important to know that the two systems are not one and the same. Here are a few key differences that set the systems apart:
Source NPCs use nodes to determine not only where to navigate, but also what to do when they reach a specific node. NextBots do not use these nodes to navigate; instead they use the navigation mesh to move around and, depending on what mark a specific area may have, perform different actions.
- The NextBot system can be applied to both bots and non-playable entities.
The inner mechanics of the Source NPC system only apply to entities which are not players. With the NextBot system, both playable and non-playable characters can be fitted with AI if needed.
- The NextBot system is almost entirely built with ground-based entities in mind.
Source NPCs can be defined to either navigate on the ground or use air nodes to fly around open spaces. Two NextBots (Monoculous and Merasmus) are capable of flight-based movement, but this is rather rudimentary, as the system currently doesn't have official support for "air navigation meshes" or any similar mechanic.
Valve-developed games which use the NextBot system
The NextBot system is used for the following games:
- Left 4 Dead and Left 4 Dead 2
- Survivor bots
- All variants of the Infected
- Team Fortress 2
- Dota 2
- Hero bots
To do: Are there other characters/entities in Dota 2 which use NextBot?
- Any game with the NextBot system built-in
How a NextBot works
This factor handles how a NextBot moves around in its environment. For example, if a NextBot was programmed to flee after being injured, it would rely on this factor to move to a different position in the map.
This factor handles the animations of a NextBot. With the "oninjured" example, a NextBot would rely on this factor to play a flinching animation.
This factor handles how a NextBot sees certain entities in its environment. The field-of-view and line-of-sight functions mainly reside in this factor.
Keep in mind that this factor is not required for NextBots to work. A Skeleton in Team Fortress 2, for example, will find and attack enemies regardless of whether or not it sees them.
This factor is where the actual AI of a NextBot resides. The Intention factor manages the different behaviors a NextBot might have, and this factor is responsible for changing these behaviors depending on the event.
For a look at how this factor works in-game, see Example of NextBot Behaviors.
A Behavior contains a series of Actions, which it will perform when the Intention factor chooses it.
This function can be considered to be the NextBot equivalent of a schedule, since they are both lists of certain actions the AI needs to perform.
This features the actual AI code of a NextBot, which will run when its parent Behavior is run by the Intention factor. Actions can have an additional child Action, which will run at the same time as its parent Action.
This function can be considered to be the NextBot equivalent of a task, since they both contain the core programming which drives the AI itself.
The AI Systems of Left 4 Dead - An official PDF regarding various mechanics of Left 4 Dead, including NextBots and the AI Director