Skip to content

Commit

Permalink
Improve a few Beta mission scripts.
Browse files Browse the repository at this point in the history
- Cam2-1: Cleanups and giving the crashed team experience.
- Cam2-d: Force total annihilation and return to LZ. Change a few timers.
- Libcampaign: Break alliances before mission load.
  • Loading branch information
KJeff01 committed Jan 19, 2018
1 parent 7fcfc5a commit ddce7a5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 49 deletions.
57 changes: 20 additions & 37 deletions data/base/script/campaign/cam2-1x.js
Expand Up @@ -4,6 +4,8 @@ Authors: Cristian Odorico (Alpha93) / KJeff01
*/
include ("script/campaign/libcampaign.js");
include ("script/campaign/templates.js");
include ("script/campaign/transitionTech.js");
var victoryFlag;

const TRANSPORT_TEAM = 1;
const COLLECTIVE_RES = [
Expand All @@ -30,10 +32,10 @@ camAreaEvent("crashSite", function(droid)

hackRemoveMessage("C21_OBJECTIVE", PROX_MSG, CAM_HUMAN_PLAYER);

var downedTransportUnits = enumDroid(TRANSPORT_TEAM);
for (var i = 0; i < downedTransportUnits.length; i++)
var droids = enumDroid(TRANSPORT_TEAM);
for (var i = 0; i < droids.length; ++i)
{
donateObject(downedTransportUnits[i], CAM_HUMAN_PLAYER);
donateObject(droids[i], CAM_HUMAN_PLAYER);
}

//Give the donation enough time to transfer them to the player. Otherwise
Expand All @@ -45,11 +47,10 @@ camAreaEvent("crashSite", function(droid)
function preDamageUnits()
{
setHealth(getObject("transporter"), 40);
// fill the array with the objects defining the allied units in the crash site area
var downedTransportUnits = enumDroid(TRANSPORT_TEAM);
for (var j = 0; j < downedTransportUnits.length; j++)
var droids = enumDroid(TRANSPORT_TEAM);
for (var j = 0; j < droids.length; ++j)
{
setHealth(downedTransportUnits[j], 40 + camRand(20));
setHealth(droids[j], 40 + camRand(20));
}
}

Expand Down Expand Up @@ -78,43 +79,23 @@ function setupCyborgGroups()
});
}

//Destroy all the droids from the downed team to give them a valid droid ID
//and recreate them.
function updateTransportUnits()
function setCrashedTeamExp()
{
var downedTransportUnits = enumDroid(TRANSPORT_TEAM);
for (var i = 0; i < downedTransportUnits.length; i++)
{
if (camDef(downedTransportUnits[i]))
{
var temp = downedTransportUnits[i];
if (camDef(temp.weapons[0]))
{
addDroid(TRANSPORT_TEAM, temp.x, temp.y, "Team Alpha unit",
temp.body, temp.propulsion, "", "", temp.weapons[0].name);
}
else
{
addDroid(TRANSPORT_TEAM, temp.x, temp.y, "Team Alpha unit",
temp.body, temp.propulsion, "", "", "Spade1Mk1");
}
}
}
const DROID_EXP = 32;
var droids = enumDroid(TRANSPORT_TEAM).filter(function(dr) {
return !camIsSystemDroid(dr) && !camIsTransporter(dr);
});

//Remove the old droids.
for(var i = 0; i < downedTransportUnits.length; i++)
for (var i = 0; i < droids.length; ++i)
{
if (camDef(downedTransportUnits[i]))
{
camSafeRemoveObject(downedTransportUnits[i], false);
}
var droid = droids[i];
setDroidExperience(droid, DROID_EXP);
}

preDamageUnits();
}

//Checks if the downed transport has been destroyed and issues a game lose. This
//likely will never happen as with the WZ Script version.
//Checks if the downed transport has been destroyed and issue a game lose.
function checkCrashedTeam()
{
if (getObject("transporter") === null)
Expand Down Expand Up @@ -155,6 +136,8 @@ function eventStartLevel()
changePlayerColour(TRANSPORT_TEAM, 0);

camCompleteRequiredResearch(COLLECTIVE_RES, THE_COLLECTIVE);
camCompleteRequiredResearch(ALPHA_RESEARCH, TRANSPORT_TEAM);
camCompleteRequiredResearch(PLAYER_RES_BETA, TRANSPORT_TEAM);

camSetEnemyBases({
"COHardpointBase": {
Expand All @@ -177,7 +160,7 @@ function eventStartLevel()
},
});

setCrashedTeamExp();
victoryFlag = false;
queue("setupCyborgGroups", 5000);
queue("updateTransportUnits", 20000);
}
26 changes: 15 additions & 11 deletions data/base/script/campaign/cam2-d.js
Expand Up @@ -39,7 +39,7 @@ function truckDefense()
camQueueBuilding(THE_COLLECTIVE, list[camRand(list.length)], camMakePos("uplinkPos"));
}

//Triggers after 1 minute. Then attacks every 2 minutes until HQ is destroyed.
//Attacks every 2 minutes until HQ is destroyed.
function vtolAttack()
{
var list; with (camTemplates) list = [colatv];
Expand All @@ -57,15 +57,15 @@ function captureUplink()
//Extra win condition callback.
function checkNASDACentral()
{
var enemyStuff = enumArea("uplinkClearArea", THE_COLLECTIVE, false);
if(!enemyStuff.length)
if (getObject("uplink") === null)
{
camCallOnce("captureUplink");
return false; //It was destroyed
}

if(!enumArea(0, 0, mapWidth, mapHeight, ENEMIES, false).length)
if (camCountStructuresInArea("uplinkClearArea", THE_COLLECTIVE) === 0)
{
return true; //Must destroy everything to win.
camCallOnce("captureUplink");
return true;
}
}

Expand All @@ -76,16 +76,20 @@ function enableReinforcements()
area: "RTLZ",
message: "C2D_LZ",
reinforcements: 300, //5 min
callback: "checkNASDACentral"
callback: "checkNASDACentral",
annihilate: true,
retlz: true
});
}

function eventStartLevel()
{
camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, "SUB_2_6S",{
camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, "SUB_2_6S", {
area: "RTLZ",
message: "C2D_LZ",
reinforcements: -1
reinforcements: -1,
annihilate: true,
retlz: true
});

var startpos = getObject("startPosition");
Expand Down Expand Up @@ -124,7 +128,7 @@ function eventStartLevel()
assembly: "COHeavyFactoryAssembly",
order: CAM_ORDER_ATTACK,
groupSize: 5,
throttle: camChangeOnDiff(80000),
throttle: camChangeOnDiff(60000),
data: {
regroup: false,
repair: 20,
Expand Down Expand Up @@ -154,5 +158,5 @@ function eventStartLevel()
camEnableFactory("COSouthCyborgFactory");

queue("enableReinforcements", 22000);
queue("vtolAttack", 60000);
queue("vtolAttack", 120000); // 2 min
}
22 changes: 21 additions & 1 deletion data/base/script/campaign/libcampaign.js
Expand Up @@ -370,6 +370,22 @@ function camMakeGroup(what, filter)
camDebug("Cannot parse", what);
}

//;; \subsection{camBreakAlliances()}
//;; Break alliances between all players.
function camBreakAlliances()
{
for (var i = 0; i < CAM_MAX_PLAYERS; ++i)
{
for (var c = 0; c < CAM_MAX_PLAYERS; ++c)
{
if (i !== c && allianceExistsBetween(i, c) === true)
{
setAlliance(i, c, false);
}
}
}
}

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

var __camCalledOnce = {};
Expand Down Expand Up @@ -2323,16 +2339,20 @@ function camNextLevel(nextLevel)
{
var bonus = 110;
if (difficulty === HARD)
{
bonus = 105;
}
else if (difficulty === INSANE)
{
bonus = 100;

}
camTrace("Bonus time", bonusTime);
setPowerModifier(bonus); // Bonus percentage for completing fast
extraPowerTime(bonusTime);
setPowerModifier(100);
}
}
camBreakAlliances();
loadLevel(nextLevel);
}

Expand Down

0 comments on commit ddce7a5

Please sign in to comment.