ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/shop.C
(Generate patch)

Comparing deliantra/server/server/shop.C (file contents):
Revision 1.1 by elmex, Sun Aug 13 17:16:04 2006 UTC vs.
Revision 1.2 by elmex, Mon Aug 14 04:22:05 2006 UTC

1/* 1/*
2 * static char *rcsid_shop_c = 2 * static char *rcsid_shop_c =
3 * "$Id: shop.C,v 1.1 2006/08/13 17:16:04 elmex Exp $"; 3 * "$Id: shop.C,v 1.2 2006/08/14 04:22:05 elmex Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
82 */ 82 */
83 83
84static uint64 approx_range; 84static uint64 approx_range;
85 85
86uint64 query_cost(const object *tmp, object *who, int flag) { 86uint64 query_cost(const object *tmp, object *who, int flag) {
87 uint64 val; 87 double val;
88 int number; /* used to better calculate value */ 88 int number; /* used to better calculate value */
89 int no_bargain; 89 int no_bargain;
90 int identified; 90 int identified;
91 int not_cursed; 91 int not_cursed;
92 int approximate; 92 int approximate;
233 diff = (1. - cha_ratio) * diff 233 diff = (1. - cha_ratio) * diff
234 + cha_ratio * (cha_bonus[who->stats.Cha] - 1.) / (cha_bonus[who->stats.Cha] + 1.); 234 + cha_ratio * (cha_bonus[who->stats.Cha] - 1.) / (cha_bonus[who->stats.Cha] + 1.);
235 235
236 diff = .02 + (.80 - .02) * diff; 236 diff = .02 + (.80 - .02) * diff;
237 237
238 if (flag == F_BUY) val += (uint64) (val * diff); 238 if (flag == F_BUY) val += (val * diff);
239 else if (flag == F_SELL) val -= (uint64) (val * diff); 239 else if (flag == F_SELL) val -= (val * diff);
240 240
241 // now find a price range. the less good we can judge, the larger the range is 241 // now find a price range. the less good we can judge, the larger the range is
242 // then the range is adjusted randomly around the correct value 242 // then the range is adjusted randomly around the correct value
243 if (approximate) 243 if (approximate)
244 approx_range = (uint64) (val / sqrt (lev_identify * 3 + 1)); 244 approx_range = (val / sqrt (lev_identify * 3 + 1));
245 } 245 }
246 246
247 /* I don't think this should really happen - if it does, it indicates and 247 /* I don't think this should really happen - if it does, it indicates and
248 * overflow of diff above. That shoudl only happen if 248 * overflow of diff above. That shoudl only happen if
249 * we are selling objects - in that case, the person just 249 * we are selling objects - in that case, the person just
258 } 258 }
259 259
260 /* if we are in a shop, check how the type of shop should affect the price */ 260 /* if we are in a shop, check how the type of shop should affect the price */
261 if (shop && who) { 261 if (shop && who) {
262 if (flag==F_SELL) 262 if (flag==F_SELL)
263 val=(uint64) ( 263 val= (
264 val 264 val
265 * shop_specialisation_ratio(tmp, who->map) 265 * shop_specialisation_ratio(tmp, who->map)
266 * shopkeeper_approval(who->map, who) 266 * shopkeeper_approval(who->map, who)
267 / shop_greed(who->map) 267 / shop_greed(who->map)
268 ); 268 );
279 * In game terms, a non-specialist shop, might not recognise the true 279 * In game terms, a non-specialist shop, might not recognise the true
280 * value of the items they sell (much like how people sometimes find 280 * value of the items they sell (much like how people sometimes find
281 * antiques in a junk shop in real life). 281 * antiques in a junk shop in real life).
282 */ 282 */
283 if (QUERY_FLAG(tmp, FLAG_PLAYER_SOLD)) 283 if (QUERY_FLAG(tmp, FLAG_PLAYER_SOLD))
284 val=(uint64) ( 284 val= (
285 val 285 val
286 * shop_greed(who->map) 286 * shop_greed(who->map)
287 * shop_specialisation_ratio(tmp, who->map) 287 * shop_specialisation_ratio(tmp, who->map)
288 / shopkeeper_approval(who->map, who) 288 / shopkeeper_approval(who->map, who)
289 ); 289 );
290 else 290 else
291 val=(uint64) ( 291 val= (
292 val 292 val
293 * shop_greed(who->map) 293 * shop_greed(who->map)
294 / (shop_specialisation_ratio(tmp, who->map)*shopkeeper_approval(who->map, who)) 294 / (shop_specialisation_ratio(tmp, who->map)*shopkeeper_approval(who->map, who))
295 ); 295 );
296 } 296 }
297 /* we will also have an extra 0-5% variation between shops of the same type 297 /* we will also have an extra 0-5% variation between shops of the same type
298 * for valuable items (below a value of 50 this effect wouldn't be very 298 * for valuable items (below a value of 50 this effect wouldn't be very
299 * pointful, and could give fun with rounding. 299 * pointful, and could give fun with rounding.
300 */ 300 */
301 if(who->map->path!=NULL && val > 50) 301 if(who->map->path!=NULL && val > 50)
302 val=(uint64) (val+0.05*(sint64)val*cos(tmp->count+strlen(who->map->path))); 302 val= (val+0.05*(sint64)val*cos(tmp->count+strlen(who->map->path)));
303 } 303 }
304 return val; 304 return val;
305} 305}
306 306
307/* Find the coin type that is worth more the 'c'. Starts at the 307/* Find the coin type that is worth more the 'c'. Starts at the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines