mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 16:15:31 +00:00
Added underwater and drowning sounds.
This commit is contained in:
parent
e9521dc8f1
commit
86020ad94d
3 changed files with 29 additions and 1 deletions
|
@ -134,6 +134,7 @@ namespace MWBase
|
||||||
|
|
||||||
virtual bool getSoundPlaying(const MWWorld::Ptr &reference, const std::string& soundId) const = 0;
|
virtual bool getSoundPlaying(const MWWorld::Ptr &reference, const std::string& soundId) const = 0;
|
||||||
///< Is the given sound currently playing on the given object?
|
///< 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;
|
virtual void pauseSounds(int types=Play_TypeMask) = 0;
|
||||||
///< Pauses all currently playing sounds, including music.
|
///< Pauses all currently playing sounds, including music.
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/dialoguemanager.hpp"
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
|
@ -287,13 +288,27 @@ namespace MWMechanics
|
||||||
MWBase::Environment::get().getWindowManager()->setValue ("level", stats.getLevel());
|
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)
|
if (mUpdatePlayer)
|
||||||
{
|
{
|
||||||
// basic player profile; should not change anymore after the creation phase is finished.
|
// basic player profile; should not change anymore after the creation phase is finished.
|
||||||
MWBase::WindowManager *winMgr =
|
MWBase::WindowManager *winMgr =
|
||||||
MWBase::Environment::get().getWindowManager();
|
MWBase::Environment::get().getWindowManager();
|
||||||
|
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
||||||
const ESM::NPC *player =
|
const ESM::NPC *player =
|
||||||
world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
|
|
|
@ -547,7 +547,19 @@ namespace MWSound
|
||||||
|
|
||||||
Environment env = Env_Normal;
|
Environment env = Env_Normal;
|
||||||
if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater)
|
if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater)
|
||||||
|
{
|
||||||
env = Env_Underwater;
|
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(
|
mOutput->updateListener(
|
||||||
mListenerPos,
|
mListenerPos,
|
||||||
|
|
Loading…
Reference in a new issue