1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 13:23:55 +00:00

Issue #324: added useSkill function to NpcStats (adjust skill level according to use)

This commit is contained in:
Marc Zinnschlag 2012-07-09 21:15:52 +02:00
parent a207c86fd1
commit 0d8150f4bd
2 changed files with 18 additions and 0 deletions

View file

@ -1,6 +1,7 @@
#include "npcstats.hpp" #include "npcstats.hpp"
#include <cmath>
#include <stdexcept> #include <stdexcept>
#include <components/esm/loadskil.hpp> #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; 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);
}

View file

@ -70,6 +70,9 @@ namespace MWMechanics
///< \param usageType: Usage specific factor, specified in the respective skill record; ///< \param usageType: Usage specific factor, specified in the respective skill record;
/// -1: use a factor of 1.0 instead. /// -1: use a factor of 1.0 instead.
/// \param level Level to base calculation on; -1: use current level. /// \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.
}; };
} }