mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 11:23:52 +00:00
Issue #324: adjusted setSkill script instructions according to the recent research
This commit is contained in:
parent
25a5657d80
commit
67c1c5ce18
1 changed files with 28 additions and 2 deletions
|
@ -1,8 +1,12 @@
|
||||||
|
|
||||||
#include "statsextensions.hpp"
|
#include "statsextensions.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
#include <components/esm/loadnpc.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include <components/compiler/extensions.hpp>
|
#include <components/compiler/extensions.hpp>
|
||||||
|
@ -260,8 +264,30 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).getSkill (mIndex).
|
MWMechanics::NpcStats& stats = MWWorld::Class::get (ptr).getNpcStats (ptr);
|
||||||
setModified (value, 0);
|
|
||||||
|
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
|
assert (ref);
|
||||||
|
|
||||||
|
const ESM::Class& class_ =
|
||||||
|
*MWBase::Environment::get().getWorld()->getStore().classes.find (ref->base->cls);
|
||||||
|
|
||||||
|
float level = 0;
|
||||||
|
float progress = std::modf (stats.getSkill (mIndex).getBase(), &level);
|
||||||
|
|
||||||
|
float modifier = stats.getSkill (mIndex).getModifier();
|
||||||
|
|
||||||
|
int newLevel = static_cast<int> (value-modifier);
|
||||||
|
|
||||||
|
progress = (progress / stats.getSkillGain (mIndex, class_, -1, level))
|
||||||
|
* stats.getSkillGain (mIndex, class_, -1, newLevel);
|
||||||
|
|
||||||
|
if (progress>=1)
|
||||||
|
progress = 0.999999999;
|
||||||
|
|
||||||
|
stats.getSkill (mIndex).set (newLevel + progress);
|
||||||
|
stats.getSkill (mIndex).setModifier (modifier);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue