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_MUSIC_BOOK, "²Î½¸" },
184 { TV_HISSATSU_BOOK, "Éð·Ý¤Î½ñ" },
186 { TV_LIFE_BOOK, "Books (Life)" },
187 { TV_SORCERY_BOOK, "Books (Sorcery)" },
188 { TV_NATURE_BOOK, "Books (Nature)" },
189 { TV_CHAOS_BOOK, "Books (Chaos)" },
190 { TV_DEATH_BOOK, "Books (Death)" },
191 { TV_TRUMP_BOOK, "Books (Trump)" },
192 { TV_ARCANE_BOOK, "Books (Arcane)" },
193 { TV_ENCHANT_BOOK, "Books (Craft)" },
194 { TV_DAEMON_BOOK, "Books (Daemon)" },
195 { TV_MUSIC_BOOK, "Song Books" },
196 { TV_HISSATSU_BOOK, "Books (Kendo)" },
200 { TV_PARCHEMENT, "ÍÓÈé»æ" },
202 { TV_PARCHEMENT, "Parchement" },
208 { TV_CHEST, "Chests" },
212 { TV_CAPTURE, "¥¥ã¥×¥Á¥ã¡¼¡¦¥Ü¡¼¥ë" },
214 { TV_CAPTURE, "Capture Ball" },
218 { TV_CARD, "¥¨¥¯¥¹¥×¥ì¥¹¥«¡¼¥É" },
220 { TV_CARD, "Express Card" },
223 { TV_FIGURINE, "Magical Figurines" },
224 { TV_STATUE, "Statues" },
225 { TV_CORPSE, "Corpses" },
230 { TV_WHISTLE, "Whistle" },
234 { TV_SPIKE, "¤¯¤µ¤Ó" },
236 { TV_SPIKE, "Spike" },
243 { TV_SKELETON, NULL },
252 static void kind_info(char *buf, char *dam, char *wgt, int *lev, s32b *val, int k)
258 /* Get local object */
261 /* Prepare a fake item */
262 object_prep(q_ptr, k);
265 q_ptr->ident |= (IDENT_KNOWN);
275 (*lev) = get_object_level(q_ptr);
278 (*val) = object_value(q_ptr);
282 if (!buf || !dam || !wgt) return;
285 /* Description (too brief) */
286 object_desc_store(buf, q_ptr, FALSE, 0);
306 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
316 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
331 sprintf(dam, "%d", q_ptr->ac);
338 sprintf(wgt, "%3d.%d", q_ptr->weight / 10, q_ptr->weight % 10);
343 * Create a spoiler file for items
345 static void spoil_obj_desc(cptr fname)
347 int i, k, s, t, n = 0;
357 /* Build the filename */
358 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
360 /* File type is "TEXT" */
361 FILE_TYPE(FILE_TYPE_TEXT);
364 fff = my_fopen(buf, "w");
369 msg_print("Cannot create spoiler file.");
375 fprintf(fff, "Spoiler File -- Basic Items (Hengband %d.%d.%d)\n\n\n",
376 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
379 fprintf(fff, "%-45s %8s%7s%5s%9s\n",
380 "Description", "Dam/AC", "Wgt", "Lev", "Cost");
381 fprintf(fff, "%-45s %8s%7s%5s%9s\n",
382 "----------------------------------------",
383 "------", "---", "---", "----");
385 /* List the groups */
386 for (i = 0; TRUE; i++)
388 /* Write out the group title */
389 if (group_item[i].name)
391 /* Hack -- bubble-sort by cost and then level */
392 for (s = 0; s < n - 1; s++)
394 for (t = 0; t < n - 1; t++)
405 kind_info(NULL, NULL, NULL, &e1, &t1, who[i1]);
406 kind_info(NULL, NULL, NULL, &e2, &t2, who[i2]);
408 if ((t1 > t2) || ((t1 == t2) && (e1 > e2)))
417 /* Spoil each item */
418 for (s = 0; s < n; s++)
423 /* Describe the kind */
424 kind_info(buf, dam, wgt, &e, &v, who[s]);
427 fprintf(fff, " %-45s%8s%7s%5d%9ld\n",
428 buf, dam, wgt, e, (long)(v));
431 /* Start a new set */
435 if (!group_item[i].tval) break;
437 /* Start a new set */
438 fprintf(fff, "\n\n%s\n\n", group_item[i].name);
441 /* Acquire legal item types */
442 for (k = 1; k < max_k_idx; k++)
444 object_kind *k_ptr = &k_info[k];
446 /* Skip wrong tval's */
447 if (k_ptr->tval != group_item[i].tval) continue;
449 /* Hack -- Skip instant-artifacts */
450 if (k_ptr->gen_flags & (TRG_INSTA_ART)) continue;
458 /* Check for errors */
459 if (ferror(fff) || my_fclose(fff))
461 msg_print("Cannot close spoiler file.");
466 msg_print("Successfully created a spoiler file.");
471 * Artifact Spoilers by: randy@PICARD.tamu.edu (Randy Hutson)
476 * Returns a "+" string if a number is non-negative and an empty
479 #define POSITIZE(v) (((v) >= 0) ? "+" : "")
482 * These are used to format the artifact spoiler file. INDENT1 is used
483 * to indent all but the first line of an artifact spoiler. INDENT2 is
484 * used when a line "wraps". (Bladeturner's resistances cause this.)
490 * MAX_LINE_LEN specifies when a line should wrap.
492 #define MAX_LINE_LEN 75
495 * Given an array, determine how many elements are in the array
497 #define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))
500 * The artifacts categorized by type
502 static grouper group_artifact[] =
505 { TV_SWORD, "Åá·õ" },
506 { TV_POLEARM, "Áä/Éà" },
507 { TV_HAFTED, "Æß´ï" },
508 { TV_DIGGING, "¥·¥ã¥Ù¥ë/¤Ä¤ë¤Ï¤·" },
509 { TV_BOW, "Èô¤ÓÆ»¶ñ" },
512 { TV_SOFT_ARMOR, "³»" },
513 { TV_HARD_ARMOR, NULL },
514 { TV_DRAG_ARMOR, NULL },
516 { TV_CLOAK, "¥¯¥í¡¼¥¯" },
519 { TV_HELM, "³õ/´§" },
521 { TV_GLOVES, "äƼê" },
525 { TV_AMULET, "¥¢¥ß¥å¥ì¥Ã¥È" },
528 { TV_SWORD, "Edged Weapons" },
529 { TV_POLEARM, "Polearms" },
530 { TV_HAFTED, "Hafted Weapons" },
531 { TV_DIGGING, "Shovels/Picks" },
533 { TV_ARROW, "Ammo" },
535 { TV_SOFT_ARMOR, "Body Armor" },
536 { TV_HARD_ARMOR, NULL },
537 { TV_DRAG_ARMOR, NULL },
539 { TV_CLOAK, "Cloaks" },
540 { TV_SHIELD, "Shields" },
542 { TV_HELM, "Helms/Crowns" },
544 { TV_GLOVES, "Gloves" },
545 { TV_BOOTS, "Boots" },
547 { TV_LITE, "Light Sources" },
548 { TV_AMULET, "Amulets" },
549 { TV_RING, "Rings" },
558 * Pair together a constant flag with a textual description.
560 * Used by both "init.c" and "wiz-spo.c".
562 * Note that it sometimes more efficient to actually make an array
563 * of textual names, where entry 'N' is assumed to be paired with
564 * the flag whose value is "1L << N", but that requires hard-coding.
567 typedef struct flag_desc flag_desc;
572 const char *const desc;
578 * These are used for "+3 to STR, DEX", etc. These are separate from
579 * the other pval affected traits to simplify the case where an object
580 * affects all stats. In this case, "All stats" is used instead of
581 * listing each stat individually.
584 static flag_desc stat_flags_desc[] =
590 { TR1_DEX, "´ïÍѤµ" },
591 { TR1_CON, "Âѵ×ÎÏ" },
604 * Besides stats, these are the other player traits
605 * which may be affected by an object's pval
608 static flag_desc pval_flags1_desc[] =
611 { TR1_MAGIC_MASTERY, "ËâË¡Æ»¶ñ»ÈÍÑǽÎÏ" },
612 { TR1_STEALTH, "±£Ì©" },
613 { TR1_SEARCH, "õº÷" },
614 { TR1_INFRA, "ÀÖ³°Àþ»ëÎÏ" },
615 { TR1_TUNNEL, "ºÎ·¡" },
616 { TR1_BLOWS, "¹¶·â²ó¿ô" },
617 { TR1_SPEED, "¥¹¥Ô¡¼¥É" }
619 { TR1_STEALTH, "Stealth" },
620 { TR1_SEARCH, "Searching" },
621 { TR1_INFRA, "Infravision" },
622 { TR1_TUNNEL, "Tunneling" },
623 { TR1_BLOWS, "Attacks" },
624 { TR1_SPEED, "Speed" }
629 * Slaying preferences for weapons
632 static flag_desc slay_flags_desc[] =
635 { TR1_SLAY_ANIMAL, "ưʪ" },
636 { TR1_SLAY_EVIL, "¼Ù°" },
637 { TR3_SLAY_HUMAN, "¿Í´Ö" },
638 { TR1_SLAY_UNDEAD, "¥¢¥ó¥Ç¥Ã¥É" },
639 { TR1_SLAY_DEMON, "°Ëâ" },
640 { TR1_SLAY_ORC, "¥ª¡¼¥¯" },
641 { TR1_SLAY_TROLL, "¥È¥í¥ë" },
642 { TR1_SLAY_GIANT, "µð¿Í" },
643 { TR1_SLAY_DRAGON, "¥É¥é¥´¥ó" },
644 { TR1_KILL_DRAGON, "*¥É¥é¥´¥ó*" },
646 { TR1_SLAY_ANIMAL, "Animal" },
647 { TR1_SLAY_EVIL, "Evil" },
648 { TR3_SLAY_HUMAN, "Human" },
649 { TR1_SLAY_UNDEAD, "Undead" },
650 { TR1_SLAY_DEMON, "Demon" },
651 { TR1_SLAY_ORC, "Orc" },
652 { TR1_SLAY_TROLL, "Troll" },
653 { TR1_SLAY_GIANT, "Giant" },
654 { TR1_SLAY_DRAGON, "Dragon" },
655 { TR1_KILL_DRAGON, "Xdragon" }
660 * Elemental brands for weapons
662 * Clearly, TR1_IMPACT is a bit out of place here. To simplify
663 * coding, it has been included here along with the elemental
664 * brands. It does seem to fit in with the brands and slaying
665 * more than the miscellaneous section.
667 static flag_desc brand_flags_desc[] =
670 { TR1_BRAND_ACID, "Íϲò" },
671 { TR1_BRAND_ELEC, "ÅÅ·â" },
672 { TR1_BRAND_FIRE, "¾Æ´þ" },
673 { TR1_BRAND_COLD, "Åà·ë" },
674 { TR1_BRAND_POIS, "ÆÇ»¦" },
676 { TR1_FORCE_WEAPON, "ÍýÎÏ" },
677 { TR1_CHAOTIC, "º®ÆÙ" },
678 { TR1_VAMPIRIC, "µÛ·ì" },
679 { TR1_IMPACT, "ÃÏ¿Ì" },
680 { TR1_VORPAL, "ÀÚ¤ìÌ£" },
682 { TR1_BRAND_ACID, "Acid Brand" },
683 { TR1_BRAND_ELEC, "Lightning Brand" },
684 { TR1_BRAND_FIRE, "Flame Tongue" },
685 { TR1_BRAND_COLD, "Frost Brand" },
686 { TR1_BRAND_POIS, "Poisoned" },
688 { TR1_FORCE_WEAPON, "Force" },
689 { TR1_CHAOTIC, "Mark of Chaos" },
690 { TR1_VAMPIRIC, "Vampiric" },
691 { TR1_IMPACT, "Earthquake impact on hit" },
692 { TR1_VORPAL, "Very sharp" },
700 static const flag_desc resist_flags_desc[] =
703 { TR2_RES_ACID, "»À" },
704 { TR2_RES_ELEC, "ÅÅ·â" },
705 { TR2_RES_FIRE, "²Ð±ê" },
706 { TR2_RES_COLD, "Î䵤" },
707 { TR2_RES_POIS, "ÆÇ" },
708 { TR2_RES_FEAR, "¶²ÉÝ"},
709 { TR2_RES_LITE, "Á®¸÷" },
710 { TR2_RES_DARK, "°Å¹õ" },
711 { TR2_RES_BLIND, "ÌÕÌÜ" },
712 { TR2_RES_CONF, "º®Íð" },
713 { TR2_RES_SOUND, "¹ì²»" },
714 { TR2_RES_SHARDS, "ÇËÊÒ" },
715 { TR2_RES_NETHER, "ÃϹö" },
716 { TR2_RES_NEXUS, "°ø²Ìº®Íð" },
717 { TR2_RES_CHAOS, "¥«¥ª¥¹" },
718 { TR2_RES_DISEN, "Îô²½" },
720 { TR2_RES_ACID, "Acid" },
721 { TR2_RES_ELEC, "Lightning" },
722 { TR2_RES_FIRE, "Fire" },
723 { TR2_RES_COLD, "Cold" },
724 { TR2_RES_POIS, "Poison" },
725 { TR2_RES_FEAR, "Fear"},
726 { TR2_RES_LITE, "Light" },
727 { TR2_RES_DARK, "Dark" },
728 { TR2_RES_BLIND, "Blindness" },
729 { TR2_RES_CONF, "Confusion" },
730 { TR2_RES_SOUND, "Sound" },
731 { TR2_RES_SHARDS, "Shards" },
732 { TR2_RES_NETHER, "Nether" },
733 { TR2_RES_NEXUS, "Nexus" },
734 { TR2_RES_CHAOS, "Chaos" },
735 { TR2_RES_DISEN, "Disenchantment" },
740 * Elemental immunities (along with poison)
743 static const flag_desc immune_flags_desc[] =
746 { TR2_IM_ACID, "»À" },
747 { TR2_IM_ELEC, "ÅÅ·â" },
748 { TR2_IM_FIRE, "²Ð±ê" },
749 { TR2_IM_COLD, "Î䵤" },
751 { TR2_IM_ACID, "Acid" },
752 { TR2_IM_ELEC, "Lightning" },
753 { TR2_IM_FIRE, "Fire" },
754 { TR2_IM_COLD, "Cold" },
759 * Sustain stats - these are given their "own" line in the
760 * spoiler file, mainly for simplicity
762 static const flag_desc sustain_flags_desc[] =
765 { TR2_SUST_STR, "ÏÓÎÏ" },
766 { TR2_SUST_INT, "ÃÎǽ" },
767 { TR2_SUST_WIS, "¸¤µ" },
768 { TR2_SUST_DEX, "´ïÍѤµ" },
769 { TR2_SUST_CON, "Âѵ×ÎÏ" },
770 { TR2_SUST_CHR, "Ì¥ÎÏ" },
772 { TR2_SUST_STR, "STR" },
773 { TR2_SUST_INT, "INT" },
774 { TR2_SUST_WIS, "WIS" },
775 { TR2_SUST_DEX, "DEX" },
776 { TR2_SUST_CON, "CON" },
777 { TR2_SUST_CHR, "CHR" },
782 * Miscellaneous magic given by an object's "flags2" field
785 static const flag_desc misc_flags2_desc[] =
788 { TR2_THROW, "ÅêÚ³" },
789 { TR2_REFLECT, "È¿¼Í" },
790 { TR2_FREE_ACT, "ËãáãÃΤ餺" },
791 { TR2_HOLD_LIFE, "À¸Ì¿ÎÏ°Ý»ý" },
793 { TR2_THROW, "Throwing" },
794 { TR2_REFLECT, "Reflection" },
795 { TR2_FREE_ACT, "Free Action" },
796 { TR2_HOLD_LIFE, "Hold Life" },
801 * Miscellaneous magic given by an object's "flags3" field
803 * Note that cursed artifacts and objects with permanent light
804 * are handled "directly" -- see analyze_misc_magic()
807 static const flag_desc misc_flags3_desc[] =
810 { TR3_SH_FIRE, "²Ð±ê¥ª¡¼¥é" },
811 { TR3_SH_ELEC, "Åŷ⥪¡¼¥é" },
812 { TR3_SH_COLD, "Î䵤¥ª¡¼¥é" },
813 { TR3_NO_TELE, "È¿¥Æ¥ì¥Ý¡¼¥È" },
814 { TR3_NO_MAGIC, "È¿ËâË¡" },
815 { TR3_FEATHER, "ÉâÍ·" },
816 { TR3_SEE_INVIS, "²Ä»ëÆ©ÌÀ" },
817 { TR3_TELEPATHY, "¥Æ¥ì¥Ñ¥·¡¼" },
818 { TR3_SLOW_DIGEST, "Ãپò½" },
819 { TR3_REGEN, "µÞ®²óÉü" },
820 { TR3_WARNING, "·Ù¹ð" },
821 /* { TR3_XTRA_MIGHT, "¶¯Îϼͷâ" }, */
822 { TR3_XTRA_SHOTS, "Äɲüͷâ" }, /* always +1? */
823 { TR3_DRAIN_EXP, "·Ð¸³Ã͵ۼý" },
824 { TR3_AGGRAVATE, "È¿´¶" },
825 { TR3_BLESSED, "½ËÊ¡" },
826 { TR3_DEC_MANA, "¾ÃÈñËâÎϸº¾¯" },
828 { TR3_SH_FIRE, "Fiery Aura" },
829 { TR3_SH_ELEC, "Electric Aura" },
830 { TR3_SH_COLD, "Coldly Aura" },
831 { TR3_NO_TELE, "Prevent Teleportation" },
832 { TR3_NO_MAGIC, "Anti-Magic" },
833 { TR3_FEATHER, "Levitation" },
834 { TR3_SEE_INVIS, "See Invisible" },
835 { TR3_TELEPATHY, "ESP" },
836 { TR3_SLOW_DIGEST, "Slow Digestion" },
837 { TR3_REGEN, "Regeneration" },
838 { TR3_WARNING, "Warning" },
839 /* { TR3_XTRA_MIGHT, "Extra Might" }, */
840 { TR3_XTRA_SHOTS, "+1 Extra Shot" }, /* always +1? */
841 { TR3_DRAIN_EXP, "Drains Experience" },
842 { TR3_AGGRAVATE, "Aggravates" },
843 { TR3_BLESSED, "Blessed Blade" },
844 { TR3_DEC_MANA, "Decrease Shouhi Mana" },
850 * A special type used just for deailing with pvals
855 * This will contain a string such as "+2", "-10", etc.
860 * A list of various player traits affected by an object's pval such
861 * as stats, speed, stealth, etc. "Extra attacks" is NOT included in
862 * this list since it will probably be desirable to format its
863 * description differently.
865 * Note that room need only be reserved for the number of stats - 1
866 * since the description "All stats" is used if an object affects all
867 * all stats. Also, room must be reserved for a sentinel NULL pointer.
869 * This will be a list such as ["STR", "DEX", "Stealth", NULL] etc.
871 * This list includes extra attacks, for simplicity.
873 cptr pval_affects[N_ELEMENTS(stat_flags_desc) - 1 +
874 N_ELEMENTS(pval_flags1_desc) + 1];
880 * An "object analysis structure"
882 * It will be filled with descriptive strings detailing an object's
883 * various magical powers. The "ignore X" traits are not noted since
884 * all artifacts ignore "normal" destruction.
889 /* "The Longsword Dragonsmiter (6d4) (+20, +25)" */
890 char description[MAX_NLEN];
892 /* Description of what is affected by an object's pval */
893 pval_info_type pval_info;
895 /* A list of an object's slaying preferences */
896 cptr slays[N_ELEMENTS(slay_flags_desc) + 1];
898 /* A list if an object's elemental brands */
899 cptr brands[N_ELEMENTS(brand_flags_desc) + 1];
901 /* A list of immunities granted by an object */
902 cptr immunities[N_ELEMENTS(immune_flags_desc) + 1];
904 /* A list of resistances granted by an object */
905 cptr resistances[N_ELEMENTS(resist_flags_desc) + 1];
907 /* A list of stats sustained by an object */
908 cptr sustains[N_ELEMENTS(sustain_flags_desc) - 1 + 1];
910 /* A list of various magical qualities an object may have */
911 cptr misc_magic[N_ELEMENTS(misc_flags2_desc) + N_ELEMENTS(misc_flags3_desc)
912 + 1 /* Permanent Light */
914 + 1 /* type of curse */
915 + 1]; /* sentinel NULL */
917 /* A string describing an artifact's activation */
920 /* "Level 20, Rarity 30, 3.0 lbs, 20000 Gold" */
926 * Write out `n' of the character `c' to the spoiler file
928 static void spoiler_out_n_chars(int n, char c)
930 while (--n >= 0) fputc(c, fff);
935 * Write out `n' blank lines to the spoiler file
937 static void spoiler_blanklines(int n)
939 spoiler_out_n_chars(n, '\n');
944 * Write a line to the spoiler file and then "underline" it with hypens
946 static void spoiler_underline(cptr str)
948 fprintf(fff, "%s\n", str);
949 spoiler_out_n_chars(strlen(str), '-');
956 * This function does most of the actual "analysis". Given a set of bit flags
957 * (which will be from one of the flags fields from the object in question),
958 * a "flag description structure", a "description list", and the number of
959 * elements in the "flag description structure", this function sets the
960 * "description list" members to the appropriate descriptions contained in
961 * the "flag description structure".
963 * The possibly updated description pointer is returned.
965 static cptr *spoiler_flag_aux(const u32b art_flags, const flag_desc *flag_ptr,
966 cptr *desc_ptr, const int n_elmnts)
970 for (i = 0; i < n_elmnts; ++i)
972 if (art_flags & flag_ptr[i].flag)
974 *desc_ptr++ = flag_ptr[i].desc;
983 * Acquire a "basic" description "The Cloak of Death [1,+10]"
985 static void analyze_general (object_type *o_ptr, char *desc_ptr)
987 /* Get a "useful" description of the object */
988 object_desc_store(desc_ptr, o_ptr, TRUE, 1);
993 * List "player traits" altered by an artifact's pval. These include stats,
994 * speed, infravision, tunneling, stealth, searching, and extra attacks.
996 static void analyze_pval (object_type *o_ptr, pval_info_type *p_ptr)
998 const u32b all_stats = (TR1_STR | TR1_INT | TR1_WIS |
999 TR1_DEX | TR1_CON | TR1_CHR);
1005 /* If pval == 0, there is nothing to do. */
1008 /* An "empty" pval description indicates that pval == 0 */
1009 p_ptr->pval_desc[0] = '\0';
1013 /* Extract the flags */
1014 object_flags(o_ptr, &f1, &f2, &f3);
1016 affects_list = p_ptr->pval_affects;
1018 /* Create the "+N" string */
1019 sprintf(p_ptr->pval_desc, "%s%d", POSITIZE(o_ptr->pval), o_ptr->pval);
1021 /* First, check to see if the pval affects all stats */
1022 if ((f1 & all_stats) == all_stats)
1025 *affects_list++ = "Á´Ç½ÎÏ";
1027 *affects_list++ = "All stats";
1031 /* Are any stats affected? */
1032 else if (f1 & all_stats)
1034 affects_list = spoiler_flag_aux(f1, stat_flags_desc,
1036 N_ELEMENTS(stat_flags_desc));
1039 /* And now the "rest" */
1040 affects_list = spoiler_flag_aux(f1, pval_flags1_desc,
1042 N_ELEMENTS(pval_flags1_desc));
1044 /* Terminate the description list */
1045 *affects_list = NULL;
1049 /* Note the slaying specialties of a weapon */
1050 static void analyze_slay (object_type *o_ptr, cptr *slay_list)
1054 object_flags(o_ptr, &f1, &f2, &f3);
1056 slay_list = spoiler_flag_aux(f1, slay_flags_desc, slay_list,
1057 N_ELEMENTS(slay_flags_desc));
1059 /* Terminate the description list */
1063 /* Note an object's elemental brands */
1064 static void analyze_brand (object_type *o_ptr, cptr *brand_list)
1068 object_flags(o_ptr, &f1, &f2, &f3);
1070 brand_list = spoiler_flag_aux(f1, brand_flags_desc, brand_list,
1071 N_ELEMENTS(brand_flags_desc));
1073 /* Terminate the description list */
1078 /* Note the resistances granted by an object */
1079 static void analyze_resist (object_type *o_ptr, cptr *resist_list)
1083 object_flags(o_ptr, &f1, &f2, &f3);
1085 resist_list = spoiler_flag_aux(f2, resist_flags_desc,
1086 resist_list, N_ELEMENTS(resist_flags_desc));
1088 /* Terminate the description list */
1089 *resist_list = NULL;
1093 /* Note the immunities granted by an object */
1094 static void analyze_immune (object_type *o_ptr, cptr *immune_list)
1098 object_flags(o_ptr, &f1, &f2, &f3);
1100 immune_list = spoiler_flag_aux(f2, immune_flags_desc,
1101 immune_list, N_ELEMENTS(immune_flags_desc));
1103 /* Terminate the description list */
1104 *immune_list = NULL;
1107 /* Note which stats an object sustains */
1109 static void analyze_sustains (object_type *o_ptr, cptr *sustain_list)
1111 const u32b all_sustains = (TR2_SUST_STR | TR2_SUST_INT | TR2_SUST_WIS |
1112 TR2_SUST_DEX | TR2_SUST_CON | TR2_SUST_CHR);
1116 object_flags(o_ptr, &f1, &f2, &f3);
1118 /* Simplify things if an item sustains all stats */
1119 if ((f2 & all_sustains) == all_sustains)
1122 *sustain_list++ = "Á´Ç½ÎÏ";
1124 *sustain_list++ = "All stats";
1128 /* Should we bother? */
1129 else if ((f2 & all_sustains))
1131 sustain_list = spoiler_flag_aux(f2, sustain_flags_desc,
1133 N_ELEMENTS(sustain_flags_desc));
1136 /* Terminate the description list */
1137 *sustain_list = NULL;
1142 * Note miscellaneous powers bestowed by an artifact such as see invisible,
1143 * free action, permanent light, etc.
1145 static void analyze_misc_magic (object_type *o_ptr, cptr *misc_list)
1149 object_flags(o_ptr, &f1, &f2, &f3);
1151 misc_list = spoiler_flag_aux(f2, misc_flags2_desc, misc_list,
1152 N_ELEMENTS(misc_flags2_desc));
1154 misc_list = spoiler_flag_aux(f3, misc_flags3_desc, misc_list,
1155 N_ELEMENTS(misc_flags3_desc));
1158 * Artifact lights -- large radius light.
1160 if ((o_ptr->tval == TV_LITE) && artifact_p(o_ptr))
1163 *misc_list++ = "±Êµ×¸÷¸»(Ⱦ·Â3)";
1165 *misc_list++ = "Permanent Light(3)";
1170 * Glowing artifacts -- small radius light.
1172 if (f3 & (TR3_LITE))
1175 *misc_list++ = "±Êµ×¸÷¸»(Ⱦ·Â1)";
1177 *misc_list++ = "Permanent Light(1)";
1182 * Handle cursed objects here to avoid redundancies such as noting
1183 * that a permanently cursed object is heavily cursed as well as
1184 * being "lightly cursed".
1187 /* if (cursed_p(o_ptr)) */
1190 if (f3 & TR3_TY_CURSE)
1193 *misc_list++ = "ÂÀ¸Å¤Î±åÇ°";
1195 *misc_list++ = "Ancient Curse";
1198 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1201 *misc_list++ = "±Ê±ó¤Î¼ö¤¤";
1203 *misc_list++ = "Permanently Cursed";
1206 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1209 *misc_list++ = "¶¯ÎϤʼö¤¤";
1211 *misc_list++ = "Heavily Cursed";
1215 else if (o_ptr->curse_flags & TRC_CURSED)
1218 *misc_list++ = "¼ö¤¤";
1220 *misc_list++ = "Cursed";
1225 /* Terminate the description list */
1233 * Determine the minimum depth an artifact can appear, its rarity, its weight,
1234 * and its value in gold pieces
1236 static void analyze_misc (object_type *o_ptr, char *misc_desc)
1238 artifact_type *a_ptr = &a_info[o_ptr->name1];
1241 sprintf(misc_desc, "¥ì¥Ù¥ë %u, ´õ¾¯ÅÙ %u, %d.%d kg, ¡ð%ld",
1242 a_ptr->level, a_ptr->rarity,
1243 lbtokg1(a_ptr->weight), lbtokg2(a_ptr->weight), a_ptr->cost);
1245 sprintf(misc_desc, "Level %u, Rarity %u, %d.%d lbs, %ld Gold",
1246 a_ptr->level, a_ptr->rarity,
1247 a_ptr->weight / 10, a_ptr->weight % 10, a_ptr->cost);
1253 * Fill in an object description structure for a given object
1255 static void object_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
1257 analyze_general(o_ptr, desc_ptr->description);
1259 analyze_pval(o_ptr, &desc_ptr->pval_info);
1261 analyze_brand(o_ptr, desc_ptr->brands);
1263 analyze_slay(o_ptr, desc_ptr->slays);
1265 analyze_immune(o_ptr, desc_ptr->immunities);
1267 analyze_resist(o_ptr, desc_ptr->resistances);
1269 analyze_sustains(o_ptr, desc_ptr->sustains);
1271 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
1273 analyze_misc(o_ptr, desc_ptr->misc_desc);
1275 desc_ptr->activation = item_activation(o_ptr);
1279 static void print_header(void)
1283 #ifndef FAKE_VERSION
1284 sprintf(buf, "Artifact Spoilers for Angband Version %d.%d.%d",
1285 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
1286 spoiler_underline(buf);
1287 #else /* FAKE_VERSION */
1288 sprintf(buf, "Artifact Spoilers for Hengband Version %d.%d.%d",
1289 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1290 spoiler_underline(buf);
1291 #endif /* FAKE_VERSION */
1296 * This is somewhat ugly.
1298 * Given a header ("Resist", e.g.), a list ("Fire", "Cold", Acid", e.g.),
1299 * and a separator character (',', e.g.), write the list to the spoiler file
1300 * in a "nice" format, such as:
1302 * Resist Fire, Cold, Acid
1304 * That was a simple example, but when the list is long, a line wrap
1305 * should occur, and this should induce a new level of indention if
1306 * a list is being spread across lines. So for example, Bladeturner's
1307 * list of resistances should look something like this
1309 * Resist Acid, Lightning, Fire, Cold, Poison, Light, Dark, Blindness,
1310 * Confusion, Sound, Shards, Nether, Nexus, Chaos, Disenchantment
1312 * However, the code distinguishes between a single list of many items vs.
1313 * many lists. (The separator is used to make this determination.) A single
1314 * list of many items will not cause line wrapping (since there is no
1315 * apparent reason to do so). So the lists of Ulmo's miscellaneous traits
1316 * might look like this:
1318 * Free Action; Hold Life; See Invisible; Slow Digestion; Regeneration
1321 * So comparing the two, "Regeneration" has no trailing separator and
1322 * "Blessed Blade" was not indented. (Also, Ulmo's lists have no headers,
1323 * but that's not relevant to line wrapping and indention.)
1326 /* ITEM_SEP separates items within a list */
1327 #define ITEM_SEP ','
1330 /* LIST_SEP separates lists */
1332 #define LIST_SEP ','
1334 #define LIST_SEP ';'
1337 static void spoiler_outlist(cptr header, cptr *list, char separator)
1339 int line_len, buf_len;
1340 char line[MAX_LINE_LEN+1], buf[80];
1342 /* Ignore an empty list */
1343 if (*list == NULL) return;
1345 /* This function always indents */
1346 strcpy(line, INDENT1);
1348 /* Create header (if one was given) */
1349 if (header && (header[0]))
1351 strcat(line, header);
1355 line_len = strlen(line);
1357 /* Now begin the tedious task */
1360 /* Copy the current item to a buffer */
1363 /* Note the buffer's length */
1364 buf_len = strlen(buf);
1367 * If there is an item following this one, pad with separator and
1368 * a space and adjust the buffer length
1373 sprintf(buf + buf_len, "%c ", separator);
1378 * If the buffer will fit on the current line, just append the
1379 * buffer to the line and adjust the line length accordingly.
1382 if (line_len + buf_len <= MAX_LINE_LEN)
1385 line_len += buf_len;
1388 /* Apply line wrapping and indention semantics described above */
1392 * Don't print a trailing list separator but do print a trailing
1395 if (line_len > 1 && line[line_len - 1] == ' '
1396 && line[line_len - 2] == LIST_SEP)
1398 /* Ignore space and separator */
1399 line[line_len - 2] = '\0';
1401 /* Write to spoiler file */
1402 fprintf(fff, "%s\n", line);
1404 /* Begin new line at primary indention level */
1405 sprintf(line, "%s%s", INDENT1, buf);
1410 /* Write to spoiler file */
1411 fprintf(fff, "%s\n", line);
1413 /* Begin new line at secondary indention level */
1414 sprintf(line, "%s%s", INDENT2, buf);
1417 line_len = strlen(line);
1420 /* Advance, with break */
1421 if (!*++list) break;
1424 /* Write what's left to the spoiler file */
1425 fprintf(fff, "%s\n", line);
1429 /* Create a spoiler file entry for an artifact */
1431 static void spoiler_print_art(obj_desc_list *art_ptr)
1433 pval_info_type *pval_ptr = &art_ptr->pval_info;
1437 /* Don't indent the first line */
1438 fprintf(fff, "%s\n", art_ptr->description);
1440 /* An "empty" pval description indicates that the pval affects nothing */
1441 if (pval_ptr->pval_desc[0])
1443 /* Mention the effects of pval */
1445 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
1447 sprintf(buf, "%s to", pval_ptr->pval_desc);
1449 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
1452 /* Now deal with the description lists */
1455 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
1457 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
1459 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
1461 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
1463 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
1465 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
1467 spoiler_outlist("", art_ptr->brands, LIST_SEP);
1469 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
1471 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
1473 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
1475 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
1478 /* Write out the possible activation at the primary indention level */
1479 if (art_ptr->activation)
1482 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
1484 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
1488 /* End with the miscellaneous facts */
1489 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
1494 * Hack -- Create a "forged" artifact
1496 static bool make_fake_artifact(object_type *o_ptr, int name1)
1500 artifact_type *a_ptr = &a_info[name1];
1503 /* Ignore "empty" artifacts */
1504 if (!a_ptr->name) return FALSE;
1506 /* Acquire the "kind" index */
1507 i = lookup_kind(a_ptr->tval, a_ptr->sval);
1510 if (!i) return (FALSE);
1512 /* Create the artifact */
1513 object_prep(o_ptr, i);
1516 o_ptr->name1 = name1;
1518 /* Extract the fields */
1519 o_ptr->pval = a_ptr->pval;
1520 o_ptr->ac = a_ptr->ac;
1521 o_ptr->dd = a_ptr->dd;
1522 o_ptr->ds = a_ptr->ds;
1523 o_ptr->to_a = a_ptr->to_a;
1524 o_ptr->to_h = a_ptr->to_h;
1525 o_ptr->to_d = a_ptr->to_d;
1526 o_ptr->weight = a_ptr->weight;
1534 * Create a spoiler file for artifacts
1536 static void spoil_artifact(cptr fname)
1543 obj_desc_list artifact;
1548 /* Build the filename */
1549 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
1551 /* File type is "TEXT" */
1552 FILE_TYPE(FILE_TYPE_TEXT);
1555 fff = my_fopen(buf, "w");
1560 msg_print("Cannot create spoiler file.");
1564 /* Dump the header */
1567 /* List the artifacts by tval */
1568 for (i = 0; group_artifact[i].tval; i++)
1570 /* Write out the group title */
1571 if (group_artifact[i].name)
1573 spoiler_blanklines(2);
1574 spoiler_underline(group_artifact[i].name);
1575 spoiler_blanklines(1);
1578 /* Now search through all of the artifacts */
1579 for (j = 1; j < max_a_idx; ++j)
1581 artifact_type *a_ptr = &a_info[j];
1583 /* We only want objects in the current group */
1584 if (a_ptr->tval != group_artifact[i].tval) continue;
1586 /* Get local object */
1589 /* Wipe the object */
1592 /* Attempt to "forge" the artifact */
1593 if (!make_fake_artifact(q_ptr, j)) continue;
1595 /* Analyze the artifact */
1596 object_analyze(q_ptr, &artifact);
1598 /* Write out the artifact description to the spoiler file */
1599 spoiler_print_art(&artifact);
1603 /* Check for errors */
1604 if (ferror(fff) || my_fclose(fff))
1606 msg_print("Cannot close spoiler file.");
1611 msg_print("Successfully created a spoiler file.");
1619 * Create a spoiler file for monsters -BEN-
1621 static void spoil_mon_desc(cptr fname)
1638 /* Build the filename */
1639 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
1641 /* File type is "TEXT" */
1642 FILE_TYPE(FILE_TYPE_TEXT);
1645 fff = my_fopen(buf, "w");
1650 msg_print("Cannot create spoiler file.");
1654 /* Allocate the "who" array */
1655 C_MAKE(who, max_r_idx, s16b);
1657 /* Dump the header */
1659 #ifndef FAKE_VERSION
1660 fprintf(fff, "Monster Spoilers for Angband Version %d.%d.%d\n",
1661 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
1662 fprintf(fff, "------------------------------------------\n\n");
1664 fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1665 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1666 fprintf(fff, "------------------------------------------\n\n");
1669 /* Dump the header */
1670 fprintf(fff, " %-38.38s%4s%4s%4s%7s%5s %11.11s\n",
1671 "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
1672 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1673 "--------", "---", "---", "---", "--", "--", "-----------");
1676 /* Scan the monsters */
1677 for (i = 1; i < max_r_idx; i++)
1679 monster_race *r_ptr = &r_info[i];
1681 /* Use that monster */
1682 if (r_ptr->name) who[n++] = i;
1685 /* Select the sort method */
1686 ang_sort_comp = ang_sort_comp_hook;
1687 ang_sort_swap = ang_sort_swap_hook;
1689 /* Sort the array by dungeon depth of monsters */
1690 ang_sort(who, &why, n);
1693 for (i = 0; i < n; i++)
1695 monster_race *r_ptr = &r_info[who[i]];
1697 cptr name = (r_name + r_ptr->name);
1698 if (r_ptr->flags7 & (RF7_KAGE)) continue;
1700 /* Get the "name" */
1701 /* if (r_ptr->flags1 & (RF1_QUESTOR)) */
1704 sprintf(nam, "[Q] %s", name);
1706 else if (r_ptr->flags1 & (RF1_UNIQUE))
1708 sprintf(nam, "[U] %s", name);
1713 sprintf(nam, " %s", name);
1715 sprintf(nam, "The %s", name);
1721 sprintf(lev, "%d", r_ptr->level);
1724 sprintf(rar, "%d", r_ptr->rarity);
1727 if (r_ptr->speed >= 110)
1729 sprintf(spd, "+%d", (r_ptr->speed - 110));
1733 sprintf(spd, "-%d", (110 - r_ptr->speed));
1737 sprintf(ac, "%d", r_ptr->ac);
1740 if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
1742 sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
1746 sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
1751 sprintf(exp, "%ld", (long)(r_ptr->mexp));
1753 /* Hack -- use visual instead */
1754 sprintf(exp, "%s '%c'", attr_to_text(r_ptr->d_attr), r_ptr->d_char);
1757 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1758 nam, lev, rar, spd, hp, ac, exp);
1765 /* Free the "who" array */
1766 C_KILL(who, max_r_idx, s16b);
1768 /* Check for errors */
1769 if (ferror(fff) || my_fclose(fff))
1771 msg_print("Cannot close spoiler file.");
1776 msg_print("Successfully created a spoiler file.");
1783 * Monster spoilers by: smchorse@ringer.cs.utsa.edu (Shawn McHorse)
1785 * Primarily based on code already in mon-desc.c, mostly by -BEN-
1791 * Buffer text to the given file. (-SHAWN-)
1792 * This is basically c_roff() from mon-desc.c with a few changes.
1794 static void spoil_out(cptr str)
1799 static char roff_buf[256];
1804 /* Current pointer into line roff_buf */
1805 static char *roff_p = roff_buf;
1807 /* Last space saved into roff_buf */
1808 static char *roff_s = NULL;
1810 /* Special handling for "new sequence" */
1813 if (roff_p != roff_buf) roff_p--;
1814 while (*roff_p == ' ' && roff_p != roff_buf) roff_p--;
1815 if (roff_p == roff_buf) fprintf(fff, "\n");
1818 *(roff_p + 1) = '\0';
1819 fprintf(fff, "%s\n\n", roff_buf);
1827 /* Scan the given string, character at a time */
1832 int k_flag = iskanji((unsigned char)(*str));
1835 int wrap = (ch == '\n');
1838 if (!isprint(ch) && !k_flag && !iskanji2) ch = ' ';
1839 if(k_flag && !iskanji2)iskanji2=1;else iskanji2=0;
1841 if (!isprint(ch)) ch = ' ';
1845 if ( roff_p >= roff_buf+( (k_flag) ? 74 : 75) ) wrap=1;
1846 if ((ch == ' ') && (roff_p + 2 >= roff_buf + ((k_flag) ? 74 : 75))) wrap = 1;
1848 if (roff_p >= roff_buf + 75) wrap = 1;
1849 if ((ch == ' ') && (roff_p + 2 >= roff_buf + 75)) wrap = 1;
1853 /* Handle line-wrap */
1861 if (roff_s && (ch != ' '))
1869 fprintf(fff, "%s\n", roff_buf);
1873 if(cbak != ' ') *roff_p++ = cbak;
1875 while (*r) *roff_p++ = *r++;
1879 if ((roff_p > roff_buf) || (ch != ' '))
1883 if (ch == ' ' || ch == '(' ) roff_s = roff_p;
1887 strncmp(str, "¡£", 2) != 0 &&
1888 strncmp(str, "¡¢", 2) != 0 &&
1889 strncmp(str, "¥£", 2) != 0 &&
1890 strncmp(str, "¡¼", 2) != 0) roff_s = roff_p;
1893 if (ch == ' ') roff_s = roff_p;
1904 * Hook function used in spoil_mon_info()
1906 void roff_func(byte attr, cptr str)
1913 * Create a spoiler file for monsters (-SHAWN-)
1915 static void spoil_mon_info(cptr fname)
1918 int msex, vn, i, j, k, l, n=0;
1919 bool breath, magic, sin;
1922 u32b flags1, flags2, flags3, flags4, flags5, flags6, flags7;
1931 /* Build the filename */
1932 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
1934 /* File type is "TEXT" */
1935 FILE_TYPE(FILE_TYPE_TEXT);
1938 fff = my_fopen(buf, "w");
1943 msg_print("Cannot create spoiler file.");
1948 /* Dump the header */
1949 #ifndef FAKE_VERSION
1950 sprintf(buf, "Monster Spoilers for Angband Version %d.%d.%d\n",
1951 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
1953 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1954 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1958 spoil_out("------------------------------------------\n\n");
1960 /* Allocate the "who" array */
1961 C_MAKE(who, max_r_idx, s16b);
1963 /* Scan the monsters */
1964 for (i = 1; i < max_r_idx; i++)
1966 monster_race *r_ptr = &r_info[i];
1968 /* Use that monster */
1969 if (r_ptr->name) who[n++] = i;
1972 /* Select the sort method */
1973 ang_sort_comp = ang_sort_comp_hook;
1974 ang_sort_swap = ang_sort_swap_hook;
1976 /* Sort the array by dungeon depth of monsters */
1977 ang_sort(who, &why, n);
1981 * List all monsters in order
1983 for (l = 0; l < n; l++)
1985 monster_race *r_ptr = &r_info[who[l]];
1987 /* Extract the flags */
1988 flags1 = r_ptr->flags1;
1989 flags2 = r_ptr->flags2;
1990 flags3 = r_ptr->flags3;
1991 flags4 = r_ptr->flags4;
1992 flags5 = r_ptr->flags5;
1993 flags6 = r_ptr->flags6;
1994 flags7 = r_ptr->flags7;
1998 /* Extract a gender (if applicable) */
1999 if (flags1 & (RF1_FEMALE)) msex = 2;
2000 else if (flags1 & (RF1_MALE)) msex = 1;
2005 if (flags1 & (RF1_QUESTOR))
2009 else if (flags1 & (RF1_UNIQUE))
2022 sprintf(buf, "%s/%s (", (r_name + r_ptr->name),(r_name+r_ptr->E_name)); /* ---)--- */
2024 sprintf(buf, "%s (", (r_name + r_ptr->name)); /* ---)--- */
2030 spoil_out(attr_to_text(r_ptr->d_attr));
2033 sprintf(buf, " '%c')\n", r_ptr->d_char);
2038 sprintf(buf, "=== ");
2042 sprintf(buf, "Num:%d ", n);
2046 sprintf(buf, "Lev:%d ", r_ptr->level);
2050 sprintf(buf, "Rar:%d ", r_ptr->rarity);
2054 if (r_ptr->speed >= 110)
2056 sprintf(buf, "Spd:+%d ", (r_ptr->speed - 110));
2060 sprintf(buf, "Spd:-%d ", (110 - r_ptr->speed));
2065 if ((flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
2067 sprintf(buf, "Hp:%d ", r_ptr->hdice * r_ptr->hside);
2071 sprintf(buf, "Hp:%dd%d ", r_ptr->hdice, r_ptr->hside);
2076 sprintf(buf, "Ac:%d ", r_ptr->ac);
2080 sprintf(buf, "Exp:%ld\n", (long)(r_ptr->mexp));
2083 /* Reuse the code of monster recall. */
2084 output_monster_spoiler(who[l], roff_func);
2089 /* Free the "who" array */
2090 C_KILL(who, max_r_idx, s16b);
2092 /* Check for errors */
2093 if (ferror(fff) || my_fclose(fff))
2095 msg_print("Cannot close spoiler file.");
2099 msg_print("Successfully created a spoiler file.");
2107 extern void do_cmd_spoilers(void);
2110 * Create Spoiler files -BEN-
2112 void do_cmd_spoilers(void)
2117 /* Save the screen */
2132 prt("Create a spoiler file.", 2, 0);
2134 /* Prompt for a file */
2135 prt("(1) Brief Object Info (obj-desc.spo)", 5, 5);
2136 prt("(2) Brief Artifact Info (artifact.spo)", 6, 5);
2137 prt("(3) Brief Monster Info (mon-desc.spo)", 7, 5);
2138 prt("(4) Full Monster Info (mon-info.spo)", 8, 5);
2142 prt("¥³¥Þ¥ó¥É:", 18, 0);
2144 prt("Command: ", 12, 0);
2160 spoil_obj_desc("obj-desc.spo");
2166 spoil_artifact("artifact.spo");
2172 spoil_mon_desc("mon-desc.spo");
2178 spoil_mon_info("mon-info.spo");
2187 /* Flush messages */
2196 /* Restore the screen */
2201 * Fill in an object description structure for a given object
2203 static void random_artifact_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
2205 analyze_general(o_ptr, desc_ptr->description);
2206 analyze_pval(o_ptr, &desc_ptr->pval_info);
2207 analyze_brand(o_ptr, desc_ptr->brands);
2208 analyze_slay(o_ptr, desc_ptr->slays);
2209 analyze_immune(o_ptr, desc_ptr->immunities);
2210 analyze_resist(o_ptr, desc_ptr->resistances);
2211 analyze_sustains(o_ptr, desc_ptr->sustains);
2212 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
2213 desc_ptr->activation = item_activation(o_ptr);
2215 sprintf(desc_ptr->misc_desc, "½Å¤µ %d.%d kg",
2216 lbtokg1(o_ptr->weight), lbtokg2(o_ptr->weight));
2218 sprintf(desc_ptr->misc_desc, "Weight %d.%d lbs",
2219 o_ptr->weight / 10, o_ptr->weight % 10);
2223 /* Create a spoiler file entry for an artifact */
2225 static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
2227 pval_info_type *pval_ptr = &art_ptr->pval_info;
2231 /* Don't indent the first line */
2232 fprintf(fff, "%s\n", art_ptr->description);
2235 if (!(o_ptr->ident & (IDENT_MENTAL)))
2238 fprintf(fff, "%sÉÔÌÀ\n",INDENT1);
2240 fprintf(fff, "%sUnknown\n",INDENT1);
2244 /* An "empty" pval description indicates that the pval affects nothing */
2245 if (pval_ptr->pval_desc[0])
2247 /* Mention the effects of pval */
2249 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
2251 sprintf(buf, "%s to", pval_ptr->pval_desc);
2253 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
2256 /* Now deal with the description lists */
2259 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
2260 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
2261 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
2262 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
2263 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
2265 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
2266 spoiler_outlist("", art_ptr->brands, LIST_SEP);
2267 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
2268 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
2269 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
2271 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
2273 /* Write out the possible activation at the primary indention level */
2274 if (art_ptr->activation)
2277 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
2279 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
2283 /* End with the miscellaneous facts */
2284 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
2287 /* Create a part of file for random artifacts */
2289 static void spoil_random_artifact_aux(object_type *o_ptr, int i)
2291 obj_desc_list artifact;
2293 if (!object_known_p(o_ptr) || !o_ptr->art_name
2294 || o_ptr->tval != group_artifact[i].tval)
2297 /* Analyze the artifact */
2298 random_artifact_analyze(o_ptr, &artifact);
2300 /* Write out the artifact description to the spoiler file */
2301 spoiler_print_randart(o_ptr, &artifact);
2305 * Create a list file for random artifacts
2307 void spoil_random_artifact(cptr fname)
2320 /* Build the filename */
2321 path_build(buf, 1024, ANGBAND_DIR_USER, fname);
2323 /* File type is "TEXT" */
2324 FILE_TYPE(FILE_TYPE_TEXT);
2327 fff = my_fopen(buf, "w");
2332 msg_print("Cannot create list file.");
2336 /* Dump the header */
2337 sprintf(buf, "Random artifacts list.\r");
2338 spoiler_underline(buf);
2340 /* List the artifacts by tval */
2341 for (j = 0; group_artifact[j].tval; j++)
2343 /* random artifacts wielding */
2344 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2346 q_ptr = &inventory[i];
2347 spoil_random_artifact_aux(q_ptr, j);
2350 /* random artifacts in inventory */
2351 for (i = 0; i < INVEN_PACK; i++)
2353 q_ptr = &inventory[i];
2354 spoil_random_artifact_aux(q_ptr, j);
2357 /* random artifacts in home */
2358 st_ptr = &town[1].store[STORE_HOME];
2359 for (i = 0; i < st_ptr->stock_num; i++)
2361 q_ptr = &st_ptr->stock[i];
2362 spoil_random_artifact_aux(q_ptr, j);
2365 /* random artifacts in museum */
2366 st_ptr = &town[1].store[STORE_MUSEUM];
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);
2374 /* Check for errors */
2375 if (ferror(fff) || my_fclose(fff))
2377 msg_print("Cannot close list file.");
2385 msg_print("Successfully created a list file.");
2392 #endif /* MACINTOSH */