Permalink
Browse files

Implemented official buy/sell amount restrictions (#3673)

* Fixes #3666.
* When purchasing items from a NPC shop, the minimum purchase price is always 1 Zeny.
* When selling items to a NPC shop, the minimum sell price is always 0 Zeny.
Thanks to @Balferian and @dastgirp!
  • Loading branch information...
aleos89 committed Nov 8, 2018
1 parent fd91ab6 commit e8c116246e8eaa97d38ab3e426690b06176cfce1
Showing with 16 additions and 4 deletions.
  1. +8 −0 conf/battle/items.conf
  2. +2 −0 src/map/battle.cpp
  3. +2 −0 src/map/battle.hpp
  4. +4 −4 src/map/pc.cpp
@@ -133,3 +133,11 @@ broadcast_hide_name: 2
// Enable to sell rental item to NPC shop? (Note 1)
rental_transaction: yes
// Minimum purchase price of items at a normal Shop
// Officially items cannot be purchased for less than 1 Zeny
min_shop_buy: 1
// Minimum sell price of items at a normal shop
// Officially items can be sold for 0 Zeny
min_shop_sell: 0
@@ -8511,6 +8511,8 @@ static const struct _battle_data {
{ "feature.attendance", &battle_config.feature_attendance, 1, 0, 1, },
{ "feature.privateairship", &battle_config.feature_privateairship, 1, 0, 1, },
{ "rental_transaction", &battle_config.rental_transaction, 1, 0, 1, },
{ "min_shop_buy", &battle_config.min_shop_buy, 1, 0, INT_MAX, },
{ "min_shop_sell", &battle_config.min_shop_sell, 0, 0, INT_MAX, },
#include "../custom/battle_config_init.inc"
};
@@ -651,6 +651,8 @@ struct Battle_Config
int feature_attendance;
int feature_privateairship;
int rental_transaction;
int min_shop_buy;
int min_shop_sell;
#include "../custom/battle_config_struct.inc"
};
@@ -4294,8 +4294,8 @@ int pc_modifybuyvalue(struct map_session_data *sd,int orig_value)
if(rate1 < rate2) rate1 = rate2;
if(rate1)
val = (int)((double)orig_value*(double)(100-rate1)/100.);
if(val < 0) val = 0;
if(orig_value > 0 && val < 1) val = 1;
if(val < battle_config.min_shop_buy)
val = battle_config.min_shop_buy;
return val;
}
@@ -4310,8 +4310,8 @@ int pc_modifysellvalue(struct map_session_data *sd,int orig_value)
rate = 5+skill*2-((skill==10)? 1:0);
if(rate)
val = (int)((double)orig_value*(double)(100+rate)/100.);
if(val < 0) val = 0;
if(orig_value > 0 && val < 1) val = 1;
if (val < battle_config.min_shop_sell)
val = battle_config.min_shop_sell;
return val;
}

0 comments on commit e8c1162

Please sign in to comment.