mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-29 22:20:33 +00:00
Remove a member variable that doesn't get saved and remove fortify maximum health code
This commit is contained in:
parent
4e52c96cf5
commit
dc495a685a
@ -399,7 +399,7 @@ namespace MWGui
|
||||
skillWidget = mSkillList->createWidget<Widgets::MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default,
|
||||
std::string("Skill") + MyGUI::utility::toString(i));
|
||||
skillWidget->setSkillNumber(skillId);
|
||||
skillWidget->setSkillValue(Widgets::MWSkill::SkillValue(static_cast<float>(race->mData.mBonus[i].mBonus)));
|
||||
skillWidget->setSkillValue(Widgets::MWSkill::SkillValue(static_cast<float>(race->mData.mBonus[i].mBonus), 0.f));
|
||||
ToolTips::createSkillToolTip(skillWidget, skillId);
|
||||
|
||||
|
||||
|
@ -181,8 +181,6 @@ namespace MWGui
|
||||
public:
|
||||
MWSpell();
|
||||
|
||||
typedef MWMechanics::Stat<int> SpellValue;
|
||||
|
||||
void setSpellId(const std::string &id);
|
||||
|
||||
/**
|
||||
@ -215,8 +213,6 @@ namespace MWGui
|
||||
public:
|
||||
MWEffectList();
|
||||
|
||||
typedef MWMechanics::Stat<int> EnchantmentValue;
|
||||
|
||||
enum EffectFlags
|
||||
{
|
||||
EF_NoTarget = 0x01, // potions have no target (target is always the player)
|
||||
|
@ -26,8 +26,6 @@ namespace MWMechanics
|
||||
mDeathAnimation(-1), mTimeOfDeath(), mSideMovementAngle(0), mLevel (0)
|
||||
, mAttackingOrSpell(false)
|
||||
{
|
||||
for (int i=0; i<4; ++i)
|
||||
mAiSettings[i] = 0;
|
||||
}
|
||||
|
||||
const AiSequence& CreatureStats::getAiSequence() const
|
||||
@ -158,9 +156,8 @@ namespace MWMechanics
|
||||
float agility = getAttribute(ESM::Attribute::Agility).getModified();
|
||||
float endurance = getAttribute(ESM::Attribute::Endurance).getModified();
|
||||
DynamicStat<float> fatigue = getFatigue();
|
||||
float diff = (strength+willpower+agility+endurance) - fatigue.getBase();
|
||||
float currentToBaseRatio = fatigue.getBase() > 0 ? (fatigue.getCurrent() / fatigue.getBase()) : 0;
|
||||
fatigue.setModified(fatigue.getModified() + diff, 0);
|
||||
fatigue.setBase(std::max(0.f, strength + willpower + agility + endurance));
|
||||
fatigue.setCurrent(fatigue.getBase() * currentToBaseRatio, false, true);
|
||||
setFatigue(fatigue);
|
||||
}
|
||||
@ -196,8 +193,6 @@ namespace MWMechanics
|
||||
|
||||
mDead = true;
|
||||
|
||||
mDynamic[index].setModifier(0);
|
||||
mDynamic[index].setCurrentModifier(0);
|
||||
mDynamic[index].setCurrent(0);
|
||||
}
|
||||
}
|
||||
@ -281,10 +276,7 @@ namespace MWMechanics
|
||||
{
|
||||
if (mDead)
|
||||
{
|
||||
if (mDynamic[0].getModified() < 1)
|
||||
mDynamic[0].setModified(1, 0);
|
||||
|
||||
mDynamic[0].setCurrent(mDynamic[0].getModified());
|
||||
mDynamic[0].setCurrent(mDynamic[0].getBase());
|
||||
mDead = false;
|
||||
mDeathAnimationFinished = false;
|
||||
}
|
||||
@ -415,9 +407,8 @@ namespace MWMechanics
|
||||
double magickaFactor = base + mMagicEffects.get(EffectKey(ESM::MagicEffect::FortifyMaximumMagicka)).getMagnitude() * 0.1;
|
||||
|
||||
DynamicStat<float> magicka = getMagicka();
|
||||
float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase();
|
||||
float currentToBaseRatio = magicka.getBase() > 0 ? magicka.getCurrent() / magicka.getBase() : 0;
|
||||
magicka.setModified(magicka.getModified() + diff, 0);
|
||||
magicka.setBase(magickaFactor * intelligence);
|
||||
magicka.setCurrent(magicka.getBase() * currentToBaseRatio, false, true);
|
||||
setMagicka(magicka);
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ namespace MWMechanics
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
DynamicStat<float> stat = creatureStats.getDynamic (i);
|
||||
stat.setCurrent (stat.getModified());
|
||||
stat.setCurrent(stat.getModified());
|
||||
creatureStats.setDynamic (i, stat);
|
||||
}
|
||||
|
||||
@ -1450,7 +1450,7 @@ namespace MWMechanics
|
||||
std::string script = target.getClass().getScript(target);
|
||||
if (!script.empty() && target.getRefData().getLocals().hasVar(script, "onpchitme") && attacker == player)
|
||||
{
|
||||
int fight = std::max(0, target.getClass().getCreatureStats(target).getAiSetting(CreatureStats::AI_Fight).getModified());
|
||||
int fight = target.getClass().getCreatureStats(target).getAiSetting(CreatureStats::AI_Fight).getModified();
|
||||
peaceful = (fight == 0);
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,7 @@ namespace
|
||||
auto& creatureStats = target.getClass().getCreatureStats(target);
|
||||
auto stat = creatureStats.getDynamic(index);
|
||||
float current = stat.getCurrent();
|
||||
stat.setModified(stat.getModified() + magnitude, 0);
|
||||
stat.setCurrentModified(stat.getCurrentModified() + magnitude);
|
||||
stat.setBase(std::max(0.f, stat.getBase() + magnitude));
|
||||
stat.setCurrent(current + magnitude);
|
||||
creatureStats.setDynamic(index, stat);
|
||||
}
|
||||
|
@ -5,174 +5,41 @@
|
||||
namespace MWMechanics
|
||||
{
|
||||
template<typename T>
|
||||
Stat<T>::Stat() : mBase (0), mModified (0), mCurrentModified (0) {}
|
||||
Stat<T>::Stat() : mBase (0), mModifier (0) {}
|
||||
template<typename T>
|
||||
Stat<T>::Stat(T base) : mBase (base), mModified (base), mCurrentModified (base) {}
|
||||
template<typename T>
|
||||
Stat<T>::Stat(T base, T modified) : mBase (base), mModified (modified), mCurrentModified (modified) {}
|
||||
|
||||
template<typename T>
|
||||
const T& Stat<T>::getBase() const
|
||||
{
|
||||
return mBase;
|
||||
}
|
||||
Stat<T>::Stat(T base, T modified) : mBase (base), mModifier (modified) {}
|
||||
|
||||
template<typename T>
|
||||
T Stat<T>::getModified(bool capped) const
|
||||
{
|
||||
if(!capped)
|
||||
return mModified;
|
||||
return std::max(static_cast<T>(0), mModified);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Stat<T>::getCurrentModified() const
|
||||
{
|
||||
return mCurrentModified;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Stat<T>::getModifier() const
|
||||
{
|
||||
return mModified-mBase;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Stat<T>::getCurrentModifier() const
|
||||
{
|
||||
return mCurrentModified - mModified;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Stat<T>::set (const T& value)
|
||||
{
|
||||
T diff = value - mBase;
|
||||
mBase = mModified = value;
|
||||
mCurrentModified += diff;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Stat<T>::setBase (const T& value)
|
||||
{
|
||||
T diff = value - mBase;
|
||||
mBase = value;
|
||||
mModified += diff;
|
||||
mCurrentModified += diff;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Stat<T>::setModified (T value, const T& min, const T& max)
|
||||
{
|
||||
T diff = value - mModified;
|
||||
|
||||
if (mBase+diff<min)
|
||||
{
|
||||
value = min + (mModified - mBase);
|
||||
diff = value - mModified;
|
||||
}
|
||||
else if (mBase+diff>max)
|
||||
{
|
||||
value = max + (mModified - mBase);
|
||||
diff = value - mModified;
|
||||
}
|
||||
|
||||
mModified = value;
|
||||
mBase += diff;
|
||||
mCurrentModified += diff;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Stat<T>::setCurrentModified(T value)
|
||||
{
|
||||
mCurrentModified = value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Stat<T>::setModifier (const T& modifier)
|
||||
{
|
||||
mModified = mBase + modifier;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Stat<T>::setCurrentModifier(const T& modifier)
|
||||
{
|
||||
mCurrentModified = mModified + modifier;
|
||||
if(capped)
|
||||
return std::max({}, mModifier + mBase);
|
||||
return mModifier + mBase;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Stat<T>::writeState (ESM::StatState<T>& state) const
|
||||
{
|
||||
state.mBase = mBase;
|
||||
state.mMod = mCurrentModified;
|
||||
state.mMod = mModifier;
|
||||
}
|
||||
template<typename T>
|
||||
void Stat<T>::readState (const ESM::StatState<T>& state)
|
||||
{
|
||||
mBase = state.mBase;
|
||||
mModified = state.mBase;
|
||||
mCurrentModified = state.mMod;
|
||||
mModifier = state.mMod;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
DynamicStat<T>::DynamicStat() : mStatic (0), mCurrent (0) {}
|
||||
DynamicStat<T>::DynamicStat() : mStatic(0, 0), mCurrent(0) {}
|
||||
template<typename T>
|
||||
DynamicStat<T>::DynamicStat(T base) : mStatic (base), mCurrent (base) {}
|
||||
DynamicStat<T>::DynamicStat(T base) : mStatic(base, 0), mCurrent(base) {}
|
||||
template<typename T>
|
||||
DynamicStat<T>::DynamicStat(T base, T modified, T current) : mStatic(base, modified), mCurrent (current) {}
|
||||
template<typename T>
|
||||
DynamicStat<T>::DynamicStat(const Stat<T> &stat, T current) : mStatic(stat), mCurrent (current) {}
|
||||
|
||||
|
||||
template<typename T>
|
||||
const T& DynamicStat<T>::getBase() const
|
||||
{
|
||||
return mStatic.getBase();
|
||||
}
|
||||
template<typename T>
|
||||
T DynamicStat<T>::getModified() const
|
||||
{
|
||||
return mStatic.getModified();
|
||||
}
|
||||
template<typename T>
|
||||
T DynamicStat<T>::getCurrentModified() const
|
||||
{
|
||||
return mStatic.getCurrentModified();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T& DynamicStat<T>::getCurrent() const
|
||||
{
|
||||
return mCurrent;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void DynamicStat<T>::set (const T& value)
|
||||
{
|
||||
mStatic.set (value);
|
||||
mCurrent = value;
|
||||
}
|
||||
template<typename T>
|
||||
void DynamicStat<T>::setBase (const T& value)
|
||||
{
|
||||
mStatic.setBase (value);
|
||||
|
||||
if (mCurrent>getModified())
|
||||
mCurrent = getModified();
|
||||
}
|
||||
template<typename T>
|
||||
void DynamicStat<T>::setModified (T value, const T& min, const T& max)
|
||||
{
|
||||
mStatic.setModified (value, min, max);
|
||||
|
||||
if (mCurrent>getModified())
|
||||
mCurrent = getModified();
|
||||
}
|
||||
template<typename T>
|
||||
void DynamicStat<T>::setCurrentModified(T value)
|
||||
{
|
||||
mStatic.setCurrentModified(value);
|
||||
}
|
||||
template<typename T>
|
||||
void DynamicStat<T>::setCurrent (const T& value, bool allowDecreaseBelowZero, bool allowIncreaseAboveModified)
|
||||
{
|
||||
@ -197,23 +64,6 @@ namespace MWMechanics
|
||||
mCurrent = 0;
|
||||
}
|
||||
}
|
||||
template<typename T>
|
||||
void DynamicStat<T>::setModifier (const T& modifier, bool allowCurrentDecreaseBelowZero)
|
||||
{
|
||||
T diff = modifier - mStatic.getModifier();
|
||||
mStatic.setModifier (modifier);
|
||||
setCurrent (getCurrent()+diff, allowCurrentDecreaseBelowZero);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void DynamicStat<T>::setCurrentModifier(const T& modifier, bool allowCurrentDecreaseBelowZero)
|
||||
{
|
||||
T diff = modifier - mStatic.getCurrentModifier();
|
||||
mStatic.setCurrentModifier(modifier);
|
||||
|
||||
// The (modifier > 0) check here allows increase over modified only if the modifier is positive (a fortify effect is active).
|
||||
setCurrent (getCurrent() + diff, allowCurrentDecreaseBelowZero, (modifier > 0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void DynamicStat<T>::writeState (ESM::StatState<T>& state) const
|
||||
|
@ -16,38 +16,22 @@ namespace MWMechanics
|
||||
class Stat
|
||||
{
|
||||
T mBase;
|
||||
T mModified;
|
||||
T mCurrentModified;
|
||||
T mModifier;
|
||||
|
||||
public:
|
||||
typedef T Type;
|
||||
|
||||
Stat();
|
||||
Stat(T base);
|
||||
Stat(T base, T modified);
|
||||
|
||||
const T& getBase() const;
|
||||
const T& getBase() const { return mBase; };
|
||||
|
||||
T getModified(bool capped = true) const;
|
||||
T getCurrentModified() const;
|
||||
T getModifier() const;
|
||||
T getCurrentModifier() const;
|
||||
T getModifier() const { return mModifier; };
|
||||
|
||||
/// Set base and modified to \a value.
|
||||
void set (const T& value);
|
||||
void setBase(const T& value) { mBase = value; };
|
||||
|
||||
/// Set base and adjust modified accordingly.
|
||||
void setBase (const T& value);
|
||||
|
||||
/// Set modified value and adjust base accordingly.
|
||||
void setModified (T value, const T& min, const T& max = std::numeric_limits<T>::max());
|
||||
|
||||
/// Set "current modified," used for drain and fortify. Unlike the regular modifier
|
||||
/// this just adds and subtracts from the current value without changing the maximum.
|
||||
void setCurrentModified(T value);
|
||||
|
||||
void setModifier (const T& modifier);
|
||||
void setCurrentModifier (const T& modifier);
|
||||
void setModifier(const T& modifier) { mModifier = modifier; };
|
||||
|
||||
void writeState (ESM::StatState<T>& state) const;
|
||||
void readState (const ESM::StatState<T>& state);
|
||||
@ -57,7 +41,7 @@ namespace MWMechanics
|
||||
inline bool operator== (const Stat<T>& left, const Stat<T>& right)
|
||||
{
|
||||
return left.getBase()==right.getBase() &&
|
||||
left.getModified()==right.getModified();
|
||||
left.getModifier()==right.getModifier();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -80,27 +64,17 @@ namespace MWMechanics
|
||||
DynamicStat(T base, T modified, T current);
|
||||
DynamicStat(const Stat<T> &stat, T current);
|
||||
|
||||
const T& getBase() const;
|
||||
T getModified() const;
|
||||
T getCurrentModified() const;
|
||||
const T& getCurrent() const;
|
||||
const T& getBase() const { return mStatic.getBase(); };
|
||||
T getModified(bool capped = true) const { return mStatic.getModified(capped); };
|
||||
const T& getCurrent() const { return mCurrent; };
|
||||
|
||||
/// Set base, modified and current to \a value.
|
||||
void set (const T& value);
|
||||
|
||||
/// Set base and adjust modified accordingly.
|
||||
void setBase (const T& value);
|
||||
|
||||
/// Set modified value and adjust base accordingly.
|
||||
void setModified (T value, const T& min, const T& max = std::numeric_limits<T>::max());
|
||||
|
||||
/// Set "current modified," used for drain and fortify. Unlike the regular modifier
|
||||
/// this just adds and subtracts from the current value without changing the maximum.
|
||||
void setCurrentModified(T value);
|
||||
/// Set base and adjust current accordingly.
|
||||
void setBase(const T& value) { mStatic.setBase(value); };
|
||||
|
||||
void setCurrent (const T& value, bool allowDecreaseBelowZero = false, bool allowIncreaseAboveModified = false);
|
||||
void setModifier (const T& modifier, bool allowCurrentToDecreaseBelowZero=false);
|
||||
void setCurrentModifier (const T& modifier, bool allowCurrentToDecreaseBelowZero = false);
|
||||
|
||||
T getModifier() const { return mStatic.getModifier(); }
|
||||
void setModifier(T value) { mStatic.setModifier(value); }
|
||||
|
||||
void writeState (ESM::StatState<T>& state) const;
|
||||
void readState (const ESM::StatState<T>& state);
|
||||
@ -110,7 +84,7 @@ namespace MWMechanics
|
||||
inline bool operator== (const DynamicStat<T>& left, const DynamicStat<T>& right)
|
||||
{
|
||||
return left.getBase()==right.getBase() &&
|
||||
left.getModified()==right.getModified() &&
|
||||
left.getModifier()==right.getModifier() &&
|
||||
left.getCurrent()==right.getCurrent();
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,11 @@ namespace MWWorld
|
||||
for(std::size_t i = 0; i < ESM::Attribute::Length; ++i)
|
||||
creatureStats.mAttributes[i].mMod = 0.f;
|
||||
for(std::size_t i = 0; i < 3; ++i)
|
||||
creatureStats.mDynamic[i].mMod = 0.f;
|
||||
{
|
||||
auto& dynamic = creatureStats.mDynamic[i];
|
||||
dynamic.mCurrent -= dynamic.mMod - dynamic.mBase;
|
||||
dynamic.mMod = 0.f;
|
||||
}
|
||||
for(std::size_t i = 0; i < 4; ++i)
|
||||
creatureStats.mAiSettings[i].mMod = 0.f;
|
||||
if(npcStats)
|
||||
|
Loading…
x
Reference in New Issue
Block a user