mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 12:23:53 +00:00
Issue #356: added function for fatigue term calculation
This commit is contained in:
parent
677158c477
commit
9dcf8939e9
2 changed files with 23 additions and 0 deletions
|
@ -1,5 +1,12 @@
|
|||
#include "creaturestats.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <components/esm_store/store.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
CreatureStats::CreatureStats()
|
||||
|
@ -55,4 +62,17 @@ namespace MWMechanics
|
|||
{
|
||||
return mAiSequence;
|
||||
}
|
||||
|
||||
float CreatureStats::getFatigueTerm() const
|
||||
{
|
||||
int max = getFatigue().getModified();
|
||||
int current = getFatigue().getCurrent();
|
||||
|
||||
float normalised = max==0 ? 1 : std::max (0.0f, static_cast<float> (current)/max);
|
||||
|
||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
|
||||
return store.gameSettings.find ("fFatigueBase")->getFloat()
|
||||
- store.gameSettings.find ("fFatigueMult")->getFloat() * (1-normalised);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,9 @@ namespace MWMechanics
|
|||
const AiSequence& getAiSequence() const;
|
||||
|
||||
AiSequence& getAiSequence();
|
||||
|
||||
float getFatigueTerm() const;
|
||||
///< Return effective fatigue
|
||||
};
|
||||
|
||||
// Inline const getters
|
||||
|
|
Loading…
Reference in a new issue