4 * Copyright (c) 1997 Ben Harrison, and others
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spoiler generation -BEN- */
20 * The spoiler file being created
22 static FILE *fff = NULL;
27 * Extract a textual representation of an attribute
29 static cptr attr_to_text(monster_race *r_ptr)
32 if (r_ptr->flags1 & RF1_ATTR_CLEAR) return "Æ©ÌÀ¤Ê";
33 if (r_ptr->flags1 & RF1_ATTR_MULTI) return "Ëü¿§¤Î";
34 if (r_ptr->flags1 & RF1_ATTR_SEMIRAND) return "½à¥é¥ó¥À¥à¤Ê";
36 if (r_ptr->flags1 & RF1_ATTR_CLEAR) return "Clear";
37 if (r_ptr->flags1 & RF1_ATTR_MULTI) return "Multi";
38 if (r_ptr->flags1 & RF1_ATTR_SEMIRAND) return "S.Rand";
41 switch (r_ptr->d_attr)
44 case TERM_DARK: return "XXX¤¤";
45 case TERM_WHITE: return "Çò¤¤";
46 case TERM_SLATE: return "Àij¥¿§¤Î";
47 case TERM_ORANGE: return "¥ª¥ì¥ó¥¸¤Î";
48 case TERM_RED: return "ÀÖ¤¤";
49 case TERM_GREEN: return "ÎФÎ";
50 case TERM_BLUE: return "ÀĤ¤";
51 case TERM_UMBER: return "àèàῧ¤Î";
52 case TERM_L_DARK: return "³¥¿§¤Î";
53 case TERM_L_WHITE: return "ÌÀÀij¥¿§¤Î";
54 case TERM_VIOLET: return "»ç¤Î";
55 case TERM_YELLOW: return "²«¿§¤¤";
56 case TERM_L_RED: return "ÌÀ¤¤ÀÖ¤Î";
57 case TERM_L_GREEN: return "ÌÀ¤¤ÎФÎ";
58 case TERM_L_BLUE: return "ÌÀ¤¤ÀĤÎ";
59 case TERM_L_UMBER: return "ÌÀ¤¤àèàῧ¤Î";
61 case TERM_DARK: return "xxx";
62 case TERM_WHITE: return "White";
63 case TERM_SLATE: return "Slate";
64 case TERM_ORANGE: return "Orange";
65 case TERM_RED: return "Red";
66 case TERM_GREEN: return "Green";
67 case TERM_BLUE: return "Blue";
68 case TERM_UMBER: return "Umber";
69 case TERM_L_DARK: return "L.Dark";
70 case TERM_L_WHITE: return "L.Slate";
71 case TERM_VIOLET: return "Violet";
72 case TERM_YELLOW: return "Yellow";
73 case TERM_L_RED: return "L.Red";
74 case TERM_L_GREEN: return "L.Green";
75 case TERM_L_BLUE: return "L.Blue";
76 case TERM_L_UMBER: return "L.Umber";
102 * Item Spoilers by: benh@phial.com (Ben Harrison)
107 * The basic items categorized by type
109 static grouper group_item[] =
112 { TV_SHOT, "¼Í·âʪ" },
127 { TV_DIGGING, "Éð´ï" },
129 { TV_DIGGING, "Weapons" },
132 { TV_POLEARM, NULL },
137 { TV_SOFT_ARMOR, "Ëɶñ (ÂÎ)" },
139 { TV_SOFT_ARMOR, "Armour (Body)" },
142 { TV_HARD_ARMOR, NULL },
143 { TV_DRAG_ARMOR, NULL },
146 { TV_BOOTS, "Ëɶñ (¤½¤Î¾)" },
148 { TV_BOOTS, "Armour (Misc)" },
159 { TV_AMULET, "¥¢¥ß¥å¥ì¥Ã¥È" },
162 { TV_LITE, "Light Sources" },
163 { TV_AMULET, "Amulets" },
164 { TV_RING, "Rings" },
169 { TV_WAND, "ËâË¡ËÀ" },
170 { TV_ROD, "¥í¥Ã¥É" },
172 { TV_STAFF, "Staffs" },
173 { TV_WAND, "Wands" },
178 { TV_SCROLL, "´¬Êª" },
182 { TV_SCROLL, "Scrolls" },
183 { TV_POTION, "Potions" },
188 { TV_LIFE_BOOK, "ËâË¡½ñ (À¸Ì¿)" },
189 { TV_SORCERY_BOOK, "ËâË¡½ñ (Àç½Ñ)" },
190 { TV_NATURE_BOOK, "ËâË¡½ñ (¼«Á³)" },
191 { TV_CHAOS_BOOK, "ËâË¡½ñ (¥«¥ª¥¹)" },
192 { TV_DEATH_BOOK, "ËâË¡½ñ (°Å¹õ)" },
193 { TV_TRUMP_BOOK, "ËâË¡½ñ (¥È¥é¥ó¥×)" },
194 { TV_ARCANE_BOOK, "ËâË¡½ñ (Èë½Ñ)" },
195 { TV_CRAFT_BOOK, "ËâË¡½ñ (¾¢)" },
196 { TV_DAEMON_BOOK, "ËâË¡½ñ (°Ëâ)" },
197 { TV_CRUSADE_BOOK, "ËâË¡½ñ (Ç˼Ù)" },
198 { TV_MUSIC_BOOK, "²Î½¸" },
199 { TV_HISSATSU_BOOK, "Éð·Ý¤Î½ñ" },
200 { TV_HEX_BOOK, "ËâË¡½ñ (¼ö½Ñ)" },
202 { TV_LIFE_BOOK, "Books (Life)" },
203 { TV_SORCERY_BOOK, "Books (Sorcery)" },
204 { TV_NATURE_BOOK, "Books (Nature)" },
205 { TV_CHAOS_BOOK, "Books (Chaos)" },
206 { TV_DEATH_BOOK, "Books (Death)" },
207 { TV_TRUMP_BOOK, "Books (Trump)" },
208 { TV_ARCANE_BOOK, "Books (Arcane)" },
209 { TV_CRAFT_BOOK, "Books (Craft)" },
210 { TV_DAEMON_BOOK, "Books (Daemon)" },
211 { TV_CRUSADE_BOOK, "Books (Crusade)" },
212 { TV_MUSIC_BOOK, "Song Books" },
213 { TV_HISSATSU_BOOK, "Books (Kendo)" },
214 { TV_HEX_BOOK, "Books (Hex)" },
219 { TV_CAPTURE, "¥¥ã¥×¥Á¥ã¡¼¡¦¥Ü¡¼¥ë" },
220 { TV_CARD, "¥¨¥¯¥¹¥×¥ì¥¹¥«¡¼¥É" },
222 { TV_WHISTLE, "Whistle" },
223 { TV_CAPTURE, "Capture Ball" },
224 { TV_CARD, "Express Card" },
230 { TV_CHEST, "Chests" },
234 { TV_FIGURINE, "¿Í·Á" },
236 { TV_CORPSE, "»àÂÎ" },
238 { TV_FIGURINE, "Magical Figurines" },
239 { TV_STATUE, "Statues" },
240 { TV_CORPSE, "Corpses" },
244 { TV_SKELETON, "¤½¤Î¾" },
246 { TV_SKELETON, "Misc" },
253 { TV_PARCHMENT, NULL },
262 static void kind_info(char *buf, char *dam, char *wgt, int *lev, s32b *val, int k)
268 /* Get local object */
271 /* Prepare a fake item */
272 object_prep(q_ptr, k);
275 q_ptr->ident |= (IDENT_KNOWN);
285 (*lev) = k_info[q_ptr->k_idx].level;
288 (*val) = object_value(q_ptr);
292 if (!buf || !dam || !wgt) return;
295 /* Description (too brief) */
296 object_desc(buf, q_ptr, (OD_NAME_ONLY | OD_STORE));
316 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
326 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
341 sprintf(dam, "%d", q_ptr->ac);
348 sprintf(wgt, "%3d.%d", q_ptr->weight / 10, q_ptr->weight % 10);
353 * Create a spoiler file for items
355 static void spoil_obj_desc(cptr fname)
357 int i, k, s, t, n = 0, group_start = 0;
367 /* Build the filename */
368 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
370 /* File type is "TEXT" */
371 FILE_TYPE(FILE_TYPE_TEXT);
374 fff = my_fopen(buf, "w");
379 msg_print("Cannot create spoiler file.");
385 fprintf(fff, "Spoiler File -- Basic Items (Hengband %d.%d.%d)\n\n\n",
386 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
389 fprintf(fff, "%-45s %8s%7s%5s%9s\n",
390 "Description", "Dam/AC", "Wgt", "Lev", "Cost");
391 fprintf(fff, "%-45s %8s%7s%5s%9s\n",
392 "----------------------------------------",
393 "------", "---", "---", "----");
395 /* List the groups */
396 for (i = 0; TRUE; i++)
398 /* Write out the group title */
399 if (group_item[i].name)
403 /* Hack -- bubble-sort by cost and then level */
404 for (s = 0; s < n - 1; s++)
406 for (t = 0; t < n - 1; t++)
417 kind_info(NULL, NULL, NULL, &e1, &t1, who[i1]);
418 kind_info(NULL, NULL, NULL, &e2, &t2, who[i2]);
420 if ((t1 > t2) || ((t1 == t2) && (e1 > e2)))
429 fprintf(fff, "\n\n%s\n\n", group_item[group_start].name);
431 /* Spoil each item */
432 for (s = 0; s < n; s++)
437 /* Describe the kind */
438 kind_info(buf, dam, wgt, &e, &v, who[s]);
441 fprintf(fff, " %-45s%8s%7s%5d%9ld\n",
442 buf, dam, wgt, e, (long)(v));
445 /* Start a new set */
450 if (!group_item[i].tval) break;
452 /* Start a new set */
456 /* Acquire legal item types */
457 for (k = 1; k < max_k_idx; k++)
459 object_kind *k_ptr = &k_info[k];
461 /* Skip wrong tval's */
462 if (k_ptr->tval != group_item[i].tval) continue;
464 /* Hack -- Skip instant-artifacts */
465 if (k_ptr->gen_flags & (TRG_INSTA_ART)) continue;
473 /* Check for errors */
474 if (ferror(fff) || my_fclose(fff))
476 msg_print("Cannot close spoiler file.");
481 msg_print("Successfully created a spoiler file.");
486 * Artifact Spoilers by: randy@PICARD.tamu.edu (Randy Hutson)
491 * Returns a "+" string if a number is non-negative and an empty
494 #define POSITIZE(v) (((v) >= 0) ? "+" : "")
497 * These are used to format the artifact spoiler file. INDENT1 is used
498 * to indent all but the first line of an artifact spoiler. INDENT2 is
499 * used when a line "wraps". (Bladeturner's resistances cause this.)
505 * MAX_LINE_LEN specifies when a line should wrap.
507 #define MAX_LINE_LEN 75
510 * Given an array, determine how many elements are in the array
512 #define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))
515 * The artifacts categorized by type
517 static grouper group_artifact[] =
520 { TV_SWORD, "Åá·õ" },
521 { TV_POLEARM, "Áä/Éà" },
522 { TV_HAFTED, "Æß´ï" },
523 { TV_DIGGING, "¥·¥ã¥Ù¥ë/¤Ä¤ë¤Ï¤·" },
524 { TV_BOW, "Èô¤ÓÆ»¶ñ" },
528 { TV_SOFT_ARMOR, "³»" },
529 { TV_HARD_ARMOR, NULL },
530 { TV_DRAG_ARMOR, NULL },
532 { TV_CLOAK, "¥¯¥í¡¼¥¯" },
535 { TV_HELM, "³õ/´§" },
537 { TV_GLOVES, "äƼê" },
541 { TV_AMULET, "¥¢¥ß¥å¥ì¥Ã¥È" },
544 { TV_SWORD, "Edged Weapons" },
545 { TV_POLEARM, "Polearms" },
546 { TV_HAFTED, "Hafted Weapons" },
547 { TV_DIGGING, "Shovels/Picks" },
549 { TV_ARROW, "Ammo" },
552 { TV_SOFT_ARMOR, "Body Armor" },
553 { TV_HARD_ARMOR, NULL },
554 { TV_DRAG_ARMOR, NULL },
556 { TV_CLOAK, "Cloaks" },
557 { TV_SHIELD, "Shields" },
559 { TV_HELM, "Helms/Crowns" },
561 { TV_GLOVES, "Gloves" },
562 { TV_BOOTS, "Boots" },
564 { TV_LITE, "Light Sources" },
565 { TV_AMULET, "Amulets" },
566 { TV_RING, "Rings" },
575 * Pair together a constant flag with a textual description.
577 * Used by both "init.c" and "wiz-spo.c".
579 * Note that it sometimes more efficient to actually make an array
580 * of textual names, where entry 'N' is assumed to be paired with
581 * the flag whose value is "1L << N", but that requires hard-coding.
584 typedef struct flag_desc flag_desc;
589 const char *const desc;
595 * These are used for "+3 to STR, DEX", etc. These are separate from
596 * the other pval affected traits to simplify the case where an object
597 * affects all stats. In this case, "All stats" is used instead of
598 * listing each stat individually.
601 static flag_desc stat_flags_desc[] =
607 { TR_DEX, "´ïÍѤµ" },
608 { TR_CON, "Âѵ×ÎÏ" },
621 * Besides stats, these are the other player traits
622 * which may be affected by an object's pval
625 static flag_desc pval_flags1_desc[] =
628 { TR_MAGIC_MASTERY, "ËâË¡Æ»¶ñ»ÈÍÑǽÎÏ" },
629 { TR_STEALTH, "±£Ì©" },
630 { TR_SEARCH, "õº÷" },
631 { TR_INFRA, "ÀÖ³°Àþ»ëÎÏ" },
632 { TR_TUNNEL, "ºÎ·¡" },
633 { TR_BLOWS, "¹¶·â²ó¿ô" },
634 { TR_SPEED, "¥¹¥Ô¡¼¥É" }
636 { TR_STEALTH, "Stealth" },
637 { TR_SEARCH, "Searching" },
638 { TR_INFRA, "Infravision" },
639 { TR_TUNNEL, "Tunneling" },
640 { TR_BLOWS, "Attacks" },
641 { TR_SPEED, "Speed" }
646 * Slaying preferences for weapons
649 static flag_desc slay_flags_desc[] =
652 { TR_SLAY_ANIMAL, "ưʪ" },
653 { TR_KILL_ANIMAL, "*ưʪ*" },
654 { TR_SLAY_EVIL, "¼Ù°" },
655 { TR_KILL_EVIL, "*¼Ù°*" },
656 { TR_SLAY_HUMAN, "¿Í´Ö" },
657 { TR_KILL_HUMAN, "*¿Í´Ö*" },
658 { TR_SLAY_UNDEAD, "¥¢¥ó¥Ç¥Ã¥É" },
659 { TR_KILL_UNDEAD, "*¥¢¥ó¥Ç¥Ã¥É*" },
660 { TR_SLAY_DEMON, "°Ëâ" },
661 { TR_KILL_DEMON, "*°Ëâ*" },
662 { TR_SLAY_ORC, "¥ª¡¼¥¯" },
663 { TR_KILL_ORC, "*¥ª¡¼¥¯*" },
664 { TR_SLAY_TROLL, "¥È¥í¥ë" },
665 { TR_KILL_TROLL, "*¥È¥í¥ë*" },
666 { TR_SLAY_GIANT, "µð¿Í" },
667 { TR_KILL_GIANT, "*µð¿Í*" },
668 { TR_SLAY_DRAGON, "¥É¥é¥´¥ó" },
669 { TR_KILL_DRAGON, "*¥É¥é¥´¥ó*" },
671 { TR_SLAY_ANIMAL, "Animal" },
672 { TR_KILL_ANIMAL, "XAnimal" },
673 { TR_SLAY_EVIL, "Evil" },
674 { TR_KILL_EVIL, "XEvil" },
675 { TR_SLAY_HUMAN, "Human" },
676 { TR_KILL_HUMAN, "XHuman" },
677 { TR_SLAY_UNDEAD, "Undead" },
678 { TR_KILL_UNDEAD, "XUndead" },
679 { TR_SLAY_DEMON, "Demon" },
680 { TR_KILL_DEMON, "XDemon" },
681 { TR_SLAY_ORC, "Orc" },
682 { TR_KILL_ORC, "XOrc" },
683 { TR_SLAY_TROLL, "Troll" },
684 { TR_KILL_TROLL, "XTroll" },
685 { TR_SLAY_GIANT, "Giant" },
686 { TR_KILL_GIANT, "Xgiant" },
687 { TR_SLAY_DRAGON, "Dragon" },
688 { TR_KILL_DRAGON, "Xdragon" }
693 * Elemental brands for weapons
695 * Clearly, TR1_IMPACT is a bit out of place here. To simplify
696 * coding, it has been included here along with the elemental
697 * brands. It does seem to fit in with the brands and slaying
698 * more than the miscellaneous section.
700 static flag_desc brand_flags_desc[] =
703 { TR_BRAND_ACID, "Íϲò" },
704 { TR_BRAND_ELEC, "ÅÅ·â" },
705 { TR_BRAND_FIRE, "¾Æ´þ" },
706 { TR_BRAND_COLD, "Åà·ë" },
707 { TR_BRAND_POIS, "ÆÇ»¦" },
709 { TR_FORCE_WEAPON, "ÍýÎÏ" },
710 { TR_CHAOTIC, "º®ÆÙ" },
711 { TR_VAMPIRIC, "µÛ·ì" },
712 { TR_IMPACT, "ÃÏ¿Ì" },
713 { TR_VORPAL, "ÀÚ¤ìÌ£" },
715 { TR_BRAND_ACID, "Acid Brand" },
716 { TR_BRAND_ELEC, "Lightning Brand" },
717 { TR_BRAND_FIRE, "Flame Tongue" },
718 { TR_BRAND_COLD, "Frost Brand" },
719 { TR_BRAND_POIS, "Poisoned" },
721 { TR_FORCE_WEAPON, "Force" },
722 { TR_CHAOTIC, "Mark of Chaos" },
723 { TR_VAMPIRIC, "Vampiric" },
724 { TR_IMPACT, "Earthquake impact on hit" },
725 { TR_VORPAL, "Very sharp" },
733 static const flag_desc resist_flags_desc[] =
736 { TR_RES_ACID, "»À" },
737 { TR_RES_ELEC, "ÅÅ·â" },
738 { TR_RES_FIRE, "²Ð±ê" },
739 { TR_RES_COLD, "Î䵤" },
740 { TR_RES_POIS, "ÆÇ" },
741 { TR_RES_FEAR, "¶²ÉÝ"},
742 { TR_RES_LITE, "Á®¸÷" },
743 { TR_RES_DARK, "°Å¹õ" },
744 { TR_RES_BLIND, "ÌÕÌÜ" },
745 { TR_RES_CONF, "º®Íð" },
746 { TR_RES_SOUND, "¹ì²»" },
747 { TR_RES_SHARDS, "ÇËÊÒ" },
748 { TR_RES_NETHER, "ÃϹö" },
749 { TR_RES_NEXUS, "°ø²Ìº®Íð" },
750 { TR_RES_CHAOS, "¥«¥ª¥¹" },
751 { TR_RES_DISEN, "Îô²½" },
753 { TR_RES_ACID, "Acid" },
754 { TR_RES_ELEC, "Lightning" },
755 { TR_RES_FIRE, "Fire" },
756 { TR_RES_COLD, "Cold" },
757 { TR_RES_POIS, "Poison" },
758 { TR_RES_FEAR, "Fear"},
759 { TR_RES_LITE, "Light" },
760 { TR_RES_DARK, "Dark" },
761 { TR_RES_BLIND, "Blindness" },
762 { TR_RES_CONF, "Confusion" },
763 { TR_RES_SOUND, "Sound" },
764 { TR_RES_SHARDS, "Shards" },
765 { TR_RES_NETHER, "Nether" },
766 { TR_RES_NEXUS, "Nexus" },
767 { TR_RES_CHAOS, "Chaos" },
768 { TR_RES_DISEN, "Disenchantment" },
773 * Elemental immunities (along with poison)
776 static const flag_desc immune_flags_desc[] =
779 { TR_IM_ACID, "»À" },
780 { TR_IM_ELEC, "ÅÅ·â" },
781 { TR_IM_FIRE, "²Ð±ê" },
782 { TR_IM_COLD, "Î䵤" },
784 { TR_IM_ACID, "Acid" },
785 { TR_IM_ELEC, "Lightning" },
786 { TR_IM_FIRE, "Fire" },
787 { TR_IM_COLD, "Cold" },
792 * Sustain stats - these are given their "own" line in the
793 * spoiler file, mainly for simplicity
795 static const flag_desc sustain_flags_desc[] =
798 { TR_SUST_STR, "ÏÓÎÏ" },
799 { TR_SUST_INT, "ÃÎǽ" },
800 { TR_SUST_WIS, "¸¤µ" },
801 { TR_SUST_DEX, "´ïÍѤµ" },
802 { TR_SUST_CON, "Âѵ×ÎÏ" },
803 { TR_SUST_CHR, "Ì¥ÎÏ" },
805 { TR_SUST_STR, "STR" },
806 { TR_SUST_INT, "INT" },
807 { TR_SUST_WIS, "WIS" },
808 { TR_SUST_DEX, "DEX" },
809 { TR_SUST_CON, "CON" },
810 { TR_SUST_CHR, "CHR" },
815 * Miscellaneous magic given by an object's "flags2" field
818 static const flag_desc misc_flags2_desc[] =
821 { TR_THROW, "ÅêÚ³" },
822 { TR_REFLECT, "È¿¼Í" },
823 { TR_FREE_ACT, "ËãáãÃΤ餺" },
824 { TR_HOLD_LIFE, "À¸Ì¿ÎÏ°Ý»ý" },
826 { TR_THROW, "Throwing" },
827 { TR_REFLECT, "Reflection" },
828 { TR_FREE_ACT, "Free Action" },
829 { TR_HOLD_LIFE, "Hold Life" },
834 * Miscellaneous magic given by an object's "flags3" field
836 * Note that cursed artifacts and objects with permanent light
837 * are handled "directly" -- see analyze_misc_magic()
840 static const flag_desc misc_flags3_desc[] =
843 { TR_SH_FIRE, "²Ð±ê¥ª¡¼¥é" },
844 { TR_SH_ELEC, "Åŷ⥪¡¼¥é" },
845 { TR_SH_COLD, "Î䵤¥ª¡¼¥é" },
846 { TR_NO_TELE, "È¿¥Æ¥ì¥Ý¡¼¥È" },
847 { TR_NO_MAGIC, "È¿ËâË¡" },
848 { TR_LEVITATION, "ÉâÍ·" },
849 { TR_SEE_INVIS, "²Ä»ëÆ©ÌÀ" },
850 { TR_TELEPATHY, "¥Æ¥ì¥Ñ¥·¡¼" },
851 { TR_ESP_ANIMAL, "ưʪ´¶ÃÎ" },
852 { TR_ESP_UNDEAD, "ÉԻശÃÎ" },
853 { TR_ESP_DEMON, "°Ëâ´¶ÃÎ" },
854 { TR_ESP_ORC, "¥ª¡¼¥¯´¶ÃÎ" },
855 { TR_ESP_TROLL, "¥È¥í¥ë´¶ÃÎ" },
856 { TR_ESP_GIANT, "µð¿Í´¶ÃÎ" },
857 { TR_ESP_DRAGON, "¥É¥é¥´¥ó´¶ÃÎ" },
858 { TR_ESP_HUMAN, "¿Í´Ö´¶ÃÎ" },
859 { TR_ESP_EVIL, "¼Ù°´¶ÃÎ" },
860 { TR_ESP_GOOD, "Á±ÎÉ´¶ÃÎ" },
861 { TR_ESP_NONLIVING, "̵À¸Êª´¶ÃÎ" },
862 { TR_ESP_UNIQUE, "¥æ¥Ë¡¼¥¯´¶ÃÎ" },
863 { TR_SLOW_DIGEST, "Ãپò½" },
864 { TR_REGEN, "µÞ®²óÉü" },
865 { TR_WARNING, "·Ù¹ð" },
866 /* { TR_XTRA_MIGHT, "¶¯Îϼͷâ" }, */
867 { TR_XTRA_SHOTS, "Äɲüͷâ" }, /* always +1? */
868 { TR_DRAIN_EXP, "·Ð¸³Ã͵ۼý" },
869 { TR_AGGRAVATE, "È¿´¶" },
870 { TR_BLESSED, "½ËÊ¡" },
871 { TR_DEC_MANA, "¾ÃÈñËâÎϸº¾¯" },
873 { TR_SH_FIRE, "Fiery Aura" },
874 { TR_SH_ELEC, "Electric Aura" },
875 { TR_SH_COLD, "Coldly Aura" },
876 { TR_NO_TELE, "Prevent Teleportation" },
877 { TR_NO_MAGIC, "Anti-Magic" },
878 { TR_LEVITATION, "Levitation" },
879 { TR_SEE_INVIS, "See Invisible" },
880 { TR_TELEPATHY, "ESP" },
881 { TR_ESP_ANIMAL, "Sense Animal" },
882 { TR_ESP_UNDEAD, "Sense Undead" },
883 { TR_ESP_DEMON, "Sense Demon" },
884 { TR_ESP_ORC, "Sense Orc" },
885 { TR_ESP_TROLL, "Sense Troll" },
886 { TR_ESP_GIANT, "Sense Giant" },
887 { TR_ESP_DRAGON, "Sense Dragon" },
888 { TR_ESP_HUMAN, "Sense Human" },
889 { TR_ESP_EVIL, "Sense Evil" },
890 { TR_ESP_GOOD, "Sense Good" },
891 { TR_ESP_NONLIVING, "Sense Nonliving" },
892 { TR_ESP_UNIQUE, "Sense Unique" },
893 { TR_SLOW_DIGEST, "Slow Digestion" },
894 { TR_REGEN, "Regeneration" },
895 { TR_WARNING, "Warning" },
896 /* { TR_XTRA_MIGHT, "Extra Might" }, */
897 { TR_XTRA_SHOTS, "+1 Extra Shot" }, /* always +1? */
898 { TR_DRAIN_EXP, "Drains Experience" },
899 { TR_AGGRAVATE, "Aggravates" },
900 { TR_BLESSED, "Blessed Blade" },
901 { TR_DEC_MANA, "Decrease Mana Consumption Rate" },
907 * A special type used just for deailing with pvals
912 * This will contain a string such as "+2", "-10", etc.
917 * A list of various player traits affected by an object's pval such
918 * as stats, speed, stealth, etc. "Extra attacks" is NOT included in
919 * this list since it will probably be desirable to format its
920 * description differently.
922 * Note that room need only be reserved for the number of stats - 1
923 * since the description "All stats" is used if an object affects all
924 * all stats. Also, room must be reserved for a sentinel NULL pointer.
926 * This will be a list such as ["STR", "DEX", "Stealth", NULL] etc.
928 * This list includes extra attacks, for simplicity.
930 cptr pval_affects[N_ELEMENTS(stat_flags_desc) - 1 +
931 N_ELEMENTS(pval_flags1_desc) + 1];
937 * An "object analysis structure"
939 * It will be filled with descriptive strings detailing an object's
940 * various magical powers. The "ignore X" traits are not noted since
941 * all artifacts ignore "normal" destruction.
946 /* "The Longsword Dragonsmiter (6d4) (+20, +25)" */
947 char description[MAX_NLEN];
949 /* Description of what is affected by an object's pval */
950 pval_info_type pval_info;
952 /* A list of an object's slaying preferences */
953 cptr slays[N_ELEMENTS(slay_flags_desc) + 1];
955 /* A list if an object's elemental brands */
956 cptr brands[N_ELEMENTS(brand_flags_desc) + 1];
958 /* A list of immunities granted by an object */
959 cptr immunities[N_ELEMENTS(immune_flags_desc) + 1];
961 /* A list of resistances granted by an object */
962 cptr resistances[N_ELEMENTS(resist_flags_desc) + 1];
964 /* A list of stats sustained by an object */
965 cptr sustains[N_ELEMENTS(sustain_flags_desc) - 1 + 1];
967 /* A list of various magical qualities an object may have */
968 cptr misc_magic[N_ELEMENTS(misc_flags2_desc) + N_ELEMENTS(misc_flags3_desc)
969 + 1 /* Permanent Light */
971 + 1 /* type of curse */
972 + 1]; /* sentinel NULL */
974 /* Additional ability or resistance */
977 /* A string describing an artifact's activation */
980 /* "Level 20, Rarity 30, 3.0 lbs, 20000 Gold" */
986 * Write out `n' of the character `c' to the spoiler file
988 static void spoiler_out_n_chars(int n, char c)
990 while (--n >= 0) fputc(c, fff);
995 * Write out `n' blank lines to the spoiler file
997 static void spoiler_blanklines(int n)
999 spoiler_out_n_chars(n, '\n');
1004 * Write a line to the spoiler file and then "underline" it with hypens
1006 static void spoiler_underline(cptr str)
1008 fprintf(fff, "%s\n", str);
1009 spoiler_out_n_chars(strlen(str), '-');
1016 * This function does most of the actual "analysis". Given a set of bit flags
1017 * (which will be from one of the flags fields from the object in question),
1018 * a "flag description structure", a "description list", and the number of
1019 * elements in the "flag description structure", this function sets the
1020 * "description list" members to the appropriate descriptions contained in
1021 * the "flag description structure".
1023 * The possibly updated description pointer is returned.
1025 static cptr *spoiler_flag_aux(const u32b art_flags[TR_FLAG_SIZE],
1026 const flag_desc *flag_ptr,
1027 cptr *desc_ptr, const int n_elmnts)
1031 for (i = 0; i < n_elmnts; ++i)
1033 if (have_flag(art_flags, flag_ptr[i].flag))
1035 *desc_ptr++ = flag_ptr[i].desc;
1044 * Acquire a "basic" description "The Cloak of Death [1,+10]"
1046 static void analyze_general(object_type *o_ptr, char *desc_ptr)
1048 /* Get a "useful" description of the object */
1049 object_desc(desc_ptr, o_ptr, (OD_NAME_AND_ENCHANT | OD_STORE));
1054 * List "player traits" altered by an artifact's pval. These include stats,
1055 * speed, infravision, tunneling, stealth, searching, and extra attacks.
1057 static void analyze_pval(object_type *o_ptr, pval_info_type *p_ptr)
1059 u32b flgs[TR_FLAG_SIZE];
1063 /* If pval == 0, there is nothing to do. */
1066 /* An "empty" pval description indicates that pval == 0 */
1067 p_ptr->pval_desc[0] = '\0';
1071 /* Extract the flags */
1072 object_flags(o_ptr, flgs);
1074 affects_list = p_ptr->pval_affects;
1076 /* Create the "+N" string */
1077 sprintf(p_ptr->pval_desc, "%s%d", POSITIZE(o_ptr->pval), o_ptr->pval);
1079 /* First, check to see if the pval affects all stats */
1080 if (have_flag(flgs, TR_STR) && have_flag(flgs, TR_INT) &&
1081 have_flag(flgs, TR_WIS) && have_flag(flgs, TR_DEX) &&
1082 have_flag(flgs, TR_CON) && have_flag(flgs, TR_CHR))
1085 *affects_list++ = "Á´Ç½ÎÏ";
1087 *affects_list++ = "All stats";
1091 /* Are any stats affected? */
1092 else if (have_flag(flgs, TR_STR) || have_flag(flgs, TR_INT) ||
1093 have_flag(flgs, TR_WIS) || have_flag(flgs, TR_DEX) ||
1094 have_flag(flgs, TR_CON) || have_flag(flgs, TR_CHR))
1096 affects_list = spoiler_flag_aux(flgs, stat_flags_desc,
1098 N_ELEMENTS(stat_flags_desc));
1101 /* And now the "rest" */
1102 affects_list = spoiler_flag_aux(flgs, pval_flags1_desc,
1104 N_ELEMENTS(pval_flags1_desc));
1106 /* Terminate the description list */
1107 *affects_list = NULL;
1111 /* Note the slaying specialties of a weapon */
1112 static void analyze_slay(object_type *o_ptr, cptr *slay_list)
1114 u32b flgs[TR_FLAG_SIZE];
1116 object_flags(o_ptr, flgs);
1118 slay_list = spoiler_flag_aux(flgs, slay_flags_desc, slay_list,
1119 N_ELEMENTS(slay_flags_desc));
1121 /* Terminate the description list */
1125 /* Note an object's elemental brands */
1126 static void analyze_brand(object_type *o_ptr, cptr *brand_list)
1128 u32b flgs[TR_FLAG_SIZE];
1130 object_flags(o_ptr, flgs);
1132 brand_list = spoiler_flag_aux(flgs, brand_flags_desc, brand_list,
1133 N_ELEMENTS(brand_flags_desc));
1135 /* Terminate the description list */
1140 /* Note the resistances granted by an object */
1141 static void analyze_resist(object_type *o_ptr, cptr *resist_list)
1143 u32b flgs[TR_FLAG_SIZE];
1145 object_flags(o_ptr, flgs);
1147 resist_list = spoiler_flag_aux(flgs, resist_flags_desc,
1148 resist_list, N_ELEMENTS(resist_flags_desc));
1150 /* Terminate the description list */
1151 *resist_list = NULL;
1155 /* Note the immunities granted by an object */
1156 static void analyze_immune(object_type *o_ptr, cptr *immune_list)
1158 u32b flgs[TR_FLAG_SIZE];
1160 object_flags(o_ptr, flgs);
1162 immune_list = spoiler_flag_aux(flgs, immune_flags_desc,
1163 immune_list, N_ELEMENTS(immune_flags_desc));
1165 /* Terminate the description list */
1166 *immune_list = NULL;
1170 /* Note which stats an object sustains */
1171 static void analyze_sustains(object_type *o_ptr, cptr *sustain_list)
1173 u32b flgs[TR_FLAG_SIZE];
1175 object_flags(o_ptr, flgs);
1177 /* Simplify things if an item sustains all stats */
1178 if (have_flag(flgs, TR_SUST_STR) && have_flag(flgs, TR_SUST_INT) &&
1179 have_flag(flgs, TR_SUST_WIS) && have_flag(flgs, TR_SUST_DEX) &&
1180 have_flag(flgs, TR_SUST_CON) && have_flag(flgs, TR_SUST_CHR))
1183 *sustain_list++ = "Á´Ç½ÎÏ";
1185 *sustain_list++ = "All stats";
1189 /* Should we bother? */
1190 else if (have_flag(flgs, TR_SUST_STR) || have_flag(flgs, TR_SUST_INT) ||
1191 have_flag(flgs, TR_SUST_WIS) || have_flag(flgs, TR_SUST_DEX) ||
1192 have_flag(flgs, TR_SUST_CON) || have_flag(flgs, TR_SUST_CHR))
1194 sustain_list = spoiler_flag_aux(flgs, sustain_flags_desc,
1196 N_ELEMENTS(sustain_flags_desc));
1199 /* Terminate the description list */
1200 *sustain_list = NULL;
1205 * Note miscellaneous powers bestowed by an artifact such as see invisible,
1206 * free action, permanent light, etc.
1208 static void analyze_misc_magic(object_type *o_ptr, cptr *misc_list)
1210 u32b flgs[TR_FLAG_SIZE];
1212 object_flags(o_ptr, flgs);
1214 misc_list = spoiler_flag_aux(flgs, misc_flags2_desc, misc_list,
1215 N_ELEMENTS(misc_flags2_desc));
1217 misc_list = spoiler_flag_aux(flgs, misc_flags3_desc, misc_list,
1218 N_ELEMENTS(misc_flags3_desc));
1221 * Artifact lights -- large radius light.
1223 if ((o_ptr->tval == TV_LITE) && object_is_fixed_artifact(o_ptr))
1226 *misc_list++ = "±Êµ×¸÷¸»(Ⱦ·Â3)";
1228 *misc_list++ = "Permanent Light(3)";
1233 * Glowing artifacts -- small radius light.
1235 if (have_flag(flgs, TR_LITE))
1238 *misc_list++ = "±Êµ×¸÷¸»(Ⱦ·Â1)";
1240 *misc_list++ = "Permanent Light(1)";
1245 * Handle cursed objects here to avoid redundancies such as noting
1246 * that a permanently cursed object is heavily cursed as well as
1247 * being "lightly cursed".
1250 /* if (object_is_cursed(o_ptr)) */
1252 if (have_flag(flgs, TR_TY_CURSE))
1255 *misc_list++ = "ÂÀ¸Å¤Î±åÇ°";
1257 *misc_list++ = "Ancient Curse";
1260 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1263 *misc_list++ = "±Ê±ó¤Î¼ö¤¤";
1265 *misc_list++ = "Permanently Cursed";
1268 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1271 *misc_list++ = "¶¯ÎϤʼö¤¤";
1273 *misc_list++ = "Heavily Cursed";
1277 else if (o_ptr->curse_flags & TRC_CURSED)
1280 *misc_list++ = "¼ö¤¤";
1282 *misc_list++ = "Cursed";
1285 if (have_flag(flgs, TR_ADD_L_CURSE))
1288 *misc_list++ = "¼ö¤¤¤òÁý¤ä¤¹";
1290 *misc_list++ = "Cursing";
1293 if (have_flag(flgs, TR_ADD_H_CURSE))
1296 *misc_list++ = "¶¯ÎϤʼö¤¤¤òÁý¤ä¤¹";
1298 *misc_list++ = "Heavily Cursing";
1303 /* Terminate the description list */
1309 * Note additional ability and/or resistance of fixed artifacts
1311 static void analyze_addition(object_type *o_ptr, char *addition)
1313 artifact_type *a_ptr = &a_info[o_ptr->name1];
1316 strcpy(addition, "");
1319 if ((a_ptr->gen_flags & TRG_XTRA_POWER) && (a_ptr->gen_flags & TRG_XTRA_H_RES)) strcat(addition, "ǽÎÏandÂÑÀ");
1320 else if (a_ptr->gen_flags & TRG_XTRA_POWER)
1322 strcat(addition, "ǽÎÏ");
1323 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "(1/2¤ÇandÂÑÀ)");
1325 else if (a_ptr->gen_flags & TRG_XTRA_H_RES)
1327 strcat(addition, "ÂÑÀ");
1328 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "(1/2¤ÇandǽÎÏ)");
1330 else if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "ǽÎÏorÂÑÀ");
1332 if ((a_ptr->gen_flags & TRG_XTRA_POWER) && (a_ptr->gen_flags & TRG_XTRA_H_RES)) strcat(addition, "Ability and Resistance");
1333 else if (a_ptr->gen_flags & TRG_XTRA_POWER)
1335 strcat(addition, "Ability");
1336 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "(plus Resistance about 1/2)");
1338 else if (a_ptr->gen_flags & TRG_XTRA_H_RES)
1340 strcat(addition, "Resistance");
1341 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "(plus Ability about 1/2)");
1343 else if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, "Ability or Resistance");
1349 * Determine the minimum depth an artifact can appear, its rarity, its weight,
1350 * and its value in gold pieces
1352 static void analyze_misc(object_type *o_ptr, char *misc_desc)
1354 artifact_type *a_ptr = &a_info[o_ptr->name1];
1357 sprintf(misc_desc, "¥ì¥Ù¥ë %u, ´õ¾¯ÅÙ %u, %d.%d kg, ¡ð%ld",
1358 a_ptr->level, a_ptr->rarity,
1359 lbtokg1(a_ptr->weight), lbtokg2(a_ptr->weight), (long int)a_ptr->cost);
1361 sprintf(misc_desc, "Level %u, Rarity %u, %d.%d lbs, %ld Gold",
1362 a_ptr->level, a_ptr->rarity,
1363 a_ptr->weight / 10, a_ptr->weight % 10, a_ptr->cost);
1369 * Fill in an object description structure for a given object
1371 static void object_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
1373 analyze_general(o_ptr, desc_ptr->description);
1374 analyze_pval(o_ptr, &desc_ptr->pval_info);
1375 analyze_brand(o_ptr, desc_ptr->brands);
1376 analyze_slay(o_ptr, desc_ptr->slays);
1377 analyze_immune(o_ptr, desc_ptr->immunities);
1378 analyze_resist(o_ptr, desc_ptr->resistances);
1379 analyze_sustains(o_ptr, desc_ptr->sustains);
1380 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
1381 analyze_addition(o_ptr, desc_ptr->addition);
1382 analyze_misc(o_ptr, desc_ptr->misc_desc);
1383 desc_ptr->activation = item_activation(o_ptr);
1387 static void print_header(void)
1391 sprintf(buf, "Artifact Spoilers for Hengband Version %d.%d.%d",
1392 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1393 spoiler_underline(buf);
1397 * This is somewhat ugly.
1399 * Given a header ("Resist", e.g.), a list ("Fire", "Cold", Acid", e.g.),
1400 * and a separator character (',', e.g.), write the list to the spoiler file
1401 * in a "nice" format, such as:
1403 * Resist Fire, Cold, Acid
1405 * That was a simple example, but when the list is long, a line wrap
1406 * should occur, and this should induce a new level of indention if
1407 * a list is being spread across lines. So for example, Bladeturner's
1408 * list of resistances should look something like this
1410 * Resist Acid, Lightning, Fire, Cold, Poison, Light, Dark, Blindness,
1411 * Confusion, Sound, Shards, Nether, Nexus, Chaos, Disenchantment
1413 * However, the code distinguishes between a single list of many items vs.
1414 * many lists. (The separator is used to make this determination.) A single
1415 * list of many items will not cause line wrapping (since there is no
1416 * apparent reason to do so). So the lists of Ulmo's miscellaneous traits
1417 * might look like this:
1419 * Free Action; Hold Life; See Invisible; Slow Digestion; Regeneration
1422 * So comparing the two, "Regeneration" has no trailing separator and
1423 * "Blessed Blade" was not indented. (Also, Ulmo's lists have no headers,
1424 * but that's not relevant to line wrapping and indention.)
1427 /* ITEM_SEP separates items within a list */
1428 #define ITEM_SEP ','
1431 /* LIST_SEP separates lists */
1433 #define LIST_SEP ','
1435 #define LIST_SEP ';'
1438 static void spoiler_outlist(cptr header, cptr *list, char separator)
1440 int line_len, buf_len;
1441 char line[MAX_LINE_LEN+1], buf[80];
1443 /* Ignore an empty list */
1444 if (*list == NULL) return;
1446 /* This function always indents */
1447 strcpy(line, INDENT1);
1449 /* Create header (if one was given) */
1450 if (header && (header[0]))
1452 strcat(line, header);
1456 line_len = strlen(line);
1458 /* Now begin the tedious task */
1461 /* Copy the current item to a buffer */
1464 /* Note the buffer's length */
1465 buf_len = strlen(buf);
1468 * If there is an item following this one, pad with separator and
1469 * a space and adjust the buffer length
1474 sprintf(buf + buf_len, "%c ", separator);
1479 * If the buffer will fit on the current line, just append the
1480 * buffer to the line and adjust the line length accordingly.
1483 if (line_len + buf_len <= MAX_LINE_LEN)
1486 line_len += buf_len;
1489 /* Apply line wrapping and indention semantics described above */
1493 * Don't print a trailing list separator but do print a trailing
1496 if (line_len > 1 && line[line_len - 1] == ' '
1497 && line[line_len - 2] == LIST_SEP)
1499 /* Ignore space and separator */
1500 line[line_len - 2] = '\0';
1502 /* Write to spoiler file */
1503 fprintf(fff, "%s\n", line);
1505 /* Begin new line at primary indention level */
1506 sprintf(line, "%s%s", INDENT1, buf);
1511 /* Write to spoiler file */
1512 fprintf(fff, "%s\n", line);
1514 /* Begin new line at secondary indention level */
1515 sprintf(line, "%s%s", INDENT2, buf);
1518 line_len = strlen(line);
1521 /* Advance, with break */
1522 if (!*++list) break;
1525 /* Write what's left to the spoiler file */
1526 fprintf(fff, "%s\n", line);
1530 /* Create a spoiler file entry for an artifact */
1532 static void spoiler_print_art(obj_desc_list *art_ptr)
1534 pval_info_type *pval_ptr = &art_ptr->pval_info;
1538 /* Don't indent the first line */
1539 fprintf(fff, "%s\n", art_ptr->description);
1541 /* An "empty" pval description indicates that the pval affects nothing */
1542 if (pval_ptr->pval_desc[0])
1544 /* Mention the effects of pval */
1546 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
1548 sprintf(buf, "%s to", pval_ptr->pval_desc);
1550 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
1553 /* Now deal with the description lists */
1556 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
1557 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
1558 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
1559 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
1560 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
1562 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
1563 spoiler_outlist("", art_ptr->brands, LIST_SEP);
1564 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
1565 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
1566 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
1568 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
1570 if (art_ptr->addition[0])
1573 fprintf(fff, "%sÄɲÃ: %s\n", INDENT1, art_ptr->addition);
1575 fprintf(fff, "%sAdditional %s\n", INDENT1, art_ptr->addition);
1579 /* Write out the possible activation at the primary indention level */
1580 if (art_ptr->activation)
1583 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
1585 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
1589 /* End with the miscellaneous facts */
1590 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
1595 * Hack -- Create a "forged" artifact
1597 static bool make_fake_artifact(object_type *o_ptr, int name1)
1601 artifact_type *a_ptr = &a_info[name1];
1604 /* Ignore "empty" artifacts */
1605 if (!a_ptr->name) return FALSE;
1607 /* Acquire the "kind" index */
1608 i = lookup_kind(a_ptr->tval, a_ptr->sval);
1611 if (!i) return (FALSE);
1613 /* Create the artifact */
1614 object_prep(o_ptr, i);
1617 o_ptr->name1 = name1;
1619 /* Extract the fields */
1620 o_ptr->pval = a_ptr->pval;
1621 o_ptr->ac = a_ptr->ac;
1622 o_ptr->dd = a_ptr->dd;
1623 o_ptr->ds = a_ptr->ds;
1624 o_ptr->to_a = a_ptr->to_a;
1625 o_ptr->to_h = a_ptr->to_h;
1626 o_ptr->to_d = a_ptr->to_d;
1627 o_ptr->weight = a_ptr->weight;
1628 o_ptr->xtra2 = a_ptr->act_idx;
1636 * Create a spoiler file for artifacts
1638 static void spoil_artifact(cptr fname)
1645 obj_desc_list artifact;
1650 /* Build the filename */
1651 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1653 /* File type is "TEXT" */
1654 FILE_TYPE(FILE_TYPE_TEXT);
1657 fff = my_fopen(buf, "w");
1662 msg_print("Cannot create spoiler file.");
1666 /* Dump the header */
1669 /* List the artifacts by tval */
1670 for (i = 0; group_artifact[i].tval; i++)
1672 /* Write out the group title */
1673 if (group_artifact[i].name)
1675 spoiler_blanklines(2);
1676 spoiler_underline(group_artifact[i].name);
1677 spoiler_blanklines(1);
1680 /* Now search through all of the artifacts */
1681 for (j = 1; j < max_a_idx; ++j)
1683 artifact_type *a_ptr = &a_info[j];
1685 /* We only want objects in the current group */
1686 if (a_ptr->tval != group_artifact[i].tval) continue;
1688 /* Get local object */
1691 /* Wipe the object */
1694 /* Attempt to "forge" the artifact */
1695 if (!make_fake_artifact(q_ptr, j)) continue;
1697 /* Analyze the artifact */
1698 object_analyze(q_ptr, &artifact);
1700 /* Write out the artifact description to the spoiler file */
1701 spoiler_print_art(&artifact);
1705 /* Check for errors */
1706 if (ferror(fff) || my_fclose(fff))
1708 msg_print("Cannot close spoiler file.");
1713 msg_print("Successfully created a spoiler file.");
1721 * Create a spoiler file for monsters -BEN-
1723 static void spoil_mon_desc(cptr fname)
1740 /* Build the filename */
1741 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1743 /* File type is "TEXT" */
1744 FILE_TYPE(FILE_TYPE_TEXT);
1747 fff = my_fopen(buf, "w");
1752 msg_print("Cannot create spoiler file.");
1756 /* Allocate the "who" array */
1757 C_MAKE(who, max_r_idx, s16b);
1759 /* Dump the header */
1760 fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1761 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1762 fprintf(fff, "------------------------------------------\n\n");
1764 /* Dump the header */
1765 fprintf(fff, " %-38.38s%4s%4s%4s%7s%5s %11.11s\n",
1766 "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
1767 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1768 "--------", "---", "---", "---", "--", "--", "-----------");
1771 /* Scan the monsters */
1772 for (i = 1; i < max_r_idx; i++)
1774 monster_race *r_ptr = &r_info[i];
1776 /* Use that monster */
1777 if (r_ptr->name) who[n++] = i;
1780 /* Select the sort method */
1781 ang_sort_comp = ang_sort_comp_hook;
1782 ang_sort_swap = ang_sort_swap_hook;
1784 /* Sort the array by dungeon depth of monsters */
1785 ang_sort(who, &why, n);
1788 for (i = 0; i < n; i++)
1790 monster_race *r_ptr = &r_info[who[i]];
1792 cptr name = (r_name + r_ptr->name);
1793 if (r_ptr->flags7 & (RF7_KAGE)) continue;
1795 /* Get the "name" */
1797 else if (r_ptr->flags1 & (RF1_QUESTOR))
1799 sprintf(nam, "[Q] %s", name);
1802 else if (r_ptr->flags1 & (RF1_UNIQUE))
1804 sprintf(nam, "[U] %s", name);
1809 sprintf(nam, " %s", name);
1811 sprintf(nam, "The %s", name);
1817 sprintf(lev, "%d", r_ptr->level);
1820 sprintf(rar, "%d", r_ptr->rarity);
1823 if (r_ptr->speed >= 110)
1825 sprintf(spd, "+%d", (r_ptr->speed - 110));
1829 sprintf(spd, "-%d", (110 - r_ptr->speed));
1833 sprintf(ac, "%d", r_ptr->ac);
1836 if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
1838 sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
1842 sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
1847 sprintf(exp, "%ld", (long)(r_ptr->mexp));
1849 /* Hack -- use visual instead */
1850 sprintf(exp, "%s '%c'", attr_to_text(r_ptr), r_ptr->d_char);
1853 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1854 nam, lev, rar, spd, hp, ac, exp);
1861 /* Free the "who" array */
1862 C_KILL(who, max_r_idx, s16b);
1864 /* Check for errors */
1865 if (ferror(fff) || my_fclose(fff))
1867 msg_print("Cannot close spoiler file.");
1872 msg_print("Successfully created a spoiler file.");
1879 * Monster spoilers by: smchorse@ringer.cs.utsa.edu (Shawn McHorse)
1881 * Primarily based on code already in mon-desc.c, mostly by -BEN-
1887 * Buffer text to the given file. (-SHAWN-)
1888 * This is basically c_roff() from mon-desc.c with a few changes.
1890 static void spoil_out(cptr str)
1895 static char roff_buf[256];
1898 static char roff_waiting_buf[256];
1901 bool iskanji_flag = FALSE;
1903 /* Current pointer into line roff_buf */
1904 static char *roff_p = roff_buf;
1906 /* Last space saved into roff_buf */
1907 static char *roff_s = NULL;
1909 /* Mega-Hack -- Delayed output */
1910 static bool waiting_output = FALSE;
1912 /* Special handling for "new sequence" */
1917 fputs(roff_waiting_buf, fff);
1918 waiting_output = FALSE;
1921 if (roff_p != roff_buf) roff_p--;
1922 while (*roff_p == ' ' && roff_p != roff_buf) roff_p--;
1924 if (roff_p == roff_buf) fprintf(fff, "\n");
1927 *(roff_p + 1) = '\0';
1928 fprintf(fff, "%s\n\n", roff_buf);
1937 /* Scan the given string, character at a time */
1942 bool k_flag = iskanji((unsigned char)(*str));
1945 bool wrap = (ch == '\n');
1948 if (!isprint(ch) && !k_flag && !iskanji_flag) ch = ' ';
1949 iskanji_flag = k_flag && !iskanji_flag;
1951 if (!isprint(ch)) ch = ' ';
1956 fputs(roff_waiting_buf, fff);
1957 if (!wrap) fputc('\n', fff);
1958 waiting_output = FALSE;
1964 if (roff_p >= roff_buf + (k_flag ? 74 : 75)) wrap = TRUE;
1965 else if ((ch == ' ') && (roff_p >= roff_buf + (k_flag ? 72 : 73))) wrap = TRUE;
1967 if (roff_p >= roff_buf + 75) wrap = TRUE;
1968 else if ((ch == ' ') && (roff_p >= roff_buf + 73)) wrap = TRUE;
1975 bool iskanji_flag_local = FALSE;
1976 cptr tail = str + (k_flag ? 2 : 1);
1978 cptr tail = str + 1;
1981 for (; *tail; tail++)
1983 if (*tail == ' ') continue;
1986 k_flag_local = iskanji((unsigned char)(*tail));
1987 if (isprint(*tail) || k_flag_local || iskanji_flag_local) break;
1988 iskanji_flag_local = k_flag_local && !iskanji_flag_local;
1990 if (isprint(*tail)) break;
1994 if (!*tail) waiting_output = TRUE;
1998 /* Handle line-wrap */
2006 if (roff_s && (ch != ' '))
2014 if (!waiting_output) fprintf(fff, "%s\n", roff_buf);
2015 else strcpy(roff_waiting_buf, roff_buf);
2019 if (cbak != ' ') *roff_p++ = cbak;
2021 while (*r) *roff_p++ = *r++;
2025 if ((roff_p > roff_buf) || (ch != ' '))
2030 if ((ch == ' ') || (ch == '(')) roff_s = roff_p;
2035 strncmp(str, "¡£", 2) != 0 &&
2036 strncmp(str, "¡¢", 2) != 0 &&
2037 strncmp(str, "¥£", 2) != 0 &&
2038 strncmp(str, "¡¼", 2) != 0) roff_s = roff_p;
2041 if (ch == ' ') roff_s = roff_p;
2052 * Hook function used in spoil_mon_info()
2054 static void roff_func(byte attr, cptr str)
2064 * Create a spoiler file for monsters (-SHAWN-)
2066 static void spoil_mon_info(cptr fname)
2075 /* Build the filename */
2076 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2078 /* File type is "TEXT" */
2079 FILE_TYPE(FILE_TYPE_TEXT);
2082 fff = my_fopen(buf, "w");
2087 msg_print("Cannot create spoiler file.");
2092 /* Dump the header */
2093 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
2094 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
2097 spoil_out("------------------------------------------\n\n");
2099 /* Allocate the "who" array */
2100 C_MAKE(who, max_r_idx, s16b);
2102 /* Scan the monsters */
2103 for (i = 1; i < max_r_idx; i++)
2105 monster_race *r_ptr = &r_info[i];
2107 /* Use that monster */
2108 if (r_ptr->name) who[n++] = i;
2111 /* Select the sort method */
2112 ang_sort_comp = ang_sort_comp_hook;
2113 ang_sort_swap = ang_sort_swap_hook;
2115 /* Sort the array by dungeon depth of monsters */
2116 ang_sort(who, &why, n);
2120 * List all monsters in order
2122 for (l = 0; l < n; l++)
2124 monster_race *r_ptr = &r_info[who[l]];
2126 /* Extract the flags */
2127 flags1 = r_ptr->flags1;
2131 if (flags1 & (RF1_QUESTOR))
2137 if (flags1 & (RF1_UNIQUE))
2150 sprintf(buf, "%s/%s (", (r_name + r_ptr->name),(r_name+r_ptr->E_name)); /* ---)--- */
2152 sprintf(buf, "%s (", (r_name + r_ptr->name)); /* ---)--- */
2158 spoil_out(attr_to_text(r_ptr));
2161 sprintf(buf, " '%c')\n", r_ptr->d_char);
2166 sprintf(buf, "=== ");
2170 sprintf(buf, "Num:%d ", who[l]);
2174 sprintf(buf, "Lev:%d ", r_ptr->level);
2178 sprintf(buf, "Rar:%d ", r_ptr->rarity);
2182 if (r_ptr->speed >= 110)
2184 sprintf(buf, "Spd:+%d ", (r_ptr->speed - 110));
2188 sprintf(buf, "Spd:-%d ", (110 - r_ptr->speed));
2193 if ((flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
2195 sprintf(buf, "Hp:%d ", r_ptr->hdice * r_ptr->hside);
2199 sprintf(buf, "Hp:%dd%d ", r_ptr->hdice, r_ptr->hside);
2204 sprintf(buf, "Ac:%d ", r_ptr->ac);
2208 sprintf(buf, "Exp:%ld\n", (long)(r_ptr->mexp));
2211 /* Reuse the code of monster recall. */
2212 output_monster_spoiler(who[l], roff_func);
2217 /* Free the "who" array */
2218 C_KILL(who, max_r_idx, s16b);
2220 /* Check for errors */
2221 if (ferror(fff) || my_fclose(fff))
2223 msg_print("Cannot close spoiler file.");
2227 msg_print("Successfully created a spoiler file.");
2232 #define MAX_EVOL_DEPTH 64
2236 * Compare two int-type array like strncmp() and return TRUE if equals
2238 static bool int_n_cmp(int *a, int *b, int length)
2240 /* Null-string comparation is always TRUE */
2241 if (!length) return TRUE;
2245 if (*a != *(b++)) return FALSE;
2246 if (!(*(a++))) break;
2255 * Returns TRUE if an evolution tree is "partial tree"
2257 static bool is_partial_tree(int *tree, int *partial_tree)
2259 int pt_head = *(partial_tree++);
2262 while (partial_tree[pt_len]) pt_len++;
2266 if (*(tree++) == pt_head)
2268 if (int_n_cmp(tree, partial_tree, pt_len)) return TRUE;
2277 * Sorting hook -- Comp function
2279 static bool ang_sort_comp_evol_tree(vptr u, vptr v, int a, int b)
2281 int **evol_tree = (int **)u;
2283 int w1 = evol_tree[a][0];
2284 int w2 = evol_tree[b][0];
2285 monster_race *r1_ptr = &r_info[w1];
2286 monster_race *r2_ptr = &r_info[w2];
2291 /* Used tree first */
2292 if (w1 && !w2) return TRUE;
2293 if (!w1 && w2) return FALSE;
2295 /* Sort by monster level */
2296 if (r1_ptr->level < r2_ptr->level) return TRUE;
2297 if (r1_ptr->level > r2_ptr->level) return FALSE;
2299 /* Sort by monster experience */
2300 if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
2301 if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
2303 /* Compare indexes */
2309 * Sorting hook -- Swap function
2311 static void ang_sort_swap_evol_tree(vptr u, vptr v, int a, int b)
2313 int **evol_tree = (int **)u;
2320 holder = evol_tree[a];
2321 evol_tree[a] = evol_tree[b];
2322 evol_tree[b] = holder;
2327 * Print monsters' evolution information to file
2329 static void spoil_mon_evol(cptr fname)
2332 monster_race *r_ptr;
2333 int **evol_tree, i, j, n, r_idx;
2334 int *evol_tree_zero; /* For C_KILL() */
2336 /* Build the filename */
2337 path_build(buf, sizeof buf, ANGBAND_DIR_USER, fname);
2339 /* File type is "TEXT" */
2340 FILE_TYPE(FILE_TYPE_TEXT);
2343 fff = my_fopen(buf, "w");
2348 msg_print("Cannot create spoiler file.");
2352 /* Dump the header */
2353 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
2354 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
2357 spoil_out("------------------------------------------\n\n");
2359 /* Allocate the "evol_tree" array (2-dimension) */
2360 C_MAKE(evol_tree, max_r_idx, int *);
2361 C_MAKE(*evol_tree, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
2362 for (i = 1; i < max_r_idx; i++) evol_tree[i] = *evol_tree + i * (MAX_EVOL_DEPTH + 1);
2363 evol_tree_zero = *evol_tree;
2365 /* Step 1: Build the evolution tree */
2366 for (i = 1; i < max_r_idx; i++)
2371 if (!r_ptr->next_exp) continue;
2373 /* Trace evolution */
2375 evol_tree[i][n++] = i;
2378 evol_tree[i][n++] = r_ptr->next_r_idx;
2379 r_ptr = &r_info[r_ptr->next_r_idx];
2381 while (r_ptr->next_exp && (n < MAX_EVOL_DEPTH));
2384 /* Step 2: Scan the evolution trees and remove "partial tree" */
2385 for (i = 1; i < max_r_idx; i++)
2387 /* Not evolution tree */
2388 if (!evol_tree[i][0]) continue;
2390 for (j = 1; j < max_r_idx; j++)
2393 if (i == j) continue;
2395 /* Not evolution tree */
2396 if (!evol_tree[j][0]) continue;
2398 /* Is evolution tree[i] is part of [j]? */
2399 if (is_partial_tree(evol_tree[j], evol_tree[i]))
2401 /* Remove this evolution tree */
2402 evol_tree[i][0] = 0;
2408 /* Step 3: Sort the evolution trees */
2410 /* Select the sort method */
2411 ang_sort_comp = ang_sort_comp_evol_tree;
2412 ang_sort_swap = ang_sort_swap_evol_tree;
2414 /* Sort the array */
2415 ang_sort(evol_tree, NULL, max_r_idx);
2417 /* Step 4: Print the evolution trees */
2418 for (i = 0; i < max_r_idx; i++)
2420 r_idx = evol_tree[i][0];
2422 /* No evolution or removed evolution tree */
2423 if (!r_idx) continue;
2425 /* Trace the evolution tree */
2426 r_ptr = &r_info[r_idx];
2428 fprintf(fff, "[%d]: %s (¥ì¥Ù¥ë%d, '%c')\n", r_idx,
2429 r_name + r_ptr->name, r_ptr->level, r_ptr->d_char);
2431 fprintf(fff, "[%d]: %s (Level %d, '%c')\n", r_idx,
2432 r_name + r_ptr->name, r_ptr->level, r_ptr->d_char);
2434 for (n = 1; r_ptr->next_exp; n++)
2436 fprintf(fff, "%*s-(%ld)-> ", n * 2, "", (long int)r_ptr->next_exp);
2437 fprintf(fff, "[%d]: ", r_ptr->next_r_idx);
2438 r_ptr = &r_info[r_ptr->next_r_idx];
2440 fprintf(fff, "%s (¥ì¥Ù¥ë%d, '%c')\n",
2441 r_name + r_ptr->name, r_ptr->level, r_ptr->d_char);
2443 fprintf(fff, "%s (Level %d, '%c')\n",
2444 r_name + r_ptr->name, r_ptr->level, r_ptr->d_char);
2448 /* End of evolution tree */
2452 /* Free the "evol_tree" array (2-dimension) */
2453 C_KILL(evol_tree_zero, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
2454 C_KILL(evol_tree, max_r_idx, int *);
2456 /* Check for errors */
2457 if (ferror(fff) || my_fclose(fff))
2459 msg_print("Cannot close spoiler file.");
2464 msg_print("Successfully created a spoiler file.");
2472 extern void do_cmd_spoilers(void);
2475 * Create Spoiler files -BEN-
2477 void do_cmd_spoilers(void)
2479 /* Save the screen */
2489 prt("Create a spoiler file.", 2, 0);
2491 /* Prompt for a file */
2492 prt("(1) Brief Object Info (obj-desc.spo)", 5, 5);
2493 prt("(2) Brief Artifact Info (artifact.spo)", 6, 5);
2494 prt("(3) Brief Monster Info (mon-desc.spo)", 7, 5);
2495 prt("(4) Full Monster Info (mon-info.spo)", 8, 5);
2496 prt("(5) Monster Evolution Info (mon-evol.spo)", 9, 5);
2500 prt("¥³¥Þ¥ó¥É:", 18, 0);
2502 prt("Command: ", 12, 0);
2510 /* Restore the screen */
2516 spoil_obj_desc("obj-desc.spo");
2521 spoil_artifact("artifact.spo");
2526 spoil_mon_desc("mon-desc.spo");
2531 spoil_mon_info("mon-info.spo");
2536 spoil_mon_evol("mon-evol.spo");
2545 /* Flush messages */
2551 * Fill in an object description structure for a given object
2553 static void random_artifact_analyze(object_type *o_ptr, obj_desc_list *desc_ptr)
2555 analyze_general(o_ptr, desc_ptr->description);
2556 analyze_pval(o_ptr, &desc_ptr->pval_info);
2557 analyze_brand(o_ptr, desc_ptr->brands);
2558 analyze_slay(o_ptr, desc_ptr->slays);
2559 analyze_immune(o_ptr, desc_ptr->immunities);
2560 analyze_resist(o_ptr, desc_ptr->resistances);
2561 analyze_sustains(o_ptr, desc_ptr->sustains);
2562 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
2563 desc_ptr->activation = item_activation(o_ptr);
2565 sprintf(desc_ptr->misc_desc, "½Å¤µ %d.%d kg",
2566 lbtokg1(o_ptr->weight), lbtokg2(o_ptr->weight));
2568 sprintf(desc_ptr->misc_desc, "Weight %d.%d lbs",
2569 o_ptr->weight / 10, o_ptr->weight % 10);
2573 /* Create a spoiler file entry for an artifact */
2575 static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
2577 pval_info_type *pval_ptr = &art_ptr->pval_info;
2581 /* Don't indent the first line */
2582 fprintf(fff, "%s\n", art_ptr->description);
2585 if (!(o_ptr->ident & (IDENT_MENTAL)))
2588 fprintf(fff, "%sÉÔÌÀ\n",INDENT1);
2590 fprintf(fff, "%sUnknown\n",INDENT1);
2594 /* An "empty" pval description indicates that the pval affects nothing */
2595 if (pval_ptr->pval_desc[0])
2597 /* Mention the effects of pval */
2599 sprintf(buf, "%s¤Î½¤Àµ:", pval_ptr->pval_desc);
2601 sprintf(buf, "%s to", pval_ptr->pval_desc);
2603 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
2606 /* Now deal with the description lists */
2609 spoiler_outlist("ÂÐ:", art_ptr->slays, ITEM_SEP);
2610 spoiler_outlist("Éð´ï°À:", art_ptr->brands, LIST_SEP);
2611 spoiler_outlist("ÌȱÖ:", art_ptr->immunities, ITEM_SEP);
2612 spoiler_outlist("ÂÑÀ:", art_ptr->resistances, ITEM_SEP);
2613 spoiler_outlist("°Ý»ý:", art_ptr->sustains, ITEM_SEP);
2615 spoiler_outlist("Slay", art_ptr->slays, ITEM_SEP);
2616 spoiler_outlist("", art_ptr->brands, LIST_SEP);
2617 spoiler_outlist("Immunity to", art_ptr->immunities, ITEM_SEP);
2618 spoiler_outlist("Resist", art_ptr->resistances, ITEM_SEP);
2619 spoiler_outlist("Sustain", art_ptr->sustains, ITEM_SEP);
2621 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
2623 /* Write out the possible activation at the primary indention level */
2624 if (art_ptr->activation)
2627 fprintf(fff, "%sȯư: %s\n", INDENT1, art_ptr->activation);
2629 fprintf(fff, "%sActivates for %s\n", INDENT1, art_ptr->activation);
2633 /* End with the miscellaneous facts */
2634 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
2637 /* Create a part of file for random artifacts */
2639 static void spoil_random_artifact_aux(object_type *o_ptr, int i)
2641 obj_desc_list artifact;
2643 if (!object_is_known(o_ptr) || !o_ptr->art_name
2644 || o_ptr->tval != group_artifact[i].tval)
2647 /* Analyze the artifact */
2648 random_artifact_analyze(o_ptr, &artifact);
2650 /* Write out the artifact description to the spoiler file */
2651 spoiler_print_randart(o_ptr, &artifact);
2655 * Create a list file for random artifacts
2657 void spoil_random_artifact(cptr fname)
2667 /* Build the filename */
2668 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2670 /* File type is "TEXT" */
2671 FILE_TYPE(FILE_TYPE_TEXT);
2674 fff = my_fopen(buf, "w");
2679 msg_print("Cannot create list file.");
2683 /* Dump the header */
2684 sprintf(buf, "Random artifacts list.\r");
2685 spoiler_underline(buf);
2687 /* List the artifacts by tval */
2688 for (j = 0; group_artifact[j].tval; j++)
2690 /* random artifacts wielding */
2691 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2693 q_ptr = &inventory[i];
2694 spoil_random_artifact_aux(q_ptr, j);
2697 /* random artifacts in inventory */
2698 for (i = 0; i < INVEN_PACK; i++)
2700 q_ptr = &inventory[i];
2701 spoil_random_artifact_aux(q_ptr, j);
2704 /* random artifacts in home */
2705 st_ptr = &town[1].store[STORE_HOME];
2706 for (i = 0; i < st_ptr->stock_num; i++)
2708 q_ptr = &st_ptr->stock[i];
2709 spoil_random_artifact_aux(q_ptr, j);
2712 /* random artifacts in museum */
2713 st_ptr = &town[1].store[STORE_MUSEUM];
2714 for (i = 0; i < st_ptr->stock_num; i++)
2716 q_ptr = &st_ptr->stock[i];
2717 spoil_random_artifact_aux(q_ptr, j);
2721 /* Check for errors */
2722 if (ferror(fff) || my_fclose(fff))
2724 msg_print("Cannot close list file.");
2729 msg_print("Successfully created a list file.");
2736 #endif /* MACINTOSH */