diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-03-30 17:44:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-03-30 17:44:47 +0300 |
commit | 8290e4011fb9c5532c96f916d17d19567077f995 (patch) | |
tree | e6fcca955c78ee8aad072b05c8c9c3de5b8fc382 | |
parent | e2874a254e4270b58727a1fb3285cc167d04fa38 (diff) | |
download | evol-hercules-8290e4011fb9c5532c96f916d17d19567077f995.tar.gz evol-hercules-8290e4011fb9c5532c96f916d17d19567077f995.tar.bz2 evol-hercules-8290e4011fb9c5532c96f916d17d19567077f995.tar.xz evol-hercules-8290e4011fb9c5532c96f916d17d19567077f995.zip |
Add script command successremovecardsindex.
For remove all cards from item by inventory index.
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 65 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 1 |
3 files changed, 67 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index f3b98cb..a9aaba5 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -143,6 +143,7 @@ HPExport void plugin_init (void) addScriptCommand("failedrefindex", "i", failedRefIndex); addScriptCommand("downrefindex", "ii", downRefIndex); addScriptCommand("successrefindex", "ii", successRefIndex); + addScriptCommand("successremovecardsindex", "i", successRemoveCardsIndex); 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 05f6841..cbd246b 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -1182,6 +1182,71 @@ BUILDIN(successRefIndex) return true; } +BUILDIN(successRemoveCardsIndex) +{ + int i = -1, c, cardflag = 0; + + getSD() + getInventoryIndex(2) + + if (sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount <= 0) + return false; + + i = n; + + if (itemdb_isspecial(sd->status.inventory[i].card[0])) + return true; + + for (c = sd->inventory_data[i]->slot - 1; c >= 0; --c) + { + if (sd->status.inventory[i].card[c] && itemdb_type(sd->status.inventory[i].card[c]) == IT_CARD) + { // extract this card from the item + int flag; + struct item item_tmp; + memset(&item_tmp, 0, sizeof(item_tmp)); + cardflag = 1; + item_tmp.nameid = sd->status.inventory[i].card[c]; + item_tmp.identify = 1; + + if ((flag = pc->additem(sd, &item_tmp, 1, LOG_TYPE_SCRIPT))) + { + // get back the cart in inventory + clif->additem(sd, 0, 0, flag); + map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + } + } + } + + if (cardflag == 1) + { + //if card was remove replace item with no card + int flag, j; + struct item item_tmp; + memset(&item_tmp,0,sizeof(item_tmp)); + + item_tmp.nameid = sd->status.inventory[i].nameid; + item_tmp.identify = 1; + item_tmp.refine = sd->status.inventory[i].refine; + item_tmp.attribute = sd->status.inventory[i].attribute; + item_tmp.expire_time = sd->status.inventory[i].expire_time; + item_tmp.bound = sd->status.inventory[i].bound; + + for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++) + item_tmp.card[j] = sd->status.inventory[i].card[j]; + + pc->delitem(sd, i, 1, 0, DELITEM_MATERIALCHANGE, LOG_TYPE_SCRIPT); + if ((flag = pc->additem(sd, &item_tmp, 1, LOG_TYPE_SCRIPT))) + { + //chk if can be spawn in inventory otherwise put on floor + clif->additem(sd, 0, 0, flag); + map->addflooritem(&sd->bl, &item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 0); + } + + clif->misceffect(&sd->bl,3); + } + return true; +} + // return paramater type // 0 - int // 1 - string diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 978f234..b3c3598 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -47,6 +47,7 @@ BUILDIN(isUnitWalking); BUILDIN(failedRefIndex); BUILDIN(downRefIndex); BUILDIN(successRefIndex); +BUILDIN(successRemoveCardsIndex); BUILDIN(isStr); BUILDIN(npcSit); BUILDIN(npcStand); |