diff options
Diffstat (limited to 'src/game/base')
-rw-r--r-- | src/game/base/ship.cc | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index ccd8718..5467728 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -29,6 +29,10 @@ using math::degrees180f; namespace game { + +// powersteering factor +const float POWERSTEERING = 4.0f; + Ship::Ship(core::Player *owner, const ShipModel *shipmodel) : core::EntityControlable() { @@ -1099,7 +1103,6 @@ void Ship::frame(const unsigned long elapsed) current_target_vstrafe = target_vstrafe; if (has_target_controlflag(core::EntityControlable::ControlFlagOverride)) { - const float powersteering = 4.0f; // use mouse aim location to set steering controls math::Vector3f direction(target_aim - location()); direction.normalize(); @@ -1109,12 +1112,12 @@ void Ship::frame(const unsigned long elapsed) if (direction.x() < 0) { // aim is behind the ship - target_pitch = direction.z() * powersteering; - target_direction = direction.y() * powersteering; + target_pitch = direction.z() * POWERSTEERING; + target_direction = direction.y() * POWERSTEERING; } else { // target is in front of the ship - target_pitch = direction.z() * powersteering; - target_direction = direction.y() * powersteering; + target_pitch = direction.z() * POWERSTEERING; + target_direction = direction.y() * POWERSTEERING; } math::clamp(target_pitch, -1.0f, 1.0f); math::clamp(target_direction, -1.0f, 1.0f); @@ -1262,6 +1265,12 @@ void Ship::frame_autopilot_goto(const unsigned long elapsed, core::Entity *targe target_pitch = 0.0f; } + target_direction *= POWERSTEERING; + current_target_pitch *= POWERSTEERING; + + math::clamp(target_pitch, -1.0f, 1.0f); + math::clamp(target_direction, -1.0f, 1.0f); + target_roll = 0.0f; // impulse or thruster @@ -1364,6 +1373,7 @@ void Ship::frame_autopilot_combat(const unsigned long elapsed, core::Entity *tar // transform direction from world coordinates to local entity coordinates direction = axis().transpose() * direction; + if (direction.x() < 0) { // target is behind the ship @@ -1385,6 +1395,12 @@ void Ship::frame_autopilot_combat(const unsigned long elapsed, core::Entity *tar target_pitch = 0.0f; } + target_direction *= POWERSTEERING; + current_target_pitch *= POWERSTEERING; + + math::clamp(target_pitch, -1.0f, 1.0f); + math::clamp(target_direction, -1.0f, 1.0f); + // transform the target's axis into local coordinates const math::Axis reference(axis().transpose() * target->axis()); if (reference.up().z() < 0.0f) { @@ -1432,6 +1448,12 @@ void Ship::frame_autopilot_formation(const unsigned long elapsed, core::Entity * target_direction = 0.0f; target_pitch = 0.0f; } + + target_direction *= POWERSTEERING; + current_target_pitch *= POWERSTEERING; + + math::clamp(target_pitch, -1.0f, 1.0f); + math::clamp(target_direction, -1.0f, 1.0f); if (reference.up().z() < 0.0f) { |