backport.orderDroid.js

Overview

Adds orderDroid() function if missing, and extends orderDroid() to enable DORDER_RECYCLE and DORDER_DESTRUCT.

Availability

 Requires backport.js and backport.dorder.js

Compatible with all versions of Warzone from 3.1 Beta 1 and above.

Notes

The orderDroid() function was added in Warzone 3.2 to allow basic orders (that don't require a location or object) to be issued to droids. This backport script implements orderDroid() in earlier versions of warzone.

In addition, it adds a simple API for implementing additional orders and provides to examples that add support for DORDER_DESTRUCT and DORDER_RECYCLE orders.

Adding new orders

To add a new order, create a new function and add it to the orderDroid.DORDER object. An example is shown below:

// define DORDER_DESTRUCT (custom extension) if DORDER_DESTRUCT constant is defined
if (DORDER_DESTRUCT) orderDroid.DORDER[DORDER_DESTRUCT] = function(droid,order) {
  try { // orderDroid() might support this in future
    return orderDroid.native(droid,order);
  } catch(err) { // but it doesn't currently so use alternative
    return orderDroidLoc(droid,order,droid.x,droid.y);
  }
}

If there is a chance that the order will be supported by orderDroid() in a future version of the JS API then its worth having your function try the native function first, before resorting to an alternate approach using something like orderDroidObj() or orderDroidLoc().

Supported DORDER's

  • Page:
    DORDER_DESTRUCT — Instruct a droid to self-destruct!
  • Page:
    DORDER_HOLD — Instruct the droid to hold its current position until instructed otherwise.
  • Page:
    DORDER_REARM — Instruct a VTOL to return to a rearming pad for repairs and rearming.
  • Page:
    DORDER_RECYCLE — Recycle a droid...
  • Page:
    DORDER_RTB — Instruct a droid to return to your base.
  • Page:
    DORDER_RTR — Instruct a land droid to go to a repair facility for repairs.
  • Page:
    DORDER_STOP — Instruct a droid to stop what it's doing.

(warning) If you try using any other order, you will get an error.

Script

  File Modified

JavaScript File orderDroid_0.1.js

Mar 05, 2012 by Aubergine

See also

  • Droids – quick reference of JS API features relating to droids
  • Droid object – query a droid's existing order via the .order property
  • .order – documentation of order constants + example code
  • orderDroid() – give a droid a simple order (that's not based on an object or location)
  • orderDroidLoc() – tell a droid to perform an order in relation to a map location
  • orderDroidObj() – tell a droid to perform an order in relation to a game object