OSDN Git Service

[Refactor] #37353 ペット処理を cmd4.c から cmd-pet.c/h へ分離。
[hengband/hengband.git] / src / melee2.c
index e0c6149..e48c48a 100644 (file)
  */
 
 #include "angband.h"
+#include "cmd-pet.h"
 
-#define SPEAK_CHANCE 8
-#define GRINDNOISE 20
-#define CYBERNOISE 20
 
 /*!
  * @brief モンスターが敵に接近するための方向を決める /
  * @param mm 移動するべき方角IDを返す参照ポインタ
  * @return 方向が確定した場合TRUE、接近する敵がそもそもいない場合FALSEを返す
  */
-static bool get_enemy_dir(int m_idx, int *mm)
+static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
 {
        int i;
        int x = 0, y = 0;
-       int t_idx;
+       IDX t_idx;
        int start;
        int plus = 1;
 
@@ -61,7 +59,7 @@ static bool get_enemy_dir(int m_idx, int *mm)
                /* Scan thru all monsters */
                for (i = start; ((i < start + m_max) && (i > start - m_max)); i+=plus)
                {
-                       int dummy = (i % m_max);
+                       IDX dummy = (i % m_max);
 
                        if (!dummy) continue;
 
@@ -194,7 +192,7 @@ static bool get_enemy_dir(int m_idx, int *mm)
  * @param who 打撃を行ったモンスターの参照ID
  * @return なし
  */
-void mon_take_hit_mon(int m_idx, int dam, bool *fear, cptr note, int who)
+void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, IDX who)
 {
        monster_type    *m_ptr = &m_list[m_idx];
 
@@ -250,7 +248,7 @@ void mon_take_hit_mon(int m_idx, int dam, bool *fear, cptr note, int who)
        }
 
        /* Hurt it */
-       m_ptr->hp -= dam;
+       m_ptr->hp -= (s16b)dam;
 
        /* It is dead now... or is it? */
        if (m_ptr->hp < 0)
@@ -362,8 +360,6 @@ void mon_take_hit_mon(int m_idx, int dam, bool *fear, cptr note, int who)
 
        if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
        {
-               char m_name[80];
-
                /* Extract monster name */
                monster_desc(m_name, m_ptr, 0);
 
@@ -395,7 +391,7 @@ void mon_take_hit_mon(int m_idx, int dam, bool *fear, cptr note, int who)
  * Note that this function is responsible for about one to five percent\n
  * of the processor use in normal conditions...\n
  */
-static int mon_will_run(int m_idx)
+static bool mon_will_run(MONSTER_IDX m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -404,8 +400,8 @@ static int mon_will_run(int m_idx)
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        u16b p_lev, m_lev;
-       u16b p_chp, p_mhp;
-       u16b m_chp, m_mhp;
+       HIT_POINT p_chp, p_mhp;
+       HIT_POINT m_chp, m_mhp;
        u32b p_val, m_val;
 
 #endif
@@ -469,7 +465,7 @@ static int mon_will_run(int m_idx)
  * @param xp 適したマスのX座標を返す参照ポインタ
  * @return 有効なマスがあった場合TRUEを返す
  */
-static bool get_moves_aux2(int m_idx, int *yp, int *xp)
+static bool get_moves_aux2(MONSTER_IDX m_idx, int *yp, int *xp)
 {
        int i, y, x, y1, x1, best = 999;
 
@@ -485,7 +481,7 @@ static bool get_moves_aux2(int m_idx, int *yp, int *xp)
        x1 = m_ptr->fx;
 
        /* Monster can already cast spell to player */
-       if (projectable(y1, x1, py, px)) return (FALSE);
+       if (projectable(y1, x1, p_ptr->y, p_ptr->x)) return (FALSE);
 
        /* Set current grid cost */
        now_cost = cave[y1][x1].cost;
@@ -528,7 +524,7 @@ static bool get_moves_aux2(int m_idx, int *yp, int *xp)
 
                if (now_cost < cost) continue;
 
-               if (!projectable(y, x, py, px)) continue;
+               if (!projectable(y, x, p_ptr->y, p_ptr->x)) continue;
 
                /* Accept louder sounds */
                if (best < cost) continue;
@@ -574,7 +570,7 @@ static bool get_moves_aux2(int m_idx, int *yp, int *xp)
  * being close enough to chase directly.  I have no idea what will\n
  * happen if you combine "smell" with low "aaf" values.\n
  */
-static bool get_moves_aux(int m_idx, int *yp, int *xp, bool no_flow)
+static bool get_moves_aux(MONSTER_IDX m_idx, int *yp, int *xp, bool no_flow)
 {
        int i, y, x, y1, x1, best;
 
@@ -586,8 +582,8 @@ static bool get_moves_aux(int m_idx, int *yp, int *xp, bool no_flow)
 
        /* Can monster cast attack spell? */
        if (r_ptr->flags4 & (RF4_ATTACK_MASK) ||
-           r_ptr->flags5 & (RF5_ATTACK_MASK) ||
-           r_ptr->flags6 & (RF6_ATTACK_MASK))
+           r_ptr->a_ability_flags1 & (RF5_ATTACK_MASK) ||
+           r_ptr->a_ability_flags2 & (RF6_ATTACK_MASK))
        {
                /* Can move spell castable grid? */
                if (get_moves_aux2(m_idx, yp, xp)) return (TRUE);
@@ -605,7 +601,7 @@ static bool get_moves_aux(int m_idx, int *yp, int *xp, bool no_flow)
        x1 = m_ptr->fx;
 
        /* Hack -- Player can see us, run towards him */
-       if (player_has_los_bold(y1, x1) && projectable(py, px, y1, x1)) return (FALSE);
+       if (player_has_los_bold(y1, x1) && projectable(p_ptr->y, p_ptr->x, y1, x1)) return (FALSE);
 
        /* Monster grid */
        c_ptr = &cave[y1][x1];
@@ -620,7 +616,7 @@ static bool get_moves_aux(int m_idx, int *yp, int *xp, bool no_flow)
        else if (c_ptr->when)
        {
                /* Too old smell */
-               if (cave[py][px].when - c_ptr->when > 127) return (FALSE);
+               if (cave[p_ptr->y][p_ptr->x].when - c_ptr->when > 127) return (FALSE);
 
                use_scent = TRUE;
                best = 0;
@@ -669,8 +665,8 @@ static bool get_moves_aux(int m_idx, int *yp, int *xp, bool no_flow)
                }
 
                /* Hack -- Save the "twiddled" location */
-               (*yp) = py + 16 * ddy_ddd[i];
-               (*xp) = px + 16 * ddx_ddd[i];
+               (*yp) = p_ptr->y + 16 * ddy_ddd[i];
+               (*xp) = p_ptr->x + 16 * ddx_ddd[i];
        }
 
        /* No legal move (?) */
@@ -693,7 +689,7 @@ static bool get_moves_aux(int m_idx, int *yp, int *xp, bool no_flow)
  * but instead of heading directly for it, the monster should "swerve"\n
  * around the player so that he has a smaller chance of getting hit.\n
  */
-static bool get_fear_moves_aux(int m_idx, int *yp, int *xp)
+static bool get_fear_moves_aux(MONSTER_IDX m_idx, int *yp, int *xp)
 {
        int y, x, y1, x1, fy, fx, gy = 0, gx = 0;
        int score = -1;
@@ -908,7 +904,7 @@ static sint *dist_offsets_x[10] =
  *\n
  * Return TRUE if a safe location is available.\n
  */
-static bool find_safety(int m_idx, int *yp, int *xp)
+static bool find_safety(MONSTER_IDX m_idx, int *yp, int *xp)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -957,10 +953,10 @@ static bool find_safety(int m_idx, int *yp, int *xp)
                        }
 
                        /* Check for absence of shot (more or less) */
-                       if (!projectable(py, px, y, x))
+                       if (!projectable(p_ptr->y, p_ptr->x, y, x))
                        {
                                /* Calculate distance from player */
-                               dis = distance(y, x, py, px);
+                               dis = distance(y, x, p_ptr->y, p_ptr->x);
 
                                /* Remember if further than previous */
                                if (dis > gdis)
@@ -1002,7 +998,7 @@ static bool find_safety(int m_idx, int *yp, int *xp)
  *\n
  * Return TRUE if a good location is available.\n
  */
-static bool find_hiding(int m_idx, int *yp, int *xp)
+static bool find_hiding(MONSTER_IDX m_idx, int *yp, int *xp)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -1037,10 +1033,10 @@ static bool find_hiding(int m_idx, int *yp, int *xp)
                        if (!monster_can_enter(y, x, r_ptr, 0)) continue;
 
                        /* Check for hidden, available grid */
-                       if (!projectable(py, px, y, x) && clean_shot(fy, fx, y, x, FALSE))
+                       if (!projectable(p_ptr->y, p_ptr->x, y, x) && clean_shot(fy, fx, y, x, FALSE))
                        {
                                /* Calculate distance from player */
-                               dis = distance(y, x, py, px);
+                               dis = distance(y, x, p_ptr->y, p_ptr->x);
 
                                /* Remember if closer than previous */
                                if (dis < gdis && dis >= 2)
@@ -1076,14 +1072,14 @@ static bool find_hiding(int m_idx, int *yp, int *xp)
  * @param mm 移動方向を返す方向IDの参照ポインタ
  * @return 有効方向があった場合TRUEを返す
  */
-static bool get_moves(int m_idx, int *mm)
+static bool get_moves(MONSTER_IDX m_idx, int *mm)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
-       int          y, ay, x, ax;
+       int          y = 0, ay, x = 0, ax;
        int          move_val = 0;
-       int          y2 = py;
-       int          x2 = px;
+       int          y2 = p_ptr->y;
+       int          x2 = p_ptr->x;
        bool         done = FALSE;
        bool         will_run = mon_will_run(m_idx);
        cave_type    *c_ptr;
@@ -1110,7 +1106,7 @@ static bool get_moves(int m_idx, int *mm)
 
        if (!done && !will_run && is_hostile(m_ptr) &&
            (r_ptr->flags1 & RF1_FRIENDS) &&
-           ((los(m_ptr->fy, m_ptr->fx, py, px) && projectable(m_ptr->fy, m_ptr->fx, py, px)) ||
+           ((los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) ||
            (cave[m_ptr->fy][m_ptr->fx].dist < MAX_SIGHT / 2)))
        {
        /*
@@ -1125,8 +1121,8 @@ static bool get_moves(int m_idx, int *mm)
                        /* Count room grids next to player */
                        for (i = 0; i < 8; i++)
                        {
-                               int xx = px + ddx_ddd[i];
-                               int yy = py + ddy_ddd[i];
+                               int xx = p_ptr->x + ddx_ddd[i];
+                               int yy = p_ptr->y + ddy_ddd[i];
 
                                if (!in_bounds2(yy, xx)) continue;
 
@@ -1139,8 +1135,8 @@ static bool get_moves(int m_idx, int *mm)
                                        room++;
                                }
                        }
-                       if (cave[py][px].info & CAVE_ROOM) room -= 2;
-                       if (!r_ptr->flags4 && !r_ptr->flags5 && !r_ptr->flags6) room -= 2;
+                       if (cave[p_ptr->y][p_ptr->x].info & CAVE_ROOM) room -= 2;
+                       if (!r_ptr->flags4 && !r_ptr->a_ability_flags1 && !r_ptr->a_ability_flags2) room -= 2;
 
                        /* Not in a room and strong player */
                        if (room < (8 * (p_ptr->chp + p_ptr->csp)) /
@@ -1160,15 +1156,15 @@ static bool get_moves(int m_idx, int *mm)
                        for (i = 0; i < 8; i++)
                        {
                                /* Pick squares near player (semi-randomly) */
-                               y2 = py + ddy_ddd[(m_idx + i) & 7];
-                               x2 = px + ddx_ddd[(m_idx + i) & 7];
+                               y2 = p_ptr->y + ddy_ddd[(m_idx + i) & 7];
+                               x2 = p_ptr->x + ddx_ddd[(m_idx + i) & 7];
 
                                /* Already there? */
                                if ((m_ptr->fy == y2) && (m_ptr->fx == x2))
                                {
                                        /* Attack the player */
-                                       y2 = py;
-                                       x2 = px;
+                                       y2 = p_ptr->y;
+                                       x2 = p_ptr->x;
 
                                        break;
                                }
@@ -1446,7 +1442,7 @@ static int check_hit2(int power, int level, int ac, int stun)
  * @param t_idx 目標側モンスターの参照ID
  * @return 実際に打撃処理が行われた場合TRUEを返す
  */
-static bool monst_attack_monst(int m_idx, int t_idx)
+static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx)
 {
        monster_type    *m_ptr = &m_list[m_idx];
        monster_type    *t_ptr = &m_list[t_idx];
@@ -1507,8 +1503,8 @@ static bool monst_attack_monst(int m_idx, int t_idx)
        {
                bool obvious = FALSE;
 
-               int power = 0;
-               int damage = 0;
+               HIT_POINT power = 0;
+               HIT_POINT damage = 0;
 
                cptr act = NULL;
 
@@ -1841,12 +1837,12 @@ static bool monst_attack_monst(int m_idx, int t_idx)
                                break;
 
                        case RBE_DR_LIFE:
-                               pt = GF_OLD_DRAIN;
+                               pt = GF_HYPODYNAMIA;
                                effect_type = BLOW_EFFECT_TYPE_HEAL;
                                break;
 
                        case RBE_INERTIA:
-                               pt = GF_INERTIA;
+                               pt = GF_INERTIAL;
                                break;
 
                        case RBE_STUN:
@@ -2105,13 +2101,14 @@ static bool check_hp_for_feat_destruction(feature_type *f_ptr, monster_type *m_p
  *\n
  * A "direction" of "5" means "pick a random direction".\n
  */
-static void process_monster(int m_idx)
+static void process_monster(MONSTER_IDX m_idx)
 {
        monster_type    *m_ptr = &m_list[m_idx];
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
        monster_race    *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
 
-       int             i, d, oy, ox, ny, nx;
+       int             i, d;
+       POSITION        oy, ox, ny, nx;
 
        int             mm[8];
 
@@ -2274,7 +2271,7 @@ static void process_monster(int m_idx)
                                if (see_m)
                                {
                                        if ((r_ptr->flags2 & RF2_CAN_SPEAK) && (m_ptr->r_idx != MON_GRIP) && (m_ptr->r_idx != MON_WOLF) && (m_ptr->r_idx != MON_FANG) &&
-                                           player_has_los_bold(m_ptr->fy, m_ptr->fx) && projectable(m_ptr->fy, m_ptr->fx, py, px))
+                                           player_has_los_bold(m_ptr->fy, m_ptr->fx) && projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x))
                                        {
                                                msg_format(_("%^s「ピンチだ!退却させてもらう!」", "%^s says 'It is the pinch! I will retreat'."), m_name);
                                        }
@@ -2415,7 +2412,7 @@ static void process_monster(int m_idx)
        }
 
 
-       if (r_ptr->flags6 & RF6_SPECIAL)
+       if (r_ptr->a_ability_flags2 & RF6_SPECIAL)
        {
                /* Hack -- Ohmu scatters molds! */
                if (m_ptr->r_idx == MON_OHMU)
@@ -2458,7 +2455,7 @@ static void process_monster(int m_idx)
                if ((ap_r_ptr->flags2 & RF2_CAN_SPEAK) && aware &&
                    one_in_(SPEAK_CHANCE) &&
                    player_has_los_bold(oy, ox) &&
-                   projectable(oy, ox, py, px))
+                   projectable(oy, ox, p_ptr->y, p_ptr->x))
                {
                        char m_name[80];
                        char monmessage[1024];
@@ -2619,7 +2616,7 @@ static void process_monster(int m_idx)
                                (void)get_moves(m_idx, mm);
 
                                /* Restore the leash */
-                               p_ptr->pet_follow_distance = dis;
+                               p_ptr->pet_follow_distance = (s16b)dis;
                        }
                }
        }
@@ -3092,7 +3089,7 @@ static void process_monster(int m_idx)
                                }
 
                                /* Hack -- Update the new location */
-                               c_ptr->m_idx = m_idx;
+                               c_ptr->m_idx = (s16b)m_idx;
 
                                /* Move the monster */
                                m_ptr->fy = ny;
@@ -3119,7 +3116,7 @@ static void process_monster(int m_idx)
                        /* Possible disturb */
                        if (m_ptr->ml &&
                            (disturb_move ||
-                            (disturb_near && (m_ptr->mflag & MFLAG_VIEW) && projectable(py, px, m_ptr->fy, m_ptr->fx)) ||
+                            (disturb_near && (m_ptr->mflag & MFLAG_VIEW) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) ||
                             (disturb_high && ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)))
                        {
                                /* Disturb */
@@ -3236,7 +3233,7 @@ static void process_monster(int m_idx)
                                                o_ptr->iy = o_ptr->ix = 0;
 
                                                /* Memorize monster */
-                                               o_ptr->held_m_idx = m_idx;
+                                               o_ptr->held_m_idx = (s16b)m_idx;
 
                                                /* Build a stack */
                                                o_ptr->next_o_idx = m_ptr->hold_o_idx;
@@ -3391,8 +3388,8 @@ static void process_monster(int m_idx)
  */
 void process_monsters(void)
 {
-       int             i;
-       int             fx, fy;
+       IDX i;
+       POSITION fx, fy;
 
        bool            test;
 
@@ -3508,12 +3505,12 @@ void process_monsters(void)
                        test = TRUE;
                }
 
-#if 0 /* (cave[py][px].when == cave[fy][fx].when) is always FALSE... */
+#if 0 /* (cave[p_ptr->y][p_ptr->x].when == cave[fy][fx].when) is always FALSE... */
                /* Hack -- Monsters can "smell" the player from far away */
                /* Note that most monsters have "aaf" of "20" or so */
                else if (!(m_ptr->mflag2 & MFLAG2_NOFLOW) &&
-                       cave_have_flag_bold(py, px, FF_MOVE) &&
-                       (cave[py][px].when == cave[fy][fx].when) &&
+                       cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_MOVE) &&
+                       (cave[p_ptr->y][p_ptr->x].when == cave[fy][fx].when) &&
                        (cave[fy][fx].dist < MONSTER_FLOW_DEPTH) &&
                        (cave[fy][fx].dist < r_ptr->aaf))
                {
@@ -3605,7 +3602,7 @@ void process_monsters(void)
  * @return mproc_type モンスターの時限ステータスID
  * @return 残りターン値
  */
-int get_mproc_idx(int m_idx, int mproc_type)
+int get_mproc_idx(MONSTER_IDX m_idx, int mproc_type)
 {
        s16b *cur_mproc_list = mproc_list[mproc_type];
        int i;
@@ -3624,9 +3621,9 @@ int get_mproc_idx(int m_idx, int mproc_type)
  * @return mproc_type 追加したいモンスターの時限ステータスID
  * @return なし
  */
-static void mproc_add(int m_idx, int mproc_type)
+static void mproc_add(MONSTER_IDX m_idx, int mproc_type)
 {
-       if (mproc_max[mproc_type] < max_m_idx) mproc_list[mproc_type][mproc_max[mproc_type]++] = m_idx;
+       if (mproc_max[mproc_type] < max_m_idx) mproc_list[mproc_type][mproc_max[mproc_type]++] = (s16b)m_idx;
 }
 
 
@@ -3636,7 +3633,7 @@ static void mproc_add(int m_idx, int mproc_type)
  * @return mproc_type 削除したいモンスターの時限ステータスID
  * @return なし
  */
-static void mproc_remove(int m_idx, int mproc_type)
+static void mproc_remove(MONSTER_IDX m_idx, int mproc_type)
 {
        int mproc_idx = get_mproc_idx(m_idx, mproc_type);
        if (mproc_idx >= 0) mproc_list[mproc_type][mproc_idx] = mproc_list[mproc_type][--mproc_max[mproc_type]];
@@ -3650,7 +3647,8 @@ static void mproc_remove(int m_idx, int mproc_type)
 void mproc_init(void)
 {
        monster_type *m_ptr;
-       int          i, cmi;
+       MONSTER_IDX i;
+       int cmi;
 
        /* Reset "mproc_max[]" */
        for (cmi = 0; cmi < MAX_MTIMED; cmi++) mproc_max[cmi] = 0;
@@ -3679,7 +3677,7 @@ void mproc_init(void)
  * @param v セットする値
  * @return 別途更新処理が必要な場合TRUEを返す
  */
-bool set_monster_csleep(int m_idx, int v)
+bool set_monster_csleep(MONSTER_IDX m_idx, int v)
 {
        monster_type *m_ptr = &m_list[m_idx];
        bool notice = FALSE;
@@ -3708,7 +3706,7 @@ bool set_monster_csleep(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_CSLEEP] = v;
+       m_ptr->mtimed[MTIMED_CSLEEP] = (s16b)v;
 
        if (!notice) return FALSE;
 
@@ -3732,7 +3730,7 @@ bool set_monster_csleep(int m_idx, int v)
  * @param v セットする値
  * @return 別途更新処理が必要な場合TRUEを返す
  */
-bool set_monster_fast(int m_idx, int v)
+bool set_monster_fast(MONSTER_IDX m_idx, int v)
 {
        monster_type *m_ptr = &m_list[m_idx];
        bool notice = FALSE;
@@ -3761,7 +3759,7 @@ bool set_monster_fast(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_FAST] = v;
+       m_ptr->mtimed[MTIMED_FAST] = (s16b)v;
 
        if (!notice) return FALSE;
 
@@ -3774,7 +3772,7 @@ bool set_monster_fast(int m_idx, int v)
 /*
  * Set "m_ptr->mtimed[MTIMED_SLOW]", notice observable changes
  */
-bool set_monster_slow(int m_idx, int v)
+bool set_monster_slow(MONSTER_IDX m_idx, int v)
 {
        monster_type *m_ptr = &m_list[m_idx];
        bool notice = FALSE;
@@ -3803,7 +3801,7 @@ bool set_monster_slow(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_SLOW] = v;
+       m_ptr->mtimed[MTIMED_SLOW] = (s16b)v;
 
        if (!notice) return FALSE;
 
@@ -3820,7 +3818,7 @@ bool set_monster_slow(int m_idx, int v)
  * @param v セットする値
  * @return 別途更新処理が必要な場合TRUEを返す
  */
-bool set_monster_stunned(int m_idx, int v)
+bool set_monster_stunned(MONSTER_IDX m_idx, int v)
 {
        monster_type *m_ptr = &m_list[m_idx];
        bool notice = FALSE;
@@ -3849,7 +3847,7 @@ bool set_monster_stunned(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_STUNNED] = v;
+       m_ptr->mtimed[MTIMED_STUNNED] = (s16b)v;
 
        return notice;
 }
@@ -3862,7 +3860,7 @@ bool set_monster_stunned(int m_idx, int v)
  * @param v セットする値
  * @return 別途更新処理が必要な場合TRUEを返す
  */
-bool set_monster_confused(int m_idx, int v)
+bool set_monster_confused(MONSTER_IDX m_idx, int v)
 {
        monster_type *m_ptr = &m_list[m_idx];
        bool notice = FALSE;
@@ -3891,7 +3889,7 @@ bool set_monster_confused(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_CONFUSED] = v;
+       m_ptr->mtimed[MTIMED_CONFUSED] = (s16b)v;
 
        return notice;
 }
@@ -3904,7 +3902,7 @@ bool set_monster_confused(int m_idx, int v)
  * @param v セットする値
  * @return 別途更新処理が必要な場合TRUEを返す
  */
-bool set_monster_monfear(int m_idx, int v)
+bool set_monster_monfear(MONSTER_IDX m_idx, int v)
 {
        monster_type *m_ptr = &m_list[m_idx];
        bool notice = FALSE;
@@ -3933,7 +3931,7 @@ bool set_monster_monfear(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_MONFEAR] = v;
+       m_ptr->mtimed[MTIMED_MONFEAR] = (s16b)v;
 
        if (!notice) return FALSE;
 
@@ -3956,7 +3954,7 @@ bool set_monster_monfear(int m_idx, int v)
  * @param energy_need TRUEならば無敵解除時に行動ターン消費を行う
  * @return 別途更新処理が必要な場合TRUEを返す
  */
-bool set_monster_invulner(int m_idx, int v, bool energy_need)
+bool set_monster_invulner(MONSTER_IDX m_idx, int v, bool energy_need)
 {
        monster_type *m_ptr = &m_list[m_idx];
        bool notice = FALSE;
@@ -3986,7 +3984,7 @@ bool set_monster_invulner(int m_idx, int v, bool energy_need)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_INVULNER] = v;
+       m_ptr->mtimed[MTIMED_INVULNER] = (s16b)v;
 
        if (!notice) return FALSE;
 
@@ -4009,7 +4007,7 @@ static u32b csleep_noise;
  * @param mtimed_idx 更新するモンスターの時限ステータスID
  * @return なし
  */
-static void process_monsters_mtimed_aux(int m_idx, int mtimed_idx)
+static void process_monsters_mtimed_aux(MONSTER_IDX m_idx, int mtimed_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -4248,7 +4246,7 @@ void process_monsters_mtimed(int mtimed_idx)
  * @param m_idx 魔力消去を受けるモンスターの参照ID
  * @return なし
  */
-void dispel_monster_status(int m_idx)
+void dispel_monster_status(MONSTER_IDX m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
        char         m_name[80];
@@ -4333,7 +4331,7 @@ bool process_the_world(int num, int who, bool vs_player)
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 
        world_monster = 0;
-       if (vs_player || (player_has_los_bold(m_ptr->fy, m_ptr->fx) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
+       if (vs_player || (player_has_los_bold(m_ptr->fy, m_ptr->fx) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)))
        {
                msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
                msg_print(NULL);
@@ -4350,7 +4348,7 @@ bool process_the_world(int num, int who, bool vs_player)
  * @param s_idx 撃破されたモンスター種族の参照ID
  * @return なし
  */
-void monster_gain_exp(int m_idx, int s_idx)
+void monster_gain_exp(MONSTER_IDX m_idx, IDX s_idx)
 {
        monster_type *m_ptr;
        monster_race *r_ptr;