1 /* 2 * See Licensing and Copyright notice in naev.h 3 */ 4 5 6 7 #ifndef OUTFIT_H 8 # define OUTFIT_H 9 10 11 #include "opengl.h" 12 #include "sound.h" 13 #include "economy.h" 14 #include "shipstats.h" 15 16 17 /* 18 * properties 19 */ 20 #define outfit_isProp(o,p) ((o)->properties & p) /**< Checks an outfit for property. */ 21 /* property flags */ 22 #define OUTFIT_PROP_WEAP_SECONDARY (1<<0) /**< Is a secondary weapon? */ 23 #define OUTFIT_PROP_WEAP_SPIN (1<<1) /**< Should weapon spin around? */ 24 #define OUTFIT_PROP_WEAP_BLOWUP_ARMOUR (1<<2) /**< Weapon blows up (armour spfx) 25 when timer is up. */ 26 #define OUTFIT_PROP_WEAP_BLOWUP_SHIELD (1<<3) /**< Weapon blows up (shield spfx) 27 when timer is up. */ 28 29 30 /* 31 * Needed because some outfittypes call other outfits. 32 */ 33 struct Outfit_; 34 35 36 /** 37 * @brief Different types of existing outfits. 38 * 39 * Outfits are organized by the order here 40 * 41 * @note If you modify this DON'T FORGET TO MODIFY outfit_getType too!!! 42 */ 43 typedef enum OutfitType_ { 44 OUTFIT_TYPE_NULL, /**< Null type. */ 45 OUTFIT_TYPE_BOLT, /**< Fixed bolt cannon. */ 46 OUTFIT_TYPE_BEAM, /**< Fixed beam cannon. */ 47 OUTFIT_TYPE_TURRET_BOLT, /**< Rotary bolt turret. */ 48 OUTFIT_TYPE_TURRET_BEAM, /**< Rotary beam turret. */ 49 OUTFIT_TYPE_LAUNCHER, /**< Launcher. */ 50 OUTFIT_TYPE_AMMO, /**< Launcher ammo. */ 51 OUTFIT_TYPE_TURRET_LAUNCHER, /**< Turret launcher. */ 52 OUTFIT_TYPE_MODIFICATION, /**< Modifies the ship base features. */ 53 OUTFIT_TYPE_AFTERBURNER, /**< Gives the ship afterburn capability. */ 54 OUTFIT_TYPE_JAMMER, /**< Used to nullify seeker missiles. */ 55 OUTFIT_TYPE_FIGHTER_BAY, /**< Contains other ships. */ 56 OUTFIT_TYPE_FIGHTER, /**< Ship contained in FIGHTER_BAY. */ 57 OUTFIT_TYPE_MAP, /**< Gives the player more knowledge about systems. */ 58 OUTFIT_TYPE_LOCALMAP, /**< Gives the player more knowledge about the current system. */ 59 OUTFIT_TYPE_GUI, /**< GUI for the player. */ 60 OUTFIT_TYPE_LICENSE, /**< License that allows player to buy special stuff. */ 61 OUTFIT_TYPE_SENTINEL /**< indicates last type */ 62 } OutfitType; 63 64 65 /** 66 * @brief Outfit slot types. 67 */ 68 typedef enum OutfitSlotType_ { 69 OUTFIT_SLOT_NULL, /**< Invalid slot type. */ 70 OUTFIT_SLOT_NA, /**< Slot type not applicable. */ 71 OUTFIT_SLOT_STRUCTURE, /**< Low energy slot. */ 72 OUTFIT_SLOT_UTILITY, /**< Medium energy slot. */ 73 OUTFIT_SLOT_WEAPON /**< High energy slot. */ 74 } OutfitSlotType; 75 76 77 /** 78 * @brief Outfit slot sizes. 79 */ 80 typedef enum OutfitSlotSize_ { 81 OUTFIT_SLOT_SIZE_NA, /**< Not applicable slot size. */ 82 OUTFIT_SLOT_SIZE_LIGHT, /**< Light slot size. */ 83 OUTFIT_SLOT_SIZE_MEDIUM, /**< Medium slot size. */ 84 OUTFIT_SLOT_SIZE_HEAVY /**< Heavy slot size. */ 85 } OutfitSlotSize; 86 87 88 /** 89 * @brief Ammo AI types. 90 */ 91 typedef enum OutfitAmmoAI_ { 92 AMMO_AI_DUMB, /**< No AI. */ 93 AMMO_AI_SEEK, /**< Aims at the target. */ 94 AMMO_AI_SMART /**< Aims at the target, correcting for relative velocity. */ 95 } OutfitAmmoAI; 96 97 /** 98 * @brief Pilot slot that can contain outfits. 99 */ 100 typedef struct OutfitSlot_ { 101 unsigned int spid; /**< Slot property ID. */ 102 int exclusive; /**< Outfit must go exclusively into the slot. */ 103 OutfitSlotType type; /**< Type of outfit slot. */ 104 OutfitSlotSize size; /**< Size of the outfit. */ 105 } OutfitSlot; 106 107 108 /** 109 * @brief Core damage that an outfit does. 110 */ 111 typedef struct Damage_ { 112 int type; /**< Type of damage. */ 113 double penetration; /**< Penetration the damage has [0:1], with 1 being 100%. */ 114 double damage; /**< Amount of damage, this counts towards killing the ship. */ 115 double disable; /**< Amount of disable damage, this counts towards disabling the ship. */ 116 } Damage; 117 118 119 /** 120 * @brief Represents the particular properties of a bolt weapon. 121 */ 122 typedef struct OutfitBoltData_ { 123 double delay; /**< Delay between shots */ 124 double speed; /**< How fast it goes. */ 125 double range; /**< How far it goes. */ 126 double falloff; /**< Point at which damage falls off. */ 127 double ew_lockon; /**< Electronic warfare lockon parameter. */ 128 double energy; /**< Energy usage */ 129 Damage dmg; /**< Damage done. */ 130 double heatup; /**< How long it should take for the weapon to heat up (approx). */ 131 double heat; /**< Heat per shot. */ 132 double track; /**< Ewarfare to track. */ 133 double swivel; /**< Amount of swivel (semiarc in radians of deviation the weapon can correct. */ 134 135 /* Sound and graphics. */ 136 glTexture* gfx_space; /**< Normal graphic. */ 137 glTexture* gfx_end; /**< End graphic with modified hue. */ 138 double spin; /**< Graphic spin rate. */ 139 int sound; /**< Sound to play on shoot.*/ 140 int sound_hit; /**< Sound to play on hit. */ 141 int spfx_armour; /**< special effect on hit. */ 142 int spfx_shield; /**< special effect on hit. */ 143 } OutfitBoltData; 144 145 /** 146 * @brief Represents the particular properties of a beam weapon. 147 */ 148 typedef struct OutfitBeamData_ { 149 /* Time stuff. */ 150 double delay; /**< Delay between usage. */ 151 double warmup; /**< How long beam takes to warm up. */ 152 double duration; /**< How long the beam lasts active. */ 153 double min_duration; /**< Minimum duration the beam can be fired for. */ 154 155 /* Beam properties. */ 156 double range; /**< how far it goes */ 157 double turn; /**< How fast it can turn. Only for turrets, in rad/s. */ 158 double energy; /**< Amount of energy it drains (per second). */ 159 Damage dmg; /**< Damage done. */ 160 double heatup; /**< How long it should take for the weapon to heat up (approx). */ 161 double heat; /**< Heat per second. */ 162 163 /* Graphics and sound. */ 164 glTexture *gfx; /**< Base texture. */ 165 int spfx_armour; /**< special effect on hit */ 166 int spfx_shield; /**< special effect on hit */ 167 int sound_warmup; /**< Sound to play when warming up. @todo use. */ 168 int sound; /**< Sound to play. */ 169 int sound_off; /**< Sound to play when turning off. */ 170 } OutfitBeamData; 171 172 /** 173 * @brief Represents a particular missile launcher. 174 * 175 * The properties of the weapon are highly dependent on the ammunition. 176 */ 177 typedef struct OutfitLauncherData_ { 178 double delay; /**< Delay between shots. */ 179 char *ammo_name; /**< Name of the ammo to use. */ 180 struct Outfit_ *ammo; /**< Ammo to use. */ 181 int amount; /**< Amount of ammo it can store. */ 182 183 /* Lockon information. */ 184 double lockon; /**< Time it takes to lock on the target */ 185 double ew_target; /**< Target ewarfare at which it the lockon time is based off of. */ 186 double ew_target2; /**< Target ewarfare squared for quicker comparisons. */ 187 double arc; /**< Semi-angle of the arc which it will lock on in. */ 188 } OutfitLauncherData; 189 190 /** 191 * @brief Represents ammunition for a launcher. 192 */ 193 typedef struct OutfitAmmoData_ { 194 double duration; /**< How long the ammo lives. */ 195 double resist; /**< Lowers chance of jamming by this amount */ 196 OutfitAmmoAI ai; /**< Smartness of ammo. */ 197 198 double speed; /**< Maximum speed */ 199 double turn; /**< Turn velocity in rad/s. */ 200 double thrust; /**< Acceleration */ 201 double energy; /**< Energy usage */ 202 Damage dmg; /**< Damage done. */ 203 204 glTexture* gfx_space; /**< Graphic. */ 205 double spin; /**< Graphic spin rate. */ 206 int sound; /**< sound to play */ 207 int sound_hit; /**< Sound to play on hit. */ 208 int spfx_armour; /**< special effect on hit */ 209 int spfx_shield; /**< special effect on hit */ 210 } OutfitAmmoData; 211 212 /** 213 * @brief Represents a ship modification. 214 * 215 * These modify the ship's basic properties when equipped on a pilot. 216 */ 217 typedef struct OutfitModificationData_ { 218 /* Active information (if applicable). */ 219 int active; /**< Outfit is active. */ 220 double duration; /**< Time the active outfit stays on (in seconds). */ 221 double cooldown; /**< Time the active outfit stays off after it's duration (in seconds). */ 222 223 /* Movement. */ 224 double thrust; /**< Maximum thrust modifier. */ 225 double thrust_rel; /**< Relative thrust modifier. */ 226 double turn; /**< Maximum turn modifier. */ 227 double turn_rel; /**< Relative turn modifier. */ 228 double speed; /**< Maximum speed modifier. */ 229 double speed_rel; /**< Relative speed modifier. */ 230 231 /* Health. */ 232 double armour; /**< Maximum armour modifier. */ 233 double armour_rel; /**< Relative to armour base modifier. */ 234 double armour_regen; /**< Armour regeneration modifier. */ 235 double shield; /**< Maximum shield modifier. */ 236 double shield_rel; /**< Relative to shield base modifier. */ 237 double shield_regen; /**< Shield regeneration modifier. */ 238 double energy; /**< Maximum energy modifier. */ 239 double energy_rel; /**< Relative to energy base modifier. */ 240 double energy_regen; /**< Energy regeneration modifier. */ 241 double energy_loss; /**< Energy regeneration modifier. */ 242 double absorb; /**< Absorption factor. */ 243 244 /* Misc. */ 245 double cargo; /**< Cargo space modifier. */ 246 double crew_rel; /**< Relative crew modification. */ 247 double mass_rel; /**< Relative mass modification. */ 248 double fuel; /**< Maximum fuel modifier. */ 249 250 /* Stats. */ 251 ShipStatList *stats; /**< Stat list. */ 252 } OutfitModificationData; 253 254 /** 255 * @brief Represents an afterburner. 256 */ 257 typedef struct OutfitAfterburnerData_ { 258 /* Internal properties. */ 259 double rumble; /**< Percent of rumble */ 260 int sound_on; /**< Sound of the afterburner turning on */ 261 int sound; /**< Sound of the afterburner being on */ 262 int sound_off; /**< Sound of the afterburner turning off */ 263 double thrust; /**< Percent of thrust increase based on ship base. */ 264 double speed; /**< Percent of speed to increase based on ship base. */ 265 double energy; /**< Energy usage while active */ 266 double mass_limit; /**< Limit at which effectiveness starts to drop. */ 267 double heatup; /**< How long it takes for the afterburner to overheat. */ 268 double heat; /**< Heat per second. */ 269 double heat_cap; /**< Temperature at which the outfit overheats (K). */ 270 double heat_base; /**< Temperature at which the outfit BEGINS to overheat(K). */ 271 } OutfitAfterburnerData; 272 273 /** 274 * @brief Represents a fighter bay. 275 */ 276 typedef struct OutfitFighterBayData_ { 277 char *ammo_name; /**< Name of the ships to use as ammo. */ 278 struct Outfit_ *ammo; /**< Ships to use as ammo. */ 279 double delay; /**< Delay between launches. */ 280 int amount; /**< Amount of ammo it can store. */ 281 } OutfitFighterBayData; 282 283 /** 284 * @brief Represents a fighter for a fighter bay. 285 */ 286 typedef struct OutfitFighterData_ { 287 char *ship; /**< Ship to use for fighter. */ 288 int sound; /**< Sound to make when launching. */ 289 } OutfitFighterData; 290 291 /* Forward declaration */ 292 struct OutfitMapData_s; 293 typedef struct OutfitMapData_s OutfitMapData_t; 294 295 /** 296 * @brief Represents a local map. 297 */ 298 typedef struct OutfitLocalMapData_ { 299 double jump_detect; /**< Ability to detect jumps. */ 300 double asset_detect; /**< Ability to detect assets. */ 301 } OutfitLocalMapData; 302 303 /** 304 * @brief Represents a jammer. 305 */ 306 typedef struct OutfitJammerData_ { 307 double energy; /**< Energy it uses to run */ 308 double range; /**< Range it starts to do effect */ 309 double range2; /**< Range squared. */ 310 double power; /**< Strength of the effect. */ 311 } OutfitJammerData; 312 313 /** 314 * @brief Represents a GUI. 315 */ 316 typedef struct OutfitGUIData_ { 317 char *gui; /**< Name of the GUI file. */ 318 } OutfitGUIData; 319 320 /** 321 * @brief A ship outfit, depends radically on the type. 322 */ 323 typedef struct Outfit_ { 324 char *name; /**< Name of the outfit. */ 325 char *typename; /**< Overrides the base type. */ 326 327 /* general specs */ 328 OutfitSlot slot; /**< Slot the outfit fits into. */ 329 char *license; /**< Licenses needed to buy it. */ 330 double mass; /**< How much weapon capacity is needed. */ 331 double cpu; /**< CPU usage. */ 332 char *limit; /**< Name to limit to one per ship (ignored if NULL). */ 333 334 /* store stuff */ 335 credits_t price; /**< Base sell price. */ 336 char *description; /**< Store description. */ 337 char *desc_short; /**< Short outfit description. */ 338 int priority; /**< Sort priority, highest first. */ 339 340 glTexture* gfx_store; /**< Store graphic. */ 341 342 unsigned int properties; /**< Properties stored bitwise. */ 343 344 unsigned int group; /**< Weapon group to use when autoweap is enabled. */ 345 346 /* Type dependent */ 347 OutfitType type; /**< Type of the outfit. */ 348 union { 349 OutfitBoltData blt; /**< BOLT */ 350 OutfitBeamData bem; /**< BEAM */ 351 OutfitLauncherData lau; /**< MISSILE */ 352 OutfitAmmoData amm; /**< AMMO */ 353 OutfitModificationData mod; /**< MODIFICATION */ 354 OutfitAfterburnerData afb; /**< AFTERBURNER */ 355 OutfitJammerData jam; /**< JAMMER */ 356 OutfitFighterBayData bay; /**< FIGHTER_BAY */ 357 OutfitFighterData fig; /**< FIGHTER */ 358 OutfitMapData_t *map; /**< MAP */ 359 OutfitLocalMapData lmap; /**< LOCALMAP */ 360 OutfitGUIData gui; /**< GUI */ 361 } u; /**< Holds the type-based outfit data. */ 362 } Outfit; 363 364 365 /* 366 * get 367 */ 368 Outfit* outfit_get( const char* name ); 369 Outfit* outfit_getW( const char* name ); 370 Outfit* outfit_getAll( int *n ); 371 int outfit_compareTech( const void *outfit1, const void *outfit2 ); 372 /* outfit types */ 373 int outfit_isActive( const Outfit* o ); 374 int outfit_isForward( const Outfit* o ); 375 int outfit_isBolt( const Outfit* o ); 376 int outfit_isBeam( const Outfit* o ); 377 int outfit_isLauncher( const Outfit* o ); 378 int outfit_isAmmo( const Outfit* o ); 379 int outfit_isSeeker( const Outfit* o ); 380 int outfit_isTurret( const Outfit* o ); 381 int outfit_isMod( const Outfit* o ); 382 int outfit_isAfterburner( const Outfit* o ); 383 int outfit_isJammer( const Outfit* o ); 384 int outfit_isFighterBay( const Outfit* o ); 385 int outfit_isFighter( const Outfit* o ); 386 int outfit_isMap( const Outfit* o ); 387 int outfit_isLocalMap( const Outfit* o ); 388 int outfit_isGUI( const Outfit* o ); 389 int outfit_isLicense( const Outfit* o ); 390 int outfit_isSecondary( const Outfit* o ); 391 const char* outfit_getType( const Outfit* o ); 392 const char* outfit_getTypeBroad( const Outfit* o ); 393 const char* outfit_getAmmoAI( const Outfit *o ); 394 395 /* 396 * Search. 397 */ 398 const char *outfit_existsCase( const char* name ); 399 char **outfit_searchFuzzyCase( const char* name, int *n ); 400 401 /* 402 * get data from outfit 403 */ 404 const char *outfit_slotName( const Outfit* o ); 405 const char *outfit_slotSize( const Outfit* o ); 406 const char *slotSize( const OutfitSlotSize o ); 407 const glColour *outfit_slotSizeColour( const OutfitSlot* os ); 408 OutfitSlotSize outfit_toSlotSize( const char *s ); 409 glTexture* outfit_gfx( const Outfit* o ); 410 int outfit_spfxArmour( const Outfit* o ); 411 int outfit_spfxShield( const Outfit* o ); 412 const Damage *outfit_damage( const Outfit* o ); 413 double outfit_delay( const Outfit* o ); 414 Outfit* outfit_ammo( const Outfit* o ); 415 int outfit_amount( const Outfit* o ); 416 double outfit_energy( const Outfit* o ); 417 double outfit_heat( const Outfit* o ); 418 double outfit_cpu( const Outfit* o ); 419 double outfit_range( const Outfit* o ); 420 double outfit_speed( const Outfit* o ); 421 double outfit_spin( const Outfit* o ); 422 int outfit_sound( const Outfit* o ); 423 int outfit_soundHit( const Outfit* o ); 424 /* Active outfits. */ 425 double outfit_duration( const Outfit* o ); 426 double outfit_cooldown( const Outfit* o ); 427 /* 428 * loading/freeing outfit stack 429 */ 430 int outfit_load (void); 431 int outfit_mapParse(void); 432 void outfit_free (void); 433 434 435 /* 436 * Misc. 437 */ 438 int outfit_fitsSlot( const Outfit* o, const OutfitSlot* s ); 439 int outfit_fitsSlotType( const Outfit* o, const OutfitSlot* s ); 440 void outfit_freeSlot( OutfitSlot* s ); 441 442 443 #endif /* OUTFIT_H */ 444