OSDN Git Service

[Refactor] #37353 グローバル変数 dungeon_type を他の慣例に従い dungeon_idx に改名。 / Rename dungeon_typ...
[hengband/hengband.git] / src / monster1.c
index e5b7caf..e15f389 100644 (file)
  */
 
 #include "angband.h"
+#include "cmd-pet.h"
+#include "monsterrace-hook.h"
+#include "objectkind-hook.h"
+#include "projection.h"
+#include "monster.h"
+#include "spells-summon.h"
+#include "quest.h"
+#include "artifact.h"
+#include "avatar.h"
 
 
 /*
  * Pronoun arrays, by gender.
  */
-static cptr wd_he[3] =
+static concptr wd_he[3] =
 #ifdef JP
 { "それ", "彼", "彼女" };
 #else
 { "it", "he", "she" };
 #endif
 
-static cptr wd_his[3] =
+static concptr wd_his[3] =
 #ifdef JP
 { "それの", "彼の", "彼女の" };
 #else
@@ -47,13 +56,11 @@ static cptr wd_his[3] =
  * @details
  * The higher the level, the fewer kills needed.
  */
-static bool know_armour(IDX r_idx)
+static bool know_armour(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
-
-       s32b level = r_ptr->level;
-
-       s32b kills = r_ptr->r_tkills;
+       DEPTH level = r_ptr->level;
+       MONSTER_NUMBER kills = r_ptr->r_tkills;
 
     bool known = (r_ptr->r_cast_spell == MAX_UCHAR)? TRUE: FALSE;
 
@@ -85,11 +92,11 @@ static bool know_armour(IDX r_idx)
  * the more damage an attack does, the more attacks you need
  * </pre>
  */
-static bool know_damage(IDX r_idx, int i)
+static bool know_damage(MONRACE_IDX r_idx, int i)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
-       s32b level = r_ptr->level;
+       DEPTH level = r_ptr->level;
 
        s32b a = r_ptr->r_blows[i];
 
@@ -117,14 +124,14 @@ static bool know_damage(IDX r_idx, int i)
 /*
  * Prepare hook for c_roff(). It will be changed for spoiler generation in wizard1.c.
  */
-void (*hook_c_roff)(byte attr, cptr str) = c_roff;
+void (*hook_c_roff)(TERM_COLOR attr, concptr str) = c_roff;
 
 /*!
  * @brief モンスターの思い出メッセージをあらかじめ指定された関数ポインタに基づき出力する
  * @param str 出力文字列
  * @return なし
  */
-static void hooked_roff(cptr str)
+static void hooked_roff(concptr str)
 {
        /* Spawn */
        hook_c_roff(TERM_WHITE, str);
@@ -142,31 +149,31 @@ static void hooked_roff(cptr str)
 */
 void dice_to_string(int base_damage, int dice_num, int dice_side, int dice_mult, int dice_div, char* msg)
 {
-    char base[80] = "", dice[80] = "", mult[80]="";
+       char base[80] = "", dice[80] = "", mult[80] = "";
 
-    if (dice_num == 0)
-    {
-        sprintf(msg, "%d", base_damage);
-    }
-    else
-    {
-        if (base_damage != 0)
-            sprintf(base, "%d+", base_damage);
-
-        if (dice_num == 1)
-            sprintf(dice, "d%d", dice_side);
-        else
-            sprintf(dice, "%dd%d", dice_num, dice_side);
-
-        if (dice_mult != 1 || dice_div != 1)
-        {
-            if (dice_div == 1)
-                sprintf(mult, "*%d", dice_mult);
-            else
-                sprintf(mult, "*(%d/%d)", dice_mult, dice_div);
-        }
-        sprintf(msg, "%s%s%s", base, dice, mult);
-    }
+       if (dice_num == 0)
+       {
+               sprintf(msg, "%d", base_damage);
+       }
+       else
+       {
+               if (base_damage != 0)
+                       sprintf(base, "%d+", base_damage);
+
+               if (dice_num == 1)
+                       sprintf(dice, "d%d", dice_side);
+               else
+                       sprintf(dice, "%dd%d", dice_num, dice_side);
+
+               if (dice_mult != 1 || dice_div != 1)
+               {
+                       if (dice_div == 1)
+                               sprintf(mult, "*%d", dice_mult);
+                       else
+                               sprintf(mult, "*(%d/%d)", dice_mult, dice_div);
+               }
+               sprintf(msg, "%s%s%s", base, dice, mult);
+       }
 }
 
 /*!
@@ -177,21 +184,21 @@ void dice_to_string(int base_damage, int dice_num, int dice_side, int dice_mult,
 * @param tmp 返すメッセージを格納する配列
 * @return なし
 */
-void set_damage(IDX r_idx, int SPELL_NUM, char* msg, char* tmp)
+void set_damage(MONRACE_IDX r_idx, int SPELL_NUM, char* msg, char* tmp)
 {
-    int base_damage = monspell_race_damage(SPELL_NUM, r_idx, BASE_DAM);
-    int dice_num = monspell_race_damage(SPELL_NUM, r_idx, DICE_NUM);
-    int dice_side = monspell_race_damage(SPELL_NUM, r_idx, DICE_SIDE);
-    int dice_mult = monspell_race_damage(SPELL_NUM, r_idx, DICE_MULT);
-    int dice_div = monspell_race_damage(SPELL_NUM, r_idx, DICE_DIV);
-    char dmg_str[80], dice_str[80];
-    dice_to_string(base_damage, dice_num, dice_side, dice_mult, dice_div, dmg_str);
-    sprintf(dice_str, "(%s)", dmg_str);
-
-    if (know_armour(r_idx))
-        sprintf(tmp, msg, dice_str);
-    else
-        sprintf(tmp, msg, "");
+       int base_damage = monspell_race_damage(SPELL_NUM, r_idx, BASE_DAM);
+       int dice_num = monspell_race_damage(SPELL_NUM, r_idx, DICE_NUM);
+       int dice_side = monspell_race_damage(SPELL_NUM, r_idx, DICE_SIDE);
+       int dice_mult = monspell_race_damage(SPELL_NUM, r_idx, DICE_MULT);
+       int dice_div = monspell_race_damage(SPELL_NUM, r_idx, DICE_DIV);
+       char dmg_str[80], dice_str[80];
+       dice_to_string(base_damage, dice_num, dice_side, dice_mult, dice_div, dmg_str);
+       sprintf(dice_str, "(%s)", dmg_str);
+
+       if (know_armour(r_idx))
+               sprintf(tmp, msg, dice_str);
+       else
+               sprintf(tmp, msg, "");
 }
 
 /*!
@@ -205,15 +212,12 @@ void set_damage(IDX r_idx, int SPELL_NUM, char* msg, char* tmp)
  * left edge of the screen, on a cleared line, in which the recall is
  * to take place.  One extra blank line is left after the recall.
  */
-static void roff_aux(IDX r_idx, int mode)
+static void roff_aux(MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
        monster_race    *r_ptr = &r_info[r_idx];
-
        bool            old = FALSE;
-
        int             m, n, r;
-
-       cptr            p, q;
+       concptr            p, q;
 
 #ifdef JP
        char            jverb_buf[64];
@@ -223,26 +227,26 @@ static void roff_aux(IDX r_idx, int mode)
        int             msex = 0;
 
        bool nightmare = ironman_nightmare && !(mode & 0x02);
-       int speed = nightmare ? r_ptr->speed + 5 : r_ptr->speed;
+       SPEED speed = nightmare ? r_ptr->speed + 5 : r_ptr->speed;
 
        bool            breath = FALSE;
        bool            magic = FALSE;
        bool            reinforce = FALSE;
 
-       u32b            flags1;
-       u32b            flags2;
-       u32b            flags3;
-       u32b            flags4;
-       u32b            a_ability_flags1;
-       u32b            a_ability_flags2;
-       u32b            flags7;
-       u32b            flagsr;
+       BIT_FLAGS flags1;
+       BIT_FLAGS flags2;
+       BIT_FLAGS flags3;
+       BIT_FLAGS flags4;
+       BIT_FLAGS a_ability_flags1;
+       BIT_FLAGS a_ability_flags2;
+       BIT_FLAGS flags7;
+       BIT_FLAGS flagsr;
 
-       byte drop_gold, drop_item;
+       ITEM_NUMBER drop_gold, drop_item;
 
        int             vn = 0;
        byte            color[96];
-       cptr            vp[96];
+       concptr         vp[96];
        char tmp_msg[96][96];
 
        bool know_everything = FALSE;
@@ -261,7 +265,7 @@ static void roff_aux(IDX r_idx, int mode)
        flags7 = (r_ptr->flags7 & r_ptr->flags7);
        flagsr = (r_ptr->flagsr & r_ptr->r_flagsr);
 
-       for(n = 0; n < 6; n++)
+       for(n = 0; n < A_MAX; n++)
        {
                if(r_ptr->reinforce_id[n] > 0) reinforce = TRUE;
        }
@@ -453,7 +457,7 @@ static void roff_aux(IDX r_idx, int mode)
 
        /* Descriptions */
        {
-               cptr tmp = r_text + r_ptr->text;
+               concptr tmp = r_text + r_ptr->text;
 
                if (tmp[0])
                {
@@ -586,8 +590,6 @@ static void roff_aux(IDX r_idx, int mode)
                        hooked_roff(format(_("%^sは", "%^s "), wd_he[msex]));
                        old = TRUE;
                }
-
-               /* Describe */
                hooked_roff(_("侵入者を追跡しない", "does not deign to chase intruders"));
        }
 
@@ -625,7 +627,7 @@ static void roff_aux(IDX r_idx, int mode)
                if (flags3 & RF3_UNDEAD)          hook_c_roff(TERM_VIOLET, _("アンデッドの", " undead"));
                if (flags3 & RF3_AMBERITE)        hook_c_roff(TERM_VIOLET, _("アンバーの王族の", " Amberite"));
 
-               if ((flags3 & (RF3_DRAGON | RF3_DEMON | RF3_GIANT | RF3_TROLL | RF3_ORC)) || (flags2 & (RF2_QUANTUM | RF2_HUMAN)))
+               if ((flags3 & (RF3_DRAGON | RF3_DEMON | RF3_GIANT | RF3_TROLL | RF3_ORC | RF3_ANGEL)) || (flags2 & (RF2_QUANTUM | RF2_HUMAN)))
                {
                /* Describe the "race" */
                        if (flags3 & RF3_DRAGON)   hook_c_roff(TERM_ORANGE, _("ドラゴン", " dragon"));
@@ -635,6 +637,7 @@ static void roff_aux(IDX r_idx, int mode)
                        if (flags3 & RF3_ORC)      hook_c_roff(TERM_UMBER, _("オーク", " orc"));
                        if (flags2 & RF2_HUMAN)    hook_c_roff(TERM_L_WHITE, _("人間", " human"));
                        if (flags2 & RF2_QUANTUM)  hook_c_roff(TERM_VIOLET, _("量子生物", " quantum creature"));
+                       if (flags3 & RF3_ANGEL)    hook_c_roff(TERM_YELLOW, _("天使", " angel"));
                }
                else
                {
@@ -648,29 +651,23 @@ static void roff_aux(IDX r_idx, int mode)
                {
                        long i, j;
 
-#ifdef JP
-                       i = p_ptr->lev;
-                       hooked_roff(format(" %lu レベルのキャラクタにとって", (long)i));
-
-                       i = (long)r_ptr->mexp * r_ptr->level / (p_ptr->max_plv+2);
-                       j = ((((long)r_ptr->mexp * r_ptr->level % (p_ptr->max_plv+2)) *
-                              (long)1000 / (p_ptr->max_plv+2) + 5) / 10);
-
-                       hooked_roff(format(" 約%ld.%02ld ポイントの経験となる。",
-                               (long)i, (long)j ));
-#else
                        /* calculate the integer exp part */
-                       i = (long)r_ptr->mexp * r_ptr->level / (p_ptr->max_plv+2);
+                       i = (long)r_ptr->mexp * r_ptr->level / (p_ptr->max_plv + 2) * 3 / 2;
 
                        /* calculate the fractional exp part scaled by 100, */
                        /* must use long arithmetic to avoid overflow  */
-                       j = ((((long)r_ptr->mexp * r_ptr->level % (p_ptr->max_plv+2)) *
-                              (long)1000 / (p_ptr->max_plv+2) + 5) / 10);
+                       j = ((((long)r_ptr->mexp * r_ptr->level % (p_ptr->max_plv + 2) * 3 / 2) *
+                               (long)1000 / (p_ptr->max_plv + 2) + 5) / 10);
+
+#ifdef JP
+                       hooked_roff(format(" %d レベルのキャラクタにとって 約%ld.%02ld ポイントの経験となる。",
+                               p_ptr->lev, (long)i, (long)j ));
+#else
 
                        /* Mention the experience */
-                       hooked_roff(format(" is worth about %ld.%02ld point%s",
-                                   (long)i, (long)j,
-                                   (((i == 1) && (j == 0)) ? "" : "s")));
+                       hooked_roff(format(" is worth about %ld.%02ld point%s for level %d player",
+                               (long)i, (long)j,
+                               (((i == 1) && (j == 0)) ? "" : "s")), p_ptr->lev);
 
                        /* Take account of annoying English */
                        p = "th";
@@ -748,7 +745,7 @@ static void roff_aux(IDX r_idx, int mode)
 #ifndef JP
                        hooked_roff(" contain ");
 #endif                 
-                       for(n = 0; n < 6; n++)
+                       for(n = 0; n < A_MAX; n++)
                        {
                                if(r_ptr->reinforce_id[n] && r_ptr->reinforce_dd[n] && r_ptr->reinforce_ds[n])
                                {
@@ -760,11 +757,10 @@ static void roff_aux(IDX r_idx, int mode)
                                        else
                                        {
 #ifdef JP
-                                               hooked_roff(format("、 %dd%d 体の%s", r_ptr->reinforce_dd[n], r_ptr->reinforce_ds[n],
-                                                       r_name + rf_ptr->name));
+                                               hooked_roff(format("、 %dd%d 体の%s", r_ptr->reinforce_dd[n], r_ptr->reinforce_ds[n], r_name + rf_ptr->name));
 #else
                                                bool plural = (r_ptr->reinforce_dd[n] * r_ptr->reinforce_ds[n] > 1);
-                                               char name[80];
+                                               GAME_TEXT name[MAX_NLEN];
                                                strcpy(name, r_name + rf_ptr->name);
                                                if(plural) plural_aux(name);
                                                hooked_roff(format(",%dd%d %s", r_ptr->reinforce_dd[n], r_ptr->reinforce_ds[n], name));
@@ -794,16 +790,16 @@ static void roff_aux(IDX r_idx, int mode)
     }
     
        if (flags4 & RF4_SHOOT)
-       { 
+       {
                for (r = 0, m = 0; m < 4; m++)
                {
                        if (r_ptr->blow[m].method == RBM_SHOOT)
-            {
-                if (know_armour(r_idx))
-                                   sprintf(tmp_msg[vn], _("威力 %dd%d の射撃をする","fire an arrow (Power:%dd%d)"), r_ptr->blow[m].d_side, r_ptr->blow[m].d_dice);
-                else
-                    sprintf(tmp_msg[vn], _("射撃をする", "fire an arrow"));
-                vp[vn] = tmp_msg[vn]; color[vn++] = TERM_UMBER;
+                       {
+                               if (know_armour(r_idx))
+                                       sprintf(tmp_msg[vn], _("威力 %dd%d の射撃をする", "fire an arrow (Power:%dd%d)"), r_ptr->blow[m].d_side, r_ptr->blow[m].d_dice);
+                               else
+                                       sprintf(tmp_msg[vn], _("射撃をする", "fire an arrow"));
+                               vp[vn] = tmp_msg[vn]; color[vn++] = TERM_UMBER;
                                break;
                        }
                }               
@@ -848,137 +844,137 @@ static void roff_aux(IDX r_idx, int mode)
 
        /* Collect breaths */
        vn = 0;
-       if (flags4 & (RF4_BR_ACID))             
-       { 
+       if (flags4 & (RF4_BR_ACID))
+       {
                set_damage(r_idx, (MS_BR_ACID), _("酸%s", "acid%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_GREEN; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_GREEN;
        }
-       if (flags4 & (RF4_BR_ELEC))             
-       { 
+       if (flags4 & (RF4_BR_ELEC))
+       {
                set_damage(r_idx, (MS_BR_ELEC), _("稲妻%s", "lightning%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_BLUE; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_BLUE;
        }
-       if (flags4 & (RF4_BR_FIRE))             
-       { 
+       if (flags4 & (RF4_BR_FIRE))
+       {
                set_damage(r_idx, (MS_BR_FIRE), _("火炎%s", "fire%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_RED; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_RED;
        }
-       if (flags4 & (RF4_BR_COLD))             
-       { 
+       if (flags4 & (RF4_BR_COLD))
+       {
                set_damage(r_idx, (MS_BR_COLD), _("冷気%s", "frost%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_WHITE; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_WHITE;
        }
-       if (flags4 & (RF4_BR_POIS))             
-       { 
+       if (flags4 & (RF4_BR_POIS))
+       {
                set_damage(r_idx, (MS_BR_POIS), _("毒%s", "poison%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_GREEN; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_GREEN;
        }
        if (flags4 & (RF4_BR_NETH))
-       { 
+       {
                set_damage(r_idx, (MS_BR_NETHER), _("地獄%s", "nether%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_DARK; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_DARK;
        }
-       if (flags4 & (RF4_BR_LITE))             
-       { 
+       if (flags4 & (RF4_BR_LITE))
+       {
                set_damage(r_idx, (MS_BR_LITE), _("閃光%s", "light%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_YELLOW; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_YELLOW;
        }
-       if (flags4 & (RF4_BR_DARK))             
-       { 
+       if (flags4 & (RF4_BR_DARK))
+       {
                set_damage(r_idx, (MS_BR_DARK), _("暗黒%s", "darkness%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_DARK; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_DARK;
        }
        if (flags4 & (RF4_BR_CONF))
-       { 
+       {
                set_damage(r_idx, (MS_BR_CONF), _("混乱%s", "confusion%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_UMBER; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_UMBER;
        }
-       if (flags4 & (RF4_BR_SOUN))             
+       if (flags4 & (RF4_BR_SOUN))
        {
                set_damage(r_idx, (MS_BR_SOUND), _("轟音%s", "sound%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_ORANGE; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_ORANGE;
        }
-       if (flags4 & (RF4_BR_CHAO))             
-       { 
+       if (flags4 & (RF4_BR_CHAO))
+       {
                set_damage(r_idx, (MS_BR_CHAOS), _("カオス%s", "chaos%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_VIOLET; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_VIOLET;
        }
-       if (flags4 & (RF4_BR_DISE))             
-       { 
+       if (flags4 & (RF4_BR_DISE))
+       {
                set_damage(r_idx, (MS_BR_DISEN), _("劣化%s", "disenchantment%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_VIOLET; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_VIOLET;
        }
-       if (flags4 & (RF4_BR_NEXU))             
-       { 
+       if (flags4 & (RF4_BR_NEXU))
+       {
                set_damage(r_idx, (MS_BR_NEXUS), _("因果混乱%s", "nexus%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_VIOLET; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_VIOLET;
        }
-       if (flags4 & (RF4_BR_TIME))             
-       { 
+       if (flags4 & (RF4_BR_TIME))
+       {
                set_damage(r_idx, (MS_BR_TIME), _("時間逆転%s", "time%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_BLUE; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_BLUE;
        }
-       if (flags4 & (RF4_BR_INER))             
-       { 
+       if (flags4 & (RF4_BR_INER))
+       {
                set_damage(r_idx, (MS_BR_INERTIA), _("遅鈍%s", "inertia%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_SLATE; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_SLATE;
        }
-       if (flags4 & (RF4_BR_GRAV))             
-       { 
+       if (flags4 & (RF4_BR_GRAV))
+       {
                set_damage(r_idx, (MS_BR_GRAVITY), _("重力%s", "gravity%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_SLATE; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_SLATE;
        }
-       if (flags4 & (RF4_BR_SHAR))             
-       { 
+       if (flags4 & (RF4_BR_SHAR))
+       {
                set_damage(r_idx, (MS_BR_SHARDS), _("破片%s", "shards%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_UMBER; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_UMBER;
        }
-       if (flags4 & (RF4_BR_PLAS))             
-       { 
+       if (flags4 & (RF4_BR_PLAS))
+       {
                set_damage(r_idx, (MS_BR_PLASMA), _("プラズマ%s", "plasma%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_RED; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_RED;
        }
-       if (flags4 & (RF4_BR_WALL))             
-       { 
+       if (flags4 & (RF4_BR_WALL))
+       {
                set_damage(r_idx, (MS_BR_FORCE), _("フォース%s", "force%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_UMBER; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_UMBER;
        }
-       if (flags4 & (RF4_BR_MANA))             
-       { 
+       if (flags4 & (RF4_BR_MANA))
+       {
                set_damage(r_idx, (MS_BR_MANA), _("魔力%s", "mana%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_BLUE; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_BLUE;
        }
-       if (flags4 & (RF4_BR_NUKE))             
-       { 
+       if (flags4 & (RF4_BR_NUKE))
+       {
                set_damage(r_idx, (MS_BR_NUKE), _("放射性廃棄物%s", "toxic waste%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_L_GREEN; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_L_GREEN;
        }
-       if (flags4 & (RF4_BR_DISI))             
-       { 
+       if (flags4 & (RF4_BR_DISI))
+       {
                set_damage(r_idx, (MS_BR_DISI), _("分解%s", "disintegration%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
-               color[vn++] = TERM_SLATE; 
+               vp[vn] = tmp_msg[vn];
+               color[vn++] = TERM_SLATE;
        }
 
        /* Describe breaths */
@@ -1014,189 +1010,189 @@ static void roff_aux(IDX r_idx, int mode)
 
        /* Collect spells */
        vn = 0;
-       if (a_ability_flags1 & (RF5_BA_ACID))         
+       if (a_ability_flags1 & (RF5_BA_ACID))
        {
                set_damage(r_idx, (MS_BALL_ACID), _("アシッド・ボール%s", "produce acid balls%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_GREEN;
        }
-       if (a_ability_flags1 & (RF5_BA_ELEC))         
+       if (a_ability_flags1 & (RF5_BA_ELEC))
        {
                set_damage(r_idx, (MS_BALL_ELEC), _("サンダー・ボール%s", "produce lightning balls%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_BLUE;
        }
-       if (a_ability_flags1 & (RF5_BA_FIRE))         
+       if (a_ability_flags1 & (RF5_BA_FIRE))
        {
                set_damage(r_idx, (MS_BALL_FIRE), _("ファイア・ボール%s", "produce fire balls%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_RED;
        }
-       if (a_ability_flags1 & (RF5_BA_COLD))         
+       if (a_ability_flags1 & (RF5_BA_COLD))
        {
                set_damage(r_idx, (MS_BALL_COLD), _("アイス・ボール%s", "produce frost balls%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_WHITE;
        }
-       if (a_ability_flags1 & (RF5_BA_POIS))         
+       if (a_ability_flags1 & (RF5_BA_POIS))
        {
                set_damage(r_idx, (MS_BALL_POIS), _("悪臭雲%s", "produce poison balls%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_GREEN;
        }
-       if (a_ability_flags1 & (RF5_BA_NETH))         
+       if (a_ability_flags1 & (RF5_BA_NETH))
        {
                set_damage(r_idx, (MS_BALL_NETHER), _("地獄球%s", "produce nether balls%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_DARK;
        }
-       if (a_ability_flags1 & (RF5_BA_WATE))         
+       if (a_ability_flags1 & (RF5_BA_WATE))
        {
                set_damage(r_idx, (MS_BALL_WATER), _("ウォーター・ボール%s", "produce water balls%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_BLUE;
        }
-       if (flags4 & (RF4_BA_NUKE))         
+       if (flags4 & (RF4_BA_NUKE))
        {
                set_damage(r_idx, (MS_BALL_NUKE), _("放射能球%s", "produce balls of radiation%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_GREEN;
        }
-       if (a_ability_flags1 & (RF5_BA_MANA))         
+       if (a_ability_flags1 & (RF5_BA_MANA))
        {
                set_damage(r_idx, (MS_BALL_MANA), _("魔力の嵐%s", "invoke mana storms%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_BLUE;
        }
-       if (a_ability_flags1 & (RF5_BA_DARK))         
+       if (a_ability_flags1 & (RF5_BA_DARK))
        {
                set_damage(r_idx, (MS_BALL_DARK), _("暗黒の嵐%s", "invoke darkness storms%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_DARK;
        }
-       if (a_ability_flags1 & (RF5_BA_LITE))         
+       if (a_ability_flags1 & (RF5_BA_LITE))
        {
                set_damage(r_idx, (MS_STARBURST), _("スターバースト%s", "invoke starburst%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_YELLOW;
        }
-       if (flags4 & (RF4_BA_CHAO))         
+       if (flags4 & (RF4_BA_CHAO))
        {
                set_damage(r_idx, (MS_BALL_CHAOS), _("純ログルス%s", "invoke raw Logrus%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_VIOLET;
        }
-       if (a_ability_flags2 & (RF6_HAND_DOOM)){ vp[vn] = _("破滅の手(40%-60%)", "invoke the Hand of Doom(40%-60%)"); color[vn++] = TERM_VIOLET; }
+       if (a_ability_flags2 & (RF6_HAND_DOOM)) { vp[vn] = _("破滅の手(40%-60%)", "invoke the Hand of Doom(40%-60%)"); color[vn++] = TERM_VIOLET; }
        if (a_ability_flags2 & (RF6_PSY_SPEAR))
        {
                set_damage(r_idx, (MS_PSY_SPEAR), _("光の剣%s", "psycho-spear%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_YELLOW;
        }
        if (a_ability_flags1 & (RF5_DRAIN_MANA))
        {
                set_damage(r_idx, (MS_DRAIN_MANA), _("魔力吸収%s", "drain mana%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_SLATE;
        }
-       if (a_ability_flags1 & (RF5_MIND_BLAST))         
+       if (a_ability_flags1 & (RF5_MIND_BLAST))
        {
                set_damage(r_idx, (MS_MIND_BLAST), _("精神攻撃%s", "cause mind blasting%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_RED;
        }
-       if (a_ability_flags1 & (RF5_BRAIN_SMASH))         
+       if (a_ability_flags1 & (RF5_BRAIN_SMASH))
        {
                set_damage(r_idx, (MS_BRAIN_SMASH), _("脳攻撃%s", "cause brain smashing%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_RED;
        }
-       if (a_ability_flags1 & (RF5_CAUSE_1))         
+       if (a_ability_flags1 & (RF5_CAUSE_1))
        {
-               set_damage(r_idx, (MS_CAUSE_1), 
+               set_damage(r_idx, (MS_CAUSE_1),
                        _("軽傷+呪い%s", "cause light wounds and cursing%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_WHITE;
        }
-       if (a_ability_flags1 & (RF5_CAUSE_2))         
+       if (a_ability_flags1 & (RF5_CAUSE_2))
        {
-               set_damage(r_idx, (MS_CAUSE_2), 
+               set_damage(r_idx, (MS_CAUSE_2),
                        _("重傷+呪い%s", "cause serious wounds and cursing%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_WHITE;
        }
-       if (a_ability_flags1 & (RF5_CAUSE_3))         
+       if (a_ability_flags1 & (RF5_CAUSE_3))
        {
-               set_damage(r_idx, (MS_CAUSE_3), 
+               set_damage(r_idx, (MS_CAUSE_3),
                        _("致命傷+呪い%s", "cause critical wounds and cursing%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_WHITE;
        }
-       if (a_ability_flags1 & (RF5_CAUSE_4))         
+       if (a_ability_flags1 & (RF5_CAUSE_4))
        {
-               set_damage(r_idx, (MS_CAUSE_4), 
+               set_damage(r_idx, (MS_CAUSE_4),
                        _("秘孔を突く%s", "cause mortal wounds%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_WHITE;
        }
-       if (a_ability_flags1 & (RF5_BO_ACID))         
+       if (a_ability_flags1 & (RF5_BO_ACID))
        {
                set_damage(r_idx, (MS_BOLT_ACID), _("アシッド・ボルト%s", "produce acid bolts%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_GREEN;
        }
-       if (a_ability_flags1 & (RF5_BO_ELEC))         
+       if (a_ability_flags1 & (RF5_BO_ELEC))
        {
                set_damage(r_idx, (MS_BOLT_ELEC), _("サンダー・ボルト%s", "produce lightning bolts%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_BLUE;
        }
-       if (a_ability_flags1 & (RF5_BO_FIRE))         
+       if (a_ability_flags1 & (RF5_BO_FIRE))
        {
                set_damage(r_idx, (MS_BOLT_FIRE), _("ファイア・ボルト%s", "produce fire bolts%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_RED;
        }
-       if (a_ability_flags1 & (RF5_BO_COLD))         
+       if (a_ability_flags1 & (RF5_BO_COLD))
        {
                set_damage(r_idx, (MS_BOLT_COLD), _("アイス・ボルト%s", "produce frost bolts%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_WHITE;
        }
-       if (a_ability_flags1 & (RF5_BO_NETH))         
+       if (a_ability_flags1 & (RF5_BO_NETH))
        {
                set_damage(r_idx, (MS_BOLT_NETHER), _("地獄の矢%s", "produce nether bolts%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_DARK;
        }
-       if (a_ability_flags1 & (RF5_BO_WATE))         
+       if (a_ability_flags1 & (RF5_BO_WATE))
        {
                set_damage(r_idx, (MS_BOLT_WATER), _("ウォーター・ボルト%s", "produce water bolts%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_BLUE;
        }
-       if (a_ability_flags1 & (RF5_BO_MANA))         
+       if (a_ability_flags1 & (RF5_BO_MANA))
        {
                set_damage(r_idx, (MS_BOLT_MANA), _("魔力の矢%s", "produce mana bolts%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_BLUE;
        }
-       if (a_ability_flags1 & (RF5_BO_PLAS))         
+       if (a_ability_flags1 & (RF5_BO_PLAS))
        {
                set_damage(r_idx, (MS_BOLT_PLASMA), _("プラズマ・ボルト%s", "produce plasma bolts%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_L_RED;
        }
-       if (a_ability_flags1 & (RF5_BO_ICEE))         
+       if (a_ability_flags1 & (RF5_BO_ICEE))
        {
                set_damage(r_idx, (MS_BOLT_ICE), _("極寒の矢%s", "produce ice bolts%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_WHITE;
        }
-       if (a_ability_flags1 & (RF5_MISSILE))         
+       if (a_ability_flags1 & (RF5_MISSILE))
        {
                set_damage(r_idx, (MS_MAGIC_MISSILE), _("マジックミサイル%s", "produce magic missiles%s"), tmp_msg[vn]);
-        vp[vn] = tmp_msg[vn];
+               vp[vn] = tmp_msg[vn];
                color[vn++] = TERM_SLATE;
        }
        if (a_ability_flags1 & (RF5_SCARE))           { vp[vn] = _("恐怖", "terrify"); color[vn++] = TERM_SLATE; }
@@ -1601,7 +1597,7 @@ static void roff_aux(IDX r_idx, int mode)
                  (r_ptr->r_ignore == MAX_UCHAR) ||
            (r_ptr->sleep == 0 && r_ptr->r_tkills >= 10) || know_everything)
        {
-               cptr act;
+               concptr act;
 
                if (r_ptr->sleep > 200)
                {
@@ -1708,7 +1704,6 @@ static void roff_aux(IDX r_idx, int mode)
 #endif
                }
 
-               /* Okay */
                else
                {
                        p = NULL;
@@ -2001,11 +1996,11 @@ static void roff_aux(IDX r_idx, int mode)
  * @param r_idx モンスターの種族ID
  * @return なし
  */
-void roff_top(IDX r_idx)
+void roff_top(MONRACE_IDX r_idx)
 {
        monster_race    *r_ptr = &r_info[r_idx];
 
-       byte            a1, a2;
+       TERM_COLOR      a1, a2;
        char            c1, c2;
 
 
@@ -2048,7 +2043,7 @@ void roff_top(IDX r_idx)
        /* Wizards get extra info */
        if (p_ptr->wizard)
        {
-               char buf[6];
+               char buf[16];
 
                sprintf(buf, "%d", r_idx);
 
@@ -2067,10 +2062,9 @@ void roff_top(IDX r_idx)
  * @param mode 表示オプション
  * @return なし
  */
-void screen_roff(IDX r_idx, int mode)
+void screen_roff(MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
-       /* Flush messages */
-       msg_print(NULL);
+       msg_erase();
 
        /* Begin recall */
        Term_erase(0, 1, 255);
@@ -2093,7 +2087,7 @@ void screen_roff(IDX r_idx, int mode)
  * @param r_idx モンスターの種族ID
  * @return なし
  */
-void display_roff(IDX r_idx)
+void display_roff(MONRACE_IDX r_idx)
 {
        int y;
 
@@ -2124,7 +2118,7 @@ void display_roff(IDX r_idx)
  * @param roff_func 出力処理を行う関数ポインタ
  * @return なし
  */
-void output_monster_spoiler(IDX r_idx, void (*roff_func)(byte attr, cptr str))
+void output_monster_spoiler(MONRACE_IDX r_idx, void (*roff_func)(TERM_COLOR attr, concptr str))
 {
        hook_c_roff = roff_func;
 
@@ -2133,262 +2127,43 @@ void output_monster_spoiler(IDX r_idx, void (*roff_func)(byte attr, cptr str))
 }
 
 
-/*!
- * @brief モンスターがダンジョンに出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return ダンジョンに出現するならばTRUEを返す
- */
-bool mon_hook_dungeon(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (!(r_ptr->flags8 & RF8_WILD_ONLY))
-               return TRUE;
-       else
-       {
-               dungeon_info_type *d_ptr = &d_info[dungeon_type];
-               if ((d_ptr->mflags8 & RF8_WILD_MOUNTAIN) &&
-                   (r_ptr->flags8 & RF8_WILD_MOUNTAIN)) return TRUE;
-               return FALSE;
-       }
-}
-
-
-/*!
- * @brief モンスターが海洋に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 海洋に出現するならばTRUEを返す
- */
-static bool mon_hook_ocean(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (r_ptr->flags8 & RF8_WILD_OCEAN)
-               return TRUE;
-       else
-               return FALSE;
-}
-
-
-/*!
- * @brief モンスターが海岸に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 海岸に出現するならばTRUEを返す
- */
-static bool mon_hook_shore(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (r_ptr->flags8 & RF8_WILD_SHORE)
-               return TRUE;
-       else
-               return FALSE;
-}
-
-
-/*!
- * @brief モンスターが荒地に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 荒地に出現するならばTRUEを返す
- */
-static bool mon_hook_waste(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (r_ptr->flags8 & (RF8_WILD_WASTE | RF8_WILD_ALL))
-               return TRUE;
-       else
-               return FALSE;
-}
-
-
-/*!
- * @brief モンスターが町に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 荒地に出現するならばTRUEを返す
- */
-static bool mon_hook_town(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (r_ptr->flags8 & (RF8_WILD_TOWN | RF8_WILD_ALL))
-               return TRUE;
-       else
-               return FALSE;
-}
-
-
-/*!
- * @brief モンスターが森林に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 森林に出現するならばTRUEを返す
- */
-static bool mon_hook_wood(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (r_ptr->flags8 & (RF8_WILD_WOOD | RF8_WILD_ALL))
-               return TRUE;
-       else
-               return FALSE;
-}
-
-
-/*!
- * @brief モンスターが火山に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 火山に出現するならばTRUEを返す
- */
-static bool mon_hook_volcano(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (r_ptr->flags8 & RF8_WILD_VOLCANO)
-               return TRUE;
-       else
-               return FALSE;
-}
-
-/*!
- * @brief モンスターが山地に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 山地に出現するならばTRUEを返す
- */
-static bool mon_hook_mountain(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (r_ptr->flags8 & RF8_WILD_MOUNTAIN)
-               return TRUE;
-       else
-               return FALSE;
-}
-
-
-/*!
- * @brief モンスターが草原に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 森林に出現するならばTRUEを返す
- */
-static bool mon_hook_grass(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (r_ptr->flags8 & (RF8_WILD_GRASS | RF8_WILD_ALL))
-               return TRUE;
-       else
-               return FALSE;
-}
-
-/*!
- * @brief モンスターが深い水地形に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 深い水地形に出現するならばTRUEを返す
- */
-static bool mon_hook_deep_water(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (!mon_hook_dungeon(r_idx)) return FALSE;
-
-       if (r_ptr->flags7 & RF7_AQUATIC)
-               return TRUE;
-       else
-               return FALSE;
-}
-
-
-/*!
- * @brief モンスターが浅い水地形に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 浅い水地形に出現するならばTRUEを返す
- */
-static bool mon_hook_shallow_water(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (!mon_hook_dungeon(r_idx)) return FALSE;
-
-       if (r_ptr->flags2 & RF2_AURA_FIRE)
-               return FALSE;
-       else
-               return TRUE;
-}
-
-
-/*!
- * @brief モンスターが溶岩地形に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 溶岩地形に出現するならばTRUEを返す
- */
-static bool mon_hook_lava(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (!mon_hook_dungeon(r_idx)) return FALSE;
-
-       if (((r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK) ||
-            (r_ptr->flags7 & RF7_CAN_FLY)) &&
-           !(r_ptr->flags3 & RF3_AURA_COLD))
-               return TRUE;
-       else
-               return FALSE;
-}
-
-
-/*!
- * @brief モンスターが通常の床地形に出現するかどうかを返す
- * @param r_idx 判定するモンスターの種族ID
- * @return 通常の床地形に出現するならばTRUEを返す
- */
-static bool mon_hook_floor(IDX r_idx)
-{
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (!(r_ptr->flags7 & RF7_AQUATIC) ||
-           (r_ptr->flags7 & RF7_CAN_FLY))
-               return TRUE;
-       else
-               return FALSE;
-}
-
 
 /*!
  * @brief プレイヤーの現在の広域マップ座標から得た地勢を元にモンスターの生成条件関数を返す
  * @return 地勢にあったモンスターの生成条件関数
  */
-monster_hook_type get_monster_hook(void)
+monsterrace_hook_type get_monster_hook(void)
 {
        if (!dun_level && !p_ptr->inside_quest)
        {
                switch (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain)
                {
                case TERRAIN_TOWN:
-                       return (monster_hook_type)mon_hook_town;
+                       return (monsterrace_hook_type)mon_hook_town;
                case TERRAIN_DEEP_WATER:
-                       return (monster_hook_type)mon_hook_ocean;
+                       return (monsterrace_hook_type)mon_hook_ocean;
                case TERRAIN_SHALLOW_WATER:
                case TERRAIN_SWAMP:
-                       return (monster_hook_type)mon_hook_shore;
+                       return (monsterrace_hook_type)mon_hook_shore;
                case TERRAIN_DIRT:
                case TERRAIN_DESERT:
-                       return (monster_hook_type)mon_hook_waste;
+                       return (monsterrace_hook_type)mon_hook_waste;
                case TERRAIN_GRASS:
-                       return (monster_hook_type)mon_hook_grass;
+                       return (monsterrace_hook_type)mon_hook_grass;
                case TERRAIN_TREES:
-                       return (monster_hook_type)mon_hook_wood;
+                       return (monsterrace_hook_type)mon_hook_wood;
                case TERRAIN_SHALLOW_LAVA:
                case TERRAIN_DEEP_LAVA:
-                       return (monster_hook_type)mon_hook_volcano;
+                       return (monsterrace_hook_type)mon_hook_volcano;
                case TERRAIN_MOUNTAIN:
-                       return (monster_hook_type)mon_hook_mountain;
+                       return (monsterrace_hook_type)mon_hook_mountain;
                default:
-                       return (monster_hook_type)mon_hook_dungeon;
+                       return (monsterrace_hook_type)mon_hook_dungeon;
                }
        }
        else
        {
-               return (monster_hook_type)mon_hook_dungeon;
+               return (monsterrace_hook_type)mon_hook_dungeon;
        }
 }
 
@@ -2396,7 +2171,7 @@ monster_hook_type get_monster_hook(void)
  * @brief 指定された広域マップ座標の地勢を元にモンスターの生成条件関数を返す
  * @return 地勢にあったモンスターの生成条件関数
  */
-monster_hook_type get_monster_hook2(int y, int x)
+monsterrace_hook_type get_monster_hook2(POSITION y, POSITION x)
 {
        feature_type *f_ptr = &f_info[cave[y][x].feat];
 
@@ -2408,23 +2183,23 @@ monster_hook_type get_monster_hook2(int y, int x)
                /* Deep water */
                if (have_flag(f_ptr->flags, FF_DEEP))
                {
-                       return (monster_hook_type)mon_hook_deep_water;
+                       return (monsterrace_hook_type)mon_hook_deep_water;
                }
 
                /* Shallow water */
                else
                {
-                       return (monster_hook_type)mon_hook_shallow_water;
+                       return (monsterrace_hook_type)mon_hook_shallow_water;
                }
        }
 
        /* Lava */
        else if (have_flag(f_ptr->flags, FF_LAVA))
        {
-               return (monster_hook_type)mon_hook_lava;
+               return (monsterrace_hook_type)mon_hook_lava;
        }
 
-       else return (monster_hook_type)mon_hook_floor;
+       else return (monsterrace_hook_type)mon_hook_floor;
 }
 
 /*!
@@ -2482,7 +2257,7 @@ void anger_monster(monster_type *m_ptr)
        if (p_ptr->inside_battle) return;
        if (is_friendly(m_ptr))
        {
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
 
                monster_desc(m_name, m_ptr, 0);
                msg_format(_("%^sは怒った!", "%^s gets angry!"), m_name);
@@ -2505,11 +2280,10 @@ void anger_monster(monster_type *m_ptr)
  * @param mode オプション
  * @return 踏破可能ならばTRUEを返す
  */
-bool monster_can_cross_terrain(s16b feat, monster_race *r_ptr, u16b mode)
+bool monster_can_cross_terrain(FEAT_IDX feat, monster_race *r_ptr, BIT_FLAGS16 mode)
 {
        feature_type *f_ptr = &f_info[feat];
 
-       /* Pattern */
        if (have_flag(f_ptr->flags, FF_PATTERN))
        {
                if (!(mode & CEM_RIDING))
@@ -2557,7 +2331,31 @@ bool monster_can_cross_terrain(s16b feat, monster_race *r_ptr, u16b mode)
                if (!(r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)) return FALSE;
        }
 
-       return TRUE;
+       /* Cold */
+       if (have_flag(f_ptr->flags, FF_COLD_PUDDLE))
+       {
+               if (!(r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)) return FALSE;
+       }
+
+       /* Elec */
+       if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE))
+       {
+               if (!(r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)) return FALSE;
+       }
+
+       /* Acid */
+       if (have_flag(f_ptr->flags, FF_ACID_PUDDLE))
+       {
+               if (!(r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)) return FALSE;
+       }
+
+       /* Poison */
+       if (have_flag(f_ptr->flags, FF_POISON_PUDDLE))
+       {
+               if (!(r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)) return FALSE;
+       }
+
+       return TRUE;
 }
 
 
@@ -2570,7 +2368,7 @@ bool monster_can_cross_terrain(s16b feat, monster_race *r_ptr, u16b mode)
  * @param mode オプション
  * @return 踏破可能ならばTRUEを返す
  */
-bool monster_can_enter(int y, int x, monster_race *r_ptr, u16b mode)
+bool monster_can_enter(POSITION y, POSITION x, monster_race *r_ptr, BIT_FLAGS16 mode)
 {
        cave_type *c_ptr = &cave[y][x];
 
@@ -2680,47 +2478,659 @@ bool monster_has_hostile_align(monster_type *m_ptr, int pa_good, int pa_evil, mo
        return FALSE;
 }
 
-
 /*!
- * @brief モンスターが生命体かどうかを返す
- * Is the monster "alive"?
- * @param r_ptr 判定するモンスターの種族情報構造体参照ポインタ
- * @return 生命体ならばTRUEを返す
+ * @brief モンスターを倒した際の財宝svalを返す
+ * @param r_idx 倒したモンスターの種族ID
+ * @return 財宝のsval
  * @details
- * Used to determine the message to print for a killed monster.
- * ("dies", "destroyed")
+ * Hack -- Return the "automatic coin type" of a monster race
+ * Used to allocate proper treasure when "Creeping coins" die
+ * Note the use of actual "monster names"
  */
-bool monster_living(monster_race *r_ptr)
+static OBJECT_SUBTYPE_VALUE get_coin_type(MONRACE_IDX r_idx)
 {
-       /* Non-living, undead, or demon */
-       if (r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))
-               return FALSE;
-       else
-               return TRUE;
+       /* Analyze monsters */
+       switch (r_idx)
+       {
+       case MON_COPPER_COINS: return 2;
+       case MON_SILVER_COINS: return 5;
+       case MON_GOLD_COINS: return 10;
+       case MON_MITHRIL_COINS:
+       case MON_MITHRIL_GOLEM: return 16;
+       case MON_ADAMANT_COINS: return 17;
+       }
+
+       /* Assume nothing */
+       return 0;
 }
 
 
 /*!
- * @brief モンスターが特殊能力上、賞金首から排除する必要があるかどうかを返す。
- * Is the monster "alive"? / Is this monster declined to be questor or bounty?
- * @param r_idx モンスターの種族ID
- * @return 賞金首に加えられないならばTRUEを返す
+ * @brief モンスターが死亡した時の処理 /
+ * Handle the "death" of a monster.
+ * @param m_idx 死亡したモンスターのID
+ * @param drop_item TRUEならばモンスターのドロップ処理を行う
+ * @return 撃破されたモンスターの述語
  * @details
- * 実質バーノール=ルパート用。
+ * <pre>
+ * Disperse treasures centered at the monster location based on the
+ * various flags contained in the monster flags fields.
+ * Check for "Quest" completion when a quest monster is killed.
+ * Note that only the player can induce "monster_death()" on Uniques.
+ * Thus (for now) all Quest monsters should be Uniques.
+ * Note that monsters can now carry objects, and when a monster dies,
+ * it drops all of its objects, which may disappear in crowded rooms.
+ * </pre>
  */
-bool no_questor_or_bounty_uniques(IDX r_idx)
+void monster_death(MONSTER_IDX m_idx, bool drop_item)
 {
-       switch (r_idx)
+       int i, j;
+       POSITION y, x;
+
+       int dump_item = 0;
+       int dump_gold = 0;
+       int number = 0;
+
+       monster_type *m_ptr = &m_list[m_idx];
+       monster_race *r_ptr = &r_info[m_ptr->r_idx];
+
+       bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
+
+       u32b mo_mode = 0L;
+
+       bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
+       bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
+       bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
+       int force_coin = get_coin_type(m_ptr->r_idx);
+
+       object_type forge;
+       object_type *q_ptr;
+
+       bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
+               && !p_ptr->inside_battle && !is_pet(m_ptr);
+
+       /* The caster is dead? */
+       if (world_monster && world_monster == m_idx) world_monster = 0;
+
+       /* Notice changes in view */
+       if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
        {
-       /*
-        * Decline them to be questor or bounty because they use
-        * special motion "split and combine"
-        */
-       case MON_BANORLUPART:
-       case MON_BANOR:
-       case MON_LUPART:
-               return TRUE;
+               /* Update some things */
+               p_ptr->update |= (PU_MON_LITE);
+       }
+
+       y = m_ptr->fy;
+       x = m_ptr->fx;
+
+       if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
+       {
+               GAME_TEXT m_name[MAX_NLEN];
+
+               monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
+               do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
+       }
+
+       /* Let monsters explode! */
+       for (i = 0; i < 4; i++)
+       {
+               if (r_ptr->blow[i].method == RBM_EXPLODE)
+               {
+                       BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
+                       EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
+                       DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
+                       DICE_SID d_side = r_ptr->blow[i].d_side;
+                       HIT_POINT damage = damroll(d_dice, d_side);
+
+                       project(m_idx, 3, y, x, damage, typ, flg, -1);
+                       break;
+               }
+       }
+
+       if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
+       {
+               choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
+               r_ptr = &r_info[m_ptr->r_idx];
+       }
+
+       /* Check for quest completion */
+       check_quest_completion(m_ptr);
+
+       /* Handle the possibility of player vanquishing arena combatant -KMW- */
+       if (p_ptr->inside_arena && !is_pet(m_ptr))
+       {
+               p_ptr->exit_bldg = TRUE;
+
+               if (p_ptr->arena_number > MAX_ARENA_MONS)
+               {
+                       msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
+               }
+               else
+               {
+                       msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
+               }
+
+               if (arena_info[p_ptr->arena_number].tval)
+               {
+                       q_ptr = &forge;
+
+                       /* Prepare to make a prize */
+                       object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
+                       apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
+                       (void)drop_near(q_ptr, -1, y, x);
+               }
+
+               if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
+               p_ptr->arena_number++;
+               if (record_arena)
+               {
+                       GAME_TEXT m_name[MAX_NLEN];
+
+                       /* Extract monster name */
+                       monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
+
+                       do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
+               }
+       }
+
+       if (m_idx == p_ptr->riding)
+       {
+               if (rakuba(-1, FALSE))
+               {
+                       msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
+               }
+       }
+
+       /* Drop a dead corpse? */
+       if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
+               (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
+               !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
+       {
+               /* Assume skeleton */
+               bool corpse = FALSE;
+
+               /*
+                * We cannot drop a skeleton? Note, if we are in this check,
+                * we *know* we can drop at least a corpse or a skeleton
+                */
+               if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
+                       corpse = TRUE;
+               else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
+                       corpse = TRUE;
+
+               /* Else, a corpse is more likely unless we did a "lot" of damage */
+               else if (r_ptr->flags9 & RF9_DROP_CORPSE)
+               {
+                       /* Lots of damage in one blow */
+                       if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
+                       {
+                               if (one_in_(5)) corpse = TRUE;
+                       }
+                       else
+                       {
+                               if (!one_in_(5)) corpse = TRUE;
+                       }
+               }
+               q_ptr = &forge;
+
+               /* Prepare to make an object */
+               object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
+
+               apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
+
+               q_ptr->pval = m_ptr->r_idx;
+               (void)drop_near(q_ptr, -1, y, x);
+       }
+
+       /* Drop objects being carried */
+       monster_drop_carried_objects(m_ptr);
+
+       if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
+       if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
+
+       switch (m_ptr->r_idx)
+       {
+       case MON_PINK_HORROR:
+               /* Pink horrors are replaced with 2 Blue horrors */
+               if (!(p_ptr->inside_arena || p_ptr->inside_battle))
+               {
+                       bool notice = FALSE;
+
+                       for (i = 0; i < 2; i++)
+                       {
+                               POSITION wy = y, wx = x;
+                               bool pet = is_pet(m_ptr);
+                               BIT_FLAGS mode = 0L;
+
+                               if (pet) mode |= PM_FORCE_PET;
+
+                               if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode, '\0'))
+                               {
+                                       if (player_can_see_bold(wy, wx)) notice = TRUE;
+                               }
+                       }
+
+                       if (notice) msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
+               }
+               break;
+
+       case MON_BLOODLETTER:
+               /* Bloodletters of Khorne may drop a blade of chaos */
+               if (drop_chosen_item && (randint1(100) < 15))
+               {
+                       q_ptr = &forge;
+
+                       /* Prepare to make a Blade of Chaos */
+                       object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
+
+                       apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
+                       (void)drop_near(q_ptr, -1, y, x);
+               }
+               break;
+
+       case MON_RAAL:
+               if (drop_chosen_item && (dun_level > 9))
+               {
+                       q_ptr = &forge;
+                       object_wipe(q_ptr);
+
+                       /* Activate restriction */
+                       if ((dun_level > 49) && one_in_(5))
+                               get_obj_num_hook = kind_is_good_book;
+                       else
+                               get_obj_num_hook = kind_is_book;
+
+                       /* Make a book */
+                       make_object(q_ptr, mo_mode);
+                       (void)drop_near(q_ptr, -1, y, x);
+               }
+               break;
+
+       case MON_DAWN:
+               /*
+                * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
+                * spawn another in the fallen one's place!
+                */
+               if (!p_ptr->inside_arena && !p_ptr->inside_battle)
+               {
+                       if (!one_in_(7))
+                       {
+                               POSITION wy = y, wx = x;
+                               int attempts = 100;
+                               bool pet = is_pet(m_ptr);
+
+                               do
+                               {
+                                       scatter(&wy, &wx, y, x, 20, 0);
+                               } while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
+
+                               if (attempts > 0)
+                               {
+                                       BIT_FLAGS mode = 0L;
+                                       if (pet) mode |= PM_FORCE_PET;
+
+                                       if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode, '\0'))
+                                       {
+                                               if (player_can_see_bold(wy, wx))
+                                                       msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
+                                       }
+                               }
+                       }
+               }
+               break;
+
+       case MON_UNMAKER:
+               /* One more ultra-hack: An Unmaker goes out with a big bang! */
+       {
+               BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
+               (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
+       }
+       break;
+
+       case MON_UNICORN_ORD:
+       case MON_MORGOTH:
+       case MON_ONE_RING:
+               /* Reward for "lazy" player */
+               if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
+               {
+                       ARTIFACT_IDX a_idx = 0;
+                       artifact_type *a_ptr = NULL;
+
+                       if (!drop_chosen_item) break;
+
+                       do
+                       {
+                               switch (randint0(3))
+                               {
+                               case 0:
+                                       a_idx = ART_NAMAKE_HAMMER;
+                                       break;
+                               case 1:
+                                       a_idx = ART_NAMAKE_BOW;
+                                       break;
+                               case 2:
+                                       a_idx = ART_NAMAKE_ARMOR;
+                                       break;
+                               }
+
+                               a_ptr = &a_info[a_idx];
+                       } while (a_ptr->cur_num);
+
+                       /* Create the artifact */
+                       if (create_named_art(a_idx, y, x))
+                       {
+                               a_ptr->cur_num = 1;
+
+                               /* Hack -- Memorize location of artifact in saved floors */
+                               if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
+                       }
+                       else if (!preserve_mode) a_ptr->cur_num = 1;
+               }
+               break;
+
+       case MON_SERPENT:
+               if (!drop_chosen_item) break;
+               q_ptr = &forge;
+
+               /* Mega-Hack -- Prepare to make "Grond" */
+               object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
+
+               /* Mega-Hack -- Mark this item as "Grond" */
+               q_ptr->name1 = ART_GROND;
+
+               /* Mega-Hack -- Actually create "Grond" */
+               apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
+               (void)drop_near(q_ptr, -1, y, x);
+               q_ptr = &forge;
+
+               /* Mega-Hack -- Prepare to make "Chaos" */
+               object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
+
+               /* Mega-Hack -- Mark this item as "Chaos" */
+               q_ptr->name1 = ART_CHAOS;
+
+               /* Mega-Hack -- Actually create "Chaos" */
+               apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
+               (void)drop_near(q_ptr, -1, y, x);
+               break;
+
+       case MON_B_DEATH_SWORD:
+               if (drop_chosen_item)
+               {
+                       q_ptr = &forge;
+
+                       /* Prepare to make a broken sword */
+                       object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
+                       (void)drop_near(q_ptr, -1, y, x);
+               }
+               break;
+
+       case MON_A_GOLD:
+       case MON_A_SILVER:
+               if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
+                       ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
+               {
+                       q_ptr = &forge;
+
+                       /* Prepare to make a Can of Toys */
+                       object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
+
+                       apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
+                       (void)drop_near(q_ptr, -1, y, x);
+               }
+               break;
+
+       case MON_ROLENTO:
+       {
+               BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
+               (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
+       }
+       break;
+
        default:
-               return FALSE;
+               if (!drop_chosen_item) break;
+
+               switch (r_ptr->d_char)
+               {
+               case '(':
+                       if (dun_level > 0)
+                       {
+                               q_ptr = &forge;
+                               object_wipe(q_ptr);
+
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_cloak;
+
+                               /* Make a cloak */
+                               make_object(q_ptr, mo_mode);
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
+
+               case '/':
+                       if (dun_level > 4)
+                       {
+                               q_ptr = &forge;
+                               object_wipe(q_ptr);
+
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_polearm;
+
+                               /* Make a poleweapon */
+                               make_object(q_ptr, mo_mode);
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
+
+               case '[':
+                       if (dun_level > 19)
+                       {
+                               q_ptr = &forge;
+                               object_wipe(q_ptr);
+
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_armor;
+
+                               /* Make a hard armor */
+                               make_object(q_ptr, mo_mode);
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
+
+               case '\\':
+                       if (dun_level > 4)
+                       {
+                               q_ptr = &forge;
+                               object_wipe(q_ptr);
+
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_hafted;
+
+                               /* Make a hafted weapon */
+                               make_object(q_ptr, mo_mode);
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
+
+               case '|':
+                       if (m_ptr->r_idx != MON_STORMBRINGER)
+                       {
+                               q_ptr = &forge;
+                               object_wipe(q_ptr);
+
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_sword;
+
+                               /* Make a sword */
+                               make_object(q_ptr, mo_mode);
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
+               }
+               break;
+       }
+
+       /* Mega-Hack -- drop fixed items */
+       if (drop_chosen_item)
+       {
+               ARTIFACT_IDX a_idx = 0;
+               int chance = 0;
+
+               for (i = 0; i < 4; i++)
+               {
+                       if (!r_ptr->artifact_id[i]) break;
+                       a_idx = r_ptr->artifact_id[i];
+                       chance = r_ptr->artifact_percent[i];
+               }
+
+               if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
+               {
+                       artifact_type *a_ptr = &a_info[a_idx];
+
+                       if (!a_ptr->cur_num)
+                       {
+                               /* Create the artifact */
+                               if (create_named_art(a_idx, y, x))
+                               {
+                                       a_ptr->cur_num = 1;
+
+                                       /* Hack -- Memorize location of artifact in saved floors */
+                                       if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
+                               }
+                               else if (!preserve_mode) a_ptr->cur_num = 1;
+                       }
+               }
+
+               if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_idx].final_guardian == m_ptr->r_idx))
+               {
+                       KIND_OBJECT_IDX k_idx = d_info[dungeon_idx].final_object ? d_info[dungeon_idx].final_object
+                               : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
+
+                       if (d_info[dungeon_idx].final_artifact)
+                       {
+                               a_idx = d_info[dungeon_idx].final_artifact;
+                               artifact_type *a_ptr = &a_info[a_idx];
+
+                               if (!a_ptr->cur_num)
+                               {
+                                       /* Create the artifact */
+                                       if (create_named_art(a_idx, y, x))
+                                       {
+                                               a_ptr->cur_num = 1;
+
+                                               /* Hack -- Memorize location of artifact in saved floors */
+                                               if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
+                                       }
+                                       else if (!preserve_mode) a_ptr->cur_num = 1;
+
+                                       /* Prevent rewarding both artifact and "default" object */
+                                       if (!d_info[dungeon_idx].final_object) k_idx = 0;
+                               }
+                       }
+
+                       if (k_idx)
+                       {
+                               q_ptr = &forge;
+
+                               /* Prepare to make a reward */
+                               object_prep(q_ptr, k_idx);
+
+                               apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"), d_name + d_info[dungeon_idx].name);
+               }
+       }
+
+       /* Determine how much we can drop */
+       if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
+       if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
+       if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
+       if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
+       if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
+       if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
+
+       if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
+               number = 0; /* Clones drop no stuff unless Cloning Pits */
+
+       if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
+               number = 0; /* Pets drop no stuff */
+       if (!drop_item && (r_ptr->d_char != '$')) number = 0;
+
+       if ((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
+               number = 0; /* Limit of Multiply monster drop */
+
+       /* Hack -- handle creeping coins */
+       coin_type = force_coin;
+
+       /* Average dungeon and monster levels */
+       object_level = (dun_level + r_ptr->level) / 2;
+
+       /* Drop some objects */
+       for (j = 0; j < number; j++)
+       {
+               q_ptr = &forge;
+               object_wipe(q_ptr);
+
+               /* Make Gold */
+               if (do_gold && (!do_item || (randint0(100) < 50)))
+               {
+                       /* Make some gold */
+                       if (!make_gold(q_ptr)) continue;
+
+                       dump_gold++;
+               }
+
+               /* Make Object */
+               else
+               {
+                       /* Make an object */
+                       if (!make_object(q_ptr, mo_mode)) continue;
+
+                       dump_item++;
+               }
+               (void)drop_near(q_ptr, -1, y, x);
+       }
+
+       /* Reset the object level */
+       object_level = base_level;
+
+       /* Reset "coin" type */
+       coin_type = 0;
+
+
+       /* Take note of any dropped treasure */
+       if (visible && (dump_item || dump_gold))
+       {
+               /* Take notes on treasure */
+               lore_treasure(m_idx, dump_item, dump_gold);
+       }
+
+       /* Only process "Quest Monsters" */
+       if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
+       if (p_ptr->inside_battle) return;
+
+       /* Winner? */
+       if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
+       {
+               /* Total winner */
+               p_ptr->total_winner = TRUE;
+
+               /* Redraw the "title" */
+               p_ptr->redraw |= (PR_TITLE);
+
+               play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
+
+               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
+
+               if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
+               {
+                       msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
+                       msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
+               }
+
+               /* Congratulations */
+               msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
+               msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
+               msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
        }
 }