FS2_Open
Open source remastering of the Freespace 2 engine
missiongoals.h
Go to the documentation of this file.
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 the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef _MISSIONGOAL_H
13 #define _MISSIONGOAL_H
14 
15 #include "globalincs/globals.h"
16 #include "globalincs/pstypes.h"
17 
18 struct ai_goal;
19 struct ai_info;
20 
21 // defines for types of primary and secondary missions
22 
23 #define MAX_GOALS 30 // maximum number of goals for any given mission
24 
25 // defines for types of goals. We will use part of the int field of the mission_goal struct
26 // as a bit field for goal flags
27 
28 #define PRIMARY_GOAL 0
29 #define SECONDARY_GOAL 1
30 #define BONUS_GOAL 2
31 
32 // defines for bitfields of type, (and mask to get the type field quickly)
33 #define INVALID_GOAL (1 << 16) // is this goal valid or not?
34 #define GOAL_TYPE_MASK (0xffff) // mask to get us the type
35 
36 // defines for goal status. These status are also used in campaign file for marking goal status
37 // in campaign save file
38 #define GOAL_FAILED 0 // status of goal
39 #define GOAL_COMPLETE 1
40 #define GOAL_INCOMPLETE 2
41 
42 #define PRIMARY_GOALS_COMPLETE 1
43 #define PRIMARY_GOALS_INCOMPLETE 0
44 #define PRIMARY_GOALS_FAILED -1
45 
46 extern const char *Goal_type_text(int n);
47 
48 // structures for primary and secondary goals
49 
50 #define MAX_GOAL_TEXT 128
51 
52 #define MGF_NO_MUSIC (1<<0) // don't play any event music when goal is achieved
53 
54 typedef struct mission_goal {
55  char name[NAME_LENGTH]; // used for storing status of goals in player file
56  int type; // primary/secondary/bonus
57  int satisfied; // has this goal been satisfied
58  char message[MAX_GOAL_TEXT]; // Brief description, such as "Destroy all vile aliens!"
59  int rating; // Some importance figure or something.
60  int formula; // Index in Sexp_nodes of this Sexp.
61  int score; // score for this goal
62  int flags; // MGF_
63  int team; // which team is this objective for.
64 } mission_goal;
65 
66 extern mission_goal Mission_goals[MAX_GOALS]; // structure for the goals of this mission
67 extern int Num_goals; // number of goals for this mission
68 
69 // structures and defines for mission events
70 
71 #define MAX_MISSION_EVENTS 512
72 #define MISSION_EVENTS_WARN 100
73 
74 // defined for event states. We will also use the satisfied/failed for saving event information
75 // in campaign save file
76 #define EVENT_UNBORN 0 // event can't be evaluated yet
77 #define EVENT_CURRENT 1 // event can currently be evaluated, but not satisfied or failed yet
78 #define EVENT_SATISFIED 2
79 #define EVENT_FAILED 3
80 #define EVENT_INCOMPLETE 4 // used in campaign save file. used when event isn't satisfied yet
81 
82 #define MEF_CURRENT (1 << 0) // is event current or past current yet?
83 #define MEF_DIRECTIVE_SPECIAL (1 << 1) // used to mark a directive as true even though not fully satisfied
84 #define MEF_DIRECTIVE_TEMP_TRUE (1 << 2) // this directive is temporarily true.
85 #define MEF_USING_TRIGGER_COUNT (1 << 3) // Karajorma - use trigger count as well as repeat count to determine how many repeats this event has
86 
87 #define MAX_MISSION_EVENT_LOG_FLAGS 9 // this must be changed if a mission log flag is added below
88 
89 #define MLF_SEXP_TRUE (1 << 0)
90 #define MLF_SEXP_FALSE (1 << 1)
91 //#define MLF_SEXP_KNOWN_TRUE (1 << 2)
92 #define MLF_SEXP_KNOWN_FALSE (1 << 3)
93 #define MLF_FIRST_REPEAT_ONLY (1 << 4)
94 #define MLF_LAST_REPEAT_ONLY (1 << 5)
95 #define MLF_FIRST_TRIGGER_ONLY (1 << 6)
96 #define MLF_LAST_TRIGGER_ONLY (1 << 7)
97 #define MLF_STATE_CHANGE (1 << 8)
98 
99 #define MLF_ALL_REPETITION_FLAGS (MLF_FIRST_REPEAT_ONLY | MLF_LAST_REPEAT_ONLY | MLF_FIRST_TRIGGER_ONLY | MLF_LAST_TRIGGER_ONLY)
100 
101 typedef struct mission_event {
102  char name[NAME_LENGTH]; // used for storing status of events in player file
103  int formula; // index into sexpression array for this formula
104  int result; // result of most recent evaluation of event
105  int repeat_count; // number of times to test this goal
106  int trigger_count; // number of times to allow this goal to trigger
107  int interval; // interval (in seconds) at which an evaulation is repeated once true.
108  int timestamp; // set at 'interval' seconds when we start to eval.
109  int score; // score for this event
111  int flags;
114  int count; // object count for directive display
115  int satisfied_time; // this is used to temporarily mark the directive as satisfied when the event isn't (e.g. for a destroyed wave when there are more waves later)
116  int born_on_date; // timestamp at which event was born
117  int team; // for multiplayer games
118 
119  // event log stuff
120  int mission_log_flags; // flags that are used to determing which events are written to the log
125  int previous_result; // result of previous evaluation of event
126 
127 } mission_event;
128 
129 extern int Num_mission_events;
131 extern int Mission_goal_timestamp;
132 extern int Event_index; // used by sexp code to tell what event it came from
133 extern bool Log_event;
134 extern bool Snapshot_all_events;
135 
136 // prototypes
137 void mission_init_goals( void );
140 void mission_show_goals_do_frame(float frametime); // displays goals on screen
141 void mission_eval_goals(); // evaluate player goals
142 int mission_ai_goal_achievable( ai_goal *aigp ); // determines if an AI goal is achievable
143 void mission_add_ai_goal( int sexp, ai_info *aip ); // adds a goal onto the given ai_info structure
144 int mission_evaluate_primary_goals(void); // determine if the primary goals for the mission are complete -- returns one of the above defines
145 int mission_goals_met();
146 
147 // function used by single and multiplayer code to change the status on goals
148 void mission_goal_status_change( int goal_num, int new_status);
149 
150 // functions used to change goal validity status
151 void mission_goal_mark_invalid( char *name );
152 void mission_goal_mark_valid( char *name );
153 
154 // function used to mark all goals as invalid, and incomplete goals as invalid.
155 extern void mission_goal_fail_all();
156 extern void mission_goal_fail_incomplete();
157 
158 void mission_goal_fetch_num_resolved(int desired_type, int *num_resolved, int *total, int team = -1);
159 int mission_goals_incomplete(int desired_type, int team = -1);
162 
165 void mission_goal_validation_change( int goal_num, int valid );
166 
167 // mark an event as directive special
170 
171 void mission_goal_exit();
172 
173 int ML_objectives_init(int x, int y, int w, int h);
174 void ML_objectives_close();
175 void ML_objectives_do_frame(int scroll_offset);
176 void ML_render_objectives_key(); // renders objectives key on ingame objectives screen
177 
178 #endif
SCP_string sexp
Definition: sexp.cpp:25556
void ML_objectives_do_frame(int scroll_offset)
SCP_vector< SCP_string > backup_log_buffer
Definition: missiongoals.h:124
void mission_show_goals_close()
void mission_add_ai_goal(int sexp, ai_info *aip)
int mission_get_event_status(int event)
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
int Mission_goal_timestamp
void mission_show_goals_do_frame(float frametime)
int Num_goals
void mission_event_unset_directive_special(int event)
struct mission_event mission_event
void mission_goal_mark_events_complete()
CButton * team
void mission_goal_fetch_num_resolved(int desired_type, int *num_resolved, int *total, int team=-1)
int mission_ai_goal_achievable(ai_goal *aigp)
SCP_vector< SCP_string > event_log_argument_buffer
Definition: missiongoals.h:123
void ML_render_objectives_key()
void mission_goal_fail_incomplete()
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: Glext.h:5156
Definition: ai.h:329
SCP_vector< SCP_string > event_log_buffer
Definition: missiongoals.h:121
void mission_goal_mark_objectives_complete()
SCP_vector< SCP_string > event_log_variable_buffer
Definition: missiongoals.h:122
char * objective_text
Definition: missiongoals.h:112
void mission_event_set_directive_special(int event)
const char * Goal_type_text(int n)
#define MAX_GOALS
Definition: missiongoals.h:23
void mission_goal_mark_invalid(char *name)
void mission_init_goals(void)
struct mission_goal mission_goal
void mission_eval_goals()
int mission_goals_met()
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
GLclampd n
Definition: Glext.h:7286
#define MAX_GOAL_TEXT
Definition: missiongoals.h:50
GLuint const GLchar * name
Definition: Glext.h:5608
int mission_goals_incomplete(int desired_type, int team=-1)
void mission_event_shutdown()
#define NAME_LENGTH
Definition: globals.h:15
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
mission_event Mission_events[MAX_MISSION_EVENTS]
void mission_goal_exit()
bool Log_event
void mission_goal_fail_all()
int Num_mission_events
mission_goal Mission_goals[MAX_GOALS]
void mission_show_goals_init()
struct _cl_event * event
Definition: Glext.h:7296
char * objective_key_text
Definition: missiongoals.h:113
#define MAX_MISSION_EVENTS
Definition: missiongoals.h:71
void mission_goal_status_change(int goal_num, int new_status)
int ML_objectives_init(int x, int y, int w, int h)
Definition: ai.h:134
int mission_evaluate_primary_goals(void)
int Event_index
void mission_goal_mark_valid(char *name)
void mission_goal_validation_change(int goal_num, int valid)
GLint y
Definition: Gl.h:1505
void ML_objectives_close()
bool Snapshot_all_events