File: guide.js

package info (click to toggle)
warzone2100 4.6.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 660,332 kB
  • sloc: cpp: 676,209; ansic: 391,201; javascript: 78,238; python: 16,632; php: 4,294; sh: 4,094; makefile: 2,629; lisp: 1,492; cs: 489; xml: 404; perl: 224; ruby: 156; java: 89
file content (240 lines) | stat: -rw-r--r-- 8,605 bytes parent folder | download
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

////////////////////////////////////////////////////////////////////////////////
// Guide topics management.
////////////////////////////////////////////////////////////////////////////////

function __camDoAddVTOLUseTopicsImpl()
{
	addGuideTopic("wz2100::units::propulsions::vtols::defending");
	addGuideTopic("wz2100::units::propulsions::vtols::attacking", SHOWTOPIC_FIRSTADD);
}

function __camDoAddCommanderUseTopicsImpl()
{
	addGuideTopic("wz2100::units::commanders::targeting");
	addGuideTopic("wz2100::units::commanders::detaching");
	addGuideTopic("wz2100::units::commanders::repairs");
	addGuideTopic("wz2100::units::commanders::attaching", SHOWTOPIC_FIRSTADD);
}

function __camDoAddVTOLDefenseTopicsImpl()
{
	addGuideTopic("wz2100::units::propulsions::vtols::defendingagainst", SHOWTOPIC_FIRSTADD);
}

function __camDoAddVTOLDefenseTopics()
{
	// delayed by a bit so the player hopefully has a solid chance to notice the VTOLs
	queue("__camDoAddVTOLDefenseTopicsImpl", camSecondsToMilliseconds(2));
}

function __camDoAddVTOLUseTopics()
{
	queue("__camDoAddVTOLUseTopicsImpl", camSecondsToMilliseconds(1));
}

function __camDoAddCommanderUseTopics()
{
	queue("__camDoAddCommanderUseTopicsImpl", camSecondsToMilliseconds(1));
}

function __camGuideTopicCheckResearchComplete(targetResearchName, justResearchedObj = null)
{
	if (justResearchedObj && justResearchedObj.name == targetResearchName)
	{
		return true;
	}
	else if (justResearchedObj == null)
	{
		const res = getResearch(targetResearchName);
		if (res && res.done)
		{
			return true;
		}
	}
	return false;
}

function __camProcessResearchGatedGuideTopics(research = null)
{
	const __SHOW_FLAGS = (research == null) ? 0 : SHOWTOPIC_FIRSTADD;
	// First "different" weapon type
	if (__camGuideTopicCheckResearchComplete('R-Wpn-Flamer01Mk1', research))
	{
		// in this case, the category topic must come first (as adding the child topics will also add it, but we want the category topic to be what's displayed)
		addGuideTopic("wz2100::weapons", __SHOW_FLAGS);
		addGuideTopic("wz2100::weapons::antipersonnel");
		addGuideTopic("wz2100::weapons::flamer");
		addGuideTopic("wz2100::units::thermaldamage");
	}
	// Repair Turret researched
	if (__camGuideTopicCheckResearchComplete('R-Sys-MobileRepairTurret01', research))
	{
		addGuideTopic("wz2100::units::repairing", __SHOW_FLAGS);
	}
	// First Module researched
	if (__camGuideTopicCheckResearchComplete('R-Struc-PowerModuleMk1', research))
	{
		addGuideTopic("wz2100::structures::modules", __SHOW_FLAGS);
	}
	// Sensor Turret researched
	if (__camGuideTopicCheckResearchComplete('R-Sys-Sensor-Turret01', research))
	{
		// in this case, the category topic must come first (as adding the child topics will also add it, but we want the category topic to be what's displayed)
		addGuideTopic("wz2100::units::sensors", __SHOW_FLAGS);
		addGuideTopic("wz2100::units::sensors::unassigning");
		addGuideTopic("wz2100::units::sensors::using");
	}
	// First "All-Rounder" weapon researched
	if (__camGuideTopicCheckResearchComplete('R-Wpn-Cannon1Mk1', research))
	{
		addGuideTopic("wz2100::weapons::allrounder", __SHOW_FLAGS);
	}
	// First "Artillery" weapon researched
	if (__camGuideTopicCheckResearchComplete('R-Wpn-Mortar01Lt', research))
	{
		addGuideTopic("wz2100::weapons::artillery", __SHOW_FLAGS);
	}
	// Half-Track Propulsion researched
	if (__camGuideTopicCheckResearchComplete('R-Vehicle-Prop-Halftracks', research))
	{
		addGuideTopic("wz2100::units::propulsions::wheels");
		addGuideTopic("wz2100::units::propulsions::halftracks", __SHOW_FLAGS);
	}
	// First "Anti-Tank" weapon researched
	if (__camGuideTopicCheckResearchComplete('R-Wpn-Rocket05-MiniPod', research))
	{
		addGuideTopic("wz2100::weapons::antitank", __SHOW_FLAGS);
	}
	// Tracked Propulsion researched
	if (__camGuideTopicCheckResearchComplete('R-Vehicle-Prop-Tracks', research))
	{
		addGuideTopic("wz2100::units::propulsions::tracks", __SHOW_FLAGS);
	}
	// First (and only) Bunker Buster weapon researched
	if (__camGuideTopicCheckResearchComplete('R-Wpn-Rocket03-HvAT', research))
	{
		addGuideTopic("wz2100::weapons::bunkerbuster", __SHOW_FLAGS);
	}
	// First "Anti-Air" weapon type
	if (__camGuideTopicCheckResearchComplete('R-Wpn-AAGun03', research))
	{
		addGuideTopic("wz2100::weapons::antiair", __SHOW_FLAGS);
	}
	// Command Turret researched
	if (__camGuideTopicCheckResearchComplete('R-Comp-CommandTurret01', research))
	{
		// in this case, the category topic must come first (as adding the child topics will also add it, but we want the category topic to be what's displayed)
		addGuideTopic("wz2100::units::commanders", __SHOW_FLAGS);
	}
	// Repair Facility researched
	if (__camGuideTopicCheckResearchComplete('R-Struc-RepairFacility', research))
	{
		addGuideTopic("wz2100::structures::repairfacility", __SHOW_FLAGS);
	}
	// VTOL Factory researched
	if (__camGuideTopicCheckResearchComplete('R-Struc-VTOLFactory', research))
	{
		addGuideTopic("wz2100::structures::vtolfactory", __SHOW_FLAGS);
	}
	// Cyborgs
	if (__camGuideTopicCheckResearchComplete('R-Struc-Factory-Cyborg', research))
	{
		addGuideTopic("wz2100::units::propulsions::cyborg");
		addGuideTopic("wz2100::structures::cyborgfactory", __SHOW_FLAGS);
	}
	// Hover Propulsion researched
	if (__camGuideTopicCheckResearchComplete('R-Vehicle-Prop-Hover', research))
	{
		addGuideTopic("wz2100::units::propulsions::hover", __SHOW_FLAGS);
	}
	// VTOL Propulsion researched
	if (__camGuideTopicCheckResearchComplete('R-Vehicle-Prop-VTOL', research))
	{
		addGuideTopic("wz2100::units::propulsions::vtols::weapons");
		addGuideTopic("wz2100::units::propulsions::vtols::using", __SHOW_FLAGS);
	}
	// CB Turret researched
	if (__camGuideTopicCheckResearchComplete('R-Sys-CBSensor-Turret01', research))
	{
		addGuideTopic("wz2100::units::sensors::cb", __SHOW_FLAGS);
	}
	// First (explosive) bomb researched
	if (__camGuideTopicCheckResearchComplete("R-Wpn-Bomb01", research))
	{
		addGuideTopic("wz2100::weapons::bombs::explosive", __SHOW_FLAGS);
	}
	// First incendiary bomb researched
	if (__camGuideTopicCheckResearchComplete("R-Wpn-Bomb03", research))
	{
		addGuideTopic("wz2100::weapons::bombs::incendiary", __SHOW_FLAGS);
	}
	// First defense researched
	if (__camGuideTopicCheckResearchComplete("R-Defense-Tower01", research))
	{
		addGuideTopic("wz2100::general::defendingbase", __SHOW_FLAGS);
	}
}

function __camEnableGuideTopics()
{
	// Always enable (most) general topics & unit orders
	addGuideTopic("wz2100::general::**", 0, ["wz2100::general::artifacts", "wz2100::general::researching", "wz2100::general::power", "wz2100::general::defendingbase"]);
	addGuideTopic("wz2100::unitorders::**");
	// Basic base / structure topics
	addGuideTopic("wz2100::structures::building");
	addGuideTopic("wz2100::structures::demolishing");
	const __IS_ALPHA_ONE = (__camNextLevel === cam_levels.alpha2);
	if (!__IS_ALPHA_ONE) // If not very first original campaign level (CAM1A), which displays these in response to events, add them
	{
		addGuideTopic("wz2100::general::artifacts");
		addGuideTopic("wz2100::general::researching");
		addGuideTopic("wz2100::general::power");
		addGuideTopic("wz2100::general::defendingbase");
		// Basic structure topics
		addGuideTopic("wz2100::structures::hq");
		addGuideTopic("wz2100::structures::researchfacility");
		addGuideTopic("wz2100::structures::oilderrick");
		addGuideTopic("wz2100::structures::powergenerator");
		addGuideTopic("wz2100::structures::rallypoint");
		addGuideTopic("wz2100::structures::factory");
		// Basic units topics
		addGuideTopic("wz2100::units::building");
		addGuideTopic("wz2100::units::designing");
	}
	// Handle research-driven topics (for things already researched - i.e. on savegame load or starting a later campaign)
	__camProcessResearchGatedGuideTopics();
	// Handle built-unit triggered topics
	if (countDroid(DROID_COMMAND, CAM_HUMAN_PLAYER) > 0)
	{
		addGuideTopic("wz2100::units::commanders::**");
	}
	let foundDroids_VTOL = false;
	const droids = enumDroid(CAM_HUMAN_PLAYER);
	for (let x = 0, len = droids.length; x < len; ++x)
	{
		const droid = droids[x];
		if (droid.isVTOL)
		{
			foundDroids_VTOL = true;
			break; // if checking for anything else in the future, remove this
		}
	}
	if (foundDroids_VTOL)
	{
		addGuideTopic("wz2100::units::propulsions::vtols::**");
	}
}

function __camEnableGuideTopicsForTransport(transport)
{
	const droids = enumCargo(transport);
	for (let i = 0, len = droids.length; i < len; ++i)
	{
		const droid = droids[i];
		if (droid.droidType === DROID_COMMAND)
		{
			addGuideTopic("wz2100::units::commanders::**");
		}
	}
}