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/weapon.cc
parent2c1c377312f9c63c1bd586fb0fd290f677cd0089 (diff)
Improved info text parsing,
added specifications to the weapon info, expanded ship specifications info.
Diffstat (limited to 'src/game/base/weapon.cc')
-rw-r--r--src/game/base/weapon.cc56
1 files changed, 55 insertions, 1 deletions
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