1 /* 2 * See Licensing and Copyright notice in naev.h 3 */ 4 5 6 #ifndef MISSION_H 7 # define MISSION_H 8 9 10 #include "opengl.h" 11 #include "claim.h" 12 #include "nlua.h" 13 14 15 /* availability by location */ 16 enum { 17 MIS_AVAIL_NONE, /**< Mission isn't available. */ 18 MIS_AVAIL_COMPUTER, /**< Mission is available at mission computer. */ 19 MIS_AVAIL_BAR, /**< Mission is available at bar. */ 20 MIS_AVAIL_OUTFIT, /**< Mission is available at outfitter. */ 21 MIS_AVAIL_SHIPYARD, /**< Mission is available at shipyard. */ 22 MIS_AVAIL_LAND, /**< Mission is available on landing. */ 23 MIS_AVAIL_COMMODITY, /**< Mission is available at commodity exchange. */ 24 MIS_AVAIL_SPACE /**< Mission is available in space. */ 25 }; 26 27 28 /* flag functions */ 29 #define mis_isFlag(m,f) ((m)->flags & (f)) 30 #define mis_setFlag(m,f) ((m)->flags |= (f)) 31 #define mis_rmFlag(m,f) ((m)->flags &= ~(f)) 32 /* actual flags */ 33 #define MISSION_UNIQUE (1<<0) /**< Unique missions can't be repeated */ 34 35 36 /** 37 * @brief Different type of system markers. 38 */ 39 typedef enum SysMarker_ { 40 SYSMARKER_COMPUTER, /**< Marker is for mission computer missions. */ 41 SYSMARKER_LOW, /**< Marker is for low priority mission targets. */ 42 SYSMARKER_HIGH, /**< Marker is for high priority mission targets. */ 43 SYSMARKER_PLOT /**< Marker is for plot priority (ultra high) mission targets. */ 44 } SysMarker; 45 46 47 /** 48 * @brief Defines the availability of a mission. 49 */ 50 typedef struct MissionAvail_s { 51 int loc; /**< Location of the mission. */ 52 int chance; /**< Chance of it appearing, last two digits represent %, first digit represents times it can appear (if 0 it behaves like once). */ 53 54 /* for specific cases */ 55 char *planet; /**< Planet name. */ 56 char *system; /**< System name. */ 57 58 /* for generic cases */ 59 int* factions; /**< To certain factions. */ 60 int nfactions; /**< Number of factions in factions. */ 61 62 char* cond; /**< Condition that must be met (Lua). */ 63 char* done; /**< Previous mission that must have been done. */ 64 65 int priority; /**< Mission priority: 0 = main plot, 5 = default, 10 = insignificant. */ 66 } MissionAvail_t; 67 68 69 /** 70 * @struct MissionData 71 * 72 * @brief Static mission data. 73 */ 74 typedef struct MissionData_ { 75 char *name; /**< The name of the mission. */ 76 77 MissionAvail_t avail; /**< Mission availability. */ 78 79 unsigned int flags; /**< Flags to store binary properties */ 80 char* lua; /**< Lua file to use. */ 81 } MissionData; 82 83 84 /** 85 * @brief Mission system marker. 86 */ 87 typedef struct MissionMarker_ { 88 int id; /**< ID of the mission marker. */ 89 int sys; /**< ID of marked system. */ 90 SysMarker type; /**< Marker type. */ 91 } MissionMarker; 92 93 94 /** 95 * @struct Mission 96 * 97 * @brief Represents an active mission. 98 */ 99 typedef struct Mission_ { 100 MissionData *data; /**< Data to use. */ 101 unsigned int id; /**< Unique mission identifier, used for keeping track of hooks. */ 102 int accepted; /**< Mission is a player mission. */ 103 104 char *title; /**< Not to be confused with name */ 105 char *desc; /**< Description of the mission */ 106 char *reward; /**< Rewards in text */ 107 glTexture *portrait; /**< Portrait of the mission giver if applicable. */ 108 char *npc; /**< Name of the NPC giving the mission. */ 109 110 /* mission cargo given to the player - need to cleanup */ 111 unsigned int *cargo; /**< Cargos given to player. */ 112 int ncargo; /**< Number of cargos given to player. */ 113 114 /* Markers. */ 115 MissionMarker *markers; /**< Markers array. */ 116 117 /* OSD. */ 118 unsigned int osd; /**< On-Screen Display ID. */ 119 int osd_set; /**< OSD was set explicitly. */ 120 121 /* Claims. */ 122 Claim_t *claims; /**< System claims. */ 123 124 nlua_env env; /**< The environment of the running Lua code. */ 125 } Mission; 126 127 128 /* 129 * current player missions 130 */ 131 #define MISSION_MAX 12 /**< No sense in allowing the player have infinite missions. */ 132 extern Mission *player_missions[MISSION_MAX]; /**< Player's active missions. */ 133 134 135 /* 136 * creates missions for a planet and such 137 */ 138 Mission* missions_genList( int *n, int faction, 139 const char* planet, const char* sysname, int loc ); 140 int mission_accept( Mission* mission ); /* player accepted mission for computer/bar */ 141 void missions_run( int loc, int faction, const char* planet, const char* sysname ); 142 int mission_start( const char *name, unsigned int *id ); 143 144 /* 145 * misc 146 */ 147 int mission_alreadyRunning( MissionData* misn ); 148 int mission_getID( const char* name ); 149 MissionData* mission_get( int id ); 150 MissionData* mission_getFromName( const char* name ); 151 int mission_addMarker( Mission *misn, int id, int sys, SysMarker type ); 152 void mission_sysMark (void); 153 void mission_sysComputerMark( Mission* misn ); 154 155 156 /* 157 * cargo stuff 158 */ 159 int mission_linkCargo( Mission* misn, unsigned int cargo_id ); 160 int mission_unlinkCargo( Mission* misn, unsigned int cargo_id ); 161 162 163 /* 164 * load/quit 165 */ 166 int missions_load (void); 167 void mission_cleanup( Mission* misn ); 168 void mission_shift( int pos ); 169 void missions_free (void); 170 void missions_cleanup (void); 171 172 /* 173 * Actually in nlua_misn.h 174 */ 175 int misn_tryRun( Mission *misn, const char *func ); 176 void misn_runStart( Mission *misn, const char *func ); 177 int misn_runFunc( Mission *misn, const char *func, int nargs ); 178 int misn_run( Mission *misn, const char *func ); 179 180 /* 181 * CLaims. 182 */ 183 void missions_activateClaims (void); 184 185 186 #endif /* MISSION_H */ 187 188 189