// we can't count DROID_WEAPON so have to approximate...
// start by getting count of all enemy droids
var totalEnemies = countDroid(DROID_ANY, ENEMIES);
// now remove trucks and commanders
var approxWeapons = totalEnemies
- countDroid(DROID_COMMAND, ENEMIES)
- countDroid(DROID_CONSTRUCT, ENEMIES);
// there may be some sensors/ECMs, transports and repair droids in there,
// but not that many so the figure will be pretty accurate
// if you need to make it more accurate...
var actualWeapons = approxWeapons;
// count weapons for each enemy
playerData.forEach(function(player, id) {
if (!allianceExistsBetween(me, id)) { // enemy
actualWeapons -= enumDroid(id, DROID_ECM).length;
actualWeapons -= enumDroid(id, DROID_REPAIR).length;
actualWeapons -= enumDroid(id, DROID_SENSOR).length;
actualWeapons -= enumDroid(id, DROID_SUPERTRANSPORTER).length;
actualWeapons -= enumDroid(id, DROID_TRANSPORTER).length;
}
});
// ...but is the extra accuracy worth it?
// alternatively, you could do this...
var actualWeapons = 0;
playerData.forEach(function(player, id) {
if (!allianceExistsBetween(me, id)) { // enemy
actualWeapons += enumDroid(id, DROID_WEAPON).length;
actualWeapons += enumDroid(id, DROID_CYBORG).length;
}
});
// ...but in late game there will be so many weapon droids that doing it
// this way will actually be slower than the more bloaty approach shown
// earlier (there will be very few ecm/repair/sensor/transport droids...)
This function is significantly faster than using enumDroid() and inspecting the .length property of the returned array, because countDroid() is referencing an existing value within the game engine and just returning that value.
Availability 3.1.0+
Requires:
Warzone 3.1.0 or above
Contents
Jump to:
See also
Related articles:
getDroidLimit() – inspect current droid production limits for a given player