|
|
|
@ -82,6 +82,23 @@ bool disintegrateSlot (MWWorld::Ptr ptr, int slot, float disintegrate)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getRestorationPerHourOfSleep (const MWWorld::Ptr& ptr, float& health, float& magicka)
|
|
|
|
|
{
|
|
|
|
|
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr);
|
|
|
|
|
const MWWorld::Store<ESM::GameSetting>& settings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
|
|
|
|
|
|
|
|
bool stunted = stats.getMagicEffects ().get(ESM::MagicEffect::StuntedMagicka).mMagnitude > 0;
|
|
|
|
|
int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified ();
|
|
|
|
|
|
|
|
|
|
health = 0.1 * endurance;
|
|
|
|
|
|
|
|
|
|
magicka = 0;
|
|
|
|
|
if (!stunted)
|
|
|
|
|
{
|
|
|
|
|
float fRestMagicMult = settings.find("fRestMagicMult")->getFloat ();
|
|
|
|
|
magicka = fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -261,37 +278,32 @@ namespace MWMechanics
|
|
|
|
|
{
|
|
|
|
|
if (ptr.getClass().getCreatureStats(ptr).isDead())
|
|
|
|
|
return;
|
|
|
|
|
CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
|
|
|
const MWWorld::Store<ESM::GameSetting>& settings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
|
|
|
|
|
|
|
|
int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified ();
|
|
|
|
|
|
|
|
|
|
float capacity = MWWorld::Class::get(ptr).getCapacity(ptr);
|
|
|
|
|
float encumbrance = MWWorld::Class::get(ptr).getEncumbrance(ptr);
|
|
|
|
|
float normalizedEncumbrance = (capacity == 0 ? 1 : encumbrance/capacity);
|
|
|
|
|
if (normalizedEncumbrance > 1)
|
|
|
|
|
normalizedEncumbrance = 1;
|
|
|
|
|
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr);
|
|
|
|
|
const MWWorld::Store<ESM::GameSetting>& settings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
health.setCurrent (health.getCurrent() + 0.1 * endurance);
|
|
|
|
|
stats.setHealth (health);
|
|
|
|
|
float health, magicka;
|
|
|
|
|
getRestorationPerHourOfSleep(ptr, health, magicka);
|
|
|
|
|
|
|
|
|
|
if (!stunted)
|
|
|
|
|
{
|
|
|
|
|
float fRestMagicMult = settings.find("fRestMagicMult")->getFloat ();
|
|
|
|
|
DynamicStat<float> stat = stats.getHealth();
|
|
|
|
|
stat.setCurrent(stat.getCurrent() + health);
|
|
|
|
|
stats.setHealth(stat);
|
|
|
|
|
|
|
|
|
|
DynamicStat<float> magicka = stats.getMagicka();
|
|
|
|
|
magicka.setCurrent (magicka.getCurrent()
|
|
|
|
|
+ fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified());
|
|
|
|
|
stats.setMagicka (magicka);
|
|
|
|
|
}
|
|
|
|
|
stat = stats.getMagicka();
|
|
|
|
|
stat.setCurrent(stat.getCurrent() + magicka);
|
|
|
|
|
stats.setMagicka(stat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified ();
|
|
|
|
|
|
|
|
|
|
float capacity = ptr.getClass().getCapacity(ptr);
|
|
|
|
|
float encumbrance = ptr.getClass().getEncumbrance(ptr);
|
|
|
|
|
float normalizedEncumbrance = (capacity == 0 ? 1 : encumbrance/capacity);
|
|
|
|
|
if (normalizedEncumbrance > 1)
|
|
|
|
|
normalizedEncumbrance = 1;
|
|
|
|
|
|
|
|
|
|
// restore fatigue
|
|
|
|
|
float fFatigueReturnBase = settings.find("fFatigueReturnBase")->getFloat ();
|
|
|
|
|
float fFatigueReturnMult = settings.find("fFatigueReturnMult")->getFloat ();
|
|
|
|
@ -303,6 +315,7 @@ namespace MWMechanics
|
|
|
|
|
DynamicStat<float> fatigue = stats.getFatigue();
|
|
|
|
|
fatigue.setCurrent (fatigue.getCurrent() + duration * x);
|
|
|
|
|
stats.setFatigue (fatigue);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration)
|
|
|
|
@ -851,6 +864,24 @@ namespace MWMechanics
|
|
|
|
|
calculateRestoration(iter->first, 3600, sleep);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Actors::getHoursToRest(const MWWorld::Ptr &ptr) const
|
|
|
|
|
{
|
|
|
|
|
float healthPerHour, magickaPerHour;
|
|
|
|
|
getRestorationPerHourOfSleep(ptr, healthPerHour, magickaPerHour);
|
|
|
|
|
|
|
|
|
|
CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
|
|
|
|
|
|
|
|
|
|
float healthHours = healthPerHour >= 0
|
|
|
|
|
? (stats.getHealth().getModified() - stats.getHealth().getCurrent()) / healthPerHour
|
|
|
|
|
: 1.0f;
|
|
|
|
|
float magickaHours = magickaPerHour >= 0
|
|
|
|
|
? (stats.getMagicka().getModified() - stats.getMagicka().getCurrent()) / magickaPerHour
|
|
|
|
|
: 1.0f;
|
|
|
|
|
|
|
|
|
|
int autoHours = std::ceil(std::max(1.f, std::max(healthHours, magickaHours)));
|
|
|
|
|
return autoHours;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Actors::countDeaths (const std::string& id) const
|
|
|
|
|
{
|
|
|
|
|
std::map<std::string, int>::const_iterator iter = mDeathCount.find(id);
|
|
|
|
|