Other great resources: Official JS API docs, Scripting Forum
Players & Alliances
- Aubergine
How are they defined?
Players and their alliances/teams are defined during game set-up. There are several ways which game set-up can be performed:
- Skirmish Game Screen or Multiplayer Game Screen, mostly on the Players Panel
- <mapname>.ini – optional file included with maps (3.2+) which defines default game settings
- Challenge Games – ini file works similar to <mapname>.ini
- Campaigns – unimaginably convoluted campaign configuration *sigh*
The Game Configuration is exposed to the JS API via a number of globals and functions. Those relating to players and are listed to the right.
Players
In current Warzone releases, there can be up to 10 human/AI players, plus an optional Scavenger player, in a game.
Each player has a unique ID, and everything associated with that player (such as Droids, Structures and even Features) is linked to the player ID.
Human and AI players
These players have IDs in the range: 0 → maxPlayers-1.
The player ID is determined by the order in which the player was added to the game, not their map position. Player 0 is always the human game host, even if that player has been moved to a different map position.
In Warzone 3.2 and above, you can determine if there are multiple human players using the isMultiplayer, and determine which players are human or AI by looking at their associated Player object in the global playerData[] array.
For more information, see Players.
Scavenger player
The Scavenger Faction player is treated separately from all other players – they are not listed in playerData[], and their ID is ≥ maxPlayers:
- Check the scavengers global to see if they have been enabled
- If enabled, scavengerPlayer contains their player ID (it will be -1 if they are disabled)
Even when enabled, Scavenges might not appear on the map if the map designer didn't define any Scavenger factories or trucks. For more information, see Adding Scavengers to Maps.
Unlike other players, scavengers tend to have multiple bases – they generally treat factories as if they were HQs. This means that the Scavenger Faction doesn't have a defined map position: While they might only appear in one place on the map, they could just as easily have lots of little bases scattered anywhere on the map.
If you want to turn a human or AI player in to Scavengers, check out NoQ's Warzone Mini: Scavenger Wars mod which does just that!
Feature Players
Most map features (trees, log cabins, etc) are owned by player 99. However, special features, such as oil resources, oil drums and artifacts, are owned by player 12.
The special features can either be picked up (in the case of oil drums and artifacts) or built on (in the case of oil resources).
For more information on features, see the imaginatively titled "Features" section of the documentation.
Player Scripts
All human, AI and scavenger players have at least one Javascript environment associated with them, in to which a relevant script is loaded.
- Human players each have an instance of rules.js, which is responsible for Game Rules & SitRep.
- AI players each have an instance of their associated AI script, which automates their decision making and actions
- The Scavenger Faction is controlled by scavfact.js, which is essentially the Scavenger's AI script
Note: Unlike all other players, Feature players don't have an associated script. If you want to perform actions on features, the best place to do it is either in rules.js or an 'extra' script (as defined in ini files).
For more information, see Player Scripts.
Alliances
The game settings allow human and AI players to be optionally formed in to alliances, with the applied setting defined in the alliancesType global.
These alliances, if enabled, can be either dynamic or fixed:
- Dynamic alliances allow players to change alliances during the game
- Fixed alliances are commonly referred to as "Teams", although it's worth noting that all human and AI players are always a member of a team, even if they are the only player in that team, regardless of alliance mode.
For more information, see Alliance.
Interactions
Players can interact during the game in a number of ways:
- Chat interface
- Beacons
- Object and Power transfers
For more information, see Interactions.
User guides
There's a number of user guides available for multiplayer:
- Alliance Modes — In multiplayer and skirmish games, there are three different alliance modes...
- Beacons — Beacons are used to draw your attention to specific locations on the map...
- Etiquette — Some guidelines for multiplayer gamers..
- In-game Chat — Chat can be used in all game modes, but is most common in skirmish and multiplayer games...
- IRC Chat Room — Avoid cheaters and other undesirable players by arranging games on IRC...
- Player Ranks — Ever wondered what those stars and medals next to your name mean?
- Transfers — Power and droids can be transferred between allies...
- Warzone Clans — A list of Warzone clans...
- Players
- me — Stores the player ID your script is associated with...
- maxPlayers — Defines the maximum number of human/AI player slots on the current map, regardless of whether those slots are filled in the current game.
- scavengers — Indicates whether scavengers are enabled in this game.
- selectedPlayer — Indicates which player is currently being played/viewed by the human on the current machine.
- difficulty — A constant representing the difficulty level selected for your script.
- playerData[] — An array of Player objects describing each human/AI player slot on the current map regardless of whether those slots have been assigned players for the current game.
- scavengerPlayer — Defines the player ID for the scavenger faction on the map.
- isMultiplayer — Determine if the game is an online multiplayer game...
- Alliance
- Player Scope — These constants group players in various ways.
- ALLIES — Send a chat message to your allies.
- ALL_PLAYERS — Send a chat message to all players.
- ENEMIES — Filter enumeration to enemy objects.
- allianceExistsBetween() — Determine whether two players are allies with each other...
- setAlliance()
- alliancesType — Defines the alliance mode selected for the current game...
- Player Scope — These constants group players in various ways.
- Interactions
- donatePower() — Transfer some power to another player...
- removeBeacon() — Send a beacon to a specific player or allies...
- addBeacon() — Send a beacon to a specific player or allies...
- donateObject() — Transfer an object to another player...
- chat() — Send an in-game message to a specific player, your alliance or everyone.