From dbbfe0b3ea7a97043ce47f6c77ed02762dd2ac30 Mon Sep 17 00:00:00 2001 From: Henrique Date: Thu, 3 Nov 2011 17:26:53 -0200 Subject: [PATCH] parse player stats --- src/otclient/const.h | 16 ++++++++++++++++ src/otclient/core/localplayer.h | 4 ++++ src/otclient/net/protocolgameparse.cpp | 24 ++++++++++++------------ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/otclient/const.h b/src/otclient/const.h index 5a621634..92b8fb51 100644 --- a/src/otclient/const.h +++ b/src/otclient/const.h @@ -259,6 +259,22 @@ namespace Otc SpriteNoMask = 255 }; + enum Statistic { + Health, + MaxHealth, + FreeCapacity, + Experience, + Level, + LevelPercent, + Mana, + MaxMana, + MagicLevel, + MagicLevelPercent, + Soul, + Stamina, + LastStatistic + }; + enum Skill { Fist = 0, Club, diff --git a/src/otclient/core/localplayer.h b/src/otclient/core/localplayer.h index e78e7fcf..412d23d8 100644 --- a/src/otclient/core/localplayer.h +++ b/src/otclient/core/localplayer.h @@ -39,6 +39,9 @@ public: void setSkill(Otc::Skill skill, Otc::SkillType skillType, int value) { m_skills[skill][skillType] = value; } int getSkill(Otc::Skill skill, Otc::SkillType skillType) { return m_skills[skill][skillType]; } + void setStatistic(Otc::Statistic statistic, double value) { m_statistics[statistic] = value; } + uint32 getStatistic(Otc::Statistic statistic) { return m_statistics[statistic]; } + void walk(Otc::Direction direction); LocalPlayerPtr asLocalPlayer() { return std::static_pointer_cast(shared_from_this()); } @@ -48,6 +51,7 @@ private: bool m_canReportBugs; int m_skills[Otc::LastSkill][Otc::LastSkillType]; + double m_statistics[Otc::LastStatistic]; }; #endif diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/net/protocolgameparse.cpp index 1e67188b..58165053 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/net/protocolgameparse.cpp @@ -629,18 +629,18 @@ void ProtocolGame::parseHouseTextWindow(InputMessage& msg) void ProtocolGame::parsePlayerStats(InputMessage& msg) { - msg.getU16(); // health - msg.getU16(); // max health - msg.getU32(); // free capacity - msg.getU32(); // experience - msg.getU16(); // level - msg.getU8(); // level percent - msg.getU16(); // mana - msg.getU16(); // max mana - msg.getU8(); // magic level - msg.getU8(); // magic level percent - msg.getU8(); // soul - msg.getU16(); // stamina + m_localPlayer->setStatistic(Otc::Health, msg.getU16()); + m_localPlayer->setStatistic(Otc::MaxHealth, msg.getU16()); + m_localPlayer->setStatistic(Otc::FreeCapacity, msg.getU32()); + m_localPlayer->setStatistic(Otc::Experience, msg.getU32()); + m_localPlayer->setStatistic(Otc::Level, msg.getU16()); + m_localPlayer->setStatistic(Otc::LevelPercent, msg.getU8()); + m_localPlayer->setStatistic(Otc::Mana, msg.getU16()); + m_localPlayer->setStatistic(Otc::MaxMana, msg.getU16()); + m_localPlayer->setStatistic(Otc::MagicLevel, msg.getU8()); + m_localPlayer->setStatistic(Otc::MagicLevelPercent, msg.getU8()); + m_localPlayer->setStatistic(Otc::Soul, msg.getU8()); + m_localPlayer->setStatistic(Otc::Stamina, msg.getU16()); } void ProtocolGame::parsePlayerSkills(InputMessage& msg)