Other great resources: Official JS API docs, Scripting Forum
addDroid()
- Aubergine
Syntax
// Warzone 3.1 syntax addDroid(player, x, y, name, body, propulsion, reserved, droidType, t1[, t2[, t3]]); // Warzone 3.2 syntax -- droidType no longer required addDroid(player, x, y, name, body, propulsion, reserved, null, t1[, t2[, t3]]);
Parameters
Parameter | Type | Mandatory | Notes | Availability |
---|---|---|---|---|
player | Number | The ID of the player who will own the droid. | 3.1 B1+ | |
x | Number | The x co-ordinate (tile) where the droid should be added. | 3.1 B1+ | |
y | Number | The y co-ordinate (tile) where the droid should be added. | 3.1 B1+ | |
name | String | The name of the droid. | 3.1 B1+ | |
body | String | The body component. | 3.1 B1+ | |
propulsion | String | The propulsion component. | 3.1 B1+ | |
reserved | Null | Not currently used, specify null . | 3.1 B1+ | |
droidType | Constant Null | 3.1 3.2+ | On Warzone 3.1 branch, a droidType must be specified:
Note: DROID_ANY is not a valid value. On Warzone 3.2 and above, the droidType is no longer required as Warzone will work it out automatically. | 3.1 BRANCH Not required in 3.2. |
t1 | String | The first turret to attach to the droid. | 3.1 B1+ | |
t2 | String | The second, optional, turret to attach to the droid. | 3.1 B1+ | |
t3 | String | The third, optional, turret to attach to the droid. | 3.1 B1+ |
Return values
Value | Type | Notes | Availability |
---|---|---|---|
<droid> | Droid object | On Warzone 3.2 and above, if the droid is created its associated droid object will be returned. | 3.2+ |
null | Null | In Warzone 3.2 and above, if the droid is not created, null is returned. | 3.2+ |
true | Boolean | In Warzone 3.1 branch, true is returned if the droid was created. | 3.1 BRANCH |
false | Boolean | In Warzone 3.1 branch, false is returned if the droid was created. | 3.1 BRANCH |
<error> | Error | Most likely invalid parameters. | 3.1 B1+ |
Notes
If this function is used in a multiplayer game, a desync will occur.
If you're making cyborg engineers or mechanics on Warzone 3.1, there is a bug with the droidType parameter – see notes in buildDroid() for more information and how to work around it.
Unlike buildDroid(), this function places the droid on the map instantly at no cost to the player. In addition, there are no checks on which turrets are specified – so, for example, you can put non-VTOL turrets on VTOLs (pic from NoQ):
Examples
Anyone want to post an example?
Availability 3.2+
Requires:
- Warzone 3.1 Beta 1
- Improved and bug-fixed in Warzone 3.2
Contents
Jump to:
Scripting: Droids
Related objects:
Constants:
- .action – what action is the droid doing?
- .droidType – what category of droid is it?
- .order – what is the droids order?
Create them:
- makeTemplate() – check various things before building a droid
- componentAvailable() – is a component (propulsion, body or turret) available?
- addDroid() – instantly add a droid to the map
- buildDroid() – produce a droid at a factory
- getDroidProduction() – find out what droid a factory is currently producing
- setDroidExperience() – set experience of a droid
Organise them:
List or count them:
- hackGetObj() – get a single droid
- enumDroid() – list droids on the map
- enumArea() – list droids in specific area
- enumRange() – list droids near a location
- enumGroup() – list droids in a group
- enumSelected() – list droids that are selected
- countDroid() – count droids
Tell them what to do:
- orderDroid() – give a basic order
- droidCanReach() – can the droid reach it's destination?
- propulsionCanReach() – can a specific propulsion travel between two points?
- orderDroidBuild() – build a structure
- orderDroidLoc() – move to a location the map
- orderDroidObj() – do something to another object (attack, repair, etc)
How to's:
- Working with Commanders
- Working with Factories
- Working with Repairs & Rearming
- Working with Sensors
- Working with Transports
- Working with Construction
- Working with VTOLs
Transfer them between players:
- donateObject() – donate a droid to an ally
- eventObjectTransfer() – a droid was transferred or assimilated
Find out what's happening to droids:
- eventDroidBuilt() – droid built or added
- eventDroidIdle() – current orders completed
- eventSelectionChange() – human (de)selects droids
- eventArea<Label>() – droid enters a labelled area
- eventObjectSeen() – droid appears on your sensors
- eventAttacked() – cluster was attacked
- eventAttackedUnthrottled() – same as above, but unthrottled
- eventPickup() – picked up an artifact or oil drum
- eventDestroyed(), bind() – destroyed or recycled
Remove them:
- removeObject() – instantly remove a droid
- DORDER_DESTRUCT – an alternate method
- DORDER_RECYCLE – recycle a droid
- enableTemplate() – allow construction trucks to be built before HQ
- enableComponent() – make a droid component available to research
- makeComponentAvailable() – make a droid component available
- setDesign() – enable or disable design mode
- setDroidLimit() – limit the number of droids a player can make
- getDroidLimit() – determine the limits set for droids
- setExperienceModifier() – change rate at which droids gain experience