|
|
|
@ -7,6 +7,7 @@
|
|
|
|
|
#include <components/esm/esmreader.hpp>
|
|
|
|
|
#include <components/esm/esmwriter.hpp>
|
|
|
|
|
|
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
|
#include "../mwworld/esmstore.hpp"
|
|
|
|
|
#include "../mwworld/player.hpp"
|
|
|
|
|
|
|
|
|
@ -22,7 +23,7 @@ namespace MWMechanics
|
|
|
|
|
mTalkedTo (false), mAlarmed (false), mAttacked (false),
|
|
|
|
|
mKnockdown(false), mKnockdownOneFrame(false), mKnockdownOverOneFrame(false),
|
|
|
|
|
mHitRecovery(false), mBlock(false), mMovementFlags(0),
|
|
|
|
|
mFallHeight(0), mRecalcMagicka(false), mLastRestock(0,0), mGoldPool(0), mActorId(-1), mHitAttemptActorId(-1),
|
|
|
|
|
mFallHeight(0), mLastRestock(0,0), mGoldPool(0), mActorId(-1), mHitAttemptActorId(-1),
|
|
|
|
|
mDeathAnimation(-1), mTimeOfDeath(), mSideMovementAngle(0), mLevel (0)
|
|
|
|
|
{
|
|
|
|
|
for (int i=0; i<4; ++i)
|
|
|
|
@ -146,7 +147,7 @@ namespace MWMechanics
|
|
|
|
|
mAttributes[index] = value;
|
|
|
|
|
|
|
|
|
|
if (index == ESM::Attribute::Intelligence)
|
|
|
|
|
mRecalcMagicka = true;
|
|
|
|
|
recalculateMagicka();
|
|
|
|
|
else if (index == ESM::Attribute::Strength ||
|
|
|
|
|
index == ESM::Attribute::Willpower ||
|
|
|
|
|
index == ESM::Attribute::Agility ||
|
|
|
|
@ -208,11 +209,10 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
void CreatureStats::modifyMagicEffects(const MagicEffects &effects)
|
|
|
|
|
{
|
|
|
|
|
if (effects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier()
|
|
|
|
|
!= mMagicEffects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier())
|
|
|
|
|
mRecalcMagicka = true;
|
|
|
|
|
|
|
|
|
|
bool recalc = effects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier() != mMagicEffects.get(ESM::MagicEffect::FortifyMaximumMagicka).getModifier();
|
|
|
|
|
mMagicEffects.setModifiers(effects);
|
|
|
|
|
if(recalc)
|
|
|
|
|
recalculateMagicka();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CreatureStats::setAiSetting (AiSetting index, Stat<int> value)
|
|
|
|
@ -400,19 +400,26 @@ namespace MWMechanics
|
|
|
|
|
return height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CreatureStats::needToRecalcDynamicStats()
|
|
|
|
|
void CreatureStats::recalculateMagicka()
|
|
|
|
|
{
|
|
|
|
|
if (mRecalcMagicka)
|
|
|
|
|
{
|
|
|
|
|
mRecalcMagicka = false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
auto world = MWBase::Environment::get().getWorld();
|
|
|
|
|
float intelligence = getAttribute(ESM::Attribute::Intelligence).getModified();
|
|
|
|
|
|
|
|
|
|
void CreatureStats::setNeedRecalcDynamicStats(bool val)
|
|
|
|
|
{
|
|
|
|
|
mRecalcMagicka = val;
|
|
|
|
|
float base = 1.f;
|
|
|
|
|
const auto& player = world->getPlayerPtr();
|
|
|
|
|
if (this == &player.getClass().getCreatureStats(player))
|
|
|
|
|
base = world->getStore().get<ESM::GameSetting>().find("fPCbaseMagickaMult")->mValue.getFloat();
|
|
|
|
|
else
|
|
|
|
|
base = world->getStore().get<ESM::GameSetting>().find("fNPCbaseMagickaMult")->mValue.getFloat();
|
|
|
|
|
|
|
|
|
|
double magickaFactor = base + mMagicEffects.get(EffectKey(ESM::MagicEffect::FortifyMaximumMagicka)).getMagnitude() * 0.1;
|
|
|
|
|
|
|
|
|
|
DynamicStat<float> magicka = getMagicka();
|
|
|
|
|
float diff = (static_cast<int>(magickaFactor*intelligence)) - magicka.getBase();
|
|
|
|
|
float currentToBaseRatio = magicka.getBase() > 0 ? magicka.getCurrent() / magicka.getBase() : 0;
|
|
|
|
|
magicka.setModified(magicka.getModified() + diff, 0);
|
|
|
|
|
magicka.setCurrent(magicka.getBase() * currentToBaseRatio, false, true);
|
|
|
|
|
setMagicka(magicka);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CreatureStats::setKnockedDown(bool value)
|
|
|
|
@ -532,7 +539,6 @@ namespace MWMechanics
|
|
|
|
|
state.mFallHeight = mFallHeight; // TODO: vertical velocity (move from PhysicActor to CreatureStats?)
|
|
|
|
|
state.mLastHitObject = mLastHitObject;
|
|
|
|
|
state.mLastHitAttemptObject = mLastHitAttemptObject;
|
|
|
|
|
state.mRecalcDynamicStats = mRecalcMagicka;
|
|
|
|
|
state.mDrawState = mDrawState;
|
|
|
|
|
state.mLevel = mLevel;
|
|
|
|
|
state.mActorId = mActorId;
|
|
|
|
@ -586,7 +592,6 @@ namespace MWMechanics
|
|
|
|
|
mFallHeight = state.mFallHeight;
|
|
|
|
|
mLastHitObject = state.mLastHitObject;
|
|
|
|
|
mLastHitAttemptObject = state.mLastHitAttemptObject;
|
|
|
|
|
mRecalcMagicka = state.mRecalcDynamicStats;
|
|
|
|
|
mDrawState = DrawState_(state.mDrawState);
|
|
|
|
|
mLevel = state.mLevel;
|
|
|
|
|
mActorId = state.mActorId;
|
|
|
|
@ -627,6 +632,8 @@ namespace MWMechanics
|
|
|
|
|
if (state.mHasAiSettings)
|
|
|
|
|
for (int i=0; i<4; ++i)
|
|
|
|
|
mAiSettings[i].readState(state.mAiSettings[i]);
|
|
|
|
|
if(state.mRecalcDynamicStats)
|
|
|
|
|
recalculateMagicka();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CreatureStats::setLastRestockTime(MWWorld::TimeStamp tradeTime)
|
|
|
|
|