(info) Other great resources: Official JS API docs, Scripting Forum

enumEnemyStruct(structure[,viewer])

Returns an array of all enemy structures of a given type, optionally filtered to visibility of lookingPlayer.

 

Code

function enumEnemyStruct(structure,viewer) {
  var list = [];
  var enemies = getEnemyPlayerIDs();
  enemies.forEach(function(enemy) {
    if (!!viewer) {
      list = list.concat(enumStruct(enemy,structure,viewer));
    } else {
      list = list.concat(enumStruct(enemy,structure));
    }
  });
  return list;
}

Example

// get a list of enemy oil derricks
var enemyDerricks = enumEnemyStruct(RESOURCE_EXTRACTOR);

Availability

Requires:

See also

Related articles:

Â