mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-06-06 09:11: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;
|
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;
|
Player *player;
|
||||||
GET_PLAYER(pid, player, 0);
|
GET_PLAYER(pid, player, 0);
|
||||||
|
|
||||||
if (pos > 7)
|
if (attribute > Attribute::Length)
|
||||||
return 0;
|
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;
|
Player *player;
|
||||||
GET_PLAYER(pid, player,);
|
GET_PLAYER(pid, player,);
|
||||||
|
|
||||||
if (pos > 7)
|
if (attribute > Attribute::Length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player->NpcStats()->mSkillIncrease[pos] = value;
|
player->NpcStats()->mSkillIncrease[attribute] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsFunctions::SetCharGenStage(unsigned short pid, int start, int end) noexcept
|
void StatsFunctions::SetCharGenStage(unsigned short pid, int start, int end) noexcept
|
||||||
|
|
|
@ -137,6 +137,13 @@ void LocalPlayer::updateSkills(bool forceUpdate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
if (ptrNpcStats.getSkillIncrease(i) != NpcStats()->mSkillIncrease[i]) {
|
||||||
|
NpcStats()->mSkillIncrease[i] = ptrNpcStats.getSkillIncrease(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isUpdating || forceUpdate)
|
if (isUpdating || forceUpdate)
|
||||||
{
|
{
|
||||||
NpcStats()->mLevelProgress = ptrNpcStats.getLevelProgress();
|
NpcStats()->mLevelProgress = ptrNpcStats.getLevelProgress();
|
||||||
|
@ -301,6 +308,11 @@ void LocalPlayer::setSkills()
|
||||||
ptrNpcStats->setSkill(i, skillValue);
|
ptrNpcStats->setSkill(i, skillValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; ++i)
|
||||||
|
{
|
||||||
|
ptrNpcStats->setSkillIncrease(i, NpcStats()->mSkillIncrease[i]);
|
||||||
|
}
|
||||||
|
|
||||||
ptrNpcStats->setLevelProgress(NpcStats()->mLevelProgress);
|
ptrNpcStats->setLevelProgress(NpcStats()->mLevelProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,6 @@ void PacketAttribute::Packet(RakNet::BitStream *bs, BasePlayer *player, bool sen
|
||||||
{
|
{
|
||||||
BasePacket::Packet(bs, player, send);
|
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);
|
RW(player->CreatureStats()->mAttributes[i], send);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace mwmp
|
||||||
class PacketAttribute : public BasePacket
|
class PacketAttribute : public BasePacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const static int AttributesCount = 8;
|
const static int AttributeCount = 8;
|
||||||
PacketAttribute(RakNet::RakPeerInterface *peer);
|
PacketAttribute(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
|
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);
|
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);
|
RW(player->NpcStats()->mSkills[i], send);
|
||||||
|
|
||||||
|
for (int i = 0; i < AttributeCount; ++i)
|
||||||
|
RW(player->NpcStats()->mSkillIncrease[i], send);
|
||||||
|
|
||||||
RW(player->NpcStats()->mLevelProgress, send);
|
RW(player->NpcStats()->mLevelProgress, send);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,8 @@ namespace mwmp
|
||||||
class PacketSkill : public BasePacket
|
class PacketSkill : public BasePacket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const static int StatsCount = 27;
|
const static int SkillCount = 27;
|
||||||
|
const static int AttributeCount = 8;
|
||||||
PacketSkill(RakNet::RakPeerInterface *peer);
|
PacketSkill(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
|
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
|
||||||
|
|
Loading…
Reference in a new issue