go.guessDroidTypeFromStats()

(info) This AI is still in early stages of development.

go.guessDroidTypeFromStats()

This function guesses the droid type from its stats...

 

Syntax

go.guessDroidTypeFromStats(factoryType, body, propulsion, reserved, t1, t2, t3) { // ... guess droidType here ...   return guessedType; // return DROID_ANY if you couldn't guess the type }

Parameters

Parameter

Type

Mandatory

Notes

factoryType

Constant

If the droid is being built in a factory, this will be the .stattype of that factory:

If the droid is being created with addDroid(), this will be:

  • undefined – no factory

body

String

The body component

propulsion

String

The propulsion compoment

reserved

Undefined

Ignore this parameter for now.

t1, t2, t3

String

Up to three turret components

Return value

Your function should return a valid .droidType constant:

If you are unable to determine the droid type, return DROID_ANY.

Notes

The results of the function are cached externally – so there's generally no need to build any additional caching in to your function.

This function is used to guess the droid type for the buildDroid() and addDroid() JS API functions, which in Warzone 3.2 do not use the droidType parameter.

If the external call to buildDroid() or addDroid() specifies a valid droid type, that value will be assumed correct except in the following cases:

  • Cyborg engineers/mecanics (see note below)

  • DROID_ANY – the guess function will be invoked

  • null, undefined or "" – the guess function will be invoked

The Warzone 3.1 bug with cyborg engineers and mechanics is dealt with separately (your function should never return types 10 or 11).

Example

The API provides a default version of this function that is based on standard game stats...

go.guessDroidTypeFromStats = function(factoryType, body, prop, reserved, t1, t2, t3) { if (isDefined(factoryType)) { // simplifies things a little switch (factoryType) { case CYBORG_FACTORY: { // check for non-weapon droids first if (t1.contains("Spade" )) return DROID_CONSTRUCT; if (t1.contains("Repair")) return DROID_REPAIR; // failing that, check if it's a person or cyborg return body.contains("Person") || prop.contains("BaBa") ? DROID_PERSON : DROID_CYBORG ; } case VTOL_FACTORY: { switch (body) { case "TransporterBody" : return DROID_TRANSPORTER; case "SuperTransportBody": return DROID_SUPERTRANSPORTER; default: return DROID_WEAPON; } } case FACTORY: { if (t1.contains("Spade")) return DROID_CONSTRUCT; if (t1.contains("epair")) return DROID_REPAIR; if (t1.contains("ECM")) return DROID_ECM; if (t1.contains("Sensor") || t1.contains("Radar") || t1.contains("CB") || t1.contains("rike")) return DROID_SENSOR ; if (t1.contains("Brain") || t1.contains("Command")) return DROID_COMMAND ; return DROID_WEAPON; } } } else switch (prop) { // work out what factory would be required and try again case "V-Tol" : { arguments[0] = VTOL_FACTORY; return arguments.callee.apply(go, arguments); } case "BaBaLegs" : case "CyborgLegs": { arguments[0] = CYBORG_FACTORY; return arguments.callee.apply(go, arguments); } case "BaBaProp" : case "wheeled01" : case "HalfTrack" : case "tracked01" : case "hover01" : { arguments[0] = FACTORY; return arguments.callee.apply(go, arguments); } } return DROID_ANY; }