OSDN Git Service

[Refactor] #40734 Separated check_cold_blood() from update_monster()
[hengband/hengband.git] / src / monster / monster-update.c
1 /*!
2  * @brief モンスター情報のアップデート処理
3  * @date 2020/03/08
4  * @author Hourier
5  */
6
7 #include "monster/monster-update.h"
8 #include "core/disturbance.h"
9 #include "core/player-redraw-types.h"
10 #include "core/player-update-types.h"
11 #include "core/window-redrawer.h"
12 #include "dungeon/dungeon-flag-types.h"
13 #include "dungeon/dungeon.h"
14 #include "floor/cave.h"
15 #include "game-option/birth-options.h"
16 #include "game-option/disturbance-options.h"
17 #include "grid/grid.h"
18 #include "mind/drs-types.h"
19 #include "monster-race/monster-race.h"
20 #include "monster-race/race-flags1.h"
21 #include "monster-race/race-flags2.h"
22 #include "monster-race/race-flags3.h"
23 #include "monster-race/race-flags7.h"
24 #include "monster-race/race-indice-types.h"
25 #include "monster/monster-flag-types.h"
26 #include "monster/monster-info.h"
27 #include "monster/monster-status.h"
28 #include "monster/smart-learn-types.h"
29 #include "player/eldritch-horror.h"
30 #include "player/player-move.h"
31 #include "player/player-status-flags.h"
32 #include "player/special-defense-types.h"
33 #include "status/element-resistance.h"
34 #include "system/floor-type-definition.h"
35 #include "target/projection-path-calculator.h"
36
37 // Update Monster.
38 typedef struct um_type {
39     monster_type *m_ptr;
40     bool do_disturb;
41     POSITION fy;
42     POSITION fx;
43     bool flag;
44     bool easy;
45     bool in_darkness;
46     bool full;
47 } um_type;
48
49 /*!
50  * @brief 騎乗中のモンスター情報を更新する
51  * @param target_ptr プレーヤーへの参照ポインタ
52  * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
53  * @param m_idx モンスターID
54  * @param oy 移動前の、モンスターのY座標
55  * @param ox 移動前の、モンスターのX座標
56  * @param ny 移動後の、モンスターのY座標
57  * @param ox 移動後の、モンスターのX座標
58  * @return アイテム等に影響を及ぼしたらTRUE
59  */
60 bool update_riding_monster(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx, POSITION oy, POSITION ox, POSITION ny, POSITION nx)
61 {
62     monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
63     grid_type *g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
64     monster_type *y_ptr = &target_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
65     if (turn_flags_ptr->is_riding_mon)
66         return move_player_effect(target_ptr, ny, nx, MPE_DONT_PICKUP);
67
68     target_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = g_ptr->m_idx;
69     if (g_ptr->m_idx) {
70         y_ptr->fy = oy;
71         y_ptr->fx = ox;
72         update_monster(target_ptr, g_ptr->m_idx, TRUE);
73     }
74
75     g_ptr->m_idx = m_idx;
76     m_ptr->fy = ny;
77     m_ptr->fx = nx;
78     update_monster(target_ptr, m_idx, TRUE);
79
80     lite_spot(target_ptr, oy, ox);
81     lite_spot(target_ptr, ny, nx);
82     return TRUE;
83 }
84
85 /*!
86  * @brief updateフィールドを更新する
87  * @param target_ptr プレーヤーへの参照ポインタ
88  * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
89  * @return なし
90  */
91 void update_player_type(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_race *r_ptr)
92 {
93     if (turn_flags_ptr->do_view) {
94         target_ptr->update |= PU_FLOW;
95         target_ptr->window |= PW_OVERHEAD | PW_DUNGEON;
96     }
97
98     if (turn_flags_ptr->do_move
99         && ((r_ptr->flags7 & (RF7_SELF_LD_MASK | RF7_HAS_DARK_1 | RF7_HAS_DARK_2))
100             || ((r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2)) && !target_ptr->phase_out))) {
101         target_ptr->update |= PU_MON_LITE;
102     }
103 }
104
105 /*!
106  * @brief モンスターのフラグを更新する
107  * @param target_ptr プレーヤーへの参照ポインタ
108  * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
109  * @param m_ptr モンスターへの参照ポインタ
110  * @return なし
111  */
112 void update_monster_race_flags(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr)
113 {
114     monster_race *r_ptr = &r_info[m_ptr->r_idx];
115     if (!is_original_ap_and_seen(target_ptr, m_ptr))
116         return;
117
118     if (turn_flags_ptr->did_open_door)
119         r_ptr->r_flags2 |= RF2_OPEN_DOOR;
120
121     if (turn_flags_ptr->did_bash_door)
122         r_ptr->r_flags2 |= RF2_BASH_DOOR;
123
124     if (turn_flags_ptr->did_take_item)
125         r_ptr->r_flags2 |= RF2_TAKE_ITEM;
126
127     if (turn_flags_ptr->did_kill_item)
128         r_ptr->r_flags2 |= RF2_KILL_ITEM;
129
130     if (turn_flags_ptr->did_move_body)
131         r_ptr->r_flags2 |= RF2_MOVE_BODY;
132
133     if (turn_flags_ptr->did_pass_wall)
134         r_ptr->r_flags2 |= RF2_PASS_WALL;
135
136     if (turn_flags_ptr->did_kill_wall)
137         r_ptr->r_flags2 |= RF2_KILL_WALL;
138 }
139
140 /*!
141  * @brief モンスターフラグの更新に基づき、モンスター表示を更新する
142  * @param monster_race_idx モンスターID
143  * @param window ウィンドウフラグ
144  * @param old_race_flags_ptr モンスターフラグへの参照ポインタ
145  * @return なし
146  */
147 void update_player_window(player_type *target_ptr, old_race_flags *old_race_flags_ptr)
148 {
149     monster_race *r_ptr;
150     r_ptr = &r_info[target_ptr->monster_race_idx];
151     if ((old_race_flags_ptr->old_r_flags1 != r_ptr->r_flags1) || (old_race_flags_ptr->old_r_flags2 != r_ptr->r_flags2)
152         || (old_race_flags_ptr->old_r_flags3 != r_ptr->r_flags3) || (old_race_flags_ptr->old_r_flags4 != r_ptr->r_flags4)
153         || (old_race_flags_ptr->old_r_flags5 != r_ptr->r_flags5) || (old_race_flags_ptr->old_r_flags6 != r_ptr->r_flags6)
154         || (old_race_flags_ptr->old_r_flagsr != r_ptr->r_flagsr) || (old_race_flags_ptr->old_r_blows0 != r_ptr->r_blows[0])
155         || (old_race_flags_ptr->old_r_blows1 != r_ptr->r_blows[1]) || (old_race_flags_ptr->old_r_blows2 != r_ptr->r_blows[2])
156         || (old_race_flags_ptr->old_r_blows3 != r_ptr->r_blows[3]) || (old_race_flags_ptr->old_r_cast_spell != r_ptr->r_cast_spell)) {
157         target_ptr->window |= PW_MONSTER;
158     }
159 }
160
161 static um_type* initialize_um_type(player_type* subject_ptr, um_type *um_ptr, MONSTER_IDX m_idx, bool full)
162 {
163     um_ptr->m_ptr = &subject_ptr->current_floor_ptr->m_list[m_idx];
164     um_ptr->do_disturb = disturb_move;
165     um_ptr->fy = um_ptr->m_ptr->fy;
166     um_ptr->fx = um_ptr->m_ptr->fx;
167     um_ptr->flag = FALSE;
168     um_ptr->easy = FALSE;
169     um_ptr->in_darkness = (d_info[subject_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !subject_ptr->see_nocto;
170     um_ptr->full = full;
171     return um_ptr;
172 }
173
174 static POSITION decide_updated_distance(player_type *subject_ptr, um_type *um_ptr)
175 {
176     if (!um_ptr->full)
177         return um_ptr->m_ptr->cdis;
178
179     int dy = (subject_ptr->y > um_ptr->fy) ? (subject_ptr->y - um_ptr->fy) : (um_ptr->fy - subject_ptr->y);
180     int dx = (subject_ptr->x > um_ptr->fx) ? (subject_ptr->x - um_ptr->fx) : (um_ptr->fx - subject_ptr->x);
181     POSITION distance = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
182     if (distance > 255)
183         distance = 255;
184
185     if (!distance)
186         distance = 1;
187
188     um_ptr->m_ptr->cdis = distance;
189     return distance;
190 }
191
192 static void update_smart_stupid_flags(monster_race *r_ptr)
193 {
194     if (r_ptr->flags2 & RF2_SMART)
195         r_ptr->r_flags2 |= RF2_SMART;
196
197     if (r_ptr->flags2 & RF2_STUPID)
198         r_ptr->r_flags2 |= RF2_STUPID;
199 }
200
201 /*!
202  * @brief WEIRD_MINDフラグ持ちのモンスターを1/10の確率でテレパシーに引っかける
203  * @param subject_ptr プレーヤーへの参照ポインタ
204  * @param um_ptr モンスター情報アップデート構造体への参照ポインタ
205  * @return WEIRD_MINDフラグがあるならTRUE
206  */
207 static bool update_weird_telepathy(player_type *subject_ptr, um_type *um_ptr)
208 {
209     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
210     if ((r_ptr->flags2 & RF2_WEIRD_MIND) == 0)
211         return FALSE;
212
213     if (!one_in_(10))
214         return TRUE;
215
216     um_ptr->flag = TRUE;
217     if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image) {
218         r_ptr->r_flags2 |= RF2_WEIRD_MIND;
219         update_smart_stupid_flags(r_ptr);
220     }
221
222     return TRUE;
223 }
224
225 static void update_telepathy_sight(player_type *subject_ptr, um_type *um_ptr)
226 {
227     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
228     if (subject_ptr->special_defense & KATA_MUSOU) {
229         um_ptr->flag = TRUE;
230         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
231             update_smart_stupid_flags(r_ptr);
232
233         return;
234     }
235     
236     if (!subject_ptr->telepathy)
237         return;
238
239     if (r_ptr->flags2 & RF2_EMPTY_MIND) {
240         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
241             r_ptr->r_flags2 |= RF2_EMPTY_MIND;
242
243         return;
244     }
245     
246     if (update_weird_telepathy(subject_ptr, um_ptr))
247         return;
248
249     um_ptr->flag = TRUE;
250     if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
251         update_smart_stupid_flags(r_ptr);
252 }
253
254 static void update_specific_race_telepathy(player_type *subject_ptr, um_type *um_ptr)
255 {
256     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
257     if ((subject_ptr->esp_animal) && (r_ptr->flags3 & RF3_ANIMAL)) {
258         um_ptr->flag = TRUE;
259         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
260             r_ptr->r_flags3 |= RF3_ANIMAL;
261     }
262
263     if ((subject_ptr->esp_undead) && (r_ptr->flags3 & RF3_UNDEAD)) {
264         um_ptr->flag = TRUE;
265         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
266             r_ptr->r_flags3 |= RF3_UNDEAD;
267     }
268
269     if ((subject_ptr->esp_demon) && (r_ptr->flags3 & RF3_DEMON)) {
270         um_ptr->flag = TRUE;
271         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
272             r_ptr->r_flags3 |= RF3_DEMON;
273     }
274
275     if ((subject_ptr->esp_orc) && (r_ptr->flags3 & RF3_ORC)) {
276         um_ptr->flag = TRUE;
277         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
278             r_ptr->r_flags3 |= RF3_ORC;
279     }
280
281     if ((subject_ptr->esp_troll) && (r_ptr->flags3 & RF3_TROLL)) {
282         um_ptr->flag = TRUE;
283         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
284             r_ptr->r_flags3 |= RF3_TROLL;
285     }
286
287     if ((subject_ptr->esp_giant) && (r_ptr->flags3 & RF3_GIANT)) {
288         um_ptr->flag = TRUE;
289         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
290             r_ptr->r_flags3 |= RF3_GIANT;
291     }
292
293     if ((subject_ptr->esp_dragon) && (r_ptr->flags3 & RF3_DRAGON)) {
294         um_ptr->flag = TRUE;
295         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
296             r_ptr->r_flags3 |= RF3_DRAGON;
297     }
298
299     if ((subject_ptr->esp_human) && (r_ptr->flags2 & RF2_HUMAN)) {
300         um_ptr->flag = TRUE;
301         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
302             r_ptr->r_flags2 |= RF2_HUMAN;
303     }
304
305     if ((subject_ptr->esp_evil) && (r_ptr->flags3 & RF3_EVIL)) {
306         um_ptr->flag = TRUE;
307         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
308             r_ptr->r_flags3 |= RF3_EVIL;
309     }
310
311     if ((subject_ptr->esp_good) && (r_ptr->flags3 & RF3_GOOD)) {
312         um_ptr->flag = TRUE;
313         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
314             r_ptr->r_flags3 |= RF3_GOOD;
315     }
316
317     if ((subject_ptr->esp_nonliving) && ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING)) {
318         um_ptr->flag = TRUE;
319         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
320             r_ptr->r_flags3 |= RF3_NONLIVING;
321     }
322
323     if ((subject_ptr->esp_unique) && (r_ptr->flags1 & RF1_UNIQUE)) {
324         um_ptr->flag = TRUE;
325         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
326             r_ptr->r_flags1 |= RF1_UNIQUE;
327     }
328 }
329
330 static bool check_cold_blood(player_type *subject_ptr, um_type *um_ptr)
331 {
332     if (distance > subject_ptr->see_infra)
333         return FALSE;
334
335     if ((r_info[um_ptr->m_ptr->r_idx].flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
336         return TRUE;
337
338     um_ptr->easy = TRUE;
339     um_ptr->flag = TRUE;
340     return TRUE;
341 }
342
343 /*!
344  * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
345  * @param m_idx 更新するモンスター情報のID
346  * @param full プレイヤーとの距離更新を行うならばtrue
347  * @return なし
348  */
349 void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full)
350 {
351     um_type tmp_um;
352     um_type *um_ptr = initialize_um_type(subject_ptr, &tmp_um, m_idx, full);
353     if (disturb_high) {
354         monster_race *ap_r_ptr = &r_info[um_ptr->m_ptr->ap_r_idx];
355         if (ap_r_ptr->r_tkills && ap_r_ptr->level >= subject_ptr->lev)
356             um_ptr->do_disturb = TRUE;
357     }
358
359     if (um_ptr->m_ptr->mflag2 & MFLAG2_MARK)
360         um_ptr->flag = TRUE;
361
362     POSITION distance = decide_updated_distance(subject_ptr, um_ptr);
363     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
364     if (distance <= (um_ptr->in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT)) {
365         if (!um_ptr->in_darkness || (distance <= MAX_SIGHT / 4)) {
366             update_telepathy_sight(subject_ptr, um_ptr);
367             update_specific_race_telepathy(subject_ptr, um_ptr);
368         }
369
370         if (player_has_los_bold(subject_ptr, um_ptr->fy, um_ptr->fx) && !subject_ptr->blind) {
371             if (subject_ptr->concent >= CONCENT_RADAR_THRESHOLD) {
372                 um_ptr->easy = TRUE;
373                 um_ptr->flag = TRUE;
374             }
375             
376             bool do_cold_blood = check_cold_blood(subject_ptr, um_ptr);
377             bool do_invisible = FALSE;
378             if (player_can_see_bold(subject_ptr, um_ptr->fy, um_ptr->fx))
379                 if (r_ptr->flags2 & RF2_INVISIBLE) {
380                     do_invisible = TRUE;
381                     if (subject_ptr->see_inv) {
382                         um_ptr->easy = TRUE;
383                         um_ptr->flag = TRUE;
384                     }                    
385                 } else {
386                     um_ptr->easy = TRUE;
387                     um_ptr->flag = TRUE;
388                 }
389                 
390             if (um_ptr->flag && is_original_ap(um_ptr->m_ptr) && !subject_ptr->image) {
391                 if (do_invisible)
392                     r_ptr->r_flags2 |= RF2_INVISIBLE;
393
394                 if (do_cold_blood)
395                     r_ptr->r_flags2 |= RF2_COLD_BLOOD;
396             }
397         }
398     }
399
400     /* The monster is now visible */
401     if (um_ptr->flag) {
402         if (!um_ptr->m_ptr->ml) {
403             um_ptr->m_ptr->ml = TRUE;
404             lite_spot(subject_ptr, um_ptr->fy, um_ptr->fx);
405
406             if (subject_ptr->health_who == m_idx)
407                 subject_ptr->redraw |= PR_HEALTH;
408
409             if (subject_ptr->riding == m_idx)
410                 subject_ptr->redraw |= PR_UHEALTH;
411
412             if (!subject_ptr->image) {
413                 if ((um_ptr->m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
414                     r_info[MON_KAGE].r_sights++;
415                 else if (is_original_ap(um_ptr->m_ptr) && (r_ptr->r_sights < MAX_SHORT))
416                     r_ptr->r_sights++;
417             }
418
419             if (r_info[um_ptr->m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
420                 sanity_blast(subject_ptr, um_ptr->m_ptr, FALSE);
421
422             if (disturb_near
423                 && (projectable(subject_ptr, um_ptr->m_ptr->fy, um_ptr->m_ptr->fx, subject_ptr->y, subject_ptr->x)
424                     && projectable(subject_ptr, subject_ptr->y, subject_ptr->x, um_ptr->m_ptr->fy, um_ptr->m_ptr->fx))) {
425                 if (disturb_pets || is_hostile(um_ptr->m_ptr))
426                     disturb(subject_ptr, TRUE, TRUE);
427             }
428         }
429     }
430
431     /* The monster is not visible */
432     else {
433         if (um_ptr->m_ptr->ml) {
434             um_ptr->m_ptr->ml = FALSE;
435             lite_spot(subject_ptr, um_ptr->fy, um_ptr->fx);
436
437             if (subject_ptr->health_who == m_idx)
438                 subject_ptr->redraw |= PR_HEALTH;
439
440             if (subject_ptr->riding == m_idx)
441                 subject_ptr->redraw |= PR_UHEALTH;
442
443             if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr)))
444                 disturb(subject_ptr, TRUE, TRUE);
445         }
446     }
447
448     /* The monster is now easily visible */
449     if (um_ptr->easy) {
450         if (!(um_ptr->m_ptr->mflag & MFLAG_VIEW)) {
451             um_ptr->m_ptr->mflag |= MFLAG_VIEW;
452             if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr)))
453                 disturb(subject_ptr, TRUE, TRUE);
454         }
455
456         return;
457     }
458
459     /* The monster is not easily visible */
460     /* Change */
461     if (!(um_ptr->m_ptr->mflag & MFLAG_VIEW))
462         return;
463
464     /* Mark as not easily visible */
465     um_ptr->m_ptr->mflag &= ~(MFLAG_VIEW);
466
467     if (um_ptr->do_disturb) {
468         if (disturb_pets || is_hostile(um_ptr->m_ptr))
469             disturb(subject_ptr, TRUE, TRUE);
470     }
471 }
472
473 /*!
474  * @param player_ptr プレーヤーへの参照ポインタ
475  * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
476  * @param full 距離更新を行うならtrue
477  * @return なし
478  */
479 void update_monsters(player_type *player_ptr, bool full)
480 {
481     floor_type *floor_ptr = player_ptr->current_floor_ptr;
482     for (MONSTER_IDX i = 1; i < floor_ptr->m_max; i++) {
483         monster_type *m_ptr = &floor_ptr->m_list[i];
484         if (!monster_is_valid(m_ptr))
485             continue;
486         update_monster(player_ptr, i, full);
487     }
488 }
489
490 /*!
491  * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
492  * @param m_idx 更新を行う「モンスター情報ID
493  * @param what 学習対象ID
494  * @return なし
495  */
496 void update_smart_learn(player_type *player_ptr, MONSTER_IDX m_idx, int what)
497 {
498     monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
499     monster_race *r_ptr = &r_info[m_ptr->r_idx];
500
501     if (!smart_learn || ((r_ptr->flags2 & RF2_STUPID) != 0) || (((r_ptr->flags2 & RF2_SMART) == 0) && (randint0(100) < 50)))
502         return;
503
504     switch (what) {
505     case DRS_ACID:
506         if (player_ptr->resist_acid)
507             m_ptr->smart |= SM_RES_ACID;
508
509         if (is_oppose_acid(player_ptr))
510             m_ptr->smart |= SM_OPP_ACID;
511
512         if (is_immune_acid(player_ptr))
513             m_ptr->smart |= SM_IMM_ACID;
514
515         break;
516     case DRS_ELEC:
517         if (player_ptr->resist_elec)
518             m_ptr->smart |= SM_RES_ELEC;
519
520         if (is_oppose_elec(player_ptr))
521             m_ptr->smart |= SM_OPP_ELEC;
522
523         if (is_immune_elec(player_ptr))
524             m_ptr->smart |= SM_IMM_ELEC;
525
526         break;
527     case DRS_FIRE:
528         if (player_ptr->resist_fire)
529             m_ptr->smart |= SM_RES_FIRE;
530
531         if (is_oppose_fire(player_ptr))
532             m_ptr->smart |= SM_OPP_FIRE;
533         
534         if (is_immune_fire(player_ptr))
535             m_ptr->smart |= SM_IMM_FIRE;
536         
537         break;
538     case DRS_COLD:
539         if (player_ptr->resist_cold)
540             m_ptr->smart |= SM_RES_COLD;
541
542         if (is_oppose_cold(player_ptr))
543             m_ptr->smart |= SM_OPP_COLD;
544
545         if (is_immune_cold(player_ptr))
546             m_ptr->smart |= SM_IMM_COLD;
547
548         break;
549     case DRS_POIS:
550         if (player_ptr->resist_pois)
551             m_ptr->smart |= SM_RES_POIS;
552
553         if (is_oppose_pois(player_ptr))
554             m_ptr->smart |= SM_OPP_POIS;
555
556         break;
557     case DRS_NETH:
558         if (player_ptr->resist_neth)
559             m_ptr->smart |= SM_RES_NETH;
560
561         break;
562     case DRS_LITE:
563         if (player_ptr->resist_lite)
564             m_ptr->smart |= SM_RES_LITE;
565
566         break;
567     case DRS_DARK:
568         if (player_ptr->resist_dark)
569             m_ptr->smart |= SM_RES_DARK;
570
571         break;
572     case DRS_FEAR:
573         if (player_ptr->resist_fear)
574             m_ptr->smart |= SM_RES_FEAR;
575
576         break;
577     case DRS_CONF:
578         if (player_ptr->resist_conf)
579             m_ptr->smart |= SM_RES_CONF;
580
581         break;
582     case DRS_CHAOS:
583         if (player_ptr->resist_chaos)
584             m_ptr->smart |= SM_RES_CHAOS;
585
586         break;
587     case DRS_DISEN:
588         if (player_ptr->resist_disen)
589             m_ptr->smart |= SM_RES_DISEN;
590
591         break;
592     case DRS_BLIND:
593         if (player_ptr->resist_blind)
594             m_ptr->smart |= SM_RES_BLIND;
595
596         break;
597     case DRS_NEXUS:
598         if (player_ptr->resist_nexus)
599             m_ptr->smart |= SM_RES_NEXUS;
600
601         break;
602     case DRS_SOUND:
603         if (player_ptr->resist_sound)
604             m_ptr->smart |= SM_RES_SOUND;
605
606         break;
607     case DRS_SHARD:
608         if (player_ptr->resist_shard)
609             m_ptr->smart |= SM_RES_SHARD;
610
611         break;
612     case DRS_FREE:
613         if (player_ptr->free_act)
614             m_ptr->smart |= SM_IMM_FREE;
615
616         break;
617     case DRS_MANA:
618         if (!player_ptr->msp)
619             m_ptr->smart |= SM_IMM_MANA;
620
621         break;
622     case DRS_REFLECT:
623         if (player_ptr->reflect)
624             m_ptr->smart |= SM_IMM_REFLECT;
625
626         break;
627     default:
628         break;
629     }
630 }