2 * $Logfile: /Freespace2/code/Mission/MissionGoals.h $
7 * Header file for Mission support. Included detection of primary
11 * Revision 1.1 2002/05/03 03:28:12 root
15 * 8 9/06/99 9:46p Jefff
16 * skip mission support
18 * 7 8/28/99 4:54p Dave
19 * Fixed directives display for multiplayer clients for wings with
20 * multiple waves. Fixed hud threat indicator rendering color.
22 * 6 7/29/99 3:06p Andsager
23 * Increase max number of events to 150
25 * 5 7/29/99 2:58p Jefff
26 * Ingame objective screen icon key now uses normal objective icons and
27 * text is drawn in code.
29 * 4 2/17/99 2:10p Dave
30 * First full run of squad war. All freespace and tracker side stuff
33 * 3 11/05/98 5:55p Dave
34 * Big pass at reducing #includes
36 * 2 10/07/98 10:53a Dave
39 * 1 10/07/98 10:49a Dave
41 * 51 5/21/98 2:47a Lawrance
42 * Fix some problems with event music
44 * 50 4/15/98 9:05a Allender
45 * fix skpping of training mission with branchs
47 * 49 4/03/98 2:47p Allender
48 * made directives act different when multiple waves of a wing take a long
51 * 48 3/31/98 12:23a Allender
52 * changed macro names of campaign types to be more descriptive. Added
53 * "team" to objectives dialog for team v. team missions. Added two
54 * distinct multiplayer campaign types
56 * 47 2/27/98 4:37p Hoffoss
57 * Combined Objectives screen into Mission Log screen.
59 * 46 2/26/98 10:07p Hoffoss
60 * Rewrote state saving and restoring to fix bugs and simplify the code.
62 * 45 2/22/98 4:30p John
63 * More string externalization classification
65 * 44 2/20/98 8:33p Lawrance
66 * Added mission_goals_incomplete()
68 * 43 1/30/98 4:24p Hoffoss
69 * Added a 3 second delay for directives before they get displayed.
71 * 42 1/28/98 6:21p Dave
72 * Made the standalone use ~8 megs less memory. Fixed multiplayer submenu
75 * 41 1/27/98 11:00a Lawrance
76 * Fix bug with showing number of resolved goals in the objective status
79 * 40 1/15/98 5:23p Lawrance
80 * Add HUD gauge to indicate completed objectives.
82 * 39 1/12/98 5:17p Allender
83 * fixed primary fired problem and ship warp out problem. Made new
84 * mission goal info packet to deal with goals more accurately.
86 * 38 12/29/97 12:16p Johnson
89 * 37 12/22/97 6:07p Hoffoss
90 * Made directives flash when completed, fixed but with is-destroyed
93 * 36 12/19/97 12:43p Hoffoss
94 * Changed code to allow counts in directives.
96 * 35 12/01/97 12:26a Lawrance
97 * Add flag MGF_NO_MUSIC to mission_goal struct, to avoid playing music
100 * 34 11/02/97 10:09p Lawrance
101 * add source control header
106 #ifndef _MISSIONGOAL_H
107 #define _MISSIONGOAL_H
113 // defines for types of primary and secondary missions
115 #define MAX_GOALS 30 // maximum number of goals for any given mission
117 // defines for types of goals. We will use part of the int field of the mission_goal struct
118 // as a bit field for goal flags
120 #define PRIMARY_GOAL 0
121 #define SECONDARY_GOAL 1
124 // defines for bitfields of type, (and mask to get the type field quickly)
125 #define INVALID_GOAL (1 << 16) // is this goal valid or not?
126 #define GOAL_TYPE_MASK (0xffff) // mask to get us the type
128 // defines for goal status. These status are also used in campaign file for marking goal status
129 // in campaign save file
130 #define GOAL_FAILED 0 // status of goal
131 #define GOAL_COMPLETE 1
132 #define GOAL_INCOMPLETE 2
134 #define PRIMARY_GOALS_COMPLETE 1
135 #define PRIMARY_GOALS_INCOMPLETE 0
136 #define PRIMARY_GOALS_FAILED -1
138 extern char *Goal_type_text(int n);
140 // structures for primary and secondary goals
142 #define MAX_GOAL_TEXT 128
144 #define MGF_NO_MUSIC (1<<0) // don't play any event music when goal is achieved
146 typedef struct mission_goal {
147 char name[NAME_LENGTH]; // used for storing status of goals in player file
148 int type; // primary/secondary/bonus
149 int satisfied; // has this goal been satisfied
150 char message[MAX_GOAL_TEXT]; // Brief description, such as "Destroy all vile aliens!"
151 int rating; // Some importance figure or something.
152 int formula; // Index in Sexp_nodes of this Sexp.
153 int score; // score for this goal
155 int team; // which team is this objective for.
158 extern mission_goal Mission_goals[MAX_GOALS]; // structure for the goals of this mission
159 extern int Num_goals; // number of goals for this mission
161 // structures and defines for mission events
163 #define MAX_MISSION_EVENTS 150
164 #define MISSION_EVENTS_WARN 100
166 // defined for event states. We will also use the satisfied/failed for saving event information
167 // in campaign save file
168 #define EVENT_UNBORN 0 // event can't be evaluated yet
169 #define EVENT_CURRENT 1 // event can currently be evaluated, but not satisfied or failed yet
170 #define EVENT_SATISFIED 2
171 #define EVENT_FAILED 3
172 #define EVENT_INCOMPLETE 4 // used in campaign save file. used when event isn't satisfied yet
174 #define MEF_CURRENT (1 << 0) // is event current or past current yet?
175 #define MEF_DIRECTIVE_SPECIAL (1 << 1) // used to mark a directive as true even though not fully satisfied
176 #define MEF_DIRECTIVE_TEMP_TRUE (1 << 2) // this directive is temporarily true.
178 typedef struct mission_event {
179 char name[NAME_LENGTH]; // used for storing status of events in player file
180 int formula; // index into sexpression array for this formula
181 int result; // result of most recent evaluation of event
182 int repeat_count; // number of times to repeat this goal
183 int interval; // interval (in seconds) at which an evaulation is repeated once true.
184 int timestamp; // set at 'interval' seconds when we start to eval.
185 int score; // score for this event
188 char *objective_text;
189 char *objective_key_text;
190 int count; // object count for directive display
192 int born_on_date; // timestamp at which event was born
193 int team; // for multiplayer games
196 extern int Num_mission_events;
197 extern mission_event Mission_events[MAX_MISSION_EVENTS];
198 extern int Mission_goal_timestamp;
199 extern int Event_index; // used by sexp code to tell what event it came from
202 void mission_init_goals( void );
203 void mission_show_goals_init();
204 void mission_show_goals_close();
205 void mission_show_goals_do_frame(float frametime); // displays goals on screen
206 void mission_eval_goals(); // evaluate player goals
207 int mission_ai_goal_achievable( ai_goals *aigp ); // determines if an AI goal is achievable
208 void mission_add_ai_goal( int sexp, ai_info *aip ); // adds a goal onto the given ai_info structure
209 int mission_evaluate_primary_goals(void); // determine if the primary goals for the mission are complete -- returns one of the above defines
210 int mission_goals_met();
212 // function used by single and multiplayer code to change the status on goals
213 void mission_goal_status_change( int goal_num, int new_status);
215 // functions used to change goal validity status
216 void mission_goal_mark_invalid( char *name );
217 void mission_goal_mark_valid( char *name );
219 // function used to mark all goals as invalid, and incomplete goals as invalid.
220 extern void mission_goal_fail_all();
221 extern void mission_goal_fail_incomplete();
223 void mission_goal_fetch_num_resolved(int desired_type, int *num_resolved, int *total, int team = -1);
224 int mission_goals_incomplete(int desired_type, int team = -1);
225 void mission_goal_mark_objectives_complete();
226 void mission_goal_mark_events_complete();
228 int mission_get_event_status(int event);
229 void mission_event_shutdown();
230 void mission_goal_validation_change( int goal_num, int valid );
232 // mark an event as directive special
233 void mission_event_set_directive_special(int event);
234 void mission_event_unset_directive_special(int event);
236 void mission_goal_exit();
238 int ML_objectives_init(int x, int y, int w, int h);
239 void ML_objectives_close();
240 void ML_objectives_do_frame(int scroll_offset);
241 void ML_render_objectives_key(); // renders objectives key on ingame objectives screen