1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 17:09:42 +00:00

Correct cast cost for enchantments.

This commit is contained in:
Miroslav Puda 2013-05-27 18:08:12 +02:00
parent 1c7b94e94f
commit 9a9b075a02
3 changed files with 20 additions and 1 deletions

View file

@ -66,7 +66,7 @@ namespace MWGui
mCharge->setCaption(boost::lexical_cast<std::string>(mEnchanting.getGemCharge()));
mCastCost->setCaption(boost::lexical_cast<std::string>(mEnchanting.getEnchantCost()));
mCastCost->setCaption(boost::lexical_cast<std::string>(mEnchanting.getCastCost()));
mPrice->setCaption(boost::lexical_cast<std::string>(mEnchanting.getEnchantPrice()));

View file

@ -206,6 +206,24 @@ namespace MWMechanics
return enchantmentCost;
}
float Enchanting::getCastCost() const
{
const float enchantCost = getEnchantCost();
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;
}
int Enchanting::getEnchantPrice() const
{
if(mEnchanter.isEmpty())

View file

@ -37,6 +37,7 @@ namespace MWMechanics
void nextCastStyle(); //Set enchant type to next possible type (for mOldItemPtr object)
int getCastStyle() const;
float getEnchantCost() const;
float getCastCost() const;
int getEnchantPrice() const;
float getMaxEnchantValue() const;
int getGemCharge() const;