From 80502be9b2391a34718f4f79e7587fbd3c9c55e5 Mon Sep 17 00:00:00 2001 From: KJeff01 Date: Tue, 26 Sep 2017 13:46:08 -0500 Subject: [PATCH] Campaign library and script fixes. -Count only finished structures during base elimination. -Filter out targets that enemy groups can not reach. -Fix CAM_ORDER_DEFENSE so that the units no longer get distracted by anything and are more determined to get to the defense position. -cam1-7: Artifact group is not forced to be grouped again. Use the original two minute trigger time again. -cam1-d: Transporter reinforcement time should be two minutes, not one. Do not remove the objective blip. -cam2-1: Use original LZ area coordinates. -cam2-c: Remove lancer template from VTOL factories. Ends even if all civilians do not make it to the player LZ, like in the WZScript version. Delay the rescue sound for a few seconds. Fix detect message for the bases. --- data/base/script/campaign/cam1-7.js | 8 ++--- data/base/script/campaign/cam1-d.js | 9 +++-- data/base/script/campaign/cam2-c.js | 42 +++++++++++++----------- data/base/script/campaign/libcampaign.js | 31 +++++++++++++---- data/base/wrf/cam2/sub2-1/labels.json | 2 +- 5 files changed, 56 insertions(+), 36 deletions(-) diff --git a/data/base/script/campaign/cam1-7.js b/data/base/script/campaign/cam1-7.js index f8dde25dedf..bda65d055c2 100644 --- a/data/base/script/campaign/cam1-7.js +++ b/data/base/script/campaign/cam1-7.js @@ -42,7 +42,7 @@ camAreaEvent("middleScavFactoryTrigger", function() camAreaEvent("NPWayPointTrigger", function() { camManageGroup(artiGroup, CAM_ORDER_DEFEND, - { pos: camMakePos("NPTransportPos"), regroup: true } + { pos: camMakePos("NPTransportPos"), regroup: false } ); }); @@ -72,7 +72,7 @@ camAreaEvent("artifactCheckNP", function() camCallOnce("removeCanyonBlip"); camManageGroup(artiGroup, CAM_ORDER_DEFEND, - { pos: camMakePos("NPWayPoint"), regroup: true } + { pos: camMakePos("NPWayPoint"), regroup: false } ); }); @@ -125,7 +125,7 @@ function eventGroupLoss(obj, group, newsize) function getArtifact() { camManageGroup(artiGroup, CAM_ORDER_DEFEND, - { pos: camMakePos("artifactLocation"), regroup: true } + { pos: camMakePos("artifactLocation"), regroup: false } ); } @@ -278,5 +278,5 @@ function eventStartLevel() hackAddMessage("C1-7_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER, true); //Canyon queue("enableReinforcements", 15000); - queue("getArtifact", 15000); + queue("getArtifact", 120000); } diff --git a/data/base/script/campaign/cam1-d.js b/data/base/script/campaign/cam1-d.js index b8470281aee..6ae08c1738a 100644 --- a/data/base/script/campaign/cam1-d.js +++ b/data/base/script/campaign/cam1-d.js @@ -21,7 +21,6 @@ camAreaEvent("tankTrapTrig", function() camEnableFactory("NPFactoryE"); camEnableFactory("NPCybFactoryE"); mrlGroupAttack(); - hackRemoveMessage("C1D_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER); }); camAreaEvent("causeWayTrig", function() @@ -29,7 +28,7 @@ camAreaEvent("causeWayTrig", function() camEnableFactory("NPFactoryNE"); camEnableFactory("NPCybFactoryNE"); cyborgGroupPatrol(); - + camDetectEnemyBase("NPLZGroup"); camSetBaseReinforcements("NPLZGroup", camChangeOnDiff(600000), "getDroidsForNPLZ", CAM_REINFORCE_TRANSPORT, { @@ -140,7 +139,7 @@ function enableReinforcements() camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, "CAM_1END", { area: "RTLZ", message: "C1D_LZ", - reinforcements: 60 //1 min + reinforcements: 120 //2 min }); } @@ -252,8 +251,8 @@ function eventStartLevel() }, }); - hackAddMessage("C1D_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER, true); //hover arti + hackAddMessage("C1D_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER, true); queue("enableReinforcements", 10000); - queue("setupPatrols", 120000); // 2 min. + queue("setupPatrols", 160000); // 2.5 min. } diff --git a/data/base/script/campaign/cam2-c.js b/data/base/script/campaign/cam2-c.js index 1476f855c1d..e5555ab4176 100644 --- a/data/base/script/campaign/cam2-c.js +++ b/data/base/script/campaign/cam2-c.js @@ -2,10 +2,11 @@ include("script/campaign/libcampaign.js"); include("script/campaign/templates.js"); -const civilians = 7; //Civilian player number. +const CIVILIAN = 7; //Civilian player number. 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 = [ "R-Defense-WallUpgrade03", "R-Struc-Materials04", "R-Struc-Factory-Upgrade04", "R-Struc-VTOLFactory-Upgrade01", @@ -147,12 +148,12 @@ function captureCivilians() var num = 1 + camRand(3); for (var i = 0; i < num; ++i) { - addDroid(civilians, currPos.x, currPos.y, "Civilian", + addDroid(CIVILIAN, 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, civilians, false); + var civs = enumArea(0, 0, 35, mapHeight, CIVILIAN, false); //Move them for (var i = 0; i < civs.length; ++i) { @@ -182,13 +183,15 @@ function civilianOrders() { var lz = getObject("startPosition"); var rescueSound = "pcv612.ogg"; //"Civilian Rescued". - var civs = enumDroid(civilians); + var civs = enumDroid(CIVILIAN); var rescued = false; //Check if a civilian is close to a player droid. for (var i = 0; i < civs.length; ++i) { - var pDroids = enumRange(civs[i].x, civs[i].y, 6, CAM_HUMAN_PLAYER, false); + var pDroids = enumRange(civs[i].x, civs[i].y, 6, CAM_HUMAN_PLAYER, false).filter(function(obj) { + return obj.type === DROID; + }); if (pDroids.length) { rescued = true; @@ -196,8 +199,10 @@ function civilianOrders() } } - if (rescued === true) + //Play the "Civilian rescued" sound and throttle it for ten seconds. + if (rescued && ((lastSoundTime + 10000) < gameTime)) { + lastSoundTime = gameTime; playSound(rescueSound); } @@ -209,7 +214,7 @@ function eventTransporterLanded(transport) { var escaping = "pcv632.ogg"; //"Enemy escaping". var position = getObject("COTransportPos"); - var civs = enumRange(position.x, position.y, 15, civilians, false); + var civs = enumRange(position.x, position.y, 15, CIVILIAN, false); if (civs.length) { @@ -253,17 +258,15 @@ function extraVictoryCondition() else { var lz = getObject("startPosition"); - var civs = enumRange(lz.x, lz.y, 30, civilians, false); + var civs = enumRange(lz.x, lz.y, 30, CIVILIAN, false); for (var i = 0; i < civs.length; ++i) { camSafeRemoveObject(civs[i], false); } - if (!enumArea(0, 0, mapWidth, mapHeight, civilians, false).length) - { - return true; - } + //Win regardless if all civilians do not make it to the LZ. + return true; } } @@ -290,27 +293,27 @@ function eventStartLevel() setPower(camChangeOnDiff(200000, true), THE_COLLECTIVE); setMissionTime(camChangeOnDiff(7200)); //120 min - setAlliance(THE_COLLECTIVE, civilians, true); - setAlliance(CAM_HUMAN_PLAYER, civilians, true); + setAlliance(THE_COLLECTIVE, CIVILIAN, true); + setAlliance(CAM_HUMAN_PLAYER, CIVILIAN, true); camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE); camSetEnemyBases({ "COAirBase": { cleanup: "airBaseCleanup", detectMsg: "C2C_BASE1", - detectSnd: "pcv393.ogg", + detectSnd: "pcv379.ogg", eliminateSnd: "pcv394.ogg", }, "COCyborgBase": { cleanup: "cyborgBaseCleanup", detectMsg: "C2C_BASE2", - detectSnd: "pcv393.ogg", + detectSnd: "pcv379.ogg", eliminateSnd: "pcv394.ogg", }, "COtransportBase": { cleanup: "transportBaseCleanup", detectMsg: "C2C_BASE3", - detectSnd: "pcv393.ogg", + detectSnd: "pcv379.ogg", eliminateSnd: "pcv394.ogg", }, }); @@ -354,7 +357,7 @@ function eventStartLevel() throttle: camChangeOnDiff(100000), regroup: false, repair: 40, - templates: [commorv, colagv, colatv] + templates: [commorv, colagv] }, "COVtolFacRight": { order: CAM_ORDER_ATTACK, @@ -362,7 +365,7 @@ function eventStartLevel() throttle: camChangeOnDiff(100000), regroup: false, repair: 40, - templates: [colatv, colagv, commorv] + templates: [colagv, commorv] }, }); @@ -370,6 +373,7 @@ function eventStartLevel() truckDefense(); capturedCivCount = 0; civilianPosIndex = 0; + lastSoundTime = 0; shepardGroup = camMakeGroup("heavyGroup2"); enableFactories(); diff --git a/data/base/script/campaign/libcampaign.js b/data/base/script/campaign/libcampaign.js index 2fdf9f1afde..d42c4f1277d 100644 --- a/data/base/script/campaign/libcampaign.js +++ b/data/base/script/campaign/libcampaign.js @@ -1167,6 +1167,7 @@ function __camCheckBaseEliminated(group) var nonLeftovers = enumArea(bi.cleanup).filter(function(obj) { return (obj.player !== CAM_HUMAN_PLAYER && obj.type === STRUCTURE + && obj.status === BUILT && !__camIsValidLeftover(obj) && (!camDef(bi.player) || (camDef(bi.player) && camPlayerMatchesFilter(obj.player, bi.player))) @@ -1175,6 +1176,7 @@ function __camCheckBaseEliminated(group) var leftovers = enumArea(bi.cleanup).filter(function(obj) { return (obj.player !== CAM_HUMAN_PLAYER && obj.type === STRUCTURE + && obj.status === BUILT && __camIsValidLeftover(obj) && (!camDef(bi.player) || (camDef(bi.player) && camPlayerMatchesFilter(obj.player, bi.player))) @@ -1498,6 +1500,7 @@ function __camPickTarget(group) { var targets = []; var gi = __camGroupInfo[group]; + var droids = enumGroup(group); switch(gi.order) { case CAM_ORDER_ATTACK: @@ -1529,10 +1532,13 @@ function __camPickTarget(group) else targets = [ gi.data.pos[gi.data.pos.length - 1] ]; } - if (!targets.length) - targets = enumStruct(CAM_HUMAN_PLAYER); + targets = targets.filter(function(obj) { + return propulsionCanReach(droids[0].propulsion, droids[0].x, droids[0].y, obj.x, obj.y); + }); if (!targets.length) targets = enumDroid(CAM_HUMAN_PLAYER); + if (!targets.length) + targets = enumStruct(CAM_HUMAN_PLAYER); break; case CAM_ORDER_DEFEND: if (!camDef(gi.data.pos)) @@ -1648,7 +1654,7 @@ function __camTacticsTickForGroup(group) var droid = droids[i]; if (back) orderDroid(droid, DORDER_RTB); - else if (droid.order !== DORDER_MOVE) // to assembly point? + else orderDroid(droid, DORDER_STOP); } return; @@ -1705,6 +1711,7 @@ function __camTacticsTickForGroup(group) } if (camDist(droid, target) >= __CAM_CLOSE_RADIUS) { + var defending = gi.order === CAM_ORDER_DEFEND; var rng = droid.droidType === DROID_SENSOR ? 10 : 5; var closeBy = enumRange(droid.x, droid.y, rng, CAM_HUMAN_PLAYER, false); closeBy = closeBy.sort(function(obj1, obj2) { @@ -1715,17 +1722,27 @@ function __camTacticsTickForGroup(group) if (droid.droidType === DROID_SENSOR) { - if (camDef(closeBy[0])) + if (!defending && camDef(closeBy[0])) orderDroidObj(droid, DORDER_OBSERVE, closeBy[0]); else - orderDroidLoc(droid, DORDER_SCOUT, target.x, target.y); + { + if (!defending) + orderDroidLoc(droid, DORDER_SCOUT, target.x, target.y); + else + orderDroidLoc(droid, DORDER_MOVE, target.x, target.y); + } } else { - if (camDef(closeBy[0])) + if (!defending && camDef(closeBy[0])) orderDroidObj(droid, DORDER_ATTACK, closeBy[0]); else - orderDroidLoc(droid, DORDER_SCOUT, target.x, target.y); + { + if (!defending) + orderDroidLoc(droid, DORDER_SCOUT, target.x, target.y); + else + orderDroidLoc(droid, DORDER_MOVE, target.x, target.y); + } } } } diff --git a/data/base/wrf/cam2/sub2-1/labels.json b/data/base/wrf/cam2/sub2-1/labels.json index 12a17a29bd2..510b9434b9a 100644 --- a/data/base/wrf/cam2/sub2-1/labels.json +++ b/data/base/wrf/cam2/sub2-1/labels.json @@ -13,7 +13,7 @@ "area_4" : { "label" : "bunkerBaseCleanup", "pos1" : [ 512, 384 ], "pos2" : [ 2304, 3200 ]}, "area_5" : { "label" : "hardpointBaseCleanup", "pos1" : [ 2432, 3456 ], "pos2" : [ 4480, 5888 ]}, "area_6" : { "label" : "bombardBaseCleanup", "pos1" : [ 4608, 4992 ], "pos2" : [ 7808, 7680 ]}, - "area_7" : { "label" : "RTLZ", "pos1" : [ 200, 5800 ], "pos2" : [ 1700, 7800 ]}, + "area_7" : { "label" : "RTLZ", "pos1" : [ 192, 6720 ], "pos2" : [ 1856, 8000 ]}, "object_0": { "label": "transporter", "id": 751, "player": 1, "type": 1 } }