diff --git a/Changelog.txt b/Changelog.txt index 88b89f1..74ed14e 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,12 @@ -Changelog: +Refactored v2.6.0 + +Update with a lot of script tidying-up to match the current libcampaign standards indroduced in 4.4.0, this should not have a noticeable impact on actual gameplay. +NOTE: Saves from previous versions may not work for most levels, as some variable names have been changed. + +Changes: +- Also fixed a script error on Beta 2. + + Refactored v2.5.5 Quick update to resolve issues with Alpha 5. @@ -6,6 +14,7 @@ Quick update to resolve issues with Alpha 5. Changes: - Updated labels to fix missing south scav base and Hardcrete artifact. + Refactored v2.5.4 Update with bugfixes to work with recent versions. @@ -31,7 +40,6 @@ Changes: - NEXUS no longer wipes the player's VTOLs on Gamma Final; if you can get VTOLs anywhere close to that base you probably already deserve a medal. -Changelog: Refactored v2.5.2 A smaller balance patch and a fix. diff --git a/script/campaign/cam1-1.js b/script/campaign/cam1-1.js index 79c44b6..568c9c6 100644 --- a/script/campaign/cam1-1.js +++ b/script/campaign/cam1-1.js @@ -2,14 +2,14 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const SCAVENGER_RES = [ +const mis_scavengerRes = [ "R-Wpn-Flamer-Damage01", "R-Wpn-MG-Damage01", ]; //Ambush player from scav base - triggered from middle path camAreaEvent("scavBaseTrigger", function() { - var ambushGroup = camMakeGroup(enumArea("eastScavs", SCAV_7, false)); + const AMBUSH_GROUP = camMakeGroup(enumArea("eastScavs", CAM_SCAV_7, false)); camManageGroup(ambushGroup, CAM_ORDER_DEFEND, { pos: camMakePos("artifactLocation") }); @@ -18,7 +18,7 @@ camAreaEvent("scavBaseTrigger", function() //Moves west scavs units closer to the base - triggered from right path camAreaEvent("ambush1Trigger", function() { - var ambushGroup = camMakeGroup(enumArea("westScavs", SCAV_7, false)); + const AMBUSH_GROUP = camMakeGroup(enumArea("westScavs", CAM_SCAV_7, false)); camManageGroup(ambushGroup, CAM_ORDER_DEFEND, { pos: camMakePos("ambush1") }); @@ -27,7 +27,7 @@ camAreaEvent("ambush1Trigger", function() //Sends some units towards player LZ - triggered from left path camAreaEvent("ambush2Trigger", function() { - var ambushGroup = camMakeGroup(enumArea("northWestScavs", SCAV_7, false)); + const AMBUSH_GROUP = camMakeGroup(enumArea("northWestScavs", CAM_SCAV_7, false)); camManageGroup(ambushGroup, CAM_ORDER_DEFEND, { pos: camMakePos("ambush2") }); @@ -51,16 +51,16 @@ function eventStartLevel() retlz: true }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - camCompleteRequiredResearch(SCAVENGER_RES, SCAV_7); + camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7); //Get rid of the already existing crate and replace with another camSafeRemoveObject("artifact1", false); diff --git a/script/campaign/cam1-1s.js b/script/campaign/cam1-1s.js index 56304ea..a40fc5e 100644 --- a/script/campaign/cam1-1s.js +++ b/script/campaign/cam1-1s.js @@ -25,8 +25,8 @@ function secondVideo() //Has player built the power module? function powerModuleBuilt() { - var gens = enumStruct(CAM_HUMAN_PLAYER, POWER_GEN, false); - for (var x = 0, l = gens.length; x < l; ++x) + const gens = enumStruct(CAM_HUMAN_PLAYER, POWER_GEN, false); + for (let x = 0, l = gens.length; x < l; ++x) { if ((gens[x].modules > 0) && (gens[x].status === BUILT)) { diff --git a/script/campaign/cam1-2.js b/script/campaign/cam1-2.js index d53f86b..d835267 100644 --- a/script/campaign/cam1-2.js +++ b/script/campaign/cam1-2.js @@ -2,7 +2,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const SCAVENGER_RES = [ +const mis_scavengerRes = [ "R-Wpn-Flamer-Damage02", "R-Wpn-Flamer-ROF01", "R-Wpn-MG-Damage02", "R-Wpn-Mortar-Damage01", "R-Wpn-Mortar-ROF01", "R-Wpn-Rocket-ROF01", @@ -66,16 +66,16 @@ function eventStartLevel() retlz: true }); - var startpos = getObject("StartPosition"); - var lz = getObject("LandingZone"); - var tent = getObject("TransporterEntry"); - var text = getObject("TransporterExit"); + const startpos = getObject("StartPosition"); + const lz = getObject("LandingZone"); + const tent = getObject("TransporterEntry"); + const text = getObject("TransporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - camCompleteRequiredResearch(SCAVENGER_RES, SCAV_7); + camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7); camSetEnemyBases({ "NorthGroup": { diff --git a/script/campaign/cam1-3.js b/script/campaign/cam1-3.js index b1f33ce..c5c704d 100644 --- a/script/campaign/cam1-3.js +++ b/script/campaign/cam1-3.js @@ -4,7 +4,7 @@ include("script/campaign/templates.js"); //New base blip, new base area, new factory data -const NEW_PARADIGM_RES = [ +const mis_newParadigmRes = [ "R-Wpn-MG-Damage03", "R-Wpn-MG-ROF01", "R-Defense-WallUpgrade01", "R-Struc-Materials01", "R-Struc-Factory-Upgrade01", "R-Vehicle-Engine01", @@ -14,7 +14,7 @@ const NEW_PARADIGM_RES = [ "R-Wpn-Rocket-Damage02", "R-Wpn-Rocket-ROF01", "R-Wpn-RocketSlow-Damage01", "R-Struc-RprFac-Upgrade03", ]; -const SCAVENGER_RES = [ +const mis_scavengerRes = [ "R-Wpn-Flamer-Damage02", "R-Wpn-Flamer-ROF01", "R-Wpn-MG-Damage02", "R-Wpn-Cannon-Damage01", "R-Wpn-Mortar-Damage01", "R-Wpn-Mortar-ROF01", "R-Wpn-Rocket-ROF01", @@ -36,11 +36,11 @@ camAreaEvent("NorthConvoyTrigger", function(droid) camAreaEvent("SouthConvoyTrigger", function(droid) { - var scout = getObject("ScoutDroid"); + const scout = getObject("ScoutDroid"); if (camDef(scout) && scout) { camTrace("New Paradigm sensor scout retreating"); - var pos = camMakePos("ScoutDroidTarget"); + const pos = camMakePos("ScoutDroidTarget"); orderDroidLoc(scout, DORDER_MOVE, pos.x, pos.y); } }); @@ -88,15 +88,15 @@ function NPReinforce() { if (getObject("NPHQ") !== null) { - var list = []; - var count = 5 + camRand(5); - var scouts = [cTempl.nphmg, cTempl.npflam, cTempl.nppod, cTempl.nphmg, cTempl.npflam]; + let list = []; + const COUNT = 5 + camRand(5); + const scouts = [cTempl.nphmg, cTempl.npflam, cTempl.nppod, cTempl.nphmg, cTempl.npflam]; - for (var i = 0; i < count; ++i) + for (let i = 0; i < COUNT; ++i) { list.push(scouts[camRand(scouts.length)]); } - camSendReinforcement(NEW_PARADIGM, camMakePos("NPReinforcementPos"), list, CAM_REINFORCE_GROUND, { + camSendReinforcement(CAM_NEW_PARADIGM, camMakePos("NPReinforcementPos"), list, CAM_REINFORCE_GROUND, { data: { regroup: false, repair: 66, @@ -129,10 +129,10 @@ function eventAttacked(victim, attacker) { { return; } - if (victim.player === NEW_PARADIGM) + if (victim.player === CAM_NEW_PARADIGM) { camCallOnce("enableNP"); - var commander = getObject("NPCommander"); + const commander = getObject("NPCommander"); if (camDef(attacker) && attacker && camDef(commander) && commander && commander.order !== DORDER_SCOUT && commander.order !== DORDER_RTR) { @@ -172,7 +172,7 @@ function camEnemyBaseEliminated_ScavBaseGroup() { //make enemy easier to find if all his buildings destroyed camManageGroup( - camMakeGroup(enumArea(0, 0, mapWidth, mapHeight, SCAV_7, false)), + camMakeGroup(enumArea(0, 0, mapWidth, mapHeight, CAM_SCAV_7, false)), CAM_ORDER_ATTACK ); } @@ -212,18 +212,18 @@ function eventStartLevel() annihilate: true }); - var startpos = getObject("StartPosition"); - var lz = getObject("LandingZone"); - var tent = getObject("TransporterEntry"); - var text = getObject("TransporterExit"); + const startpos = getObject("StartPosition"); + const lz = getObject("LandingZone"); + const tent = getObject("TransporterEntry"); + const text = getObject("TransporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - camCompleteRequiredResearch(NEW_PARADIGM_RES, NEW_PARADIGM); - camCompleteRequiredResearch(SCAVENGER_RES, SCAV_7); - setAlliance(NEW_PARADIGM, SCAV_7, true); + camCompleteRequiredResearch(mis_newParadigmRes, CAM_NEW_PARADIGM); + camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7); + setAlliance(CAM_NEW_PARADIGM, CAM_SCAV_7, true); camSetEnemyBases({ "ScavBaseGroup": { diff --git a/script/campaign/cam1-4a.js b/script/campaign/cam1-4a.js index 5140692..097766b 100644 --- a/script/campaign/cam1-4a.js +++ b/script/campaign/cam1-4a.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const NEW_PARADIGM_RES = [ +const mis_newParadigmRes = [ "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01", "R-Defense-WallUpgrade02", "R-Struc-Materials02", "R-Struc-Factory-Upgrade02", "R-Vehicle-Engine02", @@ -11,7 +11,7 @@ const NEW_PARADIGM_RES = [ "R-Wpn-Rocket-Damage02", "R-Wpn-Rocket-ROF02", "R-Wpn-RocketSlow-Damage02", "R-Struc-RprFac-Upgrade03", ]; -const SCAVENGER_RES = [ +const mis_scavengerRes = [ "R-Wpn-Flamer-Damage03", "R-Wpn-Flamer-ROF01", "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01", "R-Wpn-Rocket-Damage02", "R-Wpn-Cannon-Damage02", "R-Wpn-Mortar-Damage03", "R-Wpn-Mortar-ROF01", @@ -51,7 +51,7 @@ camAreaEvent("LandingZoneTrigger", function() camPlayVideos(["pcv456.ogg", {video: "SB1_4_B", type: MISS_MSG}]); hackRemoveMessage("C1-4_LZ", PROX_MSG, CAM_HUMAN_PLAYER); //Remove LZ 2 blip. - var lz = getObject("LandingZone2"); // will override later + const lz = getObject("LandingZone2"); // will override later setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); // Give extra 40 minutes. @@ -90,18 +90,18 @@ function NPBaseDetect() function buildDefenses() { // First wave of trucks - camQueueBuilding(NEW_PARADIGM, "GuardTower6", "BuildTower0"); - camQueueBuilding(NEW_PARADIGM, "PillBox1", "BuildTower3"); - camQueueBuilding(NEW_PARADIGM, "PillBox1", "BuildTower6"); + camQueueBuilding(CAM_NEW_PARADIGM, "GuardTower6", "BuildTower0"); + camQueueBuilding(CAM_NEW_PARADIGM, "PillBox1", "BuildTower3"); + camQueueBuilding(CAM_NEW_PARADIGM, "PillBox1", "BuildTower6"); // Second wave of trucks - camQueueBuilding(NEW_PARADIGM, "GuardTower3", "BuildTower1"); - camQueueBuilding(NEW_PARADIGM, "GuardTower6", "BuildTower2"); - camQueueBuilding(NEW_PARADIGM, "GuardTower6", "BuildTower4"); + camQueueBuilding(CAM_NEW_PARADIGM, "GuardTower3", "BuildTower1"); + camQueueBuilding(CAM_NEW_PARADIGM, "GuardTower6", "BuildTower2"); + camQueueBuilding(CAM_NEW_PARADIGM, "GuardTower6", "BuildTower4"); // Third wave of trucks - camQueueBuilding(NEW_PARADIGM, "GuardTower3", "BuildTower5"); - camQueueBuilding(NEW_PARADIGM, "GuardTower6", "BuildTower7"); + camQueueBuilding(CAM_NEW_PARADIGM, "GuardTower3", "BuildTower5"); + camQueueBuilding(CAM_NEW_PARADIGM, "GuardTower6", "BuildTower7"); } function eventStartLevel() @@ -113,19 +113,19 @@ function eventStartLevel() retlz: true }); - var startpos = getObject("StartPosition"); - var lz = getObject("LandingZone1"); // will override later - var tent = getObject("TransporterEntry"); - var text = getObject("TransporterExit"); + const startpos = getObject("StartPosition"); + const lz = getObject("LandingZone1"); // will override later + const tent = getObject("TransporterEntry"); + const text = getObject("TransporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - camCompleteRequiredResearch(NEW_PARADIGM_RES, NEW_PARADIGM); - camCompleteRequiredResearch(SCAVENGER_RES, SCAV_7); - setAlliance(NEW_PARADIGM, SCAV_7, true); + camCompleteRequiredResearch(mis_newParadigmRes, CAM_NEW_PARADIGM); + camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7); + setAlliance(CAM_NEW_PARADIGM, CAM_SCAV_7, true); camSetEnemyBases({ "SouthScavBaseGroup": { @@ -197,7 +197,7 @@ function eventStartLevel() // To be able to use camEnqueueBuilding() later, // and also to rebuild dead trucks. - camManageTrucks(NEW_PARADIGM); + camManageTrucks(CAM_NEW_PARADIGM); queue("enableSouthScavFactory", camChangeOnDiff(camSecondsToMilliseconds(10))); } \ No newline at end of file diff --git a/script/campaign/cam1-5.js b/script/campaign/cam1-5.js index 056d4f6..ac0a767 100644 --- a/script/campaign/cam1-5.js +++ b/script/campaign/cam1-5.js @@ -2,7 +2,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const NEW_PARADIGM_RES = [ +const mis_newParadigmRes = [ "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01", "R-Defense-WallUpgrade02", "R-Struc-Materials02", "R-Struc-Factory-Upgrade02", "R-Vehicle-Engine02", "R-Vehicle-Metals02", "R-Cyborg-Metals02", "R-Wpn-Cannon-Damage03", @@ -10,7 +10,7 @@ const NEW_PARADIGM_RES = [ "R-Wpn-Mortar-Acc01", "R-Wpn-Rocket-Accuracy01", "R-Wpn-Rocket-Damage03", "R-Wpn-Rocket-ROF02", "R-Wpn-RocketSlow-Damage02", "R-Struc-RprFac-Upgrade03", ]; -const SCAVENGER_RES = [ +const mis_scavengerRes = [ "R-Wpn-Flamer-Damage03", "R-Wpn-Flamer-ROF01", "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01", "R-Wpn-Rocket-Damage02", "R-Wpn-Cannon-Damage03", "R-Wpn-Mortar-Damage03", "R-Wpn-Mortar-ROF01", @@ -24,10 +24,10 @@ var useHeavyReinforcement; //Get some droids for the New Paradigm transport function getDroidsForNPLZ(args) { - var lightAttackerLimit = 8; - var heavyAttackerLimit = 3; - var unitTemplates; - var list = []; + let lightAttackerLimit = 8; + let heavyAttackerLimit = 3; + let unitTemplates; + const list = []; if (difficulty === HARD) { @@ -42,8 +42,8 @@ function getDroidsForNPLZ(args) if (useHeavyReinforcement) { - var artillery = [cTempl.npmor]; - var other = [cTempl.npmmct]; + const artillery = [cTempl.npmor]; + const other = [cTempl.npmmct]; if (camRand(2) > 0) { //Add a sensor if artillery was chosen for the heavy units @@ -60,8 +60,8 @@ function getDroidsForNPLZ(args) unitTemplates = [cTempl.nppod, cTempl.npmrl, cTempl.npsmc]; } - var lim = useHeavyReinforcement ? heavyAttackerLimit : lightAttackerLimit; - for (var i = 0; i < lim; ++i) + const LIM = useHeavyReinforcement ? heavyAttackerLimit : lightAttackerLimit; + for (let i = 0; i < LIM; ++i) { list.push(unitTemplates[camRand(unitTemplates.length)]); } @@ -122,14 +122,14 @@ function activateNPLZTransporter() function sendNPTransport() { - var nearbyDefense = enumArea("LandingZone2", NEW_PARADIGM, false).filter(function(obj) { + const nearbyDefense = enumArea("LandingZone2", CAM_NEW_PARADIGM, false).filter(function(obj) { return (obj.type === STRUCTURE && obj.stattype === DEFENSE); }); if (nearbyDefense.length > 0) { - var list = getDroidsForNPLZ(); - camSendReinforcement(NEW_PARADIGM, camMakePos("NPTransportPos"), list, CAM_REINFORCE_TRANSPORT, { + const list = getDroidsForNPLZ(); + camSendReinforcement(CAM_NEW_PARADIGM, camMakePos("NPTransportPos"), list, CAM_REINFORCE_TRANSPORT, { entry: { x: 2, y: 42 }, exit: { x: 2, y: 42 }, order: CAM_ORDER_ATTACK, @@ -165,7 +165,7 @@ function camEnemyBaseEliminated_NPBaseGroup() //Make all scavengers on map attack camManageGroup( - camMakeGroup(enumArea(0, 0, mapWidth, mapHeight, SCAV_7, false)), + camMakeGroup(enumArea(0, 0, mapWidth, mapHeight, CAM_SCAV_7, false)), CAM_ORDER_ATTACK ); } @@ -180,24 +180,24 @@ function eventStartLevel() }); useHeavyReinforcement = false; //Start with a light unit reinforcement first - var lz = getObject("LandingZone1"); //player lz - var lz2 = getObject("LandingZone2"); //new paradigm lz - var tent = getObject("TransporterEntry"); - var text = getObject("TransporterExit"); + const lz = getObject("LandingZone1"); //player lz + const lz2 = getObject("LandingZone2"); //new paradigm lz + const tent = getObject("TransporterEntry"); + const text = getObject("TransporterExit"); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); - setNoGoArea(lz2.x, lz2.y, lz2.x2, lz2.y2, NEW_PARADIGM); + setNoGoArea(lz2.x, lz2.y, lz2.x2, lz2.y2, CAM_NEW_PARADIGM); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); //Transporter is the only droid of the player's on the map - var transporter = enumDroid(); + const transporter = enumDroid(); cameraTrack(transporter[0]); //Make sure the New Paradigm and Scavs are allies - setAlliance(NEW_PARADIGM, SCAV_7, true); + setAlliance(CAM_NEW_PARADIGM, CAM_SCAV_7, true); - camCompleteRequiredResearch(NEW_PARADIGM_RES, NEW_PARADIGM); - camCompleteRequiredResearch(SCAVENGER_RES, SCAV_7); + camCompleteRequiredResearch(mis_newParadigmRes, CAM_NEW_PARADIGM); + camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7); camSetEnemyBases({ "ScavNorthGroup": { @@ -223,7 +223,7 @@ function eventStartLevel() detectMsg: "C1-5_OBJ1", detectSnd: "pcv379.ogg", eliminateSnd: "pcv394.ogg", - player: NEW_PARADIGM + player: CAM_NEW_PARADIGM }, }); diff --git a/script/campaign/cam1-7.js b/script/campaign/cam1-7.js index 463f2a0..696a919 100644 --- a/script/campaign/cam1-7.js +++ b/script/campaign/cam1-7.js @@ -2,7 +2,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const NEW_PARADIGM_RESEARCH = [ +const mis_newParadigmRes = [ "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01", "R-Defense-WallUpgrade03", "R-Struc-Materials03", "R-Struc-Factory-Upgrade03", "R-Vehicle-Engine03", @@ -12,7 +12,7 @@ const NEW_PARADIGM_RESEARCH = [ "R-Wpn-Rocket-Damage03", "R-Wpn-Rocket-ROF03", "R-Wpn-RocketSlow-Accuracy02", "R-Wpn-RocketSlow-Damage03", "R-Struc-RprFac-Upgrade03", ]; -const SCAVENGER_RES = [ +const mis_scavengerRes = [ "R-Wpn-Flamer-Damage03", "R-Wpn-Flamer-ROF01", "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01", "R-Wpn-Rocket-Damage03", "R-Wpn-Cannon-Damage03", "R-Wpn-Mortar-Damage03", "R-Wpn-Mortar-ROF01", @@ -55,8 +55,8 @@ camAreaEvent("NPTransportTrigger", function(droid) { if (enemyHasArtifact && droid.group === artiGroup) { - var list = [cTempl.npmrl, cTempl.npmrl]; - camSendReinforcement(NEW_PARADIGM, camMakePos("NPTransportPos"), list, CAM_REINFORCE_TRANSPORT, { + const list = [cTempl.npmrl, cTempl.npmrl]; + camSendReinforcement(CAM_NEW_PARADIGM, camMakePos("NPTransportPos"), list, CAM_REINFORCE_TRANSPORT, { entry: { x: 39, y: 2 }, exit: { x: 32, y: 60 } }); @@ -64,7 +64,7 @@ camAreaEvent("NPTransportTrigger", function(droid) } else { - resetLabel("NPTransportTrigger", NEW_PARADIGM); + resetLabel("NPTransportTrigger", CAM_NEW_PARADIGM); } }); @@ -80,13 +80,13 @@ function artifactVideoSetup() //by the time it lands. function eventTransporterLanded(transport) { - if (transport.player === NEW_PARADIGM && enemyHasArtifact) + if (transport.player === CAM_NEW_PARADIGM && enemyHasArtifact) { enemyStoleArtifact = true; - var crew = enumRange(transport.x, transport.y, 6, NEW_PARADIGM, false).filter(function(obj) { + const crew = enumRange(transport.x, transport.y, 6, CAM_NEW_PARADIGM, false).filter(function(obj) { return obj.type === DROID && obj.group === artiGroup; }); - for (var i = 0, l = crew.length; i < l; ++i) + for (let i = 0, l = crew.length; i < l; ++i) { camSafeRemoveObject(crew[i], false); } @@ -100,7 +100,7 @@ function eventGroupLoss(obj, group, newsize) { if (obj.id === droidWithArtiID) { - var acrate = addFeature("Crate", obj.x, obj.y); + const acrate = addFeature("Crate", obj.x, obj.y); addLabel(acrate, "newArtiLabel"); camSetArtifacts({ @@ -129,15 +129,15 @@ function getArtifact() } const GRAB_RADIUS = 2; - var artifact = camGetArtifacts().filter(function(label) { + const artifact = camGetArtifacts().filter(function(label) { return enemyCanTakeArtifact(label) && getObject(label) !== null; }); - var artiLoc = artiMovePos; + let artiLoc = artiMovePos; if (!enemyHasArtifact && !enemyStoleArtifact && artifact.length > 0) { //Go to the artifact instead. - var realCrate = artifact[0]; + const realCrate = artifact[0]; artiLoc = camMakePos(realCrate); if (!camDef(artiLoc)) { @@ -145,17 +145,17 @@ function getArtifact() } //Find the one closest to the artifact so that one can "hold" it - var artiMembers = enumGroup(artiGroup); - var idx = 0; - var dist = Infinity; + const artiMembers = enumGroup(artiGroup); + let idx = 0; + let dist = Infinity; - for (var i = 0, l = artiMembers.length; i < l; ++i) + for (let i = 0, l = artiMembers.length; i < l; ++i) { - var drDist = camDist(artiMembers[i], artiLoc); - if (drDist < dist) + const DR_DIST = camDist(artiMembers[i], artiLoc); + if (DR_DIST < dist) { idx = i; - dist = drDist; + dist = DR_DIST; } } @@ -183,17 +183,17 @@ function getArtifact() //New Paradigm truck builds six lancer hardpoints around LZ function buildLancers() { - for (var i = 1; i <= 6; ++i) + for (let i = 1; i <= 6; ++i) { - camQueueBuilding(NEW_PARADIGM, "WallTower06", "hardPoint" + i); + camQueueBuilding(CAM_NEW_PARADIGM, "WallTower06", "hardPoint" + i); } } //Must destroy all of the New Paradigm droids and make sure the artifact is safe. function extraVictory() { - var npTransportFound = false; - enumDroid(NEW_PARADIGM).forEach(function(dr) { + let npTransportFound = false; + enumDroid(CAM_NEW_PARADIGM).forEach(function(dr) { if (camIsTransporter(dr)) { npTransportFound = true; @@ -206,7 +206,7 @@ function extraVictory() return false; } - if (!enumDroid(NEW_PARADIGM).length) + if (!enumDroid(CAM_NEW_PARADIGM).length) { return true; } @@ -245,10 +245,10 @@ function eventStartLevel() enemyHasArtifact = false; enemyStoleArtifact = false; - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); @@ -263,7 +263,7 @@ function eventStartLevel() }); //Make sure the New Paradigm and Scavs are allies - setAlliance(NEW_PARADIGM, SCAV_7, true); + setAlliance(CAM_NEW_PARADIGM, CAM_SCAV_7, true); //Get rid of the already existing crate and replace with another camSafeRemoveObject("artifact1", false); @@ -271,8 +271,8 @@ function eventStartLevel() "artifactLocation": { tech: "R-Wpn-Cannon4AMk1" }, // Hyper Velocity Cannon }); - camCompleteRequiredResearch(NEW_PARADIGM_RESEARCH, NEW_PARADIGM); - camCompleteRequiredResearch(SCAVENGER_RES, SCAV_7); + camCompleteRequiredResearch(mis_newParadigmRes, CAM_NEW_PARADIGM); + camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7); camSetEnemyBases({ "ScavMiddleGroup": { @@ -331,9 +331,9 @@ function eventStartLevel() }, }); - artiGroup = camMakeGroup(enumArea("NPArtiGroup", NEW_PARADIGM, false)); + artiGroup = camMakeGroup(enumArea("NPArtiGroup", CAM_NEW_PARADIGM, false)); droidWithArtiID = 0; - camManageTrucks(NEW_PARADIGM); + camManageTrucks(CAM_NEW_PARADIGM); buildLancers(); hackAddMessage("C1-7_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER, false); //Canyon diff --git a/script/campaign/cam1-d.js b/script/campaign/cam1-d.js index 97ac47b..3fd7c9a 100644 --- a/script/campaign/cam1-d.js +++ b/script/campaign/cam1-d.js @@ -2,7 +2,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const NEW_PARADIGM_RES = [ +const mis_newParadigmRes = [ "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01", "R-Defense-WallUpgrade03", "R-Struc-Materials03", "R-Struc-Factory-Upgrade03", "R-Vehicle-Engine03", @@ -61,10 +61,10 @@ function transportBaseSetup() function getDroidsForNPLZ() { const LIM = 8; //Last alpha mission always has 8 transport units - var templates = [ cTempl.nphct, cTempl.nphct, cTempl.npmorb, cTempl.npmorb, cTempl.npsbb ]; + const templates = [ cTempl.nphct, cTempl.nphct, cTempl.npmorb, cTempl.npmorb, cTempl.npsbb ]; - var droids = []; - for (var i = 0; i < LIM; ++i) + const droids = []; + for (let i = 0; i < LIM; ++i) { droids.push(templates[camRand(templates.length)]); } @@ -148,10 +148,10 @@ function eventStartLevel() eliminateBases: true }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); @@ -165,7 +165,7 @@ function eventStartLevel() "NPFactoryNE": { tech: "R-Vehicle-Body12" }, //Main base factory }); - camCompleteRequiredResearch(NEW_PARADIGM_RES, NEW_PARADIGM); + camCompleteRequiredResearch(mis_newParadigmRes, CAM_NEW_PARADIGM); camSetEnemyBases({ "NPSouthEastGroup": { @@ -190,7 +190,7 @@ function eventStartLevel() cleanup: "NPLZ1", detectMsg: "C1D_LZ2", eliminateSnd: "pcv394.ogg", - player: NEW_PARADIGM // required for LZ-type bases + player: CAM_NEW_PARADIGM // required for LZ-type bases }, }); diff --git a/script/campaign/cam1a-c.js b/script/campaign/cam1a-c.js index 207ff21..725fca3 100644 --- a/script/campaign/cam1a-c.js +++ b/script/campaign/cam1a-c.js @@ -2,16 +2,16 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const landingZoneList = [ "npPos1", "npPos2", "npPos3", "npPos4", "npPos5" ]; -const landingZoneMessages = [ "C1A-C_LZ1", "C1A-C_LZ2", "C1A-C_LZ3", "C1A-C_LZ4", "C1A-C_LZ5" ]; -const cyborgPatrolList = [ +const mis_landingZoneList = [ "npPos1", "npPos2", "npPos3", "npPos4", "npPos5" ]; +const mis_landingZoneMessages = [ "C1A-C_LZ1", "C1A-C_LZ2", "C1A-C_LZ3", "C1A-C_LZ4", "C1A-C_LZ5" ]; +const mis_cyborgPatrolList = [ "seCybPos1", "seCybPos2", "seCybPos3", "northCybPos1", "northCybPos2", "northCybPos3", "canyonCybPos1", "canyonCybPos2", "canyonCybPos3", "hillCybPos1", "hillCybPos2", "hillCybPos3", "1aCybPos1", "1aCybPos2", "1aCybPos3", ]; -const NEW_PARADIGM_RES = [ +const mis_newParadigmRes = [ "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01", "R-Defense-WallUpgrade02", "R-Struc-Materials02", "R-Struc-Factory-Upgrade02", "R-Vehicle-Engine02", @@ -27,7 +27,7 @@ var switchLZ; //Counter for incrementing index every third landing //Check if all enemies are gone and win after 15 transports function extraVictoryCondition() { - var enemies = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false); + const enemies = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false); if(index === 5 && enemies.length === 0) { return true; @@ -43,11 +43,11 @@ function checkForGroundForces() const maxTanks = 16; const firstAmount = 10; - var droidGroup1 = []; //Heavy cannon mantis track units - var droidGroup2 = []; //Sensor and heavy mortar units - var templates = [ cTempl.nphct, cTempl.npmsens, cTempl.npmorb ]; + const droidGroup1 = []; //Heavy cannon mantis track units + const droidGroup2 = []; //Sensor and heavy mortar units + const templates = [ cTempl.nphct, cTempl.npmsens, cTempl.npmorb ]; - for (var i = 0; i <= maxTanks; ++i) + for (let i = 0; i <= maxTanks; ++i) { if (i <= firstAmount) { @@ -64,11 +64,11 @@ function checkForGroundForces() } //What part of map to appear at - var pos = (index === 0) ? camMakePos("reinforceSouthEast") : camMakePos("reinforceNorth"); - camSendReinforcement(NEW_PARADIGM, pos, droidGroup1, CAM_REINFORCE_GROUND, { + const pos = (index === 0) ? camMakePos("reinforceSouthEast") : camMakePos("reinforceNorth"); + camSendReinforcement(CAM_NEW_PARADIGM, pos, droidGroup1, CAM_REINFORCE_GROUND, { data: {regroup: false, count: -1,}, }); - camSendReinforcement(NEW_PARADIGM, pos, droidGroup2, CAM_REINFORCE_GROUND); + camSendReinforcement(CAM_NEW_PARADIGM, pos, droidGroup2, CAM_REINFORCE_GROUND); } } @@ -76,35 +76,35 @@ function checkForGroundForces() //New Paradigm transport appears fifteen times before mission win function sendTransport() { - var position = camMakePos(landingZoneList[index]); + const position = camMakePos(mis_landingZoneList[index]); switchLZ += 1; // (2 or 3 or 4) pairs of each droid template. // This emulates wzcam's droid count distribution. - var count = [ 2, 3, 4, 4, 4, 4, 4, 4, 4 ][camRand(9)]; + const COUNT = [ 2, 3, 4, 4, 4, 4, 4, 4, 4 ][camRand(9)]; - var templates = [ cTempl.npcybc, cTempl.npcybf, cTempl.npcybm ]; + const templates = [ cTempl.npcybc, cTempl.npcybf, cTempl.npcybm ]; - var droids = []; - for (var i = 0; i < count; ++i) + const droids = []; + for (let i = 0; i < COUNT; ++i) { - var t = templates[camRand(templates.length)]; + const t = templates[camRand(templates.length)]; // two droids of each template droids[droids.length] = t; droids[droids.length] = t; } - camSendReinforcement(NEW_PARADIGM, position, droids, CAM_REINFORCE_TRANSPORT, { + camSendReinforcement(CAM_NEW_PARADIGM, position, droids, CAM_REINFORCE_TRANSPORT, { entry: { x: 126, y: 36 }, exit: { x: 126, y: 76 }, - message: landingZoneMessages[index], + message: mis_landingZoneMessages[index], order: CAM_ORDER_PATROL, data: { pos:[ - camMakePos( cyborgPatrolList[(3 * index)] ), - camMakePos( cyborgPatrolList[(3 * index) + 1] ), - camMakePos( cyborgPatrolList[(3 * index) + 2] ), + camMakePos( mis_cyborgPatrolList[(3 * index)] ), + camMakePos( mis_cyborgPatrolList[(3 * index) + 1] ), + camMakePos( mis_cyborgPatrolList[(3 * index) + 2] ), ], radius: 8, interval: camMinutesToMilliseconds(1), @@ -143,21 +143,21 @@ function eventStartLevel() callback: "extraVictoryCondition" }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); setMissionTime(camChangeOnDiff(camHoursToSeconds(1))); // make sure player doesn't build on enemy LZs - for (var i = 6; i <= 10; ++i) + for (let i = 6; i <= 10; ++i) { - var ph = getObject("NPLZ" + i); - setNoGoArea(ph.x, ph.y, ph.x2, ph.y2, NEW_PARADIGM); + const ph = getObject("NPLZ" + i); + setNoGoArea(ph.x, ph.y, ph.x2, ph.y2, CAM_NEW_PARADIGM); } - camCompleteRequiredResearch(NEW_PARADIGM_RES, NEW_PARADIGM); + camCompleteRequiredResearch(mis_newParadigmRes, CAM_NEW_PARADIGM); camPlayVideos([{video: "MB1A-C_MSG", type: CAMP_MSG}, {video: "MB1A-C_MSG2", type: MISS_MSG}]); index = 0; diff --git a/script/campaign/cam1a.js b/script/campaign/cam1a.js index 600fd2d..b9a4fb6 100644 --- a/script/campaign/cam1a.js +++ b/script/campaign/cam1a.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const PLAYER_RES = [ +const mis_playerRes = [ "R-Wpn-MG1Mk1", "R-Vehicle-Body01", "R-Sys-Spade1Mk1", "R-Vehicle-Prop-Wheels", ]; @@ -25,8 +25,8 @@ camAreaEvent("launchScavAttack", function(droid) function runAway() { - var oilPatch = getObject("oilPatch"); - var droids = enumRange(oilPatch.x, oilPatch.y, 7, SCAV_7, false); + const oilPatch = getObject("oilPatch"); + const droids = enumRange(oilPatch.x, oilPatch.y, 7, CAM_SCAV_7, false); camManageGroup(camMakeGroup(droids), CAM_ORDER_ATTACK, { pos: camMakePos("scavAttack1"), fallback: camMakePos("retreat1"), @@ -84,10 +84,10 @@ function eventStructureBuilt(structure, droid) if (structure.player === CAM_HUMAN_PLAYER && structure.stattype === RESOURCE_EXTRACTOR) { // Is it in the base two area? - var objs = enumArea("scavBase2Cleanup", CAM_HUMAN_PLAYER); - for (var i = 0, l = objs.length; i < l; ++i) + const objs = enumArea("scavBase2Cleanup", CAM_HUMAN_PLAYER); + for (let i = 0, l = objs.length; i < l; ++i) { - var obj = objs[i]; + const obj = objs[i]; if (obj.type === STRUCTURE && obj.stattype === RESOURCE_EXTRACTOR) { camCallOnce("raidAttack"); @@ -119,7 +119,7 @@ function enableBaseStructures() "A0ResearchFacility", "A0LightFactory", ]; - for (var i = 0; i < STRUCTS.length; ++i) + for (let i = 0; i < STRUCTS.length; ++i) { enableStructure(STRUCTS[i], CAM_HUMAN_PLAYER); } @@ -128,8 +128,8 @@ function enableBaseStructures() function eventStartLevel() { const PLAYER_POWER = 1300; - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "CAM_1B"); @@ -149,10 +149,10 @@ function eventStartLevel() setPower(PLAYER_POWER, CAM_HUMAN_PLAYER); } - setAlliance(SCAV_6, SCAV_7, true); + setAlliance(CAM_SCAV_6, CAM_SCAV_7, true); enableBaseStructures(); - camCompleteRequiredResearch(PLAYER_RES, CAM_HUMAN_PLAYER); + camCompleteRequiredResearch(mis_playerRes, CAM_HUMAN_PLAYER); // Give player briefing. hackAddMessage("CMB1_MSG", CAMP_MSG, CAM_HUMAN_PLAYER, false); diff --git a/script/campaign/cam1b.js b/script/campaign/cam1b.js index 207f8e4..3adcaa0 100644 --- a/script/campaign/cam1b.js +++ b/script/campaign/cam1b.js @@ -3,14 +3,14 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); var NPScout; // Sensor scout -const SCAVENGER_RES = [ +const mis_scavengerRes = [ "R-Wpn-Flamer-Damage01", "R-Wpn-MG-Damage01", ]; camAreaEvent("AttackArea1", function(droid) { queue("camCallOnce", camSecondsToMilliseconds(2), "doNPRetreat"); - camManageGroup(camMakeGroup("enemy1Force1", SCAV_6), CAM_ORDER_ATTACK, { + camManageGroup(camMakeGroup("enemy1Force1", CAM_SCAV_6), CAM_ORDER_ATTACK, { pos: camMakePos("enemy1Force1Pos"), fallback: camMakePos("enemy1Force1Fallback"), morale: 50 @@ -37,7 +37,7 @@ camAreaEvent("AttackArea2", function(droid) function doNPRetreat() { - var pos = camMakePos("NPSensorTurn"); + const pos = camMakePos("NPSensorTurn"); if (NPScout) { camTrace("New Paradigm sensor droid is retreating"); @@ -61,7 +61,7 @@ function eventDestroyed(obj) camAreaEvent("NPSensorTurn", function(droid) { - var pos = camMakePos("NPSensorRemove"); + const pos = camMakePos("NPSensorRemove"); orderDroidLoc(NPScout, DORDER_MOVE, pos.x, pos.y); }); @@ -73,18 +73,18 @@ camAreaEvent("NPSensorRemove", function(droid) function eventStartLevel() { camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "SUB_1_1S"); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); setMissionTime(camChangeOnDiff(camHoursToSeconds(1))); - setAlliance(NEW_PARADIGM, SCAV_6, true); - setAlliance(NEW_PARADIGM, SCAV_7, true); - setAlliance(SCAV_6, SCAV_7, true); + setAlliance(CAM_NEW_PARADIGM, CAM_SCAV_6, true); + setAlliance(CAM_NEW_PARADIGM, CAM_SCAV_7, true); + setAlliance(CAM_SCAV_6, CAM_SCAV_7, true); - camCompleteRequiredResearch(SCAVENGER_RES, 6); - camCompleteRequiredResearch(SCAVENGER_RES, 7); + camCompleteRequiredResearch(mis_scavengerRes, 6); + camCompleteRequiredResearch(mis_scavengerRes, 7); camSetArtifacts({ "base1factory": { tech: "R-Wpn-Flamer-ROF01" }, @@ -164,6 +164,6 @@ function eventStartLevel() // New Paradigm sensor scout. Now comes with the map! NPScout = getObject("npscout"); camNeverGroupDroid(NPScout); - var pos = getObject("NPSensorWatch"); + const pos = getObject("NPSensorWatch"); orderDroidLoc(NPScout, DORDER_MOVE, pos.x, pos.y); } diff --git a/script/campaign/cam1c.js b/script/campaign/cam1c.js index a18e27c..bba0364 100644 --- a/script/campaign/cam1c.js +++ b/script/campaign/cam1c.js @@ -2,7 +2,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const NEW_PARADIGM_RES = [ +const mis_newParadigmRes = [ "R-Wpn-MG-Damage03", "R-Wpn-MG-ROF01", "R-Defense-WallUpgrade02", "R-Struc-Materials02", "R-Struc-Factory-Upgrade01", "R-Vehicle-Engine02", @@ -12,7 +12,7 @@ const NEW_PARADIGM_RES = [ "R-Wpn-Rocket-Damage02", "R-Wpn-Rocket-ROF01", "R-Wpn-RocketSlow-Damage01", "R-Struc-RprFac-Upgrade03", ]; -const SCAVENGER_RES = [ +const mis_scavengerRes = [ "R-Wpn-Flamer-Damage02", "R-Wpn-Flamer-ROF01", "R-Wpn-MG-Damage03", "R-Wpn-MG-ROF01", "R-Wpn-Rocket-Damage01", "R-Wpn-Cannon-Damage02", "R-Wpn-Mortar-Damage02", "R-Wpn-Mortar-ROF01", @@ -116,14 +116,14 @@ function camEnemyBaseEliminated_NPCentralFactory() function getDroidsForNPLZ(args) { - var scouts = [ cTempl.nppod, cTempl.nphmg ]; - var heavies = [ cTempl.npslc, cTempl.npsmct ]; - var useArtillery = (camRand(100) < 50); + const scouts = [ cTempl.nppod, cTempl.nphmg ]; + const heavies = [ cTempl.npslc, cTempl.npsmct ]; + const USE_ARTILLERY = (camRand(100) < 50); - var numScouts = camRand(5) + 1; - var heavy = heavies[camRand(heavies.length)]; - var list = []; + let numScouts = camRand(5) + 1; + let heavy = heavies[camRand(heavies.length)]; + const list = []; if (useArtillery) { @@ -132,12 +132,12 @@ function getDroidsForNPLZ(args) heavy = cTempl.npmor; } - for (var i = 0; i < numScouts; ++i) + for (let i = 0; i < numScouts; ++i) { list[list.length] = scouts[camRand(scouts.length)]; } - for (var a = numScouts; a < 8; ++a) + for (let a = numScouts; a < 8; ++a) { list[list.length] = heavy; } @@ -176,15 +176,15 @@ camAreaEvent("NPLZ2Trigger", function() function eventStartLevel() { camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "CAM_1CA"); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); // make sure player doesn't build on enemy LZs of the next level - for (var i = 1; i <= 5; ++i) + for (let i = 1; i <= 5; ++i) { - var ph = getObject("PhantomLZ" + i); + const ph = getObject("PhantomLZ" + i); // HACK: set LZs of bad players, namely 2...6, // note: player 1 is NP, player 7 is scavs setNoGoArea(ph.x, ph.y, ph.x2, ph.y2, i + 1); @@ -204,9 +204,9 @@ function eventStartLevel() } setReinforcementTime(-1); - setAlliance(NEW_PARADIGM, SCAV_7, true); - camCompleteRequiredResearch(NEW_PARADIGM_RES, NEW_PARADIGM); - camCompleteRequiredResearch(SCAVENGER_RES, SCAV_7); + setAlliance(CAM_NEW_PARADIGM, CAM_SCAV_7, true); + camCompleteRequiredResearch(mis_newParadigmRes, CAM_NEW_PARADIGM); + camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7); camSetEnemyBases({ "ScavSouthDerrickGroup": { @@ -238,7 +238,7 @@ function eventStartLevel() detectMsg: "C1C_BASE5", detectSnd: "pcv374.ogg", eliminateSnd: "pcv391.ogg", - player: SCAV_7 // hence discriminate by player filter + player: CAM_SCAV_7 // hence discriminate by player filter }, "NPEastBaseGroup": { cleanup: "NPEastBase", @@ -263,19 +263,19 @@ function eventStartLevel() detectMsg: "C1C_BASE10", detectSnd: "pcv379.ogg", eliminateSnd: "pcv394.ogg", - player: NEW_PARADIGM // hence discriminate by player filter + player: CAM_NEW_PARADIGM // hence discriminate by player filter }, "NPLZ1Group": { cleanup: "NPLZ1", // kill the four towers to disable LZ detectMsg: "C1C_LZ1", eliminateSnd: "pcv394.ogg", - player: NEW_PARADIGM // required for LZ-type bases + player: CAM_NEW_PARADIGM // required for LZ-type bases }, "NPLZ2Group": { cleanup: "NPLZ2", // kill the four towers to disable LZ detectMsg: "C1C_LZ2", eliminateSnd: "pcv394.ogg", - player: NEW_PARADIGM // required for LZ-type bases + player: CAM_NEW_PARADIGM // required for LZ-type bases }, }); @@ -337,7 +337,7 @@ function eventStartLevel() }, }); - camManageTrucks(NEW_PARADIGM); + camManageTrucks(CAM_NEW_PARADIGM); replaceTexture("page-7-barbarians-arizona.png", "page-7-barbarians-kevlar.png"); camEnableFactory("ScavSouthFactory"); diff --git a/script/campaign/cam1ca.js b/script/campaign/cam1ca.js index 9ce6a45..3dce3a0 100644 --- a/script/campaign/cam1ca.js +++ b/script/campaign/cam1ca.js @@ -2,8 +2,8 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const landingZoneList = [ "NPLZ1", "NPLZ2", "NPLZ3", "NPLZ4", "NPLZ5" ]; -const landingZoneMessages = [ "C1CA_LZ1", "C1CA_LZ2", "C1CA_LZ3", "C1CA_LZ4", "C1CA_LZ5" ]; +const mis_landingZoneList = [ "NPLZ1", "NPLZ2", "NPLZ3", "NPLZ4", "NPLZ5" ]; +const mis_landingZoneMessages = [ "C1CA_LZ1", "C1CA_LZ2", "C1CA_LZ3", "C1CA_LZ4", "C1CA_LZ5" ]; var blipActive; var lastLZ, lastHeavy; var totalTransportLoads; @@ -13,7 +13,7 @@ var totalTransportLoads; function baseEstablished() { //Now we check if there is stuff built here already from cam1-C. - var total = camCountStructuresInArea("buildArea") + + const total = camCountStructuresInArea("buildArea") + camCountStructuresInArea("buildArea2") + camCountStructuresInArea("buildArea3") + camCountStructuresInArea("buildArea4") + @@ -42,7 +42,7 @@ function baseEstablished() function extraVictoryCondition() { const MIN_TRANSPORT_RUNS = 10; - var enemies = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false); + const enemies = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false); // No enemies on map and at least eleven New Paradigm transport runs. if (baseEstablished() && (totalTransportLoads > MIN_TRANSPORT_RUNS) && !enemies.length) { @@ -60,12 +60,11 @@ function sendTransport() lastHeavy = true; } // find an LZ that is not compromised - var list = []; - var i = 0; - for (i = 0; i < landingZoneList.length; ++i) + const list = []; + for (let i = 0; i < mis_landingZoneList.length; ++i) { - var lz = landingZoneList[i]; - if (enumArea(lz, CAM_HUMAN_PLAYER, false).length === 0) + const LZ = mis_landingZoneList[i]; + if (enumArea(LZ, CAM_HUMAN_PLAYER, false).length === 0) { list.push({ idx: i, label: lz }); } @@ -73,21 +72,21 @@ function sendTransport() //If all are compromised then choose the LZ randomly if (list.length === 0) { - for (i = 0; i < 2; ++i) + for (let i = 0; i < 2; ++i) { - var rnd = camRand(landingZoneList.length); - list.push({ idx: rnd, label: landingZoneList[rnd] }); + const RND = camRand(mis_landingZoneList.length); + list.push({ idx: RND, label: mis_landingZoneList[rnd] }); } } - var picked = list[camRand(list.length)]; + const picked = list[camRand(list.length)]; lastLZ = picked.idx; - var pos = camMakePos(picked.label); + const pos = camMakePos(picked.label); // (2 or 3 or 4) pairs of each droid template. // This emulates wzcam's droid count distribution. - var count = [ 2, 3, 4, 4, 4, 4, 4, 4, 4 ][camRand(9)]; + const COUNT = [ 2, 3, 4, 4, 4, 4, 4, 4, 4 ][camRand(9)]; - var transportTime = 3; // Time, in minutes, until the next transport. (Default to 3 minutes.) + let transportTime = 3; // Time, in minutes, until the next transport. (Default to 3 minutes.) // Cut transport arrival time in half if structures on plateu are built. if (!blipActive) @@ -100,7 +99,7 @@ function sendTransport() removeTimer("sendTransport"); // Remove the old timer, so we can update it's time below } - var templates; + let templates; if (lastHeavy) { lastHeavy = false; @@ -114,24 +113,24 @@ function sendTransport() templates = [ cTempl.npsmct, cTempl.npmor, cTempl.npsmc, cTempl.npmmct, cTempl.npmrl, cTempl.nphmg, cTempl.npsbb ]; } - var droids = []; - for (i = 0; i < count; ++i) + const droids = []; + for (let i = 0; i < COUNT; ++i) { - var t = templates[camRand(templates.length)]; + const t = templates[camRand(templates.length)]; // two droids of each template droids[droids.length] = t; droids[droids.length] = t; } - camSendReinforcement(NEW_PARADIGM, pos, droids, CAM_REINFORCE_TRANSPORT, { + camSendReinforcement(CAM_NEW_PARADIGM, pos, droids, CAM_REINFORCE_TRANSPORT, { entry: { x: 126, y: 36 }, exit: { x: 126, y: 76 }, - message: landingZoneMessages[lastLZ], + message: mis_landingZoneMessages[lastLZ], order: CAM_ORDER_ATTACK, data: { regroup: true, count: -1, pos: "buildArea" } }); - totalTransportLoads = totalTransportLoads + 1; + totalTransportLoads += 1; } function startTransporterAttack() @@ -149,15 +148,15 @@ function eventStartLevel() camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "SUB_1_4AS", { callback: "extraVictoryCondition" }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); // make sure player doesn't build on enemy LZs - for (var i = 1; i <= 5; ++i) + for (let i = 1; i <= 5; ++i) { - var ph = getObject("PhantomLZ" + i); + const ph = getObject("PhantomLZ" + i); // HACK: set LZs of bad players, namely 2...6, // note: player 1 is NP setNoGoArea(ph.x, ph.y, ph.x2, ph.y2, i + 1); diff --git a/script/campaign/cam2-1s.js b/script/campaign/cam2-1s.js index a8ff2af..63e71e1 100644 --- a/script/campaign/cam2-1s.js +++ b/script/campaign/cam2-1s.js @@ -14,7 +14,7 @@ function eventStartLevel() centreView(88, 101); //Setup Landing Zone setNoGoArea(86, 99, 88, 101, CAM_HUMAN_PLAYER); - setNoGoArea(49, 83, 51, 85, THE_COLLECTIVE); + setNoGoArea(49, 83, 51, 85, CAM_THE_COLLECTIVE); //Set Mission Time setMissionTime(camChangeOnDiff(camMinutesToSeconds(30))); //Give player briefings diff --git a/script/campaign/cam2-1x.js b/script/campaign/cam2-1x.js index f59a41b..16fa84e 100644 --- a/script/campaign/cam2-1x.js +++ b/script/campaign/cam2-1x.js @@ -8,7 +8,7 @@ include ("script/campaign/transitionTech.js"); var victoryFlag; const TRANSPORT_TEAM = 1; -const COLLECTIVE_RES = [ +const mis_collectiveRes = [ "R-Defense-WallUpgrade03", "R-Struc-Materials03", "R-Vehicle-Engine04", "R-Vehicle-Metals04", "R-Cyborg-Metals04", "R-Wpn-Cannon-Accuracy02", "R-Wpn-Cannon-Damage04", "R-Wpn-Cannon-ROF01", "R-Wpn-Flamer-Damage04", "R-Wpn-Flamer-ROF01", @@ -32,8 +32,8 @@ camAreaEvent("crashSite", function(droid) hackRemoveMessage("C21_OBJECTIVE", PROX_MSG, CAM_HUMAN_PLAYER); - var droids = enumDroid(TRANSPORT_TEAM); - for (var i = 0; i < droids.length; ++i) + const droids = enumDroid(TRANSPORT_TEAM); + for (let i = 0; i < droids.length; ++i) { donateObject(droids[i], CAM_HUMAN_PLAYER); } @@ -47,8 +47,8 @@ camAreaEvent("crashSite", function(droid) function preDamageUnits() { setHealth(getObject("transporter"), 40); - var droids = enumDroid(TRANSPORT_TEAM); - for (var j = 0; j < droids.length; ++j) + const droids = enumDroid(TRANSPORT_TEAM); + for (let j = 0; j < droids.length; ++j) { setHealth(droids[j], 40 + camRand(20)); } @@ -82,13 +82,13 @@ function setupCyborgGroups() function setCrashedTeamExp() { const DROID_EXP = 32; - var droids = enumDroid(TRANSPORT_TEAM).filter(function(dr) { + const droids = enumDroid(TRANSPORT_TEAM).filter(function(dr) { return !camIsSystemDroid(dr) && !camIsTransporter(dr); }); - for (var i = 0; i < droids.length; ++i) + for (let i = 0; i < droids.length; ++i) { - var droid = droids[i]; + const droid = droids[i]; setDroidExperience(droid, DROID_EXP); } @@ -120,17 +120,17 @@ function eventStartLevel() callback: "checkCrashedTeam" }); - var subLandingZone = getObject("landingZone"); - var startpos = getObject("startingPosition"); - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const subLandingZone = getObject("landingZone"); + const startpos = getObject("startingPosition"); + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(subLandingZone.x, subLandingZone.y, subLandingZone.x2, subLandingZone.y2); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - var enemyLz = getObject("COLandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + const enemyLz = getObject("COLandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); //Add crash site blip and from an alliance with the crashed team. hackAddMessage("C21_OBJECTIVE", PROX_MSG, CAM_HUMAN_PLAYER, false); @@ -139,9 +139,9 @@ function eventStartLevel() //set downed transport team colour to match the player. changePlayerColour(TRANSPORT_TEAM, playerData[0].colour); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); - camCompleteRequiredResearch(ALPHA_RESEARCH, TRANSPORT_TEAM); - camCompleteRequiredResearch(PLAYER_RES_BETA, TRANSPORT_TEAM); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); + camCompleteRequiredResearch(mis_alphaResearchNew, TRANSPORT_TEAM); + camCompleteRequiredResearch(mis_playerResBeta, TRANSPORT_TEAM); camSetEnemyBases({ "COHardpointBase": { diff --git a/script/campaign/cam2-2.js b/script/campaign/cam2-2.js index 26bddc5..8447667 100644 --- a/script/campaign/cam2-2.js +++ b/script/campaign/cam2-2.js @@ -3,7 +3,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); const warning = "pcv632.ogg"; // Collective commander escaping -const COLLEVTIVE_RES = [ +const mis_collectiveRes = [ "R-Defense-WallUpgrade03", "R-Struc-Materials04", "R-Struc-Factory-Upgrade04", "R-Vehicle-Engine04", "R-Vehicle-Metals05", "R-Cyborg-Metals05", @@ -27,7 +27,7 @@ camAreaEvent("vtolRemoveZone", function(droid) camSafeRemoveObject(droid, false); } - resetLabel("vtolRemoveZone", THE_COLLECTIVE); + resetLabel("vtolRemoveZone", CAM_THE_COLLECTIVE); }); @@ -47,7 +47,7 @@ camAreaEvent("wayPoint1Rad", function(droid) { if (isVTOL(droid)) { - resetLabel("wayPoint1Rad", THE_COLLECTIVE); + resetLabel("wayPoint1Rad", CAM_THE_COLLECTIVE); return; } camManageGroup(commandGroup, CAM_ORDER_DEFEND, { @@ -63,12 +63,12 @@ camAreaEvent("wayPoint2Rad", function(droid) { if (droid.droidType !== DROID_COMMAND) { - resetLabel("wayPoint2Rad", THE_COLLECTIVE); + resetLabel("wayPoint2Rad", CAM_THE_COLLECTIVE); return; } - var point = getObject("wayPoint3"); - var defGroup = enumRange(point.x, point.y, 10, THE_COLLECTIVE, false).filter(function(obj) { + const point = getObject("wayPoint3"); + const defGroup = enumRange(point.x, point.y, 10, CAM_THE_COLLECTIVE, false).filter(function(obj) { return (obj.droidType === DROID_WEAPON); }); @@ -97,37 +97,37 @@ camAreaEvent("failZone", function(droid) } else { - resetLabel("failZone", THE_COLLECTIVE); + resetLabel("failZone", CAM_THE_COLLECTIVE); } }); function vtolAttack() { - var list = [cTempl.colatv]; - var ext = { + const list = [cTempl.colatv]; + const ext = { limit: 4, alternate: false, altIdx: 0 }; - camSetVtolData(THE_COLLECTIVE, "vtolAppearPoint", "vtolRemovePoint", list, camChangeOnDiff(camMinutesToMilliseconds(3)), "COCommandCenter", ext); + camSetVtolData(CAM_THE_COLLECTIVE, "vtolAppearPoint", "vtolRemovePoint", list, camChangeOnDiff(camMinutesToMilliseconds(3)), "COCommandCenter", ext); } //Order the truck to build some defenses. function truckDefense() { - if (enumDroid(THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) + if (enumDroid(CAM_THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) { removeTimer("truckDefense"); return; } const list = ["CO-Tower-LtATRkt", "PillBox1", "CO-Tower-MdCan"]; - camQueueBuilding(THE_COLLECTIVE, list[camRand(list.length)]); + camQueueBuilding(CAM_THE_COLLECTIVE, list[camRand(list.length)]); } function showGameOver() { - var arti = camGetArtifacts(); + const arti = camGetArtifacts(); camSafeRemoveObject(arti[0], false); gameOverMessage(false); } @@ -151,7 +151,7 @@ function retreatCommander() function eventAttacked(victim, attacker) { if (camDef(victim) && - victim.player === THE_COLLECTIVE && + victim.player === CAM_THE_COLLECTIVE && victim.y > Math.floor(mapHeight / 3) && //only if the commander is escaping to the south victim.group === commandGroup) { @@ -167,23 +167,23 @@ function eventStartLevel() reinforcements: camMinutesToSeconds(3) }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - var enemyLz = getObject("COLandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + const enemyLz = getObject("COLandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); camSetArtifacts({ "COCommander": { tech: "R-Wpn-RocketSlow-Accuracy03" }, }); - camCompleteRequiredResearch(COLLEVTIVE_RES, THE_COLLECTIVE); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); camSetEnemyBases({ "COEastBase": { @@ -230,7 +230,7 @@ function eventStartLevel() }); commandGroup = camMakeGroup("group1NBase"); - camManageTrucks(THE_COLLECTIVE); + camManageTrucks(CAM_THE_COLLECTIVE); truckDefense(); camEnableFactory("COFactoryWest"); diff --git a/script/campaign/cam2-2s.js b/script/campaign/cam2-2s.js index f4847e6..d4d1b40 100644 --- a/script/campaign/cam2-2s.js +++ b/script/campaign/cam2-2s.js @@ -5,7 +5,7 @@ function eventStartLevel() camSetupTransporter(87, 100, 70, 1); centreView(88, 101); setNoGoArea(86, 99, 88, 101, CAM_HUMAN_PLAYER); - setNoGoArea(49, 83, 51, 85, THE_COLLECTIVE); + setNoGoArea(49, 83, 51, 85, CAM_THE_COLLECTIVE); setMissionTime(camChangeOnDiff(camMinutesToSeconds(70))); camPlayVideos([{video: "MB2_2_MSG", type: CAMP_MSG}, {video:"MB2_2_MSG2", type: CAMP_MSG}, {video: "MB2_2_MSG3", type: MISS_MSG}]); camSetStandardWinLossConditions(CAM_VICTORY_PRE_OFFWORLD, "SUB_2_2"); diff --git a/script/campaign/cam2-5.js b/script/campaign/cam2-5.js index 6e39f0f..d46d6e6 100644 --- a/script/campaign/cam2-5.js +++ b/script/campaign/cam2-5.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const COLLECTIVE_RES = [ +const mis_collectiveRes = [ "R-Defense-WallUpgrade03", "R-Struc-Materials05", "R-Struc-Factory-Upgrade05", "R-Struc-VTOLPad-Upgrade01", "R-Vehicle-Engine04", "R-Vehicle-Metals05", "R-Cyborg-Metals05", @@ -35,7 +35,7 @@ function camEnemyBaseEliminated_COEastBase() //Tell everything not grouped on map to attack function camEnemyBaseDetected_COEastBase() { - var droids = enumArea(0, 0, mapWidth, mapHeight, THE_COLLECTIVE, false).filter(function(obj) { + const droids = enumArea(0, 0, mapWidth, mapHeight, CAM_THE_COLLECTIVE, false).filter(function(obj) { return obj.type === DROID && obj.group === null && obj.canHitGround; }); @@ -97,17 +97,17 @@ function eventStartLevel() reinforcements: camMinutesToSeconds(3) }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - var enemyLz = getObject("COLandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + const enemyLz = getObject("COLandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); camSetArtifacts({ "NuclearReactor": { tech: "R-Struc-Power-Upgrade01" }, @@ -116,7 +116,7 @@ function eventStartLevel() "COTankKillerHardpoint": { tech: "R-Wpn-RocketSlow-ROF02" }, }); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); camSetEnemyBases({ "COEastBase": { diff --git a/script/campaign/cam2-5s.js b/script/campaign/cam2-5s.js index 839bf32..29f9fa6 100644 --- a/script/campaign/cam2-5s.js +++ b/script/campaign/cam2-5s.js @@ -5,7 +5,7 @@ function eventStartLevel() camSetupTransporter(87, 100, 32, 1); centreView(88, 101); setNoGoArea(86, 99, 88, 101, CAM_HUMAN_PLAYER); - //setNoGoArea(49, 83, 51, 85, THE_COLLECTIVE); + //setNoGoArea(49, 83, 51, 85, CAM_THE_COLLECTIVE); setMissionTime(camChangeOnDiff(camHoursToSeconds(1))); camPlayVideos([{video: "MB2_5_MSG", type: CAMP_MSG}, {video: "MB2_5_MSG2", type: MISS_MSG}]); camSetStandardWinLossConditions(CAM_VICTORY_PRE_OFFWORLD, "SUB_2_5"); diff --git a/script/campaign/cam2-6.js b/script/campaign/cam2-6.js index 0db7095..9726d16 100644 --- a/script/campaign/cam2-6.js +++ b/script/campaign/cam2-6.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const COLLECTIVE_RES = [ +const mis_collectiveRes = [ "R-Defense-WallUpgrade05", "R-Struc-Materials05", "R-Struc-Factory-Upgrade05", "R-Struc-VTOLPad-Upgrade03", "R-Vehicle-Engine05", "R-Vehicle-Metals05", "R-Cyborg-Metals05", @@ -39,7 +39,7 @@ function camEnemyBaseEliminated_COUplinkBase() //Group together attack droids in this base that are not already in a group function camEnemyBaseDetected_COMediumBase() { - var droids = enumArea("mediumBaseCleanup", THE_COLLECTIVE, false).filter(function(obj) { + const droids = enumArea("mediumBaseCleanup", CAM_THE_COLLECTIVE, false).filter(function(obj) { return obj.type === DROID && obj.group === null && obj.canHitGround; }); @@ -97,17 +97,17 @@ function eventStartLevel() reinforcements: camMinutesToSeconds(3) }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - var enemyLz = getObject("COLandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + const enemyLz = getObject("COLandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); camSetArtifacts({ "COCyborgFactory-Arti": { tech: "R-Wpn-Rocket07-Tank-Killer" }, @@ -115,7 +115,7 @@ function eventStartLevel() "uplink": { tech: "R-Sys-VTOLCBS-Tower01" }, }); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); camSetEnemyBases({ "COUplinkBase": { diff --git a/script/campaign/cam2-6s.js b/script/campaign/cam2-6s.js index 57cc01f..504065d 100644 --- a/script/campaign/cam2-6s.js +++ b/script/campaign/cam2-6s.js @@ -5,7 +5,7 @@ function eventStartLevel() camSetupTransporter(87, 100, 16, 126); centreView(88, 101); setNoGoArea(86, 99, 88, 101, CAM_HUMAN_PLAYER); - //setNoGoArea(49, 83, 51, 85, THE_COLLECTIVE); + //setNoGoArea(49, 83, 51, 85, CAM_THE_COLLECTIVE); setMissionTime(camChangeOnDiff(camHoursToSeconds(1))); camPlayVideos([{video: "MB2_6_MSG", type: CAMP_MSG}, {video: "MB2_6_MSG2", type: CAMP_MSG}, {video: "MB2_6_MSG3", type: MISS_MSG}]); camSetStandardWinLossConditions(CAM_VICTORY_PRE_OFFWORLD, "SUB_2_6"); diff --git a/script/campaign/cam2-7.js b/script/campaign/cam2-7.js index 49e1eeb..41388cf 100644 --- a/script/campaign/cam2-7.js +++ b/script/campaign/cam2-7.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const COLLECTIVE_RES = [ +const mis_collectiveRes = [ "R-Defense-WallUpgrade05", "R-Struc-Materials05", "R-Struc-Factory-Upgrade05", "R-Struc-VTOLPad-Upgrade03", "R-Vehicle-Engine05", "R-Vehicle-Metals05", "R-Cyborg-Metals05", @@ -26,7 +26,7 @@ function camEnemyBaseDetected_COBase2() { hackRemoveMessage("C27_OBJECTIVE2", PROX_MSG, CAM_HUMAN_PLAYER); - var vt = enumArea("COBase2Cleanup", THE_COLLECTIVE, false).filter(function(obj) { + const vt = enumArea("COBase2Cleanup", CAM_THE_COLLECTIVE, false).filter(function(obj) { return obj.type === DROID && isVTOL(obj); }); camManageGroup(camMakeGroup(vt), CAM_ORDER_ATTACK, { @@ -46,7 +46,7 @@ function camEnemyBaseDetected_COBase4() function baseThreeVtolAttack() { - var vt = enumArea("vtolGroupBase3", THE_COLLECTIVE, false).filter(function(obj) { + const vt = enumArea("vtolGroupBase3", CAM_THE_COLLECTIVE, false).filter(function(obj) { return obj.type === DROID && isVTOL(obj); }); camManageGroup(camMakeGroup(vt), CAM_ORDER_ATTACK, { @@ -56,7 +56,7 @@ function baseThreeVtolAttack() function baseFourVtolAttack() { - var vt = enumArea("vtolGroupBase4", THE_COLLECTIVE, false).filter(function(obj) { + const vt = enumArea("vtolGroupBase4", CAM_THE_COLLECTIVE, false).filter(function(obj) { return obj.type === DROID && isVTOL(obj); }); camManageGroup(camMakeGroup(vt), CAM_ORDER_ATTACK, { @@ -95,17 +95,17 @@ function eventStartLevel() reinforcements: camMinutesToSeconds(3) }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - var enemyLz = getObject("COLandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + const enemyLz = getObject("COLandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); camSetArtifacts({ "COHeavyFac-Arti-b2": { tech: "R-Wpn-Cannon5" }, @@ -114,7 +114,7 @@ function eventStartLevel() "COHeavyFac-b4": { tech: "R-Wpn-AAGun04" }, // Whirlwind }); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); camSetEnemyBases({ "COBase1": { diff --git a/script/campaign/cam2-7s.js b/script/campaign/cam2-7s.js index 16fd360..15c23e3 100644 --- a/script/campaign/cam2-7s.js +++ b/script/campaign/cam2-7s.js @@ -5,7 +5,7 @@ function eventStartLevel() camSetupTransporter(87, 100, 100, 1); centreView(88, 101); setNoGoArea(86, 99, 88, 101, CAM_HUMAN_PLAYER); - //setNoGoArea(49, 83, 51, 85, THE_COLLECTIVE); + //setNoGoArea(49, 83, 51, 85, CAM_THE_COLLECTIVE); setMissionTime(camChangeOnDiff(camHoursToSeconds(1.5))); camPlayVideos([{video: "MB2_7_MSG", type: CAMP_MSG}, {video: "MB2_7_MSG2", type: MISS_MSG}]); camSetStandardWinLossConditions(CAM_VICTORY_PRE_OFFWORLD, "SUB_2_7"); diff --git a/script/campaign/cam2-8.js b/script/campaign/cam2-8.js index 486b9f0..3f9fadf 100644 --- a/script/campaign/cam2-8.js +++ b/script/campaign/cam2-8.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const COLLECTIVE_RES = [ +const mis_collectiveRes = [ "R-Defense-WallUpgrade05", "R-Struc-Materials06", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade03", "R-Vehicle-Engine05", "R-Vehicle-Metals05", "R-Cyborg-Metals06", @@ -26,10 +26,10 @@ function vtolAttack() function setupLandGroups() { - var hovers = enumArea("NWTankGroup", THE_COLLECTIVE, false).filter(function(obj) { + const hovers = enumArea("NWTankGroup", CAM_THE_COLLECTIVE, false).filter(function(obj) { return obj.type === DROID && obj.propulsion === "hover01"; }); - var tanks = enumArea("NWTankGroup", THE_COLLECTIVE, false).filter(function(obj) { + const tanks = enumArea("NWTankGroup", CAM_THE_COLLECTIVE, false).filter(function(obj) { return obj.type === DROID && obj.propulsion !== "hover01"; }); @@ -74,14 +74,14 @@ function enableFactories() function truckDefense() { - if (enumDroid(THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) + if (enumDroid(CAM_THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) { removeTimer("truckDefense"); return; } - var list = ["AASite-QuadBof", "CO-WallTower-HvCan", "CO-Tower-RotMG"]; - camQueueBuilding(THE_COLLECTIVE, list[camRand(list.length)]); + const list = ["AASite-QuadBof", "CO-WallTower-HvCan", "CO-Tower-RotMG"]; + camQueueBuilding(CAM_THE_COLLECTIVE, list[camRand(list.length)]); } function eventStartLevel() @@ -92,27 +92,27 @@ function eventStartLevel() annihilate: true }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - var enemyLz = getObject("COLandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + const enemyLz = getObject("COLandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); camSetArtifacts({ "COVtolFac-b3": { tech: "R-Vehicle-Body09" }, //Tiger body "COHeavyFacL-b2": { tech: "R-Wpn-HvyHowitzer" }, }); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); // Replace flamer cyborgs with thermite - camUpgradeOnMapTemplates(cTempl.npcybf, cTempl.cocybtf, THE_COLLECTIVE); + camUpgradeOnMapTemplates(cTempl.npcybf, cTempl.cocybtf, CAM_THE_COLLECTIVE); camSetEnemyBases({ "COBase1": { @@ -184,7 +184,7 @@ function eventStartLevel() }, }); - camManageTrucks(THE_COLLECTIVE); + camManageTrucks(CAM_THE_COLLECTIVE); truckDefense(); queue("setupLandGroups", camSecondsToMilliseconds(50)); diff --git a/script/campaign/cam2-8s.js b/script/campaign/cam2-8s.js index 3230a68..3a0b0d2 100644 --- a/script/campaign/cam2-8s.js +++ b/script/campaign/cam2-8s.js @@ -5,7 +5,7 @@ function eventStartLevel() camSetupTransporter(87, 100, 126, 60); centreView(88, 101); setNoGoArea(86, 99, 88, 101, CAM_HUMAN_PLAYER); - //setNoGoArea(49, 83, 51, 85, THE_COLLECTIVE); + //setNoGoArea(49, 83, 51, 85, CAM_THE_COLLECTIVE); setMissionTime(camChangeOnDiff(camHoursToSeconds(1))); camPlayVideos([{video: "MB2_8_MSG", type: CAMP_MSG}, {video: "MB2_8_MSG2", type: MISS_MSG}]); camSetStandardWinLossConditions(CAM_VICTORY_PRE_OFFWORLD, "SUB_2_8"); diff --git a/script/campaign/cam2-a.js b/script/campaign/cam2-a.js index fdacfc7..3dfc3aa 100644 --- a/script/campaign/cam2-a.js +++ b/script/campaign/cam2-a.js @@ -10,7 +10,7 @@ var startedFromMenu; camAreaEvent("vtolRemoveZone", function(droid) { camSafeRemoveObject(droid, false); - resetLabel("vtolRemoveZone", THE_COLLECTIVE); + resetLabel("vtolRemoveZone", CAM_THE_COLLECTIVE); }); //Attack and destroy all those who resist the Machine! -The Collective @@ -22,33 +22,32 @@ function secondVideo() //Damage the base and droids for the player function preDamageStuff() { - var droids = enumDroid(CAM_HUMAN_PLAYER); - var structures = enumStruct(CAM_HUMAN_PLAYER); - var x = 0; + const droids = enumDroid(CAM_HUMAN_PLAYER); + const structures = enumStruct(CAM_HUMAN_PLAYER); - for (x = 0; x < droids.length; ++x) + for (let x = 0; x < droids.length; ++x) { - var droid = droids[x]; + const droid = droids[x]; if (!camIsTransporter(droid)) { setHealth(droid, 45 + camRand(20)); } } - for (x = 0; x < structures.length; ++x) + for (let x = 0; x < structures.length; ++x) { - var struc = structures[x]; + const struc = structures[x]; setHealth(struc, 45 + camRand(45)); } } function getDroidsForCOLZ() { - var droids = []; - var count = 6 + camRand(5); - var templates; - var sensors = [cTempl.comsens, cTempl.comsens]; - var usingHeavy = false; + const droids = []; + const sensors = [cTempl.comsens, cTempl.comsens]; + const COUNT = 6 + camRand(5); + let templates; + let usingHeavy = false; if (camRand(100) < 50) { @@ -60,7 +59,7 @@ function getDroidsForCOLZ() usingHeavy = true; } - for (var i = 0; i < count; ++i) + for (let i = 0; i < COUNT; ++i) { if (!i && usingHeavy) { @@ -78,13 +77,13 @@ function getDroidsForCOLZ() //Send Collective transport units function sendCOTransporter() { - var tPos = getObject("COTransportPos"); - var nearbyDefense = enumRange(tPos.x, tPos.y, 15, THE_COLLECTIVE, false); + const tPos = getObject("COTransportPos"); + const nearbyDefense = enumRange(tPos.x, tPos.y, 15, CAM_THE_COLLECTIVE, false); if (nearbyDefense.length > 0) { - var list = getDroidsForCOLZ(); - camSendReinforcement(THE_COLLECTIVE, camMakePos("COTransportPos"), list, + const list = getDroidsForCOLZ(); + camSendReinforcement(CAM_THE_COLLECTIVE, camMakePos("COTransportPos"), list, CAM_REINFORCE_TRANSPORT, { entry: { x: 125, y: 100 }, exit: { x: 125, y: 70 } @@ -112,10 +111,10 @@ function sendPlayerTransporter() return; } - var droids = []; - var list = [cTempl.prhhpvt, cTempl.prhhpvt, cTempl.prhhpvt, cTempl.prltat, cTempl.prltat, cTempl.npcybr, cTempl.prrept]; + const droids = []; + const list = [cTempl.prhhpvt, cTempl.prhhpvt, cTempl.prhhpvt, cTempl.prltat, cTempl.prltat, cTempl.npcybr, cTempl.prrept]; - for (var i = 0; i < 10; ++i) + for (let i = 0; i < 10; ++i) { droids.push(list[camRand(list.length)]); } @@ -131,22 +130,22 @@ function sendPlayerTransporter() //Continuously spawns heavy units on the north part of the map every 7 minutes function mapEdgeDroids() { - var TankNum = 8 + camRand(6); - var list = [cTempl.npcybm, cTempl.npcybr, cTempl.npcybg, cTempl.coscymc, cTempl.comct, cTempl.cohct, cTempl.copodt]; + const TANK_NUM = 8 + camRand(6); + const list = [cTempl.npcybm, cTempl.npcybr, cTempl.npcybg, cTempl.coscymc, cTempl.comct, cTempl.cohct, cTempl.copodt]; - var droids = []; - for (var i = 0; i < TankNum; ++i) + const droids = []; + for (let i = 0; i < TANK_NUM; ++i) { droids.push(list[camRand(list.length)]); } - camSendReinforcement(THE_COLLECTIVE, camMakePos("groundUnitPos"), droids, CAM_REINFORCE_GROUND); + camSendReinforcement(CAM_THE_COLLECTIVE, camMakePos("groundUnitPos"), droids, CAM_REINFORCE_GROUND); } function vtolAttack() { - var list = [cTempl.colcbv]; - camSetVtolData(THE_COLLECTIVE, "vtolAppearPos", "vtolRemoveZone", list, camChangeOnDiff(camMinutesToMilliseconds(3)), "COCommandCenter"); + const list = [cTempl.colcbv]; + camSetVtolData(CAM_THE_COLLECTIVE, "vtolAppearPos", "vtolRemoveZone", list, camChangeOnDiff(camMinutesToMilliseconds(3)), "COCommandCenter"); } function groupPatrol() @@ -174,20 +173,20 @@ function groupPatrol() //Build defenses around oil resource function truckDefense() { - if (enumDroid(THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) + if (enumDroid(CAM_THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) { removeTimer("truckDefense"); return; } const DEFENSES = ["CO-Tower-LtATRkt", "PillBox1", "CO-Tower-MdCan"]; - camQueueBuilding(THE_COLLECTIVE, DEFENSES[camRand(DEFENSES.length)]); + camQueueBuilding(CAM_THE_COLLECTIVE, DEFENSES[camRand(DEFENSES.length)]); } //Gives starting tech and research. function cam2Setup() { - const COLLECTIVE_RES = [ + const mis_collectiveRes = [ "R-Wpn-MG1Mk1", "R-Sys-Engineering02", "R-Defense-WallUpgrade03", "R-Struc-Materials03", "R-Struc-Factory-Upgrade03", @@ -201,15 +200,15 @@ function cam2Setup() "R-Wpn-RocketSlow-Damage03", "R-Sys-Sensor-Upgrade01" ]; - for (var x = 0, l = STRUCTS_ALPHA.length; x < l; ++x) + for (let x = 0, l = mis_structsAlpha.length; x < l; ++x) { - enableStructure(STRUCTS_ALPHA[x], CAM_HUMAN_PLAYER); + enableStructure(mis_structsAlpha[x], CAM_HUMAN_PLAYER); } - camCompleteRequiredResearch(PLAYER_RES_BETA, CAM_HUMAN_PLAYER); - camCompleteRequiredResearch(ALPHA_RESEARCH_NEW, THE_COLLECTIVE); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); - camCompleteRequiredResearch(ALPHA_RESEARCH_NEW, CAM_HUMAN_PLAYER); + camCompleteRequiredResearch(mis_playerResBeta, CAM_HUMAN_PLAYER); + camCompleteRequiredResearch(mis_alphaResearchNew, CAM_THE_COLLECTIVE); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); + camCompleteRequiredResearch(mis_alphaResearchNew, CAM_HUMAN_PLAYER); enableResearch("R-Wpn-Cannon-Damage04", CAM_HUMAN_PLAYER); enableResearch("R-Wpn-Rocket-Damage04", CAM_HUMAN_PLAYER); @@ -220,8 +219,8 @@ function cam2Setup() function setUnitRank(transport) { const DROID_EXP = [128, 64, 32, 16]; - var droids; - var mapRun = false; + let droids; + let mapRun = false; if (transport) { @@ -236,9 +235,9 @@ function setUnitRank(transport) }); } - for (var i = 0, len = droids.length; i < len; ++i) + for (let i = 0, len = droids.length; i < len; ++i) { - var droid = droids[i]; + const droid = droids[i]; if (!camIsSystemDroid(droid)) { setDroidExperience(droid, DROID_EXP[mapRun ? 0 : (transporterIndex - 1)]); @@ -305,18 +304,18 @@ function eventGameLoaded() function eventStartLevel() { const PLAYER_POWER = 5000; - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var enemyLz = getObject("COLandingZone"); - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const enemyLz = getObject("COLandingZone"); + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "SUB_2_1S"); setReinforcementTime(LZ_COMPROMISED_TIME); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); @@ -346,7 +345,7 @@ function eventStartLevel() }, }); - camManageTrucks(THE_COLLECTIVE); + camManageTrucks(CAM_THE_COLLECTIVE); truckDefense(); setUnitRank(); //All pre-placed player droids are ranked. camPlayVideos({video: "MB2A_MSG", type: MISS_MSG}); diff --git a/script/campaign/cam2-b.js b/script/campaign/cam2-b.js index b0433dc..2123188 100644 --- a/script/campaign/cam2-b.js +++ b/script/campaign/cam2-b.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const COLLECTIVE_RES = [ +const mis_collectiveRes = [ "R-Defense-WallUpgrade03", "R-Struc-Materials04", "R-Struc-Factory-Upgrade04", "R-Struc-VTOLPad-Upgrade01", "R-Vehicle-Engine04", "R-Vehicle-Metals04", "R-Cyborg-Metals04", "R-Wpn-Cannon-Accuracy02", "R-Wpn-Cannon-Damage04", "R-Wpn-Cannon-ROF02", @@ -18,7 +18,7 @@ camAreaEvent("vtolRemoveZone", function(droid) { camSafeRemoveObject(droid, false); } - resetLabel("vtolRemoveZone", THE_COLLECTIVE); + resetLabel("vtolRemoveZone", CAM_THE_COLLECTIVE); }); camAreaEvent("factoryTrigger", function(droid) @@ -33,7 +33,7 @@ function camEnemyBaseDetected_COMiddleBase() { hackRemoveMessage("C2B_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER); - var droids = enumArea("base4Cleanup", THE_COLLECTIVE, false).filter(function(obj) { + const droids = enumArea("base4Cleanup", CAM_THE_COLLECTIVE, false).filter(function(obj) { return obj.type === DROID && obj.group === null; }); @@ -83,25 +83,25 @@ function ambushPlayer() function vtolAttack() { - var list = [cTempl.colcbv, cTempl.colatv]; - var ext = { + const list = [cTempl.colcbv, cTempl.colatv]; + const ext = { limit: [4, 4], //paired with list array alternate: true, altIdx: 0 }; - camSetVtolData(THE_COLLECTIVE, "vtolAppearPos", "vtolRemove", list, camChangeOnDiff(camMinutesToMilliseconds(5)), "COCommandCenter", ext); + camSetVtolData(CAM_THE_COLLECTIVE, "vtolAppearPos", "vtolRemove", list, camChangeOnDiff(camMinutesToMilliseconds(5)), "COCommandCenter", ext); } function truckDefense() { - if (enumDroid(THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) + if (enumDroid(CAM_THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) { removeTimer("truckDefense"); return; } const list = ["CO-Tower-MG3", "CO-Tower-LtATRkt", "CO-Tower-MdCan", "CO-Tower-LtATRkt"]; - camQueueBuilding(THE_COLLECTIVE, list[camRand(list.length)]); + camQueueBuilding(CAM_THE_COLLECTIVE, list[camRand(list.length)]); } function transferPower() @@ -115,13 +115,13 @@ function eventStartLevel() { camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "SUB_2_2S"); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); - var enemyLz = getObject("COLandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + const enemyLz = getObject("COLandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); setMissionTime(camChangeOnDiff(camHoursToSeconds(2))); camPlayVideos([{video: "MB2_B_MSG", type: CAMP_MSG}, {video: "MB2_B_MSG2", type: MISS_MSG}]); @@ -134,7 +134,7 @@ function eventStartLevel() "COCybFacL-b2": { tech: "R-Cyborg-Hvywpn-Mcannon" }, //Super Heavy-Gunner }); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); camSetEnemyBases({ "CONorthBase": { @@ -232,7 +232,7 @@ function eventStartLevel() }, }); - camManageTrucks(THE_COLLECTIVE); + camManageTrucks(CAM_THE_COLLECTIVE); truckDefense(); hackAddMessage("C2B_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER, false); diff --git a/script/campaign/cam2-c.js b/script/campaign/cam2-c.js index ac250f9..957830a 100644 --- a/script/campaign/cam2-c.js +++ b/script/campaign/cam2-c.js @@ -6,7 +6,7 @@ var capturedCivCount; //How many civilians have been captured. 59 for defeat. var civilianPosIndex; //Current location of civilian groups. var shepardGroup; //Enemy group that protects civilians. var lastSoundTime; //Only play the "civilian rescued" sound every so often. -const COLLECTIVE_RES = [ +const mis_collectiveRes = [ "R-Defense-WallUpgrade03", "R-Struc-Materials04", "R-Struc-Factory-Upgrade04", "R-Struc-VTOLPad-Upgrade01", "R-Vehicle-Engine04", "R-Vehicle-Metals05", "R-Cyborg-Metals05", @@ -52,7 +52,7 @@ camAreaEvent("base3Trigger", function(droid) //Send idle droids in this base to attack when the player spots the base function camEnemyBaseDetected_COAirBase() { - var droids = enumArea("airBaseCleanup", THE_COLLECTIVE, false).filter(function(obj) { + const droids = enumArea("airBaseCleanup", CAM_THE_COLLECTIVE, false).filter(function(obj) { return obj.type === DROID && obj.group === null; }); @@ -122,14 +122,14 @@ function activateGroups() function truckDefense() { - if (enumDroid(THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) + if (enumDroid(CAM_THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) { removeTimer("truckDefense"); return; } - const LIST = ["CO-Tower-LtATRkt", "PillBox1", "CO-Tower-MdCan"]; - camQueueBuilding(THE_COLLECTIVE, LIST[camRand(LIST.length)]); + const list = ["CO-Tower-LtATRkt", "PillBox1", "CO-Tower-MdCan"]; + camQueueBuilding(CAM_THE_COLLECTIVE, list[camRand(list.length)]); } //This controls the collective cyborg shepard groups and moving civilians @@ -137,35 +137,34 @@ function truckDefense() //when all of the shepard group members are destroyed). function captureCivilians() { - var wayPoints = [ + const wayPoints = [ "civPoint1", "civPoint2", "civPoint3", "civPoint4", "civPoint5", "civPoint6", "civPoint7", "civCapturePos" ]; - var currPos = getObject(wayPoints[civilianPosIndex]); - var shepardDroids = enumGroup(shepardGroup); + const currPos = getObject(wayPoints[civilianPosIndex]); + const shepardDroids = enumGroup(shepardGroup); if (shepardDroids.length > 0) { //add some civs - var i = 0; - var num = 1 + camRand(3); - for (i = 0; i < num; ++i) + const NUM = 1 + camRand(3); + for (let i = 0; i < NUM; ++i) { - addDroid(SCAV_7, currPos.x, currPos.y, "Civilian", + addDroid(CAM_SCAV_7, currPos.x, currPos.y, "Civilian", "B1BaBaPerson01", "BaBaLegs", "", "", "BabaMG"); } //Only count civilians that are not in the the transporter base. - var civs = enumArea(0, 0, 35, mapHeight, SCAV_7, false); + const civs = enumArea(0, 0, 35, mapHeight, CAM_SCAV_7, false); //Move them - for (i = 0; i < civs.length; ++i) + for (let i = 0; i < civs.length; ++i) { orderDroidLoc(civs[i], DORDER_MOVE, currPos.x, currPos.y); } if (civilianPosIndex <= 5) { - for (i = 0; i < shepardDroids.length; ++i) + for (let i = 0; i < shepardDroids.length; ++i) { orderDroidLoc(shepardDroids[i], DORDER_MOVE, currPos.x, currPos.y); } @@ -187,16 +186,15 @@ function captureCivilians() //before removal. function civilianOrders() { - var lz = getObject("startPosition"); - var rescueSound = "pcv612.ogg"; //"Civilian Rescued". - var civs = enumDroid(SCAV_7); - var rescued = false; + const lz = getObject("startPosition"); + const civs = enumDroid(CAM_SCAV_7); + let rescued = false; //Check if a civilian is close to a player droid. - for (var i = 0; i < civs.length; ++i) + for (let i = 0; i < civs.length; ++i) { - var objs = enumRange(civs[i].x, civs[i].y, 6, CAM_HUMAN_PLAYER, false); - for (var j = 0; j < objs.length; ++j) + const objs = enumRange(civs[i].x, civs[i].y, 6, CAM_HUMAN_PLAYER, false); + for (let j = 0; j < objs.length; ++j) { if (objs[j].type === DROID) { @@ -210,23 +208,24 @@ function civilianOrders() //Play the "Civilian rescued" sound and throttle it. if (rescued && ((lastSoundTime + camSecondsToMilliseconds(30)) < gameTime)) { + const RESCUE_SND = "pcv612.ogg"; // "Civilian Rescued" lastSoundTime = gameTime; - playSound(rescueSound); + playSound(RESCUE_SND); } } //Capture civilans. function eventTransporterLanded(transport) { - var escaping = "pcv632.ogg"; //"Enemy escaping". - var position = getObject("COTransportPos"); - var civs = enumRange(position.x, position.y, 15, SCAV_7, false); + const position = getObject("COTransportPos"); + const civs = enumRange(position.x, position.y, 15, CAM_SCAV_7, false); if (civs.length) { - playSound(escaping); + const ESCAPE_SND = "pcv632.ogg"; // "Enemy escaping" + playSound(ESCAPE_SND); capturedCivCount += civs.length - 1; - for (var i = 0; i < civs.length; ++i) + for (let i = 0; i < civs.length; ++i) { camSafeRemoveObject(civs[i], false); } @@ -236,13 +235,13 @@ function eventTransporterLanded(transport) //Send Collective transport as long as the player has not entered the base. function sendCOTransporter() { - var list = [cTempl.npcybr, cTempl.npcybr, cTempl.coscymc, cTempl.npcybg]; - var tPos = getObject("COTransportPos"); - var pDroid = enumRange(tPos.x, tPos.y, 6, CAM_HUMAN_PLAYER, false); + const list = [cTempl.npcybr, cTempl.npcybr, cTempl.coscymc, cTempl.npcybg]; + const tPos = getObject("COTransportPos"); + const pDroid = enumRange(tPos.x, tPos.y, 6, CAM_HUMAN_PLAYER, false); if (!pDroid.length) { - camSendReinforcement(THE_COLLECTIVE, camMakePos("COTransportPos"), list, + camSendReinforcement(CAM_THE_COLLECTIVE, camMakePos("COTransportPos"), list, CAM_REINFORCE_TRANSPORT, { entry: { x: 2, y: 80 }, exit: { x: 2, y: 80 } @@ -263,10 +262,10 @@ function extraVictoryCondition() } else { - var lz = getObject("startPosition"); - var civs = enumRange(lz.x, lz.y, 30, SCAV_7, false); + const lz = getObject("startPosition"); + const civs = enumRange(lz.x, lz.y, 30, CAM_SCAV_7, false); - for (var i = 0; i < civs.length; ++i) + for (let i = 0; i < civs.length; ++i) { camSafeRemoveObject(civs[i], false); } @@ -282,13 +281,13 @@ function eventStartLevel() callback: "extraVictoryCondition" }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); - var enemyLz = getObject("COLandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + const enemyLz = getObject("COLandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); camSetArtifacts({ "rippleRocket": { tech: "R-Wpn-Rocket06-IDF" }, @@ -302,12 +301,12 @@ function eventStartLevel() setMissionTime(camChangeOnDiff(camHoursToSeconds(2))); - setAlliance(THE_COLLECTIVE, SCAV_7, true); - setAlliance(CAM_HUMAN_PLAYER, SCAV_7, true); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); + setAlliance(CAM_THE_COLLECTIVE, CAM_SCAV_7, true); + setAlliance(CAM_HUMAN_PLAYER, CAM_SCAV_7, true); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); // Replace flamer cyborgs with thermite - camUpgradeOnMapTemplates(cTempl.npcybf, cTempl.cocybtf, THE_COLLECTIVE); + camUpgradeOnMapTemplates(cTempl.npcybf, cTempl.cocybtf, CAM_THE_COLLECTIVE); camSetEnemyBases({ "COAirBase": { @@ -401,7 +400,7 @@ function eventStartLevel() }, }); - camManageTrucks(THE_COLLECTIVE); + camManageTrucks(CAM_THE_COLLECTIVE); truckDefense(); capturedCivCount = 0; civilianPosIndex = 0; diff --git a/script/campaign/cam2-d.js b/script/campaign/cam2-d.js index 6a23adf..e096ee3 100644 --- a/script/campaign/cam2-d.js +++ b/script/campaign/cam2-d.js @@ -1,8 +1,8 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const UPLINK = 1; //The satellite uplink player number. -const COLLECTIVE_RES = [ +const MIS_UPLINK_PLAYER = 1; //The satellite uplink player number. +const mis_collectiveRes = [ "R-Defense-WallUpgrade04", "R-Struc-Materials05", "R-Struc-Factory-Upgrade05", "R-Struc-VTOLPad-Upgrade03", "R-Vehicle-Engine05", "R-Vehicle-Metals05", "R-Cyborg-Metals05", @@ -20,37 +20,37 @@ const COLLECTIVE_RES = [ camAreaEvent("vtolRemoveZone", function(droid) { - if ((droid.player === THE_COLLECTIVE) && isVTOL(droid)) + if ((droid.player === CAM_THE_COLLECTIVE) && isVTOL(droid)) { camSafeRemoveObject(droid, false); } - resetLabel("vtolRemoveZone", THE_COLLECTIVE); + resetLabel("vtolRemoveZone", CAM_THE_COLLECTIVE); }); //Order the truck to build some defenses. function truckDefense() { - if (enumDroid(THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) + if (enumDroid(CAM_THE_COLLECTIVE, DROID_CONSTRUCT).length === 0) { removeTimer("truckDefense"); return; } - var list = ["AASite-QuadBof", "CO-WallTower-HvCan", "CO-Tower-RotMG", "CO-Tower-HvFlame"]; - camQueueBuilding(THE_COLLECTIVE, list[camRand(list.length)], camMakePos("uplinkPos")); + const list = ["AASite-QuadBof", "CO-WallTower-HvCan", "CO-Tower-RotMG", "CO-Tower-HvFlame"]; + camQueueBuilding(CAM_THE_COLLECTIVE, list[camRand(list.length)], camMakePos("uplinkPos")); } //Attacks every 2 minutes until HQ is destroyed. function vtolAttack() { - var list = [cTempl.colatv, cTempl.commorvt, cTempl.colatv, cTempl.commorv]; - var ext = { + const list = [cTempl.colatv, cTempl.commorvt, cTempl.colatv, cTempl.commorv]; + const ext = { limit: [4, 2, 4, 2], alternate: true, altIdx: 0 }; - camSetVtolData(THE_COLLECTIVE, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(2)), "COCommandCenter", ext); + camSetVtolData(CAM_THE_COLLECTIVE, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(2)), "COCommandCenter", ext); } //The project captured the uplink. @@ -69,7 +69,7 @@ function checkNASDACentral() return false; //It was destroyed } - if (camCountStructuresInArea("uplinkClearArea", THE_COLLECTIVE) === 0) + if (camCountStructuresInArea("uplinkClearArea", CAM_THE_COLLECTIVE) === 0) { camCallOnce("captureUplink"); return true; @@ -89,17 +89,17 @@ function eventStartLevel() retlz: true }); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); //player lz - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); //player lz + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - var enemyLz = getObject("COLandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + const enemyLz = getObject("COLandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); camSetArtifacts({ "COCommandCenter": { tech: "R-Struc-VTOLPad-Upgrade01" }, @@ -108,10 +108,10 @@ function eventStartLevel() "COHeavyFactoryA": { tech: "R-Wpn-Mortar-Damage04" }, }); - setAlliance(CAM_HUMAN_PLAYER, UPLINK, true); - setAlliance(THE_COLLECTIVE, UPLINK, true); + setAlliance(CAM_HUMAN_PLAYER, MIS_UPLINK_PLAYER, true); + setAlliance(CAM_THE_COLLECTIVE, MIS_UPLINK_PLAYER, true); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); camSetEnemyBases({ "COSouthEastBase": { @@ -185,7 +185,7 @@ function eventStartLevel() }, }); - camManageTrucks(THE_COLLECTIVE); + camManageTrucks(CAM_THE_COLLECTIVE); truckDefense(); hackAddMessage("C2D_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER, false); diff --git a/script/campaign/cam2-ds.js b/script/campaign/cam2-ds.js index 565b470..dde5ca6 100644 --- a/script/campaign/cam2-ds.js +++ b/script/campaign/cam2-ds.js @@ -1,12 +1,11 @@ include("script/campaign/libcampaign.js"); -var index; function eventStartLevel() { camSetupTransporter(87, 100, 1, 100); centreView(88, 101); setNoGoArea(86, 99, 88, 101, CAM_HUMAN_PLAYER); - //setNoGoArea(49, 83, 51, 85, THE_COLLECTIVE); + //setNoGoArea(49, 83, 51, 85, CAM_THE_COLLECTIVE); setMissionTime(camChangeOnDiff(camMinutesToSeconds(75))); camPlayVideos([{video: "MB2_DI_MSG", type: MISS_MSG}, {video: "MB2_DI_MSG2", type: CAMP_MSG}]); camSetStandardWinLossConditions(CAM_VICTORY_PRE_OFFWORLD, "SUB_2D"); diff --git a/script/campaign/cam2-end.js b/script/campaign/cam2-end.js index e11cb02..1de2c44 100644 --- a/script/campaign/cam2-end.js +++ b/script/campaign/cam2-end.js @@ -2,7 +2,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); var allowWin; -const COLLECTIVE_RES = [ +const mis_collectiveRes = [ "R-Defense-WallUpgrade06", "R-Struc-Materials06", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade03", "R-Vehicle-Engine06", "R-Vehicle-Metals06", "R-Cyborg-Metals06", @@ -23,12 +23,12 @@ const startpos = {x: 88, y: 101}; //Remove enemy vtols when in the remove zone area. function checkEnemyVtolArea() { - var pos = {x: 127, y: 64}; - var vtols = enumRange(pos.x, pos.y, 2, THE_COLLECTIVE, false).filter(function(obj) { + const pos = {x: 127, y: 64}; + const vtols = enumRange(pos.x, pos.y, 2, CAM_THE_COLLECTIVE, false).filter(function(obj) { return isVTOL(obj); }); - for (var i = 0, l = vtols.length; i < l; ++i) + for (let i = 0, l = vtols.length; i < l; ++i) { if ((vtols[i].weapons[0].armed < 20) || (vtols[i].health < 60)) { @@ -40,11 +40,11 @@ function checkEnemyVtolArea() //Play last video sequence and destroy all droids on map. function playLastVideo() { - var droids = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter(function(obj) { + const droids = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter(function(obj) { return (obj.type === DROID && !camIsTransporter(obj)); }); - for (var i = 0, l = droids.length; i < l; ++i) + for (let i = 0, l = droids.length; i < l; ++i) { camSafeRemoveObject(droids[i], false); } @@ -56,11 +56,11 @@ function eventTransporterLaunch(transporter) { if (!allowWin && transporter.player === CAM_HUMAN_PLAYER) { - var cargoDroids = enumCargo(transporter); + const cargoDroids = enumCargo(transporter); - for (var i = 0, len = cargoDroids.length; i < len; ++i) + for (let i = 0, len = cargoDroids.length; i < len; ++i) { - var virDroid = cargoDroids[i]; + const virDroid = cargoDroids[i]; if (virDroid && virDroid.droidType === DROID_CONSTRUCT) { @@ -74,8 +74,8 @@ function eventTransporterLaunch(transporter) //Return randomly selected droid templates. function randomTemplates(list, transporterAmount) { - var droids = []; - var size; + const droids = []; + let size; if (camDef(transporterAmount) && transporterAmount) { @@ -86,7 +86,7 @@ function randomTemplates(list, transporterAmount) size = (difficulty === INSANE) ? (15 + camRand(3)) : (18 + camRand(8)); } - for (var i = 0; i < size; ++i) + for (let i = 0; i < size; ++i) { droids.push(list[camRand(list.length)]); } @@ -97,40 +97,40 @@ function randomTemplates(list, transporterAmount) //Attack every 30 seconds. function vtolAttack() { - var vtolPositions = [ + const vtolPositions = [ {x: 99, y: 1}, {x: 127, y: 65}, {x: 127, y: 28}, {x: 36, y: 1}, {x: 1, y: 28}, ]; - var vtolRemovePos = {x: 127, y: 64}; + const vtolRemovePos = {x: 127, y: 64}; if (difficulty === INSANE) { vtolPositions = undefined; //to randomize the spawns each time } - var list = [cTempl.commorv, cTempl.colcbv, cTempl.colagv, cTempl.comhvat, cTempl.commorvt, cTempl.colacv]; - camSetVtolData(THE_COLLECTIVE, vtolPositions, vtolRemovePos, list, camChangeOnDiff(camSecondsToMilliseconds(30))); + const list = [cTempl.commorv, cTempl.colcbv, cTempl.colagv, cTempl.comhvat, cTempl.commorvt, cTempl.colacv]; + camSetVtolData(CAM_THE_COLLECTIVE, vtolPositions, vtolRemovePos, list, camChangeOnDiff(camSecondsToMilliseconds(30))); } //SouthEast attackers which are mostly cyborgs. function cyborgAttack() { - var southCyborgAssembly = {x: 123, y: 125}; - var list = [cTempl.npcybr, cTempl.cocybag, cTempl.npcybc, cTempl.coscyac, cTempl.coscytk, cTempl.comhltat, cTempl.cohct, cTempl.npcybg]; + const southCyborgAssembly = {x: 123, y: 125}; + const list = [cTempl.npcybr, cTempl.cocybag, cTempl.npcybc, cTempl.coscyac, cTempl.coscytk, cTempl.comhltat, cTempl.cohct, cTempl.npcybg]; - camSendReinforcement(THE_COLLECTIVE, camMakePos(southCyborgAssembly), randomTemplates(list), CAM_REINFORCE_GROUND, { + camSendReinforcement(CAM_THE_COLLECTIVE, camMakePos(southCyborgAssembly), randomTemplates(list), CAM_REINFORCE_GROUND, { data: { regroup: false, count: -1 } }); } function cyborgAttackRandom() { - var list = [cTempl.npcybr, cTempl.cocybag, cTempl.npcybc, cTempl.coscyac, cTempl.comrotm]; //favor cannon cyborg + const list = [cTempl.npcybr, cTempl.cocybag, cTempl.npcybc, cTempl.coscyac, cTempl.comrotm]; //favor cannon cyborg - camSendReinforcement(THE_COLLECTIVE, camMakePos(camGenerateRandomMapEdgeCoordinate(startpos)), randomTemplates(list).concat(cTempl.comsens), CAM_REINFORCE_GROUND, { + camSendReinforcement(CAM_THE_COLLECTIVE, camMakePos(camGenerateRandomMapEdgeCoordinate(startpos)), randomTemplates(list).concat(cTempl.comsens), CAM_REINFORCE_GROUND, { data: { regroup: false, count: -1 } }); } @@ -138,36 +138,36 @@ function cyborgAttackRandom() //North road attacker consisting of powerful weaponry. function tankAttack() { - var extras = [cTempl.comsens, cTempl.cohaaq]; - var northTankAssembly = {x: 95, y: 3}; - var list = [cTempl.comhltat, cTempl.cohact, cTempl.cohct, cTempl.comagt, cTempl.cohbbt, cTempl.comrlt, cTempl.cohhot, cTempl.cohript]; + const extras = [cTempl.comsens, cTempl.cohaaq]; + const northTankAssembly = {x: 95, y: 3}; + const list = [cTempl.comhltat, cTempl.cohact, cTempl.cohct, cTempl.comagt, cTempl.cohbbt, cTempl.comrlt, cTempl.cohhot, cTempl.cohript]; //Extra Sensors and Whirlwind AA. - for (i = 0; i < 4; ++i) + for (let i = 0; i < 4; ++i) { list.push(extras[camRand(extras.length)]); } - camSendReinforcement(THE_COLLECTIVE, camMakePos(northTankAssembly), randomTemplates(list), CAM_REINFORCE_GROUND, { + camSendReinforcement(CAM_THE_COLLECTIVE, camMakePos(northTankAssembly), randomTemplates(list), CAM_REINFORCE_GROUND, { data: { regroup: false, count: -1, }, }); } function tankAttackWest() { - var westTankAssembly = {x: 3, y: 112}; //This was unused. Now part of Hard/Insane playthroughs. - var list = [cTempl.comhltat, cTempl.cohact, cTempl.comrlt, cTempl.comagt, cTempl.cohbbt, cTempl.cohhot, cTempl.comsens]; + const westTankAssembly = {x: 3, y: 112}; //This was unused. Now part of Hard/Insane playthroughs. + const list = [cTempl.comhltat, cTempl.cohact, cTempl.comrlt, cTempl.comagt, cTempl.cohbbt, cTempl.cohhot, cTempl.comsens]; - camSendReinforcement(THE_COLLECTIVE, camMakePos(westTankAssembly), randomTemplates(list, true), CAM_REINFORCE_GROUND, { + camSendReinforcement(CAM_THE_COLLECTIVE, camMakePos(westTankAssembly), randomTemplates(list, true), CAM_REINFORCE_GROUND, { data: { regroup: false, count: -1, }, }); } function transporterAttack() { - var droids = [cTempl.cohact, cTempl.comhltat, cTempl.coscytk, cTempl.coscyac, cTempl.cocybag]; + const droids = [cTempl.cohact, cTempl.comhltat, cTempl.coscytk, cTempl.coscyac, cTempl.cocybag]; - camSendReinforcement(THE_COLLECTIVE, camMakePos(camGenerateRandomMapCoordinate(startpos, 10, 1)), randomTemplates(droids, true), + camSendReinforcement(CAM_THE_COLLECTIVE, camMakePos(camGenerateRandomMapCoordinate(startpos, 10, 1)), randomTemplates(droids, true), CAM_REINFORCE_TRANSPORT, { entry: camGenerateRandomMapEdgeCoordinate(), exit: camGenerateRandomMapEdgeCoordinate() @@ -178,7 +178,7 @@ function transporterAttack() //NOTE: this is only called once from the library's eventMissionTimeout(). function checkIfLaunched() { - var transporters = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter(function(obj) { + const transporters = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter(function(obj) { return (obj.type === DROID && camIsTransporter(obj)); }); if (transporters.length > 0) @@ -199,8 +199,8 @@ function eventStartLevel() { camSetExtraObjectiveMessage(_("Send off at least one transporter with a truck and survive The Collective assault")); - var lz = {x: 86, y: 99, x2: 88, y2: 101}; - var tCoords = {xStart: 87, yStart: 100, xOut: 0, yOut: 55}; + const lz = {x: 86, y: 99, x2: 88, y2: 101}; + const tCoords = {xStart: 87, yStart: 100, xOut: 0, yOut: 55}; camSetStandardWinLossConditions(CAM_VICTORY_TIMEOUT, "CAM_3A", { reinforcements: camMinutesToSeconds(7), //Duration the transport "leaves" map. @@ -210,11 +210,11 @@ function eventStartLevel() setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); camSetupTransporter(tCoords.xStart, tCoords.yStart, tCoords.xOut, tCoords.yOut); - //var enemyLz = {x: 49, y: 83, x2: 51, y2: 85}; - //setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, THE_COLLECTIVE); + //const enemyLz = {x: 49, y: 83, x2: 51, y2: 85}; + //setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_THE_COLLECTIVE); setMissionTime(camMinutesToSeconds(30)); - camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); + camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE); allowWin = false; camPlayVideos([{video: "MB2_DII_MSG", type: CAMP_MSG}, {video: "MB2_DII_MSG2", type: MISS_MSG}]); diff --git a/script/campaign/cam3-1.js b/script/campaign/cam3-1.js index 50f725e..16897ec 100644 --- a/script/campaign/cam3-1.js +++ b/script/campaign/cam3-1.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const NEXUS_RES = [ +const mis_nexusRes = [ "R-Sys-Engineering03", "R-Defense-WallUpgrade07", "R-Struc-Materials07", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade06", "R-Vehicle-Engine09", "R-Vehicle-Metals06", @@ -25,7 +25,7 @@ camAreaEvent("vtolRemoveZone", function(droid) } } - resetLabel("vtolRemoveZone", NEXUS); + resetLabel("vtolRemoveZone", CAM_NEXUS); }); camAreaEvent("hillTriggerZone", function(droid) @@ -60,8 +60,8 @@ camAreaEvent("hillTriggerZone", function(droid) //Setup Nexus VTOL hit and runners. function vtolAttack() { - var list = [cTempl.nxlscouv, cTempl.nxmtherv]; - camSetVtolData(NEXUS, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(5)), "NXCommandCenter"); + const list = [cTempl.nxlscouv, cTempl.nxmtherv]; + camSetVtolData(CAM_NEXUS, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(5)), "NXCommandCenter"); } //These groups are active immediately. @@ -102,9 +102,9 @@ function missileSilosDestroyed() { const SILO_COUNT = 4; const SILO_ALIAS = "NXMissileSilo"; - var destroyed = 0; + let destroyed = 0; - for (var i = 0; i < SILO_COUNT; ++i) + for (let i = 0; i < SILO_COUNT; ++i) { destroyed += (getObject(SILO_ALIAS + (i + 1)) === null) ? 1 : 0; } @@ -116,22 +116,22 @@ function missileSilosDestroyed() function nukeAndCountSurvivors() { //Avoid destroying the one base if the player opted not to destroy it themselves. - var nuked = enumArea(0, 0, mapWidth, mapHeight, ALL_PLAYERS, false).filter(function(obj) { + const nuked = enumArea(0, 0, mapWidth, mapHeight, ALL_PLAYERS, false).filter(function(obj) { return obj.type !== STRUCTURE || (obj.type === STRUCTURE && obj.group === null); }); - var safeZone = enumArea("valleySafeZone", CAM_HUMAN_PLAYER, false); - var foundUnit = false; + const safeZone = enumArea("valleySafeZone", CAM_HUMAN_PLAYER, false); + let foundUnit = false; //Make em' explode! - for (var i = 0, len = nuked.length; i < len; ++i) + for (let i = 0, len = nuked.length; i < len; ++i) { - var nukeIt = true; - var obj1 = nuked[i]; + let nukeIt = true; + const obj1 = nuked[i]; //Check if it's in the safe area. - for (var j = 0, len2 = safeZone.length; j < len2; ++j) + for (let j = 0, len2 = safeZone.length; j < len2; ++j) { - var obj2 = safeZone[j]; + const obj2 = safeZone[j]; if (obj1.id === obj2.id) { @@ -178,16 +178,16 @@ function setupNextMission() //Play countdown sounds. Elements are shifted out of the missile launch/detonation arrays as they play. function getCountdown() { - var silosDestroyed = missileSilosDestroyed(); - var countdownObject = silosDestroyed ? detonateInfo : launchInfo; - var skip = false; + const SILOS_DESTROYED = missileSilosDestroyed(); + const countdownObject = SILOS_DESTROYED ? detonateInfo : launchInfo; + let skip = false; - for (var i = 0, len = countdownObject.length; i < len; ++i) + for (let i = 0, len = countdownObject.length; i < len; ++i) { - var currentTime = getMissionTime(); - if (currentTime <= countdownObject[0].time) + const CURRENT_TIME = getMissionTime(); + if (CURRENT_TIME <= countdownObject[0].time) { - if (len > 1 && (currentTime <= countdownObject[1].time)) + if (len > 1 && (CURRENT_TIME <= countdownObject[1].time)) { skip = true; //Huge time jump? } @@ -196,7 +196,7 @@ function getCountdown() playSound(countdownObject[0].sound, CAM_HUMAN_PLAYER); } - if (silosDestroyed) + if (SILOS_DESTROYED) { detonateInfo.shift(); } @@ -297,9 +297,9 @@ function eventStartLevel() setScrollLimits(0, 32, 64, 64); var enemyLz = getObject("NXlandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, NEXUS); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_NEXUS); - camCompleteRequiredResearch(NEXUS_RES, NEXUS); + camCompleteRequiredResearch(mis_nexusRes, CAM_NEXUS); camSetEnemyBases({ "NX-SWBase": { diff --git a/script/campaign/cam3-1s.js b/script/campaign/cam3-1s.js index b274548..a20f33a 100644 --- a/script/campaign/cam3-1s.js +++ b/script/campaign/cam3-1s.js @@ -5,7 +5,7 @@ function eventStartLevel() camSetupTransporter(56, 120, 25, 87); centreView(57, 119); setNoGoArea(55, 119, 57, 121, CAM_HUMAN_PLAYER); - setNoGoArea(7, 52, 9, 54, NEXUS); + setNoGoArea(7, 52, 9, 54, CAM_NEXUS); setMissionTime(camChangeOnDiff(camMinutesToSeconds(75))); camPlayVideos([{video: "MB3_1A_MSG", type: CAMP_MSG}, {video: "MB3_1A_MSG2", type: MISS_MSG}]); camSetStandardWinLossConditions(CAM_VICTORY_PRE_OFFWORLD, "SUB_3_1"); diff --git a/script/campaign/cam3-2.js b/script/campaign/cam3-2.js index 672b3f8..0cf126c 100644 --- a/script/campaign/cam3-2.js +++ b/script/campaign/cam3-2.js @@ -3,7 +3,7 @@ include("script/campaign/templates.js"); include("script/campaign/transitionTech.js"); const ALPHA = 1; //Team alpha units belong to player 1. -const NEXUS_RES = [ +const mis_nexusRes = [ "R-Defense-WallUpgrade08", "R-Struc-Materials08", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade06", "R-Vehicle-Engine09", "R-Vehicle-Metals07", "R-Cyborg-Metals07", "R-Vehicle-Armor-Heat05", "R-Cyborg-Armor-Heat05", @@ -28,7 +28,7 @@ camAreaEvent("vtolRemoveZone", function(droid) } } - resetLabel("vtolRemoveZone", NEXUS); + resetLabel("vtolRemoveZone", CAM_NEXUS); }); //This is an area just below the "doorway" into the alpha team pit. Activates @@ -44,7 +44,7 @@ camAreaEvent("rescueTrigger", function(droid) }); //Activate edge map queue and donate all of alpha to the player. phantomFactorySE(); - setAlliance(ALPHA, NEXUS, false); + setAlliance(ALPHA, CAM_NEXUS, false); camAbsorbPlayer(ALPHA, CAM_HUMAN_PLAYER); queue("getAlphaUnitIDs", camSecondsToMilliseconds(2)); @@ -64,13 +64,13 @@ camAreaEvent("phantomFacTrigger", function(droid) function setAlphaExp() { const DROID_EXP = 512; //Hero rank. - var alphaDroids = enumArea("alphaPit", ALPHA, false).filter(function(obj) { + const alphaDroids = enumArea("alphaPit", ALPHA, false).filter(function(obj) { return obj.type === DROID; }); - for (var i = 0, l = alphaDroids.length; i < l; ++i) + for (let i = 0, l = alphaDroids.length; i < l; ++i) { - var dr = alphaDroids[i]; + const dr = alphaDroids[i]; if (!camIsSystemDroid(dr)) { setDroidExperience(dr, DROID_EXP); @@ -82,13 +82,13 @@ function setAlphaExp() function getAlphaUnitIDs() { alphaUnitIDs = []; - var alphaDroids = enumArea("alphaPit", CAM_HUMAN_PLAYER, false).filter(function(obj) { + const alphaDroids = enumArea("alphaPit", CAM_HUMAN_PLAYER, false).filter(function(obj) { return obj.type === DROID && obj.experience === 512; }); - for (var i = 0, l = alphaDroids.length; i < l; ++i) + for (let i = 0, l = alphaDroids.length; i < l; ++i) { - var dr = alphaDroids[i]; + const dr = alphaDroids[i]; alphaUnitIDs.push(dr.id); } startExtraLoss = true; @@ -96,31 +96,31 @@ function getAlphaUnitIDs() function phantomFactoryNE() { - var list = [cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas]; + const list = [cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas]; sendEdgeMapDroids(6, "NE-PhantomFactory", list); } function phantomFactorySW() { - var list = [cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas]; + const list = [cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas]; sendEdgeMapDroids(8, "SW-PhantomFactory", list); } function phantomFactorySE() { - var list = [cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas, cTempl.nxlflash, cTempl.nxmrailh, cTempl.nxmlinkh, cTempl.nxmplash]; + const list = [cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas, cTempl.nxlflash, cTempl.nxmrailh, cTempl.nxmlinkh, cTempl.nxmplash]; sendEdgeMapDroids(10 + camRand(6), "SE-PhantomFactory", list); //10-15 units } function sendEdgeMapDroids(droidCount, location, list) { - var droids = []; - for (var i = 0; i < droidCount; ++i) + const droids = []; + for (let i = 0; i < droidCount; ++i) { droids.push(list[camRand(list.length)]); } - camSendReinforcement(NEXUS, camMakePos(location), droids, CAM_REINFORCE_GROUND, { + camSendReinforcement(CAM_NEXUS, camMakePos(location), droids, CAM_REINFORCE_GROUND, { data: {regroup: true, count: -1} }); } @@ -197,13 +197,13 @@ function setupPatrolGroups() //Setup Nexus VTOL hit and runners. function vtolAttack() { - var list = [cTempl.nxlscouv, cTempl.nxmtherv]; - var ext = { + const list = [cTempl.nxlscouv, cTempl.nxmtherv]; + const ext = { limit: [2, 4], //paired with template list alternate: true, altIdx: 0 }; - camSetVtolData(NEXUS, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(2)), undefined, ext); + camSetVtolData(CAM_NEXUS, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(2)), undefined, ext); } //Reinforcements not available until team Alpha brief about VTOLS. @@ -223,14 +223,14 @@ function alphaTeamAlive() { if (camDef(alphaUnitIDs) && startExtraLoss) { - var alphaAlive = false; - var alive = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter(function(obj) { + let alphaAlive = false; + const alive = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter(function(obj) { return obj.type === DROID; }); - for (var i = 0, l = alive.length; i < l; ++i) + for (let i = 0, l = alive.length; i < l; ++i) { - for (var x = 0, c = alphaUnitIDs.length; x < c; ++x) + for (let x = 0, c = alphaUnitIDs.length; x < c; ++x) { if (alive[i].id === alphaUnitIDs[x]) { @@ -256,10 +256,10 @@ function eventStartLevel() { camSetExtraObjectiveMessage(_("Rescue Alpha team from Nexus")); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); startExtraLoss = false; camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, "CAM3A-B", { @@ -275,12 +275,12 @@ function eventStartLevel() startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - var enemyLz = getObject("NXlandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, NEXUS); + const enemyLz = getObject("NXlandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_NEXUS); - camCompleteRequiredResearch(NEXUS_RES, NEXUS); - camCompleteRequiredResearch(GAMMA_ALLY_RES, ALPHA); - setAlliance(ALPHA, NEXUS, true); + camCompleteRequiredResearch(mis_nexusRes, CAM_NEXUS); + camCompleteRequiredResearch(mis_gammaAllyRes, ALPHA); + setAlliance(ALPHA, CAM_NEXUS, true); setAlliance(ALPHA, CAM_HUMAN_PLAYER, true); changePlayerColour(ALPHA, playerData[0].colour); diff --git a/script/campaign/cam3-2s.js b/script/campaign/cam3-2s.js index 690bd64..a23f3a8 100644 --- a/script/campaign/cam3-2s.js +++ b/script/campaign/cam3-2s.js @@ -5,7 +5,7 @@ function eventStartLevel() camSetupTransporter(56, 120, 25, 87); centreView(57, 119); setNoGoArea(55, 119, 57, 121, CAM_HUMAN_PLAYER); - setNoGoArea(7, 52, 9, 54, NEXUS); + setNoGoArea(7, 52, 9, 54, CAM_NEXUS); setMissionTime(camChangeOnDiff(camHoursToSeconds(1))); camPlayVideos([{video: "MB3_2_MSG", type: CAMP_MSG}, {video: "MB3_2_MSG2", type: MISS_MSG}]); camSetStandardWinLossConditions(CAM_VICTORY_PRE_OFFWORLD, "SUB_3_2"); diff --git a/script/campaign/cam3-4.js b/script/campaign/cam3-4.js index dc07678..fae9f18 100644 --- a/script/campaign/cam3-4.js +++ b/script/campaign/cam3-4.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const NEXUS_RES = [ +const mis_nexusRes = [ "R-Defense-WallUpgrade09", "R-Struc-Materials09", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade06", "R-Vehicle-Engine09", "R-Vehicle-Metals09", "R-Cyborg-Metals08", "R-Vehicle-Armor-Heat06", "R-Cyborg-Armor-Heat06", @@ -14,7 +14,7 @@ const NEXUS_RES = [ function eventDestroyed(obj) { - if (obj.player === NEXUS && obj.type === STRUCTURE && obj.stattype === HQ) + if (obj.player === CAM_NEXUS && obj.type === STRUCTURE && obj.stattype === HQ) { camSetNexusState(false); removeTimer("nexusHackFeature"); @@ -46,23 +46,23 @@ function nexusHackFeature() return; } - camHackIntoPlayer(CAM_HUMAN_PLAYER, NEXUS); + camHackIntoPlayer(CAM_HUMAN_PLAYER, CAM_NEXUS); } // A little suprise absorbption attack when discovering the SW base. function firstAbsorbAttack() { - var objects = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter(function(obj) { + const objects = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter(function(obj) { return (obj.type !== DROID) || (obj.type === DROID && obj.droidType !== DROID_SUPERTRANSPORTER); }); - for (var i = 0, len = objects.length; i < len; ++i) + for (let i = 0, len = objects.length; i < len; ++i) { - var obj = objects[i]; + const obj = objects[i]; //Absorb some structures from the player if (obj.type === STRUCTURE) { - if ((camRand(100) < 20) && !donateObject(obj, NEXUS)) + if ((camRand(100) < 20) && !donateObject(obj, CAM_NEXUS)) { camSafeRemoveObject(obj, true); } @@ -136,15 +136,15 @@ function setupNexusPatrols() function enableAllFactories() { - const FACTORY_LIST = [ + const factoryList = [ "NX-NWFactory1", "NX-NWFactory2", "NX-NEFactory", "NX-SWFactory", "NX-SEFactory", "NX-VtolFactory1", "NX-NWCyborgFactory", "NX-VtolFactory2", "NX-SWCyborgFactory1", "NX-SWCyborgFactory2", ]; - for (var i = 0, l = FACTORY_LIST.length; i < l; ++i) + for (let i = 0, l = factoryList.length; i < l; ++i) { - camEnableFactory(FACTORY_LIST[i]); + camEnableFactory(factoryList[i]); } //Set the already placed VTOL fighters into action @@ -155,18 +155,18 @@ function enableAllFactories() function truckDefense() { - var truckNum = countDroid(NEXUS, DROID_CONSTRUCT); - if (truckNum > 0) + const NUM_TRUCKS = countDroid(CAM_NEXUS, DROID_CONSTRUCT); + if (NUM_TRUCKS > 0) { - var list = [ + const list = [ "Sys-NEXUSLinkTOW", "P0-AASite-SAM2", "Emplacement-PrisLas", "NX-Tower-ATMiss", "Sys-NX-CBTower", "Emplacement-HvART-pit", "Sys-NX-SensorTower" ]; - for (var i = 0; i < truckNum; ++i) + for (let i = 0; i < NUM_TRUCKS; ++i) { - camQueueBuilding(NEXUS, list[camRand(list.length)]); + camQueueBuilding(CAM_NEXUS, list[camRand(list.length)]); } } else @@ -177,9 +177,9 @@ function truckDefense() function eventStartLevel() { - var startpos = getObject("startPosition"); - var tpos = getObject("transportEntryExit"); - var lz = getObject("landingZone"); + const startpos = getObject("startPosition"); + const tpos = getObject("transportEntryExit"); + const lz = getObject("landingZone"); camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, CAM_GAMMA_OUT, { area: "RTLZ", @@ -193,12 +193,12 @@ function eventStartLevel() setTransporterExit(tpos.x, tpos.y, CAM_HUMAN_PLAYER); setMissionTime(-1); //Infinite time - var enemyLz = getObject("NXlandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, NEXUS); + const enemyLz = getObject("NXlandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_NEXUS); - camCompleteRequiredResearch(NEXUS_RES, NEXUS); + camCompleteRequiredResearch(mis_nexusRes, CAM_NEXUS); setupNexusPatrols(); - camManageTrucks(NEXUS); + camManageTrucks(CAM_NEXUS); camSetArtifacts({ "NX-NWCyborgFactory": { tech: "R-Wpn-RailGun03" }, diff --git a/script/campaign/cam3-4s.js b/script/campaign/cam3-4s.js index 78bcd08..8efc334 100644 --- a/script/campaign/cam3-4s.js +++ b/script/campaign/cam3-4s.js @@ -5,7 +5,7 @@ function eventStartLevel() camSetupTransporter(50, 245, 63, 118); centreView(50, 245); setNoGoArea(49, 244, 51, 246, CAM_HUMAN_PLAYER); - setNoGoArea(7, 52, 9, 54, NEXUS); + setNoGoArea(7, 52, 9, 54, CAM_NEXUS); setScrollLimits(0, 137, 64, 256); setMissionTime(camMinutesToSeconds(30)); setPower(playerPower(CAM_HUMAN_PLAYER) + 50000, CAM_HUMAN_PLAYER); diff --git a/script/campaign/cam3-a.js b/script/campaign/cam3-a.js index e050789..54c61cc 100644 --- a/script/campaign/cam3-a.js +++ b/script/campaign/cam3-a.js @@ -16,7 +16,7 @@ camAreaEvent("vtolRemoveZone", function(droid) } } - resetLabel("vtolRemoveZone", NEXUS); + resetLabel("vtolRemoveZone", CAM_NEXUS); }); //Order base three groups to do stuff. @@ -47,15 +47,15 @@ camAreaEvent("westFactoryTrigger", function(droid) function setUnitRank(transport) { - const DROID_EXP = [1024, 128, 64, 32]; //Can make Hero Commanders if recycled. - var droids = enumCargo(transport); + const droidExp = [1024, 128, 64, 32]; //Can make Hero Commanders if recycled. + const droids = enumCargo(transport); - for (var i = 0, len = droids.length; i < len; ++i) + for (let i = 0, len = droids.length; i < len; ++i) { - var droid = droids[i]; + const droid = droids[i]; if (!camIsSystemDroid(droid)) { - setDroidExperience(droid, DROID_EXP[transporterIndex - 1]); + setDroidExperience(droid, droidExp[transporterIndex - 1]); } } } @@ -71,13 +71,13 @@ function eventTransporterLanded(transport) //Enable all factories. function enableAllFactories() { - const FACTORY_NAMES = [ + const factoryNames = [ "NXcybFac-b3", "NXcybFac-b2-1", "NXcybFac-b2-2", "NXHvyFac-b2", "NXcybFac-b4", ]; - for (var j = 0, i = FACTORY_NAMES.length; j < i; ++j) + for (let j = 0, i = factoryNames.length; j < i; ++j) { - camEnableFactory(FACTORY_NAMES[j]); + camEnableFactory(factoryNames[j]); } } @@ -98,11 +98,11 @@ function sendPlayerTransporter() return; } - var droids = []; - var list = [cTempl.prhasgnt, cTempl.prhct, cTempl.prhaacnt, cTempl.prtruck]; + const droids = []; + const list = [cTempl.prhasgnt, cTempl.prhct, cTempl.prhaacnt, cTempl.prtruck]; // send 4 Assault Guns, 2 Heavy Cannons, 2 Cyclone AA Turrets and 2 Trucks - for (var i = 0, d = list.length; i < 10; ++i) + for (let i = 0, d = list.length; i < 10; ++i) { droids.push(i < d * 2 ? list[i % 4] : list[0]); } @@ -120,8 +120,8 @@ function sendPlayerTransporter() //Setup Nexus VTOL hit and runners. function vtolAttack() { - var list = [cTempl.nxlneedv, cTempl.nxlscouv, cTempl.nxmtherv]; - camSetVtolData(NEXUS, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(5)), "NXCommandCenter"); + const list = [cTempl.nxlneedv, cTempl.nxlscouv, cTempl.nxmtherv]; + camSetVtolData(CAM_NEXUS, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(5)), "NXCommandCenter"); } //These groups are active immediately. @@ -160,7 +160,7 @@ function groupPatrolNoTrigger() //Gives starting tech and research. function cam3Setup() { - const NEXUS_RES = [ + const mis_nexusRes = [ "R-Wpn-MG1Mk1", "R-Sys-Engineering03", "R-Defense-WallUpgrade07", "R-Struc-Materials07", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade06", "R-Vehicle-Engine09", "R-Vehicle-Metals07", @@ -171,14 +171,14 @@ function cam3Setup() "R-Wpn-Rail-ROF01", "R-Wpn-Rail-Accuracy01", "R-Wpn-Flamer-Damage06", ]; - for (var x = 0, l = STRUCTS_ALPHA.length; x < l; ++x) + for (let x = 0, l = mis_structsAlpha.length; x < l; ++x) { - enableStructure(STRUCTS_ALPHA[x], CAM_HUMAN_PLAYER); + enableStructure(mis_structsAlpha[x], CAM_HUMAN_PLAYER); } - camCompleteRequiredResearch(GAMMA_ALLY_RES, CAM_HUMAN_PLAYER); - camCompleteRequiredResearch(GAMMA_ALLY_RES, NEXUS); - camCompleteRequiredResearch(NEXUS_RES, NEXUS); + camCompleteRequiredResearch(mis_gammaAllyRes, CAM_HUMAN_PLAYER); + camCompleteRequiredResearch(mis_gammaAllyRes, CAM_NEXUS); + camCompleteRequiredResearch(mis_nexusRes, CAM_NEXUS); enableResearch("R-Wpn-Howitzer03-Rot", CAM_HUMAN_PLAYER); enableResearch("R-Wpn-MG-Damage08", CAM_HUMAN_PLAYER); @@ -188,10 +188,10 @@ function cam3Setup() function eventStartLevel() { const PLAYER_POWER = 16000; - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); - var tent = getObject("transporterEntry"); - var text = getObject("transporterExit"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); + const tent = getObject("transporterEntry"); + const text = getObject("transporterExit"); camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "SUB_3_1S"); setMissionTime(camChangeOnDiff(camHoursToSeconds(2))); @@ -201,8 +201,8 @@ function eventStartLevel() startTransporterEntry(tent.x, tent.y, CAM_HUMAN_PLAYER); setTransporterExit(text.x, text.y, CAM_HUMAN_PLAYER); - var enemyLz = getObject("NXlandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, NEXUS); + const enemyLz = getObject("NXlandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_NEXUS); camSetArtifacts({ "NXPowerGenArti": { tech: "R-Struc-Power-Upgrade02" }, diff --git a/script/campaign/cam3-ab.js b/script/campaign/cam3-ab.js index 4d9b2ce..0192428 100644 --- a/script/campaign/cam3-ab.js +++ b/script/campaign/cam3-ab.js @@ -1,7 +1,7 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const NEXUS_RES = [ +const mis_nexusRes = [ "R-Defense-WallUpgrade09", "R-Struc-Materials09", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade06", "R-Vehicle-Engine09", "R-Vehicle-Metals07", "R-Cyborg-Metals07", "R-Vehicle-Armor-Heat05", "R-Cyborg-Armor-Heat05", @@ -26,33 +26,33 @@ camAreaEvent("vtolRemoveZone", function(droid) } } - resetLabel("vtolRemoveZone", NEXUS); + resetLabel("vtolRemoveZone", CAM_NEXUS); }); function sendEdgeMapDroids() { const unitCount = 6 + camRand(5); // 6 - 10. const EDGE = ["SWPhantomFactory", "NWPhantomFactory"]; - var list = [ + const list = [ cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas, cTempl.nxlflash, cTempl.nxmrailh, cTempl.nxmlinkh, cTempl.nxmscouh, cTempl.nxmsamh, cTempl.nxmplash, ]; - var droids = []; + const droids = []; if (!camDef(edgeMapCounter)) { edgeMapCounter = 0; } - for (var i = 0; i < unitCount; ++i) + for (let i = 0; i < unitCount; ++i) { droids.push(list[camRand(list.length)]); } droids = droids.concat(cTempl.nxmsens); - camSendReinforcement(NEXUS, camMakePos(EDGE[camRand(EDGE.length)]), droids, + camSendReinforcement(CAM_NEXUS, camMakePos(EDGE[camRand(EDGE.length)]), droids, CAM_REINFORCE_GROUND, { data: {regroup: false, count: -1} } @@ -64,32 +64,32 @@ function sendEdgeMapDroids() //Setup Nexus VTOL hit and runners. NOTE: These do not go away in this mission. function vtolAttack() { - var list = [cTempl.nxlscouv, cTempl.nxmtherv, cTempl.nxlscouv, cTempl.nxmheapv]; - var ext = { + const list = [cTempl.nxlscouv, cTempl.nxmtherv, cTempl.nxlscouv, cTempl.nxmheapv]; + const ext = { limit: [2, 4, 2, 4], alternate: true, altIdx: 0 }; - camSetVtolData(NEXUS, (difficulty === INSANE) ? undefined : "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(1.5)), undefined, ext); + camSetVtolData(CAM_NEXUS, (difficulty === INSANE) ? undefined : "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(1.5)), undefined, ext); } // Order any absorbed trucks to start building defenses near themselves. function truckDefense() { - var droids = enumDroid(NEXUS, DROID_CONSTRUCT); - var defenses = [ + const droids = enumDroid(CAM_NEXUS, DROID_CONSTRUCT); + const defenses = [ "Sys-NEXUSLinkTOW", "P0-AASite-SAM2", "Emplacement-PrisLas", "NX-Tower-ATMiss", "Sys-NX-CBTower", ]; - for (var i = 0, len = droids.length; i < len; ++i) + for (let i = 0, len = droids.length; i < len; ++i) { - var truck = droids[i]; + const truck = droids[i]; if (truck.order !== DORDER_BUILD) { - var defense = defenses[camRand(defenses.length)]; - var loc = pickStructLocation(truck, defense, truck.x, truck.y); - enableStructure(defense, NEXUS); + const defense = defenses[camRand(defenses.length)]; + const loc = pickStructLocation(truck, defense, truck.x, truck.y); + enableStructure(defense, CAM_NEXUS); if (camDef(loc)) { orderDroidBuild(truck, DORDER_BUILD, defense, truck.x, truck.y); @@ -108,24 +108,24 @@ function hackManufacture(structure, template) function nexusManufacture() { - if (countDroid(DROID_ANY, NEXUS) > 100) + if (countDroid(DROID_ANY, CAM_NEXUS) > 100) { return; } - var factoryType = [ + const factoryType = [ {structure: FACTORY, temps: [cTempl.nxmrailh, cTempl.nxmlinkh, cTempl.nxmscouh, cTempl.nxlflash, cTempl.nxmplash]}, {structure: CYBORG_FACTORY, temps: [cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas,]}, {structure: VTOL_FACTORY, temps: [cTempl.nxlscouv, cTempl.nxmtherv, cTempl.nxmheapv,]}, ]; - for (var i = 0; i < factoryType.length; ++i) + for (let i = 0; i < factoryType.length; ++i) { - var factories = enumStruct(NEXUS, factoryType[i].structure); - var templs = factoryType[i].temps; + const factories = enumStruct(CAM_NEXUS, factoryType[i].structure); + const templs = factoryType[i].temps; - for (var j = 0, len = factories.length; j < len; ++j) + for (let j = 0, len = factories.length; j < len; ++j) { - var fac = factories[j]; + const fac = factories[j]; if (fac.status !== BUILT || !structureIdle(fac)) { return; @@ -139,10 +139,10 @@ function nexusManufacture() function manualGrouping() { - var vtols = enumDroid(NEXUS).filter(function(obj) { + const vtols = enumDroid(CAM_NEXUS).filter(function(obj) { return obj.group === null && isVTOL(obj); }); - var nonVtols = enumDroid(NEXUS).filter(function(obj) { + const nonVtols = enumDroid(CAM_NEXUS).filter(function(obj) { return obj.group === null && !isVTOL(obj); }); if (vtols.length) @@ -157,7 +157,7 @@ function manualGrouping() function eventObjectTransfer(obj, from) { - if (obj.player === NEXUS && from === CAM_HUMAN_PLAYER) + if (obj.player === CAM_NEXUS && from === CAM_HUMAN_PLAYER) { if (obj.type === STRUCTURE) { @@ -211,13 +211,13 @@ function hackPlayer() return; } - camHackIntoPlayer(CAM_HUMAN_PLAYER, NEXUS); + camHackIntoPlayer(CAM_HUMAN_PLAYER, CAM_NEXUS); } function synapticsSound() { - playSound(SYNAPTICS_ACTIVATED); - camHackIntoPlayer(CAM_HUMAN_PLAYER, NEXUS); + playSound(CAM_SYNAPTICS_ACTIVATED_SND); + camHackIntoPlayer(CAM_HUMAN_PLAYER, CAM_NEXUS); } //winFlag is set in eventResearched. @@ -234,8 +234,8 @@ function eventStartLevel() { camSetExtraObjectiveMessage(_("Research resistance circuits and survive the assault from Nexus")); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "CAM3C", { callback: "resistanceResearched" @@ -248,10 +248,10 @@ function eventStartLevel() setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); setMissionTime(camChangeOnDiff(camHoursToSeconds(1))); - var enemyLz = getObject("NXlandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, NEXUS); + const enemyLz = getObject("NXlandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_NEXUS); - camCompleteRequiredResearch(NEXUS_RES, NEXUS); + camCompleteRequiredResearch(mis_nexusRes, CAM_NEXUS); enableResearch("R-Sys-Resistance-Upgrade01", CAM_HUMAN_PLAYER); winFlag = false; diff --git a/script/campaign/cam3-ad1.js b/script/campaign/cam3-ad1.js index 02f27bd..a91f590 100644 --- a/script/campaign/cam3-ad1.js +++ b/script/campaign/cam3-ad1.js @@ -3,7 +3,7 @@ include("script/campaign/templates.js"); const SILO_PLAYER = 1; const LASSAT_FIRING = "pcv650.ogg"; // LASER SATELLITE FIRING!!! -const NEXUS_RES = [ +const mis_nexusRes = [ "R-Defense-WallUpgrade09", "R-Struc-Materials09", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade06", "R-Vehicle-Engine09", "R-Vehicle-Metals08", "R-Cyborg-Metals08", "R-Vehicle-Armor-Heat06", "R-Cyborg-Armor-Heat06", @@ -81,8 +81,8 @@ function enableAllFactories() //when no target is found in the area. function vaporizeTarget() { - var target; - var targets = enumArea(0, 0, mapWidth, Math.floor(mapLimit), CAM_HUMAN_PLAYER, false).filter(function(obj) { + let target; + const targets = enumArea(0, 0, mapWidth, Math.floor(mapLimit), CAM_HUMAN_PLAYER, false).filter(function(obj) { return obj.type === DROID || obj.type === STRUCTURE; }); @@ -96,9 +96,9 @@ function vaporizeTarget() } else { - var dr = targets.filter(function(obj) { return obj.type === DROID && !isVTOL(obj); }); - var vt = targets.filter(function(obj) { return obj.type === DROID && isVTOL(obj); }); - var st = targets.filter(function(obj) { return obj.type === STRUCTURE; }); + const dr = targets.filter(function(obj) { return obj.type === DROID && !isVTOL(obj); }); + const vt = targets.filter(function(obj) { return obj.type === DROID && isVTOL(obj); }); + const st = targets.filter(function(obj) { return obj.type === STRUCTURE; }); if (dr.length) { @@ -133,18 +133,18 @@ function vaporizeTarget() //A simple way to fire the LasSat with a chance of missing. function laserSatFuzzyStrike(obj) { - const LOC = camMakePos(obj); + const loc = camMakePos(obj); //Initially lock onto target - var xCoord = LOC.x; - var yCoord = LOC.y; + let xCoord = loc.x; + let yCoord = loc.y; //Introduce some randomness if (camRand(101) < 67) { - var xRand = camRand(3); - var yRand = camRand(3); - xCoord = camRand(2) ? LOC.x - xRand : LOC.x + xRand; - yCoord = camRand(2) ? LOC.y - yRand : LOC.y + yRand; + const X_RAND = camRand(3); + const Y_RAND = camRand(3); + xCoord = camRand(2) ? loc.x - X_RAND : loc.x + X_RAND; + yCoord = camRand(2) ? loc.y - Y_RAND : loc.y + Y_RAND; } if (xCoord < 0) @@ -171,7 +171,7 @@ function laserSatFuzzyStrike(obj) } //Missed it so hit close to target. - if (LOC.x !== xCoord || LOC.y !== yCoord || !camDef(obj.id)) + if (loc.x !== xCoord || loc.y !== yCoord || !camDef(obj.id)) { fireWeaponAtLoc("LasSat", xCoord, yCoord, CAM_HUMAN_PLAYER); } @@ -204,10 +204,10 @@ function checkMissileSilos() return true; } - var siloArea = camMakePos(getObject("missileSilos")); - var safe = enumRange(siloArea.x, siloArea.y, 10, ALL_PLAYERS, false); - var enemies = safe.filter(function(obj) { return obj.player === NEXUS; }); - var player = safe.filter(function(obj) { return obj.player === CAM_HUMAN_PLAYER; }); + const siloArea = camMakePos(getObject("missileSilos")); + const safe = enumRange(siloArea.x, siloArea.y, 10, ALL_PLAYERS, false); + const enemies = safe.filter(function(obj) { return obj.player === CAM_NEXUS; }); + const player = safe.filter(function(obj) { return obj.player === CAM_HUMAN_PLAYER; }); if (!enemies.length && player.length) { camCallOnce("allySiloWithPlayer"); @@ -218,10 +218,10 @@ function eventStartLevel() { camSetExtraObjectiveMessage(_("Secure a missile silo")); - var siloZone = getObject("missileSilos"); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); - var lz2 = getObject("landingZone2"); + const siloZone = getObject("missileSilos"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); + const lz2 = getObject("landingZone2"); mapLimit = 1.0; camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "CAM3A-D2", { @@ -230,17 +230,17 @@ function eventStartLevel() centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); - setNoGoArea(lz2.x, lz2.y, lz2.x2, lz2.y2, NEXUS); //LZ for cam3-4s. + setNoGoArea(lz2.x, lz2.y, lz2.x2, lz2.y2, CAM_NEXUS); //LZ for cam3-4s. setNoGoArea(siloZone.x, siloZone.y, siloZone.x2, siloZone.y2, SILO_PLAYER); setMissionTime(camChangeOnDiff(camHoursToSeconds(2))); - var enemyLz = getObject("NXlandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, NEXUS); + const enemyLz = getObject("NXlandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_NEXUS); - camCompleteRequiredResearch(NEXUS_RES, NEXUS); + camCompleteRequiredResearch(mis_nexusRes, CAM_NEXUS); setAlliance(CAM_HUMAN_PLAYER, SILO_PLAYER, true); - setAlliance(NEXUS, SILO_PLAYER, true); + setAlliance(CAM_NEXUS, SILO_PLAYER, true); camSetArtifacts({ "NXbase1VtolFacArti": { tech: "R-Wpn-MdArtMissile" }, diff --git a/script/campaign/cam3-ad2.js b/script/campaign/cam3-ad2.js index f47fe1d..ae5e199 100644 --- a/script/campaign/cam3-ad2.js +++ b/script/campaign/cam3-ad2.js @@ -3,7 +3,7 @@ include("script/campaign/templates.js"); const Y_SCROLL_LIMIT = 137; const LASSAT_FIRING = "pcv650.ogg"; // LASER SATELLITE FIRING!!! -const NEXUS_RES = [ +const mis_nexusRes = [ "R-Defense-WallUpgrade09", "R-Struc-Materials09", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade06", "R-Vehicle-Engine09", "R-Vehicle-Metals09", "R-Cyborg-Metals09", "R-Vehicle-Armor-Heat06", "R-Cyborg-Armor-Heat06", @@ -32,24 +32,23 @@ camAreaEvent("vtolRemoveZone", function(droid) } } - resetLabel("vtolRemoveZone", NEXUS); + resetLabel("vtolRemoveZone", CAM_NEXUS); }); //Return a random assortment of droids with the given templates. function randomTemplates(list) { - var i = 0; - var extras = [cTempl.nxmsens, cTempl.nxmsamh]; - var droids = []; - var size = 5 + camRand(4); //Max of 8. + const extras = [cTempl.nxmsens, cTempl.nxmsamh]; + const droids = []; + const SIZE = 5 + camRand(4); //Max of 8. - for (i = 0; i < size; ++i) + for (let i = 0; i < SIZE; ++i) { droids.push(list[camRand(list.length)]); } //Sensor and vindicator hovers. - for (i = 0; i < 4; ++i) + for (let i = 0; i < 4; ++i) { droids.push(extras[camRand(extras.length)]); } @@ -66,15 +65,15 @@ function randomTemplates(list) //Chose a random spawn point for the VTOLs. function vtolAttack() { - var list = [cTempl.nxmheapv, cTempl.nxlpulsev, cTempl.nxhrailv, cTempl.nxlscouv]; - camSetVtolData(NEXUS, VTOL_POSITIONS, "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(1.5))); + const list = [cTempl.nxmheapv, cTempl.nxlpulsev, cTempl.nxhrailv, cTempl.nxlscouv]; + camSetVtolData(CAM_NEXUS, VTOL_POSITIONS, "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(1.5))); } //Chose a random spawn point to send ground reinforcements. function phantomFactorySpawn() { - var list; - var chosenFactory; + let list; + let chosenFactory; switch (camRand(3)) { @@ -95,9 +94,9 @@ function phantomFactorySpawn() chosenFactory = "phantomFacWest"; } - if (countDroid(DROID_ANY, NEXUS) < 80) + if (countDroid(DROID_ANY, CAM_NEXUS) < 80) { - camSendReinforcement(NEXUS, camMakePos(chosenFactory), randomTemplates(list), CAM_REINFORCE_GROUND, { + camSendReinforcement(CAM_NEXUS, camMakePos(chosenFactory), randomTemplates(list), CAM_REINFORCE_GROUND, { data: { regroup: false, count: -1, }, }); } @@ -107,8 +106,8 @@ function phantomFactorySpawn() //when no target is found in the area. function vaporizeTarget() { - var target; - var targets = enumArea(0, Y_SCROLL_LIMIT, mapWidth, Math.floor(mapLimit), CAM_HUMAN_PLAYER, false).filter(function(obj) { + let target; + const targets = enumArea(0, Y_SCROLL_LIMIT, mapWidth, Math.floor(mapLimit), CAM_HUMAN_PLAYER, false).filter(function(obj) { return obj.type === DROID || obj.type === STRUCTURE; }); @@ -127,9 +126,9 @@ function vaporizeTarget() } else { - var dr = targets.filter(function(obj) { return obj.type === DROID && !isVTOL(obj); }); - var vt = targets.filter(function(obj) { return obj.type === DROID && isVTOL(obj); }); - var st = targets.filter(function(obj) { return obj.type === STRUCTURE; }); + const dr = targets.filter(function(obj) { return obj.type === DROID && !isVTOL(obj); }); + const vt = targets.filter(function(obj) { return obj.type === DROID && isVTOL(obj); }); + const st = targets.filter(function(obj) { return obj.type === STRUCTURE; }); if (dr.length) { @@ -174,18 +173,18 @@ function vaporizeTarget() //A simple way to fire the LasSat with a chance of missing. function laserSatFuzzyStrike(obj) { - const LOC = camMakePos(obj); + const loc = camMakePos(obj); //Initially lock onto target - var xCoord = LOC.x; - var yCoord = LOC.y; + let xCoord = loc.x; + let yCoord = loc.y; //Introduce some randomness. More accurate than last mission. if (camRand(101) < 33) { - var xRand = camRand(2); - var yRand = camRand(2); - xCoord = camRand(2) ? LOC.x - xRand : LOC.x + xRand; - yCoord = camRand(2) ? LOC.y - yRand : LOC.y + yRand; + const X_RAND = camRand(2); + const Y_RAND = camRand(2); + xCoord = camRand(2) ? loc.x - X_RAND : loc.x + X_RAND; + yCoord = camRand(2) ? loc.y - Y_RAND : loc.y + Y_RAND; } if (xCoord < 0) @@ -214,7 +213,7 @@ function laserSatFuzzyStrike(obj) } //Missed it so hit close to target - if (LOC.x !== xCoord || LOC.y !== yCoord || !camDef(obj.id)) + if (loc.x !== xCoord || loc.y !== yCoord || !camDef(obj.id)) { fireWeaponAtLoc("LasSat", xCoord, yCoord, CAM_HUMAN_PLAYER); } @@ -229,7 +228,7 @@ function laserSatFuzzyStrike(obj) //Play videos and allow winning once the final one is researched. function eventResearched(research, structure, player) { - for (var i = 0, l = videoInfo.length; i < l; ++i) + for (let i = 0, l = videoInfo.length; i < l; ++i) { if (research.name === videoInfo[i].res && !videoInfo[i].played) { @@ -286,8 +285,8 @@ function eventStartLevel() { camSetExtraObjectiveMessage(_("Protect the missile silos and research for the missile codes")); - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); mapLimit = 137.0; winFlag = false; siegeMode = false; @@ -305,8 +304,8 @@ function eventStartLevel() setScrollLimits(0, Y_SCROLL_LIMIT, 64, 256); //Destroy everything above limits - var destroyZone = enumArea(0, 0, 64, Y_SCROLL_LIMIT, CAM_HUMAN_PLAYER, false); - for (var i = 0, l = destroyZone.length; i < l; ++i) + const destroyZone = enumArea(0, 0, 64, Y_SCROLL_LIMIT, CAM_HUMAN_PLAYER, false); + for (let i = 0, l = destroyZone.length; i < l; ++i) { camSafeRemoveObject(destroyZone[i], false); } @@ -316,10 +315,10 @@ function eventStartLevel() setMissionTime(camMinutesToSeconds(5)); enableResearch("R-Sys-Resistance", CAM_HUMAN_PLAYER); - var enemyLz = getObject("NXlandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, NEXUS); + const enemyLz = getObject("NXlandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_NEXUS); - camCompleteRequiredResearch(NEXUS_RES, NEXUS); + camCompleteRequiredResearch(mis_nexusRes, CAM_NEXUS); camPlayVideos({video: "MB3_AD2_MSG", type: MISS_MSG}); setTimer("checkTime", camSecondsToMilliseconds(0.2)); diff --git a/script/campaign/cam3-b.js b/script/campaign/cam3-b.js index 5e13218..b0d0767 100644 --- a/script/campaign/cam3-b.js +++ b/script/campaign/cam3-b.js @@ -6,7 +6,7 @@ var trapActive; var gammaAttackCount; var truckLocCounter; const GAMMA = 1; // Player 1 is Gamma team. -const NEXUS_RES = [ +const mis_nexusRes = [ "R-Defense-WallUpgrade08", "R-Struc-Materials08", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade06", "R-Vehicle-Engine09", "R-Vehicle-Metals06", "R-Cyborg-Metals07", "R-Vehicle-Armor-Heat05", "R-Cyborg-Armor-Heat05", @@ -28,7 +28,7 @@ camAreaEvent("vtolRemoveZone", function(droid) } } - resetLabel("vtolRemoveZone", NEXUS); + resetLabel("vtolRemoveZone", CAM_NEXUS); }); camAreaEvent("trapTrigger", function(droid) @@ -38,7 +38,7 @@ camAreaEvent("trapTrigger", function(droid) camAreaEvent("mockBattleTrigger", function(droid) { - setAlliance(GAMMA, NEXUS, false); //brief mockup battle + setAlliance(GAMMA, CAM_NEXUS, false); //brief mockup battle camCallOnce("activateNexusGroups"); //help destroy Gamma base }); @@ -55,14 +55,14 @@ function camEnemyBaseEliminated_NXWestBase() //Setup Nexus VTOL hit and runners. function vtolAttack() { - var list = [cTempl.nxmheapv, cTempl.nxlscouv, cTempl.nxmtherv, cTempl.nxlscouv]; - var ext = { + const list = [cTempl.nxmheapv, cTempl.nxlscouv, cTempl.nxmtherv, cTempl.nxlscouv]; + const ext = { limit: [5, 2, 5, 2], //paired with template list alternate: true, altIdx: 0 }; - camSetVtolData(NEXUS, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(2)), "NXCommandCenter", ext); + camSetVtolData(CAM_NEXUS, "vtolAppearPos", "vtolRemovePos", list, camChangeOnDiff(camMinutesToMilliseconds(2)), "NXCommandCenter", ext); } function enableAllFactories() @@ -76,12 +76,12 @@ function getDroidsForNXLZ() { //Choose 10 out of this big pile of units const COUNT = 10; - var units = [cTempl.npsbb, cTempl.npsmct, cTempl.npmsens, cTempl.nphmgh, cTempl.nphct, cTempl.npmorb, cTempl.npltat, + const units = [cTempl.npsbb, cTempl.npsmct, cTempl.npmsens, cTempl.nphmgh, cTempl.nphct, cTempl.npmorb, cTempl.npltat, cTempl.cohct, cTempl.comrlt, cTempl.comagt, cTempl.comhpv, cTempl.comhltat, cTempl.cohript, cTempl.comit, cTempl.comrotmh, cTempl.cohbbt, cTempl.cohact, cTempl.npcybr, cTempl.npcybg, cTempl.coscymc, cTempl.cocybtf, cTempl.cocybag, cTempl.coscyac, cTempl.coscytk]; - var droids = []; - for (var i = 0; i < COUNT; ++i) + const droids = []; + for (let i = 0; i < COUNT; ++i) { droids.push(units[camRand(units.length)]); } @@ -93,10 +93,10 @@ function getDroidsForNXLZ() function getDroidsForPhantomFactory() { const COUNT = 10 + camRand(6); - var units = [cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas, cTempl.nxmlinkh, cTempl.nxmrailh, cTempl.nxmsamh, cTempl.nxmplash]; //Mix of NX units + const units = [cTempl.nxcyrail, cTempl.nxcyscou, cTempl.nxcylas, cTempl.nxmlinkh, cTempl.nxmrailh, cTempl.nxmsamh, cTempl.nxmplash]; //Mix of NX units - var droids = []; - for (var i = 0; i < COUNT; ++i) + const droids = []; + for (let i = 0; i < COUNT; ++i) { droids.push(units[camRand(units.length)]); } @@ -107,24 +107,24 @@ function getDroidsForPhantomFactory() //Send Nexus transport units function sendNXTransporter() { - if (camCountStructuresInArea("NXEastBaseCleanup", NEXUS) === 0 && - camCountStructuresInArea("NXWestBaseCleanup", NEXUS) === 0) + if (camCountStructuresInArea("NXEastBaseCleanup", CAM_NEXUS) === 0 && + camCountStructuresInArea("NXWestBaseCleanup", CAM_NEXUS) === 0) { return; //Call off transport when both west and east Nexus bases are destroyed. } const LZ_ALIAS = "CM3B_TRANS"; //1 and 2 - var list = getDroidsForNXLZ(); - var lzNum; - var pos; + const list = getDroidsForNXLZ(); + let lzNum; + let pos; - if (camCountStructuresInArea("NXEastBaseCleanup", NEXUS) > 0) + if (camCountStructuresInArea("NXEastBaseCleanup", CAM_NEXUS) > 0) { lzNum = 1; pos = "nexusEastTransportPos"; } - if (camCountStructuresInArea("NXWestBaseCleanup", NEXUS) > 0 && (camRand(2) || !camDef(pos))) + if (camCountStructuresInArea("NXWestBaseCleanup", CAM_NEXUS) > 0 && (camRand(2) || !camDef(pos))) { lzNum = 2; pos = "nexusWestTransportPos"; @@ -132,7 +132,7 @@ function sendNXTransporter() if (camDef(pos)) { - camSendReinforcement(NEXUS, camMakePos(pos), list, CAM_REINFORCE_TRANSPORT, { + camSendReinforcement(CAM_NEXUS, camMakePos(pos), list, CAM_REINFORCE_TRANSPORT, { message: LZ_ALIAS + lzNum, entry: { x: 62, y: 4 }, exit: { x: 62, y: 4 } @@ -147,13 +147,13 @@ function sendNXTransporter() //Send Nexus land units function sendNXlandReinforcements() { - if (!enumArea("NXWestBaseCleanup", NEXUS, false).length) + if (!enumArea("NXWestBaseCleanup", CAM_NEXUS, false).length) { removeTimer("sendNXlandReinforcements"); return; } - camSendReinforcement(NEXUS, camMakePos("westPhantomFactory"), getDroidsForPhantomFactory(), + camSendReinforcement(CAM_NEXUS, camMakePos("westPhantomFactory"), getDroidsForPhantomFactory(), CAM_REINFORCE_GROUND, { data: {regroup: true, count: -1,}, } @@ -163,9 +163,9 @@ function sendNXlandReinforcements() function transferPower() { const AWARD = 5000; - var powerTransferSound = "power-transferred.ogg"; + const POWER_TRANSFER_SND = "power-transferred.ogg"; setPower(playerPower(CAM_HUMAN_PLAYER) + AWARD, CAM_HUMAN_PLAYER); - playSound(powerTransferSound); + playSound(POWER_TRANSFER_SND); } function activateNexusGroups() @@ -216,8 +216,8 @@ function truckDefense() return; } - var list = ["Emplacement-Howitzer150", "Emplacement-HvART-pit", "Emplacement-RotHow"]; - var position; + const list = ["Emplacement-Howitzer150", "Emplacement-HvART-pit", "Emplacement-RotHow"]; + let position; if (truckLocCounter === 0) { @@ -236,7 +236,7 @@ function truckDefense() //Take everything Gamma has and donate to Nexus. function trapSprung() { - setAlliance(GAMMA, NEXUS, true); + setAlliance(GAMMA, CAM_NEXUS, true); setAlliance(GAMMA, CAM_HUMAN_PLAYER, false); camPlayVideos({video: "MB3_B_MSG3", type: CAMP_MSG}); hackRemoveMessage("CM3B_GAMMABASE", PROX_MSG, CAM_HUMAN_PLAYER); @@ -246,7 +246,7 @@ function trapSprung() enableAllFactories(); sendNXTransporter(); - changePlayerColour(GAMMA, NEXUS); // Black painting. + changePlayerColour(GAMMA, CAM_NEXUS); // Black painting. playSound(SYNAPTICS_ACTIVATED); setTimer("sendNXTransporter", camChangeOnDiff(camMinutesToMilliseconds(3))); @@ -258,7 +258,7 @@ function setupCapture() { trapActive = true; playSound("pcv455.ogg"); //Incoming message. - setAlliance(GAMMA, NEXUS, false); + setAlliance(GAMMA, CAM_NEXUS, false); queue("trapSprung", camSecondsToMilliseconds(2)); //call this a few seconds later } @@ -270,7 +270,7 @@ function eventAttacked(victim, attacker) camCallOnce("setupCapture"); } - if (victim.player === GAMMA && attacker.player === NEXUS) + if (victim.player === GAMMA && attacker.player === CAM_NEXUS) { gammaAttackCount = gammaAttackCount + 1; } @@ -281,8 +281,8 @@ function eventStartLevel() trapActive = false; gammaAttackCount = 0; truckLocCounter = 0; - var startpos = getObject("startPosition"); - var lz = getObject("landingZone"); + const startpos = getObject("startPosition"); + const lz = getObject("landingZone"); camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, "SUB_3_2S"); setMissionTime(camChangeOnDiff(camMinutesToSeconds(30))); // For the rescue mission. @@ -290,18 +290,18 @@ function eventStartLevel() centreView(startpos.x, startpos.y); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); - var enemyLz = getObject("NXlandingZone"); - var enemyLz2 = getObject("NXlandingZone2"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, NEXUS); + const enemyLz = getObject("NXlandingZone"); + const enemyLz2 = getObject("NXlandingZone2"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_NEXUS); setNoGoArea(enemyLz2.x, enemyLz2.y, enemyLz2.x2, enemyLz2.y2, 5); - camCompleteRequiredResearch(GAMMA_ALLY_RES, NEXUS); - camCompleteRequiredResearch(NEXUS_RES, NEXUS); - camCompleteRequiredResearch(GAMMA_ALLY_RES, GAMMA); - camCompleteRequiredResearch(NEXUS_RES, GAMMA); //They get even more research. + camCompleteRequiredResearch(mis_gammaAllyRes, CAM_NEXUS); + camCompleteRequiredResearch(mis_nexusRes, CAM_NEXUS); + camCompleteRequiredResearch(mis_gammaAllyRes, GAMMA); + camCompleteRequiredResearch(mis_nexusRes, GAMMA); //They get even more research. setAlliance(GAMMA, CAM_HUMAN_PLAYER, false); - setAlliance(GAMMA, NEXUS, true); + setAlliance(GAMMA, CAM_NEXUS, true); camSetArtifacts({ "NXCommandCenter": { tech: "R-Struc-Research-Upgrade07" }, diff --git a/script/campaign/cam3-c.js b/script/campaign/cam3-c.js index ddbd143..a56f101 100644 --- a/script/campaign/cam3-c.js +++ b/script/campaign/cam3-c.js @@ -3,7 +3,7 @@ include("script/campaign/templates.js"); include("script/campaign/transitionTech.js"); const GAMMA = 1; //Gamma is player one. -const NEXUS_RES = [ +const mis_nexusRes = [ "R-Defense-WallUpgrade09", "R-Struc-Materials09", "R-Struc-Factory-Upgrade06", "R-Struc-VTOLPad-Upgrade06", "R-Vehicle-Engine09", "R-Vehicle-Metals08", "R-Cyborg-Metals08", "R-Vehicle-Armor-Heat05", "R-Cyborg-Armor-Heat05", @@ -69,7 +69,7 @@ function enableAllFactories() function discoverGammaBase() { reunited = true; - var lz = getObject("landingZone"); + const lz = getObject("landingZone"); setScrollLimits(0, 0, 64, 192); //top and middle portion. restoreLimboMissionData(); setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER); @@ -80,7 +80,7 @@ function discoverGammaBase() playSound("pcv616.ogg"); //Group rescued. camAbsorbPlayer(GAMMA, CAM_HUMAN_PLAYER); //Take everything they got! - setAlliance(NEXUS, GAMMA, false); + setAlliance(CAM_NEXUS, GAMMA, false); hackRemoveMessage("CM3C_GAMMABASE", PROX_MSG, CAM_HUMAN_PLAYER); hackRemoveMessage("CM3C_BETATEAM", PROX_MSG, CAM_HUMAN_PLAYER); @@ -90,11 +90,11 @@ function discoverGammaBase() function findBetaUnitIds() { - var droids = enumArea("betaUnits", CAM_HUMAN_PLAYER, false).filter(function(obj) { + const droids = enumArea("betaUnits", CAM_HUMAN_PLAYER, false).filter(function(obj) { return obj.type === DROID; }); - for (var i = 0, len = droids.length; i < len; ++i) + for (let i = 0, len = droids.length; i < len; ++i) { betaUnitIds.push(droids[i].id); } @@ -107,12 +107,12 @@ function betaAlive() return true; //Don't need to see if Beta is still alive if reunited with base. } - var alive = false; - var myDroids = enumDroid(CAM_HUMAN_PLAYER); + let alive = false; + const myDroids = enumDroid(CAM_HUMAN_PLAYER); - for (var i = 0, l = betaUnitIds.length; i < l; ++i) + for (let i = 0, l = betaUnitIds.length; i < l; ++i) { - for (var x = 0, c = myDroids.length; x < c; ++x) + for (let x = 0, c = myDroids.length; x < c; ++x) { if (myDroids[x].id === betaUnitIds[i]) { @@ -137,8 +137,8 @@ function eventStartLevel() { camSetExtraObjectiveMessage(_("Reunite a part of Beta team with a Gamma team outpost")); - var startpos = getObject("startPosition"); - var limboLZ = getObject("limboDroidLZ"); + const startpos = getObject("startPosition"); + const limboLZ = getObject("limboDroidLZ"); reunited = false; betaUnitIds = []; @@ -152,16 +152,16 @@ function eventStartLevel() setNoGoArea(limboLZ.x, limboLZ.y, limboLZ.x2, limboLZ.y2, -1); setMissionTime(camChangeOnDiff(camMinutesToSeconds(10))); - var enemyLz = getObject("NXlandingZone"); - setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, NEXUS); + const enemyLz = getObject("NXlandingZone"); + setNoGoArea(enemyLz.x, enemyLz.y, enemyLz.x2, enemyLz.y2, CAM_NEXUS); - camCompleteRequiredResearch(NEXUS_RES, NEXUS); - camCompleteRequiredResearch(GAMMA_ALLY_RES, GAMMA); + camCompleteRequiredResearch(mis_nexusRes, CAM_NEXUS); + camCompleteRequiredResearch(mis_gammaAllyRes, GAMMA); hackAddMessage("CM3C_GAMMABASE", PROX_MSG, CAM_HUMAN_PLAYER, false); hackAddMessage("CM3C_BETATEAM", PROX_MSG, CAM_HUMAN_PLAYER, false); setAlliance(CAM_HUMAN_PLAYER, GAMMA, true); - setAlliance(NEXUS, GAMMA, true); + setAlliance(CAM_NEXUS, GAMMA, true); camSetArtifacts({ "NXbase1HeavyFacArti": { tech: "R-Vehicle-Body07" }, //retribution diff --git a/script/campaign/libcampaign.js b/script/campaign/libcampaign.js new file mode 100644 index 0000000..b448386 --- /dev/null +++ b/script/campaign/libcampaign.js @@ -0,0 +1,261 @@ +//;; # `libcampaign.js` documentation +//;; +//;; `libcampaign.js` is a JavaScript library supplied with the game, +//;; which contains reusable code for campaign scenarios. It is designed to +//;; make scenario development as high-level and declarative as possible. +//;; It also contains a few simple convenient wrappers. +//;; Public API functions of `libcampaign.js` are prefixed with `cam`. +//;; To use `libcampaign.js`, add the following include into your scenario code: +//;; +//;; ```js +//;; include("script/campaign/libcampaign.js"); +//;; ``` +//;; +//;; Also, most of the `libcampaign.js` features require some of the game +//;; events handled by the library. Transparent JavaScript pre-hooks are +//;; therefore injected into your global event handlers upon include. +//;; For example, if `camSetArtifacts()` was called to let `libcampaign.js` +//;; manage scenario artifacts, then `eventPickup()` will be first handled +//;; by the library, and only then your handler will be called, if any. +//;; All of this happens automagically and does not normally require +//;; your attention. +//;; + +/* + Private vars and functions are prefixed with `__cam`. + Private consts are prefixed with `__CAM_` or `__cam_`. + Public vars/functions are prefixed with `cam`, consts with `CAM_` or `cam_`. + Please do not use private stuff in scenario code, use only public API. + + It is encouraged to prefix any local consts with `__` in any function in the + library if they are not objects/arrays. Mission scripts may use a `_` but + only if the name seems like it could clash with a JS API global. + + Please CAPITALIZE const names for consistency for most of everything. + The only exception to these rules is when the const is declared in a loop + initialization or will be assigned as a global-context callback function, + or if it will be a JS object/array as these aren't truly immutable. Follow + standard camel case style as usual. + + Also, in the event you want a top level const for a mission script + (and any include file) please prefix it with `MIS_` or `mis_` depending on + if it's an object/array or not. + + We CANNOT put our private vars into an anonymous namespace, even though + it's a common JS trick - + + (function(global) { + var __camPrivateVar; // something like that + })(this); + + because they would break on savegame-loadgame. So let's just agree + that we'd never use them anywhere outside the file, so that it'd be easier + to change them, and also think twice before we change the public API. + + The lib is split into sections, each section is separated with a slash line: + +//////////////////////////////////////////////////////////////////////////////// +// Section name. +//////////////////////////////////////////////////////////////////////////////// + + yeah, like that. Also, it's exactly 80 characters wide. + + In each section, public stuff is on TOP, and private stuff + is below, split from the public stuff with: + +//////////// privates + + , for easier reading (all the useful stuff on top). + + Please leave camDebug() around if something that should never happen + occurs, indicating an actual bug in campaign. Then a sensible message + should be helpful as well. But normally, no warnings should ever be + printed. + + In cheat mode, more warnings make sense, explaining what's going on + under the hood. Use camTrace() for such warnings - they'd auto-hide + outside cheat mode. + + Lines prefixed with // followed by ;; are docstrings for JavaScript API + documentation. +*/ + +//////////////////////////////////////////////////////////////////////////////// +// Library initialization. +//////////////////////////////////////////////////////////////////////////////// + +// Registers a private event namespace for this library, to avoid collisions with +// any event handling in code using this library. Make sure no other library uses +// the same namespace, or strange things will happen. After this, we can name our +// event handlers with the registered prefix, and they will still get called. +namespace("cam_"); + +//////////global vars start +//These are campaign player numbers. +const CAM_HUMAN_PLAYER = 0; +const CAM_NEW_PARADIGM = 1; +const CAM_THE_COLLECTIVE = 2; +const CAM_NEXUS = 3; +const CAM_SCAV_6 = 6; +const CAM_SCAV_7 = 7; + +const __CAM_MAX_PLAYERS = 8; +const __CAM_TICKS_PER_FRAME = 100; +const __CAM_AI_POWER = 999999; +const __CAM_INCLUDE_PATH = "script/campaign/libcampaign_includes/"; + +//level load codes here for reference. Might be useful for later code. +const CAM_GAMMA_OUT = "GAMMA_OUT"; //Fake next level for the final Gamma mission. +const __CAM_ALPHA_CAMPAIGN_NUMBER = 1; +const __CAM_BETA_CAMPAIGN_NUMBER = 2; +const __CAM_GAMMA_CAMPAIGN_NUMBER = 3; +const __CAM_UNKNOWN_CAMPAIGN_NUMBER = 1000; +const __cam_alphaLevels = [ + "CAM_1A", "CAM_1B", "SUB_1_1S", "SUB_1_1", "SUB_1_2S", "SUB_1_2", "SUB_1_3S", + "SUB_1_3", "CAM_1C", "CAM_1CA", "SUB_1_4AS", "SUB_1_4A", "SUB_1_5S", "SUB_1_5", + "CAM_1A-C", "SUB_1_7S", "SUB_1_7", "SUB_1_DS", "SUB_1_D", "CAM_1END" +]; +const __cam_betaLevels = [ + "CAM_2A", "SUB_2_1S", "SUB_2_1", "CAM_2B", "SUB_2_2S", "SUB_2_2", "CAM_2C", + "SUB_2_5S", "SUB_2_5", "SUB_2DS", "SUB_2D", "SUB_2_6S", "SUB_2_6", "SUB_2_7S", + "SUB_2_7", "SUB_2_8S", "SUB_2_8", "CAM_2END" +]; +const __cam_gammaLevels = [ + "CAM_3A", "SUB_3_1S", "SUB_3_1", "CAM_3B", "SUB_3_2S", "SUB_3_2", "CAM3A-B", + "CAM3C", "CAM3A-D1", "CAM3A-D2", "CAM_3_4S", "CAM_3_4" +]; + +//artifact +var __camArtifacts; +var __camNumArtifacts; + +//base +var __camEnemyBases; +var __camNumEnemyBases; + +//reinforcements +const CAM_REINFORCE_NONE = 0; +const CAM_REINFORCE_GROUND = 1; +const CAM_REINFORCE_TRANSPORT = 2; + +//debug +var __camMarkedTiles = {}; +var __camCheatMode = false; +var __camDebuggedOnce = {}; +var __camTracedOnce = {}; + +//events +var __camSaveLoading; + +//group +var __camNewGroupCounter; +var __camNeverGroupDroids; + +//hook +var __camOriginalEvents = {}; + +//misc +var __camCalledOnce = {}; +var __camExpLevel; + +//nexus +const CAM_DEFENSE_ABSORBED_SND = "defabsrd.ogg"; +const CAM_DEFENSE_NEUTRALIZE_SND = "defnut.ogg"; +const CAM_LAUGH1_SND = "laugh1.ogg"; +const CAM_LAUGH2_SND = "laugh2.ogg"; +const CAM_LAUGH3_SND = "laugh3.ogg"; +const CAM_PRODUCTION_COMPLETE_SND = "pordcomp.ogg"; +const CAM_RES_ABSORBED_SND = "resabsrd.ogg"; +const CAM_STRUCTURE_ABSORBED_SND = "strutabs.ogg"; +const CAM_STRUCTURE_NEUTRALIZE_SND = "strutnut.ogg"; +const CAM_SYNAPTICS_ACTIVATED_SND = "synplnk.ogg"; +const CAM_UNIT_ABSORBED_SND = "untabsrd.ogg"; +const CAM_UNIT_NEUTRALIZE_SND = "untnut.ogg"; +var __camLastNexusAttack; +var __camNexusActivated; + +//production +var __camFactoryInfo; +var __camFactoryQueue; +var __camPropulsionTypeLimit; + +//tactics +const CAM_ORDER_ATTACK = 0; +const CAM_ORDER_DEFEND = 1; +const CAM_ORDER_PATROL = 2; +const CAM_ORDER_COMPROMISE = 3; +const CAM_ORDER_FOLLOW = 4; +var __camGroupInfo; +const __CAM_TARGET_TRACKING_RADIUS = 7; +const __CAM_PLAYER_BASE_RADIUS = 20; +const __CAM_DEFENSE_RADIUS = 4; +const __CAM_CLOSE_RADIUS = 2; +const __CAM_CLUSTER_SIZE = 4; +const __CAM_FALLBACK_TIME_ON_REGROUP = 5000; +var __camGroupAvgCoord = {x: 0, y: 0}; + +//time +const CAM_MILLISECONDS_IN_SECOND = 1000; +const CAM_SECONDS_IN_MINUTE = 60; +const CAM_MINUTES_IN_HOUR = 60; + +//transport +var __camNumTransporterExits; +var __camPlayerTransports; +var __camIncomingTransports; +var __camTransporterQueue; +var __camTransporterMessage; + +//truck +var __camTruckInfo; + +//victory +const CAM_VICTORY_STANDARD = "__camVictoryStandard"; +const CAM_VICTORY_PRE_OFFWORLD = "__camVictoryPreOffworld"; +const CAM_VICTORY_OFFWORLD = "__camVictoryOffworld"; +const CAM_VICTORY_TIMEOUT = "__camVictoryTimeout"; +var __camWinLossCallback; +var __camNextLevel; +var __camNeedBonusTime; +var __camDefeatOnTimeout; +var __camVictoryData; +var __camRTLZTicker; +var __camLZCompromisedTicker; +var __camLastAttackTriggered; +var __camLevelEnded; +var __camExtraObjectiveMessage; +var __camAllowVictoryMsgClear; + +//video +var __camVideoSequences; + +//vtol +var __camVtolDataSystem; +//////////globals vars end + +// A hack to make sure we do not put this variable into the savegame. It is +// called from top level, because we need to call it again every time we load +// scripts. But other than this one, you should in general never call game +// functions from toplevel, since all game state may not be fully initialized +// yet at the time scripts are loaded. (Yes, function name needs to be quoted.) +hackDoNotSave("__camOriginalEvents"); + +include(__CAM_INCLUDE_PATH + "misc.js"); +include(__CAM_INCLUDE_PATH + "debug.js"); +include(__CAM_INCLUDE_PATH + "hook.js"); +include(__CAM_INCLUDE_PATH + "events.js"); + +include(__CAM_INCLUDE_PATH + "time.js"); +include(__CAM_INCLUDE_PATH + "research.js"); +include(__CAM_INCLUDE_PATH + "artifact.js"); +include(__CAM_INCLUDE_PATH + "base.js"); +include(__CAM_INCLUDE_PATH + "reinforcements.js"); +include(__CAM_INCLUDE_PATH + "tactics.js"); +include(__CAM_INCLUDE_PATH + "production.js"); +include(__CAM_INCLUDE_PATH + "truck.js"); +include(__CAM_INCLUDE_PATH + "victory.js"); +include(__CAM_INCLUDE_PATH + "transport.js"); +include(__CAM_INCLUDE_PATH + "vtol.js"); +include(__CAM_INCLUDE_PATH + "nexus.js"); +include(__CAM_INCLUDE_PATH + "group.js"); +include(__CAM_INCLUDE_PATH + "video.js"); diff --git a/script/campaign/libcampaign_includes/artifact.js b/script/campaign/libcampaign_includes/artifact.js index e8519d7..b6a642f 100644 --- a/script/campaign/libcampaign_includes/artifact.js +++ b/script/campaign/libcampaign_includes/artifact.js @@ -27,8 +27,8 @@ function camSetArtifacts(artifacts) __camArtifacts = artifacts; for (const alabel in __camArtifacts) { - var ai = __camArtifacts[alabel]; - var pos = camMakePos(alabel); + const ai = __camArtifacts[alabel]; + const pos = camMakePos(alabel); if (camDef(pos.id)) { // will place when object with this id is destroyed @@ -38,7 +38,7 @@ function camSetArtifacts(artifacts) else { // received position or area, place immediately - var acrate = addFeature("Crate", pos.x, pos.y); + const acrate = addFeature("Crate", pos.x, pos.y); addLabel(acrate, __camGetArtifactLabel(alabel)); ai.placed = true; } @@ -65,19 +65,19 @@ function camAllArtifactsPickedUp() //;; function camGetArtifacts() { - var camArti = []; + const camArti = []; for (const alabel in __camArtifacts) { - var artifact = __camArtifacts[alabel]; - var libLabel = __camGetArtifactLabel(alabel); + const artifact = __camArtifacts[alabel]; + const __LIB_LABEL = __camGetArtifactLabel(alabel); //libcampaign managed artifact that was placed on the map. - if (artifact.placed && getObject(libLabel) !== null) + if (artifact.placed && getObject(__LIB_LABEL) !== null) { - camArti.push(libLabel); + camArti.push(__LIB_LABEL); } //Label for artifacts that will drop after an object gets destroyed. Or is manually managed. //NOTE: Must check for ID since "alabel" could be a AREA/POSITION label. - var obj = getObject(alabel); + const obj = getObject(alabel); if (obj !== null && camDef(obj.id)) { camArti.push(alabel); @@ -102,19 +102,19 @@ function __camGetArtifactKey(objlabel) function __camCheckPlaceArtifact(obj) { // FIXME: O(n) lookup here - var alabel = getLabel(obj); - if (!camDef(alabel) || !alabel) + const __ALABEL = getLabel(obj); + if (!camDef(__ALABEL) || !__ALABEL) { return; } - var ai = __camArtifacts[alabel]; + const ai = __camArtifacts[__ALABEL]; if (!camDef(ai)) { return; } if (ai.placed) { - camDebug("Object to which artifact", alabel, "is bound, has died twice"); + camDebug("Object to which artifact", __ALABEL, "is bound, has died twice"); return; } if (ai.tech instanceof Array) @@ -122,16 +122,16 @@ function __camCheckPlaceArtifact(obj) camTrace("Placing multi-tech granting artifact"); for (let i = 0; i < ai.tech.length; ++i) { - var techString = ai.tech[i]; - camTrace(i, ":", techString); + const __TECH_STRING = ai.tech[i]; + camTrace(i, ":", __TECH_STRING); } } else { camTrace("Placing", ai.tech); } - var acrate = addFeature("Crate", obj.x, obj.y); - addLabel(acrate, __camGetArtifactLabel(alabel)); + const acrate = addFeature("Crate", obj.x, obj.y); + addLabel(acrate, __camGetArtifactLabel(__ALABEL)); ai.placed = true; } @@ -143,9 +143,9 @@ function __camPickupArtifact(artifact) return; } // FIXME: O(n) lookup here - var alabel = __camGetArtifactKey(getLabel(artifact)); - var ai = __camArtifacts[alabel]; - if (!camDef(alabel) || !alabel || !camDef(ai)) + const __ALABEL = __camGetArtifactKey(getLabel(artifact)); + const ai = __camArtifacts[__ALABEL]; + if (!camDef(__ALABEL) || !__ALABEL || !camDef(ai)) { camTrace("Artifact", artifact.id, "is not managed"); return; @@ -159,8 +159,8 @@ function __camPickupArtifact(artifact) { for (let i = 0; i < ai.tech.length; ++i) { - var techString = ai.tech[i]; - enableResearch(techString); + const __TECH_STRING = ai.tech[i]; + enableResearch(__TECH_STRING); } } else @@ -170,7 +170,7 @@ function __camPickupArtifact(artifact) // bump counter before the callback, so that it was // actual during the callback ++__camNumArtifacts; - var callback = __camGlobalContext()["camArtifactPickup_" + alabel]; + const callback = __camGlobalContext()["camArtifactPickup_" + __ALABEL]; if (camDef(callback)) { callback(); @@ -183,11 +183,11 @@ function __camLetMeWinArtifacts() { for (const alabel in __camArtifacts) { - var ai = __camArtifacts[alabel]; + const ai = __camArtifacts[alabel]; if (ai.placed) { - var label = __camGetArtifactLabel(alabel); - var artifact = getObject(label); + const __LABEL = __camGetArtifactLabel(alabel); + const artifact = getObject(__LABEL); if (!camDef(artifact) || !artifact) { continue; @@ -200,8 +200,8 @@ function __camLetMeWinArtifacts() { for (let i = 0; i < ai.tech.length; ++i) { - var techString = ai.tech[i]; - enableResearch(techString); + const __TECH_STRING = ai.tech[i]; + enableResearch(__TECH_STRING); } } else diff --git a/script/campaign/libcampaign_includes/base.js b/script/campaign/libcampaign_includes/base.js index 2a59a51..0a12d73 100644 --- a/script/campaign/libcampaign_includes/base.js +++ b/script/campaign/libcampaign_includes/base.js @@ -33,8 +33,8 @@ //;; function camSetEnemyBases(bases) { - var reload = !camDef(bases); - if (!reload) + const __RELOAD = !camDef(bases); + if (!__RELOAD) { __camEnemyBases = bases; __camNumEnemyBases = 0; @@ -42,8 +42,8 @@ function camSetEnemyBases(bases) // convert label strings to groups and store for (const baseLabel in __camEnemyBases) { - var bi = __camEnemyBases[baseLabel]; - var obj = getObject(baseLabel); + const bi = __camEnemyBases[baseLabel]; + const obj = getObject(baseLabel); if (camDef(obj) && obj) // group already defined { if (!camDef(bi.group)) @@ -52,11 +52,11 @@ function camSetEnemyBases(bases) } else { - var structures = enumGroup(bi.group); + const structures = enumGroup(bi.group); addLabel({ type: GROUP, id: bi.group }, baseLabel); for (let idx = 0, len = structures.length; idx < len; ++idx) { - var s = structures[idx]; + const s = structures[idx]; if (s.type !== STRUCTURE || __camIsValidLeftover(s)) { continue; @@ -70,11 +70,11 @@ function camSetEnemyBases(bases) } if (!camDef(bi.cleanup)) // auto-detect cleanup area { - var objs = enumGroup(bi.group); + const objs = enumGroup(bi.group); if (objs.length > 0) { - const OFFSET = 2; // increases size of the auto-detected base area a bit - var a = { + const __OFFSET = 2; // increases size of the auto-detected base area a bit + const a = { type: AREA, x: mapWidth, y: mapHeight, x2: 0, y2: 0 @@ -82,13 +82,13 @@ function camSetEnemyBases(bases) // smallest rectangle to contain all objects for (let idx = 0, len = objs.length; idx < len; ++idx) { - var o = objs[idx]; + const o = objs[idx]; if (o.x < a.x) a.x = o.x; if (o.y < a.y) a.y = o.y; if (o.x > a.x2) a.x2 = o.x; if (o.y > a.y2) a.y2 = o.y; } - a.x -= OFFSET; a.y -= OFFSET; a.x2 += OFFSET; a.y2 += OFFSET; + a.x -= __OFFSET; a.y -= __OFFSET; a.x2 += __OFFSET; a.y2 += __OFFSET; camTrace("Auto-detected cleanup area for", baseLabel, ":", a.x, a.y, a.x2, a.y2); bi.cleanup = "__cam_enemy_base_cleanup__" + baseLabel; addLabel(a, bi.cleanup); @@ -104,10 +104,10 @@ function camSetEnemyBases(bases) } bi.group = camNewGroup(); addLabel({ type: GROUP, id: bi.group }, baseLabel); - var structs = enumArea(bi.cleanup, ENEMIES, false); + const structs = enumArea(bi.cleanup, ENEMIES, false); for (let idx = 0, len = structs.length; idx < len; ++idx) { - var s = structs[idx]; + const s = structs[idx]; if (s.type !== STRUCTURE || __camIsValidLeftover(s)) { continue; @@ -123,7 +123,7 @@ function camSetEnemyBases(bases) { //camDebug("Base", baseLabel, "defined as empty group"); } - if (!reload) + if (!__RELOAD) { bi.detected = false; bi.eliminated = false; @@ -143,7 +143,7 @@ function camSetEnemyBases(bases) //;; function camDetectEnemyBase(baseLabel) { - var bi = __camEnemyBases[baseLabel]; + const bi = __camEnemyBases[baseLabel]; if (bi.detected || bi.eliminated) { return; @@ -152,13 +152,13 @@ function camDetectEnemyBase(baseLabel) bi.detected = true; if (camDef(bi.detectSnd)) { - var pos = camMakePos(bi.cleanup); + let pos = camMakePos(bi.cleanup); if (!camDef(pos)) // auto-detect sound position by group object pos { - var objs = enumGroup(bi.group); + const objs = enumGroup(bi.group); if (objs.length > 0) { - var firstObject = objs[0]; + const firstObject = objs[0]; pos = camMakePos(firstObject); } } @@ -171,7 +171,7 @@ function camDetectEnemyBase(baseLabel) { hackAddMessage(bi.detectMsg, PROX_MSG, CAM_HUMAN_PLAYER, false); } - var callback = __camGlobalContext()["camEnemyBaseDetected_" + baseLabel]; + const callback = __camGlobalContext()["camEnemyBaseDetected_" + baseLabel]; if (camDef(callback)) { callback(); @@ -194,7 +194,7 @@ function camAllEnemyBasesEliminated() function __camCheckBaseSeen(seen) { - var group = seen; // group? + let group = seen; // group? if (camDef(seen.group)) // object? { group = seen.group; @@ -206,7 +206,7 @@ function __camCheckBaseSeen(seen) // FIXME: O(n) lookup here for (const baseLabel in __camEnemyBases) { - var bi = __camEnemyBases[baseLabel]; + const bi = __camEnemyBases[baseLabel]; if (bi.group !== group) { continue; @@ -236,7 +236,7 @@ function __camIsValidLeftover(obj) function __camShouldDestroyLeftover(objInfo, basePlayer) { - var object = getObject(objInfo.type, objInfo.player, objInfo.id); + const object = getObject(objInfo.type, objInfo.player, objInfo.id); if (object === null) { return false; @@ -253,8 +253,8 @@ function __camCheckBaseEliminated(group) // FIXME: O(n) lookup here for (const baseLabel in __camEnemyBases) { - var bi = __camEnemyBases[baseLabel]; - var leftovers = []; + const bi = __camEnemyBases[baseLabel]; + const leftovers = []; if (bi.eliminated || (bi.group !== group)) { continue; @@ -265,11 +265,11 @@ function __camCheckBaseEliminated(group) } if (camDef(bi.cleanup)) { - var objects = enumArea(bi.cleanup, ENEMIES, false); + const objects = enumArea(bi.cleanup, ENEMIES, false); for (let i = 0, len = objects.length; i < len; ++i) { - var object = objects[i]; - var objInfo = { + const object = objects[i]; + const objInfo = { type: object.type, player: object.player, id: object.id @@ -282,13 +282,13 @@ function __camCheckBaseEliminated(group) for (let i = 0, len = leftovers.length; i < len; ++i) { // remove with special effect - var leftover = leftovers[i]; + const leftover = leftovers[i]; camSafeRemoveObject(leftover, true); } if (camDef(bi.eliminateSnd)) { // play sound - var pos = camMakePos(bi.cleanup); + const pos = camMakePos(bi.cleanup); playSound(bi.eliminateSnd, pos.x, pos.y, 0); } } @@ -306,7 +306,7 @@ function __camCheckBaseEliminated(group) // bump counter before the callback, so that it was // actual during the callback ++__camNumEnemyBases; - var callback = __camGlobalContext()["camEnemyBaseEliminated_" + baseLabel]; + const callback = __camGlobalContext()["camEnemyBaseEliminated_" + baseLabel]; if (camDef(callback)) { callback(); @@ -320,7 +320,7 @@ function __camBasesTick() { for (const baseLabel in __camEnemyBases) { - var bi = __camEnemyBases[baseLabel]; + const bi = __camEnemyBases[baseLabel]; if (bi.eliminated || !camDef(bi.reinforce_kind)) { continue; @@ -340,8 +340,8 @@ function __camBasesTick() return; } bi.reinforce_last = gameTime; - var list = profile(bi.reinforce_callback); - var pos = camMakePos(bi.cleanup); + const list = profile(bi.reinforce_callback); + const pos = camMakePos(bi.cleanup); camSendReinforcement(bi.player, pos, list, bi.reinforce_kind, bi.reinforce_data); } } diff --git a/script/campaign/libcampaign_includes/debug.js b/script/campaign/libcampaign_includes/debug.js index 9ffd4ec..867cac9 100644 --- a/script/campaign/libcampaign_includes/debug.js +++ b/script/campaign/libcampaign_includes/debug.js @@ -78,12 +78,12 @@ function camDebug(...args) //;; function camDebugOnce(...args) { - var str = debugGetCallerFuncName() + ": " + args.join(" "); - if (camDef(__camDebuggedOnce[str])) + const __STR = debugGetCallerFuncName() + ": " + args.join(" "); + if (camDef(__camDebuggedOnce[__STR])) { return; } - __camDebuggedOnce[str] = true; + __camDebuggedOnce[__STR] = true; __camGenericDebug("DEBUG", debugGetCallerFuncName(), args, true, __camBacktrace()); } @@ -117,12 +117,12 @@ function camTraceOnce(...args) { return; } - var str = debugGetCallerFuncName() + ": " + args.join(" "); - if (camDef(__camTracedOnce[str])) + const __STR = debugGetCallerFuncName() + ": " + args.join(" "); + if (camDef(__camTracedOnce[__STR])) { return; } - __camTracedOnce[str] = true; + __camTracedOnce[__STR] = true; __camGenericDebug("TRACE", debugGetCallerFuncName(), args); } @@ -171,11 +171,11 @@ function __camGenericDebug(flag, functionName, args, err, backtrace) { functionName = ""; } - var str = flag + ": " + functionName + ": " + Array.prototype.join.call(args, " "); - debug(str); + const __STR = flag + ": " + functionName + ": " + Array.prototype.join.call(args, " "); + debug(__STR); if (camDef(err) && err) { - dump(str); + dump(__STR); } } diff --git a/script/campaign/libcampaign_includes/events.js b/script/campaign/libcampaign_includes/events.js index 8729a5a..9285c7f 100644 --- a/script/campaign/libcampaign_includes/events.js +++ b/script/campaign/libcampaign_includes/events.js @@ -48,6 +48,15 @@ function cam_eventChat(from, to, message) { __camShowVictoryConditions(); } + if (message.lastIndexOf("rank ", 0) === 0) + { + camSetExpLevel(Number(message.substring(5))); + camSetOnMapEnemyUnitExp(); + } + if (message.lastIndexOf("prop ", 0) === 0) + { + camSetPropulsionTypeLimit(Number(message.substring(5))); + } if (!camIsCheating()) { return; @@ -78,15 +87,15 @@ function cam_eventChat(from, to, message) { while (true) // eslint-disable-line no-constant-condition { - var research = enumResearch(); + const research = enumResearch(); if (research.length === 0) { break; } for (let i = 0, len = research.length; i < len; ++i) { - var researchName = research[i].name; - completeResearch(researchName, CAM_HUMAN_PLAYER); + const __RESEARCH_NAME = research[i].name; + completeResearch(__RESEARCH_NAME, CAM_HUMAN_PLAYER); } } } @@ -124,6 +133,7 @@ function cam_eventStartLevel() __camNeverGroupDroids = []; __camNumTransporterExits = 0; __camAllowVictoryMsgClear = true; + __camExpLevel = 0; camSetPropulsionTypeLimit(); //disable the propulsion changer by default __camAiPowerReset(); //grant power to the AI setTimer("__camSpawnVtols", camSecondsToMilliseconds(0.5)); @@ -153,10 +163,16 @@ function cam_eventDroidBuilt(droid, structure) { return; } + if (camGetNexusState() && droid.player === CAM_NEXUS && __camNextLevel === "CAM3C" && camRand(100) < 7) + { + // Occasionally hint that NEXUS is producing units on Gamma 5. + playSound(CAM_PRODUCTION_COMPLETE_SND); + } if (!camDef(__camFactoryInfo)) { return; } + camSetDroidExperience(droid); __camAddDroidToFactoryGroup(droid, structure); } @@ -212,8 +228,18 @@ function cam_eventTransporterExit(transport) __camVictoryData.reinforcements > -1) || __camWinLossCallback === CAM_VICTORY_STANDARD)) { - const REINFORCEMENTS_AVAILABLE_SOUND = "pcv440.ogg"; - playSound(REINFORCEMENTS_AVAILABLE_SOUND); + const __REINFORCEMENTS_AVAILABLE_SOUND = "pcv440.ogg"; + playSound(__REINFORCEMENTS_AVAILABLE_SOUND); + //Show the transporter reinforcement timer when it leaves for the first time. + if (__camWinLossCallback === CAM_VICTORY_OFFWORLD) + { + setReinforcementTime(__camVictoryData.reinforcements); + } + } + // Show how long until the transporter comes back on Beta End. + if (__camWinLossCallback === CAM_VICTORY_TIMEOUT) + { + setReinforcementTime(__camVictoryData.reinforcements); } } @@ -236,6 +262,14 @@ function cam_eventTransporterLanded(transport) { __camLandTransporter(transport.player, camMakePos(transport)); } + else + { + // Make the transporter timer on Beta End disappear, since the transporter has arrived. + if (__camWinLossCallback === CAM_VICTORY_TIMEOUT) + { + setReinforcementTime(-1); + } + } } function cam_eventMissionTimeout() @@ -247,8 +281,8 @@ function cam_eventMissionTimeout() } else { - var won = camCheckExtraObjective(); - if (!won) + const __WON = camCheckExtraObjective(); + if (!__WON) { __camGameLost(); return; @@ -267,9 +301,9 @@ function cam_eventAttacked(victim, attacker) //of a group. Only supports those who can hit ground units. if (victim.group === null) { - const DEFAULT_RADIUS = 6; - var loc = {x: victim.x, y: victim.y}; - var droids = enumRange(loc.x, loc.y, DEFAULT_RADIUS, victim.player, false).filter((obj) => ( + const __DEFAULT_RADIUS = 6; + const loc = {x: victim.x, y: victim.y}; + const droids = enumRange(loc.x, loc.y, __DEFAULT_RADIUS, victim.player, false).filter((obj) => ( obj.type === DROID && obj.group === null && (obj.canHitGround || obj.isSensor) && @@ -310,17 +344,17 @@ function cam_eventGameLoaded() { receiveAllEvents(true); __camSaveLoading = true; - const SCAV_KEVLAR_MISSIONS = [ + const scavKevlarMissions = [ "CAM_1CA", "SUB_1_4AS", "SUB_1_4A", "SUB_1_5S", "SUB_1_5", "CAM_1A-C", "SUB_1_7S", "SUB_1_7", "SUB_1_DS", "CAM_1END", "SUB_2_5S" ]; //Need to set the scavenger kevlar vests when loading a save from later Alpha //missions or else it reverts to the original texture. - for (let i = 0, l = SCAV_KEVLAR_MISSIONS.length; i < l; ++i) + for (let i = 0, l = scavKevlarMissions.length; i < l; ++i) { - var mission = SCAV_KEVLAR_MISSIONS[i]; - if (__camNextLevel === mission) + const __MISSION = scavKevlarMissions[i]; + if (__camNextLevel === __MISSION) { if (tilesetType === "ARIZONA") { @@ -336,6 +370,13 @@ function cam_eventGameLoaded() } } + if (__camWinLossCallback === CAM_VICTORY_TIMEOUT + && enumDroid(CAM_HUMAN_PLAYER, DROID_SUPERTRANSPORTER).length === 0) + { + // If the transport is gone on Beta End, put a timer up to show when it'll be back + setReinforcementTime(__camVictoryData.reinforcements); + } + //Subscribe to eventGroupSeen again. camSetEnemyBases(); @@ -348,27 +389,27 @@ function cam_eventGameLoaded() //Plays Nexus sounds if nexusActivated is true. function cam_eventObjectTransfer(obj, from) { - if (from === CAM_HUMAN_PLAYER && obj.player === NEXUS && __camNexusActivated === true) + if (camGetNexusState() && from === CAM_HUMAN_PLAYER && obj.player === CAM_NEXUS) { - var snd; + let snd; if (obj.type === STRUCTURE) { if (obj.stattype === DEFENSE) { - snd = DEFENSE_ABSORBED; + snd = CAM_DEFENSE_ABSORBED_SND; } else if (obj.stattype === RESEARCH_LAB) { - snd = RES_ABSORBED; + snd = CAM_RES_ABSORBED_SND; } else { - snd = STRUCTURE_ABSORBED; + snd = CAM_STRUCTURE_ABSORBED_SND; } } else if (obj.type === DROID) { - snd = UNIT_ABSORBED; + snd = CAM_UNIT_ABSORBED_SND; } if (camDef(snd)) diff --git a/script/campaign/libcampaign_includes/group.js b/script/campaign/libcampaign_includes/group.js index b4c9367..335778c 100644 --- a/script/campaign/libcampaign_includes/group.js +++ b/script/campaign/libcampaign_includes/group.js @@ -35,8 +35,8 @@ function camInNeverGroup(droid) } for (let i = 0, l = __camNeverGroupDroids.length; i < l; ++i) { - var neverDroidID = __camNeverGroupDroids[i]; - if (droid.id === neverDroidID) + const __NEVERDROID_ID = __camNeverGroupDroids[i]; + if (droid.id === __NEVERDROID_ID) { return true; } @@ -59,8 +59,8 @@ function camNeverGroupDroid(what, playerFilter) { playerFilter = ENEMIES; } - var array; - var obj; + let array; + let obj; if (camIsString(what)) // label { obj = getObject(what); @@ -101,7 +101,7 @@ function camNeverGroupDroid(what, playerFilter) { for (let i = 0, l = array.length; i < l; ++i) { - var o = array[i]; + const o = array[i]; if (!camDef(o) || !o) { continue; diff --git a/script/campaign/libcampaign_includes/hook.js b/script/campaign/libcampaign_includes/hook.js index 595be36..76444ce 100644 --- a/script/campaign/libcampaign_includes/hook.js +++ b/script/campaign/libcampaign_includes/hook.js @@ -18,9 +18,9 @@ //;; function camAreaEvent(label, callback) { - var eventName = "eventArea" + label; + const __EVENT_NAME = "eventArea" + label; camMarkTiles(label); - __camPreHookEvent(eventName, function(droid) + __camPreHookEvent(__EVENT_NAME, function(droid) { if (camDef(droid)) { diff --git a/script/campaign/libcampaign_includes/misc.js b/script/campaign/libcampaign_includes/misc.js index 6650a2a..28e6d7d 100644 --- a/script/campaign/libcampaign_includes/misc.js +++ b/script/campaign/libcampaign_includes/misc.js @@ -105,7 +105,7 @@ function camMakePos(x, y) { return undefined; } - var obj = x; + let obj = x; if (camIsString(x)) { obj = getObject(x); @@ -162,7 +162,7 @@ function camDist(x1, y1, x2, y2) { return distBetweenTwoPoints(x1.x, x1.y, y1.x, y1.y); } - var pos2 = camMakePos(x2); + const pos2 = camMakePos(x2); if (camDef(pos2.x)) // x2 is pos2 { return distBetweenTwoPoints(x1, y1, pos2.x, pos2.y); @@ -189,7 +189,7 @@ function camPlayerMatchesFilter(playerId, playerFilter) case ALLIES: return playerId === CAM_HUMAN_PLAYER; case ENEMIES: - return playerId >= 0 && playerId < CAM_MAX_PLAYERS && playerId !== CAM_HUMAN_PLAYER; + return playerId >= 0 && playerId < __CAM_MAX_PLAYERS && playerId !== CAM_HUMAN_PLAYER; default: return playerId === playerFilter; } @@ -204,11 +204,11 @@ function camPlayerMatchesFilter(playerId, playerFilter) //;; function camRemoveDuplicates(items) { - var prims = {"boolean":{}, "number":{}, "string":{}}; - var objs = []; + let prims = {"boolean":{}, "number":{}, "string":{}}; + const objs = []; return items.filter((item) => { - var type = typeof item; + const type = typeof item; if (type in prims) { return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true); @@ -234,11 +234,11 @@ function camCountStructuresInArea(label, playerFilter) { playerFilter = CAM_HUMAN_PLAYER; } - var list = enumArea(label, playerFilter, false); - var ret = 0; + const list = enumArea(label, playerFilter, false); + let ret = 0; for (let i = 0, l = list.length; i < l; ++i) { - var object = list[i]; + const object = list[i]; if (object.type === STRUCTURE && object.stattype !== WALL && object.status === BUILT) { ++ret; @@ -256,7 +256,7 @@ function camCountStructuresInArea(label, playerFilter) //;; function camChangeOnDiff(numericValue) { - var modifier = 0; + let modifier = 0; switch (difficulty) { @@ -323,8 +323,8 @@ function camMakeGroup(what, playerFilter) { playerFilter = ENEMIES; } - var array; - var obj; + let array; + let obj; if (camIsString(what)) // label { obj = getObject(what); @@ -363,10 +363,10 @@ function camMakeGroup(what, playerFilter) } if (camDef(array)) { - var group = camNewGroup(); + const group = camNewGroup(); for (let i = 0, l = array.length; i < l; ++i) { - var o = array[i]; + const o = array[i]; if (!camDef(o) || !o) { camDebug("Trying to add", o); @@ -390,9 +390,9 @@ function camMakeGroup(what, playerFilter) //;; function camBreakAlliances() { - for (let i = 0; i < CAM_MAX_PLAYERS; ++i) + for (let i = 0; i < __CAM_MAX_PLAYERS; ++i) { - for (let c = 0; c < CAM_MAX_PLAYERS; ++c) + for (let c = 0; c < __CAM_MAX_PLAYERS; ++c) { if (i !== c && allianceExistsBetween(i, c) === true) { @@ -411,12 +411,12 @@ function camBreakAlliances() //;; function camGenerateRandomMapEdgeCoordinate(reachPosition) { - let limits = getScrollLimits(); + const limits = getScrollLimits(); let loc; do { - let location = {x: 0, y: 0}; + const location = {x: 0, y: 0}; let xWasRandom = false; if (camRand(100) < 50) @@ -478,7 +478,7 @@ function camGenerateRandomMapCoordinate(reachPosition, distFromReach, scanObject scanObjectRadius = 2; } - let limits = getScrollLimits(); + const limits = getScrollLimits(); let pos; do @@ -521,29 +521,52 @@ function camGenerateRandomMapCoordinate(reachPosition, distFromReach, scanObject //;; function camDiscoverCampaign() { - for (let i = 0, len = ALPHA_LEVELS.length; i < len; ++i) + for (let i = 0, len = __cam_alphaLevels.length; i < len; ++i) { - if (__camNextLevel === ALPHA_LEVELS[i] || __camNextLevel === BETA_LEVELS[0]) + if (__camNextLevel === __cam_alphaLevels[i] || __camNextLevel === __cam_betaLevels[0]) { - return ALPHA_CAMPAIGN_NUMBER; + return __CAM_ALPHA_CAMPAIGN_NUMBER; } } - for (let i = 0, len = BETA_LEVELS.length; i < len; ++i) + for (let i = 0, len = __cam_betaLevels.length; i < len; ++i) { - if (__camNextLevel === BETA_LEVELS[i] || __camNextLevel === GAMMA_LEVELS[0]) + if (__camNextLevel === __cam_betaLevels[i] || __camNextLevel === __cam_gammaLevels[0]) { - return BETA_CAMPAIGN_NUMBER; + return __CAM_BETA_CAMPAIGN_NUMBER; } } - for (let i = 0, len = GAMMA_LEVELS.length; i < len; ++i) + for (let i = 0, len = __cam_gammaLevels.length; i < len; ++i) { - if (__camNextLevel === GAMMA_LEVELS[i] || __camNextLevel === CAM_GAMMA_OUT) + if (__camNextLevel === __cam_gammaLevels[i] || __camNextLevel === CAM_GAMMA_OUT) { - return GAMMA_CAMPAIGN_NUMBER; + return __CAM_GAMMA_CAMPAIGN_NUMBER; } } - return UNKNOWN_CAMPAIGN_NUMBER; + return __CAM_UNKNOWN_CAMPAIGN_NUMBER; +} + +function camSetExpLevel(number) +{ + __camExpLevel = number; +} + +function camSetOnMapEnemyUnitExp() +{ + enumDroid(CAM_NEW_PARADIGM) + .concat(enumDroid(CAM_THE_COLLECTIVE)) + .concat(enumDroid(CAM_NEXUS)) + .concat(enumDroid(CAM_SCAV_6)) + .concat(enumDroid(CAM_SCAV_7)) + .forEach(function(obj) { + if (!allianceExistsBetween(CAM_HUMAN_PLAYER, obj.player) && //may have friendly units as other player + !camIsTransporter(obj) && + obj.droidType !== DROID_CONSTRUCT && + obj.droidType !== DROID_REPAIR) + { + camSetDroidExperience(obj); + } + }); } //////////// privates @@ -556,21 +579,21 @@ function __camGlobalContext() function __camFindClusters(list, size) { // The good old cluster analysis algorithm taken from NullBot AI. - var ret = { clusters: [], xav: [], yav: [], maxIdx: 0, maxCount: 0 }; + const ret = { clusters: [], xav: [], yav: [], maxIdx: 0, maxCount: 0 }; for (let i = list.length - 1; i >= 0; --i) { - var x = list[i].x; - var y = list[i].y; - var found = false; - var n = 0; + const __X = list[i].x; + const __Y = list[i].y; + let found = false; + let n = 0; for (let j = 0; j < ret.clusters.length; ++j) { - if (camDist(ret.xav[j], ret.yav[j], x, y) < size) + if (camDist(ret.xav[j], ret.yav[j], __X, __Y) < size) { n = ret.clusters[j].length; ret.clusters[j][n] = list[i]; - ret.xav[j] = Math.floor((n * ret.xav[j] + x) / (n + 1)); - ret.yav[j] = Math.floor((n * ret.yav[j] + y) / (n + 1)); + ret.xav[j] = Math.floor((n * ret.xav[j] + __X) / (n + 1)); + ret.yav[j] = Math.floor((n * ret.yav[j] + __Y) / (n + 1)); if (ret.clusters[j].length > ret.maxCount) { ret.maxIdx = j; @@ -584,8 +607,8 @@ function __camFindClusters(list, size) { n = ret.clusters.length; ret.clusters[n] = [list[i]]; - ret.xav[n] = x; - ret.yav[n] = y; + ret.xav[n] = __X; + ret.yav[n] = __Y; if (1 > ret.maxCount) { ret.maxIdx = n; @@ -609,8 +632,83 @@ function __camTick() //Reset AI power back to highest storage possible. function __camAiPowerReset() { - for (let i = 1; i < CAM_MAX_PLAYERS; ++i) + for (let i = 1; i < __CAM_MAX_PLAYERS; ++i) + { + setPower(__CAM_AI_POWER, i); + } +} + +function __camGetExpRangeLevel() +{ + const ranks = { + rookie: 0, + green: 4, + trained: 8, + regular: 16, + professional: 32, + veteran: 64, + elite: 128, + special: 256, + hero: 512, + }; //see brain.json + let exp = []; + + switch (__camExpLevel) + { + case 0: // fall-through + case 1: + exp = [ranks.rookie, ranks.rookie]; + break; + case 2: + exp = [ranks.green, ranks.trained, ranks.regular]; + break; + case 3: + exp = [ranks.trained, ranks.regular, ranks.professional]; + break; + case 4: + exp = [ranks.regular, ranks.professional, ranks.veteran]; + break; + case 5: + exp = [ranks.professional, ranks.veteran, ranks.elite]; + break; + case 6: + exp = [ranks.veteran, ranks.elite, ranks.special]; + break; + case 7: + exp = [ranks.elite, ranks.special, ranks.hero]; + break; + case 8: + exp = [ranks.special, ranks.hero]; + break; + case 9: + exp = [ranks.hero, ranks.hero]; + break; + default: + __camExpLevel = 0; + exp = [ranks.rookie, ranks.rookie]; + } + + return exp; +} + +function camSetDroidExperience(droid) +{ + if (droid.droidType === DROID_REPAIR || droid.droidType === DROID_CONSTRUCT || camIsTransporter(droid)) { - setPower(AI_POWER, i); + return; } + if (droid.player === CAM_HUMAN_PLAYER) + { + return; + } + + const expRange = __camGetExpRangeLevel(); + let exp = expRange[camRand(expRange.length)]; + + if (droid.droidType === DROID_COMMAND || droid.droidType === DROID_SENSOR) + { + exp = exp * 2; + } + + setDroidExperience(droid, exp); } diff --git a/script/campaign/libcampaign_includes/nexus.js b/script/campaign/libcampaign_includes/nexus.js index b4770e0..8ed8788 100644 --- a/script/campaign/libcampaign_includes/nexus.js +++ b/script/campaign/libcampaign_includes/nexus.js @@ -11,18 +11,18 @@ //;; function camNexusLaugh() { - const LAUGH_CHANCE = 45; - if (camRand(100) < LAUGH_CHANCE) + const __LAUGH_CHANCE = 45; + if (camRand(100) < __LAUGH_CHANCE) { - const LAUGHS = [LAUGH1, LAUGH2, LAUGH3]; - playSound(LAUGHS[camRand(LAUGHS.length)]); + const laughs = [CAM_LAUGH1_SND, CAM_LAUGH2_SND, CAM_LAUGH3_SND]; + playSound(laughs[camRand(laughs.length)]); } } //;; ## camAbsorbPlayer([who[, to]]) //;; //;; Completely give all of player `who` droids and structures to player `to`. -//;; Will default to `CAM_HUMAN_PLAYER` and `NEXUS` respectively. +//;; Will default to `CAM_HUMAN_PLAYER` and `CAM_NEXUS` respectively. //;; //;; @param {number} [who] //;; @param {number} [to] @@ -36,24 +36,24 @@ function camAbsorbPlayer(who, to) } if (!camDef(to)) { - to = NEXUS; + to = CAM_NEXUS; } - var units = enumDroid(who); + const units = enumDroid(who); for (let i = 0, len = units.length; i < len; ++i) { - var droid = units[i]; + const droid = units[i]; if (!donateObject(droid, to)) { camSafeRemoveObject(droid, false); } } - var structs = enumStruct(who); + const structs = enumStruct(who); for (let i = 0, len = structs.length; i < len; ++i) { - var structure = structs[i]; + const structure = structs[i]; if (!donateObject(structure, to)) { camSafeRemoveObject(structure, false); @@ -67,7 +67,7 @@ function camAbsorbPlayer(who, to) //;; ## camHackIntoPlayer([player[, to]]) //;; //;; Steal a droid or structure from a player if the NEXUS hack state is active. -//;; Will default to `CAM_HUMAN_PLAYER` and `NEXUS` respectively. +//;; Will default to `CAM_HUMAN_PLAYER` and `CAM_NEXUS` respectively. //;; //;; @param {number} [player] //;; @param {number} [to] @@ -75,14 +75,14 @@ function camAbsorbPlayer(who, to) //;; function camHackIntoPlayer(player, to) { - if (__camNexusActivated === false) + if (!camGetNexusState()) { return; } - const GIFT_CHANCE = 70; //Else neutralized - var target; - var objects; + const __GIFT_CHANCE = 70; //Else neutralized + let target; + let objects; if (!camDef(player)) { @@ -90,14 +90,14 @@ function camHackIntoPlayer(player, to) } if (!camDef(to)) { - to = NEXUS; + to = CAM_NEXUS; } if (!camDef(__camLastNexusAttack)) { __camLastNexusAttack = 0; } - var objects = __camChooseNexusTarget(player); + objects = __camChooseNexusTarget(player); if (objects.length === 0) { return; @@ -106,7 +106,7 @@ function camHackIntoPlayer(player, to) __camLastNexusAttack = gameTime; target = objects[camRand(objects.length)]; - if (camRand(100) < GIFT_CHANCE) + if ((camRand(100) < __GIFT_CHANCE) && !(target.type === STRUCTURE && target.stattype === WALL)) { camTrace("Hacking " + target.name + " at (x,y): " + target.x + " " + target.y); //Gift sounds are done in eventObjectTransfer. @@ -120,22 +120,22 @@ function camHackIntoPlayer(player, to) camTrace("Neutralized " + target.name + " at (x,y): " + target.x + " " + target.y); if (target.player === CAM_HUMAN_PLAYER) { - var sound; + let sound; //Nexus neutralize sounds if (target.type === STRUCTURE) { if (target.stattype === DEFENSE) { - sound = DEFENSE_NEUTRALIZE; + sound = CAM_DEFENSE_NEUTRALIZE_SND; } else { - sound = STRUCTURE_NEUTRALIZE; + sound = CAM_STRUCTURE_NEUTRALIZE_SND; } } else if (target.type === DROID) { - sound = UNIT_NEUTRALIZE; + sound = CAM_UNIT_NEUTRALIZE_SND; } if (camDef(sound)) @@ -188,14 +188,14 @@ function __camChooseNexusTarget(player) return enumStruct(player, HQ); } - const TARGET_UNIT_CHANCE = (getResearch("R-Sys-Resistance-Upgrade01").done) ? 40 : 20; - var objects = []; + const __TARGET_UNIT_CHANCE = (getResearch("R-Sys-Resistance-Upgrade01").done) ? 40 : 20; + let objects = []; - if (camRand(100) < TARGET_UNIT_CHANCE) + if (camRand(100) < __TARGET_UNIT_CHANCE) { objects = enumDroid(player).filter((d) => (!camIsTransporter(d))); - const EXP = { + const exp = { rookie: 0, green: 4, trained: 8, @@ -216,7 +216,7 @@ function __camChooseNexusTarget(player) { return true; } - return d.experience < EXP.hero; + return d.experience < exp.hero; } else if (getResearch("R-Sys-Resistance-Upgrade04").done) { @@ -228,7 +228,7 @@ function __camChooseNexusTarget(player) { return false; } - return d.experience < EXP.regular; + return d.experience < exp.regular; } else if (getResearch("R-Sys-Resistance-Upgrade02").done) { @@ -236,7 +236,7 @@ function __camChooseNexusTarget(player) { return false; } - return d.experience < EXP.veteran; + return d.experience < exp.veteran; } else if (getResearch("R-Sys-Resistance-Upgrade01").done) { @@ -244,7 +244,7 @@ function __camChooseNexusTarget(player) { return false; } - return d.experience < EXP.special; + return d.experience < exp.special; } else { @@ -252,7 +252,7 @@ function __camChooseNexusTarget(player) { return true; } - return d.experience < EXP.hero; //Never absorb hero-ranked units + return d.experience < exp.hero; //Never absorb hero-ranked units } }); } diff --git a/script/campaign/libcampaign_includes/production.js b/script/campaign/libcampaign_includes/production.js index 4ac53f6..2eaa896 100644 --- a/script/campaign/libcampaign_includes/production.js +++ b/script/campaign/libcampaign_includes/production.js @@ -59,7 +59,7 @@ function camSetFactories(factories) //;; function camSetFactoryData(factoryLabel, factoryData) { - var structure = getObject(factoryLabel); + const structure = getObject(factoryLabel); if (!camDef(structure) || !structure) { // Not an error! It's ok if the factory is already destroyed @@ -68,13 +68,13 @@ function camSetFactoryData(factoryLabel, factoryData) return; } // remember the old factory group, if any - var droids = []; + let droids = []; if (camDef(__camFactoryInfo[factoryLabel])) { droids = enumGroup(__camFactoryInfo[factoryLabel].group); } __camFactoryInfo[factoryLabel] = factoryData; - var fi = __camFactoryInfo[factoryLabel]; + const fi = __camFactoryInfo[factoryLabel]; if (!camDef(fi.data)) { fi.data = {}; @@ -87,7 +87,7 @@ function camSetFactoryData(factoryLabel, factoryData) } for (let i = 0, l = droids.length; i < l; ++i) { - var droid = droids[i]; + const droid = droids[i]; groupAdd(fi.group, droid); } if (!camDef(fi.data.count)) @@ -106,7 +106,7 @@ function camSetFactoryData(factoryLabel, factoryData) //;; function camEnableFactory(factoryLabel) { - var fi = __camFactoryInfo[factoryLabel]; + const fi = __camFactoryInfo[factoryLabel]; if (!camDef(fi) || !fi) { camDebug("Factory not managed", factoryLabel); @@ -120,7 +120,7 @@ function camEnableFactory(factoryLabel) } camTrace("Enabling", factoryLabel); fi.enabled = true; - var obj = getObject(factoryLabel); + const obj = getObject(factoryLabel); if (!camDef(obj) || !obj) { camTrace("Factory", factoryLabel, "not found, probably already dead"); @@ -151,19 +151,22 @@ function camQueueDroidProduction(playerId, template) //;; ## camSetPropulsionTypeLimit([limit]) //;; -//;; On hard and insane the propulsion type can be limited with this. -//;; For type II pass in `2`, and for type III pass in `3`. Hard defaults to type II and insane defaults to type III. -//;; If nothing is passed in then the type limit will match what is in templates.json. +//;; This function can automatically augment units to use Type I/II/III propulsions. +//;; If nothing or zero is passed in then the type limit will match what is in templates.json. //;; //;; @param {number} [limit] //;; @returns {void} //;; function camSetPropulsionTypeLimit(limit) { - if (!camDef(limit)) + if (!camDef(limit) || !limit) { __camPropulsionTypeLimit = "NO_USE"; } + else if (limit === 1) + { + __camPropulsionTypeLimit = "01"; + } else if (limit === 2) { __camPropulsionTypeLimit = "02"; @@ -172,6 +175,10 @@ function camSetPropulsionTypeLimit(limit) { __camPropulsionTypeLimit = "03"; } + else + { + camTrace("Unknown propulsion level specified. Use 1 - 3 to force the propulsion type, 0 to disable."); + } } //;; ## camUpgradeOnMapTemplates(template1, template2, playerId[, excluded]) @@ -195,20 +202,20 @@ function camUpgradeOnMapTemplates(template1, template2, playerId, excluded) return; } - var droidsOnMap = enumDroid(playerId); + const droidsOnMap = enumDroid(playerId); for (let i = 0, l = droidsOnMap.length; i < l; ++i) { - var dr = droidsOnMap[i]; + const dr = droidsOnMap[i]; if (!camDef(dr.weapons[0])) { continue; //don't handle systems } - var body = dr.body; - var prop = dr.propulsion; - var weap = dr.weapons[0].name; - var skip = false; - if (body === template1.body && prop === template1.prop && weap === template1.weap) + const __BODY = dr.body; + const __PROP = dr.propulsion; + const __WEAP = dr.weapons[0].name; + let skip = false; + if (__BODY === template1.body && __PROP === template1.prop && __WEAP === template1.weap) { //Check if this object should be excluded from the upgrades if (camDef(excluded)) @@ -235,10 +242,11 @@ function camUpgradeOnMapTemplates(template1, template2, playerId, excluded) } //Replace it - let droidInfo = {x: dr.x, y: dr.y, name: dr.name}; + const droidInfo = {x: dr.x, y: dr.y, name: dr.name}; camSafeRemoveObject(dr, false); - addDroid(playerId, droidInfo.x, droidInfo.y, droidInfo.name, template2.body, - __camChangePropulsionOnDiff(template2.prop), "", "", template2.weap); + const droid = addDroid(playerId, droidInfo.x, droidInfo.y, droidInfo.name, template2.body, + __camChangePropulsion(template2.prop, playerId), "", "", template2.weap); + camSetDroidExperience(droid); } } } @@ -247,13 +255,13 @@ function camUpgradeOnMapTemplates(template1, template2, playerId, excluded) function __camFactoryUpdateTactics(flabel) { - var fi = __camFactoryInfo[flabel]; + const fi = __camFactoryInfo[flabel]; if (!fi.enabled) { camDebug("Factory", flabel, "was not enabled"); return; } - var droids = enumGroup(fi.group); + const droids = enumGroup(fi.group); if (droids.length >= fi.groupSize) { camManageGroup(fi.group, fi.order, fi.data); @@ -261,7 +269,7 @@ function __camFactoryUpdateTactics(flabel) } else { - var pos = camMakePos(fi.assembly); + let pos = camMakePos(fi.assembly); if (!camDef(pos)) { pos = camMakePos(flabel); @@ -278,65 +286,51 @@ function __camAddDroidToFactoryGroup(droid, structure) return; } // FIXME: O(n) lookup here - var flabel = getLabel(structure); - if (!camDef(flabel) || !flabel) + const __FLABEL = getLabel(structure); + if (!camDef(__FLABEL) || !__FLABEL) { return; } - var fi = __camFactoryInfo[flabel]; + const fi = __camFactoryInfo[__FLABEL]; groupAdd(fi.group, droid); if (camDef(fi.assembly)) { // this is necessary in case droid is regrouped manually // in the scenario code, and thus DORDER_DEFEND for assembly // will not be applied in __camFactoryUpdateTactics() - var pos = camMakePos(fi.assembly); + const pos = camMakePos(fi.assembly); orderDroidLoc(droid, DORDER_MOVE, pos.x, pos.y); } - __camFactoryUpdateTactics(flabel); + __camFactoryUpdateTactics(__FLABEL); } -function __camChangePropulsionOnDiff(propulsion) +function __camChangePropulsion(propulsion, playerId) { - if (difficulty <= MEDIUM) + if (__camPropulsionTypeLimit === "NO_USE" || playerId === CAM_HUMAN_PLAYER) { return propulsion; } - if (camDef(__camPropulsionTypeLimit) && __camPropulsionTypeLimit === "NO_USE") - { - return propulsion; //this mission don't want this feature then - } - var name = propulsion; - var typeModifier = difficulty === HARD ? "02" : "03"; - const VALID_PROPS = [ - "CyborgLegs", "HalfTrack", "V-Tol", "hover", "tracked", "wheeled", - ]; + let name = propulsion; + const validProp = ["CyborgLegs", "HalfTrack", "V-Tol", "hover", "tracked", "wheeled"]; + const specProps = ["CyborgLegs", "HalfTrack", "V-Tol"]; //Some have "01" at the end and others don't for the base ones. - var lastTwo = name.substring(name.length - 2); - if (lastTwo === "01" || lastTwo === "02" || lastTwo === "03") + const __LAST_TWO = name.substring(name.length - 2); + if (__LAST_TWO === "01" || __LAST_TWO === "02" || __LAST_TWO === "03") { name = name.substring(0, name.length - 2); } - for (let i = 0, l = VALID_PROPS.length; i < l; ++i) + for (let i = 0, l = validProp.length; i < l; ++i) { - var currentProp = VALID_PROPS[i]; - if (name === currentProp) + const __CURRENT_PROP = validProp[i]; + if (name === __CURRENT_PROP) { - //if hard difficulty and a future template has a type III then this will - //ensure it stays type III. - if (difficulty === HARD && lastTwo === "02") - { - typeModifier = "03"; - } - //maybe a mission wants to set a limit on the highest propulsion type - if (camDef(__camPropulsionTypeLimit)) + if ((__camPropulsionTypeLimit === "01") && (specProps.indexOf(__CURRENT_PROP) !== -1)) { - typeModifier = __camPropulsionTypeLimit; + return __CURRENT_PROP; } - //return a stronger propulsion based on difficulty - return currentProp.concat(typeModifier); + return __CURRENT_PROP.concat(__camPropulsionTypeLimit); } } @@ -356,13 +350,13 @@ function __camBuildDroid(template, structure) { return false; } - var prop = __camChangePropulsionOnDiff(template.prop); + const __PROP = __camChangePropulsion(template.prop, structure.player); makeComponentAvailable(template.body, structure.player); - makeComponentAvailable(prop, structure.player); + makeComponentAvailable(__PROP, structure.player); makeComponentAvailable(template.weap, structure.player); - var n = [ structure.name, structure.id, template.body, prop, template.weap ].join(" "); + const __NAME = [ structure.name, structure.id, template.body, __PROP, template.weap ].join(" "); // multi-turret templates are not supported yet - return buildDroid(structure, n, template.body, prop, "", "", template.weap); + return buildDroid(structure, __NAME, template.body, __PROP, "", "", template.weap); } //Check if an enabled factory can begin manufacturing something. Doing this @@ -381,8 +375,8 @@ function __checkEnemyFactoryProductionTick() function __camContinueProduction(structure) { - var flabel; - var struct; + let flabel; + let struct; if (camIsString(structure)) { flabel = structure; @@ -407,7 +401,7 @@ function __camContinueProduction(structure) { return; } - var fi = __camFactoryInfo[flabel]; + const fi = __camFactoryInfo[flabel]; if (camDef(fi.maxSize) && groupSize(fi.group) >= fi.maxSize) { // retry later @@ -415,8 +409,8 @@ function __camContinueProduction(structure) } if (camDef(fi.throttle) && camDef(fi.lastprod)) { - var throttle = gameTime - fi.lastprod; - if (throttle < fi.throttle) + const __THROTTLE = gameTime - fi.lastprod; + if (__THROTTLE < fi.throttle) { // do throttle return; @@ -426,12 +420,12 @@ function __camContinueProduction(structure) if (fi.state === -1) { fi.state = 0; - var p = struct.player; - if (camDef(__camFactoryQueue[p]) && __camFactoryQueue[p].length > 0) + const __PL = struct.player; + if (camDef(__camFactoryQueue[__PL]) && __camFactoryQueue[__PL].length > 0) { - if (__camBuildDroid(__camFactoryQueue[p][0], struct)) + if (__camBuildDroid(__camFactoryQueue[__PL][0], struct)) { - __camFactoryQueue[p].shift(); + __camFactoryQueue[__PL].shift(); return; } } diff --git a/script/campaign/libcampaign_includes/reinforcements.js b/script/campaign/libcampaign_includes/reinforcements.js index 1a16ab3..ffe937c 100644 --- a/script/campaign/libcampaign_includes/reinforcements.js +++ b/script/campaign/libcampaign_includes/reinforcements.js @@ -28,9 +28,9 @@ //;; function camSendReinforcement(playerId, position, templates, kind, data) { - var pos = camMakePos(position); - var order = CAM_ORDER_ATTACK; - var order_data = { regroup: false, count: -1 }; + const pos = camMakePos(position); + let order = CAM_ORDER_ATTACK; + let order_data = { regroup: false, count: -1 }; if (camDef(data) && camDef(data.order)) { order = data.order; @@ -42,16 +42,21 @@ function camSendReinforcement(playerId, position, templates, kind, data) switch (kind) { case CAM_REINFORCE_GROUND: - var droids = []; + { + const droids = []; for (let i = 0, l = templates.length; i < l; ++i) { - var template = templates[i]; - var prop = __camChangePropulsionOnDiff(template.prop); - droids.push(addDroid(playerId, pos.x, pos.y, "Reinforcement", template.body, prop, "", "", template.weap)); + const template = templates[i]; + const __PROP = __camChangePropulsion(template.prop, playerId); + const droid = addDroid(playerId, pos.x, pos.y, "Reinforcement", template.body, __PROP, "", "", template.weap); + camSetDroidExperience(droid); + droids.push(droid); } camManageGroup(camMakeGroup(droids), order, order_data); break; + } case CAM_REINFORCE_TRANSPORT: + { __camTransporterQueue.push({ player: playerId, position: position, @@ -62,9 +67,12 @@ function camSendReinforcement(playerId, position, templates, kind, data) }); __camDispatchTransporterSafe(); break; + } default: + { camTrace("Unknown reinforcement type"); break; + } } } @@ -89,7 +97,7 @@ function camSetBaseReinforcements(baseLabel, interval, callbackName, kind, data) { camDebug("Callback name must be a string (received", callbackName, ")"); } - var bi = __camEnemyBases[baseLabel]; + const bi = __camEnemyBases[baseLabel]; bi.reinforce_kind = kind; bi.reinforce_interval = interval; bi.reinforce_callback = callbackName; diff --git a/script/campaign/libcampaign_includes/research.js b/script/campaign/libcampaign_includes/research.js index 205a0c9..407efe2 100644 --- a/script/campaign/libcampaign_includes/research.js +++ b/script/campaign/libcampaign_includes/research.js @@ -15,9 +15,9 @@ function camEnableRes(researchIds, playerId) { for (let i = 0, l = researchIds.length; i < l; ++i) { - var researchId = researchIds[i]; - enableResearch(researchId, playerId); - completeResearch(researchId, playerId); + const __RESEARCH_ID = researchIds[i]; + enableResearch(__RESEARCH_ID, playerId); + completeResearch(__RESEARCH_ID, playerId); } } @@ -35,16 +35,16 @@ function camCompleteRequiredResearch(researchIds, playerId) for (let i = 0, l = researchIds.length; i < l; ++i) { - var researchId = researchIds[i]; - dump("Searching for required research of item: " + researchId); - var reqRes = findResearch(researchId, playerId).reverse(); + const __RESEARCH_ID = researchIds[i]; + dump("Searching for required research of item: " + __RESEARCH_ID); + let reqRes = findResearch(__RESEARCH_ID, playerId).reverse(); if (reqRes.length === 0) { //HACK: autorepair like upgrades don't work after mission transition. - if (researchId === "R-Sys-NEXUSrepair") + if (__RESEARCH_ID === "R-Sys-NEXUSrepair") { - completeResearch(researchId, playerId, true); + completeResearch(__RESEARCH_ID, playerId, true); } continue; } @@ -52,10 +52,10 @@ function camCompleteRequiredResearch(researchIds, playerId) reqRes = camRemoveDuplicates(reqRes); for (let s = 0, r = reqRes.length; s < r; ++s) { - var researchReq = reqRes[s].name; - dump(" Found: " + researchReq); - enableResearch(researchReq, playerId); - completeResearch(researchReq, playerId); + const __RESEARCH_REQ = reqRes[s].name; + dump(" Found: " + __RESEARCH_REQ); + enableResearch(__RESEARCH_REQ, playerId); + completeResearch(__RESEARCH_REQ, playerId); } } } @@ -65,7 +65,7 @@ function camCompleteRequiredResearch(researchIds, playerId) //granted shortly after mission start to give enemy players instant droid production. function __camGrantSpecialResearch() { - for (let i = 1; i < CAM_MAX_PLAYERS; ++i) + for (let i = 1; i < __CAM_MAX_PLAYERS; ++i) { if (!allianceExistsBetween(CAM_HUMAN_PLAYER, i) && (countDroid(DROID_ANY, i) > 0 || enumStruct(i).length > 0)) { diff --git a/script/campaign/libcampaign_includes/tactics.js b/script/campaign/libcampaign_includes/tactics.js index 0002b28..fb8f962 100644 --- a/script/campaign/libcampaign_includes/tactics.js +++ b/script/campaign/libcampaign_includes/tactics.js @@ -62,7 +62,7 @@ //;; function camManageGroup(group, order, data) { - var saneData = data; + let saneData = data; if (!camDef(saneData)) { saneData = {}; @@ -94,11 +94,11 @@ function camManageGroup(group, order, data) }; if (order === CAM_ORDER_FOLLOW) { - var commanderGroup = camMakeGroup([getObject(data.droid)]); - camManageGroup(commanderGroup, data.order, data.data); + const __COMMANDER_GROUP = camMakeGroup([getObject(data.droid)]); + camManageGroup(__COMMANDER_GROUP, data.order, data.data); } // apply orders instantly - queue("__camTacticsTickForGroup", CAM_TICKS_PER_FRAME, group); + queue("__camTacticsTickForGroup", __CAM_TICKS_PER_FRAME, group); } //;; ## camStopManagingGroup(group) @@ -128,7 +128,7 @@ function camStopManagingGroup(group) //;; function camOrderToString(order) { - var orderString; + let orderString; switch (order) { case CAM_ORDER_ATTACK: @@ -155,61 +155,64 @@ function camOrderToString(order) //////////// privates function __camFindGroupAvgCoordinate(groupID) { - var droids = enumGroup(groupID); - var len = droids.length; - var avgCoord = {x: 0, y: 0}; + const droids = enumGroup(groupID); + const __LEN = droids.length; + const avgCoord = {x: 0, y: 0}; if (droids.length === 0) { return null; } - for (let i = 0; i < len; ++i) + for (let i = 0; i < __LEN; ++i) { - var droid = droids[i]; + const droid = droids[i]; avgCoord.x += droid.x; avgCoord.y += droid.y; } // This global is constantly changing for the tactics code per group - __camGroupAvgCoord.x = Math.floor(avgCoord.x / len); - __camGroupAvgCoord.y = Math.floor(avgCoord.y / len); + __camGroupAvgCoord.x = Math.floor(avgCoord.x / __LEN); + __camGroupAvgCoord.y = Math.floor(avgCoord.y / __LEN); } function __camDistToGroupAverage(obj1, obj2) { - var dist1 = distBetweenTwoPoints(__camGroupAvgCoord.x, __camGroupAvgCoord.y, obj1.x, obj1.y); - var dist2 = distBetweenTwoPoints(__camGroupAvgCoord.x, __camGroupAvgCoord.y, obj2.x, obj2.y); - return (dist1 - dist2); + const __DIST1 = distBetweenTwoPoints(__camGroupAvgCoord.x, __camGroupAvgCoord.y, obj1.x, obj1.y); + const __DIST2 = distBetweenTwoPoints(__camGroupAvgCoord.x, __camGroupAvgCoord.y, obj2.x, obj2.y); + return (__DIST1 - __DIST2); } function __camPickTarget(group) { - var targets = []; - var gi = __camGroupInfo[group]; - var droids = enumGroup(group); + let targets = []; + const gi = __camGroupInfo[group]; + const droids = enumGroup(group); __camFindGroupAvgCoordinate(group); switch (gi.order) { case CAM_ORDER_ATTACK: + { if (camDef(gi.target)) { targets = enumRange(gi.target.x, gi.target.y,__CAM_TARGET_TRACKING_RADIUS, CAM_HUMAN_PLAYER, false).filter((obj) => ( obj.type === STRUCTURE || (obj.type === DROID && !isVTOL(obj)) )); } + } // fall-through! we just don't track targets on COMPROMISE case CAM_ORDER_COMPROMISE: + { if (camDef(gi.data.pos)) { for (let i = 0; i < gi.data.pos.length; ++i) { - var compromisePos = gi.data.pos[i]; + const compromisePos = gi.data.pos[i]; if (targets.length > 0) { break; } - var radius = gi.data.radius; + let radius = gi.data.radius; if (!camDef(radius)) { radius = __CAM_PLAYER_BASE_RADIUS; @@ -229,7 +232,7 @@ function __camPickTarget(group) targets = [ gi.data.pos[gi.data.pos.length - 1] ]; } } - var dr = droids[0]; + const dr = droids[0]; targets = targets.filter((obj) => ( propulsionCanReach(dr.propulsion, dr.x, dr.y, obj.x, obj.y) )); @@ -253,14 +256,16 @@ function __camPickTarget(group) } } break; + } case CAM_ORDER_DEFEND: + { if (!camDef(gi.data.pos)) { camDebug("'pos' is required for DEFEND order"); return undefined; } - var defendPos = gi.data.pos[0]; - var radius = gi.data.radius; + const defendPos = gi.data.pos[0]; + let radius = gi.data.radius; if (!camDef(radius)) { radius = __CAM_DEFENSE_RADIUS; @@ -280,16 +285,19 @@ function __camPickTarget(group) targets = [ defendPos ]; } break; + } default: + { camDebug("Unsupported group order", gi.order, camOrderToString(gi.order)); break; + } } if (targets.length === 0) { return undefined; } targets.sort(__camDistToGroupAverage); - var target = targets[0]; + const target = targets[0]; if (camDef(target) && camDef(target.type) && target.type === DROID && camIsTransporter(target)) { return undefined; @@ -300,16 +308,16 @@ function __camPickTarget(group) function __camTacticsTick() { - var dt = CAM_TICKS_PER_FRAME; + let dt = __CAM_TICKS_PER_FRAME; for (const group in __camGroupInfo) { //Remove groups with no droids. if (groupSize(group) === 0) { - var remove = true; - var removable = __camGroupInfo[group].data.removable; + let remove = true; + const __REMOVABLE = __camGroupInfo[group].data.removable; //Useful if the group has manual management (seen in cam1-3 script). - if (camDef(removable) && !removable) + if (camDef(__REMOVABLE) && !__REMOVABLE) { remove = false; } @@ -320,7 +328,7 @@ function __camTacticsTick() } } queue("__camTacticsTickForGroup", dt, group); - dt += CAM_TICKS_PER_FRAME; + dt += __CAM_TICKS_PER_FRAME; } //Emulate a queue... removeTimer("__camTacticsTick"); @@ -330,7 +338,7 @@ function __camTacticsTick() //Return the range (in tiles) a droid will scout for stuff to attack around it. function __camScanRange(order, drType) { - var rng = __CAM_TARGET_TRACKING_RADIUS; //default + let rng = __CAM_TARGET_TRACKING_RADIUS; //default switch (order) { case CAM_ORDER_ATTACK: @@ -358,20 +366,20 @@ function __camScanRange(order, drType) function __camTacticsTickForGroup(group) { - var gi = __camGroupInfo[group]; + const gi = __camGroupInfo[group]; if (!camDef(gi)) { return; } - var rawDroids = enumGroup(group); + const rawDroids = enumGroup(group); if (rawDroids.length === 0) { return; } - const CLOSE_Z = 1; - var healthyDroids = []; - var repair = { + const __CLOSE_Z = 1; + let healthyDroids = []; + const repair = { hasFacility: enumStruct(rawDroids[0].player, REPAIR_FACILITY).length > 0, pos: camDef(gi.data.repairPos) ? gi.data.repairPos : undefined, percent: camDef(gi.data.repair) ? gi.data.repair : 66, @@ -382,8 +390,8 @@ function __camTacticsTickForGroup(group) { for (let i = 0, len = rawDroids.length; i < len; ++i) { - var droid = rawDroids[i]; - var repairLikeAction = false; + const droid = rawDroids[i]; + let repairLikeAction = false; if (droid.order === DORDER_RTR) { @@ -404,7 +412,7 @@ function __camTacticsTickForGroup(group) { if (droid.health < repair.percent) { - var loc = camMakePos(repair.pos); + const loc = camMakePos(repair.pos); orderDroidLoc(droid, DORDER_MOVE, loc.x, loc.y); repairLikeAction = true; } @@ -423,10 +431,10 @@ function __camTacticsTickForGroup(group) if (camDef(gi.data.regroup) && gi.data.regroup && healthyDroids.length > 0) { - var ret = __camFindClusters(healthyDroids, __CAM_CLUSTER_SIZE); - var groupX = ret.xav[ret.maxIdx]; - var groupY = ret.yav[ret.maxIdx]; - var droids = ret.clusters[ret.maxIdx]; + const ret = __camFindClusters(healthyDroids, __CAM_CLUSTER_SIZE); + const groupX = ret.xav[ret.maxIdx]; + const groupY = ret.yav[ret.maxIdx]; + const droids = ret.clusters[ret.maxIdx]; for (let i = 0, len = ret.clusters.length; i < len; ++i) { @@ -434,7 +442,7 @@ function __camTacticsTickForGroup(group) { for (let j = 0, len2 = ret.clusters[i].length; j < len2; ++j) { - var droid = ret.clusters[i][j]; + const droid = ret.clusters[i][j]; if (droid.order !== DORDER_RTR) { orderDroidLoc(droid, DORDER_MOVE, groupX, groupY); @@ -443,19 +451,19 @@ function __camTacticsTickForGroup(group) } } - var hitRecently = (gameTime - gi.lastHit < __CAM_FALLBACK_TIME_ON_REGROUP); + const __HIT_RECENTLY = (gameTime - gi.lastHit < __CAM_FALLBACK_TIME_ON_REGROUP); // not enough droids grouped? if (gi.count < 0 ? (ret.maxCount < groupSize(group) * 0.66) : (ret.maxCount < gi.count)) { for (let i = 0, len = droids.length; i < len; ++i) { - var droid = droids[i]; + const droid = droids[i]; if (droid.order === DORDER_RTR) { continue; } - if (hitRecently && enumStruct(droid.player, HQ).length > 0) + if (__HIT_RECENTLY && enumStruct(droid.player, HQ).length > 0) { if (droid.order !== DORDER_RTB) { @@ -472,8 +480,8 @@ function __camTacticsTickForGroup(group) } //Target choosing - var target; - var patrolPos; + let target; + let patrolPos; switch (gi.order) { @@ -495,13 +503,13 @@ function __camTacticsTickForGroup(group) return; } - var defending = (gi.order === CAM_ORDER_DEFEND); - var track = (gi.order === CAM_ORDER_COMPROMISE); + const __DEFENDING = (gi.order === CAM_ORDER_DEFEND); + const __TRACK = (gi.order === CAM_ORDER_COMPROMISE); for (let i = 0, len = healthyDroids.length; i < len; ++i) { - var droid = healthyDroids[i]; - var vtolUnit = (droid.type === DROID && isVTOL(droid)); + const droid = healthyDroids[i]; + const __VTOL_UNIT = (droid.type === DROID && isVTOL(droid)); if (droid.player === CAM_HUMAN_PLAYER) { @@ -509,15 +517,15 @@ function __camTacticsTickForGroup(group) } //Rearm vtols. - if (vtolUnit) + if (__VTOL_UNIT) { - var arm = droid.weapons[0].armed; - var isRearming = droid.order === DORDER_REARM; + const __ARM = droid.weapons[0].armed; + const __IS_REARMING = droid.order === DORDER_REARM; - if ((arm < 1) || (isRearming && (arm < 100 || droid.health < 100))) + if ((__ARM < 1) || (__IS_REARMING && (__ARM < 100 || droid.health < 100))) { - var havePads = enumStruct(droid.player, REARM_PAD).length > 0; - if (havePads && !isRearming) + const __HAVE_PADS = enumStruct(droid.player, REARM_PAD).length > 0; + if (__HAVE_PADS && !__IS_REARMING) { orderDroid(droid, DORDER_REARM); } @@ -527,7 +535,7 @@ function __camTacticsTickForGroup(group) if (gi.order === CAM_ORDER_FOLLOW) { - var commander = getObject(gi.data.droid); + const commander = getObject(gi.data.droid); if (commander === null) { // the commander is dead? let the group execute his last will. @@ -544,14 +552,14 @@ function __camTacticsTickForGroup(group) if (gi.order === CAM_ORDER_DEFEND) { // fall back to defense position - var dPos = gi.data.pos[0]; - var dist = camDist(droid.x, droid.y, dPos.x, dPos.y); - var radius = gi.data.radius; + const dPos = gi.data.pos[0]; + const __DIST = camDist(droid.x, droid.y, dPos.x, dPos.y); + let radius = gi.data.radius; if (!camDef(radius)) { radius = __CAM_DEFENSE_RADIUS; } - if (dist > radius) + if (__DIST > radius) { orderDroidLoc(droid, DORDER_MOVE, target.x, target.y); continue; @@ -574,7 +582,7 @@ function __camTacticsTickForGroup(group) if (gameTime - gi.lastmove > gi.data.interval) { // find random new position to visit - var list = []; + const list = []; for (let j = 0, len2 = gi.data.pos.length; j < len2; ++j) { if (j !== gi.lastspot) @@ -597,9 +605,9 @@ function __camTacticsTickForGroup(group) if (camDef(target) && camDist(droid.x, droid.y, target.x, target.y) >= __CAM_CLOSE_RADIUS) { - var closeByObj; - var artilleryLike = (droid.isCB || droid.hasIndirect || droid.isSensor); - var closeBy = enumRange(droid.x, droid.y, __camScanRange(gi.order, droid.droidType), CAM_HUMAN_PLAYER, track); + let closeByObj; + const __ARTILLERY_LIKE = (droid.isCB || droid.hasIndirect || droid.isSensor); + let closeBy = enumRange(droid.x, droid.y, __camScanRange(gi.order, droid.droidType), CAM_HUMAN_PLAYER, __TRACK); if (closeBy.length > 0) { @@ -611,9 +619,9 @@ function __camTacticsTickForGroup(group) //We only care about explicit observe/attack if the object is close //on the z coordinate. We should not chase things up or down hills //that may be far away, at least path-wise. - if (closeByObj && !vtolUnit && !artilleryLike) + if (closeByObj && !__VTOL_UNIT && !__ARTILLERY_LIKE) { - if (Math.abs(droid.z - closeByObj.z) > CLOSE_Z) + if (Math.abs(droid.z - closeByObj.z) > __CLOSE_Z) { closeByObj = undefined; } @@ -624,7 +632,7 @@ function __camTacticsTickForGroup(group) closeByObj = undefined; } - if (!defending && closeByObj) + if (!__DEFENDING && closeByObj) { if (droid.droidType === DROID_SENSOR) { @@ -637,7 +645,7 @@ function __camTacticsTickForGroup(group) } else { - if (defending || !(artilleryLike || vtolUnit)) + if (__DEFENDING || !(__ARTILLERY_LIKE || __VTOL_UNIT)) { orderDroidLoc(droid, DORDER_MOVE, target.x, target.y); } @@ -652,46 +660,52 @@ function __camTacticsTickForGroup(group) function __camCheckGroupMorale(group) { - var gi = __camGroupInfo[group]; + const gi = __camGroupInfo[group]; if (!camDef(gi.data.morale)) { return; } // morale is %. - var msize = Math.floor((100 - gi.data.morale) * gi.count / 100); - var gsize = groupSize(group); + const __MSIZE = Math.floor((100 - gi.data.morale) * gi.count / 100); + const __GSIZE = groupSize(group); switch (gi.order) { case CAM_ORDER_ATTACK: - if (gsize > msize) + { + if (__GSIZE > __MSIZE) { break; } camTrace("Group", group, "falls back"); gi.order = CAM_ORDER_DEFEND; // swap pos and fallback - var temp = gi.data.pos; + const temp = gi.data.pos; gi.data.pos = [ camMakePos(gi.data.fallback) ]; gi.data.fallback = temp; // apply orders instantly - queue("__camTacticsTickForGroup", CAM_TICKS_PER_FRAME, group); + queue("__camTacticsTickForGroup", __CAM_TICKS_PER_FRAME, group); break; + } case CAM_ORDER_DEFEND: - if (gsize <= msize) + { + if (__GSIZE <= __MSIZE) { break; } camTrace("Group", group, "restores"); gi.order = CAM_ORDER_ATTACK; // swap pos and fallback - var temp = gi.data.pos; + const temp = gi.data.pos; gi.data.pos = gi.data.fallback; gi.data.fallback = temp[0]; // apply orders instantly - queue("__camTacticsTickForGroup", CAM_TICKS_PER_FRAME, group); + queue("__camTacticsTickForGroup", __CAM_TICKS_PER_FRAME, group); break; + } default: + { camDebug("Group order doesn't support morale", camOrderToString(gi.order)); break; + } } } diff --git a/script/campaign/libcampaign_includes/time.js b/script/campaign/libcampaign_includes/time.js index ab321a2..d70c08e 100644 --- a/script/campaign/libcampaign_includes/time.js +++ b/script/campaign/libcampaign_includes/time.js @@ -13,7 +13,7 @@ //;; function camSecondsToMilliseconds(seconds) { - return seconds * MILLISECONDS_IN_SECOND; + return seconds * CAM_MILLISECONDS_IN_SECOND; } //;; ## camMinutesToMilliseconds(minutes) @@ -25,7 +25,7 @@ function camSecondsToMilliseconds(seconds) //;; function camMinutesToMilliseconds(minutes) { - return minutes * camSecondsToMilliseconds(SECONDS_IN_MINUTE); + return minutes * camSecondsToMilliseconds(CAM_SECONDS_IN_MINUTE); } //;; ## camMinutesToSeconds(minutes) @@ -37,7 +37,7 @@ function camMinutesToMilliseconds(minutes) //;; function camMinutesToSeconds(minutes) { - return minutes * SECONDS_IN_MINUTE; + return minutes * CAM_SECONDS_IN_MINUTE; } //;; ## camHoursToSeconds(hours) @@ -49,5 +49,5 @@ function camMinutesToSeconds(minutes) //;; function camHoursToSeconds(hours) { - return hours * camMinutesToSeconds(MINUTES_IN_HOUR); + return hours * camMinutesToSeconds(CAM_MINUTES_IN_HOUR); } diff --git a/script/campaign/libcampaign_includes/transport.js b/script/campaign/libcampaign_includes/transport.js index 9ca8b4a..50611e1 100644 --- a/script/campaign/libcampaign_includes/transport.js +++ b/script/campaign/libcampaign_includes/transport.js @@ -70,63 +70,63 @@ function __camDispatchTransporterUnsafe() camDebug("Transporter queue empty!"); return false; } - const OFFSET = 1; //Increaze LZ "no go" zone area a bit - var args = __camTransporterQueue[0]; - var player = args.player; - var pos = args.position; - var list = args.list; - var data = args.data; - if (camDef(__camIncomingTransports[player])) + const __OFFSET = 1; //Increaze LZ "no go" zone area a bit + const args = __camTransporterQueue[0]; + const __PLAYER = args.player; + const pos = args.position; + const list = args.list; + const data = args.data; + if (camDef(__camIncomingTransports[__PLAYER])) { - camTrace("Transporter already on map for player", player + ", delaying."); + camTrace("Transporter already on map for player", __PLAYER + ", delaying."); return false; } __camTransporterQueue.shift(); // what could possibly go wrong? - if (!camDef(__camPlayerTransports[player])) + if (!camDef(__camPlayerTransports[__PLAYER])) { - camTrace("Creating a transporter for player", player); - __camPlayerTransports[player] = addDroid(player, -1, -1, + camTrace("Creating a transporter for player", __PLAYER); + __camPlayerTransports[__PLAYER] = addDroid(__PLAYER, -1, -1, "Transporter", "TransporterBody", "V-Tol", "", "", "MG3-VTOL"); } - var trans = __camPlayerTransports[player]; - var droids = []; + const transporter = __camPlayerTransports[__PLAYER]; + const droids = []; for (let i = 0, l = list.length; i < l; ++i) { - var template = list[i]; - var prop = __camChangePropulsionOnDiff(template.prop); - var droid = addDroid(player, -1, -1, "Reinforcement", template.body, prop, "", "", template.weap); + const template = list[i]; + const __PROP = __camChangePropulsion(template.prop, __PLAYER); + const droid = addDroid(__PLAYER, -1, -1, "Reinforcement", template.body, __PROP, "", "", template.weap); droids.push(droid); - addDroidToTransporter(trans, droid); + addDroidToTransporter(transporter, droid); } - __camIncomingTransports[player] = { + __camIncomingTransports[__PLAYER] = { droids: droids, message: args.data.message, order: args.order, data: args.order_data, }; camTrace("Incoming transport with", droids.length, - "droids for player", player + + "droids for player", __PLAYER + ", queued transports", __camTransporterQueue.length); - setNoGoArea(pos.x - OFFSET, pos.y - OFFSET, pos.x + OFFSET, pos.y + OFFSET, player); + setNoGoArea(pos.x - __OFFSET, pos.y - __OFFSET, pos.x + __OFFSET, pos.y + __OFFSET, __PLAYER); //Delete previous enemy reinforcement transport blip - if (player !== CAM_HUMAN_PLAYER) + if (__PLAYER !== CAM_HUMAN_PLAYER) { camRemoveEnemyTransporterBlip(); } - if (player !== CAM_HUMAN_PLAYER) + if (__PLAYER !== CAM_HUMAN_PLAYER) { playSound("pcv381.ogg"); //Enemy transport detected. } - setTransporterExit(data.exit.x, data.exit.y, player); + setTransporterExit(data.exit.x, data.exit.y, __PLAYER); // will guess which transporter to start, automagically - startTransporterEntry(data.entry.x, data.entry.y, player); + startTransporterEntry(data.entry.x, data.entry.y, __PLAYER); return true; } @@ -140,7 +140,7 @@ function __camDispatchTransporterSafe(player, position, list, data) function __camLandTransporter(player, pos) { - var ti = __camIncomingTransports[player]; + const ti = __camIncomingTransports[player]; if (!camDef(ti)) { camDebug("Unhandled transporter for player", player); @@ -158,6 +158,13 @@ function __camLandTransporter(player, pos) camTrace("Landing transport for player", player); playSound("pcv395.ogg", pos.x, pos.y, 0); //Incoming enemy transport. camManageGroup(camMakeGroup(ti.droids), ti.order, ti.data); + if (player !== CAM_HUMAN_PLAYER) + { + for (let i = 0, len = ti.droids.length; i < len; ++i) + { + camSetDroidExperience(ti.droids[i]); + } + } } function __camRemoveIncomingTransporter(player) diff --git a/script/campaign/libcampaign_includes/truck.js b/script/campaign/libcampaign_includes/truck.js index 2b63b36..1cdb560 100644 --- a/script/campaign/libcampaign_includes/truck.js +++ b/script/campaign/libcampaign_includes/truck.js @@ -31,7 +31,7 @@ function camManageTrucks(playerId) //;; function camQueueBuilding(playerId, stat, position) { - var ti = __camTruckInfo[playerId]; + const ti = __camTruckInfo[playerId]; ti.queue.push({ stat: stat, pos: camMakePos(position) }); } @@ -39,11 +39,11 @@ function camQueueBuilding(playerId, stat, position) function __camEnumFreeTrucks(player) { - var rawDroids = enumDroid(player, DROID_CONSTRUCT); - var droids = []; + const rawDroids = enumDroid(player, DROID_CONSTRUCT); + const droids = []; for (let i = 0, l = rawDroids.length; i < l; ++i) { - var droid = rawDroids[i]; + const droid = rawDroids[i]; if (droid.order !== DORDER_BUILD && droid.order !== DORDER_HELPBUILD && droid.order !== DORDER_LINEBUILD) { droids.push(droid); @@ -52,28 +52,28 @@ function __camEnumFreeTrucks(player) return droids; } -function __camGetClosestTruck(player, pos) +function __camGetClosestTruck(player, pos, list) { - var droids = __camEnumFreeTrucks(player); + const droids = (camDef(list) && list !== null) ? list : __camEnumFreeTrucks(player); if (droids.length <= 0) { return undefined; } // Find out which one is the closest. - var minDroid = droids[0]; - var minDist = camDist(minDroid, pos); + let minDroid = droids[0]; + let minDist = camDist(minDroid, pos); for (let i = 1, l = droids.length; i < l; ++i) { - var droid = droids[i]; + const droid = droids[i]; if (!droidCanReach(droid, pos.x, pos.y)) { continue; } - var dist = camDist(droid, pos); - if (dist < minDist) + const __DIST = camDist(droid, pos); + if (__DIST < minDist) { - minDist = dist; + minDist = __DIST; minDroid = droid; } } @@ -86,22 +86,23 @@ function __camTruckTick() // See comments inside the loop to understand priority. for (const playerObj in __camTruckInfo) { - var ti = __camTruckInfo[playerObj]; - var player = ti.player; - var truck; + const ti = __camTruckInfo[playerObj]; + const __PLAYER = ti.player; + let freeTrucks = __camEnumFreeTrucks(__PLAYER); + let truck; // First, build things that were explicitly ordered. while (ti.queue.length > 0) { - var qi = ti.queue[0]; - var pos = qi.pos; - var randx = 0; - var randy = 0; + const __QI = ti.queue[0]; + let pos = __QI.pos; + let randx = 0; + let randy = 0; if (camDef(pos)) { // Find the truck most suitable for the job. - truck = __camGetClosestTruck(player, pos); + truck = __camGetClosestTruck(__PLAYER, pos, freeTrucks); if (!camDef(truck)) { break; @@ -110,39 +111,39 @@ function __camTruckTick() else { // Build near any truck if pos was not specified. - var droids = __camEnumFreeTrucks(player); - if (droids.length <= 0) + if (freeTrucks.length <= 0) { break; } - truck = droids[0]; + truck = freeTrucks[0]; pos = truck; randx = (camRand(100) < 50) ? -camRand(2) : camRand(2); randy = (camRand(100) < 50) ? -camRand(2) : camRand(2); } - enableStructure(qi.stat, player); - var loc = pickStructLocation(truck, qi.stat, pos.x, pos.y); + enableStructure(__QI.stat, __PLAYER); + const loc = pickStructLocation(truck, __QI.stat, pos.x, pos.y); if (camDef(loc) && camDef(truck)) { - if (orderDroidBuild(truck, DORDER_BUILD, qi.stat, loc.x + randx, loc.y + randy)) + if (orderDroidBuild(truck, DORDER_BUILD, __QI.stat, loc.x + randx, loc.y + randy)) { + freeTrucks = freeTrucks.filter((tr) => (tr.id !== truck.id)); ti.queue.shift(); // consider it handled } } } // Then, capture free oils. - var oils = enumFeature(ALL_PLAYERS, "OilResource"); + const oils = enumFeature(ALL_PLAYERS, "OilResource"); if (oils.length === 0) { continue; } - var oil = oils[0]; - truck = __camGetClosestTruck(player, oil); - if (camDef(truck) && player !== NEXUS) + const oil = oils[0]; + truck = __camGetClosestTruck(__PLAYER, oil, freeTrucks); + if (camDef(truck) && __PLAYER !== CAM_NEXUS) { - enableStructure("A0ResourceExtractor", player); + enableStructure("A0ResourceExtractor", __PLAYER); orderDroidBuild(truck, DORDER_BUILD, "A0ResourceExtractor", oil.x, oil.y); continue; } diff --git a/script/campaign/libcampaign_includes/victory.js b/script/campaign/libcampaign_includes/victory.js index 13d7cee..8b98059 100644 --- a/script/campaign/libcampaign_includes/victory.js +++ b/script/campaign/libcampaign_includes/victory.js @@ -14,14 +14,14 @@ function camNextLevel(nextLevel) { if (__camNeedBonusTime) { - var bonusTime = getMissionTime(); + let bonusTime = getMissionTime(); if (difficulty <= MEDIUM) { bonusTime = Math.floor(bonusTime * 0.75); } if (bonusTime > 0) { - var bonus = 110; + let bonus = 110; if (difficulty === HARD) { bonus = 105; @@ -103,7 +103,7 @@ function camSetStandardWinLossConditions(kind, nextLevel, data) __camNeedBonusTime = true; __camDefeatOnTimeout = true; __camVictoryData = data; - setReinforcementTime(__camVictoryData.reinforcements); + setReinforcementTime((__camNumTransporterExits > 0) ? __camVictoryData.reinforcements : -1); useSafetyTransport(false); break; case CAM_VICTORY_TIMEOUT: @@ -111,7 +111,7 @@ function camSetStandardWinLossConditions(kind, nextLevel, data) __camNeedBonusTime = false; __camDefeatOnTimeout = false; __camVictoryData = data; - setReinforcementTime(__camVictoryData.reinforcements); + setReinforcementTime((__camVictoryData.reinforcements > -1) ? __camVictoryData.reinforcements : -1); useSafetyTransport(true); break; default: @@ -129,13 +129,13 @@ function camSetStandardWinLossConditions(kind, nextLevel, data) //;; function camCheckExtraObjective() { - var extraObjMet = true; + let extraObjMet = true; if (camDef(__camVictoryData) && camDef(__camVictoryData.callback)) { - var result = __camGlobalContext()[__camVictoryData.callback](); - if (camDef(result)) + const __RESULT = __camGlobalContext()[__camVictoryData.callback](); + if (camDef(__RESULT)) { - if (!result) + if (!__RESULT) { __camGameLost(); return; @@ -215,15 +215,15 @@ function __camGameWon() //Checks if the player is considered to be alive on all non-offworld missions. function __camPlayerDead() { - var dead = true; - var haveFactories = enumStruct(CAM_HUMAN_PLAYER, FACTORY).filter(function(obj) { + let dead = true; + let haveFactories = enumStruct(CAM_HUMAN_PLAYER, FACTORY).filter(function(obj) { return obj.status === BUILT; }).length > 0; //If no normal factories are found, check for any cyborg factories since the player can build Combat Engineers if (!haveFactories) { - var haveFactories = enumStruct(CAM_HUMAN_PLAYER, CYBORG_FACTORY).filter(function(obj) { + haveFactories = enumStruct(CAM_HUMAN_PLAYER, CYBORG_FACTORY).filter(function(obj) { return obj.status === BUILT; }).length > 0; } @@ -250,10 +250,10 @@ function __camPlayerDead() } else if (__camNextLevel === "CAM3A-D1") { - const GAMMA_PLAYER = 1; + const __GAMMA_PLAYER = 1; //Care about all units and not just trucks at the start of cam3-c. - if (allianceExistsBetween(GAMMA_PLAYER, NEXUS) && enumDroid(CAM_HUMAN_PLAYER).length > 0) + if (allianceExistsBetween(__GAMMA_PLAYER, CAM_NEXUS) && enumDroid(CAM_HUMAN_PLAYER).length > 0) { dead = false; } @@ -261,13 +261,13 @@ function __camPlayerDead() else { //Check the transporter. - var transporter = enumDroid(CAM_HUMAN_PLAYER, DROID_SUPERTRANSPORTER); + const transporter = enumDroid(CAM_HUMAN_PLAYER, DROID_SUPERTRANSPORTER); if (transporter.length > 0) { - var cargoDroids = enumCargo(transporter[0]); + const cargoDroids = enumCargo(transporter[0]); for (let i = 0, len = cargoDroids.length; i < len; ++i) { - var virDroid = cargoDroids[i]; + const virDroid = cargoDroids[i]; if (camDef(virDroid) && virDroid && virDroid.droidType === DROID_CONSTRUCT) { dead = false; @@ -280,7 +280,7 @@ function __camPlayerDead() if (__camWinLossCallback === CAM_VICTORY_TIMEOUT) { //Make the mission fail if no units are alive on map while having no factories. - var droidCount = 0; + let droidCount = 0; enumDroid(CAM_HUMAN_PLAYER).forEach((obj) => { if (obj.droidType === DROID_SUPERTRANSPORTER) { @@ -294,7 +294,7 @@ function __camPlayerDead() droidCount += 1; } }); - dead = droidCount <= 0 && !haveFactories; + dead = droidCount <= 0 && !__HAVE_FACTORIES; //Finish Beta-end early if they have no units and factories on Easy/Normal. if (dead && (difficulty <= MEDIUM) && (__camNextLevel === "CAM_3A")) @@ -311,9 +311,8 @@ function __camTriggerLastAttack() { if (!__camLastAttackTriggered) { - var enemies = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false); // Do not order systems (sensor/trucks/repairs) to attack stuff. - enemies = enemies.filter((obj) => ( + const enemies = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false).filter((obj) => ( obj.type === DROID && !camIsTransporter(obj) && !camIsSystemDroid(obj) )); camTrace(enemies.length, "enemy droids remaining"); @@ -324,7 +323,7 @@ function __camTriggerLastAttack() function __camVictoryStandard() { - var extraObj = camCheckExtraObjective(); + const __EXTRA_OBJ = camCheckExtraObjective(); // check if game is lost if (__camPlayerDead()) { @@ -332,7 +331,7 @@ function __camVictoryStandard() return; } // check if game is won - if (camAllArtifactsPickedUp() && camAllEnemyBasesEliminated() && extraObj) + if (camAllArtifactsPickedUp() && camAllEnemyBasesEliminated() && __EXTRA_OBJ) { if (enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false).length === 0) { @@ -365,29 +364,29 @@ function __camVictoryTimeout() function __camVictoryOffworld() { - var lz = __camVictoryData.area; + const lz = __camVictoryData.area; if (!camDef(lz)) { camDebug("Landing zone area is required for OFFWORLD"); return; } - var total = countDroid(DROID_ANY, CAM_HUMAN_PLAYER); // for future use - if (total === 0) + const __TOTAL = countDroid(DROID_ANY, CAM_HUMAN_PLAYER); // for future use + if (__TOTAL === 0) { __camGameLost(); return; } - var forceLZ = camDef(__camVictoryData.retlz) ? __camVictoryData.retlz : false; - var destroyAll = camDef(__camVictoryData.annihilate) ? __camVictoryData.annihilate : false; - var elimBases = camDef(__camVictoryData.eliminateBases) ? __camVictoryData.eliminateBases : false; + const __FORCE_LZ = camDef(__camVictoryData.retlz) ? __camVictoryData.retlz : false; + const __DESTROY_ALL = camDef(__camVictoryData.annihilate) ? __camVictoryData.annihilate : false; + const __ELIM_BASES = camDef(__camVictoryData.eliminateBases) ? __camVictoryData.eliminateBases : false; if (camCheckExtraObjective() && camAllArtifactsPickedUp()) { - if (elimBases) + if (__ELIM_BASES) { if (camAllEnemyBasesEliminated()) { - var enemyDroids = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false).filter((obj) => ( + const enemyDroids = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false).filter((obj) => ( obj.type === DROID )).length; @@ -404,8 +403,8 @@ function __camVictoryOffworld() } else { - var enemyLen = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false).length; - if (!forceLZ && !enemyLen) + const __ENEMY_LEN = enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false).length; + if (!__FORCE_LZ && !__ENEMY_LEN) { //if there are no more enemies, win instantly unless forced to go //back to the LZ. @@ -414,18 +413,18 @@ function __camVictoryOffworld() } //Missions that are not won based on artifact count (see missions 2-1 and 3-2). - //If either forceLZ or destroyAll is true then ignore this. - if (__camNumArtifacts === 0 && !forceLZ && !destroyAll) + //If either __FORCE_LZ or __DESTROY_ALL is true then ignore this. + if (__camNumArtifacts === 0 && !__FORCE_LZ && !__DESTROY_ALL) { __camGameWon(); return; } //Make sure to only count droids here. - var atlz = enumArea(lz, CAM_HUMAN_PLAYER, false).filter((obj) => ( + const __TOTAL_AT_LZ = enumArea(lz, CAM_HUMAN_PLAYER, false).filter((obj) => ( obj.type === DROID && !camIsTransporter(obj) )).length; - if (((!forceLZ && !destroyAll) || (forceLZ && destroyAll && !enemyLen) || (forceLZ && !destroyAll)) && (atlz === total)) + if (((!__FORCE_LZ && !__DESTROY_ALL) || (__FORCE_LZ && __DESTROY_ALL && !__ENEMY_LEN) || (__FORCE_LZ && !__DESTROY_ALL)) && (__TOTAL_AT_LZ === __TOTAL)) { __camGameWon(); return; @@ -435,9 +434,9 @@ function __camVictoryOffworld() __camTriggerLastAttack(); } - if (!destroyAll || (forceLZ && !enemyLen)) + if (!__DESTROY_ALL || (__FORCE_LZ && !__ENEMY_LEN)) { - const REMIND_RETURN = 30; // every X seconds + const __REMIND_RETURN = 30; // every X seconds if (__camRTLZTicker === 0 && camDef(__camVictoryData.message)) { camTrace("Return to LZ message displayed"); @@ -447,9 +446,9 @@ function __camVictoryOffworld() hackAddMessage(__camVictoryData.message, PROX_MSG, CAM_HUMAN_PLAYER, false); } } - if (__camRTLZTicker % REMIND_RETURN === 0) + if (__camRTLZTicker % __REMIND_RETURN === 0) { - var pos = camMakePos(lz); + const pos = camMakePos(lz); playSound("pcv427.ogg", pos.x, pos.y, 0); console(_("Return to LZ")); } @@ -459,7 +458,7 @@ function __camVictoryOffworld() } if (enumArea(lz, ENEMIES, false).length > 0) { - const REMIND_COMPROMISED = 30; // every X seconds + const __REMIND_COMPROMISED = 30; // every X seconds //Protect against early access to reinforcements GUI if it shouldn't be available yet if (__camVictoryData.reinforcements >= 0) { @@ -469,9 +468,9 @@ function __camVictoryOffworld() { camTrace("LZ compromised"); } - if (__camLZCompromisedTicker % REMIND_COMPROMISED === 1) + if (__camLZCompromisedTicker % __REMIND_COMPROMISED === 1) { - var pos = camMakePos(lz); + const pos = camMakePos(lz); playSound("pcv445.ogg", pos.x, pos.y, 0); } ++__camLZCompromisedTicker; @@ -483,7 +482,7 @@ function __camVictoryOffworld() else if (__camLZCompromisedTicker > 0) { camTrace("LZ clear"); - var pos = camMakePos(lz); + const pos = camMakePos(lz); playSound("lz-clear.ogg", pos.x, pos.y, 0); setReinforcementTime(__camVictoryData.reinforcements); __camLZCompromisedTicker = 0; @@ -507,7 +506,7 @@ function __camSetupConsoleForVictoryConditions() function __camShowBetaHint() { - return ((camDiscoverCampaign() === BETA_CAMPAIGN_NUMBER) && (difficulty === HARD || difficulty === INSANE)); + return ((camDiscoverCampaign() === __CAM_BETA_CAMPAIGN_NUMBER) && (difficulty === HARD || difficulty === INSANE)); } function __camShowBetaHintEarly() @@ -540,10 +539,10 @@ function __camShowVictoryConditions() return; // do not need this on these missions. } - const ANNIHILATE_MESSAGE = _("Destroy all enemy units and structures"); + const __ANNIHILATE_MESSAGE = _("Destroy all enemy units and structures"); - var unitsOnMap = 0; - var structuresOnMap = 0; + let unitsOnMap = 0; + let structuresOnMap = 0; enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false).forEach((obj) => { if (obj.type === DROID) @@ -570,7 +569,7 @@ function __camShowVictoryConditions() if (camDef(__camVictoryData.annihilate) && __camVictoryData.annihilate) { - console(ANNIHILATE_MESSAGE); + console(__ANNIHILATE_MESSAGE); } if (camDef(__camVictoryData.eliminateBases) && __camVictoryData.eliminateBases) @@ -584,7 +583,7 @@ function __camShowVictoryConditions() } else if (__camWinLossCallback === CAM_VICTORY_STANDARD) { - console(ANNIHILATE_MESSAGE); + console(__ANNIHILATE_MESSAGE); } //More specific messages set through the mission scripts. @@ -594,8 +593,8 @@ function __camShowVictoryConditions() { for (let i = 0, len = __camExtraObjectiveMessage.length; i < len; ++i) { - var mes = __camExtraObjectiveMessage[i]; - console(mes); + const __MES = __camExtraObjectiveMessage[i]; + console(__MES); } } else diff --git a/script/campaign/libcampaign_includes/video.js b/script/campaign/libcampaign_includes/video.js index 6fa6d82..1777527 100644 --- a/script/campaign/libcampaign_includes/video.js +++ b/script/campaign/libcampaign_includes/video.js @@ -61,18 +61,18 @@ function __camEnqueueVideos() return; //Nothing to play } - const SOUND_IDENTIFER = ".ogg"; - var what = __camVideoSequences[0]; + const __SOUND_IDENTIFER = ".ogg"; + const what = __camVideoSequences[0]; // Check if this is a sound to play before some sequence. - if (typeof what === "string" && what.indexOf(SOUND_IDENTIFER) !== -1) + if (typeof what === "string" && what.indexOf(__SOUND_IDENTIFER) !== -1) { playSound(what); queue("__camEnqueueVideos", camSecondsToMilliseconds(3.2)); //more than enough for most sounds. } else if (typeof what === "object") { - var play = true; + let play = true; if (!camDef(what.video) || !camIsString(what.video)) { @@ -81,7 +81,7 @@ function __camEnqueueVideos() } if (!camDef(what.type) || (what.type !== MISS_MSG && what.type !== CAMP_MSG)) { - camDebug("Video message type was NOT specified. Please specify one.") + camDebug("Video message type was NOT specified. Please specify one."); play = false; } if (!camDef(what.immediate)) diff --git a/script/campaign/libcampaign_includes/vtol.js b/script/campaign/libcampaign_includes/vtol.js index b6eb195..32ee331 100644 --- a/script/campaign/libcampaign_includes/vtol.js +++ b/script/campaign/libcampaign_includes/vtol.js @@ -68,7 +68,6 @@ function camSetVtolSpawnState(state, identifier) if (__camVtolDataSystem[idx].spawnStopObject === identifier) { __camVtolDataSystem[idx].active = state; - break; } } } @@ -149,8 +148,8 @@ function __camSpawnVtols() } } - let amount = minVtolAmount + camRand(maxRandomAdditions + 1); - let droids = []; + const __AMOUNT = minVtolAmount + camRand(maxRandomAdditions + 1); + const droids = []; let pos; //Make sure to catch multiple start positions also. @@ -170,15 +169,15 @@ function __camSpawnVtols() if (!camDef(__camVtolDataSystem[idx].extras)) { //Pick some droids randomly. - for (let i = 0; i < amount; ++i) + for (let i = 0; i < __AMOUNT; ++i) { droids.push(__camVtolDataSystem[idx].templates[camRand(__camVtolDataSystem[idx].templates.length)]); } } else { - var lim = amount; - var alternate = false; + let lim = __AMOUNT; + let alternate = false; if (camDef(__camVtolDataSystem[idx].extras.alternate)) { alternate = __camVtolDataSystem[idx].extras.alternate; //Only use one template type @@ -238,16 +237,16 @@ function __camRetreatVtols() camDef(__camVtolDataSystem[idx].exitPosition.y) && enumStruct(__camVtolDataSystem[idx].player, REARM_PAD).length === 0) { - const VTOL_RETURN_HEALTH = 40; // run-away if health is less than... - const VTOL_RETURN_ARMED = 1; // run-away if weapon ammo is less than... - let vtols = enumDroid(__camVtolDataSystem[idx].player).filter((obj) => (isVTOL(obj))); + const __VTOL_RETURN_HEALTH = 40; // run-away if health is less than... + const __VTOL_RETURN_ARMED = 1; // run-away if weapon ammo is less than... + const vtols = enumDroid(__camVtolDataSystem[idx].player).filter((obj) => (isVTOL(obj))); for (let i = 0, len = vtols.length; i < len; ++i) { - let vt = vtols[i]; + const vt = vtols[i]; for (let c = 0, len2 = vt.weapons.length; c < len2; ++c) { - if ((vt.order === DORDER_RTB) || (vt.weapons[c].armed < VTOL_RETURN_ARMED) || (vt.health < VTOL_RETURN_HEALTH)) + if ((vt.order === DORDER_RTB) || (vt.weapons[c].armed < __VTOL_RETURN_ARMED) || (vt.health < __VTOL_RETURN_HEALTH)) { orderDroidLoc(vt, DORDER_MOVE, __camVtolDataSystem[idx].exitPosition.x, __camVtolDataSystem[idx].exitPosition.y); break; diff --git a/script/campaign/transitionTech.js b/script/campaign/transitionTech.js index 9b3b8ff..50f5921 100644 --- a/script/campaign/transitionTech.js +++ b/script/campaign/transitionTech.js @@ -1,7 +1,7 @@ //Contains the campaign transition technology definitions. //This array should give a player all the research from Alpha. -const ALPHA_RESEARCH_NEW = [ +const mis_alphaResearchNew = [ // 1 "R-Wpn-MG1Mk1", "R-Vehicle-Body01", "R-Sys-Spade1Mk1", "R-Vehicle-Prop-Wheels", "R-Sys-MobileRepairTurret01", "R-Sys-Engineering01", "R-Wpn-Flamer01Mk1", "R-Wpn-MG-Damage01", @@ -65,7 +65,7 @@ const ALPHA_RESEARCH_NEW = [ ]; //Basic base structures. -const STRUCTS_ALPHA = [ +const mis_structsAlpha = [ "A0CommandCentre", "A0PowerGenerator", "A0ResourceExtractor", @@ -75,14 +75,14 @@ const STRUCTS_ALPHA = [ //BETA 2-A bonus research -const PLAYER_RES_BETA = [ +const mis_playerResBeta = [ "R-Wpn-AAGun03", "R-Defense-AASite-QuadMg1", "R-Sys-Sensor-Tower02", ]; //This array should give a player all the research from Beta. -const BETA_RESEARCH_NEW = [ +const mis_betaResearchNew = [ // 1 "R-Sys-Engineering02", "R-Sys-Sensor-Upgrade01", "R-Wpn-MG-ROF02", "R-Wpn-Cannon-Damage04", "R-Wpn-Rocket-Damage04", "R-Wpn-AAGun-Damage03", @@ -146,9 +146,9 @@ const BETA_RESEARCH_NEW = [ ]; //This is used for giving allies in Gamma technology (3-b/3-2/3-c) -const GAMMA_ALLY_RES = ALPHA_RESEARCH_NEW.concat(PLAYER_RES_BETA).concat(BETA_RESEARCH_NEW); +const mis_gammaAllyRes = mis_alphaResearchNew.concat(mis_playerResBeta).concat(mis_betaResearchNew); -const GAMMA_RESEARCH_NEW = [ +const mis_gammaResearchNew = [ //1 "R-Wpn-Howitzer03-Rot", "R-Wpn-MG-Damage09", "R-Struc-Power-Upgrade02", "R-Sys-Engineering03", "R-Wpn-Cannon-Damage08", "R-Wpn-AAGun-Damage06", "R-Defense-WallUpgrade07", "R-Defense-WallUpgrade08", diff --git a/wrf/cam2/sub2-5/dinit.bjo b/wrf/cam2/sub2-5/dinit.bjo index 06ae18e..f75813d 100644 Binary files a/wrf/cam2/sub2-5/dinit.bjo and b/wrf/cam2/sub2-5/dinit.bjo differ diff --git a/wrf/cam2/sub2-5/droid.ini b/wrf/cam2/sub2-5/droid.ini index efdf4b4..f1a7f12 100644 --- a/wrf/cam2/sub2-5/droid.ini +++ b/wrf/cam2/sub2-5/droid.ini @@ -1,3 +1,17 @@ +[droid_656] +id = 656 +startpos = 2 +template = CO-M-ROTMG-T +position = 6552, 1098, 0 +rotation = 0, 0, 0 + +[droid_657] +id = 657 +startpos = 2 +template = CO-H-HPVCannon-Tracks +position = 1532, 2998, 0 +rotation = 0, 0, 0 + [droid_459] id = 459 startpos = 2 @@ -348,17 +362,3 @@ template = CO-M-ROTMG-T position = 6104, 1028, 0 rotation = 0, 0, 0 -[droid_656] -id = 656 -startpos = 2 -template = CO-M-ROTMG-T -position = 6552, 1098, 0 -rotation = 0, 0, 0 - -[droid_657] -id = 657 -startpos = 2 -template = CO-H-HPVCannon-Tracks -position = 1532, 2998, 0 -rotation = 0, 0, 0 - diff --git a/wrf/cam2/sub2-5/feature.ini b/wrf/cam2/sub2-5/feature.ini index 07f1c47..55f8189 100644 --- a/wrf/cam2/sub2-5/feature.ini +++ b/wrf/cam2/sub2-5/feature.ini @@ -670,3 +670,51 @@ position = 2752, 3264, 0 rotation = 0, 0, 0 name = building1 +[feature_673] +id = 673 +position = 448, 1344, 0 +rotation = 0, 0, 0 +name = OilDrum + +[feature_674] +id = 674 +position = 320, 1216, 0 +rotation = 0, 0, 0 +name = OilDrum + +[feature_675] +id = 675 +position = 320, 1088, 0 +rotation = 0, 0, 0 +name = OilDrum + +[feature_676] +id = 676 +position = 576, 960, 0 +rotation = 0, 0, 0 +name = OilDrum + +[feature_677] +id = 677 +position = 7744, 7232, 0 +rotation = 0, 0, 0 +name = OilDrum + +[feature_678] +id = 678 +position = 7616, 7488, 0 +rotation = 0, 0, 0 +name = OilDrum + +[feature_679] +id = 679 +position = 7616, 7360, 0 +rotation = 0, 0, 0 +name = OilDrum + +[feature_680] +id = 680 +position = 7744, 7360, 0 +rotation = 0, 0, 0 +name = OilDrum + diff --git a/wrf/cam2/sub2-5/game.map b/wrf/cam2/sub2-5/game.map index 946dc07..57ade72 100644 Binary files a/wrf/cam2/sub2-5/game.map and b/wrf/cam2/sub2-5/game.map differ diff --git a/wrf/cam2/sub2-5/struct.bjo b/wrf/cam2/sub2-5/struct.bjo index e26c256..4b5c2a5 100644 Binary files a/wrf/cam2/sub2-5/struct.bjo and b/wrf/cam2/sub2-5/struct.bjo differ diff --git a/wrf/cam2/sub2-5/struct.ini b/wrf/cam2/sub2-5/struct.ini index f190dca..48fc999 100644 --- a/wrf/cam2/sub2-5/struct.ini +++ b/wrf/cam2/sub2-5/struct.ini @@ -582,22 +582,6 @@ position = 5568, 1344, 0 rotation = 0, 0, 0 modules = 0 -[structure_356] -id = 356 -startpos = 2 -name = PillBox1 -position = 1344, 3776, 0 -rotation = 0, 0, 0 -modules = 0 - -[structure_357] -id = 357 -startpos = 2 -name = PillBox1 -position = 1728, 3776, 0 -rotation = 0, 0, 0 -modules = 0 - [structure_358] id = 358 startpos = 2 @@ -1110,11 +1094,11 @@ position = 6720, 2112, 0 rotation = 0, 0, 0 modules = 0 -[structure_682] -id = 682 +[structure_581] +id = 581 startpos = 2 -name = A0HardcreteMk1Gate -position = 7616, 2240, 0 +name = CollectiveWall +position = 7616, 3648, 0 rotation = 0, 0, 0 modules = 0 @@ -1497,96 +1481,48 @@ modules = 0 [structure_671] id = 671 startpos = 2 -name = A0HardcreteMk1Gate -position = 3520, 1600, 0 -rotation = 16384, 0, 0 +name = Pillbox-RotMG +position = 1344, 3776, 0 +rotation = 0, 0, 0 modules = 0 [structure_672] id = 672 startpos = 2 -name = A0HardcreteMk1Gate -position = 3520, 1728, 0 -rotation = 16384, 0, 0 +name = Pillbox-RotMG +position = 1728, 3776, 0 +rotation = 0, 0, 0 modules = 0 -[structure_673] -id = 673 +[structure_684] +id = 684 startpos = 2 name = A0HardcreteMk1Gate -position = 5696, 1600, 0 +position = 3520, 1728, 0 rotation = 16384, 0, 0 modules = 0 -[structure_674] -id = 674 +[structure_681] +id = 681 startpos = 2 name = A0HardcreteMk1Gate -position = 5696, 1728, 0 +position = 5696, 1600, 0 rotation = 16384, 0, 0 modules = 0 -[structure_675] -id = 675 +[structure_683] +id = 683 startpos = 2 name = A0HardcreteMk1Gate -position = 6464, 1856, 0 +position = 3520, 1600, 0 rotation = 16384, 0, 0 modules = 0 -[structure_676] -id = 676 +[structure_682] +id = 682 startpos = 2 name = A0HardcreteMk1Gate -position = 7232, 1856, 0 +position = 5696, 1728, 0 rotation = 16384, 0, 0 modules = 0 -[structure_677] -id = 677 -startpos = 2 -name = A0HardcreteMk1Gate -position = 5952, 2240, 0 -rotation = 0, 0, 0 -modules = 0 - -[structure_678] -id = 678 -startpos = 2 -name = A0HardcreteMk1Gate -position = 5952, 5056, 0 -rotation = 0, 0, 0 -modules = 0 - -[structure_679] -id = 679 -startpos = 2 -name = A0HardcreteMk1Gate -position = 5952, 3392, 0 -rotation = 0, 0, 0 -modules = 0 - -[structure_680] -id = 680 -startpos = 2 -name = A0HardcreteMk1Gate -position = 5952, 3008, 0 -rotation = 0, 0, 0 -modules = 0 - -[structure_681] -id = 681 -startpos = 2 -name = A0HardcreteMk1Gate -position = 7616, 3136, 0 -rotation = 0, 0, 0 -modules = 0 - -[structure_683] -id = 683 -startpos = 2 -name = A0HardcreteMk1Gate -position = 7616, 3648, 0 -rotation = 0, 0, 0 -modules = 0 - diff --git a/wrf/cam2/sub2-d/feat.bjo b/wrf/cam2/sub2-d/feat.bjo index 5d90604..6df8f2e 100644 Binary files a/wrf/cam2/sub2-d/feat.bjo and b/wrf/cam2/sub2-d/feat.bjo differ diff --git a/wrf/cam2/sub2-d/labels.json b/wrf/cam2/sub2-d/labels.json index 1fd68f2..df4a34b 100644 --- a/wrf/cam2/sub2-d/labels.json +++ b/wrf/cam2/sub2-d/labels.json @@ -88,7 +88,7 @@ }, "object_2": { "label": "COHeavyFactoryA", - "id": 4218, + "id": 4378, "player": 2, "type": 1 }, @@ -100,7 +100,7 @@ }, "object_4": { "label": "COResearchLab", - "id": 4175, + "id": 4172, "player": 2, "type": 1 }, @@ -112,19 +112,19 @@ }, "object_6": { "label": "COHeavyFactoryB", - "id": 4219, + "id": 4380, "player": 2, "type": 1 }, "object_7": { "label": "COHeavyFactoryC", - "id": 4220, + "id": 4376, "player": 2, "type": 1 }, "object_8": { "label": "COHeavyFactoryD", - "id": 4221, + "id": 4374, "player": 2, "type": 1 }, diff --git a/wrf/cam2/sub2-d/struct.bjo b/wrf/cam2/sub2-d/struct.bjo index 39bc691..f7b899f 100644 Binary files a/wrf/cam2/sub2-d/struct.bjo and b/wrf/cam2/sub2-d/struct.bjo differ diff --git a/wrf/cam3/cam3b/dinit.bjo b/wrf/cam3/cam3b/dinit.bjo index 225faa4..01f6fd0 100644 Binary files a/wrf/cam3/cam3b/dinit.bjo and b/wrf/cam3/cam3b/dinit.bjo differ diff --git a/wrf/cam3/cam3b/droid.ini b/wrf/cam3/cam3b/droid.ini index f1278d5..ced0aa1 100644 --- a/wrf/cam3/cam3b/droid.ini +++ b/wrf/cam3/cam3b/droid.ini @@ -229,36 +229,36 @@ template = NX-Cyb-Rail1-JUMP position = 3408, 7702, 0 rotation = 0, 0, 0 -[droid_1628] -id = 1628 +[droid_1648] +id = 1648 startpos = 1 template = Cyb-RotMG-GROUND position = 1984, 1344, 0 rotation = 11651, 0, 0 -[droid_1629] -id = 1629 +[droid_1649] +id = 1649 startpos = 1 template = Cyb-RotMG-GROUND position = 1856, 1344, 0 rotation = 49334, 0, 0 -[droid_1630] -id = 1630 +[droid_1650] +id = 1650 startpos = 1 template = Cyb-RotMG-GROUND position = 1856, 1088, 0 rotation = 53339, 0, 0 -[droid_1631] -id = 1631 +[droid_1651] +id = 1651 startpos = 1 template = Cyb-RotMG-GROUND position = 1600, 1344, 0 rotation = 28035, 0, 0 -[droid_1632] -id = 1632 +[droid_1652] +id = 1652 startpos = 1 template = Cyb-Rocket-GROUND position = 1600, 704, 0 diff --git a/wrf/cam3/cam3b/feat.bjo b/wrf/cam3/cam3b/feat.bjo index cf9d9de..d0b4b6f 100644 Binary files a/wrf/cam3/cam3b/feat.bjo and b/wrf/cam3/cam3b/feat.bjo differ diff --git a/wrf/cam3/cam3b/game.map b/wrf/cam3/cam3b/game.map index 0759c6c..1a6be2b 100644 Binary files a/wrf/cam3/cam3b/game.map and b/wrf/cam3/cam3b/game.map differ diff --git a/wrf/cam3/cam3b/labels.json b/wrf/cam3/cam3b/labels.json index b3d5c44..9fd7c04 100644 --- a/wrf/cam3/cam3b/labels.json +++ b/wrf/cam3/cam3b/labels.json @@ -159,7 +159,7 @@ }, "object_2": { "label": "gammaFactory", - "id": 432, + "id": 1647, "player": 1, "type": 1 }, @@ -171,7 +171,7 @@ }, "object_4": { "label": "gammaResLabArti", - "id": 143, + "id": 1644, "player": 1, "type": 1 }, diff --git a/wrf/cam3/cam3b/struct.bjo b/wrf/cam3/cam3b/struct.bjo index 3437b36..c817a9d 100644 Binary files a/wrf/cam3/cam3b/struct.bjo and b/wrf/cam3/cam3b/struct.bjo differ diff --git a/wrf/cam3/cam3b/ttypes.ttp b/wrf/cam3/cam3b/ttypes.ttp index 7bfabc1..b35b048 100644 Binary files a/wrf/cam3/cam3b/ttypes.ttp and b/wrf/cam3/cam3b/ttypes.ttp differ