List of L4D2 Script Functions/CommandABot

From Valve Developer Community
Jump to: navigation, search

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.

Note.png Note: Bots may still refuse the command even if it was valid, depending on their programming.


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

Note.png Note:  The enumerations are only available in the Director scope, to access them outside of Director or mutation scripts, prefix the enumearion with DirectorScript. fore example DirectorScript.BOT_CMD_ATTACK
Enumeration Value Description
BOT_CMD_ATTACK 0 Force the bot to attack a specific target. To do: Only appears to work correctly on survivors or SI when targeting a valid enemy for them.
BOT_CMD_MOVE 1 Force the bot to move to a specific location.
BOT_CMD_RETREAT 2 Force the bot to retreat from a target entity. To do: Who does this work for?
BOT_CMD_RESET 3 Removes the active bot command and lets the AI resume controlling the bot.