| version 1.43 | | version 1.44 |
|---|
| | |
| /* | | /* |
| * static char *rcsid_shop_c = | | * static char *rcsid_shop_c = |
| * "$Id: shop.c,v 1.43 2005/10/06 05:27:35 qal21 Exp $"; | | * "$Id: shop.c,v 1.44 2005/10/06 13:18:54 cavesomething Exp $"; |
| */ | | */ |
| | | |
| /* | | /* |
| | |
| #define NEUTRAL_RATIO 0.8 | | #define NEUTRAL_RATIO 0.8 |
| | | |
| static uint64 pay_from_container(object *pl, object *pouch, uint64 to_pay); | | static uint64 pay_from_container(object *pl, object *pouch, uint64 to_pay); |
| | | static uint64 value_limit(uint64 val, int quantity, object *who, int isshop); |
| | | |
| #define NUM_COINS 3 /* number of coin types */ | | #define NUM_COINS 3 /* number of coin types */ |
| static char *coins[] = {"platinacoin", "goldcoin", "silvercoin", NULL}; | | static char *coins[] = {"platinacoin", "goldcoin", "silvercoin", NULL}; |
| | |
| } | | } |
| | | |
| /* Limit amount of money you can get for really great items. */ | | /* Limit amount of money you can get for really great items. */ |
| if ((flag==F_TRUE || flag==F_SELL) && who) | | if (flag==F_TRUE || flag==F_SELL) |
| val=value_limit(val, number, who->map, shop); | | val=value_limit(val, number, who, shop); |
| | | |
| /* This modification is for bargaining skill. | | /* This modification is for bargaining skill. |
| * Now only players with max level in bargaining | | * Now only players with max level in bargaining |
| | |
| /* limit the value of items based on the wealth of the shop. If the item is close | | /* limit the value of items based on the wealth of the shop. If the item is close |
| * to the maximum value a shop will offer, we start to reduce it, if the item is | | * to the maximum value a shop will offer, we start to reduce it, if the item is |
| * below the minimum value the shop is prepared to trade in, then we don't | | * below the minimum value the shop is prepared to trade in, then we don't |
| * want it and offer nothing. | | * want it and offer nothing. If it isn't a shop, check whether we should do generic |
| | | * value reduction. |
| * | | * |
| */ | | */ |
| uint64 value_limit(uint64 val, int quantity, mapstruct *map, int isshop) { | | static uint64 value_limit(uint64 val, int quantity, object *who, int isshop) { |
| uint64 newval, unit_price; | | uint64 newval, unit_price; |
| unit_price=val/quantity; | | unit_price=val/quantity; |
| newval=unit_price; | | newval=unit_price; |
| if (isshop) { | | mapstruct *map; |
| | | if (!isshop || !who) { |
| | | newval=8000+isqrt(unit_price)*20; |
| | | } |
| | | else { |
| | | if (!who->map) { |
| | | LOG(llevError, "value_limit: asked shop price for ob %s on NULL map", who->name); |
| | | return val; |
| | | } |
| | | map=who->map; |
| if (map->shopmin && unit_price < map->shopmin) return 0; | | if (map->shopmin && unit_price < map->shopmin) return 0; |
| else if (map->shopmax && unit_price > map->shopmax/2) | | else if (map->shopmax && unit_price > map->shopmax/2) |
| newval=MIN((map->shopmax/2)+isqrt(unit_price-map->shopmax/2), map->shopmax); | | newval=MIN((map->shopmax/2)+isqrt(unit_price-map->shopmax/2), map->shopmax); |