mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 13:45:35 +00:00
Merge remote-tracking branch 'potatoesmaster/bug-664'
This commit is contained in:
commit
5dc1aceae1
7 changed files with 59 additions and 19 deletions
|
@ -109,6 +109,11 @@ namespace
|
|||
creatureStats.getAttribute(attribute).setBase ( std::min(creatureStats.getAttribute(attribute).getBase()
|
||||
+ static_cast<int>((level-1) * modifierSum+0.5), 100) );
|
||||
}
|
||||
|
||||
// initial health
|
||||
int strength = creatureStats.getAttribute(ESM::Attribute::Strength).getBase();
|
||||
int endurance = creatureStats.getAttribute(ESM::Attribute::Endurance).getBase();
|
||||
creatureStats.setHealth(static_cast<int> (0.5 * (strength + endurance)) + 4 * (creatureStats.getLevel() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -76,10 +76,6 @@ namespace MWMechanics
|
|||
double magickaFactor =
|
||||
creatureStats.getMagicEffects().get (EffectKey (ESM::MagicEffect::FortifyMaximumMagicka)).mMagnitude * 0.1 + 0.5;
|
||||
|
||||
DynamicStat<float> health = creatureStats.getHealth();
|
||||
health.setBase (static_cast<int> (0.5 * (strength + endurance)) + creatureStats.getLevelHealthBonus ());
|
||||
creatureStats.setHealth (health);
|
||||
|
||||
DynamicStat<float> magicka = creatureStats.getMagicka();
|
||||
magicka.setBase (static_cast<int> (intelligence + magickaFactor * intelligence));
|
||||
creatureStats.setMagicka (magicka);
|
||||
|
|
|
@ -18,16 +18,35 @@ namespace MWMechanics
|
|||
mAiSettings[i] = 0;
|
||||
}
|
||||
|
||||
void CreatureStats::increaseLevelHealthBonus (float value)
|
||||
{
|
||||
mLevelHealthBonus += value;
|
||||
}
|
||||
|
||||
float CreatureStats::getLevelHealthBonus () const
|
||||
{
|
||||
return mLevelHealthBonus;
|
||||
}
|
||||
|
||||
void CreatureStats::levelUp()
|
||||
{
|
||||
const MWWorld::Store<ESM::GameSetting> &gmst =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
||||
|
||||
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();
|
||||
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;
|
||||
|
|
|
@ -95,10 +95,14 @@ 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();
|
||||
|
||||
void updateHealth();
|
||||
///< Calculate health based on endurance and strength.
|
||||
/// Called at character creation and at level up.
|
||||
|
||||
bool isDead() const;
|
||||
|
||||
bool hasDied() const;
|
||||
|
|
|
@ -98,8 +98,8 @@ namespace MWMechanics
|
|||
public:
|
||||
typedef T Type;
|
||||
|
||||
DynamicStat() : mCurrent (0) {}
|
||||
DynamicStat(T current) : mCurrent (current) {}
|
||||
DynamicStat() : mStatic (0), mCurrent (0) {}
|
||||
DynamicStat(T base) : mStatic (base), mCurrent (base) {}
|
||||
DynamicStat(T base, T modified, T current) : mStatic(base, modified), mCurrent (current) {}
|
||||
DynamicStat(const Stat<T> &stat, T current) : mStatic(stat), mCurrent (current) {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue