mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
Pickup sounds for weapons
This commit is contained in:
parent
7c1475b723
commit
db9085ae59
2 changed files with 103 additions and 0 deletions
|
@ -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<MWWorld::Action> 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<MWWorld::Action> (
|
||||
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<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
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<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue