From 90705929b29445a4569ff5c9ad13b7efcb304e0a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 9 Aug 2017 21:31:02 +0300 Subject: Add different use actions for items. Can be used from chat or from custom item menu from items.xml --- src/net/eathena/inventoryhandler.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/net/eathena/inventoryhandler.cpp') 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) -- cgit v1.2.3-70-g09d2