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