3 * @brief ウィザードモードの処理(スポイラー出力中心) / Spoiler generation -BEN-
6 * Copyright (c) 1997 Ben Harrison, and others
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
10 * 2013 Deskull rearranged comment for Doxygen.
14 #include "wizard/wizard-spoiler.h"
18 #include "core/angband-version.h"
21 #include "market/store.h"
22 #include "market/store-util.h"
24 #include "object-flavor.h"
25 #include "object-hook.h"
26 #include "object-ego.h"
27 #include "object/object-kind.h"
28 #include "floor/floor-town.h"
32 * The spoiler file being created
34 static FILE *fff = NULL;
37 * @brief シンボル職の記述名を返す /
38 * Extract a textual representation of an attribute
39 * @param r_ptr モンスター種族の構造体ポインタ
42 static concptr attr_to_text(monster_race *r_ptr)
44 if (r_ptr->flags1 & RF1_ATTR_CLEAR) return _("透明な", "Clear");
45 if (r_ptr->flags1 & RF1_ATTR_MULTI) return _("万色の", "Multi");
46 if (r_ptr->flags1 & RF1_ATTR_SEMIRAND) return _("準ランダムな", "S.Rand");
48 switch (r_ptr->d_attr)
50 case TERM_DARK: return _("黒い", "Dark");
51 case TERM_WHITE: return _("白い", "White");
52 case TERM_SLATE: return _("青灰色の", "Slate");
53 case TERM_ORANGE: return _("オレンジの", "Orange");
54 case TERM_RED: return _("赤い", "Red");
55 case TERM_GREEN: return _("緑の", "Green");
56 case TERM_BLUE: return _("青い", "Blue");
57 case TERM_UMBER: return _("琥珀色の", "Umber");
58 case TERM_L_DARK: return _("灰色の", "L.Dark");
59 case TERM_L_WHITE: return _("明るい青灰色の", "L.Slate");
60 case TERM_VIOLET: return _("紫の", "Violet");
61 case TERM_YELLOW: return _("黄色の", "Yellow");
62 case TERM_L_RED: return _("明るい赤の", "L.Red");
63 case TERM_L_GREEN: return _("明るい緑の", "L.Green");
64 case TERM_L_BLUE: return _("明るい青の", "L.Blue");
65 case TERM_L_UMBER: return _("明るい琥珀色の", "L.Umber");
68 return _("変な色の", "Icky");
78 OBJECT_TYPE_VALUE tval;
85 * Item Spoilers by: benh@phial.com (Ben Harrison)
90 * The basic items categorized by type
92 static grouper group_item[] =
94 { TV_SHOT, _("射撃物", "Ammo") },
97 { TV_BOW, _("弓", "Bows") },
98 { TV_DIGGING, _("武器", "Weapons") },
102 { TV_SOFT_ARMOR, _("防具 (体)", "Armour (Body)") },
103 { TV_HARD_ARMOR, NULL },
104 { TV_DRAG_ARMOR, NULL },
105 { TV_BOOTS, _("防具 (その他)", "Armour (Misc)") },
112 { TV_LITE, _("光源", "Light Sources") },
113 { TV_AMULET, _("アミュレット", "Amulets")},
114 { TV_RING, _("指輪", "Rings") },
115 { TV_STAFF, _("杖", "Staffs") },
116 { TV_WAND, _("魔法棒", "Wands") },
117 { TV_ROD, _("ロッド", "Rods") },
118 { TV_SCROLL, _("巻物", "Scrolls") },
119 { TV_POTION, _("薬", "Potions") },
120 { TV_FOOD, _("食料", "Food") },
122 { TV_LIFE_BOOK, _("魔法書 (生命)", "Books (Life)") },
123 { TV_SORCERY_BOOK, _("魔法書 (仙術)", "Books (Sorcery)") },
124 { TV_NATURE_BOOK, _("魔法書 (自然)", "Books (Nature)") },
125 { TV_CHAOS_BOOK, _("魔法書 (カオス)", "Books (Chaos)") },
126 { TV_DEATH_BOOK, _("魔法書 (暗黒)", "Books (Death)") },
127 { TV_TRUMP_BOOK, _("魔法書 (トランプ)", "Books (Trump)") },
128 { TV_ARCANE_BOOK, _("魔法書 (秘術)", "Books (Arcane)") },
129 { TV_CRAFT_BOOK, _("魔法書 (匠)", "Books (Craft)") },
130 { TV_DAEMON_BOOK, _("魔法書 (悪魔)", "Books (Daemon)") },
131 { TV_CRUSADE_BOOK, _("魔法書 (破邪)", "Books (Crusade)") },
132 { TV_MUSIC_BOOK, _("歌集", "Song Books") },
133 { TV_HISSATSU_BOOK, _("武芸の書", "Books (Kendo)") },
134 { TV_HEX_BOOK, _("魔法書 (呪術)", "Books (Hex)") },
136 { TV_WHISTLE, _("笛", "Whistle") },
137 { TV_CAPTURE, _("キャプチャー・ボール", "Capture Ball") },
138 { TV_CARD, _("エクスプレスカード", "Express Card") },
140 { TV_CHEST, _("箱", "Chests") },
142 { TV_FIGURINE, _("人形", "Magical Figurines") },
143 { TV_STATUE, _("像", "Statues") },
144 { TV_CORPSE, _("死体", "Corpses") },
146 { TV_SKELETON, _("その他", "Misc") },
151 { TV_PARCHMENT, NULL },
158 * @brief ベースアイテムの各情報を文字列化する /
160 * @param player_ptr プレーヤーへの参照ポインタ
161 * @param buf 名称を返すバッファ参照ポインタ
162 * @param dam ダメージダイス記述を返すバッファ参照ポインタ
163 * @param wgt 重量記述を返すバッファ参照ポインタ
164 * @param lev 生成階記述を返すバッファ参照ポインタ
165 * @param chance 生成機会を返すバッファ参照ポインタ
166 * @param val 価値を返すバッファ参照ポインタ
170 static void kind_info(player_type *player_ptr, char *buf, char *dam, char *wgt, char *chance, DEPTH *lev, PRICE *val, OBJECT_IDX k)
177 /* Prepare a fake item */
178 object_prep(q_ptr, k);
181 q_ptr->ident |= (IDENT_KNOWN);
189 (*lev) = k_info[q_ptr->k_idx].level;
190 (*val) = object_value(q_ptr);
192 if (!buf || !dam || !chance || !wgt) return;
194 /* Description (too brief) */
195 object_desc(player_ptr, buf, q_ptr, (OD_NAME_ONLY | OD_STORE));
214 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
224 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
239 sprintf(dam, "%d", q_ptr->ac);
246 for (i = 0; i < 4; i++)
248 char chance_aux[20] = "";
249 if (k_info[q_ptr->k_idx].chance[i] > 0)
251 sprintf(chance_aux, "%s%3dF:%+4d", (i != 0 ? "/" : ""),
252 (int)k_info[q_ptr->k_idx].locale[i], 100 / k_info[q_ptr->k_idx].chance[i]);
253 strcat(chance, chance_aux);
259 sprintf(wgt, "%3d.%d", (int)(q_ptr->weight / 10), (int)(q_ptr->weight % 10));
264 * @brief 各ベースアイテムの情報を一行毎に記述する /
265 * @param player_ptr プレーヤーへの参照ポインタ
266 * Create a spoiler file for items
270 static void spoil_obj_desc(player_type *player_ptr, concptr fname)
272 int i, k, s, t, n = 0, group_start = 0;
282 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
284 /* File type is "TEXT" */
285 FILE_TYPE(FILE_TYPE_TEXT);
286 fff = my_fopen(buf, "w");
290 msg_print("Cannot create spoiler file.");
296 fprintf(fff, "Spoiler File -- Basic Items (Hengband %d.%d.%d.%d)\n\n\n",
297 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH, FAKE_VER_EXTRA);
300 fprintf(fff, "%-37s%8s%7s%5s %40s%9s\n",
301 "Description", "Dam/AC", "Wgt", "Lev", "Chance", "Cost");
302 fprintf(fff, "%-37s%8s%7s%5s %40s%9s\n",
303 "-------------------------------------", "------", "---", "---", "----------------", "----");
305 /* List the groups */
306 for (i = 0; TRUE; i++)
308 /* Write out the group title */
309 if (group_item[i].name)
313 /* Hack -- bubble-sort by cost and then level */
314 for (s = 0; s < n - 1; s++)
316 for (t = 0; t < n - 1; t++)
327 kind_info(player_ptr, NULL, NULL, NULL, NULL, &e1, &t1, who[i1]);
328 kind_info(player_ptr, NULL, NULL, NULL, NULL, &e2, &t2, who[i2]);
330 if ((t1 > t2) || ((t1 == t2) && (e1 > e2)))
339 fprintf(fff, "\n\n%s\n\n", group_item[group_start].name);
341 /* Spoil each item */
342 for (s = 0; s < n; s++)
347 /* Describe the kind */
348 kind_info(player_ptr, buf, dam, wgt, chance, &e, &v, who[s]);
351 fprintf(fff, " %-35s%8s%7s%5d %-40s%9ld\n",
352 buf, dam, wgt, (int)e, chance, (long)(v));
355 /* Start a new set */
360 if (!group_item[i].tval) break;
362 /* Start a new set */
366 /* Acquire legal item types */
367 for (k = 1; k < max_k_idx; k++)
369 object_kind *k_ptr = &k_info[k];
371 /* Skip wrong tval's */
372 if (k_ptr->tval != group_item[i].tval) continue;
374 /* Hack -- Skip instant-artifacts */
375 if (k_ptr->gen_flags & (TRG_INSTA_ART)) continue;
383 /* Check for errors */
384 if (ferror(fff) || my_fclose(fff))
386 msg_print("Cannot close spoiler file.");
390 msg_print("Successfully created a spoiler file.");
395 * Artifact Spoilers by: randy@PICARD.tamu.edu (Randy Hutson)
400 * Returns a "+" string if a number is non-negative and an empty
403 #define POSITIZE(v) (((v) >= 0) ? "+" : "")
406 * These are used to format the artifact spoiler file. INDENT1 is used
407 * to indent all but the first line of an artifact spoiler. INDENT2 is
408 * used when a line "wraps". (Bladeturner's resistances cause this.)
414 * MAX_LINE_LEN specifies when a line should wrap.
416 #define MAX_LINE_LEN 75
419 * Given an array, determine how many elements are in the array
421 #define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))
424 * The artifacts categorized by type
426 static grouper group_artifact[] =
430 { TV_POLEARM, "槍/斧" },
432 { TV_DIGGING, "シャベル/つるはし" },
437 { TV_SOFT_ARMOR, "鎧" },
438 { TV_HARD_ARMOR, NULL },
439 { TV_DRAG_ARMOR, NULL },
441 { TV_CLOAK, "クローク" },
450 { TV_AMULET, "アミュレット" },
453 { TV_SWORD, "Edged Weapons" },
454 { TV_POLEARM, "Polearms" },
455 { TV_HAFTED, "Hafted Weapons" },
456 { TV_DIGGING, "Shovels/Picks" },
458 { TV_ARROW, "Ammo" },
461 { TV_SOFT_ARMOR, "Body Armor" },
462 { TV_HARD_ARMOR, NULL },
463 { TV_DRAG_ARMOR, NULL },
465 { TV_CLOAK, "Cloaks" },
466 { TV_SHIELD, "Shields" },
468 { TV_HELM, "Helms/Crowns" },
470 { TV_GLOVES, "Gloves" },
471 { TV_BOOTS, "Boots" },
473 { TV_LITE, "Light Sources" },
474 { TV_AMULET, "Amulets" },
475 { TV_RING, "Rings" },
484 * Pair together a constant flag with a textual description.
486 * Used by both "init.c" and "wiz-spo.c".
488 * Note that it sometimes more efficient to actually make an array
489 * of textual names, where entry 'N' is assumed to be paired with
490 * the flag whose value is "1L << N", but that requires hard-coding.
492 typedef struct flag_desc
501 * These are used for "+3 to STR, DEX", etc. These are separate from
502 * the other pval affected traits to simplify the case where an object
503 * affects all stats. In this case, "All stats" is used instead of
504 * listing each stat individually.
507 static flag_desc stat_flags_desc[] =
527 * Besides stats, these are the other player traits
528 * which may be affected by an object's pval
531 static flag_desc pval_flags1_desc[] =
534 { TR_MAGIC_MASTERY, "魔法道具使用能力" },
535 { TR_STEALTH, "隠密" },
537 { TR_INFRA, "赤外線視力" },
539 { TR_BLOWS, "攻撃回数" },
542 { TR_STEALTH, "Stealth" },
543 { TR_SEARCH, "Searching" },
544 { TR_INFRA, "Infravision" },
545 { TR_TUNNEL, "Tunneling" },
546 { TR_BLOWS, "Attacks" },
547 { TR_SPEED, "Speed" }
552 * Slaying preferences for weapons
555 static flag_desc slay_flags_desc[] =
558 { TR_SLAY_ANIMAL, "動物" },
559 { TR_KILL_ANIMAL, "*動物*" },
560 { TR_SLAY_EVIL, "邪悪" },
561 { TR_KILL_EVIL, "*邪悪*" },
562 { TR_SLAY_HUMAN, "人間" },
563 { TR_KILL_HUMAN, "*人間*" },
564 { TR_SLAY_UNDEAD, "アンデッド" },
565 { TR_KILL_UNDEAD, "*アンデッド*" },
566 { TR_SLAY_DEMON, "悪魔" },
567 { TR_KILL_DEMON, "*悪魔*" },
568 { TR_SLAY_ORC, "オーク" },
569 { TR_KILL_ORC, "*オーク*" },
570 { TR_SLAY_TROLL, "トロル" },
571 { TR_KILL_TROLL, "*トロル*" },
572 { TR_SLAY_GIANT, "巨人" },
573 { TR_KILL_GIANT, "*巨人*" },
574 { TR_SLAY_DRAGON, "ドラゴン" },
575 { TR_KILL_DRAGON, "*ドラゴン*" },
577 { TR_SLAY_ANIMAL, "Animal" },
578 { TR_KILL_ANIMAL, "XAnimal" },
579 { TR_SLAY_EVIL, "Evil" },
580 { TR_KILL_EVIL, "XEvil" },
581 { TR_SLAY_HUMAN, "Human" },
582 { TR_KILL_HUMAN, "XHuman" },
583 { TR_SLAY_UNDEAD, "Undead" },
584 { TR_KILL_UNDEAD, "XUndead" },
585 { TR_SLAY_DEMON, "Demon" },
586 { TR_KILL_DEMON, "XDemon" },
587 { TR_SLAY_ORC, "Orc" },
588 { TR_KILL_ORC, "XOrc" },
589 { TR_SLAY_TROLL, "Troll" },
590 { TR_KILL_TROLL, "XTroll" },
591 { TR_SLAY_GIANT, "Giant" },
592 { TR_KILL_GIANT, "Xgiant" },
593 { TR_SLAY_DRAGON, "Dragon" },
594 { TR_KILL_DRAGON, "Xdragon" }
599 * Elemental brands for weapons
601 * Clearly, TR1_IMPACT is a bit out of place here. To simplify
602 * coding, it has been included here along with the elemental
603 * brands. It does seem to fit in with the brands and slaying
604 * more than the miscellaneous section.
606 static flag_desc brand_flags_desc[] =
609 { TR_BRAND_ACID, "溶解" },
610 { TR_BRAND_ELEC, "電撃" },
611 { TR_BRAND_FIRE, "焼棄" },
612 { TR_BRAND_COLD, "凍結" },
613 { TR_BRAND_POIS, "毒殺" },
615 { TR_FORCE_WEAPON, "理力" },
616 { TR_CHAOTIC, "混沌" },
617 { TR_VAMPIRIC, "吸血" },
619 { TR_VORPAL, "切れ味" },
621 { TR_BRAND_ACID, "Acid Brand" },
622 { TR_BRAND_ELEC, "Lightning Brand" },
623 { TR_BRAND_FIRE, "Flame Tongue" },
624 { TR_BRAND_COLD, "Frost Brand" },
625 { TR_BRAND_POIS, "Poisoned" },
627 { TR_FORCE_WEAPON, "Force" },
628 { TR_CHAOTIC, "Mark of Chaos" },
629 { TR_VAMPIRIC, "Vampiric" },
630 { TR_IMPACT, "Earthquake impact on hit" },
631 { TR_VORPAL, "Very sharp" },
639 static const flag_desc resist_flags_desc[] =
642 { TR_RES_ACID, "酸" },
643 { TR_RES_ELEC, "電撃" },
644 { TR_RES_FIRE, "火炎" },
645 { TR_RES_COLD, "冷気" },
646 { TR_RES_POIS, "毒" },
647 { TR_RES_FEAR, "恐怖"},
648 { TR_RES_LITE, "閃光" },
649 { TR_RES_DARK, "暗黒" },
650 { TR_RES_BLIND, "盲目" },
651 { TR_RES_CONF, "混乱" },
652 { TR_RES_SOUND, "轟音" },
653 { TR_RES_SHARDS, "破片" },
654 { TR_RES_NETHER, "地獄" },
655 { TR_RES_NEXUS, "因果混乱" },
656 { TR_RES_CHAOS, "カオス" },
657 { TR_RES_DISEN, "劣化" },
659 { TR_RES_ACID, "Acid" },
660 { TR_RES_ELEC, "Lightning" },
661 { TR_RES_FIRE, "Fire" },
662 { TR_RES_COLD, "Cold" },
663 { TR_RES_POIS, "Poison" },
664 { TR_RES_FEAR, "Fear"},
665 { TR_RES_LITE, "Light" },
666 { TR_RES_DARK, "Dark" },
667 { TR_RES_BLIND, "Blindness" },
668 { TR_RES_CONF, "Confusion" },
669 { TR_RES_SOUND, "Sound" },
670 { TR_RES_SHARDS, "Shards" },
671 { TR_RES_NETHER, "Nether" },
672 { TR_RES_NEXUS, "Nexus" },
673 { TR_RES_CHAOS, "Chaos" },
674 { TR_RES_DISEN, "Disenchantment" },
679 * Elemental immunities (along with poison)
682 static const flag_desc immune_flags_desc[] =
686 { TR_IM_ELEC, "電撃" },
687 { TR_IM_FIRE, "火炎" },
688 { TR_IM_COLD, "冷気" },
690 { TR_IM_ACID, "Acid" },
691 { TR_IM_ELEC, "Lightning" },
692 { TR_IM_FIRE, "Fire" },
693 { TR_IM_COLD, "Cold" },
698 * Sustain stats - these are given their "own" line in the
699 * spoiler file, mainly for simplicity
701 static const flag_desc sustain_flags_desc[] =
704 { TR_SUST_STR, "腕力" },
705 { TR_SUST_INT, "知能" },
706 { TR_SUST_WIS, "賢さ" },
707 { TR_SUST_DEX, "器用さ" },
708 { TR_SUST_CON, "耐久力" },
709 { TR_SUST_CHR, "魅力" },
711 { TR_SUST_STR, "STR" },
712 { TR_SUST_INT, "INT" },
713 { TR_SUST_WIS, "WIS" },
714 { TR_SUST_DEX, "DEX" },
715 { TR_SUST_CON, "CON" },
716 { TR_SUST_CHR, "CHR" },
721 * Miscellaneous magic given by an object's "flags2" field
724 static const flag_desc misc_flags2_desc[] =
728 { TR_REFLECT, "反射" },
729 { TR_FREE_ACT, "麻痺知らず" },
730 { TR_HOLD_EXP, "経験値維持" },
732 { TR_THROW, "Throwing" },
733 { TR_REFLECT, "Reflection" },
734 { TR_FREE_ACT, "Free Action" },
735 { TR_HOLD_EXP, "Hold Experience" },
740 * Miscellaneous magic given by an object's "flags3" field
742 * Note that cursed artifacts and objects with permanent light
743 * are handled "directly" -- see analyze_misc_magic()
746 static const flag_desc misc_flags3_desc[] =
749 { TR_SH_FIRE, "火炎オーラ" },
750 { TR_SH_ELEC, "電撃オーラ" },
751 { TR_SH_COLD, "冷気オーラ" },
752 { TR_NO_TELE, "反テレポート" },
753 { TR_NO_MAGIC, "反魔法" },
754 { TR_LEVITATION, "浮遊" },
755 { TR_SEE_INVIS, "可視透明" },
756 { TR_TELEPATHY, "テレパシー" },
757 { TR_ESP_ANIMAL, "動物感知" },
758 { TR_ESP_UNDEAD, "不死感知" },
759 { TR_ESP_DEMON, "悪魔感知" },
760 { TR_ESP_ORC, "オーク感知" },
761 { TR_ESP_TROLL, "トロル感知" },
762 { TR_ESP_GIANT, "巨人感知" },
763 { TR_ESP_DRAGON, "ドラゴン感知" },
764 { TR_ESP_HUMAN, "人間感知" },
765 { TR_ESP_EVIL, "邪悪感知" },
766 { TR_ESP_GOOD, "善良感知" },
767 { TR_ESP_NONLIVING, "無生物感知" },
768 { TR_ESP_UNIQUE, "ユニーク感知" },
769 { TR_SLOW_DIGEST, "遅消化" },
770 { TR_REGEN, "急速回復" },
771 { TR_WARNING, "警告" },
772 /* { TR_XTRA_MIGHT, "強力射撃" }, */
773 { TR_XTRA_SHOTS, "追加射撃" }, /* always +1? */
774 { TR_DRAIN_EXP, "経験値吸収" },
775 { TR_AGGRAVATE, "反感" },
776 { TR_BLESSED, "祝福" },
777 { TR_DEC_MANA, "消費魔力減少" },
779 { TR_SH_FIRE, "Fiery Aura" },
780 { TR_SH_ELEC, "Electric Aura" },
781 { TR_SH_COLD, "Coldly Aura" },
782 { TR_NO_TELE, "Prevent Teleportation" },
783 { TR_NO_MAGIC, "Anti-Magic" },
784 { TR_LEVITATION, "Levitation" },
785 { TR_SEE_INVIS, "See Invisible" },
786 { TR_TELEPATHY, "ESP" },
787 { TR_ESP_ANIMAL, "Sense Animal" },
788 { TR_ESP_UNDEAD, "Sense Undead" },
789 { TR_ESP_DEMON, "Sense Demon" },
790 { TR_ESP_ORC, "Sense Orc" },
791 { TR_ESP_TROLL, "Sense Troll" },
792 { TR_ESP_GIANT, "Sense Giant" },
793 { TR_ESP_DRAGON, "Sense Dragon" },
794 { TR_ESP_HUMAN, "Sense Human" },
795 { TR_ESP_EVIL, "Sense Evil" },
796 { TR_ESP_GOOD, "Sense Good" },
797 { TR_ESP_NONLIVING, "Sense Nonliving" },
798 { TR_ESP_UNIQUE, "Sense Unique" },
799 { TR_SLOW_DIGEST, "Slow Digestion" },
800 { TR_REGEN, "Regeneration" },
801 { TR_WARNING, "Warning" },
802 /* { TR_XTRA_MIGHT, "Extra Might" }, */
803 { TR_XTRA_SHOTS, "+1 Extra Shot" }, /* always +1? */
804 { TR_DRAIN_EXP, "Drains Experience" },
805 { TR_AGGRAVATE, "Aggravates" },
806 { TR_BLESSED, "Blessed Blade" },
807 { TR_DEC_MANA, "Decrease Mana Consumption Rate" },
813 * A special type used just for deailing with pvals
818 * This will contain a string such as "+2", "-10", etc.
823 * A list of various player traits affected by an object's pval such
824 * as stats, speed, stealth, etc. "Extra attacks" is NOT included in
825 * this list since it will probably be desirable to format its
826 * description differently.
828 * Note that room need only be reserved for the number of stats - 1
829 * since the description "All stats" is used if an object affects all
830 * all stats. Also, room must be reserved for a sentinel NULL pointer.
832 * This will be a list such as ["STR", "DEX", "Stealth", NULL] etc.
834 * This list includes extra attacks, for simplicity.
836 concptr pval_affects[N_ELEMENTS(stat_flags_desc) - 1 +
837 N_ELEMENTS(pval_flags1_desc) + 1];
843 * An "object analysis structure"
845 * It will be filled with descriptive strings detailing an object's
846 * various magical powers. The "ignore X" traits are not noted since
847 * all artifacts ignore "normal" destruction.
852 /* "The Longsword Dragonsmiter (6d4) (+20, +25)" */
853 char description[MAX_NLEN];
855 /* Description of what is affected by an object's pval */
856 pval_info_type pval_info;
858 /* A list of an object's slaying preferences */
859 concptr slays[N_ELEMENTS(slay_flags_desc) + 1];
861 /* A list if an object's elemental brands */
862 concptr brands[N_ELEMENTS(brand_flags_desc) + 1];
864 /* A list of immunities granted by an object */
865 concptr immunities[N_ELEMENTS(immune_flags_desc) + 1];
867 /* A list of resistances granted by an object */
868 concptr resistances[N_ELEMENTS(resist_flags_desc) + 1];
870 /* A list of stats sustained by an object */
871 concptr sustains[N_ELEMENTS(sustain_flags_desc) - 1 + 1];
873 /* A list of various magical qualities an object may have */
874 concptr misc_magic[N_ELEMENTS(misc_flags2_desc) + N_ELEMENTS(misc_flags3_desc)
875 + 1 /* Permanent Light */
877 + 1 /* type of curse */
878 + 1]; /* sentinel NULL */
880 /* Additional ability or resistance */
883 /* A string describing an artifact's activation */
886 /* "Level 20, Rarity 30, 3.0 lbs, 20000 Gold" */
892 * @brief ファイルポインタ先に同じ文字を複数出力する /
893 * Write out `n' of the character `c' to the spoiler file
898 static void spoiler_out_n_chars(int n, char c)
900 while (--n >= 0) fputc(c, fff);
905 * @brief ファイルポインタ先に改行を複数出力する /
906 * Write out `n' blank lines to the spoiler file
910 static void spoiler_blanklines(int n)
912 spoiler_out_n_chars(n, '\n');
917 * @brief ファイルポインタ先に複数のハイフンで装飾した文字列を出力する /
918 * Write a line to the spoiler file and then "underline" it with hypens
919 * @param str 出力したい文字列
922 static void spoiler_underline(concptr str)
924 fprintf(fff, "%s\n", str);
925 spoiler_out_n_chars(strlen(str), '-');
932 * @brief アーティファクトの特性一覧を出力する /
933 * Write a line to the spoiler file and then "underline" it with hypens
934 * @param art_flags アーティファクトのフラグ群
935 * @param flag_ptr フラグ記述情報の参照ポインタ
936 * @param desc_ptr 記述内容を返すための文字列参照ポインタ
937 * @param n_elmnts フラグの要素数
938 * @return desc_ptrと同じアドレス
941 * This function does most of the actual "analysis". Given a set of bit flags
942 * (which will be from one of the flags fields from the object in question),
943 * a "flag description structure", a "description list", and the number of
944 * elements in the "flag description structure", this function sets the
945 * "description list" members to the appropriate descriptions contained in
946 * the "flag description structure".
947 * The possibly updated description pointer is returned.
950 static concptr *spoiler_flag_aux(const BIT_FLAGS art_flags[TR_FLAG_SIZE],
951 const flag_desc *flag_ptr,
952 concptr *desc_ptr, const int n_elmnts)
956 for (i = 0; i < n_elmnts; ++i)
958 if (have_flag(art_flags, flag_ptr[i].flag))
960 *desc_ptr++ = flag_ptr[i].desc;
969 * @brief アイテムの特定記述内容を返す /
970 * Acquire a "basic" description "The Cloak of Death [1,+10]"
971 * @param o_ptr 記述を得たいオブジェクトの参照ポインタ
972 * @param desc_ptr 記述内容を返すための文字列参照ポインタ
975 static void analyze_general(player_type *player_ptr, object_type *o_ptr, char *desc_ptr)
977 /* Get a "useful" description of the object */
978 object_desc(player_ptr, desc_ptr, o_ptr, (OD_NAME_AND_ENCHANT | OD_STORE));
983 * @brief アーティファクトがプレイヤーに与えるpval修正を構造体に収める /
984 * List "player traits" altered by an artifact's pval. These include stats,
985 * speed, infravision, tunneling, stealth, searching, and extra attacks.
986 * @param o_ptr オブジェクト構造体の参照ポインタ
987 * @param pi_ptr pval修正構造体の参照ポインタ
990 static void analyze_pval(object_type *o_ptr, pval_info_type *pi_ptr)
992 BIT_FLAGS flgs[TR_FLAG_SIZE];
994 concptr *affects_list;
996 /* If pval == 0, there is nothing to do. */
999 /* An "empty" pval description indicates that pval == 0 */
1000 pi_ptr->pval_desc[0] = '\0';
1003 object_flags(o_ptr, flgs);
1005 affects_list = pi_ptr->pval_affects;
1007 /* Create the "+N" string */
1008 sprintf(pi_ptr->pval_desc, "%s%d", POSITIZE(o_ptr->pval), o_ptr->pval);
1010 /* First, check to see if the pval affects all stats */
1011 if (have_flag(flgs, TR_STR) && have_flag(flgs, TR_INT) &&
1012 have_flag(flgs, TR_WIS) && have_flag(flgs, TR_DEX) &&
1013 have_flag(flgs, TR_CON) && have_flag(flgs, TR_CHR))
1015 *affects_list++ = _("全能力", "All stats");
1018 /* Are any stats affected? */
1019 else if (have_flag(flgs, TR_STR) || have_flag(flgs, TR_INT) ||
1020 have_flag(flgs, TR_WIS) || have_flag(flgs, TR_DEX) ||
1021 have_flag(flgs, TR_CON) || have_flag(flgs, TR_CHR))
1023 affects_list = spoiler_flag_aux(flgs, stat_flags_desc,
1025 N_ELEMENTS(stat_flags_desc));
1028 /* And now the "rest" */
1029 affects_list = spoiler_flag_aux(flgs, pval_flags1_desc,
1031 N_ELEMENTS(pval_flags1_desc));
1033 /* Terminate the description list */
1034 *affects_list = NULL;
1038 * @brief アーティファクトの種族スレイ特性を構造体に収める /
1039 * Note the slaying specialties of a weapon
1040 * @param o_ptr オブジェクト構造体の参照ポインタ
1041 * @param slay_list 種族スレイ構造体の参照ポインタ
1044 static void analyze_slay(object_type *o_ptr, concptr *slay_list)
1046 BIT_FLAGS flgs[TR_FLAG_SIZE];
1048 object_flags(o_ptr, flgs);
1050 slay_list = spoiler_flag_aux(flgs, slay_flags_desc, slay_list,
1051 N_ELEMENTS(slay_flags_desc));
1053 /* Terminate the description list */
1059 * @brief アーティファクトの属性ブランド特性を構造体に収める /
1060 * Note an object's elemental brands
1061 * @param o_ptr オブジェクト構造体の参照ポインタ
1062 * @param brand_list 属性ブランド構造体の参照ポインタ
1065 static void analyze_brand(object_type *o_ptr, concptr *brand_list)
1067 BIT_FLAGS flgs[TR_FLAG_SIZE];
1069 object_flags(o_ptr, flgs);
1071 brand_list = spoiler_flag_aux(flgs, brand_flags_desc, brand_list,
1072 N_ELEMENTS(brand_flags_desc));
1074 /* Terminate the description list */
1080 * @brief アーティファクトの通常耐性を構造体に収める /
1081 * Note an object's elemental brands
1082 * @param o_ptr オブジェクト構造体の参照ポインタ
1083 * @param resist_list 通常耐性構造体の参照ポインタ
1086 static void analyze_resist(object_type *o_ptr, concptr *resist_list)
1088 BIT_FLAGS flgs[TR_FLAG_SIZE];
1090 object_flags(o_ptr, flgs);
1092 resist_list = spoiler_flag_aux(flgs, resist_flags_desc,
1093 resist_list, N_ELEMENTS(resist_flags_desc));
1095 /* Terminate the description list */
1096 *resist_list = NULL;
1101 * @brief アーティファクトの免疫特性を構造体に収める /
1102 * Note the immunities granted by an object
1103 * @param o_ptr オブジェクト構造体の参照ポインタ
1104 * @param immune_list 免疫構造体の参照ポインタ
1107 static void analyze_immune(object_type *o_ptr, concptr *immune_list)
1109 BIT_FLAGS flgs[TR_FLAG_SIZE];
1111 object_flags(o_ptr, flgs);
1113 immune_list = spoiler_flag_aux(flgs, immune_flags_desc,
1114 immune_list, N_ELEMENTS(immune_flags_desc));
1116 /* Terminate the description list */
1117 *immune_list = NULL;
1122 * @brief アーティファクトの維持特性を構造体に収める /
1123 * Note which stats an object sustains
1124 * @param o_ptr オブジェクト構造体の参照ポインタ
1125 * @param sustain_list 維持特性構造体の参照ポインタ
1128 static void analyze_sustains(object_type *o_ptr, concptr *sustain_list)
1130 BIT_FLAGS flgs[TR_FLAG_SIZE];
1132 object_flags(o_ptr, flgs);
1134 /* Simplify things if an item sustains all stats */
1135 if (have_flag(flgs, TR_SUST_STR) && have_flag(flgs, TR_SUST_INT) &&
1136 have_flag(flgs, TR_SUST_WIS) && have_flag(flgs, TR_SUST_DEX) &&
1137 have_flag(flgs, TR_SUST_CON) && have_flag(flgs, TR_SUST_CHR))
1139 *sustain_list++ = _("全能力", "All stats");
1142 /* Should we bother? */
1143 else if (have_flag(flgs, TR_SUST_STR) || have_flag(flgs, TR_SUST_INT) ||
1144 have_flag(flgs, TR_SUST_WIS) || have_flag(flgs, TR_SUST_DEX) ||
1145 have_flag(flgs, TR_SUST_CON) || have_flag(flgs, TR_SUST_CHR))
1147 sustain_list = spoiler_flag_aux(flgs, sustain_flags_desc,
1149 N_ELEMENTS(sustain_flags_desc));
1152 /* Terminate the description list */
1153 *sustain_list = NULL;
1158 * @brief アーティファクトのその他の特性を構造体に収める /
1159 * Note miscellaneous powers bestowed by an artifact such as see invisible,
1160 * free action, permanent light, etc.
1161 * @param o_ptr オブジェクト構造体の参照ポインタ
1162 * @param misc_list その他の特性構造体の参照ポインタ
1165 static void analyze_misc_magic(object_type *o_ptr, concptr *misc_list)
1167 BIT_FLAGS flgs[TR_FLAG_SIZE];
1171 object_flags(o_ptr, flgs);
1173 misc_list = spoiler_flag_aux(flgs, misc_flags2_desc, misc_list,
1174 N_ELEMENTS(misc_flags2_desc));
1176 misc_list = spoiler_flag_aux(flgs, misc_flags3_desc, misc_list, N_ELEMENTS(misc_flags3_desc));
1179 * Glowing artifacts -- small radius light.
1182 if (have_flag(flgs, TR_LITE_1)) rad += 1;
1183 if (have_flag(flgs, TR_LITE_2)) rad += 2;
1184 if (have_flag(flgs, TR_LITE_3)) rad += 3;
1185 if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
1186 if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
1187 if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
1189 if (o_ptr->name2 == EGO_LITE_SHINE) rad++;
1191 if (have_flag(flgs, TR_LITE_FUEL))
1193 if (rad > 0) sprintf(desc, _("それは燃料補給によって明かり(半径 %d)を授ける。", "It provides light (radius %d) when fueled."), (int)rad);
1197 if (rad > 0) sprintf(desc, _("永久光源(半径 %d)", "Permanent Light(radius %d)"), (int)rad);
1198 if (rad < 0) sprintf(desc, _("永久光源(半径-%d)。", "Permanent Light(radius -%d)"), (int)-rad);
1201 if (rad != 0) *misc_list++ = quark_str(quark_add(desc));
1204 * Handle cursed objects here to avoid redundancies such as noting
1205 * that a permanently cursed object is heavily cursed as well as
1206 * being "lightly cursed".
1209 /* if (object_is_cursed(o_ptr)) */
1211 if (have_flag(flgs, TR_TY_CURSE))
1213 *misc_list++ = _("太古の怨念", "Ancient Curse");
1215 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1217 *misc_list++ = _("永遠の呪い", "Permanently Cursed");
1219 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1221 *misc_list++ = _("強力な呪い", "Heavily Cursed");
1224 else if (o_ptr->curse_flags & TRC_CURSED)
1226 *misc_list++ = _("呪い", "Cursed");
1228 if (have_flag(flgs, TR_ADD_L_CURSE))
1230 *misc_list++ = _("呪いを増やす", "Cursing");
1232 if (have_flag(flgs, TR_ADD_H_CURSE))
1234 *misc_list++ = _("強力な呪いを増やす", "Heavily Cursing");
1238 /* Terminate the description list */
1244 * @brief アーティファクトの追加ランダム特性を構造体に収める /
1245 * Note additional ability and/or resistance of fixed artifacts
1246 * @param o_ptr オブジェクト構造体の参照ポインタ
1247 * @param addition 追加ランダム耐性構造体の参照ポインタ
1250 static void analyze_addition(object_type *o_ptr, char *addition)
1252 artifact_type *a_ptr = &a_info[o_ptr->name1];
1255 strcpy(addition, "");
1257 if ((a_ptr->gen_flags & TRG_XTRA_POWER) && (a_ptr->gen_flags & TRG_XTRA_H_RES)) strcat(addition, _("能力and耐性", "Ability and Resistance"));
1258 else if (a_ptr->gen_flags & TRG_XTRA_POWER)
1260 strcat(addition, _("能力", "Ability"));
1261 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, _("(1/2でand耐性)", "(plus Resistance about 1/2)"));
1263 else if (a_ptr->gen_flags & TRG_XTRA_H_RES)
1265 strcat(addition, _("耐性", "Resistance"));
1266 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, _("(1/2でand能力)", "(plus Ability about 1/2)"));
1268 else if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, _("能力or耐性", "Ability or Resistance"));
1273 * @brief アーティファクトの基本情報を文字列に収める /
1274 * Determine the minimum depth an artifact can appear, its rarity, its weight,
1275 * and its value in gold pieces
1276 * @param o_ptr オブジェクト構造体の参照ポインタ
1277 * @param misc_desc 基本情報を収める文字列参照ポインタ
1280 static void analyze_misc(object_type *o_ptr, char *misc_desc)
1282 artifact_type *a_ptr = &a_info[o_ptr->name1];
1284 sprintf(misc_desc, _("レベル %d, 希少度 %u, %d.%d kg, $%ld", "Level %d, Rarity %u, %d.%d lbs, %ld Gold"), (int)a_ptr->level, a_ptr->rarity,
1286 lbtokg1(a_ptr->weight), lbtokg2(a_ptr->weight), (long int)a_ptr->cost);
1288 a_ptr->weight / 10, a_ptr->weight % 10, (long int)a_ptr->cost);
1294 * @brief アーティファクトの情報全体を構造体に収める /
1295 * Fill in an object description structure for a given object
1296 * and its value in gold pieces
1297 * @param player_ptr プレーヤーへの参照ポインタ
1298 * @param o_ptr オブジェクト構造体の参照ポインタ
1299 * @param desc_ptr 全アーティファクト情報を収める文字列参照ポインタ
1302 static void object_analyze(player_type *player_ptr, object_type *o_ptr, obj_desc_list *desc_ptr)
1304 analyze_general(player_ptr, o_ptr, desc_ptr->description);
1305 analyze_pval(o_ptr, &desc_ptr->pval_info);
1306 analyze_brand(o_ptr, desc_ptr->brands);
1307 analyze_slay(o_ptr, desc_ptr->slays);
1308 analyze_immune(o_ptr, desc_ptr->immunities);
1309 analyze_resist(o_ptr, desc_ptr->resistances);
1310 analyze_sustains(o_ptr, desc_ptr->sustains);
1311 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
1312 analyze_addition(o_ptr, desc_ptr->addition);
1313 analyze_misc(o_ptr, desc_ptr->misc_desc);
1314 desc_ptr->activation = item_activation(o_ptr);
1319 * @brief バッファにアーティファクト出力情報ヘッダを収める /
1322 static void print_header(void)
1326 sprintf(buf, "Artifact Spoilers for Hengband Version %d.%d.%d", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1327 spoiler_underline(buf);
1331 * This is somewhat ugly.
1333 * Given a header ("Resist", e.g.), a list ("Fire", "Cold", Acid", e.g.),
1334 * and a separator character (',', e.g.), write the list to the spoiler file
1335 * in a "nice" format, such as:
1337 * Resist Fire, Cold, Acid
1339 * That was a simple example, but when the list is long, a line wrap
1340 * should occur, and this should induce a new level of indention if
1341 * a list is being spread across lines. So for example, Bladeturner's
1342 * list of resistances should look something like this
1344 * Resist Acid, Lightning, Fire, Cold, Poison, Light, Dark, Blindness,
1345 * Confusion, Sound, Shards, Nether, Nexus, Chaos, Disenchantment
1347 * However, the code distinguishes between a single list of many items vs.
1348 * many lists. (The separator is used to make this determination.) A single
1349 * list of many items will not cause line wrapping (since there is no
1350 * apparent reason to do so). So the lists of Ulmo's miscellaneous traits
1351 * might look like this:
1353 * Free Action; Hold Life; See Invisible; Slow Digestion; Regeneration
1356 * So comparing the two, "Regeneration" has no trailing separator and
1357 * "Blessed Blade" was not indented. (Also, Ulmo's lists have no headers,
1358 * but that's not relevant to line wrapping and indention.)
1361 /* ITEM_SEP separates items within a list */
1362 #define ITEM_SEP ','
1365 /* LIST_SEP separates lists */
1367 #define LIST_SEP ','
1369 #define LIST_SEP ';'
1373 * @brief フラグ名称を出力する汎用関数
1374 * @param header ヘッダに出力するフラグ群の名前
1375 * @param list フラグ名リスト
1376 * @param separator フラグ表示の区切り記号
1379 static void spoiler_outlist(concptr header, concptr *list, char separator)
1381 int line_len, buf_len;
1382 char line[MAX_LINE_LEN + 1], buf[80];
1384 /* Ignore an empty list */
1385 if (*list == NULL) return;
1387 /* This function always indents */
1388 strcpy(line, INDENT1);
1390 /* Create header (if one was given) */
1391 if (header && (header[0]))
1393 strcat(line, header);
1397 line_len = strlen(line);
1399 /* Now begin the tedious task */
1402 /* Copy the current item to a buffer */
1405 /* Note the buffer's length */
1406 buf_len = strlen(buf);
1409 * If there is an item following this one, pad with separator and
1410 * a space and adjust the buffer length
1415 sprintf(buf + buf_len, "%c ", separator);
1420 * If the buffer will fit on the current line, just append the
1421 * buffer to the line and adjust the line length accordingly.
1424 if (line_len + buf_len <= MAX_LINE_LEN)
1427 line_len += buf_len;
1430 /* Apply line wrapping and indention semantics described above */
1434 * Don't print a trailing list separator but do print a trailing
1437 if (line_len > 1 && line[line_len - 1] == ' '
1438 && line[line_len - 2] == LIST_SEP)
1440 /* Ignore space and separator */
1441 line[line_len - 2] = '\0';
1443 /* Write to spoiler file */
1444 fprintf(fff, "%s\n", line);
1446 /* Begin new line at primary indention level */
1447 sprintf(line, "%s%s", INDENT1, buf);
1452 /* Write to spoiler file */
1453 fprintf(fff, "%s\n", line);
1455 /* Begin new line at secondary indention level */
1456 sprintf(line, "%s%s", INDENT2, buf);
1459 line_len = strlen(line);
1462 /* Advance, with break */
1463 if (!*++list) break;
1466 /* Write what's left to the spoiler file */
1467 fprintf(fff, "%s\n", line);
1471 * @brief アーティファクト一件をスポイラー出力する /
1472 * Create a spoiler file entry for an artifact
1473 * @param art_ptr アーティファクト情報をまとめた構造体の参照ポインタ
1476 static void spoiler_print_art(obj_desc_list *art_ptr)
1478 pval_info_type *pval_ptr = &art_ptr->pval_info;
1481 /* Don't indent the first line */
1482 fprintf(fff, "%s\n", art_ptr->description);
1484 /* An "empty" pval description indicates that the pval affects nothing */
1485 if (pval_ptr->pval_desc[0])
1487 /* Mention the effects of pval */
1488 sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc);
1489 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
1492 /* Now deal with the description lists */
1493 spoiler_outlist(_("対:", "Slay"), art_ptr->slays, ITEM_SEP);
1494 spoiler_outlist(_("武器属性:", ""), art_ptr->brands, LIST_SEP);
1495 spoiler_outlist(_("免疫:", "Immunity to"), art_ptr->immunities, ITEM_SEP);
1496 spoiler_outlist(_("耐性:", "Resist"), art_ptr->resistances, ITEM_SEP);
1497 spoiler_outlist(_("維持:", "Sustain"), art_ptr->sustains, ITEM_SEP);
1498 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
1500 if (art_ptr->addition[0])
1502 fprintf(fff, _("%s追加: %s\n", "%sAdditional %s\n"), INDENT1, art_ptr->addition);
1505 /* Write out the possible activation at the primary indention level */
1506 if (art_ptr->activation)
1508 fprintf(fff, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation);
1511 /* End with the miscellaneous facts */
1512 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
1517 * @brief アーティファクト情報を出力するためにダミー生成を行う /
1518 * Hack -- Create a "forged" artifact
1519 * @param o_ptr 一時生成先を保管するオブジェクト構造体
1520 * @param name1 生成するアーティファクトID
1521 * @return 生成が成功した場合TRUEを返す
1523 static bool make_fake_artifact(object_type *o_ptr, IDX name1)
1526 artifact_type *a_ptr = &a_info[name1];
1528 /* Ignore "empty" artifacts */
1529 if (!a_ptr->name) return FALSE;
1531 /* Acquire the "kind" index */
1532 i = lookup_kind(a_ptr->tval, a_ptr->sval);
1534 if (!i) return FALSE;
1536 object_prep(o_ptr, i);
1539 o_ptr->name1 = (byte)name1;
1541 /* Extract the fields */
1542 o_ptr->pval = a_ptr->pval;
1543 o_ptr->ac = a_ptr->ac;
1544 o_ptr->dd = a_ptr->dd;
1545 o_ptr->ds = a_ptr->ds;
1546 o_ptr->to_a = a_ptr->to_a;
1547 o_ptr->to_h = a_ptr->to_h;
1548 o_ptr->to_d = a_ptr->to_d;
1549 o_ptr->weight = a_ptr->weight;
1557 * @brief アーティファクト情報のスポイラー出力を行うメインルーチン /
1558 * Create a spoiler file for artifacts
1559 * @param player_ptr プレーヤーへの参照ポインタ
1560 * @param fname 生成ファイル名
1563 static void spoil_artifact(player_type *player_ptr, concptr fname)
1570 obj_desc_list artifact;
1572 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1574 /* File type is "TEXT" */
1575 FILE_TYPE(FILE_TYPE_TEXT);
1576 fff = my_fopen(buf, "w");
1580 msg_print("Cannot create spoiler file.");
1584 /* Dump the header */
1587 /* List the artifacts by tval */
1588 for (i = 0; group_artifact[i].tval; i++)
1590 /* Write out the group title */
1591 if (group_artifact[i].name)
1593 spoiler_blanklines(2);
1594 spoiler_underline(group_artifact[i].name);
1595 spoiler_blanklines(1);
1598 /* Now search through all of the artifacts */
1599 for (j = 1; j < max_a_idx; ++j)
1601 artifact_type *a_ptr = &a_info[j];
1603 /* We only want objects in the current group */
1604 if (a_ptr->tval != group_artifact[i].tval) continue;
1608 /* Attempt to "forge" the artifact */
1609 if (!make_fake_artifact(q_ptr, j)) continue;
1611 /* Analyze the artifact */
1612 object_analyze(player_ptr, q_ptr, &artifact);
1614 /* Write out the artifact description to the spoiler file */
1615 spoiler_print_art(&artifact);
1619 /* Check for errors */
1620 if (ferror(fff) || my_fclose(fff))
1622 msg_print("Cannot close spoiler file.");
1626 msg_print("Successfully created a spoiler file.");
1631 * @brief モンスター簡易情報のスポイラー出力を行うメインルーチン /
1632 * Create a spoiler file for monsters -BEN-
1633 * @param fname 生成ファイル名
1636 static void spoil_mon_desc(concptr fname)
1652 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1654 /* File type is "TEXT" */
1655 FILE_TYPE(FILE_TYPE_TEXT);
1656 fff = my_fopen(buf, "w");
1660 msg_print("Cannot create spoiler file.");
1664 /* Allocate the "who" array */
1665 C_MAKE(who, max_r_idx, MONRACE_IDX);
1667 /* Dump the header */
1668 fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1669 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1670 fprintf(fff, "------------------------------------------\n\n");
1672 /* Dump the header */
1673 fprintf(fff, " %-38.38s%4s%4s%4s%7s%5s %11.11s\n",
1674 "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
1675 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1676 "--------", "---", "---", "---", "--", "--", "-----------");
1679 /* Scan the monsters */
1680 for (i = 1; i < max_r_idx; i++)
1682 monster_race *r_ptr = &r_info[i];
1684 /* Use that monster */
1685 if (r_ptr->name) who[n++] = (s16b)i;
1688 /* Sort the array by dungeon depth of monsters */
1689 ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
1692 for (i = 0; i < n; i++)
1694 monster_race *r_ptr = &r_info[who[i]];
1696 concptr name = (r_name + r_ptr->name);
1697 if (r_ptr->flags7 & (RF7_KAGE)) continue;
1699 /* Get the "name" */
1701 else if (r_ptr->flags3 & (RF3_NO_CONF))
1703 sprintf(nam, "[*] %s", name);
1706 else if (r_ptr->flags1 & (RF1_UNIQUE))
1708 sprintf(nam, "[U] %s", name);
1712 sprintf(nam, _(" %s", "The %s"), name);
1716 sprintf(lev, "%d", (int)r_ptr->level);
1719 sprintf(rar, "%d", (int)r_ptr->rarity);
1721 if (r_ptr->speed >= 110)
1723 sprintf(spd, "+%d", (r_ptr->speed - 110));
1727 sprintf(spd, "-%d", (110 - r_ptr->speed));
1731 sprintf(ac, "%d", r_ptr->ac);
1734 if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
1736 sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
1740 sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
1745 sprintf(exp, "%ld", (long)(r_ptr->mexp));
1747 /* Hack -- use visual instead */
1748 sprintf(exp, "%s '%c'", attr_to_text(r_ptr), r_ptr->d_char);
1751 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1752 nam, lev, rar, spd, hp, ac, exp);
1759 /* Free the "who" array */
1760 C_KILL(who, max_r_idx, s16b);
1762 /* Check for errors */
1763 if (ferror(fff) || my_fclose(fff))
1765 msg_print("Cannot close spoiler file.");
1770 msg_print("Successfully created a spoiler file.");
1777 * Monster spoilers by: smchorse@ringer.cs.utsa.edu (Shawn McHorse)
1779 * Primarily based on code already in mon-desc.c, mostly by -BEN-
1785 * @brief 文字列をファイルポインタに出力する /
1786 * Buffer text to the given file. (-SHAWN-)
1787 * This is basically c_roff() from mon-desc.c with a few changes.
1788 * @param str 文字列参照ポインタ
1791 static void spoil_out(concptr str)
1796 static char roff_buf[256];
1799 static char roff_waiting_buf[256];
1802 bool iskanji_flag = FALSE;
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 /* Mega-Hack -- Delayed output */
1811 static bool waiting_output = FALSE;
1813 /* Special handling for "new sequence" */
1818 fputs(roff_waiting_buf, fff);
1819 waiting_output = FALSE;
1822 if (roff_p != roff_buf) roff_p--;
1823 while (*roff_p == ' ' && roff_p != roff_buf) roff_p--;
1825 if (roff_p == roff_buf) fprintf(fff, "\n");
1828 *(roff_p + 1) = '\0';
1829 fprintf(fff, "%s\n\n", roff_buf);
1838 /* Scan the given string, character at a time */
1843 bool k_flag = iskanji((unsigned char)(*str));
1846 bool wrap = (ch == '\n');
1849 if (!isprint((unsigned char)ch) && !k_flag && !iskanji_flag) ch = ' ';
1850 iskanji_flag = k_flag && !iskanji_flag;
1852 if (!isprint(ch)) ch = ' ';
1857 fputs(roff_waiting_buf, fff);
1858 if (!wrap) fputc('\n', fff);
1859 waiting_output = FALSE;
1865 if (roff_p >= roff_buf + (k_flag ? 74 : 75)) wrap = TRUE;
1866 else if ((ch == ' ') && (roff_p >= roff_buf + (k_flag ? 72 : 73))) wrap = TRUE;
1868 if (roff_p >= roff_buf + 75) wrap = TRUE;
1869 else if ((ch == ' ') && (roff_p >= roff_buf + 73)) wrap = TRUE;
1876 bool iskanji_flag_local = FALSE;
1877 concptr tail = str + (k_flag ? 2 : 1);
1879 concptr tail = str + 1;
1882 for (; *tail; tail++)
1884 if (*tail == ' ') continue;
1887 k_flag_local = iskanji((unsigned char)(*tail));
1888 if (isprint((unsigned char)*tail) || k_flag_local || iskanji_flag_local) break;
1889 iskanji_flag_local = k_flag_local && !iskanji_flag_local;
1891 if (isprint(*tail)) break;
1895 if (!*tail) waiting_output = TRUE;
1899 /* Handle line-wrap */
1907 if (roff_s && (ch != ' '))
1915 if (!waiting_output) fprintf(fff, "%s\n", roff_buf);
1916 else strcpy(roff_waiting_buf, roff_buf);
1920 if (cbak != ' ') *roff_p++ = cbak;
1922 while (*r) *roff_p++ = *r++;
1926 if ((roff_p > roff_buf) || (ch != ' '))
1931 if ((ch == ' ') || (ch == '(')) roff_s = roff_p;
1936 strncmp(str, "。", 2) != 0 &&
1937 strncmp(str, "、", 2) != 0 &&
1938 strncmp(str, "ィ", 2) != 0 &&
1939 strncmp(str, "ー", 2) != 0) roff_s = roff_p;
1942 if (ch == ' ') roff_s = roff_p;
1953 * @brief 関数ポインタ用の出力関数 /
1954 * Hook function used in spoil_mon_info()
1956 * @param str 文字列参照ポインタ
1959 static void roff_func(TERM_COLOR attr, concptr str)
1969 * @brief モンスター詳細情報をスポイラー出力するメインルーチン /
1970 * Create a spoiler file for monsters (-SHAWN-)
1971 * @param fname ファイル名
1974 static void spoil_mon_info(player_type *player_ptr, concptr fname)
1982 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1984 /* File type is "TEXT" */
1985 FILE_TYPE(FILE_TYPE_TEXT);
1986 fff = my_fopen(buf, "w");
1990 msg_print("Cannot create spoiler file.");
1995 /* Dump the header */
1996 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1997 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
2000 spoil_out("------------------------------------------\n\n");
2002 /* Allocate the "who" array */
2003 C_MAKE(who, max_r_idx, MONRACE_IDX);
2005 /* Scan the monsters */
2006 for (i = 1; i < max_r_idx; i++)
2008 monster_race *r_ptr = &r_info[i];
2010 /* Use that monster */
2011 if (r_ptr->name) who[n++] = (s16b)i;
2014 ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
2017 * List all monsters in order
2019 for (l = 0; l < n; l++)
2021 monster_race *r_ptr = &r_info[who[l]];
2022 flags1 = r_ptr->flags1;
2026 if (flags1 & (RF1_QUESTOR))
2032 if (flags1 & (RF1_UNIQUE))
2045 sprintf(buf, _("%s/%s (", "%s%s ("), (r_name + r_ptr->name), _(r_name + r_ptr->E_name, "")); /* ---)--- */
2050 spoil_out(attr_to_text(r_ptr));
2053 sprintf(buf, " '%c')\n", r_ptr->d_char);
2058 sprintf(buf, "=== ");
2062 sprintf(buf, "Num:%d ", who[l]);
2066 sprintf(buf, "Lev:%d ", (int)r_ptr->level);
2070 sprintf(buf, "Rar:%d ", r_ptr->rarity);
2073 if (r_ptr->speed >= 110)
2075 sprintf(buf, "Spd:+%d ", (r_ptr->speed - 110));
2079 sprintf(buf, "Spd:-%d ", (110 - r_ptr->speed));
2084 if ((flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
2086 sprintf(buf, "Hp:%d ", r_ptr->hdice * r_ptr->hside);
2090 sprintf(buf, "Hp:%dd%d ", r_ptr->hdice, r_ptr->hside);
2095 sprintf(buf, "Ac:%d ", r_ptr->ac);
2099 sprintf(buf, "Exp:%ld\n", (long)(r_ptr->mexp));
2102 /* Reuse the code of monster recall. */
2103 output_monster_spoiler(player_ptr, who[l], roff_func);
2108 /* Free the "who" array */
2109 C_KILL(who, max_r_idx, s16b);
2111 /* Check for errors */
2112 if (ferror(fff) || my_fclose(fff))
2114 msg_print("Cannot close spoiler file.");
2118 msg_print("Successfully created a spoiler file.");
2123 #define MAX_EVOL_DEPTH 64
2127 * @brief int配列でstrncmp()と似た比較処理を行う /
2128 * Compare two int-type array like strncmp() and return TRUE if equals
2129 * @param a 比較するint配列1
2130 * @param b 比較するint配列2
2132 * @return 両者の値が等しければTRUEを返す
2134 static bool int_n_cmp(int *a, int *b, int length)
2136 /* Null-string comparation is always TRUE */
2137 if (!length) return TRUE;
2141 if (*a != *(b++)) return FALSE;
2142 if (!(*(a++))) break;
2150 * @brief ある木が指定された木の部分木かどうかを返す /
2151 * Returns TRUE if an evolution tree is "partial tree"
2152 * @param tree 元となる木構造リスト
2153 * @param partial_tree 部分木かどうか判定したい木構造リスト
2154 * @return 部分木ならばTRUEを返す
2156 static bool is_partial_tree(int *tree, int *partial_tree)
2158 int pt_head = *(partial_tree++);
2161 while (partial_tree[pt_len]) pt_len++;
2165 if (*(tree++) == pt_head)
2167 if (int_n_cmp(tree, partial_tree, pt_len)) return TRUE;
2175 * @brief 進化ツリーをスポイラー出力するメインルーチン /
2176 * Print monsters' evolution information to file
2177 * @param fname 出力ファイル名
2180 static void spoil_mon_evol(concptr fname)
2183 monster_race *r_ptr;
2184 int **evol_tree, i, j, n, r_idx;
2185 int *evol_tree_zero; /* For C_KILL() */
2186 path_build(buf, sizeof buf, ANGBAND_DIR_USER, fname);
2188 /* File type is "TEXT" */
2189 FILE_TYPE(FILE_TYPE_TEXT);
2190 fff = my_fopen(buf, "w");
2194 msg_print("Cannot create spoiler file.");
2198 /* Dump the header */
2199 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
2200 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
2203 spoil_out("------------------------------------------\n\n");
2205 /* Allocate the "evol_tree" array (2-dimension) */
2206 C_MAKE(evol_tree, max_r_idx, int *);
2207 C_MAKE(*evol_tree, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
2208 for (i = 1; i < max_r_idx; i++) evol_tree[i] = *evol_tree + i * (MAX_EVOL_DEPTH + 1);
2209 evol_tree_zero = *evol_tree;
2211 /* Step 1: Build the evolution tree */
2212 for (i = 1; i < max_r_idx; i++)
2217 if (!r_ptr->next_exp) continue;
2219 /* Trace evolution */
2221 evol_tree[i][n++] = i;
2224 evol_tree[i][n++] = r_ptr->next_r_idx;
2225 r_ptr = &r_info[r_ptr->next_r_idx];
2226 } while (r_ptr->next_exp && (n < MAX_EVOL_DEPTH));
2229 /* Step 2: Scan the evolution trees and remove "partial tree" */
2230 for (i = 1; i < max_r_idx; i++)
2232 /* Not evolution tree */
2233 if (!evol_tree[i][0]) continue;
2235 for (j = 1; j < max_r_idx; j++)
2238 if (i == j) continue;
2240 /* Not evolution tree */
2241 if (!evol_tree[j][0]) continue;
2243 /* Is evolution tree[i] is part of [j]? */
2244 if (is_partial_tree(evol_tree[j], evol_tree[i]))
2246 /* Remove this evolution tree */
2247 evol_tree[i][0] = 0;
2253 /* Step 3: Sort the evolution trees */
2254 ang_sort(evol_tree, NULL, max_r_idx, ang_sort_comp_evol_tree, ang_sort_swap_evol_tree);
2256 /* Step 4: Print the evolution trees */
2257 for (i = 0; i < max_r_idx; i++)
2259 r_idx = evol_tree[i][0];
2261 /* No evolution or removed evolution tree */
2262 if (!r_idx) continue;
2264 /* Trace the evolution tree */
2265 r_ptr = &r_info[r_idx];
2266 fprintf(fff, _("[%d]: %s (レベル%d, '%c')\n", "[%d]: %s (Level %d, '%c')\n"),
2267 r_idx, r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char);
2269 for (n = 1; r_ptr->next_exp; n++)
2271 fprintf(fff, "%*s-(%ld)-> ", n * 2, "", (long int)r_ptr->next_exp);
2272 fprintf(fff, "[%d]: ", r_ptr->next_r_idx);
2273 r_ptr = &r_info[r_ptr->next_r_idx];
2274 fprintf(fff, _("%s (レベル%d, '%c')\n", "%s (Level %d, '%c')\n"),
2275 r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char);
2278 /* End of evolution tree */
2282 /* Free the "evol_tree" array (2-dimension) */
2283 C_KILL(evol_tree_zero, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
2284 C_KILL(evol_tree, max_r_idx, int *);
2286 /* Check for errors */
2287 if (ferror(fff) || my_fclose(fff))
2289 msg_print("Cannot close spoiler file.");
2293 msg_print("Successfully created a spoiler file.");
2298 * @brief スポイラー出力を行うコマンドのメインルーチン /
2299 * Create Spoiler files -BEN-
2302 void do_cmd_spoilers(player_type *player_ptr)
2312 prt("Create a spoiler file.", 2, 0);
2314 /* Prompt for a file */
2315 prt("(1) Brief Object Info (obj-desc.txt)", 5, 5);
2316 prt("(2) Brief Artifact Info (artifact.txt)", 6, 5);
2317 prt("(3) Brief Monster Info (mon-desc.txt)", 7, 5);
2318 prt("(4) Full Monster Info (mon-info.txt)", 8, 5);
2319 prt("(5) Monster Evolution Info (mon-evol.txt)", 9, 5);
2322 prt(_("コマンド:", "Command: "), _(18, 12), 0);
2334 spoil_obj_desc(player_ptr, "obj-desc.txt");
2339 spoil_artifact(player_ptr, "artifact.txt");
2344 spoil_mon_desc("mon-desc.txt");
2349 spoil_mon_info(player_ptr, "mon-info.txt");
2354 spoil_mon_evol("mon-evol.txt");
2367 * @brief ランダムアーティファクト1件を解析する /
2368 * Fill in an object description structure for a given object
2369 * @param player_ptr プレーヤーへの参照ポインタ
2370 * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
2371 * @param desc_ptr 記述内容を収める構造体参照ポインタ
2374 static void random_artifact_analyze(player_type *player_ptr, object_type *o_ptr, obj_desc_list *desc_ptr)
2376 analyze_general(player_ptr, o_ptr, desc_ptr->description);
2377 analyze_pval(o_ptr, &desc_ptr->pval_info);
2378 analyze_brand(o_ptr, desc_ptr->brands);
2379 analyze_slay(o_ptr, desc_ptr->slays);
2380 analyze_immune(o_ptr, desc_ptr->immunities);
2381 analyze_resist(o_ptr, desc_ptr->resistances);
2382 analyze_sustains(o_ptr, desc_ptr->sustains);
2383 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
2384 desc_ptr->activation = item_activation(o_ptr);
2386 sprintf(desc_ptr->misc_desc, "重さ %d.%d kg",
2387 lbtokg1(o_ptr->weight), lbtokg2(o_ptr->weight));
2389 sprintf(desc_ptr->misc_desc, "Weight %d.%d lbs",
2390 o_ptr->weight / 10, o_ptr->weight % 10);
2395 * @brief ランダムアーティファクト1件をスポイラー出力する /
2396 * Create a spoiler file entry for an artifact
2397 * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
2398 * @param art_ptr 記述内容を収めた構造体参照ポインタ
2399 * Fill in an object description structure for a given object
2402 static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
2404 pval_info_type *pval_ptr = &art_ptr->pval_info;
2408 /* Don't indent the first line */
2409 fprintf(fff, "%s\n", art_ptr->description);
2412 if (!OBJECT_IS_FULL_KNOWN(o_ptr))
2414 fprintf(fff, _("%s不明\n", "%sUnknown\n"), INDENT1);
2417 /* An "empty" pval description indicates that the pval affects nothing */
2418 if (pval_ptr->pval_desc[0])
2420 /* Mention the effects of pval */
2421 sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc);
2422 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
2425 /* Now deal with the description lists */
2427 spoiler_outlist(_("対:", "Slay"), art_ptr->slays, ITEM_SEP);
2428 spoiler_outlist(_("武器属性:", ""), art_ptr->brands, LIST_SEP);
2429 spoiler_outlist(_("免疫:", "Immunity to"), art_ptr->immunities, ITEM_SEP);
2430 spoiler_outlist(_("耐性:", "Resist"), art_ptr->resistances, ITEM_SEP);
2431 spoiler_outlist(_("維持:", "Sustain"), art_ptr->sustains, ITEM_SEP);
2432 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
2434 /* Write out the possible activation at the primary indention level */
2435 if (art_ptr->activation)
2437 fprintf(fff, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation);
2440 /* End with the miscellaneous facts */
2441 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
2446 * @brief ランダムアーティファクト内容をスポイラー出力するサブルーチン /
2447 * @param player_ptr プレーヤーへの参照ポインタ
2448 * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
2449 * @param i 出力したい記録ランダムアーティファクトID
2452 static void spoil_random_artifact_aux(player_type *player_ptr, object_type *o_ptr, int i)
2454 obj_desc_list artifact;
2456 if (!object_is_known(o_ptr) || !o_ptr->art_name
2457 || o_ptr->tval != group_artifact[i].tval)
2460 /* Analyze the artifact */
2461 random_artifact_analyze(player_ptr, o_ptr, &artifact);
2463 /* Write out the artifact description to the spoiler file */
2464 spoiler_print_randart(o_ptr, &artifact);
2468 * @brief ランダムアーティファクト内容をスポイラー出力するメインルーチン /
2469 * Create a list file for random artifacts
2470 * @param fname 出力ファイル名
2473 void spoil_random_artifact(player_type *creature_ptr, concptr fname)
2477 store_type *store_ptr;
2481 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2483 /* File type is "TEXT" */
2484 FILE_TYPE(FILE_TYPE_TEXT);
2485 fff = my_fopen(buf, "w");
2489 msg_print("Cannot create list file.");
2493 /* Dump the header */
2494 sprintf(buf, "Random artifacts list.\r");
2495 spoiler_underline(buf);
2497 /* List the artifacts by tval */
2498 for (j = 0; group_artifact[j].tval; j++)
2500 /* random artifacts wielding */
2501 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2503 q_ptr = &creature_ptr->inventory_list[i];
2504 spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2507 for (i = 0; i < INVEN_PACK; i++)
2509 q_ptr = &creature_ptr->inventory_list[i];
2510 spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2513 /* random artifacts in home */
2514 store_ptr = &town_info[1].store[STORE_HOME];
2515 for (i = 0; i < store_ptr->stock_num; i++)
2517 q_ptr = &store_ptr->stock[i];
2518 spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2521 /* random artifacts in museum */
2522 store_ptr = &town_info[1].store[STORE_MUSEUM];
2523 for (i = 0; i < store_ptr->stock_num; i++)
2525 q_ptr = &store_ptr->stock[i];
2526 spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2530 /* Check for errors */
2531 if (ferror(fff) || my_fclose(fff))
2533 msg_print("Cannot close list file.");
2537 msg_print("Successfully created a list file.");