6 #include "floor-save.h"
7 #include "floor-events.h"
10 #include "monsterrace-hook.h"
12 #include "player-status.h"
18 quest_type *quest; /*!< Quest info */
19 QUEST_IDX max_q_idx; /*!< Maximum number of quests */
20 char quest_text[10][80]; /*!< Quest text */
21 int quest_text_line; /*!< Current line of the quest text */
22 int leaving_quest = 0;
25 * @brief クエスト突入時のメッセージテーブル / Array of places to find an inscription
27 static concptr find_quest[] =
29 _("床にメッセージが刻まれている:", "You find the following inscription in the floor"),
30 _("壁にメッセージが刻まれている:", "You see a message inscribed in the wall"),
31 _("メッセージを見つけた:", "There is a sign saying"),
32 _("何かが階段の上に書いてある:", "Something is written on the staircase"),
33 _("巻物を見つけた。メッセージが書いてある:", "You find a scroll with the following message"),
37 * @brief ランダムクエストの討伐ユニークを決める / Determine the random quest uniques
38 * @param q_ptr クエスト構造体の参照ポインタ
41 void determine_random_questor(quest_type *q_ptr)
46 get_mon_num_prep(mon_hook_quest, NULL);
51 * Random monster 5 - 10 levels out of depth
52 * (depending on level)
54 r_idx = get_mon_num(q_ptr->level + 5 + randint1(q_ptr->level / 10));
55 r_ptr = &r_info[r_idx];
57 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
58 if (r_ptr->flags1 & RF1_QUESTOR) continue;
59 if (r_ptr->rarity > 100) continue;
60 if (r_ptr->flags7 & RF7_FRIENDLY) continue;
61 if (r_ptr->flags7 & RF7_AQUATIC) continue;
62 if (r_ptr->flags8 & RF8_WILD_ONLY) continue;
63 if (no_questor_or_bounty_uniques(r_idx)) continue;
66 * Accept monsters that are 2 - 6 levels
67 * out of depth depending on the quest level
69 if (r_ptr->level > (q_ptr->level + (q_ptr->level / 20))) break;
76 * @brief クエストを達成状態にする /
77 * @param quest_num 達成状態にしたいクエストのID
80 void complete_quest(QUEST_IDX quest_num)
82 quest_type* const q_ptr = &quest[quest_num];
86 case QUEST_TYPE_RANDOM:
87 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
90 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
94 q_ptr->status = QUEST_STATUS_COMPLETED;
95 q_ptr->complev = p_ptr->lev;
97 q_ptr->comptime = current_world_ptr->play_time;
99 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
101 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
102 msg_print(_("クエストを達成した!", "You just completed your quest!"));
110 * @brief 特定の敵を倒した際にクエスト達成処理 /
111 * Check for "Quest" completion when a quest monster is killed or charmed.
112 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
115 void check_quest_completion(monster_type *m_ptr)
120 bool create_stairs = FALSE;
130 quest_num = p_ptr->inside_quest;
132 /* Search for an active quest on this dungeon level */
137 for (i = max_q_idx - 1; i > 0; i--)
139 quest_type* const q_ptr = &quest[i];
141 /* Quest is not active */
142 if (q_ptr->status != QUEST_STATUS_TAKEN)
145 /* Quest is not a dungeon quest */
146 if (q_ptr->flags & QUEST_FLAG_PRESET)
149 /* Quest is not on this level */
150 if ((q_ptr->level != current_floor_ptr->dun_level) &&
151 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
154 /* Not a "kill monster" quest */
155 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
156 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
159 /* Interesting quest */
160 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
161 (q_ptr->type == QUEST_TYPE_TOWER) ||
162 (q_ptr->type == QUEST_TYPE_KILL_ALL))
165 /* Interesting quest */
166 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
167 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
168 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
169 (q_ptr->r_idx == m_ptr->r_idx))
176 /* Handle the current quest */
177 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
180 quest_type* const q_ptr = &quest[quest_num];
184 case QUEST_TYPE_KILL_NUMBER:
188 if (q_ptr->cur_num >= q_ptr->num_mon)
190 complete_quest(quest_num);
196 case QUEST_TYPE_KILL_ALL:
198 if (!is_hostile(m_ptr)) break;
200 if (count_all_hostile_monsters() == 1)
202 if (q_ptr->flags & QUEST_FLAG_SILENT)
204 q_ptr->status = QUEST_STATUS_FINISHED;
208 complete_quest(quest_num);
213 case QUEST_TYPE_KILL_LEVEL:
214 case QUEST_TYPE_RANDOM:
216 /* Only count valid monsters */
217 if (q_ptr->r_idx != m_ptr->r_idx)
222 if (q_ptr->cur_num >= q_ptr->max_num)
224 complete_quest(quest_num);
226 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
228 create_stairs = TRUE;
229 p_ptr->inside_quest = 0;
232 /* Finish the two main quests without rewarding */
233 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
235 q_ptr->status = QUEST_STATUS_FINISHED;
238 if (q_ptr->type == QUEST_TYPE_RANDOM)
241 q_ptr->status = QUEST_STATUS_FINISHED;
246 case QUEST_TYPE_KILL_ANY_LEVEL:
249 if (q_ptr->cur_num >= q_ptr->max_num)
251 complete_quest(quest_num);
256 case QUEST_TYPE_TOWER:
258 if (!is_hostile(m_ptr)) break;
260 if (count_all_hostile_monsters() == 1)
262 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
264 if ((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
265 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
266 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
269 complete_quest(QUEST_TOWER1);
277 /* Create a magical staircase */
283 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))
285 /* Pick a location */
286 scatter(&ny, &nx, y, x, 1, 0);
292 /* Explain the staircase */
293 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
295 /* Create stairs down */
296 cave_set_feat(y, x, feat_down_stair);
298 /* Remember to update everything */
299 p_ptr->update |= (PU_FLOW);
309 for (i = 0; i < (current_floor_ptr->dun_level / 15) + 1; i++)
314 /* Make a great object */
315 make_object(o_ptr, AM_GOOD | AM_GREAT);
316 (void)drop_near(o_ptr, -1, y, x);
322 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
323 * Check for "Quest" completion when a quest monster is killed or charmed.
324 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
327 void check_find_art_quest_completion(object_type *o_ptr)
330 /* Check if completed a quest */
331 for (i = 0; i < max_q_idx; i++)
333 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
334 (quest[i].status == QUEST_STATUS_TAKEN) &&
335 (quest[i].k_idx == o_ptr->name1))
344 * @brief クエストの導入メッセージを表示する / Discover quest
345 * @param q_idx 開始されたクエストのID
347 void quest_discovery(QUEST_IDX q_idx)
349 quest_type *q_ptr = &quest[q_idx];
350 monster_race *r_ptr = &r_info[q_ptr->r_idx];
351 MONSTER_NUMBER q_num = q_ptr->max_num;
352 GAME_TEXT name[MAX_NLEN];
356 strcpy(name, (r_name + r_ptr->name));
358 msg_print(find_quest[rand_range(0, 4)]);
363 if ((r_ptr->flags1 & RF1_UNIQUE) && (0 == r_ptr->max_num))
365 msg_print(_("この階は以前は誰かによって守られていたようだ…。", "It seems that this level was protected by someone before..."));
366 /* The unique is already dead */
367 quest[q_idx].status = QUEST_STATUS_FINISHED;
370 q_ptr->comptime = current_world_ptr->play_time;
374 msg_format(_("注意せよ!この階は%sによって守られている!", "Beware, this level is protected by %s!"), name);
382 msg_format(_("注意しろ!この階は%d体の%sによって守られている!", "Be warned, this level is guarded by %d %s!"), q_num, name);
389 * @brief 新しく入ったダンジョンの階層に固定されている一般のクエストを探し出しIDを返す。
390 * / Hack -- Check if a level is a "quest" level
391 * @param level 検索対象になる階
392 * @return クエストIDを返す。該当がない場合0を返す。
394 QUEST_IDX quest_number(DEPTH level)
399 if (p_ptr->inside_quest)
400 return (p_ptr->inside_quest);
402 for (i = 0; i < max_q_idx; i++)
404 if (quest[i].status != QUEST_STATUS_TAKEN) continue;
406 if ((quest[i].type == QUEST_TYPE_KILL_LEVEL) &&
407 !(quest[i].flags & QUEST_FLAG_PRESET) &&
408 (quest[i].level == level) &&
409 (quest[i].dungeon == p_ptr->dungeon_idx))
413 /* Check for random quest */
414 return (random_quest_number(level));
418 * @brief 新しく入ったダンジョンの階層に固定されているランダムクエストを探し出しIDを返す。
419 * @param level 検索対象になる階
420 * @return クエストIDを返す。該当がない場合0を返す。
422 QUEST_IDX random_quest_number(DEPTH level)
426 if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return 0;
428 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
430 if ((quest[i].type == QUEST_TYPE_RANDOM) &&
431 (quest[i].status == QUEST_STATUS_TAKEN) &&
432 (quest[i].level == level) &&
433 (quest[i].dungeon == DUNGEON_ANGBAND))
443 * @brief クエスト階層から離脱する際の処理
446 void leave_quest_check(void)
448 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
449 leaving_quest = p_ptr->inside_quest;
451 /* Leaving an 'only once' quest marks it as failed */
454 quest_type* const q_ptr = &quest[leaving_quest];
456 if (((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
457 (q_ptr->status == QUEST_STATUS_TAKEN))
459 q_ptr->status = QUEST_STATUS_FAILED;
460 q_ptr->complev = p_ptr->lev;
462 q_ptr->comptime = current_world_ptr->play_time;
464 /* Additional settings */
467 case QUEST_TYPE_TOWER:
468 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
469 quest[QUEST_TOWER1].complev = p_ptr->lev;
471 case QUEST_TYPE_FIND_ARTIFACT:
472 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
474 case QUEST_TYPE_RANDOM:
475 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
477 /* Floor of random quest will be blocked */
478 prepare_change_floor_mode(CFM_NO_RETURN);
482 /* Record finishing a quest */
483 if (q_ptr->type == QUEST_TYPE_RANDOM)
485 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
489 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
496 * @brief 「塔」クエストの各階層から離脱する際の処理
499 void leave_tower_check(void)
501 leaving_quest = p_ptr->inside_quest;
502 /* Check for Tower Quest */
504 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
505 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
507 if (quest[leaving_quest].type == QUEST_TYPE_TOWER)
509 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
510 quest[QUEST_TOWER1].complev = p_ptr->lev;
512 quest[QUEST_TOWER1].comptime = current_world_ptr->play_time;
519 * @brief クエスト入り口にプレイヤーが乗った際の処理 / Do building commands
522 void do_cmd_quest(void)
524 if (p_ptr->wild_mode) return;
526 take_turn(p_ptr, 100);
528 if (!cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_QUEST_ENTER))
530 msg_print(_("ここにはクエストの入口はない。", "You see no quest level here."));
535 msg_print(_("ここにはクエストへの入口があります。", "There is an entry of a quest."));
536 if (!get_check(_("クエストに入りますか?", "Do you enter? "))) return;
537 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
538 msg_print(_("『とにかく入ってみようぜぇ。』", ""));
539 else if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN) msg_print("『全滅してやるぞ!』");
541 /* Player enters a new quest */
547 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) current_floor_ptr->dun_level = 1;
548 p_ptr->inside_quest = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special;
550 p_ptr->leaving = TRUE;