diff --git a/conf/battle/items.conf b/conf/battle/items.conf index 6210d0d72a..3f927a0b23 100644 --- a/conf/battle/items.conf +++ b/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 diff --git a/src/map/battle.cpp b/src/map/battle.cpp index ddc0234700..7c52b76b60 100644 --- a/src/map/battle.cpp +++ b/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, }, diff --git a/src/map/vending.cpp b/src/map/vending.cpp index c37c67aba2..9be86444db 100755 --- a/src/map/vending.cpp +++ b/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