diff options
Diffstat (limited to 'src/emap/data/itemd.c')
-rw-r--r-- | src/emap/data/itemd.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/emap/data/itemd.c b/src/emap/data/itemd.c new file mode 100644 index 0000000..4b171b2 --- /dev/null +++ b/src/emap/data/itemd.c @@ -0,0 +1,68 @@ +// 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 "map/battle.h" +#include "map/itemdb.h" + +#include "emap/data/itemd.h" +#include "emap/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) + return NULL; + + struct ItemdExt *data = getFromITEMDATA(item, 0); + if (!data) + { + data = itemd_create(); + addToITEMDATA(item, data, 0, true); + } + return data; +} + +struct ItemdExt *itemd_create(void) +{ + struct ItemdExt *data = NULL; + CREATE(data, struct ItemdExt, 1); + if (!data) + return NULL; + data->floorLifeTime = battle->bc->flooritem_lifetime; + data->allowPickup = true; + data->requiredStr = 0; + data->requiredAgi = 0; + data->requiredVit = 0; + data->requiredInt = 0; + data->requiredDex = 0; + data->requiredLuk = 0; + data->requiredMaxHp = 0; + data->requiredMaxSp = 0; + data->requiredAtk = 0; + data->requiredMAtkMin = 0; + data->requiredMAtkMax = 0; + data->requiredDef = 0; + data->requiredMDef = 0; + data->useEffect = -1; + data->useFailEffect = -1; + data->unequipEffect = -1; + data->unequipFailEffect = -1; + return data; +} |