diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-06-21 23:02:49 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-06-21 23:32:17 +0300 |
commit | 0837129c403ddbf56e581b97d4878e85ac1c4489 (patch) | |
tree | 0e99e354d650630f1de67399da5cd475d44012dd /src/emap/script_buildins.c | |
parent | 1af2a074bd643a5564a9911ee6cc9356673182be (diff) | |
download | evol-hercules-0837129c403ddbf56e581b97d4878e85ac1c4489.tar.gz evol-hercules-0837129c403ddbf56e581b97d4878e85ac1c4489.tar.bz2 evol-hercules-0837129c403ddbf56e581b97d4878e85ac1c4489.tar.xz evol-hercules-0837129c403ddbf56e581b97d4878e85ac1c4489.zip |
Add script command for remove card in item by inventory and card index.
New script command: removecardbyindex itemIndex, cardIndex
Diffstat (limited to 'src/emap/script_buildins.c')
-rw-r--r-- | src/emap/script_buildins.c | 37 |
1 files changed, 37 insertions, 0 deletions
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 |