1 #include "mspell/improper-mspell-remover.h"
2 #include "game-option/birth-options.h"
3 #include "monster-race/monster-race.h"
4 #include "monster-race/race-flags-ability1.h"
5 #include "monster-race/race-flags-ability2.h"
6 #include "monster-race/race-flags2.h"
7 #include "monster-race/race-flags4.h"
8 #include "monster/smart-learn-types.h"
9 #include "player/player-race.h"
10 #include "status/element-resistance.h"
11 #include "system/floor-type-definition.h"
12 #include "system/monster-type-definition.h"
15 * @brief モンスターがプレイヤーの弱点をついた選択を取るかどうかの判定 /
16 * Internal probability routine
17 * @param r_ptr モンスター種族の構造体参照ポインタ
19 * @return 適した選択を取るならばTRUEを返す。
21 static bool int_outof(monster_race *r_ptr, PERCENTAGE prob)
23 if (!(r_ptr->flags2 & RF2_SMART))
26 return (randint0(100) < prob);
30 * @brief モンスターの魔法一覧から戦術的に適さない魔法を除外する /
31 * Remove the "bad" spells from a spell list
32 * @param m_idx モンスターの構造体参照ポインタ
33 * @param f4p モンスター魔法のフラグリスト1
34 * @param f5p モンスター魔法のフラグリスト2
35 * @param f6p モンスター魔法のフラグリスト3
38 void remove_bad_spells(MONSTER_IDX m_idx, player_type *target_ptr, u32b *f4p, u32b *f5p, u32b *f6p)
40 monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
41 monster_race *r_ptr = &r_info[m_ptr->r_idx];
46 if (r_ptr->flags2 & RF2_STUPID)
49 if (!smart_cheat && !smart_learn)
53 if (m_ptr->smart && (randint0(100) < 1))
54 m_ptr->smart &= SM_FRIENDLY | SM_PET | SM_CLONED;
60 if (target_ptr->resist_acid)
63 if (is_oppose_acid(target_ptr))
66 if (target_ptr->immune_acid)
69 if (target_ptr->resist_elec)
72 if (is_oppose_elec(target_ptr))
75 if (target_ptr->immune_elec)
78 if (target_ptr->resist_fire)
81 if (is_oppose_fire(target_ptr))
84 if (target_ptr->immune_fire)
87 if (target_ptr->resist_cold)
89 if (is_oppose_cold(target_ptr))
92 if (target_ptr->immune_cold)
95 if (target_ptr->resist_pois)
98 if (is_oppose_pois(target_ptr))
101 if (target_ptr->resist_neth)
102 smart |= SM_RES_NETH;
104 if (target_ptr->resist_lite)
105 smart |= SM_RES_LITE;
107 if (target_ptr->resist_dark)
108 smart |= SM_RES_DARK;
110 if (target_ptr->resist_fear)
111 smart |= SM_RES_FEAR;
113 if (target_ptr->resist_conf)
114 smart |= SM_RES_CONF;
116 if (target_ptr->resist_chaos)
117 smart |= SM_RES_CHAOS;
119 if (target_ptr->resist_disen)
120 smart |= SM_RES_DISEN;
122 if (target_ptr->resist_blind)
123 smart |= SM_RES_BLIND;
125 if (target_ptr->resist_nexus)
126 smart |= SM_RES_NEXUS;
128 if (target_ptr->resist_sound)
129 smart |= SM_RES_SOUND;
131 if (target_ptr->resist_shard)
132 smart |= SM_RES_SHARD;
134 if (target_ptr->reflect)
135 smart |= SM_IMM_REFLECT;
137 if (target_ptr->free_act)
138 smart |= SM_IMM_FREE;
140 if (!target_ptr->msp)
141 smart |= SM_IMM_MANA;
147 if (smart & SM_IMM_ACID) {
148 f4 &= ~(RF4_BR_ACID);
149 f5 &= ~(RF5_BA_ACID);
150 f5 &= ~(RF5_BO_ACID);
151 } else if ((smart & SM_OPP_ACID) && (smart & SM_RES_ACID)) {
152 if (int_outof(r_ptr, 80))
153 f4 &= ~(RF4_BR_ACID);
155 if (int_outof(r_ptr, 80))
156 f5 &= ~(RF5_BA_ACID);
158 if (int_outof(r_ptr, 80))
159 f5 &= ~(RF5_BO_ACID);
160 } else if ((smart & SM_OPP_ACID) || (smart & SM_RES_ACID)) {
161 if (int_outof(r_ptr, 30))
162 f4 &= ~(RF4_BR_ACID);
164 if (int_outof(r_ptr, 30))
165 f5 &= ~(RF5_BA_ACID);
167 if (int_outof(r_ptr, 30))
168 f5 &= ~(RF5_BO_ACID);
171 if (smart & SM_IMM_ELEC) {
172 f4 &= ~(RF4_BR_ELEC);
173 f5 &= ~(RF5_BA_ELEC);
174 f5 &= ~(RF5_BO_ELEC);
175 } else if ((smart & SM_OPP_ELEC) && (smart & SM_RES_ELEC)) {
176 if (int_outof(r_ptr, 80))
177 f4 &= ~(RF4_BR_ELEC);
179 if (int_outof(r_ptr, 80))
180 f5 &= ~(RF5_BA_ELEC);
182 if (int_outof(r_ptr, 80))
183 f5 &= ~(RF5_BO_ELEC);
184 } else if ((smart & SM_OPP_ELEC) || (smart & SM_RES_ELEC)) {
185 if (int_outof(r_ptr, 30))
186 f4 &= ~(RF4_BR_ELEC);
188 if (int_outof(r_ptr, 30))
189 f5 &= ~(RF5_BA_ELEC);
191 if (int_outof(r_ptr, 30))
192 f5 &= ~(RF5_BO_ELEC);
195 if (smart & (SM_IMM_FIRE)) {
196 f4 &= ~(RF4_BR_FIRE);
197 f5 &= ~(RF5_BA_FIRE);
198 f5 &= ~(RF5_BO_FIRE);
199 } else if ((smart & SM_OPP_FIRE) && (smart & SM_RES_FIRE)) {
200 if (int_outof(r_ptr, 80))
201 f4 &= ~(RF4_BR_FIRE);
203 if (int_outof(r_ptr, 80))
204 f5 &= ~(RF5_BA_FIRE);
206 if (int_outof(r_ptr, 80))
207 f5 &= ~(RF5_BO_FIRE);
208 } else if ((smart & SM_OPP_FIRE) || (smart & SM_RES_FIRE)) {
209 if (int_outof(r_ptr, 30))
210 f4 &= ~(RF4_BR_FIRE);
212 if (int_outof(r_ptr, 30))
213 f5 &= ~(RF5_BA_FIRE);
215 if (int_outof(r_ptr, 30))
216 f5 &= ~(RF5_BO_FIRE);
219 if (smart & (SM_IMM_COLD)) {
220 f4 &= ~(RF4_BR_COLD);
221 f5 &= ~(RF5_BA_COLD);
222 f5 &= ~(RF5_BO_COLD);
223 f5 &= ~(RF5_BO_ICEE);
224 } else if ((smart & SM_OPP_COLD) && (smart & SM_RES_COLD)) {
225 if (int_outof(r_ptr, 80))
226 f4 &= ~(RF4_BR_COLD);
228 if (int_outof(r_ptr, 80))
229 f5 &= ~(RF5_BA_COLD);
231 if (int_outof(r_ptr, 80))
232 f5 &= ~(RF5_BO_COLD);
234 if (int_outof(r_ptr, 80))
235 f5 &= ~(RF5_BO_ICEE);
236 } else if ((smart & SM_OPP_COLD) || (smart & SM_RES_COLD)) {
237 if (int_outof(r_ptr, 30))
238 f4 &= ~(RF4_BR_COLD);
240 if (int_outof(r_ptr, 30))
241 f5 &= ~(RF5_BA_COLD);
243 if (int_outof(r_ptr, 30))
244 f5 &= ~(RF5_BO_COLD);
246 if (int_outof(r_ptr, 20))
247 f5 &= ~(RF5_BO_ICEE);
250 if ((smart & SM_OPP_POIS) && (smart & SM_RES_POIS)) {
251 if (int_outof(r_ptr, 80))
252 f4 &= ~(RF4_BR_POIS);
254 if (int_outof(r_ptr, 80))
255 f5 &= ~(RF5_BA_POIS);
257 if (int_outof(r_ptr, 60))
258 f4 &= ~(RF4_BA_NUKE);
260 if (int_outof(r_ptr, 60))
261 f4 &= ~(RF4_BR_NUKE);
262 } else if ((smart & SM_OPP_POIS) || (smart & SM_RES_POIS)) {
263 if (int_outof(r_ptr, 30))
264 f4 &= ~(RF4_BR_POIS);
266 if (int_outof(r_ptr, 30))
267 f5 &= ~(RF5_BA_POIS);
270 if (smart & SM_RES_NETH) {
271 if (is_specific_player_race(target_ptr, RACE_SPECTRE)) {
272 f4 &= ~(RF4_BR_NETH);
273 f5 &= ~(RF5_BA_NETH);
274 f5 &= ~(RF5_BO_NETH);
276 if (int_outof(r_ptr, 20))
277 f4 &= ~(RF4_BR_NETH);
279 if (int_outof(r_ptr, 50))
280 f5 &= ~(RF5_BA_NETH);
282 if (int_outof(r_ptr, 50))
283 f5 &= ~(RF5_BO_NETH);
287 if (smart & SM_RES_LITE) {
288 if (int_outof(r_ptr, 50))
289 f4 &= ~(RF4_BR_LITE);
291 if (int_outof(r_ptr, 50))
292 f5 &= ~(RF5_BA_LITE);
295 if (smart & SM_RES_DARK) {
296 if (is_specific_player_race(target_ptr, RACE_VAMPIRE)) {
297 f4 &= ~(RF4_BR_DARK);
298 f5 &= ~(RF5_BA_DARK);
300 if (int_outof(r_ptr, 50))
301 f4 &= ~(RF4_BR_DARK);
303 if (int_outof(r_ptr, 50))
304 f5 &= ~(RF5_BA_DARK);
308 if (smart & SM_RES_FEAR) {
312 if (smart & SM_RES_CONF) {
314 if (int_outof(r_ptr, 50))
315 f4 &= ~(RF4_BR_CONF);
318 if (smart & SM_RES_CHAOS) {
319 if (int_outof(r_ptr, 20))
320 f4 &= ~(RF4_BR_CHAO);
322 if (int_outof(r_ptr, 50))
323 f4 &= ~(RF4_BA_CHAO);
326 if (((smart & SM_RES_DISEN) != 0) && int_outof(r_ptr, 40))
327 f4 &= ~(RF4_BR_DISE);
329 if (smart & SM_RES_BLIND)
332 if (smart & SM_RES_NEXUS) {
333 if (int_outof(r_ptr, 50))
334 f4 &= ~(RF4_BR_NEXU);
336 f6 &= ~(RF6_TELE_LEVEL);
339 if (((smart & SM_RES_SOUND) != 0) && int_outof(r_ptr, 50))
340 f4 &= ~(RF4_BR_SOUN);
342 if (((smart & SM_RES_SHARD) != 0) && int_outof(r_ptr, 40))
343 f4 &= ~(RF4_BR_SHAR);
345 if (smart & SM_IMM_REFLECT) {
346 if (int_outof(r_ptr, 150))
347 f5 &= ~(RF5_BO_COLD);
349 if (int_outof(r_ptr, 150))
350 f5 &= ~(RF5_BO_FIRE);
352 if (int_outof(r_ptr, 150))
353 f5 &= ~(RF5_BO_ACID);
355 if (int_outof(r_ptr, 150))
356 f5 &= ~(RF5_BO_ELEC);
358 if (int_outof(r_ptr, 150))
359 f5 &= ~(RF5_BO_NETH);
361 if (int_outof(r_ptr, 150))
362 f5 &= ~(RF5_BO_WATE);
364 if (int_outof(r_ptr, 150))
365 f5 &= ~(RF5_BO_MANA);
367 if (int_outof(r_ptr, 150))
368 f5 &= ~(RF5_BO_PLAS);
370 if (int_outof(r_ptr, 150))
371 f5 &= ~(RF5_BO_ICEE);
373 if (int_outof(r_ptr, 150))
374 f5 &= ~(RF5_MISSILE);
377 if (smart & SM_IMM_FREE) {
382 if (smart & SM_IMM_MANA)
383 f5 &= ~(RF5_DRAIN_MANA);