1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 21:59:55 +00:00

Fix broken alchemy magnitude/duration

This commit is contained in:
scrawl 2014-10-02 13:54:56 +02:00
parent 7e10818bdf
commit afbd2de511
2 changed files with 13 additions and 10 deletions

View file

@ -133,7 +133,7 @@ void MWMechanics::Alchemy::updateEffects()
std::set<EffectKey> effects (listEffects()); std::set<EffectKey> effects (listEffects());
// general alchemy factor // general alchemy factor
float x = getChance(); float x = getAlchemyFactor();
x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->mBase->mData.mQuality; x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->mBase->mData.mQuality;
x *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fPotionStrengthMult")->getFloat(); x *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fPotionStrengthMult")->getFloat();
@ -306,18 +306,15 @@ void MWMechanics::Alchemy::increaseSkill()
mAlchemist.getClass().skillUsageSucceeded (mAlchemist, ESM::Skill::Alchemy, 0); mAlchemist.getClass().skillUsageSucceeded (mAlchemist, ESM::Skill::Alchemy, 0);
} }
float MWMechanics::Alchemy::getChance() const float MWMechanics::Alchemy::getAlchemyFactor() const
{ {
const CreatureStats& creatureStats = mAlchemist.getClass().getCreatureStats (mAlchemist); const CreatureStats& creatureStats = mAlchemist.getClass().getCreatureStats (mAlchemist);
const NpcStats& npcStats = mAlchemist.getClass().getNpcStats (mAlchemist); const NpcStats& npcStats = mAlchemist.getClass().getNpcStats (mAlchemist);
if (beginEffects() == endEffects())
return 0.f;
return return
(npcStats.getSkill (ESM::Skill::Alchemy).getModified() + (npcStats.getSkill (ESM::Skill::Alchemy).getModified() +
0.1 * creatureStats.getAttribute (1).getModified() 0.1 * creatureStats.getAttribute (ESM::Attribute::Intelligence).getModified()
+ 0.1 * creatureStats.getAttribute (7).getModified()); + 0.1 * creatureStats.getAttribute (ESM::Attribute::Luck).getModified());
} }
int MWMechanics::Alchemy::countIngredients() const int MWMechanics::Alchemy::countIngredients() const
@ -461,7 +458,14 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na
if (listEffects().empty()) if (listEffects().empty())
return Result_NoEffects; return Result_NoEffects;
if (getChance()<std::rand()/static_cast<double> (RAND_MAX)*100) if (beginEffects() == endEffects())
{
// all effects were nullified due to insufficient skill
removeIngredients();
return Result_RandomFailure;
}
if (getAlchemyFactor()<std::rand()/static_cast<double> (RAND_MAX)*100)
{ {
removeIngredients(); removeIngredients();
return Result_RandomFailure; return Result_RandomFailure;

View file

@ -69,8 +69,7 @@ namespace MWMechanics
void increaseSkill(); void increaseSkill();
///< Increase alchemist's skill. ///< Increase alchemist's skill.
float getChance() const; float getAlchemyFactor() const;
///< Return chance of success.
int countIngredients() const; int countIngredients() const;