From 91160e197b1a1f85f21cfad874e80fa286d9294f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Dec 2014 13:40:11 +0300 Subject: Add chat command for use item by id. New chat command: /use ITEMID Alias: /useitem ITEMID --- src/actions/actions.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/actions/actions.cpp') diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 93e160750..4cd863dc9 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -26,7 +26,9 @@ #include "emoteshortcut.h" #include "game.h" #include "graphicsmanager.h" +#include "inventory.h" #include "itemshortcut.h" +#include "spellmanager.h" #include "actions/actiondef.h" @@ -53,6 +55,7 @@ #include "gui/windows/setupwindow.h" #include "gui/windows/shopwindow.h" #include "gui/windows/shortcutwindow.h" +#include "gui/windows/skilldialog.h" #include "gui/widgets/tabs/chat/chattab.h" @@ -76,6 +79,7 @@ #include "resources/iteminfo.h" #include "resources/resourcemanager.h" +#include "resources/skillconsts.h" #include "resources/db/itemdb.h" @@ -1287,4 +1291,28 @@ impHandler0(mercenaryFire) return true; } +impHandler(useItem) +{ + const int itemId = atoi(event.args.c_str()); + + if (itemId < SPELL_MIN_ID) + { + const Inventory *const inv = PlayerInfo::getInventory(); + if (inv) + { + // +++ ignoring item color for now + const Item *const item = inv->findItem(itemId, 1); + PlayerInfo::useEquipItem(item, true); + } + } + else if (itemId < SKILL_MIN_ID && spellManager) + { + spellManager->useItem(itemId); + } + else if (skillDialog) + { + skillDialog->useItem(itemId); + } +} + } // namespace Actions -- cgit v1.2.3-70-g09d2