示例#1
0
文件: actors.cpp 项目: emoose/openmw
    void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr)
    {
        CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);

        // attributes
        for (int i=0; i<8; ++i)
        {
            int modifier =
                creatureStats.getMagicEffects().get (EffectKey (79, i)).mMagnitude;

            modifier -= creatureStats.getMagicEffects().get (EffectKey (17, i)).mMagnitude;

            creatureStats.getAttribute(i).setModifier (modifier);
        }

        // dynamic stats
        MagicEffects effects = creatureStats.getMagicEffects();
        
        for (int i=0; i<3; ++i)
        {
            DynamicStat<float> stat = creatureStats.getDynamic (i);
            
            stat.setModifier (
                effects.get (EffectKey(80+i)).mMagnitude - effects.get (EffectKey(18+i)).mMagnitude);
        
            creatureStats.setDynamic (i, stat);
        }        
    }
示例#2
0
    MagicEffects Spells::getMagicEffects() const
    {
        // TODO: These are recalculated every frame, no need to do that

        MagicEffects effects;

        for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter)
        {
            const ESM::Spell *spell =
                MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (iter->first);

            if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight ||
                spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse)
            {
                int i=0;
                for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->mEffects.mList.begin(); it != spell->mEffects.mList.end(); ++it)
                {
                    float random = 1.f;
                    if (iter->second.find(i) != iter->second.end())
                        random = iter->second.at(i);

                    effects.add (*it, it->mMagnMin + (it->mMagnMax - it->mMagnMin) * random);
                    ++i;
                }
            }
        }

        return effects;
    }
示例#3
0
    MagicEffects MagicEffects::diff (const MagicEffects& prev, const MagicEffects& now)
    {
        MagicEffects result;

        // adding/changing
        for (Collection::const_iterator iter (now.begin()); iter!=now.end(); ++iter)
        {
            Collection::const_iterator other = prev.mCollection.find (iter->first);

            if (other==prev.end())
            {
                // adding
                result.add (iter->first, iter->second);
            }
            else
            {
                // changing
                result.add (iter->first, iter->second - other->second);
            }
        }

        // removing
        for (Collection::const_iterator iter (prev.begin()); iter!=prev.end(); ++iter)
        {
            Collection::const_iterator other = now.mCollection.find (iter->first);
            if (other==now.end())
            {
                result.add (iter->first, EffectParam() - iter->second);
            }
        }

        return result;
    }
示例#4
0
    void CreatureStats::setMagicEffects(const MagicEffects &effects)
    {
        if (effects.get(ESM::MagicEffect::FortifyMaximumMagicka).mMagnitude
                != mMagicEffects.get(ESM::MagicEffect::FortifyMaximumMagicka).mMagnitude)
            mRecalcDynamicStats = true;

        mMagicEffects = effects;
    }
示例#5
0
    void CreatureStats::modifyMagicEffects(const MagicEffects &effects)
    {
        if (effects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier()
                != mMagicEffects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier())
            mRecalcDynamicStats = true;

        mMagicEffects.setModifiers(effects);
    }
示例#6
0
    void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr)
    {
        CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);

        // attributes
        for (int i=0; i<5; ++i)
        {
            int modifier =
                creatureStats.getMagicEffects().get (EffectKey (79, i)).mMagnitude;

            modifier -= creatureStats.getMagicEffects().get (EffectKey (17, i)).mMagnitude;

            creatureStats.getAttribute(i).setModifier (modifier);
        }

        // dynamic stats
        MagicEffects effects = creatureStats.getMagicEffects();
        creatureStats.getHealth().setModifier(
            effects.get(EffectKey(80)).mMagnitude - effects.get(EffectKey(18)).mMagnitude);

        creatureStats.getMagicka().setModifier(
            effects.get(EffectKey(81)).mMagnitude - effects.get(EffectKey(19)).mMagnitude);

        creatureStats.getFatigue().setModifier(
            effects.get(EffectKey(82)).mMagnitude - effects.get(EffectKey(20)).mMagnitude);
    }
示例#7
0
 void Spells::addSpell (const ESM::Spell *spell, MagicEffects& effects) const
 {
     effects.add (spell->mEffects);
 }