diff --git a/dat/outfit.xml b/dat/outfit.xml index 3f6af3b..5e1b42a 100644 --- a/dat/outfit.xml +++ b/dat/outfit.xml @@ -141,4 +141,28 @@ + + + 10 + 3 + 2 + 22500 + A heavy battery that will increase your ships energy allowing you to pack more firepower. + + + 75 + + + + + 3 + 5 + 3 + 55000 + A big panel that will generate energy based off solar energy. This will allow ships to regenerate it's enrgy supplies faster. + + + 125 + + diff --git a/src/outfit.c b/src/outfit.c index 16694e6..8da21f0 100644 --- a/src/outfit.c +++ b/src/outfit.c @@ -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) diff --git a/src/outfit.h b/src/outfit.h index 00d7bd4..e16cf98 100644 --- a/src/outfit.h +++ b/src/outfit.h @@ -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);