Left 4 Dead 2/Scripting/Script Functions/CommandABot: Difference between revisions
< Left 4 Dead 2 | Scripting | Script Functions
Jump to navigation
Jump to search
(Created page with " == Function Description == ''' bool CommandABot(table ''commandTable'') ''' Issues commands to bots based on a table configuration. Survivor bots, special infected and co...") |
m (→Commands: more desciptive) |
||
Line 84: | Line 84: | ||
| BOT_CMD_ATTACK | | BOT_CMD_ATTACK | ||
| 0 | | 0 | ||
| Force the bot to attack a specific target. | | Force the bot to attack a specific target, even bypassing<code>CTerrorPlayer::SetSenseFlags(DirectorScript.BOT_CANT_SEE)</code>. Only works on forcing Survivor Bots to attack player-controllable Special Infected, and vice versa. | ||
|- | |- | ||
| BOT_CMD_MOVE | | BOT_CMD_MOVE | ||
| 1 | | 1 | ||
| Force the bot to move to a specific location. | | Force the bot to move to a specific location, which then they will do it unconditionally without performing any other AI behaviors controlled by themselves. This means that Survivor Bots and most player-controllable Special Infected won't attack anything when commanded, but Common Infected still automatically attack enemies if they close in enough. | ||
|- | |- | ||
| BOT_CMD_RETREAT | | BOT_CMD_RETREAT | ||
| 2 | | 2 | ||
| Force the bot to retreat from a target entity. | | Force the bot to retreat from a target entity. Only work when used on Survivor Bots, and if target is a Tank. | ||
|- | |- | ||
| BOT_CMD_RESET | | BOT_CMD_RESET | ||
Line 98: | Line 98: | ||
| Removes the active bot command and lets the AI resume controlling the bot. | | Removes the active bot command and lets the AI resume controlling the bot. | ||
|} | |} | ||
[[Category:Left 4 Dead 2]] | [[Category:Left 4 Dead 2]] | ||
[[Category:Scripting]] | [[Category:Scripting]] |
Revision as of 15:08, 3 April 2021
Function Description
bool CommandABot(table commandTable)
Issues commands to bots based on a table configuration.
Survivor bots, special infected and common infected can be commanded. The bot's normal AI is disable while it is commanded, and it will blindly follow the command until a new command is issued.
Parameters
Type | Name | Description |
---|---|---|
table | commandTable | Table for passing configuration paramters for the bot command. |
Returns
bool - Whether the command was valid. If the command failed, an error message will also be printed to console.

Example
Here is an example of how to create a table that commands all bots to run to position 0,0,0:
commands <-
{
cmd = DirectorScript.BOT_CMD_MOVE
pos = Vector( 0,0,0 )
}
----
CommandABot( commands )
// Alternatively, you could send the data inline, like so:
CommandABot( { cmd = DirectorScript.BOT_CMD_MOVE, pos = Vector( 0,0,0 ) } )
Input Parameters
Passed to the commandTable to set up the command.
Type | Name | Description |
---|---|---|
CTerrorPlayer or Infected | bot | The bot to command. When set to null or not set, all bots are given the command. |
int | cmd | The command enumeation. Required. |
Vector | pos | Where to move in a BOT_CMD_MOVE command. |
CBaseEntity | target | The entity to attack in BOT_CMD_ATTACK or retreat from in BOT_CMD_RETREAT. |
Commands

DirectorScript
. fore example DirectorScript.BOT_CMD_ATTACK
Enumeration | Value | Description |
---|---|---|
BOT_CMD_ATTACK | 0 | Force the bot to attack a specific target, even bypassingCTerrorPlayer::SetSenseFlags(DirectorScript.BOT_CANT_SEE) . Only works on forcing Survivor Bots to attack player-controllable Special Infected, and vice versa.
|
BOT_CMD_MOVE | 1 | Force the bot to move to a specific location, which then they will do it unconditionally without performing any other AI behaviors controlled by themselves. This means that Survivor Bots and most player-controllable Special Infected won't attack anything when commanded, but Common Infected still automatically attack enemies if they close in enough. |
BOT_CMD_RETREAT | 2 | Force the bot to retreat from a target entity. Only work when used on Survivor Bots, and if target is a Tank. |
BOT_CMD_RESET | 3 | Removes the active bot command and lets the AI resume controlling the bot. |