mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Issue 61: improved ingredients handling in alchemy and documenation
This commit is contained in:
parent
3fe0a73cf2
commit
3c71378fad
@ -148,13 +148,7 @@ void MWMechanics::Alchemy::updateEffects()
|
|||||||
{
|
{
|
||||||
mEffects.clear();
|
mEffects.clear();
|
||||||
|
|
||||||
int ingredients = 0;
|
if (countIngredients()<2 || mAlchemist.isEmpty() || mTools[ESM::Apparatus::MortarPestle].isEmpty())
|
||||||
|
|
||||||
for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter)
|
|
||||||
if (!iter->isEmpty())
|
|
||||||
++ingredients;
|
|
||||||
|
|
||||||
if (ingredients<2 || mAlchemist.isEmpty() || mTools[ESM::Apparatus::MortarPestle].isEmpty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// find effects
|
// find effects
|
||||||
@ -251,6 +245,17 @@ float MWMechanics::Alchemy::getChance() const
|
|||||||
+ 0.1 * creatureStats.getAttribute (7).getModified());
|
+ 0.1 * creatureStats.getAttribute (7).getModified());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MWMechanics::Alchemy::countIngredients() const
|
||||||
|
{
|
||||||
|
int ingredients = 0;
|
||||||
|
|
||||||
|
for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter)
|
||||||
|
if (!iter->isEmpty())
|
||||||
|
++ingredients;
|
||||||
|
|
||||||
|
return ingredients;
|
||||||
|
}
|
||||||
|
|
||||||
void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc)
|
void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc)
|
||||||
{
|
{
|
||||||
mAlchemist = npc;
|
mAlchemist = npc;
|
||||||
@ -370,14 +375,8 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na
|
|||||||
{
|
{
|
||||||
if (mTools[ESM::Apparatus::MortarPestle].isEmpty())
|
if (mTools[ESM::Apparatus::MortarPestle].isEmpty())
|
||||||
return Result_NoMortarAndPestle;
|
return Result_NoMortarAndPestle;
|
||||||
|
|
||||||
int ingredients = 0;
|
if (countIngredients()<2)
|
||||||
|
|
||||||
for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter)
|
|
||||||
if (!iter->isEmpty())
|
|
||||||
++ingredients;
|
|
||||||
|
|
||||||
if (ingredients<2)
|
|
||||||
return Result_LessThanTwoIngredients;
|
return Result_LessThanTwoIngredients;
|
||||||
|
|
||||||
if (name.empty() && getPotionName().empty())
|
if (name.empty() && getPotionName().empty())
|
||||||
|
@ -70,6 +70,8 @@ namespace MWMechanics
|
|||||||
float getChance() const;
|
float getChance() const;
|
||||||
///< Return chance of success.
|
///< Return chance of success.
|
||||||
|
|
||||||
|
int countIngredients() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setAlchemist (const MWWorld::Ptr& npc);
|
void setAlchemist (const MWWorld::Ptr& npc);
|
||||||
@ -77,10 +79,12 @@ namespace MWMechanics
|
|||||||
/// there is no alchemist (alchemy session has ended).
|
/// there is no alchemist (alchemy session has ended).
|
||||||
|
|
||||||
TToolsIterator beginTools() const;
|
TToolsIterator beginTools() const;
|
||||||
|
///< \attention Iterates over tool slots, not over tools. Some of the slots may be empty.
|
||||||
|
|
||||||
TToolsIterator endTools() const;
|
TToolsIterator endTools() const;
|
||||||
|
|
||||||
TIngredientsIterator beginIngredients() const;
|
TIngredientsIterator beginIngredients() const;
|
||||||
|
///< \attention Iterates over ingredient slots, not over ingredients. Some of the slots may be empty.
|
||||||
|
|
||||||
TIngredientsIterator endIngredients() const;
|
TIngredientsIterator endIngredients() const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user