OSDN Git Service

v3.0.0 Alpha5 OSDN最終版
[hengband/hengband.git] / src / mspell / element-resistance-checker.c
1 #include "mspell/element-resistance-checker.h"
2 #include "game-option/birth-options.h"
3 #include "monster-race/race-flags-ability1.h"
4 #include "monster-race/race-flags4.h"
5 #include "monster/smart-learn-types.h"
6 #include "mspell/smart-mspell-util.h"
7 #include "status/element-resistance.h"
8 #include "player/player-status-flags.h"
9
10 void add_cheat_remove_flags_element(player_type *target_ptr, msr_type *msr_ptr)
11 {
12     if (has_resist_acid(target_ptr))
13         msr_ptr->smart |= SM_RES_ACID;
14
15     if (is_oppose_acid(target_ptr))
16         msr_ptr->smart |= SM_OPP_ACID;
17
18     if (has_immune_acid(target_ptr))
19         msr_ptr->smart |= SM_IMM_ACID;
20
21     if (has_resist_elec(target_ptr))
22         msr_ptr->smart |= SM_RES_ELEC;
23
24     if (is_oppose_elec(target_ptr))
25         msr_ptr->smart |= SM_OPP_ELEC;
26
27     if (has_immune_elec(target_ptr))
28         msr_ptr->smart |= SM_IMM_ELEC;
29
30     if (has_resist_fire(target_ptr))
31         msr_ptr->smart |= SM_RES_FIRE;
32
33     if (is_oppose_fire(target_ptr))
34         msr_ptr->smart |= SM_OPP_FIRE;
35
36     if (has_immune_fire(target_ptr))
37         msr_ptr->smart |= SM_IMM_FIRE;
38
39     if (has_resist_cold(target_ptr))
40         msr_ptr->smart |= SM_RES_COLD;
41
42     if (is_oppose_cold(target_ptr))
43         msr_ptr->smart |= SM_OPP_COLD;
44
45     if (has_immune_cold(target_ptr))
46         msr_ptr->smart |= SM_IMM_COLD;
47
48     if (has_resist_pois(target_ptr))
49         msr_ptr->smart |= SM_RES_POIS;
50
51     if (is_oppose_pois(target_ptr))
52         msr_ptr->smart |= SM_OPP_POIS;
53 }
54
55 static void check_acid_resistance(msr_type *msr_ptr)
56 {
57     if (msr_ptr->smart & SM_IMM_ACID) {
58         msr_ptr->f4 &= ~(RF4_BR_ACID);
59         msr_ptr->f5 &= ~(RF5_BA_ACID);
60         msr_ptr->f5 &= ~(RF5_BO_ACID);
61         return;
62     }
63
64     if ((msr_ptr->smart & SM_OPP_ACID) && (msr_ptr->smart & SM_RES_ACID)) {
65         if (int_outof(msr_ptr->r_ptr, 80))
66             msr_ptr->f4 &= ~(RF4_BR_ACID);
67
68         if (int_outof(msr_ptr->r_ptr, 80))
69             msr_ptr->f5 &= ~(RF5_BA_ACID);
70
71         if (int_outof(msr_ptr->r_ptr, 80))
72             msr_ptr->f5 &= ~(RF5_BO_ACID);
73
74         return;
75     }
76
77     if ((msr_ptr->smart & SM_OPP_ACID) || (msr_ptr->smart & SM_RES_ACID)) {
78         if (int_outof(msr_ptr->r_ptr, 30))
79             msr_ptr->f4 &= ~(RF4_BR_ACID);
80
81         if (int_outof(msr_ptr->r_ptr, 30))
82             msr_ptr->f5 &= ~(RF5_BA_ACID);
83
84         if (int_outof(msr_ptr->r_ptr, 30))
85             msr_ptr->f5 &= ~(RF5_BO_ACID);
86     }
87 }
88
89 static void check_elec_resistance(msr_type *msr_ptr)
90 {
91     if (msr_ptr->smart & SM_IMM_ELEC) {
92         msr_ptr->f4 &= ~(RF4_BR_ELEC);
93         msr_ptr->f5 &= ~(RF5_BA_ELEC);
94         msr_ptr->f5 &= ~(RF5_BO_ELEC);
95         return;
96     }
97
98     if ((msr_ptr->smart & SM_OPP_ELEC) && (msr_ptr->smart & SM_RES_ELEC)) {
99         if (int_outof(msr_ptr->r_ptr, 80))
100             msr_ptr->f4 &= ~(RF4_BR_ELEC);
101
102         if (int_outof(msr_ptr->r_ptr, 80))
103             msr_ptr->f5 &= ~(RF5_BA_ELEC);
104
105         if (int_outof(msr_ptr->r_ptr, 80))
106             msr_ptr->f5 &= ~(RF5_BO_ELEC);
107
108         return;
109     }
110
111     if ((msr_ptr->smart & SM_OPP_ELEC) || (msr_ptr->smart & SM_RES_ELEC)) {
112         if (int_outof(msr_ptr->r_ptr, 30))
113             msr_ptr->f4 &= ~(RF4_BR_ELEC);
114
115         if (int_outof(msr_ptr->r_ptr, 30))
116             msr_ptr->f5 &= ~(RF5_BA_ELEC);
117
118         if (int_outof(msr_ptr->r_ptr, 30))
119             msr_ptr->f5 &= ~(RF5_BO_ELEC);
120     }
121 }
122
123 static void check_fire_resistance(msr_type *msr_ptr)
124 {
125     if (msr_ptr->smart & SM_IMM_FIRE) {
126         msr_ptr->f4 &= ~(RF4_BR_FIRE);
127         msr_ptr->f5 &= ~(RF5_BA_FIRE);
128         msr_ptr->f5 &= ~(RF5_BO_FIRE);
129         return;
130     }
131
132     if ((msr_ptr->smart & SM_OPP_FIRE) && (msr_ptr->smart & SM_RES_FIRE)) {
133         if (int_outof(msr_ptr->r_ptr, 80))
134             msr_ptr->f4 &= ~(RF4_BR_FIRE);
135
136         if (int_outof(msr_ptr->r_ptr, 80))
137             msr_ptr->f5 &= ~(RF5_BA_FIRE);
138
139         if (int_outof(msr_ptr->r_ptr, 80))
140             msr_ptr->f5 &= ~(RF5_BO_FIRE);
141
142         return;
143     }
144
145     if ((msr_ptr->smart & SM_OPP_FIRE) || (msr_ptr->smart & SM_RES_FIRE)) {
146         if (int_outof(msr_ptr->r_ptr, 30))
147             msr_ptr->f4 &= ~(RF4_BR_FIRE);
148
149         if (int_outof(msr_ptr->r_ptr, 30))
150             msr_ptr->f5 &= ~(RF5_BA_FIRE);
151
152         if (int_outof(msr_ptr->r_ptr, 30))
153             msr_ptr->f5 &= ~(RF5_BO_FIRE);
154     }
155 }
156
157 static void check_cold_resistance(msr_type *msr_ptr)
158 {
159     if (msr_ptr->smart & (SM_IMM_COLD)) {
160         msr_ptr->f4 &= ~(RF4_BR_COLD);
161         msr_ptr->f5 &= ~(RF5_BA_COLD);
162         msr_ptr->f5 &= ~(RF5_BO_COLD);
163         msr_ptr->f5 &= ~(RF5_BO_ICEE);
164         return;
165     }
166
167     if ((msr_ptr->smart & SM_OPP_COLD) && (msr_ptr->smart & SM_RES_COLD)) {
168         if (int_outof(msr_ptr->r_ptr, 80))
169             msr_ptr->f4 &= ~(RF4_BR_COLD);
170
171         if (int_outof(msr_ptr->r_ptr, 80))
172             msr_ptr->f5 &= ~(RF5_BA_COLD);
173
174         if (int_outof(msr_ptr->r_ptr, 80))
175             msr_ptr->f5 &= ~(RF5_BO_COLD);
176
177         if (int_outof(msr_ptr->r_ptr, 80))
178             msr_ptr->f5 &= ~(RF5_BO_ICEE);
179
180         return;
181     }
182
183     if ((msr_ptr->smart & SM_OPP_COLD) || (msr_ptr->smart & SM_RES_COLD)) {
184         if (int_outof(msr_ptr->r_ptr, 30))
185             msr_ptr->f4 &= ~(RF4_BR_COLD);
186
187         if (int_outof(msr_ptr->r_ptr, 30))
188             msr_ptr->f5 &= ~(RF5_BA_COLD);
189
190         if (int_outof(msr_ptr->r_ptr, 30))
191             msr_ptr->f5 &= ~(RF5_BO_COLD);
192
193         if (int_outof(msr_ptr->r_ptr, 20))
194             msr_ptr->f5 &= ~(RF5_BO_ICEE);
195     }
196 }
197
198 static void check_pois_resistance(msr_type *msr_ptr)
199 {
200     if ((msr_ptr->smart & SM_OPP_POIS) && (msr_ptr->smart & SM_RES_POIS)) {
201         if (int_outof(msr_ptr->r_ptr, 80))
202             msr_ptr->f4 &= ~(RF4_BR_POIS);
203
204         if (int_outof(msr_ptr->r_ptr, 80))
205             msr_ptr->f5 &= ~(RF5_BA_POIS);
206
207         if (int_outof(msr_ptr->r_ptr, 60))
208             msr_ptr->f4 &= ~(RF4_BA_NUKE);
209
210         if (int_outof(msr_ptr->r_ptr, 60))
211             msr_ptr->f4 &= ~(RF4_BR_NUKE);
212
213         return;
214     }
215
216     if ((msr_ptr->smart & SM_OPP_POIS) || (msr_ptr->smart & SM_RES_POIS)) {
217         if (int_outof(msr_ptr->r_ptr, 30))
218             msr_ptr->f4 &= ~(RF4_BR_POIS);
219
220         if (int_outof(msr_ptr->r_ptr, 30))
221             msr_ptr->f5 &= ~(RF5_BA_POIS);
222     }
223 }
224
225 void check_element_resistance(msr_type *msr_ptr)
226 {
227     check_acid_resistance(msr_ptr);
228     check_elec_resistance(msr_ptr);
229     check_fire_resistance(msr_ptr);
230     check_cold_resistance(msr_ptr);
231     check_pois_resistance(msr_ptr);
232 }