OSDN Git Service

[Refactor] #38997 scatter() に player_type * 引数を追加 / Added player_type * argument...
[hengband/hengband.git] / src / monster2.c
index 35d56fa..1ca5e8f 100644 (file)
  */
 
 #include "angband.h"
+#include "util.h"
+#include "core.h"
+
+#include "cmd-dump.h"
 #include "cmd-pet.h"
+#include "dungeon.h"
+#include "floor.h"
+#include "object-flavor.h"
 #include "monsterrace-hook.h"
 #include "monster-status.h"
-#include "projection.h"
 #include "monster.h"
+#include "spells.h"
 #include "spells-summon.h"
 #include "quest.h"
 #include "grid.h"
 #include "player-move.h"
+#include "player-status.h"
+#include "player-race.h"
+#include "player-class.h"
+#include "player-personality.h"
 #include "wild.h"
 #include "warning.h"
-#include "player-status.h"
+#include "monster-spell.h"
+#include "files.h"
+#include "view-mainwindow.h"
+#include "world.h"
+#include "monsterrace.h"
+#include "creature.h"
+#include "targeting.h"
+#include "realm-song.h"
+#include "melee.h"
 
 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
 
-
-/*!
- * @var horror_desc
- * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
- */
-concptr horror_desc[MAX_SAN_HORROR] =
-{
-#ifdef JP
-       "忌まわしい",
-       "底知れぬ",
-       "ぞっとする",
-       "破滅的な",
-       "冒涜的な",
-
-       "いやな",
-       "恐ろしい",
-       "不潔な",
-       "容赦のない",
-       "おぞましい",
-
-       "地獄の",
-       "身の毛もよだつ",
-       "地獄の",
-       "忌まわしい",
-       "悪夢のような",
-
-       "嫌悪を感じる",
-       "罰当たりな",
-       "恐い",
-       "不浄な",
-       "言うもおぞましい",
-#else
-       "abominable",
-       "abysmal",
-       "appalling",
-       "baleful",
-       "blasphemous",
-
-       "disgusting",
-       "dreadful",
-       "filthy",
-       "grisly",
-       "hideous",
-
-       "hellish",
-       "horrible",
-       "infernal",
-       "loathsome",
-       "nightmarish",
-
-       "repulsive",
-       "sacrilegious",
-       "terrible",
-       "unclean",
-       "unspeakable",
-#endif
-
-};
-
-/*!
- * @var funny_desc
- * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
- */
-concptr funny_desc[MAX_SAN_FUNNY] =
-{
-#ifdef JP
-       "間抜けな",
-       "滑稽な",
-       "ばからしい",
-       "無味乾燥な",
-       "馬鹿げた",
-
-       "笑える",
-       "ばかばかしい",
-       "ぶっとんだ",
-       "いかした",
-       "ポストモダンな",
-
-       "ファンタスティックな",
-       "ダダイズム的な",
-       "キュビズム的な",
-       "宇宙的な",
-       "卓越した",
-
-       "理解不能な",
-       "ものすごい",
-       "驚くべき",
-       "信じられない",
-       "カオティックな",
-
-       "野性的な",
-       "非常識な",
-#else
-       "silly",
-       "hilarious",
-       "absurd",
-       "insipid",
-       "ridiculous",
-
-       "laughable",
-       "ludicrous",
-       "far-out",
-       "groovy",
-       "postmodern",
-
-       "fantastic",
-       "dadaistic",
-       "cubistic",
-       "cosmic",
-       "awesome",
-
-       "incomprehensible",
-       "fabulous",
-       "amazing",
-       "incredible",
-       "chaotic",
-
-       "wild",
-       "preposterous",
-#endif
-
-};
-
-/*!
- * @var funny_comments
- * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
- */
-concptr funny_comments[MAX_SAN_COMMENT] =
-{
-#ifdef JP
-  /* nuke me */
-       "最高だぜ!",
-       "うひょー!",
-       "いかすぜ!",
-       "すんばらしい!",
-       "ぶっとびー!"
-#else
-       "Wow, cosmic, man!",
-       "Rad!",
-       "Groovy!",
-       "Cool!",
-       "Far out!"
-#endif
-
-};
-
+MONSTER_IDX hack_m_idx = 0;    /* Hack -- see "process_monsters()" */
+MONSTER_IDX hack_m_idx_ii = 0;
 
 /*!
  * @brief モンスターの目標地点をセットする / Set the target of counter attack
@@ -239,7 +114,7 @@ MONRACE_IDX real_r_idx(monster_type *m_ptr)
 void delete_monster_idx(MONSTER_IDX i)
 {
        POSITION x, y;
-       monster_type *m_ptr = &current_floor_ptr->m_list[i];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        OBJECT_IDX this_o_idx, next_o_idx = 0;
 
@@ -250,7 +125,7 @@ void delete_monster_idx(MONSTER_IDX i)
        real_r_ptr(m_ptr)->cur_num--;
 
        /* Hack -- count the number of "reproducers" */
-       if (r_ptr->flags2 & (RF2_MULTIPLY)) current_floor_ptr->num_repro--;
+       if (r_ptr->flags2 & (RF2_MULTIPLY)) p_ptr->current_floor_ptr->num_repro--;
 
        if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
        if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
@@ -266,17 +141,17 @@ void delete_monster_idx(MONSTER_IDX i)
        /* Hack -- remove tracked monster */
        if (i == p_ptr->health_who) health_track(0);
 
-       if (pet_t_m_idx == i ) pet_t_m_idx = 0;
-       if (riding_t_m_idx == i) riding_t_m_idx = 0;
+       if (p_ptr->pet_t_m_idx == i ) p_ptr->pet_t_m_idx = 0;
+       if (p_ptr->riding_t_m_idx == i) p_ptr->riding_t_m_idx = 0;
        if (p_ptr->riding == i) p_ptr->riding = 0;
 
        /* Monster is gone */
-       current_floor_ptr->grid_array[y][x].m_idx = 0;
+       p_ptr->current_floor_ptr->grid_array[y][x].m_idx = 0;
 
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-               o_ptr = &current_floor_ptr->o_list[this_o_idx];
+               o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
                next_o_idx = o_ptr->next_o_idx;
 
                /*
@@ -290,33 +165,13 @@ void delete_monster_idx(MONSTER_IDX i)
        (void)WIPE(m_ptr, monster_type);
 
        /* Count monsters */
-       m_cnt--;
+       p_ptr->current_floor_ptr->m_cnt--;
 
-       /* Visual update */
        lite_spot(y, x);
        if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
+       {
                p_ptr->update |= (PU_MON_LITE);
-}
-
-
-/*!
- * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location
- * @param x 削除位置x座標
- * @param y 削除位置y座標
- * @return なし
- */
-void delete_monster(POSITION y, POSITION x)
-{
-       grid_type *g_ptr;
-
-       /* Paranoia */
-       if (!in_bounds(y, x)) return;
-
-       /* Check the grid */
-       g_ptr = &current_floor_ptr->grid_array[y][x];
-
-       /* Delete the monster (if any) */
-       if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
+       }
 }
 
 
@@ -326,7 +181,7 @@ void delete_monster(POSITION y, POSITION x)
  * @param i2 配列移動先添字
  * @return なし
  */
-static void compact_monsters_aux(IDX i1, IDX i2)
+static void compact_monsters_aux(MONSTER_IDX i1, MONSTER_IDX i2)
 {
        POSITION y, x;
        int i;
@@ -338,22 +193,21 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        if (i1 == i2) return;
 
        /* Old monster */
-       m_ptr = &current_floor_ptr->m_list[i1];
+       m_ptr = &p_ptr->current_floor_ptr->m_list[i1];
 
        y = m_ptr->fy;
        x = m_ptr->fx;
 
        /* Cave grid */
-       g_ptr = &current_floor_ptr->grid_array[y][x];
+       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
 
-       /* Update the current_floor_ptr->grid_array */
        g_ptr->m_idx = i2;
 
        /* Repair objects being carried by monster */
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-               o_ptr = &current_floor_ptr->o_list[this_o_idx];
+               o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
                next_o_idx = o_ptr->next_o_idx;
 
                /* Reset monster pointer */
@@ -364,8 +218,8 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        if (target_who == i1) target_who = i2;
 
        /* Hack -- Update the target */
-       if (pet_t_m_idx == i1) pet_t_m_idx = i2;
-       if (riding_t_m_idx == i1) riding_t_m_idx = i2;
+       if (p_ptr->pet_t_m_idx == i1) p_ptr->pet_t_m_idx = i2;
+       if (p_ptr->riding_t_m_idx == i1) p_ptr->riding_t_m_idx = i2;
 
        /* Hack -- Update the riding */
        if (p_ptr->riding == i1) p_ptr->riding = i2;
@@ -376,9 +230,9 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        /* Hack -- Update parent index */
        if (is_pet(m_ptr))
        {
-               for (i = 1; i < m_max; i++)
+               for (i = 1; i < p_ptr->current_floor_ptr->m_max; i++)
                {
-                       monster_type *m2_ptr = &current_floor_ptr->m_list[i];
+                       monster_type *m2_ptr = &p_ptr->current_floor_ptr->m_list[i];
 
                        if (m2_ptr->parent_m_idx == i1)
                                m2_ptr->parent_m_idx = i2;
@@ -386,15 +240,15 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        }
 
        /* Structure copy */
-       (void)COPY(&current_floor_ptr->m_list[i2], &current_floor_ptr->m_list[i1], monster_type);
+       (void)COPY(&p_ptr->current_floor_ptr->m_list[i2], &p_ptr->current_floor_ptr->m_list[i1], monster_type);
 
        /* Wipe the hole */
-       (void)WIPE(&current_floor_ptr->m_list[i1], monster_type);
+       (void)WIPE(&p_ptr->current_floor_ptr->m_list[i1], monster_type);
 
        for (i = 0; i < MAX_MTIMED; i++)
        {
                int mproc_idx = get_mproc_idx(i1, i);
-               if (mproc_idx >= 0) current_floor_ptr->mproc_list[i][mproc_idx] = i2;
+               if (mproc_idx >= 0) p_ptr->current_floor_ptr->mproc_list[i][mproc_idx] = i2;
        }
 }
 
@@ -433,9 +287,9 @@ void compact_monsters(int size)
                cur_dis = 5 * (20 - cnt);
 
                /* Check all the monsters */
-               for (i = 1; i < m_max; i++)
+               for (i = 1; i < p_ptr->current_floor_ptr->m_max; i++)
                {
-                       monster_type *m_ptr = &current_floor_ptr->m_list[i];
+                       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
 
                        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
@@ -466,7 +320,7 @@ void compact_monsters(int size)
                        {
                                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_COMPACT, m_name);
+                               exe_write_diary(p_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
                        }
 
                        delete_monster_idx(i);
@@ -478,19 +332,19 @@ void compact_monsters(int size)
 
 
        /* Excise dead monsters (backwards!) */
-       for (i = m_max - 1; i >= 1; i--)
+       for (i = p_ptr->current_floor_ptr->m_max - 1; i >= 1; i--)
        {
                /* Get the i'th monster */
-               monster_type *m_ptr = &current_floor_ptr->m_list[i];
+               monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
 
                /* Skip real monsters */
                if (m_ptr->r_idx) continue;
 
                /* Move last monster into open hole */
-               compact_monsters_aux(m_max - 1, i);
+               compact_monsters_aux(p_ptr->current_floor_ptr->m_max - 1, i);
 
-               /* Compress "m_max" */
-               m_max--;
+               /* Compress "p_ptr->current_floor_ptr->m_max" */
+               p_ptr->current_floor_ptr->m_max--;
        }
 }
 
@@ -526,13 +380,13 @@ void wipe_m_list(void)
        }
 
        /* Delete all the monsters */
-       for (i = m_max - 1; i >= 1; i--)
+       for (i = p_ptr->current_floor_ptr->m_max - 1; i >= 1; i--)
        {
-               monster_type *m_ptr = &current_floor_ptr->m_list[i];
+               monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
                if (!monster_is_valid(m_ptr)) continue;
 
                /* Monster is gone */
-               current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].m_idx = 0;
+               p_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].m_idx = 0;
 
                (void)WIPE(m_ptr, monster_type);
 
@@ -547,22 +401,22 @@ void wipe_m_list(void)
        /* Hack -- Wipe the racial counter of all monster races */
        for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
 
-       /* Reset "m_max" */
-       m_max = 1;
+       /* Reset "p_ptr->current_floor_ptr->m_max" */
+       p_ptr->current_floor_ptr->m_max = 1;
 
-       /* Reset "m_cnt" */
-       m_cnt = 0;
+       /* Reset "p_ptr->current_floor_ptr->m_cnt" */
+       p_ptr->current_floor_ptr->m_cnt = 0;
 
-       /* Reset "current_floor_ptr->mproc_max[]" */
-       for (i = 0; i < MAX_MTIMED; i++) current_floor_ptr->mproc_max[i] = 0;
+       /* Reset "p_ptr->current_floor_ptr->mproc_max[]" */
+       for (i = 0; i < MAX_MTIMED; i++) p_ptr->current_floor_ptr->mproc_max[i] = 0;
 
        /* Hack -- reset "reproducer" count */
-       current_floor_ptr->num_repro = 0;
+       p_ptr->current_floor_ptr->num_repro = 0;
 
        /* Hack -- no more target */
        target_who = 0;
-       pet_t_m_idx = 0;
-       riding_t_m_idx = 0;
+       p_ptr->pet_t_m_idx = 0;
+       p_ptr->riding_t_m_idx = 0;
 
        /* Hack -- no more tracking */
        health_track(0);
@@ -580,41 +434,39 @@ MONSTER_IDX m_pop(void)
        MONSTER_IDX i;
 
        /* Normal allocation */
-       if (m_max < current_floor_ptr->max_m_idx)
+       if (p_ptr->current_floor_ptr->m_max < current_world_ptr->max_m_idx)
        {
                /* Access the next hole */
-               i = m_max;
+               i = p_ptr->current_floor_ptr->m_max;
 
                /* Expand the array */
-               m_max++;
+               p_ptr->current_floor_ptr->m_max++;
 
                /* Count monsters */
-               m_cnt++;
+               p_ptr->current_floor_ptr->m_cnt++;
 
                /* Return the index */
                return (i);
        }
 
        /* Recycle dead monsters */
-       for (i = 1; i < m_max; i++)
+       for (i = 1; i < p_ptr->current_floor_ptr->m_max; i++)
        {
                monster_type *m_ptr;
-
-               /* Acquire monster */
-               m_ptr = &current_floor_ptr->m_list[i];
+               m_ptr = &p_ptr->current_floor_ptr->m_list[i];
 
                /* Skip live monsters */
                if (m_ptr->r_idx) continue;
 
                /* Count monsters */
-               m_cnt++;
+               p_ptr->current_floor_ptr->m_cnt++;
 
                /* Use this monster */
                return (i);
        }
 
        /* Warn the player (except during dungeon creation) */
-       if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
+       if (current_world_ptr->character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
 
        /* Try not to crash */
        return (0);
@@ -650,7 +502,7 @@ static bool summon_unique_okay = FALSE;
  * @return 召喚条件が一致するならtrue
  * @details
  */
-static bool summon_specific_aux(MONRACE_IDX r_idx)
+static bool summon_specific_aux(MONRACE_IDX summoner_idx, MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
        int okay = FALSE;
@@ -788,6 +640,16 @@ static bool summon_specific_aux(MONRACE_IDX r_idx)
 
                case SUMMON_KIN:
                {
+                       SYMBOL_CODE summon_kin_type;
+                       if (summoner_idx)
+                       {
+                               summon_kin_type = r_info[summoner_idx].d_char;
+                       }
+                       else
+                       {
+                               summon_kin_type = get_summon_symbol_from_player(p_ptr);
+                       }
+
                        okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
                        break;
                }
@@ -956,9 +818,9 @@ static int chameleon_change_m_idx = 0;
  * @param r_idx チェックするモンスター種族ID
  * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
  */
-static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
+static bool restrict_monster_to_dungeon(DUNGEON_IDX d_idx, MONRACE_IDX r_idx)
 {
-       dungeon_type *d_ptr = &d_info[p_ptr->dungeon_idx];
+       dungeon_type *d_ptr = &d_info[d_idx];
        monster_race *r_ptr = &r_info[r_idx];
        byte a;
 
@@ -985,7 +847,7 @@ static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
        }
        if (d_ptr->flags1 & DF1_BEGINNER)
        {
-               if (r_ptr->level > current_floor_ptr->dun_level)
+               if (r_ptr->level > p_ptr->current_floor_ptr->dun_level)
                        return FALSE;
        }
 
@@ -1142,6 +1004,12 @@ static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
        return TRUE;
 }
 
+/*
+ * Hack -- function hooks to restrict "get_mon_num_prep()" function
+ */
+monsterrace_hook_type get_mon_num_hook;
+monsterrace_hook_type get_mon_num2_hook;
+
 /*!
  * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
  * @param monster_hook 制限関数1
@@ -1175,7 +1043,7 @@ errr get_mon_num_prep(monsterrace_hook_type monster_hook,
                    (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
                        continue;
 
-               if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
+               if (!p_ptr->phase_out && !chameleon_change_m_idx &&
                    summon_specific_type != SUMMON_GUARDIANS)
                {
                        /* Hack -- don't create questors */
@@ -1187,14 +1055,15 @@ errr get_mon_num_prep(monsterrace_hook_type monster_hook,
 
                        /* Depth Monsters never appear out of depth */
                        if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
-                           (r_ptr->level > current_floor_ptr->dun_level))
+                           (r_ptr->level > p_ptr->current_floor_ptr->dun_level))
                                continue;
                }
 
                /* Accept this monster */
                entry->prob2 = entry->prob1;
 
-               if (current_floor_ptr->dun_level && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest)) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
+               if (p_ptr->current_floor_ptr->dun_level && (!p_ptr->current_floor_ptr->inside_quest || is_fixed_quest_idx(p_ptr->current_floor_ptr->inside_quest)) &&
+                       !restrict_monster_to_dungeon(p_ptr->dungeon_idx, entry->index) && !p_ptr->phase_out)
                {
                        int hoge = entry->prob2 * d_info[p_ptr->dungeon_idx].special_div;
                        entry->prob2 = hoge / 64;
@@ -1256,7 +1125,7 @@ MONRACE_IDX get_mon_num(DEPTH level)
        }
 
        /* Boost the level */
-       if (!p_ptr->inside_battle && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
+       if (!p_ptr->phase_out && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
        {
                /* Nightmare mode allows more out-of depth monsters */
                if (ironman_nightmare && !randint0(pls_kakuritu))
@@ -1296,7 +1165,7 @@ MONRACE_IDX get_mon_num(DEPTH level)
                /* Access the actual race */
                r_ptr = &r_info[r_idx];
 
-               if (!p_ptr->inside_battle && !chameleon_change_m_idx)
+               if (!p_ptr->phase_out && !chameleon_change_m_idx)
                {
                        /* Hack -- "unique" monsters must be "unique" */
                        if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
@@ -1646,8 +1515,8 @@ void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
                        }
 
                        /* Inside monster arena, and it is not your mount */
-                       else if (p_ptr->inside_battle &&
-                                !(p_ptr->riding && (&current_floor_ptr->m_list[p_ptr->riding] == m_ptr)))
+                       else if (p_ptr->phase_out &&
+                                !(p_ptr->riding && (&p_ptr->current_floor_ptr->m_list[p_ptr->riding] == m_ptr)))
                        {
                                /* It is a fake unique monster */
                                (void)sprintf(desc, _("%sもどき", "fake %s"), name);
@@ -1692,7 +1561,7 @@ void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
                        strcat(desc,buf);
                }
 
-               if (p_ptr->riding && (&current_floor_ptr->m_list[p_ptr->riding] == m_ptr))
+               if (p_ptr->riding && (&p_ptr->current_floor_ptr->m_list[p_ptr->riding] == m_ptr))
                {
                        strcat(desc,_("(乗馬中)", "(riding)"));
                }
@@ -1725,6 +1594,16 @@ void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
        }
 }
 
+/*!
+* @brief モンスターIDを取り、モンスター名をm_nameに代入する /
+* @param m_idx モンスターID
+* @param m_name モンスター名を入力する配列
+*/
+void monster_name(MONSTER_IDX m_idx, char* m_name)
+{
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
+       monster_desc(m_name, m_ptr, 0x00);
+}
 
 
 /*!
@@ -1853,7 +1732,7 @@ int lore_do_probe(MONRACE_IDX r_idx)
  */
 void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
 {
-       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];
 
@@ -1938,16 +1817,14 @@ void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold
  * "disturb_near" (monster which is "easily" viewable moves in some
  * way).  Note that "moves" includes "appears" and "disappears".
  */
-void update_monster(MONSTER_IDX m_idx, bool full)
+void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full)
 {
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &subject_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        bool do_disturb = disturb_move;
 
        POSITION d;
-
-       /* Current location */
        POSITION fy = m_ptr->fy;
        POSITION fx = m_ptr->fx;
 
@@ -1958,14 +1835,14 @@ void update_monster(MONSTER_IDX m_idx, bool full)
        bool easy = FALSE;
 
        /* Non-Ninja player in the darkness */
-       bool in_darkness = (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
+       bool in_darkness = (d_info[subject_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !subject_ptr->see_nocto;
 
        /* Do disturb? */
        if (disturb_high)
        {
                monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
 
-               if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
+               if (ap_r_ptr->r_tkills && ap_r_ptr->level >= subject_ptr->lev)
                        do_disturb = TRUE;
        }
 
@@ -1973,8 +1850,8 @@ void update_monster(MONSTER_IDX m_idx, bool full)
        if (full)
        {
                /* Distance components */
-               int dy = (p_ptr->y > fy) ? (p_ptr->y - fy) : (fy - p_ptr->y);
-               int dx = (p_ptr->x > fx) ? (p_ptr->x - fx) : (fx - p_ptr->x);
+               int dy = (subject_ptr->y > fy) ? (subject_ptr->y - fy) : (fy - subject_ptr->y);
+               int dx = (subject_ptr->x > fx) ? (subject_ptr->x - fx) : (fx - subject_ptr->x);
 
                /* Approximate distance */
                d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
@@ -1995,22 +1872,20 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                d = m_ptr->cdis;
        }
 
-
        /* Detected */
        if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
 
-
        /* Nearby */
        if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
        {
                if (!in_darkness || (d <= MAX_SIGHT / 4))
                {
-                       if (p_ptr->special_defense & KATA_MUSOU)
+                       if (subject_ptr->special_defense & KATA_MUSOU)
                        {
                                /* Detectable */
                                flag = TRUE;
 
-                               if (is_original_ap(m_ptr) && !p_ptr->image)
+                               if (is_original_ap(m_ptr) && !subject_ptr->image)
                                {
                                        /* Hack -- Memorize mental flags */
                                        if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
@@ -2020,13 +1895,13 @@ void update_monster(MONSTER_IDX m_idx, bool full)
 
                        /* Basic telepathy */
                        /* Snipers get telepathy when they concentrate deeper */
-                       else if (p_ptr->telepathy)
+                       else if (subject_ptr->telepathy)
                        {
                                /* Empty mind, no telepathy */
                                if (r_ptr->flags2 & (RF2_EMPTY_MIND))
                                {
                                        /* Memorize flags */
-                                       if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
+                                       if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
                                }
 
                                /* Weird mind, occasional telepathy */
@@ -2038,7 +1913,7 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                                                /* Detectable */
                                                flag = TRUE;
 
-                                               if (is_original_ap(m_ptr) && !p_ptr->image)
+                                               if (is_original_ap(m_ptr) && !subject_ptr->image)
                                                {
                                                        /* Memorize flags */
                                                        r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
@@ -2056,7 +1931,7 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                                        /* Detectable */
                                        flag = TRUE;
 
-                                       if (is_original_ap(m_ptr) && !p_ptr->image)
+                                       if (is_original_ap(m_ptr) && !subject_ptr->image)
                                        {
                                                /* Hack -- Memorize mental flags */
                                                if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
@@ -2065,95 +1940,95 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                                }
                        }
 
-                       if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
+                       if ((subject_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
                        }
 
-                       if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
+                       if ((subject_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
                        }
 
-                       if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
+                       if ((subject_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
                        }
 
-                       if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
+                       if ((subject_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
                        }
 
-                       if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
+                       if ((subject_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
                        }
 
-                       if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
+                       if ((subject_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
                        }
 
-                       if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
+                       if ((subject_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
                        }
 
-                       if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
+                       if ((subject_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
                        }
 
-                       if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
+                       if ((subject_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
                        }
 
-                       if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
+                       if ((subject_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
                        }
 
-                       if ((p_ptr->esp_nonliving) &&
+                       if ((subject_ptr->esp_nonliving) &&
                            ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
                        }
 
-                       if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
+                       if ((subject_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
                        {
                                flag = TRUE;
-                               if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
+                               if (is_original_ap(m_ptr) && !subject_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
                        }
                }
 
                /* Normal line of sight, and not blind */
-               if (player_has_los_bold(fy, fx) && !p_ptr->blind)
+               if (player_has_los_bold(subject_ptr, fy, fx) && !subject_ptr->blind)
                {
                        bool do_invisible = FALSE;
                        bool do_cold_blood = FALSE;
 
                        /* Snipers can see targets in darkness when they concentrate deeper */
-                       if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
+                       if (subject_ptr->concent >= CONCENT_RADAR_THRESHOLD)
                        {
                                /* Easy to see */
                                easy = flag = TRUE;
                        }
 
                        /* Use "infravision" */
-                       if (d <= p_ptr->see_infra)
+                       if (d <= subject_ptr->see_infra)
                        {
                                /* Handle "cold blooded" monsters */
                                if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
@@ -2170,7 +2045,7 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                        }
 
                        /* Use "illumination" */
-                       if (player_can_see_bold(fy, fx))
+                       if (player_can_see_bold(subject_ptr, fy, fx))
                        {
                                /* Handle "invisible" monsters */
                                if (r_ptr->flags2 & (RF2_INVISIBLE))
@@ -2178,7 +2053,7 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                                        do_invisible = TRUE;
 
                                        /* See invisible */
-                                       if (p_ptr->see_inv)
+                                       if (subject_ptr->see_inv)
                                        {
                                                /* Easy to see */
                                                easy = flag = TRUE;
@@ -2196,7 +2071,7 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                        /* Visible */
                        if (flag)
                        {
-                               if (is_original_ap(m_ptr) && !p_ptr->image)
+                               if (is_original_ap(m_ptr) && !subject_ptr->image)
                                {
                                        /* Memorize flags */
                                        if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
@@ -2220,11 +2095,11 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                        lite_spot(fy, fx);
 
                        /* Update health bar as needed */
-                       if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
-                       if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
+                       if (subject_ptr->health_who == m_idx) subject_ptr->redraw |= (PR_HEALTH);
+                       if (subject_ptr->riding == m_idx) subject_ptr->redraw |= (PR_UHEALTH);
 
                        /* Hack -- Count "fresh" sightings */
-                       if (!p_ptr->image)
+                       if (!subject_ptr->image)
                        {
                                if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
                                        r_info[MON_KAGE].r_sights++;
@@ -2232,17 +2107,16 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                                        r_ptr->r_sights++;
                        }
 
-                       /* Eldritch Horror */
                        if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
                        {
-                               sanity_blast(m_ptr, FALSE);
+                               sanity_blast(subject_ptr, m_ptr, FALSE);
                        }
 
                        /* Disturb on appearance */
-                       if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)))
+                       if (disturb_near && (projectable(subject_ptr->current_floor_ptr, m_ptr->fy, m_ptr->fx, subject_ptr->y, subject_ptr->x) && projectable(subject_ptr->current_floor_ptr, subject_ptr->y, subject_ptr->x, m_ptr->fy, m_ptr->fx)))
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(TRUE, TRUE);
+                                       disturb(subject_ptr, TRUE, TRUE);
                        }
                }
        }
@@ -2260,14 +2134,14 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                        lite_spot(fy, fx);
 
                        /* Update health bar as needed */
-                       if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
-                       if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
+                       if (subject_ptr->health_who == m_idx) subject_ptr->redraw |= (PR_HEALTH);
+                       if (subject_ptr->riding == m_idx) subject_ptr->redraw |= (PR_UHEALTH);
 
                        /* Disturb on disappearance */
                        if (do_disturb)
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(TRUE, TRUE);
+                                       disturb(subject_ptr, TRUE, TRUE);
                        }
                }
        }
@@ -2286,7 +2160,7 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                        if (do_disturb)
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(TRUE, TRUE);
+                                       disturb(subject_ptr, TRUE, TRUE);
                        }
                }
        }
@@ -2304,7 +2178,7 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                        if (do_disturb)
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(TRUE, TRUE);
+                                       disturb(subject_ptr, TRUE, TRUE);
                        }
                }
        }
@@ -2321,11 +2195,11 @@ void update_monsters(bool full)
        MONSTER_IDX i;
 
        /* Update each (live) monster */
-       for (i = 1; i < m_max; i++)
+       for (i = 1; i < p_ptr->current_floor_ptr->m_max; i++)
        {
-               monster_type *m_ptr = &current_floor_ptr->m_list[i];
+               monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[i];
                if (!monster_is_valid(m_ptr)) continue;
-               update_monster(i, full);
+               update_monster(p_ptr, i, full);
        }
 }
 
@@ -2338,7 +2212,7 @@ void update_monsters(bool full)
 static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
-       monster_type *m_ptr = &current_floor_ptr->m_list[chameleon_change_m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[chameleon_change_m_idx];
        monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
 
        if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
@@ -2349,7 +2223,7 @@ static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
        if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
                return FALSE;
 
-       if (!monster_can_cross_terrain(current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
+       if (!monster_can_cross_terrain(p_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
 
        /* Not born */
        if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
@@ -2360,7 +2234,7 @@ static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
        /* Born now */
        else if (summon_specific_who > 0)
        {
-               if (monster_has_hostile_align(&current_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
+               if (monster_has_hostile_align(&p_ptr->current_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
        }
 
        return TRUE;
@@ -2370,11 +2244,12 @@ static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
  * @brief カメレオンの変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
  * @param r_idx モンスター種族ID
  * @return 対象にできるならtrueを返す
+ * @todo グローバル変数対策の上 monster_hook.cへ移す。
  */
 static bool monster_hook_chameleon(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
-       monster_type *m_ptr = &current_floor_ptr->m_list[chameleon_change_m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[chameleon_change_m_idx];
        monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
 
        if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
@@ -2384,7 +2259,7 @@ static bool monster_hook_chameleon(MONRACE_IDX r_idx)
        if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
                return FALSE;
 
-       if (!monster_can_cross_terrain(current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
+       if (!monster_can_cross_terrain(p_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
 
        /* Not born */
        if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
@@ -2397,7 +2272,7 @@ static bool monster_hook_chameleon(MONRACE_IDX r_idx)
        /* Born now */
        else if (summon_specific_who > 0)
        {
-               if (monster_has_hostile_align(&current_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
+               if (monster_has_hostile_align(&p_ptr->current_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
        }
 
        return (*(get_monster_hook()))(r_idx);
@@ -2413,7 +2288,7 @@ static bool monster_hook_chameleon(MONRACE_IDX r_idx)
 void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 {
        int oldmaxhp;
-       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;
        char old_m_name[MAX_NLEN];
        bool old_unique = FALSE;
@@ -2438,10 +2313,10 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 
                if (old_unique)
                        level = r_info[MON_CHAMELEON_K].level;
-               else if (!current_floor_ptr->dun_level)
+               else if (!p_ptr->current_floor_ptr->dun_level)
                        level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
                else
-                       level = current_floor_ptr->dun_level;
+                       level = p_ptr->current_floor_ptr->dun_level;
 
                if (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
 
@@ -2449,14 +2324,12 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
                r_ptr = &r_info[r_idx];
 
                chameleon_change_m_idx = 0;
-
-               /* Paranoia */
                if (!r_idx) return;
        }
 
        m_ptr->r_idx = r_idx;
        m_ptr->ap_r_idx = r_idx;
-       update_monster(m_idx, FALSE);
+       update_monster(p_ptr, m_idx, FALSE);
        lite_spot(m_ptr->fy, m_ptr->fx);
 
        if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
@@ -2481,7 +2354,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
                monster_desc(m_name, m_ptr, 0);
                msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
                if (!(r_ptr->flags7 & RF7_RIDING))
-                       if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
+                       if (rakuba(p_ptr, 0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
        }
 
        /* Extract the monster base speed */
@@ -2518,6 +2391,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
  * @brief たぬきの変身対象となるモンスターかどうか判定する / Hook for Tanuki
  * @param r_idx モンスター種族ID
  * @return 対象にできるならtrueを返す
+ * @todo グローバル変数対策の上 monster_hook.cへ移す。
  */
 static bool monster_hook_tanuki(MONRACE_IDX r_idx)
 {
@@ -2540,15 +2414,16 @@ static bool monster_hook_tanuki(MONRACE_IDX r_idx)
  * @param r_idx モンスター種族ID
  * @return モンスター種族の表層ID
  */
-static IDX initial_r_appearance(MONRACE_IDX r_idx)
+static MONRACE_IDX initial_r_appearance(MONRACE_IDX r_idx, BIT_FLAGS generate_mode)
 {
        int attempts = 1000;
-       IDX ap_r_idx;
-       DEPTH min = MIN(current_floor_ptr->base_level-5, 50);
+       MONRACE_IDX ap_r_idx;
+       DEPTH min = MIN(p_ptr->current_floor_ptr->base_level - 5, 50);
 
-       if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
+       if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN && !(generate_mode & (PM_MULTIPLY | PM_KAGE)))
        {
-               if (current_floor_ptr->base_level == 0 || one_in_(5)) return MON_ALIEN_JURAL;
+               if (p_ptr->current_floor_ptr->base_level == 0 ||
+                       (one_in_(5) && my_strchr("hkoptuyAHOPTUVY", r_info[r_idx].d_char))) return MON_ALIEN_JURAL;
        }
 
        if (!(r_info[r_idx].flags7 & RF7_TANUKI))
@@ -2558,7 +2433,7 @@ static IDX initial_r_appearance(MONRACE_IDX r_idx)
 
        while (--attempts)
        {
-               ap_r_idx = get_mon_num(current_floor_ptr->base_level + 10);
+               ap_r_idx = get_mon_num(p_ptr->current_floor_ptr->base_level + 10);
                if (r_info[ap_r_idx].level >= min) return ap_r_idx;
        }
 
@@ -2571,13 +2446,13 @@ static IDX initial_r_appearance(MONRACE_IDX r_idx)
  * @param r_ptr モンスター種族の参照ポインタ
  * @return 加速値
  */
-byte get_mspeed(monster_race *r_ptr)
+SPEED get_mspeed(monster_race *r_ptr)
 {
        /* Extract the monster base speed */
-       int mspeed = r_ptr->speed;
+       SPEED mspeed = r_ptr->speed;
 
        /* Hack -- small racial variety */
-       if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
+       if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->current_floor_ptr->inside_arena)
        {
                /* Allow some small variation per monster */
                int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
@@ -2586,7 +2461,7 @@ byte get_mspeed(monster_race *r_ptr)
 
        if (mspeed > 199) mspeed = 199;
 
-       return (byte)mspeed;
+       return mspeed;
 }
 
 
@@ -2617,8 +2492,7 @@ byte get_mspeed(monster_race *r_ptr)
  */
 static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
-       /* Access the location */
-       grid_type               *g_ptr = &current_floor_ptr->grid_array[y][x];
+       grid_type               *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
        monster_type    *m_ptr;
        monster_race    *r_ptr = &r_info[r_idx];
        concptr         name = (r_name + r_ptr->name);
@@ -2628,13 +2502,8 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
        /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
        if (p_ptr->wild_mode) return FALSE;
 
-       /* Verify location */
-       if (!in_bounds(y, x)) return (FALSE);
-
-       /* Paranoia */
+       if (!in_bounds(p_ptr->current_floor_ptr, y, x)) return (FALSE);
        if (!r_idx) return (FALSE);
-
-       /* Paranoia */
        if (!r_ptr->name) return (FALSE);
 
        if (!(mode & PM_IGNORE_TERRAIN))
@@ -2646,7 +2515,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
        }
 
-       if (!p_ptr->inside_battle)
+       if (!p_ptr->phase_out)
        {
                /* Hack -- "unique" monsters must be "unique" */
                if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
@@ -2670,7 +2539,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                }
 
                /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
-               if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (current_floor_ptr->dun_level < r_ptr->level) &&
+               if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (p_ptr->current_floor_ptr->dun_level < r_ptr->level) &&
                    (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
                {
                        /* Cannot create */
@@ -2678,9 +2547,9 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                }
        }
 
-       if (quest_number(current_floor_ptr->dun_level))
+       if (quest_number(p_ptr->current_floor_ptr->dun_level))
        {
-               int hoge = quest_number(current_floor_ptr->dun_level);
+               int hoge = quest_number(p_ptr->current_floor_ptr->dun_level);
                if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
                {
                        if(r_idx == quest[hoge].r_idx)
@@ -2689,10 +2558,10 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                                number_mon = 0;
 
                                /* Count all quest monsters */
-                               for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
-                                       for (j2 = 0; j2 < current_floor_ptr->height; j2++)
-                                               if (current_floor_ptr->grid_array[j2][i2].m_idx > 0)
-                                                       if (current_floor_ptr->m_list[current_floor_ptr->grid_array[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
+                               for (i2 = 0; i2 < p_ptr->current_floor_ptr->width; ++i2)
+                                       for (j2 = 0; j2 < p_ptr->current_floor_ptr->height; j2++)
+                                               if (p_ptr->current_floor_ptr->grid_array[j2][i2].m_idx > 0)
+                                                       if (p_ptr->current_floor_ptr->m_list[p_ptr->current_floor_ptr->grid_array[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
                                                                number_mon++;
                                if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
                                        return FALSE;
@@ -2735,28 +2604,28 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
 
 
        /* Get a new monster record */
-       m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
+       m_ptr = &p_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
 
        /* Save the race */
        m_ptr->r_idx = r_idx;
-       m_ptr->ap_r_idx = initial_r_appearance(r_idx);
+       m_ptr->ap_r_idx = initial_r_appearance(r_idx, mode);
 
        /* No flags */
        m_ptr->mflag = 0;
        m_ptr->mflag2 = 0;
 
        /* Hack -- Appearance transfer */
-       if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&current_floor_ptr->m_list[who]))
+       if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&p_ptr->current_floor_ptr->m_list[who]))
        {
-               m_ptr->ap_r_idx = current_floor_ptr->m_list[who].ap_r_idx;
+               m_ptr->ap_r_idx = p_ptr->current_floor_ptr->m_list[who].ap_r_idx;
 
                /* Hack -- Shadower spawns Shadower */
-               if (current_floor_ptr->m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
+               if (p_ptr->current_floor_ptr->m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
        }
 
        /* Sub-alignment of a monster */
        if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
-               m_ptr->sub_align = current_floor_ptr->m_list[who].sub_align;
+               m_ptr->sub_align = p_ptr->current_floor_ptr->m_list[who].sub_align;
        else
        {
                m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
@@ -2767,6 +2636,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
        /* Place the monster at the location */
        m_ptr->fy = y;
        m_ptr->fx = x;
+       m_ptr->current_floor_ptr = p_ptr->current_floor_ptr;
 
 
        /* No "timed status" yet */
@@ -2783,7 +2653,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
 
 
        /* Your pet summons its pet. */
-       if (who > 0 && is_pet(&current_floor_ptr->m_list[who]))
+       if (who > 0 && is_pet(&p_ptr->current_floor_ptr->m_list[who]))
        {
                mode |= PM_FORCE_PET;
                m_ptr->parent_m_idx = who;
@@ -2904,7 +2774,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                p_ptr->update |= (PU_MON_LITE);
        else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
                p_ptr->update |= (PU_MON_LITE);
-       update_monster(g_ptr->m_idx, TRUE);
+       update_monster(p_ptr, g_ptr->m_idx, TRUE);
 
 
        /* Count the monsters on the level */
@@ -2914,21 +2784,14 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
         * Memorize location of the unique monster in saved floors.
         * A unique monster move from old saved floor.
         */
-       if (character_dungeon &&
+       if (current_world_ptr->character_dungeon &&
            ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
                real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
 
        /* Hack -- Count the number of "reproducers" */
-       if (r_ptr->flags2 & RF2_MULTIPLY) current_floor_ptr->num_repro++;
-
-       /* Hack -- Notice new multi-hued monsters */
-       {
-               monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
-               if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
-                       shimmer_monsters = TRUE;
-       }
+       if (r_ptr->flags2 & RF2_MULTIPLY) p_ptr->current_floor_ptr->num_repro++;
 
-       if (p_ptr->warning && character_dungeon)
+       if (p_ptr->warning && current_world_ptr->character_dungeon)
        {
                if (r_ptr->flags1 & RF1_UNIQUE)
                {
@@ -2971,7 +2834,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                        if (g_ptr->info & CAVE_MARK)
                        {
                                msg_print(_("ルーンが爆発した!", "The rune explodes!"));
-                               project(0, 2, y, x, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
+                               project(p_ptr, 0, 2, y, x, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
                        }
                }
                else
@@ -3028,10 +2891,10 @@ static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION
                for (ny = y - max_dist; ny <= y + max_dist; ny++)
                {
                        /* Ignore annoying locations */
-                       if (!in_bounds(ny, nx)) continue;
+                       if (!in_bounds(p_ptr->current_floor_ptr, ny, nx)) continue;
 
                        /* Require "line of projection" */
-                       if (!projectable(y, x, ny, nx)) continue;
+                       if (!projectable(p_ptr->current_floor_ptr, y, x, ny, nx)) continue;
 
                        if (r_idx > 0)
                        {
@@ -3044,7 +2907,7 @@ static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION
                        else
                        {
                                /* Walls and Monsters block flow */
-                               if (!cave_empty_bold2(ny, nx)) continue;
+                               if (!cave_empty_bold2(p_ptr->current_floor_ptr, ny, nx)) continue;
 
                                /* ... nor on the Pattern */
                                if (pattern_tile(ny, nx)) continue;
@@ -3104,16 +2967,16 @@ static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE
        total = randint1(10);
 
        /* Hard monsters, small groups */
-       if (r_ptr->level > current_floor_ptr->dun_level)
+       if (r_ptr->level > p_ptr->current_floor_ptr->dun_level)
        {
-               extra = r_ptr->level - current_floor_ptr->dun_level;
+               extra = r_ptr->level - p_ptr->current_floor_ptr->dun_level;
                extra = 0 - randint1(extra);
        }
 
        /* Easy monsters, large groups */
-       else if (r_ptr->level < current_floor_ptr->dun_level)
+       else if (r_ptr->level < p_ptr->current_floor_ptr->dun_level)
        {
-               extra = current_floor_ptr->dun_level - r_ptr->level;
+               extra = p_ptr->current_floor_ptr->dun_level - r_ptr->level;
                extra = randint1(extra);
        }
 
@@ -3147,10 +3010,10 @@ static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE
                {
                        POSITION mx, my;
 
-                       scatter(&my, &mx, hy, hx, 4, 0);
+                       scatter(p_ptr->current_floor_ptr, &my, &mx, hy, hx, 4, 0);
 
                        /* Walls and Monsters block flow */
-                       if (!cave_empty_bold2(my, mx)) continue;
+                       if (!cave_empty_bold2(p_ptr->current_floor_ptr, my, mx)) continue;
 
                        /* Attempt to place another monster */
                        if (place_monster_one(who, my, mx, r_idx, mode))
@@ -3190,7 +3053,7 @@ static MONSTER_IDX place_monster_m_idx = 0;
 static bool place_monster_can_escort(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[place_monster_idx];
-       monster_type *m_ptr = &current_floor_ptr->m_list[place_monster_m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[place_monster_m_idx];
 
        monster_race *z_ptr = &r_info[r_idx];
 
@@ -3272,7 +3135,7 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
                for(j = 0; j < n; j++)
                {
                        POSITION nx, ny, d = 7;
-                       scatter(&ny, &nx, y, x, d, 0);
+                       scatter(p_ptr->current_floor_ptr, &ny, &nx, y, x, d, 0);
                        (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
                }
        }
@@ -3297,10 +3160,10 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
                        MONRACE_IDX z; 
 
                        /* Pick a location */
-                       scatter(&ny, &nx, y, x, d, 0);
+                       scatter(p_ptr->current_floor_ptr, &ny, &nx, y, x, d, 0);
 
                        /* Require empty grids */
-                       if (!cave_empty_bold2(ny, nx)) continue;
+                       if (!cave_empty_bold2(p_ptr->current_floor_ptr, ny, nx)) continue;
                        get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
 
                        /* Pick a random race */
@@ -3339,7 +3202,7 @@ bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
        get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
 
        /* Pick a monster */
-       r_idx = get_mon_num(current_floor_ptr->monster_level);
+       r_idx = get_mon_num(p_ptr->current_floor_ptr->monster_level);
 
        /* Handle failure */
        if (!r_idx) return (FALSE);
@@ -3369,7 +3232,7 @@ bool alloc_horde(POSITION y, POSITION x)
        while (--attempts)
        {
                /* Pick a monster */
-               r_idx = get_mon_num(current_floor_ptr->monster_level);
+               r_idx = get_mon_num(p_ptr->current_floor_ptr->monster_level);
 
                /* Handle failure */
                if (!r_idx) return (FALSE);
@@ -3393,15 +3256,15 @@ bool alloc_horde(POSITION y, POSITION x)
 
        if (attempts < 1) return FALSE;
 
-       m_idx = current_floor_ptr->grid_array[y][x].m_idx;
+       m_idx = p_ptr->current_floor_ptr->grid_array[y][x].m_idx;
 
-       if (current_floor_ptr->m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[current_floor_ptr->m_list[m_idx].r_idx];
+       if (p_ptr->current_floor_ptr->m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[p_ptr->current_floor_ptr->m_list[m_idx].r_idx];
 
        for (attempts = randint1(10) + 5; attempts; attempts--)
        {
-               scatter(&cy, &cx, y, x, 5, 0);
+               scatter(p_ptr->current_floor_ptr, &cy, &cx, y, x, 5, 0);
 
-               (void)summon_specific(m_idx, cy, cx, current_floor_ptr->dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
+               (void)summon_specific(m_idx, cy, cx, p_ptr->current_floor_ptr->dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
 
                y = cy;
                x = cx;
@@ -3420,7 +3283,7 @@ bool alloc_guardian(bool def_val)
 {
        MONRACE_IDX guardian = d_info[p_ptr->dungeon_idx].final_guardian;
 
-       if (guardian && (d_info[p_ptr->dungeon_idx].maxdepth == current_floor_ptr->dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
+       if (guardian && (d_info[p_ptr->dungeon_idx].maxdepth == p_ptr->current_floor_ptr->dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
        {
                POSITION oy;
                POSITION ox;
@@ -3430,11 +3293,11 @@ bool alloc_guardian(bool def_val)
                while (try_count)
                {
                        /* Get a random spot */
-                       oy = randint1(current_floor_ptr->height - 4) + 2;
-                       ox = randint1(current_floor_ptr->width - 4) + 2;
+                       oy = randint1(p_ptr->current_floor_ptr->height - 4) + 2;
+                       ox = randint1(p_ptr->current_floor_ptr->width - 4) + 2;
 
                        /* Is it a good spot ? */
-                       if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(current_floor_ptr->grid_array[oy][ox].feat, &r_info[guardian], 0))
+                       if (cave_empty_bold2(p_ptr->current_floor_ptr, oy, ox) && monster_can_cross_terrain(p_ptr->current_floor_ptr->grid_array[oy][ox].feat, &r_info[guardian], 0))
                        {
                                /* Place the guardian */
                                if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
@@ -3459,7 +3322,7 @@ bool alloc_guardian(bool def_val)
  * @details
  * Place the monster at least "dis" distance from the player.
  * Use "slp" to choose the initial "sleep" status
- * Use "current_floor_ptr->monster_level" for the monster level
+ * Use "p_ptr->current_floor_ptr->monster_level" for the monster level
  */
 bool alloc_monster(POSITION dis, BIT_FLAGS mode)
 {
@@ -3473,17 +3336,17 @@ bool alloc_monster(POSITION dis, BIT_FLAGS mode)
        while (attempts_left--)
        {
                /* Pick a location */
-               y = randint0(current_floor_ptr->height);
-               x = randint0(current_floor_ptr->width);
+               y = randint0(p_ptr->current_floor_ptr->height);
+               x = randint0(p_ptr->current_floor_ptr->width);
 
                /* Require empty floor grid (was "naked") */
-               if (current_floor_ptr->dun_level)
+               if (p_ptr->current_floor_ptr->dun_level)
                {
-                       if (!cave_empty_bold2(y, x)) continue;
+                       if (!cave_empty_bold2(p_ptr->current_floor_ptr, y, x)) continue;
                }
                else
                {
-                       if (!cave_empty_bold(y, x)) continue;
+                       if (!cave_empty_bold(p_ptr->current_floor_ptr, y, x)) continue;
                }
 
                /* Accept far away grids */
@@ -3501,7 +3364,7 @@ bool alloc_monster(POSITION dis, BIT_FLAGS mode)
        }
 
 
-       if (randint1(5000) <= current_floor_ptr->dun_level)
+       if (randint1(5000) <= p_ptr->current_floor_ptr->dun_level)
        {
                if (alloc_horde(y, x))
                {
@@ -3526,6 +3389,7 @@ bool alloc_monster(POSITION dis, BIT_FLAGS mode)
 static bool summon_specific_okay(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[summon_specific_who];
 
        /* Hack - Only summon dungeon monsters */
        if (!mon_hook_dungeon(r_idx)) return (FALSE);
@@ -3533,7 +3397,6 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
        /* Hack -- identify the summoning monster */
        if (summon_specific_who > 0)
        {
-               monster_type *m_ptr = &current_floor_ptr->m_list[summon_specific_who];
 
                /* Do not summon enemies */
 
@@ -3562,7 +3425,7 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
 
        if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON)) return TRUE;
 
-       return (summon_specific_aux(r_idx));
+       return (summon_specific_aux(m_ptr->r_idx, r_idx));
 }
 
 
@@ -3597,12 +3460,12 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
  *
  * Note that this function may not succeed, though this is very rare.
  */
-bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol)
+bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode)
 {
        POSITION x, y;
        MONRACE_IDX r_idx;
 
-       if (p_ptr->inside_arena) return (FALSE);
+       if (p_ptr->current_floor_ptr->inside_arena) return (FALSE);
 
        if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
 
@@ -3612,13 +3475,11 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
        /* Save the "summon" type */
        summon_specific_type = type;
 
-       summon_kin_type = symbol;
-
        summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
        get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
 
        /* Pick a monster, using the level calculation */
-       r_idx = get_mon_num((current_floor_ptr->dun_level + lev) / 2 + 5);
+       r_idx = get_mon_num((p_ptr->current_floor_ptr->dun_level + lev) / 2 + 5);
 
        /* Handle failure */
        if (!r_idx)
@@ -3655,14 +3516,12 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
 bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
        POSITION x, y;
-
-       /* Paranoia */
        /* if (!r_idx) return; */
 
        /* Prevent illegal monsters */
        if (r_idx >= max_r_idx) return FALSE;
 
-       if (p_ptr->inside_arena) return FALSE;
+       if (p_ptr->current_floor_ptr->inside_arena) return FALSE;
 
        if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
 
@@ -3682,7 +3541,7 @@ bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_ID
  */
 bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
 {
-       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 y, x;
 
        if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
@@ -3697,8 +3556,8 @@ bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
        /* Hack -- Transfer "clone" flag */
        if (clone || (m_ptr->smart & SM_CLONED))
        {
-               current_floor_ptr->m_list[hack_m_idx_ii].smart |= SM_CLONED;
-               current_floor_ptr->m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
+               p_ptr->current_floor_ptr->m_list[hack_m_idx_ii].smart |= SM_CLONED;
+               p_ptr->current_floor_ptr->m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
        }
 
        return TRUE;
@@ -3720,7 +3579,7 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
        HIT_POINT tmp;
        PERCENTAGE percentage;
 
-       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];
 
        GAME_TEXT m_name[MAX_NLEN];
@@ -4044,7 +3903,7 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
  */
 void update_smart_learn(MONSTER_IDX m_idx, int what)
 {
-       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];
 
        /* Not allowed to learn */
@@ -4164,11 +4023,10 @@ void monster_drop_carried_objects(monster_type *m_ptr)
        /* Drop objects being carried */
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
-               o_ptr = &current_floor_ptr->o_list[this_o_idx];
+               o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
                next_o_idx = o_ptr->next_o_idx;
                q_ptr = &forge;
 
-               /* Copy the object */
                object_copy(q_ptr, o_ptr);
 
                /* Forget monster */
@@ -4183,3 +4041,31 @@ void monster_drop_carried_objects(monster_type *m_ptr)
        /* Forget objects */
        m_ptr->hold_o_idx = 0;
 }
+
+/*!
+ * @brief 指定したモンスターに隣接しているモンスターの数を返す。
+ * / Count number of adjacent monsters
+ * @param m_idx 隣接数を調べたいモンスターのID
+ * @return 隣接しているモンスターの数
+ */
+int get_monster_crowd_number(MONSTER_IDX m_idx)
+{
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
+       POSITION my = m_ptr->fy;
+       POSITION mx = m_ptr->fx;
+       int i;
+       int count = 0;
+
+       for (i = 0; i < 7; i++)
+       {
+               int ay = my + ddy_ddd[i];
+               int ax = mx + ddx_ddd[i];
+
+               if (!in_bounds(p_ptr->current_floor_ptr, ay, ax)) continue;
+
+               /* Count number of monsters */
+               if (p_ptr->current_floor_ptr->grid_array[ay][ax].m_idx > 0) count++;
+       }
+
+       return count;
+}