Syntax
Code Block |
---|
theme | RDark |
---|
language | javascript |
---|
linenumbers | true |
---|
|
me |
Values
If scavengers are enabled, there will also be an additional scavengerPlayerThe value of me, which is read-only, will be an integer in the range 0 ≤ -1 ≤ me ≤ Math.max(scavengerPlayer, 0).
Player 0 is always the human game host.There can be up to 9 additional normal (human or AI) players in a game (player IDs 1 → maxPlayers).maxPlayers):
Value | Notes | Game version |
---|
-1 | Means your script will receive events from all players There is also a hackChangeMe() function in WZ 3.2 which allows you to set the value of 'me'. | |
0 | The game host (person who started the game) is always player 0, regardless of what map position they start in. | |
1 → maxPlayers | Between 1 and 9 additional players in the game (human or AI) | |
<scavengerPlayer> | In scavfact.js, the value of 'me' will be same as scavengerPlayer. - If scavengers are enabled, the value will be 7 or maxPlayers+1, whichever is higher.
- If scavengers are disabled, the value will be -1.
| |
An additional global, selectedPlayer, allows you to determine which of the players the localhost human is playing as (remember the human can switch to different players using the Debug Menu).
rules.js in WZ 3.2+
Note: This is currently being discussed in forums.
In Warzone 3.2 and above, the value of me was updated so that hackChangeMe() could be used to set a value of -1. When this happens, the script will receive almost all events from all players. This is useful in 'extra' scripts, often used to manage missions, as they can get a much more comprehensive view on game state.An additional global, selectedPlayer, allows you to determine which of the players the local host human is playing as'me' defaults to -1 in rules.js. This means that all Events & Timers from all players will be received in rules.js. To work out which player is associated with rules.js, cache the value of selectedPlayer at the start of a game, for example:
Code Block |
---|
theme | RDark |
---|
language | javascript |
---|
linenumbers | true |
---|
|
var humanPlayer = selectedPlayer; |
Even if the human changes to a different player via the Debug Menu, which would change the value of selectedPlayer, you're cached 'humanPlayer' variable will still contain the player the human was originally playing as at the start of the game.
Example
Code Block |
---|
theme | EclipseRDark |
---|
language | javascript |
---|
title | Get a list of my droids... |
---|
linenumbers | true |
---|
|
// get a list of my droids
var myDroids = enumDroid(me); |