forked from teamnwah/openmw-tes3coop
Use separate function for fatigue restoration during resting/waiting
This commit is contained in:
parent
103325bfb8
commit
fc618cb3ea
2 changed files with 27 additions and 5 deletions
|
@ -184,7 +184,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
calculateCreatureStatModifiers (ptr, duration);
|
calculateCreatureStatModifiers (ptr, duration);
|
||||||
// fatigue restoration
|
// fatigue restoration
|
||||||
calculateRestoration(ptr, duration, false);
|
calculateRestoration(ptr, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::engageCombat (const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer)
|
void Actors::engageCombat (const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer)
|
||||||
|
@ -293,7 +293,7 @@ namespace MWMechanics
|
||||||
creatureStats.setFatigue(fatigue);
|
creatureStats.setFatigue(fatigue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::calculateRestoration (const MWWorld::Ptr& ptr, float duration, bool sleep)
|
void Actors::restoreDynamicStats (const MWWorld::Ptr& ptr, bool sleep)
|
||||||
{
|
{
|
||||||
if (ptr.getClass().getCreatureStats(ptr).isDead())
|
if (ptr.getClass().getCreatureStats(ptr).isDead())
|
||||||
return;
|
return;
|
||||||
|
@ -331,10 +331,30 @@ 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);
|
||||||
|
stats.setFatigue (fatigue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Actors::calculateRestoration (const MWWorld::Ptr& ptr, float duration)
|
||||||
|
{
|
||||||
|
if (ptr.getClass().getCreatureStats(ptr).isDead())
|
||||||
|
return;
|
||||||
|
|
||||||
|
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr);
|
||||||
|
const MWWorld::Store<ESM::GameSetting>& settings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
|
||||||
|
int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified ();
|
||||||
|
|
||||||
|
// restore fatigue
|
||||||
|
float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat ();
|
||||||
|
float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
|
||||||
|
|
||||||
|
float x = fFatigueReturnBase + fFatigueReturnMult * endurance;
|
||||||
|
|
||||||
DynamicStat<float> fatigue = stats.getFatigue();
|
DynamicStat<float> fatigue = stats.getFatigue();
|
||||||
fatigue.setCurrent (fatigue.getCurrent() + duration * x);
|
fatigue.setCurrent (fatigue.getCurrent() + duration * x);
|
||||||
stats.setFatigue (fatigue);
|
stats.setFatigue (fatigue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration)
|
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration)
|
||||||
|
@ -1206,7 +1226,7 @@ namespace MWMechanics
|
||||||
void Actors::restoreDynamicStats(bool sleep)
|
void Actors::restoreDynamicStats(bool sleep)
|
||||||
{
|
{
|
||||||
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||||
calculateRestoration(iter->first, 3600, sleep);
|
restoreDynamicStats(iter->first, sleep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Actors::getHoursToRest(const MWWorld::Ptr &ptr) const
|
int Actors::getHoursToRest(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace MWMechanics
|
||||||
void calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration);
|
void calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration);
|
||||||
void calculateNpcStatModifiers (const MWWorld::Ptr& ptr);
|
void calculateNpcStatModifiers (const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
void calculateRestoration (const MWWorld::Ptr& ptr, float duration, bool sleep);
|
void calculateRestoration (const MWWorld::Ptr& ptr, float duration);
|
||||||
|
|
||||||
void updateDrowning (const MWWorld::Ptr& ptr, float duration);
|
void updateDrowning (const MWWorld::Ptr& ptr, float duration);
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@ namespace MWMechanics
|
||||||
void restoreDynamicStats(bool sleep);
|
void restoreDynamicStats(bool sleep);
|
||||||
///< If the player is sleeping, this should be called every hour.
|
///< If the player is sleeping, this should be called every hour.
|
||||||
|
|
||||||
|
void restoreDynamicStats(const MWWorld::Ptr& actor, bool sleep);
|
||||||
|
|
||||||
int getHoursToRest(const MWWorld::Ptr& ptr) const;
|
int getHoursToRest(const MWWorld::Ptr& ptr) const;
|
||||||
///< Calculate how many hours the given actor needs to rest in order to be fully healed
|
///< Calculate how many hours the given actor needs to rest in order to be fully healed
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue