diff options
author | Matheus Macabu <mkbu95@gmail.com> | 2013-05-01 21:00:06 -0300 |
---|---|---|
committer | Matheus Macabu <mkbu95@gmail.com> | 2013-05-01 21:01:54 -0300 |
commit | c347ebacd8116b49e0e839abab1be35432ce0446 (patch) | |
tree | d2ce9350884fe69fdbdb78d8fa6aa133d007c6e5 /src/map | |
parent | 7a625b95742b780622482dc5d4de2c6622aac9ae (diff) | |
download | hercules-c347ebacd8116b49e0e839abab1be35432ce0446.tar.gz hercules-c347ebacd8116b49e0e839abab1be35432ce0446.tar.bz2 hercules-c347ebacd8116b49e0e839abab1be35432ce0446.tar.xz hercules-c347ebacd8116b49e0e839abab1be35432ce0446.zip |
Implemented "item_nouse.txt" to prevent players from using items under certain flags (which are pre-determined).
Fixes issue:7064. Thanks to Muad_Dib for providing the item list for this db.
Signed-off-by: Matheus Macabu <mkbu95@gmail.com>
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/itemdb.c | 26 | ||||
-rw-r--r-- | src/map/itemdb.h | 8 | ||||
-rw-r--r-- | src/map/pc.c | 4 |
3 files changed, 38 insertions, 0 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 386f38c5a..0b4419e0c 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -727,6 +727,31 @@ static bool itemdb_read_buyingstore(char* fields[], int columns, int current) return true; } + +/******************************************* +** Item usage restriction (item_nouse.txt) +********************************************/ +static bool itemdb_read_nouse(char* fields[], int columns, int current) +{// <nameid>,<flag>,<override> + int nameid, flag, override; + struct item_data* id; + + nameid = atoi(fields[0]); + + if( ( id = itemdb_exists(nameid) ) == NULL ) { + ShowWarning("itemdb_read_nouse: Invalid item id %d.\n", nameid); + return false; + } + + flag = atoi(fields[1]); + override = atoi(fields[2]); + + id->item_usage.flag = flag; + id->item_usage.override = override; + + return true; +} + /** * @return: amount of retrieved entries. **/ @@ -1304,6 +1329,7 @@ static void itemdb_read(void) { sv_readdb(db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay); sv_readdb(db_path, "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack); sv_readdb(db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); + sv_readdb(db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse); itemdb_uid_load(); } diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 362b42cff..c441de26a 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -68,6 +68,10 @@ enum { ITEMID_SPECIAL_COOLER, } mecha_item_list; +enum { + NOUSE_SITTING = 0x01, +} item_nouse_list; + //The only item group required by the code to be known. See const.txt for the full list. #define IG_FINDINGORE 6 #define IG_POTION 37 @@ -136,6 +140,10 @@ struct item_data { unsigned int storage:1; unsigned int guildstorage:1; } stack; + struct {// used by item_nouse.txt + unsigned int flag; + unsigned short override; + } item_usage; short gm_lv_trade_override; //GM-level to override trade_restriction /* bugreport:309 */ struct item_combo **combos; diff --git a/src/map/pc.c b/src/map/pc.c index afc92594b..892c27e87 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -4086,6 +4086,10 @@ int pc_isUseitem(struct map_session_data *sd,int n) if( !item->script ) //if it has no script, you can't really consume it! return 0; + if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) { + return 0; // You cannot use this item while sitting. + } + switch( nameid ) //@TODO, lot oh harcoded nameid here { case 605: // Anodyne |