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.
22 #include "object-flavor.h"
23 #include "object-hook.h"
24 #include "object-ego.h"
25 #include "objectkind.h"
26 #include "floor-town.h"
34 * The spoiler file being created
36 static FILE *fff = NULL;
41 * @brief シンボル職の記述名を返す /
42 * Extract a textual representation of an attribute
43 * @param r_ptr モンスター種族の構造体ポインタ
46 static concptr attr_to_text(monster_race *r_ptr)
49 if (r_ptr->flags1 & RF1_ATTR_CLEAR) return "透明な";
50 if (r_ptr->flags1 & RF1_ATTR_MULTI) return "万色の";
51 if (r_ptr->flags1 & RF1_ATTR_SEMIRAND) return "準ランダムな";
53 if (r_ptr->flags1 & RF1_ATTR_CLEAR) return "Clear";
54 if (r_ptr->flags1 & RF1_ATTR_MULTI) return "Multi";
55 if (r_ptr->flags1 & RF1_ATTR_SEMIRAND) return "S.Rand";
58 switch (r_ptr->d_attr)
61 case TERM_DARK: return "XXXい";
62 case TERM_WHITE: return "白い";
63 case TERM_SLATE: return "青灰色の";
64 case TERM_ORANGE: return "オレンジの";
65 case TERM_RED: return "赤い";
66 case TERM_GREEN: return "緑の";
67 case TERM_BLUE: return "青い";
68 case TERM_UMBER: return "琥珀色の";
69 case TERM_L_DARK: return "灰色の";
70 case TERM_L_WHITE: return "明青灰色の";
71 case TERM_VIOLET: return "紫の";
72 case TERM_YELLOW: return "黄色い";
73 case TERM_L_RED: return "明い赤の";
74 case TERM_L_GREEN: return "明い緑の";
75 case TERM_L_BLUE: return "明い青の";
76 case TERM_L_UMBER: return "明い琥珀色の";
78 case TERM_DARK: return "xxx";
79 case TERM_WHITE: return "White";
80 case TERM_SLATE: return "Slate";
81 case TERM_ORANGE: return "Orange";
82 case TERM_RED: return "Red";
83 case TERM_GREEN: return "Green";
84 case TERM_BLUE: return "Blue";
85 case TERM_UMBER: return "Umber";
86 case TERM_L_DARK: return "L.Dark";
87 case TERM_L_WHITE: return "L.Slate";
88 case TERM_VIOLET: return "Violet";
89 case TERM_YELLOW: return "Yellow";
90 case TERM_L_RED: return "L.Red";
91 case TERM_L_GREEN: return "L.Green";
92 case TERM_L_BLUE: return "L.Blue";
93 case TERM_L_UMBER: return "L.Umber";
111 OBJECT_TYPE_VALUE tval;
118 * Item Spoilers by: benh@phial.com (Ben Harrison)
123 * The basic items categorized by type
125 static grouper group_item[] =
127 { TV_SHOT, _("射撃物", "Ammo") },
130 { TV_BOW, _("弓", "Bows") },
131 { TV_DIGGING, _("武器", "Weapons") },
132 { TV_POLEARM, NULL },
135 { TV_SOFT_ARMOR, _("防具 (体)", "Armour (Body)") },
136 { TV_HARD_ARMOR, NULL },
137 { TV_DRAG_ARMOR, NULL },
138 { TV_BOOTS, _("防具 (その他)", "Armour (Misc)") },
145 { TV_LITE, _("光源", "Light Sources") },
146 { TV_AMULET, _("アミュレット", "Amulets")},
147 { TV_RING, _("指輪", "Rings") },
148 { TV_STAFF, _("杖", "Staffs") },
149 { TV_WAND, _("魔法棒", "Wands") },
150 { TV_ROD, _("ロッド", "Rods") },
151 { TV_SCROLL, _("巻物", "Scrolls") },
152 { TV_POTION, _("薬", "Potions") },
153 { TV_FOOD, _("食料", "Food") },
155 { TV_LIFE_BOOK, _("魔法書 (生命)", "Books (Life)") },
156 { TV_SORCERY_BOOK, _("魔法書 (仙術)", "Books (Sorcery)") },
157 { TV_NATURE_BOOK, _("魔法書 (自然)", "Books (Nature)") },
158 { TV_CHAOS_BOOK, _("魔法書 (カオス)", "Books (Chaos)") },
159 { TV_DEATH_BOOK, _("魔法書 (暗黒)", "Books (Death)") },
160 { TV_TRUMP_BOOK, _("魔法書 (トランプ)", "Books (Trump)") },
161 { TV_ARCANE_BOOK, _("魔法書 (秘術)", "Books (Arcane)") },
162 { TV_CRAFT_BOOK, _("魔法書 (匠)", "Books (Craft)") },
163 { TV_DAEMON_BOOK, _("魔法書 (悪魔)", "Books (Daemon)") },
164 { TV_CRUSADE_BOOK, _("魔法書 (破邪)", "Books (Crusade)") },
165 { TV_MUSIC_BOOK, _("歌集", "Song Books") },
166 { TV_HISSATSU_BOOK, _("武芸の書", "Books (Kendo)") },
167 { TV_HEX_BOOK, _("魔法書 (呪術)", "Books (Hex)") },
169 { TV_WHISTLE, _("笛", "Whistle") },
170 { TV_CAPTURE, _("キャプチャー・ボール", "Capture Ball") },
171 { TV_CARD, _("エクスプレスカード", "Express Card") },
173 { TV_CHEST, _("箱", "Chests") },
175 { TV_FIGURINE, _("人形", "Magical Figurines") },
176 { TV_STATUE, _("像", "Statues") },
177 { TV_CORPSE, _("死体", "Corpses") },
179 { TV_SKELETON, _("その他", "Misc") },
184 { TV_PARCHMENT, NULL },
191 * @brief ベースアイテムの各情報を文字列化する /
193 * @param player_ptr プレーヤーへの参照ポインタ
194 * @param buf 名称を返すバッファ参照ポインタ
195 * @param dam ダメージダイス記述を返すバッファ参照ポインタ
196 * @param wgt 重量記述を返すバッファ参照ポインタ
197 * @param lev 生成階記述を返すバッファ参照ポインタ
198 * @param chance 生成機会を返すバッファ参照ポインタ
199 * @param val 価値を返すバッファ参照ポインタ
203 static void kind_info(player_type *player_ptr, char *buf, char *dam, char *wgt, char *chance, DEPTH *lev, PRICE *val, OBJECT_IDX k)
210 /* Prepare a fake item */
211 object_prep(q_ptr, k);
214 q_ptr->ident |= (IDENT_KNOWN);
222 (*lev) = k_info[q_ptr->k_idx].level;
223 (*val) = object_value(q_ptr);
225 if (!buf || !dam || !chance || !wgt) return;
227 /* Description (too brief) */
228 object_desc(player_ptr, buf, q_ptr, (OD_NAME_ONLY | OD_STORE));
247 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
257 sprintf(dam, "%dd%d", q_ptr->dd, q_ptr->ds);
272 sprintf(dam, "%d", q_ptr->ac);
279 for (i = 0; i < 4; i++)
281 char chance_aux[20] = "";
282 if (k_info[q_ptr->k_idx].chance[i] > 0)
284 sprintf(chance_aux, "%s%3dF:%+4d", (i != 0 ? "/" : ""),
285 (int)k_info[q_ptr->k_idx].locale[i], 100 / k_info[q_ptr->k_idx].chance[i]);
286 strcat(chance, chance_aux);
292 sprintf(wgt, "%3d.%d", (int)(q_ptr->weight / 10), (int)(q_ptr->weight % 10));
297 * @brief 各ベースアイテムの情報を一行毎に記述する /
298 * @param player_ptr プレーヤーへの参照ポインタ
299 * Create a spoiler file for items
303 static void spoil_obj_desc(player_type *player_ptr, concptr fname)
305 int i, k, s, t, n = 0, group_start = 0;
315 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
317 /* File type is "TEXT" */
318 FILE_TYPE(FILE_TYPE_TEXT);
319 fff = my_fopen(buf, "w");
323 msg_print("Cannot create spoiler file.");
329 fprintf(fff, "Spoiler File -- Basic Items (Hengband %d.%d.%d.%d)\n\n\n",
330 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH, FAKE_VER_EXTRA);
333 fprintf(fff, "%-37s%8s%7s%5s %40s%9s\n",
334 "Description", "Dam/AC", "Wgt", "Lev", "Chance", "Cost");
335 fprintf(fff, "%-37s%8s%7s%5s %40s%9s\n",
336 "-------------------------------------", "------", "---", "---", "----------------", "----");
338 /* List the groups */
339 for (i = 0; TRUE; i++)
341 /* Write out the group title */
342 if (group_item[i].name)
346 /* Hack -- bubble-sort by cost and then level */
347 for (s = 0; s < n - 1; s++)
349 for (t = 0; t < n - 1; t++)
360 kind_info(player_ptr, NULL, NULL, NULL, NULL, &e1, &t1, who[i1]);
361 kind_info(player_ptr, NULL, NULL, NULL, NULL, &e2, &t2, who[i2]);
363 if ((t1 > t2) || ((t1 == t2) && (e1 > e2)))
372 fprintf(fff, "\n\n%s\n\n", group_item[group_start].name);
374 /* Spoil each item */
375 for (s = 0; s < n; s++)
380 /* Describe the kind */
381 kind_info(player_ptr, buf, dam, wgt, chance, &e, &v, who[s]);
384 fprintf(fff, " %-35s%8s%7s%5d %-40s%9ld\n",
385 buf, dam, wgt, (int)e, chance, (long)(v));
388 /* Start a new set */
393 if (!group_item[i].tval) break;
395 /* Start a new set */
399 /* Acquire legal item types */
400 for (k = 1; k < max_k_idx; k++)
402 object_kind *k_ptr = &k_info[k];
404 /* Skip wrong tval's */
405 if (k_ptr->tval != group_item[i].tval) continue;
407 /* Hack -- Skip instant-artifacts */
408 if (k_ptr->gen_flags & (TRG_INSTA_ART)) continue;
416 /* Check for errors */
417 if (ferror(fff) || my_fclose(fff))
419 msg_print("Cannot close spoiler file.");
423 msg_print("Successfully created a spoiler file.");
428 * Artifact Spoilers by: randy@PICARD.tamu.edu (Randy Hutson)
433 * Returns a "+" string if a number is non-negative and an empty
436 #define POSITIZE(v) (((v) >= 0) ? "+" : "")
439 * These are used to format the artifact spoiler file. INDENT1 is used
440 * to indent all but the first line of an artifact spoiler. INDENT2 is
441 * used when a line "wraps". (Bladeturner's resistances cause this.)
447 * MAX_LINE_LEN specifies when a line should wrap.
449 #define MAX_LINE_LEN 75
452 * Given an array, determine how many elements are in the array
454 #define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))
457 * The artifacts categorized by type
459 static grouper group_artifact[] =
463 { TV_POLEARM, "槍/斧" },
465 { TV_DIGGING, "シャベル/つるはし" },
470 { TV_SOFT_ARMOR, "鎧" },
471 { TV_HARD_ARMOR, NULL },
472 { TV_DRAG_ARMOR, NULL },
474 { TV_CLOAK, "クローク" },
483 { TV_AMULET, "アミュレット" },
486 { TV_SWORD, "Edged Weapons" },
487 { TV_POLEARM, "Polearms" },
488 { TV_HAFTED, "Hafted Weapons" },
489 { TV_DIGGING, "Shovels/Picks" },
491 { TV_ARROW, "Ammo" },
494 { TV_SOFT_ARMOR, "Body Armor" },
495 { TV_HARD_ARMOR, NULL },
496 { TV_DRAG_ARMOR, NULL },
498 { TV_CLOAK, "Cloaks" },
499 { TV_SHIELD, "Shields" },
501 { TV_HELM, "Helms/Crowns" },
503 { TV_GLOVES, "Gloves" },
504 { TV_BOOTS, "Boots" },
506 { TV_LITE, "Light Sources" },
507 { TV_AMULET, "Amulets" },
508 { TV_RING, "Rings" },
517 * Pair together a constant flag with a textual description.
519 * Used by both "init.c" and "wiz-spo.c".
521 * Note that it sometimes more efficient to actually make an array
522 * of textual names, where entry 'N' is assumed to be paired with
523 * the flag whose value is "1L << N", but that requires hard-coding.
526 typedef struct flag_desc flag_desc;
537 * These are used for "+3 to STR, DEX", etc. These are separate from
538 * the other pval affected traits to simplify the case where an object
539 * affects all stats. In this case, "All stats" is used instead of
540 * listing each stat individually.
543 static flag_desc stat_flags_desc[] =
563 * Besides stats, these are the other player traits
564 * which may be affected by an object's pval
567 static flag_desc pval_flags1_desc[] =
570 { TR_MAGIC_MASTERY, "魔法道具使用能力" },
571 { TR_STEALTH, "隠密" },
573 { TR_INFRA, "赤外線視力" },
575 { TR_BLOWS, "攻撃回数" },
578 { TR_STEALTH, "Stealth" },
579 { TR_SEARCH, "Searching" },
580 { TR_INFRA, "Infravision" },
581 { TR_TUNNEL, "Tunneling" },
582 { TR_BLOWS, "Attacks" },
583 { TR_SPEED, "Speed" }
588 * Slaying preferences for weapons
591 static flag_desc slay_flags_desc[] =
594 { TR_SLAY_ANIMAL, "動物" },
595 { TR_KILL_ANIMAL, "*動物*" },
596 { TR_SLAY_EVIL, "邪悪" },
597 { TR_KILL_EVIL, "*邪悪*" },
598 { TR_SLAY_HUMAN, "人間" },
599 { TR_KILL_HUMAN, "*人間*" },
600 { TR_SLAY_UNDEAD, "アンデッド" },
601 { TR_KILL_UNDEAD, "*アンデッド*" },
602 { TR_SLAY_DEMON, "悪魔" },
603 { TR_KILL_DEMON, "*悪魔*" },
604 { TR_SLAY_ORC, "オーク" },
605 { TR_KILL_ORC, "*オーク*" },
606 { TR_SLAY_TROLL, "トロル" },
607 { TR_KILL_TROLL, "*トロル*" },
608 { TR_SLAY_GIANT, "巨人" },
609 { TR_KILL_GIANT, "*巨人*" },
610 { TR_SLAY_DRAGON, "ドラゴン" },
611 { TR_KILL_DRAGON, "*ドラゴン*" },
613 { TR_SLAY_ANIMAL, "Animal" },
614 { TR_KILL_ANIMAL, "XAnimal" },
615 { TR_SLAY_EVIL, "Evil" },
616 { TR_KILL_EVIL, "XEvil" },
617 { TR_SLAY_HUMAN, "Human" },
618 { TR_KILL_HUMAN, "XHuman" },
619 { TR_SLAY_UNDEAD, "Undead" },
620 { TR_KILL_UNDEAD, "XUndead" },
621 { TR_SLAY_DEMON, "Demon" },
622 { TR_KILL_DEMON, "XDemon" },
623 { TR_SLAY_ORC, "Orc" },
624 { TR_KILL_ORC, "XOrc" },
625 { TR_SLAY_TROLL, "Troll" },
626 { TR_KILL_TROLL, "XTroll" },
627 { TR_SLAY_GIANT, "Giant" },
628 { TR_KILL_GIANT, "Xgiant" },
629 { TR_SLAY_DRAGON, "Dragon" },
630 { TR_KILL_DRAGON, "Xdragon" }
635 * Elemental brands for weapons
637 * Clearly, TR1_IMPACT is a bit out of place here. To simplify
638 * coding, it has been included here along with the elemental
639 * brands. It does seem to fit in with the brands and slaying
640 * more than the miscellaneous section.
642 static flag_desc brand_flags_desc[] =
645 { TR_BRAND_ACID, "溶解" },
646 { TR_BRAND_ELEC, "電撃" },
647 { TR_BRAND_FIRE, "焼棄" },
648 { TR_BRAND_COLD, "凍結" },
649 { TR_BRAND_POIS, "毒殺" },
651 { TR_FORCE_WEAPON, "理力" },
652 { TR_CHAOTIC, "混沌" },
653 { TR_VAMPIRIC, "吸血" },
655 { TR_VORPAL, "切れ味" },
657 { TR_BRAND_ACID, "Acid Brand" },
658 { TR_BRAND_ELEC, "Lightning Brand" },
659 { TR_BRAND_FIRE, "Flame Tongue" },
660 { TR_BRAND_COLD, "Frost Brand" },
661 { TR_BRAND_POIS, "Poisoned" },
663 { TR_FORCE_WEAPON, "Force" },
664 { TR_CHAOTIC, "Mark of Chaos" },
665 { TR_VAMPIRIC, "Vampiric" },
666 { TR_IMPACT, "Earthquake impact on hit" },
667 { TR_VORPAL, "Very sharp" },
675 static const flag_desc resist_flags_desc[] =
678 { TR_RES_ACID, "酸" },
679 { TR_RES_ELEC, "電撃" },
680 { TR_RES_FIRE, "火炎" },
681 { TR_RES_COLD, "冷気" },
682 { TR_RES_POIS, "毒" },
683 { TR_RES_FEAR, "恐怖"},
684 { TR_RES_LITE, "閃光" },
685 { TR_RES_DARK, "暗黒" },
686 { TR_RES_BLIND, "盲目" },
687 { TR_RES_CONF, "混乱" },
688 { TR_RES_SOUND, "轟音" },
689 { TR_RES_SHARDS, "破片" },
690 { TR_RES_NETHER, "地獄" },
691 { TR_RES_NEXUS, "因果混乱" },
692 { TR_RES_CHAOS, "カオス" },
693 { TR_RES_DISEN, "劣化" },
695 { TR_RES_ACID, "Acid" },
696 { TR_RES_ELEC, "Lightning" },
697 { TR_RES_FIRE, "Fire" },
698 { TR_RES_COLD, "Cold" },
699 { TR_RES_POIS, "Poison" },
700 { TR_RES_FEAR, "Fear"},
701 { TR_RES_LITE, "Light" },
702 { TR_RES_DARK, "Dark" },
703 { TR_RES_BLIND, "Blindness" },
704 { TR_RES_CONF, "Confusion" },
705 { TR_RES_SOUND, "Sound" },
706 { TR_RES_SHARDS, "Shards" },
707 { TR_RES_NETHER, "Nether" },
708 { TR_RES_NEXUS, "Nexus" },
709 { TR_RES_CHAOS, "Chaos" },
710 { TR_RES_DISEN, "Disenchantment" },
715 * Elemental immunities (along with poison)
718 static const flag_desc immune_flags_desc[] =
722 { TR_IM_ELEC, "電撃" },
723 { TR_IM_FIRE, "火炎" },
724 { TR_IM_COLD, "冷気" },
726 { TR_IM_ACID, "Acid" },
727 { TR_IM_ELEC, "Lightning" },
728 { TR_IM_FIRE, "Fire" },
729 { TR_IM_COLD, "Cold" },
734 * Sustain stats - these are given their "own" line in the
735 * spoiler file, mainly for simplicity
737 static const flag_desc sustain_flags_desc[] =
740 { TR_SUST_STR, "腕力" },
741 { TR_SUST_INT, "知能" },
742 { TR_SUST_WIS, "賢さ" },
743 { TR_SUST_DEX, "器用さ" },
744 { TR_SUST_CON, "耐久力" },
745 { TR_SUST_CHR, "魅力" },
747 { TR_SUST_STR, "STR" },
748 { TR_SUST_INT, "INT" },
749 { TR_SUST_WIS, "WIS" },
750 { TR_SUST_DEX, "DEX" },
751 { TR_SUST_CON, "CON" },
752 { TR_SUST_CHR, "CHR" },
757 * Miscellaneous magic given by an object's "flags2" field
760 static const flag_desc misc_flags2_desc[] =
764 { TR_REFLECT, "反射" },
765 { TR_FREE_ACT, "麻痺知らず" },
766 { TR_HOLD_EXP, "経験値維持" },
768 { TR_THROW, "Throwing" },
769 { TR_REFLECT, "Reflection" },
770 { TR_FREE_ACT, "Free Action" },
771 { TR_HOLD_EXP, "Hold Experience" },
776 * Miscellaneous magic given by an object's "flags3" field
778 * Note that cursed artifacts and objects with permanent light
779 * are handled "directly" -- see analyze_misc_magic()
782 static const flag_desc misc_flags3_desc[] =
785 { TR_SH_FIRE, "火炎オーラ" },
786 { TR_SH_ELEC, "電撃オーラ" },
787 { TR_SH_COLD, "冷気オーラ" },
788 { TR_NO_TELE, "反テレポート" },
789 { TR_NO_MAGIC, "反魔法" },
790 { TR_LEVITATION, "浮遊" },
791 { TR_SEE_INVIS, "可視透明" },
792 { TR_TELEPATHY, "テレパシー" },
793 { TR_ESP_ANIMAL, "動物感知" },
794 { TR_ESP_UNDEAD, "不死感知" },
795 { TR_ESP_DEMON, "悪魔感知" },
796 { TR_ESP_ORC, "オーク感知" },
797 { TR_ESP_TROLL, "トロル感知" },
798 { TR_ESP_GIANT, "巨人感知" },
799 { TR_ESP_DRAGON, "ドラゴン感知" },
800 { TR_ESP_HUMAN, "人間感知" },
801 { TR_ESP_EVIL, "邪悪感知" },
802 { TR_ESP_GOOD, "善良感知" },
803 { TR_ESP_NONLIVING, "無生物感知" },
804 { TR_ESP_UNIQUE, "ユニーク感知" },
805 { TR_SLOW_DIGEST, "遅消化" },
806 { TR_REGEN, "急速回復" },
807 { TR_WARNING, "警告" },
808 /* { TR_XTRA_MIGHT, "強力射撃" }, */
809 { TR_XTRA_SHOTS, "追加射撃" }, /* always +1? */
810 { TR_DRAIN_EXP, "経験値吸収" },
811 { TR_AGGRAVATE, "反感" },
812 { TR_BLESSED, "祝福" },
813 { TR_DEC_MANA, "消費魔力減少" },
815 { TR_SH_FIRE, "Fiery Aura" },
816 { TR_SH_ELEC, "Electric Aura" },
817 { TR_SH_COLD, "Coldly Aura" },
818 { TR_NO_TELE, "Prevent Teleportation" },
819 { TR_NO_MAGIC, "Anti-Magic" },
820 { TR_LEVITATION, "Levitation" },
821 { TR_SEE_INVIS, "See Invisible" },
822 { TR_TELEPATHY, "ESP" },
823 { TR_ESP_ANIMAL, "Sense Animal" },
824 { TR_ESP_UNDEAD, "Sense Undead" },
825 { TR_ESP_DEMON, "Sense Demon" },
826 { TR_ESP_ORC, "Sense Orc" },
827 { TR_ESP_TROLL, "Sense Troll" },
828 { TR_ESP_GIANT, "Sense Giant" },
829 { TR_ESP_DRAGON, "Sense Dragon" },
830 { TR_ESP_HUMAN, "Sense Human" },
831 { TR_ESP_EVIL, "Sense Evil" },
832 { TR_ESP_GOOD, "Sense Good" },
833 { TR_ESP_NONLIVING, "Sense Nonliving" },
834 { TR_ESP_UNIQUE, "Sense Unique" },
835 { TR_SLOW_DIGEST, "Slow Digestion" },
836 { TR_REGEN, "Regeneration" },
837 { TR_WARNING, "Warning" },
838 /* { TR_XTRA_MIGHT, "Extra Might" }, */
839 { TR_XTRA_SHOTS, "+1 Extra Shot" }, /* always +1? */
840 { TR_DRAIN_EXP, "Drains Experience" },
841 { TR_AGGRAVATE, "Aggravates" },
842 { TR_BLESSED, "Blessed Blade" },
843 { TR_DEC_MANA, "Decrease Mana Consumption Rate" },
849 * A special type used just for deailing with pvals
854 * This will contain a string such as "+2", "-10", etc.
859 * A list of various player traits affected by an object's pval such
860 * as stats, speed, stealth, etc. "Extra attacks" is NOT included in
861 * this list since it will probably be desirable to format its
862 * description differently.
864 * Note that room need only be reserved for the number of stats - 1
865 * since the description "All stats" is used if an object affects all
866 * all stats. Also, room must be reserved for a sentinel NULL pointer.
868 * This will be a list such as ["STR", "DEX", "Stealth", NULL] etc.
870 * This list includes extra attacks, for simplicity.
872 concptr pval_affects[N_ELEMENTS(stat_flags_desc) - 1 +
873 N_ELEMENTS(pval_flags1_desc) + 1];
879 * An "object analysis structure"
881 * It will be filled with descriptive strings detailing an object's
882 * various magical powers. The "ignore X" traits are not noted since
883 * all artifacts ignore "normal" destruction.
888 /* "The Longsword Dragonsmiter (6d4) (+20, +25)" */
889 char description[MAX_NLEN];
891 /* Description of what is affected by an object's pval */
892 pval_info_type pval_info;
894 /* A list of an object's slaying preferences */
895 concptr slays[N_ELEMENTS(slay_flags_desc) + 1];
897 /* A list if an object's elemental brands */
898 concptr brands[N_ELEMENTS(brand_flags_desc) + 1];
900 /* A list of immunities granted by an object */
901 concptr immunities[N_ELEMENTS(immune_flags_desc) + 1];
903 /* A list of resistances granted by an object */
904 concptr resistances[N_ELEMENTS(resist_flags_desc) + 1];
906 /* A list of stats sustained by an object */
907 concptr sustains[N_ELEMENTS(sustain_flags_desc) - 1 + 1];
909 /* A list of various magical qualities an object may have */
910 concptr misc_magic[N_ELEMENTS(misc_flags2_desc) + N_ELEMENTS(misc_flags3_desc)
911 + 1 /* Permanent Light */
913 + 1 /* type of curse */
914 + 1]; /* sentinel NULL */
916 /* Additional ability or resistance */
919 /* A string describing an artifact's activation */
922 /* "Level 20, Rarity 30, 3.0 lbs, 20000 Gold" */
928 * @brief ファイルポインタ先に同じ文字を複数出力する /
929 * Write out `n' of the character `c' to the spoiler file
934 static void spoiler_out_n_chars(int n, char c)
936 while (--n >= 0) fputc(c, fff);
941 * @brief ファイルポインタ先に改行を複数出力する /
942 * Write out `n' blank lines to the spoiler file
946 static void spoiler_blanklines(int n)
948 spoiler_out_n_chars(n, '\n');
953 * @brief ファイルポインタ先に複数のハイフンで装飾した文字列を出力する /
954 * Write a line to the spoiler file and then "underline" it with hypens
955 * @param str 出力したい文字列
958 static void spoiler_underline(concptr str)
960 fprintf(fff, "%s\n", str);
961 spoiler_out_n_chars(strlen(str), '-');
968 * @brief アーティファクトの特性一覧を出力する /
969 * Write a line to the spoiler file and then "underline" it with hypens
970 * @param art_flags アーティファクトのフラグ群
971 * @param flag_ptr フラグ記述情報の参照ポインタ
972 * @param desc_ptr 記述内容を返すための文字列参照ポインタ
973 * @param n_elmnts フラグの要素数
974 * @return desc_ptrと同じアドレス
977 * This function does most of the actual "analysis". Given a set of bit flags
978 * (which will be from one of the flags fields from the object in question),
979 * a "flag description structure", a "description list", and the number of
980 * elements in the "flag description structure", this function sets the
981 * "description list" members to the appropriate descriptions contained in
982 * the "flag description structure".
983 * The possibly updated description pointer is returned.
986 static concptr *spoiler_flag_aux(const BIT_FLAGS art_flags[TR_FLAG_SIZE],
987 const flag_desc *flag_ptr,
988 concptr *desc_ptr, const int n_elmnts)
992 for (i = 0; i < n_elmnts; ++i)
994 if (have_flag(art_flags, flag_ptr[i].flag))
996 *desc_ptr++ = flag_ptr[i].desc;
1005 * @brief アイテムの特定記述内容を返す /
1006 * Acquire a "basic" description "The Cloak of Death [1,+10]"
1007 * @param o_ptr 記述を得たいオブジェクトの参照ポインタ
1008 * @param desc_ptr 記述内容を返すための文字列参照ポインタ
1011 static void analyze_general(player_type *player_ptr, object_type *o_ptr, char *desc_ptr)
1013 /* Get a "useful" description of the object */
1014 object_desc(player_ptr, desc_ptr, o_ptr, (OD_NAME_AND_ENCHANT | OD_STORE));
1019 * @brief アーティファクトがプレイヤーに与えるpval修正を構造体に収める /
1020 * List "player traits" altered by an artifact's pval. These include stats,
1021 * speed, infravision, tunneling, stealth, searching, and extra attacks.
1022 * @param o_ptr オブジェクト構造体の参照ポインタ
1023 * @param pi_ptr pval修正構造体の参照ポインタ
1026 static void analyze_pval(object_type *o_ptr, pval_info_type *pi_ptr)
1028 BIT_FLAGS flgs[TR_FLAG_SIZE];
1030 concptr *affects_list;
1032 /* If pval == 0, there is nothing to do. */
1035 /* An "empty" pval description indicates that pval == 0 */
1036 pi_ptr->pval_desc[0] = '\0';
1039 object_flags(o_ptr, flgs);
1041 affects_list = pi_ptr->pval_affects;
1043 /* Create the "+N" string */
1044 sprintf(pi_ptr->pval_desc, "%s%d", POSITIZE(o_ptr->pval), o_ptr->pval);
1046 /* First, check to see if the pval affects all stats */
1047 if (have_flag(flgs, TR_STR) && have_flag(flgs, TR_INT) &&
1048 have_flag(flgs, TR_WIS) && have_flag(flgs, TR_DEX) &&
1049 have_flag(flgs, TR_CON) && have_flag(flgs, TR_CHR))
1051 *affects_list++ = _("全能力", "All stats");
1054 /* Are any stats affected? */
1055 else if (have_flag(flgs, TR_STR) || have_flag(flgs, TR_INT) ||
1056 have_flag(flgs, TR_WIS) || have_flag(flgs, TR_DEX) ||
1057 have_flag(flgs, TR_CON) || have_flag(flgs, TR_CHR))
1059 affects_list = spoiler_flag_aux(flgs, stat_flags_desc,
1061 N_ELEMENTS(stat_flags_desc));
1064 /* And now the "rest" */
1065 affects_list = spoiler_flag_aux(flgs, pval_flags1_desc,
1067 N_ELEMENTS(pval_flags1_desc));
1069 /* Terminate the description list */
1070 *affects_list = NULL;
1074 * @brief アーティファクトの種族スレイ特性を構造体に収める /
1075 * Note the slaying specialties of a weapon
1076 * @param o_ptr オブジェクト構造体の参照ポインタ
1077 * @param slay_list 種族スレイ構造体の参照ポインタ
1080 static void analyze_slay(object_type *o_ptr, concptr *slay_list)
1082 BIT_FLAGS flgs[TR_FLAG_SIZE];
1084 object_flags(o_ptr, flgs);
1086 slay_list = spoiler_flag_aux(flgs, slay_flags_desc, slay_list,
1087 N_ELEMENTS(slay_flags_desc));
1089 /* Terminate the description list */
1095 * @brief アーティファクトの属性ブランド特性を構造体に収める /
1096 * Note an object's elemental brands
1097 * @param o_ptr オブジェクト構造体の参照ポインタ
1098 * @param brand_list 属性ブランド構造体の参照ポインタ
1101 static void analyze_brand(object_type *o_ptr, concptr *brand_list)
1103 BIT_FLAGS flgs[TR_FLAG_SIZE];
1105 object_flags(o_ptr, flgs);
1107 brand_list = spoiler_flag_aux(flgs, brand_flags_desc, brand_list,
1108 N_ELEMENTS(brand_flags_desc));
1110 /* Terminate the description list */
1116 * @brief アーティファクトの通常耐性を構造体に収める /
1117 * Note an object's elemental brands
1118 * @param o_ptr オブジェクト構造体の参照ポインタ
1119 * @param resist_list 通常耐性構造体の参照ポインタ
1122 static void analyze_resist(object_type *o_ptr, concptr *resist_list)
1124 BIT_FLAGS flgs[TR_FLAG_SIZE];
1126 object_flags(o_ptr, flgs);
1128 resist_list = spoiler_flag_aux(flgs, resist_flags_desc,
1129 resist_list, N_ELEMENTS(resist_flags_desc));
1131 /* Terminate the description list */
1132 *resist_list = NULL;
1137 * @brief アーティファクトの免疫特性を構造体に収める /
1138 * Note the immunities granted by an object
1139 * @param o_ptr オブジェクト構造体の参照ポインタ
1140 * @param immune_list 免疫構造体の参照ポインタ
1143 static void analyze_immune(object_type *o_ptr, concptr *immune_list)
1145 BIT_FLAGS flgs[TR_FLAG_SIZE];
1147 object_flags(o_ptr, flgs);
1149 immune_list = spoiler_flag_aux(flgs, immune_flags_desc,
1150 immune_list, N_ELEMENTS(immune_flags_desc));
1152 /* Terminate the description list */
1153 *immune_list = NULL;
1158 * @brief アーティファクトの維持特性を構造体に収める /
1159 * Note which stats an object sustains
1160 * @param o_ptr オブジェクト構造体の参照ポインタ
1161 * @param sustain_list 維持特性構造体の参照ポインタ
1164 static void analyze_sustains(object_type *o_ptr, concptr *sustain_list)
1166 BIT_FLAGS flgs[TR_FLAG_SIZE];
1168 object_flags(o_ptr, flgs);
1170 /* Simplify things if an item sustains all stats */
1171 if (have_flag(flgs, TR_SUST_STR) && have_flag(flgs, TR_SUST_INT) &&
1172 have_flag(flgs, TR_SUST_WIS) && have_flag(flgs, TR_SUST_DEX) &&
1173 have_flag(flgs, TR_SUST_CON) && have_flag(flgs, TR_SUST_CHR))
1175 *sustain_list++ = _("全能力", "All stats");
1178 /* Should we bother? */
1179 else if (have_flag(flgs, TR_SUST_STR) || have_flag(flgs, TR_SUST_INT) ||
1180 have_flag(flgs, TR_SUST_WIS) || have_flag(flgs, TR_SUST_DEX) ||
1181 have_flag(flgs, TR_SUST_CON) || have_flag(flgs, TR_SUST_CHR))
1183 sustain_list = spoiler_flag_aux(flgs, sustain_flags_desc,
1185 N_ELEMENTS(sustain_flags_desc));
1188 /* Terminate the description list */
1189 *sustain_list = NULL;
1194 * @brief アーティファクトのその他の特性を構造体に収める /
1195 * Note miscellaneous powers bestowed by an artifact such as see invisible,
1196 * free action, permanent light, etc.
1197 * @param o_ptr オブジェクト構造体の参照ポインタ
1198 * @param misc_list その他の特性構造体の参照ポインタ
1201 static void analyze_misc_magic(object_type *o_ptr, concptr *misc_list)
1203 BIT_FLAGS flgs[TR_FLAG_SIZE];
1207 object_flags(o_ptr, flgs);
1209 misc_list = spoiler_flag_aux(flgs, misc_flags2_desc, misc_list,
1210 N_ELEMENTS(misc_flags2_desc));
1212 misc_list = spoiler_flag_aux(flgs, misc_flags3_desc, misc_list, N_ELEMENTS(misc_flags3_desc));
1215 * Glowing artifacts -- small radius light.
1218 if (have_flag(flgs, TR_LITE_1)) rad += 1;
1219 if (have_flag(flgs, TR_LITE_2)) rad += 2;
1220 if (have_flag(flgs, TR_LITE_3)) rad += 3;
1221 if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
1222 if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
1223 if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
1225 if (o_ptr->name2 == EGO_LITE_SHINE) rad++;
1227 if (have_flag(flgs, TR_LITE_FUEL))
1229 if (rad > 0) sprintf(desc, _("それは燃料補給によって明かり(半径 %d)を授ける。", "It provides light (radius %d) when fueled."), (int)rad);
1233 if (rad > 0) sprintf(desc, _("永久光源(半径 %d)", "Permanent Light(radius %d)"), (int)rad);
1234 if (rad < 0) sprintf(desc, _("永久光源(半径-%d)。", "Permanent Light(radius -%d)"), (int)-rad);
1237 if (rad != 0) *misc_list++ = quark_str(quark_add(desc));
1240 * Handle cursed objects here to avoid redundancies such as noting
1241 * that a permanently cursed object is heavily cursed as well as
1242 * being "lightly cursed".
1245 /* if (object_is_cursed(o_ptr)) */
1247 if (have_flag(flgs, TR_TY_CURSE))
1249 *misc_list++ = _("太古の怨念", "Ancient Curse");
1251 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1253 *misc_list++ = _("永遠の呪い", "Permanently Cursed");
1255 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1257 *misc_list++ = _("強力な呪い", "Heavily Cursed");
1260 else if (o_ptr->curse_flags & TRC_CURSED)
1262 *misc_list++ = _("呪い", "Cursed");
1264 if (have_flag(flgs, TR_ADD_L_CURSE))
1266 *misc_list++ = _("呪いを増やす", "Cursing");
1268 if (have_flag(flgs, TR_ADD_H_CURSE))
1270 *misc_list++ = _("強力な呪いを増やす", "Heavily Cursing");
1274 /* Terminate the description list */
1280 * @brief アーティファクトの追加ランダム特性を構造体に収める /
1281 * Note additional ability and/or resistance of fixed artifacts
1282 * @param o_ptr オブジェクト構造体の参照ポインタ
1283 * @param addition 追加ランダム耐性構造体の参照ポインタ
1286 static void analyze_addition(object_type *o_ptr, char *addition)
1288 artifact_type *a_ptr = &a_info[o_ptr->name1];
1291 strcpy(addition, "");
1293 if ((a_ptr->gen_flags & TRG_XTRA_POWER) && (a_ptr->gen_flags & TRG_XTRA_H_RES)) strcat(addition, _("能力and耐性", "Ability and Resistance"));
1294 else if (a_ptr->gen_flags & TRG_XTRA_POWER)
1296 strcat(addition, _("能力", "Ability"));
1297 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, _("(1/2でand耐性)", "(plus Resistance about 1/2)"));
1299 else if (a_ptr->gen_flags & TRG_XTRA_H_RES)
1301 strcat(addition, _("耐性", "Resistance"));
1302 if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, _("(1/2でand能力)", "(plus Ability about 1/2)"));
1304 else if (a_ptr->gen_flags & TRG_XTRA_RES_OR_POWER) strcat(addition, _("能力or耐性", "Ability or Resistance"));
1309 * @brief アーティファクトの基本情報を文字列に収める /
1310 * Determine the minimum depth an artifact can appear, its rarity, its weight,
1311 * and its value in gold pieces
1312 * @param o_ptr オブジェクト構造体の参照ポインタ
1313 * @param misc_desc 基本情報を収める文字列参照ポインタ
1316 static void analyze_misc(object_type *o_ptr, char *misc_desc)
1318 artifact_type *a_ptr = &a_info[o_ptr->name1];
1320 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,
1322 lbtokg1(a_ptr->weight), lbtokg2(a_ptr->weight), (long int)a_ptr->cost);
1324 a_ptr->weight / 10, a_ptr->weight % 10, (long int)a_ptr->cost);
1330 * @brief アーティファクトの情報全体を構造体に収める /
1331 * Fill in an object description structure for a given object
1332 * and its value in gold pieces
1333 * @param player_ptr プレーヤーへの参照ポインタ
1334 * @param o_ptr オブジェクト構造体の参照ポインタ
1335 * @param desc_ptr 全アーティファクト情報を収める文字列参照ポインタ
1338 static void object_analyze(player_type *player_ptr, object_type *o_ptr, obj_desc_list *desc_ptr)
1340 analyze_general(player_ptr, o_ptr, desc_ptr->description);
1341 analyze_pval(o_ptr, &desc_ptr->pval_info);
1342 analyze_brand(o_ptr, desc_ptr->brands);
1343 analyze_slay(o_ptr, desc_ptr->slays);
1344 analyze_immune(o_ptr, desc_ptr->immunities);
1345 analyze_resist(o_ptr, desc_ptr->resistances);
1346 analyze_sustains(o_ptr, desc_ptr->sustains);
1347 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
1348 analyze_addition(o_ptr, desc_ptr->addition);
1349 analyze_misc(o_ptr, desc_ptr->misc_desc);
1350 desc_ptr->activation = item_activation(o_ptr);
1355 * @brief バッファにアーティファクト出力情報ヘッダを収める /
1358 static void print_header(void)
1362 sprintf(buf, "Artifact Spoilers for Hengband Version %d.%d.%d", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1363 spoiler_underline(buf);
1367 * This is somewhat ugly.
1369 * Given a header ("Resist", e.g.), a list ("Fire", "Cold", Acid", e.g.),
1370 * and a separator character (',', e.g.), write the list to the spoiler file
1371 * in a "nice" format, such as:
1373 * Resist Fire, Cold, Acid
1375 * That was a simple example, but when the list is long, a line wrap
1376 * should occur, and this should induce a new level of indention if
1377 * a list is being spread across lines. So for example, Bladeturner's
1378 * list of resistances should look something like this
1380 * Resist Acid, Lightning, Fire, Cold, Poison, Light, Dark, Blindness,
1381 * Confusion, Sound, Shards, Nether, Nexus, Chaos, Disenchantment
1383 * However, the code distinguishes between a single list of many items vs.
1384 * many lists. (The separator is used to make this determination.) A single
1385 * list of many items will not cause line wrapping (since there is no
1386 * apparent reason to do so). So the lists of Ulmo's miscellaneous traits
1387 * might look like this:
1389 * Free Action; Hold Life; See Invisible; Slow Digestion; Regeneration
1392 * So comparing the two, "Regeneration" has no trailing separator and
1393 * "Blessed Blade" was not indented. (Also, Ulmo's lists have no headers,
1394 * but that's not relevant to line wrapping and indention.)
1397 /* ITEM_SEP separates items within a list */
1398 #define ITEM_SEP ','
1401 /* LIST_SEP separates lists */
1403 #define LIST_SEP ','
1405 #define LIST_SEP ';'
1409 * @brief フラグ名称を出力する汎用関数
1410 * @param header ヘッダに出力するフラグ群の名前
1411 * @param list フラグ名リスト
1412 * @param separator フラグ表示の区切り記号
1415 static void spoiler_outlist(concptr header, concptr *list, char separator)
1417 int line_len, buf_len;
1418 char line[MAX_LINE_LEN + 1], buf[80];
1420 /* Ignore an empty list */
1421 if (*list == NULL) return;
1423 /* This function always indents */
1424 strcpy(line, INDENT1);
1426 /* Create header (if one was given) */
1427 if (header && (header[0]))
1429 strcat(line, header);
1433 line_len = strlen(line);
1435 /* Now begin the tedious task */
1438 /* Copy the current item to a buffer */
1441 /* Note the buffer's length */
1442 buf_len = strlen(buf);
1445 * If there is an item following this one, pad with separator and
1446 * a space and adjust the buffer length
1451 sprintf(buf + buf_len, "%c ", separator);
1456 * If the buffer will fit on the current line, just append the
1457 * buffer to the line and adjust the line length accordingly.
1460 if (line_len + buf_len <= MAX_LINE_LEN)
1463 line_len += buf_len;
1466 /* Apply line wrapping and indention semantics described above */
1470 * Don't print a trailing list separator but do print a trailing
1473 if (line_len > 1 && line[line_len - 1] == ' '
1474 && line[line_len - 2] == LIST_SEP)
1476 /* Ignore space and separator */
1477 line[line_len - 2] = '\0';
1479 /* Write to spoiler file */
1480 fprintf(fff, "%s\n", line);
1482 /* Begin new line at primary indention level */
1483 sprintf(line, "%s%s", INDENT1, buf);
1488 /* Write to spoiler file */
1489 fprintf(fff, "%s\n", line);
1491 /* Begin new line at secondary indention level */
1492 sprintf(line, "%s%s", INDENT2, buf);
1495 line_len = strlen(line);
1498 /* Advance, with break */
1499 if (!*++list) break;
1502 /* Write what's left to the spoiler file */
1503 fprintf(fff, "%s\n", line);
1507 * @brief アーティファクト一件をスポイラー出力する /
1508 * Create a spoiler file entry for an artifact
1509 * @param art_ptr アーティファクト情報をまとめた構造体の参照ポインタ
1512 static void spoiler_print_art(obj_desc_list *art_ptr)
1514 pval_info_type *pval_ptr = &art_ptr->pval_info;
1517 /* Don't indent the first line */
1518 fprintf(fff, "%s\n", art_ptr->description);
1520 /* An "empty" pval description indicates that the pval affects nothing */
1521 if (pval_ptr->pval_desc[0])
1523 /* Mention the effects of pval */
1524 sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc);
1525 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
1528 /* Now deal with the description lists */
1529 spoiler_outlist(_("対:", "Slay"), art_ptr->slays, ITEM_SEP);
1530 spoiler_outlist(_("武器属性:", ""), art_ptr->brands, LIST_SEP);
1531 spoiler_outlist(_("免疫:", "Immunity to"), art_ptr->immunities, ITEM_SEP);
1532 spoiler_outlist(_("耐性:", "Resist"), art_ptr->resistances, ITEM_SEP);
1533 spoiler_outlist(_("維持:", "Sustain"), art_ptr->sustains, ITEM_SEP);
1534 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
1536 if (art_ptr->addition[0])
1538 fprintf(fff, _("%s追加: %s\n", "%sAdditional %s\n"), INDENT1, art_ptr->addition);
1541 /* Write out the possible activation at the primary indention level */
1542 if (art_ptr->activation)
1544 fprintf(fff, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation);
1547 /* End with the miscellaneous facts */
1548 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
1553 * @brief アーティファクト情報を出力するためにダミー生成を行う /
1554 * Hack -- Create a "forged" artifact
1555 * @param o_ptr 一時生成先を保管するオブジェクト構造体
1556 * @param name1 生成するアーティファクトID
1557 * @return 生成が成功した場合TRUEを返す
1559 static bool make_fake_artifact(object_type *o_ptr, IDX name1)
1562 artifact_type *a_ptr = &a_info[name1];
1564 /* Ignore "empty" artifacts */
1565 if (!a_ptr->name) return FALSE;
1567 /* Acquire the "kind" index */
1568 i = lookup_kind(a_ptr->tval, a_ptr->sval);
1570 if (!i) return FALSE;
1572 object_prep(o_ptr, i);
1575 o_ptr->name1 = (byte_hack)name1;
1577 /* Extract the fields */
1578 o_ptr->pval = a_ptr->pval;
1579 o_ptr->ac = a_ptr->ac;
1580 o_ptr->dd = a_ptr->dd;
1581 o_ptr->ds = a_ptr->ds;
1582 o_ptr->to_a = a_ptr->to_a;
1583 o_ptr->to_h = a_ptr->to_h;
1584 o_ptr->to_d = a_ptr->to_d;
1585 o_ptr->weight = a_ptr->weight;
1593 * @brief アーティファクト情報のスポイラー出力を行うメインルーチン /
1594 * Create a spoiler file for artifacts
1595 * @param player_ptr プレーヤーへの参照ポインタ
1596 * @param fname 生成ファイル名
1599 static void spoil_artifact(player_type *player_ptr, concptr fname)
1606 obj_desc_list artifact;
1608 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1610 /* File type is "TEXT" */
1611 FILE_TYPE(FILE_TYPE_TEXT);
1612 fff = my_fopen(buf, "w");
1616 msg_print("Cannot create spoiler file.");
1620 /* Dump the header */
1623 /* List the artifacts by tval */
1624 for (i = 0; group_artifact[i].tval; i++)
1626 /* Write out the group title */
1627 if (group_artifact[i].name)
1629 spoiler_blanklines(2);
1630 spoiler_underline(group_artifact[i].name);
1631 spoiler_blanklines(1);
1634 /* Now search through all of the artifacts */
1635 for (j = 1; j < max_a_idx; ++j)
1637 artifact_type *a_ptr = &a_info[j];
1639 /* We only want objects in the current group */
1640 if (a_ptr->tval != group_artifact[i].tval) continue;
1644 /* Attempt to "forge" the artifact */
1645 if (!make_fake_artifact(q_ptr, j)) continue;
1647 /* Analyze the artifact */
1648 object_analyze(player_ptr, q_ptr, &artifact);
1650 /* Write out the artifact description to the spoiler file */
1651 spoiler_print_art(&artifact);
1655 /* Check for errors */
1656 if (ferror(fff) || my_fclose(fff))
1658 msg_print("Cannot close spoiler file.");
1662 msg_print("Successfully created a spoiler file.");
1667 * @brief モンスター簡易情報のスポイラー出力を行うメインルーチン /
1668 * Create a spoiler file for monsters -BEN-
1669 * @param fname 生成ファイル名
1672 static void spoil_mon_desc(concptr fname)
1688 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
1690 /* File type is "TEXT" */
1691 FILE_TYPE(FILE_TYPE_TEXT);
1692 fff = my_fopen(buf, "w");
1696 msg_print("Cannot create spoiler file.");
1700 /* Allocate the "who" array */
1701 C_MAKE(who, max_r_idx, MONRACE_IDX);
1703 /* Dump the header */
1704 fprintf(fff, "Monster Spoilers for Hengband Version %d.%d.%d\n",
1705 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
1706 fprintf(fff, "------------------------------------------\n\n");
1708 /* Dump the header */
1709 fprintf(fff, " %-38.38s%4s%4s%4s%7s%5s %11.11s\n",
1710 "Name", "Lev", "Rar", "Spd", "Hp", "Ac", "Visual Info");
1711 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1712 "--------", "---", "---", "---", "--", "--", "-----------");
1715 /* Scan the monsters */
1716 for (i = 1; i < max_r_idx; i++)
1718 monster_race *r_ptr = &r_info[i];
1720 /* Use that monster */
1721 if (r_ptr->name) who[n++] = (s16b)i;
1724 /* Sort the array by dungeon depth of monsters */
1725 ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
1728 for (i = 0; i < n; i++)
1730 monster_race *r_ptr = &r_info[who[i]];
1732 concptr name = (r_name + r_ptr->name);
1733 if (r_ptr->flags7 & (RF7_KAGE)) continue;
1735 /* Get the "name" */
1737 else if (r_ptr->flags3 & (RF3_NO_CONF))
1739 sprintf(nam, "[*] %s", name);
1742 else if (r_ptr->flags1 & (RF1_UNIQUE))
1744 sprintf(nam, "[U] %s", name);
1748 sprintf(nam, _(" %s", "The %s"), name);
1752 sprintf(lev, "%d", (int)r_ptr->level);
1755 sprintf(rar, "%d", (int)r_ptr->rarity);
1757 if (r_ptr->speed >= 110)
1759 sprintf(spd, "+%d", (r_ptr->speed - 110));
1763 sprintf(spd, "-%d", (110 - r_ptr->speed));
1767 sprintf(ac, "%d", r_ptr->ac);
1770 if ((r_ptr->flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
1772 sprintf(hp, "%d", r_ptr->hdice * r_ptr->hside);
1776 sprintf(hp, "%dd%d", r_ptr->hdice, r_ptr->hside);
1781 sprintf(exp, "%ld", (long)(r_ptr->mexp));
1783 /* Hack -- use visual instead */
1784 sprintf(exp, "%s '%c'", attr_to_text(r_ptr), r_ptr->d_char);
1787 fprintf(fff, "%-42.42s%4s%4s%4s%7s%5s %11.11s\n",
1788 nam, lev, rar, spd, hp, ac, exp);
1795 /* Free the "who" array */
1796 C_KILL(who, max_r_idx, s16b);
1798 /* Check for errors */
1799 if (ferror(fff) || my_fclose(fff))
1801 msg_print("Cannot close spoiler file.");
1806 msg_print("Successfully created a spoiler file.");
1813 * Monster spoilers by: smchorse@ringer.cs.utsa.edu (Shawn McHorse)
1815 * Primarily based on code already in mon-desc.c, mostly by -BEN-
1821 * @brief 文字列をファイルポインタに出力する /
1822 * Buffer text to the given file. (-SHAWN-)
1823 * This is basically c_roff() from mon-desc.c with a few changes.
1824 * @param str 文字列参照ポインタ
1827 static void spoil_out(concptr str)
1832 static char roff_buf[256];
1835 static char roff_waiting_buf[256];
1838 bool iskanji_flag = FALSE;
1840 /* Current pointer into line roff_buf */
1841 static char *roff_p = roff_buf;
1843 /* Last space saved into roff_buf */
1844 static char *roff_s = NULL;
1846 /* Mega-Hack -- Delayed output */
1847 static bool waiting_output = FALSE;
1849 /* Special handling for "new sequence" */
1854 fputs(roff_waiting_buf, fff);
1855 waiting_output = FALSE;
1858 if (roff_p != roff_buf) roff_p--;
1859 while (*roff_p == ' ' && roff_p != roff_buf) roff_p--;
1861 if (roff_p == roff_buf) fprintf(fff, "\n");
1864 *(roff_p + 1) = '\0';
1865 fprintf(fff, "%s\n\n", roff_buf);
1874 /* Scan the given string, character at a time */
1879 bool k_flag = iskanji((unsigned char)(*str));
1882 bool wrap = (ch == '\n');
1885 if (!isprint((unsigned char)ch) && !k_flag && !iskanji_flag) ch = ' ';
1886 iskanji_flag = k_flag && !iskanji_flag;
1888 if (!isprint(ch)) ch = ' ';
1893 fputs(roff_waiting_buf, fff);
1894 if (!wrap) fputc('\n', fff);
1895 waiting_output = FALSE;
1901 if (roff_p >= roff_buf + (k_flag ? 74 : 75)) wrap = TRUE;
1902 else if ((ch == ' ') && (roff_p >= roff_buf + (k_flag ? 72 : 73))) wrap = TRUE;
1904 if (roff_p >= roff_buf + 75) wrap = TRUE;
1905 else if ((ch == ' ') && (roff_p >= roff_buf + 73)) wrap = TRUE;
1912 bool iskanji_flag_local = FALSE;
1913 concptr tail = str + (k_flag ? 2 : 1);
1915 concptr tail = str + 1;
1918 for (; *tail; tail++)
1920 if (*tail == ' ') continue;
1923 k_flag_local = iskanji((unsigned char)(*tail));
1924 if (isprint((unsigned char)*tail) || k_flag_local || iskanji_flag_local) break;
1925 iskanji_flag_local = k_flag_local && !iskanji_flag_local;
1927 if (isprint(*tail)) break;
1931 if (!*tail) waiting_output = TRUE;
1935 /* Handle line-wrap */
1943 if (roff_s && (ch != ' '))
1951 if (!waiting_output) fprintf(fff, "%s\n", roff_buf);
1952 else strcpy(roff_waiting_buf, roff_buf);
1956 if (cbak != ' ') *roff_p++ = cbak;
1958 while (*r) *roff_p++ = *r++;
1962 if ((roff_p > roff_buf) || (ch != ' '))
1967 if ((ch == ' ') || (ch == '(')) roff_s = roff_p;
1972 strncmp(str, "。", 2) != 0 &&
1973 strncmp(str, "、", 2) != 0 &&
1974 strncmp(str, "ィ", 2) != 0 &&
1975 strncmp(str, "ー", 2) != 0) roff_s = roff_p;
1978 if (ch == ' ') roff_s = roff_p;
1989 * @brief 関数ポインタ用の出力関数 /
1990 * Hook function used in spoil_mon_info()
1992 * @param str 文字列参照ポインタ
1995 static void roff_func(TERM_COLOR attr, concptr str)
2005 * @brief モンスター詳細情報をスポイラー出力するメインルーチン /
2006 * Create a spoiler file for monsters (-SHAWN-)
2007 * @param fname ファイル名
2010 static void spoil_mon_info(player_type *player_ptr, concptr fname)
2018 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2020 /* File type is "TEXT" */
2021 FILE_TYPE(FILE_TYPE_TEXT);
2022 fff = my_fopen(buf, "w");
2026 msg_print("Cannot create spoiler file.");
2031 /* Dump the header */
2032 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
2033 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
2036 spoil_out("------------------------------------------\n\n");
2038 /* Allocate the "who" array */
2039 C_MAKE(who, max_r_idx, MONRACE_IDX);
2041 /* Scan the monsters */
2042 for (i = 1; i < max_r_idx; i++)
2044 monster_race *r_ptr = &r_info[i];
2046 /* Use that monster */
2047 if (r_ptr->name) who[n++] = (s16b)i;
2050 ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
2053 * List all monsters in order
2055 for (l = 0; l < n; l++)
2057 monster_race *r_ptr = &r_info[who[l]];
2058 flags1 = r_ptr->flags1;
2062 if (flags1 & (RF1_QUESTOR))
2068 if (flags1 & (RF1_UNIQUE))
2081 sprintf(buf, _("%s/%s (", "%s%s ("), (r_name + r_ptr->name), _(r_name + r_ptr->E_name, "")); /* ---)--- */
2086 spoil_out(attr_to_text(r_ptr));
2089 sprintf(buf, " '%c')\n", r_ptr->d_char);
2094 sprintf(buf, "=== ");
2098 sprintf(buf, "Num:%d ", who[l]);
2102 sprintf(buf, "Lev:%d ", (int)r_ptr->level);
2106 sprintf(buf, "Rar:%d ", r_ptr->rarity);
2109 if (r_ptr->speed >= 110)
2111 sprintf(buf, "Spd:+%d ", (r_ptr->speed - 110));
2115 sprintf(buf, "Spd:-%d ", (110 - r_ptr->speed));
2120 if ((flags1 & (RF1_FORCE_MAXHP)) || (r_ptr->hside == 1))
2122 sprintf(buf, "Hp:%d ", r_ptr->hdice * r_ptr->hside);
2126 sprintf(buf, "Hp:%dd%d ", r_ptr->hdice, r_ptr->hside);
2131 sprintf(buf, "Ac:%d ", r_ptr->ac);
2135 sprintf(buf, "Exp:%ld\n", (long)(r_ptr->mexp));
2138 /* Reuse the code of monster recall. */
2139 output_monster_spoiler(player_ptr, who[l], roff_func);
2144 /* Free the "who" array */
2145 C_KILL(who, max_r_idx, s16b);
2147 /* Check for errors */
2148 if (ferror(fff) || my_fclose(fff))
2150 msg_print("Cannot close spoiler file.");
2154 msg_print("Successfully created a spoiler file.");
2159 #define MAX_EVOL_DEPTH 64
2163 * @brief int配列でstrncmp()と似た比較処理を行う /
2164 * Compare two int-type array like strncmp() and return TRUE if equals
2165 * @param a 比較するint配列1
2166 * @param b 比較するint配列2
2168 * @return 両者の値が等しければTRUEを返す
2170 static bool int_n_cmp(int *a, int *b, int length)
2172 /* Null-string comparation is always TRUE */
2173 if (!length) return TRUE;
2177 if (*a != *(b++)) return FALSE;
2178 if (!(*(a++))) break;
2186 * @brief ある木が指定された木の部分木かどうかを返す /
2187 * Returns TRUE if an evolution tree is "partial tree"
2188 * @param tree 元となる木構造リスト
2189 * @param partial_tree 部分木かどうか判定したい木構造リスト
2190 * @return 部分木ならばTRUEを返す
2192 static bool is_partial_tree(int *tree, int *partial_tree)
2194 int pt_head = *(partial_tree++);
2197 while (partial_tree[pt_len]) pt_len++;
2201 if (*(tree++) == pt_head)
2203 if (int_n_cmp(tree, partial_tree, pt_len)) return TRUE;
2211 * @brief 進化ツリーをスポイラー出力するメインルーチン /
2212 * Print monsters' evolution information to file
2213 * @param fname 出力ファイル名
2216 static void spoil_mon_evol(concptr fname)
2219 monster_race *r_ptr;
2220 int **evol_tree, i, j, n, r_idx;
2221 int *evol_tree_zero; /* For C_KILL() */
2222 path_build(buf, sizeof buf, ANGBAND_DIR_USER, fname);
2224 /* File type is "TEXT" */
2225 FILE_TYPE(FILE_TYPE_TEXT);
2226 fff = my_fopen(buf, "w");
2230 msg_print("Cannot create spoiler file.");
2234 /* Dump the header */
2235 sprintf(buf, "Monster Spoilers for Hengband Version %d.%d.%d\n",
2236 FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
2239 spoil_out("------------------------------------------\n\n");
2241 /* Allocate the "evol_tree" array (2-dimension) */
2242 C_MAKE(evol_tree, max_r_idx, int *);
2243 C_MAKE(*evol_tree, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
2244 for (i = 1; i < max_r_idx; i++) evol_tree[i] = *evol_tree + i * (MAX_EVOL_DEPTH + 1);
2245 evol_tree_zero = *evol_tree;
2247 /* Step 1: Build the evolution tree */
2248 for (i = 1; i < max_r_idx; i++)
2253 if (!r_ptr->next_exp) continue;
2255 /* Trace evolution */
2257 evol_tree[i][n++] = i;
2260 evol_tree[i][n++] = r_ptr->next_r_idx;
2261 r_ptr = &r_info[r_ptr->next_r_idx];
2262 } while (r_ptr->next_exp && (n < MAX_EVOL_DEPTH));
2265 /* Step 2: Scan the evolution trees and remove "partial tree" */
2266 for (i = 1; i < max_r_idx; i++)
2268 /* Not evolution tree */
2269 if (!evol_tree[i][0]) continue;
2271 for (j = 1; j < max_r_idx; j++)
2274 if (i == j) continue;
2276 /* Not evolution tree */
2277 if (!evol_tree[j][0]) continue;
2279 /* Is evolution tree[i] is part of [j]? */
2280 if (is_partial_tree(evol_tree[j], evol_tree[i]))
2282 /* Remove this evolution tree */
2283 evol_tree[i][0] = 0;
2289 /* Step 3: Sort the evolution trees */
2290 ang_sort(evol_tree, NULL, max_r_idx, ang_sort_comp_evol_tree, ang_sort_swap_evol_tree);
2292 /* Step 4: Print the evolution trees */
2293 for (i = 0; i < max_r_idx; i++)
2295 r_idx = evol_tree[i][0];
2297 /* No evolution or removed evolution tree */
2298 if (!r_idx) continue;
2300 /* Trace the evolution tree */
2301 r_ptr = &r_info[r_idx];
2302 fprintf(fff, _("[%d]: %s (レベル%d, '%c')\n", "[%d]: %s (Level %d, '%c')\n"),
2303 r_idx, r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char);
2305 for (n = 1; r_ptr->next_exp; n++)
2307 fprintf(fff, "%*s-(%ld)-> ", n * 2, "", (long int)r_ptr->next_exp);
2308 fprintf(fff, "[%d]: ", r_ptr->next_r_idx);
2309 r_ptr = &r_info[r_ptr->next_r_idx];
2310 fprintf(fff, _("%s (レベル%d, '%c')\n", "%s (Level %d, '%c')\n"),
2311 r_name + r_ptr->name, (int)r_ptr->level, r_ptr->d_char);
2314 /* End of evolution tree */
2318 /* Free the "evol_tree" array (2-dimension) */
2319 C_KILL(evol_tree_zero, max_r_idx * (MAX_EVOL_DEPTH + 1), int);
2320 C_KILL(evol_tree, max_r_idx, int *);
2322 /* Check for errors */
2323 if (ferror(fff) || my_fclose(fff))
2325 msg_print("Cannot close spoiler file.");
2329 msg_print("Successfully created a spoiler file.");
2334 * @brief スポイラー出力を行うコマンドのメインルーチン /
2335 * Create Spoiler files -BEN-
2338 void do_cmd_spoilers(player_type *player_ptr)
2348 prt("Create a spoiler file.", 2, 0);
2350 /* Prompt for a file */
2351 prt("(1) Brief Object Info (obj-desc.txt)", 5, 5);
2352 prt("(2) Brief Artifact Info (artifact.txt)", 6, 5);
2353 prt("(3) Brief Monster Info (mon-desc.txt)", 7, 5);
2354 prt("(4) Full Monster Info (mon-info.txt)", 8, 5);
2355 prt("(5) Monster Evolution Info (mon-evol.txt)", 9, 5);
2358 prt(_("コマンド:", "Command: "), _(18, 12), 0);
2370 spoil_obj_desc(player_ptr, "obj-desc.txt");
2375 spoil_artifact(player_ptr, "artifact.txt");
2380 spoil_mon_desc("mon-desc.txt");
2385 spoil_mon_info(player_ptr, "mon-info.txt");
2390 spoil_mon_evol("mon-evol.txt");
2403 * @brief ランダムアーティファクト1件を解析する /
2404 * Fill in an object description structure for a given object
2405 * @param player_ptr プレーヤーへの参照ポインタ
2406 * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
2407 * @param desc_ptr 記述内容を収める構造体参照ポインタ
2410 static void random_artifact_analyze(player_type *player_ptr, object_type *o_ptr, obj_desc_list *desc_ptr)
2412 analyze_general(player_ptr, o_ptr, desc_ptr->description);
2413 analyze_pval(o_ptr, &desc_ptr->pval_info);
2414 analyze_brand(o_ptr, desc_ptr->brands);
2415 analyze_slay(o_ptr, desc_ptr->slays);
2416 analyze_immune(o_ptr, desc_ptr->immunities);
2417 analyze_resist(o_ptr, desc_ptr->resistances);
2418 analyze_sustains(o_ptr, desc_ptr->sustains);
2419 analyze_misc_magic(o_ptr, desc_ptr->misc_magic);
2420 desc_ptr->activation = item_activation(o_ptr);
2422 sprintf(desc_ptr->misc_desc, "重さ %d.%d kg",
2423 lbtokg1(o_ptr->weight), lbtokg2(o_ptr->weight));
2425 sprintf(desc_ptr->misc_desc, "Weight %d.%d lbs",
2426 o_ptr->weight / 10, o_ptr->weight % 10);
2431 * @brief ランダムアーティファクト1件をスポイラー出力する /
2432 * Create a spoiler file entry for an artifact
2433 * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
2434 * @param art_ptr 記述内容を収めた構造体参照ポインタ
2435 * Fill in an object description structure for a given object
2438 static void spoiler_print_randart(object_type *o_ptr, obj_desc_list *art_ptr)
2440 pval_info_type *pval_ptr = &art_ptr->pval_info;
2444 /* Don't indent the first line */
2445 fprintf(fff, "%s\n", art_ptr->description);
2448 if (!(o_ptr->ident & (IDENT_MENTAL)))
2450 fprintf(fff, _("%s不明\n", "%sUnknown\n"), INDENT1);
2453 /* An "empty" pval description indicates that the pval affects nothing */
2454 if (pval_ptr->pval_desc[0])
2456 /* Mention the effects of pval */
2457 sprintf(buf, _("%sの修正:", "%s to"), pval_ptr->pval_desc);
2458 spoiler_outlist(buf, pval_ptr->pval_affects, ITEM_SEP);
2461 /* Now deal with the description lists */
2463 spoiler_outlist(_("対:", "Slay"), art_ptr->slays, ITEM_SEP);
2464 spoiler_outlist(_("武器属性:", ""), art_ptr->brands, LIST_SEP);
2465 spoiler_outlist(_("免疫:", "Immunity to"), art_ptr->immunities, ITEM_SEP);
2466 spoiler_outlist(_("耐性:", "Resist"), art_ptr->resistances, ITEM_SEP);
2467 spoiler_outlist(_("維持:", "Sustain"), art_ptr->sustains, ITEM_SEP);
2468 spoiler_outlist("", art_ptr->misc_magic, LIST_SEP);
2470 /* Write out the possible activation at the primary indention level */
2471 if (art_ptr->activation)
2473 fprintf(fff, _("%s発動: %s\n", "%sActivates for %s\n"), INDENT1, art_ptr->activation);
2476 /* End with the miscellaneous facts */
2477 fprintf(fff, "%s%s\n\n", INDENT1, art_ptr->misc_desc);
2482 * @brief ランダムアーティファクト内容をスポイラー出力するサブルーチン /
2483 * @param player_ptr プレーヤーへの参照ポインタ
2484 * @param o_ptr ランダムアーティファクトのオブジェクト構造体参照ポインタ
2485 * @param i 出力したい記録ランダムアーティファクトID
2488 static void spoil_random_artifact_aux(player_type *player_ptr, object_type *o_ptr, int i)
2490 obj_desc_list artifact;
2492 if (!object_is_known(o_ptr) || !o_ptr->art_name
2493 || o_ptr->tval != group_artifact[i].tval)
2496 /* Analyze the artifact */
2497 random_artifact_analyze(player_ptr, o_ptr, &artifact);
2499 /* Write out the artifact description to the spoiler file */
2500 spoiler_print_randart(o_ptr, &artifact);
2504 * @brief ランダムアーティファクト内容をスポイラー出力するメインルーチン /
2505 * Create a list file for random artifacts
2506 * @param fname 出力ファイル名
2509 void spoil_random_artifact(player_type *creature_ptr, concptr fname)
2517 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2519 /* File type is "TEXT" */
2520 FILE_TYPE(FILE_TYPE_TEXT);
2521 fff = my_fopen(buf, "w");
2525 msg_print("Cannot create list file.");
2529 /* Dump the header */
2530 sprintf(buf, "Random artifacts list.\r");
2531 spoiler_underline(buf);
2533 /* List the artifacts by tval */
2534 for (j = 0; group_artifact[j].tval; j++)
2536 /* random artifacts wielding */
2537 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2539 q_ptr = &creature_ptr->inventory_list[i];
2540 spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2543 for (i = 0; i < INVEN_PACK; i++)
2545 q_ptr = &creature_ptr->inventory_list[i];
2546 spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2549 /* random artifacts in home */
2550 st_ptr = &town_info[1].store[STORE_HOME];
2551 for (i = 0; i < st_ptr->stock_num; i++)
2553 q_ptr = &st_ptr->stock[i];
2554 spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2557 /* random artifacts in museum */
2558 st_ptr = &town_info[1].store[STORE_MUSEUM];
2559 for (i = 0; i < st_ptr->stock_num; i++)
2561 q_ptr = &st_ptr->stock[i];
2562 spoil_random_artifact_aux(creature_ptr, q_ptr, j);
2566 /* Check for errors */
2567 if (ferror(fff) || my_fclose(fff))
2569 msg_print("Cannot close list file.");
2573 msg_print("Successfully created a list file.");
2580 #endif /* MACINTOSH */