Add handling of skill increases

pull/76/head
David Cernat 8 years ago
parent 15a4602482
commit 6650b74498

@ -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

@ -134,6 +134,13 @@ void LocalPlayer::updateSkills(bool forceUpdate)
else if (ptrNpcStats.getSkill(i).getProgress() != NpcStats()->mSkills[i].mProgress) else if (ptrNpcStats.getSkill(i).getProgress() != NpcStats()->mSkills[i].mProgress)
{ {
ptrNpcStats.getSkill(i).writeState(NpcStats()->mSkills[i]); 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); 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…
Cancel
Save