Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-11-18 18:44:16 +0000
committerStijn Buys <ingar@osirion.org>2013-11-18 18:44:16 +0000
commit7afa635b4728e504ca6ec3bf64223efe0f991f67 (patch)
treeac697a7b946064c12ecf8b70fa906228c1230180 /src/game
parentc68a2899dc63850d77f79eaa65125f6d503fc83a (diff)
Have the autopilot disable impulse druve at 10km from a planet, preventing AI ships to seemingly dock at impulse speed.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/ship.cc56
1 files changed, 42 insertions, 14 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 7fae769..03c44aa 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -1272,13 +1272,28 @@ void Ship::frame_autopilot_goto(const unsigned long elapsed, core::Entity *targe
target_roll = 0.0f;
// impulse or thruster
- if (distance > r + PLANET_SAFE_DISTANCE) {
+ if (distance > r + 2.0f * PLANET_SAFE_DISTANCE) {
if (state() == core::Entity::Normal) {
- // enable impulse drive
+ // far away, enable impulse drive
func_impulse();
}
+ } else if (distance > r + PLANET_SAFE_DISTANCE) {
+
+ if (autopilot_target()->moduletype() == planet_enttype) {
+ if ((state() == core::Entity::Impulse) || (state() == core::Entity::ImpulseInitiate)) {
+ // near planet, disable impulse drive
+ func_impulse();
+ }
+
+ } else {
+ if (state() == core::Entity::Normal) {
+ // still far enough, enable impulse drive
+ func_impulse();
+ }
+ }
+
} else {
if (target->type() == core::Entity::Controlable) {
@@ -1287,8 +1302,8 @@ void Ship::frame_autopilot_goto(const unsigned long elapsed, core::Entity *targe
if (state() == core::Entity::Impulse) {
- if (controlable->state() != core::Entity::Impulse) {
- // disbable impulse drive
+ if (controlable->state() == core::Entity::Normal) {
+ // disable impulse drive
func_impulse();
}
@@ -1302,22 +1317,35 @@ void Ship::frame_autopilot_goto(const unsigned long elapsed, core::Entity *targe
} else {
- if (state() == core::Entity::Impulse) {
+ if ((state() == core::Entity::Impulse) || (state() == core::Entity::ImpulseInitiate)){
func_impulse();
}
}
}
- // thruster
- if (distance > 4.0f * r) {
- target_thrust = 1.0f;
-
- } else if (distance > r ) {
- target_thrust = math::max(0.1f, (distance - r ) / (3.0f * r));
-
+ if (autopilot_target()->moduletype() == planet_enttype) {
+ // thrust rules for planet approaches
+ if (distance > r + 2.0f * PLANET_SAFE_DISTANCE) {
+ target_thrust = 1.0f;
+
+ } else if (distance > r + PLANET_SAFE_DISTANCE) {
+ target_thrust = math::max(0.1f, (distance - r - PLANET_SAFE_DISTANCE) / PLANET_SAFE_DISTANCE);
+ } else {
+ target_thrust = 0.0f;
+ // TODO autolevel
+ }
} else {
- target_thrust = 0.0f;
- // TODO autolevel
+ // thruster
+ if (distance > 4.0f * r) {
+ target_thrust = 1.0f;
+
+ } else if (distance > r ) {
+ target_thrust = math::max(0.1f, (distance - r ) / (3.0f * r));
+
+ } else {
+ target_thrust = 0.0f;
+ // TODO autolevel
+ }
}
}