Skip to content

Commit

Permalink
Add rules updates from master
Browse files Browse the repository at this point in the history
We need to not enable the cyborgspade at the start since Classic has a research topic for it.
  • Loading branch information
KJeff01 committed May 31, 2024
1 parent 8f379eb commit 7137cef
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 0 deletions.
59 changes: 59 additions & 0 deletions multiplay/script/rules/events/gameinit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
function eventGameInit()
{
//From script/rules/setupgame.js
setupGame();

//From script/rules/printsettings.js
queue("printGameSettings", TICK_TIME);

//From script/rules/oildrum.js
oilDrumInit();

//global function, doc/js-functions
hackNetOff();

//From script/setup/setupscavenger.js
setupScavenger();

for (let playnum = 0; playnum < maxPlayers; ++playnum)
{
//From script/setup/powermodifier.js
setupPowerModifier(playnum);

//From script/setup/droidlimit.js
droidLimit(playnum);

//From script/setup/setupstructure.js
setupStructure(playnum);

//From script/setup/setupstructurelimit.js
setupStructureLimit(playnum);

//From script/setup/setupresearch.js
setupResearch(playnum);

//From script/setup/setupcomponents.js
setupComponents(playnum);

//From script/setup/setupbase.js
setupBase(playnum);

//From script/setup/setuptechlevels.js
setupTechLevel(playnum);

}

applyLimitSet(); // set limit options

hackNetOn();

//Structures might have been removed so we need to update the reticule button states again
//From script/rules/reticule.js
queue("setMainReticule", TICK_TIME);

if (tilesetType === "URBAN" || tilesetType === "ROCKIES")
{
setTimer("weatherCycle", 45000);
}
setTimer("autoSave", 10*60*1000);
}
159 changes: 159 additions & 0 deletions multiplay/script/rules/reticule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
function reticuleManufactureCheck()
{
var structureComplete = false;
var facs = [FACTORY, CYBORG_FACTORY, VTOL_FACTORY,];

for (let i = 0, len = facs.length; i < len; ++i)
{
var onMapFacs = enumStruct(selectedPlayer, facs[i]);
for (let j = 0, len2 = onMapFacs.length; j < len2; ++j)
{
if (onMapFacs[j].status === BUILT)
{
structureComplete = true;
break;
}
}
}

if (structureComplete === true)
{
setReticuleButton(1, _("Manufacture (F1)"), "image_manufacture_up.png", "image_manufacture_down.png");
}
else
{
setReticuleButton(1, _("Manufacture - build factory first"), "", "");
}
}

function reticuleResearchCheck()
{
var structureComplete = false;
var labs = [RESEARCH_LAB,];

for (let i = 0, len = labs.length; i < len; ++i)
{
var onMapResLabs = enumStruct(selectedPlayer, labs[i]);
for (let j = 0, len2 = onMapResLabs.length; j < len2; ++j)
{
if (onMapResLabs[j].status === BUILT)
{
structureComplete = true;
break;
}
}
}
if (structureComplete === true)
{
setReticuleButton(2, _("Research (F2)"), "image_research_up.png", "image_research_down.png");
}
else
{
setReticuleButton(2, _("Research - build research facility first"), "", "");
}
}

function reticuleBuildCheck()
{
if (enumDroid(selectedPlayer, DROID_CONSTRUCT).length > 0)
{
setReticuleButton(3, _("Build (F3)"), "image_build_up.png", "image_build_down.png");
}
else
{
setReticuleButton(3, _("Build - manufacture constructor droids first"), "", "");
}
}

function reticuleDesignCheck()
{
var structureComplete = false;
var HQS = [HQ,];

for (let i = 0, len = HQS.length; i < len; ++i)
{
var onMapHQ = enumStruct(selectedPlayer, HQS[i]);
for (let j = 0, len2 = onMapHQ.length; j < len2; ++j)
{
if (onMapHQ[j].status === BUILT)
{
structureComplete = true;
break;
}
}
}
if (structureComplete === true)
{
setReticuleButton(4, _("Design (F4)"), "image_design_up.png", "image_design_down.png");
setMiniMap(true);
}
else
{
setReticuleButton(4, _("Design - construct HQ first"), "", "");
setMiniMap(false);
}
}

function reticuleCommandCheck()
{
if (enumDroid(selectedPlayer, DROID_COMMAND).length > 0)
{
setReticuleButton(6, _("Commanders (F6)"), "image_commanddroid_up.png", "image_commanddroid_down.png");
}
else
{
setReticuleButton(6, _("Commanders - manufacture commanders first"), "", "");
}
}

function setMainReticule()
{
setReticuleButton(0, _("Close"), "image_cancel_up.png", "image_cancel_down.png");
if (isSpectator(-1))
{
setReticuleButton(1, _("Manufacture - build factory first"), "", "");
setReticuleButton(2, _("Research - build research facility first"), "", "");
setReticuleButton(3, _("Build - manufacture constructor droids first"), "", "");
setReticuleButton(4, _("Design - construct HQ first"), "", "");
setReticuleButton(5, _("Intelligence Display (F5)"), "image_intelmap_up.png", "image_intelmap_down.png");
setReticuleButton(6, _("Commanders - manufacture commanders first"), "", "");
return;
}
reticuleManufactureCheck();
reticuleResearchCheck();
reticuleBuildCheck();
reticuleDesignCheck();
setReticuleButton(5, _("Intelligence Display (F5)"), "image_intelmap_up.png", "image_intelmap_down.png");
reticuleCommandCheck();
}

function reticuleUpdate(obj, eventType)
{
var update_reticule = false;

if (eventType === TRANSFER_LIKE_EVENT)
{
update_reticule = true;
}
else if (obj.player === selectedPlayer && obj.type === STRUCTURE)
{
if (obj.stattype === HQ || obj.stattype === RESEARCH_LAB || obj.stattype === CYBORG_FACTORY ||
obj.stattype === VTOL_FACTORY || obj.stattype === FACTORY || obj.stattype === COMMAND_CONTROL)
{
update_reticule = true;
}
}
else if (obj.player === selectedPlayer && obj.type === DROID)
{
if (obj.droidType === DROID_CONSTRUCT || obj.droidType === DROID_COMMAND)
{
update_reticule = true;
}
}

if (mainReticule && update_reticule)
{
//Wait a tick for the counts to update
queue("setMainReticule", TICK_TIME);
}
}
4 changes: 4 additions & 0 deletions multiplay/script/rules/setup/components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function setupComponents(player) // inside hackNetOff()
{
// Use makeComponentAvailable() here to enable components at the start of a match.
}
40 changes: 40 additions & 0 deletions multiplay/script/rules/setupgame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function setupGame()
{
//Use light fog for multiplayer
setRevealStatus(true);

if (tilesetType === "ARIZONA")
{
setCampaignNumber(1);
}
else if (tilesetType === "URBAN")
{
setCampaignNumber(2);
replaceTexture("page-8-player-buildings-bases.png", "page-8-player-buildings-bases-urban.png");
replaceTexture("page-9-player-buildings-bases.png", "page-9-player-buildings-bases-urban.png");
replaceTexture("page-7-barbarians-arizona.png", "page-7-barbarians-urban.png");
}
else if (tilesetType === "ROCKIES")
{
setCampaignNumber(3);
replaceTexture("page-8-player-buildings-bases.png", "page-8-player-buildings-bases-rockies.png");
replaceTexture("page-9-player-buildings-bases.png", "page-9-player-buildings-bases-rockies.png");
replaceTexture("page-7-barbarians-arizona.png", "page-7-barbarians-kevlar.png");
// for some reason rockies will use arizona babas
}
if (tilesetType !== "ARIZONA")
{
setSky("texpages/page-25-sky-urban.png", 0.5, 10000.0);
}
if (!isSpectator(-1))
{
// Disabled by default
setMiniMap(false);
}
// Enable all templates
setDesign(true);

showInterface(); // init buttons. This MUST come before setting the reticule button data
queue("setMainReticule", TICK_TIME);
mainReticule = true;
}
2 changes: 2 additions & 0 deletions multiplay/script/rules/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var oilDrumData = {
maxOilDrums: 0 // maximum amount of random oil drums allowed on the map
};

const TICK_TIME = 100;

const CREATE_LIKE_EVENT = 0;
const DESTROY_LIKE_EVENT = 1;
const TRANSFER_LIKE_EVENT = 2;
Expand Down

0 comments on commit 7137cef

Please sign in to comment.