mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-16 08:42:23 +00:00
commit
d7989ac778
@ -14,6 +14,7 @@
|
|||||||
Bug #2862: [macOS] Can't quit launcher using Command-Q or OpenMW->Quit
|
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 #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 #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 #3249: Fixed revert function not updating views properly
|
||||||
Bug #3374: Touch spells not hitting kwama foragers
|
Bug #3374: Touch spells not hitting kwama foragers
|
||||||
Bug #3486: [Mod] NPC Commands does not work
|
Bug #3486: [Mod] NPC Commands does not work
|
||||||
@ -33,6 +34,7 @@
|
|||||||
Bug #4215: OpenMW shows book text after last EOL tag
|
Bug #4215: OpenMW shows book text after last EOL tag
|
||||||
Bug #4221: Characters get stuck in V-shaped terrain
|
Bug #4221: Characters get stuck in V-shaped terrain
|
||||||
Bug #4230: AiTravel package issues break some Tribunal quests
|
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 #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 #4274: Pre-0.43 death animations are not forward-compatible with 0.43+
|
||||||
Bug #4286: Scripted animations can be interrupted
|
Bug #4286: Scripted animations can be interrupted
|
||||||
|
@ -546,7 +546,7 @@ namespace MWMechanics
|
|||||||
float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase();
|
float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase();
|
||||||
float currentToBaseRatio = (magicka.getCurrent() / magicka.getBase());
|
float currentToBaseRatio = (magicka.getCurrent() / magicka.getBase());
|
||||||
magicka.setModified(magicka.getModified() + diff, 0);
|
magicka.setModified(magicka.getModified() + diff, 0);
|
||||||
magicka.setCurrent(magicka.getBase() * currentToBaseRatio);
|
magicka.setCurrent(magicka.getBase() * currentToBaseRatio, false, true);
|
||||||
creatureStats.setMagicka(magicka);
|
creatureStats.setMagicka(magicka);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +578,13 @@ namespace MWMechanics
|
|||||||
if (normalizedEncumbrance > 1)
|
if (normalizedEncumbrance > 1)
|
||||||
normalizedEncumbrance = 1;
|
normalizedEncumbrance = 1;
|
||||||
|
|
||||||
// restore fatigue
|
// 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
|
||||||
float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat ();
|
float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat ();
|
||||||
float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
|
float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
|
||||||
float fEndFatigueMult = settings.find("fEndFatigueMult")->getFloat ();
|
float fEndFatigueMult = settings.find("fEndFatigueMult")->getFloat ();
|
||||||
@ -586,7 +592,6 @@ namespace MWMechanics
|
|||||||
float x = fFatigueReturnBase + fFatigueReturnMult * (1 - normalizedEncumbrance);
|
float x = fFatigueReturnBase + fFatigueReturnMult * (1 - normalizedEncumbrance);
|
||||||
x *= fEndFatigueMult * endurance;
|
x *= fEndFatigueMult * endurance;
|
||||||
|
|
||||||
DynamicStat<float> fatigue = stats.getFatigue();
|
|
||||||
fatigue.setCurrent (fatigue.getCurrent() + 3600 * x);
|
fatigue.setCurrent (fatigue.getCurrent() + 3600 * x);
|
||||||
stats.setFatigue (fatigue);
|
stats.setFatigue (fatigue);
|
||||||
}
|
}
|
||||||
@ -598,16 +603,20 @@ namespace MWMechanics
|
|||||||
|
|
||||||
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr);
|
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>();
|
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 fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat ();
|
||||||
static const float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
|
static const float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
|
||||||
|
|
||||||
float x = fFatigueReturnBase + fFatigueReturnMult * endurance;
|
float x = fFatigueReturnBase + fFatigueReturnMult * endurance;
|
||||||
|
|
||||||
DynamicStat<float> fatigue = stats.getFatigue();
|
|
||||||
fatigue.setCurrent (fatigue.getCurrent() + duration * x);
|
fatigue.setCurrent (fatigue.getCurrent() + duration * x);
|
||||||
stats.setFatigue (fatigue);
|
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
|
// attributes
|
||||||
for(int i = 0;i < ESM::Attribute::Length;++i)
|
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
|
// AI setting modifiers
|
||||||
int creature = !ptr.getClass().isNpc();
|
int creature = !ptr.getClass().isNpc();
|
||||||
if (creature && ptr.get<ESM::Creature>()->mBase->mData.mType == ESM::Creature::Humanoid)
|
if (creature && ptr.get<ESM::Creature>()->mBase->mData.mType == ESM::Creature::Humanoid)
|
||||||
|
@ -195,6 +195,7 @@ namespace MWMechanics
|
|||||||
mDead = true;
|
mDead = true;
|
||||||
|
|
||||||
mDynamic[index].setModifier(0);
|
mDynamic[index].setModifier(0);
|
||||||
|
mDynamic[index].setCurrentModifier(0);
|
||||||
mDynamic[index].setCurrent(0);
|
mDynamic[index].setCurrent(0);
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWorld()->getGodModeState())
|
if (MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Stat<T>::Stat() : mBase (0), mModified (0) {}
|
Stat<T>::Stat() : mBase (0), mModified (0), mCurrentModified (0) {}
|
||||||
template<typename T>
|
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>
|
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>
|
template<typename T>
|
||||||
const T& Stat<T>::getBase() const
|
const T& Stat<T>::getBase() const
|
||||||
@ -22,23 +22,42 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
return std::max(static_cast<T>(0), mModified);
|
return std::max(static_cast<T>(0), mModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T Stat<T>::getCurrentModified() const
|
||||||
|
{
|
||||||
|
return mCurrentModified;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T Stat<T>::getModifier() const
|
T Stat<T>::getModifier() const
|
||||||
{
|
{
|
||||||
return mModified-mBase;
|
return mModified-mBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T Stat<T>::getCurrentModifier() const
|
||||||
|
{
|
||||||
|
return mCurrentModified - mModified;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Stat<T>::set (const T& value)
|
void Stat<T>::set (const T& value)
|
||||||
{
|
{
|
||||||
|
T diff = value - mBase;
|
||||||
mBase = mModified = value;
|
mBase = mModified = value;
|
||||||
|
mCurrentModified += diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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;
|
||||||
mBase = value;
|
mBase = value;
|
||||||
mModified += diff;
|
mModified += diff;
|
||||||
|
mCurrentModified += diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Stat<T>::setModified (T value, const T& min, const T& max)
|
void Stat<T>::setModified (T value, const T& min, const T& max)
|
||||||
{
|
{
|
||||||
@ -57,24 +76,39 @@ namespace MWMechanics
|
|||||||
|
|
||||||
mModified = value;
|
mModified = value;
|
||||||
mBase += diff;
|
mBase += diff;
|
||||||
|
mCurrentModified += diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void Stat<T>::setCurrentModified(T value)
|
||||||
|
{
|
||||||
|
mCurrentModified = value;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Stat<T>::setModifier (const T& modifier)
|
void Stat<T>::setModifier (const T& modifier)
|
||||||
{
|
{
|
||||||
mModified = mBase + modifier;
|
mModified = mBase + modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void Stat<T>::setCurrentModifier(const T& modifier)
|
||||||
|
{
|
||||||
|
mCurrentModified = mModified + modifier;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Stat<T>::writeState (ESM::StatState<T>& state) const
|
void Stat<T>::writeState (ESM::StatState<T>& state) const
|
||||||
{
|
{
|
||||||
state.mBase = mBase;
|
state.mBase = mBase;
|
||||||
state.mMod = mModified;
|
state.mMod = mCurrentModified;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Stat<T>::readState (const ESM::StatState<T>& state)
|
void Stat<T>::readState (const ESM::StatState<T>& state)
|
||||||
{
|
{
|
||||||
mBase = state.mBase;
|
mBase = state.mBase;
|
||||||
mModified = state.mMod;
|
mModified = state.mBase;
|
||||||
|
mCurrentModified = state.mMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +132,12 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
return mStatic.getModified();
|
return mStatic.getModified();
|
||||||
}
|
}
|
||||||
|
template<typename T>
|
||||||
|
T DynamicStat<T>::getCurrentModified() const
|
||||||
|
{
|
||||||
|
return mStatic.getCurrentModified();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
const T& DynamicStat<T>::getCurrent() const
|
const T& DynamicStat<T>::getCurrent() const
|
||||||
{
|
{
|
||||||
@ -127,14 +167,21 @@ namespace MWMechanics
|
|||||||
mCurrent = getModified();
|
mCurrent = getModified();
|
||||||
}
|
}
|
||||||
template<typename T>
|
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)
|
if (value > mCurrent)
|
||||||
{
|
{
|
||||||
// increase
|
// increase
|
||||||
|
if (value <= getModified() || allowIncreaseAboveModified)
|
||||||
mCurrent = value;
|
mCurrent = value;
|
||||||
|
else if (mCurrent > getModified())
|
||||||
if (mCurrent > getModified())
|
return;
|
||||||
|
else
|
||||||
mCurrent = getModified();
|
mCurrent = getModified();
|
||||||
}
|
}
|
||||||
else if (value > 0 || allowDecreaseBelowZero)
|
else if (value > 0 || allowDecreaseBelowZero)
|
||||||
@ -156,6 +203,16 @@ namespace MWMechanics
|
|||||||
setCurrent (getCurrent()+diff, allowCurrentDecreaseBelowZero);
|
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>
|
template<typename T>
|
||||||
void DynamicStat<T>::writeState (ESM::StatState<T>& state) const
|
void DynamicStat<T>::writeState (ESM::StatState<T>& state) const
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
T mBase;
|
T mBase;
|
||||||
T mModified;
|
T mModified;
|
||||||
|
T mCurrentModified;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef T Type;
|
typedef T Type;
|
||||||
@ -28,7 +29,9 @@ namespace MWMechanics
|
|||||||
const T& getBase() const;
|
const T& getBase() const;
|
||||||
|
|
||||||
T getModified() const;
|
T getModified() const;
|
||||||
|
T getCurrentModified() const;
|
||||||
T getModifier() const;
|
T getModifier() const;
|
||||||
|
T getCurrentModifier() const;
|
||||||
|
|
||||||
/// Set base and modified to \a value.
|
/// Set base and modified to \a value.
|
||||||
void set (const T& value);
|
void set (const T& value);
|
||||||
@ -36,9 +39,15 @@ namespace MWMechanics
|
|||||||
/// Set base and adjust modified accordingly.
|
/// Set base and adjust modified accordingly.
|
||||||
void setBase (const T& value);
|
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 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 setModifier (const T& modifier);
|
||||||
|
void setCurrentModifier (const T& modifier);
|
||||||
|
|
||||||
void writeState (ESM::StatState<T>& state) const;
|
void writeState (ESM::StatState<T>& state) const;
|
||||||
void readState (const ESM::StatState<T>& state);
|
void readState (const ESM::StatState<T>& state);
|
||||||
@ -73,6 +82,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
const T& getBase() const;
|
const T& getBase() const;
|
||||||
T getModified() const;
|
T getModified() const;
|
||||||
|
T getCurrentModified() const;
|
||||||
const T& getCurrent() const;
|
const T& getCurrent() const;
|
||||||
|
|
||||||
/// Set base, modified and current to \a value.
|
/// Set base, modified and current to \a value.
|
||||||
@ -81,11 +91,16 @@ namespace MWMechanics
|
|||||||
/// Set base and adjust modified accordingly.
|
/// Set base and adjust modified accordingly.
|
||||||
void setBase (const T& value);
|
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 setModified (T value, const T& min, const T& max = std::numeric_limits<T>::max());
|
||||||
|
|
||||||
void setCurrent (const T& value, bool allowDecreaseBelowZero = false);
|
/// Set "current modified," used for drain and fortify. Unlike the regular modifier
|
||||||
void setModifier (const T& modifier, bool allowCurrentDecreaseBelowZero=false);
|
/// 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 writeState (ESM::StatState<T>& state) const;
|
||||||
void readState (const ESM::StatState<T>& state);
|
void readState (const ESM::StatState<T>& state);
|
||||||
|
@ -261,6 +261,7 @@ namespace MWScript
|
|||||||
.getDynamic (mIndex));
|
.getDynamic (mIndex));
|
||||||
|
|
||||||
stat.setModified (diff + stat.getModified(), 0);
|
stat.setModified (diff + stat.getModified(), 0);
|
||||||
|
stat.setCurrentModified (diff + stat.getCurrentModified());
|
||||||
|
|
||||||
stat.setCurrent (diff + current);
|
stat.setCurrent (diff + current);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user