forked from teamnwah/openmw-tes3coop
Issue #61: fixed alchemy skill
This commit is contained in:
parent
c635447cea
commit
d7add0b9e6
2 changed files with 15 additions and 52 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <components/esm/loadskil.hpp>
|
#include <components/esm/loadskil.hpp>
|
||||||
#include <components/esm/loadappa.hpp>
|
#include <components/esm/loadappa.hpp>
|
||||||
|
@ -28,7 +29,7 @@
|
||||||
|
|
||||||
std::set<MWMechanics::EffectKey> MWMechanics::Alchemy::listEffects() const
|
std::set<MWMechanics::EffectKey> MWMechanics::Alchemy::listEffects() const
|
||||||
{
|
{
|
||||||
std::set<EffectKey> effects;
|
std::map<EffectKey, int> effects;
|
||||||
|
|
||||||
for (TIngredientsIterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter)
|
for (TIngredientsIterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
@ -38,57 +39,23 @@ std::set<MWMechanics::EffectKey> MWMechanics::Alchemy::listEffects() const
|
||||||
|
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
if (ingredient->base->mData.mEffectID[i]!=-1)
|
if (ingredient->base->mData.mEffectID[i]!=-1)
|
||||||
effects.insert (EffectKey (
|
|
||||||
ingredient->base->mData.mEffectID[i], ingredient->base->mData.mSkills[i]!=-1 ?
|
|
||||||
ingredient->base->mData.mSkills[i] : ingredient->base->mData.mAttributes[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return effects;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MWMechanics::Alchemy::filterEffects (std::set<EffectKey>& effects) const
|
|
||||||
{
|
|
||||||
std::set<EffectKey>::iterator iter = effects.begin();
|
|
||||||
|
|
||||||
while (iter!=effects.end())
|
|
||||||
{
|
|
||||||
bool remove = false;
|
|
||||||
|
|
||||||
const EffectKey& key = *iter;
|
|
||||||
|
|
||||||
{ // dodge pointless g++ warning
|
|
||||||
for (TIngredientsIterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter)
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
if (iter->isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const MWWorld::LiveCellRef<ESM::Ingredient> *ingredient = iter->get<ESM::Ingredient>();
|
|
||||||
|
|
||||||
for (int i=0; i<4; ++i)
|
|
||||||
if (key.mId==ingredient->base->mData.mEffectID[i] &&
|
|
||||||
(key.mArg==ingredient->base->mData.mSkills[i] ||
|
|
||||||
key.mArg==ingredient->base->mData.mAttributes[i]))
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
{
|
||||||
remove = true;
|
EffectKey key (
|
||||||
break;
|
ingredient->base->mData.mEffectID[i], ingredient->base->mData.mSkills[i]!=-1 ?
|
||||||
}
|
ingredient->base->mData.mSkills[i] : ingredient->base->mData.mAttributes[i]);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remove)
|
++effects[key];
|
||||||
effects.erase (iter++);
|
}
|
||||||
else
|
}
|
||||||
++iter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<EffectKey> effects2;
|
||||||
|
|
||||||
|
for (std::map<EffectKey, int>::const_iterator iter (effects.begin()); iter!=effects.end(); ++iter)
|
||||||
|
if (iter->second>1)
|
||||||
|
effects2.insert (iter->first);
|
||||||
|
|
||||||
|
return effects2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWMechanics::Alchemy::applyTools (int flags, float& value) const
|
void MWMechanics::Alchemy::applyTools (int flags, float& value) const
|
||||||
|
@ -159,7 +126,6 @@ void MWMechanics::Alchemy::updateEffects()
|
||||||
|
|
||||||
// find effects
|
// find effects
|
||||||
std::set<EffectKey> effects (listEffects());
|
std::set<EffectKey> effects (listEffects());
|
||||||
filterEffects (effects);
|
|
||||||
|
|
||||||
// general alchemy factor
|
// general alchemy factor
|
||||||
float x = getChance();
|
float x = getChance();
|
||||||
|
|
|
@ -46,10 +46,7 @@ namespace MWMechanics
|
||||||
int mValue;
|
int mValue;
|
||||||
|
|
||||||
std::set<EffectKey> listEffects() const;
|
std::set<EffectKey> listEffects() const;
|
||||||
///< List all effects of all used ingredients.
|
///< List all effects shared by at least two ingredients.
|
||||||
|
|
||||||
void filterEffects (std::set<EffectKey>& effects) const;
|
|
||||||
///< Filter out effects not shared by all ingredients.
|
|
||||||
|
|
||||||
void applyTools (int flags, float& value) const;
|
void applyTools (int flags, float& value) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue