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_HAJA_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_HAJA_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 #ifndef FAKE_VERSION
1286 sprintf(buf, "Artifact Spoilers for Angband Version %d.%d.%d",
1287 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
1288 spoiler_underline(buf);
1289 #else /* FAKE_VERSION */
1290 sprintf(buf, "Artifact Spoilers for Hengband Version %d.%d.%d",
1291 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1292 spoiler_underline(buf);
1293 #endif /* FAKE_VERSION */
1298 * This is somewhat ugly.
1300 * Given a header ("Resist", e.g.), a list ("Fire", "Cold", Acid", e.g.),
1301 * and a separator character (',', e.g.), write the list to the spoiler file
1302 * in a "nice" format, such as:
1304 * Resist Fire, Cold, Acid
1306 * That was a simple example, but when the list is long, a line wrap
1307 * should occur, and this should induce a new level of indention if
1308 * a list is being spread across lines. So for example, Bladeturner's
1309 * list of resistances should look something like this
1311 * Resist Acid, Lightning, Fire, Cold, Poison, Light, Dark, Blindness,
1312 * Confusion, Sound, Shards, Nether, Nexus, Chaos, Disenchantment
1314 * However, the code distinguishes between a single list of many items vs.
1315 * many lists. (The separator is used to make this determination.) A single
1316 * list of many items will not cause line wrapping (since there is no
1317 * apparent reason to do so). So the lists of Ulmo's miscellaneous traits
1318 * might look like this:
1320 * Free Action; Hold Life; See Invisible; Slow Digestion; Regeneration
1323 * So comparing the two, "Regeneration" has no trailing separator and
1324 * "Blessed Blade" was not indented. (Also, Ulmo's lists have no headers,
1325 * but that's not relevant to line wrapping and indention.)
1328 /* ITEM_SEP separates items within a list */
1329 #define ITEM_SEP ','
1332 /* LIST_SEP separates lists */
1334 #define LIST_SEP ','
1336 #define LIST_SEP ';'
1339 static void spoiler_outlist(cptr header, cptr *list, char separator)
1341 int line_len, buf_len;
1342 char line[MAX_LINE_LEN+1], buf[80];
1344 /* Ignore an empty list */
1345 if (*list == NULL) return;
1347 /* This function always indents */
1348 strcpy(line, INDENT1);
1350 /* Create header (if one was given) */
1351 if (header && (header[0]))
1353 strcat(line, header);
1357 line_len = strlen(line);
1359 /* Now begin the tedious task */
1362 /* Copy the current item to a buffer */
1365 /* Note the buffer's length */
1366 buf_len = strlen(buf);
1369 * If there is an item following this one, pad with separator and
1370 * a space and adjust the buffer length
1375 sprintf(buf + buf_len, "%c ", separator);
1380 * If the buffer will fit on the current line, just append the
1381 * buffer to the line and adjust the line length accordingly.
1384 if (line_len + buf_len <= MAX_LINE_LEN)
1387 line_len += buf_len;
1390 /* Apply line wrapping and indention semantics described above */
1394 * Don't print a trailing list separator but do print a trailing
1397 if (line_len > 1 && line[line_len - 1] == ' '
1398 && line[line_len - 2] == LIST_SEP)
1400 /* Ignore space and separator */
1401 line[line_len - 2] = '\0';
1403 /* Write to spoiler file */
1404 fprintf(fff, "%s\n", line);
1406 /* Begin new line at primary indention level */
1407 sprintf(line, "%s%s", INDENT1, buf);
1412 /* Write to spoiler file */
1413 fprintf(fff, "%s\n", line);
1415 /* Begin new line at secondary indention level */
1416 sprintf(line, "%s%s", INDENT2, buf);
1419 line_len = strlen(line);
1422 /* Advance, with break */
1423 if (!*++list) break;
1426 /* Write what's left to the spoiler file */
1427 fprintf(fff, "%s\n", line);
1431 /* Create a spoiler file entry for an artifact */
1433 static void spoiler_print_art(obj_desc_list *art_ptr)
1435 pval_info_type *pval_ptr = &art_ptr->pval_info;
1439 /* Don't indent the first line */
1440 fprintf(fff, "%s\n", art_ptr->description);
1442 /* An "empty" pval description indicates that the pval affects nothing */
1443 if (pval_ptr->pval_desc[0])
1445 /* Mention the effects of pval */
1447 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
1449 sprintf(buf, "%s to", pval_ptr->pval_desc);
1451 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
1454 /* Now deal with the description lists */
1457 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
1459 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
1461 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
1463 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
1465 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
1467 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
1469 spoiler_outlist("", art_ptr->brands, LIST_SEP);
1471 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
1473 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
1475 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
1477 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
1480 /* Write out the possible activation at the primary indention level */
1481 if (art_ptr->activation)
1484 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
1486 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
1490 /* End with the miscellaneous facts */
1491 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
1496 * Hack -- Create a "forged" artifact
1498 static bool make_fake_artifact(object_type *o_ptr, int name1)
1502 artifact_type *a_ptr = &a_info[name1];
1505 /* Ignore "empty" artifacts */
1506 if (!a_ptr->name) return FALSE;
1508 /* Acquire the "kind" index */
1509 i = lookup_kind(a_ptr->tval, a_ptr->sval);
1512 if (!i) return (FALSE);
1514 /* Create the artifact */
1515 object_prep(o_ptr, i);
1518 o_ptr->name1 = name1;
1520 /* Extract the fields */
1521 o_ptr->pval = a_ptr->pval;
1522 o_ptr->ac = a_ptr->ac;
1523 o_ptr->dd = a_ptr->dd;
1524 o_ptr->ds = a_ptr->ds;
1525 o_ptr->to_a = a_ptr->to_a;
1526 o_ptr->to_h = a_ptr->to_h;
1527 o_ptr->to_d = a_ptr->to_d;
1528 o_ptr->weight = a_ptr->weight;
1536 * Create a spoiler file for artifacts
1538 static void spoil_artifact(cptr fname)
1545 obj_desc_list artifact;
1550 /* Build the filename */
1551 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
1553 /* File type is "TEXT" */
1554 FILE_TYPE(FILE_TYPE_TEXT);
1557 fff = my_fopen(buf, "w");
1562 msg_print("Cannot create spoiler file.");
1566 /* Dump the header */
1569 /* List the artifacts by tval */
1570 for (i = 0; group_artifact[i].tval; i++)
1572 /* Write out the group title */
1573 if (group_artifact[i].name)
1575 spoiler_blanklines(2);
1576 spoiler_underline(group_artifact[i].name);
1577 spoiler_blanklines(1);
1580 /* Now search through all of the artifacts */
1581 for (j = 1; j < max_a_idx; ++j)
1583 artifact_type *a_ptr = &a_info[j];
1585 /* We only want objects in the current group */
1586 if (a_ptr->tval != group_artifact[i].tval) continue;
1588 /* Get local object */
1591 /* Wipe the object */
1594 /* Attempt to "forge" the artifact */
1595 if (!make_fake_artifact(q_ptr, j)) continue;
1597 /* Analyze the artifact */
1598 object_analyze(q_ptr, &artifact);
1600 /* Write out the artifact description to the spoiler file */
1601 spoiler_print_art(&artifact);
1605 /* Check for errors */
1606 if (ferror(fff) || my_fclose(fff))
1608 msg_print("Cannot close spoiler file.");
1613 msg_print("Successfully created a spoiler file.");
1621 * Create a spoiler file for monsters -BEN-
1623 static void spoil_mon_desc(cptr fname)
1640 /* Build the filename */
1641 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
1643 /* File type is "TEXT" */
1644 FILE_TYPE(FILE_TYPE_TEXT);
1647 fff = my_fopen(buf, "w");
1652 msg_print("Cannot create spoiler file.");
1656 /* Allocate the "who" array */
1657 C_MAKE(who, max_r_idx, s16b);
1659 /* Dump the header */
1661 #ifndef FAKE_VERSION
1662 fprintf(fff, "Monster Spoilers for Angband Version %d.%d.%d\n",
1663 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
1664 fprintf(fff, "------------------------------------------\n\n");
1666 fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1667 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1668 fprintf(fff, "------------------------------------------\n\n");
1671 /* Dump the header */
1672 fprintf(fff, " %-38.38s%4s%4s%4s%7s%5s %11.11s\n",
1673 "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
1674 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1675 "--------", "---", "---", "---", "--", "--", "-----------");
1678 /* Scan the monsters */
1679 for (i = 1; i < max_r_idx; i++)
1681 monster_race *r_ptr = &r_info[i];
1683 /* Use that monster */
1684 if (r_ptr->name) who[n++] = i;
1687 /* Select the sort method */
1688 ang_sort_comp = ang_sort_comp_hook;
1689 ang_sort_swap = ang_sort_swap_hook;
1691 /* Sort the array by dungeon depth of monsters */
1692 ang_sort(who, &why, n);
1695 for (i = 0; i < n; i++)
1697 monster_race *r_ptr = &r_info[who[i]];
1699 cptr name = (r_name + r_ptr->name);
1700 if (r_ptr->flags7 & (RF7_KAGE)) continue;
1702 /* Get the "name" */
1703 /* if (r_ptr->flags1 & (RF1_QUESTOR)) */
1706 sprintf(nam, "[Q] %s", name);
1708 else if (r_ptr->flags1 & (RF1_UNIQUE))
1710 sprintf(nam, "[U] %s", name);
1715 sprintf(nam, " %s", name);
1717 sprintf(nam, "The %s", name);
1723 sprintf(lev, "%d", r_ptr->level);
1726 sprintf(rar, "%d", r_ptr->rarity);
1729 if (r_ptr->speed >= 110)
1731 sprintf(spd, "+%d", (r_ptr->speed - 110));
1735 sprintf(spd, "-%d", (110 - r_ptr->speed));
1739 sprintf(ac, "%d", r_ptr->ac);
1742 if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
1744 sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
1748 sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
1753 sprintf(exp, "%ld", (long)(r_ptr->mexp));
1755 /* Hack -- use visual instead */
1756 sprintf(exp, "%s '%c'", attr_to_text(r_ptr->d_attr), r_ptr->d_char);
1759 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1760 nam, lev, rar, spd, hp, ac, exp);
1767 /* Free the "who" array */
1768 C_KILL(who, max_r_idx, s16b);
1770 /* Check for errors */
1771 if (ferror(fff) || my_fclose(fff))
1773 msg_print("Cannot close spoiler file.");
1778 msg_print("Successfully created a spoiler file.");
1785 * Monster spoilers by: smchorse@ringer.cs.utsa.edu (Shawn McHorse)
1787 * Primarily based on code already in mon-desc.c, mostly by -BEN-
1793 * Buffer text to the given file. (-SHAWN-)
1794 * This is basically c_roff() from mon-desc.c with a few changes.
1796 static void spoil_out(cptr str)
1801 static char roff_buf[256];
1806 /* Current pointer into line roff_buf */
1807 static char *roff_p = roff_buf;
1809 /* Last space saved into roff_buf */
1810 static char *roff_s = NULL;
1812 /* Special handling for "new sequence" */
1815 if (roff_p != roff_buf) roff_p--;
1816 while (*roff_p == ' ' && roff_p != roff_buf) roff_p--;
1817 if (roff_p == roff_buf) fprintf(fff, "\n");
1820 *(roff_p + 1) = '\0';
1821 fprintf(fff, "%s\n\n", roff_buf);
1829 /* Scan the given string, character at a time */
1834 int k_flag = iskanji((unsigned char)(*str));
1837 int wrap = (ch == '\n');
1840 if (!isprint(ch) && !k_flag && !iskanji2) ch = ' ';
1841 if(k_flag && !iskanji2)iskanji2=1;else iskanji2=0;
1843 if (!isprint(ch)) ch = ' ';
1847 if ( roff_p >= roff_buf+( (k_flag) ? 74 : 75) ) wrap=1;
1848 if ((ch == ' ') && (roff_p + 2 >= roff_buf + ((k_flag) ? 74 : 75))) wrap = 1;
1850 if (roff_p >= roff_buf + 75) wrap = 1;
1851 if ((ch == ' ') && (roff_p + 2 >= roff_buf + 75)) wrap = 1;
1855 /* Handle line-wrap */
1863 if (roff_s && (ch != ' '))
1871 fprintf(fff, "%s\n", roff_buf);
1875 if(cbak != ' ') *roff_p++ = cbak;
1877 while (*r) *roff_p++ = *r++;
1881 if ((roff_p > roff_buf) || (ch != ' '))
1885 if (ch == ' ' || ch == '(' ) roff_s = roff_p;
1889 strncmp(str, "¡£", 2) != 0 &&
1890 strncmp(str, "¡¢", 2) != 0 &&
1891 strncmp(str, "¥£", 2) != 0 &&
1892 strncmp(str, "¡¼", 2) != 0) roff_s = roff_p;
1895 if (ch == ' ') roff_s = roff_p;
1906 * Hook function used in spoil_mon_info()
1908 void roff_func(byte attr, cptr str)
1915 * Create a spoiler file for monsters (-SHAWN-)
1917 static void spoil_mon_info(cptr fname)
1920 int msex, i, l, n=0;
1922 u32b flags1, flags2, flags3, flags4, flags5, flags6, flags7;
1927 /* Build the filename */
1928 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
1930 /* File type is "TEXT" */
1931 FILE_TYPE(FILE_TYPE_TEXT);
1934 fff = my_fopen(buf, "w");
1939 msg_print("Cannot create spoiler file.");
1944 /* Dump the header */
1945 #ifndef FAKE_VERSION
1946 sprintf(buf, "Monster Spoilers for Angband Version %d.%d.%d\n",
1947 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
1949 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1950 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1954 spoil_out("------------------------------------------\n\n");
1956 /* Allocate the "who" array */
1957 C_MAKE(who, max_r_idx, s16b);
1959 /* Scan the monsters */
1960 for (i = 1; i < max_r_idx; i++)
1962 monster_race *r_ptr = &r_info[i];
1964 /* Use that monster */
1965 if (r_ptr->name) who[n++] = i;
1968 /* Select the sort method */
1969 ang_sort_comp = ang_sort_comp_hook;
1970 ang_sort_swap = ang_sort_swap_hook;
1972 /* Sort the array by dungeon depth of monsters */
1973 ang_sort(who, &why, n);
1977 * List all monsters in order
1979 for (l = 0; l < n; l++)
1981 monster_race *r_ptr = &r_info[who[l]];
1983 /* Extract the flags */
1984 flags1 = r_ptr->flags1;
1985 flags2 = r_ptr->flags2;
1986 flags3 = r_ptr->flags3;
1987 flags4 = r_ptr->flags4;
1988 flags5 = r_ptr->flags5;
1989 flags6 = r_ptr->flags6;
1990 flags7 = r_ptr->flags7;
1994 /* Extract a gender (if applicable) */
1995 if (flags1 & (RF1_FEMALE)) msex = 2;
1996 else if (flags1 & (RF1_MALE)) msex = 1;
2001 if (flags1 & (RF1_QUESTOR))
2005 else if (flags1 & (RF1_UNIQUE))
2018 sprintf(buf, "%s/%s (", (r_name + r_ptr->name),(r_name+r_ptr->E_name)); /* ---)--- */
2020 sprintf(buf, "%s (", (r_name + r_ptr->name)); /* ---)--- */
2026 spoil_out(attr_to_text(r_ptr->d_attr));
2029 sprintf(buf, " '%c')\n", r_ptr->d_char);
2034 sprintf(buf, "=== ");
2038 sprintf(buf, "Num:%d ", who[l]);
2042 sprintf(buf, "Lev:%d ", r_ptr->level);
2046 sprintf(buf, "Rar:%d ", r_ptr->rarity);
2050 if (r_ptr->speed >= 110)
2052 sprintf(buf, "Spd:+%d ", (r_ptr->speed - 110));
2056 sprintf(buf, "Spd:-%d ", (110 - r_ptr->speed));
2061 if ((flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
2063 sprintf(buf, "Hp:%d ", r_ptr->hdice * r_ptr->hside);
2067 sprintf(buf, "Hp:%dd%d ", r_ptr->hdice, r_ptr->hside);
2072 sprintf(buf, "Ac:%d ", r_ptr->ac);
2076 sprintf(buf, "Exp:%ld\n", (long)(r_ptr->mexp));
2079 /* Reuse the code of monster recall. */
2080 output_monster_spoiler(who[l], roff_func);
2085 /* Free the "who" array */
2086 C_KILL(who, max_r_idx, s16b);
2088 /* Check for errors */
2089 if (ferror(fff) || my_fclose(fff))
2091 msg_print("Cannot close spoiler file.");
2095 msg_print("Successfully created a spoiler file.");
2103 extern void do_cmd_spoilers(void);
2106 * Create Spoiler files -BEN-
2108 void do_cmd_spoilers(void)
2113 /* Save the screen */
2128 prt("Create a spoiler file.", 2, 0);
2130 /* Prompt for a file */
2131 prt("(1) Brief Object Info (obj-desc.spo)", 5, 5);
2132 prt("(2) Brief Artifact Info (artifact.spo)", 6, 5);
2133 prt("(3) Brief Monster Info (mon-desc.spo)", 7, 5);
2134 prt("(4) Full Monster Info (mon-info.spo)", 8, 5);
2138 prt("¥³¥Þ¥ó¥É:", 18, 0);
2140 prt("Command: ", 12, 0);
2156 spoil_obj_desc("obj-desc.spo");
2162 spoil_artifact("artifact.spo");
2168 spoil_mon_desc("mon-desc.spo");
2174 spoil_mon_info("mon-info.spo");
2183 /* Flush messages */
2192 /* Restore the screen */
2197 * Fill in an object description structure for a given object
2199 static void random_artifact_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
2201 analyze_general(o_ptr, desc_ptr->description);
2202 analyze_pval(o_ptr, &desc_ptr->pval_info);
2203 analyze_brand(o_ptr, desc_ptr->brands);
2204 analyze_slay(o_ptr, desc_ptr->slays);
2205 analyze_immune(o_ptr, desc_ptr->immunities);
2206 analyze_resist(o_ptr, desc_ptr->resistances);
2207 analyze_sustains(o_ptr, desc_ptr->sustains);
2208 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
2209 desc_ptr->activation = item_activation(o_ptr);
2211 sprintf(desc_ptr->misc_desc, "½Å¤µ %d.%d kg",
2212 lbtokg1(o_ptr->weight), lbtokg2(o_ptr->weight));
2214 sprintf(desc_ptr->misc_desc, "Weight %d.%d lbs",
2215 o_ptr->weight / 10, o_ptr->weight % 10);
2219 /* Create a spoiler file entry for an artifact */
2221 static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
2223 pval_info_type *pval_ptr = &art_ptr->pval_info;
2227 /* Don't indent the first line */
2228 fprintf(fff, "%s\n", art_ptr->description);
2231 if (!(o_ptr->ident & (IDENT_MENTAL)))
2234 fprintf(fff, "%sÉÔÌÀ\n",INDENT1);
2236 fprintf(fff, "%sUnknown\n",INDENT1);
2240 /* An "empty" pval description indicates that the pval affects nothing */
2241 if (pval_ptr->pval_desc[0])
2243 /* Mention the effects of pval */
2245 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
2247 sprintf(buf, "%s to", pval_ptr->pval_desc);
2249 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
2252 /* Now deal with the description lists */
2255 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
2256 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
2257 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
2258 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
2259 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
2261 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
2262 spoiler_outlist("", art_ptr->brands, LIST_SEP);
2263 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
2264 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
2265 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
2267 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
2269 /* Write out the possible activation at the primary indention level */
2270 if (art_ptr->activation)
2273 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
2275 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
2279 /* End with the miscellaneous facts */
2280 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
2283 /* Create a part of file for random artifacts */
2285 static void spoil_random_artifact_aux(object_type *o_ptr, int i)
2287 obj_desc_list artifact;
2289 if (!object_known_p(o_ptr) || !o_ptr->art_name
2290 || o_ptr->tval != group_artifact[i].tval)
2293 /* Analyze the artifact */
2294 random_artifact_analyze(o_ptr, &artifact);
2296 /* Write out the artifact description to the spoiler file */
2297 spoiler_print_randart(o_ptr, &artifact);
2301 * Create a list file for random artifacts
2303 void spoil_random_artifact(cptr fname)
2316 /* Build the filename */
2317 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
2319 /* File type is "TEXT" */
2320 FILE_TYPE(FILE_TYPE_TEXT);
2323 fff = my_fopen(buf, "w");
2328 msg_print("Cannot create list file.");
2332 /* Dump the header */
2333 sprintf(buf, "Random artifacts list.\r");
2334 spoiler_underline(buf);
2336 /* List the artifacts by tval */
2337 for (j = 0; group_artifact[j].tval; j++)
2339 /* random artifacts wielding */
2340 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2342 q_ptr = &inventory[i];
2343 spoil_random_artifact_aux(q_ptr, j);
2346 /* random artifacts in inventory */
2347 for (i = 0; i < INVEN_PACK; i++)
2349 q_ptr = &inventory[i];
2350 spoil_random_artifact_aux(q_ptr, j);
2353 /* random artifacts in home */
2354 st_ptr = &town[1].store[STORE_HOME];
2355 for (i = 0; i < st_ptr->stock_num; i++)
2357 q_ptr = &st_ptr->stock[i];
2358 spoil_random_artifact_aux(q_ptr, j);
2361 /* random artifacts in museum */
2362 st_ptr = &town[1].store[STORE_MUSEUM];
2363 for (i = 0; i < st_ptr->stock_num; i++)
2365 q_ptr = &st_ptr->stock[i];
2366 spoil_random_artifact_aux(q_ptr, j);
2370 /* Check for errors */
2371 if (ferror(fff) || my_fclose(fff))
2373 msg_print("Cannot close list file.");
2381 msg_print("Successfully created a list file.");
2388 #endif /* MACINTOSH */