From b277c65615482f17c966771341ae6b7a89cc9568 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 20 Oct 2013 14:36:45 +0000 Subject: Make wingmen follow you through jumpgates. --- src/game/base/npc.cc | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'src/game/base/npc.cc') diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc index be7a754..8e820a7 100644 --- a/src/game/base/npc.cc +++ b/src/game/base/npc.cc @@ -84,6 +84,8 @@ void NPC::frame(const unsigned long elapsed) } else if (leader()->zone() == zone()) { + // leader is in this zone + if (leader()->state() == Docked) { if (state() != core::Entity::Docked) { @@ -98,6 +100,15 @@ void NPC::frame(const unsigned long elapsed) unset_autopilot_flag(Ship::AutoPilotEnabled); } + } else if ((leader()->state() == JumpInitiate) || (leader()->state() == Jump)) { + + // goto wherever the leader is jumping + + set_autopilot_target(leader()->jumpdepart()); + set_autopilot_flag(Ship::AutoPilotEnabled); + set_autopilot_flag(Ship::AutoPilotDock); + unset_autopilot_flag(Ship::AutoPilotFormation); + } else { if (state() == core::Entity::Docked) { @@ -116,20 +127,27 @@ void NPC::frame(const unsigned long elapsed) } } else { - unset_autopilot_flag(Ship::AutoPilotEnabled); - - target_direction = 0; - target_pitch = 0; - target_roll = 0; - target_strafe = 0.0f; - target_vstrafe = 0.0f; - - target_afterburner = 0.0f; - target_thrust = 0; - if (state() == core::Entity::Impulse) { + // leader is not in this zone + if (!autopilot_target()) { + + target_direction = 0; + target_pitch = 0; + target_roll = 0; + target_strafe = 0.0f; + target_vstrafe = 0.0f; + + target_afterburner = 0.0f; + target_thrust = 0; + + if (state() == core::Entity::Impulse) { - func_impulse(); + func_impulse(); + } + } else { + set_autopilot_flag(Ship::AutoPilotEnabled); + set_autopilot_flag(Ship::AutoPilotDock); + unset_autopilot_flag(Ship::AutoPilotFormation); } } } -- cgit v1.2.3