diff --git a/src/graphics/explosion.cpp b/src/graphics/explosion.cpp index 8528a1093..67ffd3458 100644 --- a/src/graphics/explosion.cpp +++ b/src/graphics/explosion.cpp @@ -25,14 +25,17 @@ #include "graphics/material.hpp" #include "graphics/material_manager.hpp" #include "items/projectile_manager.hpp" +#include "race/race_manager.hpp" #include "utils/vec3.hpp" const float burst_time = 0.1f; -Explosion::Explosion(const Vec3& coord, const char* explosion_sound) +Explosion::Explosion(const Vec3& coord, const char* explosion_sound, bool player_kart_hit) { m_remaining_time = burst_time; // short emision time, explosion, not constant flame m_node = irr_driver->addParticleNode(); + m_player_kart_hit = player_kart_hit; + #ifdef DEBUG m_node->setName("explosion"); #endif @@ -89,6 +92,17 @@ Explosion::~Explosion() void Explosion::init(const Vec3& coord) { m_explode_sound->position(coord); + + // in multiplayer mode, sounds are NOT positional (because we have multiple listeners) + // so the sounds of all AIs are constantly heard. So reduce volume of sounds. + if (race_manager->getNumLocalPlayers() > 1) + { + m_explode_sound->volume(m_player_kart_hit ? 1.0f : 0.5f); + } + else + { + m_explode_sound->volume(1.0f); + } m_explode_sound->play(); } // init diff --git a/src/graphics/explosion.hpp b/src/graphics/explosion.hpp index cb32f3dce..ceacd8959 100644 --- a/src/graphics/explosion.hpp +++ b/src/graphics/explosion.hpp @@ -38,10 +38,11 @@ class Explosion : public NoCopy private: SFXBase* m_explode_sound; float m_remaining_time; + bool m_player_kart_hit; scene::IParticleSystemSceneNode *m_node; - + public: - Explosion(const Vec3& coord, const char* explosion_sound); + Explosion(const Vec3& coord, const char* explosion_sound, bool player_hit); ~Explosion(); void init (const Vec3& coord); void update (float delta_t); diff --git a/src/items/attachment.cpp b/src/items/attachment.cpp index a828dc44a..69e8372ad 100644 --- a/src/items/attachment.cpp +++ b/src/items/attachment.cpp @@ -126,7 +126,7 @@ void Attachment::hitBanana(Item *item, int new_attachment) case ATTACH_BOMB: { add_a_new_item = false; - projectile_manager->newExplosion(m_kart->getXYZ()); + projectile_manager->newExplosion(m_kart->getXYZ(), "explosion", m_kart->getController()->isPlayerController()); m_kart->handleExplosion(m_kart->getXYZ(), /*direct_hit*/ true); clear(); if(new_attachment==-1) @@ -235,7 +235,7 @@ void Attachment::update(float dt) } if(m_time_left<=0.0) { - projectile_manager->newExplosion(m_kart->getXYZ()); + projectile_manager->newExplosion(m_kart->getXYZ(), "explosion", m_kart->getController()->isPlayerController()); m_kart->handleExplosion(m_kart->getXYZ(), /*direct_hit*/ true); } diff --git a/src/items/projectile_manager.cpp b/src/items/projectile_manager.cpp index 9dc5f83c9..a1bfc05b0 100644 --- a/src/items/projectile_manager.cpp +++ b/src/items/projectile_manager.cpp @@ -85,7 +85,7 @@ void ProjectileManager::update(float dt) if(! (*p)->hasHit()) { p++; continue; } if((*p)->needsExplosion()) { - newExplosion((*p)->getXYZ(), (*p)->getExplosionSound() ); + newExplosion((*p)->getXYZ(), (*p)->getExplosionSound(), false ); } Flyable *f=*p; Projectiles::iterator pNext=m_active_projectiles.erase(p); // returns the next element @@ -187,9 +187,10 @@ Flyable *ProjectileManager::newProjectile(Kart *kart, /** See if there is an old, unused explosion object available. If so, * reuse this object, otherwise create a new one. */ Explosion* ProjectileManager::newExplosion(const Vec3& coord, - const char* explosion_sound) + const char* explosion_sound, + bool player_kart_hit) { - Explosion *e = new Explosion(coord, explosion_sound); + Explosion *e = new Explosion(coord, explosion_sound, player_kart_hit); m_active_explosions.push_back(e); return e; } // newExplosion diff --git a/src/items/projectile_manager.hpp b/src/items/projectile_manager.hpp index 2965609da..92fe33e16 100644 --- a/src/items/projectile_manager.hpp +++ b/src/items/projectile_manager.hpp @@ -72,7 +72,8 @@ public: Flyable* newProjectile (Kart *kart, PowerupManager::PowerupType type); Explosion* newExplosion (const Vec3& coord, - const char* explosion_sound="explosion"); + const char* explosion_sound="explosion", + bool is_player_kart_hit = false); void Deactivate (Flyable *p) {} void removeTextures (); };