2 #include "floor-events.h"
4 #include "monsterrace-hook.h"
8 * @brief ランダムクエストの討伐ユニークを決める / Determine the random quest uniques
9 * @param q_ptr クエスト構造体の参照ポインタ
12 void determine_random_questor(quest_type *q_ptr)
17 get_mon_num_prep(mon_hook_quest, NULL);
22 * Random monster 5 - 10 levels out of depth
23 * (depending on level)
25 r_idx = get_mon_num(q_ptr->level + 5 + randint1(q_ptr->level / 10));
26 r_ptr = &r_info[r_idx];
28 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
29 if (r_ptr->flags1 & RF1_QUESTOR) continue;
30 if (r_ptr->rarity > 100) continue;
31 if (r_ptr->flags7 & RF7_FRIENDLY) continue;
32 if (r_ptr->flags7 & RF7_AQUATIC) continue;
33 if (r_ptr->flags8 & RF8_WILD_ONLY) continue;
34 if (no_questor_or_bounty_uniques(r_idx)) continue;
37 * Accept monsters that are 2 - 6 levels
38 * out of depth depending on the quest level
40 if (r_ptr->level > (q_ptr->level + (q_ptr->level / 20))) break;
47 * @brief クエストを達成状態にする /
48 * @param quest_num 達成状態にしたいクエストのID
51 void complete_quest(QUEST_IDX quest_num)
53 quest_type* const q_ptr = &quest[quest_num];
57 case QUEST_TYPE_RANDOM:
58 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
61 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
65 q_ptr->status = QUEST_STATUS_COMPLETED;
66 q_ptr->complev = p_ptr->lev;
68 q_ptr->comptime = playtime;
70 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
72 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
73 msg_print(_("クエストを達成した!", "You just completed your quest!"));
81 * @brief 特定の敵を倒した際にクエスト達成処理 /
82 * Check for "Quest" completion when a quest monster is killed or charmed.
83 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
86 void check_quest_completion(monster_type *m_ptr)
91 bool create_stairs = FALSE;
101 quest_num = p_ptr->inside_quest;
103 /* Search for an active quest on this dungeon level */
108 for (i = max_q_idx - 1; i > 0; i--)
110 quest_type* const q_ptr = &quest[i];
112 /* Quest is not active */
113 if (q_ptr->status != QUEST_STATUS_TAKEN)
116 /* Quest is not a dungeon quest */
117 if (q_ptr->flags & QUEST_FLAG_PRESET)
120 /* Quest is not on this level */
121 if ((q_ptr->level != dun_level) &&
122 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
125 /* Not a "kill monster" quest */
126 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
127 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
130 /* Interesting quest */
131 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
132 (q_ptr->type == QUEST_TYPE_TOWER) ||
133 (q_ptr->type == QUEST_TYPE_KILL_ALL))
136 /* Interesting quest */
137 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
138 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
139 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
140 (q_ptr->r_idx == m_ptr->r_idx))
147 /* Handle the current quest */
148 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
151 quest_type* const q_ptr = &quest[quest_num];
155 case QUEST_TYPE_KILL_NUMBER:
159 if (q_ptr->cur_num >= q_ptr->num_mon)
161 complete_quest(quest_num);
167 case QUEST_TYPE_KILL_ALL:
169 if (!is_hostile(m_ptr)) break;
171 if (count_all_hostile_monsters() == 1)
173 if (q_ptr->flags & QUEST_FLAG_SILENT)
175 q_ptr->status = QUEST_STATUS_FINISHED;
179 complete_quest(quest_num);
184 case QUEST_TYPE_KILL_LEVEL:
185 case QUEST_TYPE_RANDOM:
187 /* Only count valid monsters */
188 if (q_ptr->r_idx != m_ptr->r_idx)
193 if (q_ptr->cur_num >= q_ptr->max_num)
195 complete_quest(quest_num);
197 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
199 create_stairs = TRUE;
200 p_ptr->inside_quest = 0;
203 /* Finish the two main quests without rewarding */
204 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
206 q_ptr->status = QUEST_STATUS_FINISHED;
209 if (q_ptr->type == QUEST_TYPE_RANDOM)
212 q_ptr->status = QUEST_STATUS_FINISHED;
217 case QUEST_TYPE_KILL_ANY_LEVEL:
220 if (q_ptr->cur_num >= q_ptr->max_num)
222 complete_quest(quest_num);
227 case QUEST_TYPE_TOWER:
229 if (!is_hostile(m_ptr)) break;
231 if (count_all_hostile_monsters() == 1)
233 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
235 if ((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
236 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
237 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
240 complete_quest(QUEST_TOWER1);
248 /* Create a magical staircase */
254 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT))
256 /* Pick a location */
257 scatter(&ny, &nx, y, x, 1, 0);
263 /* Explain the staircase */
264 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
266 /* Create stairs down */
267 cave_set_feat(y, x, feat_down_stair);
269 /* Remember to update everything */
270 p_ptr->update |= (PU_FLOW);
280 for (i = 0; i < (dun_level / 15) + 1; i++)
285 /* Make a great object */
286 make_object(o_ptr, AM_GOOD | AM_GREAT);
287 (void)drop_near(o_ptr, -1, y, x);
293 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
294 * Check for "Quest" completion when a quest monster is killed or charmed.
295 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
298 void check_find_art_quest_completion(object_type *o_ptr)
301 /* Check if completed a quest */
302 for (i = 0; i < max_q_idx; i++)
304 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
305 (quest[i].status == QUEST_STATUS_TAKEN) &&
306 (quest[i].k_idx == o_ptr->name1))