From b2e6c01fcefa5bb4690196193214a5010a7ca14e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 19 May 2018 20:21:41 +0300 Subject: Extend /use chat command for support color and use action. Example: /use 501 - use item 501 in default way. /use "501,1" 0 - use item 501 in default way. /use "501,2" - use item 501 with color 2 (acorn not have colors) /use 501 1 - use item 501 with action 1 (plant) --- src/progs/manaplus/actions/actions.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/progs/manaplus') diff --git a/src/progs/manaplus/actions/actions.cpp b/src/progs/manaplus/actions/actions.cpp index 188b76591..83068a61c 100644 --- a/src/progs/manaplus/actions/actions.cpp +++ b/src/progs/manaplus/actions/actions.cpp @@ -1692,17 +1692,36 @@ impHandler0(homunculusFeed) impHandler(useItem) { - const int itemId = atoi(event.args.c_str()); + StringVect pars; + if (!splitParameters(pars, event.args, " ,", '\"')) + return false; + const int sz = pars.size(); + if (sz < 1) + return false; + + const int itemId = atoi(pars[0].c_str()); if (itemId < SPELL_MIN_ID) { const Inventory *const inv = PlayerInfo::getInventory(); if (inv != nullptr) { - // +++ ignoring item color for now + ItemColor color = ItemColor_one; + int16_t useType = 0; + StringVect pars2; + if (!splitParameters(pars2, pars[0], " ,", '\"')) + return false; + const int sz2 = pars2.size(); + if (sz2 < 1) + return false; + if (sz2 >= 2) + color = fromInt(atoi(pars2[1].c_str()), ItemColor); + if (sz >= 2) + useType = atoi(pars[1].c_str()); const Item *const item = inv->findItem(itemId, - ItemColor_one); - PlayerInfo::useEquipItem(item, 0, Sfx_true); + color); + logger->log("test: %d,%d, %d", itemId, CAST_S32(color), CAST_S32(useType)); + PlayerInfo::useEquipItem(item, useType, Sfx_true); } } else if (itemId < SKILL_MIN_ID && (spellManager != nullptr)) -- cgit v1.2.3-70-g09d2