diff options
Diffstat (limited to 'src/game/base/game.cc')
-rw-r--r-- | src/game/base/game.cc | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc index aa7fd07..72a684b 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -142,12 +142,60 @@ void Game::func_impulse(core::Player *player, std::string const &args) { if (!player->control()) return; + if (player->control()->moduletype() != ship_enttype) return; + Ship * ship = static_cast<Ship *>(player->control()); ship->func_impulse(); } +// autopilot free flight +void Game::func_freeflight(core::Player *player, std::string const &args) +{ + if (!player->control()) + return; + + if (player->control()->moduletype() != ship_enttype) + return; + + Ship * ship = static_cast<Ship *>(player->control()); + + ship->set_autopilot_target(0); + ship->unset_autopilot_flag(Ship::AutoPilotEnabled); + player->send("Autopilot disabled"); +} + +// autopilot goto +void Game::func_target_goto(core::Player *player, core::Entity *entity) +{ + if (!player->control()) + return; + + if (player->control() == entity) + return; + + if (player->control()->zone() != entity->zone()) + return; + + if (player->control()->moduletype() != ship_enttype) + return; + + Ship * ship = static_cast<Ship *>(player->control()); + + if (ship->has_autopilot_flag(Ship::AutoPilotEnabled) && (entity == ship->autopilot_target())) { + ship->set_autopilot_target(0); + ship->unset_autopilot_flag(Ship::AutoPilotEnabled); + player->send("Autopilot disabled"); + } else { + ship->set_autopilot_target(entity); + ship->set_autopilot_flag(Ship::AutoPilotEnabled); + ship->unset_autopilot_flag(Ship::AutoPilotDock); + ship->unset_autopilot_flag(Ship::AutoPilotFormation); + player->send("Autopilot set to " + entity->name()); + } +} + // a player sends a docking request void Game::func_target_dock(core::Player *player, core::Entity *entity) { @@ -1631,6 +1679,9 @@ Game::Game() : core::Module("Project::OSiRiON", true) func = core::Func::add("impulse", Game::func_impulse); func->set_info("toggle kinetic impulse drive"); + + func = core::Func::add("freeflight", Game::func_freeflight); + func->set_info("disable autopilot, enable free flight"); func = core::Func::add("launch", Game::func_launch); func->set_info("launch to space when docked"); @@ -1641,6 +1692,9 @@ Game::Game() : core::Module("Project::OSiRiON", true) func = core::Func::add("goto", Game::func_goto); func->set_info("[string] goto to an entity within the zone"); + func = core::Func::add("@goto", Game::func_target_goto); + func->set_info("set autopilot to target"); + func = core::Func::add("@dock", Game::func_target_dock); func->set_info("send a docking request to target"); |