1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 04:39:42 +00:00

Allow fatigue stat to become negative when fatigue damages are taken

This commit is contained in:
Emanuel Guevel 2013-12-09 21:13:06 +01:00
parent 77a2179d1e
commit fc8bd1aacb
3 changed files with 19 additions and 7 deletions

View file

@ -199,7 +199,7 @@ namespace MWClass
else
{
MWMechanics::DynamicStat<float> fatigue(getCreatureStats(ptr).getFatigue());
fatigue.setCurrent(fatigue.getCurrent() - damage);
fatigue.setCurrent(fatigue.getCurrent() - damage, true);
getCreatureStats(ptr).setFatigue(fatigue);
}
}

View file

@ -669,7 +669,7 @@ namespace MWClass
else
{
MWMechanics::DynamicStat<float> fatigue(getCreatureStats(ptr).getFatigue());
fatigue.setCurrent(fatigue.getCurrent() - damage);
fatigue.setCurrent(fatigue.getCurrent() - damage, true);
getCreatureStats(ptr).setFatigue(fatigue);
}
}

View file

@ -162,14 +162,26 @@ namespace MWMechanics
setCurrent (getCurrent()+diff);
}
void setCurrent (const T& value)
void setCurrent (const T& value, bool allowDecreaseBelowZero = false)
{
mCurrent = value;
if (value > mCurrent)
{
// increase
mCurrent = value;
if (mCurrent<0)
if (mCurrent > getModified())
mCurrent = getModified();
}
else if (value > 0 || allowDecreaseBelowZero)
{
// allowed decrease
mCurrent = value;
}
else if (mCurrent > 0)
{
// capped decrease
mCurrent = 0;
else if (mCurrent>getModified())
mCurrent = getModified();
}
}
void setModifier (const T& modifier)