OSDN Git Service

アイテム生成に関わる関数群の変更.
[hengband/hengband.git] / src / xtra2.c
index b08e7c6..a478cfd 100644 (file)
@@ -1,15 +1,15 @@
 /* File: xtra2.c */
 
-/* Purpose: effects of various "objects" */
-
 /*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
  *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.  Other copyrights may also apply.
  */
 
+/* Purpose: effects of various "objects" */
+
 #include "angband.h"
 
 #define REWARD_CHANCE 10
  */
 void check_experience(void)
 {
-       int             i;
        bool level_reward = FALSE;
        bool level_mutation = FALSE;
        bool level_inc_stat = FALSE;
        bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
 
 
-       /* Note current level */
-       i = p_ptr->lev;
-
        /* Hack -- lower limit */
        if (p_ptr->exp < 0) p_ptr->exp = 0;
 
@@ -610,7 +606,7 @@ msg_print("
                        object_wipe(q_ptr);
 
                        /* Make a great object */
-                       make_object(q_ptr, TRUE, TRUE);
+                       make_object(q_ptr, AM_OKAY | AM_GOOD | AM_GREAT);
 
                        /* Drop it in the dungeon */
                        (void)drop_near(q_ptr, -1, y, x);
@@ -647,8 +643,7 @@ void monster_death(int m_idx, bool drop_item)
 
        bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
 
-       bool good = (r_ptr->flags1 & RF1_DROP_GOOD) ? TRUE : FALSE;
-       bool great = (r_ptr->flags1 & RF1_DROP_GREAT) ? TRUE : FALSE;
+       u32b mo_mode = AM_OKAY;
 
        bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
        bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
@@ -658,6 +653,9 @@ void monster_death(int m_idx, bool drop_item)
        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);
+
 
        if (world_monster) world_monster = FALSE;
 
@@ -686,62 +684,20 @@ void monster_death(int m_idx, bool drop_item)
        /* Let monsters explode! */
        for (i = 0; i < 4; i++)
        {
-               if ((r_ptr->blow[i].method == RBM_EXPLODE) || (m_ptr->r_idx == MON_ROLENTO))
+               if (r_ptr->blow[i].method == RBM_EXPLODE)
                {
                        int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
-                       int typ = GF_MISSILE;
+                       int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
                        int d_dice = r_ptr->blow[i].d_dice;
                        int d_side = r_ptr->blow[i].d_side;
                        int damage = damroll(d_dice, d_side);
 
-                       switch (r_ptr->blow[i].effect)
-                       {
-                               case RBE_HURT:      typ = GF_MISSILE; break;
-                               case RBE_POISON:    typ = GF_POIS; break;
-                               case RBE_UN_BONUS:  typ = GF_DISENCHANT; break;
-                               case RBE_UN_POWER:  typ = GF_MISSILE; break; /* ToDo: Apply the correct effects */
-                               case RBE_EAT_GOLD:  typ = GF_MISSILE; break;
-                               case RBE_EAT_ITEM:  typ = GF_MISSILE; break;
-                               case RBE_EAT_FOOD:  typ = GF_MISSILE; break;
-                               case RBE_EAT_LITE:  typ = GF_MISSILE; break;
-                               case RBE_ACID:      typ = GF_ACID; break;
-                               case RBE_ELEC:      typ = GF_ELEC; break;
-                               case RBE_FIRE:      typ = GF_FIRE; break;
-                               case RBE_COLD:      typ = GF_COLD; break;
-                               case RBE_BLIND:     typ = GF_MISSILE; break;
-                               case RBE_CONFUSE:   typ = GF_CONFUSION; break;
-                               case RBE_TERRIFY:   typ = GF_MISSILE; break;
-                               case RBE_PARALYZE:  typ = GF_MISSILE; break;
-                               case RBE_LOSE_STR:  typ = GF_MISSILE; break;
-                               case RBE_LOSE_DEX:  typ = GF_MISSILE; break;
-                               case RBE_LOSE_CON:  typ = GF_MISSILE; break;
-                               case RBE_LOSE_INT:  typ = GF_MISSILE; break;
-                               case RBE_LOSE_WIS:  typ = GF_MISSILE; break;
-                               case RBE_LOSE_CHR:  typ = GF_MISSILE; break;
-                               case RBE_LOSE_ALL:  typ = GF_MISSILE; break;
-                               case RBE_SHATTER:   typ = GF_ROCKET; break;
-                               case RBE_EXP_10:    typ = GF_MISSILE; break;
-                               case RBE_EXP_20:    typ = GF_MISSILE; break;
-                               case RBE_EXP_40:    typ = GF_MISSILE; break;
-                               case RBE_EXP_80:    typ = GF_MISSILE; break;
-                               case RBE_DISEASE:   typ = GF_POIS; break;
-                               case RBE_TIME:      typ = GF_TIME; break;
-                               case RBE_EXP_VAMP:  typ = GF_MISSILE; break;
-                               case RBE_DR_MANA:   typ = GF_MANA; break;
-                               case RBE_SUPERHURT: typ = GF_MISSILE; break;
-                       }
-                       if (m_ptr->r_idx == MON_ROLENTO)
-                       {
-                               typ = GF_FIRE;
-                               damage = damroll(20,10);
-                       }
-
                        project(m_idx, 3, y, x, damage, typ, flg, -1);
                        break;
                }
        }
 
-       if (m_ptr->mflag2 & MFLAG_CHAMELEON)
+       if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
        {
                choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
                r_ptr = &r_info[m_ptr->r_idx];
@@ -777,15 +733,15 @@ msg_print("
 #endif
                }
 
-               if (arena_shouhin[p_ptr->arena_number])
+               if (arena_info[p_ptr->arena_number].tval)
                {
                        /* Get local object */
                        q_ptr = &forge;
 
-                       /* Prepare to make a Blade of Chaos */
-                       object_prep(q_ptr, lookup_kind(k_info[arena_shouhin[p_ptr->arena_number]].tval, k_info[arena_shouhin[p_ptr->arena_number]].sval));
+                       /* 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, FALSE, FALSE, FALSE, FALSE);
+                       apply_magic(q_ptr, object_level, 0L);
 
                        /* Drop it in the dungeon */
                        (void)drop_near(q_ptr, -1, y, x);
@@ -846,7 +802,7 @@ msg_print("
                /* Prepare to make an object */
                object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
 
-               apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
+               apply_magic(q_ptr, object_level, 0L);
 
                q_ptr->pval = m_ptr->r_idx;
 
@@ -857,526 +813,561 @@ msg_print("
        /* Drop objects being carried */
        monster_drop_carried_objects(m_ptr);
 
-       /*
-        * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
-        * spawn another in the fallen one's place!
-        */
-       if (m_ptr->r_idx == MON_DAWN &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle))
+       switch (m_ptr->r_idx)
        {
-               if (!one_in_(7))
+       case MON_PINK_HORROR:
+               /* Pink horrors are replaced with 2 Blue horrors */
+               if (!(p_ptr->inside_arena || p_ptr->inside_battle))
                {
-                       int wy = py, wx = px;
-                       int attempts = 100;
-                       bool pet = is_pet(m_ptr);
+                       bool notice = FALSE;
 
-                       do
-                       {
-                               scatter(&wy, &wx, py, px, 20, 0);
-                       }
-                       while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
-
-                       if (attempts > 0)
+                       for (i = 0; i < 2; i++)
                        {
+                               int wy = y, wx = x;
+                               bool pet = is_pet(m_ptr);
                                u32b mode = 0L;
+
                                if (pet) mode |= PM_FORCE_PET;
 
-                               if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
+                               if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
                                {
                                        if (player_can_see_bold(wy, wx))
+                                               notice = TRUE;
+                               }
+                       }
+
+                       if (notice)
 #ifdef JP
-                                               msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
+                               msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
 #else
-                                               msg_print("A new warrior steps forth!");
+                               msg_print("The Pink horror divides!");
 #endif
-
-                               }
-                       }
                }
-       }
-
-       /* Pink horrors are replaced with 2 Blue horrors */
-       else if (m_ptr->r_idx == MON_PINK_HORROR &&
-                !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
-               bool notice = FALSE;
+               break;
 
-               for (i = 0; i < 2; i++)
+       case MON_BLOODLETTER:
+               /* Bloodletters of Khorne may drop a blade of chaos */
+               if (drop_chosen_item && (randint1(100) < 15))
                {
-                       int wy = y, wx = x;
-                       bool pet = is_pet(m_ptr);
-                       u32b mode = 0L;
+                       /* Get local object */
+                       q_ptr = &forge;
 
-                       if (pet) mode |= PM_FORCE_PET;
+                       /* Prepare to make a Blade of Chaos */
+                       object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
 
-                       if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
-                       {
-                               if (player_can_see_bold(wy, wx))
-                                       notice = TRUE;
-                       }
-               }
+                       apply_magic(q_ptr, object_level, 0L);
 
-               if (notice)
-#ifdef JP
-                       msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
-#else
-                       msg_print("The Pink horror divides!");
-#endif
+                       /* Drop it in the dungeon */
+                       (void)drop_near(q_ptr, -1, y, x);
+               }
+               break;
 
-       }
-       /* One more ultra-hack: An Unmaker goes out with a big bang! */
-       else if (m_ptr->r_idx == MON_UNMAKER)
+       case MON_RAAL:
+               if (drop_chosen_item && (dun_level > 9))
+               {
+                       /* Get local object */
+                       q_ptr = &forge;
 
-       {
-               int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
-               (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
-       }
+                       /* Wipe the object */
+                       object_wipe(q_ptr);
 
-       /* Bloodletters of Khorne may drop a blade of chaos */
-       else if (m_ptr->r_idx == MON_BLOODLETTER &&
+                       /* 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;
 
-                (randint1(100) < 15) &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
-               /* Get local object */
-               q_ptr = &forge;
+                       /* Prepare allocation table */
+                       get_obj_num_prep();
 
-               /* Prepare to make a Blade of Chaos */
-               object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
+                       /* Make a book */
+                       make_object(q_ptr, AM_OKAY);
 
-               apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
+                       /* Drop it in the dungeon */
+                       (void)drop_near(q_ptr, -1, y, x);
+               }
+               break;
 
-               /* Drop it in the dungeon */
-               (void)drop_near(q_ptr, -1, y, x);
-       }
+       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))
+                       {
+                               int wy = py, wx = px;
+                               int attempts = 100;
+                               bool pet = is_pet(m_ptr);
 
-       else if (m_ptr->r_idx == MON_RAAL &&
-           (dun_level > 9) &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
-               /* Get local object */
-               q_ptr = &forge;
+                               do
+                               {
+                                       scatter(&wy, &wx, py, px, 20, 0);
+                               }
+                               while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
 
-               /* Wipe the object */
-               object_wipe(q_ptr);
+                               if (attempts > 0)
+                               {
+                                       u32b mode = 0L;
+                                       if (pet) mode |= PM_FORCE_PET;
 
-               /* 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;
+                                       if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
+                                       {
+                                               if (player_can_see_bold(wy, wx))
+#ifdef JP
+                                                       msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
+#else
+                                                       msg_print("A new warrior steps forth!");
+#endif
 
-               /* Prepare allocation table */
-               get_obj_num_prep();
+                                       }
+                               }
+                       }
+               }
+               break;
 
-               /* Make a great object */
-               make_object(q_ptr, FALSE, FALSE);
+       case MON_UNMAKER:
+               /* One more ultra-hack: An Unmaker goes out with a big bang! */
+               {
+                       int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
+                       (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
+               }
+               break;
 
-               /* Drop it in the dungeon */
-               (void)drop_near(q_ptr, -1, y, x);
-       }
+       case MON_UNICORN_ORD:
+       case MON_MORGOTH:
+       case MON_ONE_RING:
+               /* Reward for "lazy" player */
+               if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
+               {
+                       int a_idx;
 
-       else if (m_ptr->r_idx == MON_B_DEATH_SWORD &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
-               /* Get local object */
-               q_ptr = &forge;
+                       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;
+                               }
+                       }
+                       while (a_info[a_idx].cur_num);
 
-               /* Prepare to make a Blade of Chaos */
-               object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
+                       if (a_info[a_idx].cur_num == 0)
+                       {
+                               /* Create the artifact */
+                               create_named_art(a_idx, y, x);
+                               a_info[a_idx].cur_num = 1;
+                       }
+               }
+               break;
 
-               /* Drop it in the dungeon */
-               (void)drop_near(q_ptr, -1, y, x);
-       }
+       case MON_SERPENT:
+               if (!drop_chosen_item) break;
 
-       else if ((r_ptr->d_char == '|') && !(m_ptr->r_idx == MON_STORMBRINGER) &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
                /* Get local object */
                q_ptr = &forge;
 
-               /* Wipe the object */
-               object_wipe(q_ptr);
+               /* Mega-Hack -- Prepare to make "Grond" */
+               object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
 
-               /* Activate restriction */
-               get_obj_num_hook = kind_is_sword;
+               /* Mega-Hack -- Mark this item as "Grond" */
+               q_ptr->name1 = ART_GROND;
 
-               /* Prepare allocation table */
-               get_obj_num_prep();
-
-               /* Make a great object */
-               make_object(q_ptr, FALSE, FALSE);
+               /* Mega-Hack -- Actually create "Grond" */
+               apply_magic(q_ptr, -1, AM_OKAY | AM_GOOD | AM_GREAT);
 
                /* Drop it in the dungeon */
                (void)drop_near(q_ptr, -1, y, x);
-       }
 
-       else if ((r_ptr->d_char == '(') && (dun_level > 0) &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
                /* Get local object */
                q_ptr = &forge;
 
-               /* Wipe the object */
-               object_wipe(q_ptr);
+               /* Mega-Hack -- Prepare to make "Chaos" */
+               object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
 
-               /* Activate restriction */
-               get_obj_num_hook = kind_is_cloak;
+               /* Mega-Hack -- Mark this item as "Chaos" */
+               q_ptr->name1 = ART_CHAOS;
 
-               /* Prepare allocation table */
-               get_obj_num_prep();
-
-               /* Make a great object */
-               make_object(q_ptr, FALSE, FALSE);
+               /* Mega-Hack -- Actually create "Chaos" */
+               apply_magic(q_ptr, -1, AM_OKAY | AM_GOOD | AM_GREAT);
 
                /* Drop it in the dungeon */
                (void)drop_near(q_ptr, -1, y, x);
-       }
+               break;
 
-       else if ((r_ptr->d_char == '/') && (dun_level > 4) &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
-               /* Get local object */
-               q_ptr = &forge;
+       case MON_B_DEATH_SWORD:
+               if (drop_chosen_item)
+               {
+                       /* Get local object */
+                       q_ptr = &forge;
 
-               /* Wipe the object */
-               object_wipe(q_ptr);
+                       /* Prepare to make a broken sword */
+                       object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
 
-               /* Activate restriction */
-               get_obj_num_hook = kind_is_polearm;
+                       /* Drop it in the dungeon */
+                       (void)drop_near(q_ptr, -1, y, x);
+               }
+               break;
 
-               /* Prepare allocation table */
-               get_obj_num_prep();
+       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_pkills + 1) % 5))))
+               {
+                       /* Get local object */
+                       q_ptr = &forge;
 
-               /* Make a great object */
-               make_object(q_ptr, FALSE, FALSE);
+                       /* Prepare to make a Can of Toys */
+                       object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
 
-               /* Drop it in the dungeon */
-               (void)drop_near(q_ptr, -1, y, x);
-       }
+                       apply_magic(q_ptr, object_level, 0L);
 
-       else if ((r_ptr->d_char == '[') && (dun_level > 19) &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
-               /* Get local object */
-               q_ptr = &forge;
+                       /* Drop it in the dungeon */
+                       (void)drop_near(q_ptr, -1, y, x);
+               }
+               break;
 
-               /* Wipe the object */
-               object_wipe(q_ptr);
+       case MON_ROLENTO:
+               {
+                       int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
+                       (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
+               }
+               break;
 
-               /* Activate restriction */
-               get_obj_num_hook = kind_is_armor;
+       default:
+               if (!drop_chosen_item) break;
 
-               /* Prepare allocation table */
-               get_obj_num_prep();
+               switch (r_ptr->d_char)
+               {
+               case '(':
+                       if (dun_level > 0)
+                       {
+                               /* Get local object */
+                               q_ptr = &forge;
 
-               /* Make a great object */
-               make_object(q_ptr, FALSE, FALSE);
+                               /* Wipe the object */
+                               object_wipe(q_ptr);
 
-               /* Drop it in the dungeon */
-               (void)drop_near(q_ptr, -1, y, x);
-       }
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_cloak;
 
-       else if ((m_ptr->r_idx == MON_A_GOLD || (m_ptr->r_idx == MON_A_SILVER && !((r_ptr->r_pkills+1)%5))) && !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
-               /* Get local object */
-               q_ptr = &forge;
+                               /* Prepare allocation table */
+                               get_obj_num_prep();
 
-               /* Prepare to make a Blade of Chaos */
-               object_prep(q_ptr, lookup_kind(TV_CHEST, 50));
+                               /* Make a cloak */
+                               make_object(q_ptr, AM_OKAY);
 
-               apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
+                               /* Drop it in the dungeon */
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
 
-               /* Drop it in the dungeon */
-               (void)drop_near(q_ptr, -1, y, x);
-       }
-       /* Mega-Hack -- drop "winner" treasures */
-       else
-       {
-               if (m_ptr->r_idx == MON_SERPENT)
+               case '/':
+                       if (dun_level > 4)
+                       {
+                               /* Get local object */
+                               q_ptr = &forge;
 
-               {
-                       /* Get local object */
-                       q_ptr = &forge;
+                               /* Wipe the object */
+                               object_wipe(q_ptr);
 
-                       /* Mega-Hack -- Prepare to make "Grond" */
-                       object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_polearm;
 
-                       /* Mega-Hack -- Mark this item as "Grond" */
-                       q_ptr->name1 = ART_GROND;
+                               /* Prepare allocation table */
+                               get_obj_num_prep();
 
-                       /* Mega-Hack -- Actually create "Grond" */
-                       apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
+                               /* Make a poleweapon */
+                               make_object(q_ptr, AM_OKAY);
 
-                       /* Drop it in the dungeon */
-                       (void)drop_near(q_ptr, -1, y, x);
+                               /* Drop it in the dungeon */
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
 
-                       /* Get local object */
-                       q_ptr = &forge;
+               case '[':
+                       if (dun_level > 19)
+                       {
+                               /* Get local object */
+                               q_ptr = &forge;
 
-                       /* Mega-Hack -- Prepare to make "Morgoth" */
-                       object_prep(q_ptr, lookup_kind(TV_CROWN, SV_MORGOTH));
+                               /* Wipe the object */
+                               object_wipe(q_ptr);
 
-                       /* Mega-Hack -- Mark this item as "Morgoth" */
-                       q_ptr->name1 = ART_CHAOS;
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_armor;
 
-                       /* Mega-Hack -- Actually create "Morgoth" */
-                       apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
+                               /* Prepare allocation table */
+                               get_obj_num_prep();
 
-                       /* Drop it in the dungeon */
-                       (void)drop_near(q_ptr, -1, y, x);
-               }
-               else
-               {
-                       int a_idx = 0;
-                       int chance = 0;
+                               /* Make a hard armor */
+                               make_object(q_ptr, AM_OKAY);
+
+                               /* Drop it in the dungeon */
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
 
-                       switch (m_ptr->r_idx)
+               case '|':
+                       if (m_ptr->r_idx != MON_STORMBRINGER)
                        {
-                       case MON_OBERON:
-                               if (one_in_(3))
-                               {
-                                       a_idx = ART_JUDGE;
-                                       chance = 33;
-                               }
-                               else
-                               {
-                                       a_idx = ART_AMBER;
-                                       chance = 50;
-                               }
-                               break;
+                               /* Get local object */
+                               q_ptr = &forge;
 
-                       case MON_UNICORN_ORD:
-                       case MON_MORGOTH:
-                       case MON_ONE_RING:
-                               if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
-                               {
-                                       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;
-                                               }
-                                       }
-                                       while (a_info[a_idx].cur_num);
+                               /* Wipe the object */
+                               object_wipe(q_ptr);
 
-                                       chance = 100;
-                               }
-                               break;
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_sword;
 
-                       case MON_GHB:
-                               a_idx = ART_GHB;
-                               chance = 100;
-                               break;
+                               /* Prepare allocation table */
+                               get_obj_num_prep();
 
-                       case MON_STORMBRINGER:
-                               a_idx = ART_STORMBRINGER;
-                               chance = 100;
-                               break;
+                               /* Make a sword */
+                               make_object(q_ptr, AM_OKAY);
 
-                       case MON_ECHIZEN:
-                               a_idx = ART_CRIMSON;
+                               /* Drop it in the dungeon */
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
+               }
+               break;
+       }
+
+       /* Mega-Hack -- drop fixed artifacts */
+       if (drop_chosen_item)
+       {
+               int a_idx = 0;
+               int chance = 0;
+
+               switch (m_ptr->r_idx)
+               {
+               case MON_OBERON:
+                       if (one_in_(3))
+                       {
+                               a_idx = ART_JUDGE;
+                               chance = 33;
+                       }
+                       else
+                       {
+                               a_idx = ART_AMBER;
                                chance = 50;
-                               break;
+                       }
+                       break;
 
-                       case MON_GANDALF:
-                               a_idx = ART_ICANUS;
-                               chance = 20;
-                               break;
+               case MON_GHB:
+                       a_idx = ART_GHB;
+                       chance = 100;
+                       break;
 
-                       case MON_OROCHI:
-                               a_idx = ART_KUSANAGI;
-                               chance = 25;
-                               break;
+               case MON_STORMBRINGER:
+                       a_idx = ART_STORMBRINGER;
+                       chance = 100;
+                       break;
 
-                       case MON_DWORKIN:
-                               a_idx = ART_JUDGE;
-                               chance = 20;
-                               break;
+               case MON_ECHIZEN:
+                       a_idx = ART_CRIMSON;
+                       chance = 50;
+                       break;
 
-                       case MON_SAURON:
-                               if (one_in_(10))
-                               {
-                                       a_idx = ART_POWER;
-                                       chance = 100;
-                               }
-                               else
-                               {
-                                       a_idx = ART_AHO;
-                                       chance = 100;
-                               }
-                               break;
+               case MON_GANDALF:
+                       a_idx = ART_ICANUS;
+                       chance = 20;
+                       break;
 
-                       case MON_BRAND:
-                               if (!one_in_(3))
-                               {
-                                       a_idx = ART_BRAND;
-                                       chance = 25;
-                               }
-                               else
-                               {
-                                       a_idx = ART_WEREWINDLE;
-                                       chance = 33;
-                               }
-                               break;
+               case MON_OROCHI:
+                       a_idx = ART_KUSANAGI;
+                       chance = 25;
+                       break;
 
-                       case MON_CORWIN:
-                               if (!one_in_(3))
-                               {
-                                       a_idx = ART_GRAYSWANDIR;
-                                       chance = 33;
-                               }
-                               else
-                               {
-                                       a_idx = ART_CORWIN;
-                                       chance = 33;
-                               }
-                               break;
+               case MON_DWORKIN:
+                       a_idx = ART_JUDGE;
+                       chance = 20;
+                       break;
 
-                       case MON_SURTUR:
-                               a_idx = ART_TWILIGHT;
-                               chance = 66;
-                               break;
+               case MON_SAURON:
+                       if (one_in_(10))
+                       {
+                               a_idx = ART_POWER;
+                               chance = 100;
+                       }
+                       else
+                       {
+                               a_idx = ART_AHO;
+                               chance = 100;
+                       }
+                       break;
 
-                       case MON_SARUMAN:
-                               a_idx = ART_ELENDIL;
+               case MON_BRAND:
+                       if (!one_in_(3))
+                       {
+                               a_idx = ART_BRAND;
+                               chance = 25;
+                       }
+                       else
+                       {
+                               a_idx = ART_WEREWINDLE;
                                chance = 33;
-                               break;
+                       }
+                       break;
 
-                       case MON_FIONA:
-                               a_idx = ART_FIONA;
-                               chance = 50;
-                               break;
+               case MON_CORWIN:
+                       if (!one_in_(3))
+                       {
+                               a_idx = ART_GRAYSWANDIR;
+                               chance = 33;
+                       }
+                       else
+                       {
+                               a_idx = ART_CORWIN;
+                               chance = 33;
+                       }
+                       break;
 
-                       case MON_JULIAN:
-                               a_idx = ART_JULIAN;
-                               chance = 45;
-                               break;
+               case MON_SURTUR:
+                       a_idx = ART_TWILIGHT;
+                       chance = 66;
+                       break;
 
-                       case MON_KLING:
-                               a_idx = ART_DESTINY;
-                               chance = 40;
-                               break;
+               case MON_SARUMAN:
+                       a_idx = ART_ELENDIL;
+                       chance = 33;
+                       break;
 
-                       case MON_GOEMON:
-                               a_idx = ART_ZANTETSU;
-                               chance = 75;
-                               break;
+               case MON_FIONA:
+                       a_idx = ART_FIONA;
+                       chance = 50;
+                       break;
 
-                       case MON_HAGEN:
-                               a_idx = ART_HAGEN;
-                               chance = 66;
-                               break;
+               case MON_JULIAN:
+                       a_idx = ART_JULIAN;
+                       chance = 45;
+                       break;
 
-                       case MON_CAIN:
-                               a_idx = ART_CAINE;
-                               chance = 50;
-                               break;
+               case MON_KLING:
+                       a_idx = ART_DESTINY;
+                       chance = 40;
+                       break;
 
-                       case MON_BULLGATES:
-                               a_idx = ART_WINBLOWS;
-                               chance = 66;
-                               break;
+               case MON_GOEMON:
+                       a_idx = ART_ZANTETSU;
+                       chance = 75;
+                       break;
 
-                       case MON_LUNGORTHIN:
-                               a_idx = ART_CALRIS;
-                               chance = 50;
-                               break;
+               case MON_HAGEN:
+                       a_idx = ART_HAGEN;
+                       chance = 66;
+                       break;
 
-                       case MON_JACK_SHADOWS:
-                               a_idx = ART_JACK;
-                               chance = 15;
-                               break;
+               case MON_CAINE:
+                       a_idx = ART_CAINE;
+                       chance = 50;
+                       break;
 
-                       case MON_DIO:
-                               a_idx = ART_STONEMASK;
-                               chance = 20;
-                               break;
+               case MON_BULLGATES:
+                       a_idx = ART_WINBLOWS;
+                       chance = 66;
+                       break;
 
-                       case MON_BELD:
-                               a_idx = ART_SOULCRUSH;
-                               chance = 10;
-                               break;
+               case MON_LUNGORTHIN:
+                       a_idx = ART_CALRIS;
+                       chance = 50;
+                       break;
 
-                       case MON_PIP:
-                               a_idx = ART_EXCALIBUR_J;
-                               chance = 50;
-                               break;
+               case MON_JACK_SHADOWS:
+                       a_idx = ART_JACK;
+                       chance = 15;
+                       break;
 
-                       case MON_SHUTEN:
-                               a_idx = ART_SHUTEN_DOJI;
-                               chance = 33;
-                               break;
+               case MON_DIO:
+                       a_idx = ART_STONEMASK;
+                       chance = 20;
+                       break;
 
-                       case MON_GOTHMOG:
-                               a_idx = ART_GOTHMOG;
-                               chance = 33;
-                               break;
+               case MON_BELD:
+                       a_idx = ART_SOULCRUSH;
+                       chance = 10;
+                       break;
 
-                       case MON_FUNDIN:
-                               a_idx = ART_FUNDIN;
-                               chance = 5;
-                               break;
-                       }
+               case MON_PIP:
+                       a_idx = ART_EXCALIBUR_J;
+                       chance = 50;
+                       break;
 
-                       if ((a_idx > 0) && ((randint0(100) < chance) || (p_ptr->wizard)))
-                       {
-                               if (a_info[a_idx].cur_num == 0)
-                               {
-                                       /* Create the artifact */
-                                       create_named_art(a_idx, y, x);
+               case MON_SHUTEN:
+                       a_idx = ART_SHUTEN_DOJI;
+                       chance = 33;
+                       break;
 
-                                       a_info[a_idx].cur_num = 1;
-                               }
-                       }
-               }
-       }
-       if ((r_ptr->flags7 & RF7_GUARDIAN) && !p_ptr->inside_battle && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
-       {
-               int k_idx = 198; /* Acquirement */;
+               case MON_GOTHMOG:
+                       a_idx = ART_GOTHMOG;
+                       chance = 33;
+                       break;
 
-               if (d_info[dungeon_type].final_object)
-                       k_idx = d_info[dungeon_type].final_object;
+               case MON_FUNDIN:
+                       a_idx = ART_FUNDIN;
+                       chance = 5;
+                       break;
+               }
 
-               if (d_info[dungeon_type].final_artifact)
+               if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
                {
-                       int a_idx = d_info[dungeon_type].final_artifact;
                        if (a_info[a_idx].cur_num == 0)
                        {
                                /* Create the artifact */
                                create_named_art(a_idx, y, x);
-
                                a_info[a_idx].cur_num = 1;
-                               k_idx = 0;
                        }
                }
 
-               if (k_idx)
+               if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
                {
-                       /* Get local object */
-                       q_ptr = &forge;
+                       int k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT); /* Acquirement */;
 
-                       /* Prepare to make a reward */
-                       object_prep(q_ptr, k_idx);
+                       if (d_info[dungeon_type].final_object)
+                               k_idx = d_info[dungeon_type].final_object;
 
-                       apply_magic(q_ptr, object_level, FALSE, TRUE, FALSE, FALSE);
+                       if (d_info[dungeon_type].final_artifact)
+                       {
+                               int a_idx = d_info[dungeon_type].final_artifact;
+                               if (a_info[a_idx].cur_num == 0)
+                               {
+                                       /* Create the artifact */
+                                       create_named_art(a_idx, y, x);
 
-                       /* Drop it in the dungeon */
-                       (void)drop_near(q_ptr, -1, y, x);
-               }
+                                       a_info[a_idx].cur_num = 1;
+                                       k_idx = 0;
+                               }
+                       }
+
+                       if (k_idx)
+                       {
+                               /* Get local object */
+                               q_ptr = &forge;
+
+                               /* Prepare to make a reward */
+                               object_prep(q_ptr, k_idx);
+
+                               apply_magic(q_ptr, object_level, AM_GOOD);
+
+                               /* Drop it in the dungeon */
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
 #ifdef JP
-               msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
+                       msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
 #else
-               msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
+                       msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
 #endif
+               }
        }
 
        /* Determine how much we can drop */
@@ -1400,6 +1391,9 @@ msg_print("
        /* Average dungeon and monster levels */
        object_level = (dun_level + r_ptr->level) / 2;
 
+       if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
+       if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
+
        /* Drop some objects */
        for (j = 0; j < number; j++)
        {
@@ -1423,7 +1417,7 @@ msg_print("
                else
                {
                        /* Make an object */
-                       if (!make_object(q_ptr, good, great)) continue;
+                       if (!make_object(q_ptr, mo_mode)) continue;
 
                        /* XXX XXX XXX */
                        dump_item++;
@@ -1452,7 +1446,7 @@ msg_print("
        if (p_ptr->inside_battle) return;
 
        /* Winner? */
-       if (m_ptr->r_idx == MON_SERPENT)
+       if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
        {
                /* Total winner */
                p_ptr->total_winner = TRUE;
@@ -1463,10 +1457,10 @@ msg_print("
 #ifdef JP
                do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
 #else
-               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finly!");
+               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
 #endif
 
-               if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
+               if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
                {
 #ifdef JP
                        msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
@@ -1479,23 +1473,22 @@ msg_print("
 
                /* Congratulations */
 #ifdef JP
-msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
+               msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
 #else
                msg_print("*** CONGRATULATIONS ***");
 #endif
 
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
+               msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
 #else
                msg_print("You have won the game!");
 #endif
 
 #ifdef JP
-msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
+               msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
 #else
                msg_print("You may retire (commit suicide) when you are ready.");
 #endif
-
        }
 }
 
@@ -1564,8 +1557,8 @@ static void get_exp_from_mon(int dam, monster_type *m_ptr)
                }
                else
                {
-                       m_exp = (long)r_ptr->mexp * r_ptr->level * extract_energy[m_ptr->mspeed];
-                       div = (p_ptr->max_plv+2) * extract_energy[r_ptr->speed];
+                       m_exp = (long)r_ptr->mexp * r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed);
+                       div = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
                }
                m_exp_h = m_exp/0x10000L;
                m_exp_l = m_exp%0x10000L;
@@ -1723,11 +1716,41 @@ bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
 
                if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
                {
+                       /* You might have unmasked Tanuki first time */
                        r_ptr = &r_info[m_ptr->r_idx];
                        m_ptr->ap_r_idx = m_ptr->r_idx;
                        if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
                }
 
+               if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
+               {
+                       /* You might have unmasked Chameleon first time */
+                       r_ptr = real_r_ptr(m_ptr);
+                       if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
+               }
+
+               /* When the player kills a Unique, it stays dead */
+               if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
+                       r_ptr->max_num = 0;
+
+               /* When the player kills a Nazgul, it stays dead */
+               if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
+
+               /* Recall even invisible uniques or winners */
+               if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
+               {
+                       /* Count kills this life */
+                       if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
+                       else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
+
+                       /* Count kills in all lives */
+                       if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
+                       else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
+
+                       /* Hack -- Auto-recall */
+                       monster_race_track(m_ptr->ap_r_idx);
+               }
+
                /* Extract monster name */
                monster_desc(m_name, m_ptr, 0x100);
 
@@ -1887,8 +1910,16 @@ msg_format("%^s
                        if (one_in_(4)) chg_virtue(V_NATURE, -1);
                }
 
-               if((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
-                       do_cmd_write_nikki(NIKKI_UNIQUE, 0, r_name + r_ptr->name);
+               if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
+               {
+                       char m_name[160];
+#ifdef JP
+                       sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
+#else
+                       sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
+#endif
+                       do_cmd_write_nikki(NIKKI_UNIQUE, 0, m_name);
+               }
 
                /* Make a sound */
                sound(SOUND_KILL);
@@ -1961,7 +1992,7 @@ msg_format("%s
                {
                        for (i = 0; i < MAX_KUBI; i++)
                        {
-                               if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG_CHAMELEON))
+                               if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
                                {
 #ifdef JP
 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
@@ -1973,44 +2004,8 @@ msg_format("%s
                        }
                }
 
-               if (r_ptr->flags7 & RF7_KILL_EXP)
-                       get_exp_from_mon((long)m_ptr->max_maxhp*2, &exp_mon);
-               else
-                       get_exp_from_mon(((long)m_ptr->max_maxhp+1L) * 9L / 10L, &exp_mon);
-
                /* Generate treasure */
                monster_death(m_idx, TRUE);
-               if (m_ptr->mflag2 & MFLAG_CHAMELEON)
-               {
-                       if (r_ptr->flags1 & RF1_UNIQUE)
-                               r_ptr = &r_info[MON_CHAMELEON_K];
-                       else
-                               r_ptr = &r_info[MON_CHAMELEON];
-                       if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
-               }
-
-               /* When the player kills a Unique, it stays dead */
-               if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
-                       r_ptr->max_num = 0;
-
-               /* When the player kills a Nazgul, it stays dead */
-               if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
-
-               /* Recall even invisible uniques or winners */
-               if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
-               {
-                       /* Count kills this life */
-                       if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
-                       else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
-
-                       /* Count kills in all lives */
-                       if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
-                       else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
-
-                       /* Hack -- Auto-recall */
-                       monster_race_track(m_ptr->ap_r_idx);
-               }
-
                if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
                {
                        r_info[MON_BANORLUPART].max_num = 0;
@@ -2056,6 +2051,12 @@ msg_format("%s
                        delete_monster_idx(m_idx);
                }
 
+               /* Prevent bug of chaos patron's reward */
+               if (r_ptr->flags7 & RF7_KILL_EXP)
+                       get_exp_from_mon((long)m_ptr->max_maxhp*2, &exp_mon);
+               else
+                       get_exp_from_mon(((long)m_ptr->max_maxhp+1L) * 9L / 10L, &exp_mon);
+
                /* Not afraid */
                (*fear) = FALSE;
 
@@ -2532,7 +2533,7 @@ cptr look_mon_desc(int m_idx, u32b mode)
        }
 
        /* Display monster's level --- idea borrowed from ToME */
-       if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG_KAGE))
+       if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
        {
 #ifdef JP
                return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
@@ -2895,14 +2896,16 @@ static bool target_set_accept(int y, int x)
                if ((feat >= FEAT_DOOR_HEAD) &&
                    (feat <= FEAT_DOOR_TAIL)) return (TRUE);
 
+#if 0
                /* Notice rubble */
                /* I think FEAT_RUBBLEs should not be "interesting" */
-#if 0
                if (feat == FEAT_RUBBLE) return (TRUE);
-#endif
+
                /* Notice veins with treasure */
+               /* Now veins with treasure are too many */
                if (feat == FEAT_MAGMA_K) return (TRUE);
                if (feat == FEAT_QUARTZ_K) return (TRUE);
+#endif
 
                /* Notice quest features */
                if (feat == FEAT_QUEST_ENTER) return (TRUE);
@@ -3004,7 +3007,7 @@ static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
        M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
        if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
                sprintf(buf,"**");
-       else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG_KAGE))
+       else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
                sprintf(buf,"??");
        else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
                sprintf(buf,"001");
@@ -3074,7 +3077,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
        int floor_list[23], floor_num = 0;
 
        /* Scan all objects in the grid */
-       if (easy_floor && (mode & TARGET_LOOK))
+       if (easy_floor)
        {
                floor_num = scan_floor(floor_list, y, x, 0x02);
 
@@ -3148,6 +3151,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
        {
                monster_type *m_ptr = &m_list[c_ptr->m_idx];
                monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
+               char m_name[80];
                bool recall = FALSE;
 
                /* Not boring */
@@ -3232,7 +3236,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
                if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
 
                /* Sometimes stop at "space" key */
-               if ((query == ' ' || query == 'x') && !(mode & (TARGET_LOOK))) return query;
+               if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
 
                /* Change the intro */
 #ifdef JP
@@ -3296,7 +3300,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
                        if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
 
                        /* Sometimes stop at "space" key */
-                       if ((query == ' ' || query == 'x') && !(mode & (TARGET_LOOK))) return query;
+                       if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
 
                        /* Change the intro */
 #ifdef JP
@@ -3423,12 +3427,12 @@ static int target_set_aux(int y, int x, int mode, cptr info)
 
                                /* Remove the first object from the list. */
                                excise_object_idx(o_idx);
-       
+
                                /* Find end of the list. */
                                i = c_ptr->o_idx;
                                while (o_list[i].next_o_idx)
                                        i = o_list[i].next_o_idx;
-       
+
                                /* Add after the last object. */
                                o_list[i].next_o_idx = o_idx;
 
@@ -3436,8 +3440,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
                        }
                }
 
-               /* End this grid */
-               return query;
+               /* NOTREACHED */
        }
 #endif /* ALLOW_EASY_FLOOR */
 
@@ -3476,7 +3479,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
                        query = inkey();
 
                        /* Always stop at "normal" keys */
-                       if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
+                       if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
 
                        /* Sometimes stop at "space" key */
                        if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
@@ -5371,7 +5374,7 @@ msg_print("
                        msg_print("'Death and destruction! This pleaseth me!'");
 #endif
 
-                       destroy_area(py, px, 25, TRUE);
+                       (void)destroy_area(py, px, 25, FALSE);
 #ifdef JP
                        reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
 #else
@@ -5944,4 +5947,40 @@ cptr your_alignment(void)
 }
 
 
+/*
+ * Return proficiency level of weapons and misc. skills (except riding)
+ */
+int weapon_exp_level(int weapon_exp)
+{
+       if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
+       else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
+       else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
+       else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
+       else return EXP_LEVEL_MASTER;
+}
 
+
+/*
+ * Return proficiency level of riding
+ */
+int riding_exp_level(int riding_exp)
+{
+       if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
+       else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
+       else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
+       else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
+       else return EXP_LEVEL_MASTER;
+}
+
+
+/*
+ * Return proficiency level of spells
+ */
+int spell_exp_level(int spell_exp)
+{
+       if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
+       else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
+       else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
+       else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
+       else return EXP_LEVEL_MASTER;
+}