Skip to content

Commit

Permalink
Make cam1-7 behave closer to WZScript versions.
Browse files Browse the repository at this point in the history
- Artifact group will run back to the artifact when dropped and pick it up again.
- Artifact is dropped by the enemy droid that was the closest to pick it up.

Make bombard pit available only from Beta campaign onwards.
  • Loading branch information
KJeff01 committed Feb 11, 2018
1 parent e02cc41 commit 21ad2f9
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 52 deletions.
134 changes: 90 additions & 44 deletions data/base/script/campaign/cam1-7.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ const NEW_PARADIGM_RESEARCH = [
const SCAVENGER_RES = [
"R-Wpn-MG-Damage03", "R-Wpn-Rocket-Damage02", "R-Wpn-Cannon-Damage02",
];
var artiGroup;
var enemyHasArtifact;
var enemyStoleArtifact;
var artiGroup; //Droids that take the artifact
var enemyHasArtifact; //Do they have the artifact
var enemyStoleArtifact; //Reached the LZ with the artifact
var droidWithArtiID; //The droid ID that was closest to the artifact to take it
var artiMovePos; //where artiGroup members are moving to


//These enable scav factories when close enough
Expand All @@ -41,10 +43,7 @@ camAreaEvent("middleScavFactoryTrigger", function()
//New Paradigm landing zone.
camAreaEvent("NPWayPointTrigger", function()
{
camManageGroup(artiGroup, CAM_ORDER_DEFEND, {
pos: camMakePos("NPTransportPos"),
regroup: false
});
artiMovePos = "NPTransportPos";
});

//Land New Paradigm transport if the New Paradigm have the artifact.
Expand All @@ -62,75 +61,107 @@ camAreaEvent("NPTransportTrigger", function()
}
});

camAreaEvent("artifactCheckNP", function()
//Only called once when the New Paradigm takes the artifact for the first time.
function artifactVideoSetup()
{
enemyHasArtifact = true;
var artifact = camGetArtifacts();
camSafeRemoveObject(artifact[0], false);

camPlayVideos("SB1_7_MSG3");
hackAddMessage("C1-7_LZ2", PROX_MSG, CAM_HUMAN_PLAYER, true); //NPLZ blip
camCallOnce("removeCanyonBlip");

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

//Remove nearby droids. Make sure the player loses if the NP still has the artifact
//by the time it lands.
function eventTransporterLanded(transport)
{
if ((transport.player === NEW_PARADIGM) && enemyHasArtifact)
if (transport.player === NEW_PARADIGM && enemyHasArtifact)
{
enemyStoleArtifact = true;
var crew = enumRange(transport.x, transport.y, 6, NEW_PARADIGM, false).filter(function(obj) {
return obj.type === DROID && obj.group === artiGroup;
});
for (var i = 0, l = crew.length; i < l; ++i)
{
var obj = crew[i];
camSafeRemoveObject(obj, false);
camSafeRemoveObject(crew[i], false);
}
}
}

function eventTransporterExit(transport)
//Check if the artifact group members are still alive and drop the artifact if needed.
function eventGroupLoss(obj, group, newsize)
{
if (transport.player === NEW_PARADIGM)
if (group === artiGroup && enemyHasArtifact && !enemyStoleArtifact)
{
if (enemyStoleArtifact)
if (obj.id === droidWithArtiID)
{
gameOverMessage(false);
var acrate = addFeature("Crate", obj.x, obj.y);
addLabel(acrate, "newArtiLabel");

camSetArtifacts({
"newArtiLabel": { tech: "R-Wpn-Cannon3Mk1" }
});

droidWithArtiID = undefined;
enemyHasArtifact = false;
hackRemoveMessage("C1-7_LZ2", PROX_MSG, CAM_HUMAN_PLAYER);
}
}
}

//Check if the artifact group member are still alive and drop the artifact if needed.
function eventGroupLoss(obj, group, newsize)
//Moves some New Paradigm forces to the artifact
function getArtifact()
{
if ((group === artiGroup) && !newsize && enemyHasArtifact && !enemyStoleArtifact)
if (groupSize(artiGroup) === 0)
{
var acrate = addFeature("Crate", obj.x, obj.y);
addLabel(acrate, "newArtiPos");
return;
}

camSetArtifacts({
"newArtiPos": { tech: "R-Wpn-Cannon3Mk1" },
});
var artifact = camGetArtifacts();
var artiLoc = artiMovePos;

enemyHasArtifact = false;
hackRemoveMessage("C1-7_LZ2", PROX_MSG, CAM_HUMAN_PLAYER);
if (!enemyHasArtifact && !enemyStoleArtifact && artifact.length > 0)
{
//Go to the artifact instead.
artiLoc = camMakePos(artifact[0]);
if (!camDef(artiLoc))
{
return; //player must have snatched it
}

//Find the one closest to the artifact so that one can "hold" it
var artiMembers = enumGroup(artiGroup);
var idx = 0;
var dist = Infinity;

for (var i = 0, l = artiMembers.length; i < l; ++i)
{
var drDist = camDist(artiMembers[i], artiLoc);
if (drDist < dist)
{
idx = i;
dist = drDist;
}
}

//Now take it if close enough
if (camDist(artiMembers[idx], artiLoc) < 2)
{
camCallOnce("artifactVideoSetup");
hackAddMessage("C1-7_LZ2", PROX_MSG, CAM_HUMAN_PLAYER, true); //NPLZ blip
droidWithArtiID = artiMembers[idx].id;
enemyHasArtifact = true;
camSafeRemoveObject(artifact[0], false);
}
}
}

//Moves some New Paradigm forces to the artifact
function getArtifact()
{
camManageGroup(artiGroup, CAM_ORDER_DEFEND, {
pos: camMakePos("artifactLocation"),
regroup: false
});
if (camDef(artiLoc))
{
camManageGroup(artiGroup, CAM_ORDER_DEFEND, {
pos: artiLoc,
regroup: false
});
}

queue("getArtifact", 150);
}

//New Paradigm truck builds six lancer hardpoints around LZ
Expand All @@ -145,6 +176,20 @@ function buildLancers()
//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) {
if (camIsTransporter(dr))
{
npTransportFound = true;
}
});

//fail if they stole it and the transporter is not on map anymore
if (enemyStoleArtifact && !npTransportFound)
{
return false;
}

if (!enumDroid(NEW_PARADIGM).length)
{
return true;
Expand Down Expand Up @@ -277,6 +322,7 @@ function eventStartLevel()
});

artiGroup = camMakeGroup(enumArea("NPArtiGroup", NEW_PARADIGM, false));
droidWithArtiID = 0;
camManageTrucks(NEW_PARADIGM);
buildLancers();

Expand Down
9 changes: 8 additions & 1 deletion data/base/script/campaign/libcampaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,14 @@ function camGetArtifacts()
{
if (camDef(__camArtifacts[alabel]))
{
camArti.push(__camGetArtifactLabel(alabel));
if (getObject(__camGetArtifactLabel(alabel)))
{
camArti.push(__camGetArtifactLabel(alabel));
}
else
{
camArti.push(alabel);
}
}
}
return camArti;
Expand Down
1 change: 1 addition & 0 deletions data/base/stats/research.json
Original file line number Diff line number Diff line change
Expand Up @@ -3413,6 +3413,7 @@
"R-Defense-HvyMor": {
"iconID": "IMAGE_RES_DEFENCE",
"id": "R-Defense-HvyMor",
"keyTopic": 1,
"msgName": "RES_EMP_HvyMor",
"name": "Bombard Pit",
"redStructures": [
Expand Down
8 changes: 1 addition & 7 deletions data/base/wrf/cam1/sub1-7/labels.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,12 @@
"radius": 1344
},
"radius_3": {
"label": "artifactCheckNP",
"subscriber": 1,
"pos": [1344, 3904],
"radius": 220
},
"radius_4": {
"label": "NPWayPointTrigger",
"subscriber": 1,
"pos": [5760, 768],
"radius": 500
},
"radius_5": {
"radius_4": {
"label": "NPTransportTrigger",
"subscriber": 1,
"pos": [1190, 1352],
Expand Down

0 comments on commit 21ad2f9

Please sign in to comment.