mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-13 21:40:11 +00:00
Issue #342: factored out dynamic stats calculation into a separate function
This commit is contained in:
parent
2c70a93553
commit
a3652f16ce
@ -18,22 +18,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
// magic effects
|
// magic effects
|
||||||
adjustMagicEffects (ptr);
|
adjustMagicEffects (ptr);
|
||||||
|
calculateDynamicStats (ptr);
|
||||||
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
||||||
|
|
||||||
// calculate dynamic stats
|
|
||||||
int strength = creatureStats.mAttributes[0].getBase();
|
|
||||||
int intelligence = creatureStats.mAttributes[1].getBase();
|
|
||||||
int willpower = creatureStats.mAttributes[2].getBase();
|
|
||||||
int agility = creatureStats.mAttributes[3].getBase();
|
|
||||||
int endurance = creatureStats.mAttributes[5].getBase();
|
|
||||||
|
|
||||||
double magickaFactor = creatureStats.mMagicEffects.get (EffectKey (84)).mMagnitude*0.1 + 0.5;
|
|
||||||
|
|
||||||
creatureStats.mDynamic[0].setBase (static_cast<int> (0.5 * (strength + endurance)));
|
|
||||||
creatureStats.mDynamic[1].setBase (static_cast<int> (intelligence +
|
|
||||||
magickaFactor * intelligence));
|
|
||||||
creatureStats.mDynamic[2].setBase (strength+willpower+agility+endurance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
||||||
@ -64,6 +49,24 @@ namespace MWMechanics
|
|||||||
// TODO apply diff to other stats
|
// TODO apply diff to other stats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Actors::calculateDynamicStats (const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
|
int strength = creatureStats.mAttributes[0].getBase();
|
||||||
|
int intelligence = creatureStats.mAttributes[1].getBase();
|
||||||
|
int willpower = creatureStats.mAttributes[2].getBase();
|
||||||
|
int agility = creatureStats.mAttributes[3].getBase();
|
||||||
|
int endurance = creatureStats.mAttributes[5].getBase();
|
||||||
|
|
||||||
|
double magickaFactor = creatureStats.mMagicEffects.get (EffectKey (84)).mMagnitude*0.1 + 0.5;
|
||||||
|
|
||||||
|
creatureStats.mDynamic[0].setBase (static_cast<int> (0.5 * (strength + endurance)));
|
||||||
|
creatureStats.mDynamic[1].setBase (static_cast<int> (intelligence +
|
||||||
|
magickaFactor * intelligence));
|
||||||
|
creatureStats.mDynamic[2].setBase (strength+willpower+agility+endurance);
|
||||||
|
}
|
||||||
|
|
||||||
Actors::Actors() : mDuration (0) {}
|
Actors::Actors() : mDuration (0) {}
|
||||||
|
|
||||||
void Actors::addActor (const MWWorld::Ptr& ptr)
|
void Actors::addActor (const MWWorld::Ptr& ptr)
|
||||||
|
@ -27,6 +27,8 @@ namespace MWMechanics
|
|||||||
|
|
||||||
void adjustMagicEffects (const MWWorld::Ptr& creature);
|
void adjustMagicEffects (const MWWorld::Ptr& creature);
|
||||||
|
|
||||||
|
void calculateDynamicStats (const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Actors();
|
Actors();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user