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 player_ptr プレーヤーへの参照ポインタ
82 * @param quest_num 達成状態にしたいクエストのID
85 void complete_quest(player_type *player_ptr, QUEST_IDX quest_num)
87 quest_type* const q_ptr = &quest[quest_num];
91 case QUEST_TYPE_RANDOM:
92 if (record_rand_quest) exe_write_diary(player_ptr, NIKKI_RAND_QUEST_C, quest_num, NULL);
95 if (record_fix_quest) exe_write_diary(player_ptr, NIKKI_FIX_QUEST_C, quest_num, NULL);
99 q_ptr->status = QUEST_STATUS_COMPLETED;
100 q_ptr->complev = player_ptr->lev;
102 q_ptr->comptime = current_world_ptr->play_time;
104 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
106 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
107 msg_print(_("クエストを達成した!", "You just completed your quest!"));
115 * @brief 特定の敵を倒した際にクエスト達成処理 /
116 * Check for "Quest" completion when a quest monster is killed or charmed.
117 * @param player_ptr プレーヤーへの参照ポインタ
118 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
121 void check_quest_completion(player_type *player_ptr, monster_type *m_ptr)
125 bool create_stairs = FALSE;
134 floor_type *floor_ptr = player_ptr->current_floor_ptr;
135 QUEST_IDX quest_num = floor_ptr->inside_quest;
137 /* Search for an active quest on this dungeon level */
142 for (i = max_q_idx - 1; i > 0; i--)
144 quest_type* const q_ptr = &quest[i];
146 /* Quest is not active */
147 if (q_ptr->status != QUEST_STATUS_TAKEN)
150 /* Quest is not a dungeon quest */
151 if (q_ptr->flags & QUEST_FLAG_PRESET)
154 /* Quest is not on this level */
155 if ((q_ptr->level != floor_ptr->dun_level) &&
156 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
159 /* Not a "kill monster" quest */
160 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
161 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
164 /* Interesting quest */
165 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
166 (q_ptr->type == QUEST_TYPE_TOWER) ||
167 (q_ptr->type == QUEST_TYPE_KILL_ALL))
170 /* Interesting quest */
171 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
172 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
173 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
174 (q_ptr->r_idx == m_ptr->r_idx))
181 /* Handle the current quest */
182 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
185 quest_type* const q_ptr = &quest[quest_num];
189 case QUEST_TYPE_KILL_NUMBER:
193 if (q_ptr->cur_num >= q_ptr->num_mon)
195 complete_quest(player_ptr, quest_num);
201 case QUEST_TYPE_KILL_ALL:
203 if (!is_hostile(m_ptr)) break;
205 if (count_all_hostile_monsters(floor_ptr) == 1)
207 if (q_ptr->flags & QUEST_FLAG_SILENT)
209 q_ptr->status = QUEST_STATUS_FINISHED;
213 complete_quest(player_ptr, quest_num);
218 case QUEST_TYPE_KILL_LEVEL:
219 case QUEST_TYPE_RANDOM:
221 /* Only count valid monsters */
222 if (q_ptr->r_idx != m_ptr->r_idx)
227 if (q_ptr->cur_num >= q_ptr->max_num)
229 complete_quest(player_ptr, quest_num);
231 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
233 create_stairs = TRUE;
234 floor_ptr->inside_quest = 0;
237 /* Finish the two main quests without rewarding */
238 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
240 q_ptr->status = QUEST_STATUS_FINISHED;
243 if (q_ptr->type == QUEST_TYPE_RANDOM)
246 q_ptr->status = QUEST_STATUS_FINISHED;
251 case QUEST_TYPE_KILL_ANY_LEVEL:
254 if (q_ptr->cur_num >= q_ptr->max_num)
256 complete_quest(player_ptr, quest_num);
261 case QUEST_TYPE_TOWER:
263 if (!is_hostile(m_ptr)) break;
265 if (count_all_hostile_monsters(floor_ptr) == 1)
267 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
269 if ((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
270 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
271 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
274 complete_quest(player_ptr, QUEST_TOWER1);
282 /* Create a magical staircase */
288 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))
290 /* Pick a location */
291 scatter(floor_ptr, &ny, &nx, y, x, 1, 0);
297 /* Explain the staircase */
298 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
300 /* Create stairs down */
301 cave_set_feat(floor_ptr, y, x, feat_down_stair);
303 /* Remember to update everything */
304 player_ptr->update |= (PU_FLOW);
314 for (i = 0; i < (floor_ptr->dun_level / 15) + 1; i++)
319 /* Make a great object */
320 make_object(player_ptr, o_ptr, AM_GOOD | AM_GREAT);
321 (void)drop_near(player_ptr, o_ptr, -1, y, x);
327 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
328 * Check for "Quest" completion when a quest monster is killed or charmed.
329 * @param player_ptr プレーヤーへの参照ポインタ
330 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
333 void check_find_art_quest_completion(player_type *player_ptr, object_type *o_ptr)
336 /* Check if completed a quest */
337 for (i = 0; i < max_q_idx; i++)
339 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
340 (quest[i].status == QUEST_STATUS_TAKEN) &&
341 (quest[i].k_idx == o_ptr->name1))
343 complete_quest(player_ptr, i);
350 * @brief クエストの導入メッセージを表示する / Discover quest
351 * @param q_idx 開始されたクエストのID
353 void quest_discovery(QUEST_IDX q_idx)
355 quest_type *q_ptr = &quest[q_idx];
356 monster_race *r_ptr = &r_info[q_ptr->r_idx];
357 MONSTER_NUMBER q_num = q_ptr->max_num;
358 GAME_TEXT name[MAX_NLEN];
362 strcpy(name, (r_name + r_ptr->name));
364 msg_print(find_quest[rand_range(0, 4)]);
369 if ((r_ptr->flags1 & RF1_UNIQUE) && (0 == r_ptr->max_num))
371 msg_print(_("この階は以前は誰かによって守られていたようだ…。", "It seems that this level was protected by someone before..."));
372 /* The unique is already dead */
373 quest[q_idx].status = QUEST_STATUS_FINISHED;
376 q_ptr->comptime = current_world_ptr->play_time;
380 msg_format(_("注意せよ!この階は%sによって守られている!", "Beware, this level is protected by %s!"), name);
388 msg_format(_("注意しろ!この階は%d体の%sによって守られている!", "Be warned, this level is guarded by %d %s!"), q_num, name);
395 * @brief 新しく入ったダンジョンの階層に固定されている一般のクエストを探し出しIDを返す。
396 * / Hack -- Check if a level is a "quest" level
397 * @param level 検索対象になる階
398 * @return クエストIDを返す。該当がない場合0を返す。
400 QUEST_IDX quest_number(DEPTH level)
405 if (p_ptr->current_floor_ptr->inside_quest)
406 return (p_ptr->current_floor_ptr->inside_quest);
408 for (i = 0; i < max_q_idx; i++)
410 if (quest[i].status != QUEST_STATUS_TAKEN) continue;
412 if ((quest[i].type == QUEST_TYPE_KILL_LEVEL) &&
413 !(quest[i].flags & QUEST_FLAG_PRESET) &&
414 (quest[i].level == level) &&
415 (quest[i].dungeon == p_ptr->dungeon_idx))
419 /* Check for random quest */
420 return (random_quest_number(level));
424 * @brief 新しく入ったダンジョンの階層に固定されているランダムクエストを探し出しIDを返す。
425 * @param level 検索対象になる階
426 * @return クエストIDを返す。該当がない場合0を返す。
428 QUEST_IDX random_quest_number(DEPTH level)
432 if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return 0;
434 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
436 if ((quest[i].type == QUEST_TYPE_RANDOM) &&
437 (quest[i].status == QUEST_STATUS_TAKEN) &&
438 (quest[i].level == level) &&
439 (quest[i].dungeon == DUNGEON_ANGBAND))
449 * @brief クエスト階層から離脱する際の処理
450 * @param player_ptr プレーヤーへの参照ポインタ
453 void leave_quest_check(player_type *player_ptr)
455 leaving_quest = player_ptr->current_floor_ptr->inside_quest;
456 if (!leaving_quest) return;
458 quest_type* const q_ptr = &quest[leaving_quest];
459 bool is_one_time_quest = ((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
460 (q_ptr->status == QUEST_STATUS_TAKEN);
461 if (is_one_time_quest) return;
463 q_ptr->status = QUEST_STATUS_FAILED;
464 q_ptr->complev = player_ptr->lev;
466 q_ptr->comptime = current_world_ptr->play_time;
468 /* Additional settings */
471 case QUEST_TYPE_TOWER:
472 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
473 quest[QUEST_TOWER1].complev = player_ptr->lev;
475 case QUEST_TYPE_FIND_ARTIFACT:
476 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
478 case QUEST_TYPE_RANDOM:
479 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
481 /* Floor of random quest will be blocked */
482 prepare_change_floor_mode(player_ptr, CFM_NO_RETURN);
486 /* Record finishing a quest */
487 if (q_ptr->type == QUEST_TYPE_RANDOM)
489 if (record_rand_quest) exe_write_diary(player_ptr, NIKKI_RAND_QUEST_F, leaving_quest, NULL);
493 if (record_fix_quest) exe_write_diary(player_ptr, NIKKI_FIX_QUEST_F, leaving_quest, NULL);
498 * @brief 「塔」クエストの各階層から離脱する際の処理
501 void leave_tower_check(void)
503 leaving_quest = p_ptr->current_floor_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
522 * @param player_ptr プレーヤーへの参照ポインタ
525 void do_cmd_quest(player_type *player_ptr)
527 if (player_ptr->wild_mode) return;
529 take_turn(player_ptr, 100);
531 if (!cave_have_flag_bold(player_ptr->current_floor_ptr, player_ptr->y, player_ptr->x, FF_QUEST_ENTER))
533 msg_print(_("ここにはクエストの入口はない。", "You see no quest level here."));
538 msg_print(_("ここにはクエストへの入口があります。", "There is an entry of a quest."));
539 if (!get_check(_("クエストに入りますか?", "Do you enter? "))) return;
540 if ((player_ptr->pseikaku == SEIKAKU_COMBAT) || (player_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
541 msg_print(_("『とにかく入ってみようぜぇ。』", ""));
542 else if (player_ptr->pseikaku == SEIKAKU_CHARGEMAN) msg_print("『全滅してやるぞ!』");
544 /* Player enters a new quest */
545 player_ptr->oldpy = 0;
546 player_ptr->oldpx = 0;
548 leave_quest_check(player_ptr);
550 if (quest[player_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM) player_ptr->current_floor_ptr->dun_level = 1;
551 player_ptr->current_floor_ptr->inside_quest = player_ptr->current_floor_ptr->grid_array[player_ptr->y][player_ptr->x].special;
553 player_ptr->leaving = TRUE;