diff options
-rw-r--r-- | src/game/base/npc.cc | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc index 3c8c9bf..be7a754 100644 --- a/src/game/base/npc.cc +++ b/src/game/base/npc.cc @@ -86,23 +86,37 @@ void NPC::frame(const unsigned long elapsed) if (leader()->state() == Docked) { - // TODO dock where the leader is docked - if (leader()->dock()) { - frame_autopilot_goto(elapsed, leader()->dock()); + if (state() != core::Entity::Docked) { + + set_autopilot_target(leader()->dock()); + + set_autopilot_flag(Ship::AutoPilotEnabled); + set_autopilot_flag(Ship::AutoPilotDock); + unset_autopilot_flag(Ship::AutoPilotFormation); + + } else { + unset_autopilot_flag(Ship::AutoPilotEnabled); } - + } else { - if (math::distance(location(), leader()->location()) > 4.0f * ( radius() + leader()->radius())) { - // goto the leader - frame_autopilot_goto(elapsed, leader()); + if (state() == core::Entity::Docked) { + + // FIXME check launch conditions when docked at another player's ship + launch(); + } else { - // formatian flying - frame_autopilot_formation(elapsed, leader()); + + set_autopilot_target(leader()); + + set_autopilot_flag(Ship::AutoPilotEnabled); + unset_autopilot_flag(Ship::AutoPilotDock); + set_autopilot_flag(Ship::AutoPilotFormation); } } } else { + unset_autopilot_flag(Ship::AutoPilotEnabled); target_direction = 0; target_pitch = 0; @@ -114,6 +128,7 @@ void NPC::frame(const unsigned long elapsed) target_thrust = 0; if (state() == core::Entity::Impulse) { + func_impulse(); } } |