1 #include "system/angband.h"
2 #include "birth/game-play-initializer.h"
3 #include "object/object-kind.h"
4 #include "world/world.h"
5 #include "dungeon/quest.h"
6 #include "dungeon/dungeon.h"
7 #include "dungeon/dungeon-file.h"
8 #include "object/artifact.h"
9 #include "cmd/cmd-pet.h"
10 #include "system/system-variables.h"
11 #include "player/player-races-table.h"
12 #include "market/arena.h"
15 * @brief ベースアイテム構造体の鑑定済みフラグをリセットする。
18 static void k_info_reset(void)
20 for (int i = 1; i < max_k_idx; i++) {
21 object_kind *k_ptr = &k_info[i];
28 * @brief プレイヤー構造体の内容を初期値で消去する(名前を除く) / Clear all the global "character" data (without name)
29 * @param creature_ptr プレーヤーへの参照ポインタ
31 * @details 少し長いが、これ1つで処理が完結しているので分割は見送る
33 void player_wipe_without_name(player_type *creature_ptr)
37 COPY(&tmp, creature_ptr, player_type);
38 if (creature_ptr->last_message)
39 string_free(creature_ptr->last_message);
41 if (creature_ptr->inventory_list != NULL)
42 C_WIPE(creature_ptr->inventory_list, INVEN_TOTAL, object_type);
44 (void)WIPE(creature_ptr, player_type);
46 //TODO: キャラ作成からゲーム開始までに current_floor_ptr を参照しなければならない処理は今後整理して外す。
47 creature_ptr->current_floor_ptr = &floor_info;
48 C_MAKE(creature_ptr->inventory_list, INVEN_TOTAL, object_type);
49 for (int i = 0; i < 4; i++)
50 strcpy(creature_ptr->history[i], "");
52 for (int i = 0; i < max_q_idx; i++) {
53 quest_type *const q_ptr = &quest[i];
54 q_ptr->status = QUEST_STATUS_UNTAKEN;
64 creature_ptr->total_weight = 0;
65 creature_ptr->inven_cnt = 0;
66 creature_ptr->equip_cnt = 0;
67 for (int i = 0; i < INVEN_TOTAL; i++)
68 object_wipe(&creature_ptr->inventory_list[i]);
70 for (int i = 0; i < max_a_idx; i++) {
71 artifact_type *a_ptr = &a_info[i];
76 for (int i = 1; i < max_r_idx; i++) {
77 monster_race *r_ptr = &r_info[i];
80 if (r_ptr->flags1 & RF1_UNIQUE)
82 else if (r_ptr->flags7 & RF7_NAZGUL)
83 r_ptr->max_num = MAX_NAZGUL_NUM;
89 creature_ptr->food = PY_FOOD_FULL - 1;
90 if (creature_ptr->pclass == CLASS_SORCERER) {
91 creature_ptr->spell_learned1 = creature_ptr->spell_learned2 = 0xffffffffL;
92 creature_ptr->spell_worked1 = creature_ptr->spell_worked2 = 0xffffffffL;
94 creature_ptr->spell_learned1 = creature_ptr->spell_learned2 = 0L;
95 creature_ptr->spell_worked1 = creature_ptr->spell_worked2 = 0L;
98 creature_ptr->spell_forgotten1 = creature_ptr->spell_forgotten2 = 0L;
99 for (int i = 0; i < 64; i++)
100 creature_ptr->spell_order[i] = 99;
102 creature_ptr->learned_spells = 0;
103 creature_ptr->add_spells = 0;
104 creature_ptr->knowledge = 0;
105 creature_ptr->mutant_regenerate_mod = 100;
114 cheat_diary_output = FALSE;
117 current_world_ptr->total_winner = FALSE;
118 creature_ptr->timewalk = FALSE;
119 creature_ptr->panic_save = 0;
121 current_world_ptr->noscore = 0;
122 current_world_ptr->wizard = FALSE;
123 creature_ptr->wait_report_score = FALSE;
124 creature_ptr->pet_follow_distance = PET_FOLLOW_DIST;
125 creature_ptr->pet_extra_flags = (PF_TELEPORT | PF_ATTACK_SPELL | PF_SUMMON_SPELL);
127 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
130 creature_ptr->visit = 1;
131 creature_ptr->wild_mode = FALSE;
133 for (int i = 0; i < 108; i++) {
134 creature_ptr->magic_num1[i] = 0;
135 creature_ptr->magic_num2[i] = 0;
138 creature_ptr->max_plv = creature_ptr->lev = 1;
139 creature_ptr->arena_number = 0;
140 creature_ptr->current_floor_ptr->inside_arena = FALSE;
141 creature_ptr->current_floor_ptr->inside_quest = 0;
142 for (int i = 0; i < MAX_MANE; i++) {
143 creature_ptr->mane_spell[i] = -1;
144 creature_ptr->mane_dam[i] = 0;
147 creature_ptr->mane_num = 0;
148 creature_ptr->exit_bldg = TRUE;
149 creature_ptr->today_mon = 0;
150 update_gambling_monsters(creature_ptr);
151 creature_ptr->muta1 = 0;
152 creature_ptr->muta2 = 0;
153 creature_ptr->muta3 = 0;
155 for (int i = 0; i < 8; i++)
156 creature_ptr->virtues[i] = 0;
158 creature_ptr->dungeon_idx = 0;
159 if (vanilla_town || ironman_downward) {
160 creature_ptr->recall_dungeon = DUNGEON_ANGBAND;
162 creature_ptr->recall_dungeon = DUNGEON_GALGALS;
165 memcpy(creature_ptr->name, tmp.name, sizeof(tmp.name));
169 * @brief ダンジョン内部のクエストを初期化する / Initialize random quests and final quests
170 * @param creature_ptr プレーヤーへの参照ポインタ
173 void init_dungeon_quests(player_type *creature_ptr)
175 int number_of_quests = MAX_RANDOM_QUEST - MIN_RANDOM_QUEST + 1;
176 init_flags = INIT_ASSIGN;
177 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
178 floor_ptr->inside_quest = MIN_RANDOM_QUEST;
179 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
180 floor_ptr->inside_quest = 0;
181 for (int i = MIN_RANDOM_QUEST + number_of_quests - 1; i >= MIN_RANDOM_QUEST; i--) {
182 quest_type *q_ptr = &quest[i];
183 monster_race *quest_r_ptr;
184 q_ptr->status = QUEST_STATUS_TAKEN;
185 determine_random_questor(creature_ptr, q_ptr);
186 quest_r_ptr = &r_info[q_ptr->r_idx];
187 quest_r_ptr->flags1 |= RF1_QUESTOR;
191 init_flags = INIT_ASSIGN;
192 floor_ptr->inside_quest = QUEST_OBERON;
193 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
194 quest[QUEST_OBERON].status = QUEST_STATUS_TAKEN;
196 floor_ptr->inside_quest = QUEST_SERPENT;
197 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
198 quest[QUEST_SERPENT].status = QUEST_STATUS_TAKEN;
199 floor_ptr->inside_quest = 0;
203 * @brief ゲームターンを初期化する / Reset turn
204 * @param creature_ptr プレーヤーへの参照ポインタ
206 * @details アンデッド系種族は開始時刻を夜からにする / Undead start just sunset
209 void init_turn(player_type *creature_ptr)
211 if ((creature_ptr->prace == RACE_VAMPIRE) || (creature_ptr->prace == RACE_SKELETON) || (creature_ptr->prace == RACE_ZOMBIE) || (creature_ptr->prace == RACE_SPECTRE)) {
212 current_world_ptr->game_turn = (TURNS_PER_TICK * 3 * TOWN_DAWN) / 4 + 1;
213 current_world_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * MAX_DAYS + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
215 current_world_ptr->game_turn = 1;
216 current_world_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
219 current_world_ptr->dungeon_turn = 1;
220 current_world_ptr->dungeon_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;