forked from mirror/openmw-tes3mp
Fix magicka and fatigue calculations from fortifying attributes
This commit is contained in:
parent
4dc032084c
commit
dc468dd139
4 changed files with 8 additions and 25 deletions
|
@ -425,7 +425,9 @@ namespace MWMechanics
|
||||||
|
|
||||||
DynamicStat<float> magicka = creatureStats.getMagicka();
|
DynamicStat<float> magicka = creatureStats.getMagicka();
|
||||||
float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase();
|
float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase();
|
||||||
magicka.modify(diff);
|
float currentToBaseRatio = (magicka.getCurrent() / magicka.getBase());
|
||||||
|
magicka.setModified(magicka.getModified() + diff, 0);
|
||||||
|
magicka.setCurrent(magicka.getBase() * currentToBaseRatio);
|
||||||
creatureStats.setMagicka(magicka);
|
creatureStats.setMagicka(magicka);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,8 +555,9 @@ namespace MWMechanics
|
||||||
DynamicStat<float> stat = creatureStats.getDynamic(i);
|
DynamicStat<float> stat = creatureStats.getDynamic(i);
|
||||||
stat.setModifier(effects.get(ESM::MagicEffect::FortifyHealth+i).getMagnitude() -
|
stat.setModifier(effects.get(ESM::MagicEffect::FortifyHealth+i).getMagnitude() -
|
||||||
effects.get(ESM::MagicEffect::DrainHealth+i).getMagnitude(),
|
effects.get(ESM::MagicEffect::DrainHealth+i).getMagnitude(),
|
||||||
|
// Magicka can be decreased below zero due to a fortify effect wearing off
|
||||||
// Fatigue can be decreased below zero meaning the actor will be knocked out
|
// Fatigue can be decreased below zero meaning the actor will be knocked out
|
||||||
i == 2);
|
i == 1 || i == 2);
|
||||||
|
|
||||||
creatureStats.setDynamic(i, stat);
|
creatureStats.setDynamic(i, stat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,9 @@ namespace MWMechanics
|
||||||
int endurance = getAttribute(ESM::Attribute::Endurance).getModified();
|
int endurance = getAttribute(ESM::Attribute::Endurance).getModified();
|
||||||
DynamicStat<float> fatigue = getFatigue();
|
DynamicStat<float> fatigue = getFatigue();
|
||||||
float diff = (strength+willpower+agility+endurance) - fatigue.getBase();
|
float diff = (strength+willpower+agility+endurance) - fatigue.getBase();
|
||||||
fatigue.modify(diff);
|
float currentToBaseRatio = (fatigue.getCurrent() / fatigue.getBase());
|
||||||
|
fatigue.setModified(fatigue.getModified() + diff, 0);
|
||||||
|
fatigue.setCurrent(fatigue.getBase() * currentToBaseRatio);
|
||||||
setFatigue(fatigue);
|
setFatigue(fatigue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,18 +33,6 @@ namespace MWMechanics
|
||||||
mBase = mModified = value;
|
mBase = mModified = value;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Stat<T>::modify(const T& diff)
|
|
||||||
{
|
|
||||||
mBase += diff;
|
|
||||||
if(mBase >= static_cast<T>(0))
|
|
||||||
mModified += diff;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mModified += diff - mBase;
|
|
||||||
mBase = static_cast<T>(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
void Stat<T>::setBase (const T& value)
|
void Stat<T>::setBase (const T& value)
|
||||||
{
|
{
|
||||||
T diff = value - mBase;
|
T diff = value - mBase;
|
||||||
|
@ -139,12 +127,6 @@ namespace MWMechanics
|
||||||
mCurrent = getModified();
|
mCurrent = getModified();
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void DynamicStat<T>::modify (const T& diff, bool allowCurrentDecreaseBelowZero)
|
|
||||||
{
|
|
||||||
mStatic.modify (diff);
|
|
||||||
setCurrent (getCurrent()+diff, allowCurrentDecreaseBelowZero);
|
|
||||||
}
|
|
||||||
template<typename T>
|
|
||||||
void DynamicStat<T>::setCurrent (const T& value, bool allowDecreaseBelowZero)
|
void DynamicStat<T>::setCurrent (const T& value, bool allowDecreaseBelowZero)
|
||||||
{
|
{
|
||||||
if (value > mCurrent)
|
if (value > mCurrent)
|
||||||
|
|
|
@ -32,7 +32,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
/// Set base and modified to \a value.
|
/// Set base and modified to \a value.
|
||||||
void set (const T& value);
|
void set (const T& value);
|
||||||
void modify(const T& diff);
|
|
||||||
|
|
||||||
/// Set base and adjust modified accordingly.
|
/// Set base and adjust modified accordingly.
|
||||||
void setBase (const T& value);
|
void setBase (const T& value);
|
||||||
|
@ -85,9 +84,6 @@ namespace MWMechanics
|
||||||
/// Set modified value an adjust base accordingly.
|
/// Set modified value an adjust base accordingly.
|
||||||
void setModified (T value, const T& min, const T& max = std::numeric_limits<T>::max());
|
void setModified (T value, const T& min, const T& max = std::numeric_limits<T>::max());
|
||||||
|
|
||||||
/// Change modified relatively.
|
|
||||||
void modify (const T& diff, bool allowCurrentDecreaseBelowZero=false);
|
|
||||||
|
|
||||||
void setCurrent (const T& value, bool allowDecreaseBelowZero = false);
|
void setCurrent (const T& value, bool allowDecreaseBelowZero = false);
|
||||||
void setModifier (const T& modifier, bool allowCurrentDecreaseBelowZero=false);
|
void setModifier (const T& modifier, bool allowCurrentDecreaseBelowZero=false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue