OSDN Git Service

[Fix] モンスターが暗黒免疫を学習しない
[hengbandforosx/hengbandosx.git] / src / mspell / high-resistance-checker.cpp
1 #include "mspell/high-resistance-checker.h"
2 #include "monster-race/race-ability-flags.h"
3 #include "monster/smart-learn-types.h"
4 #include "mspell/smart-mspell-util.h"
5 #include "player-base/player-race.h"
6 #include "player/player-status-flags.h"
7 #include "system/player-type-definition.h"
8 #include "util/bit-flags-calculator.h"
9
10 void add_cheat_remove_flags_others(PlayerType *player_ptr, msr_type *msr_ptr)
11 {
12     if (has_resist_neth(player_ptr)) {
13         msr_ptr->smart.set(MonsterSmartLearnType::RES_NETH);
14     }
15
16     if (has_resist_lite(player_ptr)) {
17         msr_ptr->smart.set(MonsterSmartLearnType::RES_LITE);
18     }
19
20     if (has_resist_dark(player_ptr)) {
21         msr_ptr->smart.set(MonsterSmartLearnType::RES_DARK);
22     }
23
24     if (has_resist_fear(player_ptr)) {
25         msr_ptr->smart.set(MonsterSmartLearnType::RES_FEAR);
26     }
27
28     if (has_resist_conf(player_ptr)) {
29         msr_ptr->smart.set(MonsterSmartLearnType::RES_CONF);
30     }
31
32     if (has_resist_chaos(player_ptr)) {
33         msr_ptr->smart.set(MonsterSmartLearnType::RES_CHAOS);
34     }
35
36     if (has_resist_disen(player_ptr)) {
37         msr_ptr->smart.set(MonsterSmartLearnType::RES_DISEN);
38     }
39
40     if (has_resist_blind(player_ptr)) {
41         msr_ptr->smart.set(MonsterSmartLearnType::RES_BLIND);
42     }
43
44     if (has_resist_nexus(player_ptr)) {
45         msr_ptr->smart.set(MonsterSmartLearnType::RES_NEXUS);
46     }
47
48     if (has_resist_sound(player_ptr)) {
49         msr_ptr->smart.set(MonsterSmartLearnType::RES_SOUND);
50     }
51
52     if (has_resist_shard(player_ptr)) {
53         msr_ptr->smart.set(MonsterSmartLearnType::RES_SHARD);
54     }
55
56     if (has_reflect(player_ptr)) {
57         msr_ptr->smart.set(MonsterSmartLearnType::IMM_REFLECT);
58     }
59
60     if (player_ptr->free_act) {
61         msr_ptr->smart.set(MonsterSmartLearnType::IMM_FREE);
62     }
63
64     if (!player_ptr->msp) {
65         msr_ptr->smart.set(MonsterSmartLearnType::IMM_MANA);
66     }
67 }
68
69 static void check_nether_resistance(PlayerType *player_ptr, msr_type *msr_ptr)
70 {
71     if (msr_ptr->smart.has_not(MonsterSmartLearnType::RES_NETH)) {
72         return;
73     }
74
75     if (PlayerRace(player_ptr).equals(PlayerRaceType::SPECTRE)) {
76         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_NETH);
77         msr_ptr->ability_flags.reset(MonsterAbilityType::BA_NETH);
78         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_NETH);
79         return;
80     }
81
82     if (int_outof(msr_ptr->r_ptr, 20)) {
83         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_NETH);
84     }
85
86     if (int_outof(msr_ptr->r_ptr, 50)) {
87         msr_ptr->ability_flags.reset(MonsterAbilityType::BA_NETH);
88     }
89
90     if (int_outof(msr_ptr->r_ptr, 50)) {
91         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_NETH);
92     }
93 }
94
95 static void check_lite_resistance(msr_type *msr_ptr)
96 {
97     if (msr_ptr->smart.has_not(MonsterSmartLearnType::RES_LITE)) {
98         return;
99     }
100
101     if (int_outof(msr_ptr->r_ptr, 50)) {
102         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_LITE);
103     }
104
105     if (int_outof(msr_ptr->r_ptr, 50)) {
106         msr_ptr->ability_flags.reset(MonsterAbilityType::BA_LITE);
107     }
108 }
109
110 static void check_dark_resistance(PlayerType *player_ptr, msr_type *msr_ptr)
111 {
112     if (msr_ptr->smart.has_not(MonsterSmartLearnType::RES_DARK)) {
113         return;
114     }
115
116     if (has_immune_dark(player_ptr)) {
117         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_DARK);
118         msr_ptr->ability_flags.reset(MonsterAbilityType::BA_DARK);
119         return;
120     }
121
122     if (int_outof(msr_ptr->r_ptr, 50)) {
123         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_DARK);
124     }
125
126     if (int_outof(msr_ptr->r_ptr, 50)) {
127         msr_ptr->ability_flags.reset(MonsterAbilityType::BA_DARK);
128     }
129 }
130
131 static void check_conf_resistance(msr_type *msr_ptr)
132 {
133     if (msr_ptr->smart.has_not(MonsterSmartLearnType::RES_CONF)) {
134         return;
135     }
136
137     msr_ptr->ability_flags.reset(MonsterAbilityType::CONF);
138     if (int_outof(msr_ptr->r_ptr, 50)) {
139         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_CONF);
140     }
141 }
142
143 static void check_chaos_resistance(msr_type *msr_ptr)
144 {
145     if (msr_ptr->smart.has_not(MonsterSmartLearnType::RES_CHAOS)) {
146         return;
147     }
148
149     if (int_outof(msr_ptr->r_ptr, 20)) {
150         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_CHAO);
151     }
152
153     if (int_outof(msr_ptr->r_ptr, 50)) {
154         msr_ptr->ability_flags.reset(MonsterAbilityType::BA_CHAO);
155     }
156 }
157
158 static void check_nexus_resistance(msr_type *msr_ptr)
159 {
160     if (msr_ptr->smart.has_not(MonsterSmartLearnType::RES_NEXUS)) {
161         return;
162     }
163
164     if (int_outof(msr_ptr->r_ptr, 50)) {
165         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_NEXU);
166     }
167
168     msr_ptr->ability_flags.reset(MonsterAbilityType::TELE_LEVEL);
169 }
170
171 static void check_reflection(msr_type *msr_ptr)
172 {
173     if (msr_ptr->smart.has_not(MonsterSmartLearnType::IMM_REFLECT)) {
174         return;
175     }
176
177     if (int_outof(msr_ptr->r_ptr, 150)) {
178         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_COLD);
179     }
180
181     if (int_outof(msr_ptr->r_ptr, 150)) {
182         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_FIRE);
183     }
184
185     if (int_outof(msr_ptr->r_ptr, 150)) {
186         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_ACID);
187     }
188
189     if (int_outof(msr_ptr->r_ptr, 150)) {
190         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_ELEC);
191     }
192
193     if (int_outof(msr_ptr->r_ptr, 150)) {
194         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_NETH);
195     }
196
197     if (int_outof(msr_ptr->r_ptr, 150)) {
198         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_WATE);
199     }
200
201     if (int_outof(msr_ptr->r_ptr, 150)) {
202         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_MANA);
203     }
204
205     if (int_outof(msr_ptr->r_ptr, 150)) {
206         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_PLAS);
207     }
208
209     if (int_outof(msr_ptr->r_ptr, 150)) {
210         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_ICEE);
211     }
212
213     if (int_outof(msr_ptr->r_ptr, 150)) {
214         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_VOID);
215     }
216
217     if (int_outof(msr_ptr->r_ptr, 150)) {
218         msr_ptr->ability_flags.reset(MonsterAbilityType::BO_ABYSS);
219     }
220
221     if (int_outof(msr_ptr->r_ptr, 150)) {
222         msr_ptr->ability_flags.reset(MonsterAbilityType::MISSILE);
223     }
224 }
225
226 void check_high_resistances(PlayerType *player_ptr, msr_type *msr_ptr)
227 {
228     check_nether_resistance(player_ptr, msr_ptr);
229     check_lite_resistance(msr_ptr);
230     check_dark_resistance(player_ptr, msr_ptr);
231     if (msr_ptr->smart.has(MonsterSmartLearnType::RES_FEAR)) {
232         msr_ptr->ability_flags.reset(MonsterAbilityType::SCARE);
233     }
234
235     check_conf_resistance(msr_ptr);
236     check_chaos_resistance(msr_ptr);
237     if (msr_ptr->smart.has(MonsterSmartLearnType::RES_DISEN) && int_outof(msr_ptr->r_ptr, 40)) {
238         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_DISE);
239     }
240
241     if (msr_ptr->smart.has(MonsterSmartLearnType::RES_BLIND)) {
242         msr_ptr->ability_flags.reset(MonsterAbilityType::BLIND);
243     }
244
245     check_nexus_resistance(msr_ptr);
246     if (msr_ptr->smart.has(MonsterSmartLearnType::RES_SOUND) && int_outof(msr_ptr->r_ptr, 50)) {
247         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_SOUN);
248     }
249
250     if (msr_ptr->smart.has(MonsterSmartLearnType::RES_SHARD) && int_outof(msr_ptr->r_ptr, 40)) {
251         msr_ptr->ability_flags.reset(MonsterAbilityType::BR_SHAR);
252     }
253
254     check_reflection(msr_ptr);
255     if (msr_ptr->smart.has(MonsterSmartLearnType::IMM_FREE)) {
256         msr_ptr->ability_flags.reset(MonsterAbilityType::HOLD);
257         msr_ptr->ability_flags.reset(MonsterAbilityType::SLOW);
258     }
259
260     if (msr_ptr->smart.has(MonsterSmartLearnType::IMM_MANA)) {
261         msr_ptr->ability_flags.reset(MonsterAbilityType::DRAIN_MANA);
262     }
263 }