Droid Class

Currently we can do a lot with droids, but the JS API ties our hands somewhat. What should droid objects look like in order to make them more useful and easier to work with?

Note: This isn't a definition of the C++ class, it's the JS class that exposes the C++ class to the JS environment.

Properties

Properties should be getter/setters where applicable - it's bonkers having static properties instead of getters and a huge pile of functions instead of setters

PropertyTypeRead-only?DescriptionValid for
.typeConstant(tick)

What sort of object is this?

  • WZ_TYPE_DROID
All droids
.idNumber(tick)Unique ID for this game objectAll droids
.nameString(tick)The name of this droidAll droids
.playerNumber(tick)

The ID of the player that owns this droid

Transfer a droid to another player using droid.TransferTo(player)

All droids
.selectedBoolean(error)

Has the owner of this droid currently selected it? true/false

All droids
.groupNumber(error)What group is the droid in? null if not in a groupAll droids
.experienceNumber(error)How much experience does the droid have?All droids
.ammoNumber(tick)

How much ammo does the droid have remaining (as a percentage): 100 = full, 0 = empty

If the droid doesn't have weapons / bombs then .ammo = null.

All droids
.costNumber(tick)How much did this droid cost us?All droids
.orderConstant(tick)What is the current order for this droid? (what has it been told to do?)All droids
.actionConstant(tick)What action is the droid currently performing? (how is it doing what it's been told to do?)All droids
.healthNumber(tick)What is the health level of this droid? (0 = pretty much dead, 100 = full health)All droids
.droidTypeConstant(tick)

(question) Is this really applicable any more? Other properties make it kind of redundant.

All droids
.positionPosition(tick)A position object (x,y,z)All droids
.terrainConstant(tick)

What terrain is the droid currently in/on?

  • WZ_TERRAIN_LAND
  • WZ_TERRAIN_AIR
  • WZ_TERRAIN_SEA
All droids
.thermalArmourNumber(tick)What is the thermal armour of this droid?All droids
.kineticArmourNumber(tick)What is the kinetic armour of this droid?All droids
.hasSensorBoolean(tick)Does this droid have a sensor system? true/falseAll droids
.hasCBBoolean(tick)Does this droid have CB system? true/falseAll droids
.hasECMBoolean(tick)Does this droid have ECM system? true/falseAll droids
.hasDetectorBoolean(tick)Does this droid have a radar detector? true/falseAll droids
.assigneesArray(tick)

An array of droid objects assigned to this droid.

Use otherDroid.assignTo(thisDroid) to assign droids.

All droids
.isEngineerBoolean(tick)Can this droid build/repair/demolish structures? true/falseAll droids
.isMechanicBoolean(tick)Can this droid repair droids? true/falseAll droids
.cargoArray of droid objects(tick)

An array of droids in the cargo hold of this droid.

Use droid.embark(transportDroid) to move droids in, droid.disembark() to move out.

.cargo.capacity (Number) indicates maximum capacity of the cargo hold.

remainingSpace = cargo.capacity - cargo.length

 
.canAttackAirNumber(tick)

Can this droid attack aircraft? return count of weapons capable of attacking aircraft

Can be treated as a boolean because 0 coerces to false

All droids
.canAttackGroundNumber(tick)

Can this droid attack ground units/structures/features? return count of weapons capable of attacking ground

Can be treated as a boolean because 0 coerces to false

All droids
.canAttackSeaNumber(tick)

Can this droid attack naval units (ships)? return count of weapons capable of attacking ships

Can be treated as a boolean because 0 coerces to false

 
.canIndirectFireNumber(tick)

Does this droid have an indirect fire weapon? return count of indirect fire turrets

Can be treated as a boolean because 0 coerces to false

All droids
.retreatModeConstant(error)

At what level of damage does the droid retreat?

  • WZ_RETREAT_NONE - do or die
  • WZ_RETREAT_MEDIUM - at medium damage (50%)
  • WZ_RETREAT_HEAVY - at heavy damage (75%)
All droids
.sensorRangeNumber(tick)

The range of the droids sensors/CB.

Each droid will have an innate sensor ability, albeit relatively small. Sensor turrets will greatly increase the sensorRange.

All droids
.attackRangeNumber(tick)

If this droid has weapon turrets, what's the range of it's longest-ranged weapon?

Returns 0 if no weapons.

All droids
.attackModeConstant(error)

How aggressive is the droid?

  • WZ_ATTACK_NONE - hold fire
  • WZ_ATTACK_AGGRESSORS - return fire
  • WZ_ATTACK_AT_WILL - fire at will

All droids

.rangeModeConstant(error)

What range will the droid attack at?

  • WZ_RANGE_SHORT - prefer attack at short range
  • WZ_RANGE_OPTIMAL - prefer attack at optimal range
  • WZ_RANGE_LONG - prefer attack at long range

All droids

.weaponsArray(tick)

An array of weapon objects on this droid

All droids
.systemsArray(tick)

An array of systems (sensor, ECM, CB, etc) objects on this droid

All droids
.baysArray(tick)

An array of bomb/torpedo bay objects on this droid

VTOLs (not transports)

Naval (torpedoes?)

.propulsionConstant(tick)

What sort of propulsion is the droid using?

  • WZ_PROPULSION_HOVER
  • WZ_PROPULSION_WHEELS
  • WZ_PROPULSION_HALFTRACKS
  • WZ_PROPULSION_TRACKS
  • WZ_PROPULSION_VTOL (note: includes transports!)
  • WZ_PROPULSION_NAVAL (ships)
  • WZ_PROPULSION_LEGS (people)
All droids
.bodyString?(tick)

What sort of body does the droid have?

Probably return the ID of the body?

All droids

Methods

MethodDescriptionValid for
.attack(object)

Attack something (target = feature, droid or structure)

Return: true = attacking, false = can't attack / error

Droids with weapons
.move(location)

Move to a location (any object containing x,y properties)

Return: true = moving, false = can't get there / error

All droids
.retreat()

Retreat to HQ or starting position

Return: true = retreating, false = can't retreat / error

All droids
.recycle()

Go and get recycled

Return: true = recycling, false = can't recycle / error

All droids
.build(something,position)

Build something at a location

Return: true = building, false = can't build / error

.isEngineer
.lineBuild(something,position1,position2)

Build a something several times in a line between position1 and position2

Return: true = building, false = can't build / error

.isEngineer
.helpBuild(object)

Help build a structure - either state the structure, or state a droid that's already building stuff

For example, if a droid is line building, you should pass in that droid to get the other droid to also line build.

Return: true = building, false = can't build / error

.isEngineer
.pickUp(feature)

Pick up a feature (oil barrel, artefact)

Return: true = can pick up, false = can't pick up / error

All droids except VTOL propulsion
.demolish(structure)

Demolish structure (only applies to construction droids)

Return: true = demolishing, false = can't demolish / error

Construction droids
.repairStructure(structure)

Repair a structure

Return: true = repairing, false = can't repair / error

.isEngineer
.repairDroid(droid)

Repair another droid

Return: true = repairing, false = can't repair / error

.isMechanic
.repairSelf([object])

Go and get repaired, optionally at a repair station / rearm pad, or by a repair droid.

If repair object not specified, then just find nearest thing that can repair the droid and use that.

Return: true = getting repaired, false = can't repair / error

All droids
.rearm([pad])

Get rearmed/repaired at a rearming pad (chooses nearest pad unless one specified)

Return: true = rearming, false = can't rearm / error

VTOLs (not transports)
.patrol(position1[,position2])

Patrol between two locations.

If position2 not specified, it defaults to droid's current location.

If position2 is specified, then droid proceeds to nearest position (1 or 2) before starting patrol.

Return: true = patrolling, false = can't patrol / error

All droids

.circle(position)

Circle around a specific position

Return: true = circling, false = can't circle / error

VTOLs (not transports)
.defend(object)

Defend a structure or position

Return: true = defending, false = can't defend / error

All droids
.assignTo(object)

Assign the droid to something that .hasSensor or .hasCB

Return: true = assigned, false = can't assign / error

All droids except .hasSensor / .hasCB
.embark(transportDroid)

Move the droid in to a transporter

Return: true = embarking, false = can't embark / error

All droids except transporters
.disembark()

Move droid off a transporter

Return: true = disembarking, false = can't disembark / error

All droids except transporters
.offloadCargo(position)

Offload all cargo (droids) from a transporter at the specified position.

Return: true = cargo disembarking, false = can't offload cargo / error

Transporters
.transferTo(player)Give the droid to another player 

Constants

Currently all the constants associated with droids are stored on global, which is somewhat messy. They either need a WZ_ prefix (just good practice to namespace them) or store them on an object, eg. the Droid class?

There are currently no constants defined for droid secondary orders, things like stance (fire at will, return fire, hold fire) and retreat setting (retreat at heavy damage, medium damage, do or die), etc.