From 2a0644a7c34a99daed4b90a8e33282637744abf1 Mon Sep 17 00:00:00 2001 From: Emanuel Guevel Date: Sat, 20 Jul 2013 21:56:57 +0200 Subject: [PATCH] Move some levelup logic from mwgui to mwmechanics --- apps/openmw/mwgui/levelupdialog.cpp | 7 +------ apps/openmw/mwmechanics/creaturestats.cpp | 20 +++++++++++++++----- apps/openmw/mwmechanics/creaturestats.hpp | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 5857db4d2e..7c0191d495 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -173,12 +173,7 @@ namespace MWGui attribute.setBase(100); } - // "When you gain a level, in addition to increasing three primary attributes, your Health - // will automatically increase by 10% of your Endurance attribute. If you increased Endurance this level, - // the Health increase is calculated from the increased Endurance" - creatureStats.increaseLevelHealthBonus (creatureStats.getAttribute(ESM::Attribute::Endurance).getBase() * 0.1f); - - creatureStats.setLevel (creatureStats.getLevel()+1); + creatureStats.levelUp(); pcStats.levelUp (); MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Levelup); diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 19d2080211..e6e058ad9d 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -18,16 +18,26 @@ namespace MWMechanics mAiSettings[i] = 0; } - void CreatureStats::increaseLevelHealthBonus (float value) - { - mLevelHealthBonus += value; - } - float CreatureStats::getLevelHealthBonus () const { return mLevelHealthBonus; } + void CreatureStats::levelUp() + { + const MWWorld::Store &gmst = + MWBase::Environment::get().getWorld()->getStore().get(); + + const int endurance = getAttribute(ESM::Attribute::Endurance).getBase(); + + // "When you gain a level, in addition to increasing three primary attributes, your Health + // will automatically increase by 10% of your Endurance attribute. If you increased Endurance this level, + // the Health increase is calculated from the increased Endurance" + mLevelHealthBonus += endurance * gmst.find("fLevelUpHealthEndMult")->getFloat(); + + mLevel++; + } + const AiSequence& CreatureStats::getAiSequence() const { return mAiSequence; diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index 63de13d0d4..175f56e65b 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -95,10 +95,10 @@ namespace MWMechanics float getFatigueTerm() const; ///< Return effective fatigue - // small hack to allow the fact that Health permanently increases by 10% of endurance on each level up - void increaseLevelHealthBonus(float value); float getLevelHealthBonus() const; + void levelUp(); + bool isDead() const; bool hasDied() const;