Order a construction droid to build a new structure... |
This article is in need of technical review – specifically it seems that in Warzone 3.1.x the function is not returning Please see comments at bottom of page for more info, and please add a comment about what it's actually returning. |
orderDroidBuild(droid, order, structureID, x, y[, direction]) |
Parameter | Type | Mandatory | Notes | Game Version |
---|---|---|---|---|
droid | Droid object | The droid that will build the structure(s). | 3.1 Beta 1 | |
order | Constant | Indicate the construction mode:
Note: Once construction has started, other droids can help with the building process by issuing DORDER_HELPBUILD via the orderDroidObj() function. | 3.1 Beta 1 | |
structureID | String | The ID of the structure you want built. You can find a list of structure ID's in structures.txt or structures.ini (depending on game version). Note: You cannot use structure type constants, you have to specify the specific structure id. | 3.1 Beta 1 | |
x | Number | The x co-ordinate of the top-left corner of the construction site. Note: Always find suitable co-ordinates by using pickStructLocation() first. | 3.1 Beta 1 | |
y | Number | The y co-ordinate of the top-left corner of the construction site. Note: Always find suitable co-ordinates by using pickStructLocation() first. | 3.1 Beta 1 | |
direction | Number | The direction, in degrees from North, in which the front of the building faces when built. Default: 0 (North-facing) It's recommended to use multiples of 90º for the direction, otherwise the structure could adversely affect pathfinding:
| 3.1.0 |
Value | Type | Notes | Game Version |
---|---|---|---|
true | Boolean | The order was successful and the droid will build the structure. | 3.1 Beta 1 |
false | Boolean | There was a problem and the structure will not be built. | 3.1 Beta 1 |
<error> | Error | An error occurred, for example invalid parameters. | 3.1 Beta 1 |
This function replaces the deprecated orderDroidStatsLoc() function.
A typical sequence for building a new structure is:
Only construction droids (trucks and field engineers) of type DROID_CONSTRUCT can build structures.
// define some constants if missing if (typeof NORTH == "undefined") { const NORTH = 0; const EAST = 90; const SOUTH = 180; const WEST = 270; } function isIdle(droid) { var notIdle = [ DORDER_BIULD, DORDER_HELPBUILD, DORDER_LINEBUILD, DORDER_DEMOLISH ]; return (notIdle.indexOf(droid.order) == -1); } function buildA(structure, near) { // can we build the structure? if (!isStructureAvailable(structure)) return false; // get list of construction droids var constructors = enumDroid(me, DROID_CONSTRUCT); // find free droid var freeDroid; constructors.some(function isFree(droid) { if (isIdle(droid)) { freeDroid = droid; return true; } }); // if no free droids abort if (!freeDroid) return false; // find suitable location to build var pos = pickStructLocation(freeDroid, structure, near.x, near.y); // abort if no location found if (!pos) return false; // let's build! return orderDroidBuild( freeDroid, DORDER_BUILD, structure, pos.x, pos.y, NORTH ); } // find where our HQ is var nearMyHQ = enumStuct(me, HQ)[0]; // assuming we already have one buildA("A0LightFactory", nearMyHQ); // build a factory near my HQ |
AvailabilityRequires:
|
ContentsJump to: |
See alsoRelated articles:
Interesting game mods to be aware of:
|