mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 13:15:33 +00:00
Add handling of skill increases
This commit is contained in:
parent
15a4602482
commit
6650b74498
6 changed files with 26 additions and 10 deletions
|
@ -424,26 +424,26 @@ void StatsFunctions::SetSkillProgress(unsigned short pid, unsigned short skill,
|
|||
player->NpcStats()->mSkills[skill].mProgress = value;
|
||||
}
|
||||
|
||||
int StatsFunctions::GetSkillIncrease(unsigned short pid, unsigned int pos) noexcept
|
||||
int StatsFunctions::GetSkillIncrease(unsigned short pid, unsigned int attribute) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
if (pos > 7)
|
||||
if (attribute > Attribute::Length)
|
||||
return 0;
|
||||
|
||||
return player->NpcStats()->mSkillIncrease[pos];
|
||||
return player->NpcStats()->mSkillIncrease[attribute];
|
||||
}
|
||||
|
||||
void StatsFunctions::SetSkillIncrease(unsigned short pid, unsigned int pos, int value) noexcept // TODO: need packet for transmit it
|
||||
void StatsFunctions::SetSkillIncrease(unsigned short pid, unsigned int attribute, int value) noexcept // TODO: need packet for transmit it
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
if (pos > 7)
|
||||
if (attribute > Attribute::Length)
|
||||
return;
|
||||
|
||||
player->NpcStats()->mSkillIncrease[pos] = value;
|
||||
player->NpcStats()->mSkillIncrease[attribute] = value;
|
||||
}
|
||||
|
||||
void StatsFunctions::SetCharGenStage(unsigned short pid, int start, int end) noexcept
|
||||
|
|
|
@ -134,6 +134,13 @@ void LocalPlayer::updateSkills(bool forceUpdate)
|
|||
else if (ptrNpcStats.getSkill(i).getProgress() != NpcStats()->mSkills[i].mProgress)
|
||||
{
|
||||
ptrNpcStats.getSkill(i).writeState(NpcStats()->mSkills[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (ptrNpcStats.getSkillIncrease(i) != NpcStats()->mSkillIncrease[i]) {
|
||||
NpcStats()->mSkillIncrease[i] = ptrNpcStats.getSkillIncrease(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,6 +308,11 @@ void LocalPlayer::setSkills()
|
|||
ptrNpcStats->setSkill(i, skillValue);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
ptrNpcStats->setSkillIncrease(i, NpcStats()->mSkillIncrease[i]);
|
||||
}
|
||||
|
||||
ptrNpcStats->setLevelProgress(NpcStats()->mLevelProgress);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,6 @@ void PacketAttribute::Packet(RakNet::BitStream *bs, BasePlayer *player, bool sen
|
|||
{
|
||||
BasePacket::Packet(bs, player, send);
|
||||
|
||||
for (int i = 0; i < AttributesCount; ++i)
|
||||
for (int i = 0; i < AttributeCount; ++i)
|
||||
RW(player->CreatureStats()->mAttributes[i], send);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace mwmp
|
|||
class PacketAttribute : public BasePacket
|
||||
{
|
||||
public:
|
||||
const static int AttributesCount = 8;
|
||||
const static int AttributeCount = 8;
|
||||
PacketAttribute(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
|
||||
|
|
|
@ -18,8 +18,11 @@ void PacketSkill::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
|
|||
{
|
||||
BasePacket::Packet(bs, player, send);
|
||||
|
||||
for (int i = 0; i < StatsCount; ++i)
|
||||
for (int i = 0; i < SkillCount; ++i)
|
||||
RW(player->NpcStats()->mSkills[i], send);
|
||||
|
||||
for (int i = 0; i < AttributeCount; ++i)
|
||||
RW(player->NpcStats()->mSkillIncrease[i], send);
|
||||
|
||||
RW(player->NpcStats()->mLevelProgress, send);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ namespace mwmp
|
|||
class PacketSkill : public BasePacket
|
||||
{
|
||||
public:
|
||||
const static int StatsCount = 27;
|
||||
const static int SkillCount = 27;
|
||||
const static int AttributeCount = 8;
|
||||
PacketSkill(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
|
||||
|
|
Loading…
Reference in a new issue