OSDN Git Service

Make Balrog plural to match "are resistant".
[hengband/hengband.git] / src / birth / game-play-initializer.c
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-util.h"
6 #include "game-option/birth-options.h"
7 #include "game-option/cheat-options.h"
8 #include "inventory/inventory-slot-types.h"
9 #include "market/arena.h"
10 #include "monster-race/monster-race.h"
11 #include "monster-race/race-flags1.h"
12 #include "monster-race/race-flags7.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/artifact-type-definition.h"
18 #include "system/floor-type-definition.h"
19 #include "system/system-variables.h"
20 #include "world/world.h"
21
22 /*!
23  * @brief ベースアイテム構造体の鑑定済みフラグをリセットする。
24  * @return なし
25  */
26 static void k_info_reset(void)
27 {
28     for (int i = 1; i < max_k_idx; i++) {
29         object_kind *k_ptr = &k_info[i];
30         k_ptr->tried = FALSE;
31         k_ptr->aware = FALSE;
32     }
33 }
34
35 /*!
36  * @brief プレイヤー構造体の内容を初期値で消去する(名前を除く) / Clear all the global "character" data (without name)
37  * @param creature_ptr プレーヤーへの参照ポインタ
38  * @return なし
39  * @details 少し長いが、これ1つで処理が完結しているので分割は見送る
40  */
41 void player_wipe_without_name(player_type *creature_ptr)
42 {
43     player_type tmp;
44
45 #ifdef SET_UID
46     int uid = creature_ptr->player_uid;
47 #endif
48     COPY(&tmp, creature_ptr, player_type);
49     if (creature_ptr->last_message)
50         string_free(creature_ptr->last_message);
51
52     if (creature_ptr->inventory_list != NULL)
53         C_WIPE(creature_ptr->inventory_list, INVEN_TOTAL, object_type);
54
55     (void)WIPE(creature_ptr, player_type);
56
57     //TODO: キャラ作成からゲーム開始までに  current_floor_ptr を参照しなければならない処理は今後整理して外す。
58     creature_ptr->current_floor_ptr = &floor_info;
59     C_MAKE(creature_ptr->inventory_list, INVEN_TOTAL, object_type);
60     for (int i = 0; i < 4; i++)
61         strcpy(creature_ptr->history[i], "");
62
63     for (int i = 0; i < max_q_idx; i++) {
64         quest_type *const q_ptr = &quest[i];
65         q_ptr->status = QUEST_STATUS_UNTAKEN;
66         q_ptr->cur_num = 0;
67         q_ptr->max_num = 0;
68         q_ptr->type = 0;
69         q_ptr->level = 0;
70         q_ptr->r_idx = 0;
71         q_ptr->complev = 0;
72         q_ptr->comptime = 0;
73     }
74
75     creature_ptr->inven_cnt = 0;
76     creature_ptr->equip_cnt = 0;
77     for (int i = 0; i < INVEN_TOTAL; i++)
78         object_wipe(&creature_ptr->inventory_list[i]);
79
80     for (int i = 0; i < max_a_idx; i++) {
81         artifact_type *a_ptr = &a_info[i];
82         a_ptr->cur_num = 0;
83     }
84
85     k_info_reset();
86     for (int i = 1; i < max_r_idx; i++) {
87         monster_race *r_ptr = &r_info[i];
88         r_ptr->cur_num = 0;
89         r_ptr->max_num = 100;
90         if (r_ptr->flags1 & RF1_UNIQUE)
91             r_ptr->max_num = 1;
92         else if (r_ptr->flags7 & RF7_NAZGUL)
93             r_ptr->max_num = MAX_NAZGUL_NUM;
94
95         r_ptr->r_pkills = 0;
96         r_ptr->r_akills = 0;
97     }
98
99     creature_ptr->food = PY_FOOD_FULL - 1;
100     if (creature_ptr->pclass == CLASS_SORCERER) {
101         creature_ptr->spell_learned1 = creature_ptr->spell_learned2 = 0xffffffffL;
102         creature_ptr->spell_worked1 = creature_ptr->spell_worked2 = 0xffffffffL;
103     } else {
104         creature_ptr->spell_learned1 = creature_ptr->spell_learned2 = 0L;
105         creature_ptr->spell_worked1 = creature_ptr->spell_worked2 = 0L;
106     }
107
108     creature_ptr->spell_forgotten1 = creature_ptr->spell_forgotten2 = 0L;
109     for (int i = 0; i < 64; i++)
110         creature_ptr->spell_order[i] = 99;
111
112     creature_ptr->learned_spells = 0;
113     creature_ptr->add_spells = 0;
114     creature_ptr->knowledge = 0;
115     creature_ptr->mutant_regenerate_mod = 100;
116
117     cheat_peek = FALSE;
118     cheat_hear = FALSE;
119     cheat_room = FALSE;
120     cheat_xtra = FALSE;
121     cheat_know = FALSE;
122     cheat_live = FALSE;
123     cheat_save = FALSE;
124     cheat_diary_output = FALSE;
125     cheat_turn = FALSE;
126
127     current_world_ptr->total_winner = FALSE;
128     creature_ptr->timewalk = FALSE;
129     creature_ptr->panic_save = 0;
130
131     current_world_ptr->noscore = 0;
132     current_world_ptr->wizard = FALSE;
133     creature_ptr->wait_report_score = FALSE;
134     creature_ptr->pet_follow_distance = PET_FOLLOW_DIST;
135     creature_ptr->pet_extra_flags = (PF_TELEPORT | PF_ATTACK_SPELL | PF_SUMMON_SPELL);
136
137     for (int i = 0; i < current_world_ptr->max_d_idx; i++)
138         max_dlv[i] = 0;
139
140     creature_ptr->visit = 1;
141     creature_ptr->wild_mode = FALSE;
142
143     for (int i = 0; i < MAX_SPELLS; i++) {
144         creature_ptr->magic_num1[i] = 0;
145         creature_ptr->magic_num2[i] = 0;
146     }
147
148     creature_ptr->max_plv = creature_ptr->lev = 1;
149     creature_ptr->arena_number = 0;
150     creature_ptr->current_floor_ptr->inside_arena = FALSE;
151     creature_ptr->current_floor_ptr->inside_quest = 0;
152     for (int i = 0; i < MAX_MANE; i++) {
153         creature_ptr->mane_spell[i] = -1;
154         creature_ptr->mane_dam[i] = 0;
155     }
156
157     creature_ptr->mane_num = 0;
158     creature_ptr->exit_bldg = TRUE;
159     creature_ptr->today_mon = 0;
160     update_gambling_monsters(creature_ptr);
161     creature_ptr->muta1 = 0;
162     creature_ptr->muta2 = 0;
163     creature_ptr->muta3 = 0;
164
165     for (int i = 0; i < 8; i++)
166         creature_ptr->virtues[i] = 0;
167
168     creature_ptr->dungeon_idx = 0;
169     if (vanilla_town || ironman_downward) {
170         creature_ptr->recall_dungeon = DUNGEON_ANGBAND;
171     } else {
172         creature_ptr->recall_dungeon = DUNGEON_GALGALS;
173     }
174
175     memcpy(creature_ptr->name, tmp.name, sizeof(tmp.name));
176
177 #ifdef SET_UID
178     creature_ptr->player_uid = uid;
179 #endif
180 }
181
182 /*!
183  * @brief ダンジョン内部のクエストを初期化する / Initialize random quests and final quests
184  * @param creature_ptr プレーヤーへの参照ポインタ
185  * @return なし
186  */
187 void init_dungeon_quests(player_type *creature_ptr)
188 {
189     int number_of_quests = MAX_RANDOM_QUEST - MIN_RANDOM_QUEST + 1;
190     init_flags = INIT_ASSIGN;
191     floor_type *floor_ptr = creature_ptr->current_floor_ptr;
192     floor_ptr->inside_quest = MIN_RANDOM_QUEST;
193     parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
194     floor_ptr->inside_quest = 0;
195     for (int i = MIN_RANDOM_QUEST + number_of_quests - 1; i >= MIN_RANDOM_QUEST; i--) {
196         quest_type *q_ptr = &quest[i];
197         monster_race *quest_r_ptr;
198         q_ptr->status = QUEST_STATUS_TAKEN;
199         determine_random_questor(creature_ptr, q_ptr);
200         quest_r_ptr = &r_info[q_ptr->r_idx];
201         quest_r_ptr->flags1 |= RF1_QUESTOR;
202         q_ptr->max_num = 1;
203     }
204
205     init_flags = INIT_ASSIGN;
206     floor_ptr->inside_quest = QUEST_OBERON;
207     parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
208     quest[QUEST_OBERON].status = QUEST_STATUS_TAKEN;
209
210     floor_ptr->inside_quest = QUEST_SERPENT;
211     parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
212     quest[QUEST_SERPENT].status = QUEST_STATUS_TAKEN;
213     floor_ptr->inside_quest = 0;
214 }
215
216 /*!
217  * @brief ゲームターンを初期化する / Reset turn
218  * @param creature_ptr プレーヤーへの参照ポインタ
219  * @return なし
220  * @details アンデッド系種族は開始時刻を夜からにする / Undead start just sunset
221  * @details        
222  */
223 void init_turn(player_type *creature_ptr)
224 {
225     if ((creature_ptr->prace == RACE_VAMPIRE) || (creature_ptr->prace == RACE_SKELETON) || (creature_ptr->prace == RACE_ZOMBIE) || (creature_ptr->prace == RACE_SPECTRE)) {
226         current_world_ptr->game_turn = (TURNS_PER_TICK * 3 * TOWN_DAWN) / 4 + 1;
227         current_world_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * MAX_DAYS + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
228     } else {
229         current_world_ptr->game_turn = 1;
230         current_world_ptr->game_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
231     }
232
233     current_world_ptr->dungeon_turn = 1;
234     current_world_ptr->dungeon_turn_limit = TURNS_PER_TICK * TOWN_DAWN * (MAX_DAYS - 1) + TURNS_PER_TICK * TOWN_DAWN * 3 / 4;
235 }