OSDN Git Service

ef5b1e7454fc3649ac3479c52939b5d50dc2c5dc
[hengband/hengband.git] / src / load / load-zangband.c
1 #include "load/load-zangband.h"
2 #include "cmd-building/cmd-building.h"
3 #include "dungeon/dungeon.h"
4 #include "game-option/option-flags.h"
5 #include "info-reader/fixed-map-parser.h"
6 #include "load/angband-version-comparer.h"
7 #include "load/load-util.h"
8 #include "market/bounty.h"
9 #include "monster-race/monster-race.h"
10 #include "pet/pet-util.h"
11 #include "player/attack-defense-types.h"
12 #include "player/avatar.h"
13 #include "player/patron.h"
14 #include "player/player-class.h"
15 #include "player/player-personality.h"
16 #include "player/player-race.h"
17 #include "player/player-skill.h"
18 #include "realm/realm-types.h"
19 #include "spell/spells-status.h"
20 #include "system/floor-type-definition.h"
21 #include "system/system-variables.h"
22 #include "world/world.h"
23
24 void load_zangband_options(void)
25 {
26     if (option_flag[5] & (0x00000001 << 4))
27         option_flag[5] &= ~(0x00000001 << 4);
28     else
29         option_flag[5] |= (0x00000001 << 4);
30
31     if (option_flag[2] & (0x00000001 << 5))
32         option_flag[2] &= ~(0x00000001 << 5);
33     else
34         option_flag[2] |= (0x00000001 << 5);
35
36     if (option_flag[4] & (0x00000001 << 5))
37         option_flag[4] &= ~(0x00000001 << 5);
38     else
39         option_flag[4] |= (0x00000001 << 5);
40
41     if (option_flag[5] & (0x00000001 << 0))
42         option_flag[5] &= ~(0x00000001 << 0);
43     else
44         option_flag[5] |= (0x00000001 << 0);
45
46     if (option_flag[5] & (0x00000001 << 12))
47         option_flag[5] &= ~(0x00000001 << 12);
48     else
49         option_flag[5] |= (0x00000001 << 12);
50
51     if (option_flag[1] & (0x00000001 << 0))
52         option_flag[1] &= ~(0x00000001 << 0);
53     else
54         option_flag[1] |= (0x00000001 << 0);
55
56     if (option_flag[1] & (0x00000001 << 18))
57         option_flag[1] &= ~(0x00000001 << 18);
58     else
59         option_flag[1] |= (0x00000001 << 18);
60
61     if (option_flag[1] & (0x00000001 << 19))
62         option_flag[1] &= ~(0x00000001 << 19);
63     else
64         option_flag[1] |= (0x00000001 << 19);
65
66     if (option_flag[5] & (0x00000001 << 3))
67         option_flag[1] &= ~(0x00000001 << 3);
68     else
69         option_flag[5] |= (0x00000001 << 3);
70 }
71
72 void set_zangband_realm(player_type* creature_ptr)
73 {
74     if (creature_ptr->realm1 == 9)
75         creature_ptr->realm1 = REALM_MUSIC;
76
77     if (creature_ptr->realm2 == 9)
78         creature_ptr->realm2 = REALM_MUSIC;
79
80     if (creature_ptr->realm1 == 10)
81         creature_ptr->realm1 = REALM_HISSATSU;
82
83     if (creature_ptr->realm2 == 10)
84         creature_ptr->realm2 = REALM_HISSATSU;
85 }
86
87 void set_zangband_skill(player_type *creature_ptr)
88 {
89     if (creature_ptr->pclass != CLASS_BEASTMASTER)
90         creature_ptr->skill_exp[GINOU_RIDING] /= 2;
91
92     creature_ptr->skill_exp[GINOU_RIDING] = MIN(creature_ptr->skill_exp[GINOU_RIDING], s_info[creature_ptr->pclass].s_max[GINOU_RIDING]);
93 }
94
95 void set_zangband_spells(player_type* creature_ptr)
96 {
97     for (int i = 0; i < MAX_SPELLS; i++)
98         creature_ptr->magic_num1[i] = 0;
99
100     for (int i = 0; i < MAX_SPELLS; i++)
101         creature_ptr->magic_num2[i] = 0;
102 }
103
104 void set_zangband_race(player_type *creature_ptr)
105 {
106     creature_ptr->start_race = creature_ptr->prace;
107     creature_ptr->old_race1 = 0L;
108     creature_ptr->old_race2 = 0L;
109     creature_ptr->old_realm = 0;
110 }
111
112 void set_zangband_bounty_uniques(player_type *creature_ptr)
113 {
114     determine_bounty_uniques(creature_ptr);
115     for (int i = 0; i < MAX_BOUNTY; i++) {
116         /* Is this bounty unique already dead? */
117         if (!r_info[current_world_ptr->bounty_r_idx[i]].max_num)
118             current_world_ptr->bounty_r_idx[i] += 10000;
119     }
120 }
121
122 /*!
123  * @brief ZAngband v2.0.6に存在しない時限効果を0で初期化する / Old savefiles do not have the following fields...
124  * @param creature_ptr プレーヤーへの参照ポインタ
125  * @return なし
126  * @details 厳密にv2.0.6しか見ていないため、ZAngband v2.0.5 以前のセーブデータは非対応
127  */
128 void set_zangband_timed_effects(player_type *creature_ptr)
129 {
130     creature_ptr->tim_esp = 0;
131     creature_ptr->wraith_form = 0;
132     creature_ptr->resist_magic = 0;
133     creature_ptr->tim_regen = 0;
134     creature_ptr->tim_pass_wall = 0;
135     creature_ptr->tim_stealth = 0;
136     creature_ptr->tim_levitation = 0;
137     creature_ptr->tim_sh_touki = 0;
138     creature_ptr->lightspeed = 0;
139     creature_ptr->tsubureru = 0;
140     creature_ptr->tim_res_nether = 0;
141     creature_ptr->tim_res_time = 0;
142     creature_ptr->mimic_form = 0;
143     creature_ptr->tim_mimic = 0;
144     creature_ptr->tim_sh_fire = 0;
145     creature_ptr->tim_reflect = 0;
146     creature_ptr->multishadow = 0;
147     creature_ptr->dustrobe = 0;
148     creature_ptr->chaos_patron = ((creature_ptr->age + creature_ptr->sc) % MAX_PATRON);
149     creature_ptr->muta1 = 0;
150     creature_ptr->muta2 = 0;
151     creature_ptr->muta3 = 0;
152     get_virtues(creature_ptr);
153 }
154
155 void set_zangband_mimic(player_type *creature_ptr)
156 {
157     creature_ptr->tim_res_time = 0;
158     creature_ptr->mimic_form = 0;
159     creature_ptr->tim_mimic = 0;
160     creature_ptr->tim_sh_fire = 0;
161 }
162
163 void set_zangband_holy_aura(player_type *creature_ptr)
164 {
165     creature_ptr->tim_sh_holy = 0;
166     creature_ptr->tim_eyeeye = 0;
167 }
168
169 void set_zangband_reflection(player_type *creature_ptr)
170 {
171     creature_ptr->tim_reflect = 0;
172     creature_ptr->multishadow = 0;
173     creature_ptr->dustrobe = 0;
174 }
175
176 void rd_zangband_dungeon()
177 {
178     s16b tmp16s;
179     rd_s16b(&tmp16s);
180     max_dlv[DUNGEON_ANGBAND] = tmp16s;
181 }
182
183 void set_zangband_game_turns(player_type *creature_ptr)
184 {
185     creature_ptr->current_floor_ptr->generated_turn /= 2;
186     creature_ptr->feeling_turn /= 2;
187     current_world_ptr->game_turn /= 2;
188     current_world_ptr->dungeon_turn /= 2;
189 }
190
191 void set_zangband_gambling_monsters(int i)
192 {
193     s16b tmp16s;
194     rd_s16b(&tmp16s);
195     mon_odds[i] = tmp16s;
196 }
197
198 void set_zangband_special_attack(player_type *creature_ptr)
199 {
200     byte tmp8u;
201     rd_byte(&tmp8u);
202     if (tmp8u)
203         creature_ptr->special_attack = ATTACK_CONFUSE;
204
205     creature_ptr->ele_attack = 0;
206 }
207
208 void set_zangband_special_defense(player_type *creature_ptr)
209 {
210     creature_ptr->ele_immune = 0;
211     creature_ptr->special_defense = 0;
212 }
213
214 void set_zangband_action(player_type *creature_ptr)
215 {
216     byte tmp8u;
217     rd_byte(&tmp8u);
218     if (tmp8u)
219         creature_ptr->action = ACTION_LEARN;
220 }
221
222 void set_zangband_visited_towns(player_type *creature_ptr)
223 {
224     s32b tmp32s;
225     rd_s32b(&tmp32s);
226     creature_ptr->visit = 1L;
227 }
228
229 void set_zangband_quest(player_type *creature_ptr, quest_type *const q_ptr, int loading_quest_index, const QUEST_IDX old_inside_quest)
230 {
231     if (q_ptr->flags & QUEST_FLAG_PRESET) {
232         q_ptr->dungeon = 0;
233         return;
234     }
235
236     init_flags = INIT_ASSIGN;
237     creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)loading_quest_index;
238     parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
239     creature_ptr->current_floor_ptr->inside_quest = old_inside_quest;
240 }
241
242 void set_zangband_class(player_type *creature_ptr)
243 {
244     if (z_older_than(10, 2, 2) && (creature_ptr->pclass == CLASS_BEASTMASTER) && !creature_ptr->is_dead) {
245         creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
246         roll_hitdice(creature_ptr, 0L);
247     }
248
249     if (z_older_than(10, 3, 2) && (creature_ptr->pclass == CLASS_ARCHER) && !creature_ptr->is_dead) {
250         creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
251         roll_hitdice(creature_ptr, 0L);
252     }
253
254     if (z_older_than(10, 2, 6) && (creature_ptr->pclass == CLASS_SORCERER) && !creature_ptr->is_dead) {
255         creature_ptr->hitdie = rp_ptr->r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
256         roll_hitdice(creature_ptr, 0L);
257     }
258
259     if (z_older_than(10, 4, 7) && (creature_ptr->pclass == CLASS_BLUE_MAGE) && !creature_ptr->is_dead) {
260         creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
261         roll_hitdice(creature_ptr, 0L);
262     }
263 }
264
265 void set_zangband_learnt_spells(player_type *creature_ptr)
266 {
267     creature_ptr->learned_spells = 0;
268     for (int i = 0; i < 64; i++)
269         if ((i < 32) ? (creature_ptr->spell_learned1 & (1L << i)) : (creature_ptr->spell_learned2 & (1L << (i - 32))))
270             creature_ptr->learned_spells++;
271 }
272
273 void set_zangband_pet(player_type *creature_ptr)
274 {
275     creature_ptr->pet_extra_flags = 0;
276     byte tmp8u;
277     rd_byte(&tmp8u);
278     if (tmp8u)
279         creature_ptr->pet_extra_flags |= PF_OPEN_DOORS;
280
281     rd_byte(&tmp8u);
282     if (tmp8u)
283         creature_ptr->pet_extra_flags |= PF_PICKUP_ITEMS;
284
285     if (z_older_than(10, 0, 4))
286         creature_ptr->pet_extra_flags |= PF_TELEPORT;
287     else {
288         rd_byte(&tmp8u);
289         if (tmp8u)
290             creature_ptr->pet_extra_flags |= PF_TELEPORT;
291     }
292
293     if (z_older_than(10, 0, 7))
294         creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
295     else {
296         rd_byte(&tmp8u);
297         if (tmp8u)
298             creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
299     }
300
301     if (z_older_than(10, 0, 8))
302         creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
303     else {
304         rd_byte(&tmp8u);
305         if (tmp8u)
306             creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
307     }
308
309     if (z_older_than(10, 0, 8))
310         return;
311
312     rd_byte(&tmp8u);
313     if (tmp8u)
314         creature_ptr->pet_extra_flags |= PF_BALL_SPELL;
315 }