Fix health calculation at character creation

actorid
Emanuel Guevel 12 years ago
parent 1c330fc899
commit 48f0e64ec3

@ -10,7 +10,10 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/fallback.hpp"
#include "../mwworld/player.hpp"
namespace
{
@ -41,6 +44,14 @@ namespace
// Note: Order is taken from http://www.uesp.net/wiki/Morrowind:Class_Quiz
unsigned int points[3];
};
void updatePlayerHealth()
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats(player);
creatureStats.updateHealth();
}
}
namespace MWGui
@ -334,6 +345,8 @@ namespace MWGui
mCreationStage = CSE_ClassChosen;
MWBase::Environment::get().getWindowManager()->popGuiMode();
}
updatePlayerHealth();
}
void CharacterCreation::onPickClassDialogBack()
@ -461,6 +474,8 @@ namespace MWGui
mCreationStage = CSE_RaceChosen;
MWBase::Environment::get().getWindowManager()->popGuiMode();
}
updatePlayerHealth();
}
void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
@ -484,6 +499,8 @@ namespace MWGui
mCreationStage = CSE_BirthSignChosen;
MWBase::Environment::get().getWindowManager()->popGuiMode();
}
updatePlayerHealth();
}
void CharacterCreation::onBirthSignDialogBack()
@ -547,6 +564,8 @@ namespace MWGui
mCreationStage = CSE_ClassChosen;
MWBase::Environment::get().getWindowManager()->popGuiMode();
}
updatePlayerHealth();
}
void CharacterCreation::onCreateClassDialogBack()
@ -715,6 +734,8 @@ namespace MWGui
mCreationStage = CSE_ClassChosen;
MWBase::Environment::get().getWindowManager()->popGuiMode();
}
updatePlayerHealth();
}
CharacterCreation::~CharacterCreation()

@ -29,17 +29,24 @@ namespace MWMechanics
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
const int endurance = getAttribute(ESM::Attribute::Endurance).getBase();
const int strength = getAttribute(ESM::Attribute::Strength).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();
setHealth(static_cast<int> (0.5 * (strength + endurance)) + mLevelHealthBonus);
updateHealth();
mLevel++;
}
void CreatureStats::updateHealth()
{
const int endurance = getAttribute(ESM::Attribute::Endurance).getBase();
const int strength = getAttribute(ESM::Attribute::Strength).getBase();
setHealth(static_cast<int> (0.5 * (strength + endurance)) + mLevelHealthBonus);
}
const AiSequence& CreatureStats::getAiSequence() const
{
return mAiSequence;

@ -99,6 +99,10 @@ namespace MWMechanics
void levelUp();
void updateHealth();
///< Calculate health based on endurance and strength.
/// Called at character creation and at level up.
bool isDead() const;
bool hasDied() const;

Loading…
Cancel
Save