|
|
@ -164,46 +164,36 @@ namespace MWMechanics
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Formula on UESPWiki is not entirely correct.
|
|
|
|
* Formula on UESPWiki is not entirely correct.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int Enchanting::getEnchantPoints() const
|
|
|
|
float Enchanting::getEnchantPoints(bool precise) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mEffectList.mList.empty())
|
|
|
|
if (mEffectList.mList.empty())
|
|
|
|
// No effects added, cost = 0
|
|
|
|
// No effects added, cost = 0
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
std::vector<ESM::ENAMstruct> mEffects = mEffectList.mList;
|
|
|
|
const float fEffectCostMult = store.get<ESM::GameSetting>().find("fEffectCostMult")->mValue.getFloat();
|
|
|
|
|
|
|
|
const float fEnchantmentConstantDurationMult = store.get<ESM::GameSetting>().find("fEnchantmentConstantDurationMult")->mValue.getFloat();
|
|
|
|
|
|
|
|
|
|
|
|
int enchantmentCost = 0;
|
|
|
|
float enchantmentCost = 0.f;
|
|
|
|
float cost = 0;
|
|
|
|
float cost = 0.f;
|
|
|
|
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it)
|
|
|
|
for (const ESM::ENAMstruct& effect : mEffectList.mList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float baseCost = (store.get<ESM::MagicEffect>().find(it->mEffectID))->mData.mBaseCost;
|
|
|
|
float baseCost = (store.get<ESM::MagicEffect>().find(effect.mEffectID))->mData.mBaseCost;
|
|
|
|
int magMin = std::max(1, it->mMagnMin);
|
|
|
|
int magMin = std::max(1, effect.mMagnMin);
|
|
|
|
int magMax = std::max(1, it->mMagnMax);
|
|
|
|
int magMax = std::max(1, effect.mMagnMax);
|
|
|
|
int area = std::max(1, it->mArea);
|
|
|
|
int area = std::max(1, effect.mArea);
|
|
|
|
|
|
|
|
float duration = static_cast<float>(effect.mDuration);
|
|
|
|
float magnitudeCost = (magMin + magMax) * baseCost * 0.05f;
|
|
|
|
|
|
|
|
if (mCastStyle == ESM::Enchantment::ConstantEffect)
|
|
|
|
if (mCastStyle == ESM::Enchantment::ConstantEffect)
|
|
|
|
{
|
|
|
|
duration = fEnchantmentConstantDurationMult;
|
|
|
|
magnitudeCost *= store.get<ESM::GameSetting>().find("fEnchantmentConstantDurationMult")->mValue.getFloat();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
magnitudeCost *= it->mDuration;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float areaCost = area * 0.05f * baseCost;
|
|
|
|
cost += ((magMin + magMax) * duration + area) * baseCost * fEffectCostMult * 0.05f;
|
|
|
|
|
|
|
|
|
|
|
|
const float fEffectCostMult = store.get<ESM::GameSetting>().find("fEffectCostMult")->mValue.getFloat();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cost += (magnitudeCost + areaCost) * fEffectCostMult;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cost = std::max(1.f, cost);
|
|
|
|
cost = std::max(1.f, cost);
|
|
|
|
|
|
|
|
|
|
|
|
if (it->mRange == ESM::RT_Target)
|
|
|
|
if (effect.mRange == ESM::RT_Target)
|
|
|
|
cost *= 1.5;
|
|
|
|
cost *= 1.5f;
|
|
|
|
|
|
|
|
|
|
|
|
enchantmentCost += static_cast<int>(cost);
|
|
|
|
enchantmentCost += precise ? cost : std::floor(cost);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return enchantmentCost;
|
|
|
|
return enchantmentCost;
|
|
|
@ -215,7 +205,7 @@ namespace MWMechanics
|
|
|
|
if (mCastStyle == ESM::Enchantment::ConstantEffect)
|
|
|
|
if (mCastStyle == ESM::Enchantment::ConstantEffect)
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
return getEnchantPoints();
|
|
|
|
return static_cast<int>(getEnchantPoints(false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Enchanting::getEffectiveCastCost() const
|
|
|
|
int Enchanting::getEffectiveCastCost() const
|
|
|
@ -279,21 +269,21 @@ namespace MWMechanics
|
|
|
|
mEnchanter = enchanter;
|
|
|
|
mEnchanter = enchanter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float Enchanting::getEnchantChance() const
|
|
|
|
int Enchanting::getEnchantChance() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const CreatureStats& stats = mEnchanter.getClass().getCreatureStats(mEnchanter);
|
|
|
|
const CreatureStats& stats = mEnchanter.getClass().getCreatureStats(mEnchanter);
|
|
|
|
|
|
|
|
|
|
|
|
float chance1 = (mEnchanter.getClass().getSkill(mEnchanter, ESM::Skill::Enchant) +
|
|
|
|
|
|
|
|
(0.25f * stats.getAttribute (ESM::Attribute::Intelligence).getModified())
|
|
|
|
|
|
|
|
+ (0.125f * stats.getAttribute (ESM::Attribute::Luck).getModified()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
|
|
const MWWorld::Store<ESM::GameSetting>& gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
|
|
|
|
|
|
const float a = static_cast<float>(mEnchanter.getClass().getSkill(mEnchanter, ESM::Skill::Enchant));
|
|
|
|
|
|
|
|
const float b = static_cast<float>(stats.getAttribute (ESM::Attribute::Intelligence).getModified());
|
|
|
|
|
|
|
|
const float c = static_cast<float>(stats.getAttribute (ESM::Attribute::Luck).getModified());
|
|
|
|
|
|
|
|
const float fEnchantmentChanceMult = gmst.find("fEnchantmentChanceMult")->mValue.getFloat();
|
|
|
|
|
|
|
|
const float fEnchantmentConstantChanceMult = gmst.find("fEnchantmentConstantChanceMult")->mValue.getFloat();
|
|
|
|
|
|
|
|
|
|
|
|
float chance2 = 7.5f / (gmst.find("fEnchantmentChanceMult")->mValue.getFloat() * ((mCastStyle == ESM::Enchantment::ConstantEffect) ?
|
|
|
|
float x = (a - getEnchantPoints()*fEnchantmentChanceMult + 0.2f * b + 0.1f * c) * stats.getFatigueTerm();
|
|
|
|
gmst.find("fEnchantmentConstantChanceMult")->mValue.getFloat() : 1.0f ))
|
|
|
|
if (mCastStyle == ESM::Enchantment::ConstantEffect)
|
|
|
|
* getEnchantPoints();
|
|
|
|
x *= fEnchantmentConstantChanceMult;
|
|
|
|
|
|
|
|
|
|
|
|
return (chance1-chance2);
|
|
|
|
return static_cast<int>(x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Enchanting::payForEnchantment() const
|
|
|
|
void Enchanting::payForEnchantment() const
|
|
|
|