(info) Most of the information here is for Warzone 3.1 and above.

Victory Conditions

The rules.js script is responsible for checking victory conditions.

 

How it works

The tried and tested way of checking victory conditions requires:

  • A function to check if a specific player is "alive"
  • A function to do the condition checking
  • A timer to periodically call that function – see setTimer()

Checking if a player is Alive

Under normal game rules, a player is deemed to be alive if any of the following conditions are met:

The code to do this is as follows:

function isPlayerAlive(player) {
  // check factories first
  if (enumStruct(player, FACTORY).length) return true;
  // then cyborg factories
  if (enumStruct(player, CYBORG_FACTORY).length) return true;
  // finally check droids
  if (enumDroid(player).length) return true;
  // if we get to here they must be dead
  return false;
} 

Note: Warzone 3.2 adds faster ways of counting structures and droids, see countStruct() and countDroid() for more information.

Essentially, we want to know if they can produce land units and/or if they have any units still on the map.

You'll notice that VTOLs and VTOL factories are ignored, as are transports.

Win Condition

The player is deemed to be a winner in the following scenarios:

  • All enemies are dead
  • The player (or 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.

Lose Condition

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.

See Enhanced SitRep Mod for a nice example of victory condition checking.

Contents

Assimilate:

Â