OSDN Git Service

1cca4b7c0f4666e426e5774f153f96d3f5eb5328
[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/race-info.h"
14 #include "player/attack-defense-types.h"
15 #include "player/patron.h"
16 #include "player/player-class.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 *creature_ptr)
76 {
77     if (creature_ptr->realm1 == 9)
78         creature_ptr->realm1 = REALM_MUSIC;
79
80     if (creature_ptr->realm2 == 9)
81         creature_ptr->realm2 = REALM_MUSIC;
82
83     if (creature_ptr->realm1 == 10)
84         creature_ptr->realm1 = REALM_HISSATSU;
85
86     if (creature_ptr->realm2 == 10)
87         creature_ptr->realm2 = REALM_HISSATSU;
88 }
89
90 void set_zangband_skill(player_type *creature_ptr)
91 {
92     if (creature_ptr->pclass != CLASS_BEASTMASTER)
93         creature_ptr->skill_exp[SKILL_RIDING] /= 2;
94
95     creature_ptr->skill_exp[SKILL_RIDING] = MIN(creature_ptr->skill_exp[SKILL_RIDING], s_info[creature_ptr->pclass].s_max[SKILL_RIDING]);
96 }
97
98 void set_zangband_spells(player_type *creature_ptr)
99 {
100     for (int i = 0; i < MAX_SPELLS; i++)
101         creature_ptr->magic_num1[i] = 0;
102
103     for (int i = 0; i < MAX_SPELLS; i++)
104         creature_ptr->magic_num2[i] = 0;
105 }
106
107 void set_zangband_race(player_type *creature_ptr)
108 {
109     creature_ptr->start_race = creature_ptr->prace;
110     creature_ptr->old_race1 = 0L;
111     creature_ptr->old_race2 = 0L;
112     creature_ptr->old_realm = 0;
113 }
114
115 void set_zangband_bounty_uniques(player_type *creature_ptr)
116 {
117     determine_bounty_uniques(creature_ptr);
118     for (int i = 0; i < MAX_BOUNTY; i++) {
119         /* Is this bounty unique already dead? */
120         if (!r_info[current_world_ptr->bounty_r_idx[i]].max_num)
121             current_world_ptr->bounty_r_idx[i] += 10000;
122     }
123 }
124
125 void set_zangband_mimic(player_type *creature_ptr)
126 {
127     creature_ptr->tim_res_time = 0;
128     creature_ptr->mimic_form = 0;
129     creature_ptr->tim_mimic = 0;
130     creature_ptr->tim_sh_fire = 0;
131 }
132
133 void set_zangband_holy_aura(player_type *creature_ptr)
134 {
135     creature_ptr->tim_sh_holy = 0;
136     creature_ptr->tim_eyeeye = 0;
137 }
138
139 void set_zangband_reflection(player_type *creature_ptr)
140 {
141     creature_ptr->tim_reflect = 0;
142     creature_ptr->multishadow = 0;
143     creature_ptr->dustrobe = 0;
144 }
145
146 void rd_zangband_dungeon()
147 {
148     int16_t tmp16s;
149     rd_s16b(&tmp16s);
150     max_dlv[DUNGEON_ANGBAND] = tmp16s;
151 }
152
153 void set_zangband_game_turns(player_type *creature_ptr)
154 {
155     creature_ptr->current_floor_ptr->generated_turn /= 2;
156     creature_ptr->feeling_turn /= 2;
157     current_world_ptr->game_turn /= 2;
158     current_world_ptr->dungeon_turn /= 2;
159 }
160
161 void set_zangband_gambling_monsters(int i)
162 {
163     int16_t tmp16s;
164     rd_s16b(&tmp16s);
165     mon_odds[i] = tmp16s;
166 }
167
168 void set_zangband_special_attack(player_type *creature_ptr)
169 {
170     byte tmp8u;
171     rd_byte(&tmp8u);
172     if (tmp8u)
173         creature_ptr->special_attack = ATTACK_CONFUSE;
174
175     creature_ptr->ele_attack = 0;
176 }
177
178 void set_zangband_special_defense(player_type *creature_ptr)
179 {
180     creature_ptr->ele_immune = 0;
181     creature_ptr->special_defense = 0;
182 }
183
184 void set_zangband_action(player_type *creature_ptr)
185 {
186     byte tmp8u;
187     rd_byte(&tmp8u);
188     if (tmp8u)
189         creature_ptr->action = ACTION_LEARN;
190 }
191
192 void set_zangband_visited_towns(player_type *creature_ptr)
193 {
194     int32_t tmp32s;
195     rd_s32b(&tmp32s);
196     creature_ptr->visit = 1L;
197 }
198
199 void set_zangband_quest(player_type *creature_ptr, quest_type *const q_ptr, int loading_quest_index, const QUEST_IDX old_inside_quest)
200 {
201     if (q_ptr->flags & QUEST_FLAG_PRESET) {
202         q_ptr->dungeon = 0;
203         return;
204     }
205
206     init_flags = INIT_ASSIGN;
207     creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)loading_quest_index;
208     parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
209     creature_ptr->current_floor_ptr->inside_quest = old_inside_quest;
210 }
211
212 void set_zangband_class(player_type *creature_ptr)
213 {
214     if (h_older_than(0, 2, 2) && (creature_ptr->pclass == CLASS_BEASTMASTER) && !creature_ptr->is_dead) {
215         creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
216         roll_hitdice(creature_ptr, SPOP_NONE);
217     }
218
219     if (h_older_than(0, 3, 2) && (creature_ptr->pclass == CLASS_ARCHER) && !creature_ptr->is_dead) {
220         creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
221         roll_hitdice(creature_ptr, SPOP_NONE);
222     }
223
224     if (h_older_than(0, 2, 6) && (creature_ptr->pclass == CLASS_SORCERER) && !creature_ptr->is_dead) {
225         creature_ptr->hitdie = rp_ptr->r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
226         roll_hitdice(creature_ptr, SPOP_NONE);
227     }
228
229     if (h_older_than(0, 4, 7) && (creature_ptr->pclass == CLASS_BLUE_MAGE) && !creature_ptr->is_dead) {
230         creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
231         roll_hitdice(creature_ptr, SPOP_NONE);
232     }
233 }
234
235 void set_zangband_learnt_spells(player_type *creature_ptr)
236 {
237     creature_ptr->learned_spells = 0;
238     for (int i = 0; i < 64; i++)
239         if ((i < 32) ? (creature_ptr->spell_learned1 & (1UL << i)) : (creature_ptr->spell_learned2 & (1UL << (i - 32))))
240             creature_ptr->learned_spells++;
241 }
242
243 void set_zangband_pet(player_type *creature_ptr)
244 {
245     creature_ptr->pet_extra_flags = 0;
246     byte tmp8u;
247     rd_byte(&tmp8u);
248     if (tmp8u)
249         creature_ptr->pet_extra_flags |= PF_OPEN_DOORS;
250
251     rd_byte(&tmp8u);
252     if (tmp8u)
253         creature_ptr->pet_extra_flags |= PF_PICKUP_ITEMS;
254
255     if (h_older_than(0, 0, 4))
256         creature_ptr->pet_extra_flags |= PF_TELEPORT;
257     else {
258         rd_byte(&tmp8u);
259         if (tmp8u)
260             creature_ptr->pet_extra_flags |= PF_TELEPORT;
261     }
262
263     if (h_older_than(0, 0, 7))
264         creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
265     else {
266         rd_byte(&tmp8u);
267         if (tmp8u)
268             creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
269     }
270
271     if (h_older_than(0, 0, 8))
272         creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
273     else {
274         rd_byte(&tmp8u);
275         if (tmp8u)
276             creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
277     }
278
279     if (h_older_than(0, 0, 8))
280         return;
281
282     rd_byte(&tmp8u);
283     if (tmp8u)
284         creature_ptr->pet_extra_flags |= PF_BALL_SPELL;
285 }