7 #include "floor-save.h"
8 #include "floor-events.h"
11 #include "monsterrace-hook.h"
13 #include "player-status.h"
14 #include "player-personality.h"
20 #include "view-mainwindow.h"
22 quest_type *quest; /*!< Quest info */
23 QUEST_IDX max_q_idx; /*!< Maximum number of quests */
24 char quest_text[10][80]; /*!< Quest text */
25 int quest_text_line; /*!< Current line of the quest text */
26 int leaving_quest = 0;
29 * @brief クエスト突入時のメッセージテーブル / Array of places to find an inscription
31 static concptr find_quest[] =
33 _("床にメッセージが刻まれている:", "You find the following inscription in the floor"),
34 _("壁にメッセージが刻まれている:", "You see a message inscribed in the wall"),
35 _("メッセージを見つけた:", "There is a sign saying"),
36 _("何かが階段の上に書いてある:", "Something is written on the staircase"),
37 _("巻物を見つけた。メッセージが書いてある:", "You find a scroll with the following message"),
41 * @brief ランダムクエストの討伐ユニークを決める / Determine the random quest uniques
42 * @param q_ptr クエスト構造体の参照ポインタ
45 void determine_random_questor(quest_type *q_ptr)
50 get_mon_num_prep(mon_hook_quest, NULL);
55 * Random monster 5 - 10 levels out of depth
56 * (depending on level)
58 r_idx = get_mon_num(q_ptr->level + 5 + randint1(q_ptr->level / 10));
59 r_ptr = &r_info[r_idx];
61 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
62 if (r_ptr->flags1 & RF1_QUESTOR) continue;
63 if (r_ptr->rarity > 100) continue;
64 if (r_ptr->flags7 & RF7_FRIENDLY) continue;
65 if (r_ptr->flags7 & RF7_AQUATIC) continue;
66 if (r_ptr->flags8 & RF8_WILD_ONLY) continue;
67 if (no_questor_or_bounty_uniques(r_idx)) continue;
70 * Accept monsters that are 2 - 6 levels
71 * out of depth depending on the quest level
73 if (r_ptr->level > (q_ptr->level + (q_ptr->level / 20))) break;
80 * @brief クエストを達成状態にする /
81 * @param quest_num 達成状態にしたいクエストのID
84 void complete_quest(QUEST_IDX quest_num)
86 quest_type* const q_ptr = &quest[quest_num];
90 case QUEST_TYPE_RANDOM:
91 if (record_rand_quest) exe_write_diary(p_ptr, NIKKI_RAND_QUEST_C, quest_num, NULL);
94 if (record_fix_quest) exe_write_diary(p_ptr, NIKKI_FIX_QUEST_C, quest_num, NULL);
98 q_ptr->status = QUEST_STATUS_COMPLETED;
99 q_ptr->complev = p_ptr->lev;
101 q_ptr->comptime = current_world_ptr->play_time;
103 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
105 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
106 msg_print(_("クエストを達成した!", "You just completed your quest!"));
114 * @brief 特定の敵を倒した際にクエスト達成処理 /
115 * Check for "Quest" completion when a quest monster is killed or charmed.
116 * @param player_ptr プレーヤーへの参照ポインタ
117 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
120 void check_quest_completion(player_type *player_ptr, monster_type *m_ptr)
124 bool create_stairs = FALSE;
133 floor_type *floor_ptr = player_ptr->current_floor_ptr;
134 QUEST_IDX quest_num = floor_ptr->inside_quest;
136 /* Search for an active quest on this dungeon level */
141 for (i = max_q_idx - 1; i > 0; i--)
143 quest_type* const q_ptr = &quest[i];
145 /* Quest is not active */
146 if (q_ptr->status != QUEST_STATUS_TAKEN)
149 /* Quest is not a dungeon quest */
150 if (q_ptr->flags & QUEST_FLAG_PRESET)
153 /* Quest is not on this level */
154 if ((q_ptr->level != floor_ptr->dun_level) &&
155 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
158 /* Not a "kill monster" quest */
159 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
160 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
163 /* Interesting quest */
164 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
165 (q_ptr->type == QUEST_TYPE_TOWER) ||
166 (q_ptr->type == QUEST_TYPE_KILL_ALL))
169 /* Interesting quest */
170 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
171 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
172 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
173 (q_ptr->r_idx == m_ptr->r_idx))
180 /* Handle the current quest */
181 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
184 quest_type* const q_ptr = &quest[quest_num];
188 case QUEST_TYPE_KILL_NUMBER:
192 if (q_ptr->cur_num >= q_ptr->num_mon)
194 complete_quest(quest_num);
200 case QUEST_TYPE_KILL_ALL:
202 if (!is_hostile(m_ptr)) break;
204 if (count_all_hostile_monsters(floor_ptr) == 1)
206 if (q_ptr->flags & QUEST_FLAG_SILENT)
208 q_ptr->status = QUEST_STATUS_FINISHED;
212 complete_quest(quest_num);
217 case QUEST_TYPE_KILL_LEVEL:
218 case QUEST_TYPE_RANDOM:
220 /* Only count valid monsters */
221 if (q_ptr->r_idx != m_ptr->r_idx)
226 if (q_ptr->cur_num >= q_ptr->max_num)
228 complete_quest(quest_num);
230 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
232 create_stairs = TRUE;
233 floor_ptr->inside_quest = 0;
236 /* Finish the two main quests without rewarding */
237 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
239 q_ptr->status = QUEST_STATUS_FINISHED;
242 if (q_ptr->type == QUEST_TYPE_RANDOM)
245 q_ptr->status = QUEST_STATUS_FINISHED;
250 case QUEST_TYPE_KILL_ANY_LEVEL:
253 if (q_ptr->cur_num >= q_ptr->max_num)
255 complete_quest(quest_num);
260 case QUEST_TYPE_TOWER:
262 if (!is_hostile(m_ptr)) break;
264 if (count_all_hostile_monsters(floor_ptr) == 1)
266 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
268 if ((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
269 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
270 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
273 complete_quest(QUEST_TOWER1);
281 /* Create a magical staircase */
287 while (cave_perma_bold(floor_ptr, y, x) || floor_ptr->grid_array[y][x].o_idx || (floor_ptr->grid_array[y][x].info & CAVE_OBJECT))
289 /* Pick a location */
290 scatter(floor_ptr, &ny, &nx, y, x, 1, 0);
296 /* Explain the staircase */
297 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
299 /* Create stairs down */
300 cave_set_feat(floor_ptr, y, x, feat_down_stair);
302 /* Remember to update everything */
303 player_ptr->update |= (PU_FLOW);
313 for (i = 0; i < (floor_ptr->dun_level / 15) + 1; i++)
318 /* Make a great object */
319 make_object(player_ptr, o_ptr, AM_GOOD | AM_GREAT);
320 (void)drop_near(player_ptr, o_ptr, -1, y, x);
326 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
327 * Check for "Quest" completion when a quest monster is killed or charmed.
328 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
331 void check_find_art_quest_completion(object_type *o_ptr)
334 /* Check if completed a quest */
335 for (i = 0; i < max_q_idx; i++)
337 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
338 (quest[i].status == QUEST_STATUS_TAKEN) &&
339 (quest[i].k_idx == o_ptr->name1))
348 * @brief クエストの導入メッセージを表示する / Discover quest
349 * @param q_idx 開始されたクエストのID
351 void quest_discovery(QUEST_IDX q_idx)
353 quest_type *q_ptr = &quest[q_idx];
354 monster_race *r_ptr = &r_info[q_ptr->r_idx];
355 MONSTER_NUMBER q_num = q_ptr->max_num;
356 GAME_TEXT name[MAX_NLEN];
360 strcpy(name, (r_name + r_ptr->name));
362 msg_print(find_quest[rand_range(0, 4)]);
367 if ((r_ptr->flags1 & RF1_UNIQUE) && (0 == r_ptr->max_num))
369 msg_print(_("この階は以前は誰かによって守られていたようだ…。", "It seems that this level was protected by someone before..."));
370 /* The unique is already dead */
371 quest[q_idx].status = QUEST_STATUS_FINISHED;
374 q_ptr->comptime = current_world_ptr->play_time;
378 msg_format(_("注意せよ!この階は%sによって守られている!", "Beware, this level is protected by %s!"), name);
386 msg_format(_("注意しろ!この階は%d体の%sによって守られている!", "Be warned, this level is guarded by %d %s!"), q_num, name);
393 * @brief 新しく入ったダンジョンの階層に固定されている一般のクエストを探し出しIDを返す。
394 * / Hack -- Check if a level is a "quest" level
395 * @param level 検索対象になる階
396 * @return クエストIDを返す。該当がない場合0を返す。
398 QUEST_IDX quest_number(DEPTH level)
403 if (p_ptr->current_floor_ptr->inside_quest)
404 return (p_ptr->current_floor_ptr->inside_quest);
406 for (i = 0; i < max_q_idx; i++)
408 if (quest[i].status != QUEST_STATUS_TAKEN) continue;
410 if ((quest[i].type == QUEST_TYPE_KILL_LEVEL) &&
411 !(quest[i].flags & QUEST_FLAG_PRESET) &&
412 (quest[i].level == level) &&
413 (quest[i].dungeon == p_ptr->dungeon_idx))
417 /* Check for random quest */
418 return (random_quest_number(level));
422 * @brief 新しく入ったダンジョンの階層に固定されているランダムクエストを探し出しIDを返す。
423 * @param level 検索対象になる階
424 * @return クエストIDを返す。該当がない場合0を返す。
426 QUEST_IDX random_quest_number(DEPTH level)
430 if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return 0;
432 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
434 if ((quest[i].type == QUEST_TYPE_RANDOM) &&
435 (quest[i].status == QUEST_STATUS_TAKEN) &&
436 (quest[i].level == level) &&
437 (quest[i].dungeon == DUNGEON_ANGBAND))
447 * @brief クエスト階層から離脱する際の処理
448 * @param player_ptr プレーヤーへの参照ポインタ
451 void leave_quest_check(player_type *player_ptr)
453 leaving_quest = player_ptr->current_floor_ptr->inside_quest;
454 if (!leaving_quest) return;
456 quest_type* const q_ptr = &quest[leaving_quest];
457 bool is_one_time_quest = ((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
458 (q_ptr->status == QUEST_STATUS_TAKEN);
459 if (is_one_time_quest) return;
461 q_ptr->status = QUEST_STATUS_FAILED;
462 q_ptr->complev = player_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 = player_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(player_ptr, CFM_NO_RETURN);
484 /* Record finishing a quest */
485 if (q_ptr->type == QUEST_TYPE_RANDOM)
487 if (record_rand_quest) exe_write_diary(player_ptr, NIKKI_RAND_QUEST_F, leaving_quest, NULL);
491 if (record_fix_quest) exe_write_diary(player_ptr, NIKKI_FIX_QUEST_F, leaving_quest, NULL);
496 * @brief 「塔」クエストの各階層から離脱する際の処理
499 void leave_tower_check(void)
501 leaving_quest = p_ptr->current_floor_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
520 * @param player_ptr プレーヤーへの参照ポインタ
523 void do_cmd_quest(player_type *player_ptr)
525 if (player_ptr->wild_mode) return;
527 take_turn(player_ptr, 100);
529 if (!cave_have_flag_bold(player_ptr->current_floor_ptr, player_ptr->y, player_ptr->x, FF_QUEST_ENTER))
531 msg_print(_("ここにはクエストの入口はない。", "You see no quest level here."));
536 msg_print(_("ここにはクエストへの入口があります。", "There is an entry of a quest."));
537 if (!get_check(_("クエストに入りますか?", "Do you enter? "))) return;
538 if ((player_ptr->pseikaku == SEIKAKU_COMBAT) || (player_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
539 msg_print(_("『とにかく入ってみようぜぇ。』", ""));
540 else if (player_ptr->pseikaku == SEIKAKU_CHARGEMAN) msg_print("『全滅してやるぞ!』");
542 /* Player enters a new quest */
543 player_ptr->oldpy = 0;
544 player_ptr->oldpx = 0;
546 leave_quest_check(player_ptr);
548 if (quest[player_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM) player_ptr->current_floor_ptr->dun_level = 1;
549 player_ptr->current_floor_ptr->inside_quest = player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].special;
551 player_ptr->leaving = TRUE;