[Add] Modification/Upgrades to ships.

This commit is contained in:
Allanis 2013-03-17 16:57:17 +00:00
parent 2f59ae1b84
commit ee3c81b7ff
3 changed files with 79 additions and 3 deletions

View File

@ -141,4 +141,28 @@
</damage>
</specific>
</outfit>
<outfit name="Battery">
<general>
<max>10</max>
<tech>3</tech>
<mass>2</mass>
<price>22500</price>
<description>A heavy battery that will increase your ships energy allowing you to pack more firepower.</description>
</general>
<specific type="15">
<energy>75</energy>
</specific>
</outfit>
<outfit name="Solar Panel">
<general>
<max>3</max>
<tech>5</tech>
<mass>3</mass>
<price>55000</price>
<description>A big panel that will generate energy based off solar energy. This will allow ships to regenerate it's enrgy supplies faster.</description>
</general>
<specific type="15">
<energy_regen>125</energy_regen>
</specific>
</outfit>
</Outfits>

View File

@ -28,6 +28,7 @@ static Outfit* outfit_parse(const xmlNodePtr parent);
static void outfit_parseSWeapon(Outfit* tmp, const xmlNodePtr parent);
static void outfit_parseSLauncher(Outfit* tmp, const xmlNodePtr parent);
static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent);
static void outfit_parseSMod(Outfit* tmp, const xmlNodePtr parent);
// Return an outfit.
Outfit* outfit_get(const char* name) {
@ -89,6 +90,10 @@ int outfit_isTurret(const Outfit* o) {
(o->type == OUTFIT_TYPE_TURRET_BEAM));
}
int outfit_isMod(const Outfit* o) {
return (o->type == OUTFIT_TYPE_MODIFICATION);
}
// Get the outfit graphics.
glTexture* outfit_gfx(const Outfit* o) {
if(outfit_isWeapon(o)) return o->u.blt.gfx_space;
@ -148,7 +153,8 @@ const char* outfit_typename[] = {
"Smart Swarm Missile",
"Smart Swarm Missile Ammunition Pack",
"Bolt Turret",
"Beam Turret"
"Beam Turret",
"Modification"
};
// Return the broad outfit type.
@ -157,7 +163,8 @@ const char* outfit_typenamebroad[] = {
"Weapon",
"Launcher",
"Ammo",
"Turret"
"Turret",
"Modification"
};
const char* outfit_getTypeBroad(const Outfit* o) {
@ -166,6 +173,7 @@ const char* outfit_getTypeBroad(const Outfit* o) {
else if(outfit_isLauncher(o)) i = 2;
else if(outfit_isAmmo(o)) i = 3;
else if(outfit_isTurret(o)) i = 4;
else if(outfit_isMod(o)) i = 5;
return outfit_typenamebroad[i];
}
@ -284,6 +292,37 @@ static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent) {
#undef MELEMENT
}
static void outfit_parseSMod(Outfit* tmp, const xmlNodePtr parent) {
xmlNodePtr node;
node = parent->xmlChildrenNode;
// Load all the data.
do {
// Movement.
if(xml_isNode(node, "thrust"))
tmp->u.mod.thrust = xml_getFloat(node);
else if(xml_isNode(node, "turn"))
tmp->u.mod.turn = xml_getFloat(node);
else if(xml_isNode(node, "speed"))
tmp->u.mod.speed = xml_getFloat(node);
// Health.
if(xml_isNode(node, "armour"))
tmp->u.mod.armour = xml_getFloat(node);
else if(xml_isNode(node, "shield"))
tmp->u.mod.shield = xml_getFloat(node);
else if(xml_isNode(node, "energy"))
tmp->u.mod.energy = xml_getFloat(node);
else if(xml_isNode(node, "armour_regen"))
tmp->u.mod.armour_regen = xml_getFloat(node)/60.0;
else if(xml_isNode(node, "shield_regen"))
tmp->u.mod.shield_regen = xml_getFloat(node)/60.0;
else if(xml_isNode(node, "energy_regen"))
tmp->u.mod.energy_regen = xml_getFloat(node)/60.0;
} while((node = node->next));
}
// Parse and return Outfits from parent node.
static Outfit* outfit_parse(const xmlNodePtr parent) {
Outfit* tmp = CALLOC_L(Outfit);
@ -332,6 +371,8 @@ static Outfit* outfit_parse(const xmlNodePtr parent) {
outfit_parseSAmmo(tmp, node);
else if(outfit_isTurret(tmp))
outfit_parseSWeapon(tmp, node);
else if(outfit_isMod(tmp))
outfit_parseSMod(tmp, node);
}
} while((node = node->next));
#define MELEMENT(o,s) if(o) WARN("Outfit '%s' missing '"s"' element", tmp->name)

View File

@ -22,7 +22,8 @@ typedef enum OutfitType_ {
OUTFIT_TYPE_MISSILE_SWARM_SMART = 11,
OUTFIT_TYPE_MISSILE_SWARM_SMART_AMMO = 12,
OUTFIT_TYPE_TURRET_BOLT = 13,
OUTFIT_TYPE_TURRET_BEAM = 14
OUTFIT_TYPE_TURRET_BEAM = 14,
OUTFIT_TYPE_MODIFICATION = 15
} OutfitType;
// An outfit depends a lot on the type.
@ -80,6 +81,15 @@ typedef struct Outfit_ {
int spfx; // Special effect on hit.
unsigned int lockon; // Time taken to lock on the target.
} amm;
struct { // Modification.
// Movement.
double thrust, turn, speed;
// Health.
double armour, armour_regen;
double shield, shield_regen;
double energy, energy_regen;
} mod;
} u;
} Outfit;
@ -91,6 +101,7 @@ int outfit_isWeapon(const Outfit* o);
int outfit_isLauncher(const Outfit* o);
int outfit_isAmmo(const Outfit* o);
int outfit_isTurret(const Outfit* o);
int outfit_isMod(const Outfit* o);
const char* outfit_getType(const Outfit* o);
const char* outfit_getTypeBroad(const Outfit* o);