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-08 22:17:29 +0000
committerStijn Buys <ingar@osirion.org>2008-08-08 22:17:29 +0000
commit56b0856541446cbafee4eed9ef0ee9fb69af565a (patch)
tree8cec133fb9b0a02fc2f415c26b69fcd4c6db1ef9 /src/game/ship.cc
parentf540e8dac10de8ff443692e78404b1508dde9d1e (diff)
improved truster indicator, impulse engine sounds
Diffstat (limited to 'src/game/ship.cc')
-rw-r--r--src/game/ship.cc105
1 files changed, 64 insertions, 41 deletions
diff --git a/src/game/ship.cc b/src/game/ship.cc
index f8a1143..4ddd118 100644
--- a/src/game/ship.cc
+++ b/src/game/ship.cc
@@ -40,12 +40,11 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) :
ship_shipmodel = shipmodel;
ship_jumpdrive = shipmodel->shipmodel_jumpdrive;
- ship_jumpdrive_activated = 0;
+
ship_jumptargetzone = 0;
- ship_countdown = 0;
-
- ship_impulse = false;
+ ship_impulsedrive_timer = 0;
+ ship_jumpdrive_timer = 0;
}
Ship::~Ship()
@@ -55,19 +54,26 @@ Ship::~Ship()
void Ship::impulse()
{
- if (ship_impulse) {
- ship_impulse = false;
+ if (entity_eventstate == core::Entity::Jump) {
+ return;
+
+ } else if ((entity_eventstate == core::Entity::Impulse) || (entity_eventstate == core::Entity::ImpulseInitiate)) {
entity_eventstate = core::Entity::Normal;
+
} else {
- if (ship_jumpdrive_activated) {
- ship_jumpdrive_activated = 0;
+
+ if (entity_eventstate == core::Entity::JumpInitiate) {
+ ship_jumpdrive_timer = 0;
ship_jumptargetzone = 0;
- ship_countdown = 0;
+ entity_timer = 0;
}
- entity_eventstate = core::Entity::Impulse;
- ship_impulse = true;
+ entity_eventstate = core::Entity::ImpulseInitiate;
+ entity_timer = 3;
+ ship_impulsedrive_timer = core::server()->time();
+ entity_dirty = true;
}
+
entity_dirty = true;
}
@@ -76,13 +82,15 @@ 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) {
+
+ } else if (entity_eventstate == core::Entity::Jump) {
+ return;
+
+ } else if (entity_eventstate == core::Entity::JumpInitiate) {
core::server()->send(owner(), "Jump aborted, hyperspace drive deactivated.");
- ship_jumpdrive_activated = 0;
ship_jumptargetzone = 0;
- ship_countdown = 0;
+ ship_jumpdrive_timer = 0;
+ entity_timer = 0;
entity_eventstate = core::Entity::Normal;
return;
}
@@ -115,16 +123,9 @@ void Ship::jump(std::string const &args)
return;
}
- ship_jumpdrive_activated = core::server()->time();
- ship_countdown = 10;
- ship_impulse = false;
-
- std::stringstream msg("");
- msg << "Initializing hyperspace jump drive...";
- core::server()->send(owner(), msg.str());
-
entity_eventstate = core::Entity::JumpInitiate;
- entity_timer = ship_countdown; // countdown to jump, in seconds
+ entity_timer = 10;
+ ship_jumpdrive_timer = core::server()->time();
entity_dirty = true;
}
@@ -147,34 +148,29 @@ void Ship::frame(float seconds)
// target axis
math::Axis target_axis(entity_axis);
- if (ship_jumpdrive_activated) {
+ if (entity_eventstate == core::Entity::JumpInitiate) {
- if (ship_jumpdrive_activated + 1.0f <= core::server()->time()) {
- ship_countdown -= 1.0f;
- entity_timer = ship_countdown;
+ if (ship_jumpdrive_timer + 1.0f <= core::server()->time()) {
+ entity_timer -= 1.0f;
- if (ship_countdown <= 0) {
+ if (entity_timer <= 0) {
core::server()->send(owner(), "Jumping to '" + ship_jumptargetzone->name() + '\'');
set_zone(ship_jumptargetzone);
if (owner()->control() == (EntityControlable*) this)
owner()->set_zone(ship_jumptargetzone);
- ship_jumpdrive_activated = 0;
+ ship_jumpdrive_timer = 0;
ship_jumptargetzone = 0;
- entity_dirty = true;
+ entity_timer = 0;
entity_eventstate = core::Entity::Jump;
+ entity_dirty = true;
return;
} else {
- if (ship_countdown <= 5) {
- std::stringstream msg("");
- msg << ship_countdown << "...";
- core::server()->send(owner(), msg.str());
- }
- ship_jumpdrive_activated = core::server()->time();
+ ship_jumpdrive_timer = core::server()->time();
entity_dirty = true;
}
}
- // control is disables while the jumpdrive is activated
+ // control is disabled while the jumpdrive is activated
target_thrust = 0;
target_pitch = 0;
target_roll = 0;
@@ -189,7 +185,32 @@ void Ship::frame(float seconds)
// FIXME 5 second cooldown
entity_eventstate = core::Entity::Normal;
- } else if (ship_impulse) {
+ } else if (entity_eventstate == core::Entity::ImpulseInitiate) {
+
+ if (ship_impulsedrive_timer + 1.0f <= core::server()->time()) {
+ entity_timer -= 1.0f;
+
+ if (entity_timer <= 0) {
+ actual_maxspeed = Game::instance()->g_impulsespeed->value();
+ actual_acceleration = Game::instance()->g_impulseacceleration->value();
+ entity_eventstate = core::Entity::Impulse;
+ entity_timer = 0;
+ entity_dirty = true;
+ } else {
+ ship_impulsedrive_timer = core::server()->time();
+ entity_dirty = true;
+ }
+ }
+
+ // 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_turnspeed *= 0.5;
+
+ } else if (entity_eventstate == core::Entity::Impulse) {
// clamp input values
target_thrust = 1.0f;
@@ -201,7 +222,8 @@ void Ship::frame(float seconds)
actual_acceleration = Game::instance()->g_impulseacceleration->value();
actual_turnspeed *= 0.5;
- } else {
+ } else if (entity_eventstate == core::Entity::Normal) {
+
// clamp input values
math::clamp(target_thrust, 0.0f, 1.0f);
math::clamp(target_pitch, -1.0f, 1.0f);
@@ -212,6 +234,7 @@ void Ship::frame(float seconds)
actual_acceleration = Game::instance()->g_impulseacceleration->value();
actual_turnspeed *= 0.5;
}
+
}
// update thrust