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

DORDER_HELPBUILD

Overview

Instruct a construction droid to help with an existing structure building site.

Availability

Warzone 3.1 Beta 1 and above.

Example

// function that will identify part-built structures:
var toPartiallyBuilt = function(struct) {
  return struct.status == BEING_BUILT;
}
 
// function that will find free trucks:
var busyOrders = [
  DORDER_BUILD,     // building
  DORDER_HELPBUILD, // building
  DORDER_LINEBUILD, // building
  DORDER_DEMOLISH,  // demolishing
  DORDER_REPAIR,    // repairing a building
  DORDER_RTR,       // getting repaired
  DORDER_RECYCLE,   // getting recycled (not sure about this one)
  DORDER_SCOUT      // scouting
];
var toFreeTrucks = function(droid) {
  var order = droid.order;
  return !busyOrders.some( function(busy) {return order==busy;} );
}

// get list of part-built structures:
var buildingSites = enumStruct().filter(toPartiallyBuilt);
 
// get list of free builders:
var freeBuilders = enumDroid(me,DROID_CONSTRUCT).filter(toFreeTrucks);
// Note: Should probably check that there are buildingSites before doing a costly enumDroid()
 
// get our free builders to help out where needed:
if (buildingSites.length && freeBuilders.length) {
  buildingSites.forEach(
    function(site) {
      if (freeBuilders.length) orderDroidObj(freeBuilders.shift(),DORDER_HELPBUILD,site);
    }
  )
}

Notes

The droid's current order can be determined from it's .order property. For more information see Droid object.

There's currently no easy way to determine how many builders are helping at a building site. A side effect of this is that you can end up with way too many construction droids working on one site.

See also