diff options
Diffstat (limited to 'src/map/itemdb.h')
-rw-r--r-- | src/map/itemdb.h | 235 |
1 files changed, 148 insertions, 87 deletions
diff --git a/src/map/itemdb.h b/src/map/itemdb.h index d33805174..5f0790b10 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -2,8 +2,8 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2016 Hercules Dev Team - * Copyright (C) Athena Dev Teams + * Copyright (C) 2012-2020 Hercules Dev Team + * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,10 +33,29 @@ struct hplugin_data_store; /** * Defines **/ -#define MAX_ITEMDB 0x8000 // 32k array entries in array (the rest goes to the db) +#ifndef MAX_ITEMDB +#define MAX_ITEMDB 0xFFFF +#endif + +#ifndef MAX_ITEM_ID +#if PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114 +#define MAX_ITEM_ID INT32_MAX +#else +#define MAX_ITEM_ID 0xFFFF +#endif +#endif + +#ifndef MAX_ITEMDELAYS #define MAX_ITEMDELAYS 10 // The maximum number of item delays +#endif + +#ifndef MAX_SEARCH #define MAX_SEARCH 5 //Designed for search functions, species max number of matches to display. +#endif + +#ifndef MAX_ITEMS_PER_COMBO #define MAX_ITEMS_PER_COMBO 6 /* maximum amount of items a combo may require */ +#endif #define CARD0_FORGE 0x00FF #define CARD0_CREATE 0x00FE @@ -45,8 +64,17 @@ struct hplugin_data_store; //Marks if the card0 given is "special" (non-item id used to mark pets/created items. [Skotlex] #define itemdb_isspecial(i) ((i) == CARD0_FORGE || (i) == CARD0_CREATE || (i) == CARD0_PET) +#ifndef UNKNOWN_ITEM_ID //Use apple for unknown items. #define UNKNOWN_ITEM_ID 512 +#endif + +#if MAX_ITEM_ID < MAX_ITEMDB +#error "MAX_ITEM_ID must be bigger or same with MAX_ITEMDB" +#endif +#if MAX_ITEM_ID > 0xFFFF && PACKETVER_MAIN_NUM < 20181121 && PACKETVER_RE_NUM < 20180704 && PACKETVER_ZERO_NUM < 20181114 +#error "For clients before 20181121 Main and 20180704 RE and 20181114 zero, MAX_ITEM_ID must be smaller than 0x10000" +#endif enum item_itemid { ITEMID_RED_POTION = 501, @@ -54,6 +82,7 @@ enum item_itemid { ITEMID_WHITE_POTION = 504, ITEMID_BLUE_POTION = 505, ITEMID_APPLE = 512, + ITEMID_CARROT = 515, ITEMID_HOLY_WATER = 523, ITEMID_PUMPKIN = 535, ITEMID_RED_SLIM_POTION = 545, @@ -64,8 +93,10 @@ enum item_itemid { ITEMID_BRANCH_OF_DEAD_TREE = 604, ITEMID_ANODYNE = 605, ITEMID_ALOEBERA = 606, - ITEMID_MAGNIFIER = 611, + ITEMID_SPECTACLES = 611, ITEMID_POISON_BOTTLE = 678, + ITEMID_EARTH_SCROLL_1_3 = 686, + ITEMID_EARTH_SCROLL_1_5 = 687, ITEMID_EMPTY_BOTTLE = 713, ITEMID_EMPERIUM = 714, ITEMID_YELLOW_GEMSTONE = 715, @@ -92,15 +123,16 @@ enum item_itemid { ITEMID_IRON_ORE = 1002, ITEMID_PHRACON = 1010, ITEMID_EMVERETARCON = 1011, - ITEMID_TRAP = 1065, + ITEMID_BOOBY_TRAP = 1065, ITEMID_PILEBUNCKER = 1549, ITEMID_ANGRA_MANYU = 1599, ITEMID_STRANGE_EMBRYO = 6415, ITEMID_FACE_PAINT = 6120, - ITEMID_SCARLET_POINT = 6360, - ITEMID_INDIGO_POINT = 6361, - ITEMID_YELLOW_WISH_POINT = 6362, - ITEMID_LIME_GREEN_POINT = 6363, + ITEMID_SCARLET_PTS = 6360, + ITEMID_INDIGO_PTS = 6361, + ITEMID_YELLOW_WISH_PTS = 6362, + ITEMID_LIME_GREEN_PTS = 6363, + ITEMID_BLACKSMITH_BLESSING = 6635, ITEMID_STONE = 7049, ITEMID_FIRE_BOTTLE = 7135, ITEMID_ACID_BOTTLE = 7136, @@ -109,10 +141,8 @@ enum item_itemid { ITEMID_COATING_BOTTLE = 7139, ITEMID_FRAGMENT_OF_CRYSTAL = 7321, ITEMID_SKULL_ = 7420, - ITEMID_TOKEN_OF_SIEGFRIED = 7621, - ITEMID_GOLD_KEY77 = 7782, - ITEMID_SILVER_KEY77 = 7783, - ITEMID_TRAP_ALLOY = 7940, + ITEMID_SPECIAL_ALLOY_TRAP = 7940, + ITEMID_CATNIP_FRUIT = 11602, ITEMID_RED_POUCH_OF_SURPRISE = 12024, ITEMID_BLOODY_DEAD_BRANCH = 12103, ITEMID_PORING_BOX = 12109, @@ -137,14 +167,34 @@ enum item_itemid { ITEMID_MAGIC_CASTLE = 12308, ITEMID_BULGING_HEAD = 12309, ITEMID_THICK_MANUAL50 = 12312, - ITEMID_NOVICE_MAGNIFIER = 12325, - ITEMID_ANCILLA = 12333, - ITEMID_REPAIR_A = 12392, - ITEMID_REPAIR_B = 12393, - ITEMID_REPAIR_C = 12394, + ITEMID_N_FLY_WING = 12323, + ITEMID_N_BUTTERFLY_WING = 12324, + ITEMID_N_MAGNIFIER = 12325, + ITEMID_ANSILA = 12333, + ITEMID_REPAIRA = 12392, + ITEMID_REPAIRB = 12393, + ITEMID_REPAIRC = 12394, ITEMID_BLACK_THING = 12435, - ITEMID_REINS_OF_MOUNT = 12622, + ITEMID_BOARDING_HALTER = 12622, ITEMID_NOBLE_NAMEPLATE = 12705, + ITEMID_POISON_PARALYSIS = 12717, + ITEMID_POISON_LEECH = 12718, + ITEMID_POISON_OBLIVION = 12719, + ITEMID_POISON_CONTAMINATION = 12720, + ITEMID_POISON_NUMB = 12721, + ITEMID_POISON_FEVER = 12722, + ITEMID_POISON_LAUGHING = 12723, + ITEMID_POISON_FATIGUE = 12724, + ITEMID_NAUTHIZ = 12725, + ITEMID_RAIDO = 12726, + ITEMID_BERKANA = 12727, + ITEMID_ISA = 12728, + ITEMID_OTHILA = 12729, + ITEMID_URUZ = 12730, + ITEMID_THURISAZ = 12731, + ITEMID_WYRD = 12732, + ITEMID_HAGALAZ = 12733, + ITEMID_C_WING_OF_FLY = 12887, ITEMID_DUN_TELE_SCROLL1 = 14527, ITEMID_BATTLE_MANUAL25 = 14532, ITEMID_BATTLE_MANUAL100 = 14533, @@ -159,6 +209,7 @@ enum item_itemid { ITEMID_PILEBUNCKER_S = 16030, ITEMID_PILEBUNCKER_P = 16031, ITEMID_PILEBUNCKER_T = 16032, + ITEMID_LUX_ANIMA = 22540, }; enum cards_item_list { @@ -248,49 +299,6 @@ enum mercenary_scroll_item_list { }; /** - * Cash Food - */ -enum cash_food_item_list { - ITEMID_STR_DISH10_ = 12202, - ITEMID_AGI_DISH10_, // 12203 - ITEMID_INT_DISH10_, // 12204 - ITEMID_DEX_DISH10_, // 12205 - ITEMID_LUK_DISH10_, // 12206 - ITEMID_VIT_DISH10_, // 12207 -}; - -/** - * GC Poison - */ -enum poison_item_list { - ITEMID_POISON_PARALYSIS = 12717, - ITEMID_POISON_LEECH, // 12718 - ITEMID_POISON_OBLIVION, // 12719 - ITEMID_POISON_CONTAMINATION, // 12720 - ITEMID_POISON_NUMB, // 12721 - ITEMID_POISON_FEVER, // 12722 - ITEMID_POISON_LAUGHING, // 12723 - ITEMID_POISON_FATIGUE, // 12724 -}; - - -/** - * Rune Knight - **/ -enum rune_item_list { - ITEMID_NAUTHIZ = 12725, - ITEMID_RAIDO, // 12726 - ITEMID_BERKANA, // 12727 - ITEMID_ISA, // 12728 - ITEMID_OTHILA, // 12729 - ITEMID_URUZ, // 12730 - ITEMID_THURISAZ, // 12731 - ITEMID_WYRD, // 12732 - ITEMID_HAGALAZ, // 12733 - ITEMID_LUX_ANIMA = 22540, -}; - -/** * Geneticist */ enum geneticist_item_list { @@ -352,6 +360,8 @@ enum geneticist_item_list { // enum e_chain_cache { ECC_ORE, + ECC_SIEGFRIED, + ECC_NEO_INSURANCE, /* */ ECC_MAX, }; @@ -362,7 +372,7 @@ enum item_class_upper { ITEMUPPER_UPPER = 0x02, ITEMUPPER_BABY = 0x04, ITEMUPPER_THIRD = 0x08, - ITEMUPPER_THURDUPPER = 0x10, + ITEMUPPER_THIRDUPPER = 0x10, ITEMUPPER_THIRDBABY = 0x20, ITEMUPPER_ALL = 0x3f, // Sum of all the above }; @@ -386,7 +396,7 @@ enum ItemTradeRestrictions { }; /** - * Iten No-use restrictions + * Item No-use restrictions */ enum ItemNouseRestrictions { INR_NONE = 0x0, ///< No restrictions @@ -395,6 +405,26 @@ enum ItemNouseRestrictions { INR_ALL = 0x1 ///< Sum of all the above values }; +/** + * Item Option Types + */ +enum ItemOptionTypes { + IT_OPT_INDEX = 0, + IT_OPT_VALUE, + IT_OPT_PARAM, + IT_OPT_MAX +}; + +/** + * Item name search flags + **/ + +enum item_name_search_flag { + IT_SEARCH_NAME_PARTIAL, + IT_SEARCH_NAME_EXACT, + IT_SEARCH_NAME_MAX, +}; + /** Convenience item list (entry) used in various functions */ struct itemlist_entry { int id; ///< Item ID or (inventory) index @@ -405,19 +435,19 @@ VECTOR_STRUCT_DECL(itemlist, struct itemlist_entry); struct item_combo { struct script_code *script; - unsigned short nameid[MAX_ITEMS_PER_COMBO];/* nameid array */ + int nameid[MAX_ITEMS_PER_COMBO];/* nameid array */ unsigned char count; - unsigned short id;/* id of this combo */ + int id; /* id of this combo */ }; struct item_group { - unsigned short id; - unsigned short *nameid; + int id; + int *nameid; unsigned short qty; }; struct item_chain_entry { - unsigned short id; + int id; unsigned short rate; struct item_chain_entry *next; }; @@ -428,7 +458,7 @@ struct item_chain { }; struct item_package_rand_entry { - unsigned short id; + int id; unsigned short qty; unsigned short rate; unsigned short hours; @@ -439,7 +469,7 @@ struct item_package_rand_entry { }; struct item_package_must_entry { - unsigned short id; + int id; unsigned short qty; unsigned short hours; unsigned int announce : 1; @@ -453,21 +483,34 @@ struct item_package_rand_group { }; struct item_package { - unsigned short id; + int id; struct item_package_rand_group *random_groups; struct item_package_must_entry *must_items; unsigned short random_qty; unsigned short must_qty; }; +struct itemdb_option { + int16 index; + struct script_code *script; +}; + +struct item_lapineddukddak { + int16 NeedCount; + int8 NeedRefineMin; + int8 NeedRefineMax; + VECTOR_DECL(struct itemlist_entry) SourceItems; + struct script_code *script; +}; + struct item_data { - uint16 nameid; + int nameid; char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH]; - //Do not add stuff between value_buy and view_id (see how getiteminfo works) int value_buy; int value_sell; int type; + int subtype; int maxchance; //For logs, for external game info, for scripts: Max drop chance of this item (e.g. 0.01% , etc.. if it = 0, then monsters don't drop it, -1 denotes items sold in shops only) [Lupus] int sex; int equip; @@ -476,16 +519,15 @@ struct item_data { int def; int range; int slot; - int look; + int view_sprite; int elv; int wlv; int view_id; int matk; int elvmax;/* maximum level for this item */ + int dropeffectmode; int delay; -//Lupus: I rearranged order of these fields due to compatibility with ITEMINFO script command -// some script commands should be revised as well... uint64 class_base[3]; ///< Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2) unsigned class_upper : 6; ///< Specifies if the upper-type can equip it (bitfield, 0x01: normal, 0x02: upper, 0x04: baby normal, 0x08: third normal, 0x10: third upper, 0x20: third baby) struct { @@ -495,16 +537,22 @@ struct item_data { struct script_code *script; ///< Default script for everything. struct script_code *equip_script; ///< Script executed once when equipping. struct script_code *unequip_script; ///< Script executed once when unequipping. + struct script_code *rental_start_script; ///< Script executed once this item get rented + struct script_code *rental_end_script; ///< Script executed once this item rent ends struct { unsigned available : 1; unsigned no_refine : 1; // [celest] unsigned delay_consume : 1; ///< Signifies items that are not consumed immediately upon double-click [Skotlex] unsigned trade_restriction : 9; ///< Item trade restrictions mask (@see enum ItemTradeRestrictions) - unsigned autoequip: 1; + unsigned autoequip : 1; + unsigned auto_favorite : 1; unsigned buyingstore : 1; unsigned bindonequip : 1; unsigned keepafteruse : 1; unsigned force_serial : 1; + unsigned no_options: 1; // < disallows use of item options on the item. (non-equippable items are automatically flagged) [Smokexyz] + unsigned drop_announce : 1; // Official Drop Announce [Jedzkie] + unsigned showdropeffect: 1; // < Allow showing effect on item drop [Asheraf] } flag; struct {// item stacking limitation unsigned short amount; @@ -524,6 +572,7 @@ struct item_data { /* TODO add a pointer to some sort of (struct extra) and gather all the not-common vals into it to save memory */ struct item_group *group; struct item_package *package; + struct item_lapineddukddak *lapineddukddak; struct hplugin_data_store *hdata; ///< HPM Plugin Data Store }; @@ -532,7 +581,8 @@ struct item_data { #define itemdb_type(n) (itemdb->search(n)->type) #define itemdb_atk(n) (itemdb->search(n)->atk) #define itemdb_def(n) (itemdb->search(n)->def) -#define itemdb_look(n) (itemdb->search(n)->look) +#define itemdb_subtype(n) (itemdb->search(n)->subtype) +#define itemdb_sprite(n) (itemdb->search(n)->view_sprite) #define itemdb_weight(n) (itemdb->search(n)->weight) #define itemdb_equip(n) (itemdb->search(n)->equip) #define itemdb_usescript(n) (itemdb->search(n)->script) @@ -546,13 +596,14 @@ struct item_data { #define itemdb_value_buy(n) (itemdb->search(n)->value_buy) #define itemdb_value_sell(n) (itemdb->search(n)->value_sell) #define itemdb_canrefine(n) (!itemdb->search(n)->flag.no_refine) +#define itemdb_allowoption(n) (!itemdb->search(n)->flag.no_options) +#define itemdb_showdropeffect(n) (itemdb->search(n)->flag.showdropeffect) +#define itemdb_dropeffectmode(n) (itemdb->search(n)->dropeffectmode) -#define itemdb_is_rune(n) (((n) >= ITEMID_NAUTHIZ && (n) <= ITEMID_HAGALAZ) || (n) == ITEMID_LUX_ANIMA) -#define itemdb_is_element(n) ((n) >= ITEMID_SCARLET_POINT && (n) <= ITEMID_LIME_GREEN_POINT) +#define itemdb_is_element(n) ((n) >= ITEMID_SCARLET_PTS && (n) <= ITEMID_LIME_GREEN_PTS) #define itemdb_is_spellbook(n) ((n) >= ITEMID_MAGIC_BOOK_FB && (n) <= ITEMID_MAGIC_BOOK_DL) #define itemdb_is_poison(n) ((n) >= ITEMID_POISON_PARALYSIS && (n) <= ITEMID_POISON_FATIGUE) #define itemid_isgemstone(n) ((n) >= ITEMID_YELLOW_GEMSTONE && (n) <= ITEMID_BLUE_GEMSTONE) -#define itemdb_iscashfood(n) ((n) >= ITEMID_STR_DISH10_ && (n) <= ITEMID_VIT_DISH10_) #define itemdb_is_GNbomb(n) ((n) >= ITEMID_APPLE_BOMB && (n) <= ITEMID_VERY_HARD_LUMP) #define itemdb_is_GNthrowable(n) ((n) >= ITEMID_MYSTERIOUS_POWDER && (n) <= ITEMID_BLACK_THING_TO_THROW) #define itemid_is_pilebunker(n) ((n) == ITEMID_PILEBUNCKER || (n) == ITEMID_PILEBUNCKER_P || (n) == ITEMID_PILEBUNCKER_S || (n) == ITEMID_PILEBUNCKER_T) @@ -593,21 +644,24 @@ struct itemdb_interface { /* */ struct item_data *array[MAX_ITEMDB]; struct DBMap *other;// int nameid -> struct item_data* + struct DBMap *options; // int opt_id -> struct itemdb_option* struct item_data dummy; //This is the default dummy item used for non-existant items. [Skotlex] /* */ void (*read_groups) (void); void (*read_chains) (void); void (*read_packages) (void); + void (*read_options) (void); /* */ void (*write_cached_packages) (const char *config_filename); bool (*read_cached_packages) (const char *config_filename); /* */ struct item_data* (*name2id) (const char *str); struct item_data* (*search_name) (const char *name); - int (*search_name_array) (struct item_data** data, int size, const char *str, int flag); + int (*search_name_array) (struct item_data **data, const int size, const char *str, enum item_name_search_flag flag); struct item_data* (*load)(int nameid); struct item_data* (*search)(int nameid); struct item_data* (*exists) (int nameid); + struct itemdb_option* (*option_exists) (int idx); bool (*in_group) (struct item_group *group, int nameid); int (*group_item) (struct item_group *group); int (*chain_item) (unsigned short chain_id, int *rate); @@ -617,7 +671,7 @@ struct itemdb_interface { int (*searchrandomid) (struct item_group *group); const char* (*typename) (int type); void (*jobmask2mapid) (uint64 *bclass, uint64 jobmask); - void (*jobid2mapid) (uint64 *bclass, int job_id, bool enable); + void (*jobid2mapid) (uint64 *bclass, int job_class, bool enable); void (*create_dummy_data) (void); struct item_data* (*create_item_data) (int nameid); int (*isequip) (int nameid); @@ -636,10 +690,11 @@ struct itemdb_interface { int (*isrestricted) (struct item *item, int gmlv, int gmlv2, int(*func)(struct item_data *, int, int)); int (*isidentified) (int nameid); int (*isidentified2) (struct item_data *data); - int (*combo_split_atoi) (char *str, int *val); - void (*read_combos) (void); + bool (*read_combodb_libconfig) (void); + bool (*read_combodb_libconfig_sub) (struct config_setting_t *it, int idx, const char *source); int (*gendercheck) (struct item_data *id); int (*validate_entry) (struct item_data *entry, int n, const char *source); + void (*readdb_options_additional_fields) (struct itemdb_option *ito, struct config_setting_t *t, const char *source); void (*readdb_additional_fields) (int itemid, struct config_setting_t *it, int n, const char *source); void (*readdb_job_sub) (struct item_data *id, struct config_setting_t *t); int (*readdb_libconfig_sub) (struct config_setting_t *it, int n, const char *source); @@ -648,10 +703,16 @@ struct itemdb_interface { void (*read) (bool minimal); void (*destroy_item_data) (struct item_data *self, int free_self); int (*final_sub) (union DBKey key, struct DBData *data, va_list ap); + int (*options_final_sub) (union DBKey key, struct DBData *data, va_list ap); void (*clear) (bool total); - struct item_combo * (*id2combo) (unsigned short id); + struct item_combo * (*id2combo) (int id); bool (*is_item_usable) (struct item_data *item); bool (*lookup_const) (const struct config_setting_t *it, const char *name, int *value); + bool (*lookup_const_mask) (const struct config_setting_t *it, const char *name, int *value); + int (*addname_sub) (union DBKey key, struct DBData *data, va_list ap); + bool (*read_libconfig_lapineddukddak) (void); + bool (*read_libconfig_lapineddukddak_sub) (struct config_setting_t *it, const char *source); + bool (*read_libconfig_lapineddukddak_sub_sources) (struct config_setting_t *sources, struct item_data *data); }; #ifdef HERCULES_CORE |