|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
#include "activator.hpp"
|
|
|
|
|
|
|
|
|
|
#include <components/esm/loadacti.hpp>
|
|
|
|
|
#include <components/misc/rng.hpp>
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
|
|
|
@ -134,4 +135,60 @@ namespace MWClass
|
|
|
|
|
|
|
|
|
|
return MWWorld::Ptr(cell.insert(ref), &cell);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string Activator::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
|
|
|
|
{
|
|
|
|
|
std::string model = getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise
|
|
|
|
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
|
std::string creatureId;
|
|
|
|
|
|
|
|
|
|
for (const ESM::Creature &iter : store.get<ESM::Creature>())
|
|
|
|
|
{
|
|
|
|
|
if (!iter.mModel.empty() && Misc::StringUtils::ciEqual(model, "meshes\\" + iter.mModel))
|
|
|
|
|
{
|
|
|
|
|
creatureId = !iter.mOriginal.empty() ? iter.mOriginal : iter.mId;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (creatureId.empty())
|
|
|
|
|
return std::string();
|
|
|
|
|
|
|
|
|
|
int type = getSndGenTypeFromName(name);
|
|
|
|
|
std::vector<const ESM::SoundGenerator*> sounds;
|
|
|
|
|
|
|
|
|
|
for (auto sound = store.get<ESM::SoundGenerator>().begin(); sound != store.get<ESM::SoundGenerator>().end(); ++sound)
|
|
|
|
|
if (type == sound->mType && !sound->mCreature.empty() && (Misc::StringUtils::ciEqual(creatureId, sound->mCreature)))
|
|
|
|
|
sounds.push_back(&*sound);
|
|
|
|
|
|
|
|
|
|
if (!sounds.empty())
|
|
|
|
|
return sounds[Misc::Rng::rollDice(sounds.size())]->mSound;
|
|
|
|
|
|
|
|
|
|
if (type == ESM::SoundGenerator::Land)
|
|
|
|
|
return "Body Fall Large";
|
|
|
|
|
|
|
|
|
|
return std::string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Activator::getSndGenTypeFromName(const std::string &name)
|
|
|
|
|
{
|
|
|
|
|
if (name == "left")
|
|
|
|
|
return ESM::SoundGenerator::LeftFoot;
|
|
|
|
|
if (name == "right")
|
|
|
|
|
return ESM::SoundGenerator::RightFoot;
|
|
|
|
|
if (name == "swimleft")
|
|
|
|
|
return ESM::SoundGenerator::SwimLeft;
|
|
|
|
|
if (name == "swimright")
|
|
|
|
|
return ESM::SoundGenerator::SwimRight;
|
|
|
|
|
if (name == "moan")
|
|
|
|
|
return ESM::SoundGenerator::Moan;
|
|
|
|
|
if (name == "roar")
|
|
|
|
|
return ESM::SoundGenerator::Roar;
|
|
|
|
|
if (name == "scream")
|
|
|
|
|
return ESM::SoundGenerator::Scream;
|
|
|
|
|
if (name == "land")
|
|
|
|
|
return ESM::SoundGenerator::Land;
|
|
|
|
|
|
|
|
|
|
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|