$customHeader
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

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

ParameterTypeMandatoryDescriptionGame version
gameObject

Droid object

Structure object

Feature object

(tick)

An object representing the droid or structure that was just destroyed.

Also, if a player picks up a barrel, artefact, or claims an oil resource, this event will be called with a feature object. Note, however, that regardless of who interacts with the artefact/resource the .player value will always be that of your script. So, you can detect when a barrel/artefact is picked up or when an oil resource is claimed but you can't determine who by.

(warning) 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
  • No labels