From 0837129c403ddbf56e581b97d4878e85ac1c4489 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Jun 2016 23:02:49 +0300 Subject: Add script command for remove card in item by inventory and card index. New script command: removecardbyindex itemIndex, cardIndex --- src/emap/script_buildins.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/emap/script_buildins.c') diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 7b5a224..ea73dfe 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -1370,6 +1370,43 @@ BUILDIN(getCardByIndex) return true; } +BUILDIN(removeCardByIndex) +{ + getSD() + getInventoryIndex(2) + + if (sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount <= 0) + { + ShowWarning("zero amount\n"); + script_pushint(st, -1); + return false; + } + + if (sd->status.inventory[n].equip) + { + ShowWarning("item equipped\n"); + script_pushint(st, -1); + return false; + } + + const int c = script_getnum(st, 3); + if (c < 0 || c >= MAX_SLOTS) + { + ShowWarning("wrong slot id\n"); + script_pushint(st, -1); + return false; + } + + const int amount = sd->status.inventory[n].amount; + clif->delitem(sd, n, amount, DELITEM_FAILREFINE); + sd->status.inventory[n].card[c] = 0; + clif->additem(sd, n, amount, 0); + status_calc_pc(sd, SCO_NONE); + + script_pushint(st, 0); + return true; +} + // return paramater type // 0 - int // 1 - string -- cgit v1.2.3-60-g2f50