From db9085ae5927ab4a3c38b69c962a7e444c854a8f Mon Sep 17 00:00:00 2001 From: Michael Papageorgiou Date: Tue, 13 Mar 2012 20:31:01 +0200 Subject: [PATCH] Pickup sounds for weapons --- apps/openmw/mwclass/weapon.cpp | 97 ++++++++++++++++++++++++++++++++++ apps/openmw/mwclass/weapon.hpp | 6 +++ 2 files changed, 103 insertions(+) diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 90fd3e33bb..274799d3f9 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -7,9 +7,12 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" +#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" +#include "../mwsound/soundmanager.hpp" + namespace MWClass { void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -53,6 +56,8 @@ namespace MWClass boost::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const { + environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, false, true); + return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); } @@ -84,4 +89,96 @@ namespace MWClass registerClass (typeid (ESM::Weapon).name(), instance); } + + std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + int type = ref->base->data.type; + // Ammo + if (type == 12 || type == 13) + { + return std::string("Item Ammo Up"); + } + // Bow + if (type == 9) + { + return std::string("Item Weapon Bow Up"); + } + // Crossbow + if (type == 10) + { + return std::string("Item Weapon Crossbow Up"); + } + // Longblades, One hand and Two + if (type == 1 || type == 2) + { + return std::string("Item Weapon Longblade Up"); + } + // Shortblade and thrown weapons + // thrown weapons may not be entirely correct + if (type == 0 || type == 11) + { + return std::string("Item Weapon Shortblade Up"); + } + // Spear + if (type == 6) + { + return std::string("Item Weapon Spear Up"); + } + // Blunts and Axes + if (type == 3 || type == 4 || type == 5 || type == 7 || type == 8) + { + return std::string("Item Weapon Blunt Up"); + } + + return std::string("Item Misc Up"); + } + + std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + int type = ref->base->data.type; + // Ammo + if (type == 12 || type == 13) + { + return std::string("Item Ammo Down"); + } + // Bow + if (type == 9) + { + return std::string("Item Weapon Bow Down"); + } + // Crossbow + if (type == 10) + { + return std::string("Item Weapon Crossbow Down"); + } + // Longblades, One hand and Two + if (type == 1 || type == 2) + { + return std::string("Item Weapon Longblade Down"); + } + // Shortblade and thrown weapons + // thrown weapons may not be entirely correct + if (type == 0 || type == 11) + { + return std::string("Item Weapon Shortblade Down"); + } + // Spear + if (type == 6) + { + return std::string("Item Weapon Spear Down"); + } + // Blunts and Axes + if (type == 3 || type == 4 || type == 5 || type == 7 || type == 8) + { + return std::string("Item Weapon Blunt Down"); + } + + return std::string("Item Misc Down"); + } } diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index b056249b93..330dc8d843 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -32,6 +32,12 @@ namespace MWClass ///< Return name of the script attached to ptr static void registerSelf(); + + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; + ///< Return the pick up sound Id + + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; + ///< Return the put down sound Id }; }