3 #include "floor-events.h"
5 #include "monsterrace-hook.h"
9 * @brief クエスト突入時のメッセージテーブル / Array of places to find an inscription
11 static concptr find_quest[] =
13 _("床にメッセージが刻まれている:", "You find the following inscription in the floor"),
14 _("壁にメッセージが刻まれている:", "You see a message inscribed in the wall"),
15 _("メッセージを見つけた:", "There is a sign saying"),
16 _("何かが階段の上に書いてある:", "Something is written on the staircase"),
17 _("巻物を見つけた。メッセージが書いてある:", "You find a scroll with the following message"),
21 * @brief ランダムクエストの討伐ユニークを決める / Determine the random quest uniques
22 * @param q_ptr クエスト構造体の参照ポインタ
25 void determine_random_questor(quest_type *q_ptr)
30 get_mon_num_prep(mon_hook_quest, NULL);
35 * Random monster 5 - 10 levels out of depth
36 * (depending on level)
38 r_idx = get_mon_num(q_ptr->level + 5 + randint1(q_ptr->level / 10));
39 r_ptr = &r_info[r_idx];
41 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
42 if (r_ptr->flags1 & RF1_QUESTOR) continue;
43 if (r_ptr->rarity > 100) continue;
44 if (r_ptr->flags7 & RF7_FRIENDLY) continue;
45 if (r_ptr->flags7 & RF7_AQUATIC) continue;
46 if (r_ptr->flags8 & RF8_WILD_ONLY) continue;
47 if (no_questor_or_bounty_uniques(r_idx)) continue;
50 * Accept monsters that are 2 - 6 levels
51 * out of depth depending on the quest level
53 if (r_ptr->level > (q_ptr->level + (q_ptr->level / 20))) break;
60 * @brief クエストを達成状態にする /
61 * @param quest_num 達成状態にしたいクエストのID
64 void complete_quest(QUEST_IDX quest_num)
66 quest_type* const q_ptr = &quest[quest_num];
70 case QUEST_TYPE_RANDOM:
71 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
74 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
78 q_ptr->status = QUEST_STATUS_COMPLETED;
79 q_ptr->complev = p_ptr->lev;
81 q_ptr->comptime = current_world_ptr->play_time;
83 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
85 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
86 msg_print(_("クエストを達成した!", "You just completed your quest!"));
94 * @brief 特定の敵を倒した際にクエスト達成処理 /
95 * Check for "Quest" completion when a quest monster is killed or charmed.
96 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
99 void check_quest_completion(monster_type *m_ptr)
104 bool create_stairs = FALSE;
114 quest_num = p_ptr->inside_quest;
116 /* Search for an active quest on this dungeon level */
121 for (i = max_q_idx - 1; i > 0; i--)
123 quest_type* const q_ptr = &quest[i];
125 /* Quest is not active */
126 if (q_ptr->status != QUEST_STATUS_TAKEN)
129 /* Quest is not a dungeon quest */
130 if (q_ptr->flags & QUEST_FLAG_PRESET)
133 /* Quest is not on this level */
134 if ((q_ptr->level != current_floor_ptr->dun_level) &&
135 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
138 /* Not a "kill monster" quest */
139 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
140 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
143 /* Interesting quest */
144 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
145 (q_ptr->type == QUEST_TYPE_TOWER) ||
146 (q_ptr->type == QUEST_TYPE_KILL_ALL))
149 /* Interesting quest */
150 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
151 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
152 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
153 (q_ptr->r_idx == m_ptr->r_idx))
160 /* Handle the current quest */
161 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
164 quest_type* const q_ptr = &quest[quest_num];
168 case QUEST_TYPE_KILL_NUMBER:
172 if (q_ptr->cur_num >= q_ptr->num_mon)
174 complete_quest(quest_num);
180 case QUEST_TYPE_KILL_ALL:
182 if (!is_hostile(m_ptr)) break;
184 if (count_all_hostile_monsters() == 1)
186 if (q_ptr->flags & QUEST_FLAG_SILENT)
188 q_ptr->status = QUEST_STATUS_FINISHED;
192 complete_quest(quest_num);
197 case QUEST_TYPE_KILL_LEVEL:
198 case QUEST_TYPE_RANDOM:
200 /* Only count valid monsters */
201 if (q_ptr->r_idx != m_ptr->r_idx)
206 if (q_ptr->cur_num >= q_ptr->max_num)
208 complete_quest(quest_num);
210 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
212 create_stairs = TRUE;
213 p_ptr->inside_quest = 0;
216 /* Finish the two main quests without rewarding */
217 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
219 q_ptr->status = QUEST_STATUS_FINISHED;
222 if (q_ptr->type == QUEST_TYPE_RANDOM)
225 q_ptr->status = QUEST_STATUS_FINISHED;
230 case QUEST_TYPE_KILL_ANY_LEVEL:
233 if (q_ptr->cur_num >= q_ptr->max_num)
235 complete_quest(quest_num);
240 case QUEST_TYPE_TOWER:
242 if (!is_hostile(m_ptr)) break;
244 if (count_all_hostile_monsters() == 1)
246 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
248 if ((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
249 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
250 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
253 complete_quest(QUEST_TOWER1);
261 /* Create a magical staircase */
267 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))
269 /* Pick a location */
270 scatter(&ny, &nx, y, x, 1, 0);
276 /* Explain the staircase */
277 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
279 /* Create stairs down */
280 cave_set_feat(y, x, feat_down_stair);
282 /* Remember to update everything */
283 p_ptr->update |= (PU_FLOW);
293 for (i = 0; i < (current_floor_ptr->dun_level / 15) + 1; i++)
298 /* Make a great object */
299 make_object(o_ptr, AM_GOOD | AM_GREAT);
300 (void)drop_near(o_ptr, -1, y, x);
306 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
307 * Check for "Quest" completion when a quest monster is killed or charmed.
308 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
311 void check_find_art_quest_completion(object_type *o_ptr)
314 /* Check if completed a quest */
315 for (i = 0; i < max_q_idx; i++)
317 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
318 (quest[i].status == QUEST_STATUS_TAKEN) &&
319 (quest[i].k_idx == o_ptr->name1))
328 * @brief クエストの導入メッセージを表示する / Discover quest
329 * @param q_idx 開始されたクエストのID
331 void quest_discovery(QUEST_IDX q_idx)
333 quest_type *q_ptr = &quest[q_idx];
334 monster_race *r_ptr = &r_info[q_ptr->r_idx];
335 MONSTER_NUMBER q_num = q_ptr->max_num;
336 GAME_TEXT name[MAX_NLEN];
341 strcpy(name, (r_name + r_ptr->name));
343 msg_print(find_quest[rand_range(0, 4)]);
350 /* Hack -- "unique" monsters must be "unique" */
351 if ((r_ptr->flags1 & RF1_UNIQUE) && (0 == r_ptr->max_num))
353 msg_print(_("この階は以前は誰かによって守られていたようだ…。", "It seems that this level was protected by someone before..."));
354 /* The unique is already dead */
355 quest[q_idx].status = QUEST_STATUS_FINISHED;
358 q_ptr->comptime = current_world_ptr->play_time;
362 msg_format(_("注意せよ!この階は%sによって守られている!", "Beware, this level is protected by %s!"), name);
367 /* Normal monsters */
371 msg_format(_("注意しろ!この階は%d体の%sによって守られている!", "Be warned, this level is guarded by %d %s!"), q_num, name);
378 * @brief 新しく入ったダンジョンの階層に固定されている一般のクエストを探し出しIDを返す。
379 * / Hack -- Check if a level is a "quest" level
380 * @param level 検索対象になる階
381 * @return クエストIDを返す。該当がない場合0を返す。
383 QUEST_IDX quest_number(DEPTH level)
388 if (p_ptr->inside_quest)
389 return (p_ptr->inside_quest);
391 for (i = 0; i < max_q_idx; i++)
393 if (quest[i].status != QUEST_STATUS_TAKEN) continue;
395 if ((quest[i].type == QUEST_TYPE_KILL_LEVEL) &&
396 !(quest[i].flags & QUEST_FLAG_PRESET) &&
397 (quest[i].level == level) &&
398 (quest[i].dungeon == p_ptr->dungeon_idx))
402 /* Check for random quest */
403 return (random_quest_number(level));
407 * @brief 新しく入ったダンジョンの階層に固定されているランダムクエストを探し出しIDを返す。
408 * @param level 検索対象になる階
409 * @return クエストIDを返す。該当がない場合0を返す。
411 QUEST_IDX random_quest_number(DEPTH level)
415 if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return 0;
417 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
419 if ((quest[i].type == QUEST_TYPE_RANDOM) &&
420 (quest[i].status == QUEST_STATUS_TAKEN) &&
421 (quest[i].level == level) &&
422 (quest[i].dungeon == DUNGEON_ANGBAND))
432 * @brief クエスト階層から離脱する際の処理
435 void leave_quest_check(void)
437 /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
438 leaving_quest = p_ptr->inside_quest;
440 /* Leaving an 'only once' quest marks it as failed */
443 quest_type* const q_ptr = &quest[leaving_quest];
445 if (((q_ptr->flags & QUEST_FLAG_ONCE) || (q_ptr->type == QUEST_TYPE_RANDOM)) &&
446 (q_ptr->status == QUEST_STATUS_TAKEN))
448 q_ptr->status = QUEST_STATUS_FAILED;
449 q_ptr->complev = p_ptr->lev;
451 q_ptr->comptime = current_world_ptr->play_time;
453 /* Additional settings */
456 case QUEST_TYPE_TOWER:
457 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
458 quest[QUEST_TOWER1].complev = p_ptr->lev;
460 case QUEST_TYPE_FIND_ARTIFACT:
461 a_info[q_ptr->k_idx].gen_flags &= ~(TRG_QUESTITEM);
463 case QUEST_TYPE_RANDOM:
464 r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
466 /* Floor of random quest will be blocked */
467 prepare_change_floor_mode(CFM_NO_RETURN);
471 /* Record finishing a quest */
472 if (q_ptr->type == QUEST_TYPE_RANDOM)
474 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
478 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
485 * @brief 「塔」クエストの各階層から離脱する際の処理
488 void leave_tower_check(void)
490 leaving_quest = p_ptr->inside_quest;
491 /* Check for Tower Quest */
493 (quest[leaving_quest].type == QUEST_TYPE_TOWER) &&
494 (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))
496 if (quest[leaving_quest].type == QUEST_TYPE_TOWER)
498 quest[QUEST_TOWER1].status = QUEST_STATUS_FAILED;
499 quest[QUEST_TOWER1].complev = p_ptr->lev;
501 quest[QUEST_TOWER1].comptime = current_world_ptr->play_time;