Fix incorrect alchemy failure handling when an effect has a zero magnitude/duration (Fixes #1922)

deque
scrawl 10 years ago
parent ab9d9c7001
commit b145d183ae

@ -8,6 +8,8 @@
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwmechanics/magiceffects.hpp"
#include "../mwworld/class.hpp"
#include "inventoryitemmodel.hpp"
@ -211,12 +213,21 @@ namespace MWGui
mItemView->update();
std::vector<ESM::ENAMstruct> effects;
ESM::EffectList list;
list.mList = effects;
for (MWMechanics::Alchemy::TEffectsIterator it = mAlchemy.beginEffects (); it != mAlchemy.endEffects (); ++it)
std::set<MWMechanics::EffectKey> effectIds = mAlchemy.listEffects();
Widgets::SpellEffectList list;
for (std::set<MWMechanics::EffectKey>::iterator it = effectIds.begin(); it != effectIds.end(); ++it)
{
list.mList.push_back(*it);
Widgets::SpellEffectParams params;
params.mEffectID = it->mId;
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(it->mId);
if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill)
params.mSkill = it->mArg;
else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
params.mAttribute = it->mArg;
params.mIsConstant = true;
params.mNoTarget = true;
list.push_back(params);
}
while (mEffectsBox->getChildCount())
@ -226,8 +237,7 @@ namespace MWGui
Widgets::MWEffectListPtr effectsWidget = mEffectsBox->createWidget<Widgets::MWEffectList>
("MW_StatName", coord, MyGUI::Align::Left | MyGUI::Align::Top);
Widgets::SpellEffectList _list = Widgets::MWEffectList::effectListFromESM(&list);
effectsWidget->setEffectList(_list);
effectsWidget->setEffectList(list);
std::vector<MyGUI::Widget*> effectItems;
effectsWidget->createEffectWidgets(effectItems, mEffectsBox, coord, false, 0);

@ -306,6 +306,9 @@ float MWMechanics::Alchemy::getChance() const
const CreatureStats& creatureStats = mAlchemist.getClass().getCreatureStats (mAlchemist);
const NpcStats& npcStats = mAlchemist.getClass().getNpcStats (mAlchemist);
if (beginEffects() == endEffects())
return 0.f;
return
(npcStats.getSkill (ESM::Skill::Alchemy).getModified() +
0.1 * creatureStats.getAttribute (1).getModified()
@ -450,7 +453,7 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na
if (name.empty() && getPotionName().empty())
return Result_NoName;
if (beginEffects()==endEffects())
if (listEffects().empty())
return Result_NoEffects;
if (getChance()<std::rand()/static_cast<double> (RAND_MAX)*100)

@ -50,15 +50,12 @@ namespace MWMechanics
TEffectsContainer mEffects;
int mValue;
std::set<EffectKey> listEffects() const;
///< List all effects shared by at least two ingredients.
void applyTools (int flags, float& value) const;
void updateEffects();
const ESM::Potion *getRecord() const;
///< Return existing recrod for created potion (may return 0)
///< Return existing record for created potion (may return 0)
void removeIngredients();
///< Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and
@ -75,6 +72,10 @@ namespace MWMechanics
int countIngredients() const;
TEffectsIterator beginEffects() const;
TEffectsIterator endEffects() const;
public:
void setAlchemist (const MWWorld::Ptr& npc);
@ -94,6 +95,9 @@ namespace MWMechanics
void clear();
///< Remove alchemist, tools and ingredients.
std::set<EffectKey> listEffects() const;
///< List all effects shared by at least two ingredients.
int addIngredient (const MWWorld::Ptr& ingredient);
///< Add ingredient into the next free slot.
///
@ -103,10 +107,6 @@ namespace MWMechanics
void removeIngredient (int index);
///< Remove ingredient from slot (calling this function on an empty slot is a no-op).
TEffectsIterator beginEffects() const;
TEffectsIterator endEffects() const;
std::string getPotionName() const;
///< Return the name of the potion that would be created when calling create (if a record for such
/// a potion already exists) or return an empty string.

Loading…
Cancel
Save