OSDN Git Service

Reworded English message for a monk's successful MA_SLOW attack.
[hengband/hengband.git] / src / mspell / high-resistance-checker.c
1 #include "mspell/high-resistance-checker.h"
2 #include "monster-race/race-flags-ability1.h"
3 #include "monster-race/race-flags-ability2.h"
4 #include "monster-race/race-flags4.h"
5 #include "monster/smart-learn-types.h"
6 #include "mspell/smart-mspell-util.h"
7 #include "player/player-race.h"
8 #include "player/player-status-flags.h"
9
10 void add_cheat_remove_flags_others(player_type *target_ptr, msr_type *msr_ptr)
11 {
12     if (has_resist_neth(target_ptr))
13         msr_ptr->smart |= SM_RES_NETH;
14
15     if (has_resist_lite(target_ptr))
16         msr_ptr->smart |= SM_RES_LITE;
17
18     if (has_resist_dark(target_ptr))
19         msr_ptr->smart |= SM_RES_DARK;
20
21     if (has_resist_fear(target_ptr))
22         msr_ptr->smart |= SM_RES_FEAR;
23
24     if (has_resist_conf(target_ptr))
25         msr_ptr->smart |= SM_RES_CONF;
26
27     if (has_resist_chaos(target_ptr))
28         msr_ptr->smart |= SM_RES_CHAOS;
29
30     if (has_resist_disen(target_ptr))
31         msr_ptr->smart |= SM_RES_DISEN;
32
33     if (has_resist_blind(target_ptr))
34         msr_ptr->smart |= SM_RES_BLIND;
35
36     if (has_resist_nexus(target_ptr))
37         msr_ptr->smart |= SM_RES_NEXUS;
38
39     if (has_resist_sound(target_ptr))
40         msr_ptr->smart |= SM_RES_SOUND;
41
42     if (has_resist_shard(target_ptr))
43         msr_ptr->smart |= SM_RES_SHARD;
44
45     if (has_reflect(target_ptr))
46         msr_ptr->smart |= SM_IMM_REFLECT;
47
48     if (target_ptr->free_act)
49         msr_ptr->smart |= SM_IMM_FREE;
50
51     if (!target_ptr->msp)
52         msr_ptr->smart |= SM_IMM_MANA;
53 }
54
55 static void check_nether_resistance(player_type *target_ptr, msr_type *msr_ptr)
56 {
57     if ((msr_ptr->smart & SM_RES_NETH) == 0)
58         return;
59
60     if (is_specific_player_race(target_ptr, RACE_SPECTRE)) {
61         msr_ptr->f4 &= ~(RF4_BR_NETH);
62         msr_ptr->f5 &= ~(RF5_BA_NETH);
63         msr_ptr->f5 &= ~(RF5_BO_NETH);
64         return;
65     }
66
67     if (int_outof(msr_ptr->r_ptr, 20))
68         msr_ptr->f4 &= ~(RF4_BR_NETH);
69
70     if (int_outof(msr_ptr->r_ptr, 50))
71         msr_ptr->f5 &= ~(RF5_BA_NETH);
72
73     if (int_outof(msr_ptr->r_ptr, 50))
74         msr_ptr->f5 &= ~(RF5_BO_NETH);
75 }
76
77 static void check_lite_resistance(msr_type *msr_ptr)
78 {
79     if ((msr_ptr->smart & SM_RES_LITE) == 0)
80         return;
81
82     if (int_outof(msr_ptr->r_ptr, 50))
83         msr_ptr->f4 &= ~(RF4_BR_LITE);
84
85     if (int_outof(msr_ptr->r_ptr, 50))
86         msr_ptr->f5 &= ~(RF5_BA_LITE);
87 }
88
89 static void check_dark_resistance(player_type *target_ptr, msr_type *msr_ptr)
90 {
91     if ((msr_ptr->smart & SM_RES_DARK) == 0)
92         return;
93
94     if (is_specific_player_race(target_ptr, RACE_VAMPIRE)) {
95         msr_ptr->f4 &= ~(RF4_BR_DARK);
96         msr_ptr->f5 &= ~(RF5_BA_DARK);
97         return;
98     }
99
100     if (int_outof(msr_ptr->r_ptr, 50))
101         msr_ptr->f4 &= ~(RF4_BR_DARK);
102
103     if (int_outof(msr_ptr->r_ptr, 50))
104         msr_ptr->f5 &= ~(RF5_BA_DARK);
105 }
106
107 static void check_conf_resistance(msr_type *msr_ptr)
108 {
109     if ((msr_ptr->smart & SM_RES_CONF) == 0)
110         return;
111
112     msr_ptr->f5 &= ~(RF5_CONF);
113     if (int_outof(msr_ptr->r_ptr, 50))
114         msr_ptr->f4 &= ~(RF4_BR_CONF);
115 }
116
117 static void check_chaos_resistance(msr_type *msr_ptr)
118 {
119     if ((msr_ptr->smart & SM_RES_CHAOS) == 0)
120         return;
121
122     if (int_outof(msr_ptr->r_ptr, 20))
123         msr_ptr->f4 &= ~(RF4_BR_CHAO);
124
125     if (int_outof(msr_ptr->r_ptr, 50))
126         msr_ptr->f4 &= ~(RF4_BA_CHAO);
127 }
128
129 static void check_nexus_resistance(msr_type *msr_ptr)
130 {
131     if ((msr_ptr->smart & SM_RES_NEXUS) == 0)
132         return;
133
134     if (int_outof(msr_ptr->r_ptr, 50))
135         msr_ptr->f4 &= ~(RF4_BR_NEXU);
136
137     msr_ptr->f6 &= ~(RF6_TELE_LEVEL);
138 }
139
140 static void check_reflection(msr_type *msr_ptr)
141 {
142     if ((msr_ptr->smart & SM_IMM_REFLECT) == 0)
143         return;
144
145     if (int_outof(msr_ptr->r_ptr, 150))
146         msr_ptr->f5 &= ~(RF5_BO_COLD);
147
148     if (int_outof(msr_ptr->r_ptr, 150))
149         msr_ptr->f5 &= ~(RF5_BO_FIRE);
150
151     if (int_outof(msr_ptr->r_ptr, 150))
152         msr_ptr->f5 &= ~(RF5_BO_ACID);
153
154     if (int_outof(msr_ptr->r_ptr, 150))
155         msr_ptr->f5 &= ~(RF5_BO_ELEC);
156
157     if (int_outof(msr_ptr->r_ptr, 150))
158         msr_ptr->f5 &= ~(RF5_BO_NETH);
159
160     if (int_outof(msr_ptr->r_ptr, 150))
161         msr_ptr->f5 &= ~(RF5_BO_WATE);
162
163     if (int_outof(msr_ptr->r_ptr, 150))
164         msr_ptr->f5 &= ~(RF5_BO_MANA);
165
166     if (int_outof(msr_ptr->r_ptr, 150))
167         msr_ptr->f5 &= ~(RF5_BO_PLAS);
168
169     if (int_outof(msr_ptr->r_ptr, 150))
170         msr_ptr->f5 &= ~(RF5_BO_ICEE);
171
172     if (int_outof(msr_ptr->r_ptr, 150))
173         msr_ptr->f5 &= ~(RF5_MISSILE);
174 }
175
176 void check_high_resistances(player_type *target_ptr, msr_type *msr_ptr)
177 {
178     check_nether_resistance(target_ptr, msr_ptr);
179     check_lite_resistance(msr_ptr);
180     check_dark_resistance(target_ptr, msr_ptr);
181     if (msr_ptr->smart & SM_RES_FEAR)
182         msr_ptr->f5 &= ~(RF5_SCARE);
183
184     check_conf_resistance(msr_ptr);
185     check_chaos_resistance(msr_ptr);
186     if (((msr_ptr->smart & SM_RES_DISEN) != 0) && int_outof(msr_ptr->r_ptr, 40))
187         msr_ptr->f4 &= ~(RF4_BR_DISE);
188
189     if (msr_ptr->smart & SM_RES_BLIND)
190         msr_ptr->f5 &= ~(RF5_BLIND);
191
192     check_nexus_resistance(msr_ptr);
193     if (((msr_ptr->smart & SM_RES_SOUND) != 0) && int_outof(msr_ptr->r_ptr, 50))
194         msr_ptr->f4 &= ~(RF4_BR_SOUN);
195
196     if (((msr_ptr->smart & SM_RES_SHARD) != 0) && int_outof(msr_ptr->r_ptr, 40))
197         msr_ptr->f4 &= ~(RF4_BR_SHAR);
198
199     check_reflection(msr_ptr);
200     if (msr_ptr->smart & SM_IMM_FREE) {
201         msr_ptr->f5 &= ~(RF5_HOLD);
202         msr_ptr->f5 &= ~(RF5_SLOW);
203     }
204
205     if (msr_ptr->smart & SM_IMM_MANA)
206         msr_ptr->f5 &= ~(RF5_DRAIN_MANA);
207 }