1 | /* |
1 | /* |
2 | * static char *rcsid_c_object_c = |
2 | * static char *rcsid_c_object_c = |
3 | * "$Id: c_object.C,v 1.11 2006/08/29 10:51:43 elmex Exp $"; |
3 | * "$Id: c_object.C,v 1.12 2006/09/03 00:18:42 root Exp $"; |
4 | */ |
4 | */ |
5 | /* |
5 | /* |
6 | CrossFire, A Multiplayer game for X-windows |
6 | CrossFire, A Multiplayer game for X-windows |
7 | |
7 | |
8 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
8 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
… | |
… | |
193 | return 0; |
193 | return 0; |
194 | } |
194 | } |
195 | if (sack->race && (sack->race != op->race || op->type == CONTAINER |
195 | if (sack->race && (sack->race != op->race || op->type == CONTAINER |
196 | || (sack->stats.food && sack->stats.food != op->type))) { |
196 | || (sack->stats.food && sack->stats.food != op->type))) { |
197 | new_draw_info_format(NDI_UNIQUE, 0, pl, |
197 | new_draw_info_format(NDI_UNIQUE, 0, pl, |
198 | "You can put only %s into the %s.", sack->race, query_name(sack)); |
198 | "You can put only %s into the %s.", &sack->race, query_name(sack)); |
199 | return 0; |
199 | return 0; |
200 | } |
200 | } |
201 | if (op->type == SPECIAL_KEY && sack->slaying && op->slaying) { |
201 | if (op->type == SPECIAL_KEY && sack->slaying && op->slaying) { |
202 | new_draw_info_format(NDI_UNIQUE, 0, pl, |
202 | new_draw_info_format(NDI_UNIQUE, 0, pl, |
203 | "You can't put the key into %s.", query_name(sack)); |
203 | "You can't put the key into %s.", query_name(sack)); |
… | |
… | |
332 | |
332 | |
333 | /* Decide which object to pick. */ |
333 | /* Decide which object to pick. */ |
334 | if (alt) |
334 | if (alt) |
335 | { |
335 | { |
336 | if ( ! can_pick (op, alt)) { |
336 | if ( ! can_pick (op, alt)) { |
337 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't pick up the %s.", |
337 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't pick up the %s.", &alt->name); |
338 | alt->name); |
|
|
339 | goto leave; |
338 | goto leave; |
340 | } |
339 | } |
341 | tmp = alt; |
340 | tmp = alt; |
342 | } |
341 | } |
343 | else |
342 | else |
… | |
… | |
473 | } |
472 | } |
474 | if (!params && !tmp) { |
473 | if (!params && !tmp) { |
475 | for (tmp=op->below; tmp!=NULL; tmp=tmp->next) |
474 | for (tmp=op->below; tmp!=NULL; tmp=tmp->next) |
476 | if (!tmp->invisible) { |
475 | if (!tmp->invisible) { |
477 | char buf[MAX_BUF]; |
476 | char buf[MAX_BUF]; |
478 | sprintf(buf,"You can't pick up a %s.", |
477 | sprintf(buf,"You can't pick up a %s.", &tmp->name); |
479 | tmp->name? tmp->name:"null"); |
|
|
480 | new_draw_info(NDI_UNIQUE, 0,op, buf); |
478 | new_draw_info(NDI_UNIQUE, 0, op, buf); |
481 | break; |
479 | break; |
482 | } |
480 | } |
483 | if (!tmp) new_draw_info(NDI_UNIQUE, 0,op, "There is nothing to pick up."); |
481 | if (!tmp) new_draw_info(NDI_UNIQUE, 0,op, "There is nothing to pick up."); |
484 | } |
482 | } |
485 | return 0; |
483 | return 0; |
… | |
… | |
1099 | |
1097 | |
1100 | switch(tmp->type) { |
1098 | switch(tmp->type) { |
1101 | case SPELLBOOK: |
1099 | case SPELLBOOK: |
1102 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED) && tmp->inv ) { |
1100 | if(QUERY_FLAG(tmp, FLAG_IDENTIFIED) && tmp->inv ) { |
1103 | sprintf(buf,"%s is a %s level %s spell", |
1101 | sprintf(buf,"%s is a %s level %s spell", |
1104 | tmp->inv->name, get_levelnumber(tmp->inv->level), |
1102 | &tmp->inv->name, get_levelnumber(tmp->inv->level), |
1105 | tmp->inv->skill); |
1103 | &tmp->inv->skill); |
1106 | } |
1104 | } |
1107 | break; |
1105 | break; |
1108 | |
1106 | |
1109 | case BOOK: |
1107 | case BOOK: |
1110 | if(tmp->msg!=NULL) |
1108 | if(tmp->msg!=NULL) |
… | |
… | |
1113 | |
1111 | |
1114 | case CONTAINER: |
1112 | case CONTAINER: |
1115 | if(tmp->race!=NULL) { |
1113 | if(tmp->race!=NULL) { |
1116 | if(tmp->weight_limit && tmp->stats.Str<100) |
1114 | if(tmp->weight_limit && tmp->stats.Str<100) |
1117 | sprintf (buf,"It can hold only %s and its weight limit is %.1f kg.", |
1115 | sprintf (buf,"It can hold only %s and its weight limit is %.1f kg.", |
1118 | tmp->race, tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1116 | &tmp->race, tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1119 | else |
1117 | else |
1120 | sprintf (buf,"It can hold only %s.", tmp->race); |
1118 | sprintf (buf,"It can hold only %s.", &tmp->race); |
1121 | } else |
1119 | } else |
1122 | if(tmp->weight_limit && tmp->stats.Str<100) |
1120 | if(tmp->weight_limit && tmp->stats.Str<100) |
1123 | sprintf (buf,"Its weight limit is %.1f kg.", |
1121 | sprintf (buf,"Its weight limit is %.1f kg.", |
1124 | tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1122 | tmp->weight_limit/(10.0 * (100 - tmp->stats.Str))); |
1125 | break; |
1123 | break; |
… | |
… | |
1132 | |
1130 | |
1133 | if(buf[0]!='\0') |
1131 | if(buf[0]!='\0') |
1134 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1132 | new_draw_info(NDI_UNIQUE, 0,op,buf); |
1135 | |
1133 | |
1136 | if(tmp->materialname != NULL && !tmp->msg) { |
1134 | if(tmp->materialname != NULL && !tmp->msg) { |
1137 | sprintf(buf, "It is made of: %s.", tmp->materialname); |
1135 | sprintf(buf, "It is made of: %s.", &tmp->materialname); |
1138 | new_draw_info(NDI_UNIQUE, 0, op, buf); |
1136 | new_draw_info(NDI_UNIQUE, 0, op, buf); |
1139 | } |
1137 | } |
1140 | /* Where to wear this item */ |
1138 | /* Where to wear this item */ |
1141 | for (i=0; i < NUM_BODY_LOCATIONS; i++) { |
1139 | for (i=0; i < NUM_BODY_LOCATIONS; i++) { |
1142 | if (tmp->body_info[i]<-1) { |
1140 | if (tmp->body_info[i]<-1) { |
… | |
… | |
1559 | |
1557 | |
1560 | /* Coming here, everything is fine... */ |
1558 | /* Coming here, everything is fine... */ |
1561 | if(!strlen(buf)) { |
1559 | if(!strlen(buf)) { |
1562 | /* Clear custom name */ |
1560 | /* Clear custom name */ |
1563 | if(item->custom_name) { |
1561 | if(item->custom_name) { |
1564 | FREE_AND_CLEAR_STR(item->custom_name); |
1562 | item->custom_name = 0; |
1565 | |
1563 | |
1566 | new_draw_info_format(NDI_UNIQUE, 0, op,"You stop calling your %s with weird names.",query_base_name(item,item->nrof>1?1:0)); |
1564 | new_draw_info_format(NDI_UNIQUE, 0, op,"You stop calling your %s with weird names.",query_base_name(item,item->nrof>1?1:0)); |
1567 | esrv_update_item(UPD_NAME,op,item); |
1565 | esrv_update_item(UPD_NAME,op,item); |
1568 | } else { |
1566 | } else { |
1569 | new_draw_info(NDI_UNIQUE,0,op,"This item has no custom name."); |
1567 | new_draw_info(NDI_UNIQUE,0,op,"This item has no custom name."); |
1570 | } |
1568 | } |
1571 | } else { |
1569 | } else { |
1572 | /* Set custom name */ |
1570 | /* Set custom name */ |
1573 | FREE_AND_COPY(item->custom_name,buf); |
1571 | item->custom_name = buf; |
1574 | |
1572 | |
1575 | new_draw_info_format(NDI_UNIQUE, 0, op,"Your %s will now be called %s.",query_base_name(item,item->nrof>1?1:0),buf); |
1573 | new_draw_info_format(NDI_UNIQUE, 0, op,"Your %s will now be called %s.",query_base_name(item,item->nrof>1?1:0),buf); |
1576 | esrv_update_item(UPD_NAME,op,item); |
1574 | esrv_update_item(UPD_NAME,op,item); |
1577 | } |
1575 | } |
1578 | |
1576 | |