diff options
-rw-r--r-- | src/gui/specialswindow.h | 4 | ||||
-rw-r--r-- | src/localplayer.cpp | 28 | ||||
-rw-r--r-- | src/localplayer.h | 17 | ||||
-rw-r--r-- | src/net/tmwserv/inventoryhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwserv/playerhandler.cpp | 14 | ||||
-rw-r--r-- | src/net/tmwserv/protocol.h | 3 |
6 files changed, 69 insertions, 3 deletions
diff --git a/src/gui/specialswindow.h b/src/gui/specialswindow.h index cc2a68b3..cd92c065 100644 --- a/src/gui/specialswindow.h +++ b/src/gui/specialswindow.h @@ -22,12 +22,15 @@ #ifndef SPECIALSWINDOW_H #define SPECIALSWINDOW_H +#include <vector> + #include "gui/widgets/window.h" #include "guichanfwd.h" #include <guichan/actionlistener.hpp> + #include <map> class Label; @@ -56,6 +59,7 @@ class SpecialsWindow : public Window, public gcn::ActionListener { void loadSpecials(const std::string &file); private: + std::vector<gcn::Button *> mSpellButtons; typedef std::map<int, SpecialInfo*> SpecialMap; SpecialMap mSpecials; TabbedArea *mTabs; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 319d9da7..68b70db4 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -28,6 +28,7 @@ #include "graphics.h" #include "inventory.h" #include "item.h" +#include "log.h" #include "map.h" #include "monster.h" #include "particle.h" @@ -174,6 +175,22 @@ void LocalPlayer::logic() mMessageTime--; } + if ((mSpecialRechargeUpdateNeeded%11) == 0) + { + mSpecialRechargeUpdateNeeded = 0; + for (std::map<int, Special>::iterator i = mSpecials.begin(); + i != mSpecials.end(); + i++) + { + i->second.currentMana += i->second.recharge; + if (i->second.currentMana > i->second.neededMana) + { + i->second.currentMana = i->second.neededMana; + } + } + } + mSpecialRechargeUpdateNeeded++; + #ifdef EATHENA_SUPPORT // Targeting allowed 4 times a second if (get_elapsed_time(mLastTarget) >= 250) @@ -626,13 +643,22 @@ void LocalPlayer::attack() Net::GameServer::Player::attack(getSpriteDirection()); } */ -#endif void LocalPlayer::useSpecial(int special) { Net::getSpecialHandler()->use(special); } +void LocalPlayer::setSpecialStatus(int id, int current, int max, int recharge) +{ + logger->log("SpecialUpdate Skill #%d -- (%d/%d) -> %d", id, current, max, recharge); + mSpecials[id].currentMana = current; + mSpecials[id].neededMana = max; + mSpecials[id].recharge = recharge; +} + +#endif + void LocalPlayer::attack(Being *target, bool keep) { #ifdef TMWSERV_SUPPORT diff --git a/src/localplayer.h b/src/localplayer.h index ff26e701..691307ba 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -35,6 +35,15 @@ class Inventory; class Item; class Map; + +struct Special +{ + int currentMana; + int neededMana; + int recharge; +}; + + /** * Attributes used during combat. Available to all the beings. */ @@ -172,6 +181,11 @@ class LocalPlayer : public Player void useSpecial(int id); + void setSpecialStatus(int id, int current, int max, int recharge); + + const std::map<int, Special> &getSpecialStatus() const + { return mSpecials; } + void attack(Being *target = NULL, bool keep = false); /** @@ -385,6 +399,9 @@ class LocalPlayer : public Player std::map<int, std::pair<int, int> > mSkillExp; int mCharacterPoints; int mCorrectionPoints; + int mLevelProgress; + std::map<int, Special> mSpecials; + char mSpecialRechargeUpdateNeeded; int mLevel; int mExp, mExpNeeded; int mMp, mMaxMp; diff --git a/src/net/tmwserv/inventoryhandler.cpp b/src/net/tmwserv/inventoryhandler.cpp index 8110fdd2..6993167c 100644 --- a/src/net/tmwserv/inventoryhandler.cpp +++ b/src/net/tmwserv/inventoryhandler.cpp @@ -40,6 +40,8 @@ #include "resources/iteminfo.h" +#include "log.h" // <<< REMOVE ME! + Net::InventoryHandler *inventoryHandler; namespace TmwServ { @@ -102,7 +104,9 @@ void InventoryHandler::unequipItem(const Item *item) Net::GameServer::connection->send(msg); // Tidy equipment directly to avoid weapon still shown bug, for instance - player_node->mEquipment->setEquipment(item->getInvIndex(), 0); + int equipSlot = item->getInvIndex(); + logger->log("Unequipping %d", equipSlot); + player_node->mEquipment->setEquipment(equipSlot, 0); } void InventoryHandler::useItem(const Item *item) diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp index 656befdf..ce1990ed 100644 --- a/src/net/tmwserv/playerhandler.cpp +++ b/src/net/tmwserv/playerhandler.cpp @@ -105,6 +105,7 @@ PlayerHandler::PlayerHandler() GPMSG_LEVEL_PROGRESS, GPMSG_RAISE_ATTRIBUTE_RESPONSE, GPMSG_LOWER_ATTRIBUTE_RESPONSE, + GPMSG_SPECIAL_STATUS, 0 }; handledMessages = _messages; @@ -255,6 +256,19 @@ void PlayerHandler::handleMessage(MessageIn &msg) } } break; + + case GPMSG_SPECIAL_STATUS : + { + while (msg.getUnreadLength()) + { + // { B specialID, L current, L max, L recharge } + int id = msg.readInt8(); + int current = msg.readInt32(); + int max = msg.readInt32(); + int recharge = msg.readInt32(); + player_node->setSpecialStatus(id, current, max, recharge); + } + } break; /* case SMSG_PLAYER_ARROW_MESSAGE: { diff --git a/src/net/tmwserv/protocol.h b/src/net/tmwserv/protocol.h index 90ff2437..60a50d89 100644 --- a/src/net/tmwserv/protocol.h +++ b/src/net/tmwserv/protocol.h @@ -107,8 +107,9 @@ enum { GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, W*2 position, B speed] }* GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }* PGMSG_ATTACK = 0x0290, // W being id - PGMSG_USE_SPECIAL = 0x0292, // B specialID GPMSG_BEING_ATTACK = 0x0291, // W being id + PGMSG_USE_SPECIAL = 0x0292, // B specialID + GPMSG_SPECIAL_STATUS = 0x0293, // { B specialID, L current, L max, L recharge } PGMSG_SAY = 0x02A0, // S text GPMSG_SAY = 0x02A1, // W being id, S text GPMSG_NPC_CHOICE = 0x02B0, // W being id, { S text }* |