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"
10 void add_cheat_remove_flags_others(player_type *target_ptr, msr_type *msr_ptr)
12 if (has_resist_neth(target_ptr))
13 msr_ptr->smart |= SM_RES_NETH;
15 if (has_resist_lite(target_ptr))
16 msr_ptr->smart |= SM_RES_LITE;
18 if (has_resist_dark(target_ptr))
19 msr_ptr->smart |= SM_RES_DARK;
21 if (has_resist_fear(target_ptr))
22 msr_ptr->smart |= SM_RES_FEAR;
24 if (has_resist_conf(target_ptr))
25 msr_ptr->smart |= SM_RES_CONF;
27 if (has_resist_chaos(target_ptr))
28 msr_ptr->smart |= SM_RES_CHAOS;
30 if (has_resist_disen(target_ptr))
31 msr_ptr->smart |= SM_RES_DISEN;
33 if (has_resist_blind(target_ptr))
34 msr_ptr->smart |= SM_RES_BLIND;
36 if (has_resist_nexus(target_ptr))
37 msr_ptr->smart |= SM_RES_NEXUS;
39 if (has_resist_sound(target_ptr))
40 msr_ptr->smart |= SM_RES_SOUND;
42 if (has_resist_shard(target_ptr))
43 msr_ptr->smart |= SM_RES_SHARD;
45 if (has_reflect(target_ptr))
46 msr_ptr->smart |= SM_IMM_REFLECT;
48 if (target_ptr->free_act)
49 msr_ptr->smart |= SM_IMM_FREE;
52 msr_ptr->smart |= SM_IMM_MANA;
55 static void check_nether_resistance(player_type *target_ptr, msr_type *msr_ptr)
57 if ((msr_ptr->smart & SM_RES_NETH) == 0)
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);
67 if (int_outof(msr_ptr->r_ptr, 20))
68 msr_ptr->f4 &= ~(RF4_BR_NETH);
70 if (int_outof(msr_ptr->r_ptr, 50))
71 msr_ptr->f5 &= ~(RF5_BA_NETH);
73 if (int_outof(msr_ptr->r_ptr, 50))
74 msr_ptr->f5 &= ~(RF5_BO_NETH);
77 static void check_lite_resistance(msr_type *msr_ptr)
79 if ((msr_ptr->smart & SM_RES_LITE) == 0)
82 if (int_outof(msr_ptr->r_ptr, 50))
83 msr_ptr->f4 &= ~(RF4_BR_LITE);
85 if (int_outof(msr_ptr->r_ptr, 50))
86 msr_ptr->f5 &= ~(RF5_BA_LITE);
89 static void check_dark_resistance(player_type *target_ptr, msr_type *msr_ptr)
91 if ((msr_ptr->smart & SM_RES_DARK) == 0)
94 if (is_specific_player_race(target_ptr, RACE_VAMPIRE)) {
95 msr_ptr->f4 &= ~(RF4_BR_DARK);
96 msr_ptr->f5 &= ~(RF5_BA_DARK);
100 if (int_outof(msr_ptr->r_ptr, 50))
101 msr_ptr->f4 &= ~(RF4_BR_DARK);
103 if (int_outof(msr_ptr->r_ptr, 50))
104 msr_ptr->f5 &= ~(RF5_BA_DARK);
107 static void check_conf_resistance(msr_type *msr_ptr)
109 if ((msr_ptr->smart & SM_RES_CONF) == 0)
112 msr_ptr->f5 &= ~(RF5_CONF);
113 if (int_outof(msr_ptr->r_ptr, 50))
114 msr_ptr->f4 &= ~(RF4_BR_CONF);
117 static void check_chaos_resistance(msr_type *msr_ptr)
119 if ((msr_ptr->smart & SM_RES_CHAOS) == 0)
122 if (int_outof(msr_ptr->r_ptr, 20))
123 msr_ptr->f4 &= ~(RF4_BR_CHAO);
125 if (int_outof(msr_ptr->r_ptr, 50))
126 msr_ptr->f4 &= ~(RF4_BA_CHAO);
129 static void check_nexus_resistance(msr_type *msr_ptr)
131 if ((msr_ptr->smart & SM_RES_NEXUS) == 0)
134 if (int_outof(msr_ptr->r_ptr, 50))
135 msr_ptr->f4 &= ~(RF4_BR_NEXU);
137 msr_ptr->f6 &= ~(RF6_TELE_LEVEL);
140 static void check_reflection(msr_type *msr_ptr)
142 if ((msr_ptr->smart & SM_IMM_REFLECT) == 0)
145 if (int_outof(msr_ptr->r_ptr, 150))
146 msr_ptr->f5 &= ~(RF5_BO_COLD);
148 if (int_outof(msr_ptr->r_ptr, 150))
149 msr_ptr->f5 &= ~(RF5_BO_FIRE);
151 if (int_outof(msr_ptr->r_ptr, 150))
152 msr_ptr->f5 &= ~(RF5_BO_ACID);
154 if (int_outof(msr_ptr->r_ptr, 150))
155 msr_ptr->f5 &= ~(RF5_BO_ELEC);
157 if (int_outof(msr_ptr->r_ptr, 150))
158 msr_ptr->f5 &= ~(RF5_BO_NETH);
160 if (int_outof(msr_ptr->r_ptr, 150))
161 msr_ptr->f5 &= ~(RF5_BO_WATE);
163 if (int_outof(msr_ptr->r_ptr, 150))
164 msr_ptr->f5 &= ~(RF5_BO_MANA);
166 if (int_outof(msr_ptr->r_ptr, 150))
167 msr_ptr->f5 &= ~(RF5_BO_PLAS);
169 if (int_outof(msr_ptr->r_ptr, 150))
170 msr_ptr->f5 &= ~(RF5_BO_ICEE);
172 if (int_outof(msr_ptr->r_ptr, 150))
173 msr_ptr->f5 &= ~(RF5_MISSILE);
176 void check_high_resistances(player_type *target_ptr, msr_type *msr_ptr)
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);
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);
189 if (msr_ptr->smart & SM_RES_BLIND)
190 msr_ptr->f5 &= ~(RF5_BLIND);
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);
196 if (((msr_ptr->smart & SM_RES_SHARD) != 0) && int_outof(msr_ptr->r_ptr, 40))
197 msr_ptr->f4 &= ~(RF4_BR_SHAR);
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);
205 if (msr_ptr->smart & SM_IMM_MANA)
206 msr_ptr->f5 &= ~(RF5_DRAIN_MANA);