]> icculus.org git repositories - taylor/freespace2.git/blob - include/missiongoals.h
Initial revision
[taylor/freespace2.git] / include / missiongoals.h
1 /*
2  * $Logfile: /Freespace2/code/Mission/MissionGoals.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  *  Header file for Mission support.  Included detection of primary
8  *  and secondary goals.
9  *
10  * $Log$
11  * Revision 1.1  2002/05/03 03:28:12  root
12  * Initial revision
13  *
14  * 
15  * 8     9/06/99 9:46p Jefff
16  * skip mission support
17  * 
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.
21  * 
22  * 6     7/29/99 3:06p Andsager
23  * Increase max number of events to 150
24  * 
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.
28  * 
29  * 4     2/17/99 2:10p Dave
30  * First full run of squad war. All freespace and tracker side stuff
31  * works.
32  * 
33  * 3     11/05/98 5:55p Dave
34  * Big pass at reducing #includes
35  * 
36  * 2     10/07/98 10:53a Dave
37  * Initial checkin.
38  * 
39  * 1     10/07/98 10:49a Dave
40  * 
41  * 51    5/21/98 2:47a Lawrance
42  * Fix some problems with event music
43  * 
44  * 50    4/15/98 9:05a Allender
45  * fix skpping of training mission with branchs
46  * 
47  * 49    4/03/98 2:47p Allender
48  * made directives act different when multiple waves of a wing take a long
49  * time to reappear
50  * 
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
55  * 
56  * 47    2/27/98 4:37p Hoffoss
57  * Combined Objectives screen into Mission Log screen.
58  * 
59  * 46    2/26/98 10:07p Hoffoss
60  * Rewrote state saving and restoring to fix bugs and simplify the code.
61  * 
62  * 45    2/22/98 4:30p John
63  * More string externalization classification
64  * 
65  * 44    2/20/98 8:33p Lawrance
66  * Added mission_goals_incomplete()
67  * 
68  * 43    1/30/98 4:24p Hoffoss
69  * Added a 3 second delay for directives before they get displayed.
70  * 
71  * 42    1/28/98 6:21p Dave
72  * Made the standalone use ~8 megs less memory. Fixed multiplayer submenu
73  * endgame problem.
74  * 
75  * 41    1/27/98 11:00a Lawrance
76  * Fix bug with showing number of resolved goals in the objective status
77  * popup.
78  * 
79  * 40    1/15/98 5:23p Lawrance
80  * Add HUD gauge to indicate completed objectives.
81  * 
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. 
85  * 
86  * 38    12/29/97 12:16p Johnson
87  * Upped event max.
88  * 
89  * 37    12/22/97 6:07p Hoffoss
90  * Made directives flash when completed, fixed but with is-destroyed
91  * operator.
92  * 
93  * 36    12/19/97 12:43p Hoffoss
94  * Changed code to allow counts in directives.
95  * 
96  * 35    12/01/97 12:26a Lawrance
97  * Add flag  MGF_NO_MUSIC to mission_goal struct, to avoid playing music
98  * for certain goals
99  * 
100  * 34    11/02/97 10:09p Lawrance
101  * add source control header
102  *
103  * $NoKeywords: $
104  */
105
106 #ifndef _MISSIONGOAL_H
107 #define _MISSIONGOAL_H
108
109 #include "object.h"
110 #include "ai.h"
111 #include "cfile.h"
112
113 // defines for types of primary and secondary missions
114
115 #define MAX_GOALS                       30              // maximum number of goals for any given mission
116
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
119
120 #define PRIMARY_GOAL            0
121 #define SECONDARY_GOAL          1
122 #define BONUS_GOAL                      2
123
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
127
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
133
134 #define PRIMARY_GOALS_COMPLETE          1
135 #define PRIMARY_GOALS_INCOMPLETE        0
136 #define PRIMARY_GOALS_FAILED                    -1
137
138 extern char *Goal_type_text(int n);
139
140 // structures for primary and secondary goals
141
142 #define MAX_GOAL_TEXT   128
143
144 #define MGF_NO_MUSIC    (1<<0)          // don't play any event music when goal is achieved
145
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
154         int     flags;                                                  // MGF_
155         int     team;                                                           // which team is this objective for.
156 } mission_goal;
157
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
160
161 // structures and defines for mission events
162
163 #define MAX_MISSION_EVENTS              150
164 #define MISSION_EVENTS_WARN     100
165
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
173
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.
177
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
186         int     chain_delay;
187         int     flags;
188         char    *objective_text;
189         char    *objective_key_text;
190         int     count;                                  // object count for directive display
191         int     satisfied_time;
192         int     born_on_date;                   // timestamp at which event was born
193         int     team;                                           // for multiplayer games
194 } mission_event;
195
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
200
201 // prototypes
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();
211
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);
214
215 // functions used to change goal validity status
216 void mission_goal_mark_invalid( char *name );
217 void mission_goal_mark_valid( char *name );
218
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();
222
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();
227
228 int mission_get_event_status(int event);
229 void mission_event_shutdown();
230 void mission_goal_validation_change( int goal_num, int valid );
231
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);
235
236 void mission_goal_exit();
237
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
242
243 #endif
244