Debian Codegraph @

Descent3/Mission.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/Mission.h $
21 * $Revision: 41 $
22 * $Date: 4/23/99 3:33p $
23 * $Author: Kevin $
24 *
25 * Mission level sequencing and management.
26 *
27 * $Log: /DescentIII/main/Mission.h $
28 *
29 * 41 4/23/99 3:33p Kevin
30 * mission file/multiplayer mod keyword system
31 *
32 * 40 4/22/99 6:21p Kevin
33 * mission keywords
34 *
35 * 39 4/08/99 3:13p Matt
36 * Finished cleaning up level sequencing code. Got rid of all the "level
37 * minus one" stuff.
38 *
39 * 38 4/03/99 5:23p Matt
40 * Removed name, author, & description from the mission level structure.
41 *
42 * 37 4/03/99 5:05p Samir
43 * added ENDMISSION keyword to end a mission after a certain level.
44 *
45 * 36 3/24/99 1:23p Kevin
46 * Support for level specific progress screens.
47 *
48 * 35 2/10/99 4:56p Kevin
49 * Better progress indicator & prepare for Descent message
50 *
51 * 34 1/20/99 4:20p Samir
52 * finished secret level implementation.
53 *
54 * 33 1/19/99 1:15p Samir
55 * add on missions.
56 *
57 * 32 1/13/99 12:43p Jason
58 * fixed flickering exit menu screen
59 *
60 * 31 1/08/99 2:55p Samir
61 * Ripped out OSIRIS1.
62 *
63 * 30 1/05/99 10:59a Samir
64 * readded level objective flags.
65 *
66 * 29 1/04/99 5:44p Samir
67 * added game state flags.
68 *
69 * 28 12/16/98 3:24p Samir
70 * new way to get info on a mission (used to determine training mission
71 * too.)
72 *
73 * 27 12/16/98 1:57p Samir
74 * Replaced CleanupString2 with CleanupStr
75 *
76 * 26 12/03/98 12:51p Samir
77 * music score specified per level.
78 *
79 * 25 10/18/98 2:58p Jason
80 * fixes for beta4
81 *
82 * 24 10/13/98 3:48p Samir
83 * added error checking if script failed to load (default).
84 *
85 * 23 10/08/98 7:29p Samir
86 * revamped sequencing.
87 *
88 * 22 10/02/98 5:46p Samir
89 * took out mission file objective text and replaced with level goals.
90 *
91 * 21 8/24/98 5:04p Kevin
92 * Made msn files have the option to not be playable in multiplayer
93 *
94 * 20 8/18/98 1:10a Samir
95 * some reorg of scripting and intrasave mission managment.
96 *
97 * 19 7/31/98 5:19p Samir
98 * mission filenames are dynamically allocated now to allow for pathnames
99 * (since we'd have too many 256 char arrays per level.
100 *
101 * 18 6/18/98 4:49p Kevin
102 * Updated multiplayer menus
103 *
104 * 17 5/21/98 2:32p Samir
105 * added full support for intra-mission level branching.
106 *
107 * 16 4/20/98 11:30a Jason
108 * Added ShowProgressScreen function
109 *
110 * 15 4/18/98 7:17a Samir
111 * Added level objective descriptions to mission file.
112 *
113 * 14 4/14/98 7:50p Matt
114 * Added system to keep info for each level
115 *
116 * 13 4/02/98 11:11a Samir
117 * Error checking for level load/misison init fail.
118 *
119 * 12 3/13/98 12:09p Samir
120 * Added InitMissionScript function header.
121 *
122 * 11 2/08/98 5:01p Samir
123 * New game sequencing changes.
124 *
125 * 10 11/12/97 2:47p Samir
126 * Added mission briefing name.
127 *
128 * 9 10/03/97 11:58a Samir
129 * Added mission name
130 *
131 * 8 10/02/97 12:36p Samir
132 * Redid game sequencing flow.
133 *
134 * 7 9/30/97 5:33p Samir
135 * Added GameSequencer.
136 *
137 * 6 9/24/97 2:58p Samir
138 * Moved some script defines from mission.h to ObjScript.h
139 *
140 * 5 9/10/97 1:59p Samir
141 * Added D3XProgram var to level structure.
142 *
143 * 4 8/15/97 6:33p Samir
144 * Changes reflecting enhanced editor scripting.
145 *
146 * 3 8/12/97 3:25p Samir
147 * Added QuickStart functions.
148 *
149 * 2 8/05/97 9:59a Samir
150 * Scripting stuff.
151 *
152 * 4 6/05/97 12:21p Samir
153 * Added more mission commands.
154 *
155 * 3 5/16/97 3:11p Samir
156 * Added a mission name and mission initializer.
157 *
158 * 2 5/15/97 2:09p Samir
159 * Added a bunch of sequencing from level to level, loading mission.
160 *
161 * 1 4/29/97 11:57a Samir
162 * Initial revision
163 *
164 * $NoKeywords: $
165 */
166
167 #ifndef MISSION_H
168 #define MISSION_H
169
170 #include "pstypes.h"
171 #include "descent.h"
172
173 // *** CONSTANTS ***
174 #define LOAD_PROGRESS_START 1
175 #define LOAD_PROGRESS_LOADING_LEVEL 2
176 #define LOAD_PROGRESS_PAGING_DATA 3
177 #define LOAD_PROGRESS_PREPARE 4
178 #define LOAD_PROGRESS_DONE 200
179
180 // Load level progress worker
181 void LoadLevelProgress(int step, float percent, const char *chunk = NULL);
182
183 // array constants
184 const int MSN_FILENAMELEN = _MAX_PATH, MSN_URLLEN = 256;
185
186 #define MAX_KEYWORDLEN 300
187
188 // increase this value if you are going to add more levels to a mission than the max.
189 const int MAX_LEVELS_PER_MISSION = 30;
190
191 // mission flags.
192 const unsigned LVLFLAG_STARTMOVIE = 1, LVLFLAG_ENDMOVIE = 2, LVLFLAG_BRIEFING = 4, LVLFLAG_SHIPSELECT = 8,
193 LVLFLAG_SPAWNSECRET = 16, LVLFLAG_SPECIALHOG = 32, LVLFLAG_BRANCH = 64, LVLFLAG_UNUSED = 128,
194 LVLFLAG_SCORE = 256, LVLFLAG_FINAL = 512;
195
196 const int LVLOBJ_NUM = 4;
197 const uint16_t LVLOBJF_SECONDARY1 = 1, LVLOBJF_SECONDARY2 = 2, LVLOBJF_SECONDARY3 = 4, LVLOBJF_SECONDARY4 = 8;
198
199 // Struct for info about the current level
200 struct level_info {
201 char name[100];
202 char designer[100];
203 char copyright[100];
204 char notes[1000];
205 };
206
207 // Info about the current level
208 extern level_info Level_info;
209
210 // level information
211 struct tLevelNode {
212 // level flags
213 unsigned flags; // level flags
214 unsigned objective_flags; // level objective flags
215
216 // movies
217 char *moviename;
218 char *endmovie;
219
220 // level filename
221 char *filename; // mine filename.
222 char *briefname; // briefing filename
223 char *hog; // hog file name for this level
224 char *score; // music score of level
225 char *progress; // File name containing the progress background screen
226
227 // level branching
228 uint8_t lvlbranch0, lvlbranch1; // FORK or BRANCH command
229 uint8_t secretlvl; // SECRET command
230 uint8_t pad;
231 };
232
233 // predefine mission state flags
234 #define MSN_STATE_SECRET_LEVEL 0x80000000
235
236 struct tMission {
237 int mn3_handle; // if this mission was loaded from an MN3, this is the handle.
238
239 unsigned game_state_flags; // game state information stored here (manipulated by scripting)
240 char *filename; // filename of mission.
241 char name[MSN_NAMELEN]; // name of mission
242 char author[MSN_NAMELEN]; // author of mission.
243 char desc[MSN_NAMELEN * 4]; // description of mission
244 char *hog; // default hog filename
245 char email[MSN_URLLEN]; // email and web location
246 char web[MSN_URLLEN];
247 bool multiplayable; // this level is multiplayer playable
248 bool singleplayable; // this level is playable as a single player game
249 bool training_mission; // is this mission a training mission?
250
251 // listing of levels.
252 int num_levels; // number of levels
253 int cur_level; // current level playing.
254 tLevelNode *levels; // array of levels
255 };
256
257 // structyre used to get information about a mission
258 struct tMissionInfo {
259 char name[MSN_NAMELEN];
260 char author[MSN_NAMELEN];
261 char desc[MSN_NAMELEN * 4];
262 bool multi;
263 bool single;
264 bool training;
265 int n_levels;
266 char keywords[MAX_KEYWORDLEN]; // Keywords for mods, so you can see if this mission supports a given mod
267 };
268
269 // Scripting information
270
271 // the current mission being played.
272 extern tMission Current_mission;
273 extern tLevelNode *Current_level;
274
275 extern char D3MissionsDir[];
276
277 // Get the name field out of the mission file
278 const char *GetMissionName(const char *mission);
279
280 // initializes mission system.
281 void InitMission();
282
283 // reset all states for a mission
284 void ResetMission();
285
286 // loads and verifies a mission as the current mission, returns if valid of not.
287 bool LoadMission(const char *msn);
288
289 // initializes a level's script.
290 void InitLevelScript();
291
292 // frees a level's script
293 void FreeLevelScript();
294
295 // does a mission briefing, returns if mission was canceled, a false, or 0 value.
296 bool DoMissionBriefing(int level);
297
298 // does the end mission stuff
299 void DoEndMission();
300
301 // does the mission movie stuff
302 void DoMissionMovie(const char *movie);
303
304 // loads a level and sets it as current level in mission
305 bool LoadMissionLevel(int level);
306
307 // initializes the mission script
308 bool InitMissionScript();
309
310 // Objectives
311 void CompletedPrimaryObjective();
312
313 // Shows text on a background
314 void ShowProgressScreen(const char *str, const char *str2 = NULL, bool flip = true);
315
316 // See if a mission file is multiplayer playable.
317 bool IsMissionMultiPlayable(const char *mission);
318
319 // return information about a mission
320 bool GetMissionInfo(const char *msnfile, tMissionInfo *msn);
321
322 // Returns the max number of teams this mission can support for this mod, or
323 //-1 if this level shouldn't be played with this mission
324 // Return values:
325 // -1 Bad match -- this level and this mod shouldn't be played together!
326 // MAX_NET_PLAYERS -- This is playable with any number of teams the mod wants
327 int MissionGetKeywords(const char *mission, char *keywords);
328
329 #ifdef EDITOR
330 // Used by editor to load all necessary elements for level playing for systems
331 // not initialized in editor, but only in game.
332 void QuickStartMission();
333
334 // Used by game->editor to free up all extra game mission elements not needed in editor.
335 void QuickEndMission();
336
337 #endif
338
339 #endif