summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/beinghandler.cpp17
-rw-r--r--src/net/beinghandler.h1
-rw-r--r--src/net/gameserver/player.cpp4
-rw-r--r--src/net/gameserver/player.h2
-rw-r--r--src/net/protocol.h3
5 files changed, 23 insertions, 4 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index c6db8e33..08d47f01 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -57,6 +57,7 @@ BeingHandler::BeingHandler()
GPMSG_BEING_ENTER,
GPMSG_BEING_LEAVE,
GPMSG_BEINGS_MOVE,
+ GPMSG_BEINGS_DAMAGE,
0
};
handledMessages = _messages;
@@ -89,6 +90,9 @@ void BeingHandler::handleMessage(MessageIn &msg)
case GPMSG_BEING_ATTACK:
handleBeingAttackMessage(msg);
break;
+ case GPMSG_BEINGS_DAMAGE:
+ handleBeingsDamageMessage(msg);
+ break;
/*
case SMSG_BEING_VISIBLE:
@@ -498,3 +502,16 @@ void BeingHandler::handleBeingAttackMessage(MessageIn &msg)
being->setAction(Being::ATTACK);
}
+
+void BeingHandler::handleBeingsDamageMessage(MessageIn &msg)
+{
+ while (msg.getUnreadLength())
+ {
+ Being *being = beingManager->findBeing(msg.readShort());
+ int damage = msg.readShort();
+ if (being)
+ {
+ being->setDamage(damage, 0);
+ }
+ }
+}
diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h
index ca6ad1b6..2cf0e743 100644
--- a/src/net/beinghandler.h
+++ b/src/net/beinghandler.h
@@ -38,6 +38,7 @@ class BeingHandler : public MessageHandler
void handleBeingEnterMessage(MessageIn &msg);
void handleBeingLeaveMessage(MessageIn &msg);
void handleBeingsMoveMessage(MessageIn &msg);
+ void handleBeingsDamageMessage(MessageIn &msg);
};
#endif
diff --git a/src/net/gameserver/player.cpp b/src/net/gameserver/player.cpp
index 46cee230..0a47a6bc 100644
--- a/src/net/gameserver/player.cpp
+++ b/src/net/gameserver/player.cpp
@@ -67,9 +67,9 @@ void Net::GameServer::Player::equip(int itemId, char slot)
Net::GameServer::connection->send(msg);
}
-void Net::GameServer::Player::attack()
+void Net::GameServer::Player::attack(unsigned char direction)
{
MessageOut msg(PGMSG_ATTACK);
-
+ msg.writeByte(direction);
Net::GameServer::connection->send(msg);
}
diff --git a/src/net/gameserver/player.h b/src/net/gameserver/player.h
index 3fb21516..d8f572ae 100644
--- a/src/net/gameserver/player.h
+++ b/src/net/gameserver/player.h
@@ -39,7 +39,7 @@ namespace Net
// void pickUp(...);
void useItem(int itemId);
void equip(int itemId, char slot);
- void attack();
+ void attack(unsigned char direction);
}
}
}
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 081a70fc..80ad48af 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -159,7 +159,7 @@ enum {
GPMSG_BEING_LEAVE = 0x0201, // W being id
PGMSG_WALK = 0x0260, // W*2 destination
GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, C position] [, W*2 destination] }*
- PGMSG_ATTACK = 0x0290, // -
+ PGMSG_ATTACK = 0x0290, // B direction
GPMSG_BEING_ATTACK = 0x0291, // W being id
PGMSG_SAY = 0x02A0, // S text
GPMSG_SAY = 0x02A1, // W being id, S text
@@ -167,6 +167,7 @@ enum {
GPMSG_USE_RESPONSE = 0x0301, // B error
PGMSG_EQUIP = 0x0302, // L item id, B slot
GPMSG_EQUIP_RESPONSE = 0x0303, // B error
+ GPMSG_BEINGS_DAMAGE = 0x0310, // { W being id, W ammount }*
// Chat
CPMSG_ERROR = 0x0401, // B error