summaryrefslogtreecommitdiff
path: root/src/emap/script_buildins.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emap/script_buildins.c')
-rw-r--r--src/emap/script_buildins.c65
1 files changed, 65 insertions, 0 deletions
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