Просмотр исходного кода

Adjusting Vending tax to match official (#2620)

* Adjusting Vending tax to match official
* Fixes #2528.
* There are no taxes on items being sold for less than 100 million. Anything above incurs a 5% tax.
* Refactored the tax code to use a single function.
Thanks to @mazvi, @Jeybla, and @lighta!
Aleos 7 лет назад
Родитель
Сommit
8e002bc993
3 измененных файлов с 24 добавлено и 6 удалено
  1. 3 1
      conf/battle/items.conf
  2. 1 1
      src/map/battle.cpp
  3. 20 4
      src/map/vending.cpp

+ 3 - 1
conf/battle/items.conf

@@ -19,7 +19,9 @@ vending_over_max: yes
 // Tax to apply to all vending transactions (eg: 10000 = 100%, 50 = 0.50%)
 // When a tax is applied, the item's full price is charged to the buyer, but
 // the vender will not get the whole price paid (they get 100% - this tax).
-vending_tax: 200
+// Officially there is no tax for anything less than 100 million zeny, but anything greater incurs a 5% tax.
+// -1 will follow official behavior, 0 will disable taxes while anything else will apply a global tax.
+vending_tax: -1
 
 // Show the buyer's name when successfully vended an item
 buyer_name: yes

+ 1 - 1
src/map/battle.cpp

@@ -8276,7 +8276,7 @@ static const struct _battle_data {
 	{ "hom_rename",                         &battle_config.hom_rename,                      0,      0,      1,              },
 	{ "homunculus_show_growth",             &battle_config.homunculus_show_growth,          0,      0,      1,              },
 	{ "homunculus_friendly_rate",           &battle_config.homunculus_friendly_rate,        100,    0,      INT_MAX,        },
-	{ "vending_tax",                        &battle_config.vending_tax,                     0,      0,      10000,          },
+	{ "vending_tax",                        &battle_config.vending_tax,                     -1,    -1,      10000,          },
 	{ "day_duration",                       &battle_config.day_duration,                    0,      0,      INT_MAX,        },
 	{ "night_duration",                     &battle_config.night_duration,                  0,      0,      INT_MAX,        },
 	{ "mob_remove_delay",                   &battle_config.mob_remove_delay,                60000,  1000,   INT_MAX,        },

+ 20 - 4
src/map/vending.cpp

@@ -96,6 +96,24 @@ void vending_vendinglistreq(struct map_session_data* sd, int id)
 	clif_vendinglist(sd, id, vsd->vending);
 }
 
+/**
+ * Calculates taxes for vending
+ * @param sd: Vender
+ * @param zeny: Total amount to tax
+ * @return Total amount after taxes
+ */
+static double vending_calc_tax(struct map_session_data *sd, double zeny)
+{
+	if (battle_config.vending_tax > 0) // Use custom value
+		zeny -= zeny * (battle_config.vending_tax / 10000.);
+	else if (battle_config.vending_tax == -1) { // Official servers incur a 5% tax on 100+ million
+		if (zeny >= 100000000)
+			zeny -= zeny * (5 / 100.);
+	}
+
+	return zeny;
+}
+
 /**
  * Purchase item(s) from a shop
  * @param sd : buyer player session
@@ -200,8 +218,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
 
 	pc_payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd);
 	achievement_update_objective(sd, AG_SPEND_ZENY, 1, (int)z);
-	if( battle_config.vending_tax )
-		z -= z * (battle_config.vending_tax/10000.);
+	z = vending_calc_tax(sd, z);
 	pc_getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
 
 	for( i = 0; i < count; i++ ) {
@@ -226,8 +243,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
 		}
 
 		pc_cart_delitem(vsd, idx, amount, 0, LOG_TYPE_VENDING);
-		if( battle_config.vending_tax )
-			z -= z * (battle_config.vending_tax/10000.);
+		z = vending_calc_tax(sd, z);
 		clif_vendingreport(vsd, idx, amount, sd->status.char_id, (int)z);
 
 		//print buyer's name