diff options
author | Stijn Buys <ingar@osirion.org> | 2014-12-22 22:45:38 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2014-12-22 22:45:38 +0000 |
commit | e38ab774ed6a82e75069214c3169215b0b3638a9 (patch) | |
tree | 5c40f2a513381cba8cab58612276277eef533bb6 /src/game | |
parent | 4ca3ba6e59b871fc77662eccb51e0c773a95299f (diff) |
Added 'wingmen recall' engine function to make wingmen dock at a player's carrier.
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/base/game.cc | 40 | ||||
-rw-r--r-- | src/game/base/npc.cc | 25 | ||||
-rw-r--r-- | src/game/base/ship.h | 2 |
3 files changed, 48 insertions, 19 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc index 2ec3c62..e198d42 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -724,19 +724,41 @@ void Game::func_wingmen(core::Player *player, const std::string &args) } } } - } else if (str.compare("combat") == 0) { - if (ship->has_autopilot_flag(Ship::AutoPilotCombat)) { + } else if (str.compare("combat") == 0) + { + if (ship->has_autopilot_flag(Ship::AutoPilotCombat)) + { ship->unset_autopilot_flag(Ship::AutoPilotCombat); - player->send("Wingmen going into formation!"); - } else { + player->send("^BWingmen going into formation!"); + } else + { ship->set_autopilot_flag(Ship::AutoPilotCombat); - player->send("Wingmen entering combat!"); + player->send("^BWingmen entering combat!"); + } + + } else if ((str.compare("recall") == 0) || (str.compare("laucnh") == 0)) + { + if (ship->has_flag(core::Entity::Dockable)) { + if (ship->has_autopilot_flag(Ship::AutoPilotRecall)) + { + ship->unset_autopilot_flag(Ship::AutoPilotRecall); + player->send("^BLaunching wingmen!"); + } else + { + ship->set_autopilot_flag(Ship::AutoPilotRecall); + player->send("^BRecalling wingmen to dock!"); + + } + } else + { + player->send("^WWingmen can't dock at your ship!"); } - - - } else { + } else + { player->send("Usage: wingmen add [faction label] [amount]"); - player->send(" wingmen combat"); + player->send(" wingmen combat switch wingmen between formation flying and combat mode"); + player->send(" wingmen recall switched wingmend between docked and laucnhed"); + player->send(" wingmen launch alias for recall"); } } 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<Ship *>(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<Ship *>(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; diff --git a/src/game/base/ship.h b/src/game/base/ship.h index db41ba0..eba2b2a 100644 --- a/src/game/base/ship.h +++ b/src/game/base/ship.h @@ -29,7 +29,7 @@ const float COMBAT_DISTANCE = 100.0f; class Ship : public core::EntityControlable { public: - enum AutoPilotFlags { AutoPilotDisabled = 0, AutoPilotEnabled = 1, AutoPilotDock = 2, AutoPilotFormation = 4, AutoPilotCombat = 8 }; + enum AutoPilotFlags { AutoPilotDisabled = 0, AutoPilotEnabled = 1, AutoPilotDock = 2, AutoPilotFormation = 4, AutoPilotCombat = 8, AutoPilotRecall = 16 }; Ship(core::Player *owner, const ShipModel *shipmodel); ~Ship(); |