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>2013-01-01 16:16:59 +0000
committerStijn Buys <ingar@osirion.org>2013-01-01 16:16:59 +0000
commitd3ed23de89a7c1ddbb92990eee966966ee8fbeee (patch)
treeb3c48b0b8d2ca3ef847a25746b7fc0fe7505cfef /src/game/base/ship.cc
parent614ce1267772d67825a32fb7495a049cd6498fe5 (diff)
Turrets and cannons can only be mounted in an approriate slot.
Diffstat (limited to 'src/game/base/ship.cc')
-rw-r--r--src/game/base/ship.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 4c3885a..7ce6d36 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -912,16 +912,26 @@ void Ship::frame(const unsigned long elapsed)
core::Slot *slot = (*it);
// create projectiles
- if (slot->has_flag(core::Slot::Mounted) && slot->item() && (slot->item()->info()->type() == Weapon::infotype())) {
+ if (!slot->has_flag(core::Slot::Mounted)) {
+ continue;
+
+ } else if ( !(slot->item() && (slot->item()->info()->type() == Weapon::infotype()))) {
+ continue;
+
+ } else {
const Weapon *weapon = static_cast<const Weapon *>(slot->item()->info());
- if ((weapon->subtype() == Weapon::Cannon) && (weapon->projectile_interval() > 0) && (slot->last_fired() + weapon->projectile_interval() <= core::server()->timestamp())) {
+
+ if ((weapon->subtype() != Weapon::Cannon) && (weapon->subtype() != Weapon::Turret) ) {
+ continue;
+
+ } else if ((weapon->projectile_interval() > 0) && (slot->last_fired() + weapon->projectile_interval() <= core::server()->timestamp())) {
// aim
const float projectile_radius = 0.01f; // FIXME this should be defined somewhere
math::Axis projectile_axis(axis() * slot->axis());
- math::Vector3f projectile_location(location() + (axis() * slot->location() * modelscale) + projectile_axis.forward() * projectile_radius);
+ math::Vector3f projectile_location(location() + (axis() * slot->location() * modelscale) + projectile_axis.forward() * projectile_radius);
math::Vector3f projectile_direction(target_aim - projectile_location);
projectile_direction.normalize();
float cosa = math::dotproduct(projectile_direction, projectile_axis.forward());