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"
9 void add_cheat_remove_flags_others(player_type *target_ptr, msr_type *msr_ptr)
11 if (target_ptr->resist_neth)
12 msr_ptr->smart |= SM_RES_NETH;
14 if (target_ptr->resist_lite)
15 msr_ptr->smart |= SM_RES_LITE;
17 if (target_ptr->resist_dark)
18 msr_ptr->smart |= SM_RES_DARK;
20 if (target_ptr->resist_fear)
21 msr_ptr->smart |= SM_RES_FEAR;
23 if (target_ptr->resist_conf)
24 msr_ptr->smart |= SM_RES_CONF;
26 if (target_ptr->resist_chaos)
27 msr_ptr->smart |= SM_RES_CHAOS;
29 if (target_ptr->resist_disen)
30 msr_ptr->smart |= SM_RES_DISEN;
32 if (target_ptr->resist_blind)
33 msr_ptr->smart |= SM_RES_BLIND;
35 if (target_ptr->resist_nexus)
36 msr_ptr->smart |= SM_RES_NEXUS;
38 if (target_ptr->resist_sound)
39 msr_ptr->smart |= SM_RES_SOUND;
41 if (target_ptr->resist_shard)
42 msr_ptr->smart |= SM_RES_SHARD;
44 if (target_ptr->reflect)
45 msr_ptr->smart |= SM_IMM_REFLECT;
47 if (target_ptr->free_act)
48 msr_ptr->smart |= SM_IMM_FREE;
51 msr_ptr->smart |= SM_IMM_MANA;
54 static void check_nether_resistance(player_type *target_ptr, msr_type *msr_ptr)
56 if ((msr_ptr->smart & SM_RES_NETH) == 0)
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);
66 if (int_outof(msr_ptr->r_ptr, 20))
67 msr_ptr->f4 &= ~(RF4_BR_NETH);
69 if (int_outof(msr_ptr->r_ptr, 50))
70 msr_ptr->f5 &= ~(RF5_BA_NETH);
72 if (int_outof(msr_ptr->r_ptr, 50))
73 msr_ptr->f5 &= ~(RF5_BO_NETH);
76 static void check_lite_resistance(msr_type *msr_ptr)
78 if ((msr_ptr->smart & SM_RES_LITE) == 0)
81 if (int_outof(msr_ptr->r_ptr, 50))
82 msr_ptr->f4 &= ~(RF4_BR_LITE);
84 if (int_outof(msr_ptr->r_ptr, 50))
85 msr_ptr->f5 &= ~(RF5_BA_LITE);
88 static void check_dark_resistance(player_type *target_ptr, msr_type *msr_ptr)
90 if ((msr_ptr->smart & SM_RES_DARK) == 0)
93 if (is_specific_player_race(target_ptr, RACE_VAMPIRE)) {
94 msr_ptr->f4 &= ~(RF4_BR_DARK);
95 msr_ptr->f5 &= ~(RF5_BA_DARK);
99 if (int_outof(msr_ptr->r_ptr, 50))
100 msr_ptr->f4 &= ~(RF4_BR_DARK);
102 if (int_outof(msr_ptr->r_ptr, 50))
103 msr_ptr->f5 &= ~(RF5_BA_DARK);
106 static void check_conf_resistance(msr_type *msr_ptr)
108 if ((msr_ptr->smart & SM_RES_CONF) == 0)
111 msr_ptr->f5 &= ~(RF5_CONF);
112 if (int_outof(msr_ptr->r_ptr, 50))
113 msr_ptr->f4 &= ~(RF4_BR_CONF);
116 static void check_chaos_resistance(msr_type *msr_ptr)
118 if ((msr_ptr->smart & SM_RES_CHAOS) == 0)
121 if (int_outof(msr_ptr->r_ptr, 20))
122 msr_ptr->f4 &= ~(RF4_BR_CHAO);
124 if (int_outof(msr_ptr->r_ptr, 50))
125 msr_ptr->f4 &= ~(RF4_BA_CHAO);
128 static void check_nexus_resistance(msr_type *msr_ptr)
130 if ((msr_ptr->smart & SM_RES_NEXUS) == 0)
133 if (int_outof(msr_ptr->r_ptr, 50))
134 msr_ptr->f4 &= ~(RF4_BR_NEXU);
136 msr_ptr->f6 &= ~(RF6_TELE_LEVEL);
139 static void check_reflection(msr_type *msr_ptr)
141 if ((msr_ptr->smart & SM_IMM_REFLECT) == 0)
144 if (int_outof(msr_ptr->r_ptr, 150))
145 msr_ptr->f5 &= ~(RF5_BO_COLD);
147 if (int_outof(msr_ptr->r_ptr, 150))
148 msr_ptr->f5 &= ~(RF5_BO_FIRE);
150 if (int_outof(msr_ptr->r_ptr, 150))
151 msr_ptr->f5 &= ~(RF5_BO_ACID);
153 if (int_outof(msr_ptr->r_ptr, 150))
154 msr_ptr->f5 &= ~(RF5_BO_ELEC);
156 if (int_outof(msr_ptr->r_ptr, 150))
157 msr_ptr->f5 &= ~(RF5_BO_NETH);
159 if (int_outof(msr_ptr->r_ptr, 150))
160 msr_ptr->f5 &= ~(RF5_BO_WATE);
162 if (int_outof(msr_ptr->r_ptr, 150))
163 msr_ptr->f5 &= ~(RF5_BO_MANA);
165 if (int_outof(msr_ptr->r_ptr, 150))
166 msr_ptr->f5 &= ~(RF5_BO_PLAS);
168 if (int_outof(msr_ptr->r_ptr, 150))
169 msr_ptr->f5 &= ~(RF5_BO_ICEE);
171 if (int_outof(msr_ptr->r_ptr, 150))
172 msr_ptr->f5 &= ~(RF5_MISSILE);
175 void check_high_resistances(player_type *target_ptr, msr_type *msr_ptr)
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);
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);
188 if (msr_ptr->smart & SM_RES_BLIND)
189 msr_ptr->f5 &= ~(RF5_BLIND);
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);
195 if (((msr_ptr->smart & SM_RES_SHARD) != 0) && int_outof(msr_ptr->r_ptr, 40))
196 msr_ptr->f4 &= ~(RF4_BR_SHAR);
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);
204 if (msr_ptr->smart & SM_IMM_MANA)
205 msr_ptr->f5 &= ~(RF5_DRAIN_MANA);