summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-02 14:02:49 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-02 14:03:21 +0300
commit0cff16e9883c633d8ef21228ec2991e53da54cd7 (patch)
tree22577e4d3989d2205df5804f678f9cc1ec22b2a9 /src
parent1d23256b629c02102f57b6262d261c6a4c986887 (diff)
downloadevol-hercules-0cff16e9883c633d8ef21228ec2991e53da54cd7.tar.gz
evol-hercules-0cff16e9883c633d8ef21228ec2991e53da54cd7.tar.bz2
evol-hercules-0cff16e9883c633d8ef21228ec2991e53da54cd7.tar.xz
evol-hercules-0cff16e9883c633d8ef21228ec2991e53da54cd7.zip
Reimpliment script function getareadropitem with additional parameter.
getareadropitem map, x1, y1, x2, y2, item [, delFlag]
Diffstat (limited to 'src')
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/script.c59
-rw-r--r--src/map/script.h1
3 files changed, 61 insertions, 0 deletions
diff --git a/src/map/init.c b/src/map/init.c
index cb8eece..3219c61 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -96,6 +96,7 @@ HPExport void plugin_init (void)
addScriptCommand("unequipbyid", "i", unequipById);
addScriptCommand("ispcdead", "", isPcDead);
addScriptCommand("areatimer", "siiiii*", areaTimer);
+ addScriptCommand("getareadropitem", "siiiiv*", getAreaDropItem);
do_init_langs();
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;
+}
diff --git a/src/map/script.h b/src/map/script.h
index e82a57c..b31cfb1 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -38,5 +38,6 @@ BUILDIN(getMapName);
BUILDIN(unequipById);
BUILDIN(isPcDead);
BUILDIN(areaTimer);
+BUILDIN(getAreaDropItem);
#endif // EVOL_MAP_SCRIPT