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"
21 quest_type *quest; /*!< Quest info */
22 QUEST_IDX max_q_idx; /*!< Maximum number of quests */
23 char quest_text[10][80]; /*!< Quest text */
24 int quest_text_line; /*!< Current line of the quest text */
25 int leaving_quest = 0;
28 * @brief クエスト突入時のメッセージテーブル / Array of places to find an inscription
30 static concptr find_quest[] =
32 _("床にメッセージが刻まれている:", "You find the following inscription in the floor"),
33 _("壁にメッセージが刻まれている:", "You see a message inscribed in the wall"),
34 _("メッセージを見つけた:", "There is a sign saying"),
35 _("何かが階段の上に書いてある:", "Something is written on the staircase"),
36 _("巻物を見つけた。メッセージが書いてある:", "You find a scroll with the following message"),
40 * @brief ランダムクエストの討伐ユニークを決める / Determine the random quest uniques
41 * @param q_ptr クエスト構造体の参照ポインタ
44 void determine_random_questor(quest_type *q_ptr)
49 get_mon_num_prep(mon_hook_quest, NULL);
54 * Random monster 5 - 10 levels out of depth
55 * (depending on level)
57 r_idx = get_mon_num(q_ptr->level + 5 + randint1(q_ptr->level / 10));
58 r_ptr = &r_info[r_idx];
60 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
61 if (r_ptr->flags1 & RF1_QUESTOR) continue;
62 if (r_ptr->rarity > 100) continue;
63 if (r_ptr->flags7 & RF7_FRIENDLY) continue;
64 if (r_ptr->flags7 & RF7_AQUATIC) continue;
65 if (r_ptr->flags8 & RF8_WILD_ONLY) continue;
66 if (no_questor_or_bounty_uniques(r_idx)) continue;
69 * Accept monsters that are 2 - 6 levels
70 * out of depth depending on the quest level
72 if (r_ptr->level > (q_ptr->level + (q_ptr->level / 20))) break;
79 * @brief クエストを達成状態にする /
80 * @param quest_num 達成状態にしたいクエストのID
83 void complete_quest(QUEST_IDX quest_num)
85 quest_type* const q_ptr = &quest[quest_num];
89 case QUEST_TYPE_RANDOM:
90 if (record_rand_quest) exe_write_diary(p_ptr, NIKKI_RAND_QUEST_C, quest_num, NULL);
93 if (record_fix_quest) exe_write_diary(p_ptr, NIKKI_FIX_QUEST_C, quest_num, NULL);
97 q_ptr->status = QUEST_STATUS_COMPLETED;
98 q_ptr->complev = p_ptr->lev;
100 q_ptr->comptime = current_world_ptr->play_time;
102 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
104 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
105 msg_print(_("クエストを達成した!", "You just completed your quest!"));
113 * @brief 特定の敵を倒した際にクエスト達成処理 /
114 * Check for "Quest" completion when a quest monster is killed or charmed.
115 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
118 void check_quest_completion(monster_type *m_ptr)
123 bool create_stairs = FALSE;
133 quest_num = p_ptr->inside_quest;
135 /* Search for an active quest on this dungeon level */
140 for (i = max_q_idx - 1; i > 0; i--)
142 quest_type* const q_ptr = &quest[i];
144 /* Quest is not active */
145 if (q_ptr->status != QUEST_STATUS_TAKEN)
148 /* Quest is not a dungeon quest */
149 if (q_ptr->flags & QUEST_FLAG_PRESET)
152 /* Quest is not on this level */
153 if ((q_ptr->level != current_floor_ptr->dun_level) &&
154 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
157 /* Not a "kill monster" quest */
158 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
159 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
162 /* Interesting quest */
163 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
164 (q_ptr->type == QUEST_TYPE_TOWER) ||
165 (q_ptr->type == QUEST_TYPE_KILL_ALL))
168 /* Interesting quest */
169 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
170 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
171 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
172 (q_ptr->r_idx == m_ptr->r_idx))
179 /* Handle the current quest */
180 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
183 quest_type* const q_ptr = &quest[quest_num];
187 case QUEST_TYPE_KILL_NUMBER:
191 if (q_ptr->cur_num >= q_ptr->num_mon)
193 complete_quest(quest_num);
199 case QUEST_TYPE_KILL_ALL:
201 if (!is_hostile(m_ptr)) break;
203 if (count_all_hostile_monsters(current_floor_ptr) == 1)
205 if (q_ptr->flags & QUEST_FLAG_SILENT)
207 q_ptr->status = QUEST_STATUS_FINISHED;
211 complete_quest(quest_num);
216 case QUEST_TYPE_KILL_LEVEL:
217 case QUEST_TYPE_RANDOM:
219 /* Only count valid monsters */
220 if (q_ptr->r_idx != m_ptr->r_idx)
225 if (q_ptr->cur_num >= q_ptr->max_num)
227 complete_quest(quest_num);
229 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
231 create_stairs = TRUE;
232 p_ptr->inside_quest = 0;
235 /* Finish the two main quests without rewarding */
236 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
238 q_ptr->status = QUEST_STATUS_FINISHED;
241 if (q_ptr->type == QUEST_TYPE_RANDOM)
244 q_ptr->status = QUEST_STATUS_FINISHED;
249 case QUEST_TYPE_KILL_ANY_LEVEL:
252 if (q_ptr->cur_num >= q_ptr->max_num)
254 complete_quest(quest_num);
259 case QUEST_TYPE_TOWER:
261 if (!is_hostile(m_ptr)) break;
263 if (count_all_hostile_monsters(current_floor_ptr) == 1)
265 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
267 if ((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
268 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
269 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
272 complete_quest(QUEST_TOWER1);
280 /* Create a magical staircase */
286 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))
288 /* Pick a location */
289 scatter(&ny, &nx, y, x, 1, 0);
295 /* Explain the staircase */
296 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
298 /* Create stairs down */
299 cave_set_feat(y, x, feat_down_stair);
301 /* Remember to update everything */
302 p_ptr->update |= (PU_FLOW);
312 for (i = 0; i < (current_floor_ptr->dun_level / 15) + 1; i++)
317 /* Make a great object */
318 make_object(o_ptr, AM_GOOD | AM_GREAT);
319 (void)drop_near(o_ptr, -1, y, x);
325 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
326 * Check for "Quest" completion when a quest monster is killed or charmed.
327 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
330 void check_find_art_quest_completion(object_type *o_ptr)
333 /* Check if completed a quest */
334 for (i = 0; i < max_q_idx; i++)
336 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
337 (quest[i].status == QUEST_STATUS_TAKEN) &&
338 (quest[i].k_idx == o_ptr->name1))
347 * @brief クエストの導入メッセージを表示する / Discover quest
348 * @param q_idx 開始されたクエストのID
350 void quest_discovery(QUEST_IDX q_idx)
352 quest_type *q_ptr = &quest[q_idx];
353 monster_race *r_ptr = &r_info[q_ptr->r_idx];
354 MONSTER_NUMBER q_num = q_ptr->max_num;
355 GAME_TEXT name[MAX_NLEN];
359 strcpy(name, (r_name + r_ptr->name));
361 msg_print(find_quest[rand_range(0, 4)]);
366 if ((r_ptr->flags1 & RF1_UNIQUE) && (0 == r_ptr->max_num))
368 msg_print(_("この階は以前は誰かによって守られていたようだ…。", "It seems that this level was protected by someone before..."));
369 /* The unique is already dead */
370 quest[q_idx].status = QUEST_STATUS_FINISHED;
373 q_ptr->comptime = current_world_ptr->play_time;
377 msg_format(_("注意せよ!この階は%sによって守られている!", "Beware, this level is protected by %s!"), name);
385 msg_format(_("注意しろ!この階は%d体の%sによって守られている!", "Be warned, this level is guarded by %d %s!"), q_num, name);
392 * @brief 新しく入ったダンジョンの階層に固定されている一般のクエストを探し出しIDを返す。
393 * / Hack -- Check if a level is a "quest" level
394 * @param level 検索対象になる階
395 * @return クエストIDを返す。該当がない場合0を返す。
397 QUEST_IDX quest_number(DEPTH level)
402 if (p_ptr->inside_quest)
403 return (p_ptr->inside_quest);
405 for (i = 0; i < max_q_idx; i++)
407 if (quest[i].status != QUEST_STATUS_TAKEN) continue;
409 if ((quest[i].type == QUEST_TYPE_KILL_LEVEL) &&
410 !(quest[i].flags & QUEST_FLAG_PRESET) &&
411 (quest[i].level == level) &&
412 (quest[i].dungeon == p_ptr->dungeon_idx))
416 /* Check for random quest */
417 return (random_quest_number(level));
421 * @brief 新しく入ったダンジョンの階層に固定されているランダムクエストを探し出しIDを返す。
422 * @param level 検索対象になる階
423 * @return クエストIDを返す。該当がない場合0を返す。
425 QUEST_IDX random_quest_number(DEPTH level)
429 if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return 0;
431 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
433 if ((quest[i].type == QUEST_TYPE_RANDOM) &&
434 (quest[i].status == QUEST_STATUS_TAKEN) &&
435 (quest[i].level == level) &&
436 (quest[i].dungeon == DUNGEON_ANGBAND))
446 * @brief クエスト階層から離脱する際の処理
449 void leave_quest_check(void)
451 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
452 leaving_quest = p_ptr->inside_quest;
454 /* Leaving an 'only once' quest marks it as failed */
457 quest_type* const q_ptr = &quest[leaving_quest];
459 if (((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
460 (q_ptr->status == QUEST_STATUS_TAKEN))
462 q_ptr->status = QUEST_STATUS_FAILED;
463 q_ptr->complev = p_ptr->lev;
465 q_ptr->comptime = current_world_ptr->play_time;
467 /* Additional settings */
470 case QUEST_TYPE_TOWER:
471 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
472 quest[QUEST_TOWER1].complev = p_ptr->lev;
474 case QUEST_TYPE_FIND_ARTIFACT:
475 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
477 case QUEST_TYPE_RANDOM:
478 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
480 /* Floor of random quest will be blocked */
481 prepare_change_floor_mode(CFM_NO_RETURN);
485 /* Record finishing a quest */
486 if (q_ptr->type == QUEST_TYPE_RANDOM)
488 if (record_rand_quest) exe_write_diary(p_ptr, NIKKI_RAND_QUEST_F, leaving_quest, NULL);
492 if (record_fix_quest) exe_write_diary(p_ptr, NIKKI_FIX_QUEST_F, leaving_quest, NULL);
499 * @brief 「塔」クエストの各階層から離脱する際の処理
502 void leave_tower_check(void)
504 leaving_quest = p_ptr->inside_quest;
505 /* Check for Tower Quest */
507 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
508 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
510 if (quest[leaving_quest].type == QUEST_TYPE_TOWER)
512 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
513 quest[QUEST_TOWER1].complev = p_ptr->lev;
515 quest[QUEST_TOWER1].comptime = current_world_ptr->play_time;
522 * @brief クエスト入り口にプレイヤーが乗った際の処理 / Do building commands
525 void do_cmd_quest(void)
527 if (p_ptr->wild_mode) return;
529 take_turn(p_ptr, 100);
531 if (!cave_have_flag_bold(p_ptr->y, p_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 ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
541 msg_print(_("『とにかく入ってみようぜぇ。』", ""));
542 else if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN) msg_print("『全滅してやるぞ!』");
544 /* Player enters a new quest */
550 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) current_floor_ptr->dun_level = 1;
551 p_ptr->inside_quest = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special;
553 p_ptr->leaving = TRUE;