From 249918612d55238472fe854f8fe15327b0392c36 Mon Sep 17 00:00:00 2001 From: Allofich Date: Sun, 10 Jul 2016 21:42:03 +0900 Subject: [PATCH] Play trap disarm sound when key used on trapped object --- apps/openmw/mwclass/container.cpp | 9 ++++++++- apps/openmw/mwclass/door.cpp | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index da91b5a01..2e5b495e4 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -7,6 +7,7 @@ #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" +#include "../mwbase/soundmanager.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/failedaction.hpp" @@ -159,7 +160,13 @@ namespace MWClass MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}"); unlock(ptr); // using a key disarms the trap - ptr.getCellRef().setTrap(""); + if(!ptr.getCellRef().getTrap().empty()) + { + ptr.getCellRef().setTrap(""); + MWBase::Environment::get().getSoundManager()->playSound3D(ptr, + "Disarm Trap", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, + MWBase::SoundManager::Play_Normal); + } } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index b31a958b5..12130e5df 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -131,7 +131,13 @@ namespace MWClass MWBase::Environment::get().getWindowManager()->messageBox(keyName + " #{sKeyUsed}"); unlock(ptr); //Call the function here. because that makes sense. // using a key disarms the trap - ptr.getCellRef().setTrap(""); + if(!ptr.getCellRef().getTrap().empty()) + { + ptr.getCellRef().setTrap(""); + MWBase::Environment::get().getSoundManager()->playSound3D(ptr, + "Disarm Trap", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, + MWBase::SoundManager::Play_Normal); + } } if (!needKey || hasKey)