OSDN Git Service

29328065c5b05e97bcb3df4254be939455633af0
[hengband/hengband.git] / src / monster / monster-move.c
1 /*!
2  * @brief モンスターの移動に関する処理
3  * @date 2020/03/08
4  * @author Hourier
5  */
6
7 #include "monster/monster-move.h"
8
9 /*!
10  * @brief 守りのルーンによるモンスターの移動制限を処理する
11  * @param target_ptr プレーヤーへの参照ポインタ
12  * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
13  * @param m_ptr モンスターへの参照ポインタ
14  * @param ny モンスターのY座標
15  * @param nx モンスターのX座標
16  * @return ルーンのある/なし
17  */
18 bool process_protection_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
19 {
20         grid_type *g_ptr;
21         g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
22         monster_race *r_ptr = &r_info[m_ptr->r_idx];
23         if (!turn_flags_ptr->do_move || !is_glyph_grid(g_ptr) ||
24                 (((r_ptr->flags1 & RF1_NEVER_BLOW) != 0) && player_bold(target_ptr, ny, nx)))
25                 return FALSE;
26
27         turn_flags_ptr->do_move = FALSE;
28         if (is_pet(m_ptr) || (randint1(BREAK_GLYPH) >= r_ptr->level))
29                 return TRUE;
30
31         if (g_ptr->info & CAVE_MARK)
32         {
33                 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
34         }
35
36         g_ptr->info &= ~(CAVE_MARK);
37         g_ptr->info &= ~(CAVE_OBJECT);
38         g_ptr->mimic = 0;
39         turn_flags_ptr->do_move = TRUE;
40         note_spot(target_ptr, ny, nx);
41         return TRUE;
42 }
43
44
45 /*!
46  * @brief 爆発のルーンを処理する
47  * @param target_ptr プレーヤーへの参照ポインタ
48  * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
49  * @param m_ptr モンスターへの参照ポインタ
50  * @param ny モンスターのY座標
51  * @param nx モンスターのX座標
52  * @return モンスターが死亡した場合のみFALSE
53  */
54 bool process_explosive_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
55 {
56         grid_type *g_ptr;
57         g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
58         monster_race *r_ptr = &r_info[m_ptr->r_idx];
59         if (!turn_flags_ptr->do_move || !is_explosive_rune_grid(g_ptr) ||
60                 (((r_ptr->flags1 & RF1_NEVER_BLOW) != 0) && player_bold(target_ptr, ny, nx)))
61                 return TRUE;
62
63         turn_flags_ptr->do_move = FALSE;
64         if (is_pet(m_ptr)) return TRUE;
65
66         if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
67         {
68                 if (g_ptr->info & CAVE_MARK)
69                 {
70                         msg_print(_("ルーンが爆発した!", "The rune explodes!"));
71                         BIT_FLAGS project_flags = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI;
72                         project(target_ptr, 0, 2, ny, nx, 2 * (target_ptr->lev + damroll(7, 7)), GF_MANA, project_flags, -1);
73                 }
74         }
75         else
76         {
77                 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
78         }
79
80         g_ptr->info &= ~(CAVE_MARK);
81         g_ptr->info &= ~(CAVE_OBJECT);
82         g_ptr->mimic = 0;
83
84         note_spot(target_ptr, ny, nx);
85         lite_spot(target_ptr, ny, nx);
86
87         if (!monster_is_valid(m_ptr)) return FALSE;
88
89         turn_flags_ptr->do_move = TRUE;
90         return TRUE;
91 }