mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +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();
|
||||
|
||||
int ingredients = 0;
|
||||
|
||||
for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter)
|
||||
if (!iter->isEmpty())
|
||||
++ingredients;
|
||||
|
||||
if (ingredients<2 || mAlchemist.isEmpty() || mTools[ESM::Apparatus::MortarPestle].isEmpty())
|
||||
if (countIngredients()<2 || mAlchemist.isEmpty() || mTools[ESM::Apparatus::MortarPestle].isEmpty())
|
||||
return;
|
||||
|
||||
// find effects
|
||||
@ -251,6 +245,17 @@ float MWMechanics::Alchemy::getChance() const
|
||||
+ 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)
|
||||
{
|
||||
mAlchemist = npc;
|
||||
@ -370,14 +375,8 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na
|
||||
{
|
||||
if (mTools[ESM::Apparatus::MortarPestle].isEmpty())
|
||||
return Result_NoMortarAndPestle;
|
||||
|
||||
int ingredients = 0;
|
||||
|
||||
for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter)
|
||||
if (!iter->isEmpty())
|
||||
++ingredients;
|
||||
|
||||
if (ingredients<2)
|
||||
|
||||
if (countIngredients()<2)
|
||||
return Result_LessThanTwoIngredients;
|
||||
|
||||
if (name.empty() && getPotionName().empty())
|
||||
|
@ -70,6 +70,8 @@ namespace MWMechanics
|
||||
float getChance() const;
|
||||
///< Return chance of success.
|
||||
|
||||
int countIngredients() const;
|
||||
|
||||
public:
|
||||
|
||||
void setAlchemist (const MWWorld::Ptr& npc);
|
||||
@ -77,10 +79,12 @@ namespace MWMechanics
|
||||
/// there is no alchemist (alchemy session has ended).
|
||||
|
||||
TToolsIterator beginTools() const;
|
||||
///< \attention Iterates over tool slots, not over tools. Some of the slots may be empty.
|
||||
|
||||
TToolsIterator endTools() const;
|
||||
|
||||
TIngredientsIterator beginIngredients() const;
|
||||
///< \attention Iterates over ingredient slots, not over ingredients. Some of the slots may be empty.
|
||||
|
||||
TIngredientsIterator endIngredients() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user