summaryrefslogtreecommitdiff
path: root/src/emap
diff options
context:
space:
mode:
Diffstat (limited to 'src/emap')
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script_buildins.c37
-rw-r--r--src/emap/script_buildins.h1
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);