From 7137cef97c3bb9c315fab006f7e821c814c4e462 Mon Sep 17 00:00:00 2001 From: KJeff01 Date: Fri, 31 May 2024 15:33:07 -0500 Subject: [PATCH] Add rules updates from master We need to not enable the cyborgspade at the start since Classic has a research topic for it. --- multiplay/script/rules/events/gameinit.js | 59 ++++++++ multiplay/script/rules/reticule.js | 159 +++++++++++++++++++++ multiplay/script/rules/setup/components.js | 4 + multiplay/script/rules/setupgame.js | 40 ++++++ multiplay/script/rules/variables.js | 2 + 5 files changed, 264 insertions(+) create mode 100644 multiplay/script/rules/events/gameinit.js create mode 100644 multiplay/script/rules/reticule.js create mode 100644 multiplay/script/rules/setup/components.js create mode 100644 multiplay/script/rules/setupgame.js diff --git a/multiplay/script/rules/events/gameinit.js b/multiplay/script/rules/events/gameinit.js new file mode 100644 index 0000000..23a6d10 --- /dev/null +++ b/multiplay/script/rules/events/gameinit.js @@ -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); +} diff --git a/multiplay/script/rules/reticule.js b/multiplay/script/rules/reticule.js new file mode 100644 index 0000000..5b449f5 --- /dev/null +++ b/multiplay/script/rules/reticule.js @@ -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); + } +} diff --git a/multiplay/script/rules/setup/components.js b/multiplay/script/rules/setup/components.js new file mode 100644 index 0000000..3154de2 --- /dev/null +++ b/multiplay/script/rules/setup/components.js @@ -0,0 +1,4 @@ +function setupComponents(player) // inside hackNetOff() +{ + // Use makeComponentAvailable() here to enable components at the start of a match. +} diff --git a/multiplay/script/rules/setupgame.js b/multiplay/script/rules/setupgame.js new file mode 100644 index 0000000..70b87a6 --- /dev/null +++ b/multiplay/script/rules/setupgame.js @@ -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; +} diff --git a/multiplay/script/rules/variables.js b/multiplay/script/rules/variables.js index 49fecad..df29c65 100644 --- a/multiplay/script/rules/variables.js +++ b/multiplay/script/rules/variables.js @@ -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;