Skip to content

Commit

Permalink
Add item attribute what prevent item removing on use.
Browse files Browse the repository at this point in the history
New item attribute: KeepAfterUse
  • Loading branch information
4144 committed Dec 2, 2014
1 parent 274aaeb commit 40a239f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions db/re/item_db.conf
Expand Up @@ -31,6 +31,7 @@ item_db: (
BindOnEquip: true/false (boolean, defaults to false)
BuyingStore: true/false (boolean, defaults to false)
Delay: Delay to use item (int, defaults to 0)
KeepAfterUse: true/false (boolean, defaults to false)
Trade: { (defaults to no restrictions)
override: GroupID (int, defaults to 100)
nodrop: true/false (boolean, defaults to false)
Expand Down
1 change: 1 addition & 0 deletions doc/item_db.txt
Expand Up @@ -36,6 +36,7 @@ item_db: (
BindOnEquip: true/false (boolean, defaults to false)
BuyingStore: true/false (boolean, defaults to false)
Delay: Delay to use item (int, defaults to 0)
KeepAfterUse: true/false (boolean, defaults to false)
Trade: { (defaults to no restrictions)
override: GroupID (int, defaults to 100)
nodrop: true/false (boolean, defaults to false)
Expand Down
5 changes: 4 additions & 1 deletion src/map/itemdb.c
Expand Up @@ -1787,9 +1787,12 @@ int itemdb_readdb_libconfig_sub(config_setting_t *it, int n, const char *source)
if ( (t = libconfig->setting_get_member(it, "BuyingStore")) )
id.flag.buyingstore = libconfig->setting_get_bool(t) ? 1 : 0;

if ((t = libconfig->setting_get_member(it, "KeepAfterUse")))
id.flag.keepafteruse = libconfig->setting_get_bool(t) ? 1 : 0;

if (libconfig->setting_lookup_int(it, "Delay", &i32) && i32 >= 0)
id.delay = i32;

if ( (t = libconfig->setting_get_member(it, "Trade")) ) {
if (config_setting_is_group(t)) {
config_setting_t *tt = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/map/itemdb.h
Expand Up @@ -414,6 +414,7 @@ struct item_data {
unsigned autoequip: 1;
unsigned buyingstore : 1;
unsigned bindonequip : 1;
unsigned keepafteruse : 1;
} flag;
struct {// item stacking limitation
unsigned short amount;
Expand Down
2 changes: 1 addition & 1 deletion src/map/pc.c
Expand Up @@ -4519,7 +4519,7 @@ int pc_useitem(struct map_session_data *sd,int n) {
if( sd->inventory_data[n]->flag.delay_consume )
clif->useitemack(sd,n,amount,true);
else {
if( sd->status.inventory[n].expire_time == 0 ) {
if (sd->status.inventory[n].expire_time == 0 && !(sd->inventory_data[n]->flag.keepafteruse)) {
clif->useitemack(sd,n,amount-1,true);
pc->delitem(sd,n,1,1,0,LOG_TYPE_CONSUME); // Rental Usable Items are not deleted until expiration
} else
Expand Down

0 comments on commit 40a239f

Please sign in to comment.