diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 60c96e5b9..d4dc5ea00 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -19,6 +19,7 @@ namespace MWMechanics // magic effects adjustMagicEffects (ptr); calculateDynamicStats (ptr); + calculateCreatureStatModifiers (ptr); } void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused) @@ -67,6 +68,29 @@ namespace MWMechanics creatureStats.mDynamic[2].setBase (strength+willpower+agility+endurance); } + void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr) + { + CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); + + // attributes + for (int i=0; i<5; ++i) + { + int modifier = creatureStats.mMagicEffects.get (EffectKey (79, i)).mMagnitude + - creatureStats.mMagicEffects.get (EffectKey (17, i)).mMagnitude; + + creatureStats.mAttributes[0].setModifier (modifier); + } + + // dynamic stats + for (int i=0; i<3; ++i) + { + int modifier = creatureStats.mMagicEffects.get (EffectKey (80+i)).mMagnitude + - creatureStats.mMagicEffects.get (EffectKey (18+i)).mMagnitude; + + creatureStats.mDynamic[0].setModifier (modifier); + } + } + Actors::Actors() : mDuration (0) {} void Actors::addActor (const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index 7458562e1..d5dcef487 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -29,6 +29,8 @@ namespace MWMechanics void calculateDynamicStats (const MWWorld::Ptr& ptr); + void calculateCreatureStatModifiers (const MWWorld::Ptr& ptr); + public: Actors(); diff --git a/apps/openmw/mwmechanics/stat.hpp b/apps/openmw/mwmechanics/stat.hpp index 996036fc1..d576020c5 100644 --- a/apps/openmw/mwmechanics/stat.hpp +++ b/apps/openmw/mwmechanics/stat.hpp @@ -147,7 +147,7 @@ namespace MWMechanics void modify (const T& diff) { mStatic.modify (diff); - modifyCurrent (diff); + setCurrent (getCurrent()+diff); } void setCurrent (const T& value) @@ -159,6 +159,13 @@ namespace MWMechanics else if (mCurrent>getModified()) mCurrent = getModified(); } + + void setModifier (const T& modifier) + { + T diff = modifier - mStatic.getModifier(); + mStatic.setModifier (modifier); + setCurrent (getCurrent()+diff); + } }; template