-
-
Notifications
You must be signed in to change notification settings - Fork 531
/
cam2-1x.js
183 lines (158 loc) · 5.56 KB
/
cam2-1x.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
include("script/campaign/libcampaign.js");
include("script/campaign/templates.js");
include("script/campaign/transitionTech.js");
var victoryFlag;
const MIS_TRANSPORT_TEAM_PLAYER = 1;
const mis_collectiveRes = [
"R-Defense-WallUpgrade04", "R-Struc-Materials04", "R-Sys-Engineering02",
"R-Vehicle-Engine03", "R-Vehicle-Metals03", "R-Cyborg-Metals03",
"R-Wpn-Cannon-Accuracy02", "R-Wpn-Cannon-Damage04",
"R-Wpn-Cannon-ROF01", "R-Wpn-Flamer-Damage03", "R-Wpn-Flamer-ROF01",
"R-Wpn-MG-Damage05", "R-Wpn-MG-ROF02", "R-Wpn-Mortar-Acc01",
"R-Wpn-Mortar-Damage03", "R-Wpn-Mortar-ROF01",
"R-Wpn-Rocket-Accuracy02", "R-Wpn-Rocket-Damage04",
"R-Wpn-Rocket-ROF03", "R-Wpn-RocketSlow-Accuracy03",
"R-Wpn-RocketSlow-Damage04", "R-Sys-Sensor-Upgrade01"
];
const mis_collectiveResClassic = [
"R-Defense-WallUpgrade03", "R-Struc-Materials03", "R-Vehicle-Engine04",
"R-Vehicle-Metals03", "R-Cyborg-Metals03", "R-Vehicle-Armor-Heat01",
"R-Cyborg-Armor-Heat01", "R-Wpn-Cannon-Accuracy02", "R-Wpn-Cannon-Damage04",
"R-Wpn-Cannon-ROF01", "R-Wpn-Flamer-Damage04", "R-Wpn-Flamer-ROF01",
"R-Wpn-MG-Damage04", "R-Wpn-MG-ROF02", "R-Sys-Sensor-Upgrade01",
"R-Wpn-Mortar-Damage03", "R-Wpn-Mortar-Damage04", "R-Wpn-RocketSlow-Accuracy03",
"R-Wpn-RocketSlow-Damage03", "R-Wpn-RocketSlow-ROF03"
];
//trigger event when droid reaches the downed transport.
camAreaEvent("crashSite", function(droid)
{
//Unlikely to happen.
if (!enumDroid(MIS_TRANSPORT_TEAM_PLAYER).length)
{
gameOverMessage(false);
return;
}
playSound(cam_sounds.rescue.unitsRescued);
hackRemoveMessage("C21_OBJECTIVE", PROX_MSG, CAM_HUMAN_PLAYER);
const droids = enumDroid(MIS_TRANSPORT_TEAM_PLAYER);
for (let i = 0; i < droids.length; ++i)
{
donateObject(droids[i], CAM_HUMAN_PLAYER);
}
//Give the donation enough time to transfer them to the player. Otherwise
//the level will end too fast and will trigger asserts in the next level.
queue("triggerWin", camSecondsToMilliseconds(2));
});
//function that applies damage to units in the downed transport transport team.
function preDamageUnits()
{
setHealth(getObject("transporter"), 40);
const droids = enumDroid(MIS_TRANSPORT_TEAM_PLAYER);
for (let j = 0; j < droids.length; ++j)
{
setHealth(droids[j], 40 + camRand(20));
}
}
//victory callback will thus complete the level.
function triggerWin()
{
victoryFlag = true;
}
function setupCyborgGroups()
{
//create group of cyborgs and send them on war path
camManageGroup(camMakeGroup("cyborgPositionNorth"), CAM_ORDER_ATTACK, {
regroup: false
});
//create group of cyborgs and send them on war path
camManageGroup(camMakeGroup("cyborgPositionEast"), CAM_ORDER_ATTACK, {
regroup: false
});
}
function setCrashedTeamExp()
{
const DROID_EXP = camGetRankThreshold("professional");
const droids = enumDroid(MIS_TRANSPORT_TEAM_PLAYER).filter((dr) => (
!camIsSystemDroid(dr) && !camIsTransporter(dr)
));
for (let i = 0; i < droids.length; ++i)
{
const droid = droids[i];
setDroidExperience(droid, DROID_EXP);
}
preDamageUnits();
}
//Checks if the downed transport has been destroyed and issue a game lose.
function checkCrashedTeam()
{
if (getObject("transporter") === null)
{
return false;
}
if (camDef(victoryFlag) && victoryFlag)
{
return true;
}
}
function eventStartLevel()
{
camSetExtraObjectiveMessage(_("Locate and rescue your units from the shot down transporter"));
camSetStandardWinLossConditions(CAM_VICTORY_OFFWORLD, cam_levels.beta3, {
area: "RTLZ",
message: "C21_LZ",
reinforcements: -1,
callback: "checkCrashedTeam"
});
const subLandingZone = getObject("landingZone");
const startPos = getObject("startingPosition");
const tEnt = getObject("transporterEntry");
const tExt = getObject("transporterExit");
centreView(startPos.x, startPos.y);
setNoGoArea(subLandingZone.x, subLandingZone.y, subLandingZone.x2, subLandingZone.y2, CAM_HUMAN_PLAYER);
startTransporterEntry(tEnt.x, tEnt.y, CAM_HUMAN_PLAYER);
setTransporterExit(tExt.x, tExt.y, CAM_HUMAN_PLAYER);
//Add crash site blip and from an alliance with the crashed team.
hackAddMessage("C21_OBJECTIVE", PROX_MSG, CAM_HUMAN_PLAYER, false);
setAlliance(CAM_HUMAN_PLAYER, MIS_TRANSPORT_TEAM_PLAYER, true);
//set downed transport team colour to be Project Green.
changePlayerColour(MIS_TRANSPORT_TEAM_PLAYER, 0);
if (camClassicMode())
{
camClassicResearch(mis_collectiveResClassic, CAM_THE_COLLECTIVE);
camClassicResearch(mis_alphaResearchNewClassic, MIS_TRANSPORT_TEAM_PLAYER);
camClassicResearch(mis_playerResBetaClassic, MIS_TRANSPORT_TEAM_PLAYER);
}
else
{
camCompleteRequiredResearch(mis_collectiveRes, CAM_THE_COLLECTIVE);
camCompleteRequiredResearch(mis_alphaResearchNew, MIS_TRANSPORT_TEAM_PLAYER);
camCompleteRequiredResearch(mis_playerResBeta, MIS_TRANSPORT_TEAM_PLAYER);
if (difficulty >= HARD)
{
camUpgradeOnMapTemplates(cTempl.commc, cTempl.commrp, CAM_THE_COLLECTIVE);
}
}
camSetEnemyBases({
"COHardpointBase": {
cleanup: "hardpointBaseCleanup",
detectMsg: "C21_BASE1",
detectSnd: cam_sounds.baseDetection.enemyBaseDetected,
eliminateSnd: cam_sounds.baseElimination.enemyBaseEradicated,
},
"COBombardBase": {
cleanup: "bombardBaseCleanup",
detectMsg: "C21_BASE2",
detectSnd: cam_sounds.baseDetection.enemyBaseDetected,
eliminateSnd: cam_sounds.baseElimination.enemyBaseEradicated,
},
"COBunkerBase": {
cleanup: "bunkerBaseCleanup",
detectMsg: "C21_BASE3",
detectSnd: cam_sounds.baseDetection.enemyBaseDetected,
eliminateSnd: cam_sounds.baseElimination.enemyBaseEradicated,
},
});
setCrashedTeamExp();
victoryFlag = false;
queue("setupCyborgGroups", camSecondsToMilliseconds(5));
}