Skip to main content

Behavior

Description:

  A behavior tree framework for creating game AI structures.

Seq

Type: Function.

Description:

  Creates a new sequence node that executes an array of child nodes in order.

Signature:

Seq: function(nodes: {Leaf}): Leaf

Parameters:

ParameterTypeDescription
nodes{Leaf}An array of child nodes.

Returns:

Return TypeDescription
LeafA new sequence node.

Sel

Type: Function.

Description:

  Creates a new selector node that selects and executes one of its child nodes that will succeed.

Signature:

Sel: function(nodes: {Leaf}): Leaf

Parameters:

ParameterTypeDescription
nodes{Leaf}An array of child nodes.

Returns:

Return TypeDescription
LeafA new selector node.

Con

Type: Function.

Description:

  Creates a new condition node that executes a check handler function when executed.

Signature:

Con: function(name: string, check: function(board: Blackboard): boolean): Leaf

Parameters:

ParameterTypeDescription
namestringThe name of the condition.
checkfunctionA function that takes a blackboard object and returns a boolean value.

Returns:

Return TypeDescription
LeafA new condition node.

Act

Type: Function.

Description:

  Creates a new action node that executes an action when executed. This node will block the execution until the action finishes.

Signature:

Act: function(actionName: string): Leaf

Parameters:

ParameterTypeDescription
actionNamestringThe name of the action to execute.

Returns:

Return TypeDescription
LeafA new action node.

Command

Type: Function.

Description:

  Creates a new command node that executes a command when executed. This node will return right after the action starts.

Signature:

Command: function(actionName: string): Leaf

Parameters:

ParameterTypeDescription
actionNamestringThe name of the command to execute.

Returns:

Return TypeDescription
LeafA new command node.

Wait

Type: Function.

Description:

  Creates a new wait node that waits for a specified duration when executed.

Signature:

Wait: function(duration: number): Leaf

Parameters:

ParameterTypeDescription
durationnumberThe duration to wait in seconds.

Returns:

Return TypeDescription
LeafA new wait node.

Countdown

Type: Function.

Description:

  Creates a new countdown node that executes a child node continuously until a timer runs out.

Signature:

Countdown: function(time: number, node: Leaf): Leaf

Parameters:

ParameterTypeDescription
timenumberThe time limit in seconds.
nodeLeafThe child node to execute.

Returns:

Return TypeDescription
LeafA new countdown node.

Timeout

Type: Function.

Description:

  Creates a new timeout node that executes a child node until a timer runs out.

Signature:

Timeout: function(time: number, node: Leaf): Leaf

Parameters:

ParameterTypeDescription
timenumberThe time limit in seconds.
nodeLeafThe child node to execute.

Returns:

Return TypeDescription
LeafA new timeout node.

Repeat

Type: Function.

Description:

  Creates a new repeat node that executes a child node a specified number of times.

Signature:

Repeat: function(times: integer, node: Leaf): Leaf

Parameters:

ParameterTypeDescription
timesintegerThe number of times to execute the child node.
nodeLeafThe child node to execute.

Returns:

Return TypeDescription
LeafA new repeat node.

Repeat

Type: Function.

Description:

  Creates a new repeat node that executes a child node repeatedly.

Signature:

Repeat: function(node: Leaf): Leaf

Parameters:

ParameterTypeDescription
nodeLeafThe child node to execute.

Returns:

Return TypeDescription
LeafA new repeat node.

Retry

Type: Function.

Description:

  Creates a new retry node that executes a child node repeatedly until it succeeds or a maximum number of retries is reached.

Signature:

Retry: function(times: integer, node: Leaf): Leaf

Parameters:

ParameterTypeDescription
timesintegerThe maximum number of retries.
nodeLeafThe child node to execute.

Returns:

Return TypeDescription
LeafA new retry node.

Retry

Type: Function.

Description:

  Creates a new retry node that executes a child node repeatedly until it succeeds.

Signature:

Retry: function(node: Leaf): Leaf

Parameters:

ParameterTypeDescription
nodeLeafThe child node to execute.

Returns:

Return TypeDescription
LeafA new retry node.