Reuse health of previous level rather than recalculating initial health (Fixes #1787)

deque
scrawl 11 years ago
parent 399fa90ef1
commit 4138c3e966

@ -34,7 +34,6 @@ MWMechanics::NpcStats::NpcStats()
, mProfit(0)
, mTimeToStartDrowning(20.0)
, mLastDrowningHit(0)
, mLevelHealthBonus(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
// 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();
setHealth(getHealth().getBase() + endurance * gmst.find("fLevelUpHealthEndMult")->getFloat());
setLevel(getLevel()+1);
}
@ -273,7 +271,7 @@ void MWMechanics::NpcStats::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);
setHealth(static_cast<int> (0.5 * (strength + endurance)));
}
int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const
@ -497,7 +495,6 @@ void MWMechanics::NpcStats::writeState (ESM::NpcStats& state) const
state.mTimeToStartDrowning = mTimeToStartDrowning;
state.mLastDrowningHit = mLastDrowningHit;
state.mLevelHealthBonus = mLevelHealthBonus;
}
void MWMechanics::NpcStats::readState (const ESM::NpcStats& state)
@ -549,5 +546,4 @@ void MWMechanics::NpcStats::readState (const ESM::NpcStats& state)
mTimeToStartDrowning = state.mTimeToStartDrowning;
mLastDrowningHit = state.mLastDrowningHit;
mLevelHealthBonus = state.mLevelHealthBonus;
}

@ -52,8 +52,6 @@ namespace MWMechanics
/// time since last hit from drowning
float mLastDrowningHit;
float mLevelHealthBonus;
public:
NpcStats();
@ -104,7 +102,7 @@ namespace MWMechanics
void updateHealth();
///< 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);

@ -78,8 +78,9 @@ void ESM::NpcStats::load (ESMReader &esm)
mLastDrowningHit = 0;
esm.getHNOT (mLastDrowningHit, "DRLH");
mLevelHealthBonus = 0;
esm.getHNOT (mLevelHealthBonus, "LVLH");
// No longer used
float levelHealthBonus = 0;
esm.getHNOT (levelHealthBonus, "LVLH");
mCrimeId = -1;
esm.getHNOT (mCrimeId, "CRID");
@ -148,9 +149,6 @@ void ESM::NpcStats::save (ESMWriter &esm) const
if (mLastDrowningHit)
esm.writeHNT ("DRLH", mLastDrowningHit);
if (mLevelHealthBonus)
esm.writeHNT ("LVLH", mLevelHealthBonus);
if (mCrimeId != -1)
esm.writeHNT ("CRID", mCrimeId);
}

@ -46,7 +46,6 @@ namespace ESM
std::vector<std::string> mUsedIds;
float mTimeToStartDrowning;
float mLastDrowningHit;
float mLevelHealthBonus;
int mCrimeId;
void load (ESMReader &esm);

Loading…
Cancel
Save