From 9dcf8939e96edd7e1b988b8d5d65af9357b256ae Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 10:45:32 +0200 Subject: [PATCH] Issue #356: added function for fatigue term calculation --- apps/openmw/mwmechanics/creaturestats.cpp | 20 ++++++++++++++++++++ apps/openmw/mwmechanics/creaturestats.hpp | 3 +++ 2 files changed, 23 insertions(+) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 09603bff26..49e5bb3900 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -1,5 +1,12 @@ #include "creaturestats.hpp" +#include + +#include + +#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 (current)/max); + + const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + + return store.gameSettings.find ("fFatigueBase")->getFloat() + - store.gameSettings.find ("fFatigueMult")->getFloat() * (1-normalised); + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index d19972e7b5..bb6ec94515 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -106,6 +106,9 @@ namespace MWMechanics const AiSequence& getAiSequence() const; AiSequence& getAiSequence(); + + float getFatigueTerm() const; + ///< Return effective fatigue }; // Inline const getters