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

enumDroid()

Returns an array of droid objects, optionally filtered to a specific player, droid type and looking player...

 

Syntax

var returnValue = enumDroid([player[, droidType[, viewer]]]);

Parameters

ParameterTypeMandatoryDescriptionGame version
playerNumber(error)

The ID number of the player who's droids you want to list.

Defaults to me.

3.1 Beta 1
droidTypeConstant(error)

The type of droid you want to list:

  • 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.

Default: DROID_ANY

3.1 Beta 1
viewerNumber(error)

List droids that a specific player can see (eg. on their sensors), with the player specified by their player ID.

Defaults: -1 which means "don't filter based on viewer".

3.1 Beta 1

Return value

ValueTypeDescriptionGame version
<array>ArrayAn array of Droid objects3.1 Beta 1
[]ArrayIf no matching droids are found, you get an empty array.3.1 Beta 1
<error>ErrorIf the player/viewer or droid type specified is incorrect, an error is thrown.3.1 Beta 1

Notes

The enumDroid() function will not list droids that are embarked on transports – to list those, use enumCargo() instead.

In Warzone 3.1.0 and earlier, the function would not return combat engineers or cyborg mechanics when using the DROID_CONSTRUCT or DROID_REPAIR constants. Instead you have to pass in a cyborg-specific value on the droidType parameter:

Name: Combat EngineerConstruction Truck Cyborg Mechanic Repair Droid 
Icon:
droidType:10DROID_CONSTRUCT11DROID_REPAIR

In addition, in 3.1.0 and earlier, super-cyborgs were classified as DROID_WEAPON instead of DROID_CYBORG.

In the early WZ 3.1 Beta releases, bug #3123 prevented scripts from getting lists of scavenger droids and structures. See scavengerPlayer for some ideas as to how to deal with that.

There have been several changes to the Droid objects that are returned by this function.

Examples

Get a list of all my droids
var myDroids = enumDroid();
Build an array of all enemy droids we can see
// for Warzone 3.1 RC3 or earlier, you'll need to define DROID_ANY
// const DROID_ANY = 15;
 
var enemyDroids = [];
 
playerData.forEach(function(player, id) {
  if (!allianceExistsBetween(me, id)) { // enemy player
    enemyDroids = enemyDroids.concat(enumDroid(id, DROID_ANY, me));
  }
});
Availability 3.1 B1+

Requires:

  • Warzone 3.1 Beta 1 and above.
  • (warning) Issues with cyborgs in 3.1.0 and earlier
Contents

Jump to:

See also

Related articles:

  • Droids – quick reference to all JS API stuff relating to droids
  • countDroid() – count the number of droids owned by specified player(s)
  • enumBlips() – get a list of radar detector blips on the map
  • enumFeature() – get a list of features on the map
  • enumStruct() – get a list of structures on the map