OSDN Git Service

1323001c0aa1aa9dc01a0f8635bcb86f50e96b5f
[hengbandforosx/hengbandosx.git] / src / load / load-zangband.cpp
1 #include "load/load-zangband.h"
2 #include "avatar/avatar.h"
3 #include "cmd-building/cmd-building.h"
4 #include "dungeon/dungeon.h"
5 #include "dungeon/quest.h"
6 #include "game-option/option-flags.h"
7 #include "info-reader/fixed-map-parser.h"
8 #include "load/angband-version-comparer.h"
9 #include "load/load-util.h"
10 #include "market/bounty.h"
11 #include "monster-race/monster-race.h"
12 #include "pet/pet-util.h"
13 #include "player-info/class-info.h"
14 #include "player-info/race-info.h"
15 #include "player/attack-defense-types.h"
16 #include "player/patron.h"
17 #include "player/player-personality.h"
18 #include "player/player-skill.h"
19 #include "realm/realm-types.h"
20 #include "spell/spells-status.h"
21 #include "system/floor-type-definition.h"
22 #include "system/monster-race-definition.h"
23 #include "system/player-type-definition.h"
24 #include "system/system-variables.h"
25 #include "world/world.h"
26
27 void load_zangband_options(void)
28 {
29     if (option_flag[5] & (0x00000001U << 4))
30         option_flag[5] &= ~(0x00000001U << 4);
31     else
32         option_flag[5] |= (0x00000001U << 4);
33
34     if (option_flag[2] & (0x00000001U << 5))
35         option_flag[2] &= ~(0x00000001U << 5);
36     else
37         option_flag[2] |= (0x00000001U << 5);
38
39     if (option_flag[4] & (0x00000001U << 5))
40         option_flag[4] &= ~(0x00000001U << 5);
41     else
42         option_flag[4] |= (0x00000001U << 5);
43
44     if (option_flag[5] & (0x00000001U << 0))
45         option_flag[5] &= ~(0x00000001U << 0);
46     else
47         option_flag[5] |= (0x00000001U << 0);
48
49     if (option_flag[5] & (0x00000001U << 12))
50         option_flag[5] &= ~(0x00000001U << 12);
51     else
52         option_flag[5] |= (0x00000001U << 12);
53
54     if (option_flag[1] & (0x00000001U << 0))
55         option_flag[1] &= ~(0x00000001U << 0);
56     else
57         option_flag[1] |= (0x00000001U << 0);
58
59     if (option_flag[1] & (0x00000001U << 18))
60         option_flag[1] &= ~(0x00000001U << 18);
61     else
62         option_flag[1] |= (0x00000001U << 18);
63
64     if (option_flag[1] & (0x00000001U << 19))
65         option_flag[1] &= ~(0x00000001U << 19);
66     else
67         option_flag[1] |= (0x00000001U << 19);
68
69     if (option_flag[5] & (0x00000001U << 3))
70         option_flag[1] &= ~(0x00000001U << 3);
71     else
72         option_flag[5] |= (0x00000001U << 3);
73 }
74
75 void set_zangband_realm(player_type *player_ptr)
76 {
77     if (player_ptr->realm1 == 9)
78         player_ptr->realm1 = REALM_MUSIC;
79
80     if (player_ptr->realm2 == 9)
81         player_ptr->realm2 = REALM_MUSIC;
82
83     if (player_ptr->realm1 == 10)
84         player_ptr->realm1 = REALM_HISSATSU;
85
86     if (player_ptr->realm2 == 10)
87         player_ptr->realm2 = REALM_HISSATSU;
88 }
89
90 void set_zangband_skill(player_type *player_ptr)
91 {
92     if (player_ptr->pclass != PlayerClassType::BEASTMASTER)
93         player_ptr->skill_exp[SKILL_RIDING] /= 2;
94
95     player_ptr->skill_exp[SKILL_RIDING] = std::min(player_ptr->skill_exp[SKILL_RIDING], s_info[enum2i(player_ptr->pclass)].s_max[SKILL_RIDING]);
96 }
97
98 void set_zangband_race(player_type *player_ptr)
99 {
100     player_ptr->start_race = player_ptr->prace;
101     player_ptr->old_race1 = 0L;
102     player_ptr->old_race2 = 0L;
103     player_ptr->old_realm = 0;
104 }
105
106 void set_zangband_bounty_uniques(player_type *player_ptr)
107 {
108     determine_bounty_uniques(player_ptr);
109     for (int i = 0; i < MAX_BOUNTY; i++) {
110         /* Is this bounty unique already dead? */
111         if (!r_info[w_ptr->bounty_r_idx[i]].max_num)
112             w_ptr->bounty_r_idx[i] += 10000;
113     }
114 }
115
116 void set_zangband_mimic(player_type *player_ptr)
117 {
118     player_ptr->tim_res_time = 0;
119     player_ptr->mimic_form = 0;
120     player_ptr->tim_mimic = 0;
121     player_ptr->tim_sh_fire = 0;
122 }
123
124 void set_zangband_holy_aura(player_type *player_ptr)
125 {
126     player_ptr->tim_sh_holy = 0;
127     player_ptr->tim_eyeeye = 0;
128 }
129
130 void set_zangband_reflection(player_type *player_ptr)
131 {
132     player_ptr->tim_reflect = 0;
133     player_ptr->multishadow = 0;
134     player_ptr->dustrobe = 0;
135 }
136
137 void rd_zangband_dungeon()
138 {
139     max_dlv[DUNGEON_ANGBAND] = rd_s16b();
140 }
141
142 void set_zangband_game_turns(player_type *player_ptr)
143 {
144     player_ptr->current_floor_ptr->generated_turn /= 2;
145     player_ptr->feeling_turn /= 2;
146     w_ptr->game_turn /= 2;
147     w_ptr->dungeon_turn /= 2;
148 }
149
150 void set_zangband_gambling_monsters(int i)
151 {
152     mon_odds[i] = rd_s16b();
153 }
154
155 void set_zangband_special_attack(player_type *player_ptr)
156 {
157     if (rd_byte() != 0)
158         player_ptr->special_attack = ATTACK_CONFUSE;
159
160     player_ptr->ele_attack = 0;
161 }
162
163 void set_zangband_special_defense(player_type *player_ptr)
164 {
165     player_ptr->ele_immune = 0;
166     player_ptr->special_defense = 0;
167 }
168
169 void set_zangband_action(player_type *player_ptr)
170 {
171     if (rd_byte() != 0)
172         player_ptr->action = ACTION_LEARN;
173 }
174
175 void set_zangband_visited_towns(player_type *player_ptr)
176 {
177     strip_bytes(4);
178     player_ptr->visit = 1L;
179 }
180
181 void set_zangband_quest(player_type *player_ptr, quest_type *const q_ptr, int loading_quest_index, const QUEST_IDX old_inside_quest)
182 {
183     if (q_ptr->flags & QUEST_FLAG_PRESET) {
184         q_ptr->dungeon = 0;
185         return;
186     }
187
188     init_flags = INIT_ASSIGN;
189     player_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)loading_quest_index;
190     parse_fixed_map(player_ptr, "q_info.txt", 0, 0, 0, 0);
191     player_ptr->current_floor_ptr->inside_quest = old_inside_quest;
192 }
193
194 void set_zangband_class(player_type *player_ptr)
195 {
196     if (h_older_than(0, 2, 2) && (player_ptr->pclass == PlayerClassType::BEASTMASTER) && !player_ptr->is_dead) {
197         player_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
198         roll_hitdice(player_ptr, SPOP_NONE);
199     }
200
201     if (h_older_than(0, 3, 2) && (player_ptr->pclass == PlayerClassType::ARCHER) && !player_ptr->is_dead) {
202         player_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
203         roll_hitdice(player_ptr, SPOP_NONE);
204     }
205
206     if (h_older_than(0, 2, 6) && (player_ptr->pclass == PlayerClassType::SORCERER) && !player_ptr->is_dead) {
207         player_ptr->hitdie = rp_ptr->r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
208         roll_hitdice(player_ptr, SPOP_NONE);
209     }
210
211     if (h_older_than(0, 4, 7) && (player_ptr->pclass == PlayerClassType::BLUE_MAGE) && !player_ptr->is_dead) {
212         player_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
213         roll_hitdice(player_ptr, SPOP_NONE);
214     }
215 }
216
217 void set_zangband_learnt_spells(player_type *player_ptr)
218 {
219     player_ptr->learned_spells = 0;
220     for (int i = 0; i < 64; i++)
221         if ((i < 32) ? (player_ptr->spell_learned1 & (1UL << i)) : (player_ptr->spell_learned2 & (1UL << (i - 32))))
222             player_ptr->learned_spells++;
223 }
224
225 void set_zangband_pet(player_type *player_ptr)
226 {
227     player_ptr->pet_extra_flags = 0;
228     if (rd_byte() != 0)
229         player_ptr->pet_extra_flags |= PF_OPEN_DOORS;
230
231     if (rd_byte() != 0)
232         player_ptr->pet_extra_flags |= PF_PICKUP_ITEMS;
233
234     if (h_older_than(0, 0, 4))
235         player_ptr->pet_extra_flags |= PF_TELEPORT;
236     else {
237         if (rd_byte() != 0)
238             player_ptr->pet_extra_flags |= PF_TELEPORT;
239     }
240
241     if (h_older_than(0, 0, 7))
242         player_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
243     else {
244         if (rd_byte() != 0)
245             player_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
246     }
247
248     if (h_older_than(0, 0, 8))
249         player_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
250     else {
251         if (rd_byte() != 0)
252             player_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
253     }
254
255     if (h_older_than(0, 0, 8))
256         return;
257
258     if (rd_byte() != 0)
259         player_ptr->pet_extra_flags |= PF_BALL_SPELL;
260 }