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 | |
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')
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 37 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 1 |
3 files changed, 39 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index 03c8c04..8c9600f 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -149,6 +149,7 @@ HPExport void plugin_init (void) addScriptCommand("successremovecardsindex", "i", successRemoveCardsIndex); addScriptCommand("failedremovecardsindex", "ii", failedRemoveCardsIndex); addScriptCommand("getcardbyindex", "ii", getCardByIndex); + addScriptCommand("removecardbyindex", "ii", removeCardByIndex); addScriptCommand("isstr", "v", isStr); addScriptCommand("setbgteam", "ii", setBgTeam); addScriptCommand("checknpccell", "siii", checkNpcCell); 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 diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 733e0b9..b38f8de 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -50,6 +50,7 @@ BUILDIN(successRefIndex); BUILDIN(successRemoveCardsIndex); BUILDIN(failedRemoveCardsIndex); BUILDIN(getCardByIndex); +BUILDIN(removeCardByIndex); BUILDIN(isStr); BUILDIN(npcSit); BUILDIN(npcStand); |