(info) Other great resources: Official JS API docs, Scripting Forum

Player object

Specifies useful static information about a specific player in the game.

 

Properties

PropertyTypeDescriptionGame version
difficultyConstant

The player's difficulty level, which can be set for AI players on the game set-up screen:

  • EASYAct like a punching bag...
  • MEDIUMAct like a regular skirmish player...
  • HARDAct like a seasoned MP player...
  • INSANEBe evil, cheat if you have to...

Human players currently default to MEDIUM difficulty.

3.1
colourInteger

The numeric Colour ID of the colour that's used on the player's units and buildings. They are also shown as this colour on the mini map.

Refer to "Colour ID" in the Colour Palette to determine what the actual colour is.

3.1
positionInteger

The map position to which the player is assigned. You can find it's x,y co-ordinates by cross-referencing against the startPositions[] array.

Note: This is not the same as the player ID. You can determine the player ID associated with your script using the "me" global.

3.1
teamInteger

The team to which the player is assigned, represented as a number (0 = A, 1 = B, etc).

The team is always specified, regardless of alliancesType mode:

Note: Maps can specify defaults for teams, see <mapname>.ini for details.

3.1
typeConstantPLAYER_DATA3.1 Beta 11
isHumanBoolean

Is the player a human being?

  • true – yes
  • false – no, or the player slot is empty
3.2
isAIBoolean

Is the player an AI bot?

  • true – yes
  • false – no, or the player slot is empty
3.2
nameStringPlayer's name3.2

Scavengers

(warning) The Scavenger Faction does not have an associated player object.

If they did, it would look something like this:

  • difficulty == MEDIUM (if you've got Ultimate Scavenger Mod installed) or EASY if you've not.
  • colour == undefined (it's set automatically but there isn't any way to work out what it is currently)
  • position == undefined (you could look for scavenger factories to get a rough location)
  • team == undefined (scavengers currently can't be allied with players)
  • type == PLAYER_DATA
  • isHuman == false
  • isAI == true (controlled by scavfact.js)
  • name == "Ultimate Scavenger Mod" (if USM installed) or "Scavengers"

The scavenger player ID is defined by scavengerPlayer. You can determine if scavengers are enabled via the scavengers global – note that this doesn't guarantee that the map maker added Scavengers to their map; if they didn't then regardless of scavengers being enabled there won't be any scavengers.

Notes

The player objects are based on the players in the current game. Depending on the type of the game, the source of the information is different:

  • Campaign: (question) no idea how it gets defined
  • Challenges: Players predefined in an ini file – see Challenge Games for more info.
  • Skirmish and MP: Players defined on the game set-up screen.
  • Tutorial: (question) no idea how it gets defined
  • Fast Play: (question) no idea how it gets defined

The playerData[] array and the player objects it contains are static during a game – the information is created prior to eventGameInit() being triggered. In campaign games, it is assumed (but not verified) that the information will be updated during eventStartLevel() as there could be different factions in a level.

Empty player slots are still given Player objects, so don't assume a player object denotes a filled player slot.

Availability

This object is available for:

  • Warzone 3.1 early alphas
  • The .type property was added in Warzone 3.1 Beta 11
  • New properties are planned for Warzone 3.2

Where to get them?

Player data objects are only found in one place:

  • playerData[] – an array of player objects for the current game

See also

Related documentation:

You might also like: