diff options
author | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:29:39 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:29:39 +0000 |
commit | 71503d65f1099d9f34010de98d377f8f2f5e474e (patch) | |
tree | 0e54c6dd9b80e9de86742185853b1c6d796ee2c8 /src/game/base/game.cc | |
parent | 159716799ed0aebb3c30ca156a7c253030ab09b1 (diff) |
Removed game::Projectile, added initial support for ship health.
Diffstat (limited to 'src/game/base/game.cc')
-rw-r--r-- | src/game/base/game.cc | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc index 1020fa8..e9ea476 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -751,6 +751,17 @@ void Game::func_sell(core::Player *player, const std::string &args) buyer->inventory()->set_dirty(); } + // unmount if the item was mounted + core::Slot *slot = (seller->slots() ? seller->slots()->find(seller_item) : 0); + + if (slot) { + slot->set_item(0); + slot->unset_flag(core::Slot::Active); + slot->unset_flag(core::Slot::Mounted); + seller_item->unset_flag(core::Item::Mounted); + } + + // delete the item if the amount is 0 if (seller_item->amount() == 0) { seller->inventory()->erase(seller_item->id()); seller->inventory()->set_dirty(); @@ -1195,7 +1206,7 @@ void Game::func_mount(core::Player *player, const std::string &args) if (item->info()->type() != Weapon::infotype()) { if (ship->owner()) { std::stringstream msgstr; - msgstr << "^WItem " << id << " can not be mounted"; + msgstr << "^W" << item->info()->name() << " can not be mounted"; ship->owner()->send(msgstr.str()); } return; @@ -1205,7 +1216,7 @@ void Game::func_mount(core::Player *player, const std::string &args) if (!item->unique() || (weapon->subtype() != Weapon::Cannon)) { if (ship->owner()) { std::stringstream msgstr; - msgstr << "^WItem " << id << " can not be mounted"; + msgstr << "^W" << weapon->name() << " can not be mounted"; ship->owner()->send(msgstr.str()); } return; @@ -1213,20 +1224,12 @@ void Game::func_mount(core::Player *player, const std::string &args) if (item->has_flag(core::Item::Mounted)) { // unmount - core::Slot *slot = 0; - - for(core::Slots::iterator it = ship->slots()->begin(); (!slot) && (it != ship->slots()->end()); ++it) { - if ((*it)->item() == item) { - slot = (*it); - } - } - + core::Slot *slot = ship->slots()->find(item); if (slot) { slot->set_item(0); slot->unset_flag(core::Slot::Active); slot->unset_flag(core::Slot::Mounted); - item->unset_flag(core::Item::Mounted); - + item->unset_flag(core::Item::Mounted); if (ship->owner()) { std::stringstream msgstr; msgstr << "^BUnmounted " << weapon->name(); @@ -1247,7 +1250,7 @@ void Game::func_mount(core::Player *player, const std::string &args) if (!slot) { if (ship->owner()) { std::stringstream msgstr; - msgstr << "^WNo slot available to mount item " << id; + msgstr << "^WNo slot available to mount " << weapon->name(); ship->owner()->send(msgstr.str()); } return; @@ -1256,13 +1259,6 @@ void Game::func_mount(core::Player *player, const std::string &args) slot->set_flag(core::Slot::Active); slot->set_flag(core::Slot::Mounted); item->set_flag(core::Item::Mounted); - - slot->set_projectile_damage(weapon->damage()); - slot->set_projectile_speed(weapon->projectile_speed()); - slot->set_projectile_lifespan(weapon->projectile_lifespan()); - slot->set_projectile_interval(weapon->projectile_interval()); - slot->set_projectile_modelname(weapon->projectile_modelname()); - if (ship->owner()) { std::stringstream msgstr; msgstr << "^BMounted " << weapon->name(); |