summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-05-19 20:21:41 +0300
committerAndrei Karas <akaras@inbox.ru>2018-05-19 20:21:41 +0300
commitb2e6c01fcefa5bb4690196193214a5010a7ca14e (patch)
treeba0665527418a59f6426412d66cbea74262547c2 /src
parent1b075b505f315121258e03f895fa6ce2dc0f746c (diff)
downloadmv-b2e6c01fcefa5bb4690196193214a5010a7ca14e.tar.gz
mv-b2e6c01fcefa5bb4690196193214a5010a7ca14e.tar.bz2
mv-b2e6c01fcefa5bb4690196193214a5010a7ca14e.tar.xz
mv-b2e6c01fcefa5bb4690196193214a5010a7ca14e.zip
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)
Diffstat (limited to 'src')
-rw-r--r--src/progs/manaplus/actions/actions.cpp27
1 files changed, 23 insertions, 4 deletions
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))