1 | |
1 | |
2 | /* |
2 | /* |
3 | * static char *rcsid_shop_c = |
3 | * static char *rcsid_shop_c = |
4 | * "$Id: shop.C,v 1.13 2006/09/12 01:09:54 root Exp $"; |
4 | * "$Id: shop.C,v 1.14 2006/09/12 19:20:08 root Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
104 | approximate = flag & F_APPROX; |
104 | approximate = flag & F_APPROX; |
105 | shop = flag & F_SHOP; |
105 | shop = flag & F_SHOP; |
106 | flag &= ~(F_NO_BARGAIN | F_IDENTIFIED | F_NOT_CURSED | F_APPROX | F_SHOP); |
106 | flag &= ~(F_NO_BARGAIN | F_IDENTIFIED | F_NOT_CURSED | F_APPROX | F_SHOP); |
107 | |
107 | |
108 | if (tmp->type == MONEY) |
108 | if (tmp->type == MONEY) |
109 | return (tmp->nrof * tmp->value); |
109 | return tmp->nrof * tmp->value; |
|
|
110 | |
110 | if (tmp->type == GEM) |
111 | if (tmp->type == GEM) |
111 | { |
112 | { |
112 | if (flag == F_TRUE) |
113 | if (flag == F_TRUE) |
113 | return (tmp->nrof * tmp->value); |
114 | return (tmp->nrof * tmp->value); |
|
|
115 | |
114 | if (flag == F_BUY) |
116 | if (flag == F_BUY) |
115 | return (sint64) (1.03 * tmp->nrof * tmp->value); |
117 | return (sint64) (1.03 * tmp->nrof * tmp->value); |
|
|
118 | |
116 | if (flag == F_SELL) |
119 | if (flag == F_SELL) |
117 | return (sint64) (0.97 * tmp->nrof * tmp->value); |
120 | return (sint64) (0.97 * tmp->nrof * tmp->value); |
|
|
121 | |
118 | LOG (llevError, "Query_cost: Gem type with unknown flag : %d\n", flag); |
122 | LOG (llevError, "Query_cost: Gem type with unknown flag %d: %s\n", flag, tmp->debug_desc ()); |
119 | return 0; |
123 | return 0; |
120 | } |
124 | } |
|
|
125 | |
121 | number = tmp->nrof; |
126 | number = tmp->nrof; |
122 | if (number == 0) |
127 | if (number == 0) |
123 | number = 1; |
128 | number = 1; |
124 | if (QUERY_FLAG (tmp, FLAG_IDENTIFIED) || !need_identify (tmp) || identified) |
129 | if (QUERY_FLAG (tmp, FLAG_IDENTIFIED) || !need_identify (tmp) || identified) |
125 | { |
130 | { |
… | |
… | |
224 | const typedata *tmptype; |
229 | const typedata *tmptype; |
225 | |
230 | |
226 | tmptype = get_typedata (tmp->type); |
231 | tmptype = get_typedata (tmp->type); |
227 | |
232 | |
228 | if (find_skill_by_number (who, SK_BARGAINING)) |
233 | if (find_skill_by_number (who, SK_BARGAINING)) |
229 | { |
|
|
230 | lev_bargain = find_skill_by_number (who, SK_BARGAINING)->level; |
234 | lev_bargain = find_skill_by_number (who, SK_BARGAINING)->level; |
231 | } |
235 | |
232 | if (tmptype) |
236 | if (tmptype) |
233 | { |
237 | { |
234 | idskill1 = tmptype->identifyskill; |
238 | idskill1 = tmptype->identifyskill; |
|
|
239 | |
235 | if (idskill1) |
240 | if (idskill1) |
236 | { |
241 | { |
237 | idskill2 = tmptype->identifyskill2; |
242 | idskill2 = tmptype->identifyskill2; |
|
|
243 | |
238 | if (find_skill_by_number (who, idskill1)) |
244 | if (find_skill_by_number (who, idskill1)) |
239 | { |
|
|
240 | lev_identify = find_skill_by_number (who, idskill1)->level; |
245 | lev_identify = find_skill_by_number (who, idskill1)->level; |
241 | } |
246 | |
242 | if (idskill2 && find_skill_by_number (who, idskill2)) |
247 | if (idskill2 && find_skill_by_number (who, idskill2)) |
243 | { |
|
|
244 | lev_identify += find_skill_by_number (who, idskill2)->level; |
248 | lev_identify += find_skill_by_number (who, idskill2)->level; |
245 | } |
|
|
246 | } |
249 | } |
247 | } |
250 | } |
248 | else |
251 | else |
249 | LOG (llevError, "Query_cost: item %s hasn't got a valid type\n", &tmp->name); |
252 | LOG (llevError, "Query_cost: item %s hasn't got a valid type\n", tmp->debug_desc ()); |
250 | |
253 | |
251 | /* ratio determines how much of the price modification |
254 | /* ratio determines how much of the price modification |
252 | * will come from the basic stat charisma |
255 | * will come from the basic stat charisma |
253 | * the rest will come from the level in bargaining skill |
256 | * the rest will come from the level in bargaining skill |
254 | */ |
257 | */ |