… | |
… | |
169 | /* Value of the wand is multiplied by the number of |
169 | /* Value of the wand is multiplied by the number of |
170 | * charges. the treasure code already sets up the value |
170 | * charges. the treasure code already sets up the value |
171 | * 50 charges is used as the baseline. |
171 | * 50 charges is used as the baseline. |
172 | */ |
172 | */ |
173 | if (tmp->flag [FLAG_IDENTIFIED] || !tmp->need_identify () || identified) |
173 | if (tmp->flag [FLAG_IDENTIFIED] || !tmp->need_identify () || identified) |
174 | val *= tmp->stats.food / 50; |
174 | val *= tmp->stats.food; |
175 | else /* if not identified, presume one charge */ |
175 | /* if not identified, presume one charge */ |
176 | val /= 50; |
176 | val /= 50; |
177 | } |
177 | } |
178 | |
178 | |
179 | /* Limit amount of money you can get for really great items. */ |
179 | /* Limit amount of money you can get for really great items. */ |
180 | if (flag == F_SELL) |
180 | if (flag == F_SELL) |
181 | val = value_limit (val, number, who, shop); |
181 | val = value_limit (val, number, who, shop); |
… | |
… | |
189 | * AND Cha = 30 will get optimal price. |
189 | * AND Cha = 30 will get optimal price. |
190 | * Thus charisma will never get useless. |
190 | * Thus charisma will never get useless. |
191 | * -b.e. edler@heydernet.de |
191 | * -b.e. edler@heydernet.de |
192 | */ |
192 | */ |
193 | |
193 | |
194 | if (who && who->type == PLAYER) |
194 | if (who && who->is_player ()) |
195 | { |
195 | { |
196 | int lev_bargain = 0; |
196 | int lev_bargain = 0; |
197 | int lev_identify = 0; |
197 | int lev_identify = 0; |
198 | |
198 | |
199 | if (!no_bargain) |
199 | if (!no_bargain) |
… | |
… | |
217 | /* ratio determines how much of the price modification |
217 | /* ratio determines how much of the price modification |
218 | * will come from the basic stat charisma |
218 | * will come from the basic stat charisma |
219 | * the rest will come from the level in bargaining skill |
219 | * the rest will come from the level in bargaining skill |
220 | */ |
220 | */ |
221 | const double cha_ratio = 0.40; |
221 | const double cha_ratio = 0.40; |
222 | double bargaining = min (0., 1. - powf (lev_bargain / MAXLEVEL_TREASURE, 0.25)); |
222 | double bargaining = max (0., 1. - powf (double (lev_bargain) / MAXLEVEL_TREASURE, 0.25)); |
223 | double charisma = (cha_bonus[who->stats.Cha] - 1.) / (cha_bonus[who->stats.Cha] + 1.); |
223 | double charisma = (cha_bonus[who->stats.Cha] - 1.) / (cha_bonus[who->stats.Cha] + 1.); |
224 | |
224 | |
225 | double factor = (1. - cha_ratio) * bargaining + cha_ratio * charisma; |
225 | double factor = (1. - cha_ratio) * bargaining + cha_ratio * charisma; |
226 | |
226 | |
227 | // scale 0..1 to 2 .. 80% |
227 | // scale 0..1 to 2 .. 80% |
… | |
… | |
1034 | |
1034 | |
1035 | struct shopinv |
1035 | struct shopinv |
1036 | { |
1036 | { |
1037 | char *item_sort; |
1037 | char *item_sort; |
1038 | char *item_real; |
1038 | char *item_real; |
|
|
1039 | sint64 value; |
1039 | uint16 type; |
1040 | uint16 type; |
1040 | uint32 nrof; |
1041 | uint32 nrof; |
1041 | }; |
1042 | }; |
1042 | |
1043 | |
1043 | /* There are a lot fo extra casts in here just to suppress warnings - it |
1044 | /* There are a lot fo extra casts in here just to suppress warnings - it |
… | |
… | |
1076 | * so the display is properly. |
1077 | * so the display is properly. |
1077 | */ |
1078 | */ |
1078 | if (tmp->nrof == 0) |
1079 | if (tmp->nrof == 0) |
1079 | items[*numitems].nrof++; |
1080 | items[*numitems].nrof++; |
1080 | items[*numitems].type = tmp->type; |
1081 | items[*numitems].type = tmp->type; |
|
|
1082 | |
|
|
1083 | items[*numitems].value = tmp->value; |
1081 | |
1084 | |
1082 | switch (tmp->type) |
1085 | switch (tmp->type) |
1083 | { |
1086 | { |
1084 | #if 0 |
1087 | #if 0 |
1085 | case BOOTS: |
1088 | case BOOTS: |
… | |
… | |
1097 | #endif |
1100 | #endif |
1098 | |
1101 | |
1099 | default: |
1102 | default: |
1100 | items[*numitems].item_sort = strdup (query_base_name (tmp, 0)); |
1103 | items[*numitems].item_sort = strdup (query_base_name (tmp, 0)); |
1101 | items[*numitems].item_real = strdup (query_base_name (tmp, 1)); |
1104 | items[*numitems].item_real = strdup (query_base_name (tmp, 1)); |
|
|
1105 | items[*numitems].value += tmp->value; |
1102 | (*numitems)++; |
1106 | (*numitems)++; |
1103 | break; |
1107 | break; |
1104 | } |
1108 | } |
1105 | |
1109 | |
1106 | tmp->set_flag (FLAG_UNPAID); |
1110 | tmp->set_flag (FLAG_UNPAID); |
… | |
… | |
1162 | { |
1166 | { |
1163 | /* Collapse items of the same name together */ |
1167 | /* Collapse items of the same name together */ |
1164 | if ((i + 1) < numitems && !strcmp (items[i].item_real, items[i + 1].item_real)) |
1168 | if ((i + 1) < numitems && !strcmp (items[i].item_real, items[i + 1].item_real)) |
1165 | items[i + 1].nrof += items[i].nrof; |
1169 | items[i + 1].nrof += items[i].nrof; |
1166 | else |
1170 | else |
1167 | buf.printf (" %4d %s\n", items[i].nrof ? items[i].nrof : 1, items[i].nrof == 1 ? items[i].item_sort : items[i].item_real); |
1171 | { |
|
|
1172 | buf.printf ( |
|
|
1173 | " %4d %s\n for %s\n", |
|
|
1174 | items[i].nrof ? items[i].nrof : 1, |
|
|
1175 | items[i].nrof == 1 ? items[i].item_sort : items[i].item_real, |
|
|
1176 | cost_string_from_value (items[i].value, op->flag [FLAG_WIZ] ? 0 : 1)); |
|
|
1177 | } |
1168 | |
1178 | |
1169 | free (items[i].item_sort); |
1179 | free (items[i].item_sort); |
1170 | free (items[i].item_real); |
1180 | free (items[i].item_real); |
1171 | } |
1181 | } |
1172 | |
1182 | |