2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
15 * main header file for parsing code
18 * Revision 1.3 2003/05/25 02:30:42 taylor
21 * Revision 1.2 2002/06/09 04:41:13 relnev
22 * added copyright header
24 * Revision 1.1.1.1 2002/05/03 03:28:12 root
28 * 26 8/23/99 6:21p Jefff
29 * added "no traitor" option to missions (and fred)
31 * 25 8/23/99 5:04p Jefff
32 * Added new mission flag to disable built-in messages from playing.
33 * Added fred support as well.
35 * 24 8/16/99 3:53p Andsager
36 * Add special warp in interface in Fred and saving / reading.
38 * 23 8/16/99 2:01p Andsager
39 * Knossos warp-in warp-out.
41 * 22 7/28/99 1:36p Andsager
42 * Modify cargo1 to include flag CARGO_NO_DEPLETE. Add sexp
43 * cargo-no-deplete (only for BIG / HUGE). Modify ship struct to pack
46 * 21 7/26/99 5:50p Dave
47 * Revised ingame join. Better? We'll see....
49 * 20 7/15/99 9:20a Andsager
50 * FS2_DEMO initial checkin
52 * 19 7/02/99 4:31p Dave
53 * Much more sophisticated lightning support.
55 * 18 7/01/99 11:44a Dave
56 * Updated object sound system to allow multiple obj sounds per ship.
57 * Added hit-by-beam sound. Added killed by beam sound.
59 * 17 6/28/99 4:51p Andsager
60 * Add ship-guardian sexp (does not allow ship to be killed)
62 * 16 5/20/99 7:00p Dave
63 * Added alternate type names for ships. Changed swarm missile table
66 * 15 4/26/99 8:49p Dave
67 * Made all pof based nebula stuff full customizable through fred.
69 * 14 4/26/99 12:49p Andsager
70 * Add protect object from beam support to Fred
72 * 13 3/24/99 4:05p Dave
73 * Put in support for assigning the player to a specific squadron with a
74 * specific logo. Preliminary work for doing pos/orient checksumming in
75 * multiplayer to reduce bandwidth.
77 * 12 3/01/99 7:39p Dave
78 * Added prioritizing ship respawns. Also fixed respawns in TvT so teams
79 * don't mix respawn points.
81 * 11 2/26/99 6:01p Andsager
82 * Add sexp has-been-tagged-delay and cap-subsys-cargo-known-delay
84 * 10 2/23/99 8:11p Dave
85 * Tidied up dogfight mode. Fixed TvT ship type problems for alpha wing.
86 * Small pass over todolist items.
88 * 9 2/23/99 2:29p Dave
89 * First run of oldschool dogfight mode.
91 * 8 2/11/99 2:15p Andsager
92 * Add ship explosion modification to FRED
94 * 7 2/03/99 12:42p Andsager
95 * Add escort priority. Modify ship_flags_dlg to include field. Save and
96 * Load. Add escort priority field to ship.
98 * 6 11/14/98 5:32p Dave
99 * Lots of nebula work. Put in ship contrails.
101 * 5 11/05/98 5:55p Dave
102 * Big pass at reducing #includes
104 * 4 10/23/98 3:51p Dave
105 * Full support for tstrings.tbl and foreign languages. All that remains
106 * is to make it active in Fred.
108 * 3 10/07/98 6:27p Dave
109 * Globalized mission and campaign file extensions. Removed Silent Threat
110 * special code. Moved \cache \players and \multidata into the \data
113 * 2 10/07/98 10:53a Dave
116 * 1 10/07/98 10:49a Dave
118 * 147 8/31/98 2:06p Dave
119 * Make cfile sort the ordering or vp files. Added support/checks for
120 * recognizing "mission disk" players.
122 * 146 5/11/98 4:33p Allender
123 * fixed ingame join problems -- started to work on new object updating
124 * code (currently ifdef'ed out)
126 * 145 5/05/98 11:05p Allender
127 * ability to flag mission as "no promotion" where promotions and badges
128 * are *not* granted even if they should be. Slight fix to multiplayer
129 * problem where locking_subsys is wrong for players current target
131 * 144 5/04/98 6:06p Lawrance
132 * Make red alert mode work!
134 * 143 4/20/98 4:56p Allender
135 * allow AI ships to respawn as many times as there are respawns in the
138 * 142 4/14/98 12:08a Allender
139 * save wingman status information in parse object and restore from parse
140 * object when respawned
142 * 141 4/13/98 10:25p Hoffoss
143 * Added a flag for subspace missions, and for aboard the Galatea or
146 * 140 4/06/98 10:24p Dave
147 * Fixed up Netgame.respawn for the standalone case.
149 * 139 4/03/98 12:17a Allender
150 * new sexpression to detect departed or destroyed. optionally disallow
151 * support ships. Allow docking with escape pods
153 * 138 4/02/98 6:31p Lawrance
154 * reduce MAX_SUBSYS_STATUS to 125 if DEMO defined
156 * 137 3/26/98 5:24p Allender
157 * put in respawn edit box into mission notes dialog. Made loading of
158 * missions/campaign happen when first entering the game setup screen.
160 * 136 3/18/98 10:38p Allender
161 * added required "num players" for multiplayer missions. Put in required
162 * "num players" for multiplayer campaigns. Added campaign editor support
163 * to determine "num players"
165 * 135 3/16/98 8:27p Allender
166 * Fred support for two new AI flags -- kamikaze and no dynamic goals.
177 #include "missionbriefcommon.h"
180 #define NUM_NEBULAS 3 // how many background nebulas we have altogether
181 #define NUM_NEBULA_COLORS 9
183 // arrival anchor types
184 #define SPECIAL_ARRIVAL_ANCHORS_OFFSET 90000 // offset used to avoid conflicting with ship anchors
185 #define ANY_FRIENDLY (SPECIAL_ARRIVAL_ANCHORS_OFFSET + 0)
186 #define ANY_HOSTILE (SPECIAL_ARRIVAL_ANCHORS_OFFSET + 1)
187 #define ANY_NEUTRAL (SPECIAL_ARRIVAL_ANCHORS_OFFSET + 2)
188 #define ANY_FRIENDLY_PLAYER (SPECIAL_ARRIVAL_ANCHORS_OFFSET + 3)
189 #define ANY_HOSTILE_PLAYER (SPECIAL_ARRIVAL_ANCHORS_OFFSET + 4)
190 #define ANY_NEUTRAL_PLAYER (SPECIAL_ARRIVAL_ANCHORS_OFFSET + 5)
192 // update version when mission file format changes, and add approprate code
193 // to check loaded mission version numbers in the parse code. Also, be sure
194 // to update both MissionParse and MissionSave (FRED) when changing the
195 // mission file format!
196 #define MISSION_VERSION 0.10f
197 #define FRED_MISSION_VERSION 0.10f
199 // maximum number of starting wings for the player
200 #define MAX_STARTING_WINGS 3
201 extern const char *Starting_wing_names[MAX_STARTING_WINGS+1];
203 #define WING_PLAYER_BASE 0x80000 // used by Fred to tell ship_index in a wing points to a player
205 // defines used for parse_mission() to tell what kind of information to get from the mission file
206 #define MISSION_PARSE_MISSION_INFO 1
208 // bitfield definitions for missions game types
209 #define OLD_MAX_GAME_TYPES 4 // needed for compatibility
210 #define OLD_GAME_TYPE_SINGLE_ONLY 0
211 #define OLD_GAME_TYPE_MULTI_ONLY 1
212 #define OLD_GAME_TYPE_SINGLE_MULTI 2
213 #define OLD_GAME_TYPE_TRAINING 3
215 #define MAX_MISSION_TYPES 5
216 #define MISSION_TYPE_SINGLE (1<<0)
217 #define MISSION_TYPE_MULTI (1<<1)
218 #define MISSION_TYPE_TRAINING (1<<2)
219 #define MISSION_TYPE_MULTI_COOP (1<<3)
220 #define MISSION_TYPE_MULTI_TEAMS (1<<4)
221 #define MISSION_TYPE_MULTI_DOGFIGHT (1<<5)
223 #define MISSION_FLAG_SUBSPACE (1<<0) // mission takes place in subspace
224 #define MISSION_FLAG_NO_PROMOTION (1<<1) // cannot get promoted or badges in this mission
225 #define MISSION_FLAG_FULLNEB (1<<2) // mission is a full nebula mission
226 #define MISSION_FLAG_NO_BUILTIN_MSGS (1<<3) // disables builtin msgs
227 #define MISSION_FLAG_NO_TRAITOR (1<<4) // player cannot become a traitor
229 // some mice macros for mission type
230 #define IS_MISSION_MULTI_COOP (The_mission.game_type & MISSION_TYPE_MULTI_COOP)
231 #define IS_MISSION_MULTI_TEAMS (The_mission.game_type & MISSION_TYPE_MULTI_TEAMS)
232 #define IS_MISSION_MULTI_DOGFIGHT (The_mission.game_type & MISSION_TYPE_MULTI_DOGFIGHT)
234 #define MISSION_DESC_LENGTH 512
236 typedef struct mission {
237 char name[NAME_LENGTH];
238 char author[NAME_LENGTH];
240 char created[DATE_TIME_LENGTH];
241 char modified[DATE_TIME_LENGTH];
242 char notes[NOTES_LENGTH];
243 char mission_desc[MISSION_DESC_LENGTH];
246 int num_players; // valid in multiplayer missions -- number of players supported
247 uint num_respawns; // valid in multiplayer missions -- number of respawns allowed
250 int disallow_support; // should support ships be disallowed.
251 char tour_name[NAME_LENGTH];
252 char pre_briefing_cutscene[FILESPEC_LENGTH];
253 char pre_mission_cutscene[FILESPEC_LENGTH];
254 char next_mission_success[NAME_LENGTH];
255 char next_mission_partial[NAME_LENGTH];
256 char next_mission_failure[NAME_LENGTH];
257 char squad_filename[MAX_FILENAME_LEN+1]; // if the player has been reassigned to a squadron, this is the filename of the logo, otherwise empty string
258 char squad_name[NAME_LENGTH+1]; // if the player has been reassigned to a squadron, this is the name of the squadron, otherwise empty string
262 // NOTE: MAX_CARGO MUST REMAIN <= 64 (CARGO_NO_DEPLETE) for NO_DEPLETE to work.
263 #define CARGO_INDEX_MASK 0xBF
264 #define CARGO_NO_DEPLETE 0x40
267 extern mission The_mission;
268 extern char Mission_filename[80]; // filename of mission in The_mission (Fred only)
271 #define MAX_FORMATION_NAMES 3
272 #define MAX_STATUS_NAMES 3
273 #define MAX_TEAM_NAMES 4
275 // defines for arrival locations. These defines should match their counterparts in the arrival location
277 #define MAX_ARRIVAL_NAMES 4
278 #define ARRIVE_AT_LOCATION 0
279 #define ARRIVE_NEAR_SHIP 1
280 #define ARRIVE_IN_FRONT_OF_SHIP 2
281 #define ARRIVE_FROM_DOCK_BAY 3
283 // defines for departure locations. These defines should match their counterparts in the departure location
285 #define MAX_DEPARTURE_NAMES 2
286 #define DEPART_AT_LOCATION 0
287 #define DEPART_AT_DOCK_BAY 1
289 #define MAX_GOAL_TYPE_NAMES 3
291 // alternate ship type names
292 #define MAX_ALT_TYPE_NAMES 10
293 extern char Mission_alt_types[MAX_ALT_TYPE_NAMES][NAME_LENGTH];
294 extern int Mission_alt_type_count;
296 // These species defines must match the contents of the Species_names[MAX_SPECIES_NAMES] array.
297 #define MAX_SPECIES_NAMES 3
298 #define SPECIES_TERRAN 0
299 #define SPECIES_VASUDAN 1
300 #define SPECIES_SHIVAN 2
301 #define SPECIES_NONE 3
303 #if defined(FS2_DEMO) || defined(FS1_DEMO)
304 #define MAX_SUBSYS_STATUS 125
306 #define MAX_SUBSYS_STATUS 250
309 #define MAX_SPECIAL_ARRIVAL_ANCHORS 6
310 extern const char *Special_arrival_anchor_names[MAX_SPECIAL_ARRIVAL_ANCHORS];
312 extern char *Ship_class_names[MAX_SHIP_TYPES];
313 extern const char *Iff_names[MAX_IFF];
314 extern const char *Ai_behavior_names[MAX_AI_BEHAVIORS];
315 extern char *Formation_names[MAX_FORMATION_NAMES];
316 extern const char *Team_names[MAX_TEAM_NAMES];
317 extern int Team_names_index_xlate[MAX_TEAM_NAMES_INDEX+1];
318 extern const char *Status_desc_names[MAX_STATUS_NAMES];
319 extern const char *Status_type_names[MAX_STATUS_NAMES];
320 extern const char *Status_target_names[MAX_STATUS_NAMES];
321 extern const char *Arrival_location_names[MAX_ARRIVAL_NAMES];
322 extern const char *Departure_location_names[MAX_ARRIVAL_NAMES];
323 extern const char *Goal_type_names[MAX_GOAL_TYPE_NAMES];
324 extern const char *Species_names[MAX_SPECIES_NAMES];
325 extern const char *Reinforcement_type_names[];
326 extern char *Object_flags[];
327 extern const char *Parse_object_flags[];
328 extern const char *Icon_names[];
330 extern char *Cargo_names[MAX_CARGO];
331 extern char Cargo_names_buf[MAX_CARGO][NAME_LENGTH];
333 extern char Mission_parse_storm_name[NAME_LENGTH];
336 extern int Num_ai_behaviors;
337 extern int Num_ai_classes;
338 extern int Num_cargo;
339 extern int Num_status_names;
340 extern int Num_arrival_names;
341 extern int Num_formation_names;
342 extern int Num_goal_type_names;
343 extern int Num_team_names;
344 extern int Num_reinforcement_type_names;
345 extern int Player_starts;
346 extern fix Entry_delay_time;
348 extern ushort Current_file_checksum;
349 extern int Current_file_length;
351 #define SUBSYS_STATUS_NO_CHANGE -999
353 typedef struct subsys_status {
354 char name[NAME_LENGTH];
355 float percent; // percent damaged
356 int primary_banks[MAX_PRIMARY_BANKS];
357 int secondary_banks[MAX_SECONDARY_BANKS];
358 int secondary_ammo[MAX_SECONDARY_BANKS];
360 int subsys_cargo_name;
364 // information from a $OBJECT: definition is read into this struct to
365 // be copied into the real object, ship, etc. structs
366 typedef struct p_object {
367 struct p_object *next, *prev;
368 char name[NAME_LENGTH];
374 int behavior; // ai_class;
375 int ai_goals; // sexp of lists of goals that this ship should try and do
378 int status_type[MAX_OBJECT_STATUS];
379 int status[MAX_OBJECT_STATUS];
380 int target[MAX_OBJECT_STATUS];
381 int arrival_location;
382 int arrival_distance; // used when arrival location is near or in front of some ship
383 int arrival_anchor; // ship used for anchoring an arrival point
384 int arrival_cue; // Index in Sexp_nodes of this sexp.
386 int subsys_index; // index into subsys_status array
387 int subsys_count; // number of elements used in subsys_status array
388 int initial_velocity;
392 int departure_location;
393 int departure_anchor;
394 int departure_cue; // Index in Sexp_nodes of this sexp.
397 char misc[NAME_LENGTH];
399 int wingnum; // set to -1 if not in a wing -- Wing array index otherwise
400 int flags; // mission savable flags
401 int escort_priority; // priority in escort list
403 int hotkey; // hotkey number (between 0 and 9) -1 means no hotkey
405 int orders_accepted; // which orders this ship will accept from the player
406 char docked_with[NAME_LENGTH];
407 char docker_point[NAME_LENGTH];
408 char dockee_point[NAME_LENGTH];
409 int group; // group object is within or -1 if none.
411 float kamikaze_damage; // base damage for a kamikaze attack
412 int special_exp_index;
413 ushort net_signature; // network signature this object can have
415 char wing_status_wing_index; // wing index (0-4) in wingman status gauge
416 char wing_status_wing_pos; // wing position (0-5) in wingman status gauge
418 uint respawn_count; // number of respawns for this object. Applies only to player wing ships in multiplayer
419 int respawn_priority; // priority this ship has for controlling respawn points
421 char alt_type_index; // optional alt type index
424 // defines for flags used for p_objects when they are created. Used to help create
425 // special circumstances for those ships. The order that these bitfields appear
426 // in this list MUST match the order that they appear in the flags array in MissionParse.cpp!!!!
428 #define MAX_PARSE_OBJECT_FLAGS 20
430 #define P_OF_CARGO_KNOWN (1<<0)
431 #define P_SF_IGNORE_COUNT (1<<1)
432 #define P_OF_PROTECTED (1<<2)
433 #define P_SF_REINFORCEMENT (1<<3)
434 #define P_OF_NO_SHIELDS (1<<4)
435 #define P_SF_ESCORT (1<<5)
436 #define P_OF_PLAYER_START (1<<6)
437 #define P_SF_NO_ARRIVAL_MUSIC (1<<7)
438 #define P_SF_NO_ARRIVAL_WARP (1<<8)
439 #define P_SF_NO_DEPARTURE_WARP (1<<9)
440 #define P_SF_LOCKED (1<<10)
441 #define P_SF_INVULNERABLE (1<<11)
442 #define P_SF_HIDDEN_FROM_SENSORS (1<<12)
443 #define P_SF_SCANNABLE (1<<13) // ship is a "scannable" ship
444 #define P_AIF_KAMIKAZE (1<<14)
445 #define P_AIF_NO_DYNAMIC (1<<15)
446 #define P_SF_RED_ALERT_STORE_STATUS (1<<16)
447 #define P_OF_BEAM_PROTECTED (1<<17)
448 #define P_SF_GUARDIAN (1<<18)
449 #define P_KNOSSOS_WARP_IN (1<<19)
452 // the following parse object flags are used internally by Freespace
453 #define P_SF_USE_UNIQUE_ORDERS (1<<26) // tells a newly created ship to use the default orders for that ship
454 #define P_SF_INITIALLY_DOCKED (1<<27) // is this parse object initially docked with something else
455 #define P_SF_CANNOT_ARRIVE (1<<28) // used to indicate that this ship's arrival cue will never be true
456 #define P_SF_WARP_BROKEN (1<<29) // warp engine should be broken for this ship
457 #define P_SF_WARP_NEVER (1<<30) // warp drive is destroyed
458 #define P_SF_PLAYER_START_VALID (1<<31) // this is a valid player start object
460 extern p_object ship_arrival_list; // used by sexpression parser
462 #if defined(FS2_DEMO) || defined(FS1_DEMO)
463 #define MAX_SHIP_ARRIVALS 45
464 #define MAX_WING_ARRIVALS 10
466 #define MAX_SHIP_ARRIVALS 90 // maximum of 90 objects can arrive later
467 #define MAX_WING_ARRIVALS 20 // maximum of 20 wings can arrive later
470 extern p_object ship_arrivals[MAX_SHIP_ARRIVALS];
471 extern int num_ship_arrivals;
473 extern p_object Support_ship_pobj, *Arriving_support_ship;
476 int default_ship; // default ship type for player start point (recommended choice)
477 int number_choices; // number of ship choices inside ship_list
478 int ship_list[MAX_SHIP_TYPES];
479 int ship_count[MAX_SHIP_TYPES];
480 int weaponry_pool[MAX_WEAPON_TYPES];
483 #define MAX_P_WINGS 16
484 #define MAX_SHIP_LIST 16
486 #define TOKEN_LENGTH 32
488 extern team_data Team_data[MAX_TEAMS];
489 extern subsys_status Subsys_status[MAX_SUBSYS_STATUS];
490 extern int Subsys_index;
492 extern vector Parse_viewer_pos;
493 extern matrix Parse_viewer_orient;
495 extern int Mission_arrival_timestamp;
496 extern int Mission_departure_timestamp;
497 extern fix Mission_end_time;
499 extern char Parse_names[MAX_SHIPS + MAX_WINGS][NAME_LENGTH];
500 extern int Num_parse_names;
501 extern int Num_teams;
503 extern char Player_start_shipname[NAME_LENGTH];
504 extern int Player_start_shipnum;
505 extern p_object Player_start_pobject;
507 extern int Mission_palette; // index of palette file to use for mission
508 extern int Nebula_index; // index into Nebula_filenames[] of nebula to use in mission.
509 extern const char *Nebula_filenames[NUM_NEBULAS];
510 extern const char *Nebula_colors[NUM_NEBULA_COLORS];
511 extern p_object *Arriving_support_ship;
513 extern char Neb2_texture_name[MAX_FILENAME_LEN];
515 int parse_main(const char *mission_name, int flags = 0);
516 int mission_parse_ship_arrived(const char *shipname);
517 p_object *mission_parse_get_arrival_ship( const char *name );
518 p_object *mission_parse_get_arrival_ship( ushort net_signature );
519 p_object *mission_parse_get_original_ship( ushort net_signature );
520 int parse_create_object(p_object *objp);
522 // used in squadmate messaging stuff to create wings from reinforcements.
523 int parse_wing_create_ships(wing *wingp, int num_to_create, int force = 0, int specific_instance = -1 );
525 // function for getting basic mission data without loading whole mission
526 int mission_parse_is_multi(const char *filename, char *mission_name );
527 int mission_parse_get_multi_mission_info(const char *filename);
529 // called externally from multiplayer code
530 void mission_do_departure(object *objp);
532 // called externally from Freespace.cpp
533 void mission_parse_fixup_players(void);
535 // get a index to a perminently kept around name of a ship or wing
536 int get_parse_name_index(const char *name);
538 // called from freespace game level loop
539 void mission_parse_eval_stuff();
541 // function to set the ramaing time left in the mission
542 void mission_parse_set_end_time( int seconds );
544 // code to warp in a repair ship.
545 void mission_warp_in_support_ship( object *requester_objp );
546 int mission_is_support_ship_arriving( void );
547 void mission_add_to_arriving_support( object *requester_objp );
548 int mission_is_repair_scheduled( object *objp );
549 int mission_remove_scheduled_repair( object *objp );
550 void mission_parse_support_arrived( int objnum );
552 // alternate name stuff
553 int mission_parse_lookup_alt(char *name);
554 void mission_parse_lookup_alt_index(int index, char *out, const int max_outlen);
555 int mission_parse_add_alt(char *name);
556 void mission_parse_reset_alt();
558 // code to save/restore mission parse stuff
559 int get_mission_info(char *filename, mission *missionp = NULL);