mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 15:45:33 +00:00
Reuse health of previous level rather than recalculating initial health (Fixes #1787)
This commit is contained in:
parent
399fa90ef1
commit
4138c3e966
4 changed files with 6 additions and 15 deletions
|
@ -34,7 +34,6 @@ MWMechanics::NpcStats::NpcStats()
|
||||||
, mProfit(0)
|
, mProfit(0)
|
||||||
, mTimeToStartDrowning(20.0)
|
, mTimeToStartDrowning(20.0)
|
||||||
, mLastDrowningHit(0)
|
, mLastDrowningHit(0)
|
||||||
, mLevelHealthBonus(0)
|
|
||||||
{
|
{
|
||||||
mSkillIncreases.resize (ESM::Attribute::Length, 0);
|
mSkillIncreases.resize (ESM::Attribute::Length, 0);
|
||||||
}
|
}
|
||||||
|
@ -262,8 +261,7 @@ void MWMechanics::NpcStats::levelUp()
|
||||||
// "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();
|
setHealth(getHealth().getBase() + endurance * gmst.find("fLevelUpHealthEndMult")->getFloat());
|
||||||
updateHealth();
|
|
||||||
|
|
||||||
setLevel(getLevel()+1);
|
setLevel(getLevel()+1);
|
||||||
}
|
}
|
||||||
|
@ -273,7 +271,7 @@ void MWMechanics::NpcStats::updateHealth()
|
||||||
const int endurance = getAttribute(ESM::Attribute::Endurance).getBase();
|
const int endurance = getAttribute(ESM::Attribute::Endurance).getBase();
|
||||||
const int strength = getAttribute(ESM::Attribute::Strength).getBase();
|
const int strength = getAttribute(ESM::Attribute::Strength).getBase();
|
||||||
|
|
||||||
setHealth(static_cast<int> (0.5 * (strength + endurance)) + mLevelHealthBonus);
|
setHealth(static_cast<int> (0.5 * (strength + endurance)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const
|
int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const
|
||||||
|
@ -497,7 +495,6 @@ void MWMechanics::NpcStats::writeState (ESM::NpcStats& state) const
|
||||||
|
|
||||||
state.mTimeToStartDrowning = mTimeToStartDrowning;
|
state.mTimeToStartDrowning = mTimeToStartDrowning;
|
||||||
state.mLastDrowningHit = mLastDrowningHit;
|
state.mLastDrowningHit = mLastDrowningHit;
|
||||||
state.mLevelHealthBonus = mLevelHealthBonus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWMechanics::NpcStats::readState (const ESM::NpcStats& state)
|
void MWMechanics::NpcStats::readState (const ESM::NpcStats& state)
|
||||||
|
@ -549,5 +546,4 @@ void MWMechanics::NpcStats::readState (const ESM::NpcStats& state)
|
||||||
|
|
||||||
mTimeToStartDrowning = state.mTimeToStartDrowning;
|
mTimeToStartDrowning = state.mTimeToStartDrowning;
|
||||||
mLastDrowningHit = state.mLastDrowningHit;
|
mLastDrowningHit = state.mLastDrowningHit;
|
||||||
mLevelHealthBonus = state.mLevelHealthBonus;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,6 @@ namespace MWMechanics
|
||||||
/// time since last hit from drowning
|
/// time since last hit from drowning
|
||||||
float mLastDrowningHit;
|
float mLastDrowningHit;
|
||||||
|
|
||||||
float mLevelHealthBonus;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NpcStats();
|
NpcStats();
|
||||||
|
@ -104,7 +102,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
void updateHealth();
|
void updateHealth();
|
||||||
///< Calculate health based on endurance and strength.
|
///< Calculate health based on endurance and strength.
|
||||||
/// Called at character creation and at level up.
|
/// Called at character creation.
|
||||||
|
|
||||||
void flagAsUsed (const std::string& id);
|
void flagAsUsed (const std::string& id);
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,9 @@ void ESM::NpcStats::load (ESMReader &esm)
|
||||||
mLastDrowningHit = 0;
|
mLastDrowningHit = 0;
|
||||||
esm.getHNOT (mLastDrowningHit, "DRLH");
|
esm.getHNOT (mLastDrowningHit, "DRLH");
|
||||||
|
|
||||||
mLevelHealthBonus = 0;
|
// No longer used
|
||||||
esm.getHNOT (mLevelHealthBonus, "LVLH");
|
float levelHealthBonus = 0;
|
||||||
|
esm.getHNOT (levelHealthBonus, "LVLH");
|
||||||
|
|
||||||
mCrimeId = -1;
|
mCrimeId = -1;
|
||||||
esm.getHNOT (mCrimeId, "CRID");
|
esm.getHNOT (mCrimeId, "CRID");
|
||||||
|
@ -148,9 +149,6 @@ void ESM::NpcStats::save (ESMWriter &esm) const
|
||||||
if (mLastDrowningHit)
|
if (mLastDrowningHit)
|
||||||
esm.writeHNT ("DRLH", mLastDrowningHit);
|
esm.writeHNT ("DRLH", mLastDrowningHit);
|
||||||
|
|
||||||
if (mLevelHealthBonus)
|
|
||||||
esm.writeHNT ("LVLH", mLevelHealthBonus);
|
|
||||||
|
|
||||||
if (mCrimeId != -1)
|
if (mCrimeId != -1)
|
||||||
esm.writeHNT ("CRID", mCrimeId);
|
esm.writeHNT ("CRID", mCrimeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ namespace ESM
|
||||||
std::vector<std::string> mUsedIds;
|
std::vector<std::string> mUsedIds;
|
||||||
float mTimeToStartDrowning;
|
float mTimeToStartDrowning;
|
||||||
float mLastDrowningHit;
|
float mLastDrowningHit;
|
||||||
float mLevelHealthBonus;
|
|
||||||
int mCrimeId;
|
int mCrimeId;
|
||||||
|
|
||||||
void load (ESMReader &esm);
|
void load (ESMReader &esm);
|
||||||
|
|
Loading…
Reference in a new issue