mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
Don't reveal unknown potion effects in alchemy window (Fixes #3146)
This commit is contained in:
parent
d3b76b7006
commit
b9d1d6144a
4 changed files with 20 additions and 12 deletions
|
@ -20,7 +20,7 @@
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
#include "../mwrender/renderinginterface.hpp"
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/alchemy.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
|
@ -124,17 +124,8 @@ namespace MWClass
|
||||||
|
|
||||||
// hide effects the player doesnt know about
|
// hide effects the player doesnt know about
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
MWMechanics::NpcStats& npcStats = player.getClass().getNpcStats (player);
|
for (unsigned int i=0; i<info.effects.size(); ++i)
|
||||||
int alchemySkill = npcStats.getSkill (ESM::Skill::Alchemy).getBase();
|
info.effects[i].mKnown = MWMechanics::Alchemy::knownEffect(i, player);
|
||||||
int i=0;
|
|
||||||
static const float fWortChanceValue =
|
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().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;
|
|
||||||
}
|
|
||||||
|
|
||||||
info.isPotion = true;
|
info.isPotion = true;
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,7 @@ namespace MWGui
|
||||||
|
|
||||||
std::set<MWMechanics::EffectKey> effectIds = mAlchemy->listEffects();
|
std::set<MWMechanics::EffectKey> effectIds = mAlchemy->listEffects();
|
||||||
Widgets::SpellEffectList list;
|
Widgets::SpellEffectList list;
|
||||||
|
unsigned int effectIndex=0;
|
||||||
for (std::set<MWMechanics::EffectKey>::iterator it = effectIds.begin(); it != effectIds.end(); ++it)
|
for (std::set<MWMechanics::EffectKey>::iterator it = effectIds.begin(); it != effectIds.end(); ++it)
|
||||||
{
|
{
|
||||||
Widgets::SpellEffectParams params;
|
Widgets::SpellEffectParams params;
|
||||||
|
@ -228,7 +229,10 @@ namespace MWGui
|
||||||
params.mIsConstant = true;
|
params.mIsConstant = true;
|
||||||
params.mNoTarget = true;
|
params.mNoTarget = true;
|
||||||
|
|
||||||
|
params.mKnown = mAlchemy->knownEffect(effectIndex, MWBase::Environment::get().getWorld()->getPlayerPtr());
|
||||||
|
|
||||||
list.push_back(params);
|
list.push_back(params);
|
||||||
|
++effectIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (mEffectsBox->getChildCount())
|
while (mEffectsBox->getChildCount())
|
||||||
|
|
|
@ -451,6 +451,16 @@ MWMechanics::Alchemy::TEffectsIterator MWMechanics::Alchemy::endEffects() const
|
||||||
return mEffects.end();
|
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<ESM::GameSetting>().find("fWortChanceValue")->getFloat();
|
||||||
|
return (potionEffectIndex <= 1 && alchemySkill >= fWortChanceValue)
|
||||||
|
|| (potionEffectIndex <= 3 && alchemySkill >= fWortChanceValue*2);
|
||||||
|
}
|
||||||
|
|
||||||
MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& name)
|
MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& name)
|
||||||
{
|
{
|
||||||
if (mTools[ESM::Apparatus::MortarPestle].isEmpty())
|
if (mTools[ESM::Apparatus::MortarPestle].isEmpty())
|
||||||
|
|
|
@ -80,6 +80,9 @@ namespace MWMechanics
|
||||||
|
|
||||||
public:
|
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);
|
void setAlchemist (const MWWorld::Ptr& npc);
|
||||||
///< Set alchemist and configure alchemy setup accordingly. \a npc may be empty to indicate that
|
///< Set alchemist and configure alchemy setup accordingly. \a npc may be empty to indicate that
|
||||||
/// there is no alchemist (alchemy session has ended).
|
/// there is no alchemist (alchemy session has ended).
|
||||||
|
|
Loading…
Reference in a new issue