diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/base/game.cc | 6 | ||||
-rw-r--r-- | src/game/base/projectile.h | 5 | ||||
-rw-r--r-- | src/game/base/ship.cc | 23 | ||||
-rw-r--r-- | src/game/base/spacemine.h | 18 |
4 files changed, 49 insertions, 3 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc index a8a1aa2..2355a9e 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -1012,6 +1012,7 @@ void Game::func_drop(core::Player *player, const std::string &args) SpaceMine *spacemine = new SpaceMine(weapon); spacemine->set_color(ship->color()); + spacemine->set_ownerid(player->id()); spacemine->set_color_second(ship->color_second()); spacemine->set_location(ship->location() + ship->axis().forward() * -1.0f * (ship->radius() + spacemine->radius())); spacemine->set_axis(ship->axis()); @@ -1283,6 +1284,9 @@ void Game::func_respawn(core::Player *player, std::string const &args) return; } + // restore armor + ship->set_armor(ship->maxarmor()); + core::Entity *spawn = ship->spawn(); if (!spawn) { ship->set_zone(Default::zone); @@ -1300,7 +1304,7 @@ void Game::func_respawn(core::Player *player, std::string const &args) ship->set_state(core::Entity::Normal); player->set_view(0); player->send("^BRespawning"); - } + } } diff --git a/src/game/base/projectile.h b/src/game/base/projectile.h index 877632f..f9cda64 100644 --- a/src/game/base/projectile.h +++ b/src/game/base/projectile.h @@ -64,7 +64,10 @@ public: { projectile_damage = damage; } - + + /** + * @brief set the id of the player who fired the projectile + * */ inline void set_ownerid(const int ownerid) { projectile_ownerid = ownerid; diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index 676ba65..dc039e4 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -42,6 +42,7 @@ Ship::Ship(core::Player *owner, const ShipModel *shipmodel) : core::EntityContro ship_spawn = 0; ship_maxarmor = 100.0f; + ship_armor = 0.0f; ship_maxshield = 0.0f; ship_shield = 0.0f; @@ -499,7 +500,24 @@ void Ship::collision(core::Entity *other) ship_armor = 0; std::string message("^B"); message.append(owner()->name()); - message.append(" ^Bwent boom."); + + core::Player *assassin = 0; + + if (spacemine->ownerid()) { + assassin = core::server()->find_player(spacemine->ownerid()); + } + + if (assassin) { + if (assassin == owner()) { + message.append(" ^Bran into his own mine."); + } else { + message.append(" ^Bran into "); + message.append(assassin->name()); + message.append(" ^B's mine."); + } + } else { + message.append(" ^Bwent boom."); + } core::server()->broadcast(message); } else { die(); @@ -860,6 +878,9 @@ void Ship::frame(const unsigned long elapsed) Projectile * projectile = new Projectile((*it)->lifespan()); projectile->set_damage(10.0f); projectile->set_color(color()); + if (owner()) { + projectile->set_ownerid(owner()->id()); + } projectile->set_zone(zone()); projectile->set_axis(axis() * (*it)->axis()); projectile->set_location(location() + (axis() * (*it)->location() * modelscale) + projectile->axis().forward() * projectile->radius()); diff --git a/src/game/base/spacemine.h b/src/game/base/spacemine.h index 4f95849..3c314c2 100644 --- a/src/game/base/spacemine.h +++ b/src/game/base/spacemine.h @@ -41,6 +41,14 @@ public: return spacemine_damage; } + /** + * @brief id of the player who dropped the spacemine + * */ + inline const int ownerid() const + { + return spacemine_ownerid; + } + /* --- mutators -------------------------------------------- */ /** @@ -50,11 +58,21 @@ public: { spacemine_damage = damage; } + + /** + * @brief set the id of the player who dropped the spacemine + * */ + inline void set_ownerid(const int ownerid) + { + spacemine_ownerid = ownerid; + } private: unsigned long spacemine_detonated_timestamp; float spacemine_damage; + int spacemine_ownerid; + static const Template *spacemine_template; }; |