From 7afa635b4728e504ca6ec3bf64223efe0f991f67 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 18 Nov 2013 18:44:16 +0000 Subject: Have the autopilot disable impulse druve at 10km from a planet, preventing AI ships to seemingly dock at impulse speed. --- src/game/base/ship.cc | 56 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 14 deletions(-) (limited to 'src/game') 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 + } } } -- cgit v1.2.3