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

isVTOL()

Overview

Determine if a droid is using VTOL propulsion.

You can use this function on droids owned by any player, not just your own.

Note: Recent versions of the API provide an .isVTOL property on Droid objects.

Availability

Warzone 3.1 Beta 2 and above.

Syntax

var returnValue = isVTOL(droid);

Parameters

ParameterTypeMandatoryDescriptionGame version
droidDroid object(tick)The droid that you want to examine.3.1 Beta 2

Return values

ValueTypeDescriptionGame version
trueBooleanThe droid is a VTOL3.1 Beta 2
false
BooleanThe droid is using some other form of propulsion (wheels, hover, half-tracks, tracks, cyborg, etc.)3.1 Beta 2
<error>Error

The droid specified does not exist.

Considering it the droid might have just been destroyed, I highly recommend wrapping this function in a "try ... catch" clause.

Or use the .isVTOL property on a Droid object if you can.

3.1 Beta 2

Examples

Find idle Laser Satellites
var myDroids = enumDroid(me);
for (var i=0; i<myDroids.length; i++) {
  if (isVTOL(myDroids[i])) {
    // do stuff with my VTOL
  }
}

Notes

This function can sometimes break unexpectedly, particularly if it's used in eventDestroyed() or on game objects that aren't droids.

I tend to use something like the function below as an alternative - it checks that the object is a droid and first tries to use the .isVTOL property of the droid object (if found) before using the isVTOL() function as  a last resort:

// More reliable way to identify VTOLs
var isFixVTOL = function(obj) {
  try {
    return ( (obj.type == DROID) && (("isVTOL" in obj && obj.isVTOL) || isVTOL(obj)) );
  } catch(e) {
    console("isFixVTOL(): "+e.message);
  }
}

See also

  • Droids – list of API features associated with droids