7 #include "knowledge-quests.h"
8 #include "core/show-file.h"
10 #include "dungeon/dungeon.h"
11 #include "dungeon/quest.h"
12 #include "floor/floor.h"
13 #include "info-reader/fixed-map-parser.h"
14 #include "io-dump/dump-util.h"
15 #include "locale/english.h"
16 #include "monster-race/monster-race.h"
17 #include "object-enchant/artifact.h"
18 #include "object-enchant/special-object-flags.h"
19 #include "object/object-flavor.h"
20 #include "object/object-generator.h"
21 #include "object/object-kind-hook.h"
22 #include "system/system-variables.h" // 暫定、init_flagsのため。後で消すかも.
23 #include "term/screen-processor.h"
24 #include "util/angband-files.h"
25 #include "world/world.h"
28 * Check on the status of an active quest
29 * @param creature_ptr プレーヤーへの参照ポインタ
32 void do_cmd_checkquest(player_type *creature_ptr)
35 do_cmd_knowledge_quests(creature_ptr);
41 * todo player_typeではなくQUEST_IDXを引数にすべきかもしれない
42 * Print all active quests
43 * @param creature_ptr プレーヤーへの参照ポインタ
46 static void do_cmd_knowledge_quests_current(player_type *creature_ptr, FILE *fff)
49 char rand_tmp_str[120] = "\0";
50 GAME_TEXT name[MAX_NLEN];
55 fprintf(fff, _("《遂行中のクエスト》\n", "< Current Quest >\n"));
57 for (QUEST_IDX i = 1; i < max_q_idx; i++)
59 bool is_print = quest[i].status == QUEST_STATUS_TAKEN;
60 is_print |= (quest[i].status == QUEST_STATUS_STAGE_COMPLETED) && (quest[i].type == QUEST_TYPE_TOWER);
61 is_print |= quest[i].status == QUEST_STATUS_COMPLETED;
65 QUEST_IDX old_quest = creature_ptr->current_floor_ptr->inside_quest;
66 for (int j = 0; j < 10; j++)
67 quest_text[j][0] = '\0';
70 creature_ptr->current_floor_ptr->inside_quest = i;
71 init_flags = INIT_SHOW_TEXT;
72 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
73 creature_ptr->current_floor_ptr->inside_quest = old_quest;
74 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
77 if (quest[i].type != QUEST_TYPE_RANDOM)
81 if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_STAGE_COMPLETED)
83 switch (quest[i].type)
85 case QUEST_TYPE_KILL_LEVEL:
86 case QUEST_TYPE_KILL_ANY_LEVEL:
87 r_ptr = &r_info[quest[i].r_idx];
88 strcpy(name, r_name + r_ptr->name);
89 if (quest[i].max_num > 1)
92 sprintf(note, " - %d 体の%sを倒す。(あと %d 体)",
93 (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
96 sprintf(note, " - kill %d %s, have killed %d.",
97 (int)quest[i].max_num, name, (int)quest[i].cur_num);
101 sprintf(note, _(" - %sを倒す。", " - kill %s."), name);
104 case QUEST_TYPE_FIND_ARTIFACT:
107 artifact_type *a_ptr = &a_info[quest[i].k_idx];
109 object_type *q_ptr = &forge;
110 KIND_OBJECT_IDX k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
111 object_prep(q_ptr, k_idx);
112 q_ptr->name1 = quest[i].k_idx;
113 q_ptr->ident = IDENT_STORE;
114 object_desc(creature_ptr, name, q_ptr, OD_NAME_ONLY);
116 sprintf(note, _("\n - %sを見つけ出す。", "\n - Find %s."), name);
118 case QUEST_TYPE_FIND_EXIT:
119 sprintf(note, _(" - 出口に到達する。", " - Reach exit."));
122 case QUEST_TYPE_KILL_NUMBER:
124 sprintf(note, " - %d 体のモンスターを倒す。(あと %d 体)",
125 (int)quest[i].max_num, (int)(quest[i].max_num - quest[i].cur_num));
127 sprintf(note, " - Kill %d monsters, have killed %d.",
128 (int)quest[i].max_num, (int)quest[i].cur_num);
132 case QUEST_TYPE_KILL_ALL:
133 case QUEST_TYPE_TOWER:
134 sprintf(note, _(" - 全てのモンスターを倒す。", " - Kill all monsters."));
139 sprintf(tmp_str, _(" %s (危険度:%d階相当)%s\n", " %s (Danger level: %d)%s\n"),
140 quest[i].name, (int)quest[i].level, note);
142 if (quest[i].status == QUEST_STATUS_COMPLETED)
144 sprintf(tmp_str, _(" クエスト達成 - まだ報酬を受けとってない。\n", " Quest Completed - Unrewarded\n"));
150 while (quest_text[k][0] && k < 10)
152 fprintf(fff, " %s\n", quest_text[k]);
159 if (quest[i].level >= rand_level)
162 rand_level = quest[i].level;
163 if (max_dlv[DUNGEON_ANGBAND] < rand_level) continue;
165 r_ptr = &r_info[quest[i].r_idx];
166 strcpy(name, r_name + r_ptr->name);
167 if (quest[i].max_num <= 1)
169 sprintf(rand_tmp_str, _(" %s (%d 階) - %sを倒す。\n", " %s (Dungeon level: %d)\n Kill %s.\n"),
170 quest[i].name, (int)quest[i].level, name);
175 sprintf(rand_tmp_str, " %s (%d 階) - %d 体の%sを倒す。(あと %d 体)\n",
176 quest[i].name, (int)quest[i].level,
177 (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
181 sprintf(rand_tmp_str, " %s (Dungeon level: %d)\n Kill %d %s, have killed %d.\n",
182 quest[i].name, (int)quest[i].level,
183 (int)quest[i].max_num, name, (int)quest[i].cur_num);
187 if (rand_tmp_str[0]) fputs(rand_tmp_str, fff);
189 if (!total) fprintf(fff, _(" なし\n", " Nothing.\n"));
193 static bool do_cmd_knowledge_quests_aux(player_type *player_ptr, FILE *fff, IDX q_idx)
196 char playtime_str[16];
197 quest_type* const q_ptr = &quest[q_idx];
199 floor_type *floor_ptr = player_ptr->current_floor_ptr;
200 if (is_fixed_quest_idx(q_idx))
202 IDX old_quest = floor_ptr->inside_quest;
203 floor_ptr->inside_quest = q_idx;
204 init_flags = INIT_NAME_ONLY;
205 parse_fixed_map(player_ptr, "q_info.txt", 0, 0, 0, 0);
206 floor_ptr->inside_quest = old_quest;
207 if (q_ptr->flags & QUEST_FLAG_SILENT) return FALSE;
210 strnfmt(playtime_str, sizeof(playtime_str), "%02d:%02d:%02d",
211 q_ptr->comptime / (60 * 60), (q_ptr->comptime / 60) % 60, q_ptr->comptime % 60);
213 if (is_fixed_quest_idx(q_idx) || (q_ptr->r_idx == 0))
216 _(" %-35s (危険度:%3d階相当) - レベル%2d - %s\n",
217 " %-35s (Danger level: %3d) - level %2d - %s\n"),
218 q_ptr->name, (int)q_ptr->level, q_ptr->complev, playtime_str);
223 if (q_ptr->complev == 0)
226 _(" %-35s (%3d階) - 不戦勝 - %s\n",
227 " %-35s (Dungeon level: %3d) - Unearned - %s\n"),
228 r_name + r_info[q_ptr->r_idx].name,
229 (int)q_ptr->level, playtime_str);
235 _(" %-35s (%3d階) - レベル%2d - %s\n",
236 " %-35s (Dungeon level: %3d) - level %2d - %s\n"),
237 r_name + r_info[q_ptr->r_idx].name,
247 * Print all finished quests
248 * @param creature_ptr プレーヤーへの参照ポインタ
249 * @param fff セーブファイル (展開済?)
250 * @param quest_num[] 受注したことのあるクエスト群
253 void do_cmd_knowledge_quests_completed(player_type *creature_ptr, FILE *fff, QUEST_IDX quest_num[])
255 fprintf(fff, _("《達成したクエスト》\n", "< Completed Quest >\n"));
257 for (QUEST_IDX i = 1; i < max_q_idx; i++)
259 QUEST_IDX q_idx = quest_num[i];
260 quest_type* const q_ptr = &quest[q_idx];
262 if (q_ptr->status == QUEST_STATUS_FINISHED && do_cmd_knowledge_quests_aux(creature_ptr, fff, q_idx))
268 if (!total) fprintf(fff, _(" なし\n", " Nothing.\n"));
273 * Print all failed quests
274 * @param creature_ptr プレーヤーへの参照ポインタ
275 * @param fff セーブファイル (展開済?)
276 * @param quest_num[] 受注したことのあるクエスト群
279 void do_cmd_knowledge_quests_failed(player_type *creature_ptr, FILE *fff, QUEST_IDX quest_num[])
281 fprintf(fff, _("《失敗したクエスト》\n", "< Failed Quest >\n"));
283 for (QUEST_IDX i = 1; i < max_q_idx; i++)
285 QUEST_IDX q_idx = quest_num[i];
286 quest_type* const q_ptr = &quest[q_idx];
288 if (((q_ptr->status == QUEST_STATUS_FAILED_DONE) || (q_ptr->status == QUEST_STATUS_FAILED)) &&
289 do_cmd_knowledge_quests_aux(creature_ptr, fff, q_idx))
295 if (!total) fprintf(fff, _(" なし\n", " Nothing.\n"));
300 * Print all random quests
302 static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
304 fprintf(fff, _("《残りのランダムクエスト》\n", "< Remaining Random Quest >\n"));
305 GAME_TEXT tmp_str[120];
307 for (QUEST_IDX i = 1; i < max_q_idx; i++)
309 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
311 if ((quest[i].type == QUEST_TYPE_RANDOM) && (quest[i].status == QUEST_STATUS_TAKEN))
314 sprintf(tmp_str, _(" %s (%d階, %s)\n", " %s (%d, %s)\n"),
315 quest[i].name, (int)quest[i].level, r_name + r_info[quest[i].r_idx].name);
320 if (!total) fprintf(fff, _(" なし\n", " Nothing.\n"));
324 * Print quest status of all active quests
325 * @param creature_ptr プレーヤーへの参照ポインタ
328 void do_cmd_knowledge_quests(player_type *creature_ptr)
331 GAME_TEXT file_name[FILE_NAME_SIZE];
332 if (!open_temporary_file(&fff, file_name)) return;
335 C_MAKE(quest_num, max_q_idx, QUEST_IDX);
337 for (IDX i = 1; i < max_q_idx; i++)
341 ang_sort(creature_ptr, quest_num, &dummy, max_q_idx, ang_sort_comp_quest_num, ang_sort_swap_quest_num);
343 do_cmd_knowledge_quests_current(creature_ptr, fff);
345 do_cmd_knowledge_quests_completed(creature_ptr, fff, quest_num);
347 do_cmd_knowledge_quests_failed(creature_ptr, fff, quest_num);
348 if (current_world_ptr->wizard)
351 do_cmd_knowledge_quests_wiz_random(fff);
355 (void)show_file(creature_ptr, TRUE, file_name, _("クエスト達成状況", "Quest status"), 0, 0);
357 C_KILL(quest_num, max_q_idx, QUEST_IDX);