OSDN Git Service

[Fix] #37285 ティボルトのUNIQUE属性付加忘れを修正。
[hengband/hengband.git] / src / spells2.c
index 90eccf0..952dc5a 100644 (file)
@@ -28,6 +28,8 @@
 #include "spells-floor.h"
 #include "realm-hex.h"
 #include "object-hook.h"
+#include "monster-status.h"
+#include "player-status.h"
 
 /*!
  * @brief プレイヤー周辺の地形を感知する
@@ -373,9 +375,7 @@ bool detect_monsters_normal(POSITION range)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -422,8 +422,7 @@ bool detect_monsters_invis(POSITION range)
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -474,9 +473,7 @@ bool detect_monsters_evil(POSITION range)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -530,9 +527,7 @@ bool detect_monsters_nonliving(POSITION range)
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
-
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -581,9 +576,7 @@ bool detect_monsters_mind(POSITION range)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -634,9 +627,7 @@ bool detect_monsters_string(POSITION range, concptr Match)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -689,9 +680,7 @@ bool detect_monsters_xxx(POSITION range, u32b match_flag)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -786,14 +775,11 @@ bool project_all_los(EFFECT_ID typ, HIT_POINT dam)
        BIT_FLAGS flg = PROJECT_JUMP | PROJECT_KILL | PROJECT_HIDE;
        bool obvious = FALSE;
 
-
        /* Mark all (nearby) monsters */
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
-
-               /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -802,7 +788,7 @@ bool project_all_los(EFFECT_ID typ, HIT_POINT dam)
                if (!player_has_los_bold(y, x) || !projectable(p_ptr->y, p_ptr->x, y, x)) continue;
 
                /* Mark the monster */
-               m_ptr->mflag |= (MFLAG_TEMP);
+               m_ptr->mflag |= (MFLAG_LOS);
        }
 
        /* Affect all marked monsters */
@@ -811,10 +797,10 @@ bool project_all_los(EFFECT_ID typ, HIT_POINT dam)
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Skip unmarked monsters */
-               if (!(m_ptr->mflag & (MFLAG_TEMP))) continue;
+               if (!(m_ptr->mflag & (MFLAG_LOS))) continue;
 
                /* Remove mark */
-               m_ptr->mflag &= ~(MFLAG_TEMP);
+               m_ptr->mflag &= ~(MFLAG_LOS);
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -981,9 +967,7 @@ void aggravate_monsters(MONSTER_IDX who)
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
-
-               /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip aggravating monster (or player) */
                if (i == who) continue;
@@ -1132,9 +1116,7 @@ bool symbol_genocide(int power, bool player_cast)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip "wrong" monsters */
                if (r_ptr->d_char != typ) continue;
@@ -1173,9 +1155,7 @@ bool mass_genocide(int power, bool player_cast)
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
-
-               /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip distant monsters */
                if (m_ptr->cdis > MAX_SIGHT) continue;
@@ -1216,9 +1196,7 @@ bool mass_genocide_undead(int power, bool player_cast)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                if (!(r_ptr->flags3 & RF3_UNDEAD)) continue;
 
@@ -1262,9 +1240,7 @@ bool probing(void)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Require line of sight */
                if (!player_has_los_bold(m_ptr->fy, m_ptr->fx)) continue;
@@ -1491,8 +1467,6 @@ bool destroy_area(POSITION y1, POSITION x1, POSITION r, bool in_generate)
                                {
                                        object_type *o_ptr;
                                        o_ptr = &current_floor_ptr->o_list[this_o_idx];
-
-                                       /* Acquire next object */
                                        next_o_idx = o_ptr->next_o_idx;
 
                                        /* Hack -- Preserve unknown artifacts */
@@ -1745,7 +1719,6 @@ bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
                /* Check around the player */
                for (i = 0; i < 8; i++)
                {
-                       /* Access the location */
                        y = p_ptr->y + ddy_ddd[i];
                        x = p_ptr->x + ddx_ddd[i];
 
@@ -1838,10 +1811,7 @@ bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
                        {
                                GAME_TEXT m_name[MAX_NLEN];
                                monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
-
-                               /* Get the monster's real name */
-                               monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
-
+                               monster_desc(m_name, m_ptr, MD_WRONGDOER_NAME);
                                killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name);
                        }
                        else
@@ -2193,10 +2163,10 @@ static void cave_temp_room_lite(void)
        int i;
 
        /* Clear them all */
-       for (i = 0; i < temp_n; i++)
+       for (i = 0; i < tmp_pos.n; i++)
        {
-               POSITION y = temp_y[i];
-               POSITION x = temp_x[i];
+               POSITION y = tmp_pos.y[i];
+               POSITION x = tmp_pos.x[i];
 
                grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
 
@@ -2212,7 +2182,7 @@ static void cave_temp_room_lite(void)
                /* Process affected monsters */
                if (g_ptr->m_idx)
                {
-                       int chance = 25;
+                       PERCENTAGE chance = 25;
                        monster_type    *m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
                        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
                        update_monster(g_ptr->m_idx, FALSE);
@@ -2245,7 +2215,7 @@ static void cave_temp_room_lite(void)
        }
 
        /* None left */
-       temp_n = 0;
+       tmp_pos.n = 0;
 }
 
 
@@ -2267,10 +2237,10 @@ static void cave_temp_room_unlite(void)
        int i;
 
        /* Clear them all */
-       for (i = 0; i < temp_n; i++)
+       for (i = 0; i < tmp_pos.n; i++)
        {
-               POSITION y = temp_y[i];
-               POSITION x = temp_x[i];
+               POSITION y = tmp_pos.y[i];
+               POSITION x = tmp_pos.x[i];
                int j;
 
                grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
@@ -2326,7 +2296,7 @@ static void cave_temp_room_unlite(void)
        }
 
        /* None left */
-       temp_n = 0;
+       tmp_pos.n = 0;
 }
 
 
@@ -2395,7 +2365,7 @@ static int next_to_walls_adj(POSITION cy, POSITION cx, bool (*pass_bold)(POSITIO
 
 
 /*!
- * @brief 部屋内にある一点の周囲に該当する地形数かいくつあるかをグローバル変数temp_nに返す / Aux function -- see below
+ * @brief 部屋内にある一点の周囲に該当する地形数かいくつあるかをグローバル変数tmp_pos.nに返す / Aux function -- see below
  * @param y 部屋内のy座標1点
  * @param x 部屋内のx座標1点
  * @param only_room 部屋内地形のみをチェック対象にするならば TRUE
@@ -2435,15 +2405,15 @@ static void cave_temp_room_aux(POSITION y, POSITION x, bool only_room, bool (*pa
        }
 
        /* Paranoia -- verify space */
-       if (temp_n == TEMP_MAX) return;
+       if (tmp_pos.n == TEMP_MAX) return;
 
        /* Mark the grid as "seen" */
        g_ptr->info |= (CAVE_TEMP);
 
        /* Add it to the "seen" set */
-       temp_y[temp_n] = y;
-       temp_x[temp_n] = x;
-       temp_n++;
+       tmp_pos.y[tmp_pos.n] = y;
+       tmp_pos.x[tmp_pos.n] = x;
+       tmp_pos.n++;
 }
 
 /*!
@@ -2458,7 +2428,7 @@ static bool cave_pass_lite_bold(POSITION y, POSITION x)
 }
 
 /*!
- * @brief 部屋内にある一点の周囲がいくつ光を通すかをグローバル変数temp_nに返す / Aux function -- see below
+ * @brief 部屋内にある一点の周囲がいくつ光を通すかをグローバル変数tmp_pos.nに返す / Aux function -- see below
  * @param y 指定Y座標
  * @param x 指定X座標
  * @return なし
@@ -2481,7 +2451,7 @@ static bool cave_pass_dark_bold(POSITION y, POSITION x)
 
 
 /*!
- * @brief 部屋内にある一点の周囲がいくつ射線を通すかをグローバル変数temp_nに返す / Aux function -- see below
+ * @brief 部屋内にある一点の周囲がいくつ射線を通すかをグローバル変数tmp_pos.nに返す / Aux function -- see below
  * @param y 指定Y座標
  * @param x 指定X座標
  * @return なし
@@ -2507,9 +2477,9 @@ void lite_room(POSITION y1, POSITION x1)
        cave_temp_lite_room_aux(y1, x1);
 
        /* While grids are in the queue, add their neighbors */
-       for (i = 0; i < temp_n; i++)
+       for (i = 0; i < tmp_pos.n; i++)
        {
-               x = temp_x[i], y = temp_y[i];
+               x = tmp_pos.x[i], y = tmp_pos.y[i];
 
                /* Walls get lit, but stop light */
                if (!cave_pass_lite_bold(y, x)) continue;
@@ -2552,9 +2522,9 @@ void unlite_room(POSITION y1, POSITION x1)
        cave_temp_unlite_room_aux(y1, x1);
 
        /* Spread, breadth first */
-       for (i = 0; i < temp_n; i++)
+       for (i = 0; i < tmp_pos.n; i++)
        {
-               x = temp_x[i], y = temp_y[i];
+               x = tmp_pos.x[i], y = tmp_pos.y[i];
 
                /* Walls get dark, but stop darkness */
                if (!cave_pass_dark_bold(y, x)) continue;
@@ -2647,7 +2617,6 @@ bool unlite_area(HIT_POINT dam, POSITION rad)
 {
        BIT_FLAGS flg = PROJECT_GRID | PROJECT_KILL;
 
-       /* Hack -- Message */
        if (!p_ptr->blind)
        {
                msg_print(_("暗闇が辺りを覆った。", "Darkness surrounds you."));
@@ -5166,8 +5135,6 @@ bool rodeo(player_type *creature_ptr)
        {
                msg_format(_("%sに振り落とされた!", "You have thrown off by %s."), m_name);
                rakuba(1, TRUE);
-
-               /* Paranoia */
                /* 落馬処理に失敗してもとにかく乗馬解除 */
                creature_ptr->riding = 0;
        }