(info) Other great resources: Official JS API docs, Scripting Forum

buildDroid()

Instruct a factory to build a droid...

 

Syntax

For warzone 3.1 and earlier:

WZ v3.1
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):

WZ v3.2+
buildDroid(factory, name, body, propulsion, null, null, turret[, turret2[, turret3]]);

Parameters

ParameterTypeMandatoryDescriptionGame version
factoryStructure object(tick)

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
nameString(tick)

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

(tick)

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

(tick)

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+)

(tick)

In warzone 3.1 and earlier, you have to specify the droidType and it must match the type of droid being built:

  • DROID_WEAPONA droid capable of attacking other droids.
  • DROID_CYBORGA cyborg warrior capable of attacking the enemy.
  • DROID_COMMANDA commander unit, to which other units can be assigned.
  • DROID_ECMA droid that has an Electronic Counter Measures (radar jammer) turret.
  • DROID_SENSOR
  • DROID_CONSTRUCTA construction truck or a cyborg engineer.
  • DROID_SUPERTRANSPORTERA heavy transport unit, capable of airlifting any type of droid (including VTOLs) to some other location on the map...
  • DROID_PERSONA droid that uses "legs" propulsion, for example a civilian or a scavenger machinegunner.
  • DROID_REPAIRA droid that has a repair turret, capable of repairing other droids.
  • DROID_TRANSPORTERA cyborg transporter (or possibly a super transporter in Warzone 3.1 Beta 4 and earlier), capable of airlifting droids to some other location on the map.
  • DROID_ANYUsed to bypass droid type filtering in functions that list or count droids.

In Warzone 3.2 and later, pass in null – the function will determine the droid type automatically.

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

(tick)

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

(error)

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.

(question)
turret3

String

Array of String

(error)

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.

(question)

Return value

ValueTypeDescriptionGame version
trueBooleanThe factory is building you a shiny new droid.3.1 Beta 1
falseBooleanSomething went wrong - check the logs to find out what.3.1 Beta 1
<error>ErrorThe structure you specified doesn't exist, isn't owned by you, or isn't a factory. Duh!3.1 Beta 1

Example

Creating cyborg engineers and mechanics - Works in Warzone 3.1 and 3.2
// cyborg engineer
buildDroid(
	borgFactory,
	"Cyb-Engineer",
	"Cyb-Bod-ComEng",
	"CyborgLegs",
	"",
	10,
	"CyborgSpade"
);
 
// cyborg mechanic
buildDroid(
	borgFactory,
	"Cyb-Mechanic",
	"Cyb-Bod-Mechanic",
	"CyborgLegs",
	"",
	11,
	"CyborgRepair"
);
Be careful when creating cyborg engineers and mechanics on WZ 3.1 – see examples for how to make it work. 
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:

See also

How To's:

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:

Organise them:

List or count them:

Tell them what to do:

How to's:

Transfer them between players:

Find out what's happening to droids:

Remove them:

Player Initialisation: