mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-20 21:23:52 +00:00
Add loading code for multi-effect projectiles
This commit is contained in:
parent
c6cd1f813b
commit
dbd7c038b2
4 changed files with 58 additions and 28 deletions
|
@ -304,9 +304,7 @@ namespace MWMechanics
|
|||
if (count != 0)
|
||||
speed /= count;
|
||||
|
||||
std::string projectileID;
|
||||
std::vector<std::string> projectileIDs;
|
||||
std::string sound;
|
||||
std::vector<std::string> sounds;
|
||||
ESM::EffectList projectileEffects;
|
||||
|
||||
|
@ -321,23 +319,22 @@ namespace MWMechanics
|
|||
const ESM::MagicEffect *magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
|
||||
iter->mEffectID);
|
||||
|
||||
projectileID = magicEffect->mBolt;
|
||||
if (projectileID.empty())
|
||||
projectileID = "VFX_DefaultBolt";
|
||||
projectileIDs.push_back(projectileID);
|
||||
if (magicEffect->mBolt.empty())
|
||||
projectileIDs.push_back("VFX_DefaultBolt");
|
||||
else
|
||||
projectileIDs.push_back(magicEffect->mBolt);
|
||||
|
||||
static const std::string schools[] = {
|
||||
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
||||
};
|
||||
if (!magicEffect->mBoltSound.empty())
|
||||
sound = magicEffect->mBoltSound;
|
||||
sounds.push_back(magicEffect->mBoltSound);
|
||||
else
|
||||
sound = schools[magicEffect->mData.mSchool] + " bolt";
|
||||
sounds.push_back(sound);
|
||||
sounds.push_back(schools[magicEffect->mData.mSchool] + " bolt");
|
||||
projectileEffects.mList.push_back(*iter);
|
||||
}
|
||||
|
||||
if (projectileEffects.mList.size() > 1) // add a VFX_Multiple projectile if there are multiple projectile effects
|
||||
if (projectileEffects.mList.size() > 1) // insert a VFX_Multiple projectile if there are multiple projectile effects
|
||||
{
|
||||
std::ostringstream ID;
|
||||
ID << "VFX_Multiple" << projectileEffects.mList.size();
|
||||
|
|
|
@ -1296,14 +1296,13 @@ namespace MWRender
|
|||
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, std::string texture)
|
||||
{
|
||||
if (!mObjectRoot.get())
|
||||
{
|
||||
std::cout << "no objectroot" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Early out if we already have this effect
|
||||
for (std::vector<EffectParams>::iterator it = mEffects.begin(); it != mEffects.end(); ++it)
|
||||
if (it->mLoop && loop && it->mEffectId == effectId && it->mBoneName == bonename)
|
||||
return;
|
||||
|
||||
EffectParams params;
|
||||
params.mModelName = model;
|
||||
osg::ref_ptr<osg::Group> parentNode;
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace MWWorld
|
|||
state.mSpeed = speed;
|
||||
state.mStack = stack;
|
||||
state.mIdMagic = projectileIDs;
|
||||
state.mSoundId = sounds;
|
||||
state.mSoundIds = sounds;
|
||||
|
||||
// Should have already had non-projectile effects removed
|
||||
state.mEffects = effects;
|
||||
|
@ -173,7 +173,7 @@ namespace MWWorld
|
|||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
for (size_t it = 0; it != sounds.size(); it++)
|
||||
{
|
||||
state.mSound.push_back(sndMgr->playSound3D(pos, sounds.at(it), 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop));
|
||||
state.mSounds.push_back(sndMgr->playSound3D(pos, sounds.at(it), 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop));
|
||||
}
|
||||
|
||||
mMagicBolts.push_back(state);
|
||||
|
@ -217,9 +217,9 @@ namespace MWWorld
|
|||
osg::Vec3f pos(it->mNode->getPosition());
|
||||
osg::Vec3f newPos = pos + direction * duration * speed;
|
||||
|
||||
for (size_t soundIter = 0; soundIter != it->mSound.size(); soundIter++)
|
||||
for (size_t soundIter = 0; soundIter != it->mSounds.size(); soundIter++)
|
||||
{
|
||||
it->mSound.at(soundIter)->setPosition(newPos);
|
||||
it->mSounds.at(soundIter)->setPosition(newPos);
|
||||
}
|
||||
|
||||
it->mNode->setPosition(newPos);
|
||||
|
@ -260,9 +260,9 @@ namespace MWWorld
|
|||
MWBase::Environment::get().getWorld()->explodeSpell(pos, it->mEffects, caster, result.mHitObject,
|
||||
ESM::RT_Target, it->mSpellId, it->mSourceName);
|
||||
|
||||
for (size_t soundIter = 0; soundIter != it->mSound.size(); soundIter++)
|
||||
for (size_t soundIter = 0; soundIter != it->mSounds.size(); soundIter++)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->stopSound(it->mSound.at(soundIter));
|
||||
MWBase::Environment::get().getSoundManager()->stopSound(it->mSounds.at(soundIter));
|
||||
}
|
||||
|
||||
mParent->removeChild(it->mNode);
|
||||
|
@ -344,9 +344,9 @@ namespace MWWorld
|
|||
for (std::vector<MagicBoltState>::iterator it = mMagicBolts.begin(); it != mMagicBolts.end(); ++it)
|
||||
{
|
||||
mParent->removeChild(it->mNode);
|
||||
for (size_t soundIter = 0; soundIter != it->mSound.size(); soundIter++)
|
||||
for (size_t soundIter = 0; soundIter != it->mSounds.size(); soundIter++)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->stopSound(it->mSound.at(soundIter));
|
||||
MWBase::Environment::get().getSoundManager()->stopSound(it->mSounds.at(soundIter));
|
||||
}
|
||||
}
|
||||
mMagicBolts.clear();
|
||||
|
@ -385,7 +385,7 @@ namespace MWWorld
|
|||
|
||||
state.mSpellId = it->mSpellId;
|
||||
state.mEffects = it->mEffects;
|
||||
state.mSound = it->mSoundId.at(0);
|
||||
state.mSound = it->mSoundIds.at(0);
|
||||
state.mSourceName = it->mSourceName;
|
||||
state.mSpeed = it->mSpeed;
|
||||
state.mStack = it->mStack;
|
||||
|
@ -441,10 +441,41 @@ namespace MWWorld
|
|||
state.mStack = esm.mStack;
|
||||
state.mEffects = esm.mEffects;
|
||||
|
||||
std::string projectileID;
|
||||
std::vector<std::string> projectileIDs;
|
||||
|
||||
if (esm.mEffects.mList.size() > 1)
|
||||
{
|
||||
std::ostringstream ID;
|
||||
ID << "VFX_Multiple" << esm.mEffects.mList.size();
|
||||
state.mIdMagic.push_back(ID.str());
|
||||
}
|
||||
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator iter (esm.mEffects.mList.begin());
|
||||
iter != esm.mEffects.mList.end(); ++iter)
|
||||
{
|
||||
const ESM::MagicEffect *magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (
|
||||
iter->mEffectID);
|
||||
|
||||
projectileID = magicEffect->mBolt;
|
||||
if (projectileID.empty())
|
||||
projectileID = "VFX_DefaultBolt";
|
||||
state.mIdMagic.push_back(projectileID);
|
||||
|
||||
static const std::string schools[] = {
|
||||
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
||||
};
|
||||
|
||||
if (!magicEffect->mBoltSound.empty())
|
||||
state.mSoundIds.push_back(magicEffect->mBoltSound);
|
||||
else
|
||||
state.mSoundIds.push_back(schools[magicEffect->mData.mSchool] + " bolt");
|
||||
}
|
||||
|
||||
std::string model;
|
||||
try
|
||||
{
|
||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), esm.mId);
|
||||
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), state.mIdMagic.at(0));
|
||||
MWWorld::Ptr ptr = ref.getPtr();
|
||||
model = ptr.getClass().getModel(ptr);
|
||||
}
|
||||
|
@ -456,9 +487,12 @@ namespace MWWorld
|
|||
createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation), true);
|
||||
|
||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
state.mSound.push_back(sndMgr->playSound3D(esm.mPosition, esm.mSound, 1.0f, 1.0f,
|
||||
MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop));
|
||||
state.mSoundId.push_back(esm.mSound);
|
||||
|
||||
for (size_t soundIter = 0; soundIter != state.mSoundIds.size(); soundIter++)
|
||||
{
|
||||
state.mSounds.push_back(sndMgr->playSound3D(esm.mPosition, state.mSoundIds.at(soundIter), 1.0f, 1.0f,
|
||||
MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop));
|
||||
}
|
||||
|
||||
mMagicBolts.push_back(state);
|
||||
return true;
|
||||
|
|
|
@ -104,8 +104,8 @@ namespace MWWorld
|
|||
|
||||
bool mStack;
|
||||
|
||||
std::vector<MWBase::SoundPtr> mSound;
|
||||
std::vector<std::string> mSoundId;
|
||||
std::vector<MWBase::SoundPtr> mSounds;
|
||||
std::vector<std::string> mSoundIds;
|
||||
};
|
||||
|
||||
struct ProjectileState : public State
|
||||
|
|
Loading…
Reference in a new issue