OSDN Git Service

[Refactor] #38997 lite_room() と unlite_room() にplayer_type * 引数を追加 (コールチェーンが長いのでその他省略...
[hengband/hengband.git] / src / monster-process.c
index f04bbec..393b2e7 100644 (file)
@@ -56,38 +56,38 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
        int start;
        int plus = 1;
 
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        monster_type *t_ptr;
 
-       if (p_ptr->riding_t_m_idx && player_bold(m_ptr->fy, m_ptr->fx))
+       if (p_ptr->riding_t_m_idx && player_bold(p_ptr, m_ptr->fy, m_ptr->fx))
        {
-               y = current_floor_ptr->m_list[p_ptr->riding_t_m_idx].fy;
-               x = current_floor_ptr->m_list[p_ptr->riding_t_m_idx].fx;
+               y = p_ptr->current_floor_ptr->m_list[p_ptr->riding_t_m_idx].fy;
+               x = p_ptr->current_floor_ptr->m_list[p_ptr->riding_t_m_idx].fx;
        }
        else if (is_pet(m_ptr) && p_ptr->pet_t_m_idx)
        {
-               y = current_floor_ptr->m_list[p_ptr->pet_t_m_idx].fy;
-               x = current_floor_ptr->m_list[p_ptr->pet_t_m_idx].fx;
+               y = p_ptr->current_floor_ptr->m_list[p_ptr->pet_t_m_idx].fy;
+               x = p_ptr->current_floor_ptr->m_list[p_ptr->pet_t_m_idx].fx;
        }
        else
        {
                if (p_ptr->phase_out)
                {
-                       start = randint1(current_floor_ptr->m_max-1)+current_floor_ptr->m_max;
+                       start = randint1(p_ptr->current_floor_ptr->m_max-1)+p_ptr->current_floor_ptr->m_max;
                        if(randint0(2)) plus = -1;
                }
-               else start = current_floor_ptr->m_max + 1;
+               else start = p_ptr->current_floor_ptr->m_max + 1;
 
                /* Scan thru all monsters */
-               for (i = start; ((i < start + current_floor_ptr->m_max) && (i > start - current_floor_ptr->m_max)); i+=plus)
+               for (i = start; ((i < start + p_ptr->current_floor_ptr->m_max) && (i > start - p_ptr->current_floor_ptr->m_max)); i+=plus)
                {
-                       MONSTER_IDX dummy = (i % current_floor_ptr->m_max);
+                       MONSTER_IDX dummy = (i % p_ptr->current_floor_ptr->m_max);
 
                        if (!dummy) continue;
 
                        t_idx = dummy;
-                       t_ptr = &current_floor_ptr->m_list[t_idx];
+                       t_ptr = &p_ptr->current_floor_ptr->m_list[t_idx];
 
                        /* The monster itself isn't a target */
                        if (t_ptr == m_ptr) continue;
@@ -121,11 +121,11 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
                        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 (!in_disintegration_range(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) continue;
+                               if (!in_disintegration_range(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) continue;
                        }
                        else
                        {
-                               if (!projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) continue;
+                               if (!projectable(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) continue;
                        }
 
                        /* OK -- we've got a target */
@@ -220,7 +220,7 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
  */
 static bool mon_will_run(MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
 
 #ifdef ALLOW_TERROR
 
@@ -302,7 +302,7 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        bool can_open_door = FALSE;
        int now_cost;
 
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        /* Monster location */
@@ -310,10 +310,10 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        x1 = m_ptr->fx;
 
        /* Monster can already cast spell to player */
-       if (projectable(y1, x1, p_ptr->y, p_ptr->x)) return (FALSE);
+       if (projectable(p_ptr->current_floor_ptr, y1, x1, p_ptr->y, p_ptr->x)) return (FALSE);
 
        /* Set current grid cost */
-       now_cost = current_floor_ptr->grid_array[y1][x1].cost;
+       now_cost = p_ptr->current_floor_ptr->grid_array[y1][x1].cost;
        if (now_cost == 0) now_cost = 999;
 
        /* Can monster bash or open doors? */
@@ -331,12 +331,12 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                x = x1 + ddx_ddd[i];
 
                /* Ignore locations off of edge */
-               if (!in_bounds2(y, x)) continue;
+               if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue;
 
                /* Simply move to player */
-               if (player_bold(y, x)) return (FALSE);
+               if (player_bold(p_ptr, y, x)) return (FALSE);
 
-               g_ptr = &current_floor_ptr->grid_array[y][x];
+               g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
 
                cost = g_ptr->cost;
 
@@ -352,7 +352,7 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
 
                if (now_cost < cost) continue;
 
-               if (!projectable(y, x, p_ptr->y, p_ptr->x)) continue;
+               if (!projectable(p_ptr->current_floor_ptr, y, x, p_ptr->y, p_ptr->x)) continue;
 
                /* Accept louder sounds */
                if (best < cost) continue;
@@ -406,7 +406,7 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
        grid_type *g_ptr;
        bool use_scent = FALSE;
 
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        /* Can monster cast attack spell? */
@@ -430,10 +430,10 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
        x1 = m_ptr->fx;
 
        /* Hack -- Player can see us, run towards him */
-       if (player_has_los_bold(y1, x1) && projectable(p_ptr->y, p_ptr->x, y1, x1)) return (FALSE);
+       if (player_has_los_bold(p_ptr, y1, x1) && projectable(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, y1, x1)) return (FALSE);
 
        /* Monster grid */
-       g_ptr = &current_floor_ptr->grid_array[y1][x1];
+       g_ptr = &p_ptr->current_floor_ptr->grid_array[y1][x1];
 
        /* If we can hear noises, advance towards them */
        if (g_ptr->cost)
@@ -445,7 +445,7 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
        else if (g_ptr->when)
        {
                /* Too old smell */
-               if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when - g_ptr->when > 127) return (FALSE);
+               if (p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].when - g_ptr->when > 127) return (FALSE);
 
                use_scent = TRUE;
                best = 0;
@@ -464,9 +464,9 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
                x = x1 + ddx_ddd[i];
 
                /* Ignore locations off of edge */
-               if (!in_bounds2(y, x)) continue;
+               if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue;
 
-               g_ptr = &current_floor_ptr->grid_array[y][x];
+               g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
 
                /* We're following a scent trail */
                if (use_scent)
@@ -523,7 +523,7 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        int score = -1;
        int i;
 
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
 
        /* Monster location */
        fy = m_ptr->fy;
@@ -542,16 +542,13 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                x = fx + ddx_ddd[i];
 
                /* Ignore locations off of edge */
-               if (!in_bounds2(y, x)) continue;
-
-               /* Don't move toward player */
-               /* if (current_floor_ptr->grid_array[y][x].dist < 3) continue; */ /* Hmm.. Need it? */
+               if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue;
 
                /* Calculate distance of this grid from our destination */
                dis = distance(y, x, y1, x1);
 
                /* Score this grid */
-               s = 5000 / (dis + 3) - 500 / (current_floor_ptr->grid_array[y][x].dist + 1);
+               s = 5000 / (dis + 3) - 500 / (p_ptr->current_floor_ptr->grid_array[y][x].dist + 1);
 
                /* No negative scores */
                if (s < 0) s = 0;
@@ -710,7 +707,7 @@ static POSITION *dist_offsets_x[10] =
  */
 static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
 {
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
 
        POSITION fy = m_ptr->fy;
        POSITION fx = m_ptr->fx;
@@ -739,9 +736,9 @@ static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                        x = fx + dx;
 
                        /* Skip illegal locations */
-                       if (!in_bounds(y, x)) continue;
+                       if (!in_bounds(p_ptr->current_floor_ptr, y, x)) continue;
 
-                       g_ptr = &current_floor_ptr->grid_array[y][x];
+                       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
 
                        /* Skip locations in a wall */
                        if (!monster_can_cross_terrain(g_ptr->feat, &r_info[m_ptr->r_idx], (m_idx == p_ptr->riding) ? CEM_RIDING : 0)) continue;
@@ -753,11 +750,11 @@ static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                                if (g_ptr->dist == 0) continue;
 
                                /* Ignore too-distant grids */
-                               if (g_ptr->dist > current_floor_ptr->grid_array[fy][fx].dist + 2 * d) continue;
+                               if (g_ptr->dist > p_ptr->current_floor_ptr->grid_array[fy][fx].dist + 2 * d) continue;
                        }
 
                        /* Check for absence of shot (more or less) */
-                       if (!projectable(p_ptr->y, p_ptr->x, y, x))
+                       if (!projectable(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, y, x))
                        {
                                /* Calculate distance from player */
                                dis = distance(y, x, p_ptr->y, p_ptr->x);
@@ -804,7 +801,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 = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        POSITION fy = m_ptr->fy;
@@ -831,13 +828,13 @@ static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
                        x = fx + dx;
 
                        /* Skip illegal locations */
-                       if (!in_bounds(y, x)) continue;
+                       if (!in_bounds(p_ptr->current_floor_ptr, y, x)) continue;
 
                        /* Skip occupied locations */
                        if (!monster_can_enter(y, x, r_ptr, 0)) continue;
 
                        /* Check for hidden, available grid */
-                       if (!projectable(p_ptr->y, p_ptr->x, y, x) && clean_shot(fy, fx, y, x, FALSE))
+                       if (!projectable(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, y, x) && clean_shot(fy, fx, y, x, FALSE))
                        {
                                /* Calculate distance from player */
                                dis = distance(y, x, p_ptr->y, p_ptr->x);
@@ -878,7 +875,7 @@ static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
  */
 static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
 {
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_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;
@@ -887,19 +884,19 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
        bool         done = FALSE;
        bool         will_run = mon_will_run(m_idx);
        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         no_flow = ((m_ptr->mflag2 & MFLAG2_NOFLOW) && (p_ptr->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 = current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
+               int t_m_idx = p_ptr->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, &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))
+                   are_enemies(m_ptr, &p_ptr->current_floor_ptr->m_list[t_m_idx]) &&
+                   los(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x) &&
+                   projectable(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
                {
                        /* Extract the "pseudo-direction" */
                        y = m_ptr->fy - m_ptr->target_y;
@@ -910,8 +907,8 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *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)) ||
-           (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
+           ((los(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(p_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) ||
+           (p_ptr->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
@@ -928,9 +925,9 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
                                int xx = p_ptr->x + ddx_ddd[i];
                                int yy = p_ptr->y + ddy_ddd[i];
 
-                               if (!in_bounds2(yy, xx)) continue;
+                               if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue;
 
-                               g_ptr = &current_floor_ptr->grid_array[yy][xx];
+                               g_ptr = &p_ptr->current_floor_ptr->grid_array[yy][xx];
 
                                /* Check grid */
                                if (monster_can_cross_terrain(g_ptr->feat, r_ptr, 0))
@@ -939,7 +936,7 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
                                        room++;
                                }
                        }
-                       if (current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].info & CAVE_ROOM) room -= 2;
+                       if (p_ptr->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 */
@@ -952,7 +949,7 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
                }
 
                /* Monster groups try to surround the player */
-               if (!done && (current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < 3))
+               if (!done && (p_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].dist < 3))
                {
                        int i;
 
@@ -973,7 +970,7 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
                                        break;
                                }
 
-                               if (!in_bounds2(y2, x2)) continue;
+                               if (!in_bounds2(p_ptr->current_floor_ptr, y2, x2)) continue;
 
                                /* Ignore filled grids */
                                if (!monster_can_enter(y2, x2, r_ptr, 0)) continue;
@@ -1211,8 +1208,9 @@ static bool check_hp_for_feat_destruction(feature_type *f_ptr, monster_type *m_p
 
 
 /*!
- * @brief モンスター単体のターン行動処理メインルーチン /
+ * @brief モンスター単体の1ターン行動処理メインルーチン /
  * Process a monster
+ * @param target_ptr プレーヤーへの参照ポインタ
  * @param m_idx 行動モンスターの参照ID
  * @return なし
  * @details
@@ -1239,9 +1237,9 @@ static bool check_hp_for_feat_destruction(feature_type *f_ptr, monster_type *m_p
  *\n
  * A "direction" of "5" means "pick a random direction".\n
  */
-void process_monster(MONSTER_IDX m_idx)
+void process_monster(player_type *target_ptr, MONSTER_IDX m_idx)
 {
-       monster_type    *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type    *m_ptr = &target_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];
 
@@ -1272,18 +1270,18 @@ void process_monster(MONSTER_IDX m_idx)
        bool            aware = TRUE;
 
        bool fear, dead;
-       bool is_riding_mon = (m_idx == p_ptr->riding);
+       bool is_riding_mon = (m_idx == target_ptr->riding);
        bool see_m = is_seen(m_ptr);
 
        if (is_riding_mon && !(r_ptr->flags7 & RF7_RIDING))
        {
-               if (rakuba(p_ptr, 0, TRUE))
+               if (rakuba(target_ptr, 0, TRUE))
                {
 #ifdef JP
                        msg_print("地面に落とされた。");
 #else
                        GAME_TEXT m_name[MAX_NLEN];
-                       monster_desc(m_name, &current_floor_ptr->m_list[p_ptr->riding], 0);
+                       monster_desc(m_name, &target_ptr->current_floor_ptr->m_list[target_ptr->riding], 0);
                        msg_format("You have fallen from %s.", m_name);
 #endif
                }
@@ -1296,18 +1294,18 @@ void process_monster(MONSTER_IDX m_idx)
        }
 
        /* Players hidden in shadow are almost imperceptable. -LM- */
-       if (p_ptr->special_defense & NINJA_S_STEALTH)
+       if (target_ptr->special_defense & NINJA_S_STEALTH)
        {
-               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;
+               int tmp = target_ptr->lev*6+(target_ptr->skill_stl+10)*4;
+               if (target_ptr->monlite) tmp /= 3;
+               if (target_ptr->cursed & TRC_AGGRAVATE) tmp /= 2;
+               if (r_ptr->level > (target_ptr->lev * target_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 && !current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx)
+       if (m_ptr->parent_m_idx && !target_ptr->current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx)
        {
                /* Its parent have gone, it also goes away. */
 
@@ -1322,7 +1320,7 @@ void process_monster(MONSTER_IDX m_idx)
                {
                        GAME_TEXT m_name[MAX_NLEN];
                        monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                       exe_write_diary(p_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_LOSE_PARENT, m_name);
+                       exe_write_diary(target_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_LOSE_PARENT, m_name);
                }
 
                delete_monster_idx(m_idx);
@@ -1370,7 +1368,7 @@ void process_monster(MONSTER_IDX 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->phase_out)
+       if ((is_pet(m_ptr) || is_friendly(m_ptr)) && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) && !target_ptr->phase_out)
        {
                static int riding_pinch = 0;
 
@@ -1384,14 +1382,14 @@ void process_monster(MONSTER_IDX m_idx)
                                msg_format(_("%sは傷の痛さの余りあなたの束縛から逃れようとしている。",
                                                         "%^s seems to be in so much pain, and trying to escape from your restriction."), m_name);
                                riding_pinch++;
-                               disturb(p_ptr, TRUE, TRUE);
+                               disturb(target_ptr, TRUE, TRUE);
                        }
                        else
                        {
                                if (is_riding_mon)
                                {
                                        msg_format(_("%sはあなたの束縛から脱出した。", "%^s succeeded to escape from your restriction!"), m_name);
-                                       if (rakuba(p_ptr, -1, FALSE))
+                                       if (rakuba(target_ptr, -1, FALSE))
                                        {
                                                msg_print(_("地面に落とされた。", "You have fallen from riding pet."));
                                        }
@@ -1400,7 +1398,7 @@ void process_monster(MONSTER_IDX m_idx)
                                if (see_m)
                                {
                                        if ((r_ptr->flags2 & RF2_CAN_SPEAK) && (m_ptr->r_idx != MON_GRIP) && (m_ptr->r_idx != MON_WOLF) && (m_ptr->r_idx != MON_FANG) &&
-                                           player_has_los_bold(m_ptr->fy, m_ptr->fx) && projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x))
+                                           player_has_los_bold(target_ptr, m_ptr->fy, m_ptr->fx) && projectable(target_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, target_ptr->y, target_ptr->x))
                                        {
                                                msg_format(_("%^s「ピンチだ!退却させてもらう!」", "%^s says 'It is the pinch! I will retreat'."), m_name);
                                        }
@@ -1408,7 +1406,7 @@ void process_monster(MONSTER_IDX m_idx)
                                        msg_format(_("%^sが消え去った。", "%^s disappears."), m_name);
                                }
 
-                               if (is_riding_mon && rakuba(p_ptr, -1, FALSE))
+                               if (is_riding_mon && rakuba(target_ptr, -1, FALSE))
                                {
                                        msg_print(_("地面に落とされた。", "You have fallen from riding pet."));
                                }
@@ -1429,7 +1427,7 @@ void process_monster(MONSTER_IDX m_idx)
        if (MON_CSLEEP(m_ptr))
        {
                /* Handle non-aggravation - Still sleeping */
-               if (!(p_ptr->cursed & TRC_AGGRAVATE)) return;
+               if (!(target_ptr->cursed & TRC_AGGRAVATE)) return;
 
                (void)set_monster_csleep(m_idx, 0);
 
@@ -1457,11 +1455,11 @@ void process_monster(MONSTER_IDX m_idx)
 
        if (is_riding_mon)
        {
-               p_ptr->update |= (PU_BONUS);
+               target_ptr->update |= (PU_BONUS);
        }
 
        /* No one wants to be your friend if you're aggravating */
-       if (is_friendly(m_ptr) && (p_ptr->cursed & TRC_AGGRAVATE))
+       if (is_friendly(m_ptr) && (target_ptr->cursed & TRC_AGGRAVATE))
                gets_angry = TRUE;
 
        /* Paranoia... no pet uniques outside wizard mode -- TY */
@@ -1471,7 +1469,7 @@ void process_monster(MONSTER_IDX m_idx)
                gets_angry = TRUE;
        }
 
-       if (p_ptr->phase_out) gets_angry = FALSE;
+       if (target_ptr->phase_out) gets_angry = FALSE;
 
        if (gets_angry)
        {
@@ -1490,7 +1488,7 @@ void process_monster(MONSTER_IDX m_idx)
        ox = m_ptr->fx;
 
        /* Attempt to "multiply" if able and allowed */
-       if ((r_ptr->flags2 & RF2_MULTIPLY) && (current_floor_ptr->num_repro < MAX_REPRO))
+       if ((r_ptr->flags2 & RF2_MULTIPLY) && (target_ptr->current_floor_ptr->num_repro < MAX_REPRO))
        {
                int k;
                POSITION y, x;
@@ -1501,12 +1499,12 @@ void process_monster(MONSTER_IDX m_idx)
                        for (x = ox - 1; x <= ox + 1; x++)
                        {
                                /* Ignore locations off of edge */
-                               if (!in_bounds2(y, x)) continue;
-                               if (current_floor_ptr->grid_array[y][x].m_idx) k++;
+                               if (!in_bounds2(target_ptr->current_floor_ptr, y, x)) continue;
+                               if (target_ptr->current_floor_ptr->grid_array[y][x].m_idx) k++;
                        }
                }
 
-               if (multiply_barrier(m_idx)) k = 8;
+               if (multiply_barrier(target_ptr, m_idx)) k = 8;
 
                /* Hack -- multiply slower in crowded areas */
                if ((k < 4) && (!k || !randint0(k * MON_MULT_ADJ)))
@@ -1515,7 +1513,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 (current_floor_ptr->m_list[hack_m_idx_ii].ml && is_original_ap_and_seen(m_ptr))
+                               if (target_ptr->current_floor_ptr->m_list[hack_m_idx_ii].ml && is_original_ap_and_seen(m_ptr))
                                {
                                        r_ptr->r_flags2 |= (RF2_MULTIPLY);
                                }
@@ -1531,7 +1529,7 @@ void process_monster(MONSTER_IDX m_idx)
                /* Hack -- Ohmu scatters molds! */
                if (m_ptr->r_idx == MON_OHMU)
                {
-                       if (!p_ptr->inside_arena && !p_ptr->phase_out)
+                       if (!target_ptr->current_floor_ptr->inside_arena && !target_ptr->phase_out)
                        {
                                if (r_ptr->freq_spell && (randint1(100) <= r_ptr->freq_spell))
                                {
@@ -1543,7 +1541,7 @@ void process_monster(MONSTER_IDX m_idx)
                                        {
                                                if (summon_specific(m_idx, m_ptr->fy, m_ptr->fx, rlev, SUMMON_MOLD, (PM_ALLOW_GROUP | p_mode)))
                                                {
-                                                       if (current_floor_ptr->m_list[hack_m_idx_ii].ml) count++;
+                                                       if (target_ptr->current_floor_ptr->m_list[hack_m_idx_ii].ml) count++;
                                                }
                                        }
 
@@ -1553,22 +1551,22 @@ void process_monster(MONSTER_IDX m_idx)
                }
        }
 
-       if (!p_ptr->phase_out)
+       if (!target_ptr->phase_out)
        {
                /* Hack! "Cyber" monster makes noise... */
                if (m_ptr->ap_r_idx == MON_CYBER &&
                    one_in_(CYBERNOISE) &&
                    !m_ptr->ml && (m_ptr->cdis <= MAX_SIGHT))
                {
-                       if (disturb_minor) disturb(p_ptr, FALSE, FALSE);
+                       if (disturb_minor) disturb(target_ptr, FALSE, FALSE);
                        msg_print(_("重厚な足音が聞こえた。", "You hear heavy steps."));
                }
 
                /* Some monsters can speak */
                if ((ap_r_ptr->flags2 & RF2_CAN_SPEAK) && aware &&
                    one_in_(SPEAK_CHANCE) &&
-                   player_has_los_bold(oy, ox) &&
-                   projectable(oy, ox, p_ptr->y, p_ptr->x))
+                   player_has_los_bold(target_ptr, oy, ox) &&
+                   projectable(target_ptr->current_floor_ptr, oy, ox, target_ptr->y, target_ptr->x))
                {
                        GAME_TEXT m_name[MAX_NLEN];
                        char monmessage[1024];
@@ -1606,11 +1604,11 @@ void process_monster(MONSTER_IDX m_idx)
                /* Give priority to counter attack? */
                if (m_ptr->target_y)
                {
-                       MONSTER_IDX t_m_idx = current_floor_ptr->grid_array[m_ptr->target_y][m_ptr->target_x].m_idx;
+                       MONSTER_IDX t_m_idx = target_ptr->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, &current_floor_ptr->m_list[t_m_idx]) &&
-                           projectable(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
+                       if (t_m_idx && are_enemies(m_ptr, &target_ptr->current_floor_ptr->m_list[t_m_idx]) &&
+                           projectable(target_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
                        {
                                counterattack = TRUE;
                        }
@@ -1619,20 +1617,20 @@ void process_monster(MONSTER_IDX m_idx)
                if (!counterattack)
                {
                        /* Attempt to cast a spell */
-                       if (aware && make_attack_spell(m_idx)) return;
+                       if (aware && make_attack_spell(m_idx, target_ptr)) return;
 
                        /*
                         * Attempt to cast a spell at an enemy other than the player
                         * (may slow the game a smidgeon, but I haven't noticed.)
                         */
-                       if (monst_spell_monst(m_idx)) return;
+                       if (monst_spell_monst(target_ptr, m_idx)) return;
                }
                else
                {
                        /* Attempt to do counter attack at first */
-                       if (monst_spell_monst(m_idx)) return;
+                       if (monst_spell_monst(target_ptr, m_idx)) return;
 
-                       if (aware && make_attack_spell(m_idx)) return;
+                       if (aware && make_attack_spell(m_idx, target_ptr)) return;
                }
        }
 
@@ -1697,10 +1695,10 @@ 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 = ((target_ptr->pet_follow_distance < 0) && (m_ptr->cdis <= (0 - target_ptr->pet_follow_distance)));
 
                /* Do we want to find the player? */
-               bool lonely = (!avoid && (m_ptr->cdis > p_ptr->pet_follow_distance));
+               bool lonely = (!avoid && (m_ptr->cdis > target_ptr->pet_follow_distance));
 
                /* Should we find the player if we can't find a monster? */
                bool distant = (m_ptr->cdis > PET_SEEK_DIST);
@@ -1715,19 +1713,19 @@ void process_monster(MONSTER_IDX m_idx)
                        if (avoid || lonely || distant)
                        {
                                /* Remember the leash length */
-                               POSITION dis = p_ptr->pet_follow_distance;
+                               POSITION dis = target_ptr->pet_follow_distance;
 
                                /* Hack -- adjust follow distance temporarily */
-                               if (p_ptr->pet_follow_distance > PET_SEEK_DIST)
+                               if (target_ptr->pet_follow_distance > PET_SEEK_DIST)
                                {
-                                       p_ptr->pet_follow_distance = PET_SEEK_DIST;
+                                       target_ptr->pet_follow_distance = PET_SEEK_DIST;
                                }
 
                                /* Find the player */
                                (void)get_moves(m_idx, mm);
 
                                /* Restore the leash */
-                               p_ptr->pet_follow_distance = (s16b)dis;
+                               target_ptr->pet_follow_distance = (s16b)dis;
                        }
                }
        }
@@ -1777,18 +1775,18 @@ void process_monster(MONSTER_IDX m_idx)
                nx = ox + ddx[d];
 
                /* Ignore locations off of edge */
-               if (!in_bounds2(ny, nx)) continue;
+               if (!in_bounds2(target_ptr->current_floor_ptr, ny, nx)) continue;
 
                /* Access that grid */
-               g_ptr = &current_floor_ptr->grid_array[ny][nx];
+               g_ptr = &target_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 grid's contents */
-               y_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
+               y_ptr = &target_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
 
                /* Hack -- player 'in' wall */
-               if (player_bold(ny, nx))
+               if (player_bold(target_ptr, ny, nx))
                {
                        do_move = TRUE;
                }
@@ -1820,7 +1818,7 @@ void process_monster(MONSTER_IDX m_idx)
                        do_move = TRUE;
 
                        /* Monster moves through walls (and doors) */
-                       if ((r_ptr->flags2 & RF2_PASS_WALL) && (!is_riding_mon || p_ptr->pass_wall) &&
+                       if ((r_ptr->flags2 & RF2_PASS_WALL) && (!is_riding_mon || target_ptr->pass_wall) &&
                            have_flag(f_ptr->flags, FF_CAN_PASS))
                        {
                                /* Monster went through a wall */
@@ -1838,7 +1836,7 @@ void process_monster(MONSTER_IDX m_idx)
 
                        /* Creature can open doors. */
                        if ((r_ptr->flags2 & RF2_OPEN_DOOR) && have_flag(f_ptr->flags, FF_OPEN) &&
-                                (!is_pet(m_ptr) || (p_ptr->pet_extra_flags & PF_OPEN_DOORS)))
+                                (!is_pet(m_ptr) || (target_ptr->pet_extra_flags & PF_OPEN_DOORS)))
                        {
                                /* Closed doors */
                                if (!f_ptr->power)
@@ -1871,7 +1869,7 @@ void process_monster(MONSTER_IDX m_idx)
 
                        /* Stuck doors -- attempt to bash them down if allowed */
                        if (may_bash && (r_ptr->flags2 & RF2_BASH_DOOR) && have_flag(f_ptr->flags, FF_BASH) &&
-                               (!is_pet(m_ptr) || (p_ptr->pet_extra_flags & PF_OPEN_DOORS)))
+                               (!is_pet(m_ptr) || (target_ptr->pet_extra_flags & PF_OPEN_DOORS)))
                        {
                                /* Attempt to Bash */
                                if (check_hp_for_feat_destruction(f_ptr, m_ptr) && (randint0(m_ptr->hp / 10) > f_ptr->power))
@@ -1882,7 +1880,7 @@ void process_monster(MONSTER_IDX m_idx)
                                                msg_print(_("ドアを叩き開ける音がした!", "You hear a door burst open!"));
 
                                        /* Disturb (sometimes) */
-                                       if (disturb_minor) disturb(p_ptr, FALSE, FALSE);
+                                       if (disturb_minor) disturb(target_ptr, FALSE, FALSE);
 
                                        /* The door was bashed open */
                                        did_bash_door = TRUE;
@@ -1904,8 +1902,8 @@ void process_monster(MONSTER_IDX m_idx)
 
                                        if (!monster_is_valid(m_ptr)) /* Killed by shards of glass, etc. */
                                        {
-                                               p_ptr->update |= (PU_FLOW);
-                                               p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+                                               target_ptr->update |= (PU_FLOW);
+                                               target_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                                                if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_BASH_DOOR);
 
                                                return;
@@ -1927,7 +1925,7 @@ void process_monster(MONSTER_IDX m_idx)
 
                /* Hack -- check for Glyph of Warding */
                if (do_move && is_glyph_grid(g_ptr) &&
-                   !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
+                   !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(target_ptr, ny, nx)))
                {
                        /* Assume no move allowed */
                        do_move = FALSE;
@@ -1955,7 +1953,7 @@ void process_monster(MONSTER_IDX m_idx)
                        }
                }
                else if (do_move && is_explosive_rune_grid(g_ptr) &&
-                        !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(ny, nx)))
+                        !((r_ptr->flags1 & RF1_NEVER_BLOW) && player_bold(target_ptr, ny, nx)))
                {
                        /* Assume no move allowed */
                        do_move = FALSE;
@@ -1970,7 +1968,7 @@ void process_monster(MONSTER_IDX m_idx)
                                        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);
+                                               project(target_ptr, 0, 2, ny, nx, 2 * (target_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
                                        }
                                }
                                else
@@ -1995,7 +1993,7 @@ void process_monster(MONSTER_IDX m_idx)
                }
 
                /* The player is in the way */
-               if (do_move && player_bold(ny, nx))
+               if (do_move && player_bold(target_ptr, ny, nx))
                {
                        /* Some monsters never attack */
                        if (r_ptr->flags1 & RF1_NEVER_BLOW)
@@ -2007,8 +2005,8 @@ void process_monster(MONSTER_IDX m_idx)
                                do_move = FALSE;
                        }
 
-                       /* 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))
+                       /* In anti-melee dungeon, stupid or confused monster takes useless turn */
+                       if (do_move && (d_info[target_ptr->dungeon_idx].flags1 & DF1_NO_MELEE))
                        {
                                if (!MON_CONFUSED(m_ptr))
                                {
@@ -2023,15 +2021,15 @@ void process_monster(MONSTER_IDX m_idx)
                        /* The player is in the way.  Attack him. */
                        if (do_move)
                        {
-                               if (!p_ptr->riding || one_in_(2))
+                               if (!target_ptr->riding || one_in_(2))
                                {
                                        /* Do the attack */
-                                       (void)make_attack_normal(p_ptr, m_idx);
+                                       (void)make_attack_normal(target_ptr, m_idx);
 
                                        /* Do not move */
                                        do_move = FALSE;
 
-                                       /* Took a current_world_ptr->game_turn */
+                                       /* Took a turn */
                                        do_turn = TRUE;
                                }
                        }
@@ -2048,7 +2046,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 && (g_ptr->m_idx != p_ptr->riding)) ||
+                                can_cross && (g_ptr->m_idx != target_ptr->riding)) ||
                                are_enemies(m_ptr, y_ptr) || MON_CONFUSED(m_ptr))
                        {
                                if (!(r_ptr->flags1 & RF1_NEVER_BLOW))
@@ -2061,10 +2059,10 @@ void process_monster(MONSTER_IDX m_idx)
                                        /* attack */
                                        if (y_ptr->r_idx && (y_ptr->hp >= 0))
                                        {
-                                               if (monst_attack_monst(m_idx, g_ptr->m_idx)) return;
+                                               if (monst_attack_monst(target_ptr, m_idx, g_ptr->m_idx)) return;
 
-                                               /* 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)
+                                               /* In anti-melee dungeon, stupid or confused monster takes useless turn */
+                                               else if (d_info[target_ptr->dungeon_idx].flags1 & DF1_NO_MELEE)
                                                {
                                                        if (MON_CONFUSED(m_ptr)) return;
                                                        else if (r_ptr->flags2 & RF2_STUPID)
@@ -2080,8 +2078,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 && (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))
+                               can_cross && (g_ptr->m_idx != target_ptr->riding) &&
+                               monster_can_cross_terrain(target_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
                        {
                                /* Allow movement */
                                do_move = TRUE;
@@ -2098,7 +2096,7 @@ void process_monster(MONSTER_IDX m_idx)
 
                if (is_riding_mon)
                {
-                       if (!p_ptr->riding_ryoute && !MON_MONFEAR(&current_floor_ptr->m_list[p_ptr->riding])) do_move = FALSE;
+                       if (!target_ptr->riding_ryoute && !MON_MONFEAR(&target_ptr->current_floor_ptr->m_list[target_ptr->riding])) do_move = FALSE;
                }
 
                if (did_kill_wall && do_move)
@@ -2115,8 +2113,8 @@ void process_monster(MONSTER_IDX m_idx)
 
                        if (!monster_is_valid(m_ptr)) /* Killed by shards of glass, etc. */
                        {
-                               p_ptr->update |= (PU_FLOW);
-                               p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+                               target_ptr->update |= (PU_FLOW);
+                               target_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                                if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags2 |= (RF2_KILL_WALL);
 
                                return;
@@ -2176,7 +2174,7 @@ void process_monster(MONSTER_IDX m_idx)
                        if (!is_riding_mon)
                        {
                                /* Hack -- Update the old location */
-                               current_floor_ptr->grid_array[oy][ox].m_idx = g_ptr->m_idx;
+                               target_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = g_ptr->m_idx;
 
                                /* Mega-Hack -- move the old monster, if any */
                                if (g_ptr->m_idx)
@@ -2186,7 +2184,7 @@ void process_monster(MONSTER_IDX m_idx)
                                        y_ptr->fx = ox;
 
                                        /* Update the old monster */
-                                       update_monster(g_ptr->m_idx, TRUE);
+                                       update_monster(target_ptr, g_ptr->m_idx, TRUE);
                                }
 
                                /* Hack -- Update the new location */
@@ -2195,7 +2193,7 @@ void process_monster(MONSTER_IDX m_idx)
                                /* Move the monster */
                                m_ptr->fy = ny;
                                m_ptr->fx = nx;
-                               update_monster(m_idx, TRUE);
+                               update_monster(target_ptr, m_idx, TRUE);
 
                                lite_spot(oy, ox);
                                lite_spot(ny, nx);
@@ -2203,22 +2201,22 @@ void process_monster(MONSTER_IDX m_idx)
                        else
                        {
                                /* sound(SOUND_WALK); */
-                               if (!move_player_effect(p_ptr, ny, nx, MPE_DONT_PICKUP)) break;
+                               if (!move_player_effect(target_ptr, ny, nx, MPE_DONT_PICKUP)) break;
                        }
 
                        /* Possible disturb */
                        if (m_ptr->ml &&
                            (disturb_move ||
-                            (disturb_near && (m_ptr->mflag & MFLAG_VIEW) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) ||
-                            (disturb_high && ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)))
+                            (disturb_near && (m_ptr->mflag & MFLAG_VIEW) && projectable(target_ptr->current_floor_ptr, target_ptr->y, target_ptr->x, m_ptr->fy, m_ptr->fx)) ||
+                            (disturb_high && ap_r_ptr->r_tkills && ap_r_ptr->level >= target_ptr->lev)))
                        {
                                if (is_hostile(m_ptr))
-                                       disturb(p_ptr, FALSE, TRUE);
+                                       disturb(target_ptr, FALSE, TRUE);
                        }
 
                        /* Take or Kill objects on the floor */
                        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))))
+                           (!is_pet(m_ptr) || ((target_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;
@@ -2228,7 +2226,7 @@ void process_monster(MONSTER_IDX m_idx)
                                {
                                        BIT_FLAGS flgs[TR_FLAG_SIZE], flg2 = 0L, flg3 = 0L, flgr = 0L;
                                        GAME_TEXT m_name[MAX_NLEN], o_name[MAX_NLEN];
-                                       object_type *o_ptr = &current_floor_ptr->o_list[this_o_idx];
+                                       object_type *o_ptr = &target_ptr->current_floor_ptr->o_list[this_o_idx];
                                        next_o_idx = o_ptr->next_o_idx;
 
                                        if (do_take)
@@ -2287,7 +2285,7 @@ void process_monster(MONSTER_IDX m_idx)
                                                        did_take_item = TRUE;
 
                                                        /* Describe observable situations */
-                                                       if (m_ptr->ml && player_can_see_bold(ny, nx))
+                                                       if (m_ptr->ml && player_can_see_bold(target_ptr, ny, nx))
                                                        {
                                                                msg_format(_("%^sは%sを拾おうとしたが、だめだった。", "%^s tries to pick up %s, but fails."), m_name, o_name);
                                                        }
@@ -2300,7 +2298,7 @@ void process_monster(MONSTER_IDX m_idx)
                                                did_take_item = TRUE;
 
                                                /* Describe observable situations */
-                                               if (player_can_see_bold(ny, nx))
+                                               if (player_can_see_bold(target_ptr, ny, nx))
                                                {
                                                        msg_format(_("%^sが%sを拾った。", "%^s picks up %s."), m_name, o_name);
                                                }
@@ -2330,7 +2328,7 @@ void process_monster(MONSTER_IDX m_idx)
                                                did_kill_item = TRUE;
 
                                                /* Describe observable situations */
-                                               if (player_has_los_bold(ny, nx))
+                                               if (player_has_los_bold(target_ptr, ny, nx))
                                                {
                                                        msg_format(_("%^sが%sを破壊した。", "%^s destroys %s."), m_name, o_name);
                                                }
@@ -2349,7 +2347,7 @@ void process_monster(MONSTER_IDX m_idx)
         *  Forward movements failed, but now received LOS attack!
         *  Try to flow by smell.
         */
-       if (p_ptr->no_flowed && i > 2 &&  m_ptr->target_y)
+       if (target_ptr->no_flowed && i > 2 &&  m_ptr->target_y)
                m_ptr->mflag2 &= ~MFLAG2_NOFLOW;
 
        /* If we haven't done anything, try casting a spell again */
@@ -2358,7 +2356,7 @@ void process_monster(MONSTER_IDX m_idx)
                /* Try to cast spell again */
                if (r_ptr->freq_spell && randint1(100) <= r_ptr->freq_spell)
                {
-                       if (make_attack_spell(m_idx)) return;
+                       if (make_attack_spell(m_idx, target_ptr)) return;
                }
        }
 
@@ -2366,15 +2364,15 @@ void process_monster(MONSTER_IDX m_idx)
        /* Notice changes in view */
        if (do_view)
        {
-               p_ptr->update |= (PU_FLOW);
-               p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+               target_ptr->update |= (PU_FLOW);
+               target_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
        }
 
        /* Notice changes in view */
        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->phase_out)))
+               || ((r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2)) && !target_ptr->phase_out)))
        {
-               p_ptr->update |= (PU_MON_LITE);
+               target_ptr->update |= (PU_MON_LITE);
        }
 
        /* Learn things from observable monster */
@@ -2417,7 +2415,7 @@ void process_monster(MONSTER_IDX m_idx)
                        msg_format(_("%^sは戦いを決意した!", "%^s turns to fight!"), m_name);
                }
 
-               if (m_ptr->ml) chg_virtue(p_ptr, V_COMPASSION, -1);
+               if (m_ptr->ml) chg_virtue(target_ptr, V_COMPASSION, -1);
 
                /* Actually do something now (?) */
        }
@@ -2457,7 +2455,7 @@ void process_monster(MONSTER_IDX m_idx)
  * changes (flags, attacks, spells), we induce a redraw of the monster\n
  * recall window.\n
  */
-void process_monsters(void)
+void process_monsters(player_type *target_ptr)
 {
        MONSTER_IDX i;
        POSITION fx, fy;
@@ -2487,16 +2485,17 @@ void process_monsters(void)
        SPEED speed;
 
        /* Clear monster fighting indicator */
-       current_floor_ptr->monster_noise = FALSE;
+       floor_type *floor_ptr = target_ptr->current_floor_ptr;
+       floor_ptr->monster_noise = FALSE;
 
        /* Memorize old race */
-       old_monster_race_idx = p_ptr->monster_race_idx;
+       old_monster_race_idx = target_ptr->monster_race_idx;
 
        /* Acquire knowledge */
-       if (p_ptr->monster_race_idx)
+       if (target_ptr->monster_race_idx)
        {
                /* Acquire current monster */
-               r_ptr = &r_info[p_ptr->monster_race_idx];
+               r_ptr = &r_info[target_ptr->monster_race_idx];
 
                /* Memorize flags */
                old_r_flags1 = r_ptr->r_flags1;
@@ -2519,18 +2518,18 @@ void process_monsters(void)
 
 
        /* Process the monsters (backwards) */
-       for (i = current_floor_ptr->m_max - 1; i >= 1; i--)
+       for (i = floor_ptr->m_max - 1; i >= 1; i--)
        {
-               m_ptr = &current_floor_ptr->m_list[i];
+               m_ptr = &floor_ptr->m_list[i];
                r_ptr = &r_info[m_ptr->r_idx];
 
                /* Handle "leaving" */
-               if (p_ptr->leaving) break;
+               if (target_ptr->leaving) break;
 
                /* Ignore "dead" monsters */
                if (!monster_is_valid(m_ptr)) continue;
 
-               if (p_ptr->wild_mode) continue;
+               if (target_ptr->wild_mode) continue;
 
 
                /* Handle "fresh" monsters */
@@ -2550,7 +2549,7 @@ void process_monsters(void)
                fy = m_ptr->fy;
 
                /* Flow by smell is allowed */
-               if (!p_ptr->no_flowed)
+               if (!target_ptr->no_flowed)
                {
                        m_ptr->mflag2 &= ~MFLAG2_NOFLOW;
                }
@@ -2566,21 +2565,21 @@ void process_monsters(void)
                }
 
                /* Handle "sight" and "aggravation" */
-        else if ((m_ptr->cdis <= MAX_SIGHT || p_ptr->phase_out) &&
-                       (player_has_los_bold(fy, fx) || (p_ptr->cursed & TRC_AGGRAVATE)))
+        else if ((m_ptr->cdis <= MAX_SIGHT || target_ptr->phase_out) &&
+                       (player_has_los_bold(target_ptr, fy, fx) || (target_ptr->cursed & TRC_AGGRAVATE)))
                {
                        /* We can "see" or "feel" the player */
                        test = TRUE;
                }
 
-#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... */
+#if 0 /* (floor_ptr->grid_array[target_ptr->y][target_ptr->x].when == 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) &&
-                       (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))
+                       cave_have_flag_bold(target_ptr->y, target_ptr->x, FF_MOVE) &&
+                       (floor_ptr->grid_array[target_ptr->y][target_ptr->x].when == floor_ptr->grid_array[fy][fx].when) &&
+                       (floor_ptr->grid_array[fy][fx].dist < MONSTER_FLOW_DEPTH) &&
+                       (floor_ptr->grid_array[fy][fx].dist < r_ptr->aaf))
                {
                        /* We can "smell" the player */
                        test = TRUE;
@@ -2592,8 +2591,8 @@ void process_monsters(void)
                if (!test) continue;
 
 
-               if (p_ptr->riding == i)
-                       speed = p_ptr->pspeed;
+               if (target_ptr->riding == i)
+                       speed = target_ptr->pspeed;
                else
                {
                        speed = m_ptr->mspeed;
@@ -2618,19 +2617,19 @@ void process_monsters(void)
                hack_m_idx = i;
 
                /* Process the monster */
-               process_monster(i);
+               process_monster(target_ptr, i);
 
                reset_target(m_ptr);
 
                /* Give up flow_by_smell when it might useless */
-               if (p_ptr->no_flowed && one_in_(3))
+               if (target_ptr->no_flowed && one_in_(3))
                        m_ptr->mflag2 |= MFLAG2_NOFLOW;
 
                /* Hack -- notice death or departure */
-               if (!p_ptr->playing || p_ptr->is_dead) break;
+               if (!target_ptr->playing || target_ptr->is_dead) break;
 
                /* Notice leaving */
-               if (p_ptr->leaving) break;
+               if (target_ptr->leaving) break;
        }
 
        /* Reset global index */
@@ -2638,27 +2637,27 @@ void process_monsters(void)
 
 
        /* Tracking a monster race (the same one we were before) */
-       if (p_ptr->monster_race_idx && (p_ptr->monster_race_idx == old_monster_race_idx))
+       if (!target_ptr->monster_race_idx || (target_ptr->monster_race_idx != old_monster_race_idx))
+               return;
+
+       /* Acquire monster race */
+       r_ptr = &r_info[target_ptr->monster_race_idx];
+
+       /* Check for knowledge change */
+       if ((old_r_flags1 != r_ptr->r_flags1) ||
+               (old_r_flags2 != r_ptr->r_flags2) ||
+               (old_r_flags3 != r_ptr->r_flags3) ||
+               (old_r_flags4 != r_ptr->r_flags4) ||
+               (old_r_flags5 != r_ptr->r_flags5) ||
+               (old_r_flags6 != r_ptr->r_flags6) ||
+               (old_r_flagsr != r_ptr->r_flagsr) ||
+               (old_r_blows0 != r_ptr->r_blows[0]) ||
+               (old_r_blows1 != r_ptr->r_blows[1]) ||
+               (old_r_blows2 != r_ptr->r_blows[2]) ||
+               (old_r_blows3 != r_ptr->r_blows[3]) ||
+               (old_r_cast_spell != r_ptr->r_cast_spell))
        {
-               /* Acquire monster race */
-               r_ptr = &r_info[p_ptr->monster_race_idx];
-
-               /* Check for knowledge change */
-               if ((old_r_flags1 != r_ptr->r_flags1) ||
-                       (old_r_flags2 != r_ptr->r_flags2) ||
-                       (old_r_flags3 != r_ptr->r_flags3) ||
-                       (old_r_flags4 != r_ptr->r_flags4) ||
-                       (old_r_flags5 != r_ptr->r_flags5) ||
-                       (old_r_flags6 != r_ptr->r_flags6) ||
-                       (old_r_flagsr != r_ptr->r_flagsr) ||
-                       (old_r_blows0 != r_ptr->r_blows[0]) ||
-                       (old_r_blows1 != r_ptr->r_blows[1]) ||
-                       (old_r_blows2 != r_ptr->r_blows[2]) ||
-                       (old_r_blows3 != r_ptr->r_blows[3]) ||
-                       (old_r_cast_spell != r_ptr->r_cast_spell))
-               {
-                       p_ptr->window |= (PW_MONSTER);
-               }
+               target_ptr->window |= (PW_MONSTER);
        }
 }