Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
How to initialise player technologies, buildings, base type effects, determine victory (win/lose) conditions and send situation reports to players... |
Player Initialisation
See Player Initialisation Rules
Design Mode & Mini Map
Under normal game rules a HQ is required to enable the Design Mode (droid design tool) and mini map.
If the HQ gets destroyed, both those features must be disabled. If a HQ gets build, they are re-enabled.
The code to do this is usually stored in a function so that it can be called from three key events:
- eventGameInit() – when the game starts, as there might be a HQ present after player initialisation
- eventStructureBuilt() – in case an HQ has been built
- eventDestroyed() – in case the HQ has been destroyed
Victory Conditions
Therules.js
Each human player in a game will have an associated rules.js script assigned to them. It runs for the duration of the game.
The rules.js script is responsible for checking victory conditions. This is generally performed by setting up a timer (using setTimer() function) to periodically call a global function that performs the victory condition checking.
Winning
The player is deemed to be a winner in the following scenarios:
- All enemies are dead
- The player of a member of their team (if using ALLIANCES_TEAMS mode) is still alive
Upon winning, rules.js should trigger gameOverMessage(true) to end the game. It should also use removeTimer() to prevent any subsequent calls to the victory condition checking code.
Losing
The player is deemed to have lost in the following scenarios:
- If using ALLIANCES_TEAMS mode, the player loses if they and all members of their team are dead
- If using ALLIANCES or NO_ALLIANCES mode, the player loses as soon as they are killed (even if they have allies that are still alive)
Upon losing, rules.js should trigger gameOverMessage(false) to end the game. It should also use removeTimer() to prevent any subsequent calls to the victory condition checking code.
Definition of "Alive"
Under normal game rules, a player is deemed to be alive if any of the following conditions are met:
- They have at least one FACTORY or CYBORG_FACTORY, and/or...
- They have at least one DROID left on the map
Essentially, we want to know if they can produce land units and/or if they have any units still on the map.
other
Child pages (Children Display) | ||||||
---|---|---|---|---|---|---|
|
See also
Javascript API & Javascript Coding – game rules are implemented using JavaScriptapplying and monitoring game rules, and providing in-game situation reporting (SitRep) to the human player.
Game Rules
There are three key parts to the game rules as follows:
- Player Initialisation – set up technologies, components, base type, starting power, etc.
- Mini Map and Design Mode – enable or disable based on presence of HQ (Command Centre)
- Victory Conditions – check if the game is won or lost
You should make yourself familiar with all of them, even if you have no intention of modding them.
Situation Reporting (SitRep)
Realtime (or near-realtime) reporting of important events taking place in the game.
For detailed information, see:
- Situation Reporting (SitRep) – in-game situation reporting
Div | ||
---|---|---|
| ||
The game rules scripting lives in rules.js. |
Div | ||||
---|---|---|---|---|
| ||||
ContentsAssimilate:
|
Div | ||
---|---|---|
| ||
Developer LinksRelated documentation:
|