1 #include "load/quest-loader.h"
2 #include "dungeon/quest.h"
3 #include "floor/floor-town.h"
4 #include "load/angband-version-comparer.h"
5 #include "load/load-util.h"
6 #include "load/load-zangband.h"
7 #include "monster-race/monster-race.h"
8 #include "monster-race/race-flags1.h"
9 #include "monster-race/race-flags7.h"
10 #include "object-enchant/trg-types.h"
11 #include "system/artifact-type-definition.h"
12 #include "system/floor-type-definition.h"
13 #include "system/system-variables.h"
16 * @brief ランダムクエスト情報の読み込み
19 * @details MAX_TRIES: ランダムクエストのモンスターを確定するために試行する回数 /
20 * Maximum number of tries for selection of a proper quest monster
22 void rd_unique_info(void)
24 const int MAX_TRIES = 100;
25 for (int i = 0; i < max_r_idx; i++) {
26 monster_race *r_ptr = &r_info[i];
27 r_ptr->max_num = MAX_TRIES;
28 if (r_ptr->flags1 & RF1_UNIQUE)
30 else if (r_ptr->flags7 & RF7_NAZGUL)
31 r_ptr->max_num = MAX_NAZGUL_NUM;
38 rd_u16b(&max_towns_load);
39 if (max_towns_load <= max_towns)
42 load_note(format(_("町が多すぎる(%u)!", "Too many (%u) towns!"), max_towns_load));
46 errr load_quest_info(u16b *max_quests_load, byte *max_rquests_load)
48 rd_u16b(max_quests_load);
49 if (z_older_than(11, 0, 7))
50 *max_rquests_load = 10;
52 rd_byte(max_rquests_load);
54 if (*max_quests_load <= max_q_idx)
57 load_note(format(_("クエストが多すぎる(%u)!", "Too many (%u) quests!"), *max_quests_load));
61 static bool check_quest_index(int loading_quest_index)
63 if (loading_quest_index < max_q_idx)
71 static void load_quest_completion(quest_type *q_ptr)
73 rd_s16b(&q_ptr->status);
76 q_ptr->level = tmp16s;
78 if (z_older_than(11, 0, 6))
83 q_ptr->complev = tmp8u;
86 if (h_older_than(2, 1, 2, 2))
89 rd_u32b(&q_ptr->comptime);
92 static void load_quest_details(player_type *creature_ptr, quest_type *q_ptr, int loading_quest_index)
96 q_ptr->cur_num = (MONSTER_NUMBER)tmp16s;
98 q_ptr->max_num = (MONSTER_NUMBER)tmp16s;
99 rd_s16b(&q_ptr->type);
101 rd_s16b(&q_ptr->r_idx);
102 if ((q_ptr->type == QUEST_TYPE_RANDOM) && (!q_ptr->r_idx))
103 determine_random_questor(creature_ptr, &quest[loading_quest_index]);
105 rd_s16b(&q_ptr->k_idx);
107 a_info[q_ptr->k_idx].gen_flags |= TRG_QUESTITEM;
111 q_ptr->flags = tmp8u;
114 void analyze_quests(player_type *creature_ptr, const u16b max_quests_load, const byte max_rquests_load)
116 QUEST_IDX old_inside_quest = creature_ptr->current_floor_ptr->inside_quest;
117 for (int i = 0; i < max_quests_load; i++) {
118 if (check_quest_index(i))
121 quest_type *const q_ptr = &quest[i];
122 load_quest_completion(q_ptr);
123 bool is_quest_running = (q_ptr->status == QUEST_STATUS_TAKEN);
124 is_quest_running |= (!z_older_than(10, 3, 14) && (q_ptr->status == QUEST_STATUS_COMPLETED));
125 is_quest_running |= (!z_older_than(11, 0, 7) && (i >= MIN_RANDOM_QUEST) && (i <= (MIN_RANDOM_QUEST + max_rquests_load)));
126 if (!is_quest_running)
129 load_quest_details(creature_ptr, q_ptr, i);
130 if (z_older_than(10, 3, 11))
131 set_zangband_quest(creature_ptr, q_ptr, i, old_inside_quest);
135 q_ptr->dungeon = tmp8u;
138 if (q_ptr->status == QUEST_STATUS_TAKEN || q_ptr->status == QUEST_STATUS_UNTAKEN)
139 if (r_info[q_ptr->r_idx].flags1 & RF1_UNIQUE)
140 r_info[q_ptr->r_idx].flags1 |= RF1_QUESTOR;