Other great resources: Official JS API docs, Scripting Forum
eventDestroyed()
- Aubergine
Â
Syntax
function eventDestroyed(gameObject) { // do stuff }
Parameters
Parameter | Type | Mandatory | Description | Game version |
---|---|---|---|---|
gameObject | The droid, structure or feature that was just destroyed. See "Notes" section below for important information. | 3.1 Beta 1 Updated in Warzone 3.2 |
Return value
Warzone does not process the event handler's return value.
Notes
By the time the event is triggered, the gameObject will already have been removed from the map so you can't use it with any other JS API functions – it's for reference purposes only.
This event is unthrottled, it will be called whenever an object is destroyed – avoid complex or time consuming processing in your event handler.
In Warzone 3.1, the event is triggered when:
- One of your droids is destroyed or recycled
- One of your structures is destroyed or demolished
- A barrel or artifact is picked up (note: gameObject.player is incorrectly reported as me on these objects)
- An oil resource is claimed by any player (note: gameObject.player is incorrectly reported as me)
In Warzone 3.2 and above, the event is triggered when:
- Same scenarios as above, but also...
- Any droid or structure owned by any other player.
As such, it's vital to check which player the destroyed gameObject belongs to before deciding how to react, regardless of game version.
Example
function eventDestroyed(gameObject) { switch (gameObject.type) { case DROID: { // do stuff when a droid is destroyed // gameObject.order == DORDER_RECYCLE indicates droid was destroyed due to recycling break; } case STRUCTURE: { // do stuff when a structure is destroyed // gameObject.status != BUILT indicates structure was demolished by truck break; } case FEATURE: { // a feature was destroyed, picked up or claimed } default: { debug("eventDestroyed: Unknown object type: "+gameObject.type); } } }Â
Availability 3.1 B1+
Requires:
- Warzone 3.1 or above
- Event scope changed in Warzone 3.2
Contents
Jump to:
See also
Related articles:
- bind() – monitor other players' objects (and even features) to get notified when they are destroyed
- eventAttacked() – find out what's attacking your objects
- eventGroupLoss() – triggered when an object is removed from a group
Â