Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Overview

Excerpt

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.

 

Overview

By inspecting the player data stored in this array, you can determine some useful information about your opponents/allies.

...

The data is based on either the settings in a campaign file, or the game settings from a skirmish or multiplayer game:

Image Removed

The index of each element in the array relates to the player ID. So the data for player 0 will be in playerData[0] and so on.

Properties

Each (numerically referenced) element in the array contains an object with the following properties:

PropertyTypeDescriptionGame version
difficultyConstantThe player's difficulty level (only applicable for AI players).3.1
colourStringThe colour associated with the player on the map. You can use _() to translate the colour names in to the human player's locale.3.1
positionIntegerThe map position to which the player is assigned. You can find it's x,y co-ordinates by cross-referencing against the startPositions array.3.1
teamStringThe team to which the player is assigned, if fixed alliances are set (see Alliance types).3.1
isHumanBooleanIs the player a human being?3.2
isAIBooleanIs the player an AI script?3.2
nameStringPlayer's name3.2

Examples

To follow

See also

...

 For example, what colour or difficulty was set on the Players Panel or the .ini file that defined the game settings?

Image Added

Note: Reordering players in the list changes their start position, not their player ID.

There can be up to 10 "normal" (human or AI bot) players in a game and, optionally, an additional scavengers player.

Note

The Scavenger Faction is not listed in the playerData array, and it's player ID will always be ≥maxPlayers. You can get the ID of the scavenger faction using scavengerPlayer. As such, it's not possible to determine the colour, etc., for the scavengers faction.

If a player slot is "Closed" or "Empty", it will still be included in the playerData array.

When players are defeated, they do not get removed from the array.

Properties

PropertyTypeNotesGame Version
<N>Player object

The numeric element indexes in the array represent the player IDs.

So, playerData[me] gives the player object for the player associated with your script, playerData[0] is the player object for player #0, etc.

Player IDs are set based on the order in which a player joins the game, not the order in which they appear on the Players Panel. The order they appear in the players panel defines their startPositions[].

The human game host is always player ID 0.

3.1
.lengthNumber

The number of "normal" players in the game (same value as maxPlayers).

Players are zero-indexed, so if a game as 4 players the <n> elements would be numbered 0..3, etc.

3.1

The playerData array is a normal array and thus inherits all standard methods and properties of the Javascript Array class.

Examples

Code Block
themeRDark
languagejavascript
titleIterate through playerData array
linenumberstrue
playerData.forEach( function get(data, player) {
	// player = player id
    // data = Player object containing info about that player
});
Div
classbox
Availability
Status
colourGreen
title3.1 b1+

Available since:

  • Warzone 3.1 Beta 1
  • See Player object for details of subsequent updates.
Div
classbox
Contents

Jump to:

Table of Contents
maxLevel5

Div
classbox

See also

Related API features:

You might also like: