OSDN Git Service

[Refactor] #37353 コメント整理 / Refactor comments.
[hengband/hengband.git] / src / monster-process.c
index 5239eab..aff5af8 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "angband.h"
 #include "cmd-pet.h"
+#include "monsterrace-hook.h"
 
 
 /*!
@@ -84,8 +85,7 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
                                        }
                                }
                                /* Hack -- no fighting away from player */
-                               else if ((m_ptr->cdis < t_ptr->cdis) &&
-                                                       (t_ptr->cdis > p_ptr->pet_follow_distance))
+                               else if ((m_ptr->cdis < t_ptr->cdis) && (t_ptr->cdis > p_ptr->pet_follow_distance))
                                {
                                        continue;
                                }
@@ -212,7 +212,6 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
                if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
        }
 
-       /* Wake it up */
        (void)set_monster_csleep(m_idx, 0);
 
        if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(TRUE, TRUE);
@@ -223,7 +222,6 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
                {
                        msg_format(_("%^sはダメージを受けない。", "%^s is unharmed."), m_name);
                }
-
                return;
        }
 
@@ -245,7 +243,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
        }
 
        /* Hurt it */
-       m_ptr->hp -= (s16b)dam;
+       m_ptr->hp -= dam;
 
        /* It is dead now... or is it? */
        if (m_ptr->hp < 0)
@@ -259,7 +257,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
                else
                {
                        /* Make a sound */
-                       if (!monster_living(r_ptr))
+                       if (!monster_living(m_ptr->r_idx))
                        {
                                sound(SOUND_N_KILL);
                        }
@@ -282,7 +280,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
                                        msg_format(_("%^s%s", "%^s%s"), m_name, note);
                                }
                                /* Death by normal attack -- nonliving monster */
-                               else if (!monster_living(r_ptr))
+                               else if (!monster_living(m_ptr->r_idx))
                                {
                                        msg_format(_("%^sは破壊された。", "%^s is destroyed."), m_name);
                                }
@@ -294,11 +292,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
                        }
 
                        monster_gain_exp(who, m_ptr->r_idx);
-
-                       /* Generate treasure */
                        monster_death(m_idx, FALSE);
-
-
                        delete_monster_idx(m_idx);
 
                        /* Not afraid */
@@ -396,7 +390,8 @@ static bool mon_will_run(MONSTER_IDX m_idx)
 
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       u16b p_lev, m_lev;
+       PLAYER_LEVEL p_lev;
+       DEPTH m_lev;
        HIT_POINT p_chp, p_mhp;
        HIT_POINT m_chp, m_mhp;
        u32b p_val, m_val;
@@ -496,7 +491,6 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        {
                int cost;
 
-               /* Get the location */
                y = y1 + ddy_ddd[i];
                x = x1 + ddx_ddd[i];
 
@@ -630,7 +624,6 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no
        /* Check nearby grids, diagonals first */
        for (i = 7; i >= 0; i--)
        {
-               /* Get the location */
                y = y1 + ddy_ddd[i];
                x = x1 + ddx_ddd[i];
 
@@ -709,7 +702,6 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        {
                POSITION dis, s;
 
-               /* Get the location */
                y = fy + ddy_ddd[i];
                x = fx + ddx_ddd[i];
 
@@ -1048,7 +1040,7 @@ static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
  * @param mm 移動方向を返す方向IDの参照ポインタ
  * @return 有効方向があった場合TRUEを返す
  */
-static bool get_moves(MONSTER_IDX m_idx, int *mm)
+static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -1508,7 +1500,6 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                /* Monster hits */
                if (!effect || check_hit2(power, rlev, ac, MON_STUNNED(m_ptr)))
                {
-                       /* Wake it up */
                        (void)set_monster_csleep(t_idx, 0);
 
                        if (t_ptr->ml)
@@ -1852,7 +1843,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                                        break;
 
                                case BLOW_EFFECT_TYPE_HEAL:
-                                       if ((monster_living(tr_ptr)) && (damage > 2))
+                                       if ((monster_living(m_idx)) && (damage > 2))
                                        {
                                                bool did_heal = FALSE;
 
@@ -1962,7 +1953,6 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                        case RBM_ENGULF:
                        case RBM_CHARGE:
                                {
-                                       /* Wake it up */
                                        (void)set_monster_csleep(t_idx, 0);
 
                                        /* Visible monsters */
@@ -2082,10 +2072,10 @@ void process_monster(MONSTER_IDX m_idx)
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
        monster_race    *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
 
-       int             i, d;
-       POSITION        oy, ox, ny, nx;
+       int i, d;
+       POSITION oy, ox, ny, nx;
 
-       int             mm[8];
+       DIRECTION mm[8];
 
        cave_type       *c_ptr;
        feature_type    *f_ptr;
@@ -2153,8 +2143,6 @@ void process_monster(MONSTER_IDX m_idx)
                if (see_m)
                {
                        char m_name[80];
-
-                       /* Acquire the monster name */
                        monster_desc(m_name, m_ptr, 0);
                        msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
                }
@@ -2184,14 +2172,11 @@ void process_monster(MONSTER_IDX m_idx)
                {
                        bool sad = FALSE;
 
-                       if (is_pet(m_ptr) && !(m_ptr->ml))
-                               sad = TRUE;
+                       if (is_pet(m_ptr) && !(m_ptr->ml)) sad = TRUE;
 
                        if (see_m)
                        {
                                char m_name[80];
-
-                               /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
 
                                msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
@@ -2202,7 +2187,6 @@ void process_monster(MONSTER_IDX m_idx)
 
 
                        delete_monster_idx(m_idx);
-
                        if (sad)
                        {
                                msg_print(_("少しの間悲しい気分になった。", "You feel sad for a moment."));
@@ -2290,8 +2274,6 @@ void process_monster(MONSTER_IDX m_idx)
                if (m_ptr->ml)
                {
                        char m_name[80];
-
-                       /* Acquire the monster name */
                        monster_desc(m_name, m_ptr, 0);
 
                        /* Dump a message */
@@ -2397,9 +2379,9 @@ void process_monster(MONSTER_IDX m_idx)
                        {
                                if (r_ptr->freq_spell && (randint1(100) <= r_ptr->freq_spell))
                                {
-                                       int  k, count = 0;
-                                       int  rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
-                                       u32b p_mode = is_pet(m_ptr) ? PM_FORCE_PET : 0L;
+                                       int k, count = 0;
+                                       DEPTH rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
+                                       BIT_FLAGS p_mode = is_pet(m_ptr) ? PM_FORCE_PET : 0L;
 
                                        for (k = 0; k < 6; k++)
                                        {
@@ -2469,11 +2451,10 @@ void process_monster(MONSTER_IDX m_idx)
                /* Give priority to counter attack? */
                if (m_ptr->target_y)
                {
-                       int t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
+                       MONSTER_IDX t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx;
 
                        /* The monster must be an enemy, and projectable */
-                       if (t_m_idx &&
-                           are_enemies(m_ptr, &m_list[t_m_idx]) &&
+                       if (t_m_idx && are_enemies(m_ptr, &m_list[t_m_idx]) &&
                            projectable(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x))
                        {
                                counterattack = TRUE;
@@ -3055,7 +3036,7 @@ void process_monster(MONSTER_IDX m_idx)
                                        y_ptr->fx = ox;
 
                                        /* Update the old monster */
-                                       update_mon(c_ptr->m_idx, TRUE);
+                                       update_monster(c_ptr->m_idx, TRUE);
                                }
 
                                /* Hack -- Update the new location */
@@ -3064,9 +3045,7 @@ void process_monster(MONSTER_IDX m_idx)
                                /* Move the monster */
                                m_ptr->fy = ny;
                                m_ptr->fx = nx;
-
-                               /* Update the monster */
-                               update_mon(m_idx, TRUE);
+                               update_monster(m_idx, TRUE);
 
                                /* Redraw the old grid */
                                lite_spot(oy, ox);
@@ -3104,8 +3083,6 @@ void process_monster(MONSTER_IDX m_idx)
                                {
                                        BIT_FLAGS flgs[TR_FLAG_SIZE], flg2 = 0L, flg3 = 0L, flgr = 0L;
                                        char m_name[80], o_name[MAX_NLEN];
-
-                                       /* Acquire object */
                                        object_type *o_ptr = &o_list[this_o_idx];
 
                                        /* Acquire next object */
@@ -3130,8 +3107,6 @@ void process_monster(MONSTER_IDX m_idx)
 
                                        /* Acquire the object name */
                                        object_desc(o_name, o_ptr, 0);
-
-                                       /* Acquire the monster name */
                                        monster_desc(m_name, m_ptr, MD_INDEF_HIDDEN);
 
                                        /* React to objects that hurt the monster */
@@ -3304,8 +3279,6 @@ void process_monster(MONSTER_IDX m_idx)
                if (see_m)
                {
                        char m_name[80];
-
-                       /* Acquire the monster name */
                        monster_desc(m_name, m_ptr, 0);
 
                        /* Dump a message */
@@ -3362,24 +3335,24 @@ void process_monsters(void)
        monster_type    *m_ptr;
        monster_race    *r_ptr;
 
-       int             old_monster_race_idx;
+       MONRACE_IDX old_monster_race_idx;
 
-       u32b    old_r_flags1 = 0L;
-       u32b    old_r_flags2 = 0L;
-       u32b    old_r_flags3 = 0L;
-       u32b    old_r_flags4 = 0L;
-       u32b    old_r_flags5 = 0L;
-       u32b    old_r_flags6 = 0L;
-       u32b    old_r_flagsr = 0L;
+       BIT_FLAGS old_r_flags1 = 0L;
+       BIT_FLAGS old_r_flags2 = 0L;
+       BIT_FLAGS old_r_flags3 = 0L;
+       BIT_FLAGS old_r_flags4 = 0L;
+       BIT_FLAGS old_r_flags5 = 0L;
+       BIT_FLAGS old_r_flags6 = 0L;
+       BIT_FLAGS old_r_flagsr = 0L;
 
-       byte    old_r_blows0 = 0;
-       byte    old_r_blows1 = 0;
-       byte    old_r_blows2 = 0;
-       byte    old_r_blows3 = 0;
+       byte old_r_blows0 = 0;
+       byte old_r_blows1 = 0;
+       byte old_r_blows2 = 0;
+       byte old_r_blows3 = 0;
 
-       byte    old_r_cast_spell = 0;
+       byte old_r_cast_spell = 0;
 
-       int speed;
+       SPEED speed;
 
        /* Clear monster fighting indicator */
        mon_fight = FALSE;