summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/script.c29
-rw-r--r--src/map/script.h1
3 files changed, 29 insertions, 2 deletions
diff --git a/src/map/init.c b/src/map/init.c
index f5e9e1a..1685a82 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -93,6 +93,7 @@ HPExport void plugin_init (void)
addScriptCommand("changemusic", "ss", changeMusic);
addScriptCommand("setnpcdialogtitle", "s", setNpcDialogTitle);
addScriptCommand("getmapname", "", getMapName);
+ addScriptCommand("unequipbyid", "i", unequipById);
do_init_langs();
diff --git a/src/map/script.c b/src/map/script.c
index 79e6043..d225052 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -706,8 +706,33 @@ BUILDIN(getMapName)
if (!sd || sd->bl.m == -1)
{
script_pushstr(st, aStrdup(""));
- return 1;
+ return false;
}
script_pushstr(st, aStrdup(map->list[sd->bl.m].name));
- return 0;
+ return true;
+}
+
+BUILDIN(unequipById)
+{
+ int nameid = 0;
+ int i;
+ struct item_data *item_data;
+ TBL_PC *sd = script->rid2sd(st);
+
+ if (sd == NULL)
+ return false;
+
+ nameid = script_getnum(st, 2);
+ if((item_data = itemdb->exists(nameid)) == NULL)
+ return false;
+ for (i = 0; i < EQI_MAX; i++)
+ {
+ const int idx = sd->equip_index[i];
+ if (idx >= 0)
+ {
+ if (sd->status.inventory[idx].nameid == nameid)
+ pc->unequipitem(sd, idx, 1 | 2);
+ }
+ }
+ return true;
}
diff --git a/src/map/script.h b/src/map/script.h
index bdd78ec..ef3208c 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -35,5 +35,6 @@ BUILDIN(clear);
BUILDIN(changeMusic);
BUILDIN(setNpcDialogTitle);
BUILDIN(getMapName);
+BUILDIN(unequipById);
#endif // EVOL_MAP_SCRIPT