diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 01520a331..255f38dd9 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -122,14 +122,10 @@ namespace MWClass const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); const ESM::MagicEffect *effect; - effect = store.get().find(59); + int index = effect->effectStringToId("sEffectTelekinesis"); + effect = store.get().find(index); - osg::Vec4f glowcolor(1,1,1,1); - glowcolor.x() = effect->mData.mRed / 255.f; - glowcolor.y() = effect->mData.mGreen / 255.f; - glowcolor.z() = effect->mData.mBlue / 255.f; - - animation->addSpellCastGlow(glowcolor); // TODO: Telekinesis glow should only be as long as the door animation + animation->addSpellCastGlow(effect); // TODO: Telekinesis glow should only be as long as the door animation } // make key id lowercase diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index bef720764..4c6a4c02d 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -584,6 +584,12 @@ namespace MWMechanics } else if (effectId == ESM::MagicEffect::Open) { + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const ESM::MagicEffect *magiceffect; + magiceffect = store.get().find(effectId); + MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target); + animation->addSpellCastGlow(magiceffect); + if (target.getCellRef().getLockLevel() <= magnitude) { if (target.getCellRef().getLockLevel() > 0) @@ -837,7 +843,7 @@ namespace MWMechanics mCaster.getClass().skillUsageSucceeded(mCaster, spellSchoolToSkill(school), 0); - // A non-actor doesn't play its effects from a character controller, so play spell casting effects here + // A non-actor doesn't play its spell cast effects from a character controller, so play them here if (!mCaster.getClass().isActor()) playSpellCastingEffects(mId); @@ -945,7 +951,7 @@ namespace MWMechanics MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(mCaster); - if (mCaster.getClass().isActor()) // TODO: Non-actors (except for large statics?) should also create a visual casting effect + if (mCaster.getClass().isActor()) // TODO: Non-actors (except for large statics?) should also create a spell cast vfx { const ESM::Static* castStatic; if (!effect->mCasting.empty()) @@ -957,14 +963,7 @@ namespace MWMechanics } if (!mCaster.getClass().isActor()) - { - osg::Vec4f glowcolor(1,1,1,1); - glowcolor.x() = effect->mData.mRed / 255.f; - glowcolor.y() = effect->mData.mGreen / 255.f; - glowcolor.z() = effect->mData.mBlue / 255.f; - - animation->addSpellCastGlow(glowcolor); - } + animation->addSpellCastGlow(effect); static const std::string schools[] = { "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 71b569285..0470cfe8c 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -159,9 +159,9 @@ namespace else writableStateSet = osg::clone(mNode->getStateSet(), osg::CopyOp::SHALLOW_COPY); - for (size_t index = 0; index < mTextures.size(); index++) + for (size_t i = 0; i < mTextures.size(); i++) { - writableStateSet->removeTextureAttribute(mTexUnit, mTextures[index]); + writableStateSet->removeTextureAttribute(mTexUnit, mTextures[i]); } writableStateSet->removeUniform(mUniform); // remove the uniform given to the temporary glow in addglow() @@ -1194,7 +1194,13 @@ namespace MWRender int mLowestUnusedTexUnit; }; - void Animation::addSpellCastGlow(osg::Vec4f glowColor){ + void Animation::addSpellCastGlow(const ESM::MagicEffect *effect){ + + osg::Vec4f glowColor = {1,1,1,1}; + glowColor.x() = effect->mData.mRed / 255.f; + glowColor.y() = effect->mData.mGreen / 255.f; + glowColor.z() = effect->mData.mBlue / 255.f; + if (!mObjectRoot->getUpdateCallback()) // If there is no glow on object addGlow(mObjectRoot, glowColor, 1.5); // Glow length measured from in-game as about 1.5 seconds diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 96bd0c03e..2fddc55c3 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -8,6 +8,7 @@ namespace ESM { struct Light; + struct MagicEffect; } namespace Resource @@ -351,7 +352,7 @@ public: void removeEffect (int effectId); void getLoopingEffects (std::vector& out) const; - void addSpellCastGlow(osg::Vec4f glowColor); + void addSpellCastGlow(const ESM::MagicEffect *effect); virtual void updatePtr(const MWWorld::Ptr &ptr);