From e38ab774ed6a82e75069214c3169215b0b3638a9 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 22 Dec 2014 22:45:38 +0000 Subject: Added 'wingmen recall' engine function to make wingmen dock at a player's carrier. --- src/game/base/npc.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/game/base/npc.cc') diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc index f327f16..f9a600e 100644 --- a/src/game/base/npc.cc +++ b/src/game/base/npc.cc @@ -302,13 +302,12 @@ void NPC::frame(const unsigned long elapsed) if (dock()->moduletype() == ship_enttype) { Ship *carrier = static_cast(dock()); + set_location(carrier->location()); + set_axis(carrier->axis()); if (zone() != carrier->zone()) { set_zone(carrier->zone()); - } - set_location(carrier->location()); - set_axis(carrier->axis()); - + } if (carrier->state() == core::Entity::Destroyed) { explode(); @@ -331,7 +330,7 @@ void NPC::frame(const unsigned long elapsed) } else { npc_repair_timestamp = 0; - if (carrier->state() == core::Entity::Normal) + if ( (carrier->state() == core::Entity::Normal) && ((carrier != leader()) || !leader()->has_autopilot_flag(Ship::AutoPilotRecall)) ) { launch(); } @@ -341,7 +340,7 @@ void NPC::frame(const unsigned long elapsed) } } } else { - if (leader()->has_flag(core::Entity::Dockable) && (health() < NPC_REPAIR_WIMPY)) + if (leader()->has_flag(core::Entity::Dockable) && ((health() < NPC_REPAIR_WIMPY) || leader()->has_autopilot_flag(Ship::AutoPilotRecall)) ) { set_autopilot_target(leader()); @@ -382,10 +381,18 @@ void NPC::frame(const unsigned long elapsed) } } else { - // leader is not in this zone - if (!autopilot_target()) { - + if ((state() == core::Entity::Docked) && (dock()) && (dock()->moduletype() == ship_enttype)) + { + Ship *carrier = static_cast(dock()); + set_location(carrier->location()); + set_axis(carrier->axis()); + if (zone() != carrier->zone()) + { + set_zone(carrier->zone()); + } + } else if (!autopilot_target()) + { target_direction = 0; target_pitch = 0; target_roll = 0; -- cgit v1.2.3