mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 08:23:52 +00:00
Issue #324: added useSkill function to NpcStats (adjust skill level according to use)
This commit is contained in:
parent
a207c86fd1
commit
0d8150f4bd
2 changed files with 18 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "npcstats.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <components/esm/loadskil.hpp>
|
||||
|
@ -123,3 +124,17 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla
|
|||
|
||||
return 1.0 / (level +1) * (1.0 / skillFactor) * typeFactor * specialisationFactor;
|
||||
}
|
||||
|
||||
void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType)
|
||||
{
|
||||
float base = getSkill (skillIndex).getBase();
|
||||
|
||||
int level = static_cast<int> (base);
|
||||
|
||||
base += getSkillGain (skillIndex, class_, usageType);
|
||||
|
||||
if (static_cast<int> (base)!=level)
|
||||
base = level+1;
|
||||
|
||||
getSkill (skillIndex).setBase (base);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,9 @@ namespace MWMechanics
|
|||
///< \param usageType: Usage specific factor, specified in the respective skill record;
|
||||
/// -1: use a factor of 1.0 instead.
|
||||
/// \param level Level to base calculation on; -1: use current level.
|
||||
|
||||
void useSkill (int skillIndex, const ESM::Class& class_, int usageType = -1);
|
||||
///< Increase skill by usage.
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue