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>2008-08-01 23:01:35 +0000
committerStijn Buys <ingar@osirion.org>2008-08-01 23:01:35 +0000
commite5a14a1e1a6d822b3b97df803c91727b16d770d2 (patch)
tree431f0a3611298c8c41750edaecf3b6f9c7a81407 /src/game/ship.cc
parentf831477c2502b7a2b32cd1fe1b6678a9c87d3fda (diff)
the kinetic impulse drive
Diffstat (limited to 'src/game/ship.cc')
-rw-r--r--src/game/ship.cc63
1 files changed, 51 insertions, 12 deletions
diff --git a/src/game/ship.cc b/src/game/ship.cc
index d502260..14a5cc8 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -43,6 +43,8 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) :
ship_jumptargetzone = 0;
ship_countdown = 0;
+
+ ship_impulse = false;
}
Ship::~Ship()
@@ -50,13 +52,29 @@ Ship::~Ship()
}
+void Ship::impulse()
+{
+ if (ship_impulse) {
+ ship_impulse = false;
+
+ } else {
+ if (ship_jumpdrive_activated) {
+ ship_jumpdrive_activated = 0;
+ ship_jumptargetzone = 0;
+ ship_countdown = 0;
+ }
+
+ ship_impulse = true;
+ }
+}
+
void Ship::jump(std::string const &args)
{
if (!jumpdrive()) {
core::server()->send(owner(), "This ship is not equiped with a hyperspace drive!");
return;
}
-
+
if (ship_jumpdrive_activated) {
core::server()->send(owner(), "Jump aborted, hyperspace drive deactivated.");
ship_jumpdrive_activated = 0;
@@ -88,13 +106,14 @@ void Ship::jump(std::string const &args)
}
if (ship_jumptargetzone == zone()) {
- core::server()->send(owner(), "Already in '" + ship_jumptargetzone->name() + '\'');
+ core::server()->send(owner(), "Already in the " + ship_jumptargetzone->name() + '.');
ship_jumptargetzone = 0;
return;
}
ship_jumpdrive_activated = core::server()->time();
ship_countdown = 5;
+ ship_impulse = false;
std::stringstream msg("");
msg << "Hyperspace drive activated. Jumping in " << ship_countdown << "...";
@@ -109,6 +128,10 @@ void Ship::frame(float seconds)
float angle; // angle in radians
math::Vector3f n; // normal of a plane
+ float actual_maxspeed = ship_shipmodel->maxspeed();
+ float actual_turnspeed = ship_shipmodel->turnspeed();
+ float actual_acceleration = ship_shipmodel->acceleration();
+
// jumpdrive
// target axis
math::Axis target_axis(entity_axis);
@@ -139,13 +162,29 @@ void Ship::frame(float seconds)
target_roll = 0;
target_direction = 0;
- } else {
+ } else if (ship_impulse) {
+
+ // clamp input values
+ target_thrust = 1.0f;
+ math::clamp(target_pitch, -1.0f, 1.0f);
+ math::clamp(target_roll, -1.0f, 1.0f);
+ math::clamp(target_direction, -1.0f, 1.0f);
+
+ actual_maxspeed = Game::instance()->g_impulsespeed->value();
+ actual_acceleration = Game::instance()->g_impulseacceleration->value();
+ actual_turnspeed *= 0.5;
+ } else {
// clamp input values
math::clamp(target_thrust, 0.0f, 1.0f);
math::clamp(target_pitch, -1.0f, 1.0f);
math::clamp(target_roll, -1.0f, 1.0f);
math::clamp(target_direction, -1.0f, 1.0f);
+
+ if (speed() > actual_maxspeed) {
+ actual_acceleration = Game::instance()->g_impulseacceleration->value();
+ actual_turnspeed *= 0.5;
+ }
}
// update thrust
@@ -170,7 +209,7 @@ void Ship::frame(float seconds)
if (fabs(current_target_roll) > MIN_DELTA) {
float roll_offset = seconds * current_target_roll;
- entity_axis.change_roll(ship_shipmodel->turnspeed() * roll_offset);
+ entity_axis.change_roll(actual_turnspeed * roll_offset);
} else {
current_target_roll = 0.0f;
}
@@ -190,7 +229,7 @@ void Ship::frame(float seconds)
if (fabs(current_target_direction) > MIN_DELTA ) {
math::clamp(current_target_direction, -1.0f, 1.0f);
- target_axis.change_direction(ship_shipmodel->turnspeed() * current_target_direction);
+ target_axis.change_direction(actual_turnspeed * current_target_direction);
} else {
current_target_direction = 0.0f;
}
@@ -207,7 +246,7 @@ void Ship::frame(float seconds)
if (fabs(current_target_pitch) > MIN_DELTA) {
math::clamp(current_target_pitch, -1.0f, 1.0f);
- target_axis.change_pitch(ship_shipmodel->turnspeed() * current_target_pitch);
+ target_axis.change_pitch(actual_turnspeed * current_target_pitch);
} else {
current_target_pitch = 0.0f;
}
@@ -222,13 +261,13 @@ void Ship::frame(float seconds)
}
// update speed
- if (entity_speed < entity_thrust * ship_shipmodel->maxspeed()) {
- entity_speed += ship_shipmodel->acceleration() * seconds;
- if (entity_speed > entity_thrust * ship_shipmodel->maxspeed()) {
- entity_speed = entity_thrust * ship_shipmodel->maxspeed();
+ if (entity_speed < entity_thrust * actual_maxspeed) {
+ entity_speed += actual_acceleration * seconds;
+ if (entity_speed > entity_thrust * actual_maxspeed) {
+ entity_speed = entity_thrust * actual_maxspeed;
}
- } else if(entity_speed > entity_thrust * ship_shipmodel->maxspeed()) {
- entity_speed -= ship_shipmodel->acceleration() * seconds;
+ } else if(entity_speed > entity_thrust * actual_maxspeed) {
+ entity_speed -= actual_acceleration * seconds;
if (entity_speed < 0.0f) entity_speed = 0.0f;
}