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?
Also, would it be worth having distinct objects depending on the type of droid - for example trucks have a load of unique features that other droids can't do. Maybe droid categories could be something like:
- Construction - build, help build, demolish, repair stuff
- Attack - attack stuff
- Sensor - would this just be sensors or also ECM?
- Repair - droids with repair turrets
- Commander - commander droids.
Properties
Methods
...
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
Property | Type | Read-only? | Description | Valid for |
---|---|---|---|---|
.type | Constant | What sort of object is this?
| All droids | |
.id | Number | Unique ID for this game object | All droids | |
.name | String | The name of this droid | All droids | |
.player | Number | The ID of the player that owns this droid Transfer a droid to another player using droid.TransferTo(player) | All droids | |
.selected | Boolean | Has the owner of this droid currently selected it? true/false | All droids | |
.group | Number | What group is the droid in? null if not in a group | All droids | |
.experience | Number | How much experience does the droid have? | All droids | |
.ammo | Number | 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 | |
.cost | Number | How much did this droid cost us? | All droids | |
.order | Constant | What is the current order for this droid? (what has it been told to do?) | All droids | |
.action | Constant | What action is the droid currently performing? (how is it doing what it's been told to do?) | All droids | |
.health | Number | What is the health level of this droid? (0 = pretty much dead, 100 = full health) | All droids | |
.droidType | Constant | Is this really applicable any more? Other properties make it kind of redundant. | All droids | |
.position | Position | A position object (x,y,z) | All droids | |
.terrain | Constant | What terrain is the droid currently in/on?
| All droids | |
.thermalArmour | Number | What is the thermal armour of this droid? | All droids | |
.kineticArmour | Number | What is the kinetic armour of this droid? | All droids | |
.hasSensor | Boolean | Does this droid have a sensor system? true/false | All droids | |
.hasCB | Boolean | Does this droid have CB system? true/false | All droids | |
.hasECM | Boolean | Does this droid have ECM system? true/false | All droids | |
.hasDetector | Boolean | Does this droid have a radar detector? true/false | All droids | |
.assignees | Array | An array of droid objects assigned to this droid. Use otherDroid.assignTo(thisDroid) to assign droids. | All droids | |
.isEngineer | Boolean | Can this droid build/repair/demolish structures? true/false | All droids | |
.isMechanic | Boolean | Can this droid repair droids? true/false | All droids | |
.cargo | Array of droid objects | 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.
| ||
.canAttackAir | Number | 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 | |
.canAttackGround | Number | 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 | |
.canAttackSea | Number | 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 | ||
.canIndirectFire | Number | 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 | |
.retreatMode | Constant | At what level of damage does the droid retreat?
| All droids | |
.sensorRange | Number | 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 | |
.attackRange | Number | If this droid has weapon turrets, what's the range of it's longest-ranged weapon? Returns 0 if no weapons. | All droids | |
.attackMode | Constant | How aggressive is the droid?
| All droids | |
.rangeMode | Constant | What range will the droid attack at?
| All droids | |
.weapons | Array | An array of weapon objects on this droid | All droids | |
.systems | Array | An array of systems (sensor, ECM, CB, etc) objects on this droid | All droids | |
.bays | Array | An array of bomb/torpedo bay objects on this droid | VTOLs (not transports) Naval (torpedoes?) | |
.propulsion | Constant | What sort of propulsion is the droid using?
| All droids | |
.body | String? | What sort of body does the droid have? Probably return the ID of the body? | All droids |
Methods
Method | Description | Valid 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) |
.demolish() | Demolish something (only applies to construction droids) | |
.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. However, they have a naming convention, for example DROID_* refers to droid types, and DORDER_* refers to droid orders.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.
...