diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-07-15 14:43:16 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-07-15 14:47:24 -0600 |
commit | 18aaa873abcaa617bbd296f73138d062423662b8 (patch) | |
tree | cfdcf6d3a5750549c01df38cda27f0ea14b47279 /src/net | |
parent | fa6d39d9f56e09abfb6b48bacdd66ddbad20c641 (diff) | |
download | mana-18aaa873abcaa617bbd296f73138d062423662b8.tar.gz mana-18aaa873abcaa617bbd296f73138d062423662b8.tar.bz2 mana-18aaa873abcaa617bbd296f73138d062423662b8.tar.xz mana-18aaa873abcaa617bbd296f73138d062423662b8.zip |
Merge and cleanup attribute code
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/generalhandler.cpp | 15 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 229 | ||||
-rw-r--r-- | src/net/ea/protocol.h | 24 | ||||
-rw-r--r-- | src/net/tmwserv/generalhandler.cpp | 8 |
5 files changed, 176 insertions, 102 deletions
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 4ffea0c9..a09f11f9 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -205,7 +205,7 @@ LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot) tempPlayer->setSprite(Being::MISC2_SPRITE, msg.readInt16()); tempPlayer->setName(msg.readString(24)); for (int i = 0; i < 6; i++) { - tempPlayer->mAttr[i] = msg.readInt8(); + tempPlayer->setAttributeBase(i + STR, msg.readInt8()); } slot = msg.readInt8(); // character slot msg.readInt8(); // unknown diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp index 8ff62d37..bbadd44f 100644 --- a/src/net/ea/generalhandler.cpp +++ b/src/net/ea/generalhandler.cpp @@ -23,6 +23,7 @@ #include "gui/inventorywindow.h" #include "gui/skilldialog.h" +#include "gui/status.h" #include "net/ea/network.h" #include "net/ea/protocol.h" @@ -203,6 +204,20 @@ void GeneralHandler::guiWindowsLoaded() partyTab = new PartyTab; inventoryWindow->setSplitAllowed(false); skillDialog->loadSkills("ea-skills.xml"); + + /*statusWindow->addAttribute(STR, _("Strength"), true); + statusWindow->addAttribute(AGI, _("Agility"), true); + statusWindow->addAttribute(VIT, _("Vitality"), true); + statusWindow->addAttribute(INT, _("Intelligence"), true); + statusWindow->addAttribute(DEX, _("Dexterity"), true); + statusWindow->addAttribute(LUK, _("Luck"), true); + + statusWindow->addAttribute(ATK, _("Attack"), false); + statusWindow->addAttribute(DEF, _("Defense"), false); + statusWindow->addAttribute(MATK, _("M.Attack"), false); + statusWindow->addAttribute(MDEF, _("M.Defense"), false); + statusWindow->addAttribute(HIT, _("% Accuracy"), false); + statusWindow->addAttribute(FLEE, _("% Evade"), false);*/ } void GeneralHandler::guiWindowsUnloaded() diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 9b4c56e2..9464723a 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -53,6 +53,9 @@ OkDialog *deathNotice = NULL; // everything beyond will reset the port hard. static const int MAP_TELEPORT_SCROLL_DISTANCE = 8; +#define ATTR_BONUS(atr) \ +(player_node->getAttributeEffective(atr) - player_node->getAttributeBase(atr)) + // TODO Move somewhere else namespace { @@ -223,17 +226,14 @@ void PlayerHandler::handleMessage(MessageIn &msg) switch (type) { case 0x0000: player_node->setWalkSpeed(value); break; + case 0x0004: break; // manner case 0x0005: player_node->setHp(value); break; case 0x0006: player_node->setMaxHp(value); break; case 0x0007: player_node->mMp = value; break; case 0x0008: player_node->mMaxMp = value; break; - case 0x0009: - player_node->setCharacterPoints(value); - break; + case 0x0009: player_node->setCharacterPoints(value); break; case 0x000b: player_node->setLevel(value); break; - case 0x000c: - player_node->setSkillPoints(value); - break; + case 0x000c: player_node->setSkillPoints(value); break; case 0x0018: if (value >= player_node->getMaxWeight() / 2 && player_node->getTotalWeight() < @@ -249,13 +249,44 @@ void PlayerHandler::handleMessage(MessageIn &msg) player_node->setTotalWeight(value); break; case 0x0019: player_node->setMaxWeight(value); break; - case 0x0029: player_node->ATK = value; break; - case 0x002b: player_node->MATK = value; break; - case 0x002d: player_node->DEF = value; break; - case 0x002e: player_node->DEF_BONUS = value; break; - case 0x002f: player_node->MDEF = value; break; - case 0x0031: player_node->HIT = value; break; - case 0x0032: player_node->FLEE = value; break; + + case 0x0029: player_node->setAttributeEffective(ATK, value + + ATTR_BONUS(ATK)); + player_node->setAttributeBase(ATK, value); + break; + case 0x002a: value += player_node->getAttributeBase(ATK); + player_node->setAttributeEffective(ATK, value); break; + + case 0x002b: player_node->setAttributeEffective(MATK, value + + ATTR_BONUS(MATK)); + player_node->setAttributeBase(MATK, value); break; + case 0x002c: value += player_node->getAttributeBase(MATK); + player_node->setAttributeEffective(MATK, value); break; + + case 0x002d: player_node->setAttributeEffective(DEF, value + + ATTR_BONUS(DEF)); + player_node->setAttributeBase(DEF, value); break; + case 0x002e: value += player_node->getAttributeBase(DEF); + player_node->setAttributeEffective(DEF, value); break; + + case 0x002f: player_node->setAttributeEffective(MDEF, value + + ATTR_BONUS(MDEF)); + player_node->setAttributeBase(MDEF, value); break; + case 0x0030: value += player_node->getAttributeBase(MDEF); + player_node->setAttributeEffective(MDEF, value); break; + + case 0x0031: player_node->setAttributeBase(HIT, value); + player_node->setAttributeEffective(HIT, value); break; + + case 0x0032: player_node->setAttributeEffective(FLEE, value + + ATTR_BONUS(FLEE)); + player_node->setAttributeBase(FLEE, value); break; + case 0x0033: value += player_node->getAttributeBase(FLEE); + player_node->setAttributeEffective(FLEE, value); break; + + case 0x0034: player_node->setAttributeBase(CRIT, value); + player_node->setAttributeEffective(CRIT, value); break; + case 0x0035: player_node->mAttackSpeed = value; break; case 0x0037: player_node->mJobLevel = value; break; case 500: player_node->setGMLevel(value); break; @@ -302,26 +333,13 @@ void PlayerHandler::handleMessage(MessageIn &msg) int type = msg.readInt32(); int base = msg.readInt32(); int bonus = msg.readInt32(); - int total = base + bonus; - switch (type) { - case 0x000d: player_node->mAttr[LocalPlayer::STR] = total; - break; - case 0x000e: player_node->mAttr[LocalPlayer::AGI] = total; - break; - case 0x000f: player_node->mAttr[LocalPlayer::VIT] = total; - break; - case 0x0010: player_node->mAttr[LocalPlayer::INT] = total; - break; - case 0x0011: player_node->mAttr[LocalPlayer::DEX] = total; - break; - case 0x0012: player_node->mAttr[LocalPlayer::LUK] = total; - break; - } + player_node->setAttributeBase(type, base); + player_node->setAttributeEffective(type, base + bonus); } break; - case SMSG_PLAYER_STAT_UPDATE_4: + case SMSG_PLAYER_STAT_UPDATE_4: // Attribute increase ack { int type = msg.readInt16(); int fail = msg.readInt8(); @@ -330,72 +348,104 @@ void PlayerHandler::handleMessage(MessageIn &msg) if (fail != 1) break; - switch (type) { - case 0x000d: player_node->mAttr[LocalPlayer::STR] = value; - break; - case 0x000e: player_node->mAttr[LocalPlayer::AGI] = value; - break; - case 0x000f: player_node->mAttr[LocalPlayer::VIT] = value; - break; - case 0x0010: player_node->mAttr[LocalPlayer::INT] = value; - break; - case 0x0011: player_node->mAttr[LocalPlayer::DEX] = value; - break; - case 0x0012: player_node->mAttr[LocalPlayer::LUK] = value; - break; - } + int bonus = ATTR_BONUS(type); + + player_node->setAttributeBase(type, value); + player_node->setAttributeEffective(type, value + bonus); } break; // Updates stats and status points case SMSG_PLAYER_STAT_UPDATE_5: player_node->setCharacterPoints(msg.readInt16()); - player_node->mAttr[LocalPlayer::STR] = msg.readInt8(); - player_node->mAttrUp[LocalPlayer::STR] = msg.readInt8(); - player_node->mAttr[LocalPlayer::AGI] = msg.readInt8(); - player_node->mAttrUp[LocalPlayer::AGI] = msg.readInt8(); - player_node->mAttr[LocalPlayer::VIT] = msg.readInt8(); - player_node->mAttrUp[LocalPlayer::VIT] = msg.readInt8(); - player_node->mAttr[LocalPlayer::INT] = msg.readInt8(); - player_node->mAttrUp[LocalPlayer::INT] = msg.readInt8(); - player_node->mAttr[LocalPlayer::DEX] = msg.readInt8(); - player_node->mAttrUp[LocalPlayer::DEX] = msg.readInt8(); - player_node->mAttr[LocalPlayer::LUK] = msg.readInt8(); - player_node->mAttrUp[LocalPlayer::LUK] = msg.readInt8(); - player_node->ATK = msg.readInt16(); // ATK - player_node->ATK_BONUS = msg.readInt16(); // ATK bonus - player_node->MATK = msg.readInt16(); // MATK max - player_node->MATK_BONUS = msg.readInt16(); // MATK min - player_node->DEF = msg.readInt16(); // DEF - player_node->DEF_BONUS = msg.readInt16(); // DEF bonus - player_node->MDEF = msg.readInt16(); // MDEF - player_node->MDEF_BONUS = msg.readInt16(); // MDEF bonus - player_node->HIT = msg.readInt16(); // HIT - player_node->FLEE = msg.readInt16(); // FLEE - player_node->FLEE_BONUS = msg.readInt16(); // FLEE bonus - msg.readInt16(); // critical - msg.readInt16(); // unknown + + { + int val = msg.readInt8(); + player_node->setAttributeEffective(STR, val + ATTR_BONUS(STR)); + player_node->setAttributeBase(STR, val); + player_node->setAttributeBase(STR, msg.readInt8()); + + val = msg.readInt8(); + player_node->setAttributeEffective(AGI, val + ATTR_BONUS(AGI)); + player_node->setAttributeBase(AGI, val); + player_node->setAttributeBase(AGI_U, msg.readInt8()); + + val = msg.readInt8(); + player_node->setAttributeEffective(VIT, val + ATTR_BONUS(VIT)); + player_node->setAttributeBase(VIT, val); + player_node->setAttributeBase(VIT_U, msg.readInt8()); + + val = msg.readInt8(); + player_node->setAttributeEffective(INT, val + ATTR_BONUS(INT)); + player_node->setAttributeBase(INT, val); + player_node->setAttributeBase(INT_U, msg.readInt8()); + + val = msg.readInt8(); + player_node->setAttributeEffective(DEX, val + ATTR_BONUS(DEX)); + player_node->setAttributeBase(DEX, val); + player_node->setAttributeBase(DEX_U, msg.readInt8()); + + val = msg.readInt8(); + player_node->setAttributeEffective(LUK, val + ATTR_BONUS(LUK)); + player_node->setAttributeBase(LUK, val); + player_node->setAttributeBase(LUK_U, msg.readInt8()); + + val = msg.readInt16(); // ATK + player_node->setAttributeBase(ATK, val); + val += msg.readInt16(); // ATK bonus + player_node->setAttributeEffective(ATK, val); + + val = msg.readInt16(); // MATK + player_node->setAttributeBase(MATK, val); + val += msg.readInt16(); // MATK bonus + player_node->setAttributeEffective(MATK, val); + + val = msg.readInt16(); // DEF + player_node->setAttributeBase(DEF, val); + val += msg.readInt16(); // DEF bonus + player_node->setAttributeEffective(DEF, val); + + val = msg.readInt16(); // MDEF + player_node->setAttributeBase(MDEF, val); + val += msg.readInt16(); // MDEF bonus + player_node->setAttributeEffective(MDEF, val); + + val = msg.readInt16(); // HIT + player_node->setAttributeBase(ATK, val); + player_node->setAttributeEffective(ATK, val); + + val = msg.readInt16(); // FLEE + player_node->setAttributeBase(FLEE, val); + val += msg.readInt16(); // FLEE bonus + player_node->setAttributeEffective(FLEE, val); + + val = msg.readInt16(); + player_node->setAttributeBase(CRIT, val); + player_node->setAttributeEffective(CRIT, val); + } + + msg.readInt16(); // manner break; case SMSG_PLAYER_STAT_UPDATE_6: switch (msg.readInt16()) { case 0x0020: - player_node->mAttrUp[LocalPlayer::STR] = msg.readInt8(); + player_node->setAttributeBase(STR_U, msg.readInt8()); break; case 0x0021: - player_node->mAttrUp[LocalPlayer::AGI] = msg.readInt8(); + player_node->setAttributeBase(AGI_U, msg.readInt8()); break; case 0x0022: - player_node->mAttrUp[LocalPlayer::VIT] = msg.readInt8(); + player_node->setAttributeBase(VIT_U, msg.readInt8()); break; case 0x0023: - player_node->mAttrUp[LocalPlayer::INT] = msg.readInt8(); + player_node->setAttributeBase(INT_U, msg.readInt8()); break; case 0x0024: - player_node->mAttrUp[LocalPlayer::DEX] = msg.readInt8(); + player_node->setAttributeBase(DEX_U, msg.readInt8()); break; case 0x0025: - player_node->mAttrUp[LocalPlayer::LUK] = msg.readInt8(); + player_node->setAttributeBase(LUK_U, msg.readInt8()); break; } break; @@ -433,35 +483,12 @@ void PlayerHandler::emote(int emoteId) void PlayerHandler::increaseAttribute(size_t attr) { - MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST); - - switch (attr) + if (attr >= STR && attr <= LUK) { - case LocalPlayer::STR: - outMsg.writeInt16(0x000d); - break; - - case LocalPlayer::AGI: - outMsg.writeInt16(0x000e); - break; - - case LocalPlayer::VIT: - outMsg.writeInt16(0x000f); - break; - - case LocalPlayer::INT: - outMsg.writeInt16(0x0010); - break; - - case LocalPlayer::DEX: - outMsg.writeInt16(0x0011); - break; - - case LocalPlayer::LUK: - outMsg.writeInt16(0x0012); - break; + MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST); + outMsg.writeInt16(STR); + outMsg.writeInt8(1); } - outMsg.writeInt8(1); } void PlayerHandler::decreaseAttribute(size_t attr) diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h index fcb96f22..268c8c67 100644 --- a/src/net/ea/protocol.h +++ b/src/net/ea/protocol.h @@ -22,6 +22,30 @@ #ifndef EA_PROTOCOL_H #define EA_PROTOCOL_H +enum { + STR = 0xd, + AGI, + VIT, + INT, + DEX, + LUK, + + STR_U, + AGI_U, + VIT_U, + INT_U, + DEX_U, + LUK_U, + + ATK, + DEF, + MATK, + MDEF, + HIT, + FLEE, + CRIT +}; + static const int INVENTORY_OFFSET = 2; static const int STORAGE_OFFSET = 1; diff --git a/src/net/tmwserv/generalhandler.cpp b/src/net/tmwserv/generalhandler.cpp index 10b2c0f3..c04df973 100644 --- a/src/net/tmwserv/generalhandler.cpp +++ b/src/net/tmwserv/generalhandler.cpp @@ -22,6 +22,7 @@ #include "gui/inventorywindow.h" #include "gui/partywindow.h" #include "gui/skilldialog.h" +#include "gui/statuswindow.h" #include "net/tmwserv/generalhandler.h" @@ -148,6 +149,13 @@ void GeneralHandler::guiWindowsLoaded() inventoryWindow->setSplitAllowed(true); partyWindow->clearPartyName(); skillDialog->loadSkills("tmw-skills.xml"); + + /*statusWindow->addAttribute(16, _("Strength"), true); + statusWindow->addAttribute(17, _("Agility"), true); + statusWindow->addAttribute(18, _("Dexterity"), true); + statusWindow->addAttribute(19, _("Vitality"), true); + statusWindow->addAttribute(20, _("Intelligence"), true); + statusWindow->addAttribute(21, _("Willpower"), true);*/ } void GeneralHandler::guiWindowsUnloaded() |