mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 10:23:56 +00:00
Fix incorrect alchemy failure handling when an effect has a zero magnitude/duration (Fixes #1922)
This commit is contained in:
parent
ab9d9c7001
commit
b145d183ae
3 changed files with 29 additions and 16 deletions
|
@ -8,6 +8,8 @@
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/magiceffects.hpp"
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
#include "inventoryitemmodel.hpp"
|
#include "inventoryitemmodel.hpp"
|
||||||
|
@ -211,12 +213,21 @@ namespace MWGui
|
||||||
|
|
||||||
mItemView->update();
|
mItemView->update();
|
||||||
|
|
||||||
std::vector<ESM::ENAMstruct> effects;
|
std::set<MWMechanics::EffectKey> effectIds = mAlchemy.listEffects();
|
||||||
ESM::EffectList list;
|
Widgets::SpellEffectList list;
|
||||||
list.mList = effects;
|
for (std::set<MWMechanics::EffectKey>::iterator it = effectIds.begin(); it != effectIds.end(); ++it)
|
||||||
for (MWMechanics::Alchemy::TEffectsIterator it = mAlchemy.beginEffects (); it != mAlchemy.endEffects (); ++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())
|
while (mEffectsBox->getChildCount())
|
||||||
|
@ -226,8 +237,7 @@ namespace MWGui
|
||||||
Widgets::MWEffectListPtr effectsWidget = mEffectsBox->createWidget<Widgets::MWEffectList>
|
Widgets::MWEffectListPtr effectsWidget = mEffectsBox->createWidget<Widgets::MWEffectList>
|
||||||
("MW_StatName", coord, MyGUI::Align::Left | MyGUI::Align::Top);
|
("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;
|
std::vector<MyGUI::Widget*> effectItems;
|
||||||
effectsWidget->createEffectWidgets(effectItems, mEffectsBox, coord, false, 0);
|
effectsWidget->createEffectWidgets(effectItems, mEffectsBox, coord, false, 0);
|
||||||
|
|
|
@ -306,6 +306,9 @@ float MWMechanics::Alchemy::getChance() 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 (1).getModified()
|
||||||
|
@ -450,7 +453,7 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na
|
||||||
if (name.empty() && getPotionName().empty())
|
if (name.empty() && getPotionName().empty())
|
||||||
return Result_NoName;
|
return Result_NoName;
|
||||||
|
|
||||||
if (beginEffects()==endEffects())
|
if (listEffects().empty())
|
||||||
return Result_NoEffects;
|
return Result_NoEffects;
|
||||||
|
|
||||||
if (getChance()<std::rand()/static_cast<double> (RAND_MAX)*100)
|
if (getChance()<std::rand()/static_cast<double> (RAND_MAX)*100)
|
||||||
|
|
|
@ -50,15 +50,12 @@ namespace MWMechanics
|
||||||
TEffectsContainer mEffects;
|
TEffectsContainer mEffects;
|
||||||
int mValue;
|
int mValue;
|
||||||
|
|
||||||
std::set<EffectKey> listEffects() const;
|
|
||||||
///< List all effects shared by at least two ingredients.
|
|
||||||
|
|
||||||
void applyTools (int flags, float& value) const;
|
void applyTools (int flags, float& value) const;
|
||||||
|
|
||||||
void updateEffects();
|
void updateEffects();
|
||||||
|
|
||||||
const ESM::Potion *getRecord() const;
|
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();
|
void removeIngredients();
|
||||||
///< Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and
|
///< Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and
|
||||||
|
@ -75,6 +72,10 @@ namespace MWMechanics
|
||||||
|
|
||||||
int countIngredients() const;
|
int countIngredients() const;
|
||||||
|
|
||||||
|
TEffectsIterator beginEffects() const;
|
||||||
|
|
||||||
|
TEffectsIterator endEffects() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setAlchemist (const MWWorld::Ptr& npc);
|
void setAlchemist (const MWWorld::Ptr& npc);
|
||||||
|
@ -94,6 +95,9 @@ namespace MWMechanics
|
||||||
void clear();
|
void clear();
|
||||||
///< Remove alchemist, tools and ingredients.
|
///< 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);
|
int addIngredient (const MWWorld::Ptr& ingredient);
|
||||||
///< Add ingredient into the next free slot.
|
///< Add ingredient into the next free slot.
|
||||||
///
|
///
|
||||||
|
@ -103,10 +107,6 @@ namespace MWMechanics
|
||||||
void removeIngredient (int index);
|
void removeIngredient (int index);
|
||||||
///< Remove ingredient from slot (calling this function on an empty slot is a no-op).
|
///< 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;
|
std::string getPotionName() const;
|
||||||
///< Return the name of the potion that would be created when calling create (if a record for such
|
///< 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.
|
/// a potion already exists) or return an empty string.
|
||||||
|
|
Loading…
Reference in a new issue