forked from mirror/openmw-tes3mp
Issue #479: Use magnitude specified when adding disease
This commit is contained in:
parent
f4ee8e2642
commit
654cd3ab9b
4 changed files with 15 additions and 15 deletions
|
@ -68,7 +68,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagicEffects::add (const ESM::EffectList& list)
|
void MagicEffects::add (const ESM::EffectList& list, float magnitude)
|
||||||
{
|
{
|
||||||
for (std::vector<ESM::ENAMstruct>::const_iterator iter (list.mList.begin()); iter!=list.mList.end();
|
for (std::vector<ESM::ENAMstruct>::const_iterator iter (list.mList.begin()); iter!=list.mList.end();
|
||||||
++iter)
|
++iter)
|
||||||
|
@ -78,9 +78,13 @@ namespace MWMechanics
|
||||||
if (iter->mMagnMin>=iter->mMagnMax)
|
if (iter->mMagnMin>=iter->mMagnMax)
|
||||||
param.mMagnitude = iter->mMagnMin;
|
param.mMagnitude = iter->mMagnMin;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (magnitude==-1)
|
||||||
|
magnitude = static_cast<float> (std::rand()) / RAND_MAX;
|
||||||
|
|
||||||
param.mMagnitude = static_cast<int> (
|
param.mMagnitude = static_cast<int> (
|
||||||
(iter->mMagnMax-iter->mMagnMin+1)*
|
(iter->mMagnMax-iter->mMagnMin+1)*magnitude + iter->mMagnMin);
|
||||||
(static_cast<float> (std::rand()) / RAND_MAX) + iter->mMagnMin);
|
}
|
||||||
|
|
||||||
add (*iter, param);
|
add (*iter, param);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
void add (const EffectKey& key, const EffectParam& param);
|
void add (const EffectKey& key, const EffectParam& param);
|
||||||
|
|
||||||
void add (const ESM::EffectList& list);
|
void add (const ESM::EffectList& list, float magnitude = -1);
|
||||||
|
///< \param magnitude normalised magnitude (-1: random)
|
||||||
|
|
||||||
MagicEffects& operator+= (const MagicEffects& effects);
|
MagicEffects& operator+= (const MagicEffects& effects);
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
|
|
||||||
#include "spells.hpp"
|
#include "spells.hpp"
|
||||||
|
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <components/esm/loadspel.hpp>
|
#include <components/esm/loadspel.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/esmstore.hpp"
|
||||||
|
|
||||||
#include "magiceffects.hpp"
|
#include "magiceffects.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
void Spells::addSpell (const ESM::Spell *spell, MagicEffects& effects) const
|
|
||||||
{
|
|
||||||
effects.add (spell->mEffects);
|
|
||||||
}
|
|
||||||
|
|
||||||
Spells::TIterator Spells::begin() const
|
Spells::TIterator Spells::begin() const
|
||||||
{
|
{
|
||||||
return mSpells.begin();
|
return mSpells.begin();
|
||||||
|
@ -30,7 +27,7 @@ namespace MWMechanics
|
||||||
void Spells::add (const std::string& spellId)
|
void Spells::add (const std::string& spellId)
|
||||||
{
|
{
|
||||||
if (mSpells.find (spellId)==mSpells.end())
|
if (mSpells.find (spellId)==mSpells.end())
|
||||||
mSpells.insert (std::make_pair (spellId, -1));
|
mSpells.insert (std::make_pair (spellId, static_cast<float> (std::rand()) / RAND_MAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spells::remove (const std::string& spellId)
|
void Spells::remove (const std::string& spellId)
|
||||||
|
@ -55,7 +52,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight ||
|
if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight ||
|
||||||
spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse)
|
spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse)
|
||||||
addSpell (spell, effects);
|
effects.add (spell->mEffects, iter->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
return effects;
|
return effects;
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::map<std::string, float> TContainer; // ID, magnitude
|
typedef std::map<std::string, float> TContainer; // ID, normalised magnitude
|
||||||
typedef TContainer::const_iterator TIterator;
|
typedef TContainer::const_iterator TIterator;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -29,8 +29,6 @@ namespace MWMechanics
|
||||||
TContainer mSpells;
|
TContainer mSpells;
|
||||||
std::string mSelectedSpell;
|
std::string mSelectedSpell;
|
||||||
|
|
||||||
void addSpell (const ESM::Spell *, MagicEffects& effects) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TIterator begin() const;
|
TIterator begin() const;
|
||||||
|
|
Loading…
Reference in a new issue