-
-
Notifications
You must be signed in to change notification settings - Fork 531
/
cam1-7.js
383 lines (344 loc) · 11.5 KB
/
cam1-7.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
include("script/campaign/libcampaign.js");
include("script/campaign/templates.js");
const mis_newParadigmRes = [
"R-Wpn-MG1Mk1", "R-Vehicle-Body01", "R-Sys-Spade1Mk1", "R-Vehicle-Prop-Wheels",
"R-Sys-Engineering01", "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF02", "R-Wpn-Cannon-Damage03",
"R-Wpn-Flamer-Damage03", "R-Wpn-Flamer-Range01", "R-Wpn-Flamer-ROF01",
"R-Defense-WallUpgrade03", "R-Struc-Materials03", "R-Vehicle-Engine03",
"R-Struc-RprFac-Upgrade03", "R-Wpn-Rocket-Damage03", "R-Wpn-Rocket-ROF03",
"R-Vehicle-Metals03", "R-Wpn-Mortar-Damage03", "R-Wpn-Rocket-Accuracy02",
"R-Wpn-RocketSlow-Damage03", "R-Wpn-Mortar-ROF01", "R-Cyborg-Metals03",
"R-Wpn-Mortar-Acc01", "R-Wpn-RocketSlow-Accuracy01", "R-Wpn-Cannon-Accuracy01",
];
const mis_scavengerRes = [
"R-Wpn-Flamer-Damage03", "R-Wpn-Flamer-Range01", "R-Wpn-Flamer-ROF01",
"R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01", "R-Wpn-Rocket-Damage03",
"R-Wpn-Cannon-Damage03", "R-Wpn-Mortar-Damage03", "R-Wpn-Mortar-ROF01",
"R-Wpn-Rocket-Accuracy02", "R-Wpn-Rocket-ROF03", "R-Vehicle-Metals02",
"R-Defense-WallUpgrade03", "R-Struc-Materials03", "R-Wpn-Cannon-Accuracy01",
"R-Wpn-Mortar-Acc01",
];
const mis_newParadigmResClassic = [
"R-Defense-WallUpgrade03", "R-Struc-Materials03", "R-Struc-Factory-Upgrade03",
"R-Vehicle-Engine03", "R-Vehicle-Metals03", "R-Cyborg-Metals03",
"R-Wpn-Cannon-Accuracy01", "R-Wpn-Cannon-Damage03", "R-Wpn-Flamer-Damage03",
"R-Wpn-Flamer-ROF01", "R-Wpn-MG-Damage04", "R-Wpn-MG-ROF01",
"R-Wpn-Mortar-Acc01", "R-Wpn-Mortar-Damage03", "R-Wpn-Rocket-Accuracy01",
"R-Wpn-Rocket-Damage03", "R-Wpn-Rocket-ROF03", "R-Wpn-RocketSlow-Accuracy02",
"R-Wpn-RocketSlow-Damage03", "R-Struc-RprFac-Upgrade03"
];
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
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
camAreaEvent("northScavFactoryTrigger", function(droid)
{
camEnableFactory("scavNorthEastFactory");
});
camAreaEvent("southScavFactoryTrigger", function(droid)
{
camEnableFactory("scavSouthEastFactory");
});
camAreaEvent("middleScavFactoryTrigger", function(droid)
{
camEnableFactory("scavMiddleFactory");
});
//If a group member of artiGroup gets to the waypoint, then go to the
//New Paradigm landing zone.
camAreaEvent("NPWayPointTrigger", function(droid)
{
artiMovePos = "NPTransportPos";
});
//Land New Paradigm transport if the New Paradigm have the artifact.
camAreaEvent("NPTransportTrigger", function(droid)
{
if (enemyHasArtifact && droid.group === artiGroup)
{
const list = [cTempl.npmrl, cTempl.npmrl];
camSendReinforcement(CAM_NEW_PARADIGM, camMakePos("NPTransportPos"), list, CAM_REINFORCE_TRANSPORT, {
entry: { x: 39, y: 2 },
exit: { x: 32, y: 60 }
});
playSound(cam_sounds.enemyEscaping);
}
else
{
resetLabel("NPTransportTrigger", CAM_NEW_PARADIGM);
}
});
//Only called once when the New Paradigm takes the artifact for the first time.
function artifactVideoSetup()
{
camPlayVideos({video: "SB1_7_MSG3", type: MISS_MSG});
camCallOnce("removeCanyonBlip");
}
//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 === CAM_NEW_PARADIGM && enemyHasArtifact)
{
enemyStoleArtifact = true;
const crew = enumRange(transport.x, transport.y, 6, CAM_NEW_PARADIGM, false).filter((obj) => (
obj.type === DROID && obj.group === artiGroup
));
for (let i = 0, l = crew.length; i < l; ++i)
{
camSafeRemoveObject(crew[i], false);
}
}
}
//Check if the artifact group members are still alive and drop the artifact if needed.
function eventGroupLoss(obj, group, newsize)
{
if (group === artiGroup && enemyHasArtifact && !enemyStoleArtifact)
{
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, MIS_NEW_ARTI_LABEL);
if (camClassicMode())
{
camAddArtifact(MIS_NEW_ARTI_LABEL, "R-Wpn-Cannon3Mk1");
}
else
{
camAddArtifact(MIS_NEW_ARTI_LABEL, ["R-Wpn-Cannon3Mk1", "R-Wpn-RocketSlow-Damage03"]);
}
droidWithArtiID = undefined;
enemyHasArtifact = false;
hackRemoveMessage("C1-7_LZ2", PROX_MSG, CAM_HUMAN_PLAYER);
}
}
}
function enemyCanTakeArtifact(label)
{
return label.indexOf(MIS_NEW_ARTI_LABEL) !== -1 || label.indexOf("artifact1") !== -1;
}
//Moves some New Paradigm forces to the artifact
function getArtifact()
{
if (groupSize(artiGroup) === 0)
{
removeTimer("getArtifact");
return;
}
const GRAB_RADIUS = 2;
const artifact = camGetArtifacts().filter((label) => (
enemyCanTakeArtifact(label) && getObject(label) !== null
));
let artiLoc = artiMovePos;
if (!enemyHasArtifact && !enemyStoleArtifact && artifact.length > 0)
{
//Go to the artifact instead.
const realCrate = artifact[0];
artiLoc = camMakePos(realCrate);
if (!camDef(artiLoc))
{
return; //player must have snatched it
}
//Find the one closest to the artifact so that one can "hold" it
const artiMembers = enumGroup(artiGroup);
let idx = 0;
let dist = Infinity;
for (let i = 0, l = artiMembers.length; i < l; ++i)
{
const DR_DIST = camDist(artiMembers[i], artiLoc);
if (DR_DIST < dist)
{
idx = i;
dist = DR_DIST;
}
}
//Now take it if close enough
if (camDist(artiMembers[idx], artiLoc) < GRAB_RADIUS)
{
camCallOnce("artifactVideoSetup");
hackAddMessage("C1-7_LZ2", PROX_MSG, CAM_HUMAN_PLAYER, false); //NPLZ blip
droidWithArtiID = artiMembers[idx].id;
enemyHasArtifact = true;
camSafeRemoveObject(realCrate, false);
}
}
if (camDef(artiLoc))
{
camManageGroup(artiGroup, CAM_ORDER_DEFEND, {
pos: artiLoc,
radius: 0,
regroup: false
});
}
}
//New Paradigm truck builds six lancer hardpoints around LZ
function buildLancers()
{
for (let i = 1; i <= 6; ++i)
{
camQueueBuilding(CAM_NEW_PARADIGM, "WallTower06", "hardPoint" + i);
}
}
//Must destroy all of the New Paradigm droids and make sure the artifact is safe.
function extraVictory()
{
let npTransportFound = false;
enumDroid(CAM_NEW_PARADIGM).forEach((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(CAM_NEW_PARADIGM).length)
{
return true;
}
}
function removeCanyonBlip()
{
hackRemoveMessage("C1-7_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER);
}
function eventPickup(feature, droid)
{
if (feature.stattype === ARTIFACT)
{
if (droid.player === CAM_HUMAN_PLAYER)
{
if (enemyHasArtifact)
{
hackRemoveMessage("C1-7_LZ2", PROX_MSG, CAM_HUMAN_PLAYER);
}
enemyHasArtifact = false;
camCallOnce("removeCanyonBlip");
}
}
}
function startArtifactCollection()
{
setTimer("getArtifact", camSecondsToMilliseconds(0.2));
}
//Mission setup stuff
function eventStartLevel()
{
camSetExtraObjectiveMessage(_("Destroy all New Paradigm units"));
enemyHasArtifact = false;
enemyStoleArtifact = false;
artiMovePos = "NPWayPoint";
const startPos = getObject("startPosition");
const lz = getObject("landingZone"); //player lz
const tEnt = getObject("transporterEntry");
const tExt = getObject("transporterExit");
centreView(startPos.x, startPos.y);
setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER);
startTransporterEntry(tEnt.x, tEnt.y, CAM_HUMAN_PLAYER);
setTransporterExit(tExt.x, tExt.y, CAM_HUMAN_PLAYER);
camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, cam_levels.alpha12.pre, {
area: "RTLZ",
message: "C1-7_LZ",
reinforcements: camMinutesToSeconds(1),
callback: "extraVictory",
retlz: true,
});
//Make sure the New Paradigm and Scavs are allies
setAlliance(CAM_NEW_PARADIGM, CAM_SCAV_7, true);
if (camClassicMode())
{
camClassicResearch(mis_newParadigmResClassic, CAM_NEW_PARADIGM);
camClassicResearch(mis_scavengerResClassic, CAM_SCAV_7);
camSetArtifacts({
"artifact1": { tech: "R-Wpn-Cannon3Mk1" },
});
}
else
{
camCompleteRequiredResearch(mis_newParadigmRes, CAM_NEW_PARADIGM);
camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7);
camUpgradeOnMapTemplates(cTempl.bloke, cTempl.blokeheavy, CAM_SCAV_7);
camUpgradeOnMapTemplates(cTempl.trike, cTempl.trikeheavy, CAM_SCAV_7);
camUpgradeOnMapTemplates(cTempl.buggy, cTempl.buggyheavy, CAM_SCAV_7);
camUpgradeOnMapTemplates(cTempl.bjeep, cTempl.bjeepheavy, CAM_SCAV_7);
camUpgradeOnMapTemplates(cTempl.rbjeep, cTempl.rbjeep8, CAM_SCAV_7);
// New MRA Mantis Tracks units on the hill
if (difficulty >= HARD)
{
addDroid(CAM_NEW_PARADIGM, 29, 16, "MRA Mantis Tracks", tBody.tank.mantis, tProp.tank.tracks, "", "", tWeap.tank.miniRocketArray);
addDroid(CAM_NEW_PARADIGM, 29, 17, "MRA Mantis Tracks", tBody.tank.mantis, tProp.tank.tracks, "", "", tWeap.tank.miniRocketArray);
addDroid(CAM_NEW_PARADIGM, 29, 18, "MRA Mantis Tracks", tBody.tank.mantis, tProp.tank.tracks, "", "", tWeap.tank.miniRocketArray);
}
camSetArtifacts({
"artifact1": { tech: ["R-Wpn-Cannon3Mk1", "R-Wpn-RocketSlow-Damage03"] },
});
}
camSetEnemyBases({
"ScavMiddleGroup": {
cleanup: "scavMiddle",
detectMsg: "C1-7_BASE1",
detectSnd: cam_sounds.baseDetection.scavengerBaseDetected,
eliminateSnd: cam_sounds.baseElimination.scavengerBaseEradicated
},
"ScavSouthEastGroup": {
cleanup: "scavSouthEast",
detectMsg: "C1-7_BASE2",
detectSnd: cam_sounds.baseDetection.scavengerBaseDetected,
eliminateSnd: cam_sounds.baseElimination.scavengerBaseEradicated
},
"ScavNorthEastGroup": {
cleanup: "scavNorth",
detectMsg: "C1-7_BASE3",
detectSnd: cam_sounds.baseDetection.scavengerBaseDetected,
eliminateSnd: cam_sounds.baseElimination.scavengerBaseEradicated
},
});
camSetFactories({
"scavMiddleFactory": {
assembly: "middleAssembly",
order: CAM_ORDER_ATTACK,
groupSize: 4,
throttle: camChangeOnDiff(camSecondsToMilliseconds(10)),
data: {
regroup: true,
count: -1,
},
templates: (!camClassicMode()) ? [ cTempl.firecan, cTempl.rbjeep8, cTempl.rbuggy, cTempl.blokeheavy ] : [ cTempl.firecan, cTempl.rbjeep, cTempl.rbuggy, cTempl.bloke ]
},
"scavSouthEastFactory": {
assembly: "southAssembly",
order: CAM_ORDER_ATTACK,
groupSize: 4,
throttle: camChangeOnDiff(camSecondsToMilliseconds(10)),
data: {
regroup: true,
count: -1,
},
templates: (!camClassicMode()) ? [ cTempl.firecan, cTempl.rbjeep8, cTempl.rbuggy, cTempl.blokeheavy ] : [ cTempl.firecan, cTempl.rbjeep, cTempl.rbuggy, cTempl.bloke ]
},
"scavNorthEastFactory": {
assembly: "northAssembly",
order: CAM_ORDER_ATTACK,
groupSize: 4,
throttle: camChangeOnDiff(camSecondsToMilliseconds(10)),
rdata: {
regroup: true,
count: -1,
},
templates: (!camClassicMode()) ? [ cTempl.firecan, cTempl.rbjeep8, cTempl.rbuggy, cTempl.blokeheavy ] : [ cTempl.firecan, cTempl.rbjeep, cTempl.rbuggy, cTempl.bloke ]
},
});
artiGroup = camMakeGroup(enumArea("NPArtiGroup", CAM_NEW_PARADIGM, false));
droidWithArtiID = 0;
camManageTrucks(CAM_NEW_PARADIGM);
buildLancers();
hackAddMessage("C1-7_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER, false); //Canyon
queue("startArtifactCollection", camChangeOnDiff(camMinutesToMilliseconds(1.5)));
}