diff options
Diffstat (limited to 'src/game/base/npc.cc')
-rw-r--r-- | src/game/base/npc.cc | 75 |
1 files changed, 14 insertions, 61 deletions
diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc index bb4c180..dba7929 100644 --- a/src/game/base/npc.cc +++ b/src/game/base/npc.cc @@ -71,11 +71,8 @@ void NPC::frame(const unsigned long elapsed) } } else { - - // FIXME verify the leader is still alive - - // TODO pilot magic and mood witchcraft + // TODO pilot magic and mood witchcraft if (leader()) { // verify leader still exists @@ -87,66 +84,22 @@ void NPC::frame(const unsigned long elapsed) } else if (leader()->zone() == zone()) { - // rotate towards leader: direction - math::Vector3f d(leader()->location() - location()); - float distance = d.length(); - - d.normalize(); - - float direction_angle = math::dotproduct(axis().forward(), d); - float direction_sign = math::sgnf(math::dotproduct(axis().left(), d)); - - if (direction_sign < 0 ) { - target_direction = direction_sign; - } else if (direction_angle + MIN_DELTA < 1.0f ) { - target_direction = direction_sign * direction_angle; - } else { - target_direction = 0.0f; - } - - // rotate towards leader: pitch - direction_angle = math::dotproduct(axis().forward(), d); - direction_sign = math::sgnf(math::dotproduct(axis().up(), d)); - - if (direction_sign < 0 ) { - target_pitch = direction_sign; - } else if (direction_angle + MIN_DELTA < 1.0f ) { - target_pitch = direction_sign * direction_angle; - } else { - target_pitch = 0.0f; - } - - const float r = 2.0f * (radius() + leader()->radius()); - - if (distance > 2.0f * r + 50.0f) { - if (state() == core::Entity::Normal) { - // enable impulse drive - func_impulse(); - } - } else { - if (state() == core::Entity::Impulse) { - - if (leader()->state() != core::Entity::Impulse) { - // disbable impulse drive - func_impulse(); - } - - } else if (state() == core::Entity::Normal) { - - if ((leader()->state() == core::Entity::Impulse) || (leader()->state() == core::Entity::ImpulseInitiate)) { - // enable impulse drive - func_impulse(); - } + if (leader()->state() == Docked) { + + // TODO dock where the leader is docked + if (leader()->dock()) { + frame_autopilot_goto(elapsed, leader()->dock()); } - } - - if (distance > 2.0f * r) { - target_thrust = 1.0f; - } else if (distance > r) { - target_thrust = (distance - r ) / r; } else { - target_thrust = 0.0f; + + if (math::distance(location(), leader()->location()) > 4.0f * ( radius() + leader()->radius())) { + // goto the leader + frame_autopilot_goto(elapsed, leader()); + } else { + // formatian flying + frame_autopilot_formation(elapsed, leader()); + } } } else { |