diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-09 21:31:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-09 21:31:02 +0300 |
commit | 90705929b29445a4569ff5c9ad13b7efcb304e0a (patch) | |
tree | 0dae1643b0fb33131fb918fe3a1729e879379e26 /src/net/eathena | |
parent | b3fa7a53a29a1001935514a38f140af2b816771a (diff) | |
download | mv-90705929b29445a4569ff5c9ad13b7efcb304e0a.tar.gz mv-90705929b29445a4569ff5c9ad13b7efcb304e0a.tar.bz2 mv-90705929b29445a4569ff5c9ad13b7efcb304e0a.tar.xz mv-90705929b29445a4569ff5c9ad13b7efcb304e0a.zip |
Add different use actions for items.
Can be used from chat or from custom item menu from items.xml
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 23 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.h | 3 | ||||
-rw-r--r-- | src/net/eathena/packetsout.inc | 2 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index f59dc4c6c..40ae67d5d 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -38,6 +38,7 @@ #include "debug.h" extern int packetVersion; +extern int serverVersion; // this conversion from bit corrupted LOOK_* to EquipSlot // for how it corrupted, see BeingRecv::processBeingChangeLookContinue @@ -117,6 +118,28 @@ void InventoryHandler::useItem(const Item *const item) const outMsg.writeInt32(item->getId(), "unused"); } +void InventoryHandler::useItem(const Item *const item, + const int16_t useType) const +{ + if (item == nullptr) + return; + + if (serverVersion >= 19) + { + createOutPacket(CMSG_PLAYER_INVENTORY_USE2); + outMsg.writeInt16(CAST_S16( + item->getInvIndex() + INVENTORY_OFFSET), "index"); + outMsg.writeInt16(useType, "use type"); + } + else + { + createOutPacket(CMSG_PLAYER_INVENTORY_USE); + outMsg.writeInt16(CAST_S16( + item->getInvIndex() + INVENTORY_OFFSET), "index"); + outMsg.writeInt32(item->getId(), "unused"); + } +} + void InventoryHandler::dropItem(const Item *const item, const int amount) const { if (item == nullptr) diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h index 3a804fb3d..79155ddaa 100644 --- a/src/net/eathena/inventoryhandler.h +++ b/src/net/eathena/inventoryhandler.h @@ -43,6 +43,9 @@ class InventoryHandler final : public Ea::InventoryHandler void useItem(const Item *const item) const override final; + void useItem(const Item *const item, + const int16_t useType) const override final; + void dropItem(const Item *const item, const int amount) const override final; diff --git a/src/net/eathena/packetsout.inc b/src/net/eathena/packetsout.inc index c1ad6ac4f..92c986755 100644 --- a/src/net/eathena/packetsout.inc +++ b/src/net/eathena/packetsout.inc @@ -259,6 +259,8 @@ packet(CMSG_SET_STATUS, 0x0b0e, 0, nullptr); packet(CMSG_ONLINE_LIST, 0x0b0f, 0, nullptr); +packet(CMSG_PLAYER_INVENTORY_USE2, 0x0b26, 6, nullptr); + #ifndef PACKETS_UPDATE // 0 packet(CMSG_ALCHEMIST_RANKS, 0x0000, 0, nullptr); |