-
-
Notifications
You must be signed in to change notification settings - Fork 531
/
cam1a.js
358 lines (319 loc) · 9.71 KB
/
cam1a.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
include("script/campaign/libcampaign.js");
include("script/campaign/templates.js");
const GUIDE_STRUCT_BUILT_DELAY_TIME = 100;
const mis_playerRes = [
"R-Wpn-MG1Mk1", "R-Vehicle-Body01", "R-Sys-Spade1Mk1", "R-Vehicle-Prop-Wheels",
];
const mis_scavengerRes = [
"R-Wpn-MG-Damage01", "R-Wpn-MG-ROF01", "R-Wpn-Flamer-Range01-ScavReduce",
];
// CLASSIC: No research.
// Handlers for guide topics
function cam1A_doAddHQBuiltTopics()
{
addGuideTopic("wz2100::structures::factory");
addGuideTopic("wz2100::units::designing", SHOWTOPIC_FIRSTADD);
}
function cam1A_doAddFactoryBuiltTopics()
{
addGuideTopic("wz2100::units::designing");
addGuideTopic("wz2100::structures::rallypoint");
addGuideTopic("wz2100::structures::factory");
addGuideTopic("wz2100::units::building", SHOWTOPIC_FIRSTADD);
}
function cam1A_doAddResearchFacilityBuiltTopics()
{
addGuideTopic("wz2100::structures::researchfacility", SHOWTOPIC_FIRSTADD);
}
function cam1A_doAddOilDerrickBuiltTopics()
{
addGuideTopic("wz2100::general::power");
addGuideTopic("wz2100::structures::oilderrick");
addGuideTopic("wz2100::structures::powergenerator", SHOWTOPIC_FIRSTADD);
}
// Player zero's droid enters area next to first oil patch.
camAreaEvent("launchScavAttack", function(droid)
{
camPlayVideos([cam_sounds.incoming.incomingIntelligenceReport, {video: "MB1A_MSG", type: MISS_MSG}]);
hackAddMessage("C1A_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER, false);
// Send scavengers on war path if triggered above.
camManageGroup(camMakeGroup("scavAttack1", ENEMIES), CAM_ORDER_ATTACK, {
pos: camMakePos("playerBase"),
fallback: camMakePos("retreat1"),
morale: 50
});
// Activate mission timer, unlike the original campaign.
if (!tweakOptions.classicTimers && difficulty !== HARD && difficulty !== INSANE)
{
setMissionTime(camChangeOnDiff(camHoursToSeconds(1)));
}
});
function runAway()
{
const oilPatch = getObject("oilPatch");
const droids = enumRange(oilPatch.x, oilPatch.y, 7, CAM_SCAV_7, false);
camManageGroup(camMakeGroup(droids), CAM_ORDER_ATTACK, {
pos: camMakePos("scavAttack1"),
fallback: camMakePos("retreat1"),
morale: 20 // Will run away after losing a few people.
});
}
function doAmbush()
{
camManageGroup(camMakeGroup("roadblockArea"), CAM_ORDER_ATTACK, {
pos: camMakePos("oilPatch"),
fallback: camMakePos("retreat2"),
morale: 50 // Will mostly die.
});
}
// Area with the radar blip just before the first scavenger outpost.
camAreaEvent("scavAttack1", function(droid)
{
hackRemoveMessage("C1A_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER);
queue("runAway", camSecondsToMilliseconds(1));
queue("doAmbush", camSecondsToMilliseconds(5));
});
// Road between first outpost and base two.
camAreaEvent("roadblockArea", function(droid)
{
camEnableFactory("base2Factory");
});
// Scavengers hiding in the split canyon area between base two and three.
function raidAttack()
{
if (!camClassicMode())
{
camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_6);
camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7);
}
camManageGroup(camMakeGroup("raidTrigger", ENEMIES), CAM_ORDER_ATTACK, {
pos: camMakePos("scavBase3Cleanup")
});
camManageGroup(camMakeGroup("raidGroup", ENEMIES), CAM_ORDER_ATTACK, {
pos: camMakePos("scavBase3Cleanup")
});
camManageGroup(camMakeGroup("scavBase3Cleanup", ENEMIES), CAM_ORDER_DEFEND, {
pos: camMakePos("scavBase3Cleanup")
});
camEnableFactory("base3Factory");
}
// Wait for player to get close to the split canyon and attack, if not already.
camAreaEvent("raidTrigger", function(droid)
{
camCallOnce("raidAttack");
});
// Or, they built on base two's oil patch instead. Initiate a surprise attack.
// (Also handles queuing guide topics for structures built)
function eventStructureBuilt(structure, droid)
{
if (structure.player === CAM_HUMAN_PLAYER)
{
if (structure.stattype === FACTORY)
{
queue("cam1A_doAddFactoryBuiltTopics", GUIDE_STRUCT_BUILT_DELAY_TIME);
}
else if (structure.stattype === RESEARCH_LAB)
{
queue("cam1A_doAddResearchFacilityBuiltTopics", GUIDE_STRUCT_BUILT_DELAY_TIME);
}
else if (structure.stattype === RESOURCE_EXTRACTOR)
{
// Is it in the base two area?
const objs = enumArea("scavBase2Cleanup", CAM_HUMAN_PLAYER);
for (let i = 0, l = objs.length; i < l; ++i)
{
const obj = objs[i];
if (obj.type === STRUCTURE && obj.stattype === RESOURCE_EXTRACTOR)
{
camCallOnce("raidAttack");
break;
}
}
// Add the oil derrick topic
queue("cam1A_doAddOilDerrickBuiltTopics", GUIDE_STRUCT_BUILT_DELAY_TIME);
}
else if (structure.stattype === HQ)
{
queue("cam1A_doAddHQBuiltTopics", GUIDE_STRUCT_BUILT_DELAY_TIME);
}
}
}
camAreaEvent("factoryTrigger", function(droid)
{
camEnableFactory("base4Factory");
});
function camEnemyBaseEliminated_scavGroup1()
{
camEnableFactory("base2Factory");
}
function camEnemyBaseEliminated_scavGroup2()
{
queue("camDetectEnemyBase", camSecondsToMilliseconds(2), "scavGroup3");
}
function enableBaseStructures()
{
const structs = [
cam_base_structures.commandCenter, cam_base_structures.powerGenerator,
cam_base_structures.derrick, cam_base_structures.researchLab,
cam_base_structures.factory,
];
for (let i = 0; i < structs.length; ++i)
{
enableStructure(structs[i], CAM_HUMAN_PLAYER);
}
}
function cam1A_doNeedPowerTopics()
{
// inform the user about power (and the need to build an oil derrick)
addGuideTopic("wz2100::structures::oilderrick");
addGuideTopic("wz2100::general::power", SHOWTOPIC_FIRSTADD);
}
function eventDroidBuilt(droid, structure)
{
if (!camDef(structure)) // "clone wars" cheat
{
return;
}
if (droid.player === CAM_HUMAN_PLAYER)
{
// inform the user about power (and the need to build an oil derrick)
camCallOnce("cam1A_doNeedPowerTopics");
}
}
function doAddHQGuideTopic()
{
addGuideTopic("wz2100::structures::hq", SHOWTOPIC_FIRSTADD);
}
function eventStartLevel()
{
const PLAYER_POWER = 1300;
const startPos = getObject("startPosition");
const lz = getObject("landingZone");
camSetStandardWinLossConditions(CAM_VICTORY_STANDARD, cam_levels.alpha2);
centreView(startPos.x, startPos.y);
setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER);
setAlliance(CAM_SCAV_6, CAM_SCAV_7, true);
enableBaseStructures();
camCompleteRequiredResearch(mis_playerRes, CAM_HUMAN_PLAYER);
if (camClassicMode())
{
setPower(PLAYER_POWER, CAM_HUMAN_PLAYER);
camSetArtifacts({
"base1ArtifactPos": { tech: "R-Wpn-MG-Damage01" },
"base2Factory": { tech: "R-Wpn-Flamer01Mk1" },
"base3Factory": { tech: "R-Defense-Tower01" },
"base4Factory": { tech: "R-Sys-Engineering01" },
});
}
else
{
if (difficulty === HARD)
{
setPower(600, CAM_HUMAN_PLAYER);
}
else if (difficulty === INSANE)
{
setPower(300, CAM_HUMAN_PLAYER);
}
else
{
setPower(PLAYER_POWER, CAM_HUMAN_PLAYER);
}
completeResearch("R-Wpn-Flamer-Range01-ScavReduce", CAM_SCAV_6);
completeResearch("R-Wpn-Flamer-Range01-ScavReduce", CAM_SCAV_7);
if (difficulty >= HARD)
{
camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_6);
camCompleteRequiredResearch(mis_scavengerRes, CAM_SCAV_7);
}
if (difficulty === INSANE)
{
completeResearch("R-Wpn-Flamer-Range01-ScavReduce-Undo", CAM_SCAV_6);
completeResearch("R-Wpn-Flamer-Range01-ScavReduce-Undo", CAM_SCAV_7);
}
camSetArtifacts({
"base1ArtifactPos": { tech: ["R-Wpn-MG-Damage01", "R-Sys-Engineering01"] },
"base2Factory": { tech: ["R-Wpn-Flamer01Mk1", "R-Sys-MobileRepairTurret01"] },
"base3Factory": { tech: "R-Wpn-MG-Damage02" },
"base4Factory": { tech: "R-Wpn-MG-ROF01" },
});
}
// Give player briefing.
camPlayVideos({video: "CMB1_MSG", type: CAMP_MSG, immediate: false});
if (tweakOptions.classicTimers)
{
setMissionTime(-1);
}
else
{
if (difficulty === HARD)
{
setMissionTime(camMinutesToSeconds(40));
}
else if (difficulty === INSANE)
{
setMissionTime(camMinutesToSeconds(30));
}
else
{
setMissionTime(-1); // will start mission timer later
}
}
// Feed libcampaign.js with data to do the rest.
camSetEnemyBases({
"scavGroup1": {
cleanup: "scavBase1Cleanup",
detectMsg: "C1A_BASE0",
detectSnd: cam_sounds.baseDetection.scavengerOutpostDetected,
eliminateSnd: cam_sounds.baseElimination.scavengerOutpostEradicated
},
"scavGroup2": {
cleanup: "scavBase2Cleanup",
detectMsg: "C1A_BASE1",
detectSnd: cam_sounds.baseDetection.scavengerBaseDetected,
eliminateSnd: cam_sounds.baseElimination.scavengerBaseEradicated
},
"scavGroup3": {
cleanup: "scavBase3Cleanup",
detectMsg: "C1A_BASE2",
detectSnd: cam_sounds.baseDetection.scavengerBaseDetected,
eliminateSnd: cam_sounds.baseElimination.scavengerBaseEradicated
},
"scavGroup4": {
cleanup: "scavBase4Cleanup",
detectMsg: "C1A_BASE3",
detectSnd: cam_sounds.baseDetection.scavengerBaseDetected,
eliminateSnd: cam_sounds.baseElimination.scavengerBaseEradicated
},
});
camSetFactories({
"base2Factory": {
assembly: "base2Assembly",
order: CAM_ORDER_ATTACK,
data: { pos: "playerBase" },
groupSize: 3,
maxSize: 3,
throttle: camChangeOnDiff(camSecondsToMilliseconds((difficulty <= MEDIUM) ? 24 : 18)),
templates: [ cTempl.trike, cTempl.bloke ]
},
"base3Factory": {
assembly: "base3Assembly",
order: CAM_ORDER_ATTACK,
data: { pos: "playerBase" },
groupSize: 4,
maxSize: 4,
throttle: camChangeOnDiff(camSecondsToMilliseconds((difficulty <= MEDIUM) ? 20 : 14)),
templates: [ cTempl.bloke, cTempl.buggy, cTempl.bloke ]
},
"base4Factory": {
assembly: "base4Assembly",
order: CAM_ORDER_ATTACK,
data: { pos: "playerBase" },
groupSize: 4,
maxSize: 4,
throttle: camChangeOnDiff(camSecondsToMilliseconds((difficulty <= MEDIUM) ? 16 : 12)),
templates: [ cTempl.bjeep, cTempl.bloke, cTempl.trike, cTempl.bloke ]
},
});
queue("doAddHQGuideTopic", camSecondsToMilliseconds(3));
}