Added underwater and drowning sounds.

actorid
PLkolek 12 years ago
parent e9521dc8f1
commit 86020ad94d

@ -134,6 +134,7 @@ namespace MWBase
virtual bool getSoundPlaying(const MWWorld::Ptr &reference, const std::string& soundId) const = 0;
///< Is the given sound currently playing on the given object?
/// If you want to check if sound played with playSound is playing, use empty Ptr
virtual void pauseSounds(int types=Play_TypeMask) = 0;
///< Pauses all currently playing sounds, including music.

@ -8,6 +8,7 @@
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/player.hpp"
@ -287,13 +288,27 @@ namespace MWMechanics
MWBase::Environment::get().getWindowManager()->setValue ("level", stats.getLevel());
}
//update drowning sound
MWBase::World *world = MWBase::Environment::get().getWorld();
MWBase::SoundManager * sndmgr = MWBase::Environment::get().getSoundManager();
MWWorld::Ptr playerPtr = world->getPlayer().getPlayer();
NpcStats& playerStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr);
if(!sndmgr->getSoundPlaying(MWWorld::Ptr(), "drown") && playerStats.getTimeToStartDrowning()==0.0)
{
sndmgr->playSound("drown",1.0,1.0,MWBase::SoundManager::Play_TypeSfx,MWBase::SoundManager::Play_Loop);
}
if(playerStats.getTimeToStartDrowning()>0.0)
{
//no need to check if it's playing, stop sound does nothing in that case
sndmgr->stopSound("drown");
}
if (mUpdatePlayer)
{
// basic player profile; should not change anymore after the creation phase is finished.
MWBase::WindowManager *winMgr =
MWBase::Environment::get().getWindowManager();
MWBase::World *world = MWBase::Environment::get().getWorld();
const ESM::NPC *player =
world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;

@ -547,7 +547,19 @@ namespace MWSound
Environment env = Env_Normal;
if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater)
{
env = Env_Underwater;
//play underwater sound
//HACK: this sound is always played underwater, so set volume and pitch higher (it's then lowered)
//Currently not possible to play looping sound with no environment
if(!getSoundPlaying(MWWorld::Ptr(), "Underwater"))
playSound("Underwater", 1.11, 1.42 ,Play_TypeSfx, Play_Loop );
}
else
{
//no need to check if it's playing, stop sound does nothing in that case
stopSound("Underwater");
}
mOutput->updateListener(
mListenerPos,

Loading…
Cancel
Save