4 * Copyright (c) 1997 Ben Harrison, and others
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spoiler generation -BEN- */
20 * The spoiler file being created
22 static FILE *fff = NULL;
27 * Extract a textual representation of an attribute
29 static cptr attr_to_text(byte a)
34 case TERM_DARK: return ("XXX¤¤");
35 case TERM_WHITE: return ("Çò¤¤");
36 case TERM_SLATE: return ("Àij¥¿§¤Î");
37 case TERM_ORANGE: return ("¥ª¥ì¥ó¥¸¤Î");
38 case TERM_RED: return ("ÀÖ¤¤");
39 case TERM_GREEN: return ("ÎФÎ");
40 case TERM_BLUE: return ("ÀĤ¤");
41 case TERM_UMBER: return ("àèàῧ¤Î");
42 case TERM_L_DARK: return ("³¥¿§¤Î");
43 case TERM_L_WHITE: return ("ÌÀÀij¥¿§¤Î");
44 case TERM_VIOLET: return ("»ç¤Î");
45 case TERM_YELLOW: return ("²«¿§¤¤");
46 case TERM_L_RED: return ("ÌÀ¤¤ÀÖ¤Î");
47 case TERM_L_GREEN: return ("ÌÀ¤¤ÎФÎ");
48 case TERM_L_BLUE: return ("ÌÀ¤¤ÀĤÎ");
49 case TERM_L_UMBER: return ("ÌÀ¤¤àèàῧ¤Î");
51 case TERM_DARK: return ("xxx");
52 case TERM_WHITE: return ("White");
53 case TERM_SLATE: return ("Slate");
54 case TERM_ORANGE: return ("Orange");
55 case TERM_RED: return ("Red");
56 case TERM_GREEN: return ("Green");
57 case TERM_BLUE: return ("Blue");
58 case TERM_UMBER: return ("Umber");
59 case TERM_L_DARK: return ("L.Dark");
60 case TERM_L_WHITE: return ("L.Slate");
61 case TERM_VIOLET: return ("Violet");
62 case TERM_YELLOW: return ("Yellow");
63 case TERM_L_RED: return ("L.Red");
64 case TERM_L_GREEN: return ("L.Green");
65 case TERM_L_BLUE: return ("L.Blue");
66 case TERM_L_UMBER: return ("L.Umber");
94 * Item Spoilers by: benh@phial.com (Ben Harrison)
99 * The basic items categorized by type
101 static grouper group_item[] =
104 { TV_SHOT, "¼Í·âʪ" },
120 { TV_SWORD, "Éð´ï" },
122 { TV_SWORD, "Weapons" },
125 { TV_POLEARM, NULL },
127 { TV_DIGGING, NULL },
130 { TV_SOFT_ARMOR, "Ëɶñ¡ÊÂΡË" },
132 { TV_SOFT_ARMOR, "Armour (Body)" },
135 { TV_HARD_ARMOR, NULL },
136 { TV_DRAG_ARMOR, NULL },
139 { TV_CLOAK, "Ëɶñ¡Ê¤½¤Î¾¡Ë" },
141 { TV_CLOAK, "Armour (Misc)" },
151 { TV_AMULET, "¥¢¥ß¥å¥ì¥Ã¥È" },
154 { TV_AMULET, "Amulets" },
155 { TV_RING, "Rings" },
160 { TV_SCROLL, "´¬Êª" },
164 { TV_SCROLL, "Scrolls" },
165 { TV_POTION, "Potions" },
171 { TV_ROD, "¥í¥Ã¥É" },
172 { TV_WAND, "ËâË¡ËÀ" },
176 { TV_WAND, "Wands" },
177 { TV_STAFF, "Staffs" },
182 { TV_LIFE_BOOK, "ËâË¡½ñ¡ÊÀ¸Ì¿¡Ë" },
183 { TV_SORCERY_BOOK, "ËâË¡½ñ¡ÊÀç½Ñ¡Ë" },
184 { TV_NATURE_BOOK, "ËâË¡½ñ¡Ê¼«Á³¡Ë" },
185 { TV_CHAOS_BOOK, "ËâË¡½ñ¡Ê¥«¥ª¥¹¡Ë" },
186 { TV_DEATH_BOOK, "ËâË¡½ñ¡Ê°Å¹õ¡Ë" },
187 { TV_TRUMP_BOOK, "ËâË¡½ñ¡Ê¥È¥é¥ó¥×¡Ë" },
188 { TV_ARCANE_BOOK, "ËâË¡½ñ¡ÊÈë½Ñ¡Ë" },
189 { TV_ENCHANT_BOOK, "ËâË¡½ñ¡Ê¾¢¡Ë" },
190 { TV_DAEMON_BOOK, "ËâË¡½ñ¡Ê°Ëâ¡Ë" },
191 { TV_CRUSADE_BOOK, "ËâË¡½ñ¡ÊÇ˼١Ë" },
192 { TV_MUSIC_BOOK, "²Î½¸" },
193 { TV_HISSATSU_BOOK, "Éð·Ý¤Î½ñ" },
195 { TV_LIFE_BOOK, "Books (Life)" },
196 { TV_SORCERY_BOOK, "Books (Sorcery)" },
197 { TV_NATURE_BOOK, "Books (Nature)" },
198 { TV_CHAOS_BOOK, "Books (Chaos)" },
199 { TV_DEATH_BOOK, "Books (Death)" },
200 { TV_TRUMP_BOOK, "Books (Trump)" },
201 { TV_ARCANE_BOOK, "Books (Arcane)" },
202 { TV_ENCHANT_BOOK, "Books (Craft)" },
203 { TV_DAEMON_BOOK, "Books (Daemon)" },
204 { TV_CRUSADE_BOOK, "Books (Crusade)" },
205 { TV_MUSIC_BOOK, "Song Books" },
206 { TV_HISSATSU_BOOK, "Books (Kendo)" },
210 { TV_PARCHEMENT, "ÍÓÈé»æ" },
212 { TV_PARCHEMENT, "Parchement" },
218 { TV_CHEST, "Chests" },
222 { TV_CAPTURE, "¥¥ã¥×¥Á¥ã¡¼¡¦¥Ü¡¼¥ë" },
224 { TV_CAPTURE, "Capture Ball" },
228 { TV_CARD, "¥¨¥¯¥¹¥×¥ì¥¹¥«¡¼¥É" },
230 { TV_CARD, "Express Card" },
233 { TV_FIGURINE, "Magical Figurines" },
234 { TV_STATUE, "Statues" },
235 { TV_CORPSE, "Corpses" },
240 { TV_WHISTLE, "Whistle" },
244 { TV_SPIKE, "¤¯¤µ¤Ó" },
246 { TV_SPIKE, "Spike" },
253 { TV_SKELETON, NULL },
262 static void kind_info(char *buf, char *dam, char *wgt, int *lev, s32b *val, int k)
268 /* Get local object */
271 /* Prepare a fake item */
272 object_prep(q_ptr, k);
275 q_ptr->ident |= (IDENT_KNOWN);
285 (*lev) = get_object_level(q_ptr);
288 (*val) = object_value(q_ptr);
292 if (!buf || !dam || !wgt) return;
295 /* Description (too brief) */
296 object_desc_store(buf, q_ptr, FALSE, 0);
316 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
326 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
341 sprintf(dam, "%d", q_ptr->ac);
348 sprintf(wgt, "%3d.%d", q_ptr->weight / 10, q_ptr->weight % 10);
353 * Create a spoiler file for items
355 static void spoil_obj_desc(cptr fname)
357 int i, k, s, t, n = 0;
367 /* Build the filename */
368 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
370 /* File type is "TEXT" */
371 FILE_TYPE(FILE_TYPE_TEXT);
374 fff = my_fopen(buf, "w");
379 msg_print("Cannot create spoiler file.");
385 fprintf(fff, "Spoiler File -- Basic Items (Hengband %d.%d.%d)\n\n\n",
386 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
389 fprintf(fff, "%-45s %8s%7s%5s%9s\n",
390 "Description", "Dam/AC", "Wgt", "Lev", "Cost");
391 fprintf(fff, "%-45s %8s%7s%5s%9s\n",
392 "----------------------------------------",
393 "------", "---", "---", "----");
395 /* List the groups */
396 for (i = 0; TRUE; i++)
398 /* Write out the group title */
399 if (group_item[i].name)
401 /* Hack -- bubble-sort by cost and then level */
402 for (s = 0; s < n - 1; s++)
404 for (t = 0; t < n - 1; t++)
415 kind_info(NULL, NULL, NULL, &e1, &t1, who[i1]);
416 kind_info(NULL, NULL, NULL, &e2, &t2, who[i2]);
418 if ((t1 > t2) || ((t1 == t2) && (e1 > e2)))
427 /* Spoil each item */
428 for (s = 0; s < n; s++)
433 /* Describe the kind */
434 kind_info(buf, dam, wgt, &e, &v, who[s]);
437 fprintf(fff, " %-45s%8s%7s%5d%9ld\n",
438 buf, dam, wgt, e, (long)(v));
441 /* Start a new set */
445 if (!group_item[i].tval) break;
447 /* Start a new set */
448 fprintf(fff, "\n\n%s\n\n", group_item[i].name);
451 /* Acquire legal item types */
452 for (k = 1; k < max_k_idx; k++)
454 object_kind *k_ptr = &k_info[k];
456 /* Skip wrong tval's */
457 if (k_ptr->tval != group_item[i].tval) continue;
459 /* Hack -- Skip instant-artifacts */
460 if (k_ptr->gen_flags & (TRG_INSTA_ART)) continue;
468 /* Check for errors */
469 if (ferror(fff) || my_fclose(fff))
471 msg_print("Cannot close spoiler file.");
476 msg_print("Successfully created a spoiler file.");
481 * Artifact Spoilers by: randy@PICARD.tamu.edu (Randy Hutson)
486 * Returns a "+" string if a number is non-negative and an empty
489 #define POSITIZE(v) (((v) >= 0) ? "+" : "")
492 * These are used to format the artifact spoiler file. INDENT1 is used
493 * to indent all but the first line of an artifact spoiler. INDENT2 is
494 * used when a line "wraps". (Bladeturner's resistances cause this.)
500 * MAX_LINE_LEN specifies when a line should wrap.
502 #define MAX_LINE_LEN 75
505 * Given an array, determine how many elements are in the array
507 #define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))
510 * The artifacts categorized by type
512 static grouper group_artifact[] =
515 { TV_SWORD, "Åá·õ" },
516 { TV_POLEARM, "Áä/Éà" },
517 { TV_HAFTED, "Æß´ï" },
518 { TV_DIGGING, "¥·¥ã¥Ù¥ë/¤Ä¤ë¤Ï¤·" },
519 { TV_BOW, "Èô¤ÓÆ»¶ñ" },
522 { TV_SOFT_ARMOR, "³»" },
523 { TV_HARD_ARMOR, NULL },
524 { TV_DRAG_ARMOR, NULL },
526 { TV_CLOAK, "¥¯¥í¡¼¥¯" },
529 { TV_HELM, "³õ/´§" },
531 { TV_GLOVES, "äƼê" },
535 { TV_AMULET, "¥¢¥ß¥å¥ì¥Ã¥È" },
538 { TV_SWORD, "Edged Weapons" },
539 { TV_POLEARM, "Polearms" },
540 { TV_HAFTED, "Hafted Weapons" },
541 { TV_DIGGING, "Shovels/Picks" },
543 { TV_ARROW, "Ammo" },
545 { TV_SOFT_ARMOR, "Body Armor" },
546 { TV_HARD_ARMOR, NULL },
547 { TV_DRAG_ARMOR, NULL },
549 { TV_CLOAK, "Cloaks" },
550 { TV_SHIELD, "Shields" },
552 { TV_HELM, "Helms/Crowns" },
554 { TV_GLOVES, "Gloves" },
555 { TV_BOOTS, "Boots" },
557 { TV_LITE, "Light Sources" },
558 { TV_AMULET, "Amulets" },
559 { TV_RING, "Rings" },
568 * Pair together a constant flag with a textual description.
570 * Used by both "init.c" and "wiz-spo.c".
572 * Note that it sometimes more efficient to actually make an array
573 * of textual names, where entry 'N' is assumed to be paired with
574 * the flag whose value is "1L << N", but that requires hard-coding.
577 typedef struct flag_desc flag_desc;
582 const char *const desc;
588 * These are used for "+3 to STR, DEX", etc. These are separate from
589 * the other pval affected traits to simplify the case where an object
590 * affects all stats. In this case, "All stats" is used instead of
591 * listing each stat individually.
594 static flag_desc stat_flags_desc[] =
600 { TR_DEX, "´ïÍѤµ" },
601 { TR_CON, "Âѵ×ÎÏ" },
614 * Besides stats, these are the other player traits
615 * which may be affected by an object's pval
618 static flag_desc pval_flags1_desc[] =
621 { TR_MAGIC_MASTERY, "ËâË¡Æ»¶ñ»ÈÍÑǽÎÏ" },
622 { TR_STEALTH, "±£Ì©" },
623 { TR_SEARCH, "õº÷" },
624 { TR_INFRA, "ÀÖ³°Àþ»ëÎÏ" },
625 { TR_TUNNEL, "ºÎ·¡" },
626 { TR_BLOWS, "¹¶·â²ó¿ô" },
627 { TR_SPEED, "¥¹¥Ô¡¼¥É" }
629 { TR_STEALTH, "Stealth" },
630 { TR_SEARCH, "Searching" },
631 { TR_INFRA, "Infravision" },
632 { TR_TUNNEL, "Tunneling" },
633 { TR_BLOWS, "Attacks" },
634 { TR_SPEED, "Speed" }
639 * Slaying preferences for weapons
642 static flag_desc slay_flags_desc[] =
645 { TR_SLAY_ANIMAL, "ưʪ" },
646 { TR_KILL_ANIMAL, "*ưʪ*" },
647 { TR_SLAY_EVIL, "¼Ù°" },
648 { TR_KILL_EVIL, "*¼Ù°*" },
649 { TR_SLAY_HUMAN, "¿Í´Ö" },
650 { TR_KILL_HUMAN, "*¿Í´Ö*" },
651 { TR_SLAY_UNDEAD, "¥¢¥ó¥Ç¥Ã¥É" },
652 { TR_KILL_UNDEAD, "*¥¢¥ó¥Ç¥Ã¥É*" },
653 { TR_SLAY_DEMON, "°Ëâ" },
654 { TR_KILL_DEMON, "*°Ëâ*" },
655 { TR_SLAY_ORC, "¥ª¡¼¥¯" },
656 { TR_KILL_ORC, "*¥ª¡¼¥¯*" },
657 { TR_SLAY_TROLL, "¥È¥í¥ë" },
658 { TR_KILL_TROLL, "*¥È¥í¥ë*" },
659 { TR_SLAY_GIANT, "µð¿Í" },
660 { TR_KILL_GIANT, "*µð¿Í*" },
661 { TR_SLAY_DRAGON, "¥É¥é¥´¥ó" },
662 { TR_KILL_DRAGON, "*¥É¥é¥´¥ó*" },
664 { TR_SLAY_ANIMAL, "Animal" },
665 { TR_KILL_ANIMAL, "XAnimal" },
666 { TR_SLAY_EVIL, "Evil" },
667 { TR_KILL_EVIL, "XEvil" },
668 { TR_SLAY_HUMAN, "Human" },
669 { TR_KILL_HUMAN, "XHuman" },
670 { TR_SLAY_UNDEAD, "Undead" },
671 { TR_KILL_UNDEAD, "XUndead" },
672 { TR_SLAY_DEMON, "Demon" },
673 { TR_KILL_DEMON, "XDemon" },
674 { TR_SLAY_ORC, "Orc" },
675 { TR_KILL_ORC, "XOrc" },
676 { TR_SLAY_TROLL, "Troll" },
677 { TR_KILL_TROLL, "XTroll" },
678 { TR_SLAY_GIANT, "Giant" },
679 { TR_KILL_GIANT, "Xgiant" },
680 { TR_SLAY_DRAGON, "Dragon" },
681 { TR_KILL_DRAGON, "Xdragon" }
686 * Elemental brands for weapons
688 * Clearly, TR1_IMPACT is a bit out of place here. To simplify
689 * coding, it has been included here along with the elemental
690 * brands. It does seem to fit in with the brands and slaying
691 * more than the miscellaneous section.
693 static flag_desc brand_flags_desc[] =
696 { TR_BRAND_ACID, "Íϲò" },
697 { TR_BRAND_ELEC, "ÅÅ·â" },
698 { TR_BRAND_FIRE, "¾Æ´þ" },
699 { TR_BRAND_COLD, "Åà·ë" },
700 { TR_BRAND_POIS, "ÆÇ»¦" },
702 { TR_FORCE_WEAPON, "ÍýÎÏ" },
703 { TR_CHAOTIC, "º®ÆÙ" },
704 { TR_VAMPIRIC, "µÛ·ì" },
705 { TR_IMPACT, "ÃÏ¿Ì" },
706 { TR_VORPAL, "ÀÚ¤ìÌ£" },
708 { TR_BRAND_ACID, "Acid Brand" },
709 { TR_BRAND_ELEC, "Lightning Brand" },
710 { TR_BRAND_FIRE, "Flame Tongue" },
711 { TR_BRAND_COLD, "Frost Brand" },
712 { TR_BRAND_POIS, "Poisoned" },
714 { TR_FORCE_WEAPON, "Force" },
715 { TR_CHAOTIC, "Mark of Chaos" },
716 { TR_VAMPIRIC, "Vampiric" },
717 { TR_IMPACT, "Earthquake impact on hit" },
718 { TR_VORPAL, "Very sharp" },
726 static const flag_desc resist_flags_desc[] =
729 { TR_RES_ACID, "»À" },
730 { TR_RES_ELEC, "ÅÅ·â" },
731 { TR_RES_FIRE, "²Ð±ê" },
732 { TR_RES_COLD, "Î䵤" },
733 { TR_RES_POIS, "ÆÇ" },
734 { TR_RES_FEAR, "¶²ÉÝ"},
735 { TR_RES_LITE, "Á®¸÷" },
736 { TR_RES_DARK, "°Å¹õ" },
737 { TR_RES_BLIND, "ÌÕÌÜ" },
738 { TR_RES_CONF, "º®Íð" },
739 { TR_RES_SOUND, "¹ì²»" },
740 { TR_RES_SHARDS, "ÇËÊÒ" },
741 { TR_RES_NETHER, "ÃϹö" },
742 { TR_RES_NEXUS, "°ø²Ìº®Íð" },
743 { TR_RES_CHAOS, "¥«¥ª¥¹" },
744 { TR_RES_DISEN, "Îô²½" },
746 { TR_RES_ACID, "Acid" },
747 { TR_RES_ELEC, "Lightning" },
748 { TR_RES_FIRE, "Fire" },
749 { TR_RES_COLD, "Cold" },
750 { TR_RES_POIS, "Poison" },
751 { TR_RES_FEAR, "Fear"},
752 { TR_RES_LITE, "Light" },
753 { TR_RES_DARK, "Dark" },
754 { TR_RES_BLIND, "Blindness" },
755 { TR_RES_CONF, "Confusion" },
756 { TR_RES_SOUND, "Sound" },
757 { TR_RES_SHARDS, "Shards" },
758 { TR_RES_NETHER, "Nether" },
759 { TR_RES_NEXUS, "Nexus" },
760 { TR_RES_CHAOS, "Chaos" },
761 { TR_RES_DISEN, "Disenchantment" },
766 * Elemental immunities (along with poison)
769 static const flag_desc immune_flags_desc[] =
772 { TR_IM_ACID, "»À" },
773 { TR_IM_ELEC, "ÅÅ·â" },
774 { TR_IM_FIRE, "²Ð±ê" },
775 { TR_IM_COLD, "Î䵤" },
777 { TR_IM_ACID, "Acid" },
778 { TR_IM_ELEC, "Lightning" },
779 { TR_IM_FIRE, "Fire" },
780 { TR_IM_COLD, "Cold" },
785 * Sustain stats - these are given their "own" line in the
786 * spoiler file, mainly for simplicity
788 static const flag_desc sustain_flags_desc[] =
791 { TR_SUST_STR, "ÏÓÎÏ" },
792 { TR_SUST_INT, "ÃÎǽ" },
793 { TR_SUST_WIS, "¸¤µ" },
794 { TR_SUST_DEX, "´ïÍѤµ" },
795 { TR_SUST_CON, "Âѵ×ÎÏ" },
796 { TR_SUST_CHR, "Ì¥ÎÏ" },
798 { TR_SUST_STR, "STR" },
799 { TR_SUST_INT, "INT" },
800 { TR_SUST_WIS, "WIS" },
801 { TR_SUST_DEX, "DEX" },
802 { TR_SUST_CON, "CON" },
803 { TR_SUST_CHR, "CHR" },
808 * Miscellaneous magic given by an object's "flags2" field
811 static const flag_desc misc_flags2_desc[] =
814 { TR_THROW, "ÅêÚ³" },
815 { TR_REFLECT, "È¿¼Í" },
816 { TR_FREE_ACT, "ËãáãÃΤ餺" },
817 { TR_HOLD_LIFE, "À¸Ì¿ÎÏ°Ý»ý" },
819 { TR_THROW, "Throwing" },
820 { TR_REFLECT, "Reflection" },
821 { TR_FREE_ACT, "Free Action" },
822 { TR_HOLD_LIFE, "Hold Life" },
827 * Miscellaneous magic given by an object's "flags3" field
829 * Note that cursed artifacts and objects with permanent light
830 * are handled "directly" -- see analyze_misc_magic()
833 static const flag_desc misc_flags3_desc[] =
836 { TR_SH_FIRE, "²Ð±ê¥ª¡¼¥é" },
837 { TR_SH_ELEC, "Åŷ⥪¡¼¥é" },
838 { TR_SH_COLD, "Î䵤¥ª¡¼¥é" },
839 { TR_NO_TELE, "È¿¥Æ¥ì¥Ý¡¼¥È" },
840 { TR_NO_MAGIC, "È¿ËâË¡" },
841 { TR_FEATHER, "ÉâÍ·" },
842 { TR_SEE_INVIS, "²Ä»ëÆ©ÌÀ" },
843 { TR_TELEPATHY, "¥Æ¥ì¥Ñ¥·¡¼" },
844 { TR_ESP_ANIMAL, "ưʪ´¶ÃÎ" },
845 { TR_ESP_UNDEAD, "ÉԻശÃÎ" },
846 { TR_ESP_DEMON, "°Ëâ´¶ÃÎ" },
847 { TR_ESP_ORC, "¥ª¡¼¥¯´¶ÃÎ" },
848 { TR_ESP_TROLL, "¥È¥í¥ë´¶ÃÎ" },
849 { TR_ESP_GIANT, "µð¿Í´¶ÃÎ" },
850 { TR_ESP_DRAGON, "¥É¥é¥´¥ó´¶ÃÎ" },
851 { TR_ESP_HUMAN, "¿Í´Ö´¶ÃÎ" },
852 { TR_ESP_EVIL, "¼Ù°´¶ÃÎ" },
853 { TR_ESP_GOOD, "Á±ÎÉ´¶ÃÎ" },
854 { TR_ESP_NONLIVING, "̵À¸Êª´¶ÃÎ" },
855 { TR_ESP_UNIQUE, "¥æ¥Ë¡¼¥¯´¶ÃÎ" },
856 { TR_SLOW_DIGEST, "Ãپò½" },
857 { TR_REGEN, "µÞ®²óÉü" },
858 { TR_WARNING, "·Ù¹ð" },
859 /* { TR_XTRA_MIGHT, "¶¯Îϼͷâ" }, */
860 { TR_XTRA_SHOTS, "Äɲüͷâ" }, /* always +1? */
861 { TR_DRAIN_EXP, "·Ð¸³Ã͵ۼý" },
862 { TR_AGGRAVATE, "È¿´¶" },
863 { TR_BLESSED, "½ËÊ¡" },
864 { TR_DEC_MANA, "¾ÃÈñËâÎϸº¾¯" },
866 { TR_SH_FIRE, "Fiery Aura" },
867 { TR_SH_ELEC, "Electric Aura" },
868 { TR_SH_COLD, "Coldly Aura" },
869 { TR_NO_TELE, "Prevent Teleportation" },
870 { TR_NO_MAGIC, "Anti-Magic" },
871 { TR_FEATHER, "Levitation" },
872 { TR_SEE_INVIS, "See Invisible" },
873 { TR_TELEPATHY, "ESP" },
874 { TR_SLOW_DIGEST, "Slow Digestion" },
875 { TR_REGEN, "Regeneration" },
876 { TR_WARNING, "Warning" },
877 /* { TR_XTRA_MIGHT, "Extra Might" }, */
878 { TR_XTRA_SHOTS, "+1 Extra Shot" }, /* always +1? */
879 { TR_DRAIN_EXP, "Drains Experience" },
880 { TR_AGGRAVATE, "Aggravates" },
881 { TR_BLESSED, "Blessed Blade" },
882 { TR_DEC_MANA, "Decrease Mana Consumption Rate" },
888 * A special type used just for deailing with pvals
893 * This will contain a string such as "+2", "-10", etc.
898 * A list of various player traits affected by an object's pval such
899 * as stats, speed, stealth, etc. "Extra attacks" is NOT included in
900 * this list since it will probably be desirable to format its
901 * description differently.
903 * Note that room need only be reserved for the number of stats - 1
904 * since the description "All stats" is used if an object affects all
905 * all stats. Also, room must be reserved for a sentinel NULL pointer.
907 * This will be a list such as ["STR", "DEX", "Stealth", NULL] etc.
909 * This list includes extra attacks, for simplicity.
911 cptr pval_affects[N_ELEMENTS(stat_flags_desc) - 1 +
912 N_ELEMENTS(pval_flags1_desc) + 1];
918 * An "object analysis structure"
920 * It will be filled with descriptive strings detailing an object's
921 * various magical powers. The "ignore X" traits are not noted since
922 * all artifacts ignore "normal" destruction.
927 /* "The Longsword Dragonsmiter (6d4) (+20, +25)" */
928 char description[MAX_NLEN];
930 /* Description of what is affected by an object's pval */
931 pval_info_type pval_info;
933 /* A list of an object's slaying preferences */
934 cptr slays[N_ELEMENTS(slay_flags_desc) + 1];
936 /* A list if an object's elemental brands */
937 cptr brands[N_ELEMENTS(brand_flags_desc) + 1];
939 /* A list of immunities granted by an object */
940 cptr immunities[N_ELEMENTS(immune_flags_desc) + 1];
942 /* A list of resistances granted by an object */
943 cptr resistances[N_ELEMENTS(resist_flags_desc) + 1];
945 /* A list of stats sustained by an object */
946 cptr sustains[N_ELEMENTS(sustain_flags_desc) - 1 + 1];
948 /* A list of various magical qualities an object may have */
949 cptr misc_magic[N_ELEMENTS(misc_flags2_desc) + N_ELEMENTS(misc_flags3_desc)
950 + 1 /* Permanent Light */
952 + 1 /* type of curse */
953 + 1]; /* sentinel NULL */
955 /* A string describing an artifact's activation */
958 /* "Level 20, Rarity 30, 3.0 lbs, 20000 Gold" */
964 * Write out `n' of the character `c' to the spoiler file
966 static void spoiler_out_n_chars(int n, char c)
968 while (--n >= 0) fputc(c, fff);
973 * Write out `n' blank lines to the spoiler file
975 static void spoiler_blanklines(int n)
977 spoiler_out_n_chars(n, '\n');
982 * Write a line to the spoiler file and then "underline" it with hypens
984 static void spoiler_underline(cptr str)
986 fprintf(fff, "%s\n", str);
987 spoiler_out_n_chars(strlen(str), '-');
994 * This function does most of the actual "analysis". Given a set of bit flags
995 * (which will be from one of the flags fields from the object in question),
996 * a "flag description structure", a "description list", and the number of
997 * elements in the "flag description structure", this function sets the
998 * "description list" members to the appropriate descriptions contained in
999 * the "flag description structure".
1001 * The possibly updated description pointer is returned.
1003 static cptr *spoiler_flag_aux(const u32b art_flags[TR_FLAG_SIZE],
1004 const flag_desc *flag_ptr,
1005 cptr *desc_ptr, const int n_elmnts)
1009 for (i = 0; i < n_elmnts; ++i)
1011 if (have_flag(art_flags, flag_ptr[i].flag))
1013 *desc_ptr++ = flag_ptr[i].desc;
1022 * Acquire a "basic" description "The Cloak of Death [1,+10]"
1024 static void analyze_general (object_type *o_ptr, char *desc_ptr)
1026 /* Get a "useful" description of the object */
1027 object_desc_store(desc_ptr, o_ptr, TRUE, 1);
1032 * List "player traits" altered by an artifact's pval. These include stats,
1033 * speed, infravision, tunneling, stealth, searching, and extra attacks.
1035 static void analyze_pval (object_type *o_ptr, pval_info_type *p_ptr)
1037 u32b flgs[TR_FLAG_SIZE];
1041 /* If pval == 0, there is nothing to do. */
1044 /* An "empty" pval description indicates that pval == 0 */
1045 p_ptr->pval_desc[0] = '\0';
1049 /* Extract the flags */
1050 object_flags(o_ptr, flgs);
1052 affects_list = p_ptr->pval_affects;
1054 /* Create the "+N" string */
1055 sprintf(p_ptr->pval_desc, "%s%d", POSITIZE(o_ptr->pval), o_ptr->pval);
1057 /* First, check to see if the pval affects all stats */
1058 if (have_flag(flgs, TR_STR) && have_flag(flgs, TR_INT) &&
1059 have_flag(flgs, TR_WIS) && have_flag(flgs, TR_DEX) &&
1060 have_flag(flgs, TR_CON) && have_flag(flgs, TR_CHR))
1063 *affects_list++ = "Á´Ç½ÎÏ";
1065 *affects_list++ = "All stats";
1069 /* Are any stats affected? */
1070 else if (have_flag(flgs, TR_STR) || have_flag(flgs, TR_INT) ||
1071 have_flag(flgs, TR_WIS) || have_flag(flgs, TR_DEX) ||
1072 have_flag(flgs, TR_CON) || have_flag(flgs, TR_CHR))
1074 affects_list = spoiler_flag_aux(flgs, stat_flags_desc,
1076 N_ELEMENTS(stat_flags_desc));
1079 /* And now the "rest" */
1080 affects_list = spoiler_flag_aux(flgs, pval_flags1_desc,
1082 N_ELEMENTS(pval_flags1_desc));
1084 /* Terminate the description list */
1085 *affects_list = NULL;
1089 /* Note the slaying specialties of a weapon */
1090 static void analyze_slay (object_type *o_ptr, cptr *slay_list)
1092 u32b flgs[TR_FLAG_SIZE];
1094 object_flags(o_ptr, flgs);
1096 slay_list = spoiler_flag_aux(flgs, slay_flags_desc, slay_list,
1097 N_ELEMENTS(slay_flags_desc));
1099 /* Terminate the description list */
1103 /* Note an object's elemental brands */
1104 static void analyze_brand (object_type *o_ptr, cptr *brand_list)
1106 u32b flgs[TR_FLAG_SIZE];
1108 object_flags(o_ptr, flgs);
1110 brand_list = spoiler_flag_aux(flgs, brand_flags_desc, brand_list,
1111 N_ELEMENTS(brand_flags_desc));
1113 /* Terminate the description list */
1118 /* Note the resistances granted by an object */
1119 static void analyze_resist (object_type *o_ptr, cptr *resist_list)
1121 u32b flgs[TR_FLAG_SIZE];
1123 object_flags(o_ptr, flgs);
1125 resist_list = spoiler_flag_aux(flgs, resist_flags_desc,
1126 resist_list, N_ELEMENTS(resist_flags_desc));
1128 /* Terminate the description list */
1129 *resist_list = NULL;
1133 /* Note the immunities granted by an object */
1134 static void analyze_immune (object_type *o_ptr, cptr *immune_list)
1136 u32b flgs[TR_FLAG_SIZE];
1138 object_flags(o_ptr, flgs);
1140 immune_list = spoiler_flag_aux(flgs, immune_flags_desc,
1141 immune_list, N_ELEMENTS(immune_flags_desc));
1143 /* Terminate the description list */
1144 *immune_list = NULL;
1147 /* Note which stats an object sustains */
1149 static void analyze_sustains (object_type *o_ptr, cptr *sustain_list)
1151 u32b flgs[TR_FLAG_SIZE];
1153 object_flags(o_ptr, flgs);
1155 /* Simplify things if an item sustains all stats */
1156 if (have_flag(flgs, TR_SUST_STR) && have_flag(flgs, TR_SUST_INT) &&
1157 have_flag(flgs, TR_SUST_WIS) && have_flag(flgs, TR_SUST_DEX) &&
1158 have_flag(flgs, TR_SUST_CON) && have_flag(flgs, TR_SUST_CHR))
1161 *sustain_list++ = "Á´Ç½ÎÏ";
1163 *sustain_list++ = "All stats";
1167 /* Should we bother? */
1168 else if (have_flag(flgs, TR_SUST_STR) || have_flag(flgs, TR_SUST_INT) ||
1169 have_flag(flgs, TR_SUST_WIS) || have_flag(flgs, TR_SUST_DEX) ||
1170 have_flag(flgs, TR_SUST_CON) || have_flag(flgs, TR_SUST_CHR))
1172 sustain_list = spoiler_flag_aux(flgs, sustain_flags_desc,
1174 N_ELEMENTS(sustain_flags_desc));
1177 /* Terminate the description list */
1178 *sustain_list = NULL;
1183 * Note miscellaneous powers bestowed by an artifact such as see invisible,
1184 * free action, permanent light, etc.
1186 static void analyze_misc_magic (object_type *o_ptr, cptr *misc_list)
1188 u32b flgs[TR_FLAG_SIZE];
1190 object_flags(o_ptr, flgs);
1192 misc_list = spoiler_flag_aux(flgs, misc_flags2_desc, misc_list,
1193 N_ELEMENTS(misc_flags2_desc));
1195 misc_list = spoiler_flag_aux(flgs, misc_flags3_desc, misc_list,
1196 N_ELEMENTS(misc_flags3_desc));
1199 * Artifact lights -- large radius light.
1201 if ((o_ptr->tval == TV_LITE) && artifact_p(o_ptr))
1204 *misc_list++ = "±Êµ×¸÷¸»(Ⱦ·Â3)";
1206 *misc_list++ = "Permanent Light(3)";
1211 * Glowing artifacts -- small radius light.
1213 if (have_flag(flgs, TR_LITE))
1216 *misc_list++ = "±Êµ×¸÷¸»(Ⱦ·Â1)";
1218 *misc_list++ = "Permanent Light(1)";
1223 * Handle cursed objects here to avoid redundancies such as noting
1224 * that a permanently cursed object is heavily cursed as well as
1225 * being "lightly cursed".
1228 /* if (cursed_p(o_ptr)) */
1231 if (have_flag(flgs, TR_TY_CURSE))
1234 *misc_list++ = "ÂÀ¸Å¤Î±åÇ°";
1236 *misc_list++ = "Ancient Curse";
1239 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1242 *misc_list++ = "±Ê±ó¤Î¼ö¤¤";
1244 *misc_list++ = "Permanently Cursed";
1247 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1250 *misc_list++ = "¶¯ÎϤʼö¤¤";
1252 *misc_list++ = "Heavily Cursed";
1256 else if (o_ptr->curse_flags & TRC_CURSED)
1259 *misc_list++ = "¼ö¤¤";
1261 *misc_list++ = "Cursed";
1266 /* Terminate the description list */
1274 * Determine the minimum depth an artifact can appear, its rarity, its weight,
1275 * and its value in gold pieces
1277 static void analyze_misc (object_type *o_ptr, char *misc_desc)
1279 artifact_type *a_ptr = &a_info[o_ptr->name1];
1282 sprintf(misc_desc, "¥ì¥Ù¥ë %u, ´õ¾¯ÅÙ %u, %d.%d kg, ¡ð%ld",
1283 a_ptr->level, a_ptr->rarity,
1284 lbtokg1(a_ptr->weight), lbtokg2(a_ptr->weight), a_ptr->cost);
1286 sprintf(misc_desc, "Level %u, Rarity %u, %d.%d lbs, %ld Gold",
1287 a_ptr->level, a_ptr->rarity,
1288 a_ptr->weight / 10, a_ptr->weight % 10, a_ptr->cost);
1294 * Fill in an object description structure for a given object
1296 static void object_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
1298 analyze_general(o_ptr, desc_ptr->description);
1300 analyze_pval(o_ptr, &desc_ptr->pval_info);
1302 analyze_brand(o_ptr, desc_ptr->brands);
1304 analyze_slay(o_ptr, desc_ptr->slays);
1306 analyze_immune(o_ptr, desc_ptr->immunities);
1308 analyze_resist(o_ptr, desc_ptr->resistances);
1310 analyze_sustains(o_ptr, desc_ptr->sustains);
1312 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
1314 analyze_misc(o_ptr, desc_ptr->misc_desc);
1316 desc_ptr->activation = item_activation(o_ptr);
1320 static void print_header(void)
1324 sprintf(buf, "Artifact Spoilers for Hengband Version %d.%d.%d",
1325 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1326 spoiler_underline(buf);
1330 * This is somewhat ugly.
1332 * Given a header ("Resist", e.g.), a list ("Fire", "Cold", Acid", e.g.),
1333 * and a separator character (',', e.g.), write the list to the spoiler file
1334 * in a "nice" format, such as:
1336 * Resist Fire, Cold, Acid
1338 * That was a simple example, but when the list is long, a line wrap
1339 * should occur, and this should induce a new level of indention if
1340 * a list is being spread across lines. So for example, Bladeturner's
1341 * list of resistances should look something like this
1343 * Resist Acid, Lightning, Fire, Cold, Poison, Light, Dark, Blindness,
1344 * Confusion, Sound, Shards, Nether, Nexus, Chaos, Disenchantment
1346 * However, the code distinguishes between a single list of many items vs.
1347 * many lists. (The separator is used to make this determination.) A single
1348 * list of many items will not cause line wrapping (since there is no
1349 * apparent reason to do so). So the lists of Ulmo's miscellaneous traits
1350 * might look like this:
1352 * Free Action; Hold Life; See Invisible; Slow Digestion; Regeneration
1355 * So comparing the two, "Regeneration" has no trailing separator and
1356 * "Blessed Blade" was not indented. (Also, Ulmo's lists have no headers,
1357 * but that's not relevant to line wrapping and indention.)
1360 /* ITEM_SEP separates items within a list */
1361 #define ITEM_SEP ','
1364 /* LIST_SEP separates lists */
1366 #define LIST_SEP ','
1368 #define LIST_SEP ';'
1371 static void spoiler_outlist(cptr header, cptr *list, char separator)
1373 int line_len, buf_len;
1374 char line[MAX_LINE_LEN+1], buf[80];
1376 /* Ignore an empty list */
1377 if (*list == NULL) return;
1379 /* This function always indents */
1380 strcpy(line, INDENT1);
1382 /* Create header (if one was given) */
1383 if (header && (header[0]))
1385 strcat(line, header);
1389 line_len = strlen(line);
1391 /* Now begin the tedious task */
1394 /* Copy the current item to a buffer */
1397 /* Note the buffer's length */
1398 buf_len = strlen(buf);
1401 * If there is an item following this one, pad with separator and
1402 * a space and adjust the buffer length
1407 sprintf(buf + buf_len, "%c ", separator);
1412 * If the buffer will fit on the current line, just append the
1413 * buffer to the line and adjust the line length accordingly.
1416 if (line_len + buf_len <= MAX_LINE_LEN)
1419 line_len += buf_len;
1422 /* Apply line wrapping and indention semantics described above */
1426 * Don't print a trailing list separator but do print a trailing
1429 if (line_len > 1 && line[line_len - 1] == ' '
1430 && line[line_len - 2] == LIST_SEP)
1432 /* Ignore space and separator */
1433 line[line_len - 2] = '\0';
1435 /* Write to spoiler file */
1436 fprintf(fff, "%s\n", line);
1438 /* Begin new line at primary indention level */
1439 sprintf(line, "%s%s", INDENT1, buf);
1444 /* Write to spoiler file */
1445 fprintf(fff, "%s\n", line);
1447 /* Begin new line at secondary indention level */
1448 sprintf(line, "%s%s", INDENT2, buf);
1451 line_len = strlen(line);
1454 /* Advance, with break */
1455 if (!*++list) break;
1458 /* Write what's left to the spoiler file */
1459 fprintf(fff, "%s\n", line);
1463 /* Create a spoiler file entry for an artifact */
1465 static void spoiler_print_art(obj_desc_list *art_ptr)
1467 pval_info_type *pval_ptr = &art_ptr->pval_info;
1471 /* Don't indent the first line */
1472 fprintf(fff, "%s\n", art_ptr->description);
1474 /* An "empty" pval description indicates that the pval affects nothing */
1475 if (pval_ptr->pval_desc[0])
1477 /* Mention the effects of pval */
1479 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
1481 sprintf(buf, "%s to", pval_ptr->pval_desc);
1483 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
1486 /* Now deal with the description lists */
1489 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
1491 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
1493 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
1495 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
1497 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
1499 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
1501 spoiler_outlist("", art_ptr->brands, LIST_SEP);
1503 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
1505 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
1507 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
1509 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
1512 /* Write out the possible activation at the primary indention level */
1513 if (art_ptr->activation)
1516 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
1518 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
1522 /* End with the miscellaneous facts */
1523 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
1528 * Hack -- Create a "forged" artifact
1530 static bool make_fake_artifact(object_type *o_ptr, int name1)
1534 artifact_type *a_ptr = &a_info[name1];
1537 /* Ignore "empty" artifacts */
1538 if (!a_ptr->name) return FALSE;
1540 /* Acquire the "kind" index */
1541 i = lookup_kind(a_ptr->tval, a_ptr->sval);
1544 if (!i) return (FALSE);
1546 /* Create the artifact */
1547 object_prep(o_ptr, i);
1550 o_ptr->name1 = name1;
1552 /* Extract the fields */
1553 o_ptr->pval = a_ptr->pval;
1554 o_ptr->ac = a_ptr->ac;
1555 o_ptr->dd = a_ptr->dd;
1556 o_ptr->ds = a_ptr->ds;
1557 o_ptr->to_a = a_ptr->to_a;
1558 o_ptr->to_h = a_ptr->to_h;
1559 o_ptr->to_d = a_ptr->to_d;
1560 o_ptr->weight = a_ptr->weight;
1568 * Create a spoiler file for artifacts
1570 static void spoil_artifact(cptr fname)
1577 obj_desc_list artifact;
1582 /* Build the filename */
1583 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1585 /* File type is "TEXT" */
1586 FILE_TYPE(FILE_TYPE_TEXT);
1589 fff = my_fopen(buf, "w");
1594 msg_print("Cannot create spoiler file.");
1598 /* Dump the header */
1601 /* List the artifacts by tval */
1602 for (i = 0; group_artifact[i].tval; i++)
1604 /* Write out the group title */
1605 if (group_artifact[i].name)
1607 spoiler_blanklines(2);
1608 spoiler_underline(group_artifact[i].name);
1609 spoiler_blanklines(1);
1612 /* Now search through all of the artifacts */
1613 for (j = 1; j < max_a_idx; ++j)
1615 artifact_type *a_ptr = &a_info[j];
1617 /* We only want objects in the current group */
1618 if (a_ptr->tval != group_artifact[i].tval) continue;
1620 /* Get local object */
1623 /* Wipe the object */
1626 /* Attempt to "forge" the artifact */
1627 if (!make_fake_artifact(q_ptr, j)) continue;
1629 /* Analyze the artifact */
1630 object_analyze(q_ptr, &artifact);
1632 /* Write out the artifact description to the spoiler file */
1633 spoiler_print_art(&artifact);
1637 /* Check for errors */
1638 if (ferror(fff) || my_fclose(fff))
1640 msg_print("Cannot close spoiler file.");
1645 msg_print("Successfully created a spoiler file.");
1653 * Create a spoiler file for monsters -BEN-
1655 static void spoil_mon_desc(cptr fname)
1672 /* Build the filename */
1673 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1675 /* File type is "TEXT" */
1676 FILE_TYPE(FILE_TYPE_TEXT);
1679 fff = my_fopen(buf, "w");
1684 msg_print("Cannot create spoiler file.");
1688 /* Allocate the "who" array */
1689 C_MAKE(who, max_r_idx, s16b);
1691 /* Dump the header */
1692 fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1693 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1694 fprintf(fff, "------------------------------------------\n\n");
1696 /* Dump the header */
1697 fprintf(fff, " %-38.38s%4s%4s%4s%7s%5s %11.11s\n",
1698 "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
1699 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1700 "--------", "---", "---", "---", "--", "--", "-----------");
1703 /* Scan the monsters */
1704 for (i = 1; i < max_r_idx; i++)
1706 monster_race *r_ptr = &r_info[i];
1708 /* Use that monster */
1709 if (r_ptr->name) who[n++] = i;
1712 /* Select the sort method */
1713 ang_sort_comp = ang_sort_comp_hook;
1714 ang_sort_swap = ang_sort_swap_hook;
1716 /* Sort the array by dungeon depth of monsters */
1717 ang_sort(who, &why, n);
1720 for (i = 0; i < n; i++)
1722 monster_race *r_ptr = &r_info[who[i]];
1724 cptr name = (r_name + r_ptr->name);
1725 if (r_ptr->flags7 & (RF7_KAGE)) continue;
1727 /* Get the "name" */
1728 /* if (r_ptr->flags1 & (RF1_QUESTOR)) */
1731 sprintf(nam, "[Q] %s", name);
1733 else if (r_ptr->flags1 & (RF1_UNIQUE))
1735 sprintf(nam, "[U] %s", name);
1740 sprintf(nam, " %s", name);
1742 sprintf(nam, "The %s", name);
1748 sprintf(lev, "%d", r_ptr->level);
1751 sprintf(rar, "%d", r_ptr->rarity);
1754 if (r_ptr->speed >= 110)
1756 sprintf(spd, "+%d", (r_ptr->speed - 110));
1760 sprintf(spd, "-%d", (110 - r_ptr->speed));
1764 sprintf(ac, "%d", r_ptr->ac);
1767 if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
1769 sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
1773 sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
1778 sprintf(exp, "%ld", (long)(r_ptr->mexp));
1780 /* Hack -- use visual instead */
1781 sprintf(exp, "%s '%c'", attr_to_text(r_ptr->d_attr), r_ptr->d_char);
1784 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1785 nam, lev, rar, spd, hp, ac, exp);
1792 /* Free the "who" array */
1793 C_KILL(who, max_r_idx, s16b);
1795 /* Check for errors */
1796 if (ferror(fff) || my_fclose(fff))
1798 msg_print("Cannot close spoiler file.");
1803 msg_print("Successfully created a spoiler file.");
1810 * Monster spoilers by: smchorse@ringer.cs.utsa.edu (Shawn McHorse)
1812 * Primarily based on code already in mon-desc.c, mostly by -BEN-
1818 * Buffer text to the given file. (-SHAWN-)
1819 * This is basically c_roff() from mon-desc.c with a few changes.
1821 static void spoil_out(cptr str)
1826 static char roff_buf[256];
1831 /* Current pointer into line roff_buf */
1832 static char *roff_p = roff_buf;
1834 /* Last space saved into roff_buf */
1835 static char *roff_s = NULL;
1837 /* Special handling for "new sequence" */
1840 if (roff_p != roff_buf) roff_p--;
1841 while (*roff_p == ' ' && roff_p != roff_buf) roff_p--;
1842 if (roff_p == roff_buf) fprintf(fff, "\n");
1845 *(roff_p + 1) = '\0';
1846 fprintf(fff, "%s\n\n", roff_buf);
1854 /* Scan the given string, character at a time */
1859 int k_flag = iskanji((unsigned char)(*str));
1862 int wrap = (ch == '\n');
1865 if (!isprint(ch) && !k_flag && !iskanji2) ch = ' ';
1866 if(k_flag && !iskanji2)iskanji2=1;else iskanji2=0;
1868 if (!isprint(ch)) ch = ' ';
1872 if ( roff_p >= roff_buf+( (k_flag) ? 74 : 75) ) wrap=1;
1873 if ((ch == ' ') && (roff_p + 2 >= roff_buf + ((k_flag) ? 74 : 75))) wrap = 1;
1875 if (roff_p >= roff_buf + 75) wrap = 1;
1876 if ((ch == ' ') && (roff_p + 2 >= roff_buf + 75)) wrap = 1;
1880 /* Handle line-wrap */
1888 if (roff_s && (ch != ' '))
1896 fprintf(fff, "%s\n", roff_buf);
1900 if(cbak != ' ') *roff_p++ = cbak;
1902 while (*r) *roff_p++ = *r++;
1906 if ((roff_p > roff_buf) || (ch != ' '))
1910 if (ch == ' ' || ch == '(' ) roff_s = roff_p;
1914 strncmp(str, "¡£", 2) != 0 &&
1915 strncmp(str, "¡¢", 2) != 0 &&
1916 strncmp(str, "¥£", 2) != 0 &&
1917 strncmp(str, "¡¼", 2) != 0) roff_s = roff_p;
1920 if (ch == ' ') roff_s = roff_p;
1931 * Hook function used in spoil_mon_info()
1933 static void roff_func(byte attr, cptr str)
1943 * Create a spoiler file for monsters (-SHAWN-)
1945 static void spoil_mon_info(cptr fname)
1948 int msex, i, l, n=0;
1950 u32b flags1, flags2, flags3, flags4, flags5, flags6, flags7;
1955 /* Build the filename */
1956 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1958 /* File type is "TEXT" */
1959 FILE_TYPE(FILE_TYPE_TEXT);
1962 fff = my_fopen(buf, "w");
1967 msg_print("Cannot create spoiler file.");
1972 /* Dump the header */
1973 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1974 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1977 spoil_out("------------------------------------------\n\n");
1979 /* Allocate the "who" array */
1980 C_MAKE(who, max_r_idx, s16b);
1982 /* Scan the monsters */
1983 for (i = 1; i < max_r_idx; i++)
1985 monster_race *r_ptr = &r_info[i];
1987 /* Use that monster */
1988 if (r_ptr->name) who[n++] = i;
1991 /* Select the sort method */
1992 ang_sort_comp = ang_sort_comp_hook;
1993 ang_sort_swap = ang_sort_swap_hook;
1995 /* Sort the array by dungeon depth of monsters */
1996 ang_sort(who, &why, n);
2000 * List all monsters in order
2002 for (l = 0; l < n; l++)
2004 monster_race *r_ptr = &r_info[who[l]];
2006 /* Extract the flags */
2007 flags1 = r_ptr->flags1;
2008 flags2 = r_ptr->flags2;
2009 flags3 = r_ptr->flags3;
2010 flags4 = r_ptr->flags4;
2011 flags5 = r_ptr->flags5;
2012 flags6 = r_ptr->flags6;
2013 flags7 = r_ptr->flags7;
2017 /* Extract a gender (if applicable) */
2018 if (flags1 & (RF1_FEMALE)) msex = 2;
2019 else if (flags1 & (RF1_MALE)) msex = 1;
2024 if (flags1 & (RF1_QUESTOR))
2028 else if (flags1 & (RF1_UNIQUE))
2041 sprintf(buf, "%s/%s (", (r_name + r_ptr->name),(r_name+r_ptr->E_name)); /* ---)--- */
2043 sprintf(buf, "%s (", (r_name + r_ptr->name)); /* ---)--- */
2049 spoil_out(attr_to_text(r_ptr->d_attr));
2052 sprintf(buf, " '%c')\n", r_ptr->d_char);
2057 sprintf(buf, "=== ");
2061 sprintf(buf, "Num:%d ", who[l]);
2065 sprintf(buf, "Lev:%d ", r_ptr->level);
2069 sprintf(buf, "Rar:%d ", r_ptr->rarity);
2073 if (r_ptr->speed >= 110)
2075 sprintf(buf, "Spd:+%d ", (r_ptr->speed - 110));
2079 sprintf(buf, "Spd:-%d ", (110 - r_ptr->speed));
2084 if ((flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
2086 sprintf(buf, "Hp:%d ", r_ptr->hdice * r_ptr->hside);
2090 sprintf(buf, "Hp:%dd%d ", r_ptr->hdice, r_ptr->hside);
2095 sprintf(buf, "Ac:%d ", r_ptr->ac);
2099 sprintf(buf, "Exp:%ld\n", (long)(r_ptr->mexp));
2102 /* Reuse the code of monster recall. */
2103 output_monster_spoiler(who[l], roff_func);
2108 /* Free the "who" array */
2109 C_KILL(who, max_r_idx, s16b);
2111 /* Check for errors */
2112 if (ferror(fff) || my_fclose(fff))
2114 msg_print("Cannot close spoiler file.");
2118 msg_print("Successfully created a spoiler file.");
2126 extern void do_cmd_spoilers(void);
2129 * Create Spoiler files -BEN-
2131 void do_cmd_spoilers(void)
2136 /* Save the screen */
2147 prt("Create a spoiler file.", 2, 0);
2149 /* Prompt for a file */
2150 prt("(1) Brief Object Info (obj-desc.spo)", 5, 5);
2151 prt("(2) Brief Artifact Info (artifact.spo)", 6, 5);
2152 prt("(3) Brief Monster Info (mon-desc.spo)", 7, 5);
2153 prt("(4) Full Monster Info (mon-info.spo)", 8, 5);
2157 prt("¥³¥Þ¥ó¥É:", 18, 0);
2159 prt("Command: ", 12, 0);
2175 spoil_obj_desc("obj-desc.spo");
2181 spoil_artifact("artifact.spo");
2187 spoil_mon_desc("mon-desc.spo");
2193 spoil_mon_info("mon-info.spo");
2202 /* Flush messages */
2207 /* Restore the screen */
2212 * Fill in an object description structure for a given object
2214 static void random_artifact_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
2216 analyze_general(o_ptr, desc_ptr->description);
2217 analyze_pval(o_ptr, &desc_ptr->pval_info);
2218 analyze_brand(o_ptr, desc_ptr->brands);
2219 analyze_slay(o_ptr, desc_ptr->slays);
2220 analyze_immune(o_ptr, desc_ptr->immunities);
2221 analyze_resist(o_ptr, desc_ptr->resistances);
2222 analyze_sustains(o_ptr, desc_ptr->sustains);
2223 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
2224 desc_ptr->activation = item_activation(o_ptr);
2226 sprintf(desc_ptr->misc_desc, "½Å¤µ %d.%d kg",
2227 lbtokg1(o_ptr->weight), lbtokg2(o_ptr->weight));
2229 sprintf(desc_ptr->misc_desc, "Weight %d.%d lbs",
2230 o_ptr->weight / 10, o_ptr->weight % 10);
2234 /* Create a spoiler file entry for an artifact */
2236 static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
2238 pval_info_type *pval_ptr = &art_ptr->pval_info;
2242 /* Don't indent the first line */
2243 fprintf(fff, "%s\n", art_ptr->description);
2246 if (!(o_ptr->ident & (IDENT_MENTAL)))
2249 fprintf(fff, "%sÉÔÌÀ\n",INDENT1);
2251 fprintf(fff, "%sUnknown\n",INDENT1);
2255 /* An "empty" pval description indicates that the pval affects nothing */
2256 if (pval_ptr->pval_desc[0])
2258 /* Mention the effects of pval */
2260 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
2262 sprintf(buf, "%s to", pval_ptr->pval_desc);
2264 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
2267 /* Now deal with the description lists */
2270 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
2271 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
2272 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
2273 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
2274 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
2276 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
2277 spoiler_outlist("", art_ptr->brands, LIST_SEP);
2278 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
2279 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
2280 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
2282 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
2284 /* Write out the possible activation at the primary indention level */
2285 if (art_ptr->activation)
2288 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
2290 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
2294 /* End with the miscellaneous facts */
2295 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
2298 /* Create a part of file for random artifacts */
2300 static void spoil_random_artifact_aux(object_type *o_ptr, int i)
2302 obj_desc_list artifact;
2304 if (!object_known_p(o_ptr) || !o_ptr->art_name
2305 || o_ptr->tval != group_artifact[i].tval)
2308 /* Analyze the artifact */
2309 random_artifact_analyze(o_ptr, &artifact);
2311 /* Write out the artifact description to the spoiler file */
2312 spoiler_print_randart(o_ptr, &artifact);
2316 * Create a list file for random artifacts
2318 void spoil_random_artifact(cptr fname)
2328 /* Build the filename */
2329 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2331 /* File type is "TEXT" */
2332 FILE_TYPE(FILE_TYPE_TEXT);
2335 fff = my_fopen(buf, "w");
2340 msg_print("Cannot create list file.");
2344 /* Dump the header */
2345 sprintf(buf, "Random artifacts list.\r");
2346 spoiler_underline(buf);
2348 /* List the artifacts by tval */
2349 for (j = 0; group_artifact[j].tval; j++)
2351 /* random artifacts wielding */
2352 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2354 q_ptr = &inventory[i];
2355 spoil_random_artifact_aux(q_ptr, j);
2358 /* random artifacts in inventory */
2359 for (i = 0; i < INVEN_PACK; i++)
2361 q_ptr = &inventory[i];
2362 spoil_random_artifact_aux(q_ptr, j);
2365 /* random artifacts in home */
2366 st_ptr = &town[1].store[STORE_HOME];
2367 for (i = 0; i < st_ptr->stock_num; i++)
2369 q_ptr = &st_ptr->stock[i];
2370 spoil_random_artifact_aux(q_ptr, j);
2373 /* random artifacts in museum */
2374 st_ptr = &town[1].store[STORE_MUSEUM];
2375 for (i = 0; i < st_ptr->stock_num; i++)
2377 q_ptr = &st_ptr->stock[i];
2378 spoil_random_artifact_aux(q_ptr, j);
2382 /* Check for errors */
2383 if (ferror(fff) || my_fclose(fff))
2385 msg_print("Cannot close list file.");
2390 msg_print("Successfully created a list file.");
2397 #endif /* MACINTOSH */