1 #include "birth/game-play-initializer.h"
2 #include "info-reader/fixed-map-parser.h"
3 #include "dungeon/dungeon.h"
4 #include "dungeon/quest.h"
5 #include "floor/floor.h"
6 #include "game-option/birth-options.h"
7 #include "game-option/cheat-options.h"
8 #include "market/arena.h"
9 #include "monster-race/monster-race.h"
10 #include "monster-race/race-flags1.h"
11 #include "monster-race/race-flags7.h"
12 #include "object-enchant/artifact.h"
13 #include "object/object-generator.h"
14 #include "object/object-kind.h"
15 #include "pet/pet-util.h"
16 #include "player/player-race-types.h"
17 #include "system/system-variables.h"
18 #include "world/world.h"
21 * @brief ベースアイテム構造体の鑑定済みフラグをリセットする。
24 static void k_info_reset(void)
26 for (int i = 1; i < max_k_idx; i++) {
27 object_kind *k_ptr = &k_info[i];
34 * @brief プレイヤー構造体の内容を初期値で消去する(名前を除く) / Clear all the global "character" data (without name)
35 * @param creature_ptr プレーヤーへの参照ポインタ
37 * @details 少し長いが、これ1つで処理が完結しているので分割は見送る
39 void player_wipe_without_name(player_type *creature_ptr)
43 COPY(&tmp, creature_ptr, player_type);
44 if (creature_ptr->last_message)
45 string_free(creature_ptr->last_message);
47 if (creature_ptr->inventory_list != NULL)
48 C_WIPE(creature_ptr->inventory_list, INVEN_TOTAL, object_type);
50 (void)WIPE(creature_ptr, player_type);
52 //TODO: キャラ作成からゲーム開始までに current_floor_ptr を参照しなければならない処理は今後整理して外す。
53 creature_ptr->current_floor_ptr = &floor_info;
54 C_MAKE(creature_ptr->inventory_list, INVEN_TOTAL, object_type);
55 for (int i = 0; i < 4; i++)
56 strcpy(creature_ptr->history[i], "");
58 for (int i = 0; i < max_q_idx; i++) {
59 quest_type *const q_ptr = &quest[i];
60 q_ptr->status = QUEST_STATUS_UNTAKEN;
70 creature_ptr->total_weight = 0;
71 creature_ptr->inven_cnt = 0;
72 creature_ptr->equip_cnt = 0;
73 for (int i = 0; i < INVEN_TOTAL; i++)
74 object_wipe(&creature_ptr->inventory_list[i]);
76 for (int i = 0; i < max_a_idx; i++) {
77 artifact_type *a_ptr = &a_info[i];
82 for (int i = 1; i < max_r_idx; i++) {
83 monster_race *r_ptr = &r_info[i];
86 if (r_ptr->flags1 & RF1_UNIQUE)
88 else if (r_ptr->flags7 & RF7_NAZGUL)
89 r_ptr->max_num = MAX_NAZGUL_NUM;
95 creature_ptr->food = PY_FOOD_FULL - 1;
96 if (creature_ptr->pclass == CLASS_SORCERER) {
97 creature_ptr->spell_learned1 = creature_ptr->spell_learned2 = 0xffffffffL;
98 creature_ptr->spell_worked1 = creature_ptr->spell_worked2 = 0xffffffffL;
100 creature_ptr->spell_learned1 = creature_ptr->spell_learned2 = 0L;
101 creature_ptr->spell_worked1 = creature_ptr->spell_worked2 = 0L;
104 creature_ptr->spell_forgotten1 = creature_ptr->spell_forgotten2 = 0L;
105 for (int i = 0; i < 64; i++)
106 creature_ptr->spell_order[i] = 99;
108 creature_ptr->learned_spells = 0;
109 creature_ptr->add_spells = 0;
110 creature_ptr->knowledge = 0;
111 creature_ptr->mutant_regenerate_mod = 100;
120 cheat_diary_output = FALSE;
123 current_world_ptr->total_winner = FALSE;
124 creature_ptr->timewalk = FALSE;
125 creature_ptr->panic_save = 0;
127 current_world_ptr->noscore = 0;
128 current_world_ptr->wizard = FALSE;
129 creature_ptr->wait_report_score = FALSE;
130 creature_ptr->pet_follow_distance = PET_FOLLOW_DIST;
131 creature_ptr->pet_extra_flags = (PF_TELEPORT | PF_ATTACK_SPELL | PF_SUMMON_SPELL);
133 for (int i = 0; i < current_world_ptr->max_d_idx; i++)
136 creature_ptr->visit = 1;
137 creature_ptr->wild_mode = FALSE;
139 for (int i = 0; i < 108; i++) {
140 creature_ptr->magic_num1[i] = 0;
141 creature_ptr->magic_num2[i] = 0;
144 creature_ptr->max_plv = creature_ptr->lev = 1;
145 creature_ptr->arena_number = 0;
146 creature_ptr->current_floor_ptr->inside_arena = FALSE;
147 creature_ptr->current_floor_ptr->inside_quest = 0;
148 for (int i = 0; i < MAX_MANE; i++) {
149 creature_ptr->mane_spell[i] = -1;
150 creature_ptr->mane_dam[i] = 0;
153 creature_ptr->mane_num = 0;
154 creature_ptr->exit_bldg = TRUE;
155 creature_ptr->today_mon = 0;
156 update_gambling_monsters(creature_ptr);
157 creature_ptr->muta1 = 0;
158 creature_ptr->muta2 = 0;
159 creature_ptr->muta3 = 0;
161 for (int i = 0; i < 8; i++)
162 creature_ptr->virtues[i] = 0;
164 creature_ptr->dungeon_idx = 0;
165 if (vanilla_town || ironman_downward) {
166 creature_ptr->recall_dungeon = DUNGEON_ANGBAND;
168 creature_ptr->recall_dungeon = DUNGEON_GALGALS;
171 memcpy(creature_ptr->name, tmp.name, sizeof(tmp.name));
175 * @brief ダンジョン内部のクエストを初期化する / Initialize random quests and final quests
176 * @param creature_ptr プレーヤーへの参照ポインタ
179 void init_dungeon_quests(player_type *creature_ptr)
181 int number_of_quests = MAX_RANDOM_QUEST - MIN_RANDOM_QUEST + 1;
182 init_flags = INIT_ASSIGN;
183 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
184 floor_ptr->inside_quest = MIN_RANDOM_QUEST;
185 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
186 floor_ptr->inside_quest = 0;
187 for (int i = MIN_RANDOM_QUEST + number_of_quests - 1; i >= MIN_RANDOM_QUEST; i--) {
188 quest_type *q_ptr = &quest[i];
189 monster_race *quest_r_ptr;
190 q_ptr->status = QUEST_STATUS_TAKEN;
191 determine_random_questor(creature_ptr, q_ptr);
192 quest_r_ptr = &r_info[q_ptr->r_idx];
193 quest_r_ptr->flags1 |= RF1_QUESTOR;
197 init_flags = INIT_ASSIGN;
198 floor_ptr->inside_quest = QUEST_OBERON;
199 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
200 quest[QUEST_OBERON].status = QUEST_STATUS_TAKEN;
202 floor_ptr->inside_quest = QUEST_SERPENT;
203 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
204 quest[QUEST_SERPENT].status = QUEST_STATUS_TAKEN;
205 floor_ptr->inside_quest = 0;
209 * @brief ゲームターンを初期化する / Reset turn
210 * @param creature_ptr プレーヤーへの参照ポインタ
212 * @details アンデッド系種族は開始時刻を夜からにする / Undead start just sunset
215 void init_turn(player_type *creature_ptr)
217 if ((creature_ptr->prace == RACE_VAMPIRE) || (creature_ptr->prace == RACE_SKELETON) || (creature_ptr->prace == RACE_ZOMBIE) || (creature_ptr->prace == RACE_SPECTRE)) {
218 current_world_ptr->game_turn = (TURNS_PER_TICK * 3 * TOWN_DAWN) / 4 + 1;
219 current_world_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * MAX_DAYS + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
221 current_world_ptr->game_turn = 1;
222 current_world_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
225 current_world_ptr->dungeon_turn = 1;
226 current_world_ptr->dungeon_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;