SetCommand

Category: Objects / Commands
Since engine version: 1.0 OC

Description

Gives a command to an object. The object will try to complete the command using the internal artificial intelligence (including pathfinding).

Syntax

bool SetCommand(string command, object target, int x, int y, object target2, any Data, int retries);

Parameters

command:
Command name (as string). See the table below.
target:
[opt] target object for the command
x:
[opt] X target coordinate
y:
[opt] Y target coordinate
target2:
[opt] secondary target object
Data:
[opt] additional data for the command
retries:
[opt] Number of retries if the command fails, until the command fails completely.

Remark

The following commands are defined:
command target x, y target2 Data Description
Acquire Null 0,0 Ignore container Object type (id) Type of object to be acquired. May be bought at the home base if necessary. Material contained in the specified container (Target2) is to be ignored in the search.
Activate Target object Activate the target object (exit from its container).
Activate Null 0,0 Target object Open the Get menu for the contents of the target object.
Activate Null Number,0 Target object Object type (id) Activate n objects of the specified type in the target object.
Attack Target object Attack the target object.
Buy Null 0,0 Null Object type (id) Buy an object of the specified type at the closest friendly home base.
Buy Basis Number,0 Null Object type (id) Buy n objects of the specified type at the home base.
Buy Basis Open the Buy menu for the specified home base.
Call Object Par(1),Par(2) Par(3) Function (string) Call Function in the object script. Par(0) will be the calling object. If the command fails because underlaying commands have failed, the function FunctionFailed is called instead.
Chop Target object Fell the target object object (tree).
Dig Null Target position Dig towards the target position.
Drop Immediately drop the first object in the inventory.
Drop Null Target position Drop the first object in the inventory at the target position.
Drop Target object Target position Collect the target object and drop it at the target position.
Enter Target object Enter the target object.
Exit Exit the current container.
Follow Target object Follow the target object (permanently).
Get Target object Collect the target object, dig it out if necessary.
Get Null Number,0 Target object Object type (id) Get the specified number of objects from the target object.
Grab Target object Offset Grab the target object at the specified offset to the object center.
Home Return to the closest friendly home base.
Jump Jump into the current direction.
Jump Null Target position Jump into the direction of the target position.
MoveTo Target object 0,0 Null No automatic adjustment? (bool) Move to the position of the target object. Set iData to true to avoid automatic adjustment of the target coordinates to landscape surface.
MoveTo Null Target position Null No automatic adjustment? (bool) Move to the target position. Set iData to true to avoid automatic adjustment of the target coordinates to landscape surface.
None Clear all current commands.
PushTo Target object Target position Push the target object to the target position.
PushTo Object 0,0 Target object Push the target object into the secondary target object.
Put Target object Put the first inventory object into the target object.
Put Target object Number,0 Put the specified number of inventory objects into the target object.
Put Target object 0,0 Object Collect the target object and put it into the secondary target object.
Put Target object 0,0 Null Object type (id) Put the inventory object of the specified type into the target object.
Put Target object Number,0 Null Object type (id) Put the specified number of inventory objects of the specified type into the target object.
Sell Null 0,0 Object2 Object type (id) Sell an object of the specified type at the closest home base. If Object2 is specified, this one will be sold first.
Sell Basis Number,0 Object2 Object type (id) Sell a number of objects of the specified type at the home base. If Object2 is specified, this one will be sold first.
Sell Basis Open Sell menu for the specified base object.
Throw Throw the first inventory item immediately.
Throw Null Target position Throw the first inventory item towards the target position.
Throw Target object Target position Collect the target object and throw it towards the target position.
UnGrab Let go of the object currently grabbed.
Wait Null 0,0 Null Frames Wait specified number of frames/ticks.

Example

SetCommand("Attack", FindObject(Find_ID(Clonk),Sort_Distance(0,0)), 0, 0, 0, 0, 10);
This script gives the clonk the order to attack the closest clonk of player 1. If the command fails (e.g. due to unsuccessful pathfinding), retry 10 times.
See also: AddCommand, AppendCommand, FinishCommand, GetCommand
PeterW, 2001-11