mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 09:45:35 +00:00
Fix health calculation at character creation
This commit is contained in:
parent
1c330fc899
commit
48f0e64ec3
3 changed files with 34 additions and 2 deletions
|
@ -10,7 +10,10 @@
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
#include "../mwbase/mechanicsmanager.hpp"
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/fallback.hpp"
|
#include "../mwworld/fallback.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -41,6 +44,14 @@ namespace
|
||||||
// Note: Order is taken from http://www.uesp.net/wiki/Morrowind:Class_Quiz
|
// Note: Order is taken from http://www.uesp.net/wiki/Morrowind:Class_Quiz
|
||||||
unsigned int points[3];
|
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
|
namespace MWGui
|
||||||
|
@ -334,6 +345,8 @@ namespace MWGui
|
||||||
mCreationStage = CSE_ClassChosen;
|
mCreationStage = CSE_ClassChosen;
|
||||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePlayerHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::onPickClassDialogBack()
|
void CharacterCreation::onPickClassDialogBack()
|
||||||
|
@ -461,6 +474,8 @@ namespace MWGui
|
||||||
mCreationStage = CSE_RaceChosen;
|
mCreationStage = CSE_RaceChosen;
|
||||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePlayerHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
|
void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
|
||||||
|
@ -484,6 +499,8 @@ namespace MWGui
|
||||||
mCreationStage = CSE_BirthSignChosen;
|
mCreationStage = CSE_BirthSignChosen;
|
||||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePlayerHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::onBirthSignDialogBack()
|
void CharacterCreation::onBirthSignDialogBack()
|
||||||
|
@ -547,6 +564,8 @@ namespace MWGui
|
||||||
mCreationStage = CSE_ClassChosen;
|
mCreationStage = CSE_ClassChosen;
|
||||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePlayerHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::onCreateClassDialogBack()
|
void CharacterCreation::onCreateClassDialogBack()
|
||||||
|
@ -715,6 +734,8 @@ namespace MWGui
|
||||||
mCreationStage = CSE_ClassChosen;
|
mCreationStage = CSE_ClassChosen;
|
||||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatePlayerHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
CharacterCreation::~CharacterCreation()
|
CharacterCreation::~CharacterCreation()
|
||||||
|
|
|
@ -29,17 +29,24 @@ namespace MWMechanics
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||||
|
|
||||||
const int endurance = getAttribute(ESM::Attribute::Endurance).getBase();
|
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
|
// "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,
|
// will automatically increase by 10% of your Endurance attribute. If you increased Endurance this level,
|
||||||
// the Health increase is calculated from the increased Endurance"
|
// the Health increase is calculated from the increased Endurance"
|
||||||
mLevelHealthBonus += endurance * gmst.find("fLevelUpHealthEndMult")->getFloat();
|
mLevelHealthBonus += endurance * gmst.find("fLevelUpHealthEndMult")->getFloat();
|
||||||
setHealth(static_cast<int> (0.5 * (strength + endurance)) + mLevelHealthBonus);
|
updateHealth();
|
||||||
|
|
||||||
mLevel++;
|
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
|
const AiSequence& CreatureStats::getAiSequence() const
|
||||||
{
|
{
|
||||||
return mAiSequence;
|
return mAiSequence;
|
||||||
|
|
|
@ -99,6 +99,10 @@ namespace MWMechanics
|
||||||
|
|
||||||
void levelUp();
|
void levelUp();
|
||||||
|
|
||||||
|
void updateHealth();
|
||||||
|
///< Calculate health based on endurance and strength.
|
||||||
|
/// Called at character creation and at level up.
|
||||||
|
|
||||||
bool isDead() const;
|
bool isDead() const;
|
||||||
|
|
||||||
bool hasDied() const;
|
bool hasDied() const;
|
||||||
|
|
Loading…
Reference in a new issue