From b8ee97b6a15d453c6473bf898429ead14bb0a887 Mon Sep 17 00:00:00 2001 From: Atemo Date: Thu, 21 May 2020 21:13:45 +0200 Subject: [PATCH] Added rental_item_novalue config (#3749) * Added a config to always sell the rental items to NPC for 0 Thanks to @Lemongrass3110, @cydh, @aleos89, @Daegaladh for the review ! --- conf/battle/items.conf | 3 +++ src/map/battle.cpp | 1 + src/map/battle.hpp | 1 + src/map/clif.cpp | 10 +++++++--- src/map/npc.cpp | 5 ++++- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/conf/battle/items.conf b/conf/battle/items.conf index be5e6448d0..bc2c21ce5a 100644 --- a/conf/battle/items.conf +++ b/conf/battle/items.conf @@ -134,6 +134,9 @@ broadcast_hide_name: 2 // Enable to sell rental item to NPC shop? (Note 1) rental_transaction: yes +// Sell rental item for 0 to NPC shop regardless of the item value in item_db? (Note 1) +rental_item_novalue: no + // Minimum purchase price of items at a normal Shop // Officially items cannot be purchased for less than 1 Zeny min_shop_buy: 1 diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 772581dd49..712db7102c 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -8952,6 +8952,7 @@ static const struct _battle_data { { "devotion_standup_fix", &battle_config.devotion_standup_fix, 1, 0, 1, }, { "feature.bgqueue", &battle_config.feature_bgqueue, 1, 0, 1, }, { "homunculus_exp_gain", &battle_config.homunculus_exp_gain, 10, 0, 100, }, + { "rental_item_novalue", &battle_config.rental_item_novalue, 1, 0, 1, }, #include "../custom/battle_config_init.inc" }; diff --git a/src/map/battle.hpp b/src/map/battle.hpp index 17c53d4305..5c0938e9cc 100644 --- a/src/map/battle.hpp +++ b/src/map/battle.hpp @@ -676,6 +676,7 @@ struct Battle_Config int devotion_standup_fix; int feature_bgqueue; int homunculus_exp_gain; + int rental_item_novalue; #include "../custom/battle_config_struct.inc" }; diff --git a/src/map/clif.cpp b/src/map/clif.cpp index d3a7adbd85..94a7291cbe 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -2038,9 +2038,13 @@ void clif_selllist(struct map_session_data *sd) if( !pc_can_sell_item(sd, &sd->inventory.u.items_inventory[i], nd->subtype)) continue; - val=sd->inventory_data[i]->value_sell; - if( val < 0 ) - continue; + if (battle_config.rental_item_novalue && sd->inventory.u.items_inventory[i].expire_time) + val = 0; + else { + val = sd->inventory_data[i]->value_sell; + if( val < 0 ) + continue; + } WFIFOW(fd,4+c*10)=i+2; WFIFOL(fd,6+c*10)=val; WFIFOL(fd,10+c*10)=pc_modifysellvalue(sd,val); diff --git a/src/map/npc.cpp b/src/map/npc.cpp index f65a3c5755..f86995f35e 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -2211,7 +2211,10 @@ uint8 npc_selllist(struct map_session_data* sd, int n, unsigned short *item_list return 1; // In official server, this illegal attempt the player will be disconnected } - value = pc_modifysellvalue(sd, sd->inventory_data[idx]->value_sell); + if (battle_config.rental_item_novalue && sd->inventory.u.items_inventory[idx].expire_time) + value = 0; + else + value = pc_modifysellvalue(sd, sd->inventory_data[idx]->value_sell); z+= (double)value*amount; }