Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-11-18 17:59:52 +0000
committerStijn Buys <ingar@osirion.org>2012-11-18 17:59:52 +0000
commitdf20ff5ad47b1d8a04385956589a7564522258a6 (patch)
tree55112286358004c7f5099c9a78f74cc5113063f3 /src
parent2cd1f55f26f2236641fa2f3b36d9d23b99ca072f (diff)
Support for ownerid() on projectiles and spacemines,
show assassin name in death messages.
Diffstat (limited to 'src')
-rw-r--r--src/game/base/game.cc6
-rw-r--r--src/game/base/projectile.h5
-rw-r--r--src/game/base/ship.cc23
-rw-r--r--src/game/base/spacemine.h18
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;
};