diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-01-02 14:02:49 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-01-02 14:03:21 +0300 |
commit | 0cff16e9883c633d8ef21228ec2991e53da54cd7 (patch) | |
tree | 22577e4d3989d2205df5804f678f9cc1ec22b2a9 /src/map/script.c | |
parent | 1d23256b629c02102f57b6262d261c6a4c986887 (diff) | |
download | plugin-0cff16e9883c633d8ef21228ec2991e53da54cd7.tar.gz plugin-0cff16e9883c633d8ef21228ec2991e53da54cd7.tar.bz2 plugin-0cff16e9883c633d8ef21228ec2991e53da54cd7.tar.xz plugin-0cff16e9883c633d8ef21228ec2991e53da54cd7.zip |
Reimpliment script function getareadropitem with additional parameter.
getareadropitem map, x1, y1, x2, y2, item [, delFlag]
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index c38a377..ab42198 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -784,3 +784,62 @@ BUILDIN(areaTimer) return true; } + +static int buildin_getareadropitem_sub_del(struct block_list *bl, va_list ap) +{ + const int item = va_arg(ap, int); + int *const amount = va_arg(ap, int *); + struct flooritem_data *drop = (struct flooritem_data *)bl; + + if (drop->item_data.nameid == item) + { + (*amount) += drop->item_data.amount; + map->clearflooritem(&drop->bl); + } + + return 0; +} + +BUILDIN(getAreaDropItem) +{ + const char *const str = script_getstr(st, 2); + int16 m; + int x0 = script_getnum(st, 3); + int y0 = script_getnum(st, 4); + int x1 = script_getnum(st, 5); + int y1 = script_getnum(st, 6); + int item; + int amount = 0; + + if (script_isstringtype(st, 7)) + { + const char *name = script_getstr(st, 7); + struct item_data *item_data = itemdb->search_name(name); + item = UNKNOWN_ITEM_ID; + if (item_data) + item = item_data->nameid; + } + else + { + item = script_getnum(st, 7); + } + + if ((m = map->mapname2mapid(str)) < 0) + { + script_pushint(st, -1); + return true; + } + + if (script_hasdata(st, 8) && script_getnum(st, 8)) + { + map->foreachinarea(buildin_getareadropitem_sub_del, + m, x0, y0, x1, y1, BL_ITEM, item, &amount); + } + else + { + map->foreachinarea(script->buildin_getareadropitem_sub, + m, x0, y0, x1, y1, BL_ITEM, item, &amount); + } + script_pushint(st, amount); + return true; +} |