forked from mirror/openmw-tes3mp
Fix fatigue not restoring when waiting
This commit is contained in:
parent
ba27b693f8
commit
0d0005c433
8 changed files with 19 additions and 18 deletions
|
@ -76,8 +76,9 @@ namespace MWBase
|
||||||
virtual void setPlayerClass (const ESM::Class& class_) = 0;
|
virtual void setPlayerClass (const ESM::Class& class_) = 0;
|
||||||
///< Set player class to custom class.
|
///< Set player class to custom class.
|
||||||
|
|
||||||
virtual void restoreDynamicStats() = 0;
|
virtual void rest(bool sleep) = 0;
|
||||||
///< If the player is sleeping, this should be called every hour.
|
///< 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;
|
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.
|
///< 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
|
// advance time
|
||||||
MWBase::Environment::get().getWorld ()->advanceTime (2);
|
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);
|
MWBase::Environment::get().getWorld ()->getFader()->fadeOut(0.25);
|
||||||
mFadeTimeRemaining = 0.5;
|
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());
|
int hours = static_cast<int>(d /MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fTravelTimeMult")->getFloat());
|
||||||
for(int i = 0;i < hours;i++)
|
for(int i = 0;i < hours;i++)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats ();
|
MWBase::Environment::get().getMechanicsManager ()->rest (true);
|
||||||
}
|
}
|
||||||
MWBase::Environment::get().getWorld()->advanceTime(hours);
|
MWBase::Environment::get().getWorld()->advanceTime(hours);
|
||||||
|
|
||||||
|
|
|
@ -253,8 +253,7 @@ namespace MWGui
|
||||||
if (mCurHour <= mHours)
|
if (mCurHour <= mHours)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld ()->advanceTime (1);
|
MWBase::Environment::get().getWorld ()->advanceTime (1);
|
||||||
if (mSleeping)
|
MWBase::Environment::get().getMechanicsManager ()->rest (mSleeping);
|
||||||
MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
// fatigue restoration
|
// fatigue restoration
|
||||||
calculateRestoration(ptr, duration);
|
calculateRestoration(ptr, duration, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
||||||
|
@ -257,7 +257,7 @@ namespace MWMechanics
|
||||||
creatureStats.setFatigue(fatigue);
|
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())
|
if (ptr.getClass().getCreatureStats(ptr).isDead())
|
||||||
return;
|
return;
|
||||||
|
@ -272,10 +272,9 @@ namespace MWMechanics
|
||||||
if (normalizedEncumbrance > 1)
|
if (normalizedEncumbrance > 1)
|
||||||
normalizedEncumbrance = 1;
|
normalizedEncumbrance = 1;
|
||||||
|
|
||||||
if (duration == 3600)
|
if (sleep)
|
||||||
{
|
{
|
||||||
// the actor is sleeping, restore health and magicka
|
// the actor is sleeping, restore health and magicka
|
||||||
|
|
||||||
bool stunted = stats.getMagicEffects ().get(ESM::MagicEffect::StuntedMagicka).mMagnitude > 0;
|
bool stunted = stats.getMagicEffects ().get(ESM::MagicEffect::StuntedMagicka).mMagnitude > 0;
|
||||||
|
|
||||||
DynamicStat<float> health = stats.getHealth();
|
DynamicStat<float> health = stats.getHealth();
|
||||||
|
@ -294,7 +293,6 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore fatigue
|
// 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 ();
|
||||||
|
@ -847,10 +845,10 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Actors::restoreDynamicStats()
|
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);
|
calculateRestoration(iter->first, 3600, sleep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Actors::countDeaths (const std::string& id) const
|
int Actors::countDeaths (const std::string& id) 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);
|
void calculateRestoration (const MWWorld::Ptr& ptr, float duration, bool sleep);
|
||||||
|
|
||||||
void updateDrowning (const MWWorld::Ptr& ptr, float duration);
|
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
|
///< This function is normally called automatically during the update process, but it can
|
||||||
/// also be called explicitly at any time to force an update.
|
/// 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.
|
///< If the player is sleeping, this should be called every hour.
|
||||||
|
|
||||||
int countDeaths (const std::string& id) const;
|
int countDeaths (const std::string& id) const;
|
||||||
|
|
|
@ -370,9 +370,9 @@ namespace MWMechanics
|
||||||
mObjects.update(duration, paused);
|
mObjects.update(duration, paused);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::restoreDynamicStats()
|
void MechanicsManager::rest(bool sleep)
|
||||||
{
|
{
|
||||||
mActors.restoreDynamicStats ();
|
mActors.restoreDynamicStats (sleep);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::setPlayerName (const std::string& name)
|
void MechanicsManager::setPlayerName (const std::string& name)
|
||||||
|
|
|
@ -81,8 +81,9 @@ namespace MWMechanics
|
||||||
virtual void setPlayerClass (const ESM::Class& class_);
|
virtual void setPlayerClass (const ESM::Class& class_);
|
||||||
///< Set player class to custom class.
|
///< Set player class to custom class.
|
||||||
|
|
||||||
virtual void restoreDynamicStats();
|
virtual void rest(bool sleep);
|
||||||
///< If the player is sleeping, this should be called every hour.
|
///< 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);
|
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.
|
///< This is used by every service to determine the price of objects given the trading skills of the player and NPC.
|
||||||
|
|
Loading…
Reference in a new issue