Skip to content

Commit

Permalink
Change Nexus hacking Gamma 9
Browse files Browse the repository at this point in the history
Remove destruction of VTOLs at start of SW base being sited, instead, just protect the HQ with a force-field wave against them.

Take over chance attack happens on all difficulties with varied chances now. Commanders ignored for initial hit.

Finally, some added checks to see if the HQ was destroyed before base detection to prevent warnings.
  • Loading branch information
KJeff01 committed Jan 13, 2024
1 parent c1598bb commit 0f20b67
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 31 deletions.
71 changes: 40 additions & 31 deletions script/campaign/cam3-4.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const mis_nexusRes = [

function eventDestroyed(obj)
{
if (obj.player === CAM_NEXUS && obj.type === STRUCTURE && obj.stattype === HQ)
if (camGetNexusState() && obj.player === CAM_NEXUS && obj.type === STRUCTURE && obj.stattype === HQ)
{
camSetNexusState(false);
removeTimer("nexusHackFeature");
Expand Down Expand Up @@ -47,11 +47,11 @@ function nexusHackFeature()

switch (difficulty)
{
case SUPEREASY: hackFailChance = 90; break;
case EASY: hackFailChance = 80; break;
case MEDIUM: hackFailChance = 70; break;
case SUPEREASY: hackFailChance = 95; break;
case EASY: hackFailChance = 85; break;
case MEDIUM: hackFailChance = 75; break;
case HARD: hackFailChance = 65; break;
case INSANE: hackFailChance = 60; break;
case INSANE: hackFailChance = 55; break;
default: hackFailChance = 70;
}

Expand All @@ -66,15 +66,29 @@ function nexusHackFeature()
// A little suprise absorbption attack when discovering the SW base.
function takeoverChanceAttack()
{
const CHANCE = (difficulty === INSANE) ? 10 : 5;
let chance = 0;
switch (difficulty)
{
case SUPEREASY: chance = 1; break;
case EASY: chance = 3; break;
case MEDIUM: chance = 5; break;
case HARD: chance = 7; break;
case INSANE: chance = 9; break;
default: chance = 5;
}

const objects = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter((obj) => (
(obj.type !== DROID) || (obj.type === DROID && obj.droidType !== DROID_SUPERTRANSPORTER)
));

for (let i = 0, len = objects.length; i < len; ++i)
{
const obj = objects[i];
if (camRand(100) < CHANCE)
if (obj.type === DROID && obj.droidType === DROID_COMMAND)
{
continue; //A little too hectic to take a Commander immediately.
}
if (camRand(100) < chance)
{
if (obj.type === STRUCTURE && obj.stattype === WALL)
{
Expand All @@ -88,26 +102,23 @@ function takeoverChanceAttack()
}
}

//Destroy some VTOLs initially.
function destroyPlayerVtols()
{
let vtolBlowupAmount = 0;
const vtols = enumArea(0, 0, mapWidth, mapHeight, CAM_HUMAN_PLAYER, false).filter((obj) => (
(obj.type === DROID) && (obj.droidType !== DROID_SUPERTRANSPORTER) && isVTOL(obj)
));

switch (difficulty)
const hq = getObject("NX-HQ");
if (hq === null)
{
case MEDIUM: vtolBlowupAmount = 0.5; break;
case HARD: vtolBlowupAmount = 0.65; break;
case INSANE: vtolBlowupAmount = 0.8; break;
default: vtolBlowupAmount = 0.5;
removeTimer("destroyPlayerVtols");
return;
}

for (let i = 0, len = Math.floor(vtolBlowupAmount * vtols.length); i < len; ++i)
const __SCAN_RADIUS = 11;
const objects = enumRange(hq.x, hq.y, __SCAN_RADIUS, CAM_HUMAN_PLAYER, false);
for (let i = 0, len = objects.length; i < len; ++i)
{
const vtol = vtols[i];
camSafeRemoveObject(vtol, true);
const obj = objects[i];
if (obj.type === DROID && isVTOL(obj))
{
camSafeRemoveObject(obj, true);
}
}
}

Expand All @@ -116,21 +127,19 @@ function activateNexus()
camSetExtraObjectiveMessage(_("Destroy the Nexus HQ to disable the Nexus Intruder Program"));
playSound(cam_sounds.nexus.synapticLinksActivated);
camSetNexusState(true);
setTimer("nexusHackFeature", camSecondsToMilliseconds((difficulty <= MEDIUM) ? 20 : 10));
setTimer("nexusHackFeature", camSecondsToMilliseconds((difficulty <= EASY) ? 20 : 10));
setTimer("destroyPlayerVtols", camSecondsToMilliseconds(0.2));
}

function camEnemyBaseDetected_NX_SWBase()
{
camPlayVideos({video: "MB3_4_MSG4", type: MISS_MSG});
//Do these before Nexus state activation to prevent sound spam.
if (difficulty >= MEDIUM)
{
queue("destroyPlayerVtols", camSecondsToMilliseconds(0.2));
}
if (difficulty >= HARD)
if (getObject("NX-HQ") === null)
{
queue("takeoverChanceAttack", camSecondsToMilliseconds(0.5));
return; //Probably destroyed through cheats?
}
camPlayVideos({video: "MB3_4_MSG4", type: MISS_MSG});
//Do these before Nexus state activation to prevent sound spam.
queue("takeoverChanceAttack", camSecondsToMilliseconds(0.5));
queue("activateNexus", camSecondsToMilliseconds(1));
}

Expand Down
6 changes: 6 additions & 0 deletions wrf/cam3/cam3-4/labels.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,11 @@
"id": 1235,
"player": 3,
"type": 1
},
"object_11": {
"label": "NX-HQ",
"id": 237,
"player": 3,
"type": 1
}
}

0 comments on commit 0f20b67

Please sign in to comment.