Players Objects

(info) This AI is still in early stages of development.

Players Objects

The objects returned by the Players API are enhanced versions of Player objects...

 

Properties

Property

Settable

Type

Notes

API Version

Property

Settable

Type

Notes

API Version

id

Number

The id of the player.

Note: For the scavenger player, their id will be >= maxPlayers (see scavengerPlayer for more info)

0.1

type

Constant

PLAYER_DATA

Note: The constant is backported by the Players API for Warzone 3.1 Beta 10 and earlier, so it will always be available regardless of Warzone version.

0.1

name

String

What is the player's name?

  • If Scavengers faction: "Scavengers"

  • On Warzone 3.1: the name of the colour associated with the player.

  • On Warzone 3.2: the name of the player taken from their JS API Player object.

0.1

isAI

Boolean

Undefined

Is the player an AI?

  • On Warzone 3.1:

    • true – the player is an AI or Scavenger faction

    • false – the player is human

    • undefined – could be human or AI (unable to disambiguate)

  • On Warzone 3.2:

    • true – the player is an AI or Scavenger faction

    • false – the player is human

0.1

isScavenger

Boolean

Is the player the Scavenger Faction faction?

  • true – the player is Scavenger faction

  • false – the player is not Scavenger faction

0.1

isHuman

Boolean

Undefined

Is the player human?

  • On Warzone 3.1:

    • true – the player is human

    • false – the player is an AI or Scavenger faction

    • undefined – could be AI or human (unable to disambiguate)

  • On Warzone 3.2:

    • true – the player is human

    • false – the player is an AI or Scavenger faction

0.1

isHost

Boolean

Is the player the game host?

  • true – yes, they are the game host

  • false – no

0.1

isVacant

Boolean

Is the player slot vacant?

  • true – yes, this player slot is empty

  • false – no, the player slot is occupied

A player is considered vacant if they are not alive when the Players API initialises (either at the start of a new game, or when loading a saved game).

0.1

difficulty

Constant

What Difficulty Level is the player?

Note: Confirmed human players will have a difficulty of HARD, ambiguous human players will have a difficulty of MEDIUM.

0.1

colour

Object

An object describing the colour associated with the player – it has two properties:

  • .id – the numeric colour index

  • .name – a string containing the canonical name of the colour

The Scavenger faction has a custom colour defined:

  • .id == -1

  • .name == "Random"

See Colour Palette for possible values of each property.

You can use _(player.colour.name) to localise the colour name.

0.1

team

Object

An object describing the team the player is in – it has two properties:

  • .id – the numeric team ID

  • .name – the alphabet letter, in uppercase, associated with the team ID

The Scavenger faction has a custom team defined:

  • .id == "18"

  • .name == "S"

The team is always specified, regardless of alliancesType mode:

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

 0.1

isAlly

3.1

3.2+

Boolean

Is the player an ally of the script player (me)?

  • true – yes, they are our ally

  • false – no, they are an enemy

On Warzone 3.2 and above, you can set this value, for example: Players[3].isAlly = false; will make player 3 an enemy. If the value cannot be set for some reason, eg. on Warzone 3.1 or if alliancesType != ALLIANCES, the value will remain unchanged.

1.0

isEnemy

3.1

3.2+

Boolean

Is the player an enemy of the script player (me)?

  • true – yes, they are an enemy

  • false – no, they are not an enemy

On Warzone 3.2 and above, you can set this value, for example: Players[3].isEnemy = false; will make player 3 an ally. If the value cannot be set for some reason, eg. on Warzone 3.1 or if  alliancesType !=  ALLIANCES, the value will remain unchanged.

1.0

isAlive

Boolean

Is the player "Alive" according to game rules?

  • true – yes, they are alive

  • false – no

0.1

position

Number

Undefined

What map position did the player start in?

  • <number> – the position number, which can be cross-referenced with startPositions[] array to find the x,y co-ordinates of the position.

  • undefined – Scavengers don't have a specific start position and will often have multiple bases on the map

0.1

isSelected

Boolean

Has the localhost human player selected this player?

  • true – yes

  • false – no

For more information, see selectedPlayer.

0.1