forked from teamnwah/openmw-tes3coop
Minor rewrite, make "open" spells play glow effect
This commit is contained in:
parent
e132b52a69
commit
35c14bb9bb
4 changed files with 23 additions and 21 deletions
|
@ -122,14 +122,10 @@ namespace MWClass
|
||||||
|
|
||||||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
const ESM::MagicEffect *effect;
|
const ESM::MagicEffect *effect;
|
||||||
effect = store.get<ESM::MagicEffect>().find(59);
|
int index = effect->effectStringToId("sEffectTelekinesis");
|
||||||
|
effect = store.get<ESM::MagicEffect>().find(index);
|
||||||
|
|
||||||
osg::Vec4f glowcolor(1,1,1,1);
|
animation->addSpellCastGlow(effect); // TODO: Telekinesis glow should only be as long as the door animation
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make key id lowercase
|
// make key id lowercase
|
||||||
|
|
|
@ -584,6 +584,12 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
else if (effectId == ESM::MagicEffect::Open)
|
else if (effectId == ESM::MagicEffect::Open)
|
||||||
{
|
{
|
||||||
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
const ESM::MagicEffect *magiceffect;
|
||||||
|
magiceffect = store.get<ESM::MagicEffect>().find(effectId);
|
||||||
|
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target);
|
||||||
|
animation->addSpellCastGlow(magiceffect);
|
||||||
|
|
||||||
if (target.getCellRef().getLockLevel() <= magnitude)
|
if (target.getCellRef().getLockLevel() <= magnitude)
|
||||||
{
|
{
|
||||||
if (target.getCellRef().getLockLevel() > 0)
|
if (target.getCellRef().getLockLevel() > 0)
|
||||||
|
@ -837,7 +843,7 @@ namespace MWMechanics
|
||||||
mCaster.getClass().skillUsageSucceeded(mCaster,
|
mCaster.getClass().skillUsageSucceeded(mCaster,
|
||||||
spellSchoolToSkill(school), 0);
|
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())
|
if (!mCaster.getClass().isActor())
|
||||||
playSpellCastingEffects(mId);
|
playSpellCastingEffects(mId);
|
||||||
|
|
||||||
|
@ -945,7 +951,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(mCaster);
|
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;
|
const ESM::Static* castStatic;
|
||||||
if (!effect->mCasting.empty())
|
if (!effect->mCasting.empty())
|
||||||
|
@ -957,14 +963,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mCaster.getClass().isActor())
|
if (!mCaster.getClass().isActor())
|
||||||
{
|
animation->addSpellCastGlow(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;
|
|
||||||
|
|
||||||
animation->addSpellCastGlow(glowcolor);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const std::string schools[] = {
|
static const std::string schools[] = {
|
||||||
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"
|
||||||
|
|
|
@ -159,9 +159,9 @@ namespace
|
||||||
else
|
else
|
||||||
writableStateSet = osg::clone(mNode->getStateSet(), osg::CopyOp::SHALLOW_COPY);
|
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()
|
writableStateSet->removeUniform(mUniform); // remove the uniform given to the temporary glow in addglow()
|
||||||
|
@ -1194,7 +1194,13 @@ namespace MWRender
|
||||||
int mLowestUnusedTexUnit;
|
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
|
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
|
addGlow(mObjectRoot, glowColor, 1.5); // Glow length measured from in-game as about 1.5 seconds
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
struct Light;
|
struct Light;
|
||||||
|
struct MagicEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
|
@ -351,7 +352,7 @@ public:
|
||||||
void removeEffect (int effectId);
|
void removeEffect (int effectId);
|
||||||
void getLoopingEffects (std::vector<int>& out) const;
|
void getLoopingEffects (std::vector<int>& out) const;
|
||||||
|
|
||||||
void addSpellCastGlow(osg::Vec4f glowColor);
|
void addSpellCastGlow(const ESM::MagicEffect *effect);
|
||||||
|
|
||||||
virtual void updatePtr(const MWWorld::Ptr &ptr);
|
virtual void updatePtr(const MWWorld::Ptr &ptr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue