… | |
… | |
206 | * AND Cha = 30 will get optimal price. |
206 | * AND Cha = 30 will get optimal price. |
207 | * Thus charisma will never get useless. |
207 | * Thus charisma will never get useless. |
208 | * -b.e. edler@heydernet.de |
208 | * -b.e. edler@heydernet.de |
209 | */ |
209 | */ |
210 | |
210 | |
211 | if (who != NULL && who->type == PLAYER) |
211 | if (who && who->type == PLAYER) |
212 | { |
212 | { |
213 | int lev_bargain = 0; |
213 | int lev_bargain = 0; |
214 | int lev_identify = 0; |
214 | int lev_identify = 0; |
215 | int idskill1 = 0; |
|
|
216 | int idskill2 = 0; |
|
|
217 | const typedata *tmptype; |
|
|
218 | |
|
|
219 | tmptype = get_typedata (tmp->type); |
|
|
220 | |
215 | |
221 | if (find_skill_by_number (who, SK_BARGAINING)) |
216 | if (find_skill_by_number (who, SK_BARGAINING)) |
222 | lev_bargain = find_skill_by_number (who, SK_BARGAINING)->level; |
217 | lev_bargain = find_skill_by_number (who, SK_BARGAINING)->level; |
223 | |
218 | |
224 | if (tmptype) |
219 | if (const typedata *tmptype = get_typedata (tmp->type)) |
225 | { |
220 | { |
226 | idskill1 = tmptype->identifyskill; |
221 | if (int idskill1 = tmptype->identifyskill) |
227 | |
|
|
228 | if (idskill1) |
|
|
229 | { |
222 | { |
230 | idskill2 = tmptype->identifyskill2; |
223 | int idskill2 = tmptype->identifyskill2; |
231 | |
224 | |
232 | if (find_skill_by_number (who, idskill1)) |
225 | if (find_skill_by_number (who, idskill1)) |
233 | lev_identify = find_skill_by_number (who, idskill1)->level; |
226 | lev_identify = find_skill_by_number (who, idskill1)->level; |
234 | |
227 | |
235 | if (idskill2 && find_skill_by_number (who, idskill2)) |
228 | if (idskill2 && find_skill_by_number (who, idskill2)) |
236 | lev_identify += find_skill_by_number (who, idskill2)->level; |
229 | lev_identify += find_skill_by_number (who, idskill2)->level; |
237 | } |
230 | } |
238 | } |
231 | } |
239 | else |
|
|
240 | LOG (llevError, "Query_cost: item %s hasn't got a valid type\n", tmp->debug_desc ()); |
|
|
241 | |
232 | |
242 | /* ratio determines how much of the price modification |
233 | /* ratio determines how much of the price modification |
243 | * will come from the basic stat charisma |
234 | * will come from the basic stat charisma |
244 | * the rest will come from the level in bargaining skill |
235 | * the rest will come from the level in bargaining skill |
245 | */ |
236 | */ |
… | |
… | |
418 | |
409 | |
419 | if (coin == NULL) |
410 | if (coin == NULL) |
420 | return "nothing"; |
411 | return "nothing"; |
421 | |
412 | |
422 | num = real_value / coin->value; |
413 | num = real_value / coin->value; |
|
|
414 | |
423 | if (num == 1) |
415 | if (num == 1) |
424 | sprintf (buf, "about one %s", &coin->object::name); |
416 | sprintf (buf, "about one %s", &coin->object::name); |
425 | else if (num < 5) |
417 | else if (num < 5) |
426 | sprintf (buf, "a few %s", &coin->object::name_pl); |
418 | sprintf (buf, "a few %s", &coin->object::name_pl); |
427 | else if (num < 10) |
419 | else if (num < 10) |
… | |
… | |
432 | sprintf (buf, "lots of %s", &coin->object::name_pl); |
424 | sprintf (buf, "lots of %s", &coin->object::name_pl); |
433 | else if (num < 1000) |
425 | else if (num < 1000) |
434 | sprintf (buf, "a great many %s", &coin->object::name_pl); |
426 | sprintf (buf, "a great many %s", &coin->object::name_pl); |
435 | else |
427 | else |
436 | sprintf (buf, "a vast quantity of %s", &coin->object::name_pl); |
428 | sprintf (buf, "a vast quantity of %s", &coin->object::name_pl); |
|
|
429 | |
437 | return buf; |
430 | return buf; |
438 | } |
431 | } |
439 | } |
432 | } |
440 | } |
433 | } |
441 | |
434 | |
… | |
… | |
673 | unpaid_price += query_cost (item, pl, F_BUY | F_SHOP); |
666 | unpaid_price += query_cost (item, pl, F_BUY | F_SHOP); |
674 | } |
667 | } |
675 | |
668 | |
676 | if (unpaid_price > player_wealth) |
669 | if (unpaid_price > player_wealth) |
677 | { |
670 | { |
678 | char buf[MAX_BUF]; |
671 | dynbuf_text buf; |
679 | char cost[MAX_BUF]; |
|
|
680 | char missing[MAX_BUF]; |
|
|
681 | |
672 | |
682 | snprintf (cost, MAX_BUF, "%s", cost_string_from_value (unpaid_price, 0)); |
673 | buf << "You have " << unpaid_count |
683 | snprintf (missing, MAX_BUF, "%s", cost_string_from_value (unpaid_price - player_wealth, 0)); |
674 | << " unpaid item(s) that would cost you " << cost_string_from_value (unpaid_price, 0) |
|
|
675 | << ". You need another " << cost_string_from_value (unpaid_price - player_wealth, 0) |
|
|
676 | << " to be able to afford that."; |
684 | |
677 | |
685 | snprintf (buf, MAX_BUF, "You have %d unpaid items that would cost you %s. You need another %s to be able to afford that.", |
678 | pl->failmsg (buf); |
686 | unpaid_count, cost, missing); |
|
|
687 | new_draw_info (NDI_UNIQUE, 0, pl, buf); |
|
|
688 | |
679 | |
689 | return 0; |
680 | return 0; |
690 | } |
681 | } |
691 | else |
682 | else |
692 | return 1; |
683 | return 1; |
… | |
… | |
804 | |
795 | |
805 | /* elmex: this is for the bank plugin :( */ |
796 | /* elmex: this is for the bank plugin :( */ |
806 | sint64 |
797 | sint64 |
807 | pay_player_arch (object *pl, const char *arch, sint64 amount) |
798 | pay_player_arch (object *pl, const char *arch, sint64 amount) |
808 | { |
799 | { |
809 | archetype *at = archetype::find (arch); |
|
|
810 | |
|
|
811 | if (!at) |
|
|
812 | return 0; |
|
|
813 | |
|
|
814 | if (amount > 0) |
800 | if (amount) |
815 | { |
801 | { |
816 | object *tmp = arch_to_object (at); |
802 | object *ob = archetype::get (arch); |
|
|
803 | |
|
|
804 | if (!ob) |
|
|
805 | return 0; |
|
|
806 | |
817 | tmp->nrof = amount; |
807 | ob->nrof = amount; |
818 | insert_ob_in_ob (tmp, pl); |
808 | pl->insert (ob); |
819 | } |
809 | } |
820 | |
810 | |
821 | return 1; |
811 | return 1; |
822 | } |
812 | } |
823 | |
813 | |
… | |
… | |
1075 | { |
1065 | { |
1076 | shopinv *s1 = (shopinv *) a1, *s2 = (shopinv *) a2; |
1066 | shopinv *s1 = (shopinv *) a1, *s2 = (shopinv *) a2; |
1077 | |
1067 | |
1078 | if (s1->type < s2->type) |
1068 | if (s1->type < s2->type) |
1079 | return -1; |
1069 | return -1; |
|
|
1070 | |
1080 | if (s1->type > s2->type) |
1071 | if (s1->type > s2->type) |
1081 | return 1; |
1072 | return 1; |
1082 | |
1073 | |
1083 | /* the type is the same (what atoi gets), so do a strcasecmp to sort |
1074 | /* the type is the same (what atoi gets), so do a strcasecmp to sort |
1084 | * via alphabetical order |
1075 | * via alphabetical order |
… | |
… | |
1134 | |
1125 | |
1135 | void |
1126 | void |
1136 | shop_listing (object *sign, object *op) |
1127 | shop_listing (object *sign, object *op) |
1137 | { |
1128 | { |
1138 | int i, j, numitems = 0, numallocated = 0, x1, x2, y1, y2; |
1129 | int i, j, numitems = 0, numallocated = 0, x1, x2, y1, y2; |
1139 | const char *shop_coords = get_ob_key_value (sign, "shop_coords"); |
1130 | const char *shop_coords = sign->kv (shstr_shop_coords); |
1140 | object *stack; |
1131 | object *stack; |
1141 | shopinv *items; |
1132 | shopinv *items; |
1142 | |
1133 | |
1143 | /* Should never happen, but just in case a monster does apply a sign */ |
1134 | /* Should never happen, but just in case a monster does apply a sign */ |
1144 | if (op->type != PLAYER) |
1135 | if (op->type != PLAYER) |
… | |
… | |
1217 | |
1208 | |
1218 | /* elmex: this function checks whether the object is in a shop */ |
1209 | /* elmex: this function checks whether the object is in a shop */ |
1219 | bool |
1210 | bool |
1220 | is_in_shop (object *o) |
1211 | is_in_shop (object *o) |
1221 | { |
1212 | { |
1222 | if (!o->map) |
1213 | if (!o->is_on_map ()) |
1223 | return false; |
1214 | return false; |
1224 | |
1215 | |
1225 | return is_in_shop (o->map, o->x, o->y); |
1216 | return is_in_shop (o->map, o->x, o->y); |
1226 | } |
1217 | } |
1227 | |
1218 | |
… | |
… | |
1235 | is_in_shop (maptile *map, int x, int y) |
1226 | is_in_shop (maptile *map, int x, int y) |
1236 | { |
1227 | { |
1237 | for (object *floor = GET_MAP_OB (map, x, y); floor; floor = floor->above) |
1228 | for (object *floor = GET_MAP_OB (map, x, y); floor; floor = floor->above) |
1238 | if (QUERY_FLAG (floor, FLAG_IS_FLOOR)) |
1229 | if (QUERY_FLAG (floor, FLAG_IS_FLOOR)) |
1239 | return floor->type == SHOP_FLOOR; |
1230 | return floor->type == SHOP_FLOOR; |
|
|
1231 | |
1240 | return false; |
1232 | return false; |
1241 | } |
1233 | } |
1242 | |
1234 | |