summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-18 14:13:09 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-18 14:13:09 +0300
commit0846b3e83759b42d8d5abea155605d7bcc0c2e22 (patch)
tree1e791a8b2a0b7a9dc2b503474c4f041a2076c777
parentda93a53f7630a62f342f51743d63914f3ea5f266 (diff)
downloadevol-hercules-0846b3e83759b42d8d5abea155605d7bcc0c2e22.tar.gz
evol-hercules-0846b3e83759b42d8d5abea155605d7bcc0c2e22.tar.bz2
evol-hercules-0846b3e83759b42d8d5abea155605d7bcc0c2e22.tar.xz
evol-hercules-0846b3e83759b42d8d5abea155605d7bcc0c2e22.zip
Impliment FloorLifeTime in item_db.conf
-rw-r--r--src/Makefile.am2
-rw-r--r--src/map/data/itemd.c9
-rw-r--r--src/map/data/itemd.h1
-rw-r--r--src/map/init.c2
-rw-r--r--src/map/map.c43
-rw-r--r--src/map/map.h9
6 files changed, 66 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f6c504..289c775 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,6 +29,8 @@ MAP_SRC = map/clif.c \
map/itemdb.h \
map/lang.c \
map/lang.h \
+ map/map.c \
+ map/map.h \
map/npc.c \
map/npc.h \
map/parse.c \
diff --git a/src/map/data/itemd.c b/src/map/data/itemd.c
index a862617..7b7bda7 100644
--- a/src/map/data/itemd.c
+++ b/src/map/data/itemd.c
@@ -16,6 +16,15 @@
#include "map/data/itemd.h"
#include "map/struct/itemdext.h"
+struct ItemdExt *itemd_get_by_item(struct item *item)
+{
+ if (!item)
+ return NULL;
+ const int nameid = item->nameid;
+ struct item_data *item_data = itemdb->exists(nameid);
+ return itemd_get(item_data);
+}
+
struct ItemdExt *itemd_get(struct item_data *item)
{
if (!item)
diff --git a/src/map/data/itemd.h b/src/map/data/itemd.h
index 611d6cd..d3c529b 100644
--- a/src/map/data/itemd.h
+++ b/src/map/data/itemd.h
@@ -6,6 +6,7 @@
struct ItemdExt;
+struct ItemdExt *itemd_get_by_item(struct item *item);
struct ItemdExt *itemd_get(struct item_data *item);
struct ItemdExt *itemd_create(void);
diff --git a/src/map/init.c b/src/map/init.c
index a3a7556..1ce4a78 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -37,6 +37,7 @@
#include "map/clif.h"
#include "map/itemdb.h"
#include "map/lang.h"
+#include "map/map.h"
#include "map/npc.h"
#include "map/parse.h"
#include "map/pc.h"
@@ -119,6 +120,7 @@ HPExport void plugin_init (void)
addHookPost("status->set_viewdata", estatus_set_viewdata_post);
addHookPost("clif->set_unit_walking", eclif_set_unit_walking);
addHookPost("clif->move", eclif_move);
+ addHookPost("map->addflooritem", emap_addflooritem_post);
langScriptId = script->add_str("Lang");
}
diff --git a/src/map/map.c b/src/map/map.c
new file mode 100644
index 0000000..08ad216
--- /dev/null
+++ b/src/map/map.c
@@ -0,0 +1,43 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../../../common/HPMi.h"
+#include "../../../common/malloc.h"
+#include "../../../common/mmo.h"
+#include "../../../common/socket.h"
+#include "../../../common/strlib.h"
+#include "../../../common/timer.h"
+#include "../../../map/battle.h"
+#include "../../../map/itemdb.h"
+#include "../../../map/map.h"
+
+#include "map/data/itemd.h"
+#include "map/struct/itemdext.h"
+
+int emap_addflooritem_post(int retVal,
+ struct item *item,
+ int *amount __attribute__ ((unused)),
+ int16 *m __attribute__ ((unused)),
+ int16 *x __attribute__ ((unused)),
+ int16 *y __attribute__ ((unused)),
+ int *first_charid __attribute__ ((unused)),
+ int *second_charid __attribute__ ((unused)),
+ int *third_charid __attribute__ ((unused)),
+ int *flags __attribute__ ((unused)))
+{
+ struct flooritem_data* fitem = (struct flooritem_data*)idb_get(map->id_db, retVal);
+ if (fitem->cleartimer != INVALID_TIMER)
+ {
+ int timeout = battle->bc->flooritem_lifetime;
+ struct ItemdExt *data = itemd_get_by_item(item);
+ if (data)
+ timeout = data->floorLifeTime;
+ timer->delete(fitem->cleartimer, map->clearflooritem_timer);
+ fitem->cleartimer = timer->add(timer->gettick() + timeout, map->clearflooritem_timer, fitem->bl.id, 0);
+ }
+ return retVal;
+}
diff --git a/src/map/map.h b/src/map/map.h
new file mode 100644
index 0000000..9c77905
--- /dev/null
+++ b/src/map/map.h
@@ -0,0 +1,9 @@
+// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// Copyright (c) 2014 Evol developers
+
+#ifndef EVOL_MAP_MAP
+#define EVOL_MAP_MAP
+
+int emap_addflooritem_post(int retVal, struct item *item, int *amount, int16 *m, int16 *x, int16 *y, int *first_charid, int *second_charid, int *third_charid, int *flags);
+
+#endif // EVOL_MAP_MAP