forked from mirror/openmw-tes3mp
[General] Rework getting/clearing of skill modifiers as with attributes
This commit is contained in:
parent
047ad40b96
commit
e97c9f72a2
3 changed files with 17 additions and 10 deletions
|
@ -239,7 +239,7 @@ int StatsFunctions::GetSkillBase(unsigned short pid, unsigned short skill) noexc
|
|||
return player->npcStats.mSkills[skill].mBase;
|
||||
}
|
||||
|
||||
int StatsFunctions::GetSkillCurrent(unsigned short pid, unsigned short skill) noexcept
|
||||
int StatsFunctions::GetSkillModifier(unsigned short pid, unsigned short skill) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
@ -247,7 +247,7 @@ int StatsFunctions::GetSkillCurrent(unsigned short pid, unsigned short skill) no
|
|||
if (skill >= Skill::Length)
|
||||
return 0;
|
||||
|
||||
return player->npcStats.mSkills[skill].mCurrent;
|
||||
return player->npcStats.mSkills[skill].mMod;
|
||||
}
|
||||
|
||||
double StatsFunctions::GetSkillProgress(unsigned short pid, unsigned short skill) noexcept
|
||||
|
@ -442,7 +442,7 @@ void StatsFunctions::ClearAttributeModifier(unsigned short pid, unsigned short a
|
|||
player->creatureStats.mAttributes[attribute].mMod = 0;
|
||||
}
|
||||
|
||||
void StatsFunctions::SetSkillBase(unsigned short pid, unsigned short skill, int value) noexcept //TODO: need packet for one value
|
||||
void StatsFunctions::SetSkillBase(unsigned short pid, unsigned short skill, int value) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
@ -453,7 +453,7 @@ void StatsFunctions::SetSkillBase(unsigned short pid, unsigned short skill, int
|
|||
player->npcStats.mSkills[skill].mBase = value;
|
||||
}
|
||||
|
||||
void StatsFunctions::SetSkillCurrent(unsigned short pid, unsigned short skill, int value) noexcept //TODO: need packet for one value
|
||||
void StatsFunctions::ClearSkillModifier(unsigned short pid, unsigned short skill) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
@ -461,7 +461,7 @@ void StatsFunctions::SetSkillCurrent(unsigned short pid, unsigned short skill, i
|
|||
if (skill >= Skill::Length)
|
||||
return;
|
||||
|
||||
player->npcStats.mSkills[skill].mCurrent = value;
|
||||
player->npcStats.mSkills[skill].mMod = 0;
|
||||
}
|
||||
|
||||
void StatsFunctions::SetSkillProgress(unsigned short pid, unsigned short skill, double value) noexcept
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
{"GetAttributeModifier", StatsFunctions::GetAttributeModifier},\
|
||||
\
|
||||
{"GetSkillBase", StatsFunctions::GetSkillBase},\
|
||||
{"GetSkillCurrent", StatsFunctions::GetSkillCurrent},\
|
||||
{"GetSkillModifier", StatsFunctions::GetSkillModifier},\
|
||||
{"GetSkillProgress", StatsFunctions::GetSkillProgress},\
|
||||
{"GetSkillIncrease", StatsFunctions::GetSkillIncrease},\
|
||||
\
|
||||
|
@ -67,7 +67,7 @@
|
|||
{"ClearAttributeModifier", StatsFunctions::ClearAttributeModifier},\
|
||||
\
|
||||
{"SetSkillBase", StatsFunctions::SetSkillBase},\
|
||||
{"SetSkillCurrent", StatsFunctions::SetSkillCurrent},\
|
||||
{"ClearSkillModifier", StatsFunctions::ClearSkillModifier},\
|
||||
{"SetSkillProgress", StatsFunctions::SetSkillProgress},\
|
||||
{"SetSkillIncrease", StatsFunctions::SetSkillIncrease},\
|
||||
\
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
static int GetAttributeModifier(unsigned short pid, unsigned short attribute) noexcept;
|
||||
|
||||
static int GetSkillBase(unsigned short pid, unsigned short skill) noexcept;
|
||||
static int GetSkillCurrent(unsigned short pid, unsigned short skill) noexcept;
|
||||
static int GetSkillModifier(unsigned short pid, unsigned short skill) noexcept;
|
||||
static double GetSkillProgress(unsigned short pid, unsigned short skill) noexcept;
|
||||
static int GetSkillIncrease(unsigned short pid, unsigned int pos) noexcept;
|
||||
|
||||
|
@ -144,7 +144,7 @@ public:
|
|||
static void ClearAttributeModifier(unsigned short pid, unsigned short attribute) noexcept;
|
||||
|
||||
static void SetSkillBase(unsigned short pid, unsigned short skill, int value) noexcept;
|
||||
static void SetSkillCurrent(unsigned short pid, unsigned short skill, int value) noexcept;
|
||||
static void ClearSkillModifier(unsigned short pid, unsigned short skill) noexcept;
|
||||
static void SetSkillProgress(unsigned short pid, unsigned short skill, double value) noexcept;
|
||||
static void SetSkillIncrease(unsigned short pid, unsigned int pos, int value) noexcept;
|
||||
|
||||
|
|
|
@ -275,7 +275,8 @@ void LocalPlayer::updateSkills(bool forceUpdate)
|
|||
|
||||
for (int i = 0; i < 27; ++i)
|
||||
{
|
||||
if (ptrNpcStats.getSkill(i).getBase() != npcStats.mSkills[i].mBase)
|
||||
if (ptrNpcStats.getSkill(i).getBase() != npcStats.mSkills[i].mBase ||
|
||||
ptrNpcStats.getSkill(i).getModifier() != npcStats.mSkills[i].mMod)
|
||||
{
|
||||
ptrNpcStats.getSkill(i).writeState(npcStats.mSkills[i]);
|
||||
skillsChanged = true;
|
||||
|
@ -812,6 +813,12 @@ void LocalPlayer::setSkills()
|
|||
|
||||
for (int i = 0; i < 27; ++i)
|
||||
{
|
||||
// If the server wants to clear our skill's non-zero modifier, we need to remove
|
||||
// the spell effect causing it, to avoid an infinite loop where the effect keeps resetting
|
||||
// the modifier
|
||||
if (npcStats.mSkills[i].mMod == 0 && ptrNpcStats->getSkill(i).getModifier() > 0)
|
||||
ptrNpcStats->getActiveSpells().purgeEffectByArg(ESM::MagicEffect::FortifySkill, i);
|
||||
|
||||
skillValue.readState(npcStats.mSkills[i]);
|
||||
ptrNpcStats->setSkill(i, skillValue);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue