Most of the information here is for Warzone 3.1 and above.
rules.js
Description
The rules.js script is responsible for Game Rules & SitRep (see that link for full details and modding guidelines).
Every human player in the game has rules.js associated with them.
The rules.js code must be exactly the same for all human players otherwise "2 + 2 = 5" desyncs will occur.
The rules.js is responsible for:
- Player Initialisation– setting up players at the start of a game
- Mini Map and Design Mode– enabling or disabling depending on presence of HQ
- Victory Conditions– deciding when the game is won or lost
- Situation Reporting (SitRep) – notifying the human player of important events as they happen
Players
As mentioned in Player Initialisation, the initialisation sequence is applied to all players (except Scavengers), not just the human player associated with the script.
When it comes to Victory Conditions, again all players are being checked but only to determine if the human player associated with the script has won or lost.
With the Mini Map and Design Mode checking, only the human player associated with the script is checked and updated.
In terms of Situation Reporting (SitRep), that will usually be performed in relation to the player the human is currently controlling – usually their own player, but if they are in debug mode they might have switched to a different player.
Here's a list of JS API globals and which players they relate to:
Global variable | Relates to... | Use for... |
---|---|---|
me | This will always be the human player in the context of rules.js | |
selectedPlayer | This will be the player the human is currently controlling. | Situation Reporting (SitRep) |
scavengerPlayer | This is always the Scavenger faction (if enabled in the game) | Not applicable Although you might use it to customise SitReps |
maxPlayers | Iteration of all players in the game (excluding Scavengers) |
You can view the normal rules.js online.
Contents
Assimilate: