… | |
… | |
327 | enc -= 2; |
327 | enc -= 2; |
328 | else if (op->path_repelled & (1 << i)) |
328 | else if (op->path_repelled & (1 << i)) |
329 | enc--; |
329 | enc--; |
330 | } |
330 | } |
331 | |
331 | |
332 | if (QUERY_FLAG (op, FLAG_LIFESAVE)) |
332 | if (op->flag [FLAG_LIFESAVE ]) enc += 5; |
333 | enc += 5; |
333 | if (op->flag [FLAG_REFL_SPELL ]) enc += 3; |
334 | if (QUERY_FLAG (op, FLAG_REFL_SPELL)) |
334 | if (op->flag [FLAG_REFL_MISSILE]) enc += 2; |
335 | enc += 3; |
335 | if (op->flag [FLAG_XRAYS ]) enc += 2; |
336 | if (QUERY_FLAG (op, FLAG_REFL_MISSILE)) |
336 | if (op->flag [FLAG_STEALTH ]) enc += 1; |
337 | enc += 2; |
337 | if (op->flag [FLAG_SEE_IN_DARK ]) enc += 1; |
338 | if (QUERY_FLAG (op, FLAG_STEALTH)) |
338 | if (op->flag [FLAG_MAKE_INVIS ]) enc += 1; |
339 | enc += 1; |
|
|
340 | if (QUERY_FLAG (op, FLAG_XRAYS)) |
|
|
341 | enc += 2; |
|
|
342 | if (QUERY_FLAG (op, FLAG_SEE_IN_DARK)) |
|
|
343 | enc += 1; |
|
|
344 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
|
|
345 | enc += 1; |
|
|
346 | |
339 | |
347 | return get_power_from_ench (enc); |
340 | return get_power_from_ench (enc); |
348 | } |
341 | } |
349 | |
342 | |
350 | /* returns the typedata that has a number equal to itemtype, if there |
343 | /* returns the typedata that has a number equal to itemtype, if there |
351 | * isn't one, returns NULL */ |
344 | * isn't one, returns NULL */ |
352 | const typedata * |
345 | const typedata * |
353 | get_typedata (int itemtype) |
346 | get_typedata (int itemtype) |
354 | { |
347 | { |
355 | int i; |
|
|
356 | |
|
|
357 | for (i = 0; i < item_types_size; i++) |
348 | for (int i = 0; i < item_types_size; i++) |
358 | if (item_types[i].number == itemtype) |
349 | if (item_types[i].number == itemtype) |
359 | return &item_types[i]; |
350 | return &item_types[i]; |
360 | |
351 | |
361 | return NULL; |
352 | return NULL; |
362 | } |
353 | } |
… | |
… | |
365 | * isn't one, return the plural name that matches, if there still isn't |
356 | * isn't one, return the plural name that matches, if there still isn't |
366 | * one return NULL */ |
357 | * one return NULL */ |
367 | const typedata * |
358 | const typedata * |
368 | get_typedata_by_name (const char *name) |
359 | get_typedata_by_name (const char *name) |
369 | { |
360 | { |
370 | int i; |
|
|
371 | |
|
|
372 | for (i = 0; i < item_types_size; i++) |
361 | for (int i = 0; i < item_types_size; i++) |
373 | if (!strcmp (item_types[i].name, name)) |
362 | if (!strcmp (item_types[i].name, name)) |
374 | return &item_types[i]; |
363 | return &item_types[i]; |
375 | |
364 | |
376 | for (i = 0; i < item_types_size; i++) |
365 | for (int i = 0; i < item_types_size; i++) |
377 | if (!strcmp (item_types[i].name_pl, name)) |
366 | if (!strcmp (item_types[i].name_pl, name)) |
378 | { |
367 | { |
379 | LOG (llevInfo, |
368 | LOG (llevInfo, |
380 | "get_typedata_by_name: I have been sent the plural %s, the singular form %s is prefered\n", name, item_types[i].name); |
369 | "get_typedata_by_name: I have been sent the plural %s, the singular form %s is prefered\n", name, item_types[i].name); |
381 | return &item_types[i]; |
370 | return &item_types[i]; |
382 | } |
371 | } |
383 | |
372 | |
384 | return NULL; |
373 | return 0; |
385 | } |
374 | } |
386 | |
375 | |
387 | /* describe_resistance generates the visible naming for resistances. |
376 | /* describe_resistance generates the visible naming for resistances. |
388 | * returns a static array of the description. This can return |
377 | * returns a static array of the description. This can return |
389 | * a big buffer. |
378 | * a big buffer. |
… | |
… | |
408 | sprintf (buf1, "%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]); |
397 | sprintf (buf1, "%s %d\n", resist_plus[tmpvar], op->resist[tmpvar]); |
409 | |
398 | |
410 | strcat (buf, buf1); |
399 | strcat (buf, buf1); |
411 | } |
400 | } |
412 | } |
401 | } |
|
|
402 | |
413 | return buf; |
403 | return buf; |
414 | } |
404 | } |
415 | |
405 | |
416 | |
406 | |
417 | /* |
407 | /* |
418 | * query_weight(object) returns a character pointer to a static buffer |
408 | * query_weight(object) returns a character pointer to a static buffer |
419 | * containing the text-representation of the weight of the given object. |
409 | * containing the text-representation of the weight of the given object. |
420 | * The buffer will be overwritten by the next call to query_weight(). |
410 | * The buffer will be overwritten by the next call to query_weight(). |
|
|
411 | * |
|
|
412 | * Seems to be used only by unimportant stuff. Remove? |
421 | */ |
413 | */ |
422 | const char * |
414 | const char * |
423 | query_weight (const object *op) |
415 | query_weight (const object *op) |
424 | { |
416 | { |
425 | static char buf[10]; |
417 | static char buf[10]; |
… | |
… | |
451 | return buf; |
443 | return buf; |
452 | } |
444 | } |
453 | |
445 | |
454 | if (i < 21) |
446 | if (i < 21) |
455 | return levelnumbers[i]; |
447 | return levelnumbers[i]; |
|
|
448 | |
456 | if (!(i % 10)) |
449 | if (!(i % 10)) |
457 | return levelnumbers_10[i / 10]; |
450 | return levelnumbers_10[i / 10]; |
458 | |
451 | |
459 | strcpy (buf, numbers_10[i / 10]); |
452 | strcpy (buf, numbers_10[i / 10]); |
460 | strcat (buf, levelnumbers[i % 10]); |
453 | strcat (buf, levelnumbers[i % 10]); |
… | |
… | |
536 | } |
529 | } |
537 | |
530 | |
538 | /* |
531 | /* |
539 | * query_short_name(object) is similar to query_name, but doesn't |
532 | * query_short_name(object) is similar to query_name, but doesn't |
540 | * contain any information about object status (worn/cursed/etc.) |
533 | * contain any information about object status (worn/cursed/etc.) |
|
|
534 | * |
|
|
535 | * It is sometimes used when printing messages, so should fit well into a sentence. |
541 | */ |
536 | */ |
542 | const char * |
537 | const char * |
543 | query_short_name (const object *op) |
538 | query_short_name (const object *op) |
544 | { |
539 | { |
545 | if (!op->name) |
540 | if (!op->name) |
… | |
… | |
629 | * you can make several calls to query_name before the bufs start getting |
624 | * you can make several calls to query_name before the bufs start getting |
630 | * overwritten. This may be a bad thing (it may be easier to assume the value |
625 | * overwritten. This may be a bad thing (it may be easier to assume the value |
631 | * returned is good forever.) However, it makes printing statements that |
626 | * returned is good forever.) However, it makes printing statements that |
632 | * use several names much easier (don't need to store them to temp variables.) |
627 | * use several names much easier (don't need to store them to temp variables.) |
633 | * |
628 | * |
|
|
629 | * It is used extensively within messages, so should return only a prose |
|
|
630 | * and short description of the item. |
634 | */ |
631 | */ |
635 | const char * |
632 | const char * |
636 | query_name (const object *op) |
633 | query_name (const object *op) |
637 | { |
634 | { |
638 | int len = 0; |
635 | int len = 0; |
… | |
… | |
675 | */ |
672 | */ |
676 | if (QUERY_FLAG (op, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (op, FLAG_IDENTIFIED)) |
673 | if (QUERY_FLAG (op, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (op, FLAG_IDENTIFIED)) |
677 | buf << " (magic)"; |
674 | buf << " (magic)"; |
678 | |
675 | |
679 | #if 0 |
676 | #if 0 |
680 | /* item_power will be returned in desribe_item - it shouldn't really |
677 | /* item_power will be returned in describe_item - it shouldn't really |
681 | * be returned in the name. |
678 | * be returned in the name. |
682 | */ |
679 | */ |
683 | if (op->item_power) |
680 | if (op->item_power) |
684 | sprintf (buf[use_buf] + strlen (buf[use_buf]), "(item_power %+d)", op->item_power); |
681 | sprintf (buf[use_buf] + strlen (buf[use_buf]), "(item_power %+d)", op->item_power); |
685 | |
682 | |
… | |
… | |
750 | * of the given object. The buffer will be overwritten at the next |
747 | * of the given object. The buffer will be overwritten at the next |
751 | * call to query_base_name(). This is a lot like query_name, but we |
748 | * call to query_base_name(). This is a lot like query_name, but we |
752 | * don't include the item count or item status. Used for inventory sorting |
749 | * don't include the item count or item status. Used for inventory sorting |
753 | * and sending to client. |
750 | * and sending to client. |
754 | * If plural is set, we generate the plural name of this. |
751 | * If plural is set, we generate the plural name of this. |
|
|
752 | * |
|
|
753 | * It is sometimes used to display messages, and usually only used to match stuff, |
|
|
754 | * so maybe this function should be removed. |
755 | */ |
755 | */ |
756 | const char * |
756 | const char * |
757 | query_base_name (const object *op, int plural) |
757 | query_base_name (const object *op, int plural) |
758 | { |
758 | { |
759 | if ((!plural && !op->name) || (plural && !op->name_pl)) |
759 | if ((!plural && !op->name) || (plural && !op->name_pl)) |
… | |
… | |
954 | * wouldn't need to use the SEE_INVISIBLE flag to know it is |
954 | * wouldn't need to use the SEE_INVISIBLE flag to know it is |
955 | * a dragon player examining food. Could have things like |
955 | * a dragon player examining food. Could have things like |
956 | * a dwarven axe, in which the full abilities are only known to |
956 | * a dwarven axe, in which the full abilities are only known to |
957 | * dwarves, etc. |
957 | * dwarves, etc. |
958 | * |
958 | * |
959 | * This function is really much more complicated than it should |
|
|
960 | * be, because different objects have different meanings |
|
|
961 | * for the same field (eg, wands use 'food' for charges). This |
|
|
962 | * means these special cases need to be worked out. |
|
|
963 | * |
|
|
964 | * Add 'owner' who is the person examining this object. |
959 | * Add 'owner' who is the person examining this object. |
965 | * owner can be null if no one is being associated with this |
960 | * owner can be null if no one is being associated with this |
966 | * item (eg, debug dump or the like) |
961 | * item (eg, debug dump or the like) |
967 | */ |
962 | */ |
968 | const char * |
963 | const char * |
… | |
… | |
1213 | if (QUERY_FLAG (op, FLAG_STEALTH)) buf << "(stealth)"; |
1208 | if (QUERY_FLAG (op, FLAG_STEALTH)) buf << "(stealth)"; |
1214 | |
1209 | |
1215 | if (op->slaying && op->type != FOOD) |
1210 | if (op->slaying && op->type != FOOD) |
1216 | buf.printf ("(slay %s)", &op->slaying); |
1211 | buf.printf ("(slay %s)", &op->slaying); |
1217 | |
1212 | |
|
|
1213 | if (op->type == SKILL_TOOL && op->skill) buf.printf ("(%s)", &op->skill); |
|
|
1214 | |
1218 | buf.add_abilities ("Attacks", op->attacktype); |
1215 | buf.add_abilities ("Attacks", op->attacktype); |
1219 | /* resistance on flesh is only visible for quetzals. If |
1216 | /* resistance on flesh is only visible for quetzals. If |
1220 | * non flesh, everyone can see its resistances |
1217 | * non flesh, everyone can see its resistances |
1221 | */ |
1218 | */ |
1222 | if (op->type != FLESH || (owner && is_dragon_pl (owner))) |
1219 | if (op->type != FLESH || (owner && is_dragon_pl (owner))) |
… | |
… | |
1238 | |
1235 | |
1239 | void |
1236 | void |
1240 | examine (object *op, object *tmp) |
1237 | examine (object *op, object *tmp) |
1241 | { |
1238 | { |
1242 | std::string info = tmp->describe (op); |
1239 | std::string info = tmp->describe (op); |
|
|
1240 | |
1243 | op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); |
1241 | op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ()); |
1244 | } |
1242 | } |
1245 | |
1243 | |
1246 | /* |
1244 | /* |
1247 | * inventory prints object's inventory. If inv==NULL then print player's |
1245 | * inventory prints object's inventory. If inv==NULL then print player's |