Other great resources: Official JS API docs, Scripting Forum
buildDroid()
- Aubergine
- JB
Syntax
For warzone 3.1 and earlier:
buildDroid(factory, name, body, propulsion, "", droidType, turret[, turret2[, turret3]]);
In master / warzone 3.2 and later, the droidType parameter is no longer required (it is determined automatically in order to fix bug #3133):
buildDroid(factory, name, body, propulsion, null, null, turret[, turret2[, turret3]]);
Parameters
Parameter | Type | Mandatory | Description | Game version |
---|---|---|---|---|
factory | Structure object | The factory in which the droid should be constructed. You must own this structure! The structure's .status must be BUILT, and it must be idle (not currently building anything). The structure's .stattype must be the correct type of structure for the droid's propulsion type:
| 3.1 Beta 1 | |
name | String | The name to give the droid, for example "Bob the Droid". It's useful to base the name on the purpose of the droid, for example "AT" for droids that are designed to attack tanks. You can then quickly find droids by looking through a list of Droid objects returned by the enumDroid() function. | 3.1 Beta 1 | |
body | String Array of String | The body that your droid will use. You can quickly find the ID strings for bodies in the online guide - just click any body and look at "Body ID". If you pass in an array of body types, the first available body in the list will be used. | 3.1 Beta 1 | |
propulsion | String Array of String | The propulsion the droid will use. If you pass in an array of propulsion types, the first available propulsion in the list will be used. | 3.1 Beta 1 | |
droidType | Number (in wz 3.1) Null (in wz 3.2+) | In warzone 3.1 and earlier, you have to specify the droidType and it must match the type of droid being built:
In Warzone 3.2 and later, pass in If your script needs to work on both v3.1 and v3.2, specify the droid type (it will be ignored in 3.2) but bear in mind the issues with cyborg engineers and mechanics in Warzone 3.1 (bug #3133) – see examples below. | 3.1 Beta 1 Simplified in 3.2 | |
turret | String Array of String | The turret (weapon, sensor, etc) that will be placed on the droid. If you pass in an array of turrets, the first available turret in the list will be used. | 3.1 Beta 1 | |
turret2 | String Array of String | If the body can handle 2 or more turrets, this parameter can be specified to define the second turret if desired. If the body can't handle 2 or more turrets, do not specify this parameter. | ||
turret3 | String Array of String | If the body can handle 3 turrets, this parameter can be specified to define the third turret if desired. Note that you must define the second turret (turret2) parameter if you want to define the third turret (turret3). If the body can't handle 3 turrets, do not define this parameter. |
Return value
Value | Type | Description | Game version |
---|---|---|---|
true | Boolean | The factory is building you a shiny new droid. | 3.1 Beta 1 |
false | Boolean | Something went wrong - check the logs to find out what. | 3.1 Beta 1 |
<error> | Error | The structure you specified doesn't exist, isn't owned by you, or isn't a factory. Duh! | 3.1 Beta 1 |
Example
// cyborg engineer buildDroid( borgFactory, "Cyb-Engineer", "Cyb-Bod-ComEng", "CyborgLegs", "", 10, "CyborgSpade" ); // cyborg mechanic buildDroid( borgFactory, "Cyb-Mechanic", "Cyb-Bod-Mechanic", "CyborgLegs", "", 11, "CyborgRepair" );
Availability 3.1 B1+
Requires:
- Warzone 3.1 Beta 1 and above.
- Warzone 3.2 makes cyborg engineer/mechanic production more reliable
Contents
Jump to:
Scripting: Droids
Related objects:
Constants:
- .action – what action is the droid doing?
- .droidType – what category of droid is it?
- .order – what is the droids order?
Create them:
- makeTemplate() – check various things before building a droid
- componentAvailable() – is a component (propulsion, body or turret) available?
- addDroid() – instantly add a droid to the map
- buildDroid() – produce a droid at a factory
- getDroidProduction() – find out what droid a factory is currently producing
- setDroidExperience() – set experience of a droid
Organise them:
List or count them:
- hackGetObj() – get a single droid
- enumDroid() – list droids on the map
- enumArea() – list droids in specific area
- enumRange() – list droids near a location
- enumGroup() – list droids in a group
- enumSelected() – list droids that are selected
- countDroid() – count droids
Tell them what to do:
- orderDroid() – give a basic order
- droidCanReach() – can the droid reach it's destination?
- propulsionCanReach() – can a specific propulsion travel between two points?
- orderDroidBuild() – build a structure
- orderDroidLoc() – move to a location the map
- orderDroidObj() – do something to another object (attack, repair, etc)
How to's:
- Working with Commanders
- Working with Factories
- Working with Repairs & Rearming
- Working with Sensors
- Working with Transports
- Working with Construction
- Working with VTOLs
Transfer them between players:
- donateObject() – donate a droid to an ally
- eventObjectTransfer() – a droid was transferred or assimilated
Find out what's happening to droids:
- eventDroidBuilt() – droid built or added
- eventDroidIdle() – current orders completed
- eventSelectionChange() – human (de)selects droids
- eventArea<Label>() – droid enters a labelled area
- eventObjectSeen() – droid appears on your sensors
- eventAttacked() – cluster was attacked
- eventAttackedUnthrottled() – same as above, but unthrottled
- eventPickup() – picked up an artifact or oil drum
- eventDestroyed(), bind() – destroyed or recycled
Remove them:
- removeObject() – instantly remove a droid
- DORDER_DESTRUCT – an alternate method
- DORDER_RECYCLE – recycle a droid
- enableTemplate() – allow construction trucks to be built before HQ
- enableComponent() – make a droid component available to research
- makeComponentAvailable() – make a droid component available
- setDesign() – enable or disable design mode
- setDroidLimit() – limit the number of droids a player can make
- getDroidLimit() – determine the limits set for droids
- setExperienceModifier() – change rate at which droids gain experience