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 (Nescius moved page Left 4 Dead 2/Script Functions/CommandABot to Left 4 Dead 2/Scripting/Script Functions/CommandABot: same as tf2) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{Dead end|date=January 2024}} | |||
== Function Description == | == Function Description == | ||
Line 6: | Line 7: | ||
Issues commands to bots based on a table configuration. | 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. | |||
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 == | == Parameters == | ||
Line 20: | Line 19: | ||
| Table for passing configuration paramters for the bot command. | | Table for passing configuration paramters for the bot command. | ||
|} | |} | ||
== Returns == | == Returns == | ||
Line 27: | Line 25: | ||
{{note|Bots may still refuse the command even if it was valid, depending on their programming.}} | {{note|Bots may still refuse the command even if it was valid, depending on their programming.}} | ||
== Example == | |||
== Example == | |||
Here is an example of how to create a table that commands all bots to run to position 0,0,0: | Here is an example of how to create a table that commands all bots to run to position 0,0,0: | ||
Line 44: | Line 41: | ||
CommandABot( { cmd = DirectorScript.BOT_CMD_MOVE, pos = Vector( 0,0,0 ) } ) | CommandABot( { cmd = DirectorScript.BOT_CMD_MOVE, pos = Vector( 0,0,0 ) } ) | ||
</source> | </source> | ||
== Input Parameters == | == Input Parameters == | ||
Line 71: | Line 67: | ||
| The entity to attack in BOT_CMD_ATTACK or retreat from in BOT_CMD_RETREAT. | | The entity to attack in BOT_CMD_ATTACK or retreat from in BOT_CMD_RETREAT. | ||
|} | |} | ||
== Commands == | == Commands == | ||
Line 84: | Line 79: | ||
| 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 93: | ||
| 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]] |
Latest revision as of 14:02, 15 September 2024

This article has no
links to other VDC articles. Please help improve this article by adding links
that are relevant to the context within the existing text.
January 2024


January 2024
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. |