Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-12-09 23:09:12 +0000
committerStijn Buys <ingar@osirion.org>2012-12-09 23:09:12 +0000
commit66fd5337bda32d0ef04fff7514a8249ecb5c3b15 (patch)
tree8c187a18452c0f6a8f48520f3c855997ef142108 /src/game/base
parent2c1c377312f9c63c1bd586fb0fd290f677cd0089 (diff)
Improved info text parsing,
added specifications to the weapon info, expanded ship specifications info.
Diffstat (limited to 'src/game/base')
-rw-r--r--src/game/base/shipmodel.cc22
-rw-r--r--src/game/base/shipmodel.h3
-rw-r--r--src/game/base/weapon.cc56
-rw-r--r--src/game/base/weapon.h9
4 files changed, 77 insertions, 13 deletions
diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc
index ba01765..a308b64 100644
--- a/src/game/base/shipmodel.cc
+++ b/src/game/base/shipmodel.cc
@@ -230,32 +230,34 @@ void ShipModel::generate_info()
{
// default mass
set_mass(radius() * 100.0f);
-
- //clear_text();
if (text().size())
- add_text("");
+ add_line("");
- add_text("^BSpecifications:^N");
+ add_line("^BSpecifications:^N");
std::stringstream str;
str << "price: ^B" << price() << " ^Ncredits";
- add_text(str.str());
+ add_line(str.str());
str.str("");
- str << "cargo hold: ^B" << maxcargo() << " ^Ncubic meters";
- add_text(str.str());
+ str << "cargo hold: ^B" << maxcargo() << " ^Ncubic meter";
+ add_line(str.str());
str.str("");
str << "mass: ^B" << mass() << " ^Nmetric tonnes";
- add_text(str.str());
+ add_line(str.str());
+ str.str("");
+
+ str << "hull strength ^B" << maxarmor() << "^N";
+ add_line(str.str());
str.str("");
if (jumpdrive()) {
- add_text("^Bhyperspace jump drive");
+ add_line("^Bhyperspace jump drive");
}
if (dockable()) {
- add_text("^Bdockable");
+ add_line("^Bdockable");
}
}
diff --git a/src/game/base/shipmodel.h b/src/game/base/shipmodel.h
index 243860d..ef37cbf 100644
--- a/src/game/base/shipmodel.h
+++ b/src/game/base/shipmodel.h
@@ -232,6 +232,9 @@ protected:
}
public:
+ /**
+ * @brief generate specifications info.
+ * */
void generate_info();
void buy(core::EntityControlable *buyer, core::Entity *seller);
diff --git a/src/game/base/weapon.cc b/src/game/base/weapon.cc
index ab1ae49..22527c2 100644
--- a/src/game/base/weapon.cc
+++ b/src/game/base/weapon.cc
@@ -196,20 +196,24 @@ bool Weapon::init()
} else if (weaponsini.got_section()) {
+ Weapon *previous = 0;
if (weaponsini.got_section("mine")) {
+ previous = weapon;
weapon = new Weapon();
weapon->set_stackable(true);
weapon->set_subtype(Mine);
count++;
} else if (weaponsini.got_section("cannon")) {
+ previous = weapon;
weapon = new Weapon();
weapon->set_stackable(false);
weapon->set_subtype(Cannon);
count++;
} else if (weaponsini.got_section("turret")) {
+ previous = weapon;
weapon = new Weapon();
weapon->set_stackable(false);
weapon->set_subtype(Turret);
@@ -222,10 +226,18 @@ bool Weapon::init()
} else if (weaponsini.got_section()) {
weaponsini.unknown_section();
- }
+ }
+
+ if (previous) {
+ previous->generate_info();
+ }
}
}
+ if (weapon) {
+ weapon->generate_info();
+ }
+
// add weapon infos
con_debug << " " << weaponsini.name() << " " << count << " weapon types" << std::endl;
@@ -290,5 +302,47 @@ void Weapon::set_subtype(const SubType subtype)
weapon_subtype = subtype;
}
+void Weapon::generate_info()
+{
+ if (text().size())
+ add_line("");
+
+ add_line("^BSpecifications:^N");
+
+ std::stringstream str;
+ str << "price: ^B" << price() << " ^Ncredits";
+ add_line(str.str());
+ str.str("");
+
+ str << "volume: ^B" << volume() << " ^Ncubic meter";
+ add_line(str.str());
+ str.str("");
+
+ if (subtype() == Cannon) {
+ add_line("");
+ add_line("^BProjectiles:^N");
+ str << "damage: ^B" << damage() << "^N";
+ add_line(str.str());
+ str.str("");
+
+ str << "range: ^B" << floor(((float) projectile_lifespan() * projectile_speed()) / 10.0f) << " ^Nmeter";
+ add_line(str.str());
+ str.str("");
+
+ str << "speed: ^B" << floor(projectile_speed()) * 100.0f << " ^Nm/sec";
+ add_line(str.str());
+ str.str("");
+
+ str << "interval: ^B" << projectile_interval() << " ^Nms";
+ add_line(str.str());
+ str.str("");
+
+ } else {
+ str << "damage: ^B" << damage() << "^N";
+ add_line(str.str());
+ str.str("");
+ }
+}
+
} // namespace game
diff --git a/src/game/base/weapon.h b/src/game/base/weapon.h
index b4a790c..746a9ad 100644
--- a/src/game/base/weapon.h
+++ b/src/game/base/weapon.h
@@ -53,7 +53,7 @@ public:
}
/**
- * @brief speed of projectiles generated by this weapon
+ * @brief speed of projectiles generated by this weapon, in game units per second
* */
inline const float projectile_speed() const
{
@@ -123,7 +123,12 @@ public:
{
weapon_projectile_modelname.assign(projectile_modelname);
}
-
+
+ /**
+ * @brief generate specifications info.
+ * */
+ void generate_info();
+
/* --- static registry functions ---------------------------------- */
static Weapon *find(const std::string & label);