Overview
This event is triggered when one of your droids or structures ceases to exist due to being destroyed, recycled or demolished.If you want to know when something you don't own is destroyed, or when map features (like trees) are destroyed, use the bind() function instead.
Avilability
Warzone 3.1 Beta 1 and above.
Syntax
function eventDestroyed(gameObject) { // do stuff }
Parameters
Parameter | Type | Mandatory | Description | Game version |
---|---|---|---|---|
gameObject | An object representing the droid or structure that was just destroyed. Also, if you pick up a barrel, artefact, or claim an oil resource, this event will be called with a feature object where the "player" property is set to the player that picked the item up or, in the case of an oil resource, build a derrick on it. This object will quickly be deleted from the game data so it must not be used in further API calls. | 3.1 Beta 1 |
Return value
Warzone does not process the event handler's return value.
Example
Process the object differently based on it's type
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 == BEING_DEMOLISHED indicates structure was demolished by truck break; } default: { debug("eventDestroyed: Unknown object type: "+gameObject.type); } } }
See also
- bind() – monitor other players' objects (and even features) to get notified when they are destroyed
- eventAttacked() – find out what's attacking your objects