createUnit: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 11: Line 11:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Create an interacting AI soldier. |= Description
| Create unit of given '''type'''.
____________________________________________________________________________________________


| type '''createUnit''' [position, group, init*, skill*, rank*] * optional, if one is set, all precedent arguments have to be set too |= Syntax
Format of '''unitInfo''' is:


|p1= type: [[String]] - type of the unit that should be created |= Parameter 1
[pos ([[Position]]), group ([[Group]]),init ([[String]]), skill ([[Number]]), rank ([[String]])]


|p2= position: [[Position]] - position to create the unit at |= Parameter 2
init, skill and rank are optional, default values are: "", 0.5, "PRIVATE".


|p3= group: [[Group]] - group were the unit will belong to. This group has to exist already! It is not possible to use grpNull as argument. |= Parameter 3
The Group parameter '''MUST''' be an existing group or the unit won't be created. |= Description
____________________________________________________________________________________________


|p4= init: [[String]] - commands that are executed when the unit has been created. The unit is stored in the ''[[this]]'' variable. The default value is "". |= Parameter 4
| type '''createUnit''' unitInfo |= Syntax


|p5= skill: [[Number]] - range 0 to 1. 0 is the lowest skill, 1 the highest. The default value is 0.5. If this argument is set, init must be set too. |= Parameter 5
|p1= type: [[String]] - Classname of unit to be created |= Parameter 1


|p6= rank: [[String]] - one of "PRIVATE", "CORPORAL", "SERGEANT", "LIEUTNANT", "CAPTAIN", "MAJOR" and "COLONEL". If this argument is set, init and skill must be set too. |= Parameter 6
|p2= unitInfo: [[Array]] |= Parameter 2


| [[Nothing]] |= Return value
| [[Nothing]] |= Return value
Line 35: Line 35:
   
   
|x1= <pre>"SoldierWB" createUnit [position player, group player]</pre> |= Example 1
|x1= <pre>"SoldierWB" createUnit [position player, group player]</pre> |= Example 1
|x2= <pre>"soldierWB" createUnit [getMarkerPos "barracks", groupAlpha]</pre> |= Example 2
|x3= <pre>"soldierWB" createUnit [getMarkerPos "marker_1", groupAlpha,"loon1 = this ;
this addweapon {binocular}, 0.6, "corporal"]</pre> |= Example 3
____________________________________________________________________________________________
____________________________________________________________________________________________



Revision as of 13:28, 28 February 2007

Hover & click on the images for description

Description

Description:
Create unit of given type. Format of unitInfo is: [pos (Position), group (Group),init (String), skill (Number), rank (String)] init, skill and rank are optional, default values are: "", 0.5, "PRIVATE". The Group parameter MUST be an existing group or the unit won't be created.
Multiplayer:
The code in init is executed on all connected clients in multiplayer. It can therefore be used to get around the publicVariable limitation of not being able to send strings and arrays over the network.
Groups:
Uncategorised

Syntax

Syntax:
type createUnit unitInfo
Parameters:
type: String - Classname of unit to be created
unitInfo: Array
Return Value:
Nothing

Examples

Example 1:
"SoldierWB" createUnit [position player, group player]
Example 2:
"soldierWB" createUnit [getMarkerPos "barracks", groupAlpha]
Example 3:
"soldierWB" createUnit [getMarkerPos "marker_1", groupAlpha,"loon1 = this ;
 this addweapon {binocular}, 0.6, "corporal"]

Additional Information

See also:
createVehiclecreateUnit arraycreateVehicle arraycreateVehicleLocaldeleteVehicle

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Posted on August 13, 2006 - 12:32
raedor
Does not return anything. To give a newly created unit a name, put "newUnit = this" in the init.

Bottom Section