Lephisto/src/outfit.h
2013-03-07 18:44:01 +00:00

100 lines
2.7 KiB
C

#pragma once
#include "opengl.h"
#include "sound.h"
#define outfit_isProp(o,p) ((o)->properties & p)
// Property flags.
#define OUTFIT_PROP_WEAP_SECONDARY (1<<0)
// Outfit types.
typedef enum OutfitType_ {
OUTFIT_TYPE_NULL = 0,
OUTFIT_TYPE_BOLT = 1,
OUTFIT_TYPE_BEAM = 2,
OUTFIT_TYPE_MISSILE_DUMB = 3,
OUTFIT_TYPE_MISSILE_DUMB_AMMO = 4,
OUTFIT_TYPE_MISSILE_SEEK = 5,
OUTFIT_TYPE_MISSILE_SEEK_AMMO = 6,
OUTFIT_TYPE_MISSILE_SEEK_SMART = 7,
OUTFIT_TYPE_MISSILE_SEEK_SMART_AMMO = 8,
OUTFIT_TYPE_MISSILE_SWARM = 9,
OUTFIT_TYPE_MISSILE_SWARM_AMMO = 10,
OUTFIT_TYPE_MISSILE_SWARM_SMART = 11,
OUTFIT_TYPE_MISSILE_SWARM_SMART_AMMO = 12,
OUTFIT_TYPE_TURRET_BOLT = 13,
OUTFIT_TYPE_TURRET_BEAM = 14
} OutfitType;
// An outfit depends a lot on the type.
typedef struct Outfit_ {
char* name;
// General specs.
int max;
int tech;
int mass;
// Store stuff.
unsigned int price;
char* description;
glTexture gfx_store; // Store graphic.
int properties; // Properties stored bitwise.
// Type dependant.
OutfitType type;
union {
struct { // Beam/Bolt.
unsigned int delay; // Delay between shots.
double speed; // Speed of shot. (not applicable to beam.
double range;
double accuracy; // Desviation accuracy.
double damage_armour, damage_shield; // Damage.
glTexture* gfx_space;
ALuint sound; // Sound to play.
int spfx; // Special effect on hit.
} wpn;
struct { // Launcher.
unsigned int delay; // Delay between shots.
char* ammo;
} lau;
struct { // Ammo.
unsigned int duration; // Duration.
double speed; // Max speed.
double turn; // Turn vel.
double thrust; // Acceleration.
double damage_armour, damage_shield; // Damage.
glTexture* gfx_space;
ALuint sound; // Sound to play.
int spfx; // Special effect on hit.
unsigned int lockon; // Time taken to lock on the target.
} amm;
} u;
} Outfit;
// Get.
Outfit* outfit_get(const char* name);
char** outfit_getAll(int* n);
// Outfit types.
int outfit_isWeapon(const Outfit* o);
int outfit_isLauncher(const Outfit* o);
int outfit_isAmmo(const Outfit* o);
int outfit_isTurret(const Outfit* o);
const char* outfit_getType(const Outfit* o);
const char* outfit_getTypeBroad(const Outfit* o);
// Get data from outfit.
glTexture* outfit_gfx(const Outfit* o);
int outfit_spfx(const Outfit* o);
double outfit_dmgShield(const Outfit* o);
double outfit_dmgArmour(const Outfit* o);
int outfit_delay(const Outfit* o);
// Load/free outfit stack.
int outfit_load(void);
void outfit_free(void);