mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
commit
d7989ac778
@ -14,6 +14,7 @@
|
||||
Bug #2862: [macOS] Can't quit launcher using Command-Q or OpenMW->Quit
|
||||
Bug #2872: Tab completion in console doesn't work with explicit reference
|
||||
Bug #2971: Compiler did not reject lines with naked expressions beginning with x.y
|
||||
Bug #3049: Drain and Fortify effects are not properly applied on health, magicka and fatigue
|
||||
Bug #3249: Fixed revert function not updating views properly
|
||||
Bug #3374: Touch spells not hitting kwama foragers
|
||||
Bug #3486: [Mod] NPC Commands does not work
|
||||
@ -33,6 +34,7 @@
|
||||
Bug #4215: OpenMW shows book text after last EOL tag
|
||||
Bug #4221: Characters get stuck in V-shaped terrain
|
||||
Bug #4230: AiTravel package issues break some Tribunal quests
|
||||
Bug #4231: Infected rats from the "Crimson Plague" quest rendered unconscious by change in Drain Fatigue functionality
|
||||
Bug #4251: Stationary NPCs do not return to their position after combat
|
||||
Bug #4274: Pre-0.43 death animations are not forward-compatible with 0.43+
|
||||
Bug #4286: Scripted animations can be interrupted
|
||||
|
@ -546,7 +546,7 @@ namespace MWMechanics
|
||||
float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase();
|
||||
float currentToBaseRatio = (magicka.getCurrent() / magicka.getBase());
|
||||
magicka.setModified(magicka.getModified() + diff, 0);
|
||||
magicka.setCurrent(magicka.getBase() * currentToBaseRatio);
|
||||
magicka.setCurrent(magicka.getBase() * currentToBaseRatio, false, true);
|
||||
creatureStats.setMagicka(magicka);
|
||||
}
|
||||
|
||||
@ -577,8 +577,14 @@ namespace MWMechanics
|
||||
float normalizedEncumbrance = ptr.getClass().getNormalizedEncumbrance(ptr);
|
||||
if (normalizedEncumbrance > 1)
|
||||
normalizedEncumbrance = 1;
|
||||
|
||||
// Current fatigue can be above base value due to a fortify effect.
|
||||
// In that case stop here and don't try to restore.
|
||||
DynamicStat<float> fatigue = stats.getFatigue();
|
||||
if (fatigue.getCurrent() >= fatigue.getBase())
|
||||
return;
|
||||
|
||||
// restore fatigue
|
||||
// Restore fatigue
|
||||
float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat ();
|
||||
float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
|
||||
float fEndFatigueMult = settings.find("fEndFatigueMult")->getFloat ();
|
||||
@ -586,7 +592,6 @@ namespace MWMechanics
|
||||
float x = fFatigueReturnBase + fFatigueReturnMult * (1 - normalizedEncumbrance);
|
||||
x *= fEndFatigueMult * endurance;
|
||||
|
||||
DynamicStat<float> fatigue = stats.getFatigue();
|
||||
fatigue.setCurrent (fatigue.getCurrent() + 3600 * x);
|
||||
stats.setFatigue (fatigue);
|
||||
}
|
||||
@ -598,16 +603,20 @@ namespace MWMechanics
|
||||
|
||||
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr);
|
||||
|
||||
int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified ();
|
||||
// Current fatigue can be above base value due to a fortify effect.
|
||||
// In that case stop here and don't try to restore.
|
||||
DynamicStat<float> fatigue = stats.getFatigue();
|
||||
if (fatigue.getCurrent() >= fatigue.getBase())
|
||||
return;
|
||||
|
||||
// restore fatigue
|
||||
// Restore fatigue
|
||||
int endurance = stats.getAttribute(ESM::Attribute::Endurance).getModified();
|
||||
const MWWorld::Store<ESM::GameSetting>& settings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
static const float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat ();
|
||||
static const float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
|
||||
|
||||
float x = fFatigueReturnBase + fFatigueReturnMult * endurance;
|
||||
|
||||
DynamicStat<float> fatigue = stats.getFatigue();
|
||||
fatigue.setCurrent (fatigue.getCurrent() + duration * x);
|
||||
stats.setFatigue (fatigue);
|
||||
}
|
||||
@ -688,6 +697,19 @@ namespace MWMechanics
|
||||
}
|
||||
}
|
||||
|
||||
// dynamic stats
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
DynamicStat<float> stat = creatureStats.getDynamic(i);
|
||||
stat.setCurrentModifier(effects.get(ESM::MagicEffect::FortifyHealth + 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
|
||||
i == 1 || i == 2);
|
||||
|
||||
creatureStats.setDynamic(i, stat);
|
||||
}
|
||||
|
||||
// attributes
|
||||
for(int i = 0;i < ESM::Attribute::Length;++i)
|
||||
{
|
||||
@ -719,19 +741,6 @@ namespace MWMechanics
|
||||
}
|
||||
}
|
||||
|
||||
// dynamic stats
|
||||
for(int i = 0;i < 3;++i)
|
||||
{
|
||||
DynamicStat<float> stat = creatureStats.getDynamic(i);
|
||||
stat.setModifier(effects.get(ESM::MagicEffect::FortifyHealth+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
|
||||
i == 1 || i == 2);
|
||||
|
||||
creatureStats.setDynamic(i, stat);
|
||||
}
|
||||
|
||||
// AI setting modifiers
|
||||
int creature = !ptr.getClass().isNpc();
|
||||
if (creature && ptr.get<ESM::Creature>()->mBase->mData.mType == ESM::Creature::Humanoid)
|
||||
|
@ -195,6 +195,7 @@ namespace MWMechanics
|
||||
mDead = true;
|
||||
|
||||
mDynamic[index].setModifier(0);
|
||||
mDynamic[index].setCurrentModifier(0);
|
||||
mDynamic[index].setCurrent(0);
|
||||
|
||||
if (MWBase::Environment::get().getWorld()->getGodModeState())
|
||||
|
@ -5,11 +5,11 @@
|
||||
namespace MWMechanics
|
||||
{
|
||||
template<typename T>
|
||||
Stat<T>::Stat() : mBase (0), mModified (0) {}
|
||||
Stat<T>::Stat() : mBase (0), mModified (0), mCurrentModified (0) {}
|
||||
template<typename T>
|
||||
Stat<T>::Stat(T base) : mBase (base), mModified (base) {}
|
||||
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) {}
|
||||
Stat<T>::Stat(T base, T modified) : mBase (base), mModified (modified), mCurrentModified (modified) {}
|
||||
|
||||
template<typename T>
|
||||
const T& Stat<T>::getBase() const
|
||||
@ -22,23 +22,42 @@ namespace MWMechanics
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -57,24 +76,39 @@ namespace MWMechanics
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Stat<T>::writeState (ESM::StatState<T>& state) const
|
||||
{
|
||||
state.mBase = mBase;
|
||||
state.mMod = mModified;
|
||||
state.mMod = mCurrentModified;
|
||||
}
|
||||
template<typename T>
|
||||
void Stat<T>::readState (const ESM::StatState<T>& state)
|
||||
{
|
||||
mBase = state.mBase;
|
||||
mModified = state.mMod;
|
||||
mModified = state.mBase;
|
||||
mCurrentModified = state.mMod;
|
||||
}
|
||||
|
||||
|
||||
@ -98,6 +132,12 @@ namespace MWMechanics
|
||||
{
|
||||
return mStatic.getModified();
|
||||
}
|
||||
template<typename T>
|
||||
T DynamicStat<T>::getCurrentModified() const
|
||||
{
|
||||
return mStatic.getCurrentModified();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T& DynamicStat<T>::getCurrent() const
|
||||
{
|
||||
@ -127,14 +167,21 @@ namespace MWMechanics
|
||||
mCurrent = getModified();
|
||||
}
|
||||
template<typename T>
|
||||
void DynamicStat<T>::setCurrent (const T& value, bool allowDecreaseBelowZero)
|
||||
void DynamicStat<T>::setCurrentModified(T value)
|
||||
{
|
||||
mStatic.setCurrentModified(value);
|
||||
}
|
||||
template<typename T>
|
||||
void DynamicStat<T>::setCurrent (const T& value, bool allowDecreaseBelowZero, bool allowIncreaseAboveModified)
|
||||
{
|
||||
if (value > mCurrent)
|
||||
{
|
||||
// increase
|
||||
mCurrent = value;
|
||||
|
||||
if (mCurrent > getModified())
|
||||
if (value <= getModified() || allowIncreaseAboveModified)
|
||||
mCurrent = value;
|
||||
else if (mCurrent > getModified())
|
||||
return;
|
||||
else
|
||||
mCurrent = getModified();
|
||||
}
|
||||
else if (value > 0 || allowDecreaseBelowZero)
|
||||
@ -156,6 +203,16 @@ namespace MWMechanics
|
||||
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
|
||||
{
|
||||
|
@ -17,6 +17,7 @@ namespace MWMechanics
|
||||
{
|
||||
T mBase;
|
||||
T mModified;
|
||||
T mCurrentModified;
|
||||
|
||||
public:
|
||||
typedef T Type;
|
||||
@ -28,7 +29,9 @@ namespace MWMechanics
|
||||
const T& getBase() const;
|
||||
|
||||
T getModified() const;
|
||||
T getCurrentModified() const;
|
||||
T getModifier() const;
|
||||
T getCurrentModifier() const;
|
||||
|
||||
/// Set base and modified to \a value.
|
||||
void set (const T& value);
|
||||
@ -36,9 +39,15 @@ namespace MWMechanics
|
||||
/// Set base and adjust modified accordingly.
|
||||
void setBase (const T& value);
|
||||
|
||||
/// Set modified value an adjust base accordingly.
|
||||
/// 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 writeState (ESM::StatState<T>& state) const;
|
||||
void readState (const ESM::StatState<T>& state);
|
||||
@ -73,6 +82,7 @@ namespace MWMechanics
|
||||
|
||||
const T& getBase() const;
|
||||
T getModified() const;
|
||||
T getCurrentModified() const;
|
||||
const T& getCurrent() const;
|
||||
|
||||
/// Set base, modified and current to \a value.
|
||||
@ -81,11 +91,16 @@ namespace MWMechanics
|
||||
/// Set base and adjust modified accordingly.
|
||||
void setBase (const T& value);
|
||||
|
||||
/// Set modified value an adjust base accordingly.
|
||||
/// Set modified value and adjust base accordingly.
|
||||
void setModified (T value, const T& min, const T& max = std::numeric_limits<T>::max());
|
||||
|
||||
void setCurrent (const T& value, bool allowDecreaseBelowZero = false);
|
||||
void setModifier (const T& modifier, bool allowCurrentDecreaseBelowZero=false);
|
||||
/// 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 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);
|
||||
|
||||
void writeState (ESM::StatState<T>& state) const;
|
||||
void readState (const ESM::StatState<T>& state);
|
||||
|
@ -261,6 +261,7 @@ namespace MWScript
|
||||
.getDynamic (mIndex));
|
||||
|
||||
stat.setModified (diff + stat.getModified(), 0);
|
||||
stat.setCurrentModified (diff + stat.getCurrentModified());
|
||||
|
||||
stat.setCurrent (diff + current);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user