Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/base/ship.cc95
1 files changed, 60 insertions, 35 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 6a7ac56..b3f6fd0 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -533,15 +533,34 @@ void Ship::launch()
if (!ship_dock)
return;
- get_axis().assign(ship_dock->axis());
-
if (ship_dock->type() == core::Entity::Globe) {
+ get_axis().assign(ship_dock->axis());
get_location().assign(ship_dock->location() + (ship_dock->axis().forward() * (PLANET_SAFE_DISTANCE + this->radius() + ship_dock->radius())));
- } else {
- get_location().assign(ship_dock->location() + (ship_dock->axis().forward() * (this->radius() + ship_dock->radius())));
+
+ } else {
+ if (ship_dock->model() && ship_dock->model()->docks().size()) {
+ // choose a random dock to launch from
+ model::Model::Docks::iterator dit = ship_dock->model()->docks().begin();
+ int launchbay_index = math::randomi(ship_dock->model()->docks().size());
+ for (int i = 0; i < launchbay_index; i++) {
+ ++dit;
+ }
+ model::Dock *launchbay = (*dit);
+
+ const float modelscale = ship_dock->radius() / ship_dock->model()->radius();
+
+ get_axis().assign(ship_dock->axis() * launchbay->axis());
+ get_location().assign(ship_dock->location() + ship_dock->axis() * ( launchbay->location() * modelscale + launchbay->axis().forward() * radius()));
+
+ } else {
+ const float r = radius() + ship_dock->radius();
+
+ get_axis().assign(ship_dock->axis());
+ get_location().assign(ship_dock->location() + (ship_dock->axis().forward() * r ) );
+ }
}
- nudge();
+ nudge(false);
ship_dock = 0;
@@ -659,25 +678,28 @@ void Ship::hit(core::Entity *other)
}
if (owner()) {
- std::string message("^B");
- message.append(owner()->name());
+ // broadcast death message if the owner is controlling this ship
+ if (owner()->control() == this) {
+ std::string message("^B");
+ message.append(owner()->name());
- if (assassin) {
- if (assassin == owner()) {
- message.append(" ^Bran into his own mine.");
+ 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.");
+
+ // asssissin killed a player
+ assassin->set_pvpkills(assassin->pvpkills() + 1);
+ assassin->set_dirty();
+ }
} else {
- message.append(" ^Bran into ");
- message.append(assassin->name());
- message.append(" ^B's mine.");
-
- // asssissin killed a player
- assassin->set_pvpkills(assassin->pvpkills() + 1);
- assassin->set_dirty();
+ message.append(" ^Bwent boom.");
}
- } else {
- message.append(" ^Bwent boom.");
+ core::server()->broadcast(message);
}
- core::server()->broadcast(message);
} else {
if (assassin) {
@@ -713,22 +735,25 @@ void Ship::hit(core::Entity *other)
explode();
if (owner()) {
- // broadcast death message
- std::string message("^B");
- message.append(owner()->name());
-
-
- if (assassin) {
- if (assassin == owner()) {
- message.append(" ^Bate his own bullet.");
+ // broadcast death message if the owner is controlling this ship
+ if (owner()->control() == this) {
+ // broadcast death message
+ std::string message("^B");
+ message.append(owner()->name());
+
+
+ if (assassin) {
+ if (assassin == owner()) {
+ message.append(" ^Bate his own bullet.");
+ } else {
+ message.append(" ^Bwas blown to bits by ");
+ message.append(assassin->name());
+ }
} else {
- message.append(" ^Bwas blown to bits by ");
- message.append(assassin->name());
+ message.append(" ^Bwas blown to bits.");
}
- } else {
- message.append(" ^Bwas blown to bits.");
+ core::server()->broadcast(message);
}
- core::server()->broadcast(message);
} else if (faction()) {
@@ -761,8 +786,8 @@ void Ship::hit(core::Entity *other)
assassin->sound("game/target_hit");
}
- // send got hit sound to owner
- if (owner()) {
+ // send hit sound if the owner is controlling this ship
+ if (owner() && (owner()->control() == this)) {
const float chance = math::randomf(100.0f);
if (chance < 33.0f) {