mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
[Server] Fix skill-related script functions
Add getSkillIncrease() and setSkillIncrease() script functions to get and set the attribute bonuses received at the next level up as a result of skill increases. Previously, getSkill() and setSkill() attempted to return and set the attribute bonuses, respectively. However, they mistakenly used a skill ID as a parameter for the attribute bonuses, when in fact npcStats.mSkillIncrease is an integer array of size 8 where the key stands for an attribute's ID. As a result, setSkill() had the unexpected side effect of messing up a player's major and minor skills because of the invalid values it was setting for npcStats.mSkillIncreases.
This commit is contained in:
parent
57a0415ba3
commit
80be664139
2 changed files with 27 additions and 7 deletions
|
@ -67,6 +67,9 @@ void Player::Init(LuaState &lua)
|
|||
"getSkill", &Player::getSkill,
|
||||
"setSkill", &Player::setSkill,
|
||||
|
||||
"getSkillIncrease", &Player::getSkillIncrease,
|
||||
"setSkillIncrease", &Player::setSkillIncrease,
|
||||
|
||||
"getClass", &Player::getCharClass,
|
||||
"getSettings", &Player::getSettings,
|
||||
"getBooks", &Player::getBooks,
|
||||
|
@ -483,16 +486,16 @@ void Player::setAttribute(unsigned short id, int base, int current)
|
|||
attributesChanged = true;
|
||||
}
|
||||
|
||||
std::tuple<int, int, float, int> Player::getSkill(unsigned short id) const
|
||||
std::tuple<int, int, float> Player::getSkill(unsigned short id) const
|
||||
{
|
||||
if (id >= ESM::Skill::Length)
|
||||
return make_tuple(0, 0, 0.0f, 0);
|
||||
return make_tuple(0, 0, 0.0f);
|
||||
|
||||
const auto &skill = npcStats.mSkills[id];
|
||||
return make_tuple(skill.mBase, skill.mCurrent, skill.mProgress, npcStats.mSkillIncrease[id]);
|
||||
return make_tuple(skill.mBase, skill.mCurrent, skill.mProgress);
|
||||
}
|
||||
|
||||
void Player::setSkill(unsigned short id, int base, int current, float progress, int increase)
|
||||
void Player::setSkill(unsigned short id, int base, int current, float progress)
|
||||
{
|
||||
if (id >= ESM::Skill::Length)
|
||||
return;
|
||||
|
@ -501,7 +504,21 @@ void Player::setSkill(unsigned short id, int base, int current, float progress,
|
|||
skill.mBase = base;
|
||||
skill.mCurrent = current;
|
||||
skill.mProgress = progress;
|
||||
npcStats.mSkillIncrease[id] = increase;
|
||||
|
||||
skillsChanged = true;
|
||||
}
|
||||
|
||||
int Player::getSkillIncrease(unsigned short attributeId) const
|
||||
{
|
||||
return npcStats.mSkillIncrease[attributeId];
|
||||
}
|
||||
|
||||
void Player::setSkillIncrease(unsigned short attributeId, int increase)
|
||||
{
|
||||
if (attributeId >= ESM::Attribute::Length)
|
||||
return;
|
||||
|
||||
npcStats.mSkillIncrease[attributeId] = increase;
|
||||
|
||||
skillsChanged = true;
|
||||
}
|
||||
|
|
|
@ -158,8 +158,11 @@ public:
|
|||
*
|
||||
* @return base, current, progress, increase
|
||||
*/
|
||||
std::tuple<int, int, float, int> getSkill(unsigned short id) const;
|
||||
void setSkill(unsigned short id, int base, int current, float progress, int increase);
|
||||
std::tuple<int, int, float> getSkill(unsigned short id) const;
|
||||
void setSkill(unsigned short id, int base, int current, float progress);
|
||||
|
||||
int getSkillIncrease(unsigned short attributeId) const;
|
||||
void setSkillIncrease(unsigned short attributeId, int increase);
|
||||
|
||||
CellState getCellState(int i);
|
||||
size_t cellStateSize() const;
|
||||
|
|
Loading…
Reference in a new issue