1
0
forked from 0ad/0ad
0ad/binaries/data/mods/official/scripts/game_startup.js
Matei 77c59070c1 # Various gameplay updates.
- Added per-player resource pool and modified the GUI and entity scripts
to work with it.
- Modified unit creation functions so the unit is always assigned a
player before firing its initialize event, so that this event can deduct
population, etc from the right player.
- Fixed various small bugs, like a unit not cancelling all of its queued
items when it dies, or buildings not costing anything.

This was SVN commit r3998.
2006-06-10 03:05:16 +00:00

45 lines
999 B
JavaScript

/*
DESCRIPTION : Script called when the game is started, which should initialize the players and their units based on the game settings.
NOTES :
*/
// Assign the players resources
for(var i=0; i<players.length; i++)
{
var p = players[i];
p.resources = new Object();
switch( g_GameAttributes.resourceLevel.toLowerCase() )
{
case "high":
p.resources.food = 1000;
p.resources.wood = 1000;
p.resources.ore = 500;
p.resources.stone = 500;
break;
default:
p.resources.food = 200;
p.resources.wood = 200;
p.resources.ore = 100;
p.resources.stone = 100;
break;
}
p.resources.population = 0;
p.resources.housing = 0;
}
// Give the players their civ techs (which will set up their civ bonuses)
for(var i=0; i<players.length; i++)
{
var tech = getTechnology( "civ_" + players[i].civilization.toLowerCase() );
if( tech != null )
{
tech.applyEffects( i, false, false );
}
}
console.write( "Game startup script done." );