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