1 /* 2 SAR Mission Management, Callbacks, and Procedures 3 */ 4 5 #ifndef MISSION_H 6 #define MISSION_H 7 8 #include "obj.h" 9 10 11 /* 12 * Mission log codes: 13 * 14 * These are codes used to determine the event type found in 15 * mission log events 16 */ 17 #define SAR_MISSION_LOG_EVENT_COMMENT 0 18 #define SAR_MISSION_LOG_EVENT_POSITION 1 19 20 #define SAR_MISSION_LOG_EVENT_TAKEOFF 10 21 #define SAR_MISSION_LOG_EVENT_LAND 11 22 #define SAR_MISSION_LOG_EVENT_CRASH 12 23 #define SAR_MISSION_LOG_EVENT_PICKUP 13 24 #define SAR_MISSION_LOG_EVENT_DROPOFF 14 25 26 27 /* 28 * Mission objective types: 29 */ 30 /* Must reach object specified by name arrive_at_name within a (optional) 31 * time limit set by time_limit (if positive) 32 */ 33 #define SAR_MISSION_OBJECTIVE_ARRIVE_AT 1 34 /* Must pick up atleast humans_need_rescue many humans within a (optional) 35 * time limit set by time_limit (if positive) 36 */ 37 #define SAR_MISSION_OBJECTIVE_PICK_UP 2 38 /* Must pick up atleast humans_need_rescue many humans within a (optional) 39 * time limit set by time_limit (if positive) and reach the object 40 * specified by arrive_at_name 41 */ 42 #define SAR_MISSION_OBJECTIVE_PICK_UP_ARRIVE_AT 3 43 44 45 /* 46 * Mission objective structure: 47 */ 48 typedef struct { 49 50 int type; /* One of SAR_MISSION_OBJECTIVE_* */ 51 52 #define SAR_MISSION_OBJECTIVE_STATE_INCOMPLETE 0 /* In progress */ 53 #define SAR_MISSION_OBJECTIVE_STATE_SUCCESS 1 54 #define SAR_MISSION_OBJECTIVE_STATE_FAILED 2 55 int state; /* One of SAR_MISSION_OBJECTIVE_STATE_* */ 56 57 58 /* Time left in seconds for this objective to be completed. 59 * Note that type float is used, because the milliseconds 60 * resolution needs to be preserved 61 * 62 * A non-positive value implies that there is no time_limit 63 */ 64 float time_left; 65 66 67 /* Number of humans that still need rescue (haven't been brought 68 * to safety) for this objective, a non-positive total_humans 69 * value implies no humans need to be rescued 70 */ 71 int humans_need_rescue; 72 73 /* Total number of humans that needed to be rescued. This only 74 * reflects the number of humans that need to be rescued, not 75 * the total number of humans in the scene. If this value is 76 * not positive then that implies no humans need to be rescued 77 */ 78 int total_humans; 79 80 81 /* Name of object to land at for this objective. The value can be 82 * NULL to indicate n/a, but be careful as a NULL value for 83 * objectives of type SAR_MISSION_OBJECTIVE_ARRIVE_AT will always 84 * fail under that situation 85 */ 86 char *arrive_at_name; 87 88 /* Success and fail message for this objective, if this objective 89 * is passed successfully then message_success is printed 90 * 91 * Otherwise message_fail is printed. Any of these values can 92 * be NULL for no message 93 */ 94 char *message_success, 95 *message_fail; 96 97 } sar_mission_objective_struct; 98 99 100 /* 101 * Base mission structure: 102 */ 103 typedef struct { 104 105 #define MISSION_STATE_IN_PROGRESS 0 106 #define MISSION_STATE_FAILED 1 107 #define MISSION_STATE_ACCOMPLISHED 2 108 int state; /* Mission state, one of MISSION_STATE_* */ 109 110 char *title; /* Title of this mission */ 111 char *description; /* Description of this mission 112 * objectives 113 */ 114 115 char *start_location_name; /* Name of starting location */ 116 117 char *scene_file; /* Full path to scene file */ 118 char *player_model_file; /* Full path to player object model file */ 119 char *player_stats_file; /* Full path to player stats file */ 120 121 /* Objectives */ 122 sar_mission_objective_struct *objective; 123 int total_objectives; 124 125 /* Current objective */ 126 int cur_objective; 127 128 129 /* Time spent so far this mission, in seconds */ 130 float time_spent; 131 132 /* Timmings, in milliseconds */ 133 time_t next_check, check_int, 134 next_log_position, log_position_int; 135 136 } sar_mission_struct; 137 #define SAR_MISSION(p) ((sar_mission_struct *)(p)) 138 139 140 #endif /* MISSION_H */ 141