enum CMD
OPT_ALT
CMD.OPT_ALT = 128
[source]
OPT_CTRL
CMD.OPT_CTRL = 64
[source]
OPT_SHIFT
CMD.OPT_SHIFT = 32
[source]
OPT_RIGHT
CMD.OPT_RIGHT = 16
[source]
OPT_INTERNAL
CMD.OPT_INTERNAL = 8
[source]
OPT_META
CMD.OPT_META = 4
[source]
MOVESTATE_NONE
CMD.MOVESTATE_NONE = -1
[source]
MOVESTATE_HOLDPOS
CMD.MOVESTATE_HOLDPOS = 0
[source]
MOVESTATE_MANEUVER
CMD.MOVESTATE_MANEUVER = 1
[source]
MOVESTATE_ROAM
CMD.MOVESTATE_ROAM = 2
[source]
FIRESTATE_NONE
CMD.FIRESTATE_NONE = -1
[source]
FIRESTATE_HOLDFIRE
CMD.FIRESTATE_HOLDFIRE = 0
[source]
FIRESTATE_RETURNFIRE
CMD.FIRESTATE_RETURNFIRE = 1
[source]
FIRESTATE_FIREATWILL
CMD.FIRESTATE_FIREATWILL = 2
[source]
FIRESTATE_FIREATNEUTRAL
CMD.FIRESTATE_FIREATNEUTRAL = 3
[source]
WAITCODE_TIME
CMD.WAITCODE_TIME = 1
[source]
WAITCODE_DEATH
CMD.WAITCODE_DEATH = 2
[source]
WAITCODE_SQUAD
CMD.WAITCODE_SQUAD = 3
[source]
WAITCODE_GATHER
CMD.WAITCODE_GATHER = 4
[source]
STOP
CMD.STOP = 0
Stop the current action and clear the unit’s command queue.
For factories, this will cancel the new unit orders queue. For units, this will cancel the current command and queue.
Accepts no parameters.
It won’t do anything if used with CMD.INSERT
, or the shift
option.
[source]
INSERT
CMD.INSERT = 1
[source]
REMOVE
CMD.REMOVE = 2
Remove all commands from a unit’s queue matching specific cmdIDs or tags.
Modes of operation
Filter by tag
Removes any command with a tag matching those included in params.
params
{tag1, tag2 …} an array of tags to look for.
This is the default mode of operation.
Filter by id
Removes any command with a command id
matching those included in params.
params
{id1, id2 …} or {tag1, tag2, …} an array of ids tags to look for.
To use this mode you need to pass the alt
option.
Command Options
alt
Tag/Id switchctrl
Alternative queue selection.- For factories alternative queue is the factory command queue, default queue is the rally queue.
- For other units no effect.
Examples
Delete all attack orders from unit, or factory rally queue if factory:
Spring.GiveOrderToUnit(unitID, CMD.REMOVE, CMD.ATTACK)
Delete all attack and fight orders from unit, or factory rally queue if factory:
Spring.GiveOrderToUnit(unitID, CMD.REMOVE, {CMD.ATTACK, CMD.FIGHT}, CMD.OPT_ALT)
Delete commands with specific tags:
Spring.GiveOrderToUnit(unitID, CMD.REMOVE, {tag1, tag2, tag3})
Delete all commands to build units with UnitDef ids unitDefId1 and unitDefId2 from factory queue:
Spring.GiveOrderToUnit(unitID, CMD.REMOVE, {-unitDefId1, -unitDefId2}, CMD.OPT_ALT + CMD.OPT_CTRL)
[source]
WAIT
CMD.WAIT = 5
Makes the unit suspend processing its command queue until wait is removed.
Accepts no parameters.
[source]
TIMEWAIT
CMD.TIMEWAIT = 6
Makes the unit suspend processing its command queue for a given duration.
params
{duration} Time to wait in seconds.
[source]
DEATHWAIT
CMD.DEATHWAIT = 7
Makes the unit suspend processing its commmand queue until the death of a given unit or units in an area.
Modes of operation
Wait for death of specific unit
params
{unitID} unitID of the unit to wait for.
Wait for death of units in an area
params
{x1, y1, z1, x2, y2, z2}: Wait for death of units in square {x1, z1, x2, z2}.
[source]
SQUADWAIT
CMD.SQUADWAIT = 8
Makes selected units, or units coming out of a factory wait until squadSize peers are found to go with them.
If given to non factory units and the squadSize is smaller than the selected number of units the command will have no effect.
Each unit will find squadSize other units and resume wait, those remaining without peers will wait. For example if there are 30 selected units and a squadSize of 12 is sent, 6 units will stay waiting, as 30 - 12*2 = 6
.
If given at a waypoint for a factory queue for new units, units coming out of the factory will wait at the waypoint until squadSize units are available, and then they will proceed together.
Can also be given to a group of factories, and units from those factories will gather together.
params
{squadSize} Squad size.
[source]
GATHERWAIT
CMD.GATHERWAIT = 9
Makes the unit wait for all other selected units to reach the command.
Useful to make units wait until all other units have reached a waypoint.
Will only be given to movable (unitDef.canMove == true
) non-factory units.
Accepts no parameters.
[source]
MOVE
CMD.MOVE = 10
[source]
PATROL
CMD.PATROL = 15
[source]
FIGHT
CMD.FIGHT = 16
[source]
ATTACK
CMD.ATTACK = 20
Attack command. Gives an order to attack some target(s).
The command has different modes of operation, depending on the number of parameters and options used.
Modes of operation
Attack single target
params
{unitID}: Attack a unit
The command will end once the target is dead or not valid any more.
Area attack
Will create a number of single target
actions by finding targets in a circle.
Note: this is different than CMD.AREA_ATTACK, since this initially finds the targets but then doesn’t consider the area any more.
params
{x,y,z,r} when radius is greater than 0.- r: radius
- x,y,z: map position
Ground attack
params
{x,y,z,0} or {x,y,z}- x,y,z: map position
Command Options
alt
Also target stunned targets. Without this stunned targets will be skipped.meta
OverridemanualFire
, andnoAutoTarget
weapon behaviours.
Other modifiers
modInfo.targetableTransportedUnits
: Controls whether transported units are targetable.
Callins
- UnitCmdDone: Run when the command is finished.
Examples
Attack unit with id targetID
.
Spring.GiveOrderToUnit(unitID, CMD.ATTACK, targetID)
Area attack of radius 50 at map position 1000,1000 with height 100:
Spring.GiveOrderToUnit(unitID, CMD.ATTACK, {1000,100,1000,50})
Ground attack at map position 1000,1000 with height 100:
Spring.GiveOrderToUnit(unitID, CMD.ATTACK, {1000,100,1000})
[source]
AREA_ATTACK
CMD.AREA_ATTACK = 21
[source]
GUARD
CMD.GUARD = 25
[source]
GROUPSELECT
CMD.GROUPSELECT = 35
[source]
GROUPADD
CMD.GROUPADD = 36
[source]
GROUPCLEAR
CMD.GROUPCLEAR = 37
[source]
REPAIR
CMD.REPAIR = 40
[source]
FIRE_STATE
CMD.FIRE_STATE = 45
[source]
MOVE_STATE
CMD.MOVE_STATE = 50
[source]
SETBASE
CMD.SETBASE = 55
[source]
INTERNAL
CMD.INTERNAL = 60
[source]
SELFD
CMD.SELFD = 65
[source]
LOAD_UNITS
CMD.LOAD_UNITS = 75
[source]
LOAD_ONTO
CMD.LOAD_ONTO = 76
[source]
UNLOAD_UNITS
CMD.UNLOAD_UNITS = 80
[source]
UNLOAD_UNIT
CMD.UNLOAD_UNIT = 81
[source]
ONOFF
CMD.ONOFF = 85
[source]
RECLAIM
CMD.RECLAIM = 90
[source]
CLOAK
CMD.CLOAK = 95
[source]
STOCKPILE
CMD.STOCKPILE = 100
[source]
MANUALFIRE
CMD.MANUALFIRE = 105
[source]
DGUN
CMD.DGUN = 105
[source]
RESTORE
CMD.RESTORE = 110
[source]
REPEAT
CMD.REPEAT = 115
[source]
TRAJECTORY
CMD.TRAJECTORY = 120
[source]
RESURRECT
CMD.RESURRECT = 125
[source]
CAPTURE
CMD.CAPTURE = 130
[source]
AUTOREPAIRLEVEL
CMD.AUTOREPAIRLEVEL = 135
[source]
LOOPBACKATTACK
CMD.LOOPBACKATTACK = 20
[source]
IDLEMODE
CMD.IDLEMODE = 145
[source]