mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 21:45:34 +00:00
Fix continuous FX getting removed instantly
This commit is contained in:
parent
da5c59c8af
commit
0b5f5351b5
7 changed files with 36 additions and 22 deletions
|
@ -374,6 +374,13 @@ namespace MWMechanics
|
||||||
|
|
||||||
if(!paused)
|
if(!paused)
|
||||||
{
|
{
|
||||||
|
// Note: we need to do this before any of the animations are updated.
|
||||||
|
// Reaching the text keys may trigger Hit / Spellcast (and as such, particles),
|
||||||
|
// so updating VFX immediately after that would just remove the particle effects instantly.
|
||||||
|
// There needs to be a magic effect update in between.
|
||||||
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||||
|
iter->second->updateContinuousVfx();
|
||||||
|
|
||||||
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||||
iter->second->update(duration);
|
iter->second->update(duration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -716,8 +716,6 @@ void CharacterController::update(float duration)
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
||||||
Ogre::Vector3 movement(0.0f);
|
Ogre::Vector3 movement(0.0f);
|
||||||
|
|
||||||
updateContinuousVfx();
|
|
||||||
|
|
||||||
if(!cls.isActor())
|
if(!cls.isActor())
|
||||||
{
|
{
|
||||||
if(mAnimQueue.size() > 1)
|
if(mAnimQueue.size() > 1)
|
||||||
|
|
|
@ -173,12 +173,13 @@ class CharacterController
|
||||||
|
|
||||||
bool updateNpcState(bool onground, bool inwater, bool isrunning, bool sneak);
|
bool updateNpcState(bool onground, bool inwater, bool isrunning, bool sneak);
|
||||||
|
|
||||||
void updateContinuousVfx();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim);
|
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim);
|
||||||
virtual ~CharacterController();
|
virtual ~CharacterController();
|
||||||
|
|
||||||
|
// Be careful when to call this, see comment in Actors
|
||||||
|
void updateContinuousVfx();
|
||||||
|
|
||||||
void updatePtr(const MWWorld::Ptr &ptr);
|
void updatePtr(const MWWorld::Ptr &ptr);
|
||||||
|
|
||||||
void update(float duration);
|
void update(float duration);
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
std::vector<float> random;
|
std::vector<float> random;
|
||||||
random.resize(spell->mEffects.mList.size());
|
random.resize(spell->mEffects.mList.size());
|
||||||
for (int i=0; i<random.size();++i)
|
for (unsigned int i=0; i<random.size();++i)
|
||||||
random[i] = static_cast<float> (std::rand()) / RAND_MAX;
|
random[i] = static_cast<float> (std::rand()) / RAND_MAX;
|
||||||
mSpells.insert (std::make_pair (spellId, random));
|
mSpells.insert (std::make_pair (spellId, random));
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
MagicEffects Spells::getMagicEffects() const
|
MagicEffects Spells::getMagicEffects() const
|
||||||
{
|
{
|
||||||
|
// TODO: These are recalculated every frame, no need to do that
|
||||||
|
|
||||||
MagicEffects effects;
|
MagicEffects effects;
|
||||||
|
|
||||||
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
|
for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
|
||||||
|
|
|
@ -998,7 +998,7 @@ void Animation::addEffect(const std::string &model, int effectId, bool loop, con
|
||||||
{
|
{
|
||||||
// Early out if we already have this effect
|
// Early out if we already have this effect
|
||||||
for (std::vector<EffectParams>::iterator it = mEffects.begin(); it != mEffects.end(); ++it)
|
for (std::vector<EffectParams>::iterator it = mEffects.begin(); it != mEffects.end(); ++it)
|
||||||
if (it->mEffectId == effectId)
|
if (it->mLoop && loop && it->mEffectId == effectId && it->mBoneName == bonename)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EffectParams params;
|
EffectParams params;
|
||||||
|
@ -1006,6 +1006,7 @@ void Animation::addEffect(const std::string &model, int effectId, bool loop, con
|
||||||
params.mObjects = NifOgre::Loader::createObjects(mInsert, model);
|
params.mObjects = NifOgre::Loader::createObjects(mInsert, model);
|
||||||
params.mLoop = loop;
|
params.mLoop = loop;
|
||||||
params.mEffectId = effectId;
|
params.mEffectId = effectId;
|
||||||
|
params.mBoneName = bonename;
|
||||||
|
|
||||||
for(size_t i = 0;i < params.mObjects.mControllers.size();i++)
|
for(size_t i = 0;i < params.mObjects.mControllers.size();i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -115,6 +115,7 @@ protected:
|
||||||
NifOgre::ObjectList mObjects;
|
NifOgre::ObjectList mObjects;
|
||||||
int mEffectId;
|
int mEffectId;
|
||||||
bool mLoop;
|
bool mLoop;
|
||||||
|
std::string mBoneName;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<EffectParams> mEffects;
|
std::vector<EffectParams> mEffects;
|
||||||
|
|
|
@ -308,25 +308,29 @@ void MWWorld::InventoryStore::updateMagicEffects(const Ptr& actor)
|
||||||
// so it doesn't really matter if both items will get the same magnitude. *Extreme* edge case.
|
// so it doesn't really matter if both items will get the same magnitude. *Extreme* edge case.
|
||||||
mPermanentMagicEffectMagnitudes[(**iter).getCellRef().mRefID] = random;
|
mPermanentMagicEffectMagnitudes[(**iter).getCellRef().mRefID] = random;
|
||||||
|
|
||||||
// Only the sound of the first effect plays
|
// TODO: What do we do if no animation yet?
|
||||||
if (effectIt == enchantment.mEffects.mList.begin())
|
if (MWBase::Environment::get().getWorld()->getAnimation(actor))
|
||||||
{
|
{
|
||||||
static const std::string schools[] = {
|
// Only the sound of the first effect plays
|
||||||
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
if (effectIt == enchantment.mEffects.mList.begin())
|
||||||
};
|
{
|
||||||
|
static const std::string schools[] = {
|
||||||
|
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
||||||
|
};
|
||||||
|
|
||||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||||
if(!magicEffect->mHitSound.empty())
|
if(!magicEffect->mHitSound.empty())
|
||||||
sndMgr->playSound3D(actor, magicEffect->mHitSound, 1.0f, 1.0f);
|
sndMgr->playSound3D(actor, magicEffect->mHitSound, 1.0f, 1.0f);
|
||||||
else
|
else
|
||||||
sndMgr->playSound3D(actor, schools[magicEffect->mData.mSchool]+" hit", 1.0f, 1.0f);
|
sndMgr->playSound3D(actor, schools[magicEffect->mData.mSchool]+" hit", 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!magicEffect->mHit.empty())
|
if (!magicEffect->mHit.empty())
|
||||||
{
|
{
|
||||||
const ESM::Static* castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find (magicEffect->mHit);
|
const ESM::Static* castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find (magicEffect->mHit);
|
||||||
bool loop = magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx;
|
bool loop = magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx;
|
||||||
MWBase::Environment::get().getWorld()->getAnimation(actor)->addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, "");
|
MWBase::Environment::get().getWorld()->getAnimation(actor)->addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue