OSDN Git Service

[Refactor] #37353 マジックナンバー修正(A_MAX) / Fix magic number (A_MAX).
[hengband/hengband.git] / src / monster2.c
index 8c3fcb2..3b49643 100644 (file)
@@ -11,6 +11,9 @@
  */
 
 #include "angband.h"
+#include "cmd-pet.h"
+#include "monsterrace-hook.h"
+#include "monster-status.h"
 
 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
@@ -169,7 +172,7 @@ cptr funny_comments[MAX_SAN_COMMENT] =
  * @param x 目標x座標
  * @return なし
  */
-void set_target(monster_type *m_ptr, int y, int x)
+void set_target(monster_type *m_ptr, POSITION y, POSITION x)
 {
        m_ptr->target_y = y;
        m_ptr->target_x = x;
@@ -194,19 +197,24 @@ void reset_target(monster_type *m_ptr)
  */
 monster_race *real_r_ptr(monster_type *m_ptr)
 {
+       return &r_info[real_r_idx(m_ptr)];
+}
+
+MONRACE_IDX real_r_idx(monster_type *m_ptr)
+{
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        /* Extract real race */
        if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
        {
                if (r_ptr->flags1 & RF1_UNIQUE)
-                       return &r_info[MON_CHAMELEON_K];
+                       return MON_CHAMELEON_K;
                else
-                       return &r_info[MON_CHAMELEON];
+                       return MON_CHAMELEON;
        }
        else
        {
-               return r_ptr;
+               return m_ptr->r_idx;
        }
 }
 
@@ -221,20 +229,14 @@ monster_race *real_r_ptr(monster_type *m_ptr)
  */
 void delete_monster_idx(MONSTER_IDX i)
 {
-       int x, y;
-
+       POSITION x, y;
        monster_type *m_ptr = &m_list[i];
-
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
 
-       s16b this_o_idx, next_o_idx = 0;
-
-
-       /* Get location */
        y = m_ptr->fy;
        x = m_ptr->fx;
 
-
        /* Hack -- Reduce the racial counter */
        real_r_ptr(m_ptr)->cur_num--;
 
@@ -249,7 +251,6 @@ void delete_monster_idx(MONSTER_IDX i)
        if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
        if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
 
-
        /* Hack -- remove target monster */
        if (i == target_who) target_who = 0;
 
@@ -268,8 +269,6 @@ void delete_monster_idx(MONSTER_IDX i)
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-
-               /* Acquire object */
                o_ptr = &o_list[this_o_idx];
 
                /* Acquire next object */
@@ -280,7 +279,6 @@ void delete_monster_idx(MONSTER_IDX i)
                 * to prevent calling lite_spot()
                 */
 
-               /* Delete the object */
                delete_object_idx(this_o_idx);
        }
 
@@ -332,23 +330,18 @@ void delete_monster(POSITION y, POSITION x)
  */
 static void compact_monsters_aux(IDX i1, IDX i2)
 {
-       int y, x, i;
-
+       POSITION y, x;
+       int i;
        cave_type *c_ptr;
-
        monster_type *m_ptr;
-
-       s16b this_o_idx, next_o_idx = 0;
-
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        /* Do nothing */
        if (i1 == i2) return;
 
-
        /* Old monster */
        m_ptr = &m_list[i1];
 
-       /* Location */
        y = m_ptr->fy;
        x = m_ptr->fx;
 
@@ -362,8 +355,6 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-
-               /* Acquire object */
                o_ptr = &o_list[this_o_idx];
 
                /* Acquire next object */
@@ -477,13 +468,11 @@ void compact_monsters(int size)
 
                        if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
                        {
-                               char m_name[80];
-
+                               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);
                        }
 
-                       /* Delete the monster */
                        delete_monster_idx(i);
 
                        /* Count the monster */
@@ -597,7 +586,6 @@ MONSTER_IDX m_pop(void)
 {
        MONSTER_IDX i;
 
-
        /* Normal allocation */
        if (m_max < max_m_idx)
        {
@@ -614,7 +602,6 @@ MONSTER_IDX m_pop(void)
                return (i);
        }
 
-
        /* Recycle dead monsters */
        for (i = 1; i < m_max; i++)
        {
@@ -633,7 +620,6 @@ MONSTER_IDX m_pop(void)
                return (i);
        }
 
-
        /* Warn the player (except during dungeon creation) */
        if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
 
@@ -807,7 +793,6 @@ static bool summon_specific_aux(MONRACE_IDX r_idx)
                        break;
                }
 
-
                case SUMMON_KIN:
                {
                        okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
@@ -841,13 +826,13 @@ static bool summon_specific_aux(MONRACE_IDX r_idx)
 
                case SUMMON_HI_DRAGON_LIVING:
                {
-                       okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr));
+                       okay = ((r_ptr->d_char == 'D') && monster_living(r_idx));
                        break;
                }
 
                case SUMMON_LIVING:
                {
-                       okay = monster_living(r_ptr);
+                       okay = monster_living(r_idx);
                        break;
                }
 
@@ -901,7 +886,7 @@ static bool summon_specific_aux(MONRACE_IDX r_idx)
 
                        for (i = 0; i < 4; i++)
                                if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
-                       okay = (okay && monster_living(r_ptr));
+                       okay = (okay && monster_living(r_idx));
                        break;
                }
 
@@ -961,8 +946,6 @@ static bool summon_specific_aux(MONRACE_IDX r_idx)
                        break;
                }
        }
-
-       /* Result */
        /* Since okay is int, "return (okay);" is not correct. */
        return (bool)(okay ? TRUE : FALSE);
 }
@@ -1172,8 +1155,8 @@ static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
  * @param monster_hook2 制限関数2
  * @return エラーコード
  */
-errr get_mon_num_prep(monster_hook_type monster_hook,
-                                         monster_hook_type monster_hook2)
+errr get_mon_num_prep(monsterrace_hook_type monster_hook,
+                                         monsterrace_hook_type monster_hook2)
 {
        int i;
 
@@ -1186,7 +1169,7 @@ errr get_mon_num_prep(monster_hook_type monster_hook,
        /* Scan the allocation table */
        for (i = 0; i < alloc_race_size; i++)
        {
-               monster_race    *r_ptr;
+               monster_race *r_ptr;
                
                /* Get the entry */
                alloc_entry *entry = &alloc_race_table[i];
@@ -1230,47 +1213,6 @@ errr get_mon_num_prep(monster_hook_type monster_hook,
        return (0);
 }
 
-/*!
- * @brief 平方根を切り捨て整数で返す
- * @param n 数値
- * @return 平方根
- */
-static int mysqrt(int n)
-{
-       int tmp = n>>1;
-       int tasu = 10;
-       int kaeriti = 1;
-
-       if (!tmp)
-       {
-               if (n) return 1;
-               else return 0;
-       }
-
-       while(tmp)
-       {
-               if ((n/tmp) < tmp)
-               {
-                       tmp >>= 1;
-               }
-               else break;
-       }
-       kaeriti = tmp;
-       while(tasu)
-       {
-               if ((n/tmp) < tmp)
-               {
-                       tasu--;
-                       tmp = kaeriti;
-               }
-               else
-               {
-                       kaeriti = tmp;
-                       tmp += tasu;
-               }
-       }
-       return kaeriti;
-}
 
 /*!
  * @brief 生成モンスター種族を1種生成テーブルから選択する
@@ -1300,17 +1242,15 @@ static int mysqrt(int n)
  */
 MONRACE_IDX get_mon_num(DEPTH level)
 {
-       int                     i, j, p;
-       int                     r_idx;
-       long            value, total;
-       monster_race    *r_ptr;
-       alloc_entry             *table = alloc_race_table;
+       int i, j, p;
+       MONRACE_IDX r_idx;
+       long value, total;
+       monster_race *r_ptr;
+       alloc_entry *table = alloc_race_table;
 
        int pls_kakuritu, pls_level;
        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 * 5000L) - delay / 10)));
        pls_level    = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
 
@@ -1342,6 +1282,9 @@ MONRACE_IDX get_mon_num(DEPTH level)
                }
        }
 
+       if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
+       if (level < 0) level = 0;
+
        /* Reset total */
        total = 0L;
 
@@ -1454,8 +1397,6 @@ MONRACE_IDX get_mon_num(DEPTH level)
                /* Keep the "best" one */
                if (table[i].level < table[j].level) i = j;
        }
-
-       /* Result */
        return (table[i].index);
 }
 
@@ -1520,7 +1461,7 @@ void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
 
        cptr            name;
        char            buf[128];
-       char            silly_name[1024];
+       GAME_TEXT silly_name[1024];
        bool            seen, pron;
        bool            named = FALSE;
 
@@ -1898,7 +1839,6 @@ int lore_do_probe(MONRACE_IDX r_idx)
        /* Update monster recall window */
        if (p_ptr->monster_race_idx == r_idx)
        {
-               /* Window stuff */
                p_ptr->window |= (PW_MONSTER);
        }
 
@@ -1944,7 +1884,6 @@ void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold
        /* Update monster recall window */
        if (p_ptr->monster_race_idx == m_ptr->r_idx)
        {
-               /* Window stuff */
                p_ptr->window |= (PW_MONSTER);
        }
 }
@@ -1964,7 +1903,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
 
        if (!necro && m_ptr)
        {
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
                monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
 
                power = r_ptr->level / 2;
@@ -1985,7 +1924,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
                        return; /* Cannot see it for some reason */
 
                if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
-                       return; /* oops */
+                       return;
 
                if (is_pet(m_ptr))
                        return; /* Pet eldritch horrors are safe most of the time */
@@ -2043,7 +1982,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
        else if(!necro)
        {
                monster_race *r_ptr;
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
                cptr desc;
 
                get_mon_num_prep(get_nightmare, NULL);
@@ -2054,7 +1993,6 @@ void sanity_blast(monster_type *m_ptr, bool necro)
 
                get_mon_num_prep(NULL, NULL);
 
-               /* Describe it */
 #ifndef JP
                if (!(r_ptr->flags1 & RF1_UNIQUE))
                        sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
@@ -2301,7 +2239,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(MONSTER_IDX m_idx, bool full)
+void update_monster(MONSTER_IDX m_idx, bool full)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -2534,7 +2472,6 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                                /* Handle "cold blooded" monsters */
                                if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
                                {
-                                       /* Take note */
                                        do_cold_blood = TRUE;
                                }
 
@@ -2552,7 +2489,6 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                                /* Handle "invisible" monsters */
                                if (r_ptr->flags2 & (RF2_INVISIBLE))
                                {
-                                       /* Take note */
                                        do_invisible = TRUE;
 
                                        /* See invisible */
@@ -2620,7 +2556,7 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                        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);
+                                       disturb(TRUE, TRUE);
                        }
                }
        }
@@ -2645,7 +2581,7 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                        if (do_disturb)
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(1, 1);
+                                       disturb(TRUE, TRUE);
                        }
                }
        }
@@ -2664,7 +2600,7 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                        if (do_disturb)
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(1, 1);
+                                       disturb(TRUE, TRUE);
                        }
                }
        }
@@ -2682,7 +2618,7 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                        if (do_disturb)
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(1, 1);
+                                       disturb(TRUE, TRUE);
                        }
                }
        }
@@ -2705,9 +2641,7 @@ void update_monsters(bool full)
 
                /* Skip dead monsters */
                if (!m_ptr->r_idx) continue;
-
-               /* Update the monster */
-               update_mon(i, full);
+               update_monster(i, full);
        }
 }
 
@@ -2797,7 +2731,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
        int oldmaxhp;
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr;
-       char old_m_name[80];
+       char old_m_name[MAX_NLEN];
        bool old_unique = FALSE;
        int old_r_idx = m_ptr->r_idx;
 
@@ -2810,7 +2744,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 
        if (!r_idx)
        {
-               int level;
+               DEPTH level;
 
                chameleon_change_m_idx = m_idx;
                if (old_unique)
@@ -2840,7 +2774,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 
        m_ptr->r_idx = r_idx;
        m_ptr->ap_r_idx = r_idx;
-       update_mon(m_idx, FALSE);
+       update_monster(m_idx, FALSE);
        lite_spot(m_ptr->fy, m_ptr->fx);
 
        if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
@@ -2863,7 +2797,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 
        if (m_idx == p_ptr->riding)
        {
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
                monster_desc(m_name, m_ptr, 0);
                msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
                if (!(r_ptr->flags7 & RF7_RIDING))
@@ -2988,10 +2922,10 @@ byte get_mspeed(monster_race *r_ptr)
  *
  * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
  *
- * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
+ * Use special "here" and "dead" flags for unique monsters,
  * remove old "cur_num" and "max_num" fields.
  *
- * XXX XXX XXX Actually, do something similar for artifacts, to simplify
+ * Actually, do something similar for artifacts, to simplify
  * the "preserve" mode, and to make the "what artifacts" flag more useful.
  *
  * This is the only function which may place a monster in the dungeon,
@@ -3099,7 +3033,6 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                        c_ptr->info &= ~(CAVE_OBJECT);
                        c_ptr->mimic = 0;
 
-                       /* Notice */
                        note_spot(y, x);
                }
                else return FALSE;
@@ -3287,9 +3220,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 the monster */
-       update_mon(c_ptr->m_idx, TRUE);
+       update_monster(c_ptr->m_idx, TRUE);
 
 
        /* Count the monsters on the level */
@@ -3319,7 +3250,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                {
                        cptr color;
                        object_type *o_ptr;
-                       char o_name[MAX_NLEN];
+                       GAME_TEXT o_name[MAX_NLEN];
 
                        if (r_ptr->level > p_ptr->lev + 30)
                                color = _("黒く", "black");
@@ -3463,8 +3394,6 @@ static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION
        return TRUE;
 }
 
-#define GROUP_MAX 32 /*!< place_monster_group() 関数によるモンスターのGROUP生成時の配置最大数 / Maximum size of a group of monsters */
-
 /*!
  * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location
  * @param who 召喚主のモンスター情報ID
@@ -3474,7 +3403,7 @@ static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION
  * @param mode 生成オプション
  * @return 成功したらtrue
  */
-static bool place_monster_group(IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
+static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -3560,14 +3489,14 @@ static bool place_monster_group(IDX who, POSITION y, POSITION x, MONRACE_IDX r_i
  * @brief 護衛対象となるモンスター種族IDを渡すグローバル変数 / Hack -- help pick an escort type
  * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_idxを除去し、関数引数化する
  */
-static IDX place_monster_idx = 0;
+static MONSTER_IDX place_monster_idx = 0;
 
 /*!
  * @var place_monster_m_idx
  * @brief 護衛対象となるモンスターIDを渡すグローバル変数 / Hack -- help pick an escort type
  * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_m_idxを除去し、関数引数化する
  */
-static IDX place_monster_m_idx = 0;
+static MONSTER_IDX place_monster_m_idx = 0;
 
 /*!
  * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type
@@ -3607,7 +3536,6 @@ static bool place_monster_can_escort(MONRACE_IDX r_idx)
        if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
                return FALSE;
 
-       /* Okay */
        return (TRUE);
 }
 
@@ -3653,7 +3581,7 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
        place_monster_m_idx = hack_m_idx_ii;
 
        /* Reinforcement */
-       for(i = 0; i < 6; i++)
+       for(i = 0; i < A_MAX; i++)
        {
                if(!r_ptr->reinforce_id[i]) break;
                n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
@@ -3739,13 +3667,9 @@ bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
        /* Attempt to place the monster */
        if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
 
-       /* Oops */
        return (FALSE);
 }
 
-
-#ifdef MONSTER_HORDES
-
 /*!
  * @brief 指定地点に1種類のモンスター種族による群れを生成する
  * @param y 生成地点y座標
@@ -3794,24 +3718,21 @@ bool alloc_horde(POSITION y, POSITION x)
        m_idx = cave[y][x].m_idx;
 
        if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
-       summon_kin_type = r_ptr->d_char;
 
        for (attempts = randint1(10) + 5; attempts; attempts--)
        {
                scatter(&cy, &cx, y, x, 5, 0);
 
-               (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
+               (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
 
                y = cy;
                x = cx;
        }
 
+       if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), r_ptr->d_char);
        return TRUE;
 }
 
-#endif /* MONSTER_HORDES */
-
-
 /*!
  * @brief ダンジョンの主生成を試みる / Put the Guardian
  * @param def_val 現在の主の生成状態
@@ -3862,10 +3783,10 @@ bool alloc_guardian(bool def_val)
  * Use "slp" to choose the initial "sleep" status
  * Use "monster_level" for the monster level
  */
-bool alloc_monster(int dis, BIT_FLAGS mode)
+bool alloc_monster(POSITION dis, BIT_FLAGS mode)
 {
-       int                     y = 0, x = 0;
-       int         attempts_left = 10000;
+       int y = 0, x = 0;
+       int attempts_left = 10000;
 
        /* Put the Guardian */
        if (alloc_guardian(FALSE)) return TRUE;
@@ -3902,27 +3823,19 @@ bool alloc_monster(int dis, BIT_FLAGS mode)
        }
 
 
-#ifdef MONSTER_HORDES
        if (randint1(5000) <= dun_level)
        {
                if (alloc_horde(y, x))
                {
-                       if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), summon_kin_type);
                        return (TRUE);
                }
        }
        else
        {
-#endif /* MONSTER_HORDES */
-
                /* Attempt to place the monster, allow groups */
                if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
-
-#ifdef MONSTER_HORDES
        }
-#endif /* MONSTER_HORDES */
 
-       /* Nope */
        return (FALSE);
 }
 
@@ -4006,7 +3919,7 @@ 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)
+bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol)
 {
        POSITION x, y;
        MONRACE_IDX r_idx;
@@ -4021,6 +3934,8 @@ 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;
 
        /* Prepare allocation table */
@@ -4047,6 +3962,7 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
 
        summon_specific_type = 0;
        /* Success */
+       sound(SOUND_SUMMON);
        return (TRUE);
 }
 
@@ -4060,7 +3976,7 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
  * @param mode 生成オプション 
  * @return 召喚できたらtrueを返す
  */
-bool summon_named_creature (MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
+bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
        POSITION x, y;
 
@@ -4125,15 +4041,15 @@ bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
  */
 void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
 {
-       long oldhp, newhp, tmp;
-       int percentage;
+       HIT_POINT oldhp, newhp;
+       HIT_POINT tmp;
+       PERCENTAGE percentage;
 
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       char m_name[80];
+       GAME_TEXT m_name[MAX_NLEN];
 
-       /* Get the monster name */
        monster_desc(m_name, m_ptr, 0);
 
        if(dam == 0) // Notice non-damage
@@ -4143,10 +4059,10 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
        }
 
        /* Note -- subtle fix -CFT */
-       newhp = (long)(m_ptr->hp);
-       oldhp = newhp + (long)(dam);
+       newhp = m_ptr->hp;
+       oldhp = newhp + dam;
        tmp = (newhp * 100L) / oldhp;
-       percentage = (int)(tmp);
+       percentage = tmp;
 
        if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
        {
@@ -4454,10 +4370,8 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
 void update_smart_learn(MONSTER_IDX m_idx, int what)
 {
        monster_type *m_ptr = &m_list[m_idx];
-
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-
        /* Not allowed to learn */
        if (!smart_learn) return;
 
@@ -4467,9 +4381,6 @@ void update_smart_learn(MONSTER_IDX m_idx, int what)
        /* Not intelligent, only learn sometimes */
        if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
 
-
-       /* XXX XXX XXX */
-
        /* Analyze the knowledge */
        switch (what)
        {
@@ -4589,7 +4500,7 @@ bool player_place(POSITION y, POSITION x)
  */
 void monster_drop_carried_objects(monster_type *m_ptr)
 {
-       s16b this_o_idx, next_o_idx = 0;
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
        object_type forge;
        object_type *o_ptr;
        object_type *q_ptr;
@@ -4598,13 +4509,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)
        {
-               /* Acquire object */
                o_ptr = &o_list[this_o_idx];
 
                /* Acquire next object */
                next_o_idx = o_ptr->next_o_idx;
-
-               /* Get local object */
                q_ptr = &forge;
 
                /* Copy the object */
@@ -4613,7 +4521,6 @@ void monster_drop_carried_objects(monster_type *m_ptr)
                /* Forget monster */
                q_ptr->held_m_idx = 0;
 
-               /* Delete the object */
                delete_object_idx(this_o_idx);
 
                /* Drop it */