From 28bafa75762012a088a52f71e5b18838a4e678c2 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 17 Oct 2013 18:39:28 +0000 Subject: Use the ship autopilot interface for NPCs, have wingmen dock at a bases when the player does. --- src/game/base/npc.cc | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'src/game') 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(); } } -- cgit v1.2.3