Lephisto/src/ship.h
2014-05-20 14:23:16 +01:00

121 lines
3.4 KiB
C

#pragma once
#include "opengl.h"
#include "outfit.h"
#include "sound.h"
/* Target gfx dimensions. */
#define SHIP_TARGET_W 128 /**< Ship target graphic width. */
#define SHIP_TARGET_H 96 /**< Ship target graphic height. */
/**
* @brief Contains the different types of ships.
*/
typedef enum ShipClass_ {
SHIP_CLASS_NULL, /**< Invalid ship. */
/* Civilian. */
SHIP_CLASS_YACHT, /**< Small cheap ship. */
SHIP_CLASS_LUXURY_YACHT, /**< Small expensive ship. */
SHIP_CLASS_CRUISE_SHIP, /**< Medium Ship. */
/* Merchant. */
SHIP_CLASS_COURIER, /**< Small ship. */
SHIP_CLASS_FREIGHTER, /**< Medium ship. */
SHIP_CLASS_BULK_CARRIER, /**< Large ship. */
/* Military. */
SHIP_CLASS_SCOUT, /**< Small scouter. */
SHIP_CLASS_FIGHTER, /**< Small attack ship. */
SHIP_CLASS_BOMBER, /**< Small attack ship with many missiles. */
SHIP_CLASS_CORVETTE, /**< Very agile medium ship. */
SHIP_CLASS_DESTROYER, /**< Not so agile medium ship. */
SHIP_CLASS_CRUISER, /**< Large ship. */
SHIP_CLASS_CARRIER, /**< Large ship with fighter bays. */
/* Robotic. */
SHIP_CLASS_DRONE, /**< Unmanned small robotic ship. */
SHIP_CLASS_HEAVY_DRONE, /**< Unmannded medium robotic ship. */
SHIP_CLASS_MOTHERSHIP /**< Unmanned large robotic carrier. */
/* Hybrid. */
/** @todo hybrid ship classification. */
} ShipClass;
/**
* @brief Represents a ship weapon mount point.
*/
typedef struct ShipMount_ {
double x; /**< X position of the mount point. */
double y; /**< Y position of the mount point. */
double h; /**< Mount point height (displacement). */
} ShipMount;
/**
* @brief Small wrapper for the outfits.
*/
typedef struct ShipOutfit_ {
struct ShipOutfit_* next; /* Linked list. */
Outfit* data; /* Data itself. */
int quantity;
} ShipOutfit;
/* Ship structure. */
typedef struct Ship_ {
char* name; /* Ship name. */
ShipClass class; /* Ship class. */
/* Store stuff. */
unsigned int price; /**< Price! */
int tech; /**< Tech needed for it to be availabe. See space.c */
char* license; /**< License needed to buy it. */
char* fabricator; /**< Manufacturer. */
char* description; /**< Sales pitch. */
/* Movement. */
double thrust, turn, speed;
/* Graphics. */
glTexture* gfx_space;
glTexture* gfx_target;
glTexture* gfx_comm;
/* GUI interface. */
char* gui;
/* Sound. */
int sound;
/* Characteristics. */
int crew;
int mass;
int fuel; /* How many jumps by default. */
/* Health. */
double armour, armour_regen;
double shield, shield_regen;
double energy, energy_regen;
/* Capacity. */
int cap_cargo, cap_weapon;
/* Outfits */
ShipOutfit* outfit;
/* Mounts. */
ShipMount* mounts; /**< Ship weapon mount points. First is primary weapon. */
int nmounts; /**< Number of mount points ship has. */
double mangle; /**< Mount angle to simplify mount calculations. */
} Ship;
/* Load/quit. */
int ships_load(void);
void ships_free(void);
/* Get. */
int ship_getMount(Ship* s, double dir, const int id, Vec2* p);
Ship* ship_get(const char* name);
Ship** ship_getTech(int* n, const int* tech, const int techmax);
char* ship_class(Ship* p);
ShipClass ship_classFromString(char* str);
int ship_basePrice(Ship* s);
/* Toolkit. */
void ship_view(unsigned int unused, char* shipname);