OSDN Git Service

Merge remote-tracking branch 'remotes/origin/For2.2.2-Fix-Hourier' into For2.2.2...
[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
9 void add_cheat_remove_flags_others(player_type *target_ptr, msr_type *msr_ptr)
10 {
11     if (target_ptr->resist_neth)
12         msr_ptr->smart |= SM_RES_NETH;
13
14     if (target_ptr->resist_lite)
15         msr_ptr->smart |= SM_RES_LITE;
16
17     if (target_ptr->resist_dark)
18         msr_ptr->smart |= SM_RES_DARK;
19
20     if (target_ptr->resist_fear)
21         msr_ptr->smart |= SM_RES_FEAR;
22
23     if (target_ptr->resist_conf)
24         msr_ptr->smart |= SM_RES_CONF;
25
26     if (target_ptr->resist_chaos)
27         msr_ptr->smart |= SM_RES_CHAOS;
28
29     if (target_ptr->resist_disen)
30         msr_ptr->smart |= SM_RES_DISEN;
31
32     if (target_ptr->resist_blind)
33         msr_ptr->smart |= SM_RES_BLIND;
34
35     if (target_ptr->resist_nexus)
36         msr_ptr->smart |= SM_RES_NEXUS;
37
38     if (target_ptr->resist_sound)
39         msr_ptr->smart |= SM_RES_SOUND;
40
41     if (target_ptr->resist_shard)
42         msr_ptr->smart |= SM_RES_SHARD;
43
44     if (target_ptr->reflect)
45         msr_ptr->smart |= SM_IMM_REFLECT;
46
47     if (target_ptr->free_act)
48         msr_ptr->smart |= SM_IMM_FREE;
49
50     if (!target_ptr->msp)
51         msr_ptr->smart |= SM_IMM_MANA;
52 }
53
54 static void check_nether_resistance(player_type *target_ptr, msr_type *msr_ptr)
55 {
56     if ((msr_ptr->smart & SM_RES_NETH) == 0)
57         return;
58
59     if (is_specific_player_race(target_ptr, RACE_SPECTRE)) {
60         msr_ptr->f4 &= ~(RF4_BR_NETH);
61         msr_ptr->f5 &= ~(RF5_BA_NETH);
62         msr_ptr->f5 &= ~(RF5_BO_NETH);
63         return;
64     }
65
66     if (int_outof(msr_ptr->r_ptr, 20))
67         msr_ptr->f4 &= ~(RF4_BR_NETH);
68
69     if (int_outof(msr_ptr->r_ptr, 50))
70         msr_ptr->f5 &= ~(RF5_BA_NETH);
71
72     if (int_outof(msr_ptr->r_ptr, 50))
73         msr_ptr->f5 &= ~(RF5_BO_NETH);
74 }
75
76 static void check_lite_resistance(msr_type *msr_ptr)
77 {
78     if ((msr_ptr->smart & SM_RES_LITE) == 0)
79         return;
80
81     if (int_outof(msr_ptr->r_ptr, 50))
82         msr_ptr->f4 &= ~(RF4_BR_LITE);
83
84     if (int_outof(msr_ptr->r_ptr, 50))
85         msr_ptr->f5 &= ~(RF5_BA_LITE);
86 }
87
88 static void check_dark_resistance(player_type *target_ptr, msr_type *msr_ptr)
89 {
90     if ((msr_ptr->smart & SM_RES_DARK) == 0)
91         return;
92
93     if (is_specific_player_race(target_ptr, RACE_VAMPIRE)) {
94         msr_ptr->f4 &= ~(RF4_BR_DARK);
95         msr_ptr->f5 &= ~(RF5_BA_DARK);
96         return;
97     }
98
99     if (int_outof(msr_ptr->r_ptr, 50))
100         msr_ptr->f4 &= ~(RF4_BR_DARK);
101
102     if (int_outof(msr_ptr->r_ptr, 50))
103         msr_ptr->f5 &= ~(RF5_BA_DARK);
104 }
105
106 static void check_conf_resistance(msr_type *msr_ptr)
107 {
108     if ((msr_ptr->smart & SM_RES_CONF) == 0)
109         return;
110
111     msr_ptr->f5 &= ~(RF5_CONF);
112     if (int_outof(msr_ptr->r_ptr, 50))
113         msr_ptr->f4 &= ~(RF4_BR_CONF);
114 }
115
116 static void check_chaos_resistance(msr_type *msr_ptr)
117 {
118     if ((msr_ptr->smart & SM_RES_CHAOS) == 0)
119         return;
120
121     if (int_outof(msr_ptr->r_ptr, 20))
122         msr_ptr->f4 &= ~(RF4_BR_CHAO);
123
124     if (int_outof(msr_ptr->r_ptr, 50))
125         msr_ptr->f4 &= ~(RF4_BA_CHAO);
126 }
127
128 static void check_nexus_resistance(msr_type *msr_ptr)
129 {
130     if ((msr_ptr->smart & SM_RES_NEXUS) == 0)
131         return;
132
133     if (int_outof(msr_ptr->r_ptr, 50))
134         msr_ptr->f4 &= ~(RF4_BR_NEXU);
135
136     msr_ptr->f6 &= ~(RF6_TELE_LEVEL);
137 }
138
139 static void check_reflection(msr_type *msr_ptr)
140 {
141     if ((msr_ptr->smart & SM_IMM_REFLECT) == 0)
142         return;
143
144     if (int_outof(msr_ptr->r_ptr, 150))
145         msr_ptr->f5 &= ~(RF5_BO_COLD);
146
147     if (int_outof(msr_ptr->r_ptr, 150))
148         msr_ptr->f5 &= ~(RF5_BO_FIRE);
149
150     if (int_outof(msr_ptr->r_ptr, 150))
151         msr_ptr->f5 &= ~(RF5_BO_ACID);
152
153     if (int_outof(msr_ptr->r_ptr, 150))
154         msr_ptr->f5 &= ~(RF5_BO_ELEC);
155
156     if (int_outof(msr_ptr->r_ptr, 150))
157         msr_ptr->f5 &= ~(RF5_BO_NETH);
158
159     if (int_outof(msr_ptr->r_ptr, 150))
160         msr_ptr->f5 &= ~(RF5_BO_WATE);
161
162     if (int_outof(msr_ptr->r_ptr, 150))
163         msr_ptr->f5 &= ~(RF5_BO_MANA);
164
165     if (int_outof(msr_ptr->r_ptr, 150))
166         msr_ptr->f5 &= ~(RF5_BO_PLAS);
167
168     if (int_outof(msr_ptr->r_ptr, 150))
169         msr_ptr->f5 &= ~(RF5_BO_ICEE);
170
171     if (int_outof(msr_ptr->r_ptr, 150))
172         msr_ptr->f5 &= ~(RF5_MISSILE);
173 }
174
175 void check_high_resistances(player_type *target_ptr, msr_type *msr_ptr)
176 {
177     check_nether_resistance(target_ptr, msr_ptr);
178     check_lite_resistance(msr_ptr);
179     check_dark_resistance(target_ptr, msr_ptr);
180     if (msr_ptr->smart & SM_RES_FEAR)
181         msr_ptr->f5 &= ~(RF5_SCARE);
182
183     check_conf_resistance(msr_ptr);
184     check_chaos_resistance(msr_ptr);
185     if (((msr_ptr->smart & SM_RES_DISEN) != 0) && int_outof(msr_ptr->r_ptr, 40))
186         msr_ptr->f4 &= ~(RF4_BR_DISE);
187
188     if (msr_ptr->smart & SM_RES_BLIND)
189         msr_ptr->f5 &= ~(RF5_BLIND);
190
191     check_nexus_resistance(msr_ptr);
192     if (((msr_ptr->smart & SM_RES_SOUND) != 0) && int_outof(msr_ptr->r_ptr, 50))
193         msr_ptr->f4 &= ~(RF4_BR_SOUN);
194
195     if (((msr_ptr->smart & SM_RES_SHARD) != 0) && int_outof(msr_ptr->r_ptr, 40))
196         msr_ptr->f4 &= ~(RF4_BR_SHAR);
197
198     check_reflection(msr_ptr);
199     if (msr_ptr->smart & SM_IMM_FREE) {
200         msr_ptr->f5 &= ~(RF5_HOLD);
201         msr_ptr->f5 &= ~(RF5_SLOW);
202     }
203
204     if (msr_ptr->smart & SM_IMM_MANA)
205         msr_ptr->f5 &= ~(RF5_DRAIN_MANA);
206 }