OSDN Git Service

[Add] @return を不要に書き込んだことによる警告をひとまず置換で修正.
[hengbandforosx/hengbandosx.git] / src / monster / monster-update.cpp
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 "floor/geometry.h"
16 #include "game-option/birth-options.h"
17 #include "game-option/disturbance-options.h"
18 #include "grid/grid.h"
19 #include "mind/drs-types.h"
20 #include "monster-race/monster-race.h"
21 #include "monster-race/race-flags1.h"
22 #include "monster-race/race-flags2.h"
23 #include "monster-race/race-flags3.h"
24 #include "monster-race/race-flags7.h"
25 #include "monster-race/race-indice-types.h"
26 #include "monster/monster-flag-types.h"
27 #include "monster/monster-info.h"
28 #include "monster/monster-processor-util.h"
29 #include "monster/monster-status.h"
30 #include "monster/smart-learn-types.h"
31 #include "player/player-move.h"
32 #include "player/player-status-flags.h"
33 #include "player/special-defense-types.h"
34 #include "status/element-resistance.h"
35 #include "system/floor-type-definition.h"
36 #include "system/monster-race-definition.h"
37 #include "system/monster-type-definition.h"
38 #include "system/player-type-definition.h"
39 #include "target/projection-path-calculator.h"
40 #include "util/bit-flags-calculator.h"
41 #include "world/world.h"
42
43 // Update Monster.
44 typedef struct um_type {
45     monster_type *m_ptr;
46     bool do_disturb;
47     POSITION fy;
48     POSITION fx;
49     bool flag;
50     bool easy;
51     bool in_darkness;
52     bool full;
53 } um_type;
54
55 /*!
56  * @brief 騎乗中のモンスター情報を更新する
57  * @param target_ptr プレーヤーへの参照ポインタ
58  * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
59  * @param m_idx モンスターID
60  * @param oy 移動前の、モンスターのY座標
61  * @param ox 移動前の、モンスターのX座標
62  * @param ny 移動後の、モンスターのY座標
63  * @param ox 移動後の、モンスターのX座標
64  * @return アイテム等に影響を及ぼしたらTRUE
65  */
66 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)
67 {
68     monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
69     grid_type *g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
70     monster_type *y_ptr = &target_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
71     if (turn_flags_ptr->is_riding_mon)
72         return move_player_effect(target_ptr, ny, nx, MPE_DONT_PICKUP);
73
74     target_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = g_ptr->m_idx;
75     if (g_ptr->m_idx) {
76         y_ptr->fy = oy;
77         y_ptr->fx = ox;
78         update_monster(target_ptr, g_ptr->m_idx, TRUE);
79     }
80
81     g_ptr->m_idx = m_idx;
82     m_ptr->fy = ny;
83     m_ptr->fx = nx;
84     update_monster(target_ptr, m_idx, TRUE);
85
86     lite_spot(target_ptr, oy, ox);
87     lite_spot(target_ptr, ny, nx);
88     return TRUE;
89 }
90
91 /*!
92  * @brief updateフィールドを更新する
93  * @param target_ptr プレーヤーへの参照ポインタ
94  * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
95  */
96 void update_player_type(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_race *r_ptr)
97 {
98     if (turn_flags_ptr->do_view) {
99         target_ptr->update |= PU_FLOW;
100         target_ptr->window_flags |= PW_OVERHEAD | PW_DUNGEON;
101     }
102
103     if (turn_flags_ptr->do_move
104         && ((r_ptr->flags7 & (RF7_SELF_LD_MASK | RF7_HAS_DARK_1 | RF7_HAS_DARK_2))
105             || ((r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2)) && !target_ptr->phase_out))) {
106         target_ptr->update |= PU_MON_LITE;
107     }
108 }
109
110 /*!
111  * @brief モンスターのフラグを更新する
112  * @param target_ptr プレーヤーへの参照ポインタ
113  * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
114  * @param m_ptr モンスターへの参照ポインタ
115  */
116 void update_monster_race_flags(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr)
117 {
118     monster_race *r_ptr = &r_info[m_ptr->r_idx];
119     if (!is_original_ap_and_seen(target_ptr, m_ptr))
120         return;
121
122     if (turn_flags_ptr->did_open_door)
123         r_ptr->r_flags2 |= RF2_OPEN_DOOR;
124
125     if (turn_flags_ptr->did_bash_door)
126         r_ptr->r_flags2 |= RF2_BASH_DOOR;
127
128     if (turn_flags_ptr->did_take_item)
129         r_ptr->r_flags2 |= RF2_TAKE_ITEM;
130
131     if (turn_flags_ptr->did_kill_item)
132         r_ptr->r_flags2 |= RF2_KILL_ITEM;
133
134     if (turn_flags_ptr->did_move_body)
135         r_ptr->r_flags2 |= RF2_MOVE_BODY;
136
137     if (turn_flags_ptr->did_pass_wall)
138         r_ptr->r_flags2 |= RF2_PASS_WALL;
139
140     if (turn_flags_ptr->did_kill_wall)
141         r_ptr->r_flags2 |= RF2_KILL_WALL;
142 }
143
144 /*!
145  * @brief モンスターフラグの更新に基づき、モンスター表示を更新する
146  * @param monster_race_idx モンスターID
147  * @param window ウィンドウフラグ
148  * @param old_race_flags_ptr モンスターフラグへの参照ポインタ
149  */
150 void update_player_window(player_type *target_ptr, old_race_flags *old_race_flags_ptr)
151 {
152     monster_race *r_ptr;
153     r_ptr = &r_info[target_ptr->monster_race_idx];
154     if ((old_race_flags_ptr->old_r_flags1 != r_ptr->r_flags1) || (old_race_flags_ptr->old_r_flags2 != r_ptr->r_flags2)
155         || (old_race_flags_ptr->old_r_flags3 != r_ptr->r_flags3) || (old_race_flags_ptr->old_r_ability_flags != r_ptr->r_ability_flags)
156         || (old_race_flags_ptr->old_r_flagsr != r_ptr->r_flagsr) || (old_race_flags_ptr->old_r_blows0 != r_ptr->r_blows[0])
157         || (old_race_flags_ptr->old_r_blows1 != r_ptr->r_blows[1]) || (old_race_flags_ptr->old_r_blows2 != r_ptr->r_blows[2])
158         || (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)) {
159         target_ptr->window_flags |= PW_MONSTER;
160     }
161 }
162
163 static um_type *initialize_um_type(player_type *subject_ptr, um_type *um_ptr, MONSTER_IDX m_idx, bool full)
164 {
165     um_ptr->m_ptr = &subject_ptr->current_floor_ptr->m_list[m_idx];
166     um_ptr->do_disturb = disturb_move;
167     um_ptr->fy = um_ptr->m_ptr->fy;
168     um_ptr->fx = um_ptr->m_ptr->fx;
169     um_ptr->flag = FALSE;
170     um_ptr->easy = FALSE;
171     um_ptr->in_darkness = (d_info[subject_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !subject_ptr->see_nocto;
172     um_ptr->full = full;
173     return um_ptr;
174 }
175
176 static POSITION decide_updated_distance(player_type *subject_ptr, um_type *um_ptr)
177 {
178     if (!um_ptr->full)
179         return um_ptr->m_ptr->cdis;
180
181     int dy = (subject_ptr->y > um_ptr->fy) ? (subject_ptr->y - um_ptr->fy) : (um_ptr->fy - subject_ptr->y);
182     int dx = (subject_ptr->x > um_ptr->fx) ? (subject_ptr->x - um_ptr->fx) : (um_ptr->fx - subject_ptr->x);
183     POSITION distance = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
184     if (distance > 255)
185         distance = 255;
186
187     if (!distance)
188         distance = 1;
189
190     um_ptr->m_ptr->cdis = distance;
191     return distance;
192 }
193
194 static void update_smart_stupid_flags(monster_race *r_ptr)
195 {
196     if (r_ptr->flags2 & RF2_SMART)
197         r_ptr->r_flags2 |= RF2_SMART;
198
199     if (r_ptr->flags2 & RF2_STUPID)
200         r_ptr->r_flags2 |= RF2_STUPID;
201 }
202
203 /*!
204  * @brief WEIRD_MINDフラグ持ちのモンスターを1/10の確率でテレパシーに引っかける
205  * @param subject_ptr プレーヤーへの参照ポインタ
206  * @param um_ptr モンスター情報アップデート構造体への参照ポインタ
207  * @param m_idx モンスターID
208  * @return WEIRD_MINDフラグがあるならTRUE
209  */
210 static bool update_weird_telepathy(player_type *subject_ptr, um_type *um_ptr, MONSTER_IDX m_idx)
211 {
212     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
213     if ((r_ptr->flags2 & RF2_WEIRD_MIND) == 0)
214         return FALSE;
215
216     if ((m_idx % 10) != (current_world_ptr->game_turn % 10))
217         return TRUE;
218
219     um_ptr->flag = TRUE;
220     um_ptr->m_ptr->mflag.set(MFLAG::ESP);
221     if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image) {
222         r_ptr->r_flags2 |= RF2_WEIRD_MIND;
223         update_smart_stupid_flags(r_ptr);
224     }
225
226     return TRUE;
227 }
228
229 static void update_telepathy_sight(player_type *subject_ptr, um_type *um_ptr, MONSTER_IDX m_idx)
230 {
231     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
232     if (subject_ptr->special_defense & KATA_MUSOU) {
233         um_ptr->flag = TRUE;
234         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
235         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
236             update_smart_stupid_flags(r_ptr);
237
238         return;
239     }
240
241     if (!subject_ptr->telepathy)
242         return;
243
244     if (r_ptr->flags2 & RF2_EMPTY_MIND) {
245         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
246             r_ptr->r_flags2 |= RF2_EMPTY_MIND;
247
248         return;
249     }
250
251     if (update_weird_telepathy(subject_ptr, um_ptr, m_idx))
252         return;
253
254     um_ptr->flag = TRUE;
255     um_ptr->m_ptr->mflag.set(MFLAG::ESP);
256     if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
257         update_smart_stupid_flags(r_ptr);
258 }
259
260 static void update_specific_race_telepathy(player_type *subject_ptr, um_type *um_ptr)
261 {
262     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
263     if ((subject_ptr->esp_animal) && (r_ptr->flags3 & RF3_ANIMAL)) {
264         um_ptr->flag = TRUE;
265         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
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         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
273         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
274             r_ptr->r_flags3 |= RF3_UNDEAD;
275     }
276
277     if ((subject_ptr->esp_demon) && (r_ptr->flags3 & RF3_DEMON)) {
278         um_ptr->flag = TRUE;
279         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
280         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
281             r_ptr->r_flags3 |= RF3_DEMON;
282     }
283
284     if ((subject_ptr->esp_orc) && (r_ptr->flags3 & RF3_ORC)) {
285         um_ptr->flag = TRUE;
286         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
287         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
288             r_ptr->r_flags3 |= RF3_ORC;
289     }
290
291     if ((subject_ptr->esp_troll) && (r_ptr->flags3 & RF3_TROLL)) {
292         um_ptr->flag = TRUE;
293         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
294         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
295             r_ptr->r_flags3 |= RF3_TROLL;
296     }
297
298     if ((subject_ptr->esp_giant) && (r_ptr->flags3 & RF3_GIANT)) {
299         um_ptr->flag = TRUE;
300         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
301         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
302             r_ptr->r_flags3 |= RF3_GIANT;
303     }
304
305     if ((subject_ptr->esp_dragon) && (r_ptr->flags3 & RF3_DRAGON)) {
306         um_ptr->flag = TRUE;
307         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
308         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
309             r_ptr->r_flags3 |= RF3_DRAGON;
310     }
311
312     if ((subject_ptr->esp_human) && (r_ptr->flags2 & RF2_HUMAN)) {
313         um_ptr->flag = TRUE;
314         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
315         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
316             r_ptr->r_flags2 |= RF2_HUMAN;
317     }
318
319     if ((subject_ptr->esp_evil) && (r_ptr->flags3 & RF3_EVIL)) {
320         um_ptr->flag = TRUE;
321         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
322         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
323             r_ptr->r_flags3 |= RF3_EVIL;
324     }
325
326     if ((subject_ptr->esp_good) && (r_ptr->flags3 & RF3_GOOD)) {
327         um_ptr->flag = TRUE;
328         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
329         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
330             r_ptr->r_flags3 |= RF3_GOOD;
331     }
332
333     if ((subject_ptr->esp_nonliving) && ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING)) {
334         um_ptr->flag = TRUE;
335         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
336         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
337             r_ptr->r_flags3 |= RF3_NONLIVING;
338     }
339
340     if ((subject_ptr->esp_unique) && (r_ptr->flags1 & RF1_UNIQUE)) {
341         um_ptr->flag = TRUE;
342         um_ptr->m_ptr->mflag.set(MFLAG::ESP);
343         if (is_original_ap(um_ptr->m_ptr) && !subject_ptr->image)
344             r_ptr->r_flags1 |= RF1_UNIQUE;
345     }
346 }
347
348 static bool check_cold_blood(player_type *subject_ptr, um_type *um_ptr, const POSITION distance)
349 {
350     if (distance > subject_ptr->see_infra)
351         return FALSE;
352
353     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
354     if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
355         return FALSE;
356
357     um_ptr->easy = TRUE;
358     um_ptr->flag = TRUE;
359     return TRUE;
360 }
361
362 static bool check_invisible(player_type *subject_ptr, um_type *um_ptr)
363 {
364     if (!player_can_see_bold(subject_ptr, um_ptr->fy, um_ptr->fx))
365         return FALSE;
366
367     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
368     if (r_ptr->flags2 & RF2_INVISIBLE) {
369         if (subject_ptr->see_inv) {
370             um_ptr->easy = TRUE;
371             um_ptr->flag = TRUE;
372         }
373     } else {
374         um_ptr->easy = TRUE;
375         um_ptr->flag = TRUE;
376     }
377
378     return TRUE;
379 }
380
381 /*!
382  * @brief テレパシー・赤外線視力・可視透明によってモンスターを感知できるかどうかの判定
383  * @param subject_ptr プレーヤーへの参照ポインタ
384  * @param um_ptr モンスター情報アップデート構造体への参照ポインタ
385  */
386 static void decide_sight_invisible_monster(player_type *subject_ptr, um_type *um_ptr, MONSTER_IDX m_idx)
387 {
388     POSITION distance = decide_updated_distance(subject_ptr, um_ptr);
389     monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
390
391     um_ptr->m_ptr->mflag.reset(MFLAG::ESP);
392
393     if (distance > (um_ptr->in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
394         return;
395
396     if (!um_ptr->in_darkness || (distance <= MAX_SIGHT / 4)) {
397         update_telepathy_sight(subject_ptr, um_ptr, m_idx);
398         update_specific_race_telepathy(subject_ptr, um_ptr);
399     }
400
401     if (!player_has_los_bold(subject_ptr, um_ptr->fy, um_ptr->fx) || subject_ptr->blind)
402         return;
403
404     if (subject_ptr->concent >= CONCENT_RADAR_THRESHOLD) {
405         um_ptr->easy = TRUE;
406         um_ptr->flag = TRUE;
407     }
408
409     bool do_cold_blood = check_cold_blood(subject_ptr, um_ptr, distance);
410     bool do_invisible = check_invisible(subject_ptr, um_ptr);
411     if (!um_ptr->flag || !is_original_ap(um_ptr->m_ptr) || subject_ptr->image)
412         return;
413
414     if (do_invisible)
415         r_ptr->r_flags2 |= RF2_INVISIBLE;
416
417     if (do_cold_blood)
418         r_ptr->r_flags2 |= RF2_COLD_BLOOD;
419 }
420
421 /*!
422  * @brief 壁の向こうにいるモンスターへのテレパシー・赤外線視力による冷血動物以外の透明モンスター・可視透明能力による透明モンスター
423  * 以上を感知する
424  * @param subject_ptr プレーヤーへの参照ポインタ
425  * @param um_ptr モンスター情報アップデート構造体への参照ポインタ
426  * @param m_idx フロアのモンスター番号
427  * @details 感知した結果、エルドリッチホラー持ちがいたら精神を破壊する
428  */
429 static void update_invisible_monster(player_type *subject_ptr, um_type *um_ptr, MONSTER_IDX m_idx)
430 {
431     if (um_ptr->m_ptr->ml)
432         return;
433
434     um_ptr->m_ptr->ml = TRUE;
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 (!subject_ptr->image) {
444         monster_race *r_ptr = &r_info[um_ptr->m_ptr->r_idx];
445         if ((um_ptr->m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
446             r_info[MON_KAGE].r_sights++;
447         else if (is_original_ap(um_ptr->m_ptr) && (r_ptr->r_sights < MAX_SHORT))
448             r_ptr->r_sights++;
449     }
450
451     if (current_world_ptr->is_loading_now && current_world_ptr->character_dungeon && !subject_ptr->phase_out
452         && r_info[um_ptr->m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
453         um_ptr->m_ptr->mflag.set(MFLAG::SANITY_BLAST);
454
455     if (disturb_near
456         && (projectable(subject_ptr, um_ptr->m_ptr->fy, um_ptr->m_ptr->fx, subject_ptr->y, subject_ptr->x)
457             && projectable(subject_ptr, subject_ptr->y, subject_ptr->x, um_ptr->m_ptr->fy, um_ptr->m_ptr->fx))) {
458         if (disturb_pets || is_hostile(um_ptr->m_ptr))
459             disturb(subject_ptr, TRUE, TRUE);
460     }
461 }
462
463 static void update_visible_monster(player_type *subject_ptr, um_type *um_ptr, MONSTER_IDX m_idx)
464 {
465     if (!um_ptr->m_ptr->ml)
466         return;
467
468     um_ptr->m_ptr->ml = FALSE;
469     lite_spot(subject_ptr, um_ptr->fy, um_ptr->fx);
470
471     if (subject_ptr->health_who == m_idx)
472         subject_ptr->redraw |= PR_HEALTH;
473
474     if (subject_ptr->riding == m_idx)
475         subject_ptr->redraw |= PR_UHEALTH;
476
477     if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr)))
478         disturb(subject_ptr, TRUE, TRUE);
479 }
480
481 static bool update_clear_monster(player_type *subject_ptr, um_type *um_ptr)
482 {
483     if (!um_ptr->easy)
484         return FALSE;
485
486     if (um_ptr->m_ptr->mflag.has_not(MFLAG::VIEW)) {
487         um_ptr->m_ptr->mflag.set(MFLAG::VIEW);
488         if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr)))
489             disturb(subject_ptr, TRUE, TRUE);
490     }
491
492     return TRUE;
493 }
494
495 /*!
496  * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
497  * @param m_idx 更新するモンスター情報のID
498  * @param full プレイヤーとの距離更新を行うならばtrue
499  */
500 void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full)
501 {
502     um_type tmp_um;
503     um_type *um_ptr = initialize_um_type(subject_ptr, &tmp_um, m_idx, full);
504     if (disturb_high) {
505         monster_race *ap_r_ptr = &r_info[um_ptr->m_ptr->ap_r_idx];
506         if (ap_r_ptr->r_tkills && ap_r_ptr->level >= subject_ptr->lev)
507             um_ptr->do_disturb = TRUE;
508     }
509
510     if (um_ptr->m_ptr->mflag2.has(MFLAG2::MARK))
511         um_ptr->flag = TRUE;
512
513     decide_sight_invisible_monster(subject_ptr, um_ptr, m_idx);
514     if (um_ptr->flag)
515         update_invisible_monster(subject_ptr, um_ptr, m_idx);
516     else
517         update_visible_monster(subject_ptr, um_ptr, m_idx);
518
519     if (update_clear_monster(subject_ptr, um_ptr) || um_ptr->m_ptr->mflag.has_not(MFLAG::VIEW))
520         return;
521
522     um_ptr->m_ptr->mflag.reset(MFLAG::VIEW);
523     if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr)))
524         disturb(subject_ptr, TRUE, TRUE);
525 }
526
527 /*!
528  * @param player_ptr プレーヤーへの参照ポインタ
529  * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
530  * @param full 距離更新を行うならtrue
531  * @todo モンスターの感知状況しか更新していないように見える。関数名変更を検討する
532  */
533 void update_monsters(player_type *player_ptr, bool full)
534 {
535     floor_type *floor_ptr = player_ptr->current_floor_ptr;
536     for (MONSTER_IDX i = 1; i < floor_ptr->m_max; i++) {
537         monster_type *m_ptr = &floor_ptr->m_list[i];
538         if (!monster_is_valid(m_ptr))
539             continue;
540
541         update_monster(player_ptr, i, full);
542     }
543 }
544
545 /*!
546  * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
547  * @param m_idx 更新を行う「モンスター情報ID
548  * @param what 学習対象ID
549  */
550 void update_smart_learn(player_type *player_ptr, MONSTER_IDX m_idx, int what)
551 {
552     monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
553     monster_race *r_ptr = &r_info[m_ptr->r_idx];
554     if (!smart_learn || ((r_ptr->flags2 & RF2_STUPID) != 0) || (((r_ptr->flags2 & RF2_SMART) == 0) && (randint0(100) < 50)))
555         return;
556
557     switch (what) {
558     case DRS_ACID:
559         if (has_resist_acid(player_ptr))
560             m_ptr->smart.set(SM::RES_ACID);
561
562         if (is_oppose_acid(player_ptr))
563             m_ptr->smart.set(SM::OPP_ACID);
564
565         if (has_immune_acid(player_ptr))
566             m_ptr->smart.set(SM::IMM_ACID);
567
568         break;
569     case DRS_ELEC:
570         if (has_resist_elec(player_ptr))
571             m_ptr->smart.set(SM::RES_ELEC);
572
573         if (is_oppose_elec(player_ptr))
574             m_ptr->smart.set(SM::OPP_ELEC);
575
576         if (has_immune_elec(player_ptr))
577             m_ptr->smart.set(SM::IMM_ELEC);
578
579         break;
580     case DRS_FIRE:
581         if (has_resist_fire(player_ptr))
582             m_ptr->smart.set(SM::RES_FIRE);
583
584         if (is_oppose_fire(player_ptr))
585             m_ptr->smart.set(SM::OPP_FIRE);
586
587         if (has_immune_fire(player_ptr))
588             m_ptr->smart.set(SM::IMM_FIRE);
589
590         break;
591     case DRS_COLD:
592         if (has_resist_cold(player_ptr))
593             m_ptr->smart.set(SM::RES_COLD);
594
595         if (is_oppose_cold(player_ptr))
596             m_ptr->smart.set(SM::OPP_COLD);
597
598         if (has_immune_cold(player_ptr))
599             m_ptr->smart.set(SM::IMM_COLD);
600
601         break;
602     case DRS_POIS:
603         if (has_resist_pois(player_ptr))
604             m_ptr->smart.set(SM::RES_POIS);
605
606         if (is_oppose_pois(player_ptr))
607             m_ptr->smart.set(SM::OPP_POIS);
608
609         break;
610     case DRS_NETH:
611         if (has_resist_neth(player_ptr))
612             m_ptr->smart.set(SM::RES_NETH);
613
614         break;
615     case DRS_LITE:
616         if (has_resist_lite(player_ptr))
617             m_ptr->smart.set(SM::RES_LITE);
618
619         break;
620     case DRS_DARK:
621         if (has_resist_dark(player_ptr))
622             m_ptr->smart.set(SM::RES_DARK);
623
624         break;
625     case DRS_FEAR:
626         if (has_resist_fear(player_ptr))
627             m_ptr->smart.set(SM::RES_FEAR);
628
629         break;
630     case DRS_CONF:
631         if (has_resist_conf(player_ptr))
632             m_ptr->smart.set(SM::RES_CONF);
633
634         break;
635     case DRS_CHAOS:
636         if (has_resist_chaos(player_ptr))
637             m_ptr->smart.set(SM::RES_CHAOS);
638
639         break;
640     case DRS_DISEN:
641         if (has_resist_disen(player_ptr))
642             m_ptr->smart.set(SM::RES_DISEN);
643
644         break;
645     case DRS_BLIND:
646         if (has_resist_blind(player_ptr))
647             m_ptr->smart.set(SM::RES_BLIND);
648
649         break;
650     case DRS_NEXUS:
651         if (has_resist_nexus(player_ptr))
652             m_ptr->smart.set(SM::RES_NEXUS);
653
654         break;
655     case DRS_SOUND:
656         if (has_resist_sound(player_ptr))
657             m_ptr->smart.set(SM::RES_SOUND);
658
659         break;
660     case DRS_SHARD:
661         if (has_resist_shard(player_ptr))
662             m_ptr->smart.set(SM::RES_SHARD);
663
664         break;
665     case DRS_FREE:
666         if (player_ptr->free_act)
667             m_ptr->smart.set(SM::IMM_FREE);
668
669         break;
670     case DRS_MANA:
671         if (!player_ptr->msp)
672             m_ptr->smart.set(SM::IMM_MANA);
673
674         break;
675     case DRS_REFLECT:
676         if (has_reflect(player_ptr))
677             m_ptr->smart.set(SM::IMM_REFLECT);
678
679         break;
680     default:
681         break;
682     }
683 }