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