Browse Source

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 !
Atemo 5 năm trước cách đây
mục cha
commit
b8ee97b6a1
5 tập tin đã thay đổi với 16 bổ sung4 xóa
  1. 3 0
      conf/battle/items.conf
  2. 1 0
      src/map/battle.cpp
  3. 1 0
      src/map/battle.hpp
  4. 7 3
      src/map/clif.cpp
  5. 4 1
      src/map/npc.cpp

+ 3 - 0
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

+ 1 - 0
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"
 };

+ 1 - 0
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"
 };

+ 7 - 3
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);

+ 4 - 1
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;
 	}