OSDN Git Service

空腹充足の巻物の記述を削除.
[hengband/hengband.git] / src / xtra2.c
index 0ee635f..ca129b2 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;
+       int  old_lev = p_ptr->lev;
 
        /* Hack -- lower limit */
        if (p_ptr->exp < 0) p_ptr->exp = 0;
-
-       /* Hack -- lower limit */
        if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
+       if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
 
        /* Hack -- upper limit */
        if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
-
-       /* Hack -- upper limit */
        if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
+       if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
 
        /* Hack -- maintain "max" experience */
        if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
 
+       /* Hack -- maintain "max max" experience */
+       if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
+
        /* Redraw experience */
        p_ptr->redraw |= (PR_EXP);
 
@@ -107,24 +104,25 @@ void check_experience(void)
 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
 #else
                msg_format("Welcome to level %d.", p_ptr->lev);
+
 #endif
 
                /* Update some stuff */
                p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
 
                /* Redraw some stuff */
-               p_ptr->redraw |= (PR_LEV | PR_TITLE);
+               p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
 
                /* Window stuff */
-               p_ptr->window |= (PW_PLAYER | PW_SPELL);
+               p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
 
                /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
-                level_up = 1;
+               level_up = 1;
 
                /* Handle stuff */
                handle_stuff();
 
-                level_up = 0;
+               level_up = 0;
 
                if (level_inc_stat)
                {
@@ -223,6 +221,9 @@ msg_print("
                /* Handle stuff */
                handle_stuff();
        }
+
+       /* Load an autopick preference file */
+       if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
 }
 
 
@@ -234,24 +235,19 @@ msg_print("
  */
 static int get_coin_type(int r_idx)
 {
-       monster_race    *r_ptr = &r_info[r_idx];
-
-       /* Analyze "coin" monsters */
-       if (r_ptr->d_char == '$')
+       /* Analyze monsters */
+       switch (r_idx)
        {
-               /* Look for textual clues */
-               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: return (16);
-               case MON_ADAMANT_COINS: return (17);
-               }
+       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);
+       return 0;
 }
 
 
@@ -364,6 +360,24 @@ static bool kind_is_armor(int k_idx)
 
 
 /*
+ * Hack -- determine if a template is hafted weapon
+ */
+static bool kind_is_hafted(int k_idx)
+{
+       object_kind *k_ptr = &k_info[k_idx];
+
+       /* Analyze the item type */
+       if (k_ptr->tval == TV_HAFTED)
+       {
+               return (TRUE);
+       }
+
+       /* Assume not good */
+       return (FALSE);
+}
+
+
+/*
  * Check for "Quest" completion when a quest monster is killed or charmed.
  */
 void check_quest_completion(monster_type *m_ptr)
@@ -590,10 +604,10 @@ msg_print("
 
 
                /* Create stairs down */
-               cave_set_feat(y, x, FEAT_MORE);
+               cave_set_feat(y, x, feat_down_stair);
 
                /* Remember to update everything */
-               p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS);
+               p_ptr->update |= (PU_FLOW);
        }
 
        /*
@@ -610,7 +624,7 @@ msg_print("
                        object_wipe(q_ptr);
 
                        /* Make a great object */
-                       make_object(q_ptr, TRUE, TRUE);
+                       make_object(q_ptr, AM_GOOD | AM_GREAT);
 
                        /* Drop it in the dungeon */
                        (void)drop_near(q_ptr, -1, y, x);
@@ -618,6 +632,45 @@ msg_print("
        }
 }
 
+
+/*
+ * Return monster death string
+ */
+cptr extract_note_dies(monster_race *r_ptr)
+{
+       /* Some monsters get "destroyed" */
+       if (!monster_living(r_ptr))
+       {
+               int i;
+
+               for (i = 0; i < 4; i++)
+               {
+                       if (r_ptr->blow[i].method == RBM_EXPLODE)
+                       {
+#ifdef JP
+                               return "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
+#else
+                               return " explodes into tiny shreds.";
+#endif
+                       }
+               }
+
+#ifdef JP
+               return "¤òÅݤ·¤¿¡£";
+#else
+               return " is destroyed.";
+#endif
+       }
+
+       /* Assume a default death */
+#ifdef JP
+       return "¤Ï»à¤ó¤À¡£";
+#else
+       return " dies.";
+#endif
+}
+
+
 /*
  * Handle the "death" of a monster.
  *
@@ -645,24 +698,26 @@ void monster_death(int m_idx, bool drop_item)
 
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
+       bool visible = ((m_ptr->ml && !p_ptr->image) || (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 = 0L;
 
        bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
        bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
-       bool cloned = FALSE;
+       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);
 
-       if (world_monster) world_monster = FALSE;
+       /* The caster is dead? */
+       if (world_monster && world_monster == m_idx) world_monster = 0;
 
        /* Notice changes in view */
-       if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2 | RF7_SELF_LITE_1 | RF7_SELF_LITE_2))
+       if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
        {
                /* Update some things */
                p_ptr->update |= (PU_MON_LITE);
@@ -672,76 +727,31 @@ void monster_death(int m_idx, bool drop_item)
        y = m_ptr->fy;
        x = m_ptr->fx;
 
-       if (m_ptr->smart & SM_CLONED)
-               cloned = TRUE;
-
        if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
        {
                char m_name[80];
 
-               monster_desc(m_name, m_ptr, 0x08);
+               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) || (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];
@@ -753,11 +763,6 @@ void monster_death(int m_idx, bool drop_item)
        /* Handle the possibility of player vanquishing arena combatant -KMW- */
        if (p_ptr->inside_arena && !is_pet(m_ptr))
        {
-               char m_name[80];
-
-               /* Extract monster name */
-               monster_desc(m_name, m_ptr, 0);
-
                p_ptr->exit_bldg = TRUE;
 
                if (p_ptr->arena_number > MAX_ARENA_MONS)
@@ -777,15 +782,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, AM_NO_FIXED_ART);
 
                        /* Drop it in the dungeon */
                        (void)drop_near(q_ptr, -1, y, x);
@@ -793,7 +798,15 @@ msg_print("
 
                if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
                p_ptr->arena_number++;
-               if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
+               if (record_arena)
+               {
+                       char m_name[80];
+                       
+                       /* 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)
@@ -810,9 +823,8 @@ msg_print("
 
        /* Drop a dead corpse? */
        if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
-           ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
-            (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle || (m_ptr->smart & SM_CLONED) || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
+           (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;
@@ -823,7 +835,7 @@ msg_print("
                 */
                if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
                        corpse = TRUE;
-               else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
+               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 */
@@ -846,7 +858,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, AM_NO_FIXED_ART);
 
                q_ptr->pval = m_ptr->r_idx;
 
@@ -857,526 +869,591 @@ 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))
+       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)
        {
-               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);
-
-                       do
-                       {
-                               scatter(&wy, &wx, py, px, 20, 0);
-                       }
-                       while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
+                       bool notice = FALSE;
 
-                       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
-
-                               }
-                       }
                }
-       }
+               break;
 
-       /* 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;
-
-               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, AM_NO_FIXED_ART | mo_mode);
+
+                       /* Drop it in the dungeon */
+                       (void)drop_near(q_ptr, -1, y, x);
                }
+               break;
 
-               if (notice)
-#ifdef JP
-                       msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
-#else
-                       msg_print("The Pink horror divides!");
-#endif
+       case MON_RAAL:
+               if (drop_chosen_item && (dun_level > 9))
+               {
+                       /* Get local object */
+                       q_ptr = &forge;
 
-       }
-       /* One more ultra-hack: An Unmaker goes out with a big bang! */
-       else if (m_ptr->r_idx == MON_UNMAKER)
+                       /* Wipe the object */
+                       object_wipe(q_ptr);
 
-       {
-               int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
-               (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
-       }
+                       /* 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;
 
-       /* Bloodletters of Khorne may drop a blade of chaos */
-       else if (m_ptr->r_idx == MON_BLOODLETTER &&
+                       /* Make a book */
+                       make_object(q_ptr, mo_mode);
 
-                (randint1(100) < 15) &&
-           !(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;
 
-               /* Prepare to make a Blade of Chaos */
-               object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
+       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 = y, wx = x;
+                               int attempts = 100;
+                               bool pet = is_pet(m_ptr);
 
-               apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
+                               do
+                               {
+                                       scatter(&wy, &wx, y, x, 20, 0);
+                               }
+                               while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
 
-               /* Drop it in the dungeon */
-               (void)drop_near(q_ptr, -1, y, x);
-       }
+                               if (attempts > 0)
+                               {
+                                       u32b mode = 0L;
+                                       if (pet) mode |= PM_FORCE_PET;
 
-       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;
+                                       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
 
-               /* Wipe the object */
-               object_wipe(q_ptr);
+                                       }
+                               }
+                       }
+               }
+               break;
 
-               /* 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;
+       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;
 
-               /* Prepare allocation table */
-               get_obj_num_prep();
+       case MON_UNICORN_ORD:
+       case MON_MORGOTH:
+       case MON_ONE_RING:
+               /* Reward for "lazy" player */
+               if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
+               {
+                       int a_idx = 0;
+                       artifact_type *a_ptr = NULL;
 
-               /* Make a great object */
-               make_object(q_ptr, FALSE, FALSE);
+                       if (!drop_chosen_item) break;
 
-               /* Drop it in the dungeon */
-               (void)drop_near(q_ptr, -1, y, x);
-       }
+                       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;
+                               }
 
-       else if (m_ptr->r_idx == MON_B_DEATH_SWORD &&
-           !(p_ptr->inside_arena || p_ptr->inside_battle))
-       {
-               /* Get local object */
-               q_ptr = &forge;
+                               a_ptr = &a_info[a_idx];
+                       }
+                       while (a_ptr->cur_num);
 
-               /* Prepare to make a Blade of Chaos */
-               object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
+                       /* Create the artifact */
+                       if (create_named_art(a_idx, y, x))
+                       {
+                               a_ptr->cur_num = 1;
 
-               /* Drop it in the dungeon */
-               (void)drop_near(q_ptr, -1, y, x);
-       }
+                               /* 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;
 
-       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);
-
-               /* Activate restriction */
-               get_obj_num_hook = kind_is_sword;
+               /* Mega-Hack -- Prepare to make "Grond" */
+               object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
 
-               /* Prepare allocation table */
-               get_obj_num_prep();
+               /* Mega-Hack -- Mark this item as "Grond" */
+               q_ptr->name1 = ART_GROND;
 
-               /* Make a great object */
-               make_object(q_ptr, FALSE, FALSE);
+               /* Mega-Hack -- Actually create "Grond" */
+               apply_magic(q_ptr, -1, 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_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_akills % 5 == 0))))
+               {
+                       /* 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, AM_NO_FIXED_ART);
 
-       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;
+                               /* Make a cloak */
+                               make_object(q_ptr, mo_mode);
 
-               /* Prepare to make a Blade of Chaos */
-               object_prep(q_ptr, lookup_kind(TV_CHEST, 50));
+                               /* Drop it in the dungeon */
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
 
-               apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
+               case '/':
+                       if (dun_level > 4)
+                       {
+                               /* Get local object */
+                               q_ptr = &forge;
 
-               /* 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)
+                               /* Wipe the object */
+                               object_wipe(q_ptr);
 
-               {
-                       /* Get local object */
-                       q_ptr = &forge;
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_polearm;
 
-                       /* Mega-Hack -- Prepare to make "Grond" */
-                       object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
+                               /* Make a poleweapon */
+                               make_object(q_ptr, mo_mode);
 
-                       /* Mega-Hack -- Mark this item as "Grond" */
-                       q_ptr->name1 = ART_GROND;
+                               /* Drop it in the dungeon */
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
 
-                       /* Mega-Hack -- Actually create "Grond" */
-                       apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
+               case '[':
+                       if (dun_level > 19)
+                       {
+                               /* Get local object */
+                               q_ptr = &forge;
 
-                       /* Drop it in the dungeon */
-                       (void)drop_near(q_ptr, -1, y, x);
+                               /* Wipe the object */
+                               object_wipe(q_ptr);
 
-                       /* Get local object */
-                       q_ptr = &forge;
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_armor;
 
-                       /* Mega-Hack -- Prepare to make "Morgoth" */
-                       object_prep(q_ptr, lookup_kind(TV_CROWN, SV_MORGOTH));
+                               /* Make a hard armor */
+                               make_object(q_ptr, mo_mode);
 
-                       /* Mega-Hack -- Mark this item as "Morgoth" */
-                       q_ptr->name1 = ART_CHAOS;
+                               /* Drop it in the dungeon */
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
 
-                       /* Mega-Hack -- Actually create "Morgoth" */
-                       apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
+               case '\\':
+                       if (dun_level > 4)
+                       {
+                               /* Get local object */
+                               q_ptr = &forge;
 
-                       /* Drop it in the dungeon */
-                       (void)drop_near(q_ptr, -1, y, x);
-               }
-               else
-               {
-                       int a_idx = 0;
-                       int chance = 0;
+                               /* Wipe the object */
+                               object_wipe(q_ptr);
+
+                               /* Activate restriction */
+                               get_obj_num_hook = kind_is_hafted;
+
+                               /* Make a hafted weapon */
+                               make_object(q_ptr, mo_mode);
+
+                               /* 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;
+                               /* Make a sword */
+                               make_object(q_ptr, mo_mode);
 
-                       case MON_STORMBRINGER:
-                               a_idx = ART_STORMBRINGER;
-                               chance = 100;
-                               break;
+                               /* Drop it in the dungeon */
+                               (void)drop_near(q_ptr, -1, y, x);
+                       }
+                       break;
+               }
+               break;
+       }
+
+       /* Mega-Hack -- drop fixed items */
+       if (drop_chosen_item)
+       {
+               int a_idx = 0;
+               int chance = 0;
 
-                       case MON_ECHIZEN:
-                               a_idx = ART_CRIMSON;
+               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_BRAND:
+                       if (!one_in_(3))
+                       {
+                               a_idx = ART_BRAND;
+                               chance = 25;
+                       }
+                       else
+                       {
+                               a_idx = ART_WEREWINDLE;
+                               chance = 33;
+                       }
+                       break;
 
-                       case MON_SARUMAN:
-                               a_idx = ART_ELENDIL;
+               case MON_CORWIN:
+                       if (!one_in_(3))
+                       {
+                               a_idx = ART_GRAYSWANDIR;
                                chance = 33;
-                               break;
+                       }
+                       else
+                       {
+                               a_idx = ART_CORWIN;
+                               chance = 33;
+                       }
+                       break;
 
-                       case MON_FIONA:
-                               a_idx = ART_FIONA;
-                               chance = 50;
-                               break;
+               case MON_SURTUR:
+                       a_idx = ART_TWILIGHT;
+                       chance = 66;
+                       break;
 
-                       case MON_JULIAN:
-                               a_idx = ART_JULIAN;
-                               chance = 45;
-                               break;
+               case MON_SARUMAN:
+                       a_idx = ART_ELENDIL;
+                       chance = 33;
+                       break;
 
-                       case MON_KLING:
-                               a_idx = ART_DESTINY;
-                               chance = 40;
-                               break;
+               case MON_FIONA:
+                       a_idx = ART_FIONA;
+                       chance = 50;
+                       break;
 
-                       case MON_GOEMON:
-                               a_idx = ART_ZANTETSU;
-                               chance = 75;
-                               break;
+               case MON_JULIAN:
+                       a_idx = ART_JULIAN;
+                       chance = 45;
+                       break;
 
-                       case MON_HAGEN:
-                               a_idx = ART_HAGEN;
-                               chance = 66;
-                               break;
+               case MON_KLING:
+                       a_idx = ART_DESTINY;
+                       chance = 40;
+                       break;
 
-                       case MON_CAIN:
-                               a_idx = ART_CAINE;
-                               chance = 50;
-                               break;
+               case MON_GOEMON:
+                       a_idx = ART_ZANTETSU;
+                       chance = 75;
+                       break;
 
-                       case MON_BULLGATES:
-                               a_idx = ART_WINBLOWS;
-                               chance = 66;
-                               break;
+               case MON_HAGEN:
+                       a_idx = ART_HAGEN;
+                       chance = 66;
+                       break;
 
-                       case MON_LUNGORTHIN:
-                               a_idx = ART_CALRIS;
-                               chance = 50;
-                               break;
+               case MON_CAINE:
+                       a_idx = ART_CAINE;
+                       chance = 50;
+                       break;
 
-                       case MON_JACK_SHADOWS:
-                               a_idx = ART_JACK;
-                               chance = 15;
-                               break;
+               case MON_BULLGATES:
+                       a_idx = ART_WINBLOWS;
+                       chance = 66;
+                       break;
 
-                       case MON_DIO:
-                               a_idx = ART_STONEMASK;
-                               chance = 20;
-                               break;
+               case MON_LUNGORTHIN:
+                       a_idx = ART_CALRIS;
+                       chance = 50;
+                       break;
 
-                       case MON_BELD:
-                               a_idx = ART_SOULCRUSH;
-                               chance = 10;
-                               break;
+               case MON_JACK_SHADOWS:
+                       a_idx = ART_JACK;
+                       chance = 15;
+                       break;
 
-                       case MON_PIP:
-                               a_idx = ART_EXCALIBUR_J;
-                               chance = 50;
-                               break;
+               case MON_DIO:
+                       a_idx = ART_STONEMASK;
+                       chance = 20;
+                       break;
 
-                       case MON_SHUTEN:
-                               a_idx = ART_SHUTEN_DOJI;
-                               chance = 33;
-                               break;
+               case MON_BELD:
+                       a_idx = ART_SOULCRUSH;
+                       chance = 10;
+                       break;
 
-                       case MON_GOTHMOG:
-                               a_idx = ART_GOTHMOG;
-                               chance = 33;
-                               break;
+               case MON_PIP:
+                       a_idx = ART_EXCALIBUR_J;
+                       chance = 50;
+                       break;
 
-                       case MON_FUNDIN:
-                               a_idx = ART_FUNDIN;
-                               chance = 5;
-                               break;
-                       }
+               case MON_SHUTEN:
+                       a_idx = ART_SHUTEN_DOJI;
+                       chance = 33;
+                       break;
+
+               case MON_GOTHMOG:
+                       a_idx = ART_GOTHMOG;
+                       chance = 33;
+                       break;
+
+               case MON_FUNDIN:
+                       a_idx = ART_FUNDIN;
+                       chance = 5;
+                       break;
+               }
+
+               if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
+               {
+                       artifact_type *a_ptr = &a_info[a_idx];
 
-                       if ((a_idx > 0) && ((randint0(100) < chance) || (p_ptr->wizard)))
+                       if (!a_ptr->cur_num)
                        {
-                               if (a_info[a_idx].cur_num == 0)
+                               /* Create the artifact */
+                               if (create_named_art(a_idx, y, x))
                                {
-                                       /* Create the artifact */
-                                       create_named_art(a_idx, y, x);
+                                       a_ptr->cur_num = 1;
 
-                                       a_info[a_idx].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) && !p_ptr->inside_battle && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
-       {
-               int k_idx = 198; /* Acquirement */;
-
-               if (d_info[dungeon_type].final_object)
-                       k_idx = d_info[dungeon_type].final_object;
 
-               if (d_info[dungeon_type].final_artifact)
+               if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
                {
-                       int a_idx = d_info[dungeon_type].final_artifact;
-                       if (a_info[a_idx].cur_num == 0)
+                       int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
+                               : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
+
+                       if (d_info[dungeon_type].final_artifact)
                        {
-                               /* Create the artifact */
-                               create_named_art(a_idx, y, x);
+                               int a_idx = d_info[dungeon_type].final_artifact;
+                               artifact_type *a_ptr = &a_info[a_idx];
 
-                               a_info[a_idx].cur_num = 1;
-                               k_idx = 0;
+                               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_type].final_object) k_idx = 0;
+                               }
                        }
-               }
 
-               if (k_idx)
-               {
-                       /* Get local object */
-                       q_ptr = &forge;
+                       if (k_idx)
+                       {
+                               /* Get local object */
+                               q_ptr = &forge;
 
-                       /* Prepare to make a reward */
-                       object_prep(q_ptr, k_idx);
+                               /* Prepare to make a reward */
+                               object_prep(q_ptr, k_idx);
 
-                       apply_magic(q_ptr, object_level, FALSE, TRUE, FALSE, FALSE);
+                               apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
 
-                       /* 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);
+                       }
 #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 */
@@ -1423,7 +1500,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 +1529,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 +1540,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 +1556,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
-
        }
 }
 
@@ -1512,20 +1588,20 @@ int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
 {
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
 
-       if ((r_ptr->flags3 & RF3_RES_ALL) && dam > 0)
+       if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
        {
                dam /= 100;
-               if((dam == 0) && one_in_(3)) dam = 1;
+               if ((dam == 0) && one_in_(3)) dam = 1;
        }
 
-       if (m_ptr->invulner)
+       if (MON_INVULNER(m_ptr))
        {
                if (is_psy_spear)
                {
-                       if(!p_ptr->blind && m_ptr->ml)
+                       if (!p_ptr->blind && is_seen(m_ptr))
                        {
 #ifdef JP
-msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
+                               msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
 #else
                                msg_print("The barrier is penetrated!");
 #endif
@@ -1539,115 +1615,70 @@ msg_print("
        return (dam);
 }
 
+
+/*
+ * Calculate experience point to be get
+ *
+ * Even the 64 bit operation is not big enough to avoid overflaw
+ * unless we carefully choose orders of multiplication and division.
+ *
+ * Get the coefficient first, and multiply (potentially huge) base
+ * experience point of a monster later.
+ */
 static void get_exp_from_mon(int dam, monster_type *m_ptr)
 {
-       s32b         div, new_exp, new_exp_frac;
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
-       int          monnum_penarty = 0;
+
+       s32b new_exp;
+       u32b new_exp_frac;
+       s32b div_h;
+       u32b div_l;
 
        if (!m_ptr->r_idx) return;
        if (is_pet(m_ptr) || p_ptr->inside_battle) return;
+
+       /*
+        * - Ratio of monster's level to player's level effects
+        * - Varying speed effects
+        * - Get a fraction in proportion of damage point
+        */
+       new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
+       new_exp_frac = 0;
+       div_h = 0L;
+       div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
+
+       /* Use (average maxhp * 2) as a denominator */
+       if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
+               s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
        else
-       {
-               u32b m_exp;
-               u32b m_exp_h, m_exp_l;
-               u32b div_h, div_l;
-               if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
-               {
-                       monnum_penarty = r_ptr->r_pkills / 400;
-                       if (monnum_penarty > 8) monnum_penarty = 8;
-               }
-               if (r_ptr->flags1 & RF1_UNIQUE)
-               {
-                       m_exp = (long)r_ptr->mexp * r_ptr->level;
-                       div = (p_ptr->max_plv+2);
-               }
-               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_h = m_exp/0x10000L;
-               m_exp_l = m_exp%0x10000L;
-               m_exp_h *= dam;
-               m_exp_l *= dam;
-               m_exp_h += m_exp_l / 0x10000L;
-               m_exp_l %= 0x10000L;
-
-               /* real monster maxhp have effect on EXP */
-               if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
-               {
-                 u32b maxhp = m_ptr->max_maxhp*2;
-                 m_exp_h *= maxhp;
-                 m_exp_l *= maxhp;
-                 m_exp_h += m_exp_l / 0x10000L;
-                 m_exp_l %= 0x10000L;
+               s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
 
-                 div *= r_ptr->hdice * (r_ptr->hside + 1);
-               }
-               if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
-               div_h = div/0x10000L;
-               div_l = div%0x10000L;
-               div_h *= (m_ptr->max_maxhp*2);
-               div_l *= (m_ptr->max_maxhp*2);
-               div_h += div_l / 0x10000L;
-               div_l %= 0x10000L;
-
-               while (monnum_penarty)
-               {
-                       div_h *= 4;
-                       div_l *= 4;
-                       div_h += div_l / 0x10000L;
-                       div_l %= 0x10000L;
-                       monnum_penarty--;
-               }
+       /* Special penalty in the wilderness */
+       if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
+               s64b_mul(&div_h, &div_l, 0, 5);
+
+       /* Do division first to prevent overflaw */
+       s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
+
+       /* Special penalty for mutiply-monster */
+       if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
+       {
+               int monnum_penarty = r_ptr->r_akills / 400;
+               if (monnum_penarty > 8) monnum_penarty = 8;
 
-               m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
-               m_exp_h = m_exp_h >> 15;
-               div_l = (0x7fffffff & (div_h << 16)) | div_l;
-               div_h = div_h >> 15;
-
-#define M_INT_GREATER63(h1,l1,h2,l2)  ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
-#define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
-#define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
-#define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
-#define M_INT_DIV63(h1,l1,h2,l2,result) \
-               do{ \
-                 int bit=1; \
-                  result = 0; \
-                 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
-                 for(bit>>=1; bit>=1; bit>>=1){ \
-                   M_INT_RSHIFT63(h2, l2); \
-                   if(M_INT_GREATER63(h1, l1, h2, l2)) \
-                     {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
-                 } \
-                } while(0)
-
-               /* Give some experience for the kill */
-               M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
-
-               /* Handle fractional experience */
-               /* multiply 0x10000L to remainder */
-               m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
-               m_exp_l <<= 16;
-               M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
-               new_exp_frac += p_ptr->exp_frac;
-               /* Keep track of experience */
-               if (new_exp_frac >= 0x10000L)
+               while (monnum_penarty--)
                {
-                       new_exp++;
-                       p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
+                       /* Divide by 4 */
+                       s64b_RSHIFT(new_exp, new_exp_frac, 2);
                }
-               else
-               {
-                       p_ptr->exp_frac = (u16b)new_exp_frac;
-               }
-
-               /* Gain experience */
-               gain_exp(new_exp);
        }
-}
 
+       /* Finally multiply base experience point of the monster */
+       s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
+
+       /* Gain experience */
+       gain_exp_64(new_exp, new_exp_frac);
+}
 
 
 /*
@@ -1705,7 +1736,7 @@ bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
        if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
 
        /* Wake it up */
-       m_ptr->csleep = 0;
+       (void)set_monster_csleep(m_idx, 0);
 
        /* Hack - Cancel any special player stealth magics. -LM- */
        if (p_ptr->special_defense & NINJA_S_STEALTH)
@@ -1723,13 +1754,71 @@ 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++;
+               }
+
+               if (!(m_ptr->smart & SM_CLONED))
+               {
+                       /* When the player kills a Unique, it stays dead */
+                       if (r_ptr->flags1 & RF1_UNIQUE)
+                       {
+                               r_ptr->max_num = 0;
+
+                               /* Mega-Hack -- Banor & Lupart */
+                               if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
+                               {
+                                       r_info[MON_BANORLUPART].max_num = 0;
+                                       r_info[MON_BANORLUPART].r_pkills++;
+                                       r_info[MON_BANORLUPART].r_akills++;
+                                       if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
+                               }
+                               else if (m_ptr->r_idx == MON_BANORLUPART)
+                               {
+                                       r_info[MON_BANOR].max_num = 0;
+                                       r_info[MON_BANOR].r_pkills++;
+                                       r_info[MON_BANOR].r_akills++;
+                                       if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
+                                       r_info[MON_LUPART].max_num = 0;
+                                       r_info[MON_LUPART].r_pkills++;
+                                       r_info[MON_LUPART].r_akills++;
+                                       if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
+                               }
+                       }
+
+                       /* When the player kills a Nazgul, it stays dead */
+                       else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
+               }
+
+               /* Count all monsters killed */
+               if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
+
+               /* Recall even invisible uniques or winners */
+               if ((m_ptr->ml && !p_ptr->image) || (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);
+               monster_desc(m_name, m_ptr, MD_TRUE_NAME);
 
                /* Don't kill Amberites */
                if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
@@ -1794,19 +1883,18 @@ msg_format("%^s
                                chg_virtue(V_VALOUR, 2);
                }
 
-               if ((r_ptr->flags1 & RF1_UNIQUE) && ((r_ptr->flags3 & RF3_EVIL) ||
-                       (r_ptr->flags3 & RF3_GOOD)))
-                       
-                       chg_virtue(V_HARMONY, 2);
-
-               if ((r_ptr->flags1 & RF1_UNIQUE) && (r_ptr->flags3 & RF3_GOOD))
+               if (r_ptr->flags1 & RF1_UNIQUE)
                {
-                       chg_virtue(V_UNLIFE, 2);
-                       chg_virtue(V_VITALITY, -2);
-               }
+                       if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
 
-               if ((r_ptr->flags1 & RF1_UNIQUE) && one_in_(3))
-                       chg_virtue(V_INDIVIDUALISM, -1);
+                       if (r_ptr->flags3 & RF3_GOOD)
+                       {
+                               chg_virtue(V_UNLIFE, 2);
+                               chg_virtue(V_VITALITY, -2);
+                       }
+
+                       if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
+               }
 
                if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
                {
@@ -1815,7 +1903,6 @@ msg_format("%^s
 
                if ((r_ptr->flags3 & RF3_GOOD) &&
                        ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
-                       
                        chg_virtue(V_UNLIFE, 1);
 
                if (r_ptr->d_char == 'A')
@@ -1850,18 +1937,18 @@ msg_format("%^s
                                chg_virtue(V_HONOUR, 1);
                        }
                }
-               if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
+               if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
                {
                        chg_virtue(V_VALOUR, -1);
                }
-               
+
                for (i = 0; i < 4; i++)
                {
-                       if(r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
-               
+                       if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
+
                        if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
                                || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
-                       
+
                                thief = TRUE; /* Thief! */
                }
 
@@ -1874,7 +1961,6 @@ msg_format("%^s
                                chg_virtue(V_JUSTICE, 3);
                        else if (1+((r_ptr->level) / 10 + (2 * dun_level))
                                >= randint1(100))
-                               
                                chg_virtue(V_JUSTICE, 1);
                }
                else if (innocent)
@@ -1887,8 +1973,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 note_buf[160];
+#ifdef JP
+                       sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
+#else
+                       sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
+#endif
+                       do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
+               }
 
                /* Make a sound */
                sound(SOUND_KILL);
@@ -1927,9 +2021,9 @@ msg_format("%s
                        /* Special note at death */
                        if (explode)
 #ifdef JP
-msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
+                               msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
 #else
-                               msg_format("%s explodes into tiny shreds.", m_name);
+                               msg_format("%^s explodes into tiny shreds.", m_name);
 #endif
                        else
                        {
@@ -1957,11 +2051,11 @@ msg_format("%s
 #endif
 
                }
-               if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
+               if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
                {
                        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,60 +2067,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;
-                       r_info[MON_BANORLUPART].r_pkills++;
-                       if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
-               }
-
-               if (m_ptr->r_idx == MON_BANORLUPART)
-               {
-                       r_info[MON_BANOR].max_num = 0;
-                       r_info[MON_BANOR].r_pkills++;
-                       if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
-                       r_info[MON_LUPART].max_num = 0;
-                       r_info[MON_LUPART].r_pkills++;
-                       if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
-               }
 
                /* Mega hack : replace IKETA to BIKETAL */
                if ((m_ptr->r_idx == MON_IKETA) &&
@@ -2056,6 +2098,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)exp_mon.max_maxhp*2, &exp_mon);
+               else
+                       get_exp_from_mon(((long)exp_mon.max_maxhp+1L) * 9L / 10L, &exp_mon);
+
                /* Not afraid */
                (*fear) = FALSE;
 
@@ -2067,50 +2115,36 @@ msg_format("%s
 #ifdef ALLOW_FEAR
 
        /* Mega-Hack -- Pain cancels fear */
-       if (m_ptr->monfear && (dam > 0))
+       if (MON_MONFEAR(m_ptr) && (dam > 0))
        {
-               int tmp = randint1(dam);
-
-               /* Cure a little fear */
-               if (tmp < m_ptr->monfear)
-               {
-                       /* Reduce fear */
-                       m_ptr->monfear -= tmp;
-               }
-
-               /* Cure all the fear */
-               else
+               /* Cure fear */
+               if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
                {
-                       /* Cure fear */
-                       m_ptr->monfear = 0;
-
                        /* No more fear */
                        (*fear) = FALSE;
                }
        }
 
        /* Sometimes a monster gets scared by damage */
-       if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
+       if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
        {
-               int percentage;
-
                /* Percentage of fully healthy */
-               percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
+               int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
 
                /*
                 * Run (sometimes) if at 10% or less of max hit points,
                 * or (usually) when hit for half its current hit points
                 */
-                if ((randint1(10) >= percentage) ||
+               if ((randint1(10) >= percentage) ||
                    ((dam >= m_ptr->hp) && (randint0(100) < 80)))
                {
                        /* Hack -- note fear */
                        (*fear) = TRUE;
 
                        /* XXX XXX XXX Hack -- Add some timed fear */
-                       m_ptr->monfear = (randint1(10) +
-                                         (((dam >= m_ptr->hp) && (percentage > 7)) ?
-                                          20 : ((11 - percentage) * 5)));
+                       (void)set_monster_monfear(m_idx, (randint1(10) +
+                                         (((dam >= m_ptr->hp) && (percentage > 7)) ?
+                                          20 : ((11 - percentage) * 5))));
                }
        }
 
@@ -2227,12 +2261,6 @@ void redraw_window(void)
 {
        /* Only if the dungeon exists */
        if (!character_dungeon) return;
-       
-       /* Hack - Activate term zero for the redraw */
-       Term_activate(&term_screen[0]);
-       
-       /* Hack -- react to changes */
-       Term_xtra(TERM_XTRA_REACT, 0);
 
        /* Window stuff */
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
@@ -2245,9 +2273,6 @@ void redraw_window(void)
 
        /* Redraw */
        Term_redraw();
-
-       /* Refresh */
-       Term_fresh();
 }
 
 
@@ -2421,13 +2446,14 @@ void verify_panel(void)
 /*
  * Monster health description
  */
-cptr look_mon_desc(int m_idx)
+cptr look_mon_desc(monster_type *m_ptr, u32b mode)
 {
-       monster_type *m_ptr = &m_list[m_idx];
        monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
        bool         living;
        int          perc;
-       cptr desc = NULL;
+       cptr desc;
+       cptr attitude;
+       cptr clone;
 
        /* Determine if the monster is "living" */
        living = monster_living(ap_r_ptr);
@@ -2486,21 +2512,64 @@ cptr look_mon_desc(int m_idx)
 #endif
        }
 
+
+       /* Need attitude information? */
+       if (!(mode & 0x01))
+       {
+               /* Full information is not needed */
+               attitude = "";
+       }
+       else if (is_pet(m_ptr))
+       {
+#ifdef JP
+               attitude = ", ¥Ú¥Ã¥È";
+#else
+               attitude = ", pet";
+#endif
+       }
+       else if (is_friendly(m_ptr))
+       {
+#ifdef JP
+               attitude = ", Í§¹¥Åª";
+#else
+               attitude = ", friendly";
+#endif
+       }
+       else
+       {
+#ifdef JP
+               attitude = "";
+#else
+               attitude = "";
+#endif
+       }
+
+
+       /* Clone monster? */
+       if (m_ptr->smart & SM_CLONED)
+       {
+               clone = ", clone";
+       }
+       else
+       {
+               clone = "";
+       }
+
        /* 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", ap_r_ptr->level, desc);
+               return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
 #else
-               return format("Level %d, %s", ap_r_ptr->level, desc);
+               return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
 #endif
        }
        else 
        {
 #ifdef JP
-               return format("¥ì¥Ù¥ë???, %s", desc);
+               return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
 #else
-               return format("Level ???, %s", desc);
+               return format("Level ???, %s%s%s", desc, attitude, clone);
 #endif
        }
 }
@@ -2649,7 +2718,6 @@ bool target_okay(void)
 }
 
 
-
 /*
  * Sorting hook -- comp function -- by "distance to player"
  *
@@ -2683,6 +2751,75 @@ static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
 
 
 /*
+ * Sorting hook -- comp function -- by importance level of grids
+ *
+ * We use "u" and "v" to point to arrays of "x" and "y" positions,
+ * and sort the arrays by level of monster
+ */
+static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
+{
+       byte *x = (byte*)(u);
+       byte *y = (byte*)(v);
+       cave_type *ca_ptr = &cave[y[a]][x[a]];
+       cave_type *cb_ptr = &cave[y[b]][x[b]];
+       monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
+       monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
+       monster_race *ap_ra_ptr, *ap_rb_ptr;
+
+       /* The player grid */
+       if (y[a] == py && x[a] == px) return TRUE;
+       if (y[b] == py && x[b] == px) return FALSE;
+
+       /* Extract monster race */
+       if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
+       else ap_ra_ptr = NULL;
+       if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
+       else ap_rb_ptr = NULL;
+
+       if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
+       if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
+
+       /* Compare two monsters */
+       if (ap_ra_ptr && ap_rb_ptr)
+       {
+               /* Unique monsters first */
+               if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
+               if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
+
+               /* Shadowers first (¤¢¤ä¤·¤¤±Æ) */
+               if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
+               if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
+
+               /* Unknown monsters first */
+               if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
+               if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
+
+               /* Higher level monsters first (if known) */
+               if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
+               {
+                       if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
+                       if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
+               }
+
+               /* Sort by index if all conditions are same */
+               if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
+               if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
+       }
+
+       /* An object get higher priority */
+       if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
+       if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
+
+       /* Priority from the terrain */
+       if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
+       if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
+
+       /* If all conditions are same, compare distance */
+       return ang_sort_comp_distance(u, v, a, b);
+}
+
+
+/*
  * Sorting hook -- swap function -- by "distance to player"
  *
  * We use "u" and "v" to point to arrays of "x" and "y" positions,
@@ -2773,7 +2910,7 @@ static bool target_set_accept(int y, int x)
        if (!(in_bounds(y, x))) return (FALSE);
 
        /* Player grid is always interesting */
-       if ((y == py) && (x == px)) return (TRUE);
+       if (player_bold(y, x)) return (TRUE);
 
 
        /* Handle hallucination */
@@ -2804,68 +2941,17 @@ static bool target_set_accept(int y, int x)
                next_o_idx = o_ptr->next_o_idx;
 
                /* Memorized object */
-               if (o_ptr->marked) return (TRUE);
+               if (o_ptr->marked & OM_FOUND) return (TRUE);
        }
 
        /* Interesting memorized features */
        if (c_ptr->info & (CAVE_MARK))
        {
-                byte feat;
-
-                /* Feature code (applying "mimic" field) */
-                feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
-
-               /* Notice glyphs */
+               /* Notice object features */
                if (c_ptr->info & CAVE_OBJECT) return (TRUE);
 
-               /* Notice the Pattern */
-               if ((feat <= FEAT_PATTERN_XTRA2) &&
-                   (feat >= FEAT_PATTERN_START))
-                       return (TRUE);
-
-               /* Notice doors */
-               if (feat == FEAT_OPEN) return (TRUE);
-               if (feat == FEAT_BROKEN) return (TRUE);
-
-               /* Notice stairs */
-               if (feat == FEAT_LESS) return (TRUE);
-               if (feat == FEAT_MORE) return (TRUE);
-               if (feat == FEAT_LESS_LESS) return (TRUE);
-               if (feat == FEAT_MORE_MORE) return (TRUE);
-
-               /* Notice shops */
-               if ((feat >= FEAT_SHOP_HEAD) &&
-                   (feat <= FEAT_SHOP_TAIL)) return (TRUE);
-
-               if (feat == FEAT_MUSEUM) return (TRUE);
-
-               /* Notice buildings -KMW- */
-               if ((feat >= FEAT_BLDG_HEAD) &&
-                   (feat <= FEAT_BLDG_TAIL)) return (TRUE);
-
-               /* Notice traps */
-               if (is_trap(feat)) return (TRUE);
-
-               /* Notice doors */
-               if ((feat >= FEAT_DOOR_HEAD) &&
-                   (feat <= FEAT_DOOR_TAIL)) return (TRUE);
-
-               /* Notice rubble */
-               /* I think FEAT_RUBBLEs should not be "interesting" */
-#if 0
-               if (feat == FEAT_RUBBLE) return (TRUE);
-#endif
-               /* Notice veins with treasure */
-               if (feat == FEAT_MAGMA_K) return (TRUE);
-               if (feat == FEAT_QUARTZ_K) return (TRUE);
-
-               /* Notice quest features */
-               if (feat == FEAT_QUEST_ENTER) return (TRUE);
-               if (feat == FEAT_QUEST_EXIT) return (TRUE);
-               if (feat == FEAT_QUEST_DOWN) return (TRUE);
-               if (feat == FEAT_QUEST_UP) return (TRUE);
-               if (feat == FEAT_TOWN) return (TRUE);
-               if (feat == FEAT_ENTRANCE) return (TRUE);
+               /* Feature code (applying "mimic" field) */
+               if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
        }
 
        /* Nope */
@@ -2892,9 +2978,6 @@ static void target_set_prepare(int mode)
                {
                        cave_type *c_ptr;
 
-                       /* Require line of sight, unless "look" is "expanded" */
-                       if (!expand_look && !player_has_los_bold(y, x)) continue;
-
                        /* Require "interesting" contents */
                        if (!target_set_accept(y, x)) continue;
 
@@ -2913,8 +2996,18 @@ static void target_set_prepare(int mode)
        }
 
        /* Set the sort hooks */
-       ang_sort_comp = ang_sort_comp_distance;
-       ang_sort_swap = ang_sort_swap_distance;
+       if (mode & (TARGET_KILL))
+       {
+               /* Target the nearest monster for shooting */
+               ang_sort_comp = ang_sort_comp_distance;
+               ang_sort_swap = ang_sort_swap_distance;
+       }
+       else
+       {
+               /* Look important grids first in Look command */
+               ang_sort_comp = ang_sort_comp_importance;
+               ang_sort_swap = ang_sort_swap_distance;
+       }
 
        /* Sort the positions */
        ang_sort(temp_x, temp_y, temp_n);
@@ -2934,6 +3027,63 @@ static void target_set_prepare(int mode)
 
 
 /*
+ * Evaluate number of kill needed to gain level
+ */
+static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
+{
+       monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
+       u32b num;
+       s32b exp_mon, exp_adv;
+       u32b exp_mon_frac, exp_adv_frac;
+
+       if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
+       {
+               sprintf(buf,"**");
+               return;
+       }
+       else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
+       {
+               if (!p_ptr->wizard)
+               {
+                       sprintf(buf,"??");
+                       return;
+               }
+       }
+
+
+       /* The monster's experience point (assuming average monster speed) */
+       exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
+       exp_mon_frac = 0;
+       s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
+
+
+       /* Total experience value for next level */
+       exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
+       exp_adv_frac = 0;
+       s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
+
+       /* Experience value need to get */
+       s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
+
+
+       /* You need to kill at least one monster to get any experience */
+       s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
+       s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
+
+       /* Extract number of monsters needed */
+       s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
+
+       /* If 999 or more monsters needed, only display "999". */
+       num = MIN(999, exp_adv_frac);
+
+       /* Display the number */
+       sprintf(buf,"%03ld", num);
+}
+
+
+bool show_gold_on_floor = FALSE;
+
+/*
  * Examine a grid, return a keypress.
  *
  * The "mode" argument contains the "TARGET_LOOK" bit flag, which
@@ -2957,686 +3107,601 @@ static void target_set_prepare(int mode)
 static int target_set_aux(int y, int x, int mode, cptr info)
 {
        cave_type *c_ptr = &cave[y][x];
-
        s16b this_o_idx, next_o_idx = 0;
-
-       cptr s1, s2, s3;
-
-       bool boring;
-
-       byte feat;
-
-       int query;
-
+       cptr s1 = "", s2 = "", s3 = "", x_info = "";
+       bool boring = TRUE;
+       s16b feat;
+       feature_type *f_ptr;
+       int query = '\001';
        char out_val[MAX_NLEN+80];
 
+#ifdef ALLOW_EASY_FLOOR
+       int floor_list[23], floor_num = 0;
 
-       /* Repeat forever */
-       while (1)
+       /* Scan all objects in the grid */
+       if (easy_floor)
        {
-               /* Paranoia */
-               query = ' ';
-
-               /* Assume boring */
-               boring = TRUE;
+               floor_num = scan_floor(floor_list, y, x, 0x02);
 
-               /* Default */
+               if (floor_num)
+               {
 #ifdef JP
-s1 = "";
+                       x_info = "xʪ ";
 #else
-               s1 = "You see ";
+                       x_info = "x,";
 #endif
+               }
+       }
 
-               s2 = "";
-               s3 = "";
+#endif /* ALLOW_EASY_FLOOR */
 
-               /* Hack -- under the player */
-               if ((y == py) && (x == px))
-               {
-                       /* Description */
+       /* Hack -- under the player */
+       if (player_bold(y, x))
+       {
+               /* Description */
 #ifdef JP
-                       s1 = "¤¢¤Ê¤¿¤Ï";
-                       s2 = "¤Î¾å";
-                       s3 = "¤Ë¤¤¤ë";
+               s1 = "¤¢¤Ê¤¿¤Ï";
+               s2 = "¤Î¾å";
+               s3 = "¤Ë¤¤¤ë";
 #else
-                       s1 = "You are ";
+               s1 = "You are ";
 
-                       /* Preposition */
-                       s2 = "on ";
+               /* Preposition */
+               s2 = "on ";
 #endif
-
-               }
-               else
-               {
+       }
+       else
+       {
 #ifdef JP
-                       s1 = "¥¿¡¼¥²¥Ã¥È:";
+               s1 = "¥¿¡¼¥²¥Ã¥È:";
 #else
-                       s1 = "Target:";
+               s1 = "Target:";
 #endif
-               }
+       }
 
-               /* Hack -- hallucination */
-               if (p_ptr->image)
-               {
+       /* Hack -- hallucination */
+       if (p_ptr->image)
+       {
 #ifdef JP
-cptr name = "²¿¤«´ñ̯¤Êʪ";
+               cptr name = "²¿¤«´ñ̯¤Êʪ";
 #else
-                       cptr name = "something strange";
+               cptr name = "something strange";
 #endif
 
 
-                       /* Display a message */
+               /* Display a message */
 #ifdef JP
-                       sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
+               sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
 #else
-                       sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
+               sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
 #endif
 
-                       prt(out_val, 0, 0);
-                       move_cursor_relative(y, x);
-                       query = inkey();
-
-                       /* Stop on everything but "return" */
-                       if ((query != '\r') && (query != '\n')) break;
-
-                       /* Repeat forever */
-                       continue;
-               }
-
-
-               /* Actual monsters */
-               if (c_ptr->m_idx)
-               {
-                       monster_type *m_ptr = &m_list[c_ptr->m_idx];
-                       monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
-
-                       /* Visible */
-                       if (m_ptr->ml)
-                       {
-                               bool recall = FALSE;
-
-                               char m_name[80];
-
-                               /* Not boring */
-                               boring = FALSE;
+               prt(out_val, 0, 0);
+               move_cursor_relative(y, x);
+               query = inkey();
 
-                               /* Get the monster name ("a kobold") */
-                               monster_desc(m_name, m_ptr, 0x08);
+               /* Stop on everything but "return" */
+               if ((query != '\r') && (query != '\n')) return query;
 
-                               /* Hack -- track this monster race */
-                               monster_race_track(m_ptr->ap_r_idx);
+               /* Repeat forever */
+               return 0;
+       }
 
-                               /* Hack -- health bar for this monster */
-                               health_track(c_ptr->m_idx);
 
-                               /* Hack -- handle stuff */
-                               handle_stuff();
+       /* Actual monsters */
+       if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
+       {
+               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;
 
-                               /* Interact */
-                               while (1)
-                               {
-                                       /* Recall */
-                                       if (recall)
-                                       {
-                                               /* Save */
-                                               screen_save();
+               /* Not boring */
+               boring = FALSE;
 
-                                               /* Recall on screen */
-                                               screen_roff(m_ptr->ap_r_idx, 0);
+               /* Get the monster name ("a kobold") */
+               monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
 
-                                               /* Hack -- Complete the prompt (again) */
-#ifdef JP
-Term_addstr(-1, TERM_WHITE, format("  [r»× %s]", info));
-#else
-                                               Term_addstr(-1, TERM_WHITE, format("  [r,%s]", info));
-#endif
+               /* Hack -- track this monster race */
+               monster_race_track(m_ptr->ap_r_idx);
 
+               /* Hack -- health bar for this monster */
+               health_track(c_ptr->m_idx);
 
-                                               /* Command */
-                                               query = inkey();
+               /* Hack -- handle stuff */
+               handle_stuff();
 
-                                               /* Restore */
-                                               screen_load();
-                                       }
+               /* Interact */
+               while (1)
+               {
+                       char acount[10];
 
-                                       /* Normal */
-                                       else
-                                       {
-                                               cptr attitude;
-                                               cptr tekitou;
+                       /* Recall */
+                       if (recall)
+                       {
+                               /* Save */
+                               screen_save();
 
-                                               if (p_ptr->riding && (p_ptr->riding == c_ptr->m_idx))
-                                               {
-#ifdef JP
-                                                        tekitou = "(¥Ú¥Ã¥È)";
-#else
-                                                        tekitou = "(pet)";
-#endif
-                                               }
-                                               else
-                                               {
-                                                        tekitou = "";
-                                               }
+                               /* Recall on screen */
+                               screen_roff(m_ptr->ap_r_idx, 0);
 
-                                               if (is_pet(m_ptr) && (p_ptr->riding != c_ptr->m_idx))
+                               /* Hack -- Complete the prompt (again) */
 #ifdef JP
-attitude = " (¥Ú¥Ã¥È) ";
+                               Term_addstr(-1, TERM_WHITE, format("  [r»× %s%s]", x_info, info));
 #else
-                                                       attitude = " (pet) ";
+                               Term_addstr(-1, TERM_WHITE, format("  [r,%s%s]", x_info, info));
 #endif
 
-                                               else if (is_friendly(m_ptr))
-#ifdef JP
-attitude = " (ͧ¹¥Åª) ";
-#else
-                                                       attitude = " (friendly) ";
-#endif
+                               /* Command */
+                               query = inkey();
 
-                                               else
-#ifdef JP
-attitude = " ";
-#else
-                                                       attitude = " ";
-#endif
+                               /* Restore */
+                               screen_load();
 
+                               /* Normal commands */
+                               if (query != 'r') break;
 
-                                               /* Describe, and prompt for recall */
-{
-#define M_INT_GREATER(h1,l1,h2,l2)  ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
-#define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
-#define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
-#define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
-#define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
-#define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
-       char acount[10];
-       u32b tmp_h,tmp_l;
-       int bit,result;
-       u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
-       u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
-       u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
-       
-       u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
-       u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
-       
-       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(acount,"[**]");
-       else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG_KAGE))
-               sprintf(acount,"[??]");
-       else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
-               sprintf(acount,"[001]");
-       else 
-       {
-               M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
-               if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
-                       sprintf(acount,"[999]");
-               else
-               {
-                       bit=1; result=0;
-                       M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
-                       M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
-                       while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
-                       {
-                               M_INT_LSHIFT(exp_mon_h,exp_mon_l);
-                               bit <<= 1;
-                       }
-                       M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
-                       for(;bit>=1;bit>>=1)
-                       {
-                               if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
-                               {
-                                       result |= bit;
-                                       M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
-                               }
-                               M_INT_RSHIFT(exp_mon_h,exp_mon_l); 
+                               /* Toggle recall */
+                               recall = FALSE;
+
+                               /* Cleare recall text and repeat */
+                               continue;
                        }
-                       sprintf(acount,"[%03d]",result);
-               }
-       }
-       sprintf(out_val, 
+
+                       /*** Normal ***/
+
+                       /* Describe, and prompt for recall */
+                       evaluate_monster_exp(acount, m_ptr);
+
 #ifdef JP
-               "%s%s%s(%s)%s%s%s%s%s[r»× %s]",
-               acount, s1, m_name, look_mon_desc(c_ptr->m_idx), tekitou, s2, s3, 
+                       sprintf(out_val, "[%s]%s%s(%s)%s%s [r»× %s%s]", acount, s1, m_name, look_mon_desc(m_ptr, 0x01), s2, s3, x_info, info);
 #else
-               "%s%s%s%s%s(%s)%s%s%s[r, %s]",
-               acount, s1, s2, s3, m_name, look_mon_desc(c_ptr->m_idx), tekitou, 
+                       sprintf(out_val, "[%s]%s%s%s%s(%s) [r, %s%s]", acount, s1, s2, s3, m_name, look_mon_desc(m_ptr, 0x01), x_info, info);
 #endif
-               (m_ptr->smart & SM_CLONED ? " (clone)": ""),
-               attitude,info);
-}
 
-                                               prt(out_val, 0, 0);
+                       prt(out_val, 0, 0);
 
-                                               /* Place cursor */
-                                               move_cursor_relative(y, x);
+                       /* Place cursor */
+                       move_cursor_relative(y, x);
 
-                                               /* Command */
-                                               query = inkey();
-                                       }
+                       /* Command */
+                       query = inkey();
 
-                                       /* Normal commands */
-                                       if (query != 'r') break;
+                       /* Normal commands */
+                       if (query != 'r') break;
 
-                                       /* Toggle recall */
-                                       recall = !recall;
-                               }
+                       /* Toggle recall */
+                       recall = TRUE;
+               }
 
-                               /* Always stop at "normal" keys */
-                               if ((query != '\r') && (query != '\n') && (query != ' ')) break;
+               /* Always stop at "normal" keys */
+               if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
 
-                               /* Sometimes stop at "space" key */
-                               if ((query == ' ') && !(mode & (TARGET_LOOK))) break;
+               /* Sometimes stop at "space" key */
+               if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
 
-                               /* Change the intro */
+               /* Change the intro */
 #ifdef JP
-s1 = "¤½¤ì¤Ï";
+               s1 = "¤½¤ì¤Ï";
 #else
-                               s1 = "It is ";
+               s1 = "It is ";
 #endif
 
 
-                               /* Hack -- take account of gender */
+               /* Hack -- take account of gender */
 #ifdef JP
-if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
+               if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
 #else
-                               if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
+               if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
 #endif
 
 #ifdef JP
-else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
+               else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
 #else
-                               else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
+               else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
 #endif
 
 
-                               /* Use a preposition */
+               /* Use a preposition */
 #ifdef JP
-                               s2 = "¤ò";
-                               s3 = "»ý¤Ã¤Æ¤¤¤ë";
+               s2 = "¤ò";
+               s3 = "»ý¤Ã¤Æ¤¤¤ë";
 #else
-                               s2 = "carrying ";
+               s2 = "carrying ";
 #endif
 
 
-                               /* Scan all objects being carried */
-                               for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
-                               {
-                                       char o_name[MAX_NLEN];
+               /* Scan all objects being carried */
+               for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
+               {
+                       char o_name[MAX_NLEN];
 
-                                       object_type *o_ptr;
+                       object_type *o_ptr;
 
-                                       /* Acquire object */
-                                       o_ptr = &o_list[this_o_idx];
+                       /* Acquire object */
+                       o_ptr = &o_list[this_o_idx];
 
-                                       /* Acquire next object */
-                                       next_o_idx = o_ptr->next_o_idx;
+                       /* Acquire next object */
+                       next_o_idx = o_ptr->next_o_idx;
 
-                                       /* Obtain an object description */
-                                       object_desc(o_name, o_ptr, TRUE, 3);
+                       /* Obtain an object description */
+                       object_desc(o_name, o_ptr, 0);
 
-                                       /* Describe the object */
+                       /* Describe the object */
 #ifdef JP
-                                       sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
+                       sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
 #else
-                                       sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
+                       sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
 #endif
 
-                                       prt(out_val, 0, 0);
-                                       move_cursor_relative(y, x);
-                                       query = inkey();
+                       prt(out_val, 0, 0);
+                       move_cursor_relative(y, x);
+                       query = inkey();
 
-                                       /* Always stop at "normal" keys */
-                                       if ((query != '\r') && (query != '\n') && (query != ' ')) break;
+                       /* Always stop at "normal" keys */
+                       if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
 
-                                       /* Sometimes stop at "space" key */
-                                       if ((query == ' ') && !(mode & (TARGET_LOOK))) break;
+                       /* Sometimes stop at "space" key */
+                       if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
 
-                                       /* Change the intro */
+                       /* Change the intro */
 #ifdef JP
-s2 = "¤ò¤Þ¤¿";
+                       s2 = "¤ò¤Þ¤¿";
 #else
-                                       s2 = "also carrying ";
+                       s2 = "also carrying ";
 #endif
+               }
 
-                               }
-
-                               /* Double break */
-                               if (this_o_idx) break;
-
-                               /* Use a preposition */
+               /* Use a preposition */
 #ifdef JP
-                              s2 = "¤Î¾å";
-                              s3 = "¤Ë¤¤¤ë";
+               s2 = "¤Î¾å";
+               s3 = "¤Ë¤¤¤ë";
 #else
-                               s2 = "on ";
+               s2 = "on ";
 #endif
-
-                       }
-               }
+       }
 
 
 #ifdef ALLOW_EASY_FLOOR
+       if (floor_num)
+       {
+               int min_width = 0;
 
-               /* Scan all objects in the grid */
-               if (easy_floor)
+               while (1)
                {
-                       int floor_list[23], floor_num;
-                       int min_width = 0;
-
-                       floor_num = scan_floor(floor_list, y, x, 0x02);
-
-                       if (floor_num)
+                       if (floor_num == 1)
                        {
-                               /* Not boring */
-                               boring = FALSE;
-
-                               while (1)
-                               {
-                                       if (floor_num == 1)
-                                       {
-                                               char o_name[MAX_NLEN];
+                               char o_name[MAX_NLEN];
 
-                                               object_type *o_ptr;
+                               object_type *o_ptr;
 
-                                               /* Acquire object */
-                                               o_ptr = &o_list[floor_list[0]];
+                               /* Acquire object */
+                               o_ptr = &o_list[floor_list[0]];
 
-                                               /* Describe the object */
-                                               object_desc(o_name, o_ptr, TRUE, 3);
+                               /* Describe the object */
+                               object_desc(o_name, o_ptr, 0);
 
-                                               /* Message */
+                               /* Message */
 #ifdef JP
-sprintf(out_val, "%s%s%s%s[%s]",
-s1, o_name, s2, s3, info);
+                               sprintf(out_val, "%s%s%s%s[%s]",
+                                       s1, o_name, s2, s3, info);
 #else
-                                               sprintf(out_val, "%s%s%s%s [%s]",
-                                                       s1, s2, s3, o_name, info);
+                               sprintf(out_val, "%s%s%s%s [%s]",
+                                       s1, s2, s3, o_name, info);
 #endif
 
-                                       }
-                                       else
-                                       {
-                                               /* Message */
+                               prt(out_val, 0, 0);
+                               move_cursor_relative(y, x);
+
+                               /* Command */
+                               query = inkey();
+
+                               /* End this grid */
+                               return query;
+                       }
+
+                       /* Provide one cushion before item listing  */
+                       if (boring)
+                       {
+                               /* Display rough information about items */
 #ifdef JP
-                                               sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
-                                                       s1, floor_num, s2, s3, info);
+                               sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
+                                       s1, floor_num, s2, s3, info);
 #else
-                                               sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
-                                                       s1, s2, s3, floor_num, info);
+                               sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
+                                       s1, s2, s3, floor_num, info);
 #endif
 
-                                       }
+                               prt(out_val, 0, 0);
+                               move_cursor_relative(y, x);
+
+                               /* Command */
+                               query = inkey();
 
-                                       prt(out_val, 0, 0);
-                                       move_cursor_relative(y, x);
+                               /* No request for listing */
+                               if (query != 'x' && query != ' ') return query;
+                       }
 
-                                       /* Command */
-                                       query = inkey();
 
-                                       /* Display list of items (query == "el", not "won") */
-                                       if (floor_num == 1 || query != 'x')
-                                       {
-                                               /* Stop */
-                                               break;
-                                       }
-                                       else while (1)
-                                       {
-                                               int i, o_idx;
-                                               cave_type *c_ptr;
+                       /** Display list of items **/
 
-                                               /* Save screen */
-                                               screen_save();
+                       /* Continue scrolling list if requested */
+                       while (1)
+                       {
+                               int i, o_idx;
+
+                               /* Save screen */
+                               screen_save();
 
-                                               /* Display */
-                                               (void)show_floor(0, y, x, &min_width);
+                               /* Display */
+                               show_gold_on_floor = TRUE;
+                               (void)show_floor(0, y, x, &min_width);
+                               show_gold_on_floor = FALSE;
 
-                                               /* Prompt */
+                               /* Prompt */
 #ifdef JP
-                                               prt("Enter¤Ç¼¡¤Ø¡¢Â¾¤Î¥­¡¼¤ò²¡¤¹¤È¥²¡¼¥à¤ËÌá¤ê¤Þ¤¹", 0, 0);
+                               sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
+                                       s1, floor_num, s2, s3, info);
 #else
-                                               prt("Hit Enter to scroll, Hit any other key to continue", 0, 0);
+                               sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
+                                       s1, s2, s3, floor_num, info);
 #endif
+                               prt(out_val, 0, 0);
 
-                                               /* Wait */
-                                               query = inkey();
 
-                                               /* Load screen */
-                                               screen_load();
+                               /* Wait */
+                               query = inkey();
+
+                               /* Load screen */
+                               screen_load();
 
-                                               /* Exit unless 'Enter' */
-                                               if (query != '\n' && query != '\r') break;
+                               /* Exit unless 'Enter' */
+                               if (query != '\n' && query != '\r')
+                               {
+                                       return query;
+                               }
 
-                                               /* Get the object being moved. */
-                                               c_ptr = &cave[y][x];
-                                               o_idx = c_ptr->o_idx;
+                               /* Get the object being moved. */
+                               o_idx = c_ptr->o_idx;
  
-                                               /* Only rotate a pile of two or more objects. */
-                                               if (o_idx && o_list[o_idx].next_o_idx)
-                                               {
+                               /* Only rotate a pile of two or more objects. */
+                               if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
 
-                                                       /* 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;
-                                               }
-                                       }
-                               }
+                               /* Remove the first object from the list. */
+                               excise_object_idx(o_idx);
 
-                               /* Stop */
-                               break;
+                               /* 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;
+
+                               /* Loop and re-display the list */
                        }
                }
 
+               /* NOTREACHED */
+       }
 #endif /* ALLOW_EASY_FLOOR */
 
 
-               /* Scan all objects in the grid */
-               for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
-               {
-                       object_type *o_ptr;
+       /* Scan all objects in the grid */
+       for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+       {
+               object_type *o_ptr;
 
-                       /* Acquire object */
-                       o_ptr = &o_list[this_o_idx];
+               /* Acquire object */
+               o_ptr = &o_list[this_o_idx];
 
-                       /* Acquire next object */
-                       next_o_idx = o_ptr->next_o_idx;
+               /* Acquire next object */
+               next_o_idx = o_ptr->next_o_idx;
 
-                       /* Describe it */
-                       if (o_ptr->marked)
-                       {
-                               char o_name[MAX_NLEN];
+               /* Describe it */
+               if (o_ptr->marked & OM_FOUND)
+               {
+                       char o_name[MAX_NLEN];
 
-                               /* Not boring */
-                               boring = FALSE;
+                       /* Not boring */
+                       boring = FALSE;
 
-                               /* Obtain an object description */
-                               object_desc(o_name, o_ptr, TRUE, 3);
+                       /* Obtain an object description */
+                       object_desc(o_name, o_ptr, 0);
 
-                               /* Describe the object */
+                       /* Describe the object */
 #ifdef JP
-sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
+                       sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
 #else
-                               sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
+                       sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
 #endif
 
-                               prt(out_val, 0, 0);
-                               move_cursor_relative(y, x);
-                               query = inkey();
+                       prt(out_val, 0, 0);
+                       move_cursor_relative(y, x);
+                       query = inkey();
 
-                               /* Always stop at "normal" keys */
-                               if ((query != '\r') && (query != '\n') && (query != ' ')) break;
+                       /* Always stop at "normal" keys */
+                       if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
 
-                               /* Sometimes stop at "space" key */
-                               if ((query == ' ') && !(mode & TARGET_LOOK)) break;
+                       /* Sometimes stop at "space" key */
+                       if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
 
-                               /* Change the intro */
+                       /* Change the intro */
 #ifdef JP
-s1 = "¤½¤ì¤Ï";
+                       s1 = "¤½¤ì¤Ï";
 #else
-                               s1 = "It is ";
+                       s1 = "It is ";
 #endif
 
 
-                               /* Plurals */
+                       /* Plurals */
 #ifdef JP
-if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
+                       if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
 #else
-                               if (o_ptr->number != 1) s1 = "They are ";
+                       if (o_ptr->number != 1) s1 = "They are ";
 #endif
 
 
-                               /* Preposition */
+                       /* Preposition */
 #ifdef JP
-                               s2 = "¤Î¾å";
-                               s3 = "¤Ë¸«¤¨¤ë";
+                       s2 = "¤Î¾å";
+                       s3 = "¤Ë¸«¤¨¤ë";
 #else
-                               s2 = "on ";
+                       s2 = "on ";
 #endif
 
-                       }
                }
+       }
 
-               /* Double break */
-               if (this_o_idx) break;
 
-                /* Feature code (applying "mimic" field) */
-                feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+       /* Feature code (applying "mimic" field) */
+       feat = get_feat_mimic(c_ptr);
 
-               /* Require knowledge about grid, or ability to see grid */
-               if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
-               {
-                       /* Forget feature */
-                       feat = FEAT_NONE;
-               }
+       /* Require knowledge about grid, or ability to see grid */
+       if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
+       {
+               /* Forget feature */
+               feat = feat_none;
+       }
+
+       f_ptr = &f_info[feat];
 
-               /* Terrain feature if needed */
-               if (boring || (feat > FEAT_INVIS))
+       /* Terrain feature if needed */
+       if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
+       {
+               cptr name;
+
+               /* Hack -- special handling for quest entrances */
+               if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
                {
-                       cptr name;
+                       /* Set the quest number temporary */
+                       int old_quest = p_ptr->inside_quest;
+                       int j;
 
-                       /* Hack -- special handling for building doors */
-                       if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
-                       {
-                               name = building[feat - FEAT_BLDG_HEAD].name;
-                       }
-                       else if (feat == FEAT_ENTRANCE)
-                       {
-#ifdef JP
-                               name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
-#else
-                               name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
-#endif
-                        }
-                       else if (feat == FEAT_TOWN)
-                       {
-                               name = town[c_ptr->special].name;
-                        }
-                       else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
-                       {
-#ifdef JP
-                               name = "ƻ";
-#else
-                               name = "road";
-#endif
-                       }
-                       else
-                       {
-                               name = f_name + f_info[feat].name;
-                       }
+                       /* Clear the text */
+                       for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
+                       quest_text_line = 0;
 
+                       p_ptr->inside_quest = c_ptr->special;
+
+                       /* Get the quest text */
+                       init_flags = INIT_SHOW_TEXT;
+
+                       process_dungeon_file("q_info.txt", 0, 0, 0, 0);
 
-                       /* Pick a prefix */
-                       if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
-                          (feat <= FEAT_PATTERN_XTRA2)))
-                       {
 #ifdef JP
-s2 = "¤Î¾å";
+                       name = format("¥¯¥¨¥¹¥È¡Ö%s¡×(%d³¬ÁêÅö)", quest[c_ptr->special].name, quest[c_ptr->special].level);
 #else
-                               s2 = "on ";
+                       name = format("the entrance to the quest '%s'(level %d)", quest[c_ptr->special].name, quest[c_ptr->special].level);
 #endif
 
-                       }
-                       else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
-                               (feat <= FEAT_PERM_SOLID)))
-                       {
+                       /* Reset the old quest number */
+                       p_ptr->inside_quest = old_quest;
+               }
+
+               /* Hack -- special handling for building doors */
+               else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
+               {
+                       name = building[f_ptr->subtype].name;
+               }
+               else if (have_flag(f_ptr->flags, FF_ENTRANCE))
+               {
 #ifdef JP
-s2 = "¤ÎÃæ";
+                       name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
 #else
-                               s2 = "in ";
+                       name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
 #endif
-
-                       }
-                       else if (*s2 && (feat == FEAT_TOWN))
-                       {
+               }
+               else if (have_flag(f_ptr->flags, FF_TOWN))
+               {
+                       name = town[c_ptr->special].name;
+               }
+               else if (p_ptr->wild_mode && (feat == feat_floor))
+               {
 #ifdef JP
-s2 = "¤ÎÃæ";
+                       name = "ƻ";
 #else
-                               s2 = "in ";
+                       name = "road";
 #endif
+               }
+               else
+               {
+                       name = f_name + f_ptr->name;
+               }
 
-                       }
 
-                       /* Hack -- special introduction for store & building doors -KMW- */
-                       if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
-                           ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
-                           (feat == FEAT_MUSEUM) ||
-                           (feat == FEAT_ENTRANCE))
-                       {
+               /* Pick a prefix */
+               if (*s2 &&
+                   ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
+                    (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
+                    have_flag(f_ptr->flags, FF_TOWN)))
+               {
 #ifdef JP
-s2 = "¤ÎÆþ¸ý";
+                       s2 = "¤ÎÃæ";
 #else
-                               s3 = "";
+                       s2 = "in ";
 #endif
+               }
 
-                       }
-                       else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
-                       {
-#ifndef JP
-                               s3 ="";
+               /* Hack -- special introduction for store & building doors -KMW- */
+               if (have_flag(f_ptr->flags, FF_STORE) ||
+                   have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
+                   (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
+                   have_flag(f_ptr->flags, FF_ENTRANCE))
+               {
+#ifdef JP
+                       s2 = "¤ÎÆþ¸ý";
+#else
+                       s3 = "";
 #endif
-                       }
-                       else
-                       {
-                               /* Pick proper indefinite article */
+               }
 #ifndef JP
-                               s3 = (is_a_vowel(name[0])) ? "an " : "a ";
+               else if (have_flag(f_ptr->flags, FF_FLOOR) ||
+                        have_flag(f_ptr->flags, FF_TOWN) ||
+                        have_flag(f_ptr->flags, FF_SHALLOW) ||
+                        have_flag(f_ptr->flags, FF_DEEP))
+               {
+                       s3 ="";
+               }
+               else
+               {
+                       /* Pick proper indefinite article */
+                       s3 = (is_a_vowel(name[0])) ? "an " : "a ";
+               }
 #endif
-                       }
 
-                       /* Display a message */
-                       if (p_ptr->wizard)
+               /* Display a message */
+               if (p_ptr->wizard)
+               {
+                       char f_idx_str[32];
+                       if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
+                       else sprintf(f_idx_str, "%d", c_ptr->feat);
 #ifdef JP
-                       sprintf(out_val, "%s%s%s%s[%s] %x %d %d %d %d (%d,%d)", s1, name, s2, s3, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when, x, y);
+                       sprintf(out_val, "%s%s%s%s[%s] %x %s %d %d %d (%d,%d)", s1, name, s2, s3, info, c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, y, x);
 #else
-                       sprintf(out_val, "%s%s%s%s [%s] %x %d %d %d %d (%d,%d)", s1, s2, s3, name, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when, x, y);
+                       sprintf(out_val, "%s%s%s%s [%s] %x %s %d %d %d (%d,%d)", s1, s2, s3, name, info, c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, y, x);
 #endif
-                       else
+               }
+               else
 #ifdef JP
                        sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
 #else
                        sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
 #endif
 
-                       prt(out_val, 0, 0);
-                       move_cursor_relative(y, x);
-                       query = inkey();
-
-                       /* Always stop at "normal" keys */
-                       if ((query != '\r') && (query != '\n') && (query != ' ')) break;
-               }
+               prt(out_val, 0, 0);
+               move_cursor_relative(y, x);
+               query = inkey();
 
-               /* Stop on everything but "return" */
-               if ((query != '\r') && (query != '\n')) break;
+               /* Always stop at "normal" keys */
+               if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
        }
 
-       /* Keep going */
-       return (query);
+       /* Stop on everything but "return" */
+       if ((query != '\r') && (query != '\n')) return query;
+
+       /* Repeat forever */
+       return 0;
 }
 
 
@@ -3699,6 +3764,7 @@ bool target_set(int mode)
 
        int wid, hgt;
 
+
        /* Get size */
        get_screen_size(&wid, &hgt);
 
@@ -3753,7 +3819,7 @@ strcpy(info, "q
                        }
 
                        /* Describe and Prompt */
-                       query = target_set_aux(y, x, mode, info);
+                       while (!(query = target_set_aux(y, x, mode, info)));
 
                        /* Cancel tracking */
                        /* health_track(0); */
@@ -3967,6 +4033,8 @@ strcpy(info, "q
                /* Arbitrary grids */
                else
                {
+                       bool move_fast = FALSE;
+
                        if (!(mode & TARGET_LOOK)) prt_path(y, x);
 
                        /* Access */
@@ -3981,7 +4049,7 @@ strcpy(info, "q
 
 
                        /* Describe and Prompt (enable "TARGET_LOOK") */
-                       query = target_set_aux(y, x, mode | TARGET_LOOK, info);
+                       while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
 
                        /* Cancel tracking */
                        /* health_track(0); */
@@ -4080,6 +4148,9 @@ strcpy(info, "q
                                        /* Extract the action (if any) */
                                        d = get_keymap_dir(query);
 
+                                       /* XTRA HACK MOVEFAST */
+                                       if (isupper(query)) move_fast = TRUE;
+
                                        if (!d) bell();
                                        break;
                                }
@@ -4091,9 +4162,18 @@ strcpy(info, "q
                                int dx = ddx[d];
                                int dy = ddy[d];
 
-                               /* Move */
-                               x += dx;
-                               y += dy;
+                               /* XTRA HACK MOVEFAST */
+                               if (move_fast)
+                               {
+                                       int mag = MIN(wid / 2, hgt / 2);
+                                       x += dx * mag;
+                                       y += dy * mag;
+                               }
+                               else
+                               {
+                                       x += dx;
+                                       y += dy;
+                               }
 
                                /* Do not move horizontally if unnecessary */
                                if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
@@ -4396,7 +4476,7 @@ if (!get_com("
                monster_type *m_ptr = &m_list[p_ptr->riding];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-               if (m_ptr->confused)
+               if (MON_CONFUSED(m_ptr))
                {
                        /* Standard confusion */
                        if (randint0(100) < 75)
@@ -4435,7 +4515,7 @@ msg_print("
                        monster_type *m_ptr = &m_list[p_ptr->riding];
 
                        monster_desc(m_name, m_ptr, 0);
-                       if (m_ptr->confused)
+                       if (MON_CONFUSED(m_ptr))
                        {
 #ifdef JP
 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
@@ -4557,12 +4637,6 @@ msg_print("
 }
 
 
-int get_chaos_patron(void)
-{
-       return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
-}
-
-
 void gain_level_reward(int chosen_reward)
 {
        object_type *q_ptr;
@@ -5197,7 +5271,7 @@ msg_print("
 #endif
                        break;
                case REW_CURSE_WP:
-                       if (!buki_motteruka(INVEN_RARM)) break;
+                       if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
 #ifdef JP
 msg_format("%s¤ÎÀ¼¤¬¶Á¤­ÅϤä¿:",
                                chaos_patrons[p_ptr->chaos_patron]);
@@ -5212,8 +5286,14 @@ msg_print("
                        msg_print("'Thou reliest too much on thy weapon.'");
 #endif
 
-                       object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
-                       (void)curse_weapon(FALSE, INVEN_RARM);
+                       dummy = INVEN_RARM;
+                       if (buki_motteruka(INVEN_LARM))
+                       {
+                               dummy = INVEN_LARM;
+                               if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
+                       }
+                       object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
+                       (void)curse_weapon(FALSE, dummy);
 #ifdef JP
                        reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
 #else
@@ -5236,7 +5316,7 @@ msg_print("
                        msg_print("'Thou reliest too much on thine equipment.'");
 #endif
 
-                       object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
+                       object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
                        (void)curse_armor();
 #ifdef JP
                        reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
@@ -5280,9 +5360,15 @@ msg_print("
                                case 3:
                                        if (one_in_(2))
                                        {
-                                               if (!buki_motteruka(INVEN_RARM)) break;
-                                               object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
-                                               (void)curse_weapon(FALSE, INVEN_RARM);
+                                               if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
+                                               dummy = INVEN_RARM;
+                                               if (buki_motteruka(INVEN_LARM))
+                                               {
+                                                       dummy = INVEN_LARM;
+                                                       if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
+                                               }
+                                               object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
+                                               (void)curse_weapon(FALSE, dummy);
 #ifdef JP
                                                reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
 #else
@@ -5292,7 +5378,7 @@ msg_print("
                                        else
                                        {
                                                if (!inventory[INVEN_BODY].k_idx) break;
-                                               object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
+                                               object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
                                                (void)curse_armor();
 #ifdef JP
                                                reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
@@ -5335,7 +5421,19 @@ msg_print("
                        }
                        activate_hi_summon(py, px, FALSE);
                        (void)activate_ty_curse(FALSE, &count);
-                       if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
+                       if (one_in_(2))
+                       {
+                               dummy = 0;
+
+                               if (buki_motteruka(INVEN_RARM))
+                               {
+                                       dummy = INVEN_RARM;
+                                       if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
+                               }
+                               else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
+
+                               if (dummy) (void)curse_weapon(FALSE, dummy);
+                       }
                        if (one_in_(2)) (void)curse_armor();
                        break;
                case REW_DESTRUCT:
@@ -5353,7 +5451,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
@@ -5555,8 +5653,8 @@ msg_print("
                case '5':
                case '0':
                        /* illegal place */
-                       if (x == px && y == py) ch = 0;
-                       
+                       if (player_bold(y, x)) ch = 0;
+
                        /* okay place */
                        else success = TRUE;
 
@@ -5574,15 +5672,18 @@ msg_print("
                                int dx = ddx[d];
                                int dy = ddy[d];
 
-                                /* XTRA HACK MOVEFAST */
-                                if (move_fast)
-                                {
-                                     x += dx * wid / 2;
-                                     y += dy * hgt / 2;
-                                } else {
-                                x += dx;
-                                y += dy;
-                                }
+                               /* XTRA HACK MOVEFAST */
+                               if (move_fast)
+                               {
+                                       int mag = MIN(wid / 2, hgt / 2);
+                                       x += dx * mag;
+                                       y += dy * mag;
+                               }
+                               else
+                               {
+                                       x += dx;
+                                       y += dy;
+                               }
 
                                /* Do not move horizontally if unnecessary */
                                if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
@@ -5923,4 +6024,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;
+}