Skip to content

Commit

Permalink
Campaign library and script fixes.
Browse files Browse the repository at this point in the history
-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.
  • Loading branch information
KJeff01 committed Sep 29, 2017
1 parent 81c95fd commit 80502be
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 36 deletions.
8 changes: 4 additions & 4 deletions data/base/script/campaign/cam1-7.js
Expand Up @@ -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 }
);
});

Expand Down Expand Up @@ -72,7 +72,7 @@ camAreaEvent("artifactCheckNP", function()
camCallOnce("removeCanyonBlip");

camManageGroup(artiGroup, CAM_ORDER_DEFEND,
{ pos: camMakePos("NPWayPoint"), regroup: true }
{ pos: camMakePos("NPWayPoint"), regroup: false }
);
});

Expand Down Expand Up @@ -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 }
);
}

Expand Down Expand Up @@ -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);
}
9 changes: 4 additions & 5 deletions data/base/script/campaign/cam1-d.js
Expand Up @@ -21,15 +21,14 @@ camAreaEvent("tankTrapTrig", function()
camEnableFactory("NPFactoryE");
camEnableFactory("NPCybFactoryE");
mrlGroupAttack();
hackRemoveMessage("C1D_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER);
});

camAreaEvent("causeWayTrig", function()
{
camEnableFactory("NPFactoryNE");
camEnableFactory("NPCybFactoryNE");
cyborgGroupPatrol();

camDetectEnemyBase("NPLZGroup");
camSetBaseReinforcements("NPLZGroup", camChangeOnDiff(600000), "getDroidsForNPLZ",
CAM_REINFORCE_TRANSPORT, {
Expand Down Expand Up @@ -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
});
}

Expand Down Expand Up @@ -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.
}
42 changes: 23 additions & 19 deletions data/base/script/campaign/cam2-c.js
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -182,22 +183,26 @@ 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;
orderDroidLoc(civs[i], DORDER_MOVE, lz.x, lz.y);
}
}

if (rescued === true)
//Play the "Civilian rescued" sound and throttle it for ten seconds.
if (rescued && ((lastSoundTime + 10000) < gameTime))
{
lastSoundTime = gameTime;
playSound(rescueSound);
}

Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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",
},
});
Expand Down Expand Up @@ -354,22 +357,23 @@ function eventStartLevel()
throttle: camChangeOnDiff(100000),
regroup: false,
repair: 40,
templates: [commorv, colagv, colatv]
templates: [commorv, colagv]
},
"COVtolFacRight": {
order: CAM_ORDER_ATTACK,
groupSize: 5,
throttle: camChangeOnDiff(100000),
regroup: false,
repair: 40,
templates: [colatv, colagv, commorv]
templates: [colagv, commorv]
},
});

camManageTrucks(THE_COLLECTIVE);
truckDefense();
capturedCivCount = 0;
civilianPosIndex = 0;
lastSoundTime = 0;
shepardGroup = camMakeGroup("heavyGroup2");
enableFactories();

Expand Down
31 changes: 24 additions & 7 deletions data/base/script/campaign/libcampaign.js
Expand Up @@ -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)))
Expand All @@ -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)))
Expand Down Expand Up @@ -1498,6 +1500,7 @@ function __camPickTarget(group)
{
var targets = [];
var gi = __camGroupInfo[group];
var droids = enumGroup(group);
switch(gi.order)
{
case CAM_ORDER_ATTACK:
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion data/base/wrf/cam2/sub2-1/labels.json
Expand Up @@ -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 }
}

0 comments on commit 80502be

Please sign in to comment.