1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | |
3 | * |
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | |
7 | * |
8 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. |
11 | * (at your option) any later version. |
12 | |
12 | * |
13 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | |
17 | * |
18 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | |
21 | * |
22 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <funcpoint.h> |
26 | #include <funcpoint.h> |
27 | #include <living.h> |
27 | #include <living.h> |
28 | #include <spells.h> |
28 | #include <spells.h> |
… | |
… | |
250 | }; |
250 | }; |
251 | |
251 | |
252 | int |
252 | int |
253 | get_power_from_ench (int ench) |
253 | get_power_from_ench (int ench) |
254 | { |
254 | { |
255 | if (ench < 0) |
255 | if (ench < 0) ench = 0; |
256 | ench = 0; |
256 | if (ench > 20) ench = 20; |
257 | if (ench > 20) |
257 | |
258 | ench = 20; |
|
|
259 | return enc_to_item_power[ench]; |
258 | return enc_to_item_power[ench]; |
260 | } |
259 | } |
261 | |
260 | |
262 | /* This takes an object 'op' and figures out what its item_power |
261 | /* This takes an object 'op' and figures out what its item_power |
263 | * rating should be. This should only really be used by the treasure |
262 | * rating should be. This should only really be used by the treasure |
… | |
… | |
342 | enc += 1; |
341 | enc += 1; |
343 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
342 | if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) |
344 | enc += 1; |
343 | enc += 1; |
345 | |
344 | |
346 | return get_power_from_ench (enc); |
345 | return get_power_from_ench (enc); |
347 | |
|
|
348 | } |
346 | } |
349 | |
347 | |
350 | /* returns the typedata that has a number equal to itemtype, if there |
348 | /* returns the typedata that has a number equal to itemtype, if there |
351 | * isn't one, returns NULL */ |
349 | * isn't one, returns NULL */ |
352 | |
|
|
353 | const typedata * |
350 | const typedata * |
354 | get_typedata (int itemtype) |
351 | get_typedata (int itemtype) |
355 | { |
352 | { |
356 | int i; |
353 | int i; |
357 | |
354 | |
… | |
… | |
362 | } |
359 | } |
363 | |
360 | |
364 | /* returns the typedata that has a name equal to itemtype, if there |
361 | /* returns the typedata that has a name equal to itemtype, if there |
365 | * isn't one, return the plural name that matches, if there still isn't |
362 | * isn't one, return the plural name that matches, if there still isn't |
366 | * one return NULL */ |
363 | * one return NULL */ |
367 | |
|
|
368 | const typedata * |
364 | const typedata * |
369 | get_typedata_by_name (const char *name) |
365 | get_typedata_by_name (const char *name) |
370 | { |
366 | { |
371 | int i; |
367 | int i; |
372 | |
368 | |
… | |
… | |
387 | * returns a static array of the description. This can return |
383 | * returns a static array of the description. This can return |
388 | * a big buffer. |
384 | * a big buffer. |
389 | * if newline is true, we don't put parens around the description |
385 | * if newline is true, we don't put parens around the description |
390 | * but do put a newline at the end. Useful when dumping to files |
386 | * but do put a newline at the end. Useful when dumping to files |
391 | */ |
387 | */ |
392 | char * |
388 | const char * |
393 | describe_resistance (const object *op, int newline) |
389 | describe_resistance (const object *op, int newline) |
394 | { |
390 | { |
395 | static char buf[VERY_BIG_BUF]; |
391 | static char buf[VERY_BIG_BUF]; |
396 | char buf1[VERY_BIG_BUF]; |
392 | char buf1[VERY_BIG_BUF]; |
397 | int tmpvar; |
393 | int tmpvar; |
… | |
… | |
416 | /* |
412 | /* |
417 | * query_weight(object) returns a character pointer to a static buffer |
413 | * query_weight(object) returns a character pointer to a static buffer |
418 | * containing the text-representation of the weight of the given object. |
414 | * containing the text-representation of the weight of the given object. |
419 | * The buffer will be overwritten by the next call to query_weight(). |
415 | * The buffer will be overwritten by the next call to query_weight(). |
420 | */ |
416 | */ |
421 | |
417 | const char * |
422 | char * |
|
|
423 | query_weight (const object *op) |
418 | query_weight (const object *op) |
424 | { |
419 | { |
425 | static char buf[10]; |
420 | static char buf[10]; |
426 | sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; |
421 | sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; |
427 | |
422 | |
428 | if (op->weight < 0) |
423 | if (op->weight < 0) |
429 | return " "; |
424 | return " "; |
|
|
425 | |
430 | if (i % 1000) |
426 | if (i % 1000) |
431 | sprintf (buf, "%6.1f", i / 1000.0); |
427 | sprintf (buf, "%6.1f", i / 1000.0); |
432 | else |
428 | else |
433 | sprintf (buf, "%4d ", i / 1000); |
429 | sprintf (buf, "%4d ", i / 1000); |
|
|
430 | |
434 | return buf; |
431 | return buf; |
435 | } |
432 | } |
436 | |
433 | |
437 | /* |
434 | /* |
438 | * Returns the pointer to a static buffer containing |
435 | * Returns the pointer to a static buffer containing |
439 | * the number requested (of the form first, second, third...) |
436 | * the number requested (of the form first, second, third...) |
440 | */ |
437 | */ |
441 | |
438 | const char * |
442 | char * |
|
|
443 | get_levelnumber (int i) |
439 | get_levelnumber (int i) |
444 | { |
440 | { |
445 | static char buf[MAX_BUF]; |
441 | static char buf[MAX_BUF]; |
446 | |
442 | |
447 | if (i > 99) |
443 | if (i > 99) |
448 | { |
444 | { |
449 | sprintf (buf, "%d.", i); |
445 | sprintf (buf, "%d.", i); |
450 | return buf; |
446 | return buf; |
451 | } |
447 | } |
|
|
448 | |
452 | if (i < 21) |
449 | if (i < 21) |
453 | return levelnumbers[i]; |
450 | return levelnumbers[i]; |
454 | if (!(i % 10)) |
451 | if (!(i % 10)) |
455 | return levelnumbers_10[i / 10]; |
452 | return levelnumbers_10[i / 10]; |
|
|
453 | |
456 | strcpy (buf, numbers_10[i / 10]); |
454 | strcpy (buf, numbers_10[i / 10]); |
457 | strcat (buf, levelnumbers[i % 10]); |
455 | strcat (buf, levelnumbers[i % 10]); |
458 | return buf; |
456 | return buf; |
459 | } |
457 | } |
460 | |
|
|
461 | |
458 | |
462 | /* |
459 | /* |
463 | * get_number(integer) returns the text-representation of the given number |
460 | * get_number(integer) returns the text-representation of the given number |
464 | * in a static buffer. The buffer might be overwritten at the next |
461 | * in a static buffer. The buffer might be overwritten at the next |
465 | * call to get_number(). |
462 | * call to get_number(). |
466 | * It is currently only used by the query_name() function. |
463 | * It is currently only used by the query_name() function. |
467 | */ |
464 | */ |
468 | |
465 | const char * |
469 | char * |
|
|
470 | get_number (int i) |
466 | get_number (int i) |
471 | { |
467 | { |
472 | if (i <= 20) |
468 | if (i <= 20) |
473 | return numbers[i]; |
469 | return numbers[i]; |
474 | else |
470 | else |
… | |
… | |
491 | */ |
487 | */ |
492 | |
488 | |
493 | /* Aug 95 modified this slightly so that Skill tools don't have magic bonus |
489 | /* Aug 95 modified this slightly so that Skill tools don't have magic bonus |
494 | * from stats.sp - b.t. |
490 | * from stats.sp - b.t. |
495 | */ |
491 | */ |
496 | char * |
492 | const char * |
497 | ring_desc (const object *op) |
493 | ring_desc (const object *op) |
498 | { |
494 | { |
499 | static char buf[VERY_BIG_BUF]; |
495 | static char buf[VERY_BIG_BUF]; |
500 | int attr, val, len; |
496 | int attr, val, len; |
501 | |
497 | |
… | |
… | |
509 | if ((val = get_attr_value (&(op->stats), attr)) != 0) |
505 | if ((val = get_attr_value (&(op->stats), attr)) != 0) |
510 | { |
506 | { |
511 | sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); |
507 | sprintf (buf + strlen (buf), "(%s%+d)", short_stat_name[attr], val); |
512 | } |
508 | } |
513 | } |
509 | } |
|
|
510 | |
514 | if (op->stats.exp) |
511 | if (op->stats.exp) |
515 | sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); |
512 | sprintf (buf + strlen (buf), "(speed %+lld)", (long long) op->stats.exp); |
516 | if (op->stats.wc) |
513 | if (op->stats.wc) |
517 | sprintf (buf + strlen (buf), "(wc%+d)", op->stats.wc); |
514 | sprintf (buf + strlen (buf), "(wc%+d)", op->stats.wc); |
518 | if (op->stats.dam) |
515 | if (op->stats.dam) |
… | |
… | |
540 | strcat (buf, "(reflect spells)"); |
537 | strcat (buf, "(reflect spells)"); |
541 | if (QUERY_FLAG (op, FLAG_REFL_MISSILE)) |
538 | if (QUERY_FLAG (op, FLAG_REFL_MISSILE)) |
542 | strcat (buf, "(reflect missiles)"); |
539 | strcat (buf, "(reflect missiles)"); |
543 | if (QUERY_FLAG (op, FLAG_STEALTH)) |
540 | if (QUERY_FLAG (op, FLAG_STEALTH)) |
544 | strcat (buf, "(stealth)"); |
541 | strcat (buf, "(stealth)"); |
|
|
542 | |
545 | /* Shorten some of the names, so they appear better in the windows */ |
543 | /* Shorten some of the names, so they appear better in the windows */ |
546 | len = strlen (buf); |
544 | len = strlen (buf); |
547 | DESCRIBE_PATH_SAFE (buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); |
545 | DESCRIBE_PATH_SAFE (buf, op->path_attuned, "Attuned", &len, VERY_BIG_BUF); |
548 | DESCRIBE_PATH_SAFE (buf, op->path_repelled, "Repelled", &len, VERY_BIG_BUF); |
546 | DESCRIBE_PATH_SAFE (buf, op->path_repelled, "Repelled", &len, VERY_BIG_BUF); |
549 | DESCRIBE_PATH_SAFE (buf, op->path_denied, "Denied", &len, VERY_BIG_BUF); |
547 | DESCRIBE_PATH_SAFE (buf, op->path_denied, "Denied", &len, VERY_BIG_BUF); |
… | |
… | |
614 | case AMULET: |
612 | case AMULET: |
615 | case RING: |
613 | case RING: |
616 | if (!op->title) |
614 | if (!op->title) |
617 | { |
615 | { |
618 | /* If ring has a title, full description isn't so useful */ |
616 | /* If ring has a title, full description isn't so useful */ |
619 | char *s = ring_desc (op); |
617 | const char *s = ring_desc (op); |
620 | |
618 | |
621 | if (s[0]) |
619 | if (s[0]) |
622 | { |
620 | { |
623 | safe_strcat (buf, " ", &len, HUGE_BUF); |
621 | safe_strcat (buf, " ", &len, HUGE_BUF); |
624 | safe_strcat (buf, s, &len, HUGE_BUF); |
622 | safe_strcat (buf, s, &len, HUGE_BUF); |
… | |
… | |
644 | * overwritten. This may be a bad thing (it may be easier to assume the value |
642 | * overwritten. This may be a bad thing (it may be easier to assume the value |
645 | * returned is good forever.) However, it makes printing statements that |
643 | * returned is good forever.) However, it makes printing statements that |
646 | * use several names much easier (don't need to store them to temp variables.) |
644 | * use several names much easier (don't need to store them to temp variables.) |
647 | * |
645 | * |
648 | */ |
646 | */ |
649 | char * |
647 | const char * |
650 | query_name (const object *op) |
648 | query_name (const object *op) |
651 | { |
649 | { |
652 | static char buf[5][HUGE_BUF]; |
650 | static char buf[5][HUGE_BUF]; // OMFG |
653 | static int use_buf = 0; |
651 | static int use_buf = 0; |
654 | int len = 0; |
652 | int len = 0; |
655 | |
653 | |
656 | #ifdef NEW_MATERIAL_CODE |
654 | #ifdef NEW_MATERIAL_CODE |
657 | materialtype_t *mt; |
655 | materialtype_t *mt; |
… | |
… | |
684 | if (QUERY_FLAG (op, FLAG_DAMNED)) |
682 | if (QUERY_FLAG (op, FLAG_DAMNED)) |
685 | safe_strcat (buf[use_buf], " (damned)", &len, HUGE_BUF); |
683 | safe_strcat (buf[use_buf], " (damned)", &len, HUGE_BUF); |
686 | else if (QUERY_FLAG (op, FLAG_CURSED)) |
684 | else if (QUERY_FLAG (op, FLAG_CURSED)) |
687 | safe_strcat (buf[use_buf], " (cursed)", &len, HUGE_BUF); |
685 | safe_strcat (buf[use_buf], " (cursed)", &len, HUGE_BUF); |
688 | } |
686 | } |
|
|
687 | |
689 | /* Basically, if the object is known magical (detect magic spell on it), |
688 | /* Basically, if the object is known magical (detect magic spell on it), |
690 | * and it isn't identified, print out the fact that |
689 | * and it isn't identified, print out the fact that |
691 | * it is magical. Assume that the detect magical spell will only set |
690 | * it is magical. Assume that the detect magical spell will only set |
692 | * KNOWN_MAGICAL if the item actually is magical. |
691 | * KNOWN_MAGICAL if the item actually is magical. |
693 | * |
692 | * |
… | |
… | |
709 | |
708 | |
710 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
709 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
711 | { |
710 | { |
712 | switch (op->type) |
711 | switch (op->type) |
713 | { |
712 | { |
714 | case BOW: |
713 | case BOW: |
715 | case WAND: |
714 | case WAND: |
716 | case ROD: |
715 | case ROD: |
717 | case HORN: |
716 | case HORN: |
718 | safe_strcat (buf[use_buf], " (readied)", &len, HUGE_BUF); |
717 | safe_strcat (buf[use_buf], " (readied)", &len, HUGE_BUF); |
719 | break; |
718 | break; |
720 | case WEAPON: |
719 | case WEAPON: |
721 | safe_strcat (buf[use_buf], " (wielded)", &len, HUGE_BUF); |
720 | safe_strcat (buf[use_buf], " (wielded)", &len, HUGE_BUF); |
722 | break; |
721 | break; |
723 | case ARMOUR: |
722 | case ARMOUR: |
724 | case HELMET: |
723 | case HELMET: |
725 | case SHIELD: |
724 | case SHIELD: |
726 | case RING: |
725 | case RING: |
727 | case BOOTS: |
726 | case BOOTS: |
728 | case GLOVES: |
727 | case GLOVES: |
729 | case AMULET: |
728 | case AMULET: |
730 | case GIRDLE: |
729 | case GIRDLE: |
731 | case BRACERS: |
730 | case BRACERS: |
732 | case CLOAK: |
731 | case CLOAK: |
733 | safe_strcat (buf[use_buf], " (worn)", &len, HUGE_BUF); |
732 | safe_strcat (buf[use_buf], " (worn)", &len, HUGE_BUF); |
734 | break; |
733 | break; |
735 | case CONTAINER: |
734 | case CONTAINER: |
736 | safe_strcat (buf[use_buf], " (active)", &len, HUGE_BUF); |
735 | safe_strcat (buf[use_buf], " (active)", &len, HUGE_BUF); |
737 | break; |
736 | break; |
738 | case SKILL: |
737 | case SKILL: |
739 | default: |
738 | default: |
740 | safe_strcat (buf[use_buf], " (applied)", &len, HUGE_BUF); |
739 | safe_strcat (buf[use_buf], " (applied)", &len, HUGE_BUF); |
741 | } |
740 | } |
742 | } |
741 | } |
|
|
742 | |
743 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
743 | if (QUERY_FLAG (op, FLAG_UNPAID)) |
744 | safe_strcat (buf[use_buf], " (unpaid)", &len, HUGE_BUF); |
744 | safe_strcat (buf[use_buf], " (unpaid)", &len, HUGE_BUF); |
745 | |
745 | |
746 | return buf[use_buf]; |
746 | return buf [use_buf]; |
747 | } |
747 | } |
748 | |
748 | |
749 | /* |
749 | /* |
750 | * query_base_name(object) returns a character pointer pointing to a static |
750 | * query_base_name(object) returns a character pointer pointing to a static |
751 | * buffer which contains a verbose textual representation of the name |
751 | * buffer which contains a verbose textual representation of the name |
… | |
… | |
785 | } |
785 | } |
786 | else |
786 | else |
787 | { |
787 | { |
788 | #endif |
788 | #endif |
789 | if (!plural) |
789 | if (!plural) |
790 | strcpy (buf, op->name); |
790 | assign (buf, op->name); |
791 | else |
791 | else |
792 | strcpy (buf, op->name_pl); |
792 | assign (buf, op->name_pl); |
|
|
793 | |
793 | len = strlen (buf); |
794 | len = strlen (buf); |
794 | #ifdef NEW_MATERIAL_CODE |
795 | #ifdef NEW_MATERIAL_CODE |
795 | } |
796 | } |
796 | #endif |
797 | #endif |
797 | |
798 | |
… | |
… | |
801 | safe_strcat (buf, op->title, &len, MAX_BUF); |
802 | safe_strcat (buf, op->title, &len, MAX_BUF); |
802 | } |
803 | } |
803 | |
804 | |
804 | switch (op->type) |
805 | switch (op->type) |
805 | { |
806 | { |
806 | case SPELLBOOK: |
807 | case SPELLBOOK: |
807 | case SCROLL: |
808 | case SCROLL: |
808 | case WAND: |
809 | case WAND: |
809 | case ROD: |
810 | case ROD: |
810 | if (QUERY_FLAG (op, FLAG_IDENTIFIED) || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) |
811 | if (QUERY_FLAG (op, FLAG_IDENTIFIED) || QUERY_FLAG (op, FLAG_BEEN_APPLIED)) |
811 | { |
812 | { |
812 | if (!op->title) |
813 | if (!op->title) |
813 | { |
814 | { |
814 | safe_strcat (buf, " of ", &len, MAX_BUF); |
815 | safe_strcat (buf, " of ", &len, MAX_BUF); |
815 | if (op->inv) |
816 | if (op->inv) |
816 | safe_strcat (buf, op->inv->name, &len, MAX_BUF); |
817 | safe_strcat (buf, op->inv->name, &len, MAX_BUF); |
817 | else |
818 | else |
818 | LOG (llevError, "Spellbook %s lacks inventory\n", &op->name); |
819 | LOG (llevError, "Spellbook %s lacks inventory\n", &op->name); |
819 | } |
820 | } |
820 | if (op->type != SPELLBOOK) |
821 | if (op->type != SPELLBOOK) |
821 | { |
822 | { |
822 | sprintf (buf2, " (lvl %d)", op->level); |
823 | sprintf (buf2, " (lvl %d)", op->level); |
823 | safe_strcat (buf, buf2, &len, MAX_BUF); |
824 | safe_strcat (buf, buf2, &len, MAX_BUF); |
824 | } |
825 | } |
825 | } |
826 | } |
826 | break; |
827 | break; |
827 | |
828 | |
828 | |
829 | |
829 | case SKILL: |
830 | case SKILL: |
830 | case AMULET: |
831 | case AMULET: |
831 | case RING: |
832 | case RING: |
832 | if (!op->title) |
833 | if (!op->title) |
833 | { |
834 | { |
834 | /* If ring has a title, full description isn't so useful */ |
835 | /* If ring has a title, full description isn't so useful */ |
835 | char *s = ring_desc (op); |
836 | const char *s = ring_desc (op); |
836 | |
837 | |
837 | if (s[0]) |
838 | if (s[0]) |
838 | { |
839 | { |
839 | safe_strcat (buf, " ", &len, MAX_BUF); |
840 | safe_strcat (buf, " ", &len, MAX_BUF); |
840 | safe_strcat (buf, s, &len, MAX_BUF); |
841 | safe_strcat (buf, s, &len, MAX_BUF); |
841 | } |
842 | } |
842 | } |
843 | } |
843 | break; |
844 | break; |
844 | default: |
845 | default: |
845 | if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) |
846 | if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) |
846 | { |
847 | { |
847 | sprintf (buf + strlen (buf), " %+d", op->magic); |
848 | sprintf (buf + strlen (buf), " %+d", op->magic); |
848 | } |
849 | } |
849 | } |
850 | } |
|
|
851 | |
850 | return buf; |
852 | return buf; |
851 | } |
853 | } |
852 | |
854 | |
853 | /* Break this off from describe_item - that function was way |
855 | /* Break this off from describe_item - that function was way |
854 | * too long, making it difficult to read. This function deals |
856 | * too long, making it difficult to read. This function deals |
855 | * with describing the monsters & players abilities. It should only |
857 | * with describing the monsters & players abilities. It should only |
856 | * be called with monster & player objects. Returns a description |
858 | * be called with monster & player objects. Returns a description |
857 | * in a static buffer. |
859 | * in a static buffer. |
858 | */ |
860 | */ |
859 | |
|
|
860 | static char * |
861 | static char * |
861 | describe_monster (const object *op) |
862 | describe_monster (const object *op) |
862 | { |
863 | { |
863 | char buf[MAX_BUF]; |
864 | char buf[MAX_BUF]; |
864 | static char retbuf[VERY_BIG_BUF]; |
865 | static char retbuf[VERY_BIG_BUF]; |
… | |
… | |
990 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
991 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
991 | if (tmp->type == SKILL && !strcmp (tmp->name, "clawing")) |
992 | if (tmp->type == SKILL && !strcmp (tmp->name, "clawing")) |
992 | break; |
993 | break; |
993 | |
994 | |
994 | if (tmp && tmp->attacktype != 0) |
995 | if (tmp && tmp->attacktype != 0) |
995 | { |
|
|
996 | DESCRIBE_ABILITY (retbuf, tmp->attacktype, "Claws"); |
996 | { DESCRIBE_ABILITY (retbuf, tmp->attacktype, "Claws") } |
997 | } |
|
|
998 | else |
997 | else |
999 | { |
|
|
1000 | DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks"); |
998 | { DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks") } |
1001 | } |
|
|
1002 | } |
999 | } |
1003 | else |
1000 | else |
1004 | { |
|
|
1005 | DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks"); |
1001 | { DESCRIBE_ABILITY (retbuf, op->attacktype, "Attacks") } |
1006 | } |
1002 | |
1007 | DESCRIBE_PATH (retbuf, op->path_attuned, "Attuned"); |
1003 | DESCRIBE_PATH (retbuf, op->path_attuned, "Attuned"); |
1008 | DESCRIBE_PATH (retbuf, op->path_repelled, "Repelled"); |
1004 | DESCRIBE_PATH (retbuf, op->path_repelled, "Repelled"); |
1009 | DESCRIBE_PATH (retbuf, op->path_denied, "Denied"); |
1005 | DESCRIBE_PATH (retbuf, op->path_denied, "Denied"); |
|
|
1006 | |
1010 | for (i = 0; i < NROFATTACKS; i++) |
1007 | for (i = 0; i < NROFATTACKS; i++) |
1011 | { |
|
|
1012 | if (op->resist[i]) |
1008 | if (op->resist[i]) |
1013 | { |
1009 | { |
1014 | sprintf (buf, "(%s %+d)", resist_plus[i], op->resist[i]); |
1010 | sprintf (buf, "(%s %+d)", resist_plus[i], op->resist[i]); |
1015 | strcat (retbuf, buf); |
1011 | strcat (retbuf, buf); |
1016 | } |
1012 | } |
1017 | } |
1013 | |
1018 | return retbuf; |
1014 | return retbuf; |
1019 | } |
1015 | } |
1020 | |
1016 | |
1021 | |
1017 | |
1022 | /* |
1018 | /* |
… | |
… | |
1043 | * |
1039 | * |
1044 | * Add 'owner' who is the person examining this object. |
1040 | * Add 'owner' who is the person examining this object. |
1045 | * owner can be null if no one is being associated with this |
1041 | * owner can be null if no one is being associated with this |
1046 | * item (eg, debug dump or the like) |
1042 | * item (eg, debug dump or the like) |
1047 | */ |
1043 | */ |
1048 | |
1044 | const char * |
1049 | char * |
|
|
1050 | describe_item (const object *op, object *owner) |
1045 | describe_item (const object *op, object *owner) |
1051 | { |
1046 | { |
1052 | char buf[MAX_BUF]; |
1047 | char buf[MAX_BUF]; |
1053 | static char retbuf[VERY_BIG_BUF]; |
1048 | static char retbuf[VERY_BIG_BUF]; |
1054 | int identified, i; |
1049 | int identified, i; |
… | |
… | |
1364 | } |
1359 | } |
1365 | |
1360 | |
1366 | return retbuf; |
1361 | return retbuf; |
1367 | } |
1362 | } |
1368 | |
1363 | |
|
|
1364 | std::string |
|
|
1365 | object::describe_item (object *who) |
|
|
1366 | { |
|
|
1367 | return std::string (::describe_item (this, who)); |
|
|
1368 | } |
|
|
1369 | |
1369 | /* Return true if the item is magical. A magical item is one that |
1370 | /* Return true if the item is magical. A magical item is one that |
1370 | * increases/decreases any abilities, provides a resistance, |
1371 | * increases/decreases any abilities, provides a resistance, |
1371 | * has a generic magical bonus, or is an artifact. |
1372 | * has a generic magical bonus, or is an artifact. |
1372 | * This function is used by detect_magic to determine if an item |
1373 | * This function is used by detect_magic to determine if an item |
1373 | * should be marked as magical. |
1374 | * should be marked as magical. |
… | |
… | |
1524 | } |
1525 | } |
1525 | } |
1526 | } |
1526 | |
1527 | |
1527 | /* If the object is on a map, make sure we update its face */ |
1528 | /* If the object is on a map, make sure we update its face */ |
1528 | if (op->map) |
1529 | if (op->map) |
1529 | update_object (op, UP_OBJ_FACE); |
1530 | update_object (op, UP_OBJ_CHANGE); |
1530 | else |
1531 | else |
1531 | { |
1532 | { |
1532 | pl = op->in_player (); |
1533 | pl = op->in_player (); |
1533 | if (pl) |
1534 | if (pl) |
1534 | /* A lot of the values can change from an update - might as well send |
1535 | /* A lot of the values can change from an update - might as well send |