From c6861ed2a9807973373b6f3267980ffdc20f5e53 Mon Sep 17 00:00:00 2001 From: Michael Papageorgiou Date: Mon, 27 Feb 2012 09:39:35 +0200 Subject: [PATCH 1/3] Added door activation sounds --- apps/openmw/mwclass/door.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index d0b3b11a2..3c09b36b9 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -14,6 +14,8 @@ #include "../mwrender/objects.hpp" +#include "../mwsound/soundmanager.hpp" + namespace MWClass { void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -61,11 +63,16 @@ namespace MWClass ESMS::LiveCellRef *ref = ptr.get(); + const std::string &openSound = ref->base->openSound; + //const std::string &closeSound = ref->base->closeSound; + const std::string lockedSound = "LockedDoor"; + if (ptr.getCellRef().lockLevel>0) { // TODO check for key // TODO report failure to player (message, sound?). Look up behaviour of original MW. std::cout << "Locked!" << std::endl; + environment.mSoundManager->playSound(lockedSound, 1.0, 1.0); return boost::shared_ptr (new MWWorld::NullAction); } @@ -77,6 +84,7 @@ namespace MWClass if (environment.mWorld->getPlayer().getPlayer()==actor) { // the player is using the door + environment.mSoundManager->playSound(openSound, 1.0, 1.0); return boost::shared_ptr ( new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest)); } From 28fdfb0f997fb52d3047e19a77dcadb47ba03a68 Mon Sep 17 00:00:00 2001 From: Michael Papageorgiou Date: Mon, 27 Feb 2012 16:37:05 +0200 Subject: [PATCH 2/3] Added container locked and trapped activation sounds --- apps/openmw/mwclass/container.cpp | 35 +++++++++++++++++++++++++++++++ apps/openmw/mwclass/container.hpp | 4 ++++ 2 files changed, 39 insertions(+) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 1ad9e845e..ae1d085ef 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -6,11 +6,15 @@ #include #include "../mwworld/ptr.hpp" +#include "../mwworld/nullaction.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/customdata.hpp" +#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" +#include "../mwsound/soundmanager.hpp" + namespace { struct CustomData : public MWWorld::CustomData @@ -71,6 +75,37 @@ namespace MWClass } + boost::shared_ptr Container::activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + { + const std::string lockedSound = "LockedChest"; + const std::string trapActivationSound = "Disarm Trap Fail"; + + if (ptr.getCellRef().lockLevel>0) + { + // TODO check for key + std::cout << "Locked container" << std::endl; + environment.mSoundManager->playSound(lockedSound, 1.0, 1.0); + return boost::shared_ptr (new MWWorld::NullAction); + } + else + { + std::cout << "Unlocked container" << std::endl; + if(ptr.getCellRef().trap.empty()) + { + // Not trapped, Inventory GUI goes here + return boost::shared_ptr (new MWWorld::NullAction); + } + else + { + // Trap activation goes here + std::cout << "Trapped with: " << ptr.getCellRef().trap << std::endl; + environment.mSoundManager->playSound(trapActivationSound, 1.0, 1.0); + return boost::shared_ptr (new MWWorld::NullAction); + } + } + } + std::string Container::getName (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 66a47a956..387714176 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -20,6 +20,10 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + ///< Generate action for activation + virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const; ///< Return container store From fe977fe313b8b32a51c27435eab7538eca748031 Mon Sep 17 00:00:00 2001 From: Michael Papageorgiou Date: Mon, 27 Feb 2012 16:59:45 +0200 Subject: [PATCH 3/3] More container and door trap fixes --- apps/openmw/mwclass/container.cpp | 3 ++- apps/openmw/mwclass/door.cpp | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index ae1d085ef..c58606996 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -99,8 +99,9 @@ namespace MWClass else { // Trap activation goes here - std::cout << "Trapped with: " << ptr.getCellRef().trap << std::endl; + std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; environment.mSoundManager->playSound(trapActivationSound, 1.0, 1.0); + ptr.getCellRef().trap = ""; return boost::shared_ptr (new MWWorld::NullAction); } } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 3c09b36b9..bd7af9597 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -66,6 +66,7 @@ namespace MWClass const std::string &openSound = ref->base->openSound; //const std::string &closeSound = ref->base->closeSound; const std::string lockedSound = "LockedDoor"; + const std::string trapActivationSound = "Disarm Trap Fail"; if (ptr.getCellRef().lockLevel>0) { @@ -76,7 +77,14 @@ namespace MWClass return boost::shared_ptr (new MWWorld::NullAction); } - // TODO check trap + if(!ptr.getCellRef().trap.empty()) + { + // Trap activation + std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; + environment.mSoundManager->playSound(trapActivationSound, 1.0, 1.0); + ptr.getCellRef().trap = ""; + return boost::shared_ptr (new MWWorld::NullAction); + } if (ref->ref.teleport) { @@ -99,6 +107,9 @@ namespace MWClass { // animated door // TODO return action for rotating the door + + // This is a little pointless, but helps with testing + environment.mSoundManager->playSound(openSound, 1.0, 1.0); return boost::shared_ptr (new MWWorld::NullAction); } }