Player data and scripts, alliances/teams, and player interactions...

 

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:

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 DroidsStructures 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: