summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/specialswindow.cpp41
-rw-r--r--src/net/manaserv/manaserv_protocol.h3
-rw-r--r--src/net/manaserv/specialhandler.cpp14
-rw-r--r--src/resources/specialdb.cpp15
-rw-r--r--src/resources/specialdb.h9
5 files changed, 38 insertions, 44 deletions
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 8097eb05..7db5952a 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -48,6 +48,8 @@
#include "utils/stringutils.h"
#include "utils/xml.h"
+#include "localplayer.h"
+
#include <string>
#define SPECIALS_WIDTH 200
@@ -106,12 +108,20 @@ void SpecialsWindow::action(const gcn::ActionEvent &event)
if (disp)
{
- /*Being *target = local_player->getTarget();
-
- if (target)
- Net::getSpecialHandler()->use(disp->mInfo->id, 1, target->getId());
- else*/
- Net::getSpecialHandler()->use(disp->mInfo->id);
+ if (disp->mInfo->targetMode == SpecialInfo::TARGET_BEING)
+ {
+ Being *target = local_player->getTarget();
+
+ if (target)
+ Net::getSpecialHandler()->use(disp->mInfo->id, 1, target->getId());
+ else
+ Net::getSpecialHandler()->use(disp->mInfo->id);
+ }
+ else
+ {
+ // TODO: Allow the player to aim at a position on the map and
+ // Use special on the map position.
+ }
}
}
else if (event.getId() == "close")
@@ -202,22 +212,11 @@ SpecialEntry::SpecialEntry(SpecialInfo *info) :
mNameLabel->setPosition(35, 0);
add(mNameLabel);
- if (info->hasLevel)
- {
- mLevelLabel = new Label(toString(info->level));
- mLevelLabel->setPosition(getWidth() - mLevelLabel->getWidth(), 0);
- add(mLevelLabel);
- }
-
-
- if (info->isActive)
- {
- mUse = new Button("Use", "use", specialsWindow);
- mUse->setPosition(getWidth() - mUse->getWidth(), 13);
- add(mUse);
- }
+ mUse = new Button("Use", "use", specialsWindow);
+ mUse->setPosition(getWidth() - mUse->getWidth(), 13);
+ add(mUse);
- if (info->hasRechargeBar)
+ if (info->rechargeable)
{
float progress = (float)info->rechargeCurrent / (float)info->rechargeNeeded;
mRechargeBar = new ProgressBar(progress, 100, 10, Theme::PROG_MP);
diff --git a/src/net/manaserv/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h
index aa1976f1..79dbc542 100644
--- a/src/net/manaserv/manaserv_protocol.h
+++ b/src/net/manaserv/manaserv_protocol.h
@@ -127,8 +127,9 @@ enum {
GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }*
PGMSG_ATTACK = 0x0290, // W being id
GPMSG_BEING_ATTACK = 0x0291, // W being id, B direction, B attack Id
- PGMSG_USE_SPECIAL = 0x0292, // B specialID
+ PGMSG_USE_SPECIAL_ON_BEING = 0x0292, // B specialID, W being id
GPMSG_SPECIAL_STATUS = 0x0293, // { B specialID, D current, D max, D recharge }
+ PGMSG_USE_SPECIAL_ON_POINT = 0x0294, // B specialID, W*2 position
PGMSG_SAY = 0x02A0, // S text
GPMSG_SAY = 0x02A1, // W being id, S text
GPMSG_NPC_CHOICE = 0x02B0, // W being id, { S text }*
diff --git a/src/net/manaserv/specialhandler.cpp b/src/net/manaserv/specialhandler.cpp
index fa98cd48..4cd0ce2b 100644
--- a/src/net/manaserv/specialhandler.cpp
+++ b/src/net/manaserv/specialhandler.cpp
@@ -44,19 +44,27 @@ void SpecialHandler::handleMessage(Net::MessageIn &msg)
void SpecialHandler::use(int id)
{
- MessageOut msg(PGMSG_USE_SPECIAL);
+ MessageOut msg(PGMSG_USE_SPECIAL_ON_BEING);
msg.writeInt8(id);
+ msg.writeInt16(0);
gameServerConnection->send(msg);
}
void SpecialHandler::use(int id, int level, int beingId)
{
- // TODO
+ MessageOut msg(PGMSG_USE_SPECIAL_ON_BEING);
+ msg.writeInt8(id);
+ msg.writeInt16(beingId);
+ gameServerConnection->send(msg);
}
void SpecialHandler::use(int id, int level, int x, int y)
{
- // TODO
+ MessageOut msg(PGMSG_USE_SPECIAL_ON_POINT);
+ msg.writeInt8(id);
+ msg.writeInt16(x);
+ msg.writeInt16(y);
+ gameServerConnection->send(msg);
}
void SpecialHandler::use(int id, const std::string &map)
diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp
index 5dac2e6c..426a1143 100644
--- a/src/resources/specialdb.cpp
+++ b/src/resources/specialdb.cpp
@@ -34,14 +34,11 @@ namespace
SpecialInfo::TargetMode SpecialDB::targetModeFromString(const std::string& str)
{
- if (str=="self") return SpecialInfo::TARGET_SELF;
- else if (str=="friend") return SpecialInfo::TARGET_FRIEND;
- else if (str=="enemy") return SpecialInfo::TARGET_ENEMY;
- else if (str=="being") return SpecialInfo::TARGET_BEING;
+ if (str=="being") return SpecialInfo::TARGET_BEING;
else if (str=="point") return SpecialInfo::TARGET_POINT;
logger->log("SpecialDB: Warning, unknown target mode \"%s\"", str.c_str() );
- return SpecialInfo::TARGET_SELF;
+ return SpecialInfo::TARGET_BEING;
}
void SpecialDB::load()
@@ -80,13 +77,9 @@ void SpecialDB::load()
info->name = XML::getProperty(special, "name", "");
info->icon = XML::getProperty(special, "icon", "");
- info->isActive = XML::getBoolProperty(special, "active", false);
- info->targetMode = targetModeFromString(XML::getProperty(special, "target", "self"));
+ info->targetMode = targetModeFromString(XML::getProperty(special, "target", "being"));
- info->level = XML::getProperty(special, "level", -1);
- info->hasLevel = info->level > -1;
-
- info->hasRechargeBar = XML::getBoolProperty(special, "recharge", false);
+ info->rechargeable = XML::getBoolProperty(special, "rechargeable", true);
info->rechargeNeeded = 0;
info->rechargeCurrent = 0;
diff --git a/src/resources/specialdb.h b/src/resources/specialdb.h
index 5c105ed5..dc1c26b6 100644
--- a/src/resources/specialdb.h
+++ b/src/resources/specialdb.h
@@ -28,9 +28,6 @@ struct SpecialInfo
{
enum TargetMode
{
- TARGET_SELF, // no target selection
- TARGET_FRIEND, // target friendly being
- TARGET_ENEMY, // target hostile being
TARGET_BEING, // target any being
TARGET_POINT // target map location
};
@@ -39,13 +36,9 @@ struct SpecialInfo
std::string name; // displayed name of special
std::string icon; // filename of graphical icon
- bool isActive; // true when the special can be used
TargetMode targetMode; // target mode
- bool hasLevel; // true when the special has levels
- int level; // level of special when applicable
-
- bool hasRechargeBar; // true when the special has a recharge bar
+ bool rechargeable; // true when the special has a recharge bar
int rechargeNeeded; // maximum recharge when applicable
int rechargeCurrent; // current recharge when applicable
};