diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-03-30 18:10:07 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-03-30 18:10:07 +0300 |
commit | b826af28255cbd69318929aeb06b4164feed5588 (patch) | |
tree | 227894e4b607180e6c18001341aa383bcf8f4380 /src/emap | |
parent | 8290e4011fb9c5532c96f916d17d19567077f995 (diff) | |
download | plugin-b826af28255cbd69318929aeb06b4164feed5588.tar.gz plugin-b826af28255cbd69318929aeb06b4164feed5588.tar.bz2 plugin-b826af28255cbd69318929aeb06b4164feed5588.tar.xz plugin-b826af28255cbd69318929aeb06b4164feed5588.zip |
Add script command failedremovecardsindex.
For remove all cards from item by inventory index.
Diffstat (limited to 'src/emap')
-rw-r--r-- | src/emap/init.c | 1 | ||||
-rw-r--r-- | src/emap/script_buildins.c | 85 | ||||
-rw-r--r-- | src/emap/script_buildins.h | 1 |
3 files changed, 87 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c index a9aaba5..4e63623 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -144,6 +144,7 @@ HPExport void plugin_init (void) addScriptCommand("downrefindex", "ii", downRefIndex); addScriptCommand("successrefindex", "ii", successRefIndex); addScriptCommand("successremovecardsindex", "i", successRemoveCardsIndex); + addScriptCommand("failedremovecardsindex", "ii", failedRemoveCardsIndex); 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 cbd246b..d62d4bc 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -1247,6 +1247,91 @@ BUILDIN(successRemoveCardsIndex) return true; } +/// <type>=0 : will destroy both the item and the cards. +/// <type>=1 : will keep the item, but destroy the cards. +/// <type>=2 : will keep the cards, but destroy the item. +/// <type>=? : will just display the failure effect. +BUILDIN(failedRemoveCardsIndex) +{ + 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; + + int typefail = script_getnum(st, 3); + + 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) + { + cardflag = 1; + + if (typefail == 2) + { // add cards to inventory, clear + int flag; + struct item item_tmp; + + memset(&item_tmp, 0, sizeof(item_tmp)); + + item_tmp.nameid = sd->status.inventory[i].card[c]; + item_tmp.identify = 1; + + if((flag = pc->additem(sd, &item_tmp, 1, LOG_TYPE_SCRIPT))) + { + 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 (typefail == 0 || typefail == 2) + { + // destroy the item + pc->delitem(sd, i, 1, 0, DELITEM_FAILREFINE, LOG_TYPE_SCRIPT); + } + else if (typefail == 1) + { + // destroy the 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_FAILREFINE, LOG_TYPE_SCRIPT); + + if((flag = pc->additem(sd, &item_tmp, 1, LOG_TYPE_SCRIPT))) + { + 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, 2); + } + + return true; +} + // return paramater type // 0 - int // 1 - string diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index b3c3598..1d83813 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -48,6 +48,7 @@ BUILDIN(failedRefIndex); BUILDIN(downRefIndex); BUILDIN(successRefIndex); BUILDIN(successRemoveCardsIndex); +BUILDIN(failedRemoveCardsIndex); BUILDIN(isStr); BUILDIN(npcSit); BUILDIN(npcStand); |