OSDN Git Service

[Refactor] #38993 m_cnt, m_max を floor_type 構造体に取り込み.
[hengband/hengband.git] / src / monster-process.c
index 4d04039..9056d1d 100644 (file)
  */
 
 #include "angband.h"
+#include "util.h"
+
 #include "cmd-pet.h"
+#include "melee.h"
+#include "spells.h"
+#include "spells-summon.h"
+#include "quest.h"
+#include "avatar.h"
+#include "realm-hex.h"
+#include "object-flavor.h"
+#include "object-hook.h"
+#include "feature.h"
+#include "grid.h"
+#include "player-move.h"
+#include "monster-status.h"
+#include "monster-spell.h"
+#include "monster-process.h"
+#include "monsterrace-hook.h"
+#include "dungeon.h"
+#include "floor.h"
+#include "files.h"
 
 
 /*!
@@ -28,49 +48,47 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
 {
        int i;
        POSITION x = 0, y = 0;
-       IDX t_idx;
+       MONSTER_IDX t_idx;
        int start;
        int plus = 1;
 
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
        monster_type *t_ptr;
 
        if (riding_t_m_idx && player_bold(m_ptr->fy, m_ptr->fx))
        {
-               y = m_list[riding_t_m_idx].fy;
-               x = m_list[riding_t_m_idx].fx;
+               y = current_floor_ptr->m_list[riding_t_m_idx].fy;
+               x = current_floor_ptr->m_list[riding_t_m_idx].fx;
        }
        else if (is_pet(m_ptr) && pet_t_m_idx)
        {
-               y = m_list[pet_t_m_idx].fy;
-               x = m_list[pet_t_m_idx].fx;
+               y = current_floor_ptr->m_list[pet_t_m_idx].fy;
+               x = current_floor_ptr->m_list[pet_t_m_idx].fx;
        }
        else
        {
                if (p_ptr->inside_battle)
                {
-                       start = randint1(m_max-1)+m_max;
+                       start = randint1(current_floor_ptr->m_max-1)+current_floor_ptr->m_max;
                        if(randint0(2)) plus = -1;
                }
-               else start = m_max + 1;
+               else start = current_floor_ptr->m_max + 1;
 
                /* Scan thru all monsters */
-               for (i = start; ((i < start + m_max) && (i > start - m_max)); i+=plus)
+               for (i = start; ((i < start + current_floor_ptr->m_max) && (i > start - current_floor_ptr->m_max)); i+=plus)
                {
-                       IDX dummy = (i % m_max);
+                       MONSTER_IDX dummy = (i % current_floor_ptr->m_max);
 
                        if (!dummy) continue;
 
                        t_idx = dummy;
-                       t_ptr = &m_list[t_idx];
+                       t_ptr = &current_floor_ptr->m_list[t_idx];
 
                        /* The monster itself isn't a target */
                        if (t_ptr == m_ptr) continue;
 
-                       /* Paranoia -- Skip dead monsters */
-                       if (!t_ptr->r_idx) continue;
+                       if (!monster_is_valid(t_ptr)) continue;
 
                        if (is_pet(m_ptr))
                        {
@@ -84,8 +102,7 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
                                        }
                                }
                                /* Hack -- no fighting away from player */
-                               else if ((m_ptr->cdis < t_ptr->cdis) &&
-                                                       (t_ptr->cdis > p_ptr->pet_follow_distance))
+                               else if ((m_ptr->cdis < t_ptr->cdis) && (t_ptr->cdis > p_ptr->pet_follow_distance))
                                {
                                        continue;
                                }
@@ -181,196 +198,6 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
        return TRUE;
 }
 
-
-/*!
- * @brief モンスターが敵モンスターに行う打撃処理 /
- * Hack, based on mon_take_hit... perhaps all monster attacks on other monsters should use this?
- * @param m_idx 目標となるモンスターの参照ID
- * @param dam ダメージ量
- * @param fear 目標となるモンスターの恐慌状態を返す参照ポインタ
- * @param note 目標モンスターが死亡した場合の特別メッセージ(NULLならば標準表示を行う)
- * @param who 打撃を行ったモンスターの参照ID
- * @return なし
- */
-void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, IDX who)
-{
-       monster_type *m_ptr = &m_list[m_idx];
-       monster_race *r_ptr = &r_info[m_ptr->r_idx];
-       char m_name[160];
-       bool seen = is_seen(m_ptr);
-
-       /* Can the player be aware of this attack? */
-       bool known = (m_ptr->cdis <= MAX_SIGHT);
-
-       /* Extract monster name */
-       monster_desc(m_name, m_ptr, 0);
-
-       /* Redraw (later) if needed */
-       if (m_ptr->ml)
-       {
-               if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
-               if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
-       }
-
-       (void)set_monster_csleep(m_idx, 0);
-
-       if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(TRUE, TRUE);
-
-       if (MON_INVULNER(m_ptr) && randint0(PENETRATE_INVULNERABILITY))
-       {
-               if (seen)
-               {
-                       msg_format(_("%^sはダメージを受けない。", "%^s is unharmed."), m_name);
-               }
-
-               return;
-       }
-
-       if (r_ptr->flagsr & RFR_RES_ALL)
-       {
-               if(dam > 0)
-               {
-                       dam /= 100;
-                       if((dam == 0) && one_in_(3)) dam = 1;
-               }
-               if(dam == 0)
-               {
-                       if (seen)
-                       {
-                               msg_format(_("%^sはダメージを受けない。", "%^s is unharmed."), m_name);
-                       }
-                       return;
-               }
-       }
-
-       /* Hurt it */
-       m_ptr->hp -= (s16b)dam;
-
-       /* It is dead now... or is it? */
-       if (m_ptr->hp < 0)
-       {
-               if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) ||
-                   (r_ptr->flags7 & RF7_NAZGUL)) &&
-                   !p_ptr->inside_battle)
-               {
-                       m_ptr->hp = 1;
-               }
-               else
-               {
-                       /* Make a sound */
-                       if (!monster_living(r_ptr))
-                       {
-                               sound(SOUND_N_KILL);
-                       }
-                       else
-                       {
-                               sound(SOUND_KILL);
-                       }
-
-                       if (known)
-                       {
-                               monster_desc(m_name, m_ptr, MD_TRUE_NAME);
-                               /* Unseen death by normal attack */
-                               if (!seen)
-                               {
-                                       mon_fight = TRUE;
-                               }
-                               /* Death by special attack */
-                               else if (note)
-                               {
-                                       msg_format(_("%^s%s", "%^s%s"), m_name, note);
-                               }
-                               /* Death by normal attack -- nonliving monster */
-                               else if (!monster_living(r_ptr))
-                               {
-                                       msg_format(_("%^sは破壊された。", "%^s is destroyed."), m_name);
-                               }
-                               /* Death by normal attack -- living monster */
-                               else
-                               {
-                                       msg_format(_("%^sは殺された。", "%^s is killed."), m_name);
-                               }
-                       }
-
-                       monster_gain_exp(who, m_ptr->r_idx);
-
-                       /* Generate treasure */
-                       monster_death(m_idx, FALSE);
-
-
-                       delete_monster_idx(m_idx);
-
-                       /* Not afraid */
-                       (*fear) = FALSE;
-
-                       /* Monster is dead */
-                       return;
-               }
-       }
-
-#ifdef ALLOW_FEAR
-
-       /* Mega-Hack -- Pain cancels fear */
-       if (MON_MONFEAR(m_ptr) && (dam > 0))
-       {
-               /* Cure fear */
-               if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam / 4)))
-               {
-                       /* No more fear */
-                       (*fear) = FALSE;
-               }
-       }
-
-       /* Sometimes a monster gets scared by damage */
-       if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & RF3_NO_FEAR))
-       {
-               /* Percentage of fully healthy */
-               int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
-
-               /*
-               * Run (sometimes) if at 10% or less of max hit points,
-               * or (usually) when hit for half its current hit points
-                */
-               if (((percentage <= 10) && (randint0(10) < percentage)) ||
-                       ((dam >= m_ptr->hp) && (randint0(100) < 80)))
-               {
-                       /* Hack -- note fear */
-                       (*fear) = TRUE;
-
-                       /* Hack -- Add some timed fear */
-                       (void)set_monster_monfear(m_idx, (randint1(10) +
-                               (((dam >= m_ptr->hp) && (percentage > 7)) ?
-                               20 : ((11 - percentage) * 5))));
-               }
-       }
-
-#endif /* ALLOW_FEAR */
-
-       if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr) && (who != m_idx))
-       {
-               if (is_pet(&m_list[who]) && !player_bold(m_ptr->target_y, m_ptr->target_x))
-               {
-                       set_target(m_ptr, m_list[who].fy, m_list[who].fx);
-               }
-       }
-
-       if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
-       {
-               /* Extract monster name */
-               monster_desc(m_name, m_ptr, 0);
-
-               if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
-               if (rakuba((dam > 200) ? 200 : dam, FALSE))
-               {
-                       msg_format(_("%^sに振り落とされた!", "You have thrown off from %s!"), m_name);
-               }
-       }
-
-       /* Not dead yet */
-       return;
-}
-
-
 /*!
  * @brief モンスターがプレイヤーから逃走するかどうかを返す /
  * Returns whether a given monster will try to run from the player.
@@ -389,13 +216,14 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
  */
 static bool mon_will_run(MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
 
 #ifdef ALLOW_TERROR
 
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       u16b p_lev, m_lev;
+       PLAYER_LEVEL p_lev;
+       DEPTH m_lev;
        HIT_POINT p_chp, p_mhp;
        HIT_POINT m_chp, m_mhp;
        u32b p_val, m_val;
@@ -466,11 +294,11 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        int i, best = 999;
        POSITION y, x, y1, x1;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
        bool can_open_door = FALSE;
        int now_cost;
 
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        /* Monster location */
@@ -481,7 +309,7 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        if (projectable(y1, x1, p_ptr->y, p_ptr->x)) return (FALSE);
 
        /* Set current grid cost */
-       now_cost = cave[y1][x1].cost;
+       now_cost = current_floor_ptr->grid_array[y1][x1].cost;
        if (now_cost == 0) now_cost = 999;
 
        /* Can monster bash or open doors? */
@@ -495,7 +323,6 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        {
                int cost;
 
-               /* Get the location */
                y = y1 + ddy_ddd[i];
                x = x1 + ddx_ddd[i];
 
@@ -505,15 +332,15 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                /* Simply move to player */
                if (player_bold(y, x)) return (FALSE);
 
-               c_ptr = &cave[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
-               cost = c_ptr->cost;
+               cost = g_ptr->cost;
 
                /* Monster cannot kill or pass walls */
                if (!(((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall)) || ((r_ptr->flags2 & RF2_KILL_WALL) && (m_idx != p_ptr->riding))))
                {
                        if (cost == 0) continue;
-                       if (!can_open_door && is_closed_door(c_ptr->feat)) continue;
+                       if (!can_open_door && is_closed_door(g_ptr->feat)) continue;
                }
 
                /* Hack -- for kill or pass wall monster.. */
@@ -572,10 +399,10 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
        int i, best;
        POSITION y, x, y1, x1;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
        bool use_scent = FALSE;
 
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        /* Can monster cast attack spell? */
@@ -602,19 +429,19 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
        if (player_has_los_bold(y1, x1) && projectable(p_ptr->y, p_ptr->x, y1, x1)) return (FALSE);
 
        /* Monster grid */
-       c_ptr = &cave[y1][x1];
+       g_ptr = &current_floor_ptr->grid_array[y1][x1];
 
        /* If we can hear noises, advance towards them */
-       if (c_ptr->cost)
+       if (g_ptr->cost)
        {
                best = 999;
        }
 
        /* Otherwise, try to follow a scent trail */
-       else if (c_ptr->when)
+       else if (g_ptr->when)
        {
                /* Too old smell */
-               if (cave[p_ptr->y][p_ptr->x].when - c_ptr->when > 127) return (FALSE);
+               if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when - g_ptr->when > 127) return (FALSE);
 
                use_scent = TRUE;
                best = 0;
@@ -629,19 +456,18 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
        /* Check nearby grids, diagonals first */
        for (i = 7; i >= 0; i--)
        {
-               /* Get the location */
                y = y1 + ddy_ddd[i];
                x = x1 + ddx_ddd[i];
 
                /* Ignore locations off of edge */
                if (!in_bounds2(y, x)) continue;
 
-               c_ptr = &cave[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* We're following a scent trail */
                if (use_scent)
                {
-                       int when = c_ptr->when;
+                       int when = g_ptr->when;
 
                        /* Accept younger scent */
                        if (best > when) continue;
@@ -654,8 +480,8 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
                        int cost;
 
                        if (r_ptr->flags2 & (RF2_BASH_DOOR | RF2_OPEN_DOOR))
-                               cost = c_ptr->dist;
-                       else cost = c_ptr->cost;
+                               cost = g_ptr->dist;
+                       else cost = g_ptr->cost;
 
                        /* Accept louder sounds */
                        if ((cost == 0) || (best < cost)) continue;
@@ -693,7 +519,7 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        int score = -1;
        int i;
 
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
 
        /* Monster location */
        fy = m_ptr->fy;
@@ -708,7 +534,6 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        {
                POSITION dis, s;
 
-               /* Get the location */
                y = fy + ddy_ddd[i];
                x = fx + ddx_ddd[i];
 
@@ -716,13 +541,13 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                if (!in_bounds2(y, x)) continue;
 
                /* Don't move toward player */
-               /* if (cave[y][x].dist < 3) continue; */ /* Hmm.. Need it? */
+               /* if (current_floor_ptr->grid_array[y][x].dist < 3) continue; */ /* Hmm.. Need it? */
 
                /* Calculate distance of this grid from our destination */
                dis = distance(y, x, y1, x1);
 
                /* Score this grid */
-               s = 5000 / (dis + 3) - 500 / (cave[y][x].dist + 1);
+               s = 5000 / (dis + 3) - 500 / (current_floor_ptr->grid_array[y][x].dist + 1);
 
                /* No negative scores */
                if (s < 0) s = 0;
@@ -773,89 +598,89 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
  */
 
 
-static sint d_off_y_0[] = { 0 };
-static sint d_off_x_0[] = { 0 };
+static POSITION d_off_y_0[] = { 0 };
+static POSITION d_off_x_0[] = { 0 };
 
-static sint d_off_y_1[] = { -1, -1, -1, 0, 0, 1, 1, 1, 0 };
-static sint d_off_x_1[] = { -1, 0, 1, -1, 1, -1, 0, 1, 0 };
+static POSITION d_off_y_1[] = { -1, -1, -1, 0, 0, 1, 1, 1, 0 };
+static POSITION d_off_x_1[] = { -1, 0, 1, -1, 1, -1, 0, 1, 0 };
 
-static sint d_off_y_2[] = { -1, -1, -2, -2, -2, 0, 0, 1, 1, 2, 2, 2, 0 };
-static sint d_off_x_2[] = { -2, 2, -1, 0, 1, -2, 2, -2, 2, -1, 0, 1, 0 };
+static POSITION d_off_y_2[] = { -1, -1, -2, -2, -2, 0, 0, 1, 1, 2, 2, 2, 0 };
+static POSITION d_off_x_2[] = { -2, 2, -1, 0, 1, -2, 2, -2, 2, -1, 0, 1, 0 };
 
-static sint d_off_y_3[] = { -1, -1, -2, -2, -3, -3, -3, 0, 0, 1, 1, 2, 2, 3, 3, 3, 0 };
-static sint d_off_x_3[] = { -3, 3, -2, 2, -1, 0, 1, -3, 3, -3, 3, -2, 2, -1, 0, 1, 0 };
+static POSITION d_off_y_3[] = { -1, -1, -2, -2, -3, -3, -3, 0, 0, 1, 1, 2, 2, 3, 3, 3, 0 };
+static POSITION d_off_x_3[] = { -3, 3, -2, 2, -1, 0, 1, -3, 3, -3, 3, -2, 2, -1, 0, 1, 0 };
 
-static sint d_off_y_4[] = { -1, -1, -2, -2, -3, -3, -3, -3, -4, -4, -4, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 0 };
-static sint d_off_x_4[] = { -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, -4, 4, -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, 0 };
+static POSITION d_off_y_4[] = { -1, -1, -2, -2, -3, -3, -3, -3, -4, -4, -4, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 0 };
+static POSITION d_off_x_4[] = { -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, -4, 4, -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, 0 };
 
 
-static sint d_off_y_5[] =
+static POSITION d_off_y_5[] =
 { -1, -1, -2, -2, -3, -3, -4, -4, -4, -4, -5, -5,
   -5, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5,
   5, 0 };
 
-static sint d_off_x_5[] =
+static POSITION d_off_x_5[] =
 { -5, 5, -4, 4, -4, 4, -2, -3, 2, 3, -1, 0, 1,
   -5, 5, -5, 5, -4, 4, -4, 4, -2, -3, 2, 3, -1,
   0, 1, 0 };
 
 
-static sint d_off_y_6[] =
+static POSITION d_off_y_6[] =
 { -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -5, -5,
   -6, -6, -6, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5,
   5, 5, 6, 6, 6, 0 };
 
-static sint d_off_x_6[] =
+static POSITION d_off_x_6[] =
 { -6, 6, -5, 5, -5, 5, -4, 4, -2, -3, 2, 3, -1,
   0, 1, -6, 6, -6, 6, -5, 5, -5, 5, -4, 4, -2,
   -3, 2, 3, -1, 0, 1, 0 };
 
 
-static sint d_off_y_7[] =
+static POSITION d_off_y_7[] =
 { -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -5, -5,
   -6, -6, -6, -6, -7, -7, -7, 0, 0, 1, 1, 2, 2, 3,
   3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 0 };
 
-static sint d_off_x_7[] =
+static POSITION d_off_x_7[] =
 { -7, 7, -6, 6, -6, 6, -5, 5, -4, -5, 4, 5, -2,
   -3, 2, 3, -1, 0, 1, -7, 7, -7, 7, -6, 6, -6,
   6, -5, 5, -4, -5, 4, 5, -2, -3, 2, 3, -1, 0,
   1, 0 };
 
 
-static sint d_off_y_8[] =
+static POSITION d_off_y_8[] =
 { -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6,
   -6, -6, -7, -7, -7, -7, -8, -8, -8, 0, 0, 1, 1,
   2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
   8, 8, 8, 0 };
 
-static sint d_off_x_8[] =
+static POSITION d_off_x_8[] =
 { -8, 8, -7, 7, -7, 7, -6, 6, -6, 6, -4, -5, 4,
   5, -2, -3, 2, 3, -1, 0, 1, -8, 8, -8, 8, -7,
   7, -7, 7, -6, 6, -6, 6, -4, -5, 4, 5, -2, -3,
   2, 3, -1, 0, 1, 0 };
 
 
-static sint d_off_y_9[] =
+static POSITION d_off_y_9[] =
 { -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6,
   -7, -7, -7, -7, -8, -8, -8, -8, -9, -9, -9, 0,
   0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7,
   7, 8, 8, 8, 8, 9, 9, 9, 0 };
 
-static sint d_off_x_9[] =
+static POSITION d_off_x_9[] =
 { -9, 9, -8, 8, -8, 8, -7, 7, -7, 7, -6, 6, -4,
   -5, 4, 5, -2, -3, 2, 3, -1, 0, 1, -9, 9, -9,
   9, -8, 8, -8, 8, -7, 7, -7, 7, -6, 6, -4, -5,
   4, 5, -2, -3, 2, 3, -1, 0, 1, 0 };
 
 
-static sint *dist_offsets_y[10] =
+static POSITION *dist_offsets_y[10] =
 {
        d_off_y_0, d_off_y_1, d_off_y_2, d_off_y_3, d_off_y_4,
        d_off_y_5, d_off_y_6, d_off_y_7, d_off_y_8, d_off_y_9
 };
 
-static sint *dist_offsets_x[10] =
+static POSITION *dist_offsets_x[10] =
 {
        d_off_x_0, d_off_x_1, d_off_x_2, d_off_x_3, d_off_x_4,
        d_off_x_5, d_off_x_6, d_off_x_7, d_off_x_8, d_off_x_9
@@ -881,7 +706,7 @@ static sint *dist_offsets_x[10] =
  */
 static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
 
        POSITION fy = m_ptr->fy;
        POSITION fx = m_ptr->fx;
@@ -889,10 +714,10 @@ static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        POSITION y, x, dy, dx, d, dis, i;
        POSITION gy = 0, gx = 0, gdis = 0;
 
-       sint *y_offsets;
-       sint *x_offsets;
+       POSITION *y_offsets;
+       POSITION *x_offsets;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
 
        /* Start with adjacent locations, spread further */
        for (d = 1; d < 10; d++)
@@ -912,19 +737,19 @@ static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                        /* Skip illegal locations */
                        if (!in_bounds(y, x)) continue;
 
-                       c_ptr = &cave[y][x];
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Skip locations in a wall */
-                       if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], (m_idx == p_ptr->riding) ? CEM_RIDING : 0)) continue;
+                       if (!monster_can_cross_terrain(g_ptr->feat, &r_info[m_ptr->r_idx], (m_idx == p_ptr->riding) ? CEM_RIDING : 0)) continue;
 
                        /* Check for "availability" (if monsters can flow) */
                        if (!(m_ptr->mflag2 & MFLAG2_NOFLOW))
                        {
                                /* Ignore grids very far from the player */
-                               if (c_ptr->dist == 0) continue;
+                               if (g_ptr->dist == 0) continue;
 
                                /* Ignore too-distant grids */
-                               if (c_ptr->dist > cave[fy][fx].dist + 2 * d) continue;
+                               if (g_ptr->dist > current_floor_ptr->grid_array[fy][fx].dist + 2 * d) continue;
                        }
 
                        /* Check for absence of shot (more or less) */
@@ -975,7 +800,7 @@ static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
  */
 static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        POSITION fy = m_ptr->fy;
@@ -984,7 +809,7 @@ static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        POSITION y, x, dy, dx, d, dis, i;
        POSITION gy = 0, gx = 0, gdis = 999;
 
-       sint *y_offsets, *x_offsets;
+       POSITION *y_offsets, *x_offsets;
 
        /* Start with adjacent locations, spread further */
        for (d = 1; d < 10; d++)
@@ -1047,9 +872,9 @@ static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
  * @param mm 移動方向を返す方向IDの参照ポインタ
  * @return 有効方向があった場合TRUEを返す
  */
-static bool get_moves(MONSTER_IDX m_idx, int *mm)
+static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        POSITION     y = 0, ay, x = 0, ax;
        int          move_val = 0;
@@ -1057,18 +882,18 @@ static bool get_moves(MONSTER_IDX m_idx, int *mm)
        POSITION     x2 = p_ptr->x;
        bool         done = FALSE;
        bool         will_run = mon_will_run(m_idx);
-       cave_type    *c_ptr;
-       bool         no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (cave[m_ptr->fy][m_ptr->fx].cost > 2));
+       grid_type    *g_ptr;
+       bool         no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].cost > 2));
        bool         can_pass_wall = ((r_ptr->flags2 & RF2_PASS_WALL) && ((m_idx != p_ptr->riding) || p_ptr->pass_wall));
 
        /* Counter attack to an enemy monster */
        if (!will_run && m_ptr->target_y)
        {
-               int t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
+               int t_m_idx = current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
 
                /* The monster must be an enemy, and in LOS */
                if (t_m_idx &&
-                   are_enemies(m_ptr, &m_list[t_m_idx]) &&
+                   are_enemies(m_ptr, &current_floor_ptr->m_list[t_m_idx]) &&
                    los(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x) &&
                    projectable(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
                {
@@ -1082,7 +907,7 @@ static bool get_moves(MONSTER_IDX m_idx, int *mm)
        if (!done && !will_run && is_hostile(m_ptr) &&
            (r_ptr->flags1 & RF1_FRIENDS) &&
            ((los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) ||
-           (cave[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
+           (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
        {
        /*
         * Animal packs try to get the player out of corridors
@@ -1101,16 +926,16 @@ static bool get_moves(MONSTER_IDX m_idx, int *mm)
 
                                if (!in_bounds2(yy, xx)) continue;
 
-                               c_ptr = &cave[yy][xx];
+                               g_ptr = &current_floor_ptr->grid_array[yy][xx];
 
                                /* Check grid */
-                               if (monster_can_cross_terrain(c_ptr->feat, r_ptr, 0))
+                               if (monster_can_cross_terrain(g_ptr->feat, r_ptr, 0))
                                {
                                        /* One more room grid */
                                        room++;
                                }
                        }
-                       if (cave[p_ptr->y][p_ptr->x].info & CAVE_ROOM) room -= 2;
+                       if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_ROOM) room -= 2;
                        if (!r_ptr->flags4 && !r_ptr->a_ability_flags1 && !r_ptr->a_ability_flags2) room -= 2;
 
                        /* Not in a room and strong player */
@@ -1123,7 +948,7 @@ static bool get_moves(MONSTER_IDX m_idx, int *mm)
                }
 
                /* Monster groups try to surround the player */
-               if (!done && (cave[m_ptr->fy][m_ptr->fx].dist < 3))
+               if (!done && (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < 3))
                {
                        int i;
 
@@ -1418,8 +1243,8 @@ static int check_hit2(int power, DEPTH level, ARMOUR_CLASS ac, int stun)
  */
 static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 {
-       monster_type    *m_ptr = &m_list[m_idx];
-       monster_type    *t_ptr = &m_list[t_idx];
+       monster_type    *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type    *t_ptr = &current_floor_ptr->m_list[t_idx];
 
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
        monster_race    *tr_ptr = &r_info[t_ptr->r_idx];
@@ -1428,12 +1253,12 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
        ARMOUR_CLASS ac;
        DEPTH rlev;
        int pt;
-       char            m_name[80], t_name[80];
+       GAME_TEXT m_name[MAX_NLEN], t_name[MAX_NLEN];
        char            temp[MAX_NLEN];
        bool            blinked;
-       bool            explode = FALSE, touched = FALSE, fear = FALSE;
-       int             y_saver = t_ptr->fy;
-       int             x_saver = t_ptr->fx;
+       bool            explode = FALSE, touched = FALSE, fear = FALSE, dead = FALSE;
+       POSITION y_saver = t_ptr->fy;
+       POSITION x_saver = t_ptr->fx;
        int             effect_type;
 
        bool see_m = is_seen(m_ptr);
@@ -1450,7 +1275,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
        /* Not allowed to attack */
        if (r_ptr->flags1 & RF1_NEVER_BLOW) return FALSE;
 
-       if (d_info[dungeon_type].flags1 & DF1_NO_MELEE) return (FALSE);
+       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE) return (FALSE);
 
        /* Total armor */
        ac = tr_ptr->ac;
@@ -1458,10 +1283,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
        /* Extract the effective monster level */
        rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
 
-       /* Get the monster name (or "it") */
        monster_desc(m_name, m_ptr, 0);
-
-       /* Get the monster name (or "it") */
        monster_desc(t_name, t_ptr, 0);
 
        /* Assume no blink */
@@ -1482,7 +1304,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                HIT_POINT power = 0;
                HIT_POINT damage = 0;
 
-               cptr act = NULL;
+               concptr act = NULL;
 
                /* Extract the attack infomation */
                int effect = r_ptr->blow[ap_cnt].effect;
@@ -1490,7 +1312,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                int d_dice = r_ptr->blow[ap_cnt].d_dice;
                int d_side = r_ptr->blow[ap_cnt].d_side;
 
-               if (!m_ptr->r_idx) break;
+               if (!monster_is_valid(m_ptr)) break;
 
                /* Stop attacking if the target dies! */
                if (t_ptr->fx != x_saver || t_ptr->fy != y_saver)
@@ -1850,7 +1672,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                                        break;
 
                                case BLOW_EFFECT_TYPE_HEAL:
-                                       if ((monster_living(tr_ptr)) && (damage > 2))
+                                       if ((monster_living(m_idx)) && (damage > 2))
                                        {
                                                bool did_heal = FALSE;
 
@@ -1999,7 +1821,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 
                /* Cancel Invulnerability */
                (void)set_monster_invulner(m_idx, 0, FALSE);
-               mon_take_hit_mon(m_idx, m_ptr->hp + 1, &fear, _("は爆発して粉々になった。", " explodes into tiny shreds."), m_idx);
+               mon_take_hit_mon(m_idx, m_ptr->hp + 1, &dead, &fear, _("は爆発して粉々になった。", " explodes into tiny shreds."), m_idx);
                blinked = FALSE;
        }
 
@@ -2039,8 +1861,8 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 static bool check_hp_for_feat_destruction(feature_type *f_ptr, monster_type *m_ptr)
 {
        return !have_flag(f_ptr->flags, FF_GLASS) ||
-              (r_info[m_ptr->r_idx].flags2 & RF2_STUPID) ||
-              (m_ptr->hp >= MAX(m_ptr->maxhp / 3, 200));
+               (r_info[m_ptr->r_idx].flags2 & RF2_STUPID) ||
+               (m_ptr->hp >= MAX(m_ptr->maxhp / 3, 200));
 }
 
 
@@ -2075,16 +1897,16 @@ static bool check_hp_for_feat_destruction(feature_type *f_ptr, monster_type *m_p
  */
 void process_monster(MONSTER_IDX m_idx)
 {
-       monster_type    *m_ptr = &m_list[m_idx];
+       monster_type    *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
        monster_race    *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
 
-       int             i, d;
-       POSITION        oy, ox, ny, nx;
+       int i, d;
+       POSITION oy, ox, ny, nx;
 
-       int             mm[8];
+       DIRECTION mm[8];
 
-       cave_type       *c_ptr;
+       grid_type       *g_ptr;
        feature_type    *f_ptr;
 
        monster_type    *y_ptr;
@@ -2105,11 +1927,9 @@ void process_monster(MONSTER_IDX m_idx)
        bool            can_cross;
        bool            aware = TRUE;
 
-       bool            fear;
-
-       bool            is_riding_mon = (m_idx == p_ptr->riding);
-
-       bool            see_m = is_seen(m_ptr);
+       bool fear, dead;
+       bool is_riding_mon = (m_idx == p_ptr->riding);
+       bool see_m = is_seen(m_ptr);
 
        if (is_riding_mon && !(r_ptr->flags7 & RF7_RIDING))
        {
@@ -2118,8 +1938,8 @@ void process_monster(MONSTER_IDX m_idx)
 #ifdef JP
                        msg_print("地面に落とされた。");
 #else
-                       char m_name[80];
-                       monster_desc(m_name, &m_list[p_ptr->riding], 0);
+                       GAME_TEXT m_name[MAX_NLEN];
+                       monster_desc(m_name, &current_floor_ptr->m_list[p_ptr->riding], 0);
                        msg_format("You have fallen from %s.", m_name);
 #endif
                }
@@ -2137,34 +1957,30 @@ void process_monster(MONSTER_IDX m_idx)
                int tmp = p_ptr->lev*6+(p_ptr->skill_stl+10)*4;
                if (p_ptr->monlite) tmp /= 3;
                if (p_ptr->cursed & TRC_AGGRAVATE) tmp /= 2;
-               if (r_ptr->level > (p_ptr->lev*p_ptr->lev/20+10)) tmp /= 3;
+               if (r_ptr->level > (p_ptr->lev * p_ptr->lev / 20 + 10)) tmp /= 3;
                /* Low-level monsters will find it difficult to locate the player. */
                if (randint0(tmp) > (r_ptr->level+20)) aware = FALSE;
        }
 
        /* Are there its parent? */
-       if (m_ptr->parent_m_idx && !m_list[m_ptr->parent_m_idx].r_idx)
+       if (m_ptr->parent_m_idx && !current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx)
        {
                /* Its parent have gone, it also goes away. */
 
                if (see_m)
                {
-                       char m_name[80];
-
-                       /* Acquire the monster name */
+                       GAME_TEXT m_name[MAX_NLEN];
                        monster_desc(m_name, m_ptr, 0);
                        msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
                }
 
                if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
                {
-                       char m_name[80];
-
+                       GAME_TEXT m_name[MAX_NLEN];
                        monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
                        do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_LOSE_PARENT, m_name);
                }
 
-
                delete_monster_idx(m_idx);
 
                return;
@@ -2181,14 +1997,11 @@ void process_monster(MONSTER_IDX m_idx)
                {
                        bool sad = FALSE;
 
-                       if (is_pet(m_ptr) && !(m_ptr->ml))
-                               sad = TRUE;
+                       if (is_pet(m_ptr) && !(m_ptr->ml)) sad = TRUE;
 
                        if (see_m)
                        {
-                               char m_name[80];
-
-                               /* Acquire the monster name */
+                               GAME_TEXT m_name[MAX_NLEN];
                                monster_desc(m_name, m_ptr, 0);
 
                                msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
@@ -2197,9 +2010,7 @@ void process_monster(MONSTER_IDX m_idx)
                        /* Generate treasure, etc */
                        monster_death(m_idx, FALSE);
 
-
                        delete_monster_idx(m_idx);
-
                        if (sad)
                        {
                                msg_print(_("少しの間悲しい気分になった。", "You feel sad for a moment."));
@@ -2211,7 +2022,8 @@ void process_monster(MONSTER_IDX m_idx)
 
        if (m_ptr->r_idx == MON_SHURYUUDAN)
        {
-               mon_take_hit_mon(m_idx, 1, &fear, _("は爆発して粉々になった。", " explodes into tiny shreds."), m_idx);
+               mon_take_hit_mon(m_idx, 1, &dead, &fear, _("は爆発して粉々になった。", " explodes into tiny shreds."), m_idx);
+               if(dead) return;
        }
 
        if ((is_pet(m_ptr) || is_friendly(m_ptr)) && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) && !p_ptr->inside_battle)
@@ -2220,7 +2032,7 @@ void process_monster(MONSTER_IDX m_idx)
 
                if (m_ptr->hp < m_ptr->maxhp/3)
                {
-                       char m_name[80];
+                       GAME_TEXT m_name[MAX_NLEN];
                        monster_desc(m_name, m_ptr, 0);
 
                        if (is_riding_mon && riding_pinch < 2)
@@ -2257,11 +2069,8 @@ void process_monster(MONSTER_IDX m_idx)
                                        msg_print(_("地面に落とされた。", "You have fallen from riding pet."));
                                }
 
-                               /* Check for quest completion */
                                check_quest_completion(m_ptr);
-
                                delete_monster_idx(m_idx);
-
                                return;
                        }
                }
@@ -2278,20 +2087,13 @@ void process_monster(MONSTER_IDX m_idx)
                /* Handle non-aggravation - Still sleeping */
                if (!(p_ptr->cursed & TRC_AGGRAVATE)) return;
 
-               /* Handle aggravation */
-
-               /* Reset sleep counter */
                (void)set_monster_csleep(m_idx, 0);
 
                /* Notice the "waking up" */
                if (m_ptr->ml)
                {
-                       char m_name[80];
-
-                       /* Acquire the monster name */
+                       GAME_TEXT m_name[MAX_NLEN];
                        monster_desc(m_name, m_ptr, 0);
-
-                       /* Dump a message */
                        msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
                }
 
@@ -2319,10 +2121,8 @@ void process_monster(MONSTER_IDX m_idx)
                gets_angry = TRUE;
 
        /* Paranoia... no pet uniques outside wizard mode -- TY */
-       if (is_pet(m_ptr) &&
-           ((((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
-             monster_has_hostile_align(NULL, 10, -10, r_ptr))
-            || (r_ptr->flagsr & RFR_RES_ALL)))
+       if (is_pet(m_ptr) && ((((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
+             monster_has_hostile_align(NULL, 10, -10, r_ptr)) || (r_ptr->flagsr & RFR_RES_ALL)))
        {
                gets_angry = TRUE;
        }
@@ -2333,7 +2133,7 @@ void process_monster(MONSTER_IDX m_idx)
        {
                if (is_pet(m_ptr) || see_m)
                {
-                       char m_name[80];
+                       GAME_TEXT m_name[MAX_NLEN];
                        monster_desc(m_name, m_ptr, is_pet(m_ptr) ? MD_ASSUME_VISIBLE : 0);
                        msg_format(_("%^sは突然敵にまわった!", "%^s suddenly becomes hostile!"), m_name);
                }
@@ -2345,11 +2145,11 @@ void process_monster(MONSTER_IDX m_idx)
        oy = m_ptr->fy;
        ox = m_ptr->fx;
 
-
        /* Attempt to "multiply" if able and allowed */
-       if ((r_ptr->flags2 & RF2_MULTIPLY) && (num_repro < MAX_REPRO))
+       if ((r_ptr->flags2 & RF2_MULTIPLY) && (current_floor_ptr->num_repro < MAX_REPRO))
        {
-               int k, y, x;
+               int k;
+               POSITION y, x;
 
                /* Count the adjacent monsters */
                for (k = 0, y = oy - 1; y <= oy + 1; y++)
@@ -2358,8 +2158,7 @@ void process_monster(MONSTER_IDX m_idx)
                        {
                                /* Ignore locations off of edge */
                                if (!in_bounds2(y, x)) continue;
-
-                               if (cave[y][x].m_idx) k++;
+                               if (current_floor_ptr->grid_array[y][x].m_idx) k++;
                        }
                }
 
@@ -2373,7 +2172,7 @@ void process_monster(MONSTER_IDX m_idx)
                        if (multiply_monster(m_idx, FALSE, (is_pet(m_ptr) ? PM_FORCE_PET : 0)))
                        {
                                /* Take note if visible */
-                               if (m_list[hack_m_idx_ii].ml && is_original_ap_and_seen(m_ptr))
+                               if (current_floor_ptr->m_list[hack_m_idx_ii].ml && is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags2 |= (RF2_MULTIPLY);
                                }
@@ -2384,7 +2183,6 @@ void process_monster(MONSTER_IDX m_idx)
                }
        }
 
-
        if (r_ptr->a_ability_flags2 & RF6_SPECIAL)
        {
                /* Hack -- Ohmu scatters molds! */
@@ -2394,15 +2192,15 @@ void process_monster(MONSTER_IDX m_idx)
                        {
                                if (r_ptr->freq_spell && (randint1(100) <= r_ptr->freq_spell))
                                {
-                                       int  k, count = 0;
-                                       int  rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
-                                       u32b p_mode = is_pet(m_ptr) ? PM_FORCE_PET : 0L;
+                                       int k, count = 0;
+                                       DEPTH rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
+                                       BIT_FLAGS p_mode = is_pet(m_ptr) ? PM_FORCE_PET : 0L;
 
-                                       for (k = 0; k < 6; k++)
+                                       for (k = 0; k < A_MAX; k++)
                                        {
-                                               if (summon_specific(m_idx, m_ptr->fy, m_ptr->fx, rlev, SUMMON_MOLD, (PM_ALLOW_GROUP | p_mode)))
+                                               if (summon_specific(m_idx, m_ptr->fy, m_ptr->fx, rlev, SUMMON_MOLD, (PM_ALLOW_GROUP | p_mode), '\0'))
                                                {
-                                                       if (m_list[hack_m_idx_ii].ml) count++;
+                                                       if (current_floor_ptr->m_list[hack_m_idx_ii].ml) count++;
                                                }
                                        }
 
@@ -2412,7 +2210,6 @@ void process_monster(MONSTER_IDX m_idx)
                }
        }
 
-
        if (!p_ptr->inside_battle)
        {
                /* Hack! "Cyber" monster makes noise... */
@@ -2430,9 +2227,9 @@ void process_monster(MONSTER_IDX m_idx)
                    player_has_los_bold(oy, ox) &&
                    projectable(oy, ox, p_ptr->y, p_ptr->x))
                {
-                       char m_name[80];
+                       GAME_TEXT m_name[MAX_NLEN];
                        char monmessage[1024];
-                       cptr filename;
+                       concptr filename;
 
                        /* Acquire the monster name/poss */
                        if (m_ptr->ml)
@@ -2466,11 +2263,10 @@ void process_monster(MONSTER_IDX m_idx)
                /* Give priority to counter attack? */
                if (m_ptr->target_y)
                {
-                       int t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
+                       MONSTER_IDX t_m_idx = current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
 
                        /* The monster must be an enemy, and projectable */
-                       if (t_m_idx &&
-                           are_enemies(m_ptr, &m_list[t_m_idx]) &&
+                       if (t_m_idx && are_enemies(m_ptr, &current_floor_ptr->m_list[t_m_idx]) &&
                            projectable(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
                        {
                                counterattack = TRUE;
@@ -2558,8 +2354,7 @@ void process_monster(MONSTER_IDX m_idx)
        else if (is_pet(m_ptr))
        {
                /* Are we trying to avoid the player? */
-               bool avoid = ((p_ptr->pet_follow_distance < 0) &&
-                                                 (m_ptr->cdis <= (0 - p_ptr->pet_follow_distance)));
+               bool avoid = ((p_ptr->pet_follow_distance < 0) && (m_ptr->cdis <= (0 - p_ptr->pet_follow_distance)));
 
                /* Do we want to find the player? */
                bool lonely = (!avoid && (m_ptr->cdis > p_ptr->pet_follow_distance));
@@ -2625,7 +2420,6 @@ void process_monster(MONSTER_IDX m_idx)
        did_pass_wall = FALSE;
        did_kill_wall = FALSE;
 
-
        /* Take a zero-terminated array of "directions" */
        for (i = 0; mm[i]; i++)
        {
@@ -2642,13 +2436,13 @@ void process_monster(MONSTER_IDX m_idx)
                /* Ignore locations off of edge */
                if (!in_bounds2(ny, nx)) continue;
 
-               /* Access that cave grid */
-               c_ptr = &cave[ny][nx];
-               f_ptr = &f_info[c_ptr->feat];
-               can_cross = monster_can_cross_terrain(c_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0);
+               /* Access that grid */
+               g_ptr = &current_floor_ptr->grid_array[ny][nx];
+               f_ptr = &f_info[g_ptr->feat];
+               can_cross = monster_can_cross_terrain(g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0);
 
-               /* Access that cave grid's contents */
-               y_ptr = &m_list[c_ptr->m_idx];
+               /* Access that grid's contents */
+               y_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
 
                /* Hack -- player 'in' wall */
                if (player_bold(ny, nx))
@@ -2657,7 +2451,7 @@ void process_monster(MONSTER_IDX m_idx)
                }
 
                /* Possibly a monster to attack */
-               else if (c_ptr->m_idx)
+               else if (g_ptr->m_idx)
                {
                        do_move = TRUE;
                }
@@ -2692,7 +2486,7 @@ void process_monster(MONSTER_IDX m_idx)
                }
 
                /* Handle doors and secret doors */
-               else if (is_closed_door(c_ptr->feat))
+               else if (is_closed_door(g_ptr->feat))
                {
                        bool may_bash = TRUE;
 
@@ -2761,13 +2555,12 @@ void process_monster(MONSTER_IDX m_idx)
                        if (did_open_door || did_bash_door)
                        {
                                /* Break down the door */
-                               if (did_bash_door && ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS)))
+                               if (did_bash_door && ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS)))
                                {
                                        cave_alter_feat(ny, nx, FF_BASH);
 
-                                       if (!m_ptr->r_idx) /* Killed by shards of glass, etc. */
+                                       if (!monster_is_valid(m_ptr)) /* Killed by shards of glass, etc. */
                                        {
-                                               /* Update some things */
                                                p_ptr->update |= (PU_FLOW);
                                                p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                                                if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_BASH_DOOR);
@@ -2782,7 +2575,7 @@ void process_monster(MONSTER_IDX m_idx)
                                        cave_alter_feat(ny, nx, FF_OPEN);
                                }
 
-                               f_ptr = &f_info[c_ptr->feat];
+                               f_ptr = &f_info[g_ptr->feat];
 
                                /* Handle viewable doors */
                                do_view = TRUE;
@@ -2790,7 +2583,7 @@ void process_monster(MONSTER_IDX m_idx)
                }
 
                /* Hack -- check for Glyph of Warding */
-               if (do_move && is_glyph_grid(c_ptr) &&
+               if (do_move && is_glyph_grid(g_ptr) &&
                    !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
                {
                        /* Assume no move allowed */
@@ -2800,17 +2593,17 @@ void process_monster(MONSTER_IDX m_idx)
                        if (!is_pet(m_ptr) && (randint1(BREAK_GLYPH) < r_ptr->level))
                        {
                                /* Describe observable breakage */
-                               if (c_ptr->info & CAVE_MARK)
+                               if (g_ptr->info & CAVE_MARK)
                                {
                                        msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
                                }
 
                                /* Forget the rune */
-                               c_ptr->info &= ~(CAVE_MARK);
+                               g_ptr->info &= ~(CAVE_MARK);
 
                                /* Break the rune */
-                               c_ptr->info &= ~(CAVE_OBJECT);
-                               c_ptr->mimic = 0;
+                               g_ptr->info &= ~(CAVE_OBJECT);
+                               g_ptr->mimic = 0;
 
                                /* Allow movement */
                                do_move = TRUE;
@@ -2818,7 +2611,7 @@ void process_monster(MONSTER_IDX m_idx)
                                note_spot(ny, nx);
                        }
                }
-               else if (do_move && is_explosive_rune_grid(c_ptr) &&
+               else if (do_move && is_explosive_rune_grid(g_ptr) &&
                         !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
                {
                        /* Assume no move allowed */
@@ -2831,7 +2624,7 @@ void process_monster(MONSTER_IDX m_idx)
                                if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
                                {
                                        /* Describe observable breakage */
-                                       if (c_ptr->info & CAVE_MARK)
+                                       if (g_ptr->info & CAVE_MARK)
                                        {
                                                msg_print(_("ルーンが爆発した!", "The rune explodes!"));
                                                project(0, 2, ny, nx, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
@@ -2843,16 +2636,16 @@ void process_monster(MONSTER_IDX m_idx)
                                }
 
                                /* Forget the rune */
-                               c_ptr->info &= ~(CAVE_MARK);
+                               g_ptr->info &= ~(CAVE_MARK);
 
                                /* Break the rune */
-                               c_ptr->info &= ~(CAVE_OBJECT);
-                               c_ptr->mimic = 0;
+                               g_ptr->info &= ~(CAVE_OBJECT);
+                               g_ptr->mimic = 0;
 
                                note_spot(ny, nx);
                                lite_spot(ny, nx);
 
-                               if (!m_ptr->r_idx) return;
+                               if (!monster_is_valid(m_ptr)) return;
                                /* Allow movement */
                                do_move = TRUE;
                        }
@@ -2871,8 +2664,8 @@ void process_monster(MONSTER_IDX m_idx)
                                do_move = FALSE;
                        }
 
-                       /* In anti-melee dungeon, stupid or confused monster takes useless turn */
-                       if (do_move && (d_info[dungeon_type].flags1 & DF1_NO_MELEE))
+                       /* In anti-melee dungeon, stupid or confused monster takes useless current_world_ptr->game_turn */
+                       if (do_move && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE))
                        {
                                if (!MON_CONFUSED(m_ptr))
                                {
@@ -2895,14 +2688,14 @@ void process_monster(MONSTER_IDX m_idx)
                                        /* Do not move */
                                        do_move = FALSE;
 
-                                       /* Took a turn */
+                                       /* Took a current_world_ptr->game_turn */
                                        do_turn = TRUE;
                                }
                        }
                }
 
                /* A monster is in the way */
-               if (do_move && c_ptr->m_idx)
+               if (do_move && g_ptr->m_idx)
                {
                        monster_race *z_ptr = &r_info[y_ptr->r_idx];
 
@@ -2912,7 +2705,7 @@ void process_monster(MONSTER_IDX m_idx)
                        /* Attack 'enemies' */
                        if (((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW) &&
                                 (r_ptr->mexp * r_ptr->level > z_ptr->mexp * z_ptr->level) &&
-                                can_cross && (c_ptr->m_idx != p_ptr->riding)) ||
+                                can_cross && (g_ptr->m_idx != p_ptr->riding)) ||
                                are_enemies(m_ptr, y_ptr) || MON_CONFUSED(m_ptr))
                        {
                                if (!(r_ptr->flags1 & RF1_NEVER_BLOW))
@@ -2925,10 +2718,10 @@ void process_monster(MONSTER_IDX m_idx)
                                        /* attack */
                                        if (y_ptr->r_idx && (y_ptr->hp >= 0))
                                        {
-                                               if (monst_attack_monst(m_idx, c_ptr->m_idx)) return;
+                                               if (monst_attack_monst(m_idx, g_ptr->m_idx)) return;
 
-                                               /* In anti-melee dungeon, stupid or confused monster takes useless turn */
-                                               else if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
+                                               /* In anti-melee dungeon, stupid or confused monster takes useless current_world_ptr->game_turn */
+                                               else if (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MELEE)
                                                {
                                                        if (MON_CONFUSED(m_ptr)) return;
                                                        else if (r_ptr->flags2 & RF2_STUPID)
@@ -2944,8 +2737,8 @@ void process_monster(MONSTER_IDX m_idx)
                        /* Push past weaker monsters (unless leaving a wall) */
                        else if ((r_ptr->flags2 & RF2_MOVE_BODY) && !(r_ptr->flags1 & RF1_NEVER_MOVE) &&
                                (r_ptr->mexp > z_ptr->mexp) &&
-                               can_cross && (c_ptr->m_idx != p_ptr->riding) &&
-                               monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
+                               can_cross && (g_ptr->m_idx != p_ptr->riding) &&
+                               monster_can_cross_terrain(current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
                        {
                                /* Allow movement */
                                do_move = TRUE;
@@ -2954,7 +2747,7 @@ void process_monster(MONSTER_IDX m_idx)
                                did_move_body = TRUE;
 
                                /* Wake up the moved monster */
-                               (void)set_monster_csleep(c_ptr->m_idx, 0);
+                               (void)set_monster_csleep(g_ptr->m_idx, 0);
 
                                /* Message */
                        }
@@ -2962,7 +2755,7 @@ void process_monster(MONSTER_IDX m_idx)
 
                if (is_riding_mon)
                {
-                       if (!p_ptr->riding_ryoute && !MON_MONFEAR(&m_list[p_ptr->riding])) do_move = FALSE;
+                       if (!p_ptr->riding_ryoute && !MON_MONFEAR(&current_floor_ptr->m_list[p_ptr->riding])) do_move = FALSE;
                }
 
                if (did_kill_wall && do_move)
@@ -2977,9 +2770,8 @@ void process_monster(MONSTER_IDX m_idx)
 
                        cave_alter_feat(ny, nx, FF_HURT_DISI);
 
-                       if (!m_ptr->r_idx) /* Killed by shards of glass, etc. */
+                       if (!monster_is_valid(m_ptr)) /* Killed by shards of glass, etc. */
                        {
-                               /* Update some things */
                                p_ptr->update |= (PU_FLOW);
                                p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                                if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_KILL_WALL);
@@ -2987,17 +2779,16 @@ void process_monster(MONSTER_IDX m_idx)
                                return;
                        }
 
-                       f_ptr = &f_info[c_ptr->feat];
+                       f_ptr = &f_info[g_ptr->feat];
 
                        /* Note changes to viewable region */
                        do_view = TRUE;
-
                        do_turn = TRUE;
                }
 
                if (must_alter_to_move && (r_ptr->flags7 & RF7_AQUATIC))
                {
-                       if (!monster_can_cross_terrain(c_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0))
+                       if (!monster_can_cross_terrain(g_ptr->feat, r_ptr, is_riding_mon ? CEM_RIDING : 0))
                        {
                                /* Assume no move allowed */
                                do_move = FALSE;
@@ -3042,38 +2833,33 @@ void process_monster(MONSTER_IDX m_idx)
                        if (!is_riding_mon)
                        {
                                /* Hack -- Update the old location */
-                               cave[oy][ox].m_idx = c_ptr->m_idx;
+                               current_floor_ptr->grid_array[oy][ox].m_idx = g_ptr->m_idx;
 
                                /* Mega-Hack -- move the old monster, if any */
-                               if (c_ptr->m_idx)
+                               if (g_ptr->m_idx)
                                {
                                        /* Move the old monster */
                                        y_ptr->fy = oy;
                                        y_ptr->fx = ox;
 
                                        /* Update the old monster */
-                                       update_monster(c_ptr->m_idx, TRUE);
+                                       update_monster(g_ptr->m_idx, TRUE);
                                }
 
                                /* Hack -- Update the new location */
-                               c_ptr->m_idx = (s16b)m_idx;
+                               g_ptr->m_idx = m_idx;
 
                                /* Move the monster */
                                m_ptr->fy = ny;
                                m_ptr->fx = nx;
                                update_monster(m_idx, TRUE);
 
-                               /* Redraw the old grid */
                                lite_spot(oy, ox);
-
-                               /* Redraw the new grid */
                                lite_spot(ny, nx);
                        }
                        else
                        {
                                /* sound(SOUND_WALK); */
-
-                               /* Move the player */
                                if (!move_player_effect(ny, nx, MPE_DONT_PICKUP)) break;
                        }
 
@@ -3088,20 +2874,18 @@ void process_monster(MONSTER_IDX m_idx)
                        }
 
                        /* Take or Kill objects on the floor */
-                       if (c_ptr->o_idx && (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) &&
+                       if (g_ptr->o_idx && (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) &&
                            (!is_pet(m_ptr) || ((p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) && (r_ptr->flags2 & RF2_TAKE_ITEM))))
                        {
                                OBJECT_IDX this_o_idx, next_o_idx;
                                bool do_take = (r_ptr->flags2 & RF2_TAKE_ITEM) ? TRUE : FALSE;
 
                                /* Scan all objects in the grid */
-                               for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+                               for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                                {
                                        BIT_FLAGS flgs[TR_FLAG_SIZE], flg2 = 0L, flg3 = 0L, flgr = 0L;
-                                       char m_name[80], o_name[MAX_NLEN];
-                                       object_type *o_ptr = &o_list[this_o_idx];
-
-                                       /* Acquire next object */
+                                       GAME_TEXT m_name[MAX_NLEN], o_name[MAX_NLEN];
+                                       object_type *o_ptr = &current_floor_ptr->o_list[this_o_idx];
                                        next_o_idx = o_ptr->next_o_idx;
 
                                        if (do_take)
@@ -3123,8 +2907,6 @@ void process_monster(MONSTER_IDX m_idx)
 
                                        /* Acquire the object name */
                                        object_desc(o_name, o_ptr, 0);
-
-                                       /* Acquire the monster name */
                                        monster_desc(m_name, m_ptr, MD_INDEF_HIDDEN);
 
                                        /* React to objects that hurt the monster */
@@ -3159,13 +2941,11 @@ void process_monster(MONSTER_IDX m_idx)
                                                /* Only give a message for "take_item" */
                                                if (do_take && (r_ptr->flags2 & RF2_STUPID))
                                                {
-                                                       /* Take note */
                                                        did_take_item = TRUE;
 
                                                        /* Describe observable situations */
                                                        if (m_ptr->ml && player_can_see_bold(ny, nx))
                                                        {
-                                                               /* Dump a message */
                                                                msg_format(_("%^sは%sを拾おうとしたが、だめだった。", "%^s tries to pick up %s, but fails."), m_name, o_name);
                                                        }
                                                }
@@ -3174,13 +2954,11 @@ void process_monster(MONSTER_IDX m_idx)
                                        /* Pick up the item */
                                        else if (do_take)
                                        {
-                                               /* Take note */
                                                did_take_item = TRUE;
 
                                                /* Describe observable situations */
                                                if (player_can_see_bold(ny, nx))
                                                {
-                                                       /* Dump a message */
                                                        msg_format(_("%^sが%sを拾った。", "%^s picks up %s."), m_name, o_name);
                                                }
 
@@ -3194,7 +2972,7 @@ void process_monster(MONSTER_IDX m_idx)
                                                o_ptr->iy = o_ptr->ix = 0;
 
                                                /* Memorize monster */
-                                               o_ptr->held_m_idx = (s16b)m_idx;
+                                               o_ptr->held_m_idx = m_idx;
 
                                                /* Build a stack */
                                                o_ptr->next_o_idx = m_ptr->hold_o_idx;
@@ -3206,13 +2984,11 @@ void process_monster(MONSTER_IDX m_idx)
                                        /* Destroy the item if not a pet */
                                        else if (!is_pet(m_ptr))
                                        {
-                                               /* Take note */
                                                did_kill_item = TRUE;
 
                                                /* Describe observable situations */
                                                if (player_has_los_bold(ny, nx))
                                                {
-                                                       /* Dump a message */
                                                        msg_format(_("%^sが%sを破壊した。", "%^s destroys %s."), m_name, o_name);
                                                }
 
@@ -3247,9 +3023,7 @@ void process_monster(MONSTER_IDX m_idx)
        /* Notice changes in view */
        if (do_view)
        {
-               /* Update some things */
                p_ptr->update |= (PU_FLOW);
-
                p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
        }
 
@@ -3257,7 +3031,6 @@ void process_monster(MONSTER_IDX m_idx)
        if (do_move && ((r_ptr->flags7 & (RF7_SELF_LD_MASK | RF7_HAS_DARK_1 | RF7_HAS_DARK_2))
                || ((r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2)) && !p_ptr->inside_battle)))
        {
-               /* Update some things */
                p_ptr->update |= (PU_MON_LITE);
        }
 
@@ -3296,12 +3069,8 @@ void process_monster(MONSTER_IDX m_idx)
                /* Message if seen */
                if (see_m)
                {
-                       char m_name[80];
-
-                       /* Acquire the monster name */
+                       GAME_TEXT m_name[MAX_NLEN];
                        monster_desc(m_name, m_ptr, 0);
-
-                       /* Dump a message */
                        msg_format(_("%^sは戦いを決意した!", "%^s turns to fight!"), m_name);
                }
 
@@ -3313,10 +3082,10 @@ void process_monster(MONSTER_IDX m_idx)
 
 /*!
  * @brief 全モンスターのターン管理メインルーチン /
- * Process all the "live" monsters, once per game turn.
+ * Process all the "live" monsters, once per game current_world_ptr->game_turn.
  * @return なし
  * @details
- * During each game turn, we scan through the list of all the "live" monsters,\n
+ * During each game current_world_ptr->game_turn, we scan through the list of all the "live" monsters,\n
  * (backwards, so we can excise any "freshly dead" monsters), energizing each\n
  * monster, and allowing fully energized monsters to move, attack, pass, etc.\n
  *\n
@@ -3335,8 +3104,8 @@ void process_monster(MONSTER_IDX m_idx)
  *\n
  * Note the special "MFLAG_BORN" flag, which allows us to ignore "fresh"\n
  * monsters while they are still being "born".  A monster is "fresh" only\n
- * during the turn in which it is created, and we use the "hack_m_idx" to\n
- * determine if the monster is yet to be processed during the current turn.\n
+ * during the current_world_ptr->game_turn in which it is created, and we use the "hack_m_idx" to\n
+ * determine if the monster is yet to be processed during the current current_world_ptr->game_turn.\n
  *\n
  * Note the special "MFLAG_NICE" flag, which allows the player to get one\n
  * move before any "nasty" monsters get to use their spell attacks.\n
@@ -3347,7 +3116,7 @@ void process_monster(MONSTER_IDX m_idx)
  */
 void process_monsters(void)
 {
-       IDX i;
+       MONSTER_IDX i;
        POSITION fx, fy;
 
        bool            test;
@@ -3407,17 +3176,17 @@ void process_monsters(void)
 
 
        /* Process the monsters (backwards) */
-       for (i = m_max - 1; i >= 1; i--)
+       for (i = current_floor_ptr->m_max - 1; i >= 1; i--)
        {
                /* Access the monster */
-               m_ptr = &m_list[i];
+               m_ptr = &current_floor_ptr->m_list[i];
                r_ptr = &r_info[m_ptr->r_idx];
 
                /* Handle "leaving" */
                if (p_ptr->leaving) break;
 
                /* Ignore "dead" monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                if (p_ptr->wild_mode) continue;
 
@@ -3435,8 +3204,6 @@ void process_monsters(void)
                /* Hack -- Require proximity */
                if (m_ptr->cdis >= AAF_LIMIT) continue;
 
-
-               /* Access the location */
                fx = m_ptr->fx;
                fy = m_ptr->fy;
 
@@ -3464,14 +3231,14 @@ void process_monsters(void)
                        test = TRUE;
                }
 
-#if 0 /* (cave[p_ptr->y][p_ptr->x].when == cave[fy][fx].when) is always FALSE... */
+#if 0 /* (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when == current_floor_ptr->grid_array[fy][fx].when) is always FALSE... */
                /* Hack -- Monsters can "smell" the player from far away */
                /* Note that most monsters have "aaf" of "20" or so */
                else if (!(m_ptr->mflag2 & MFLAG2_NOFLOW) &&
                        cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_MOVE) &&
-                       (cave[p_ptr->y][p_ptr->x].when == cave[fy][fx].when) &&
-                       (cave[fy][fx].dist < MONSTER_FLOW_DEPTH) &&
-                       (cave[fy][fx].dist < r_ptr->aaf))
+                       (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when == current_floor_ptr->grid_array[fy][fx].when) &&
+                       (current_floor_ptr->grid_array[fy][fx].dist < MONSTER_FLOW_DEPTH) &&
+                       (current_floor_ptr->grid_array[fy][fx].dist < r_ptr->aaf))
                {
                        /* We can "smell" the player */
                        test = TRUE;