OSDN Git Service

[Refactor] #37353 ペット処理を cmd4.c から cmd-pet.c/h へ分離。
[hengband/hengband.git] / src / melee2.c
index 0561bb6..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];
 
@@ -393,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 bool mon_will_run(int m_idx)
+static bool mon_will_run(MONSTER_IDX m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -467,7 +465,7 @@ static bool 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;
 
@@ -572,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;
 
@@ -691,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;
@@ -906,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];
 
@@ -1000,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];
@@ -1074,7 +1072,7 @@ 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];
@@ -1444,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(IDX m_idx, IDX 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];
@@ -1839,7 +1837,7 @@ static bool monst_attack_monst(IDX m_idx, IDX t_idx)
                                break;
 
                        case RBE_DR_LIFE:
-                               pt = GF_OLD_DRAIN;
+                               pt = GF_HYPODYNAMIA;
                                effect_type = BLOW_EFFECT_TYPE_HEAL;
                                break;
 
@@ -2103,7 +2101,7 @@ 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];
@@ -3390,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;
 
@@ -3550,7 +3548,7 @@ void process_monsters(void)
 
 
                /* Save global index */
-               hack_m_idx = (s16b)i;
+               hack_m_idx = i;
 
                /* Process the monster */
                process_monster(i);
@@ -3604,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;
@@ -3623,7 +3621,7 @@ 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]++] = (s16b)m_idx;
 }
@@ -3635,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]];
@@ -3649,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;
@@ -3678,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;
@@ -3731,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;
@@ -3773,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;
@@ -3819,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;
@@ -3861,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;
@@ -3903,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;
@@ -3955,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;
@@ -4008,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];
 
@@ -4247,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];
@@ -4349,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;