OSDN Git Service

Merge pull request #765 from sikabane-works/release/3.0.0Alpha17
[hengbandforosx/hengbandosx.git] / src / load / load-zangband.cpp
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-info/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] & (0x00000001U << 4))
27         option_flag[5] &= ~(0x00000001U << 4);
28     else
29         option_flag[5] |= (0x00000001U << 4);
30
31     if (option_flag[2] & (0x00000001U << 5))
32         option_flag[2] &= ~(0x00000001U << 5);
33     else
34         option_flag[2] |= (0x00000001U << 5);
35
36     if (option_flag[4] & (0x00000001U << 5))
37         option_flag[4] &= ~(0x00000001U << 5);
38     else
39         option_flag[4] |= (0x00000001U << 5);
40
41     if (option_flag[5] & (0x00000001U << 0))
42         option_flag[5] &= ~(0x00000001U << 0);
43     else
44         option_flag[5] |= (0x00000001U << 0);
45
46     if (option_flag[5] & (0x00000001U << 12))
47         option_flag[5] &= ~(0x00000001U << 12);
48     else
49         option_flag[5] |= (0x00000001U << 12);
50
51     if (option_flag[1] & (0x00000001U << 0))
52         option_flag[1] &= ~(0x00000001U << 0);
53     else
54         option_flag[1] |= (0x00000001U << 0);
55
56     if (option_flag[1] & (0x00000001U << 18))
57         option_flag[1] &= ~(0x00000001U << 18);
58     else
59         option_flag[1] |= (0x00000001U << 18);
60
61     if (option_flag[1] & (0x00000001U << 19))
62         option_flag[1] &= ~(0x00000001U << 19);
63     else
64         option_flag[1] |= (0x00000001U << 19);
65
66     if (option_flag[5] & (0x00000001U << 3))
67         option_flag[1] &= ~(0x00000001U << 3);
68     else
69         option_flag[5] |= (0x00000001U << 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 void set_zangband_mimic(player_type *creature_ptr)
123 {
124     creature_ptr->tim_res_time = 0;
125     creature_ptr->mimic_form = 0;
126     creature_ptr->tim_mimic = 0;
127     creature_ptr->tim_sh_fire = 0;
128 }
129
130 void set_zangband_holy_aura(player_type *creature_ptr)
131 {
132     creature_ptr->tim_sh_holy = 0;
133     creature_ptr->tim_eyeeye = 0;
134 }
135
136 void set_zangband_reflection(player_type *creature_ptr)
137 {
138     creature_ptr->tim_reflect = 0;
139     creature_ptr->multishadow = 0;
140     creature_ptr->dustrobe = 0;
141 }
142
143 void rd_zangband_dungeon()
144 {
145     s16b tmp16s;
146     rd_s16b(&tmp16s);
147     max_dlv[DUNGEON_ANGBAND] = tmp16s;
148 }
149
150 void set_zangband_game_turns(player_type *creature_ptr)
151 {
152     creature_ptr->current_floor_ptr->generated_turn /= 2;
153     creature_ptr->feeling_turn /= 2;
154     current_world_ptr->game_turn /= 2;
155     current_world_ptr->dungeon_turn /= 2;
156 }
157
158 void set_zangband_gambling_monsters(int i)
159 {
160     s16b tmp16s;
161     rd_s16b(&tmp16s);
162     mon_odds[i] = tmp16s;
163 }
164
165 void set_zangband_special_attack(player_type *creature_ptr)
166 {
167     byte tmp8u;
168     rd_byte(&tmp8u);
169     if (tmp8u)
170         creature_ptr->special_attack = ATTACK_CONFUSE;
171
172     creature_ptr->ele_attack = 0;
173 }
174
175 void set_zangband_special_defense(player_type *creature_ptr)
176 {
177     creature_ptr->ele_immune = 0;
178     creature_ptr->special_defense = 0;
179 }
180
181 void set_zangband_action(player_type *creature_ptr)
182 {
183     byte tmp8u;
184     rd_byte(&tmp8u);
185     if (tmp8u)
186         creature_ptr->action = ACTION_LEARN;
187 }
188
189 void set_zangband_visited_towns(player_type *creature_ptr)
190 {
191     s32b tmp32s;
192     rd_s32b(&tmp32s);
193     creature_ptr->visit = 1L;
194 }
195
196 void set_zangband_quest(player_type *creature_ptr, quest_type *const q_ptr, int loading_quest_index, const QUEST_IDX old_inside_quest)
197 {
198     if (q_ptr->flags & QUEST_FLAG_PRESET) {
199         q_ptr->dungeon = 0;
200         return;
201     }
202
203     init_flags = INIT_ASSIGN;
204     creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)loading_quest_index;
205     parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
206     creature_ptr->current_floor_ptr->inside_quest = old_inside_quest;
207 }
208
209 void set_zangband_class(player_type *creature_ptr)
210 {
211     if (h_older_than(0, 2, 2) && (creature_ptr->pclass == CLASS_BEASTMASTER) && !creature_ptr->is_dead) {
212         creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
213         roll_hitdice(creature_ptr, SPOP_NONE);
214     }
215
216     if (h_older_than(0, 3, 2) && (creature_ptr->pclass == CLASS_ARCHER) && !creature_ptr->is_dead) {
217         creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
218         roll_hitdice(creature_ptr, SPOP_NONE);
219     }
220
221     if (h_older_than(0, 2, 6) && (creature_ptr->pclass == CLASS_SORCERER) && !creature_ptr->is_dead) {
222         creature_ptr->hitdie = rp_ptr->r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
223         roll_hitdice(creature_ptr, SPOP_NONE);
224     }
225
226     if (h_older_than(0, 4, 7) && (creature_ptr->pclass == CLASS_BLUE_MAGE) && !creature_ptr->is_dead) {
227         creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
228         roll_hitdice(creature_ptr, SPOP_NONE);
229     }
230 }
231
232 void set_zangband_learnt_spells(player_type *creature_ptr)
233 {
234     creature_ptr->learned_spells = 0;
235     for (int i = 0; i < 64; i++)
236         if ((i < 32) ? (creature_ptr->spell_learned1 & (1UL << i)) : (creature_ptr->spell_learned2 & (1UL << (i - 32))))
237             creature_ptr->learned_spells++;
238 }
239
240 void set_zangband_pet(player_type *creature_ptr)
241 {
242     creature_ptr->pet_extra_flags = 0;
243     byte tmp8u;
244     rd_byte(&tmp8u);
245     if (tmp8u)
246         creature_ptr->pet_extra_flags |= PF_OPEN_DOORS;
247
248     rd_byte(&tmp8u);
249     if (tmp8u)
250         creature_ptr->pet_extra_flags |= PF_PICKUP_ITEMS;
251
252     if (h_older_than(0, 0, 4))
253         creature_ptr->pet_extra_flags |= PF_TELEPORT;
254     else {
255         rd_byte(&tmp8u);
256         if (tmp8u)
257             creature_ptr->pet_extra_flags |= PF_TELEPORT;
258     }
259
260     if (h_older_than(0, 0, 7))
261         creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
262     else {
263         rd_byte(&tmp8u);
264         if (tmp8u)
265             creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
266     }
267
268     if (h_older_than(0, 0, 8))
269         creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
270     else {
271         rd_byte(&tmp8u);
272         if (tmp8u)
273             creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
274     }
275
276     if (h_older_than(0, 0, 8))
277         return;
278
279     rd_byte(&tmp8u);
280     if (tmp8u)
281         creature_ptr->pet_extra_flags |= PF_BALL_SPELL;
282 }