diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 40b4d6234..c26b925f6 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -20,7 +20,7 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" -#include "../mwmechanics/npcstats.hpp" +#include "../mwmechanics/alchemy.hpp" namespace MWClass { @@ -124,17 +124,8 @@ namespace MWClass // hide effects the player doesnt know about MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr(); - MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats (player); - int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase(); - int i=0; - static const float fWortChanceValue = - MWBase::Environment::get().getWorld()->getStore().get().find("fWortChanceValue")->getFloat(); - for (MWGui::Widgets::SpellEffectList::iterator it = info.effects.begin(); it != info.effects.end(); ++it) - { - it->mKnown = (i <= 1 && alchemySkill >= fWortChanceValue) - || (i <= 3 && alchemySkill >= fWortChanceValue*2); - ++i; - } + for (unsigned int i=0; i effectIds = mAlchemy->listEffects(); Widgets::SpellEffectList list; + unsigned int effectIndex=0; for (std::set::iterator it = effectIds.begin(); it != effectIds.end(); ++it) { Widgets::SpellEffectParams params; @@ -228,7 +229,10 @@ namespace MWGui params.mIsConstant = true; params.mNoTarget = true; + params.mKnown = mAlchemy->knownEffect(effectIndex, MWBase::Environment::get().getWorld()->getPlayerPtr()); + list.push_back(params); + ++effectIndex; } while (mEffectsBox->getChildCount()) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index d39c88150..d02376d23 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -451,6 +451,16 @@ MWMechanics::Alchemy::TEffectsIterator MWMechanics::Alchemy::endEffects() const return mEffects.end(); } +bool MWMechanics::Alchemy::knownEffect(unsigned int potionEffectIndex, const MWWorld::Ptr &npc) +{ + MWMechanics::NpcStats& npcStats = npc.getClass().getNpcStats(npc); + int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase(); + static const float fWortChanceValue = + MWBase::Environment::get().getWorld()->getStore().get().find("fWortChanceValue")->getFloat(); + return (potionEffectIndex <= 1 && alchemySkill >= fWortChanceValue) + || (potionEffectIndex <= 3 && alchemySkill >= fWortChanceValue*2); +} + MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& name) { if (mTools[ESM::Apparatus::MortarPestle].isEmpty()) diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index caba26f14..f351881e0 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -80,6 +80,9 @@ namespace MWMechanics public: + static bool knownEffect (unsigned int potionEffectIndex, const MWWorld::Ptr& npc); + ///< Does npc have sufficient alchemy skill to know about this potion effect? + void setAlchemist (const MWWorld::Ptr& npc); ///< Set alchemist and configure alchemy setup accordingly. \a npc may be empty to indicate that /// there is no alchemist (alchemy session has ended).