OSDN Git Service

#37287 #37353 (2.2.0.89) MULTIPLY 型を定義し、型の置換を継続中。 / Define MULTIPLY, ongoing type...
[hengband/hengband.git] / src / monster2.c
index 822213b..484b994 100644 (file)
@@ -219,7 +219,7 @@ monster_race *real_r_ptr(monster_type *m_ptr)
  * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 /
  * When a monster is deleted, all of its objects are deleted.
  */
-void delete_monster_idx(int i)
+void delete_monster_idx(MONSTER_IDX i)
 {
        int x, y;
 
@@ -309,7 +309,7 @@ void delete_monster_idx(int i)
  * @param y 削除位置y座標
  * @return なし
  */
-void delete_monster(int y, int x)
+void delete_monster(POSITION y, POSITION x)
 {
        cave_type *c_ptr;
 
@@ -330,7 +330,7 @@ void delete_monster(int y, int x)
  * @param i2 配列移動先添字
  * @return なし
  */
-static void compact_monsters_aux(int i1, int i2)
+static void compact_monsters_aux(IDX i1, IDX i2)
 {
        int y, x, i;
 
@@ -428,8 +428,9 @@ static void compact_monsters_aux(int i1, int i2)
  */
 void compact_monsters(int size)
 {
-       int             i, num, cnt;
-       int             cur_lev, cur_dis, chance;
+       MONSTER_IDX i;
+       int num, cnt;
+       int cur_lev, cur_dis, chance;
 
        /* Message (only if compacting) */
        if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
@@ -592,9 +593,9 @@ void wipe_m_list(void)
  * @details
  * This routine should almost never fail, but it *can* happen.
  */
-s16b m_pop(void)
+MONSTER_IDX m_pop(void)
 {
-       int i;
+       MONSTER_IDX i;
 
 
        /* Normal allocation */
@@ -670,7 +671,7 @@ static bool summon_unique_okay = FALSE;
  * @return 召喚条件が一致するならtrue
  * @details
  */
-static bool summon_specific_aux(int r_idx)
+static bool summon_specific_aux(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
        int okay = FALSE;
@@ -834,7 +835,7 @@ static bool summon_specific_aux(int r_idx)
                               !(r_ptr->flags3 & (RF3_UNDEAD)) &&
                               !(r_ptr->flags3 & (RF3_DEMON)) &&
                               !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
-                              !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
+                              !(r_ptr->flags4 || r_ptr->a_ability_flags1 || r_ptr->a_ability_flags2));
                        break;
                }
 
@@ -979,7 +980,7 @@ 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(int r_idx)
+static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
 {
        dungeon_info_type *d_ptr = &d_info[dungeon_type];
        monster_race *r_ptr = &r_info[r_idx];
@@ -994,16 +995,16 @@ static bool restrict_monster_to_dungeon(int r_idx)
                if (r_idx != MON_CHAMELEON &&
                    r_ptr->freq_spell && 
                    !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
-                   !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
-                   !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
+                   !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK) &&
+                   !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK))
                        return FALSE;
        }
        if (d_ptr->flags1 & DF1_NO_MELEE)
        {
                if (r_idx == MON_CHAMELEON) return TRUE;
                if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
-                   !(r_ptr->flags5 & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | RF5_MIND_BLAST | RF5_BRAIN_SMASH)) &&
-                   !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
+                   !(r_ptr->a_ability_flags1 & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | RF5_MIND_BLAST | RF5_BRAIN_SMASH)) &&
+                   !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
                        return FALSE;
        }
        if (d_ptr->flags1 & DF1_BEGINNER)
@@ -1038,14 +1039,14 @@ static bool restrict_monster_to_dungeon(int r_idx)
                        if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
                                return FALSE;
                }
-               if (d_ptr->mflags5)
+               if (d_ptr->m_a_ability_flags1)
                {
-                       if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
+                       if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
                                return FALSE;
                }
-               if (d_ptr->mflags6)
+               if (d_ptr->m_a_ability_flags2)
                {
-                       if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
+                       if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
                                return FALSE;
                }
                if (d_ptr->mflags7)
@@ -1094,14 +1095,14 @@ static bool restrict_monster_to_dungeon(int r_idx)
                        if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
                                return TRUE;
                }
-               if (d_ptr->mflags5)
+               if (d_ptr->m_a_ability_flags1)
                {
-                       if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
+                       if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
                                return TRUE;
                }
-               if (d_ptr->mflags6)
+               if (d_ptr->m_a_ability_flags2)
                {
-                       if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
+                       if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
                                return TRUE;
                }
                if (d_ptr->mflags7)
@@ -1134,8 +1135,8 @@ static bool restrict_monster_to_dungeon(int r_idx)
                if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
                if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
                if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
-               if (r_ptr->flags5 & d_ptr->mflags5) return TRUE;
-               if (r_ptr->flags6 & d_ptr->mflags6) return TRUE;
+               if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return TRUE;
+               if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return TRUE;
                if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
                if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
                if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
@@ -1150,8 +1151,8 @@ static bool restrict_monster_to_dungeon(int r_idx)
                if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
                if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
                if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
-               if (r_ptr->flags5 & d_ptr->mflags5) return FALSE;
-               if (r_ptr->flags6 & d_ptr->mflags6) return FALSE;
+               if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return FALSE;
+               if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return FALSE;
                if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
                if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
                if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
@@ -1297,7 +1298,7 @@ static int mysqrt(int n)
  * Note that if no monsters are "appropriate", then this function will
  * fail, and return zero, but this should *almost* never happen.
  */
-s16b get_mon_num(int level)
+MONRACE_IDX get_mon_num(DEPTH level)
 {
        int                     i, j, p;
        int                     r_idx;
@@ -1306,12 +1307,12 @@ s16b get_mon_num(int level)
        alloc_entry             *table = alloc_race_table;
 
        int pls_kakuritu, pls_level;
-       int hoge = mysqrt(level*10000L);
+       int delay = mysqrt(level * 10000L) + 400L;
 
        if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
 
-       pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 2500L) - hoge / 10)));
-       pls_level    = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 20000L) - hoge / 40 + MIN(5, level / 10)) ;
+       pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
+       pls_level    = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
 
        if (d_info[dungeon_type].flags1 & DF1_MAZE)
        {
@@ -1805,7 +1806,7 @@ void monster_desc(char *desc, monster_type *m_ptr, int mode)
  * @details
  * Return the number of new flags learnt.  -Mogami-
  */
-int lore_do_probe(int r_idx)
+int lore_do_probe(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
        int i, n = 0;
@@ -1865,9 +1866,9 @@ int lore_do_probe(int r_idx)
                if (!(r_ptr->r_flags4 & (1L << i)) &&
                    (r_ptr->flags4 & (1L << i))) n++;
                if (!(r_ptr->r_flags5 & (1L << i)) &&
-                   (r_ptr->flags5 & (1L << i))) n++;
+                   (r_ptr->a_ability_flags1 & (1L << i))) n++;
                if (!(r_ptr->r_flags6 & (1L << i)) &&
-                   (r_ptr->flags6 & (1L << i))) n++;
+                   (r_ptr->a_ability_flags2 & (1L << i))) n++;
                if (!(r_ptr->r_flagsr & (1L << i)) &&
                    (r_ptr->flagsr & (1L << i))) n++;
 
@@ -1883,8 +1884,8 @@ int lore_do_probe(int r_idx)
        r_ptr->r_flags2 = r_ptr->flags2;
        r_ptr->r_flags3 = r_ptr->flags3;
        r_ptr->r_flags4 = r_ptr->flags4;
-       r_ptr->r_flags5 = r_ptr->flags5;
-       r_ptr->r_flags6 = r_ptr->flags6;
+       r_ptr->r_flags5 = r_ptr->a_ability_flags1;
+       r_ptr->r_flags6 = r_ptr->a_ability_flags2;
        r_ptr->r_flagsr = r_ptr->flagsr;
 
        /* r_flags7 is actually unused */
@@ -1923,7 +1924,7 @@ int lore_do_probe(int r_idx)
  * gold and items are dropped, and remembers that information to be
  * described later by the monster recall code.
  */
-void lore_treasure(int m_idx, int num_item, int num_gold)
+void lore_treasure(MONSTER_IDX m_idx, int num_item, int num_gold)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -1964,8 +1965,8 @@ void sanity_blast(monster_type *m_ptr, bool necro)
 
        if (!necro && m_ptr)
        {
-               char            m_name[80];
-               monster_race    *r_ptr = &r_info[m_ptr->ap_r_idx];
+               char m_name[80];
+               monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
 
                power = r_ptr->level / 2;
 
@@ -1987,8 +1988,6 @@ void sanity_blast(monster_type *m_ptr, bool necro)
                if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
                        return; /* oops */
 
-
-
                if (is_pet(m_ptr))
                        return; /* Pet eldritch horrors are safe most of the time */
 
@@ -2010,7 +2009,6 @@ void sanity_blast(monster_type *m_ptr, bool necro)
                                funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
 #endif
 
-
                        if (one_in_(3))
                        {
                                msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
@@ -2045,9 +2043,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
        }
        else if(!necro)
        {
-               bool happened = FALSE;
                monster_race *r_ptr;
-               int power;
                char m_name[80];
                cptr desc;
 
@@ -2347,7 +2343,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
  * "disturb_near" (monster which is "easily" viewable moves in some
  * way).  Note that "moves" includes "appears" and "disappears".
  */
-void update_mon(int m_idx, bool full)
+void update_mon(MONSTER_IDX m_idx, bool full)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -2383,8 +2379,8 @@ void update_mon(int m_idx, bool full)
        if (full)
        {
                /* Distance components */
-               int dy = (py > fy) ? (py - fy) : (fy - py);
-               int dx = (px > fx) ? (px - fx) : (fx - px);
+               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);
 
                /* Approximate distance */
                d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
@@ -2663,7 +2659,7 @@ void update_mon(int m_idx, bool full)
                        }
 
                        /* Disturb on appearance */
-                       if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
+                       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_pets || is_hostile(m_ptr))
                                        disturb(1, 1);
@@ -2742,7 +2738,7 @@ void update_mon(int m_idx, bool full)
  */
 void update_monsters(bool full)
 {
-       int i;
+       IDX i;
 
        /* Update each (live) monster */
        for (i = 1; i < m_max; i++)
@@ -2763,7 +2759,7 @@ void update_monsters(bool full)
  * @param r_idx モンスター種族ID
  * @return 対象にできるならtrueを返す
  */
-static bool monster_hook_chameleon_lord(int r_idx)
+static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
        monster_type *m_ptr = &m_list[chameleon_change_m_idx];
@@ -2799,7 +2795,7 @@ static bool monster_hook_chameleon_lord(int r_idx)
  * @param r_idx モンスター種族ID
  * @return 対象にできるならtrueを返す
  */
-static bool monster_hook_chameleon(int r_idx)
+static bool monster_hook_chameleon(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
        monster_type *m_ptr = &m_list[chameleon_change_m_idx];
@@ -2838,7 +2834,7 @@ static bool monster_hook_chameleon(int r_idx)
  * @param r_idx 旧モンスター種族のID
  * @return なし
  */
-void choose_new_monster(int m_idx, bool born, int r_idx)
+void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 {
        int oldmaxhp;
        monster_type *m_ptr = &m_list[m_idx];
@@ -2934,7 +2930,7 @@ void choose_new_monster(int m_idx, bool born, int r_idx)
        if (ironman_nightmare)
        {
                u32b hp = m_ptr->max_maxhp * 2L;
-               m_ptr->max_maxhp = (s16b)MIN(30000, hp);
+               m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
        }
 
        m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
@@ -2951,7 +2947,7 @@ void choose_new_monster(int m_idx, bool born, int r_idx)
  * @param r_idx モンスター種族ID
  * @return 対象にできるならtrueを返す
  */
-static bool monster_hook_tanuki(int r_idx)
+static bool monster_hook_tanuki(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -2972,12 +2968,12 @@ static bool monster_hook_tanuki(int r_idx)
  * @param r_idx モンスター種族ID
  * @return モンスター種族の表層ID
  */
-static int initial_r_appearance(int r_idx)
+static IDX initial_r_appearance(MONRACE_IDX r_idx)
 {
        int attempts = 1000;
 
-       int ap_r_idx;
-       int min = MIN(base_level-5, 50);
+       IDX ap_r_idx;
+       DEPTH min = MIN(base_level-5, 50);
 
        if (!(r_info[r_idx].flags7 & RF7_TANUKI))
                return r_idx;
@@ -3043,15 +3039,12 @@ byte get_mspeed(monster_race *r_ptr)
  * This is the only function which may place a monster in the dungeon,
  * except for the savefile loading code.
  */
-static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
+static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
        /* Access the location */
        cave_type               *c_ptr = &cave[y][x];
-
        monster_type    *m_ptr;
-
        monster_race    *r_ptr = &r_info[r_idx];
-
        cptr            name = (r_name + r_ptr->name);
 
        int cmi;
@@ -3154,30 +3147,7 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
                else return FALSE;
        }
 
-       /* Powerful monster */
-       if (r_ptr->level > dun_level)
-       {
-               /* Unique monsters */
-               if (r_ptr->flags1 & (RF1_UNIQUE))
-               {
-                       /* Message for cheaters */
-                       if (cheat_hear) msg_format(_("深層のユニーク・モンスター (%s)。", "Deep Unique (%s)."), name);
-               }
-
-               /* Normal monsters */
-               else
-               {
-                       /* Message for cheaters */
-                       if (cheat_hear) msg_format(_("深層のモンスター (%s)。", "Deep Monster (%s)."), name);
-               }
-       }
-
-       /* Note the monster */
-       else if (r_ptr->flags1 & (RF1_UNIQUE))
-       {
-               /* Unique monsters induce message */
-               if (cheat_hear) msg_format(_("ユニーク・モンスター (%s)。", "Unique (%s)."), name);
-       }
+       msg_format_wizard(CHEAT_MONSTER, _("%s(Lv%d)を生成しました。", "%s(Lv%d) was generated."), name, r_ptr->level);
 
        if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
 
@@ -3306,7 +3276,7 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
        {
                u32b hp = m_ptr->max_maxhp * 2L;
 
-               m_ptr->max_maxhp = (s16b)MIN(30000, hp);
+               m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
        }
 
        m_ptr->maxhp = m_ptr->max_maxhp;
@@ -3466,7 +3436,7 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
  * @return 成功したらtrue
  *  
  */
-static bool mon_scatter(int r_idx, int *yp, int *xp, int y, int x, int max_dist)
+static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist)
 {
        int place_x[MON_SCAT_MAXD];
        int place_y[MON_SCAT_MAXD];
@@ -3546,7 +3516,7 @@ static bool mon_scatter(int r_idx, int *yp, int *xp, int y, int x, int max_dist)
  * @param mode 生成オプション
  * @return 成功したらtrue
  */
-static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
+static bool place_monster_group(IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, u32b mode)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -3555,8 +3525,8 @@ static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
 
        int hack_n = 0;
 
-       byte hack_y[GROUP_MAX];
-       byte hack_x[GROUP_MAX];
+       POSITION hack_y[GROUP_MAX];
+       POSITION hack_x[GROUP_MAX];
 
 
        /* Pick a group size */
@@ -3598,13 +3568,13 @@ static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
        for (n = 0; (n < hack_n) && (hack_n < total); n++)
        {
                /* Grab the location */
-               int hx = hack_x[n];
-               int hy = hack_y[n];
+               POSITION hx = hack_x[n];
+               POSITION hy = hack_y[n];
 
                /* Check each direction, up to total */
                for (i = 0; (i < 8) && (hack_n < total); i++)
                {
-                       int mx, my;
+                       POSITION mx, my;
 
                        scatter(&my, &mx, hy, hx, 4, 0);
 
@@ -3632,21 +3602,21 @@ static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
  * @brief 護衛対象となるモンスター種族IDを渡すグローバル変数 / Hack -- help pick an escort type
  * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_idxを除去し、関数引数化する
  */
-static int place_monster_idx = 0;
+static IDX place_monster_idx = 0;
 
 /*!
  * @var place_monster_m_idx
  * @brief 護衛対象となるモンスターIDを渡すグローバル変数 / Hack -- help pick an escort type
  * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_m_idxを除去し、関数引数化する
  */
-static int place_monster_m_idx = 0;
+static IDX place_monster_m_idx = 0;
 
 /*!
  * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type
  * @param r_idx チェックするモンスター種族のID
  * @return 護衛にできるならばtrue
  */
-static bool place_monster_okay(int r_idx)
+static bool place_monster_can_escort(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[place_monster_idx];
        monster_type *m_ptr = &m_list[place_monster_m_idx];
@@ -3708,7 +3678,7 @@ static bool place_monster_okay(int r_idx)
  * Note the use of the new "monster allocation table" code to restrict
  * the "get_mon_num()" function to "legal" escort types.
  */
-bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
+bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
        int             i, j, n;
        monster_race    *r_ptr = &r_info[r_idx];
@@ -3731,7 +3701,7 @@ bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
                n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
                for(j = 0; j < n; j++)
                {
-                       int nx, ny, d = 7;
+                       POSITION nx, ny, d = 7;
                        scatter(&ny, &nx, y, x, d, 0);
                        (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
                }
@@ -3753,7 +3723,8 @@ bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
                /* Try to place several "escorts" */
                for (i = 0; i < 32; i++)
                {
-                       int nx, ny, z, d = 3;
+                       POSITION nx, ny, d = 3;
+                       MONRACE_IDX z; 
 
                        /* Pick a location */
                        scatter(&ny, &nx, y, x, d, 0);
@@ -3762,7 +3733,7 @@ bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
                        if (!cave_empty_bold2(ny, nx)) continue;
 
                        /* Prepare allocation table */
-                       get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
+                       get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
 
                        /* Pick a random race */
                        z = get_mon_num(r_ptr->level);
@@ -3794,9 +3765,9 @@ bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
  * @param mode 生成オプション
  * @return 生成に成功したらtrue
  */
-bool place_monster(int y, int x, u32b mode)
+bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
 {
-       int r_idx;
+       MONRACE_IDX r_idx;
 
        /* Prepare allocation table */
        get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
@@ -3823,14 +3794,14 @@ bool place_monster(int y, int x, u32b mode)
  * @param x 生成地点x座標
  * @return 生成に成功したらtrue
  */
-bool alloc_horde(int y, int x)
+bool alloc_horde(POSITION y, POSITION x)
 {
        monster_race *r_ptr = NULL;
-       int r_idx = 0;
-       int m_idx;
+       MONRACE_IDX r_idx = 0;
+       MONSTER_IDX m_idx;
        int attempts = 1000;
-       int cy = y;
-       int cx = x;
+       POSITION cy = y;
+       POSITION cx = x;
 
        /* Prepare allocation table */
        get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
@@ -3890,7 +3861,7 @@ bool alloc_horde(int y, int x)
  */
 bool alloc_guardian(bool def_val)
 {
-       int guardian = d_info[dungeon_type].final_guardian;
+       MONRACE_IDX guardian = d_info[dungeon_type].final_guardian;
 
        if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
        {
@@ -3959,7 +3930,7 @@ bool alloc_monster(int dis, u32b mode)
                }
 
                /* Accept far away grids */
-               if (distance(y, x, py, px) > dis) break;
+               if (distance(y, x, p_ptr->y, p_ptr->x) > dis) break;
        }
 
        if (!attempts_left)
@@ -4003,7 +3974,7 @@ bool alloc_monster(int dis, u32b mode)
  * @param r_idx チェックするモンスター種族ID
  * @return 召喚対象にできるならばTRUE
  */
-static bool summon_specific_okay(int r_idx)
+static bool summon_specific_okay(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -4077,9 +4048,10 @@ static bool summon_specific_okay(int r_idx)
  *
  * Note that this function may not succeed, though this is very rare.
  */
-bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
+bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode)
 {
-       int x, y, r_idx;
+       POSITION x, y;
+       MONRACE_IDX r_idx;
 
        if (p_ptr->inside_arena) return (FALSE);
 
@@ -4130,9 +4102,9 @@ bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
  * @param mode 生成オプション 
  * @return 召喚できたらtrueを返す
  */
-bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
+bool summon_named_creature (MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
-       int x, y;
+       POSITION x, y;
 
        /* Paranoia */
        /* if (!r_idx) return; */
@@ -4158,11 +4130,11 @@ bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
  * @details
  * Note that "reproduction" REQUIRES empty space.
  */
-bool multiply_monster(int m_idx, bool clone, u32b mode)
+bool multiply_monster(MONSTER_IDX m_idx, bool clone, u32b mode)
 {
        monster_type    *m_ptr = &m_list[m_idx];
 
-       int y, x;
+       POSITION y, x;
 
        if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
                return FALSE;
@@ -4193,7 +4165,7 @@ bool multiply_monster(int m_idx, bool clone, u32b mode)
  * @details
  * Technically should attempt to treat "Beholder"'s as jelly's
  */
-void message_pain(int m_idx, int dam)
+void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
 {
        long oldhp, newhp, tmp;
        int percentage;
@@ -4521,7 +4493,7 @@ void message_pain(int m_idx, int dam)
  * @param what 学習対象ID
  * @return なし
  */
-void update_smart_learn(int m_idx, int what)
+void update_smart_learn(MONSTER_IDX m_idx, int what)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -4638,14 +4610,14 @@ void update_smart_learn(int m_idx, int what)
  * @param y 配置先Y座標
  * @return 配置に成功したらTRUE
  */
-bool player_place(int y, int x)
+bool player_place(POSITION y, POSITION x)
 {
        /* Paranoia XXX XXX */
        if (cave[y][x].m_idx != 0) return FALSE;
 
        /* Save player location */
-       py = y;
-       px = x;
+       p_ptr->y = y;
+       p_ptr->x = x;
 
        /* Success */
        return TRUE;