Fix fatigue not restoring when waiting

actorid
scrawl 11 years ago
parent ba27b693f8
commit 0d0005c433

@ -76,8 +76,9 @@ namespace MWBase
virtual void setPlayerClass (const ESM::Class& class_) = 0;
///< Set player class to custom class.
virtual void restoreDynamicStats() = 0;
///< If the player is sleeping, this should be called every hour.
virtual void rest(bool sleep) = 0;
///< If the player is sleeping or waiting, this should be called every hour.
/// @param sleep is the player sleeping or waiting?
virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0;
///< This is used by every service to determine the price of objects given the trading skills of the player and NPC.

@ -154,6 +154,8 @@ namespace MWGui
// advance time
MWBase::Environment::get().getWorld ()->advanceTime (2);
MWBase::Environment::get().getMechanicsManager()->rest(false);
MWBase::Environment::get().getMechanicsManager()->rest(false);
MWBase::Environment::get().getWorld ()->getFader()->fadeOut(0.25);
mFadeTimeRemaining = 0.5;

@ -148,7 +148,7 @@ namespace MWGui
int hours = static_cast<int>(d /MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fTravelTimeMult")->getFloat());
for(int i = 0;i < hours;i++)
{
MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats ();
MWBase::Environment::get().getMechanicsManager ()->rest (true);
}
MWBase::Environment::get().getWorld()->advanceTime(hours);

@ -253,8 +253,7 @@ namespace MWGui
if (mCurHour <= mHours)
{
MWBase::Environment::get().getWorld ()->advanceTime (1);
if (mSleeping)
MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats ();
MWBase::Environment::get().getMechanicsManager ()->rest (mSleeping);
}
}

@ -199,7 +199,7 @@ namespace MWMechanics
}
// fatigue restoration
calculateRestoration(ptr, duration);
calculateRestoration(ptr, duration, false);
}
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
@ -257,7 +257,7 @@ namespace MWMechanics
creatureStats.setFatigue(fatigue);
}
void Actors::calculateRestoration (const MWWorld::Ptr& ptr, float duration)
void Actors::calculateRestoration (const MWWorld::Ptr& ptr, float duration, bool sleep)
{
if (ptr.getClass().getCreatureStats(ptr).isDead())
return;
@ -272,10 +272,9 @@ namespace MWMechanics
if (normalizedEncumbrance > 1)
normalizedEncumbrance = 1;
if (duration == 3600)
if (sleep)
{
// the actor is sleeping, restore health and magicka
bool stunted = stats.getMagicEffects ().get(ESM::MagicEffect::StuntedMagicka).mMagnitude > 0;
DynamicStat<float> health = stats.getHealth();
@ -294,7 +293,6 @@ namespace MWMechanics
}
// restore fatigue
float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat ();
float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
float fEndFatigueMult = settings.find("fEndFatigueMult")->getFloat ();
@ -847,10 +845,10 @@ namespace MWMechanics
}
}
}
void Actors::restoreDynamicStats()
void Actors::restoreDynamicStats(bool sleep)
{
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
calculateRestoration(iter->first, 3600);
calculateRestoration(iter->first, 3600, sleep);
}
int Actors::countDeaths (const std::string& id) const

@ -36,7 +36,7 @@ namespace MWMechanics
void calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration);
void calculateNpcStatModifiers (const MWWorld::Ptr& ptr);
void calculateRestoration (const MWWorld::Ptr& ptr, float duration);
void calculateRestoration (const MWWorld::Ptr& ptr, float duration, bool sleep);
void updateDrowning (const MWWorld::Ptr& ptr, float duration);
@ -79,7 +79,7 @@ namespace MWMechanics
///< This function is normally called automatically during the update process, but it can
/// also be called explicitly at any time to force an update.
void restoreDynamicStats();
void restoreDynamicStats(bool sleep);
///< If the player is sleeping, this should be called every hour.
int countDeaths (const std::string& id) const;

@ -370,9 +370,9 @@ namespace MWMechanics
mObjects.update(duration, paused);
}
void MechanicsManager::restoreDynamicStats()
void MechanicsManager::rest(bool sleep)
{
mActors.restoreDynamicStats ();
mActors.restoreDynamicStats (sleep);
}
void MechanicsManager::setPlayerName (const std::string& name)

@ -81,8 +81,9 @@ namespace MWMechanics
virtual void setPlayerClass (const ESM::Class& class_);
///< Set player class to custom class.
virtual void restoreDynamicStats();
///< If the player is sleeping, this should be called every hour.
virtual void rest(bool sleep);
///< If the player is sleeping or waiting, this should be called every hour.
/// @param sleep is the player sleeping or waiting?
virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying);
///< This is used by every service to determine the price of objects given the trading skills of the player and NPC.

Loading…
Cancel
Save