| version 1.56 | | version 1.57 |
|---|
| | |
| /* | | /* |
| * static char *rcsid_shop_c = | | * static char *rcsid_shop_c = |
| * "$Id: shop.c,v 1.56 2006/08/07 07:22:19 ryo_saeba Exp $"; | | * "$Id: shop.c,v 1.57 2006/09/04 07:21:05 mwedel Exp $"; |
| */ | | */ |
| | | |
| /* | | /* |
| | |
| } | | } |
| } | | } |
| if (denominations > 1) make_list_like(buf); | | if (denominations > 1) make_list_like(buf); |
| new_draw_info(NDI_UNIQUE, 0, pl, buf); | | draw_ext_info(NDI_UNIQUE, 0, pl, MSG_TYPE_SHOP, MSG_TYPE_SHOP_PAYMENT, buf, NULL); |
| return 0; | | return 0; |
| } | | } |
| else return 1; | | else return 1; |
| | |
| if(!pay_for_item(op,pl)) { | | if(!pay_for_item(op,pl)) { |
| uint64 i=query_cost(op,pl,F_BUY | F_SHOP) - query_money(pl); | | uint64 i=query_cost(op,pl,F_BUY | F_SHOP) - query_money(pl); |
| CLEAR_FLAG(op, FLAG_UNPAID); | | CLEAR_FLAG(op, FLAG_UNPAID); |
| new_draw_info_format(NDI_UNIQUE, 0, pl, | | draw_ext_info_format(NDI_UNIQUE, 0, pl, MSG_TYPE_SHOP, MSG_TYPE_SHOP_PAYMENT, |
| "You lack %s to buy %s.", cost_string_from_value(i), | | "You lack %s to buy %s.", |
| query_name(op)); | | "You lack %s to buy %s.", |
| | | cost_string_from_value(i), query_name(op)); |
| SET_FLAG(op, FLAG_UNPAID); | | SET_FLAG(op, FLAG_UNPAID); |
| return 0; | | return 0; |
| } else { | | } else { |
| | |
| | | |
| CLEAR_FLAG(op, FLAG_UNPAID); | | CLEAR_FLAG(op, FLAG_UNPAID); |
| CLEAR_FLAG(op, FLAG_PLAYER_SOLD); | | CLEAR_FLAG(op, FLAG_PLAYER_SOLD); |
| new_draw_info_format(NDI_UNIQUE, 0, op, | | draw_ext_info_format(NDI_UNIQUE, 0, pl, MSG_TYPE_SHOP, MSG_TYPE_SHOP_PAYMENT, |
| "You paid %s for %s.",buf,query_name(op)); | | "You paid %s for %s.", |
| | | "You paid %s for %s.", |
| | | buf,query_name(op)); |
| tmp=merge_ob(op,NULL); | | tmp=merge_ob(op,NULL); |
| if (pl->type == PLAYER) { | | if (pl->type == PLAYER) { |
| if (tmp) { /* it was merged */ | | if (tmp) { /* it was merged */ |
| | |
| if(op->custom_name) FREE_AND_CLEAR_STR(op->custom_name); | | if(op->custom_name) FREE_AND_CLEAR_STR(op->custom_name); |
| | | |
| if(!i) { | | if(!i) { |
| new_draw_info_format(NDI_UNIQUE, 0, pl, | | draw_ext_info_format(NDI_UNIQUE, 0, pl, MSG_TYPE_SHOP, MSG_TYPE_SHOP_SELL, |
| "We're not interested in %s.",query_name(op)); | | "We're not interested in %s.", |
| | | "We're not interested in %s.", |
| | | query_name(op)); |
| | | |
| /* Even if the character doesn't get anything for it, it may still be | | /* Even if the character doesn't get anything for it, it may still be |
| * worth something. If so, make it unpaid | | * worth something. If so, make it unpaid |
| | |
| LOG(llevError,"Warning - payment not zero: %I64u\n", i); | | LOG(llevError,"Warning - payment not zero: %I64u\n", i); |
| #endif | | #endif |
| | | |
| new_draw_info_format(NDI_UNIQUE, 0, pl, | | draw_ext_info_format(NDI_UNIQUE, 0, pl, MSG_TYPE_SHOP, MSG_TYPE_SHOP_SELL, |
| "You receive %s for %s.",query_cost_string(op,pl,F_SELL | F_SHOP), | | "You receive %s for %s.", |
| query_name(op)); | | "You receive %s for %s.", |
| | | query_cost_string(op,pl,F_SELL | F_SHOP), query_name(op)); |
| | | |
| SET_FLAG(op, FLAG_UNPAID); | | SET_FLAG(op, FLAG_UNPAID); |
| identify(op); | | identify(op); |
| } | | } |
| | |
| int pos=0, i; | | int pos=0, i; |
| double opinion=0; | | double opinion=0; |
| char tmp[MAX_BUF]="\0"; | | char tmp[MAX_BUF]="\0"; |
| | | |
| if (op->type != PLAYER) return 0; | | if (op->type != PLAYER) return 0; |
| | | |
| /*check if there is a shop specified for this map */ | | /*check if there is a shop specified for this map */ |
| if (map->shopitems || map->shopgreed || map->shoprace || map->shopmin || map->shopmax) { | | if (map->shopitems || map->shopgreed || map->shoprace || map->shopmin || map->shopmax) { |
| new_draw_info(NDI_UNIQUE,0,op,"From looking at the nearby shop you determine that it trades in:"); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_LISTING, |
| | | "From looking at the nearby shop you determine that it trades in:", |
| | | NULL); |
| | | |
| if (map->shopitems) { | | if (map->shopitems) { |
| for (i=0; i < map->shopitems[0].index; i++) { | | for (i=0; i < map->shopitems[0].index; i++) { |
| if (map->shopitems[i].name && map->shopitems[i].strength > 10) { | | if (map->shopitems[i].name && map->shopitems[i].strength > 10) { |
| | |
| } | | } |
| } | | } |
| } | | } |
| if (!pos) strcat(tmp, "a little of everything."); | | if (!pos) strcpy(tmp, "a little of everything."); |
| | | |
| /* format the string into a list */ | | /* format the string into a list */ |
| make_list_like(tmp); | | make_list_like(tmp); |
| new_draw_info_format(NDI_UNIQUE, 0, op, "%s", tmp); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_LISTING, tmp, NULL); |
| | | |
| if (map->shopmax) | | if (map->shopmax) |
| new_draw_info_format(NDI_UNIQUE,0,op,"It won't trade for items above %s.", | | draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "It won't trade for items above %s.", |
| | | "It won't trade for items above %s.", |
| cost_string_from_value(map->shopmax)); | | cost_string_from_value(map->shopmax)); |
| | | |
| if (map->shopmin) | | if (map->shopmin) |
| new_draw_info_format(NDI_UNIQUE,0,op,"It won't trade in items worth less than %s.", | | draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "It won't trade in items worth less than %s.", |
| | | "It won't trade in items worth less than %s.", |
| cost_string_from_value(map->shopmin)); | | cost_string_from_value(map->shopmin)); |
| | | |
| if (map->shopgreed) { | | if (map->shopgreed) { |
| if (map->shopgreed >2.0) | | if (map->shopgreed >2.0) |
| new_draw_info(NDI_UNIQUE,0,op,"It tends to overcharge massively."); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "It tends to overcharge massively.", NULL); |
| else if (map->shopgreed >1.5) | | else if (map->shopgreed >1.5) |
| new_draw_info(NDI_UNIQUE,0,op,"It tends to overcharge substantially."); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "It tends to overcharge substantially.", NULL); |
| else if (map->shopgreed >1.1) | | else if (map->shopgreed >1.1) |
| new_draw_info(NDI_UNIQUE,0,op,"It tends to overcharge slightly."); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "It tends to overcharge slightly.", NULL); |
| else if (map->shopgreed <0.9) | | else if (map->shopgreed <0.9) |
| new_draw_info(NDI_UNIQUE,0,op,"It tends to undercharge."); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "It tends to undercharge.", NULL); |
| } | | } |
| if (map->shoprace) { | | if (map->shoprace) { |
| opinion=shopkeeper_approval(map, op); | | opinion=shopkeeper_approval(map, op); |
| if (opinion > 0.8) | | if (opinion > 0.8) |
| new_draw_info(NDI_UNIQUE,0,op,"You think the shopkeeper likes you."); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "You think the shopkeeper likes you.", NULL); |
| else if (opinion > 0.5) | | else if (opinion > 0.5) |
| new_draw_info(NDI_UNIQUE,0,op,"The shopkeeper seems unconcerned by you."); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "The shopkeeper seems unconcerned by you.", NULL); |
| else | | else |
| new_draw_info(NDI_UNIQUE,0,op,"The shopkeeper seems to have taken a dislike to you."); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "The shopkeeper seems to have taken a dislike to you.", NULL); |
| } | | } |
| } | | } |
| else new_draw_info(NDI_UNIQUE,0,op,"There is no shop nearby."); | | else draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_MISC, |
| | | "There is no shop nearby.", NULL); |
| | | |
| return 1; | | return 1; |
| } | | } |
| | |
| /* Should never happen, but just in case a monster does apply a sign */ | | /* Should never happen, but just in case a monster does apply a sign */ |
| if (op->type!=PLAYER) return; | | if (op->type!=PLAYER) return; |
| | | |
| new_draw_info(NDI_UNIQUE, 0, op, "\nThe shop contains:"); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_LISTING, |
| | | "\nThe shop contains:", NULL); |
| | | |
| magic_mapping_mark(op, map_mark, 3); | | magic_mapping_mark(op, map_mark, 3); |
| items=malloc(40*sizeof(shopinv)); | | items=malloc(40*sizeof(shopinv)); |
| | |
| } | | } |
| free(map_mark); | | free(map_mark); |
| if (numitems == 0) { | | if (numitems == 0) { |
| new_draw_info(NDI_UNIQUE, 0, op, "The shop is currently empty.\n"); | | draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_LISTING, |
| | | "The shop is currently empty.\n", NULL); |
| free(items); | | free(items); |
| return; | | return; |
| } | | } |
| | |
| free(items[i].item_sort); | | free(items[i].item_sort); |
| free(items[i].item_real); | | free(items[i].item_real); |
| } else { | | } else { |
| new_draw_info_format(NDI_UNIQUE, 0, op, "%d %s", | | draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_SHOP, MSG_TYPE_SHOP_LISTING, |
| | | "%d %s", "%d %s", |
| items[i].nrof? items[i].nrof:1, | | items[i].nrof? items[i].nrof:1, |
| items[i].nrof==1?items[i].item_sort: items[i].item_real); | | items[i].nrof==1?items[i].item_sort: items[i].item_real); |
| free(items[i].item_sort); | | free(items[i].item_sort); |