Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-12-29 23:23:44 +0000
committerStijn Buys <ingar@osirion.org>2012-12-29 23:23:44 +0000
commit93dd038acea20774143dde34bd924f6eb0d3568a (patch)
treec357b11eeb6eb455543180ea30fa04f2054ac0d4 /src/game/base/ship.cc
parent962a744f6782fbcfadf7771ceb157bd82f369ab3 (diff)
Added sound effects for weapon mounting and target hitting,
enabled projectile soundname transfer in networked games, resolved an issue where a ship was able to shoot itself, bumped network protocol to 26,
Diffstat (limited to 'src/game/base/ship.cc')
-rw-r--r--src/game/base/ship.cc53
1 files changed, 30 insertions, 23 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 2368352..ea793af 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -479,8 +479,8 @@ void Ship::hit(core::Entity *other)
core::Player *assassin = 0;
- if (spacemine->ownerid()) {
- assassin = core::server()->find_player(spacemine->ownerid());
+ if (spacemine->owner_id()) {
+ assassin = core::server()->find_player(spacemine->owner_id());
}
if (assassin) {
@@ -506,11 +506,16 @@ void Ship::hit(core::Entity *other)
core::EntityProjectile *projectile = static_cast<core::EntityProjectile *>(other);
// don't hit self
- if ((projectile->state() != core::Entity::Destroyed) &&
- (projectile->ownerid() != id())) {
-
+ if ((projectile->state() != core::Entity::Destroyed) && (projectile->spawn_id() != id())) {
+
ship_armor -= projectile->damage();
+ core::Player *assassin = 0;
+
+ if (projectile->owner_id()) {
+ assassin = core::server()->find_player(projectile->owner_id());
+ }
+
// destroyed
if (ship_armor <= 0) {
explode();
@@ -520,11 +525,6 @@ void Ship::hit(core::Entity *other)
std::string message("^B");
message.append(owner()->name());
- core::Player *assassin = 0;
-
- if (projectile->ownerid()) {
- assassin = core::server()->find_player(projectile->ownerid());
- }
if (assassin) {
if (assassin == owner()) {
@@ -540,6 +540,16 @@ void Ship::hit(core::Entity *other)
} else {
die();
}
+
+ // send kill sound to assassin
+ if (assassin) {
+ assassin->sound("game/target_kill");
+ }
+ } else {
+ // send hit sound to assassin
+ if (assassin) {
+ assassin->sound("game/target_hit");
+ }
}
}
}
@@ -892,9 +902,8 @@ void Ship::frame(const unsigned long elapsed)
*/
EntityControlable::frame(elapsed);
-
-
- // TODO move to core::
+
+ // fire weapons
if (model() && slots() && (state() == core::Entity::Normal) && has_controlflag(core::EntityControlable::ControlFlagFire)) {
const float modelscale = radius() / model()->radius();
@@ -907,25 +916,23 @@ void Ship::frame(const unsigned long elapsed)
const Weapon *weapon = static_cast<const Weapon *>(slot->item()->info());
if ((weapon->subtype() == Weapon::Cannon) && (weapon->projectile_interval() > 0) && (slot->last_fired() + weapon->projectile_interval() <= core::server()->timestamp())) {
- slot->set_last_fired(core::server()->timestamp());
-
- core::EntityProjectile *projectile = new core::EntityProjectile();
+ // spawn a new projectile
+ core::EntityProjectile *projectile = new core::EntityProjectile(this);
+
projectile->set_damage(weapon->damage());
projectile->set_lifespan(weapon->projectile_lifespan());
projectile->set_projectile_modelname(weapon->projectile_modelname());
projectile->set_projectile_soundname(weapon->projectile_soundname());
- projectile->set_color(color());
- projectile->set_color_second(color_second());
- projectile->set_zone(zone());
+
projectile->set_axis(axis() * slot->axis());
projectile->set_location(location() + (axis() * slot->location() * modelscale) + projectile->axis().forward() * projectile->radius());
- if (owner()) {
- projectile->set_ownerid(owner()->id());
- }
- projectile->set_speed(weapon->projectile_speed());
+ projectile->set_speed(weapon->projectile_speed());
+
projectile->reset();
+ slot->set_last_fired(core::server()->timestamp());
+
}
}
}