From 614ce1267772d67825a32fb7495a049cd6498fe5 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 1 Jan 2013 15:20:14 +0000 Subject: Initial support for turret-style weapons. --- src/game/base/ship.cc | 9 +++++++-- src/game/base/shipmodel.cc | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/game/base') 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) { diff --git a/src/game/base/shipmodel.cc b/src/game/base/shipmodel.cc index ba87024..7d54ee2 100644 --- a/src/game/base/shipmodel.cc +++ b/src/game/base/shipmodel.cc @@ -235,6 +235,7 @@ void ShipModel::generate_info() add_line(""); add_line("^BSpecifications:^N"); + std::stringstream str; str << "price: ^B" << price() << " ^Ncredits"; add_line(str.str()); @@ -259,6 +260,17 @@ void ShipModel::generate_info() if (dockable()) { add_line("^Bdockable"); } + + if (modelname().size()) { + // FIXME the model has to be loaded to got slot information + /* + int nbcannons = 0; + int nbturrets = 0; + + add_line(""); + add_line("^BWeapons:^N"); + */ + } } ShipModel *ShipModel::find(const std::string & label) -- cgit v1.2.3