Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base/ship.cc')
-rw-r--r--src/game/base/ship.cc77
1 files changed, 53 insertions, 24 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index edfc949..ba5d7ba 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -63,24 +63,24 @@ void Ship::reset()
}
void Ship::func_impulse()
{
- if (entity_eventstate == core::Entity::Impulse) {
- entity_eventstate = core::Entity::Normal;
+ if (entity_state == core::Entity::Impulse) {
+ entity_state = core::Entity::Normal;
target_thrust = 1.0f;
entity_thrust = 1.0f;
- } else if (entity_eventstate == core::Entity::ImpulseInitiate) {
- entity_eventstate = core::Entity::Normal;
+ } else if (entity_state == core::Entity::ImpulseInitiate) {
+ entity_state = core::Entity::Normal;
- } else if (entity_eventstate != core::Entity::Normal) {
+ } else if (entity_state != core::Entity::Normal) {
return;
} else {
- if (entity_eventstate == core::Entity::JumpInitiate) {
+ if (entity_state == core::Entity::JumpInitiate) {
ship_jumpdrive_timer = 0;
entity_timer = 0;
}
- entity_eventstate = core::Entity::ImpulseInitiate;
+ entity_state = core::Entity::ImpulseInitiate;
if (Game::g_devel->value()) {
entity_timer = 0;
} else {
@@ -104,7 +104,7 @@ void Ship::initiate_jump(JumpPoint *depart)
return;
ship_jumpdepart = depart;
- entity_eventstate = core::Entity::JumpInitiate;
+ entity_state = core::Entity::JumpInitiate;
if (Game::g_devel->value()) {
entity_timer = 0;
@@ -118,7 +118,7 @@ void Ship::initiate_jump(JumpPoint *depart)
void Ship::func_jump(std::string const &args)
{
- if (entity_eventstate == core::Entity::Docked) {
+ if (entity_state == core::Entity::Docked) {
return;
}
@@ -150,7 +150,7 @@ void Ship::func_jump(std::string const &args)
ship_jumpdrive_timer = 0;
entity_timer = 0;
- entity_eventstate = core::Entity::Jump;
+ entity_state = core::Entity::Jump;
entity_dirty = true;
return;
@@ -160,14 +160,14 @@ void Ship::func_jump(std::string const &args)
owner()->send("This ship is not equiped with a hyperspace drive!");
return;
- } else if (entity_eventstate == core::Entity::Jump) {
+ } else if (entity_state == core::Entity::Jump) {
return;
- } else if (entity_eventstate == core::Entity::JumpInitiate) {
+ } else if (entity_state == core::Entity::JumpInitiate) {
owner()->send("Jump aborted, hyperspace drive deactivated");
ship_jumpdrive_timer = 0;
entity_timer = 0;
- entity_eventstate = core::Entity::Normal;
+ entity_state = core::Entity::Normal;
return;
}
initiate_jump(find_closest_jumppoint());
@@ -207,6 +207,24 @@ JumpPoint * Ship::find_closest_jumppoint()
return 0;
}
+void Ship::explode()
+{
+ set_state(core::Entity::Destroyed);
+
+ target_thrust = 0;
+ target_pitch = 0;
+ target_roll = 0;
+ target_direction = 0;
+ target_afterburner = 0.0f;
+ target_thrust = 0;
+ entity_thrust = 0;
+
+ if (owner()) {
+ if (owner()->control() == this)
+ owner()->set_view(this);
+ }
+};
+
void Ship::frame(float seconds)
{
const float direction_change_speed = 2;
@@ -228,7 +246,7 @@ void Ship::frame(float seconds)
// target axis
math::Axis target_axis(entity_axis);
- if (entity_eventstate == core::Entity::Docked) {
+ if (entity_state == core::Entity::Docked) {
target_thrust = 0;
target_pitch = 0;
@@ -238,16 +256,17 @@ void Ship::frame(float seconds)
target_thrust = 0;
entity_speed = 0;
+ entity_thrust = 0;
return;
- } else if (entity_eventstate == core::Entity::JumpInitiate) {
+ } else if (entity_state == core::Entity::JumpInitiate) {
if (ship_jumpdrive_timer + 1.0f <= core::server()->time()) {
entity_timer -= 1.0f;
if (entity_timer <= 0) {
if (ship_jumpdepart && ship_jumpdepart->target()) {
- entity_eventstate = core::Entity::Jump;
+ set_state(core::Entity::Jump);
set_zone(ship_jumpdepart->target()->zone());
if (owner() && owner()->control() == (EntityControlable*) this)
owner()->set_zone(ship_jumpdepart->target()->zone());
@@ -261,7 +280,7 @@ void Ship::frame(float seconds)
}
owner()->send("^BJumping to the " + ship_jumpdepart->target()->zone()->name());
} else {
- entity_eventstate = core::Entity::Normal;
+ set_state(core::Entity::Normal);
}
ship_jumpdrive_timer = 0;
entity_timer = 0;
@@ -282,7 +301,7 @@ void Ship::frame(float seconds)
target_afterburner = 0.0f;
target_thrust = 0.1;
- } else if (entity_eventstate == core::Entity::Jump) {
+ } else if (entity_state == core::Entity::Jump) {
// control is disabled while the jumpdrive is activated
target_thrust = 0;
target_pitch = 0;
@@ -298,12 +317,12 @@ void Ship::frame(float seconds)
// FIXME 5 second cooldown
entity_speed = Game::g_impulsespeed->value();
- entity_eventstate = core::Entity::Normal;
+ entity_state = core::Entity::Normal;
if (owner() && owner()->view() && owner()->control() == (EntityControlable*) this)
owner()->set_view(0);
- } else if (entity_eventstate == core::Entity::ImpulseInitiate) {
+ } else if (entity_state == core::Entity::ImpulseInitiate) {
if (ship_impulsedrive_timer + 1.0f <= core::server()->time()) {
entity_timer -= 1.0f;
@@ -311,7 +330,7 @@ void Ship::frame(float seconds)
if (entity_timer <= 0) {
actual_maxspeed = Game::g_impulsespeed->value();
actual_acceleration = Game::g_impulseacceleration->value();
- entity_eventstate = core::Entity::Impulse;
+ entity_state = core::Entity::Impulse;
entity_timer = 0;
entity_dirty = true;
} else {
@@ -328,7 +347,7 @@ void Ship::frame(float seconds)
math::clamp(target_afterburner, -1.0f, 1.0f);
actual_turnspeed *= 0.5;
- } else if (entity_eventstate == core::Entity::Impulse) {
+ } else if (entity_state == core::Entity::Impulse) {
// clamp input values
target_thrust = 0.0f;
@@ -340,7 +359,7 @@ void Ship::frame(float seconds)
actual_acceleration = Game::g_impulseacceleration->value();
actual_turnspeed *= 0.5;
- } else if (entity_eventstate == core::Entity::Normal) {
+ } else if (entity_state == core::Entity::Normal) {
// clamp input values
math::clamp(target_thrust, 0.0f, 1.0f);
@@ -354,6 +373,16 @@ void Ship::frame(float seconds)
actual_turnspeed *= 0.5;
}
+ } else if (entity_state == core::Entity::Destroyed) {
+
+ target_thrust = 0;
+ target_pitch = 0;
+ target_roll = 0;
+ target_direction = 0;
+ target_afterburner = 0.0f;
+ target_thrust = 0;
+
+ entity_thrust = 0;
}
// update roll
@@ -449,7 +478,7 @@ void Ship::frame(float seconds)
math::clamp(entity_thrust, 0.0f, 1.0f);
float actual_thrust = entity_thrust + current_target_afterburner * 0.15f;
- if ((entity_eventstate == core::Entity::ImpulseInitiate) || (entity_eventstate == core::Entity::Impulse)) {
+ if ((entity_state == core::Entity::ImpulseInitiate) || (entity_state == core::Entity::Impulse)) {
actual_thrust = 1.0f;
}