OSDN Git Service

[Refactor] #37353 PROJECT_* 定義を新規ファイル projection.h へ移動。 / Move PROJECT_* definition...
[hengband/hengband.git] / src / mspells2.c
index 07b2d5a..c7f4b85 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include "angband.h"
+#include "projection.h"
 
 /*!
  * @brief モンスターが敵対モンスターにビームを当てること可能かを判定する /
@@ -73,7 +74,7 @@ static bool direct_beam(int y1, int x1, int y2, int x2, monster_type *m_ptr)
  * @param is_friend TRUEならば、プレイヤーを巻き込む時にブレスの判定をFALSEにする。
  * @return ブレスを直接当てられるならばTRUEを返す
  */
-static bool breath_direct(POSITION y1, POSITION x1, POSITION y2, POSITION x2, POSITION rad, int typ, bool is_friend)
+static bool breath_direct(POSITION y1, POSITION x1, POSITION y2, POSITION x2, POSITION rad, EFFECT_ID typ, bool is_friend)
 {
        /* Must be the same as projectable() */
 
@@ -191,7 +192,7 @@ static bool breath_direct(POSITION y1, POSITION x1, POSITION y2, POSITION x2, PO
  * @param flg 判定のフラグ配列
  * @return なし
  */
-void get_project_point(int sy, int sx, int *ty, int *tx, BIT_FLAGS flg)
+void get_project_point(POSITION sy, POSITION sx, POSITION *ty, POSITION *tx, BIT_FLAGS flg)
 {
        u16b path_g[128];
        int  path_n, i;
@@ -222,7 +223,7 @@ void get_project_point(int sy, int sx, int *ty, int *tx, BIT_FLAGS flg)
  * @param t_idx 目標のモンスターID
  * @return 魔力消去を使うべきならばTRUEを変えす。
  */
-static bool dispel_check_monster(MONSTER_IDX m_idx, IDX t_idx)
+static bool dispel_check_monster(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 {
        monster_type *t_ptr = &m_list[t_idx];
 
@@ -257,7 +258,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
 {
        POSITION y = 0, x = 0;
        int i, k;
-       MONSTER_IDX t_idx = 0;
+       MONSTER_IDX target_idx = 0;
        int thrown_spell;
        HIT_POINT dam = 0;
        int start;
@@ -265,8 +266,8 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
 
        byte spell[96], num = 0;
 
-       char m_name[160];
-       char t_name[160];
+       GAME_TEXT m_name[160];
+       GAME_TEXT t_name[160];
 
 #ifndef JP
        char m_poss[160];
@@ -300,30 +301,30 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
        /* Target is given for pet? */
        if (pet_t_m_idx && pet)
        {
-               t_idx = pet_t_m_idx;
-               t_ptr = &m_list[t_idx];
+               target_idx = pet_t_m_idx;
+               t_ptr = &m_list[target_idx];
 
                /* Cancel if not projectable (for now) */
-               if ((m_idx == t_idx) || !projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx))
+               if ((m_idx == target_idx) || !projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx))
                {
-                       t_idx = 0;
+                       target_idx = 0;
                }
        }
 
        /* Is there counter attack target? */
-       if (!t_idx && m_ptr->target_y)
+       if (!target_idx && m_ptr->target_y)
        {
-               t_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
+               target_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
 
-               if (t_idx)
+               if (target_idx)
                {
-                       t_ptr = &m_list[t_idx];
+                       t_ptr = &m_list[target_idx];
 
                        /* Cancel if neither enemy nor a given target */
-                       if ((m_idx == t_idx) ||
-                           ((t_idx != pet_t_m_idx) && !are_enemies(m_ptr, t_ptr)))
+                       if ((m_idx == target_idx) ||
+                           ((target_idx != pet_t_m_idx) && !are_enemies(m_ptr, t_ptr)))
                        {
-                               t_idx = 0;
+                               target_idx = 0;
                        }
 
                        /* Allow only summoning etc.. if not projectable */
@@ -337,7 +338,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
        }
 
        /* Look for enemies normally */
-       if (!t_idx)
+       if (!target_idx)
        {
                bool success = FALSE;
 
@@ -354,14 +355,14 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
                        MONSTER_IDX dummy = (i % m_max);
                        if (!dummy) continue;
 
-                       t_idx = dummy;
-                       t_ptr = &m_list[t_idx];
+                       target_idx = dummy;
+                       t_ptr = &m_list[target_idx];
 
                        /* Skip dead monsters */
                        if (!t_ptr->r_idx) continue;
 
                        /* Monster must be 'an enemy' */
-                       if ((m_idx == t_idx) || !are_enemies(m_ptr, t_ptr)) continue;
+                       if ((m_idx == target_idx) || !are_enemies(m_ptr, t_ptr)) continue;
 
                        /* Monster must be projectable */
                        if (!projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) continue;
@@ -474,8 +475,8 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
                            (f5 & RF5_BALL_MASK) ||
                            (f6 & RF6_BALL_MASK))
                        {
-                               int real_y = y;
-                               int real_x = x;
+                               POSITION real_y = y;
+                               POSITION real_x = x;
 
                                get_project_point(m_ptr->fy, m_ptr->fx, &real_y, &real_x, 0L);
 
@@ -505,17 +506,15 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
 
                        if (f4 & RF4_ROCKET)
                        {
-                               int real_y = y;
-                               int real_x = x;
+                               POSITION real_y = y;
+                               POSITION real_x = x;
 
                                get_project_point(m_ptr->fy, m_ptr->fx, &real_y, &real_x, PROJECT_STOP);
                                if (projectable(real_y, real_x, p_ptr->y, p_ptr->x) && (distance(real_y, real_x, p_ptr->y, p_ptr->x) <= 2))
                                        f4 &= ~(RF4_ROCKET);
                        }
 
-                       if (((f4 & RF4_BEAM_MASK) ||
-                            (f5 & RF5_BEAM_MASK) ||
-                            (f6 & RF6_BEAM_MASK)) &&
+                       if (((f4 & RF4_BEAM_MASK) || (f5 & RF5_BEAM_MASK) || (f6 & RF6_BEAM_MASK)) &&
                            !direct_beam(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx, m_ptr))
                        {
                                f4 &= ~(RF4_BEAM_MASK);
@@ -523,12 +522,10 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
                                f6 &= ~(RF6_BEAM_MASK);
                        }
 
-                       if ((f4 & RF4_BREATH_MASK) ||
-                           (f5 & RF5_BREATH_MASK) ||
-                           (f6 & RF6_BREATH_MASK))
+                       if ((f4 & RF4_BREATH_MASK) || (f5 & RF5_BREATH_MASK) || (f6 & RF6_BREATH_MASK))
                        {
                                /* Expected breath radius */
-                               int rad = (r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2;
+                               POSITION rad = (r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2;
 
                                if (!breath_direct(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx, rad, 0, TRUE))
                                {
@@ -594,7 +591,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
                }
 
                /* Dispel magic */
-               if ((f4 & RF4_DISPEL) && !dispel_check_monster(m_idx, t_idx))
+               if ((f4 & RF4_DISPEL) && !dispel_check_monster(m_idx, target_idx))
                {
                        /* Remove dispel spell */
                        f4 &= ~(RF4_DISPEL);
@@ -630,7 +627,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
                }
 
                /* Hack -- decline "teleport level" in some case */
-               if ((f6 & RF6_TELE_LEVEL) && TELE_LEVEL_IS_INEFF((t_idx == p_ptr->riding) ? 0 : t_idx))
+               if ((f6 & RF6_TELE_LEVEL) && TELE_LEVEL_IS_INEFF((target_idx == p_ptr->riding) ? 0 : target_idx))
                {
                        f6 &= ~(RF6_TELE_LEVEL);
                }
@@ -680,13 +677,12 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
        /* Choose a spell to cast */
        thrown_spell = spell[randint0(num)];
 
-       if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(1, 1);
+       if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(TRUE, TRUE);
 
        /* Check for spell failure (inate attacks never fail) */
        if (!spell_is_inate(thrown_spell) && (in_no_magic_dungeon || (MON_STUNNED(m_ptr) && one_in_(2))))
        {
-               disturb(1, 1);
-               /* Message */
+               disturb(TRUE, TRUE);
                if (see_m) msg_format(_("%^sは呪文を唱えようとしたが失敗した。", 
                                            "%^s tries to cast a spell, but fails."), m_name);
 
@@ -703,8 +699,8 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
 
        can_remember = is_original_ap_and_seen(m_ptr);
 
-    dam = monspell_to_monster(thrown_spell, y, x, m_idx, t_idx);
-    if (dam < 0)return FALSE;
+       dam = monspell_to_monster(thrown_spell, y, x, m_idx, target_idx);
+       if (dam < 0) return FALSE;
 
        if (m_ptr->ml && maneable && !world_monster && !p_ptr->blind && (p_ptr->pclass == CLASS_IMITATOR))
        {