mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 23:15:41 +00:00
Issue #342: factored out dynamic stats calculation into a separate function
This commit is contained in:
parent
2c70a93553
commit
a3652f16ce
2 changed files with 21 additions and 16 deletions
|
@ -18,22 +18,7 @@ namespace MWMechanics
|
|||
{
|
||||
// magic effects
|
||||
adjustMagicEffects (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);
|
||||
calculateDynamicStats (ptr);
|
||||
}
|
||||
|
||||
void Actors::updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused)
|
||||
|
@ -64,6 +49,24 @@ namespace MWMechanics
|
|||
// 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) {}
|
||||
|
||||
void Actors::addActor (const MWWorld::Ptr& ptr)
|
||||
|
|
|
@ -27,6 +27,8 @@ namespace MWMechanics
|
|||
|
||||
void adjustMagicEffects (const MWWorld::Ptr& creature);
|
||||
|
||||
void calculateDynamicStats (const MWWorld::Ptr& ptr);
|
||||
|
||||
public:
|
||||
|
||||
Actors();
|
||||
|
|
Loading…
Reference in a new issue