Add general rules script for the campaign.

Enable design and minimap only when an HQ exists.
master
cybersphinx 2012-02-02 22:57:43 +01:00
parent 78dee1c706
commit 4a71db9e9b
2 changed files with 40 additions and 0 deletions

37
data/base/script/rules.js Normal file
View File

@ -0,0 +1,37 @@
// General rules for the campaign
//
// * Enable unit design and minimap only when an HQ exists
function eventStartLevel()
{
// Disable by default
setMiniMap(false);
setDesign(false);
var structlist = enumStruct(me);
for (var i = 0; i < structlist.length; i++)
{
// Simulate build events to enable minimap/unit design when an HQ exists
eventStructureBuilt(structlist[i]);
}
}
function eventStructureBuilt(struct)
{
if (struct.player == selectedPlayer && struct.type == STRUCTURE && struct.stattype == HQ)
{
// Enable unit design and minimap when an HQ gets built
setMiniMap(true);
setDesign(true);
}
}
function eventDestroyed(victim)
{
if (victim.player == selectedPlayer && victim.type == STRUCTURE && victim.stattype == HQ)
{
// Disable unit design and minimap when the HQ gets destroyed
setMiniMap(false);
setDesign(false);
}
}

View File

@ -179,3 +179,6 @@ file ANI "cybdpjmp.ani"
file ANI "cybdplnd.ani"
file ANI "cybdprun.ani"
file ANIMCFG "anim.cfg"
directory "script"
file JAVASCRIPT "rules.js"