Exemplo n.º 1
0
    int Enchanting::getBaseCastCost() const
    {
        if (mCastStyle == ESM::Enchantment::ConstantEffect)
            return 0;

        return getEnchantPoints();
    }
Exemplo n.º 2
0
    float Enchanting::getEnchantChance() const
    {
        const NpcStats& npcStats = mEnchanter.getClass().getNpcStats (mEnchanter);

        float chance1 = (npcStats.getSkill (ESM::Skill::Enchant).getModified() + 
        (0.25f * npcStats.getAttribute (ESM::Attribute::Intelligence).getModified())
        + (0.125f * npcStats.getAttribute (ESM::Attribute::Luck).getModified()));

        const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

        float chance2 = 7.5f / (gmst.find("fEnchantmentChanceMult")->getFloat() * ((mCastStyle == ESM::Enchantment::ConstantEffect) ?
                                                                          gmst.find("fEnchantmentConstantChanceMult")->getFloat() : 1.0f ))
                * getEnchantPoints();

        return (chance1-chance2);
    }
Exemplo n.º 3
0
    bool Enchanting::create()
    {
        MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
        ESM::Enchantment enchantment;
        enchantment.mData.mCharge = getGemCharge();

        mSoulGemPtr.getRefData().setCount (mSoulGemPtr.getRefData().getCount()-1);

        //Exception for Azura Star, new one will be added after enchanting
        if(boost::iequals(mSoulGemPtr.get<ESM::Miscellaneous>()->mBase->mId, "Misc_SoulGem_Azura"))
        {
            MWWorld::ManualRef azura (MWBase::Environment::get().getWorld()->getStore(), "Misc_SoulGem_Azura");
            MWWorld::Class::get (player).getContainerStore (player).add (azura.getPtr());
        }

        if(mSelfEnchanting)
        {
            if(getEnchantChance()<std::rand()/static_cast<double> (RAND_MAX)*100)
                return false;

            MWWorld::Class::get (mEnchanter).skillUsageSucceeded (mEnchanter, ESM::Skill::Enchant, 1);
        }

        if(mCastStyle==ESM::Enchantment::ConstantEffect)
        {
            enchantment.mData.mCharge=0;
        }
        enchantment.mData.mType = mCastStyle;
        enchantment.mData.mCost = getEnchantPoints();
        enchantment.mEffects = mEffectList;

        const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment);

        MWWorld::Class::get(mOldItemPtr).applyEnchantment(mOldItemPtr, enchantmentPtr->mId, getGemCharge(), mNewItemName);

        mOldItemPtr.getRefData().setCount(1);

        MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), mOldItemId);
        ref.getPtr().getRefData().setCount (mOldItemCount-1);

        MWWorld::Class::get (player).getContainerStore (player).add (ref.getPtr());
        if(!mSelfEnchanting)
            payForEnchantment();

        return true;
    }
Exemplo n.º 4
0
    float Enchanting::getCastCost() const
    {
        if (mCastStyle == ESM::Enchantment::ConstantEffect)
            return 0;

        const float enchantCost = getEnchantPoints();
        MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
        MWMechanics::NpcStats &stats = MWWorld::Class::get(player).getNpcStats(player);
        int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified();

        /*
         * Each point of enchant skill above/under 10 subtracts/adds
         * one percent of enchantment cost while minimum is 1.
         */
        const float castCost = enchantCost - (enchantCost / 100) * (eSkill - 10);

        return (castCost < 1) ? 1 : castCost;
    }
Exemplo n.º 5
0
    float Enchanting::getEnchantChance() const
    {
        /*
        Formula from http://www.uesp.net/wiki/Morrowind:Enchant
        */
        const CreatureStats& creatureStats = MWWorld::Class::get (mEnchanter).getCreatureStats (mEnchanter);
        const NpcStats& npcStats = MWWorld::Class::get (mEnchanter).getNpcStats (mEnchanter);

        float chance1 = (npcStats.getSkill (ESM::Skill::Enchant).getModified() + 
        (0.25 * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified())
        + (0.125 * creatureStats.getAttribute (ESM::Attribute::Luck).getModified()));

        float chance2 = 2.5 * getEnchantPoints();
        if(mCastStyle==ESM::Enchantment::ConstantEffect)
        {
            float constantChance = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fEnchantmentConstantChanceMult")->getFloat();
            chance2 /= constantChance;
        }
        return (chance1-chance2);
    }
Exemplo n.º 6
0
    int Enchanting::getEnchantPrice() const
    {
        if(mEnchanter.isEmpty())
            return 0;

        float priceMultipler = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fEnchantmentValueMult")->getFloat();
        int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mEnchanter, (getEnchantPoints() * priceMultipler), true);
        return price;
    }