2 #include "floor-events.h"
4 #include "monsterrace-hook.h"
8 * @brief クエスト突入時のメッセージテーブル / Array of places to find an inscription
10 static concptr find_quest[] =
12 _("床にメッセージが刻まれている:", "You find the following inscription in the floor"),
13 _("壁にメッセージが刻まれている:", "You see a message inscribed in the wall"),
14 _("メッセージを見つけた:", "There is a sign saying"),
15 _("何かが階段の上に書いてある:", "Something is written on the staircase"),
16 _("巻物を見つけた。メッセージが書いてある:", "You find a scroll with the following message"),
20 * @brief ランダムクエストの討伐ユニークを決める / Determine the random quest uniques
21 * @param q_ptr クエスト構造体の参照ポインタ
24 void determine_random_questor(quest_type *q_ptr)
29 get_mon_num_prep(mon_hook_quest, NULL);
34 * Random monster 5 - 10 levels out of depth
35 * (depending on level)
37 r_idx = get_mon_num(q_ptr->level + 5 + randint1(q_ptr->level / 10));
38 r_ptr = &r_info[r_idx];
40 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
41 if (r_ptr->flags1 & RF1_QUESTOR) continue;
42 if (r_ptr->rarity > 100) continue;
43 if (r_ptr->flags7 & RF7_FRIENDLY) continue;
44 if (r_ptr->flags7 & RF7_AQUATIC) continue;
45 if (r_ptr->flags8 & RF8_WILD_ONLY) continue;
46 if (no_questor_or_bounty_uniques(r_idx)) continue;
49 * Accept monsters that are 2 - 6 levels
50 * out of depth depending on the quest level
52 if (r_ptr->level > (q_ptr->level + (q_ptr->level / 20))) break;
59 * @brief クエストを達成状態にする /
60 * @param quest_num 達成状態にしたいクエストのID
63 void complete_quest(QUEST_IDX quest_num)
65 quest_type* const q_ptr = &quest[quest_num];
69 case QUEST_TYPE_RANDOM:
70 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
73 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
77 q_ptr->status = QUEST_STATUS_COMPLETED;
78 q_ptr->complev = p_ptr->lev;
80 q_ptr->comptime = playtime;
82 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
84 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
85 msg_print(_("クエストを達成した!", "You just completed your quest!"));
93 * @brief 特定の敵を倒した際にクエスト達成処理 /
94 * Check for "Quest" completion when a quest monster is killed or charmed.
95 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
98 void check_quest_completion(monster_type *m_ptr)
103 bool create_stairs = FALSE;
113 quest_num = p_ptr->inside_quest;
115 /* Search for an active quest on this dungeon level */
120 for (i = max_q_idx - 1; i > 0; i--)
122 quest_type* const q_ptr = &quest[i];
124 /* Quest is not active */
125 if (q_ptr->status != QUEST_STATUS_TAKEN)
128 /* Quest is not a dungeon quest */
129 if (q_ptr->flags & QUEST_FLAG_PRESET)
132 /* Quest is not on this level */
133 if ((q_ptr->level != dun_level) &&
134 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
137 /* Not a "kill monster" quest */
138 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
139 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
142 /* Interesting quest */
143 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
144 (q_ptr->type == QUEST_TYPE_TOWER) ||
145 (q_ptr->type == QUEST_TYPE_KILL_ALL))
148 /* Interesting quest */
149 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
150 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
151 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
152 (q_ptr->r_idx == m_ptr->r_idx))
159 /* Handle the current quest */
160 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
163 quest_type* const q_ptr = &quest[quest_num];
167 case QUEST_TYPE_KILL_NUMBER:
171 if (q_ptr->cur_num >= q_ptr->num_mon)
173 complete_quest(quest_num);
179 case QUEST_TYPE_KILL_ALL:
181 if (!is_hostile(m_ptr)) break;
183 if (count_all_hostile_monsters() == 1)
185 if (q_ptr->flags & QUEST_FLAG_SILENT)
187 q_ptr->status = QUEST_STATUS_FINISHED;
191 complete_quest(quest_num);
196 case QUEST_TYPE_KILL_LEVEL:
197 case QUEST_TYPE_RANDOM:
199 /* Only count valid monsters */
200 if (q_ptr->r_idx != m_ptr->r_idx)
205 if (q_ptr->cur_num >= q_ptr->max_num)
207 complete_quest(quest_num);
209 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
211 create_stairs = TRUE;
212 p_ptr->inside_quest = 0;
215 /* Finish the two main quests without rewarding */
216 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
218 q_ptr->status = QUEST_STATUS_FINISHED;
221 if (q_ptr->type == QUEST_TYPE_RANDOM)
224 q_ptr->status = QUEST_STATUS_FINISHED;
229 case QUEST_TYPE_KILL_ANY_LEVEL:
232 if (q_ptr->cur_num >= q_ptr->max_num)
234 complete_quest(quest_num);
239 case QUEST_TYPE_TOWER:
241 if (!is_hostile(m_ptr)) break;
243 if (count_all_hostile_monsters() == 1)
245 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
247 if ((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
248 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
249 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
252 complete_quest(QUEST_TOWER1);
260 /* Create a magical staircase */
266 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT))
268 /* Pick a location */
269 scatter(&ny, &nx, y, x, 1, 0);
275 /* Explain the staircase */
276 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
278 /* Create stairs down */
279 cave_set_feat(y, x, feat_down_stair);
281 /* Remember to update everything */
282 p_ptr->update |= (PU_FLOW);
292 for (i = 0; i < (dun_level / 15) + 1; i++)
297 /* Make a great object */
298 make_object(o_ptr, AM_GOOD | AM_GREAT);
299 (void)drop_near(o_ptr, -1, y, x);
305 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
306 * Check for "Quest" completion when a quest monster is killed or charmed.
307 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
310 void check_find_art_quest_completion(object_type *o_ptr)
313 /* Check if completed a quest */
314 for (i = 0; i < max_q_idx; i++)
316 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
317 (quest[i].status == QUEST_STATUS_TAKEN) &&
318 (quest[i].k_idx == o_ptr->name1))
327 * @brief クエストの導入メッセージを表示する / Discover quest
328 * @param q_idx 開始されたクエストのID
330 void quest_discovery(QUEST_IDX q_idx)
332 quest_type *q_ptr = &quest[q_idx];
333 monster_race *r_ptr = &r_info[q_ptr->r_idx];
334 MONSTER_NUMBER q_num = q_ptr->max_num;
335 GAME_TEXT name[MAX_NLEN];
340 strcpy(name, (r_name + r_ptr->name));
342 msg_print(find_quest[rand_range(0, 4)]);
349 /* Hack -- "unique" monsters must be "unique" */
350 if ((r_ptr->flags1 & RF1_UNIQUE) && (0 == r_ptr->max_num))
352 msg_print(_("この階は以前は誰かによって守られていたようだ…。", "It seems that this level was protected by someone before..."));
353 /* The unique is already dead */
354 quest[q_idx].status = QUEST_STATUS_FINISHED;
357 q_ptr->comptime = playtime;
361 msg_format(_("注意せよ!この階は%sによって守られている!", "Beware, this level is protected by %s!"), name);
366 /* Normal monsters */
370 msg_format(_("注意しろ!この階は%d体の%sによって守られている!", "Be warned, this level is guarded by %d %s!"), q_num, name);
377 * @brief 新しく入ったダンジョンの階層に固定されている一般のクエストを探し出しIDを返す。
378 * / Hack -- Check if a level is a "quest" level
379 * @param level 検索対象になる階
380 * @return クエストIDを返す。該当がない場合0を返す。
382 QUEST_IDX quest_number(DEPTH level)
387 if (p_ptr->inside_quest)
388 return (p_ptr->inside_quest);
390 for (i = 0; i < max_q_idx; i++)
392 if (quest[i].status != QUEST_STATUS_TAKEN) continue;
394 if ((quest[i].type == QUEST_TYPE_KILL_LEVEL) &&
395 !(quest[i].flags & QUEST_FLAG_PRESET) &&
396 (quest[i].level == level) &&
397 (quest[i].dungeon == dungeon_idx))
401 /* Check for random quest */
402 return (random_quest_number(level));
406 * @brief 新しく入ったダンジョンの階層に固定されているランダムクエストを探し出しIDを返す。
407 * @param level 検索対象になる階
408 * @return クエストIDを返す。該当がない場合0を返す。
410 QUEST_IDX random_quest_number(DEPTH level)
414 if (dungeon_idx != DUNGEON_ANGBAND) return 0;
416 for (i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
418 if ((quest[i].type == QUEST_TYPE_RANDOM) &&
419 (quest[i].status == QUEST_STATUS_TAKEN) &&
420 (quest[i].level == level) &&
421 (quest[i].dungeon == DUNGEON_ANGBAND))