diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-01-01 22:24:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-01-01 22:24:17 +0300 |
commit | 3242c560742518770c6ea97db03bf89d314cb963 (patch) | |
tree | 107e7868125bb67034e0ef3a9ef2101007420033 /src | |
parent | dc7c6e13e5535e4fe78bb84f9920347880022327 (diff) | |
download | evol-hercules-3242c560742518770c6ea97db03bf89d314cb963.tar.gz evol-hercules-3242c560742518770c6ea97db03bf89d314cb963.tar.bz2 evol-hercules-3242c560742518770c6ea97db03bf89d314cb963.tar.xz evol-hercules-3242c560742518770c6ea97db03bf89d314cb963.zip |
Add script function for unequip item by id.
New script function: unequipbyid ID
Diffstat (limited to 'src')
-rw-r--r-- | src/map/init.c | 1 | ||||
-rw-r--r-- | src/map/script.c | 29 | ||||
-rw-r--r-- | src/map/script.h | 1 |
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 |