Don't touch base stats when turning into a werewolf

This commit is contained in:
Evil Eye 2021-12-27 00:47:33 +01:00
parent c166341ec0
commit debdcf2953
7 changed files with 83 additions and 44 deletions

View file

@ -44,13 +44,43 @@ void ESM::Player::load (ESMReader &esm)
checkPrevItems = false;
}
bool intFallback = esm.getFormat() < 11;
if (esm.hasMoreSubs())
if(esm.getFormat() < 19)
{
for (int i=0; i<ESM::Attribute::Length; ++i)
mSaveAttributes[i].load(esm, intFallback);
for (int i=0; i<ESM::Skill::Length; ++i)
mSaveSkills[i].load(esm, intFallback);
bool intFallback = esm.getFormat() < 11;
bool clearModified = esm.getFormat() < 17 && !mObject.mNpcStats.mIsWerewolf;
if (esm.hasMoreSubs())
{
for (int i=0; i<ESM::Attribute::Length; ++i)
{
StatState<float> attribute;
attribute.load(esm, intFallback);
if (clearModified)
attribute.mMod = 0.f;
mSaveAttributes[i] = attribute.mBase + attribute.mMod - attribute.mDamage;
if (mObject.mNpcStats.mIsWerewolf)
mObject.mCreatureStats.mAttributes[i] = attribute;
}
for (int i=0; i<ESM::Skill::Length; ++i)
{
StatState<float> skill;
skill.load(esm, intFallback);
if (clearModified)
skill.mMod = 0.f;
mSaveSkills[i] = skill.mBase + skill.mMod - skill.mDamage;
if (mObject.mNpcStats.mIsWerewolf)
{
if(i == ESM::Skill::Acrobatics)
mSetWerewolfAcrobatics = mObject.mNpcStats.mSkills[i].mBase != skill.mBase;
mObject.mNpcStats.mSkills[i] = skill;
}
}
}
}
else
{
mSetWerewolfAcrobatics = false;
esm.getHNT(mSaveAttributes, "WWAT");
esm.getHNT(mSaveSkills, "WWSK");
}
}
@ -79,8 +109,6 @@ void ESM::Player::save (ESMWriter &esm) const
esm.writeHNString ("PREV", it->second);
}
for (int i=0; i<ESM::Attribute::Length; ++i)
mSaveAttributes[i].save(esm);
for (int i=0; i<ESM::Skill::Length; ++i)
mSaveSkills[i].save(esm);
esm.writeHNT("WWAT", mSaveAttributes);
esm.writeHNT("WWSK", mSaveSkills);
}

View file

@ -23,6 +23,7 @@ namespace ESM
CellId mCellId;
float mLastKnownExteriorPosition[3];
unsigned char mHasMark;
bool mSetWerewolfAcrobatics;
ESM::Position mMarkedPosition;
CellId mMarkedCell;
std::string mBirthsign;
@ -30,8 +31,8 @@ namespace ESM
int mCurrentCrimeId;
int mPaidCrimeId;
StatState<float> mSaveAttributes[ESM::Attribute::Length];
StatState<float> mSaveSkills[ESM::Skill::Length];
float mSaveAttributes[ESM::Attribute::Length];
float mSaveSkills[ESM::Skill::Length];
typedef std::map<std::string, std::string> PreviousItems; // previous equipped items, needed for bound spells
PreviousItems mPreviousItems;

View file

@ -4,7 +4,7 @@
#include "esmwriter.hpp"
unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE;
int ESM::SavedGame::sCurrentFormat = 18;
int ESM::SavedGame::sCurrentFormat = 19;
void ESM::SavedGame::load (ESMReader &esm)
{