1 #include "io-dump/character-dump.h"
2 #include "artifact/fixed-art-types.h"
3 #include "avatar/avatar.h"
4 #include "cmd-building/cmd-building.h"
5 #include "dungeon/quest.h"
6 #include "flavor/flavor-describer.h"
7 #include "floor/floor-town.h"
8 #include "game-option/birth-options.h"
9 #include "game-option/game-play-options.h"
10 #include "inventory/inventory-slot-types.h"
11 #include "io-dump/player-status-dump.h"
12 #include "io-dump/special-class-dump.h"
13 #include "io/mutations-dump.h"
14 #include "io/write-diary.h"
15 #include "knowledge/knowledge-quests.h"
16 #include "main/angband-headers.h"
17 #include "market/arena-info-table.h"
18 #include "monster-race/monster-race.h"
19 #include "monster-race/race-flags1.h"
20 #include "monster/monster-describer.h"
21 #include "monster/monster-description-types.h"
22 #include "monster/monster-info.h"
23 #include "monster/monster-status.h"
24 #include "monster/smart-learn-types.h"
25 #include "object/object-info.h"
26 #include "pet/pet-util.h"
27 #include "player-info/alignment.h"
28 #include "player/player-status-flags.h"
29 #include "player/player-status-table.h"
30 #include "player/race-info-table.h"
31 #include "realm/realm-names-table.h"
32 #include "store/store-util.h"
33 #include "store/store.h"
34 #include "system/angband-version.h"
35 #include "system/building-type-definition.h"
36 #include "system/dungeon-info.h"
37 #include "system/floor-type-definition.h"
38 #include "system/item-entity.h"
39 #include "system/monster-entity.h"
40 #include "system/monster-race-info.h"
41 #include "system/player-type-definition.h"
42 #include "term/z-form.h"
43 #include "util/enum-converter.h"
44 #include "util/int-char-converter.h"
45 #include "util/sort.h"
46 #include "util/string-processor.h"
47 #include "view/display-messages.h"
48 #include "world/world.h"
53 * @brief プレイヤーのペット情報をファイルにダンプする
54 * @param player_ptr プレイヤーへの参照ポインタ
57 static void dump_aux_pet(PlayerType *player_ptr, FILE *fff)
60 bool pet_settings = false;
61 for (int i = player_ptr->current_floor_ptr->m_max - 1; i >= 1; i--) {
62 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
64 if (!m_ptr->is_valid()) {
67 if (!m_ptr->is_pet()) {
71 if (!m_ptr->is_named() && (player_ptr->riding != i)) {
75 fprintf(fff, _("\n\n [主なペット]\n\n", "\n\n [Leading Pets]\n\n"));
79 const auto pet_name = monster_desc(player_ptr, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
80 fprintf(fff, "%s\n", pet_name.data());
87 fprintf(fff, _("\n\n [ペットへの命令]\n", "\n\n [Command for Pets]\n"));
89 fprintf(fff, _("\n ドアを開ける: %s", "\n Pets open doors: %s"),
90 (player_ptr->pet_extra_flags & PF_OPEN_DOORS) ? "ON" : "OFF");
92 fprintf(fff, _("\n アイテムを拾う: %s", "\n Pets pick up items: %s"),
93 (player_ptr->pet_extra_flags & PF_PICKUP_ITEMS) ? "ON" : "OFF");
95 fprintf(fff, _("\n テレポート系魔法を使う: %s", "\n Allow teleport: %s"),
96 (player_ptr->pet_extra_flags & PF_TELEPORT) ? "ON" : "OFF");
98 fprintf(fff, _("\n 攻撃魔法を使う: %s", "\n Allow cast attack spell: %s"),
99 (player_ptr->pet_extra_flags & PF_ATTACK_SPELL) ? "ON" : "OFF");
101 fprintf(fff, _("\n 召喚魔法を使う: %s", "\n Allow cast summon spell: %s"),
102 (player_ptr->pet_extra_flags & PF_SUMMON_SPELL) ? "ON" : "OFF");
104 fprintf(fff, _("\n プレイヤーを巻き込む範囲魔法を使う: %s", "\n Allow involve player in area spell: %s"),
105 (player_ptr->pet_extra_flags & PF_BALL_SPELL) ? "ON" : "OFF");
111 * @brief クエスト情報をファイルにダンプする
112 * @param player_ptr プレイヤーへの参照ポインタ
113 * @param fff ファイルポインタ
115 static void dump_aux_quest(PlayerType *player_ptr, FILE *fff)
117 fprintf(fff, _("\n\n [クエスト情報]\n", "\n\n [Quest Information]\n"));
119 const auto &quest_list = QuestList::get_instance();
120 std::vector<QuestId> quest_numbers;
121 for (const auto &[q_idx, q_ref] : quest_list) {
122 quest_numbers.push_back(q_idx);
125 ang_sort(player_ptr, quest_numbers.data(), &dummy, quest_numbers.size(), ang_sort_comp_quest_num, ang_sort_swap_quest_num);
128 do_cmd_knowledge_quests_completed(player_ptr, fff, quest_numbers);
130 do_cmd_knowledge_quests_failed(player_ptr, fff, quest_numbers);
135 * @brief 死の直前メッセージ並びに遺言をファイルにダンプする
136 * @param player_ptr プレイヤーへの参照ポインタ
137 * @param fff ファイルポインタ
139 static void dump_aux_last_message(PlayerType *player_ptr, FILE *fff)
141 if (!player_ptr->is_dead) {
145 if (!w_ptr->total_winner) {
146 fprintf(fff, _("\n [死ぬ直前のメッセージ]\n\n", "\n [Last Messages]\n\n"));
147 for (int i = std::min(message_num(), 30); i >= 0; i--) {
148 fprintf(fff, "> %s\n", message_str((int16_t)i));
155 if (player_ptr->last_message) {
156 fprintf(fff, _("\n [*勝利*メッセージ]\n\n", "\n [*Winning* Message]\n\n"));
157 fprintf(fff, " %s\n", player_ptr->last_message);
163 * @brief 帰還場所情報をファイルにダンプする
164 * @param fff ファイルポインタ
166 static void dump_aux_recall(FILE *fff)
168 fprintf(fff, _("\n [帰還場所]\n\n", "\n [Recall Depth]\n\n"));
169 for (const auto &d_ref : dungeons_info) {
172 if (d_ref.idx == 0 || !d_ref.maxdepth) {
175 if (!max_dlv[d_ref.idx]) {
178 if (MonsterRace(d_ref.final_guardian).is_valid()) {
179 if (!monraces_info[d_ref.final_guardian].max_num) {
182 } else if (max_dlv[d_ref.idx] == d_ref.maxdepth) {
186 fprintf(fff, _(" %c%-12s: %3d 階\n", " %c%-16s: level %3d\n"), seiha ? '!' : ' ', d_ref.name.data(), (int)max_dlv[d_ref.idx]);
191 * @brief オプション情報をファイルにダンプする
192 * @param fff ファイルポインタ
194 static void dump_aux_options(FILE *fff)
196 fprintf(fff, _("\n [オプション設定]\n", "\n [Option Settings]\n"));
198 fprintf(fff, _("\n 保存モード: ON", "\n Preserve Mode: ON"));
200 fprintf(fff, _("\n 保存モード: OFF", "\n Preserve Mode: OFF"));
203 if (ironman_small_levels) {
204 fprintf(fff, _("\n 小さいダンジョン: ALWAYS", "\n Small Levels: ALWAYS"));
205 } else if (always_small_levels) {
206 fprintf(fff, _("\n 小さいダンジョン: ON", "\n Small Levels: ON"));
207 } else if (small_levels) {
208 fprintf(fff, _("\n 小さいダンジョン: ENABLED", "\n Small Levels: ENABLED"));
210 fprintf(fff, _("\n 小さいダンジョン: OFF", "\n Small Levels: OFF"));
214 fprintf(fff, _("\n 元祖の町のみ: ON", "\n Vanilla Town: ON"));
215 } else if (lite_town) {
216 fprintf(fff, _("\n 小規模な町: ON", "\n Lite Town: ON"));
220 fprintf(fff, _("\n 店なし: ON", "\n No Shops: ON"));
223 if (ironman_downward) {
224 fprintf(fff, _("\n 階段を上がれない: ON", "\n Diving Only: ON"));
228 fprintf(fff, _("\n 普通でない部屋: ON", "\n Unusual Rooms: ON"));
231 if (ironman_nightmare) {
232 fprintf(fff, _("\n 悪夢モード: ON", "\n Nightmare Mode: ON"));
235 if (ironman_empty_levels) {
236 fprintf(fff, _("\n アリーナ: ALWAYS", "\n Arena Levels: ALWAYS"));
237 } else if (empty_levels) {
238 fprintf(fff, _("\n アリーナ: ENABLED", "\n Arena Levels: ENABLED"));
240 fprintf(fff, _("\n アリーナ: OFF", "\n Arena Levels: OFF"));
245 if (w_ptr->noscore) {
246 fprintf(fff, _("\n 何か不正なことをしてしまっています。\n", "\n You have done something illegal.\n"));
253 * @brief 闘技場の情報をファイルにダンプする
254 * @param player_ptr プレイヤーへの参照ポインタ
255 * @param fff ファイルポインタ
257 static void dump_aux_arena(PlayerType *player_ptr, FILE *fff)
259 if (lite_town || vanilla_town) {
263 if (player_ptr->arena_number < 0) {
264 if (player_ptr->arena_number <= ARENA_DEFEATED_OLD_VER) {
265 fprintf(fff, _("\n 闘技場: 敗北\n", "\n Arena: Defeated\n"));
269 fff, "\n 闘技場: %d回戦で%sの前に敗北\n", -player_ptr->arena_number, monraces_info[arena_info[-1 - player_ptr->arena_number].r_idx].name.data());
271 fprintf(fff, "\n Arena: Defeated by %s in the %d%s fight\n", monraces_info[arena_info[-1 - player_ptr->arena_number].r_idx].name.data(),
272 -player_ptr->arena_number, get_ordinal_number_suffix(-player_ptr->arena_number));
280 if (player_ptr->arena_number > MAX_ARENA_MONS + 2) {
281 fprintf(fff, _("\n 闘技場: 真のチャンピオン\n", "\n Arena: True Champion\n"));
286 if (player_ptr->arena_number > MAX_ARENA_MONS - 1) {
287 fprintf(fff, _("\n 闘技場: チャンピオン\n", "\n Arena: Champion\n"));
293 fprintf(fff, "\n 闘技場: %2d勝\n", (player_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : player_ptr->arena_number));
295 fprintf(fff, "\n Arena: %2d Victor%s\n", (player_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : player_ptr->arena_number),
296 (player_ptr->arena_number > 1) ? "ies" : "y");
302 * @brief 撃破モンスターの情報をファイルにダンプする
303 * @param fff ファイルポインタ
305 static void dump_aux_monsters(PlayerType *player_ptr, FILE *fff)
307 fprintf(fff, _("\n [倒したモンスター]\n\n", "\n [Defeated Monsters]\n\n"));
309 /* Allocate the "who" array */
311 std::vector<MonsterRaceId> who;
313 /* Count monster kills */
315 for (const auto &[r_idx, r_ref] : monraces_info) {
316 /* Ignore unused index */
317 if (!MonsterRace(r_ref.idx).is_valid() || r_ref.name.empty()) {
321 if (r_ref.kind_flags.has(MonsterKindType::UNIQUE)) {
322 bool dead = (r_ref.max_num == 0);
326 /* Add a unique monster to the list */
327 who.push_back(r_ref.idx);
333 if (r_ref.r_pkills > 0) {
334 norm_total += r_ref.r_pkills;
338 /* No monsters is defeated */
339 if (norm_total < 1) {
340 fprintf(fff, _("まだ敵を倒していません。\n", "You have defeated no enemies yet.\n"));
344 auto uniq_total = static_cast<int>(who.size());
345 /* Defeated more than one normal monsters */
346 if (uniq_total == 0) {
348 fprintf(fff, "%d体の敵を倒しています。\n", norm_total);
350 fprintf(fff, "You have defeated %d %s.\n", norm_total, norm_total == 1 ? "enemy" : "enemies");
355 /* Defeated more than one unique monsters */
357 fprintf(fff, "%d体のユニーク・モンスターを含む、合計%d体の敵を倒しています。\n", uniq_total, norm_total);
359 fprintf(fff, "You have defeated %d %s including %d unique monster%s in total.\n", norm_total, norm_total == 1 ? "enemy" : "enemies", uniq_total,
360 (uniq_total == 1 ? "" : "s"));
363 /* Sort the array by dungeon depth of monsters */
364 ang_sort(player_ptr, who.data(), &why, uniq_total, ang_sort_comp_hook, ang_sort_swap_hook);
365 fprintf(fff, _("\n《上位%d体のユニーク・モンスター》\n", "\n< Unique monsters top %d >\n"), std::min(uniq_total, 10));
368 for (auto it = who.rbegin(); it != who.rend() && std::distance(who.rbegin(), it) < 10; it++) {
369 auto *r_ptr = &monraces_info[*it];
370 if (r_ptr->defeat_level && r_ptr->defeat_time) {
371 strnfmt(buf, sizeof(buf), _(" - レベル%2d - %d:%02d:%02d", " - level %2d - %d:%02d:%02d"), r_ptr->defeat_level, r_ptr->defeat_time / (60 * 60),
372 (r_ptr->defeat_time / 60) % 60, r_ptr->defeat_time % 60);
377 auto name = str_separate(r_ptr->name, 40);
378 fprintf(fff, _(" %-40s (レベル%3d)%s\n", " %-40s (level %3d)%s\n"), name.front().data(), (int)r_ptr->level, buf);
379 for (auto i = 1U; i < name.size(); ++i) {
380 fprintf(fff, " %s\n", name[i].data());
386 * @brief 元種族情報をファイルにダンプする
387 * @param player_ptr プレイヤーへの参照ポインタ
388 * @param fff ファイルポインタ
390 static void dump_aux_race_history(PlayerType *player_ptr, FILE *fff)
392 if (!player_ptr->old_race1 && !player_ptr->old_race2) {
396 fprintf(fff, _("\n\n あなたは%sとして生まれた。", "\n\n You were born as %s."), race_info[enum2i(player_ptr->start_race)].title);
397 for (int i = 0; i < MAX_RACES; i++) {
398 if (enum2i(player_ptr->start_race) == i) {
402 if (!(player_ptr->old_race1 & 1UL << i)) {
406 if (!(player_ptr->old_race2 & 1UL << (i - 32))) {
411 fprintf(fff, _("\n あなたはかつて%sだった。", "\n You were a %s before."), race_info[i].title);
418 * @brief 元魔法領域情報をファイルにダンプする
419 * @param player_ptr プレイヤーへの参照ポインタ
420 * @param fff ファイルポインタ
422 static void dump_aux_realm_history(PlayerType *player_ptr, FILE *fff)
424 if (player_ptr->old_realm == 0) {
429 for (int i = 0; i < MAX_MAGIC; i++) {
430 if (!(player_ptr->old_realm & 1UL << i)) {
433 fprintf(fff, _("\n あなたはかつて%s魔法を使えた。", "\n You were able to use %s magic before."), realm_names[i + 1]);
440 * @brief 徳の情報をファイルにダンプする
441 * @param player_ptr プレイヤーへの参照ポインタ
442 * @param fff ファイルポインタ
444 static void dump_aux_virtues(PlayerType *player_ptr, FILE *fff)
446 fprintf(fff, _("\n\n [自分に関する情報]\n\n", "\n\n [HP-rate & Max stat & Virtues]\n\n"));
448 int percent = (int)(((long)player_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) / (2 * player_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (player_ptr->hitdie + 1))));
451 if (player_ptr->knowledge & KNOW_HPRATE) {
452 fprintf(fff, "現在の体力ランク : %d/100\n\n", percent);
454 fprintf(fff, "現在の体力ランク : ???\n\n");
456 fprintf(fff, "能力の最大値\n");
458 if (player_ptr->knowledge & KNOW_HPRATE) {
459 fprintf(fff, "Your current Life Rating is %d/100.\n\n", percent);
461 fprintf(fff, "Your current Life Rating is ???.\n\n");
463 fprintf(fff, "Limits of maximum stats\n");
465 for (int v_nr = 0; v_nr < A_MAX; v_nr++) {
466 if ((player_ptr->knowledge & KNOW_STAT) || player_ptr->stat_max[v_nr] == player_ptr->stat_max_max[v_nr]) {
467 fprintf(fff, "%s 18/%d\n", stat_names[v_nr], player_ptr->stat_max_max[v_nr] - 18);
469 fprintf(fff, "%s ???\n", stat_names[v_nr]);
473 std::string alg = PlayerAlignment(player_ptr).get_alignment_description();
474 fprintf(fff, _("\n属性 : %s\n", "\nYour alignment : %s\n"), alg.data());
476 dump_virtues(player_ptr, fff);
480 * @brief 突然変異の情報をファイルにダンプする
481 * @param player_ptr プレイヤーへの参照ポインタ
482 * @param fff ファイルポインタ
484 static void dump_aux_mutations(PlayerType *player_ptr, FILE *fff)
486 if (player_ptr->muta.any()) {
487 fprintf(fff, _("\n\n [突然変異]\n\n", "\n\n [Mutations]\n\n"));
488 dump_mutations(player_ptr, fff);
493 * @brief 所持品の情報をファイルにダンプする
494 * @param player_ptr プレイヤーへの参照ポインタ
495 * @param fff ファイルポインタ
497 static void dump_aux_equipment_inventory(PlayerType *player_ptr, FILE *fff)
499 GAME_TEXT o_name[MAX_NLEN];
500 if (player_ptr->equip_cnt) {
501 fprintf(fff, _(" [キャラクタの装備]\n\n", " [Character Equipment]\n\n"));
502 for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
503 describe_flavor(player_ptr, o_name, &player_ptr->inventory_list[i], 0);
504 if ((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(player_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(player_ptr))) && has_two_handed_weapons(player_ptr)) {
505 strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
508 fprintf(fff, "%c) %s\n", index_to_label(i), o_name);
511 fprintf(fff, "\n\n");
514 fprintf(fff, _(" [キャラクタの持ち物]\n\n", " [Character Inventory]\n\n"));
516 for (int i = 0; i < INVEN_PACK; i++) {
517 if (!player_ptr->inventory_list[i].bi_id) {
520 describe_flavor(player_ptr, o_name, &player_ptr->inventory_list[i], 0);
521 fprintf(fff, "%c) %s\n", index_to_label(i), o_name);
524 fprintf(fff, "\n\n");
528 * @brief 我が家と博物館のオブジェクト情報をファイルにダンプする
529 * @param fff ファイルポインタ
531 static void dump_aux_home_museum(PlayerType *player_ptr, FILE *fff)
533 store_type *store_ptr;
534 store_ptr = &town_info[1].store[enum2i(StoreSaleType::HOME)];
536 GAME_TEXT o_name[MAX_NLEN];
537 if (store_ptr->stock_num) {
538 fprintf(fff, _(" [我が家のアイテム]\n", " [Home Inventory]\n"));
541 for (int i = 0; i < store_ptr->stock_num; i++) {
543 fprintf(fff, _("\n ( %d ページ )\n", "\n ( page %d )\n"), x++);
545 describe_flavor(player_ptr, o_name, &store_ptr->stock[i], 0);
546 fprintf(fff, "%c) %s\n", I2A(i % 12), o_name);
549 fprintf(fff, "\n\n");
552 store_ptr = &town_info[1].store[enum2i(StoreSaleType::MUSEUM)];
554 if (store_ptr->stock_num == 0) {
558 fprintf(fff, _(" [博物館のアイテム]\n", " [Museum]\n"));
561 for (int i = 0; i < store_ptr->stock_num; i++) {
563 fprintf(fff, _("\n ( %d ページ )\n", "\n ( page %d )\n"), x++);
565 describe_flavor(player_ptr, o_name, &store_ptr->stock[i], 0);
566 fprintf(fff, "%c) %s\n", I2A(i % 12), o_name);
569 fprintf(fff, "\n\n");
573 * @brief チェックサム情報を出力 / Get check sum in string form
574 * @return チェックサム情報の文字列
576 static std::string get_check_sum(void)
578 return format("%02x%02x%02x%02x%02x%02x%02x%02x%02x", terrains_header.checksum, baseitems_header.checksum,
579 artifacts_header.checksum, egos_header.checksum, monraces_header.checksum, dungeons_header.checksum,
580 class_magics_header.checksum, class_skills_header.checksum, vaults_header.checksum);
584 * @brief ダンプ出力のメインルーチン
585 * Output the character dump to a file
586 * @param player_ptr プレイヤーへの参照ポインタ
587 * @param fff ファイルポインタ
590 void make_character_dump(PlayerType *player_ptr, FILE *fff)
592 TermOffsetSetter tos(0, 0);
594 fprintf(fff, _(" [%s キャラクタ情報]\n\n", " [%s Character Dump]\n\n"), get_version().data());
596 dump_aux_player_status(player_ptr, fff);
597 dump_aux_last_message(player_ptr, fff);
598 dump_aux_options(fff);
599 dump_aux_recall(fff);
600 dump_aux_quest(player_ptr, fff);
601 dump_aux_arena(player_ptr, fff);
602 dump_aux_monsters(player_ptr, fff);
603 dump_aux_virtues(player_ptr, fff);
604 dump_aux_race_history(player_ptr, fff);
605 dump_aux_realm_history(player_ptr, fff);
606 dump_aux_class_special(player_ptr, fff);
607 dump_aux_mutations(player_ptr, fff);
608 dump_aux_pet(player_ptr, fff);
610 dump_aux_equipment_inventory(player_ptr, fff);
611 dump_aux_home_museum(player_ptr, fff);
613 fprintf(fff, _(" [チェックサム: \"%s\"]\n\n", " [Check Sum: \"%s\"]\n\n"), get_check_sum().data());