summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorJessica Tölke <jtoelke@mail.upb.de>2011-02-26 16:13:05 +0100
committerJessica Tölke <jtoelke@mail.upb.de>2011-02-26 16:49:55 +0100
commita3c9810fdc9d090d02c75dce7a261c64d192502d (patch)
tree3fd37cb14666f47588ec524e968c51f5f84eeb7d /src/map/script.c
parent9da7223209942907024898e76edb69ea598fcee0 (diff)
downloadtmwa-a3c9810fdc9d090d02c75dce7a261c64d192502d.tar.gz
tmwa-a3c9810fdc9d090d02c75dce7a261c64d192502d.tar.bz2
tmwa-a3c9810fdc9d090d02c75dce7a261c64d192502d.tar.xz
tmwa-a3c9810fdc9d090d02c75dce7a261c64d192502d.zip
Adding an option to scriptfunction getareadropitem.
Count items on the floor and optionally delete them. Reviewed by Stefan Beller
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/map/script.c b/src/map/script.c
index ad175c3..fc0169b 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -551,7 +551,7 @@ struct
{
buildin_getareausers, "getareausers", "siiii"},
{
- buildin_getareadropitem, "getareadropitem", "siiiii"},
+ buildin_getareadropitem, "getareadropitem", "siiiiii"},
{
buildin_enablenpc, "enablenpc", "s"},
{
@@ -4730,10 +4730,24 @@ int buildin_getareadropitem_sub (struct block_list *bl, va_list ap)
return 0;
}
+int buildin_getareadropitem_sub_anddelete (struct block_list *bl, va_list ap)
+{
+ int item = va_arg (ap, int);
+ int *amount = va_arg (ap, int *);
+ struct flooritem_data *drop = (struct flooritem_data *) bl;
+
+ if (drop->item_data.nameid == item) {
+ (*amount) += drop->item_data.amount;
+ clif_clearflooritem(drop, 0);
+ map_delobject(drop->bl.id, drop->bl.type);
+ }
+ return 0;
+}
+
int buildin_getareadropitem (struct script_state *st)
{
char *str;
- int m, x0, y0, x1, y1, item, amount = 0;
+ int m, x0, y0, x1, y1, item, amount = 0, delitems = 0;
struct script_data *data;
str = conv_str (st, &(st->stack->stack_data[st->start + 2]));
@@ -4755,13 +4769,20 @@ int buildin_getareadropitem (struct script_state *st)
else
item = conv_num (st, data);
+ delitems = conv_num (st, &(st->stack->stack_data[st->start + 8]));
+
if ((m = map_mapname2mapid (str)) < 0)
{
push_val (st->stack, C_INT, -1);
return 0;
}
- map_foreachinarea (buildin_getareadropitem_sub,
- m, x0, y0, x1, y1, BL_ITEM, item, &amount);
+ if (delitems)
+ map_foreachinarea (buildin_getareadropitem_sub_anddelete,
+ m, x0, y0, x1, y1, BL_ITEM, item, &amount);
+ else
+ map_foreachinarea (buildin_getareadropitem_sub,
+ m, x0, y0, x1, y1, BL_ITEM, item, &amount);
+
push_val (st->stack, C_INT, amount);
return 0;
}