3 /* Purpose: Spoiler generation -BEN- */
12 * The spoiler file being created
14 static FILE *fff = NULL;
19 * Extract a textual representation of an attribute
21 static cptr attr_to_text(byte a)
26 case TERM_DARK: return ("XXX¤¤");
27 case TERM_WHITE: return ("Çò¤¤");
28 case TERM_SLATE: return ("Àij¥¿§¤Î");
29 case TERM_ORANGE: return ("¥ª¥ì¥ó¥¸¤Î");
30 case TERM_RED: return ("ÀÖ¤¤");
31 case TERM_GREEN: return ("ÎФÎ");
32 case TERM_BLUE: return ("ÀĤ¤");
33 case TERM_UMBER: return ("àèàῧ¤Î");
34 case TERM_L_DARK: return ("³¥¿§¤Î");
35 case TERM_L_WHITE: return ("ÌÀÀij¥¿§¤Î");
36 case TERM_VIOLET: return ("»ç¤Î");
37 case TERM_YELLOW: return ("²«¿§¤¤");
38 case TERM_L_RED: return ("ÌÀ¤¤ÀÖ¤Î");
39 case TERM_L_GREEN: return ("ÌÀ¤¤ÎФÎ");
40 case TERM_L_BLUE: return ("ÌÀ¤¤ÀĤÎ");
41 case TERM_L_UMBER: return ("ÌÀ¤¤àèàῧ¤Î");
43 case TERM_DARK: return ("xxx");
44 case TERM_WHITE: return ("White");
45 case TERM_SLATE: return ("Slate");
46 case TERM_ORANGE: return ("Orange");
47 case TERM_RED: return ("Red");
48 case TERM_GREEN: return ("Green");
49 case TERM_BLUE: return ("Blue");
50 case TERM_UMBER: return ("Umber");
51 case TERM_L_DARK: return ("L.Dark");
52 case TERM_L_WHITE: return ("L.Slate");
53 case TERM_VIOLET: return ("Violet");
54 case TERM_YELLOW: return ("Yellow");
55 case TERM_L_RED: return ("L.Red");
56 case TERM_L_GREEN: return ("L.Green");
57 case TERM_L_BLUE: return ("L.Blue");
58 case TERM_L_UMBER: return ("L.Umber");
86 * Item Spoilers by: benh@phial.com (Ben Harrison)
91 * The basic items categorized by type
93 static grouper group_item[] =
96 { TV_SHOT, "¼Í·âʪ" },
112 { TV_SWORD, "Éð´ï" },
114 { TV_SWORD, "Weapons" },
117 { TV_POLEARM, NULL },
119 { TV_DIGGING, NULL },
122 { TV_SOFT_ARMOR, "Ëɶñ¡ÊÂΡË" },
124 { TV_SOFT_ARMOR, "Armour (Body)" },
127 { TV_HARD_ARMOR, NULL },
128 { TV_DRAG_ARMOR, NULL },
131 { TV_CLOAK, "Ëɶñ¡Ê¤½¤Î¾¡Ë" },
133 { TV_CLOAK, "Armour (Misc)" },
143 { TV_AMULET, "¥¢¥ß¥å¥ì¥Ã¥È" },
146 { TV_AMULET, "Amulets" },
147 { TV_RING, "Rings" },
152 { TV_SCROLL, "´¬Êª" },
156 { TV_SCROLL, "Scrolls" },
157 { TV_POTION, "Potions" },
163 { TV_ROD, "¥í¥Ã¥É" },
164 { TV_WAND, "ËâË¡ËÀ" },
168 { TV_WAND, "Wands" },
169 { TV_STAFF, "Staffs" },
174 { TV_LIFE_BOOK, "ËâË¡½ñ¡ÊÀ¸Ì¿¡Ë" },
175 { TV_SORCERY_BOOK, "ËâË¡½ñ¡ÊÀç½Ñ¡Ë" },
176 { TV_NATURE_BOOK, "ËâË¡½ñ¡Ê¼«Á³¡Ë" },
177 { TV_CHAOS_BOOK, "ËâË¡½ñ¡Ê¥«¥ª¥¹¡Ë" },
178 { TV_DEATH_BOOK, "ËâË¡½ñ¡Ê°Å¹õ¡Ë" },
179 { TV_TRUMP_BOOK, "ËâË¡½ñ¡Ê¥È¥é¥ó¥×¡Ë" },
180 { TV_ARCANE_BOOK, "ËâË¡½ñ¡ÊÈë½Ñ¡Ë" },
181 { TV_ENCHANT_BOOK, "ËâË¡½ñ¡Ê¾¢¡Ë" },
182 { TV_DAEMON_BOOK, "ËâË¡½ñ¡Ê°Ëâ¡Ë" },
183 { TV_CRUSADE_BOOK, "ËâË¡½ñ¡ÊÇ˼١Ë" },
184 { TV_MUSIC_BOOK, "²Î½¸" },
185 { TV_HISSATSU_BOOK, "Éð·Ý¤Î½ñ" },
187 { TV_LIFE_BOOK, "Books (Life)" },
188 { TV_SORCERY_BOOK, "Books (Sorcery)" },
189 { TV_NATURE_BOOK, "Books (Nature)" },
190 { TV_CHAOS_BOOK, "Books (Chaos)" },
191 { TV_DEATH_BOOK, "Books (Death)" },
192 { TV_TRUMP_BOOK, "Books (Trump)" },
193 { TV_ARCANE_BOOK, "Books (Arcane)" },
194 { TV_ENCHANT_BOOK, "Books (Craft)" },
195 { TV_DAEMON_BOOK, "Books (Daemon)" },
196 { TV_CRUSADE_BOOK, "Books (Crusade)" },
197 { TV_MUSIC_BOOK, "Song Books" },
198 { TV_HISSATSU_BOOK, "Books (Kendo)" },
202 { TV_PARCHEMENT, "ÍÓÈé»æ" },
204 { TV_PARCHEMENT, "Parchement" },
210 { TV_CHEST, "Chests" },
214 { TV_CAPTURE, "¥¥ã¥×¥Á¥ã¡¼¡¦¥Ü¡¼¥ë" },
216 { TV_CAPTURE, "Capture Ball" },
220 { TV_CARD, "¥¨¥¯¥¹¥×¥ì¥¹¥«¡¼¥É" },
222 { TV_CARD, "Express Card" },
225 { TV_FIGURINE, "Magical Figurines" },
226 { TV_STATUE, "Statues" },
227 { TV_CORPSE, "Corpses" },
232 { TV_WHISTLE, "Whistle" },
236 { TV_SPIKE, "¤¯¤µ¤Ó" },
238 { TV_SPIKE, "Spike" },
245 { TV_SKELETON, NULL },
254 static void kind_info(char *buf, char *dam, char *wgt, int *lev, s32b *val, int k)
260 /* Get local object */
263 /* Prepare a fake item */
264 object_prep(q_ptr, k);
267 q_ptr->ident |= (IDENT_KNOWN);
277 (*lev) = get_object_level(q_ptr);
280 (*val) = object_value(q_ptr);
284 if (!buf || !dam || !wgt) return;
287 /* Description (too brief) */
288 object_desc_store(buf, q_ptr, FALSE, 0);
308 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
318 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
333 sprintf(dam, "%d", q_ptr->ac);
340 sprintf(wgt, "%3d.%d", q_ptr->weight / 10, q_ptr->weight % 10);
345 * Create a spoiler file for items
347 static void spoil_obj_desc(cptr fname)
349 int i, k, s, t, n = 0;
359 /* Build the filename */
360 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
362 /* File type is "TEXT" */
363 FILE_TYPE(FILE_TYPE_TEXT);
366 fff = my_fopen(buf, "w");
371 msg_print("Cannot create spoiler file.");
377 fprintf(fff, "Spoiler File -- Basic Items (Hengband %d.%d.%d)\n\n\n",
378 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
381 fprintf(fff, "%-45s %8s%7s%5s%9s\n",
382 "Description", "Dam/AC", "Wgt", "Lev", "Cost");
383 fprintf(fff, "%-45s %8s%7s%5s%9s\n",
384 "----------------------------------------",
385 "------", "---", "---", "----");
387 /* List the groups */
388 for (i = 0; TRUE; i++)
390 /* Write out the group title */
391 if (group_item[i].name)
393 /* Hack -- bubble-sort by cost and then level */
394 for (s = 0; s < n - 1; s++)
396 for (t = 0; t < n - 1; t++)
407 kind_info(NULL, NULL, NULL, &e1, &t1, who[i1]);
408 kind_info(NULL, NULL, NULL, &e2, &t2, who[i2]);
410 if ((t1 > t2) || ((t1 == t2) && (e1 > e2)))
419 /* Spoil each item */
420 for (s = 0; s < n; s++)
425 /* Describe the kind */
426 kind_info(buf, dam, wgt, &e, &v, who[s]);
429 fprintf(fff, " %-45s%8s%7s%5d%9ld\n",
430 buf, dam, wgt, e, (long)(v));
433 /* Start a new set */
437 if (!group_item[i].tval) break;
439 /* Start a new set */
440 fprintf(fff, "\n\n%s\n\n", group_item[i].name);
443 /* Acquire legal item types */
444 for (k = 1; k < max_k_idx; k++)
446 object_kind *k_ptr = &k_info[k];
448 /* Skip wrong tval's */
449 if (k_ptr->tval != group_item[i].tval) continue;
451 /* Hack -- Skip instant-artifacts */
452 if (k_ptr->gen_flags & (TRG_INSTA_ART)) continue;
460 /* Check for errors */
461 if (ferror(fff) || my_fclose(fff))
463 msg_print("Cannot close spoiler file.");
468 msg_print("Successfully created a spoiler file.");
473 * Artifact Spoilers by: randy@PICARD.tamu.edu (Randy Hutson)
478 * Returns a "+" string if a number is non-negative and an empty
481 #define POSITIZE(v) (((v) >= 0) ? "+" : "")
484 * These are used to format the artifact spoiler file. INDENT1 is used
485 * to indent all but the first line of an artifact spoiler. INDENT2 is
486 * used when a line "wraps". (Bladeturner's resistances cause this.)
492 * MAX_LINE_LEN specifies when a line should wrap.
494 #define MAX_LINE_LEN 75
497 * Given an array, determine how many elements are in the array
499 #define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))
502 * The artifacts categorized by type
504 static grouper group_artifact[] =
507 { TV_SWORD, "Åá·õ" },
508 { TV_POLEARM, "Áä/Éà" },
509 { TV_HAFTED, "Æß´ï" },
510 { TV_DIGGING, "¥·¥ã¥Ù¥ë/¤Ä¤ë¤Ï¤·" },
511 { TV_BOW, "Èô¤ÓÆ»¶ñ" },
514 { TV_SOFT_ARMOR, "³»" },
515 { TV_HARD_ARMOR, NULL },
516 { TV_DRAG_ARMOR, NULL },
518 { TV_CLOAK, "¥¯¥í¡¼¥¯" },
521 { TV_HELM, "³õ/´§" },
523 { TV_GLOVES, "äƼê" },
527 { TV_AMULET, "¥¢¥ß¥å¥ì¥Ã¥È" },
530 { TV_SWORD, "Edged Weapons" },
531 { TV_POLEARM, "Polearms" },
532 { TV_HAFTED, "Hafted Weapons" },
533 { TV_DIGGING, "Shovels/Picks" },
535 { TV_ARROW, "Ammo" },
537 { TV_SOFT_ARMOR, "Body Armor" },
538 { TV_HARD_ARMOR, NULL },
539 { TV_DRAG_ARMOR, NULL },
541 { TV_CLOAK, "Cloaks" },
542 { TV_SHIELD, "Shields" },
544 { TV_HELM, "Helms/Crowns" },
546 { TV_GLOVES, "Gloves" },
547 { TV_BOOTS, "Boots" },
549 { TV_LITE, "Light Sources" },
550 { TV_AMULET, "Amulets" },
551 { TV_RING, "Rings" },
560 * Pair together a constant flag with a textual description.
562 * Used by both "init.c" and "wiz-spo.c".
564 * Note that it sometimes more efficient to actually make an array
565 * of textual names, where entry 'N' is assumed to be paired with
566 * the flag whose value is "1L << N", but that requires hard-coding.
569 typedef struct flag_desc flag_desc;
574 const char *const desc;
580 * These are used for "+3 to STR, DEX", etc. These are separate from
581 * the other pval affected traits to simplify the case where an object
582 * affects all stats. In this case, "All stats" is used instead of
583 * listing each stat individually.
586 static flag_desc stat_flags_desc[] =
592 { TR1_DEX, "´ïÍѤµ" },
593 { TR1_CON, "Âѵ×ÎÏ" },
606 * Besides stats, these are the other player traits
607 * which may be affected by an object's pval
610 static flag_desc pval_flags1_desc[] =
613 { TR1_MAGIC_MASTERY, "ËâË¡Æ»¶ñ»ÈÍÑǽÎÏ" },
614 { TR1_STEALTH, "±£Ì©" },
615 { TR1_SEARCH, "õº÷" },
616 { TR1_INFRA, "ÀÖ³°Àþ»ëÎÏ" },
617 { TR1_TUNNEL, "ºÎ·¡" },
618 { TR1_BLOWS, "¹¶·â²ó¿ô" },
619 { TR1_SPEED, "¥¹¥Ô¡¼¥É" }
621 { TR1_STEALTH, "Stealth" },
622 { TR1_SEARCH, "Searching" },
623 { TR1_INFRA, "Infravision" },
624 { TR1_TUNNEL, "Tunneling" },
625 { TR1_BLOWS, "Attacks" },
626 { TR1_SPEED, "Speed" }
631 * Slaying preferences for weapons
634 static flag_desc slay_flags_desc[] =
637 { TR1_SLAY_ANIMAL, "ưʪ" },
638 { TR1_SLAY_EVIL, "¼Ù°" },
639 { TR3_SLAY_HUMAN, "¿Í´Ö" },
640 { TR1_SLAY_UNDEAD, "¥¢¥ó¥Ç¥Ã¥É" },
641 { TR1_SLAY_DEMON, "°Ëâ" },
642 { TR1_SLAY_ORC, "¥ª¡¼¥¯" },
643 { TR1_SLAY_TROLL, "¥È¥í¥ë" },
644 { TR1_SLAY_GIANT, "µð¿Í" },
645 { TR1_SLAY_DRAGON, "¥É¥é¥´¥ó" },
646 { TR1_KILL_DRAGON, "*¥É¥é¥´¥ó*" },
648 { TR1_SLAY_ANIMAL, "Animal" },
649 { TR1_SLAY_EVIL, "Evil" },
650 { TR3_SLAY_HUMAN, "Human" },
651 { TR1_SLAY_UNDEAD, "Undead" },
652 { TR1_SLAY_DEMON, "Demon" },
653 { TR1_SLAY_ORC, "Orc" },
654 { TR1_SLAY_TROLL, "Troll" },
655 { TR1_SLAY_GIANT, "Giant" },
656 { TR1_SLAY_DRAGON, "Dragon" },
657 { TR1_KILL_DRAGON, "Xdragon" }
662 * Elemental brands for weapons
664 * Clearly, TR1_IMPACT is a bit out of place here. To simplify
665 * coding, it has been included here along with the elemental
666 * brands. It does seem to fit in with the brands and slaying
667 * more than the miscellaneous section.
669 static flag_desc brand_flags_desc[] =
672 { TR1_BRAND_ACID, "Íϲò" },
673 { TR1_BRAND_ELEC, "ÅÅ·â" },
674 { TR1_BRAND_FIRE, "¾Æ´þ" },
675 { TR1_BRAND_COLD, "Åà·ë" },
676 { TR1_BRAND_POIS, "ÆÇ»¦" },
678 { TR1_FORCE_WEAPON, "ÍýÎÏ" },
679 { TR1_CHAOTIC, "º®ÆÙ" },
680 { TR1_VAMPIRIC, "µÛ·ì" },
681 { TR1_IMPACT, "ÃÏ¿Ì" },
682 { TR1_VORPAL, "ÀÚ¤ìÌ£" },
684 { TR1_BRAND_ACID, "Acid Brand" },
685 { TR1_BRAND_ELEC, "Lightning Brand" },
686 { TR1_BRAND_FIRE, "Flame Tongue" },
687 { TR1_BRAND_COLD, "Frost Brand" },
688 { TR1_BRAND_POIS, "Poisoned" },
690 { TR1_FORCE_WEAPON, "Force" },
691 { TR1_CHAOTIC, "Mark of Chaos" },
692 { TR1_VAMPIRIC, "Vampiric" },
693 { TR1_IMPACT, "Earthquake impact on hit" },
694 { TR1_VORPAL, "Very sharp" },
702 static const flag_desc resist_flags_desc[] =
705 { TR2_RES_ACID, "»À" },
706 { TR2_RES_ELEC, "ÅÅ·â" },
707 { TR2_RES_FIRE, "²Ð±ê" },
708 { TR2_RES_COLD, "Î䵤" },
709 { TR2_RES_POIS, "ÆÇ" },
710 { TR2_RES_FEAR, "¶²ÉÝ"},
711 { TR2_RES_LITE, "Á®¸÷" },
712 { TR2_RES_DARK, "°Å¹õ" },
713 { TR2_RES_BLIND, "ÌÕÌÜ" },
714 { TR2_RES_CONF, "º®Íð" },
715 { TR2_RES_SOUND, "¹ì²»" },
716 { TR2_RES_SHARDS, "ÇËÊÒ" },
717 { TR2_RES_NETHER, "ÃϹö" },
718 { TR2_RES_NEXUS, "°ø²Ìº®Íð" },
719 { TR2_RES_CHAOS, "¥«¥ª¥¹" },
720 { TR2_RES_DISEN, "Îô²½" },
722 { TR2_RES_ACID, "Acid" },
723 { TR2_RES_ELEC, "Lightning" },
724 { TR2_RES_FIRE, "Fire" },
725 { TR2_RES_COLD, "Cold" },
726 { TR2_RES_POIS, "Poison" },
727 { TR2_RES_FEAR, "Fear"},
728 { TR2_RES_LITE, "Light" },
729 { TR2_RES_DARK, "Dark" },
730 { TR2_RES_BLIND, "Blindness" },
731 { TR2_RES_CONF, "Confusion" },
732 { TR2_RES_SOUND, "Sound" },
733 { TR2_RES_SHARDS, "Shards" },
734 { TR2_RES_NETHER, "Nether" },
735 { TR2_RES_NEXUS, "Nexus" },
736 { TR2_RES_CHAOS, "Chaos" },
737 { TR2_RES_DISEN, "Disenchantment" },
742 * Elemental immunities (along with poison)
745 static const flag_desc immune_flags_desc[] =
748 { TR2_IM_ACID, "»À" },
749 { TR2_IM_ELEC, "ÅÅ·â" },
750 { TR2_IM_FIRE, "²Ð±ê" },
751 { TR2_IM_COLD, "Î䵤" },
753 { TR2_IM_ACID, "Acid" },
754 { TR2_IM_ELEC, "Lightning" },
755 { TR2_IM_FIRE, "Fire" },
756 { TR2_IM_COLD, "Cold" },
761 * Sustain stats - these are given their "own" line in the
762 * spoiler file, mainly for simplicity
764 static const flag_desc sustain_flags_desc[] =
767 { TR2_SUST_STR, "ÏÓÎÏ" },
768 { TR2_SUST_INT, "ÃÎǽ" },
769 { TR2_SUST_WIS, "¸¤µ" },
770 { TR2_SUST_DEX, "´ïÍѤµ" },
771 { TR2_SUST_CON, "Âѵ×ÎÏ" },
772 { TR2_SUST_CHR, "Ì¥ÎÏ" },
774 { TR2_SUST_STR, "STR" },
775 { TR2_SUST_INT, "INT" },
776 { TR2_SUST_WIS, "WIS" },
777 { TR2_SUST_DEX, "DEX" },
778 { TR2_SUST_CON, "CON" },
779 { TR2_SUST_CHR, "CHR" },
784 * Miscellaneous magic given by an object's "flags2" field
787 static const flag_desc misc_flags2_desc[] =
790 { TR2_THROW, "ÅêÚ³" },
791 { TR2_REFLECT, "È¿¼Í" },
792 { TR2_FREE_ACT, "ËãáãÃΤ餺" },
793 { TR2_HOLD_LIFE, "À¸Ì¿ÎÏ°Ý»ý" },
795 { TR2_THROW, "Throwing" },
796 { TR2_REFLECT, "Reflection" },
797 { TR2_FREE_ACT, "Free Action" },
798 { TR2_HOLD_LIFE, "Hold Life" },
803 * Miscellaneous magic given by an object's "flags3" field
805 * Note that cursed artifacts and objects with permanent light
806 * are handled "directly" -- see analyze_misc_magic()
809 static const flag_desc misc_flags3_desc[] =
812 { TR3_SH_FIRE, "²Ð±ê¥ª¡¼¥é" },
813 { TR3_SH_ELEC, "Åŷ⥪¡¼¥é" },
814 { TR3_SH_COLD, "Î䵤¥ª¡¼¥é" },
815 { TR3_NO_TELE, "È¿¥Æ¥ì¥Ý¡¼¥È" },
816 { TR3_NO_MAGIC, "È¿ËâË¡" },
817 { TR3_FEATHER, "ÉâÍ·" },
818 { TR3_SEE_INVIS, "²Ä»ëÆ©ÌÀ" },
819 { TR3_TELEPATHY, "¥Æ¥ì¥Ñ¥·¡¼" },
820 { TR3_SLOW_DIGEST, "Ãپò½" },
821 { TR3_REGEN, "µÞ®²óÉü" },
822 { TR3_WARNING, "·Ù¹ð" },
823 /* { TR3_XTRA_MIGHT, "¶¯Îϼͷâ" }, */
824 { TR3_XTRA_SHOTS, "Äɲüͷâ" }, /* always +1? */
825 { TR3_DRAIN_EXP, "·Ð¸³Ã͵ۼý" },
826 { TR3_AGGRAVATE, "È¿´¶" },
827 { TR3_BLESSED, "½ËÊ¡" },
828 { TR3_DEC_MANA, "¾ÃÈñËâÎϸº¾¯" },
830 { TR3_SH_FIRE, "Fiery Aura" },
831 { TR3_SH_ELEC, "Electric Aura" },
832 { TR3_SH_COLD, "Coldly Aura" },
833 { TR3_NO_TELE, "Prevent Teleportation" },
834 { TR3_NO_MAGIC, "Anti-Magic" },
835 { TR3_FEATHER, "Levitation" },
836 { TR3_SEE_INVIS, "See Invisible" },
837 { TR3_TELEPATHY, "ESP" },
838 { TR3_SLOW_DIGEST, "Slow Digestion" },
839 { TR3_REGEN, "Regeneration" },
840 { TR3_WARNING, "Warning" },
841 /* { TR3_XTRA_MIGHT, "Extra Might" }, */
842 { TR3_XTRA_SHOTS, "+1 Extra Shot" }, /* always +1? */
843 { TR3_DRAIN_EXP, "Drains Experience" },
844 { TR3_AGGRAVATE, "Aggravates" },
845 { TR3_BLESSED, "Blessed Blade" },
846 { TR3_DEC_MANA, "Decrease Shouhi Mana" },
852 * A special type used just for deailing with pvals
857 * This will contain a string such as "+2", "-10", etc.
862 * A list of various player traits affected by an object's pval such
863 * as stats, speed, stealth, etc. "Extra attacks" is NOT included in
864 * this list since it will probably be desirable to format its
865 * description differently.
867 * Note that room need only be reserved for the number of stats - 1
868 * since the description "All stats" is used if an object affects all
869 * all stats. Also, room must be reserved for a sentinel NULL pointer.
871 * This will be a list such as ["STR", "DEX", "Stealth", NULL] etc.
873 * This list includes extra attacks, for simplicity.
875 cptr pval_affects[N_ELEMENTS(stat_flags_desc) - 1 +
876 N_ELEMENTS(pval_flags1_desc) + 1];
882 * An "object analysis structure"
884 * It will be filled with descriptive strings detailing an object's
885 * various magical powers. The "ignore X" traits are not noted since
886 * all artifacts ignore "normal" destruction.
891 /* "The Longsword Dragonsmiter (6d4) (+20, +25)" */
892 char description[MAX_NLEN];
894 /* Description of what is affected by an object's pval */
895 pval_info_type pval_info;
897 /* A list of an object's slaying preferences */
898 cptr slays[N_ELEMENTS(slay_flags_desc) + 1];
900 /* A list if an object's elemental brands */
901 cptr brands[N_ELEMENTS(brand_flags_desc) + 1];
903 /* A list of immunities granted by an object */
904 cptr immunities[N_ELEMENTS(immune_flags_desc) + 1];
906 /* A list of resistances granted by an object */
907 cptr resistances[N_ELEMENTS(resist_flags_desc) + 1];
909 /* A list of stats sustained by an object */
910 cptr sustains[N_ELEMENTS(sustain_flags_desc) - 1 + 1];
912 /* A list of various magical qualities an object may have */
913 cptr misc_magic[N_ELEMENTS(misc_flags2_desc) + N_ELEMENTS(misc_flags3_desc)
914 + 1 /* Permanent Light */
916 + 1 /* type of curse */
917 + 1]; /* sentinel NULL */
919 /* A string describing an artifact's activation */
922 /* "Level 20, Rarity 30, 3.0 lbs, 20000 Gold" */
928 * Write out `n' of the character `c' to the spoiler file
930 static void spoiler_out_n_chars(int n, char c)
932 while (--n >= 0) fputc(c, fff);
937 * Write out `n' blank lines to the spoiler file
939 static void spoiler_blanklines(int n)
941 spoiler_out_n_chars(n, '\n');
946 * Write a line to the spoiler file and then "underline" it with hypens
948 static void spoiler_underline(cptr str)
950 fprintf(fff, "%s\n", str);
951 spoiler_out_n_chars(strlen(str), '-');
958 * This function does most of the actual "analysis". Given a set of bit flags
959 * (which will be from one of the flags fields from the object in question),
960 * a "flag description structure", a "description list", and the number of
961 * elements in the "flag description structure", this function sets the
962 * "description list" members to the appropriate descriptions contained in
963 * the "flag description structure".
965 * The possibly updated description pointer is returned.
967 static cptr *spoiler_flag_aux(const u32b art_flags, const flag_desc *flag_ptr,
968 cptr *desc_ptr, const int n_elmnts)
972 for (i = 0; i < n_elmnts; ++i)
974 if (art_flags & flag_ptr[i].flag)
976 *desc_ptr++ = flag_ptr[i].desc;
985 * Acquire a "basic" description "The Cloak of Death [1,+10]"
987 static void analyze_general (object_type *o_ptr, char *desc_ptr)
989 /* Get a "useful" description of the object */
990 object_desc_store(desc_ptr, o_ptr, TRUE, 1);
995 * List "player traits" altered by an artifact's pval. These include stats,
996 * speed, infravision, tunneling, stealth, searching, and extra attacks.
998 static void analyze_pval (object_type *o_ptr, pval_info_type *p_ptr)
1000 const u32b all_stats = (TR1_STR | TR1_INT | TR1_WIS |
1001 TR1_DEX | TR1_CON | TR1_CHR);
1007 /* If pval == 0, there is nothing to do. */
1010 /* An "empty" pval description indicates that pval == 0 */
1011 p_ptr->pval_desc[0] = '\0';
1015 /* Extract the flags */
1016 object_flags(o_ptr, &f1, &f2, &f3);
1018 affects_list = p_ptr->pval_affects;
1020 /* Create the "+N" string */
1021 sprintf(p_ptr->pval_desc, "%s%d", POSITIZE(o_ptr->pval), o_ptr->pval);
1023 /* First, check to see if the pval affects all stats */
1024 if ((f1 & all_stats) == all_stats)
1027 *affects_list++ = "Á´Ç½ÎÏ";
1029 *affects_list++ = "All stats";
1033 /* Are any stats affected? */
1034 else if (f1 & all_stats)
1036 affects_list = spoiler_flag_aux(f1, stat_flags_desc,
1038 N_ELEMENTS(stat_flags_desc));
1041 /* And now the "rest" */
1042 affects_list = spoiler_flag_aux(f1, pval_flags1_desc,
1044 N_ELEMENTS(pval_flags1_desc));
1046 /* Terminate the description list */
1047 *affects_list = NULL;
1051 /* Note the slaying specialties of a weapon */
1052 static void analyze_slay (object_type *o_ptr, cptr *slay_list)
1056 object_flags(o_ptr, &f1, &f2, &f3);
1058 slay_list = spoiler_flag_aux(f1, slay_flags_desc, slay_list,
1059 N_ELEMENTS(slay_flags_desc));
1061 /* Terminate the description list */
1065 /* Note an object's elemental brands */
1066 static void analyze_brand (object_type *o_ptr, cptr *brand_list)
1070 object_flags(o_ptr, &f1, &f2, &f3);
1072 brand_list = spoiler_flag_aux(f1, brand_flags_desc, brand_list,
1073 N_ELEMENTS(brand_flags_desc));
1075 /* Terminate the description list */
1080 /* Note the resistances granted by an object */
1081 static void analyze_resist (object_type *o_ptr, cptr *resist_list)
1085 object_flags(o_ptr, &f1, &f2, &f3);
1087 resist_list = spoiler_flag_aux(f2, resist_flags_desc,
1088 resist_list, N_ELEMENTS(resist_flags_desc));
1090 /* Terminate the description list */
1091 *resist_list = NULL;
1095 /* Note the immunities granted by an object */
1096 static void analyze_immune (object_type *o_ptr, cptr *immune_list)
1100 object_flags(o_ptr, &f1, &f2, &f3);
1102 immune_list = spoiler_flag_aux(f2, immune_flags_desc,
1103 immune_list, N_ELEMENTS(immune_flags_desc));
1105 /* Terminate the description list */
1106 *immune_list = NULL;
1109 /* Note which stats an object sustains */
1111 static void analyze_sustains (object_type *o_ptr, cptr *sustain_list)
1113 const u32b all_sustains = (TR2_SUST_STR | TR2_SUST_INT | TR2_SUST_WIS |
1114 TR2_SUST_DEX | TR2_SUST_CON | TR2_SUST_CHR);
1118 object_flags(o_ptr, &f1, &f2, &f3);
1120 /* Simplify things if an item sustains all stats */
1121 if ((f2 & all_sustains) == all_sustains)
1124 *sustain_list++ = "Á´Ç½ÎÏ";
1126 *sustain_list++ = "All stats";
1130 /* Should we bother? */
1131 else if ((f2 & all_sustains))
1133 sustain_list = spoiler_flag_aux(f2, sustain_flags_desc,
1135 N_ELEMENTS(sustain_flags_desc));
1138 /* Terminate the description list */
1139 *sustain_list = NULL;
1144 * Note miscellaneous powers bestowed by an artifact such as see invisible,
1145 * free action, permanent light, etc.
1147 static void analyze_misc_magic (object_type *o_ptr, cptr *misc_list)
1151 object_flags(o_ptr, &f1, &f2, &f3);
1153 misc_list = spoiler_flag_aux(f2, misc_flags2_desc, misc_list,
1154 N_ELEMENTS(misc_flags2_desc));
1156 misc_list = spoiler_flag_aux(f3, misc_flags3_desc, misc_list,
1157 N_ELEMENTS(misc_flags3_desc));
1160 * Artifact lights -- large radius light.
1162 if ((o_ptr->tval == TV_LITE) && artifact_p(o_ptr))
1165 *misc_list++ = "±Êµ×¸÷¸»(Ⱦ·Â3)";
1167 *misc_list++ = "Permanent Light(3)";
1172 * Glowing artifacts -- small radius light.
1174 if (f3 & (TR3_LITE))
1177 *misc_list++ = "±Êµ×¸÷¸»(Ⱦ·Â1)";
1179 *misc_list++ = "Permanent Light(1)";
1184 * Handle cursed objects here to avoid redundancies such as noting
1185 * that a permanently cursed object is heavily cursed as well as
1186 * being "lightly cursed".
1189 /* if (cursed_p(o_ptr)) */
1192 if (f3 & TR3_TY_CURSE)
1195 *misc_list++ = "ÂÀ¸Å¤Î±åÇ°";
1197 *misc_list++ = "Ancient Curse";
1200 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1203 *misc_list++ = "±Ê±ó¤Î¼ö¤¤";
1205 *misc_list++ = "Permanently Cursed";
1208 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1211 *misc_list++ = "¶¯ÎϤʼö¤¤";
1213 *misc_list++ = "Heavily Cursed";
1217 else if (o_ptr->curse_flags & TRC_CURSED)
1220 *misc_list++ = "¼ö¤¤";
1222 *misc_list++ = "Cursed";
1227 /* Terminate the description list */
1235 * Determine the minimum depth an artifact can appear, its rarity, its weight,
1236 * and its value in gold pieces
1238 static void analyze_misc (object_type *o_ptr, char *misc_desc)
1240 artifact_type *a_ptr = &a_info[o_ptr->name1];
1243 sprintf(misc_desc, "¥ì¥Ù¥ë %u, ´õ¾¯ÅÙ %u, %d.%d kg, ¡ð%ld",
1244 a_ptr->level, a_ptr->rarity,
1245 lbtokg1(a_ptr->weight), lbtokg2(a_ptr->weight), a_ptr->cost);
1247 sprintf(misc_desc, "Level %u, Rarity %u, %d.%d lbs, %ld Gold",
1248 a_ptr->level, a_ptr->rarity,
1249 a_ptr->weight / 10, a_ptr->weight % 10, a_ptr->cost);
1255 * Fill in an object description structure for a given object
1257 static void object_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
1259 analyze_general(o_ptr, desc_ptr->description);
1261 analyze_pval(o_ptr, &desc_ptr->pval_info);
1263 analyze_brand(o_ptr, desc_ptr->brands);
1265 analyze_slay(o_ptr, desc_ptr->slays);
1267 analyze_immune(o_ptr, desc_ptr->immunities);
1269 analyze_resist(o_ptr, desc_ptr->resistances);
1271 analyze_sustains(o_ptr, desc_ptr->sustains);
1273 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
1275 analyze_misc(o_ptr, desc_ptr->misc_desc);
1277 desc_ptr->activation = item_activation(o_ptr);
1281 static void print_header(void)
1285 sprintf(buf, "Artifact Spoilers for Hengband Version %d.%d.%d",
1286 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1287 spoiler_underline(buf);
1291 * This is somewhat ugly.
1293 * Given a header ("Resist", e.g.), a list ("Fire", "Cold", Acid", e.g.),
1294 * and a separator character (',', e.g.), write the list to the spoiler file
1295 * in a "nice" format, such as:
1297 * Resist Fire, Cold, Acid
1299 * That was a simple example, but when the list is long, a line wrap
1300 * should occur, and this should induce a new level of indention if
1301 * a list is being spread across lines. So for example, Bladeturner's
1302 * list of resistances should look something like this
1304 * Resist Acid, Lightning, Fire, Cold, Poison, Light, Dark, Blindness,
1305 * Confusion, Sound, Shards, Nether, Nexus, Chaos, Disenchantment
1307 * However, the code distinguishes between a single list of many items vs.
1308 * many lists. (The separator is used to make this determination.) A single
1309 * list of many items will not cause line wrapping (since there is no
1310 * apparent reason to do so). So the lists of Ulmo's miscellaneous traits
1311 * might look like this:
1313 * Free Action; Hold Life; See Invisible; Slow Digestion; Regeneration
1316 * So comparing the two, "Regeneration" has no trailing separator and
1317 * "Blessed Blade" was not indented. (Also, Ulmo's lists have no headers,
1318 * but that's not relevant to line wrapping and indention.)
1321 /* ITEM_SEP separates items within a list */
1322 #define ITEM_SEP ','
1325 /* LIST_SEP separates lists */
1327 #define LIST_SEP ','
1329 #define LIST_SEP ';'
1332 static void spoiler_outlist(cptr header, cptr *list, char separator)
1334 int line_len, buf_len;
1335 char line[MAX_LINE_LEN+1], buf[80];
1337 /* Ignore an empty list */
1338 if (*list == NULL) return;
1340 /* This function always indents */
1341 strcpy(line, INDENT1);
1343 /* Create header (if one was given) */
1344 if (header && (header[0]))
1346 strcat(line, header);
1350 line_len = strlen(line);
1352 /* Now begin the tedious task */
1355 /* Copy the current item to a buffer */
1358 /* Note the buffer's length */
1359 buf_len = strlen(buf);
1362 * If there is an item following this one, pad with separator and
1363 * a space and adjust the buffer length
1368 sprintf(buf + buf_len, "%c ", separator);
1373 * If the buffer will fit on the current line, just append the
1374 * buffer to the line and adjust the line length accordingly.
1377 if (line_len + buf_len <= MAX_LINE_LEN)
1380 line_len += buf_len;
1383 /* Apply line wrapping and indention semantics described above */
1387 * Don't print a trailing list separator but do print a trailing
1390 if (line_len > 1 && line[line_len - 1] == ' '
1391 && line[line_len - 2] == LIST_SEP)
1393 /* Ignore space and separator */
1394 line[line_len - 2] = '\0';
1396 /* Write to spoiler file */
1397 fprintf(fff, "%s\n", line);
1399 /* Begin new line at primary indention level */
1400 sprintf(line, "%s%s", INDENT1, buf);
1405 /* Write to spoiler file */
1406 fprintf(fff, "%s\n", line);
1408 /* Begin new line at secondary indention level */
1409 sprintf(line, "%s%s", INDENT2, buf);
1412 line_len = strlen(line);
1415 /* Advance, with break */
1416 if (!*++list) break;
1419 /* Write what's left to the spoiler file */
1420 fprintf(fff, "%s\n", line);
1424 /* Create a spoiler file entry for an artifact */
1426 static void spoiler_print_art(obj_desc_list *art_ptr)
1428 pval_info_type *pval_ptr = &art_ptr->pval_info;
1432 /* Don't indent the first line */
1433 fprintf(fff, "%s\n", art_ptr->description);
1435 /* An "empty" pval description indicates that the pval affects nothing */
1436 if (pval_ptr->pval_desc[0])
1438 /* Mention the effects of pval */
1440 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
1442 sprintf(buf, "%s to", pval_ptr->pval_desc);
1444 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
1447 /* Now deal with the description lists */
1450 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
1452 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
1454 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
1456 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
1458 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
1460 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
1462 spoiler_outlist("", art_ptr->brands, LIST_SEP);
1464 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
1466 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
1468 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
1470 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
1473 /* Write out the possible activation at the primary indention level */
1474 if (art_ptr->activation)
1477 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
1479 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
1483 /* End with the miscellaneous facts */
1484 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
1489 * Hack -- Create a "forged" artifact
1491 static bool make_fake_artifact(object_type *o_ptr, int name1)
1495 artifact_type *a_ptr = &a_info[name1];
1498 /* Ignore "empty" artifacts */
1499 if (!a_ptr->name) return FALSE;
1501 /* Acquire the "kind" index */
1502 i = lookup_kind(a_ptr->tval, a_ptr->sval);
1505 if (!i) return (FALSE);
1507 /* Create the artifact */
1508 object_prep(o_ptr, i);
1511 o_ptr->name1 = name1;
1513 /* Extract the fields */
1514 o_ptr->pval = a_ptr->pval;
1515 o_ptr->ac = a_ptr->ac;
1516 o_ptr->dd = a_ptr->dd;
1517 o_ptr->ds = a_ptr->ds;
1518 o_ptr->to_a = a_ptr->to_a;
1519 o_ptr->to_h = a_ptr->to_h;
1520 o_ptr->to_d = a_ptr->to_d;
1521 o_ptr->weight = a_ptr->weight;
1529 * Create a spoiler file for artifacts
1531 static void spoil_artifact(cptr fname)
1538 obj_desc_list artifact;
1543 /* Build the filename */
1544 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
1546 /* File type is "TEXT" */
1547 FILE_TYPE(FILE_TYPE_TEXT);
1550 fff = my_fopen(buf, "w");
1555 msg_print("Cannot create spoiler file.");
1559 /* Dump the header */
1562 /* List the artifacts by tval */
1563 for (i = 0; group_artifact[i].tval; i++)
1565 /* Write out the group title */
1566 if (group_artifact[i].name)
1568 spoiler_blanklines(2);
1569 spoiler_underline(group_artifact[i].name);
1570 spoiler_blanklines(1);
1573 /* Now search through all of the artifacts */
1574 for (j = 1; j < max_a_idx; ++j)
1576 artifact_type *a_ptr = &a_info[j];
1578 /* We only want objects in the current group */
1579 if (a_ptr->tval != group_artifact[i].tval) continue;
1581 /* Get local object */
1584 /* Wipe the object */
1587 /* Attempt to "forge" the artifact */
1588 if (!make_fake_artifact(q_ptr, j)) continue;
1590 /* Analyze the artifact */
1591 object_analyze(q_ptr, &artifact);
1593 /* Write out the artifact description to the spoiler file */
1594 spoiler_print_art(&artifact);
1598 /* Check for errors */
1599 if (ferror(fff) || my_fclose(fff))
1601 msg_print("Cannot close spoiler file.");
1606 msg_print("Successfully created a spoiler file.");
1614 * Create a spoiler file for monsters -BEN-
1616 static void spoil_mon_desc(cptr fname)
1633 /* Build the filename */
1634 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
1636 /* File type is "TEXT" */
1637 FILE_TYPE(FILE_TYPE_TEXT);
1640 fff = my_fopen(buf, "w");
1645 msg_print("Cannot create spoiler file.");
1649 /* Allocate the "who" array */
1650 C_MAKE(who, max_r_idx, s16b);
1652 /* Dump the header */
1653 fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1654 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1655 fprintf(fff, "------------------------------------------\n\n");
1657 /* Dump the header */
1658 fprintf(fff, " %-38.38s%4s%4s%4s%7s%5s %11.11s\n",
1659 "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
1660 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1661 "--------", "---", "---", "---", "--", "--", "-----------");
1664 /* Scan the monsters */
1665 for (i = 1; i < max_r_idx; i++)
1667 monster_race *r_ptr = &r_info[i];
1669 /* Use that monster */
1670 if (r_ptr->name) who[n++] = i;
1673 /* Select the sort method */
1674 ang_sort_comp = ang_sort_comp_hook;
1675 ang_sort_swap = ang_sort_swap_hook;
1677 /* Sort the array by dungeon depth of monsters */
1678 ang_sort(who, &why, n);
1681 for (i = 0; i < n; i++)
1683 monster_race *r_ptr = &r_info[who[i]];
1685 cptr name = (r_name + r_ptr->name);
1686 if (r_ptr->flags7 & (RF7_KAGE)) continue;
1688 /* Get the "name" */
1689 /* if (r_ptr->flags1 & (RF1_QUESTOR)) */
1692 sprintf(nam, "[Q] %s", name);
1694 else if (r_ptr->flags1 & (RF1_UNIQUE))
1696 sprintf(nam, "[U] %s", name);
1701 sprintf(nam, " %s", name);
1703 sprintf(nam, "The %s", name);
1709 sprintf(lev, "%d", r_ptr->level);
1712 sprintf(rar, "%d", r_ptr->rarity);
1715 if (r_ptr->speed >= 110)
1717 sprintf(spd, "+%d", (r_ptr->speed - 110));
1721 sprintf(spd, "-%d", (110 - r_ptr->speed));
1725 sprintf(ac, "%d", r_ptr->ac);
1728 if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
1730 sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
1734 sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
1739 sprintf(exp, "%ld", (long)(r_ptr->mexp));
1741 /* Hack -- use visual instead */
1742 sprintf(exp, "%s '%c'", attr_to_text(r_ptr->d_attr), r_ptr->d_char);
1745 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1746 nam, lev, rar, spd, hp, ac, exp);
1753 /* Free the "who" array */
1754 C_KILL(who, max_r_idx, s16b);
1756 /* Check for errors */
1757 if (ferror(fff) || my_fclose(fff))
1759 msg_print("Cannot close spoiler file.");
1764 msg_print("Successfully created a spoiler file.");
1771 * Monster spoilers by: smchorse@ringer.cs.utsa.edu (Shawn McHorse)
1773 * Primarily based on code already in mon-desc.c, mostly by -BEN-
1779 * Buffer text to the given file. (-SHAWN-)
1780 * This is basically c_roff() from mon-desc.c with a few changes.
1782 static void spoil_out(cptr str)
1787 static char roff_buf[256];
1792 /* Current pointer into line roff_buf */
1793 static char *roff_p = roff_buf;
1795 /* Last space saved into roff_buf */
1796 static char *roff_s = NULL;
1798 /* Special handling for "new sequence" */
1801 if (roff_p != roff_buf) roff_p--;
1802 while (*roff_p == ' ' && roff_p != roff_buf) roff_p--;
1803 if (roff_p == roff_buf) fprintf(fff, "\n");
1806 *(roff_p + 1) = '\0';
1807 fprintf(fff, "%s\n\n", roff_buf);
1815 /* Scan the given string, character at a time */
1820 int k_flag = iskanji((unsigned char)(*str));
1823 int wrap = (ch == '\n');
1826 if (!isprint(ch) && !k_flag && !iskanji2) ch = ' ';
1827 if(k_flag && !iskanji2)iskanji2=1;else iskanji2=0;
1829 if (!isprint(ch)) ch = ' ';
1833 if ( roff_p >= roff_buf+( (k_flag) ? 74 : 75) ) wrap=1;
1834 if ((ch == ' ') && (roff_p + 2 >= roff_buf + ((k_flag) ? 74 : 75))) wrap = 1;
1836 if (roff_p >= roff_buf + 75) wrap = 1;
1837 if ((ch == ' ') && (roff_p + 2 >= roff_buf + 75)) wrap = 1;
1841 /* Handle line-wrap */
1849 if (roff_s && (ch != ' '))
1857 fprintf(fff, "%s\n", roff_buf);
1861 if(cbak != ' ') *roff_p++ = cbak;
1863 while (*r) *roff_p++ = *r++;
1867 if ((roff_p > roff_buf) || (ch != ' '))
1871 if (ch == ' ' || ch == '(' ) roff_s = roff_p;
1875 strncmp(str, "¡£", 2) != 0 &&
1876 strncmp(str, "¡¢", 2) != 0 &&
1877 strncmp(str, "¥£", 2) != 0 &&
1878 strncmp(str, "¡¼", 2) != 0) roff_s = roff_p;
1881 if (ch == ' ') roff_s = roff_p;
1892 * Hook function used in spoil_mon_info()
1894 static void roff_func(byte attr, cptr str)
1901 * Create a spoiler file for monsters (-SHAWN-)
1903 static void spoil_mon_info(cptr fname)
1906 int msex, i, l, n=0;
1908 u32b flags1, flags2, flags3, flags4, flags5, flags6, flags7;
1913 /* Build the filename */
1914 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
1916 /* File type is "TEXT" */
1917 FILE_TYPE(FILE_TYPE_TEXT);
1920 fff = my_fopen(buf, "w");
1925 msg_print("Cannot create spoiler file.");
1930 /* Dump the header */
1931 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1932 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1935 spoil_out("------------------------------------------\n\n");
1937 /* Allocate the "who" array */
1938 C_MAKE(who, max_r_idx, s16b);
1940 /* Scan the monsters */
1941 for (i = 1; i < max_r_idx; i++)
1943 monster_race *r_ptr = &r_info[i];
1945 /* Use that monster */
1946 if (r_ptr->name) who[n++] = i;
1949 /* Select the sort method */
1950 ang_sort_comp = ang_sort_comp_hook;
1951 ang_sort_swap = ang_sort_swap_hook;
1953 /* Sort the array by dungeon depth of monsters */
1954 ang_sort(who, &why, n);
1958 * List all monsters in order
1960 for (l = 0; l < n; l++)
1962 monster_race *r_ptr = &r_info[who[l]];
1964 /* Extract the flags */
1965 flags1 = r_ptr->flags1;
1966 flags2 = r_ptr->flags2;
1967 flags3 = r_ptr->flags3;
1968 flags4 = r_ptr->flags4;
1969 flags5 = r_ptr->flags5;
1970 flags6 = r_ptr->flags6;
1971 flags7 = r_ptr->flags7;
1975 /* Extract a gender (if applicable) */
1976 if (flags1 & (RF1_FEMALE)) msex = 2;
1977 else if (flags1 & (RF1_MALE)) msex = 1;
1982 if (flags1 & (RF1_QUESTOR))
1986 else if (flags1 & (RF1_UNIQUE))
1999 sprintf(buf, "%s/%s (", (r_name + r_ptr->name),(r_name+r_ptr->E_name)); /* ---)--- */
2001 sprintf(buf, "%s (", (r_name + r_ptr->name)); /* ---)--- */
2007 spoil_out(attr_to_text(r_ptr->d_attr));
2010 sprintf(buf, " '%c')\n", r_ptr->d_char);
2015 sprintf(buf, "=== ");
2019 sprintf(buf, "Num:%d ", who[l]);
2023 sprintf(buf, "Lev:%d ", r_ptr->level);
2027 sprintf(buf, "Rar:%d ", r_ptr->rarity);
2031 if (r_ptr->speed >= 110)
2033 sprintf(buf, "Spd:+%d ", (r_ptr->speed - 110));
2037 sprintf(buf, "Spd:-%d ", (110 - r_ptr->speed));
2042 if ((flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
2044 sprintf(buf, "Hp:%d ", r_ptr->hdice * r_ptr->hside);
2048 sprintf(buf, "Hp:%dd%d ", r_ptr->hdice, r_ptr->hside);
2053 sprintf(buf, "Ac:%d ", r_ptr->ac);
2057 sprintf(buf, "Exp:%ld\n", (long)(r_ptr->mexp));
2060 /* Reuse the code of monster recall. */
2061 output_monster_spoiler(who[l], roff_func);
2066 /* Free the "who" array */
2067 C_KILL(who, max_r_idx, s16b);
2069 /* Check for errors */
2070 if (ferror(fff) || my_fclose(fff))
2072 msg_print("Cannot close spoiler file.");
2076 msg_print("Successfully created a spoiler file.");
2084 extern void do_cmd_spoilers(void);
2087 * Create Spoiler files -BEN-
2089 void do_cmd_spoilers(void)
2094 /* Save the screen */
2109 prt("Create a spoiler file.", 2, 0);
2111 /* Prompt for a file */
2112 prt("(1) Brief Object Info (obj-desc.spo)", 5, 5);
2113 prt("(2) Brief Artifact Info (artifact.spo)", 6, 5);
2114 prt("(3) Brief Monster Info (mon-desc.spo)", 7, 5);
2115 prt("(4) Full Monster Info (mon-info.spo)", 8, 5);
2119 prt("¥³¥Þ¥ó¥É:", 18, 0);
2121 prt("Command: ", 12, 0);
2137 spoil_obj_desc("obj-desc.spo");
2143 spoil_artifact("artifact.spo");
2149 spoil_mon_desc("mon-desc.spo");
2155 spoil_mon_info("mon-info.spo");
2164 /* Flush messages */
2173 /* Restore the screen */
2178 * Fill in an object description structure for a given object
2180 static void random_artifact_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
2182 analyze_general(o_ptr, desc_ptr->description);
2183 analyze_pval(o_ptr, &desc_ptr->pval_info);
2184 analyze_brand(o_ptr, desc_ptr->brands);
2185 analyze_slay(o_ptr, desc_ptr->slays);
2186 analyze_immune(o_ptr, desc_ptr->immunities);
2187 analyze_resist(o_ptr, desc_ptr->resistances);
2188 analyze_sustains(o_ptr, desc_ptr->sustains);
2189 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
2190 desc_ptr->activation = item_activation(o_ptr);
2192 sprintf(desc_ptr->misc_desc, "½Å¤µ %d.%d kg",
2193 lbtokg1(o_ptr->weight), lbtokg2(o_ptr->weight));
2195 sprintf(desc_ptr->misc_desc, "Weight %d.%d lbs",
2196 o_ptr->weight / 10, o_ptr->weight % 10);
2200 /* Create a spoiler file entry for an artifact */
2202 static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
2204 pval_info_type *pval_ptr = &art_ptr->pval_info;
2208 /* Don't indent the first line */
2209 fprintf(fff, "%s\n", art_ptr->description);
2212 if (!(o_ptr->ident & (IDENT_MENTAL)))
2215 fprintf(fff, "%sÉÔÌÀ\n",INDENT1);
2217 fprintf(fff, "%sUnknown\n",INDENT1);
2221 /* An "empty" pval description indicates that the pval affects nothing */
2222 if (pval_ptr->pval_desc[0])
2224 /* Mention the effects of pval */
2226 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
2228 sprintf(buf, "%s to", pval_ptr->pval_desc);
2230 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
2233 /* Now deal with the description lists */
2236 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
2237 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
2238 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
2239 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
2240 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
2242 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
2243 spoiler_outlist("", art_ptr->brands, LIST_SEP);
2244 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
2245 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
2246 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
2248 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
2250 /* Write out the possible activation at the primary indention level */
2251 if (art_ptr->activation)
2254 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
2256 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
2260 /* End with the miscellaneous facts */
2261 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
2264 /* Create a part of file for random artifacts */
2266 static void spoil_random_artifact_aux(object_type *o_ptr, int i)
2268 obj_desc_list artifact;
2270 if (!object_known_p(o_ptr) || !o_ptr->art_name
2271 || o_ptr->tval != group_artifact[i].tval)
2274 /* Analyze the artifact */
2275 random_artifact_analyze(o_ptr, &artifact);
2277 /* Write out the artifact description to the spoiler file */
2278 spoiler_print_randart(o_ptr, &artifact);
2282 * Create a list file for random artifacts
2284 void spoil_random_artifact(cptr fname)
2297 /* Build the filename */
2298 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
2300 /* File type is "TEXT" */
2301 FILE_TYPE(FILE_TYPE_TEXT);
2304 fff = my_fopen(buf, "w");
2309 msg_print("Cannot create list file.");
2313 /* Dump the header */
2314 sprintf(buf, "Random artifacts list.\r");
2315 spoiler_underline(buf);
2317 /* List the artifacts by tval */
2318 for (j = 0; group_artifact[j].tval; j++)
2320 /* random artifacts wielding */
2321 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2323 q_ptr = &inventory[i];
2324 spoil_random_artifact_aux(q_ptr, j);
2327 /* random artifacts in inventory */
2328 for (i = 0; i < INVEN_PACK; i++)
2330 q_ptr = &inventory[i];
2331 spoil_random_artifact_aux(q_ptr, j);
2334 /* random artifacts in home */
2335 st_ptr = &town[1].store[STORE_HOME];
2336 for (i = 0; i < st_ptr->stock_num; i++)
2338 q_ptr = &st_ptr->stock[i];
2339 spoil_random_artifact_aux(q_ptr, j);
2342 /* random artifacts in museum */
2343 st_ptr = &town[1].store[STORE_MUSEUM];
2344 for (i = 0; i < st_ptr->stock_num; i++)
2346 q_ptr = &st_ptr->stock[i];
2347 spoil_random_artifact_aux(q_ptr, j);
2351 /* Check for errors */
2352 if (ferror(fff) || my_fclose(fff))
2354 msg_print("Cannot close list file.");
2362 msg_print("Successfully created a list file.");
2369 #endif /* MACINTOSH */