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 15:20:14 +0000
committerStijn Buys <ingar@osirion.org>2013-01-01 15:20:14 +0000
commit614ce1267772d67825a32fb7495a049cd6498fe5 (patch)
tree20374ef083b62524e831bce2a8a89fcc70a63f42 /src/game/base/ship.cc
parent18969b1c444597741547598d35e8f0f97acd39dc (diff)
Initial support for turret-style weapons.
Diffstat (limited to 'src/game/base/ship.cc')
-rw-r--r--src/game/base/ship.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 219cb0c..4c3885a 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -925,10 +925,15 @@ void Ship::frame(const unsigned long elapsed)
math::Vector3f projectile_direction(target_aim - projectile_location);
projectile_direction.normalize();
float cosa = math::dotproduct(projectile_direction, projectile_axis.forward());
+
+
// fire a projectile if the angle between the aim direction and the slot's forward direction is small enough
- // TODO configurable aim cone
- if (cosa > 0.5f) {
+
+ // we only need half the cone angle for the cosine calculation
+ float conecos = cosf( slot->cone() / 360.0f * M_PI);
+
+ if (cosa >= conecos) {
// aim
math::Vector3f normal(math::crossproduct(projectile_direction, projectile_axis.forward()));
if (normal.length() > MIN_DELTA) {