Skip to content

Commit

Permalink
Campaign updates
Browse files Browse the repository at this point in the history
  • Loading branch information
KJeff01 committed Apr 20, 2024
1 parent ef2fb5c commit dc90676
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 125 deletions.
22 changes: 9 additions & 13 deletions data/base/script/campaign/cam1-7.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const mis_newParadigmResClassic = [
const mis_scavengerResClassic = [
"R-Wpn-MG-Damage03", "R-Wpn-Rocket-Damage02"
];
const MIS_NEW_ARTI_LABEL = "newArtiLabel"; //Label for the picked-up artifact once dropped.
var artiGroup; //Droids that take the artifact
var enemyHasArtifact; //Do they have the artifact
var enemyStoleArtifact; //Reached the LZ with the artifact
Expand Down Expand Up @@ -109,20 +110,18 @@ function eventGroupLoss(obj, group, newsize)
{
if (obj.id === droidWithArtiID)
{
camDeleteArtifact("artifact1", false); //Clear original map-placed artifact if found.
//Setup the new artifact.
const acrate = addFeature(CAM_ARTIFACT_STAT, obj.x, obj.y);
addLabel(acrate, "newArtiLabel");
addLabel(acrate, MIS_NEW_ARTI_LABEL);

if (camClassicMode())
{
camSetArtifacts({
"newArtiLabel": { tech: "R-Wpn-Cannon3Mk1" }
});
camAddArtifact(MIS_NEW_ARTI_LABEL, "R-Wpn-Cannon3Mk1");
}
else
{
camSetArtifacts({
"newArtiLabel": { tech: ["R-Wpn-Cannon3Mk1", "R-Wpn-RocketSlow-Damage03"] }
});
camAddArtifact(MIS_NEW_ARTI_LABEL, ["R-Wpn-Cannon3Mk1", "R-Wpn-RocketSlow-Damage03"]);
}

droidWithArtiID = undefined;
Expand All @@ -134,7 +133,7 @@ function eventGroupLoss(obj, group, newsize)

function enemyCanTakeArtifact(label)
{
return label.indexOf("newArtiLabel") !== -1 || label.indexOf("artifactLocation") !== -1;
return label.indexOf(MIS_NEW_ARTI_LABEL) !== -1 || label.indexOf("artifact1") !== -1;
}

//Moves some New Paradigm forces to the artifact
Expand Down Expand Up @@ -284,16 +283,13 @@ function eventStartLevel()
//Make sure the New Paradigm and Scavs are allies
setAlliance(CAM_NEW_PARADIGM, CAM_SCAV_7, true);

//Get rid of the already existing crate and replace with another
camSafeRemoveObject("artifact1", false);

if (camClassicMode())
{
camClassicResearch(mis_newParadigmResClassic, CAM_NEW_PARADIGM);
camClassicResearch(mis_scavengerResClassic, CAM_SCAV_7);

camSetArtifacts({
"artifactLocation": { tech: "R-Wpn-Cannon3Mk1" },
"artifact1": { tech: "R-Wpn-Cannon3Mk1" },
});
}
else
Expand All @@ -316,7 +312,7 @@ function eventStartLevel()
}

camSetArtifacts({
"artifactLocation": { tech: ["R-Wpn-Cannon3Mk1", "R-Wpn-RocketSlow-Damage03"] },
"artifact1": { tech: ["R-Wpn-Cannon3Mk1", "R-Wpn-RocketSlow-Damage03"] },
});
}

Expand Down
4 changes: 1 addition & 3 deletions data/base/script/campaign/cam1-d.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ function eventStartLevel()
startTransporterEntry(tEnt.x, tEnt.y, CAM_HUMAN_PLAYER);
setTransporterExit(tExt.x, tExt.y, CAM_HUMAN_PLAYER);

//Get rid of the already existing crate and replace with another
camSafeRemoveObject("artifact1", false);
camSetArtifacts({
"artifactLocation": { tech: "R-Vehicle-Prop-Hover" }, //SE base
"artifact1": { tech: "R-Vehicle-Prop-Hover" }, //SE base
"NPFactoryW": { tech: "R-Vehicle-Metals03" }, //West factory
"NPFactoryNE": { tech: "R-Vehicle-Body12" }, //Main base factory
});
Expand Down
12 changes: 8 additions & 4 deletions data/base/script/campaign/cam3-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,9 @@ function missileSilosDestroyed()
//Nuclear missile destroys everything not in safe zone.
function nukeAndCountSurvivors()
{
//Avoid destroying the one base if the player opted not to destroy it themselves.
const nuked = enumArea(0, 0, mapWidth, mapHeight, ALL_PLAYERS, false).filter((obj) => (
obj.type !== STRUCTURE || (obj.type === STRUCTURE && obj.group === null)
));
// Remove the base in the rare event an auto-explosion triggers as we nuke the base here.
camSetEnemyBases({});
const nuked = enumArea(0, 0, mapWidth, mapHeight, ALL_PLAYERS, false);
const safeZone = enumArea("valleySafeZone", CAM_HUMAN_PLAYER, false);
let foundUnit = false;

Expand Down Expand Up @@ -270,6 +269,11 @@ function enableAllFactories()
//For now just make sure we have all the droids in the canyon.
function unitsInValley()
{
if (!camAllArtifactsPickedUp())
{
return;
}

const safeZone = enumArea("valleySafeZone", CAM_HUMAN_PLAYER, false).filter((obj) => (
obj.type === DROID
));
Expand Down
99 changes: 85 additions & 14 deletions data/base/script/campaign/libcampaign_includes/artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//;; The argument is a JavaScript map from object labels to artifact description.
//;; If the label points to a game object, artifact will be placed when this object
//;; is destroyed; if the label is a position, the artifact will be placed instantly.
//;; The label can point to a pre-existing feature artifact on the map too.
//;; Artifact description is a JavaScript object with the following fields:
//;; * `tech` The technology to grant when the artifact is recovered.
//;; Note that this can be made into an array to make artifacts give out
Expand All @@ -27,22 +28,64 @@ function camSetArtifacts(artifacts)
__camArtifacts = artifacts;
for (const alabel in __camArtifacts)
{
const ai = __camArtifacts[alabel];
const pos = camMakePos(alabel);
if (camDef(pos.id))
__camSetupArtifactData(alabel);
}
}

//;; ## camAddArtifact(artiLabel, artiTech)
//;;
//;; Adds another artifact to be managed. Will override existing ones if the names match.
//;;
//;; @param {String} artiLabel
//;; @param {String|Array} artiTech
//;; @returns {void}
//;;
function camAddArtifact(artiLabel, artiTech)
{
if (!camDef(artiLabel) || !camDef(artiTech))
{
camDebug("Attempt to add new artifact failed due to undefined name or tech parameter");
return;
}
__camArtifacts[artiLabel] = { tech: artiTech };
__camSetupArtifactData(artiLabel);
}

//;; ## camDeleteArtifact(artiLabel)
//;;
//;; Deletes the artifact from the list of managed artifacts.
//;;
//;; @param {String} artiLabel
//;; @returns {void}
//;;
function camDeleteArtifact(artiLabel, warnIfNotFound)
{
if (!camDef(warnIfNotFound))
{
warnIfNotFound = true;
}
if (!camDef(artiLabel))
{
camDebug("Tried to delete undefined artifact label");
return;
}
if (!(artiLabel in __camArtifacts))
{
if (warnIfNotFound)
{
// will place when object with this id is destroyed
ai.id = "" + pos.id;
ai.placed = false;
camDebug("Artifact label doesn't exist in list of artifacts");
}
else
return;
}
if (__camArtifacts[artiLabel].placed)
{
const obj = getObject(__camGetArtifactLabel(artiLabel));
if (camDef(obj) && obj !== null)
{
// received position or area, place immediately
const acrate = addFeature(CAM_ARTIFACT_STAT, pos.x, pos.y);
addLabel(acrate, __camGetArtifactLabel(alabel));
ai.placed = true;
camSafeRemoveObject(obj, false);
}
}
delete __camArtifacts[artiLabel];
}

//;; ## camAllArtifactsPickedUp()
Expand Down Expand Up @@ -70,15 +113,15 @@ function camGetArtifacts()
{
const artifact = __camArtifacts[alabel];
const __LIB_LABEL = __camGetArtifactLabel(alabel);
//libcampaign managed artifact that was placed on the map.
const obj = getObject(alabel);
//libcampaign managed artifact that was placed on the map (or map placed artifact).
if (artifact.placed && getObject(__LIB_LABEL) !== null)
{
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.
const obj = getObject(alabel);
if (obj !== null && camDef(obj.id))
else if (obj !== null && camDef(obj.id))
{
camArti.push(alabel);
}
Expand All @@ -88,6 +131,34 @@ function camGetArtifacts()

//////////// privates

function __camSetupArtifactData(alabel)
{
const ai = __camArtifacts[alabel];
const pos = camMakePos(alabel);
if (camDef(pos.id))
{
const obj = getObject(alabel);
if (obj && obj.type === FEATURE && obj.stattype === ARTIFACT)
{
addLabel(obj, __camGetArtifactLabel(alabel));
ai.placed = true; // this is an artifact feature on the map itself.
}
else
{
// will place when object with this id is destroyed
ai.id = "" + pos.id;
ai.placed = false;
}
}
else
{
// received position or area, place immediately
const acrate = addFeature(CAM_ARTIFACT_STAT, pos.x, pos.y);
addLabel(acrate, __camGetArtifactLabel(alabel));
ai.placed = true;
}
}

function __camGetArtifactLabel(alabel)
{
return alabel + "_artifact_label";
Expand Down
4 changes: 4 additions & 0 deletions data/base/script/campaign/libcampaign_includes/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ function cam_eventDroidBuilt(droid, structure)

function cam_eventDestroyed(obj)
{
if (obj.type === FEATURE && obj.stattype === ARTIFACT)
{
return;
}
__camCheckPlaceArtifact(obj);
if (obj.type === DROID)
{
Expand Down
35 changes: 17 additions & 18 deletions data/base/stats/research.json
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,8 @@
"id": "R-Cyborg-Wpn-Cannon02",
"msgName": "RES_CYW_CN2",
"name": "Sniper Cyborg",
"replacedComponents": [
"CyborgCannon:CyborgCannon02"
"redComponents": [
"CyborgCannon"
],
"requiredResearch": [
"R-Wpn-Cannon4AMk1"
Expand Down Expand Up @@ -1185,8 +1185,8 @@
"id": "R-Cyborg-Wpn-Flamer02",
"msgName": "RES_CYW_FL2",
"name": "Thermite Cyborg",
"replacedComponents": [
"CyborgFlamer01:CyborgFlamer02"
"redComponents": [
"CyborgFlamer01"
],
"requiredResearch": [
"R-Wpn-Flame2"
Expand Down Expand Up @@ -1236,8 +1236,8 @@
"id": "R-Cyborg-Wpn-Rocket02",
"msgName": "RES_CYW_RK2",
"name": "Tank Killer Cyborg",
"replacedComponents": [
"CyborgRocket:CyborgRocket02"
"redComponents": [
"CyborgRocket"
],
"requiredResearch": [
"R-Wpn-Rocket07-Tank-Killer"
Expand All @@ -1254,8 +1254,8 @@
"id": "R-Cyborg-Wpn-RotMG",
"msgName": "RES_CYW_MG4",
"name": "Assault Gunner Cyborg",
"replacedComponents": [
"CyborgChaingun:CyborgRotMG"
"redComponents": [
"CyborgChaingun"
],
"requiredResearch": [
"R-Wpn-MG4"
Expand All @@ -1272,8 +1272,8 @@
"id": "R-Cyborg-Wpn-ATMiss",
"msgName": "RES_CYW_ATM",
"name": "Scourge Cyborg",
"replacedComponents": [
"CyborgRocket02:Cyb-Wpn-Atmiss"
"redComponents": [
"CyborgRocket02"
],
"requiredResearch": [
"R-Wpn-Missile2A-T"
Expand Down Expand Up @@ -1305,8 +1305,8 @@
"id": "R-Cyborg-Wpn-Rail1",
"msgName": "RES_CYW_RL1",
"name": "Needle Gunner Cyborg",
"replacedComponents": [
"CyborgCannon02:Cyb-Wpn-Rail1"
"redComponents": [
"CyborgCannon02"
],
"requiredResearch": [
"R-Wpn-RailGun01"
Expand Down Expand Up @@ -3469,7 +3469,8 @@
"researchPoints": 1200,
"researchPower": 37,
"resultComponents": [
"Rocket-Pod"
"Rocket-Pod",
"Rocket-VTOL-Pod"
],
"statID": "Rocket-Pod"
},
Expand Down Expand Up @@ -8718,11 +8719,9 @@
"Laser3BEAMMk1",
"MG4ROTARY-VTOL",
"MG4ROTARYMk1",
"Flame2"
],
"replacedComponents": [
"CyborgRotMG:Cyb-Wpn-Laser",
"CyborgFlamer02:Cyb-Wpn-Laser"
"Flame2",
"CyborgRotMG",
"CyborgFlamer02"
],
"requiredResearch": [
"R-Wpn-Laser01"
Expand Down
10 changes: 5 additions & 5 deletions data/base/stats/structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@
"thermal": 10,
"type": "DEFENSE",
"weapons": [
"Flame2"
"Flame2-Emplacement"
],
"width": 1
},
Expand Down Expand Up @@ -2186,7 +2186,7 @@
"thermal": 20,
"type": "DEFENSE",
"weapons": [
"Flame1Mk1"
"Flame1Mk1-Tower"
],
"width": 1
},
Expand Down Expand Up @@ -2476,7 +2476,7 @@
"thermal": 10,
"type": "DEFENSE",
"weapons": [
"Flame2"
"Flame2-Emplacement"
],
"width": 1
},
Expand Down Expand Up @@ -2684,7 +2684,7 @@
"thermal": 10,
"type": "DEFENSE",
"weapons": [
"Flame2"
"Flame2-Emplacement"
],
"width": 1
},
Expand Down Expand Up @@ -2876,7 +2876,7 @@
"thermal": 15,
"type": "DEFENSE",
"weapons": [
"Flame1Mk1"
"Flame1Mk1-Tower"
],
"width": 1
},
Expand Down
Loading

0 comments on commit dc90676

Please sign in to comment.