6 #include "floor-save.h"
7 #include "floor-events.h"
10 #include "monsterrace-hook.h"
12 #include "player-status.h"
13 #include "player-personality.h"
20 quest_type *quest; /*!< Quest info */
21 QUEST_IDX max_q_idx; /*!< Maximum number of quests */
22 char quest_text[10][80]; /*!< Quest text */
23 int quest_text_line; /*!< Current line of the quest text */
24 int leaving_quest = 0;
27 * @brief クエスト突入時のメッセージテーブル / Array of places to find an inscription
29 static concptr find_quest[] =
31 _("床にメッセージが刻まれている:", "You find the following inscription in the floor"),
32 _("壁にメッセージが刻まれている:", "You see a message inscribed in the wall"),
33 _("メッセージを見つけた:", "There is a sign saying"),
34 _("何かが階段の上に書いてある:", "Something is written on the staircase"),
35 _("巻物を見つけた。メッセージが書いてある:", "You find a scroll with the following message"),
39 * @brief ランダムクエストの討伐ユニークを決める / Determine the random quest uniques
40 * @param q_ptr クエスト構造体の参照ポインタ
43 void determine_random_questor(quest_type *q_ptr)
48 get_mon_num_prep(mon_hook_quest, NULL);
53 * Random monster 5 - 10 levels out of depth
54 * (depending on level)
56 r_idx = get_mon_num(q_ptr->level + 5 + randint1(q_ptr->level / 10));
57 r_ptr = &r_info[r_idx];
59 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
60 if (r_ptr->flags1 & RF1_QUESTOR) continue;
61 if (r_ptr->rarity > 100) continue;
62 if (r_ptr->flags7 & RF7_FRIENDLY) continue;
63 if (r_ptr->flags7 & RF7_AQUATIC) continue;
64 if (r_ptr->flags8 & RF8_WILD_ONLY) continue;
65 if (no_questor_or_bounty_uniques(r_idx)) continue;
68 * Accept monsters that are 2 - 6 levels
69 * out of depth depending on the quest level
71 if (r_ptr->level > (q_ptr->level + (q_ptr->level / 20))) break;
78 * @brief クエストを達成状態にする /
79 * @param quest_num 達成状態にしたいクエストのID
82 void complete_quest(QUEST_IDX quest_num)
84 quest_type* const q_ptr = &quest[quest_num];
88 case QUEST_TYPE_RANDOM:
89 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
92 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
96 q_ptr->status = QUEST_STATUS_COMPLETED;
97 q_ptr->complev = p_ptr->lev;
99 q_ptr->comptime = current_world_ptr->play_time;
101 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
103 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
104 msg_print(_("クエストを達成した!", "You just completed your quest!"));
112 * @brief 特定の敵を倒した際にクエスト達成処理 /
113 * Check for "Quest" completion when a quest monster is killed or charmed.
114 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
117 void check_quest_completion(monster_type *m_ptr)
122 bool create_stairs = FALSE;
132 quest_num = p_ptr->inside_quest;
134 /* Search for an active quest on this dungeon level */
139 for (i = max_q_idx - 1; i > 0; i--)
141 quest_type* const q_ptr = &quest[i];
143 /* Quest is not active */
144 if (q_ptr->status != QUEST_STATUS_TAKEN)
147 /* Quest is not a dungeon quest */
148 if (q_ptr->flags & QUEST_FLAG_PRESET)
151 /* Quest is not on this level */
152 if ((q_ptr->level != current_floor_ptr->dun_level) &&
153 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
156 /* Not a "kill monster" quest */
157 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
158 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
161 /* Interesting quest */
162 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
163 (q_ptr->type == QUEST_TYPE_TOWER) ||
164 (q_ptr->type == QUEST_TYPE_KILL_ALL))
167 /* Interesting quest */
168 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
169 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
170 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
171 (q_ptr->r_idx == m_ptr->r_idx))
178 /* Handle the current quest */
179 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
182 quest_type* const q_ptr = &quest[quest_num];
186 case QUEST_TYPE_KILL_NUMBER:
190 if (q_ptr->cur_num >= q_ptr->num_mon)
192 complete_quest(quest_num);
198 case QUEST_TYPE_KILL_ALL:
200 if (!is_hostile(m_ptr)) break;
202 if (count_all_hostile_monsters() == 1)
204 if (q_ptr->flags & QUEST_FLAG_SILENT)
206 q_ptr->status = QUEST_STATUS_FINISHED;
210 complete_quest(quest_num);
215 case QUEST_TYPE_KILL_LEVEL:
216 case QUEST_TYPE_RANDOM:
218 /* Only count valid monsters */
219 if (q_ptr->r_idx != m_ptr->r_idx)
224 if (q_ptr->cur_num >= q_ptr->max_num)
226 complete_quest(quest_num);
228 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
230 create_stairs = TRUE;
231 p_ptr->inside_quest = 0;
234 /* Finish the two main quests without rewarding */
235 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
237 q_ptr->status = QUEST_STATUS_FINISHED;
240 if (q_ptr->type == QUEST_TYPE_RANDOM)
243 q_ptr->status = QUEST_STATUS_FINISHED;
248 case QUEST_TYPE_KILL_ANY_LEVEL:
251 if (q_ptr->cur_num >= q_ptr->max_num)
253 complete_quest(quest_num);
258 case QUEST_TYPE_TOWER:
260 if (!is_hostile(m_ptr)) break;
262 if (count_all_hostile_monsters() == 1)
264 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
266 if ((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
267 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
268 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
271 complete_quest(QUEST_TOWER1);
279 /* Create a magical staircase */
285 while (cave_perma_bold(y, x) || current_floor_ptr->grid_array[y][x].o_idx || (current_floor_ptr->grid_array[y][x].info & CAVE_OBJECT))
287 /* Pick a location */
288 scatter(&ny, &nx, y, x, 1, 0);
294 /* Explain the staircase */
295 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
297 /* Create stairs down */
298 cave_set_feat(y, x, feat_down_stair);
300 /* Remember to update everything */
301 p_ptr->update |= (PU_FLOW);
311 for (i = 0; i < (current_floor_ptr->dun_level / 15) + 1; i++)
316 /* Make a great object */
317 make_object(o_ptr, AM_GOOD | AM_GREAT);
318 (void)drop_near(o_ptr, -1, y, x);
324 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
325 * Check for "Quest" completion when a quest monster is killed or charmed.
326 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
329 void check_find_art_quest_completion(object_type *o_ptr)
332 /* Check if completed a quest */
333 for (i = 0; i < max_q_idx; i++)
335 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
336 (quest[i].status == QUEST_STATUS_TAKEN) &&
337 (quest[i].k_idx == o_ptr->name1))
346 * @brief クエストの導入メッセージを表示する / Discover quest
347 * @param q_idx 開始されたクエストのID
349 void quest_discovery(QUEST_IDX q_idx)
351 quest_type *q_ptr = &quest[q_idx];
352 monster_race *r_ptr = &r_info[q_ptr->r_idx];
353 MONSTER_NUMBER q_num = q_ptr->max_num;
354 GAME_TEXT name[MAX_NLEN];
358 strcpy(name, (r_name + r_ptr->name));
360 msg_print(find_quest[rand_range(0, 4)]);
365 if ((r_ptr->flags1 & RF1_UNIQUE) && (0 == r_ptr->max_num))
367 msg_print(_("この階は以前は誰かによって守られていたようだ…。", "It seems that this level was protected by someone before..."));
368 /* The unique is already dead */
369 quest[q_idx].status = QUEST_STATUS_FINISHED;
372 q_ptr->comptime = current_world_ptr->play_time;
376 msg_format(_("注意せよ!この階は%sによって守られている!", "Beware, this level is protected by %s!"), name);
384 msg_format(_("注意しろ!この階は%d体の%sによって守られている!", "Be warned, this level is guarded by %d %s!"), q_num, name);
391 * @brief 新しく入ったダンジョンの階層に固定されている一般のクエストを探し出しIDを返す。
392 * / Hack -- Check if a level is a "quest" level
393 * @param level 検索対象になる階
394 * @return クエストIDを返す。該当がない場合0を返す。
396 QUEST_IDX quest_number(DEPTH level)
401 if (p_ptr->inside_quest)
402 return (p_ptr->inside_quest);
404 for (i = 0; i < max_q_idx; i++)
406 if (quest[i].status != QUEST_STATUS_TAKEN) continue;
408 if ((quest[i].type == QUEST_TYPE_KILL_LEVEL) &&
409 !(quest[i].flags & QUEST_FLAG_PRESET) &&
410 (quest[i].level == level) &&
411 (quest[i].dungeon == p_ptr->dungeon_idx))
415 /* Check for random quest */
416 return (random_quest_number(level));
420 * @brief 新しく入ったダンジョンの階層に固定されているランダムクエストを探し出しIDを返す。
421 * @param level 検索対象になる階
422 * @return クエストIDを返す。該当がない場合0を返す。
424 QUEST_IDX random_quest_number(DEPTH level)
428 if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return 0;
430 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
432 if ((quest[i].type == QUEST_TYPE_RANDOM) &&
433 (quest[i].status == QUEST_STATUS_TAKEN) &&
434 (quest[i].level == level) &&
435 (quest[i].dungeon == DUNGEON_ANGBAND))
445 * @brief クエスト階層から離脱する際の処理
448 void leave_quest_check(void)
450 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
451 leaving_quest = p_ptr->inside_quest;
453 /* Leaving an 'only once' quest marks it as failed */
456 quest_type* const q_ptr = &quest[leaving_quest];
458 if (((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
459 (q_ptr->status == QUEST_STATUS_TAKEN))
461 q_ptr->status = QUEST_STATUS_FAILED;
462 q_ptr->complev = p_ptr->lev;
464 q_ptr->comptime = current_world_ptr->play_time;
466 /* Additional settings */
469 case QUEST_TYPE_TOWER:
470 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
471 quest[QUEST_TOWER1].complev = p_ptr->lev;
473 case QUEST_TYPE_FIND_ARTIFACT:
474 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
476 case QUEST_TYPE_RANDOM:
477 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
479 /* Floor of random quest will be blocked */
480 prepare_change_floor_mode(CFM_NO_RETURN);
484 /* Record finishing a quest */
485 if (q_ptr->type == QUEST_TYPE_RANDOM)
487 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
491 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
498 * @brief 「塔」クエストの各階層から離脱する際の処理
501 void leave_tower_check(void)
503 leaving_quest = p_ptr->inside_quest;
504 /* Check for Tower Quest */
506 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
507 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
509 if (quest[leaving_quest].type == QUEST_TYPE_TOWER)
511 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
512 quest[QUEST_TOWER1].complev = p_ptr->lev;
514 quest[QUEST_TOWER1].comptime = current_world_ptr->play_time;
521 * @brief クエスト入り口にプレイヤーが乗った際の処理 / Do building commands
524 void do_cmd_quest(void)
526 if (p_ptr->wild_mode) return;
528 take_turn(p_ptr, 100);
530 if (!cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_QUEST_ENTER))
532 msg_print(_("ここにはクエストの入口はない。", "You see no quest level here."));
537 msg_print(_("ここにはクエストへの入口があります。", "There is an entry of a quest."));
538 if (!get_check(_("クエストに入りますか?", "Do you enter? "))) return;
539 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
540 msg_print(_("『とにかく入ってみようぜぇ。』", ""));
541 else if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN) msg_print("『全滅してやるぞ!』");
543 /* Player enters a new quest */
549 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) current_floor_ptr->dun_level = 1;
550 p_ptr->inside_quest = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special;
552 p_ptr->leaving = TRUE;