Adds orderDroid() function if missing, and extends orderDroid() to enable DORDER_RECYCLE and DORDER_DESTRUCT. |
Requires backport.js and backport.dorder.js
Compatible with all versions of Warzone from 3.1 Beta 1 and above.
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.
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().
If you try using any other order, you will get an error.