[1] | 1 | // Copyright (c) Athena Dev Teams - Licensed under GNU GPL |
---|
| 2 | // For more information, see LICENCE in the main folder |
---|
| 3 | |
---|
| 4 | #ifndef _ITEMDB_H_ |
---|
| 5 | #define _ITEMDB_H_ |
---|
| 6 | |
---|
| 7 | #include "../common/mmo.h" // ITEM_NAME_LENGTH |
---|
| 8 | |
---|
| 9 | #define MAX_RANDITEM 10000 |
---|
| 10 | |
---|
| 11 | #define MAX_SEARCH 5 //Designed for search functions, species max number of matches to display. |
---|
| 12 | |
---|
| 13 | #define ITEMID_YELLOW_GEMSTONE 715 |
---|
| 14 | #define ITEMID_RED_GEMSTONE 716 |
---|
| 15 | #define ITEMID_BLUE_GEMSTONE 717 |
---|
| 16 | #define itemid_isgemstone(id) ( (id) >= ITEMID_YELLOW_GEMSTONE && (id) <= ITEMID_BLUE_GEMSTONE ) |
---|
| 17 | |
---|
| 18 | #define ITEMID_TRAP 1065 |
---|
| 19 | |
---|
| 20 | //The only item group required by the code to be known. See const.txt for the full list. |
---|
| 21 | #define IG_FINDINGORE 6 |
---|
| 22 | #define IG_POTION 37 |
---|
| 23 | //The max. item group count (increase this when needed). |
---|
| 24 | #define MAX_ITEMGROUP 47 |
---|
| 25 | |
---|
| 26 | #define CARD0_FORGE 0x00FF |
---|
| 27 | #define CARD0_CREATE 0x00FE |
---|
| 28 | #define CARD0_PET ((short)0xFF00) |
---|
| 29 | |
---|
| 30 | //Marks if the card0 given is "special" (non-item id used to mark pets/created items. [Skotlex] |
---|
| 31 | #define itemdb_isspecial(i) (i == CARD0_FORGE || i == CARD0_CREATE || i == CARD0_PET) |
---|
| 32 | |
---|
| 33 | //Use apple for unknown items. |
---|
| 34 | #define UNKNOWN_ITEM_ID 512 |
---|
| 35 | |
---|
| 36 | struct item_data { |
---|
| 37 | int nameid; |
---|
| 38 | char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH]; |
---|
| 39 | //Do not add stuff between value_buy and wlv (see how getiteminfo works) |
---|
| 40 | int value_buy; |
---|
| 41 | int value_sell; |
---|
| 42 | int type; |
---|
| 43 | 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) [Lupus] |
---|
| 44 | int sex; |
---|
| 45 | int equip; |
---|
| 46 | int weight; |
---|
| 47 | int atk; |
---|
| 48 | int def; |
---|
| 49 | int range; |
---|
| 50 | int slot; |
---|
| 51 | int look; |
---|
| 52 | int elv; |
---|
| 53 | int wlv; |
---|
| 54 | int view_id; |
---|
| 55 | //Lupus: I rearranged order of these fields due to compatibility with ITEMINFO script command |
---|
| 56 | // some script commands should be revised as well... |
---|
| 57 | unsigned int class_base[3]; //Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2) |
---|
| 58 | unsigned class_upper : 3; //Specifies if the upper-type can equip it (bitfield, 1: normal, 2: upper, 3: baby) |
---|
| 59 | struct { |
---|
| 60 | unsigned short chance; |
---|
| 61 | int id; |
---|
| 62 | } mob[MAX_SEARCH]; //Holds the mobs that have the highest drop rate for this item. [Skotlex] |
---|
| 63 | struct script_code *script; //Default script for everything. |
---|
| 64 | struct script_code *equip_script; //Script executed once when equipping. |
---|
| 65 | struct script_code *unequip_script;//Script executed once when unequipping. |
---|
| 66 | struct { |
---|
| 67 | unsigned available : 1; |
---|
| 68 | unsigned value_notdc : 1; |
---|
| 69 | unsigned value_notoc : 1; |
---|
| 70 | short no_equip; |
---|
| 71 | unsigned no_refine : 1; // [celest] |
---|
| 72 | unsigned delay_consume : 1; // Signifies items that are not consumed immediately upon double-click [Skotlex] |
---|
| 73 | unsigned trade_restriction : 7; //Item restrictions mask [Skotlex] |
---|
| 74 | unsigned autoequip: 1; |
---|
| 75 | } flag; |
---|
| 76 | short gm_lv_trade_override; //GM-level to override trade_restriction |
---|
| 77 | }; |
---|
| 78 | |
---|
| 79 | struct item_group { |
---|
| 80 | int nameid[MAX_RANDITEM]; |
---|
| 81 | int qty; //Counts amount of items in the group. |
---|
| 82 | }; |
---|
| 83 | |
---|
| 84 | struct item_data* itemdb_searchname(const char *name); |
---|
| 85 | int itemdb_searchname_array(struct item_data** data, int size, const char *str); |
---|
| 86 | struct item_data* itemdb_load(int nameid); |
---|
| 87 | struct item_data* itemdb_search(int nameid); |
---|
| 88 | struct item_data* itemdb_exists(int nameid); |
---|
| 89 | #define itemdb_name(n) itemdb_search(n)->name |
---|
| 90 | #define itemdb_jname(n) itemdb_search(n)->jname |
---|
| 91 | #define itemdb_type(n) itemdb_search(n)->type |
---|
| 92 | #define itemdb_atk(n) itemdb_search(n)->atk |
---|
| 93 | #define itemdb_def(n) itemdb_search(n)->def |
---|
| 94 | #define itemdb_look(n) itemdb_search(n)->look |
---|
| 95 | #define itemdb_weight(n) itemdb_search(n)->weight |
---|
| 96 | #define itemdb_equip(n) itemdb_search(n)->equip |
---|
| 97 | #define itemdb_usescript(n) itemdb_search(n)->script |
---|
| 98 | #define itemdb_equipscript(n) itemdb_search(n)->script |
---|
| 99 | #define itemdb_wlv(n) itemdb_search(n)->wlv |
---|
| 100 | #define itemdb_range(n) itemdb_search(n)->range |
---|
| 101 | #define itemdb_slot(n) itemdb_search(n)->slot |
---|
| 102 | #define itemdb_available(n) (itemdb_exists(n) && itemdb_search(n)->flag.available) |
---|
| 103 | #define itemdb_viewid(n) (itemdb_search(n)->view_id) |
---|
| 104 | #define itemdb_autoequip(n) (itemdb_search(n)->flag.autoequip) |
---|
| 105 | |
---|
| 106 | int itemdb_group_bonus(struct map_session_data* sd, int itemid); |
---|
| 107 | int itemdb_searchrandomid(int flags); |
---|
| 108 | |
---|
| 109 | #define itemdb_value_buy(n) itemdb_search(n)->value_buy |
---|
| 110 | #define itemdb_value_sell(n) itemdb_search(n)->value_sell |
---|
| 111 | #define itemdb_value_notdc(n) itemdb_search(n)->flag.value_notdc |
---|
| 112 | #define itemdb_value_notoc(n) itemdb_search(n)->flag.value_notoc |
---|
| 113 | #define itemdb_canrefine(n) itemdb_search(n)->flag.no_refine |
---|
| 114 | //Item trade restrictions [Skotlex] |
---|
| 115 | int itemdb_isdropable_sub(struct item_data *, int, int); |
---|
| 116 | int itemdb_cantrade_sub(struct item_data*, int, int); |
---|
| 117 | int itemdb_canpartnertrade_sub(struct item_data*, int, int); |
---|
| 118 | int itemdb_cansell_sub(struct item_data*,int, int); |
---|
| 119 | int itemdb_cancartstore_sub(struct item_data*, int, int); |
---|
| 120 | int itemdb_canstore_sub(struct item_data*, int, int); |
---|
| 121 | int itemdb_canguildstore_sub(struct item_data*, int, int); |
---|
| 122 | int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(struct item_data*, int, int)); |
---|
| 123 | #define itemdb_isdropable(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_isdropable_sub) |
---|
| 124 | #define itemdb_cantrade(item, gmlv, gmlv2) itemdb_isrestricted(item, gmlv, gmlv2, itemdb_cantrade_sub) |
---|
| 125 | #define itemdb_canpartnertrade(item, gmlv, gmlv2) itemdb_isrestricted(item, gmlv, gmlv2, itemdb_canpartnertrade_sub) |
---|
| 126 | #define itemdb_cansell(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_cansell_sub) |
---|
| 127 | #define itemdb_cancartstore(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_cancartstore_sub) |
---|
| 128 | #define itemdb_canstore(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_canstore_sub) |
---|
| 129 | #define itemdb_canguildstore(item, gmlv) itemdb_isrestricted(item , gmlv, 0, itemdb_canguildstore_sub) |
---|
| 130 | |
---|
| 131 | int itemdb_isequip(int); |
---|
| 132 | int itemdb_isequip2(struct item_data *); |
---|
| 133 | int itemdb_isidentified(int); |
---|
| 134 | int itemdb_isstackable(int); |
---|
| 135 | int itemdb_isstackable2(struct item_data *); |
---|
| 136 | |
---|
| 137 | void itemdb_reload(void); |
---|
| 138 | |
---|
| 139 | void do_final_itemdb(void); |
---|
| 140 | int do_init_itemdb(void); |
---|
| 141 | |
---|
| 142 | #endif /* _ITEMDB_H_ */ |
---|