diff options
author | Stijn Buys <ingar@osirion.org> | 2008-03-03 17:39:02 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-03-03 17:39:02 +0000 |
commit | b0af6f8e14449e8bd49efe94da1041628a549120 (patch) | |
tree | aea4b9f1930af1b89e96d05832bc8559fae0a7f0 /src/game | |
parent | e379b1bfeb231716e07f0e4ae9ef024be9bfd08f (diff) |
usable models, target_engine
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/game.cc | 29 | ||||
-rw-r--r-- | src/game/ship.cc | 13 | ||||
-rw-r--r-- | src/game/ship.h | 2 |
3 files changed, 38 insertions, 6 deletions
diff --git a/src/game/game.cc b/src/game/game.cc index 4aa505d..7dc342a 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -25,7 +25,7 @@ void func_join(core::Player *player, std::string const &args) if (player->control()) return; - player->player_control = new Ship(player); + player->player_control = new Ship(player, "micron_vector"); player->control()->entity_color = player->color(); std::string message(player->name()); @@ -54,6 +54,30 @@ void func_spectate(core::Player *player, std::string const &args) player->player_dirty = true; } +/// a player buys a ship +void func_buy(core::Player *player, std::string const &args) +{ + if (!player->control()) { + return; + } + + std::string shipname; + std::istringstream is(args); + is >> shipname; + if ((shipname == "micron_vector") || (shipname == "canasta")) { + // player has only ship for now + player->player_control->die(); + player->player_control = 0; + + player->player_control = new Ship(player, shipname); + player->control()->entity_color = player->color(); + + core::server()->broadcast(player->name() + " purchased a " + shipname); + } + if (!shipname.size()) { + core::server()->send(player, "Usage: buy <micron_vector|canasta>"); + } +} /*----- Game ------------------------------------------------------ */ Game::Game() : core::Module("Project::OSiRiON") @@ -127,9 +151,10 @@ void Game::init() axis->entity_name = "axis: Origin"; // add engine game functions + core::Func::add("buy", (core::GameFuncPtr) func_buy); core::Func::add("join", (core::GameFuncPtr) func_join); core::Func::add("spectate", (core::GameFuncPtr) func_spectate); - + // add engine game variables core::Cvar::set("g_borgcubes", "2", core::Cvar::Game); core::Cvar::set("g_name", name().c_str(), core::Cvar::Game | core::Cvar::ReadOnly); diff --git a/src/game/ship.cc b/src/game/ship.cc index 37c8cd8..19cccbe 100644 --- a/src/game/ship.cc +++ b/src/game/ship.cc @@ -17,13 +17,20 @@ using math::degrees180f; namespace game { -Ship::Ship(core::Player *owner) : +Ship::Ship(core::Player *owner, std::string const & model) : core::EntityControlable(owner, ship_enttype) { // entity properties - entity_name = "ship: <" + owner->name() + "> Micron Vector"; entity_owner = owner; - entity_modelname = "ships/micron_vector"; + + // ship model + if (model.size()) { + entity_modelname = "ships/" + model; + entity_name = model + ": <" + owner->name() + ">"; + } else { + entity_modelname = "ships/micron_vector"; + entity_name = "micron_vector: <" + owner->name() + ">"; + } // ship specs acceleration = 1.5f; diff --git a/src/game/ship.h b/src/game/ship.h index 1d0fdd4..88f42e5 100644 --- a/src/game/ship.h +++ b/src/game/ship.h @@ -17,7 +17,7 @@ namespace game { class Ship : public core::EntityControlable { public: - Ship(core::Player *owner); + Ship(core::Player *owner, std::string const & model); ~Ship(); /// update the ship state |