From 0846b3e83759b42d8d5abea155605d7bcc0c2e22 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 18 Dec 2014 14:13:09 +0300 Subject: Impliment FloorLifeTime in item_db.conf --- src/Makefile.am | 2 ++ src/map/data/itemd.c | 9 +++++++++ src/map/data/itemd.h | 1 + src/map/init.c | 2 ++ src/map/map.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/map/map.h | 9 +++++++++ 6 files changed, 66 insertions(+) create mode 100644 src/map/map.c create mode 100644 src/map/map.h 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 +#include +#include + +#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 -- cgit v1.2.3-70-g09d2