OSDN Git Service

[Refactor] #40734 Separated update_telepathy_sight() 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 static void update_telepathy_sight(player_type *subject_ptr, um_type *um_ptr)
202 {
203     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
204     if (subject_ptr->special_defense & KATA_MUSOU) {
205         um_ptr->flag = TRUE;
206         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
207             update_smart_stupid_flags(r_ptr);
208
209         return;
210     }
211     
212     if (!subject_ptr->telepathy)
213         return;
214
215     if (r_ptr->flags2 & RF2_EMPTY_MIND) {
216         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
217             r_ptr->r_flags2 |= RF2_EMPTY_MIND;
218
219         return;
220     }
221     
222     if (r_ptr->flags2 & RF2_WEIRD_MIND) {
223         const int weird_telepathy_possibility = 10;
224         if (one_in_(weird_telepathy_possibility)) {
225             um_ptr->flag = TRUE;
226             if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image) {
227                 r_ptr->r_flags2 |= RF2_WEIRD_MIND;
228                 update_smart_stupid_flags(r_ptr);
229             }
230         }
231
232         return;
233     }
234
235     um_ptr->flag = TRUE;
236     if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
237         update_smart_stupid_flags(r_ptr);
238 }
239
240 /*!
241  * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
242  * @param m_idx 更新するモンスター情報のID
243  * @param full プレイヤーとの距離更新を行うならばtrue
244  * @return なし
245  */
246 void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full)
247 {
248     um_type tmp_um;
249     um_type *um_ptr = initialize_um_type(subject_ptr, &tmp_um, m_idx, full);
250     if (disturb_high) {
251         monster_race *ap_r_ptr = &r_info[um_ptr->m_ptr->ap_r_idx];
252         if (ap_r_ptr->r_tkills && ap_r_ptr->level >= subject_ptr->lev)
253             um_ptr->do_disturb = TRUE;
254     }
255
256     if (um_ptr->m_ptr->mflag2 & MFLAG2_MARK)
257         um_ptr->flag = TRUE;
258
259     POSITION distance = decide_updated_distance(subject_ptr, um_ptr);
260     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
261     if (distance <= (um_ptr->in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT)) {
262         if (!um_ptr->in_darkness || (distance <= MAX_SIGHT / 4)) {
263             update_telepathy_sight(subject_ptr, um_ptr);
264             if ((subject_ptr->esp_animal) && (r_ptr->flags3 & RF3_ANIMAL)) {
265                 um_ptr->flag = TRUE;
266                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
267                     r_ptr->r_flags3 |= RF3_ANIMAL;
268             }
269
270             if ((subject_ptr->esp_undead) && (r_ptr->flags3 & RF3_UNDEAD)) {
271                 um_ptr->flag = TRUE;
272                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
273                     r_ptr->r_flags3 |= RF3_UNDEAD;
274             }
275
276             if ((subject_ptr->esp_demon) && (r_ptr->flags3 & RF3_DEMON)) {
277                 um_ptr->flag = TRUE;
278                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
279                     r_ptr->r_flags3 |= RF3_DEMON;
280             }
281
282             if ((subject_ptr->esp_orc) && (r_ptr->flags3 & RF3_ORC)) {
283                 um_ptr->flag = TRUE;
284                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
285                     r_ptr->r_flags3 |= RF3_ORC;
286             }
287
288             if ((subject_ptr->esp_troll) && (r_ptr->flags3 & RF3_TROLL)) {
289                 um_ptr->flag = TRUE;
290                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
291                     r_ptr->r_flags3 |= RF3_TROLL;
292             }
293
294             if ((subject_ptr->esp_giant) && (r_ptr->flags3 & RF3_GIANT)) {
295                 um_ptr->flag = TRUE;
296                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
297                     r_ptr->r_flags3 |= RF3_GIANT;
298             }
299
300             if ((subject_ptr->esp_dragon) && (r_ptr->flags3 & RF3_DRAGON)) {
301                 um_ptr->flag = TRUE;
302                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
303                     r_ptr->r_flags3 |= RF3_DRAGON;
304             }
305
306             if ((subject_ptr->esp_human) && (r_ptr->flags2 & RF2_HUMAN)) {
307                 um_ptr->flag = TRUE;
308                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
309                     r_ptr->r_flags2 |= RF2_HUMAN;
310             }
311
312             if ((subject_ptr->esp_evil) && (r_ptr->flags3 & RF3_EVIL)) {
313                 um_ptr->flag = TRUE;
314                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
315                     r_ptr->r_flags3 |= RF3_EVIL;
316             }
317
318             if ((subject_ptr->esp_good) && (r_ptr->flags3 & RF3_GOOD)) {
319                 um_ptr->flag = TRUE;
320                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
321                     r_ptr->r_flags3 |= RF3_GOOD;
322             }
323
324             if ((subject_ptr->esp_nonliving) && ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING)) {
325                 um_ptr->flag = TRUE;
326                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
327                     r_ptr->r_flags3 |= RF3_NONLIVING;
328             }
329
330             if ((subject_ptr->esp_unique) && (r_ptr->flags1 & RF1_UNIQUE)) {
331                 um_ptr->flag = TRUE;
332                 if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
333                     r_ptr->r_flags1 |= RF1_UNIQUE;
334             }
335         }
336
337         if (player_has_los_bold(subject_ptr, um_ptr->fy, um_ptr->fx) && !subject_ptr->blind) {
338             bool do_invisible = FALSE;
339             bool do_cold_blood = FALSE;
340             if (subject_ptr->concent >= CONCENT_RADAR_THRESHOLD) {
341                 um_ptr->easy = TRUE;
342                 um_ptr->flag = TRUE;
343             }
344             
345             if (distance <= subject_ptr->see_infra)
346                 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD) {
347                     do_cold_blood = TRUE;
348                 } else {
349                     um_ptr->easy = TRUE;
350                     um_ptr->flag = TRUE;
351                 }
352
353             if (player_can_see_bold(subject_ptr, um_ptr->fy, um_ptr->fx))
354                 if (r_ptr->flags2 & RF2_INVISIBLE) {
355                     do_invisible = TRUE;
356                     if (subject_ptr->see_inv) {
357                         um_ptr->easy = TRUE;
358                         um_ptr->flag = TRUE;
359                     }                    
360                 } else {
361                     um_ptr->easy = TRUE;
362                     um_ptr->flag = TRUE;
363                 }
364                 
365             if (um_ptr->flag && is_original_ap(um_ptr->m_ptr) && !subject_ptr->image) {
366                 if (do_invisible)
367                     r_ptr->r_flags2 |= RF2_INVISIBLE;
368
369                 if (do_cold_blood)
370                     r_ptr->r_flags2 |= RF2_COLD_BLOOD;
371             }
372         }
373     }
374
375     /* The monster is now visible */
376     if (um_ptr->flag) {
377         if (!um_ptr->m_ptr->ml) {
378             um_ptr->m_ptr->ml = TRUE;
379             lite_spot(subject_ptr, um_ptr->fy, um_ptr->fx);
380
381             if (subject_ptr->health_who == m_idx)
382                 subject_ptr->redraw |= PR_HEALTH;
383
384             if (subject_ptr->riding == m_idx)
385                 subject_ptr->redraw |= PR_UHEALTH;
386
387             if (!subject_ptr->image) {
388                 if ((um_ptr->m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
389                     r_info[MON_KAGE].r_sights++;
390                 else if (is_original_ap(um_ptr->m_ptr) && (r_ptr->r_sights < MAX_SHORT))
391                     r_ptr->r_sights++;
392             }
393
394             if (r_info[um_ptr->m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
395                 sanity_blast(subject_ptr, um_ptr->m_ptr, FALSE);
396
397             if (disturb_near
398                 && (projectable(subject_ptr, um_ptr->m_ptr->fy, um_ptr->m_ptr->fx, subject_ptr->y, subject_ptr->x)
399                     && projectable(subject_ptr, subject_ptr->y, subject_ptr->x, um_ptr->m_ptr->fy, um_ptr->m_ptr->fx))) {
400                 if (disturb_pets || is_hostile(um_ptr->m_ptr))
401                     disturb(subject_ptr, TRUE, TRUE);
402             }
403         }
404     }
405
406     /* The monster is not visible */
407     else {
408         if (um_ptr->m_ptr->ml) {
409             um_ptr->m_ptr->ml = FALSE;
410             lite_spot(subject_ptr, um_ptr->fy, um_ptr->fx);
411
412             if (subject_ptr->health_who == m_idx)
413                 subject_ptr->redraw |= PR_HEALTH;
414
415             if (subject_ptr->riding == m_idx)
416                 subject_ptr->redraw |= PR_UHEALTH;
417
418             if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr)))
419                 disturb(subject_ptr, TRUE, TRUE);
420         }
421     }
422
423     /* The monster is now easily visible */
424     if (um_ptr->easy) {
425         if (!(um_ptr->m_ptr->mflag & MFLAG_VIEW)) {
426             um_ptr->m_ptr->mflag |= MFLAG_VIEW;
427             if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr)))
428                 disturb(subject_ptr, TRUE, TRUE);
429         }
430
431         return;
432     }
433
434     /* The monster is not easily visible */
435     /* Change */
436     if (!(um_ptr->m_ptr->mflag & MFLAG_VIEW))
437         return;
438
439     /* Mark as not easily visible */
440     um_ptr->m_ptr->mflag &= ~(MFLAG_VIEW);
441
442     if (um_ptr->do_disturb) {
443         if (disturb_pets || is_hostile(um_ptr->m_ptr))
444             disturb(subject_ptr, TRUE, TRUE);
445     }
446 }
447
448 /*!
449  * @param player_ptr プレーヤーへの参照ポインタ
450  * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
451  * @param full 距離更新を行うならtrue
452  * @return なし
453  */
454 void update_monsters(player_type *player_ptr, bool full)
455 {
456     floor_type *floor_ptr = player_ptr->current_floor_ptr;
457     for (MONSTER_IDX i = 1; i < floor_ptr->m_max; i++) {
458         monster_type *m_ptr = &floor_ptr->m_list[i];
459         if (!monster_is_valid(m_ptr))
460             continue;
461         update_monster(player_ptr, i, full);
462     }
463 }
464
465 /*!
466  * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
467  * @param m_idx 更新を行う「モンスター情報ID
468  * @param what 学習対象ID
469  * @return なし
470  */
471 void update_smart_learn(player_type *player_ptr, MONSTER_IDX m_idx, int what)
472 {
473     monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
474     monster_race *r_ptr = &r_info[m_ptr->r_idx];
475
476     if (!smart_learn || ((r_ptr->flags2 & RF2_STUPID) != 0) || (((r_ptr->flags2 & RF2_SMART) == 0) && (randint0(100) < 50)))
477         return;
478
479     switch (what) {
480     case DRS_ACID:
481         if (player_ptr->resist_acid)
482             m_ptr->smart |= SM_RES_ACID;
483
484         if (is_oppose_acid(player_ptr))
485             m_ptr->smart |= SM_OPP_ACID;
486
487         if (is_immune_acid(player_ptr))
488             m_ptr->smart |= SM_IMM_ACID;
489
490         break;
491     case DRS_ELEC:
492         if (player_ptr->resist_elec)
493             m_ptr->smart |= SM_RES_ELEC;
494
495         if (is_oppose_elec(player_ptr))
496             m_ptr->smart |= SM_OPP_ELEC;
497
498         if (is_immune_elec(player_ptr))
499             m_ptr->smart |= SM_IMM_ELEC;
500
501         break;
502     case DRS_FIRE:
503         if (player_ptr->resist_fire)
504             m_ptr->smart |= SM_RES_FIRE;
505
506         if (is_oppose_fire(player_ptr))
507             m_ptr->smart |= SM_OPP_FIRE;
508         
509         if (is_immune_fire(player_ptr))
510             m_ptr->smart |= SM_IMM_FIRE;
511         
512         break;
513     case DRS_COLD:
514         if (player_ptr->resist_cold)
515             m_ptr->smart |= SM_RES_COLD;
516
517         if (is_oppose_cold(player_ptr))
518             m_ptr->smart |= SM_OPP_COLD;
519
520         if (is_immune_cold(player_ptr))
521             m_ptr->smart |= SM_IMM_COLD;
522
523         break;
524     case DRS_POIS:
525         if (player_ptr->resist_pois)
526             m_ptr->smart |= SM_RES_POIS;
527
528         if (is_oppose_pois(player_ptr))
529             m_ptr->smart |= SM_OPP_POIS;
530
531         break;
532     case DRS_NETH:
533         if (player_ptr->resist_neth)
534             m_ptr->smart |= SM_RES_NETH;
535
536         break;
537     case DRS_LITE:
538         if (player_ptr->resist_lite)
539             m_ptr->smart |= SM_RES_LITE;
540
541         break;
542     case DRS_DARK:
543         if (player_ptr->resist_dark)
544             m_ptr->smart |= SM_RES_DARK;
545
546         break;
547     case DRS_FEAR:
548         if (player_ptr->resist_fear)
549             m_ptr->smart |= SM_RES_FEAR;
550
551         break;
552     case DRS_CONF:
553         if (player_ptr->resist_conf)
554             m_ptr->smart |= SM_RES_CONF;
555
556         break;
557     case DRS_CHAOS:
558         if (player_ptr->resist_chaos)
559             m_ptr->smart |= SM_RES_CHAOS;
560
561         break;
562     case DRS_DISEN:
563         if (player_ptr->resist_disen)
564             m_ptr->smart |= SM_RES_DISEN;
565
566         break;
567     case DRS_BLIND:
568         if (player_ptr->resist_blind)
569             m_ptr->smart |= SM_RES_BLIND;
570
571         break;
572     case DRS_NEXUS:
573         if (player_ptr->resist_nexus)
574             m_ptr->smart |= SM_RES_NEXUS;
575
576         break;
577     case DRS_SOUND:
578         if (player_ptr->resist_sound)
579             m_ptr->smart |= SM_RES_SOUND;
580
581         break;
582     case DRS_SHARD:
583         if (player_ptr->resist_shard)
584             m_ptr->smart |= SM_RES_SHARD;
585
586         break;
587     case DRS_FREE:
588         if (player_ptr->free_act)
589             m_ptr->smart |= SM_IMM_FREE;
590
591         break;
592     case DRS_MANA:
593         if (!player_ptr->msp)
594             m_ptr->smart |= SM_IMM_MANA;
595
596         break;
597     case DRS_REFLECT:
598         if (player_ptr->reflect)
599             m_ptr->smart |= SM_IMM_REFLECT;
600
601         break;
602     default:
603         break;
604     }
605 }