| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| # Warzone2100 JavaScript Scripting API | ||
|
|
||
| ## Introduction | ||
|
|
||
| Warzone2100 contains a scripting language for implementing AIs, campaigns and some of the game | ||
| rules. It uses JavaScript, so you should become familiar with this language before proceeding | ||
| with this document. A number of very good guides to JavaScript exist on the Internet. | ||
|
|
||
| The following hard-coded files exist for game rules that use this API: | ||
|
|
||
| * multiplay/skirmish/rules.js Default game rules - base setup, starting research, winning and losing. | ||
| * multiplay/script/scavfact.js Scavenger AI. This script is active if scavengers are. | ||
|
|
||
| For ordinary AI scripts, these are controlled using AI JSON files that are present in the ```multiplayer/skirmish``` | ||
| directory. Here is an example of such a file that defines an AI implemented using this API: | ||
|
|
||
| ```json | ||
| { | ||
| "AI": { | ||
| "js": "semperfi.js", | ||
| "name": "SemperFi JS", | ||
| "tip": "Rocket and missile technology based AI." | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| It references a '.js' JavaScript file that needs to be in the same directory as the '.json' file. | ||
|
|
||
| The code in a javascript file is accessed through specially named functions called 'events'. These are defined below. | ||
| An event is expected to carry out some computation then return immediately. The game is on hold while an event is | ||
| processed, so do not do too many things at once, or else the player will experience stuttering. | ||
|
|
||
| All global variables are saved when the game is saved. However, do not try to keep JavaScript objects that are | ||
| returned from API functions defined here around in the global scope. They are not meant to be used this way, and | ||
| bad things may happen. If you need to keep static arrays around, it is better to keep them locally defined to a | ||
| function, as they will then not be saved and loaded. | ||
|
|
||
| One error that it is easy to make upon initially learning JavaScript and using this API, is to try to use | ||
| the 'for (... in ...)' construct to iterate over an array of objects. This does not work! Instead, use code | ||
| like the following: | ||
|
|
||
| ```javascript | ||
| var droidlist = enumDroid(me, DROID_CONSTRUCT); | ||
| for (var i = 0; i < droidlist.length; i++) | ||
| { | ||
| var droid = droidlist[i]; | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| The above code gets a list of all your construction droids, and iterates over them one by one. | ||
|
|
||
| The droid object that you receive here has multiple properties that can be accessed to learn more about it. | ||
| These propertie are read-only, and cannot be changed. In fact, objects that you get are just a copies of | ||
| game state, and do not give any access to changing the game state itself. | ||
|
|
||
| Any value written in ALL_CAPS_WITH_UNDERSCORES are enums, special read-only constants defined by the | ||
| game. | ||
|
|
||
| ## Challenges | ||
|
|
||
| Challenges may load scripts as well, if a 'scripts' dictionary is present in the challenge file, and has the keys | ||
| "extra" or "rules". The "extra" key sets up an additional script to be run during the challenge. The "rules" | ||
| key sets up an alternative rules file, which means that the "rules.js" mentioned above is *not* run. In | ||
| this case, you must implement your own rules for winning and losing, among other things. Here is an example | ||
| of such a scripts section: | ||
|
|
||
| ```json | ||
| "scripts": | ||
| { | ||
| "rules": "towerdefense.js" | ||
| } | ||
| ``` | ||
|
|
||
| You can also specify which AI scripts are to be run for each player. These must be given a path to the script, | ||
| since you may sometimes want them from the AI directory (```multiplay/skirmish/```) and sometimes from the challenge | ||
| directory (```challenges/```). If you do not want an AI script to be loaded for a player (for example, if you want | ||
| this player to be controlled from one of your challenge scripts), then you can give it the special value "null". | ||
| Here is an example if a challenge player definition with its AI specified: | ||
|
|
||
| ```json | ||
| "player_1": { | ||
| "name": "Alpha", | ||
| "ai": "multiplay/skirmish/nb_generic.js", | ||
| "difficulty": "Hard", | ||
| "team": 1 | ||
| } | ||
| ``` | ||
|
|
||
| ## Common Objects | ||
|
|
||
| Some objects are described under the functions creating them. The following objects are produced by | ||
| multiple functions and widely used throughout, so it is better to learn about them first. | ||
|
|
||
| Note the special term **game object** that is used in several places in this document. This refers | ||
| to the results of any function returning a Structure, Droid, Feature or Base Object as described below. | ||
| Some functions may take such objects as input parameters, in this case they may not take any other kind | ||
| of object as input parameter instead. | ||
|
|
||
| ## In depth | ||
|
|
||
| Read more in depth about the following topics in their own pages. For newcomers, they are listed in | ||
| the order we recommended reading them in. If you do not intend to change the campaign (or write a | ||
| new campaign), you can skip the campaign topic. | ||
|
|
||
| [Game objects](js-objects.md) | ||
|
|
||
| [Events](js-events.md) | ||
|
|
||
| [Globals](js-globals.md) | ||
|
|
||
| [Functions](js-functions.md) | ||
|
|
||
| [Campaign](js-campaign.md) | ||
|
|
||
| ## Gotchas / Bugs | ||
|
|
||
| ### Case sensitivity | ||
|
|
||
| Due to a bug that is not so easy to fix in the short term, variables defined in global must be case insensitive. | ||
| Otherwise, they may collide on savegame loading. This is only for variables defined in your script. There is no | ||
| need to maintain case insensitivity in regards to variables defined in global by the game itself, such as ```FACTORY``` | ||
| (you can safely define your own 'factory' variable) -- the only exception to this is ```me```. | ||
|
|
||
| ### Global objects | ||
|
|
||
| You must never put a **game object**, such as a droid or a structure, on the global scope. You only get a snapshot | ||
| of their state, the state is not updated, and they are not removed when they die. Trying to store them globally | ||
| then using them later will fail. | ||
|
|
||
| All variables stored in the global scope are stored when the game is saved, and restored when it is loaded. | ||
| However, this may not work properly for complex objects. Basic arrays and basic types are supported, but it is | ||
| generally not recommended to put objects on global, even though simple ones may work. Since the game cannot be | ||
| saved while a function is running, you don't need to worry about local variables. | ||
|
|
||
| Const definitions are not stored in savegames, and are therefore recommended over variables to hold information | ||
| that does not change. | ||
|
|
||
| ### Object states | ||
|
|
||
| Most object states that are changed from the scripts are not in fact changed, but queued up to be synchronized | ||
| among clients. This means that you cannot check the state later in the same script invokation and expect it to | ||
| have changed. This includes such things as giving orders to droids, setting production to structures, and so on. | ||
| Instead, if for example you want to mark droids that have been ordered to do something, you can mark them by | ||
| adding a custom property. Note that this property will not be remembered when it goes out of scope. | ||
|
|
||
| ### Early research | ||
|
|
||
| You cannot set research topics for research labs directly from eventStartLevel. Instead, queue up a function | ||
| call to set it at some later frame. | ||
|
|
||
| ### Cyborg construction | ||
|
|
||
| Cyborg components are inter-linked, and cannot be passed in as lists as you can with ordinary droids, even | ||
| though they might look that way. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| # Events | ||
| This section describes event callbacks (or 'events' for short) that are | ||
| called from the game when something specific happens. Which scripts | ||
| receive them is usually filtered by player. Call ```receiveAllEvents(true)``` | ||
| to start receiving all events unfiltered. | ||
| ## eventGameInit() | ||
| An event that is run once as the game is initialized. Not all game state may have been | ||
| properly initialized by this time, so use this only to initialize script state. | ||
| ## eventStartLevel() | ||
| An event that is run once the game has started and all game data has been loaded. | ||
| ## eventMissionTimeout() | ||
| An event that is run when the mission timer has run out. | ||
| ## eventVideoDone() | ||
| An event that is run when a video show stopped playing. | ||
| ## eventGameLoaded() | ||
| An event that is run when game is loaded from a saved game. There is usually no need to use this event. | ||
| ## eventGameSaving() | ||
| An event that is run before game is saved. There is usually no need to use this event. | ||
| ## eventGameSaved() | ||
| An event that is run after game is saved. There is usually no need to use this event. | ||
| ## eventDeliveryPointMoving() | ||
| An event that is run when the current player starts to move a delivery point. | ||
| ## eventDeliveryPointMoved() | ||
| An event that is run after the current player has moved a delivery point. | ||
| ## eventTransporterLaunch(transport) | ||
| An event that is run when the mission transporter has been ordered to fly off. | ||
| ## eventTransporterArrived(transport) | ||
| An event that is run when the mission transporter has arrived at the map edge with reinforcements. | ||
| ## eventTransporterExit(transport) | ||
| An event that is run when the mission transporter has left the map. | ||
| ## eventTransporterDone(transport) | ||
| An event that is run when the mission transporter has no more reinforcements to deliver. | ||
| ## eventTransporterLanded(transport) | ||
| An event that is run when the mission transporter has landed with reinforcements. | ||
| ## eventDesignBody() | ||
| An event that is run when current user picks a body in the design menu. | ||
| ## eventDesignPropulsion() | ||
| An event that is run when current user picks a propulsion in the design menu. | ||
| ## eventDesignWeapon() | ||
| An event that is run when current user picks a weapon in the design menu. | ||
| ## eventDesignCommand() | ||
| An event that is run when current user picks a command turret in the design menu. | ||
| ## eventDesignSystem() | ||
| An event that is run when current user picks a system other than command turret in the design menu. | ||
| ## eventDesignQuit() | ||
| An event that is run when current user leaves the design menu. | ||
| ## eventMenuBuildSelected() | ||
| An event that is run when current user picks something new in the build menu. | ||
| ## eventMenuBuild() | ||
| An event that is run when current user opens the build menu. | ||
| ## eventMenuResearch() | ||
| An event that is run when current user opens the research menu. | ||
| ## eventMenuManufacture() | ||
| An event that is run when current user opens the manufacture menu. | ||
| ## eventPlayerLeft(player index) | ||
| An event that is run after a player has left the game. | ||
| ## eventCheatMode(entered) | ||
| Game entered or left cheat/debug mode. | ||
| The entered parameter is true if cheat mode entered, false otherwise. | ||
| ## eventDroidIdle(droid) | ||
| A droid should be given new orders. | ||
| ## eventDroidBuilt(droid[, structure]) | ||
| An event that is run every time a droid is built. The structure parameter is set | ||
| if the droid was produced in a factory. It is not triggered for droid theft or | ||
| gift (check ```eventObjectTransfer``` for that). | ||
| ## eventStructureBuilt(structure[, droid]) | ||
| An event that is run every time a structure is produced. The droid parameter is set | ||
| if the structure was built by a droid. It is not triggered for building theft | ||
| (check ```eventObjectTransfer``` for that). | ||
| ## eventStructureReady(structure) | ||
| An event that is run every time a structure is ready to perform some | ||
| special ability. It will only fire once, so if the time is not right, | ||
| register your own timer to keep checking. | ||
| ## eventAttacked(victim, attacker) | ||
| An event that is run when an object belonging to the script's controlling player is | ||
| attacked. The attacker parameter may be either a structure or a droid. | ||
| ## eventResearched(research, structure, player) | ||
| An event that is run whenever a new research is available. The structure | ||
| parameter is set if the research comes from a research lab owned by the | ||
| current player. If an ally does the research, the structure parameter will | ||
| be set to null. The player parameter gives the player it is called for. | ||
| ## eventDestroyed(object) | ||
| An event that is run whenever an object is destroyed. Careful passing | ||
| the parameter object around, since it is about to vanish! | ||
| ## eventPickup(feature, droid) | ||
| An event that is run whenever a feature is picked up. It is called for | ||
| all players / scripts. | ||
| Careful passing the parameter object around, since it is about to vanish! (3.2+ only) | ||
| ## eventObjectSeen(viewer, seen) | ||
| An event that is run sometimes when an object, which was marked by an object label, | ||
| which was reset through resetLabel() to subscribe for events, goes from not seen to seen. | ||
| An event that is run sometimes when an objectm goes from not seen to seen. | ||
| First parameter is **game object** doing the seeing, the next the game | ||
| object being seen. | ||
| ## eventGroupSeen(viewer, group) | ||
| An event that is run sometimes when a member of a group, which was marked by a group label, | ||
| which was reset through resetLabel() to subscribe for events, goes from not seen to seen. | ||
| First parameter is **game object** doing the seeing, the next the id of the group | ||
| being seen. | ||
| ## eventObjectTransfer(object, from) | ||
| An event that is run whenever an object is transferred between players, | ||
| for example due to a Nexus Link weapon. The event is called after the | ||
| object has been transferred, so the target player is in object.player. | ||
| The event is called for both players. | ||
| ## eventChat(from, to, message) | ||
| An event that is run whenever a chat message is received. The ```from``` parameter is the | ||
| player sending the chat message. For the moment, the ```to``` parameter is always the script | ||
| player. | ||
| ## eventBeacon(x, y, from, to[, message]) | ||
| An event that is run whenever a beacon message is received. The ```from``` parameter is the | ||
| player sending the beacon. For the moment, the ```to``` parameter is always the script player. | ||
| Message may be undefined. | ||
| ## eventBeaconRemoved(from, to) | ||
| An event that is run whenever a beacon message is removed. The ```from``` parameter is the | ||
| player sending the beacon. For the moment, the ```to``` parameter is always the script player. | ||
| ## eventSelectionChanged(objects) | ||
| An event that is triggered whenever the host player selects one or more game objects. | ||
| The ```objects``` parameter contains an array of the currently selected game objects. | ||
| Keep in mind that the player may drag and drop select many units at once, select one | ||
| unit specifically, or even add more selections to a current selection one at a time. | ||
| This event will trigger once for each user action, not once for each selected or | ||
| deselected object. If all selected game objects are deselected, ```objects``` will | ||
| be empty. | ||
| ## eventGroupLoss(object, group id, new size) | ||
| An event that is run whenever a group becomes empty. Input parameter | ||
| is the about to be killed object, the group's id, and the new group size. | ||
| ## eventArea<label>(droid) | ||
| An event that is run whenever a droid enters an area label. The area is then | ||
| deactived. Call resetArea() to reactivate it. The name of the event is | ||
| eventArea + the name of the label. | ||
| ## eventDesignCreated(template) | ||
| An event that is run whenever a new droid template is created. It is only | ||
| run on the client of the player designing the template. | ||
| ## eventAllianceOffer(from, to) | ||
| An event that is called whenever an alliance offer is requested. | ||
| ## eventAllianceAccepted(from, to) | ||
| An event that is called whenever an alliance is accepted. | ||
| ## eventAllianceBroken(from, to) | ||
| An event that is called whenever an alliance is broken. | ||
| ## eventSyncRequest(req_id, x, y, obj_id, obj_id2) | ||
| An event that is called from a script and synchronized with all other scripts and hosts | ||
| to prevent desync from happening. Sync requests must be carefully validated to prevent | ||
| cheating! | ||
| ## eventKeyPressed(meta, key) | ||
| An event that is called whenever user presses a key in the game, not counting chat | ||
| or other pop-up user interfaces. The key values are currently undocumented. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Globals | ||
| This section describes global variables (or 'globals' for short) that are | ||
| available from all scripts. You typically cannot write to these variables, | ||
| they are read-only. | ||
| * ```version``` Current version of the game, set in *major.minor* format. | ||
| * ```selectedPlayer``` The player ontrolled by the client on which the script runs. | ||
| * ```gameTime``` The current game time. Updated before every invokation of a script. | ||
| * ```modList``` The current loaded mods. | ||
| * ```difficulty``` The currently set campaign difficulty, or the current AI's difficulty setting. It will be one of | ||
| ```EASY```, ```MEDIUM```, ```HARD``` or ```INSANE```. | ||
| * ```mapName``` The name of the current map. | ||
| * ```tilesetType``` The area name of the map. | ||
| * ```baseType``` The type of base that the game starts with. It will be one of ```CAMP_CLEAN```, ```CAMP_BASE``` or ```CAMP_WALLS```. | ||
| * ```alliancesType``` The type of alliances permitted in this game. It will be one of ```NO_ALLIANCES```, ```ALLIANCES``` or ```ALLIANCES_TEAMS```. | ||
| * ```powerType``` The power level set for this game. | ||
| * ```maxPlayers``` The number of active players in this game. | ||
| * ```scavengers``` Whether or not scavengers are activated in this game. | ||
| * ```mapWidth``` Width of map in tiles. | ||
| * ```mapHeight``` Height of map in tiles. | ||
| * ```scavengerPlayer``` Index of scavenger player. (3.2+ only) | ||
| * ```isMultiplayer``` If the current game is a online multiplayer game or not. (3.2+ only) | ||
| * ```me``` The player the script is currently running as. | ||
| * ```scriptName``` Base name of the script that is running. | ||
| * ```scriptPath``` Base path of the script that is running. | ||
| * ```Stats``` A sparse, read-only array containing rules information for game entity types. | ||
| (For now only the highest level member attributes are documented here. Use the 'jsdebug' cheat | ||
| to see them all.) | ||
| These values are defined: | ||
| * ```Body``` Droid bodies | ||
| * ```Sensor``` Sensor turrets | ||
| * ```ECM``` ECM (Electronic Counter-Measure) turrets | ||
| * ```Propulsion``` Propulsions | ||
| * ```Repair``` Repair turrets (not used, incidentally, for repair centers) | ||
| * ```Construct``` Constructor turrets (eg for trucks) | ||
| * ```Brain``` Brains | ||
| * ```Weapon``` Weapon turrets | ||
| * ```WeaponClass``` Defined weapon classes | ||
| * ```Building``` Buildings | ||
| * ```Upgrades``` A special array containing per-player rules information for game entity types, | ||
| which can be written to in order to implement upgrades and other dynamic rules changes. Each item in the | ||
| array contains a subset of the sparse array of rules information in the ```Stats``` global. | ||
| These values are defined: | ||
| * ```Body``` Droid bodies | ||
| * ```Sensor``` Sensor turrets | ||
| * ```Propulsion``` Propulsions | ||
| * ```ECM``` ECM (Electronic Counter-Measure) turrets | ||
| * ```Repair``` Repair turrets (not used, incidentally, for repair centers) | ||
| * ```Construct``` Constructor turrets (eg for trucks) | ||
| * ```Brain``` Brains | ||
| BaseCommandLimit: How many droids a commander can command. CommandLimitByLevel: How many extra droids | ||
| a commander can command for each of its rank levels. RankThresholds: An array describing how many | ||
| kills are required for this brain to level up to the next rank. To alter this from scripts, you must | ||
| set the entire array at once. Setting each item in the array will not work at the moment. | ||
| * ```Weapon``` Weapon turrets | ||
| * ```Building``` Buildings | ||
| * ```groupSizes``` A sparse array of group sizes. If a group has never been used, the entry in this array will | ||
| be undefined. | ||
| * ```playerData``` An array of information about the players in a game. Each item in the array is an object | ||
| containing the following variables: | ||
| * ```difficulty``` (see ```difficulty``` global constant) | ||
| * ```colour``` number describing the colour of the player | ||
| * ```position``` number describing the position of the player in the game's setup screen | ||
| * ```isAI``` whether the player is an AI (3.2+ only) | ||
| * ```isHuman``` whether the player is human (3.2+ only) | ||
| * ```name``` the name of the player (3.2+ only) | ||
| * ```team``` the number of the team the player is part of | ||
| * ```derrickPositions``` An array of derrick starting positions on the current map. Each item in the array is an | ||
| object containing the x and y variables for a derrick. | ||
| * ```startPositions``` An array of player start positions on the current map. Each item in the array is an | ||
| object containing the x and y variables for a player start position. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| # Game objects | ||
| This section describes various **game objects** defined by the script interface, | ||
| and which are both accepted by functions and returned by them. Changing the | ||
| fields of a **game object** has no effect on the game before it is passed to a | ||
| function that does something with the **game object**. | ||
| ## Research | ||
| Describes a research item. The following properties are defined: | ||
| * ```power``` Number of power points needed for starting the research. | ||
| * ```points``` Number of research points needed to complete the research. | ||
| * ```started``` A boolean saying whether or not this research has been started by current player or any of its allies. | ||
| * ```done``` A boolean saying whether or not this research has been completed. | ||
| * ```name``` A string containing the full name of the research. | ||
| * ```id``` A string containing the index name of the research. | ||
| * ```type``` The type will always be ```RESEARCH_DATA```. | ||
| ## Structure | ||
| Describes a structure (building). It inherits all the properties of the base object (see below). | ||
| In addition, the following properties are defined: | ||
| * ```status``` The completeness status of the structure. It will be one of ```BEING_BUILT``` and ```BUILT```. | ||
| * ```type``` The type will always be ```STRUCTURE```. | ||
| * ```cost``` What it would cost to build this structure. (3.2+ only) | ||
| * ```stattype``` The stattype defines the type of structure. It will be one of ```HQ```, ```FACTORY```, ```POWER_GEN```, | ||
| ```RESOURCE_EXTRACTOR```, ```LASSAT```, ```DEFENSE```, ```WALL```, ```RESEARCH_LAB```, ```REPAIR_FACILITY```, | ||
| ```CYBORG_FACTORY```, ```VTOL_FACTORY```, ```REARM_PAD```, ```SAT_UPLINK```, ```GATE``` and ```COMMAND_CONTROL```. | ||
| * ```modules``` If the stattype is set to one of the factories, ```POWER_GEN``` or ```RESEARCH_LAB```, then this property is set to the | ||
| number of module upgrades it has. | ||
| * ```canHitAir``` True if the structure has anti-air capabilities. (3.2+ only) | ||
| * ```canHitGround``` True if the structure has anti-ground capabilities. (3.2+ only) | ||
| * ```isSensor``` True if the structure has sensor ability. (3.2+ only) | ||
| * ```isCB``` True if the structure has counter-battery ability. (3.2+ only) | ||
| * ```isRadarDetector``` True if the structure has radar detector ability. (3.2+ only) | ||
| * ```range``` Maximum range of its weapons. (3.2+ only) | ||
| * ```hasIndirect``` One or more of the structure's weapons are indirect. (3.2+ only) | ||
| ## Feature | ||
| Describes a feature (a **game object** not owned by any player). It inherits all the properties of the base object (see below). | ||
| In addition, the following properties are defined: | ||
| * ```type``` It will always be ```FEATURE```. | ||
| * ```stattype``` The type of feature. Defined types are ```OIL_RESOURCE```, ```OIL_DRUM``` and ```ARTIFACT```. | ||
| * ```damageable``` Can this feature be damaged? | ||
| ## Droid | ||
| Describes a droid. It inherits all the properties of the base object (see below). | ||
| In addition, the following properties are defined: | ||
| * ```type``` It will always be ```DROID```. | ||
| * ```order``` The current order of the droid. This is its plan. The following orders are defined: | ||
| * ```DORDER_ATTACK``` Order a droid to attack something. | ||
| * ```DORDER_MOVE``` Order a droid to move somewhere. | ||
| * ```DORDER_SCOUT``` Order a droid to move somewhere and stop to attack anything on the way. | ||
| * ```DORDER_BUILD``` Order a droid to build something. | ||
| * ```DORDER_HELPBUILD``` Order a droid to help build something. | ||
| * ```DORDER_LINEBUILD``` Order a droid to build something repeatedly in a line. | ||
| * ```DORDER_REPAIR``` Order a droid to repair something. | ||
| * ```DORDER_RETREAT``` Order a droid to retreat back to HQ. | ||
| * ```DORDER_PATROL``` Order a droid to patrol. | ||
| * ```DORDER_DEMOLISH``` Order a droid to demolish something. | ||
| * ```DORDER_EMBARK``` Order a droid to embark on a transport. | ||
| * ```DORDER_DISEMBARK``` Order a transport to disembark its units at the given position. | ||
| * ```DORDER_FIRESUPPORT``` Order a droid to fire at whatever the target sensor is targeting. (3.2+ only) | ||
| * ```DORDER_COMMANDERSUPPORT``` Assign the droid to a commander. (3.2+ only) | ||
| * ```DORDER_STOP``` Order a droid to stop whatever it is doing. (3.2+ only) | ||
| * ```DORDER_RTR``` Order a droid to return for repairs. (3.2+ only) | ||
| * ```DORDER_RTB``` Order a droid to return to base. (3.2+ only) | ||
| * ```DORDER_HOLD``` Order a droid to hold its position. (3.2+ only) | ||
| * ```DORDER_REARM``` Order a VTOL droid to rearm. If given a target, will go to specified rearm pad. If not, will go to nearest rearm pad. (3.2+ only) | ||
| * ```DORDER_OBSERVE``` Order a droid to keep a target in sensor view. (3.2+ only) | ||
| * ```DORDER_RECOVER``` Order a droid to pick up something. (3.2+ only) | ||
| * ```DORDER_RECYCLE``` Order a droid to factory for recycling. (3.2+ only) | ||
| * ```action``` The current action of the droid. This is how it intends to carry out its plan. The | ||
| C++ code may change the action frequently as it tries to carry out its order. You never want to set | ||
| the action directly, but it may be interesting to look at what it currently is. | ||
| * ```droidType``` The droid's type. The following types are defined: | ||
| * ```DROID_CONSTRUCT``` Trucks and cyborg constructors. | ||
| * ```DROID_WEAPON``` Droids with weapon turrets, except cyborgs. | ||
| * ```DROID_PERSON``` Non-cyborg two-legged units, like scavengers. | ||
| * ```DROID_REPAIR``` Units with repair turret, including repair cyborgs. | ||
| * ```DROID_SENSOR``` Units with sensor turret. | ||
| * ```DROID_ECM``` Unit with ECM jammer turret. | ||
| * ```DROID_CYBORG``` Cyborgs with weapons. | ||
| * ```DROID_TRANSPORTER``` Cyborg transporter. | ||
| * ```DROID_SUPERTRANSPORTER``` Droid transporter. | ||
| * ```DROID_COMMAND``` Commanders. | ||
| * ```group``` The group this droid is member of. This is a numerical ID. If not a member of any group, will be set to \emph{null}. | ||
| * ```armed``` The percentage of weapon capability that is fully armed. Will be \emph{null} for droids other than VTOLs. | ||
| * ```experience``` Amount of experience this droid has, based on damage it has dealt to enemies. | ||
| * ```cost``` What it would cost to build the droid. (3.2+ only) | ||
| * ```isVTOL``` True if the droid is VTOL. (3.2+ only) | ||
| * ```canHitAir``` True if the droid has anti-air capabilities. (3.2+ only) | ||
| * ```canHitGround``` True if the droid has anti-ground capabilities. (3.2+ only) | ||
| * ```isSensor``` True if the droid has sensor ability. (3.2+ only) | ||
| * ```isCB``` True if the droid has counter-battery ability. (3.2+ only) | ||
| * ```isRadarDetector``` True if the droid has radar detector ability. (3.2+ only) | ||
| * ```hasIndirect``` One or more of the droid's weapons are indirect. (3.2+ only) | ||
| * ```range``` Maximum range of its weapons. (3.2+ only) | ||
| * ```body``` The body component of the droid. (3.2+ only) | ||
| * ```propulsion``` The propulsion component of the droid. (3.2+ only) | ||
| * ```weapons``` The weapon components of the droid, as an array. Contains 'name', 'id', 'armed' percentage and 'lastFired' properties. (3.2+ only) | ||
| * ```cargoCapacity``` Defined for transporters only: Total cargo capacity (number of items that will fit may depend on their size). (3.2+ only) | ||
| * ```cargoSpace``` Defined for transporters only: Cargo capacity left. (3.2+ only) | ||
| * ```cargoCount``` Defined for transporters only: Number of individual \emph{items} in the cargo hold. (3.2+ only) | ||
| * ```cargoSize``` The amount of cargo space the droid will take inside a transport. (3.2+ only) | ||
| ## Base Object | ||
| Describes a basic object. It will always be a droid, structure or feature, but sometimes the | ||
| difference does not matter, and you can treat any of them simply as a basic object. These | ||
| fields are also inherited by the droid, structure and feature objects. | ||
| The following properties are defined: | ||
| * ```type``` It will be one of ```DROID```, ```STRUCTURE``` or ```FEATURE```. | ||
| * ```id``` The unique ID of this object. | ||
| * ```x``` X position of the object in tiles. | ||
| * ```y``` Y position of the object in tiles. | ||
| * ```z``` Z (height) position of the object in tiles. | ||
| * ```player``` The player owning this object. | ||
| * ```selected``` A boolean saying whether 'selectedPlayer' has selected this object. | ||
| * ```name``` A user-friendly name for this object. | ||
| * ```health``` Percentage that this object is damaged (where 100 means not damaged at all). | ||
| * ```armour``` Amount of armour points that protect against kinetic weapons. | ||
| * ```thermal``` Amount of thermal protection that protect against heat based weapons. | ||
| * ```born``` The game time at which this object was produced or came into the world. (3.2+ only) | ||
| ## Template | ||
| Describes a template type. Templates are droid designs that a player has created. | ||
| The following properties are defined: | ||
| * ```id``` The ID of this object. | ||
| * ```name``` Name of the template. | ||
| * ```cost``` The power cost of the template if put into production. | ||
| * ```droidType``` The type of droid that would be created. | ||
| * ```body``` The name of the body type. | ||
| * ```propulsion``` The name of the propulsion type. | ||
| * ```brain``` The name of the brain type. | ||
| * ```repair``` The name of the repair type. | ||
| * ```ecm``` The name of the ECM (electronic counter-measure) type. | ||
| * ```construct``` The name of the construction type. | ||
| * ```weapons``` An array of weapon names attached to this template. |