OSDN Git Service

typo修正。何年気がつかなかったんだろ、これ。
[hengband/hengband.git] / src / cmd6.c
index a171792..5860d15 100644 (file)
@@ -1,15 +1,15 @@
 /* File: cmd6.c */
 
-/* Purpose: Object commands */
-
 /*
- * 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: Object commands */
+
 #include "angband.h"
 
 
@@ -59,6 +59,8 @@ static void do_cmd_eat_food_aux(int item)
        int ident, lev;
        object_type *o_ptr;
 
+       if (music_singing_any()) stop_singing();
+
        /* Get the item (in the pack) */
        if (item >= 0)
        {
@@ -81,25 +83,18 @@ static void do_cmd_eat_food_aux(int item)
        ident = FALSE;
 
        /* Object level */
-       lev = get_object_level(o_ptr);
-
-#ifdef USE_SCRIPT
-       eat_callback(o_ptr->sval);
-
-       if (!object_eat_callback(o_ptr))
-#endif /* USE_SCRIPT */
+       lev = k_info[o_ptr->k_idx].level;
 
+       if (o_ptr->tval == TV_FOOD)
        {
-               if (o_ptr->tval == TV_FOOD)
-               {
                /* Analyze the food */
                switch (o_ptr->sval)
                {
                        case SV_FOOD_POISON:
                        {
-                               if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
+                               if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
                                {
-                                       if (set_poisoned(p_ptr->poisoned + rand_int(10) + 10))
+                                       if (set_poisoned(p_ptr->poisoned + randint0(10) + 10))
                                        {
                                                ident = TRUE;
                                        }
@@ -111,7 +106,7 @@ static void do_cmd_eat_food_aux(int item)
                        {
                                if (!p_ptr->resist_blind)
                                {
-                                       if (set_blind(p_ptr->blind + rand_int(200) + 200))
+                                       if (set_blind(p_ptr->blind + randint0(200) + 200))
                                        {
                                                ident = TRUE;
                                        }
@@ -123,7 +118,7 @@ static void do_cmd_eat_food_aux(int item)
                        {
                                if (!p_ptr->resist_fear)
                                {
-                                       if (set_afraid(p_ptr->afraid + rand_int(10) + 10))
+                                       if (set_afraid(p_ptr->afraid + randint0(10) + 10))
                                        {
                                                ident = TRUE;
                                        }
@@ -135,7 +130,7 @@ static void do_cmd_eat_food_aux(int item)
                        {
                                if (!p_ptr->resist_conf)
                                {
-                                       if (set_confused(p_ptr->confused + rand_int(10) + 10))
+                                       if (set_confused(p_ptr->confused + randint0(10) + 10))
                                        {
                                                ident = TRUE;
                                        }
@@ -147,7 +142,7 @@ static void do_cmd_eat_food_aux(int item)
                        {
                                if (!p_ptr->resist_chaos)
                                {
-                                       if (set_image(p_ptr->image + rand_int(250) + 250))
+                                       if (set_image(p_ptr->image + randint0(250) + 250))
                                        {
                                                ident = TRUE;
                                        }
@@ -159,7 +154,7 @@ static void do_cmd_eat_food_aux(int item)
                        {
                                if (!p_ptr->free_act)
                                {
-                                       if (set_paralyzed(p_ptr->paralyzed + rand_int(10) + 10))
+                                       if (set_paralyzed(p_ptr->paralyzed + randint0(10) + 10))
                                        {
                                                ident = TRUE;
                                        }
@@ -170,7 +165,7 @@ static void do_cmd_eat_food_aux(int item)
                        case SV_FOOD_WEAKNESS:
                        {
 #ifdef JP
-                       take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
+                               take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
 #else
                                take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1);
 #endif
@@ -183,7 +178,7 @@ static void do_cmd_eat_food_aux(int item)
                        case SV_FOOD_SICKNESS:
                        {
 #ifdef JP
-                       take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
+                               take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
 #else
                                take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1);
 #endif
@@ -196,7 +191,7 @@ static void do_cmd_eat_food_aux(int item)
                        case SV_FOOD_STUPIDITY:
                        {
 #ifdef JP
-                       take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
+                               take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
 #else
                                take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1);
 #endif
@@ -209,7 +204,7 @@ static void do_cmd_eat_food_aux(int item)
                        case SV_FOOD_NAIVETY:
                        {
 #ifdef JP
-                       take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
+                               take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
 #else
                                take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1);
 #endif
@@ -222,7 +217,7 @@ static void do_cmd_eat_food_aux(int item)
                        case SV_FOOD_UNHEALTH:
                        {
 #ifdef JP
-                       take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
+                               take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
 #else
                                take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1);
 #endif
@@ -235,7 +230,7 @@ static void do_cmd_eat_food_aux(int item)
                        case SV_FOOD_DISEASE:
                        {
 #ifdef JP
-                       take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
+                               take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
 #else
                                take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1);
 #endif
@@ -300,34 +295,34 @@ static void do_cmd_eat_food_aux(int item)
 
 
 #ifdef JP
-               /* ¤½¤ì¤¾¤ì¤Î¿©¤Ùʪ¤Î´¶ÁÛ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
-               case SV_FOOD_BISCUIT:
-               {
-                       msg_print("´Å¤¯¤Æ¥µ¥¯¥µ¥¯¤·¤Æ¤È¤Æ¤â¤ª¤¤¤·¤¤¡£");
-                       ident = TRUE;
-                       break;
-               }
+                       /* ¤½¤ì¤¾¤ì¤Î¿©¤Ùʪ¤Î´¶ÁÛ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
+                       case SV_FOOD_BISCUIT:
+                       {
+                               msg_print("´Å¤¯¤Æ¥µ¥¯¥µ¥¯¤·¤Æ¤È¤Æ¤â¤ª¤¤¤·¤¤¡£");
+                               ident = TRUE;
+                               break;
+                       }
 
-               case SV_FOOD_JERKY:
-               {
-                       msg_print("»õ¤´¤¿¤¨¤¬¤¢¤Ã¤Æ¤ª¤¤¤·¤¤¡£");
-                       ident = TRUE;
-                       break;
-               }
+                       case SV_FOOD_JERKY:
+                       {
+                               msg_print("»õ¤´¤¿¤¨¤¬¤¢¤Ã¤Æ¤ª¤¤¤·¤¤¡£");
+                               ident = TRUE;
+                               break;
+                       }
 
-               case SV_FOOD_SLIME_MOLD:
-               {
-                       msg_print("¤³¤ì¤Ï¤Ê¤ó¤È¤â·ÁÍƤ·¤¬¤¿¤¤Ì£¤À¡£");
-                       ident = TRUE;
-                       break;
-               }
+                       case SV_FOOD_SLIME_MOLD:
+                       {
+                               msg_print("¤³¤ì¤Ï¤Ê¤ó¤È¤â·ÁÍƤ·¤¬¤¿¤¤Ì£¤À¡£");
+                               ident = TRUE;
+                               break;
+                       }
 
-               case SV_FOOD_RATION:
-               {
-                       msg_print("¤³¤ì¤Ï¤ª¤¤¤·¤¤¡£");
-                       ident = TRUE;
-                       break;
-               }
+                       case SV_FOOD_RATION:
+                       {
+                               msg_print("¤³¤ì¤Ï¤ª¤¤¤·¤¤¡£");
+                               ident = TRUE;
+                               break;
+                       }
 #else
                        case SV_FOOD_RATION:
                        case SV_FOOD_BISCUIT:
@@ -344,7 +339,7 @@ static void do_cmd_eat_food_aux(int item)
                        case SV_FOOD_WAYBREAD:
                        {
 #ifdef JP
-                       msg_print("¤³¤ì¤Ï¤Ò¤¸¤ç¤¦¤ËÈþÌ£¤À¡£");
+                               msg_print("¤³¤ì¤Ï¤Ò¤¸¤ç¤¦¤ËÈþÌ£¤À¡£");
 #else
                                msg_print("That tastes good.");
 #endif
@@ -357,11 +352,11 @@ static void do_cmd_eat_food_aux(int item)
 
 #ifdef JP
                        case SV_FOOD_PINT_OF_ALE:
-               {
-                       msg_print("¤Î¤É¤´¤·Á֤䤫¤À¡£");
-                       ident = TRUE;
-                       break;
-               }
+                       {
+                               msg_print("¤Î¤É¤´¤·Á֤䤫¤À¡£");
+                               ident = TRUE;
+                               break;
+                       }
 
                        case SV_FOOD_PINT_OF_WINE:
                        {
@@ -380,16 +375,12 @@ static void do_cmd_eat_food_aux(int item)
 #endif
 
                }
-               }
-               else
-               {
-               }
        }
 
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
 
-       if (!(object_aware_p(o_ptr)))
+       if (!(object_is_aware(o_ptr)))
        {
                chg_virtue(V_KNOWLEDGE, -1);
                chg_virtue(V_PATIENCE, -1);
@@ -397,10 +388,10 @@ static void do_cmd_eat_food_aux(int item)
        }
 
        /* We have tried it */
-       object_tried(o_ptr);
+       if (o_ptr->tval == TV_FOOD) object_tried(o_ptr);
 
        /* The player is now aware of the object */
-       if (ident && !object_aware_p(o_ptr))
+       if (ident && !object_is_aware(o_ptr))
        {
                object_aware(o_ptr);
                gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
@@ -429,8 +420,141 @@ msg_print("
 #endif
 
        }
-       else if (p_ptr->prace == RACE_SKELETON)
+       else if ((prace_is_(RACE_SKELETON) ||
+                 prace_is_(RACE_GOLEM) ||
+                 prace_is_(RACE_ZOMBIE) ||
+                 prace_is_(RACE_SPECTRE)) &&
+                (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND))
+       {
+               cptr staff;
+
+               if (o_ptr->tval == TV_STAFF &&
+                   (item < 0) && (o_ptr->number > 1))
+               {
+#ifdef JP
+                       msg_print("¤Þ¤º¤Ï¾ó¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
+#else
+                       msg_print("You must first pick up the staffs.");
+#endif
+                       return;
+               }
+
+#ifdef JP
+               staff = (o_ptr->tval == TV_STAFF) ? "¾ó" : "ËâË¡ËÀ";
+#else
+               staff = (o_ptr->tval == TV_STAFF) ? "staff" : "wand";
+#endif
+
+               /* "Eat" charges */
+               if (o_ptr->pval == 0)
+               {
+#ifdef JP
+                       msg_format("¤³¤Î%s¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£", staff);
+#else
+                       msg_format("The %s has no charges left.", staff);
+#endif
+
+                       o_ptr->ident |= (IDENT_EMPTY);
+
+                       /* Combine / Reorder the pack (later) */
+                       p_ptr->notice |= (PN_COMBINE | PN_REORDER);
+                       p_ptr->window |= (PW_INVEN);
+
+                       return;
+               }
+
+#ifdef JP
+               msg_format("¤¢¤Ê¤¿¤Ï%s¤ÎËâÎϤò¥¨¥Í¥ë¥®¡¼¸»¤È¤·¤ÆµÛ¼ý¤·¤¿¡£", staff);
+#else
+               msg_format("You absorb mana of the %s as your energy.", staff);
+#endif
+
+               /* Use a single charge */
+               o_ptr->pval--;
+
+               /* Eat a charge */
+               set_food(p_ptr->food + 5000);
+
+               /* XXX Hack -- unstack if necessary */
+               if (o_ptr->tval == TV_STAFF &&
+                   (item >= 0) && (o_ptr->number > 1))
+               {
+                       object_type forge;
+                       object_type *q_ptr;
+
+                       /* Get local object */
+                       q_ptr = &forge;
+
+                       /* Obtain a local object */
+                       object_copy(q_ptr, o_ptr);
+
+                       /* Modify quantity */
+                       q_ptr->number = 1;
+
+                       /* Restore the charges */
+                       o_ptr->pval++;
+
+                       /* Unstack the used item */
+                       o_ptr->number--;
+                       p_ptr->total_weight -= q_ptr->weight;
+                       item = inven_carry(q_ptr);
+
+                       /* Message */
+#ifdef JP
+                       msg_format("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
+#else
+                       msg_print("You unstack your staff.");
+#endif
+               }
+
+               /* Describe charges in the pack */
+               if (item >= 0)
+               {
+                       inven_item_charges(item);
+               }
+
+               /* Describe charges on the floor */
+               else
+               {
+                       floor_item_charges(0 - item);
+               }
+
+               /* Don't eat a staff/wand itself */
+               return;
+       }
+       else if ((prace_is_(RACE_DEMON) ||
+                (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) &&
+                (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE &&
+                 my_strchr("pht", r_info[o_ptr->pval].d_char)))
+       {
+               /* Drain vitality of humanoids */
+               char o_name[MAX_NLEN];
+
+               object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
+
+#ifdef JP
+               msg_format("%s¤Ïdz¤¨¾å¤ê³¥¤Ë¤Ê¤Ã¤¿¡£ÀºÎϤòµÛ¼ý¤·¤¿µ¤¤¬¤¹¤ë¡£", o_name);
+#else
+               msg_format("%^s is burnt to ashes.  You absorb its vitality!", o_name);
+#endif
+               (void)set_food(PY_FOOD_MAX - 1);
+       }
+       else if (prace_is_(RACE_SKELETON))
        {
+#if 0
+               if (o_ptr->tval == TV_SKELETON ||
+                   (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
+               {
+#ifdef JP
+                       msg_print("¤¢¤Ê¤¿¤Ï¹ü¤Ç¼«Ê¬¤ÎÂΤòÊä¤Ã¤¿¡£");
+#else
+                       msg_print("Your body absorbs the bone.");
+#endif
+                       set_food(p_ptr->food + 5000);
+               }
+               else 
+#endif
+
                if (!((o_ptr->sval == SV_FOOD_WAYBREAD) ||
                      (o_ptr->sval < SV_FOOD_BISCUIT)))
                {
@@ -447,10 +571,6 @@ msg_print("
                        /* Create the item */
                        object_prep(q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval));
 
-#ifdef USE_SCRIPT
-                       q_ptr->python = object_create_callback(q_ptr);
-#endif /* USE_SCRIPT */
-
                        /* Drop the object from heaven */
                        (void)drop_near(q_ptr, -1, py, px);
                }
@@ -464,12 +584,12 @@ msg_print("
 
                }
        }
-       else if ((p_ptr->prace == RACE_GOLEM) ||
-                (p_ptr->prace == RACE_ZOMBIE) ||
-                (p_ptr->prace == RACE_ENT) ||
-                (p_ptr->prace == RACE_DEMON) ||
-                (p_ptr->prace == RACE_ANDROID) ||
-                (p_ptr->prace == RACE_SPECTRE) ||
+       else if (prace_is_(RACE_GOLEM) ||
+                prace_is_(RACE_ZOMBIE) ||
+                prace_is_(RACE_ENT) ||
+                prace_is_(RACE_DEMON) ||
+                prace_is_(RACE_ANDROID) ||
+                prace_is_(RACE_SPECTRE) ||
                 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
        {
 #ifdef JP
@@ -480,8 +600,14 @@ msg_print("
 
                set_food(p_ptr->food + ((o_ptr->pval) / 20));
        }
+       else if (o_ptr->tval == TV_FOOD && o_ptr->sval == SV_FOOD_WAYBREAD)
+       {
+               /* Waybread is always fully satisfying. */
+               set_food(MAX(p_ptr->food, PY_FOOD_MAX - 1));
+       }
        else
        {
+               /* Food can feed the player */
                (void)set_food(p_ptr->food + o_ptr->pval);
        }
 
@@ -508,8 +634,34 @@ msg_print("
  */
 static bool item_tester_hook_eatable(object_type *o_ptr)
 {
-//     if ((o_ptr->tval==TV_FOOD) || ((o_ptr->tval==TV_CORPSE) && o_ptr->sval)) return (TRUE);
-       if (o_ptr->tval==TV_FOOD) return (TRUE);
+       if (o_ptr->tval==TV_FOOD) return TRUE;
+
+#if 0
+       if (prace_is_(RACE_SKELETON))
+       {
+               if (o_ptr->tval == TV_SKELETON ||
+                   (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
+                       return TRUE;
+       }
+       else 
+#endif
+
+       if (prace_is_(RACE_SKELETON) ||
+           prace_is_(RACE_GOLEM) ||
+           prace_is_(RACE_ZOMBIE) ||
+           prace_is_(RACE_SPECTRE))
+       {
+               if (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND)
+                       return TRUE;
+       }
+       else if (prace_is_(RACE_DEMON) ||
+                (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON))
+       {
+               if (o_ptr->tval == TV_CORPSE &&
+                   o_ptr->sval == SV_CORPSE &&
+                   my_strchr("pht", r_info[o_ptr->pval].d_char))
+                       return TRUE;
+       }
 
        /* Assume not */
        return (FALSE);
@@ -576,10 +728,7 @@ static void do_cmd_quaff_potion_aux(int item)
                return;
        }
 
-        if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
-        {
-                stop_singing();
-        }
+       if (music_singing_any()) stop_singing();
 
        /* Get the item (in the pack) */
        if (item >= 0)
@@ -626,98 +775,95 @@ static void do_cmd_quaff_potion_aux(int item)
        ident = FALSE;
 
        /* Object level */
-       lev = get_object_level(q_ptr);
+       lev = k_info[q_ptr->k_idx].level;
 
        /* Analyze the potion */
-       switch (q_ptr->sval)
+       if (q_ptr->tval == TV_POTION)
        {
+               switch (q_ptr->sval)
+               {
 #ifdef JP
-               /* °û¤ß¤´¤¿¤¨¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
+                       /* °û¤ß¤´¤¿¤¨¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
                case SV_POTION_WATER:
-               {
                        msg_print("¸ý¤ÎÃ椬¤µ¤Ã¤Ñ¤ê¤·¤¿¡£");
                        msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
                        ident = TRUE;
                        break;
-               }
+
                case SV_POTION_APPLE_JUICE:
-               {
                        msg_print("´Å¤¯¤Æ¥µ¥Ã¥Ñ¥ê¤È¤·¤Æ¤¤¤Æ¡¢¤È¤Æ¤â¤ª¤¤¤·¤¤¡£");
                        msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
                        ident = TRUE;
                        break;
-               }
+
                case SV_POTION_SLIME_MOLD:
-               {
                        msg_print("¤Ê¤ó¤È¤âÉÔµ¤Ì£¤ÊÌ£¤À¡£");
                        msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
                        ident = TRUE;
                        break;
-               }
+
 #else
                case SV_POTION_WATER:
                case SV_POTION_APPLE_JUICE:
                case SV_POTION_SLIME_MOLD:
-               {
                        msg_print("You feel less thirsty.");
                        ident = TRUE;
                        break;
-               }
 #endif
 
-
                case SV_POTION_SLOWNESS:
-               {
-                       if (set_slow(randint(25) + 15, FALSE)) ident = TRUE;
+                       if (set_slow(randint1(25) + 15, FALSE)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_SALT_WATER:
-               {
 #ifdef JP
                        msg_print("¤¦¤§¡ª»×¤ï¤ºÅǤ¤¤Æ¤·¤Þ¤Ã¤¿¡£");
 #else
                        msg_print("The potion makes you vomit!");
 #endif
 
-                       (void)set_food(PY_FOOD_STARVE - 1);
+                       if (!(prace_is_(RACE_GOLEM) ||
+                             prace_is_(RACE_ZOMBIE) ||
+                             prace_is_(RACE_DEMON) ||
+                             prace_is_(RACE_ANDROID) ||
+                             prace_is_(RACE_SPECTRE) ||
+                             (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)))
+                       {
+                               /* Only living creatures get thirsty */
+                               (void)set_food(PY_FOOD_STARVE - 1);
+                       }
+
                        (void)set_poisoned(0);
                        (void)set_paralyzed(p_ptr->paralyzed + 4);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_POISON:
-               {
-                       if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
+                       if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
                        {
-                               if (set_poisoned(p_ptr->poisoned + rand_int(15) + 10))
+                               if (set_poisoned(p_ptr->poisoned + randint0(15) + 10))
                                {
                                        ident = TRUE;
                                }
                        }
                        break;
-               }
 
                case SV_POTION_BLINDNESS:
-               {
                        if (!p_ptr->resist_blind)
                        {
-                               if (set_blind(p_ptr->blind + rand_int(100) + 100))
+                               if (set_blind(p_ptr->blind + randint0(100) + 100))
                                {
                                        ident = TRUE;
                                }
                        }
                        break;
-               }
 
                case SV_POTION_CONFUSION: /* Booze */
-               {
                        if (p_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
                        else if (!p_ptr->resist_conf) p_ptr->special_attack |= ATTACK_SUIKEN;
                        if (!p_ptr->resist_conf)
                        {
-                               if (set_confused(rand_int(20) + 15))
+                               if (set_confused(randint0(20) + 15))
                                {
                                        ident = TRUE;
                                }
@@ -727,7 +873,7 @@ static void do_cmd_quaff_potion_aux(int item)
                        {
                                if (one_in_(2))
                                {
-                                       if (set_image(p_ptr->image + rand_int(150) + 150))
+                                       if (set_image(p_ptr->image + randint0(150) + 150))
                                        {
                                                ident = TRUE;
                                        }
@@ -737,11 +883,11 @@ static void do_cmd_quaff_potion_aux(int item)
                                        ident = TRUE;
                                        if (one_in_(3)) lose_all_info();
                                        else wiz_dark();
-                                       teleport_player(100);
+                                       (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
                                        wiz_dark();
 #ifdef JP
-msg_print("ÃΤé¤Ê¤¤¾ì½ê¤ÇÌܤ¬Àä᤿¡£Æ¬Äˤ¬¤¹¤ë¡£");
-msg_print("²¿¤â»×¤¤½Ð¤»¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ØÍ褿¤Î¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
+                                       msg_print("ÃΤé¤Ê¤¤¾ì½ê¤ÇÌܤ¬Àä᤿¡£Æ¬Äˤ¬¤¹¤ë¡£");
+                                       msg_print("²¿¤â»×¤¤½Ð¤»¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ØÍ褿¤Î¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
 #else
                                        msg_print("You wake up somewhere with a sore head...");
                                        msg_print("You can't remember a thing, or how you got here!");
@@ -750,16 +896,14 @@ msg_print("
                                }
                        }
                        break;
-               }
 
                case SV_POTION_SLEEP:
-               {
                        if (!p_ptr->free_act)
                        {
 #ifdef JP
-               msg_print("¤¢¤Ê¤¿¤Ï̲¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
+               msg_print("¤¢¤Ê¤¿¤Ï̲¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
 #else
-               msg_print("You fall asleep.");
+               msg_print("You fall asleep.");
 #endif
 
 
@@ -781,16 +925,14 @@ msg_print("
                                        /* Remove the monster restriction */
                                        get_mon_num_prep(NULL, NULL);
                                }
-                               if (set_paralyzed(p_ptr->paralyzed + rand_int(4) + 4))
+                               if (set_paralyzed(p_ptr->paralyzed + randint0(4) + 4))
                                {
                                        ident = TRUE;
                                }
                        }
                        break;
-               }
 
                case SV_POTION_LOSE_MEMORIES:
-               {
                        if (!p_ptr->hold_life && (p_ptr->exp > 0))
                        {
 #ifdef JP
@@ -804,10 +946,8 @@ msg_print("
                                ident = TRUE;
                        }
                        break;
-               }
 
                case SV_POTION_RUINATION:
-               {
 #ifdef JP
                        msg_print("¿È¤â¿´¤â¼å¤Ã¤Æ¤­¤Æ¡¢Àºµ¤¤¬È´¤±¤Æ¤¤¤¯¤è¤¦¤À¡£");
                        take_hit(DAMAGE_LOSELIFE, damroll(10, 10), "ÇËÌǤÎÌô", -1);
@@ -824,46 +964,32 @@ msg_print("
                        (void)dec_stat(A_INT, 25, TRUE);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_DEC_STR:
-               {
                        if (do_dec_stat(A_STR)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_DEC_INT:
-               {
                        if (do_dec_stat(A_INT)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_DEC_WIS:
-               {
                        if (do_dec_stat(A_WIS)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_DEC_DEX:
-               {
                        if (do_dec_stat(A_DEX)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_DEC_CON:
-               {
                        if (do_dec_stat(A_CON)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_DEC_CHR:
-               {
                        if (do_dec_stat(A_CHR)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_DETONATIONS:
-               {
 #ifdef JP
                        msg_print("ÂΤÎÃæ¤Ç·ã¤·¤¤Çúȯ¤¬µ¯¤­¤¿¡ª");
                        take_hit(DAMAGE_NOESCAPE, damroll(50, 20), "Çúȯ¤ÎÌô", -1);
@@ -876,10 +1002,8 @@ msg_print("
                        (void)set_cut(p_ptr->cut + 5000);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_DEATH:
-               {
                        chg_virtue(V_VITALITY, -1);
                        chg_virtue(V_UNLIFE, 5);
 #ifdef JP
@@ -892,112 +1016,86 @@ msg_print("
 
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_INFRAVISION:
-               {
-                       if (set_tim_infra(p_ptr->tim_infra + 100 + randint(100), FALSE))
+                       if (set_tim_infra(p_ptr->tim_infra + 100 + randint1(100), FALSE))
                        {
                                ident = TRUE;
                        }
                        break;
-               }
 
                case SV_POTION_DETECT_INVIS:
-               {
-                       if (set_tim_invis(p_ptr->tim_invis + 12 + randint(12), FALSE))
+                       if (set_tim_invis(p_ptr->tim_invis + 12 + randint1(12), FALSE))
                        {
                                ident = TRUE;
                        }
                        break;
-               }
 
                case SV_POTION_SLOW_POISON:
-               {
                        if (set_poisoned(p_ptr->poisoned / 2)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_CURE_POISON:
-               {
                        if (set_poisoned(0)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_BOLDNESS:
-               {
                        if (set_afraid(0)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_SPEED:
-               {
                        if (!p_ptr->fast)
                        {
-                               if (set_fast(randint(25) + 15, FALSE)) ident = TRUE;
+                               if (set_fast(randint1(25) + 15, FALSE)) ident = TRUE;
                        }
                        else
                        {
                                (void)set_fast(p_ptr->fast + 5, FALSE);
                        }
                        break;
-               }
 
                case SV_POTION_RESIST_HEAT:
-               {
-                       if (set_oppose_fire(p_ptr->oppose_fire + randint(10) + 10, FALSE))
+                       if (set_oppose_fire(p_ptr->oppose_fire + randint1(10) + 10, FALSE))
                        {
                                ident = TRUE;
                        }
                        break;
-               }
 
                case SV_POTION_RESIST_COLD:
-               {
-                       if (set_oppose_cold(p_ptr->oppose_cold + randint(10) + 10, FALSE))
+                       if (set_oppose_cold(p_ptr->oppose_cold + randint1(10) + 10, FALSE))
                        {
                                ident = TRUE;
                        }
                        break;
-               }
 
                case SV_POTION_HEROISM:
-               {
                        if (set_afraid(0)) ident = TRUE;
-                       if (set_hero(p_ptr->hero + randint(25) + 25, FALSE)) ident = TRUE;
+                       if (set_hero(p_ptr->hero + randint1(25) + 25, FALSE)) ident = TRUE;
                        if (hp_player(10)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_BESERK_STRENGTH:
-               {
                        if (set_afraid(0)) ident = TRUE;
-                       if (set_shero(p_ptr->shero + randint(25) + 25, FALSE)) ident = TRUE;
+                       if (set_shero(p_ptr->shero + randint1(25) + 25, FALSE)) ident = TRUE;
                        if (hp_player(30)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_CURE_LIGHT:
-               {
                        if (hp_player(damroll(2, 8))) ident = TRUE;
                        if (set_blind(0)) ident = TRUE;
                        if (set_cut(p_ptr->cut - 10)) ident = TRUE;
                        if (set_shero(0,TRUE)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_CURE_SERIOUS:
-               {
                        if (hp_player(damroll(4, 8))) ident = TRUE;
                        if (set_blind(0)) ident = TRUE;
                        if (set_confused(0)) ident = TRUE;
                        if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
                        if (set_shero(0,TRUE)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_CURE_CRITICAL:
-               {
                        if (hp_player(damroll(6, 8))) ident = TRUE;
                        if (set_blind(0)) ident = TRUE;
                        if (set_confused(0)) ident = TRUE;
@@ -1006,10 +1104,8 @@ msg_print("
                        if (set_cut(0)) ident = TRUE;
                        if (set_shero(0,TRUE)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_HEALING:
-               {
                        if (hp_player(300)) ident = TRUE;
                        if (set_blind(0)) ident = TRUE;
                        if (set_confused(0)) ident = TRUE;
@@ -1018,10 +1114,8 @@ msg_print("
                        if (set_cut(0)) ident = TRUE;
                        if (set_shero(0,TRUE)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_STAR_HEALING:
-               {
                        if (hp_player(1200)) ident = TRUE;
                        if (set_blind(0)) ident = TRUE;
                        if (set_confused(0)) ident = TRUE;
@@ -1030,10 +1124,8 @@ msg_print("
                        if (set_cut(0)) ident = TRUE;
                        if (set_shero(0,TRUE)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_LIFE:
-               {
                        chg_virtue(V_VITALITY, 1);
                        chg_virtue(V_UNLIFE, -5);
 #ifdef JP
@@ -1056,31 +1148,30 @@ msg_print("
                        (void)do_res_stat(A_INT);
                        (void)do_res_stat(A_CHR);
                        (void)set_shero(0,TRUE);
+                       update_stuff();
                        hp_player(5000);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_RESTORE_MANA:
-               {
                        if (p_ptr->pclass == CLASS_MAGIC_EATER)
                        {
                                int i;
-                               for (i = 0; i < 72; i++)
+                               for (i = 0; i < EATER_EXT*2; i++)
                                {
-                                       p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? 0x30000 : p_ptr->magic_num2[i]*0x05555;
-                                       if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i]*0x10000) p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*0x10000L;
+                                       p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i]*EATER_CHARGE/3;
+                                       if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i]*EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
                                }
-                               for (; i < 108; i++)
+                               for (; i < EATER_EXT*3; i++)
                                {
-                                       int k_idx = lookup_kind(TV_ROD, i-72);
-                                       p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? 0x30000 : p_ptr->magic_num2[i]*0x5555)*k_info[k_idx].pval;
+                                       int k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
+                                       p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE*3 : p_ptr->magic_num2[i]*EATER_ROD_CHARGE/3)*k_info[k_idx].pval;
                                        if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
                                }
 #ifdef JP
                                msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
 #else
-                               msg_print("Your feel your head clear.");
+                               msg_print("You feel your head clear.");
 #endif
                                p_ptr->window |= (PW_PLAYER);
                                ident = TRUE;
@@ -1092,7 +1183,7 @@ msg_print("
 #ifdef JP
                                msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
 #else
-                               msg_print("Your feel your head clear.");
+                               msg_print("You feel your head clear.");
 #endif
 
                                p_ptr->redraw |= (PR_MANA);
@@ -1102,88 +1193,60 @@ msg_print("
                        }
                        if (set_shero(0,TRUE)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_RESTORE_EXP:
-               {
                        if (restore_level()) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_RES_STR:
-               {
                        if (do_res_stat(A_STR)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_RES_INT:
-               {
                        if (do_res_stat(A_INT)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_RES_WIS:
-               {
                        if (do_res_stat(A_WIS)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_RES_DEX:
-               {
                        if (do_res_stat(A_DEX)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_RES_CON:
-               {
                        if (do_res_stat(A_CON)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_RES_CHR:
-               {
                        if (do_res_stat(A_CHR)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_INC_STR:
-               {
                        if (do_inc_stat(A_STR)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_INC_INT:
-               {
                        if (do_inc_stat(A_INT)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_INC_WIS:
-               {
                        if (do_inc_stat(A_WIS)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_INC_DEX:
-               {
                        if (do_inc_stat(A_DEX)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_INC_CON:
-               {
                        if (do_inc_stat(A_CON)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_INC_CHR:
-               {
                        if (do_inc_stat(A_CHR)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_AUGMENTATION:
-               {
                        if (do_inc_stat(A_STR)) ident = TRUE;
                        if (do_inc_stat(A_INT)) ident = TRUE;
                        if (do_inc_stat(A_WIS)) ident = TRUE;
@@ -1191,11 +1254,8 @@ msg_print("
                        if (do_inc_stat(A_CON)) ident = TRUE;
                        if (do_inc_stat(A_CHR)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_ENLIGHTENMENT:
-               {
-                       chg_virtue(V_ENLIGHTEN, 1);
 #ifdef JP
                        msg_print("¼«Ê¬¤ÎÃÖ¤«¤ì¤Æ¤¤¤ë¾õ¶·¤¬Ç¾Î¢¤ËÉ⤫¤ó¤Ç¤­¤¿...");
 #else
@@ -1204,13 +1264,11 @@ msg_print("
 
                        chg_virtue(V_KNOWLEDGE, 1);
                        chg_virtue(V_ENLIGHTEN, 1);
-                       wiz_lite(FALSE, FALSE);
+                       wiz_lite(FALSE);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_STAR_ENLIGHTENMENT:
-               {
 #ifdef JP
                        msg_print("¹¹¤Ê¤ë·¼Ìؤò´¶¤¸¤¿...");
 #else
@@ -1218,12 +1276,12 @@ msg_print("
 #endif
 
                        chg_virtue(V_KNOWLEDGE, 1);
-                       chg_virtue(V_ENLIGHTEN, 1);
+                       chg_virtue(V_ENLIGHTEN, 2);
                        msg_print(NULL);
-                       wiz_lite(TRUE, FALSE);
+                       wiz_lite(FALSE);
                        (void)do_inc_stat(A_INT);
                        (void)do_inc_stat(A_WIS);
-                       (void)detect_traps(DETECT_RAD_DEFAULT);
+                       (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                        (void)detect_doors(DETECT_RAD_DEFAULT);
                        (void)detect_stairs(DETECT_RAD_DEFAULT);
                        (void)detect_treasure(DETECT_RAD_DEFAULT);
@@ -1233,10 +1291,8 @@ msg_print("
                        self_knowledge();
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_SELF_KNOWLEDGE:
-               {
 #ifdef JP
                        msg_print("¼«Ê¬¼«¿È¤Î¤³¤È¤¬¾¯¤·¤Ïʬ¤«¤Ã¤¿µ¤¤¬¤¹¤ë...");
 #else
@@ -1247,10 +1303,8 @@ msg_print("
                        self_knowledge();
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_EXPERIENCE:
-               {
                        if (p_ptr->prace == RACE_ANDROID) break;
                        chg_virtue(V_ENLIGHTEN, 1);
                        if (p_ptr->exp < PY_MAX_EXP)
@@ -1267,21 +1321,17 @@ msg_print("
                                ident = TRUE;
                        }
                        break;
-               }
 
                case SV_POTION_RESISTANCE:
-               {
-                       (void)set_oppose_acid(p_ptr->oppose_acid + randint(20) + 20, FALSE);
-                       (void)set_oppose_elec(p_ptr->oppose_elec + randint(20) + 20, FALSE);
-                       (void)set_oppose_fire(p_ptr->oppose_fire + randint(20) + 20, FALSE);
-                       (void)set_oppose_cold(p_ptr->oppose_cold + randint(20) + 20, FALSE);
-                       (void)set_oppose_pois(p_ptr->oppose_pois + randint(20) + 20, FALSE);
+                       (void)set_oppose_acid(p_ptr->oppose_acid + randint1(20) + 20, FALSE);
+                       (void)set_oppose_elec(p_ptr->oppose_elec + randint1(20) + 20, FALSE);
+                       (void)set_oppose_fire(p_ptr->oppose_fire + randint1(20) + 20, FALSE);
+                       (void)set_oppose_cold(p_ptr->oppose_cold + randint1(20) + 20, FALSE);
+                       (void)set_oppose_pois(p_ptr->oppose_pois + randint1(20) + 20, FALSE);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_CURING:
-               {
                        if (hp_player(50)) ident = TRUE;
                        if (set_blind(0)) ident = TRUE;
                        if (set_poisoned(0)) ident = TRUE;
@@ -1290,17 +1340,13 @@ msg_print("
                        if (set_cut(0)) ident = TRUE;
                        if (set_image(0)) ident = TRUE;
                        break;
-               }
 
                case SV_POTION_INVULNERABILITY:
-               {
-                       (void)set_invuln(p_ptr->invuln + randint(4) + 4, FALSE);
+                       (void)set_invuln(p_ptr->invuln + randint1(4) + 4, FALSE);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_NEW_LIFE:
-               {
                        do_cmd_rerate(FALSE);
                        get_max_stats();
                        p_ptr->update |= PU_BONUS;
@@ -1320,18 +1366,14 @@ msg_print("
                        }
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_NEO_TSUYOSHI:
-               {
                        (void)set_image(0);
-                       (void)set_tsuyoshi(p_ptr->tsuyoshi + randint(100) + 100, FALSE);
+                       (void)set_tsuyoshi(p_ptr->tsuyoshi + randint1(100) + 100, FALSE);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_TSUYOSHI:
-               {
 #ifdef JP
 msg_print("¡Ö¥ª¥¯¥ì·»¤µ¤ó¡ª¡×");
 #else
@@ -1342,14 +1384,12 @@ msg_print("
                        (void)set_tsuyoshi(0, TRUE);
                        if (!p_ptr->resist_chaos)
                        {
-                               (void)set_image(50 + randint(50));
+                               (void)set_image(50 + randint1(50));
                        }
                        ident = TRUE;
                        break;
-               }
                
                case SV_POTION_POLYMORPH:
-               {
                        if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && one_in_(23))
                        {
                                chg_virtue(V_CHANCE, -5);
@@ -1378,7 +1418,7 @@ msg_print("
                }
        }
 
-       if (p_ptr->prace == RACE_SKELETON)
+       if (prace_is_(RACE_SKELETON))
        {
 #ifdef JP
 msg_print("±ÕÂΤΰìÉô¤Ï¤¢¤Ê¤¿¤Î¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¤¿¡ª");
@@ -1392,7 +1432,7 @@ msg_print("
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
 
-       if (!(object_aware_p(o_ptr)))
+       if (!(object_is_aware(o_ptr)))
        {
                chg_virtue(V_PATIENCE, -1);
                chg_virtue(V_CHANCE, 1);
@@ -1403,7 +1443,7 @@ msg_print("
        object_tried(q_ptr);
 
        /* An identification was made */
-       if (ident && !object_aware_p(q_ptr))
+       if (ident && !object_is_aware(q_ptr))
        {
                object_aware(q_ptr);
                gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
@@ -1426,12 +1466,33 @@ msg_print("
                                break;
                        case RACE_GOLEM:
                        case RACE_ZOMBIE:
-                       case RACE_ENT:
                        case RACE_DEMON:
                        case RACE_SPECTRE:
-                       case RACE_ANDROID:
                                set_food(p_ptr->food + ((o_ptr->pval) / 20));
                                break;
+                       case RACE_ANDROID:
+                               if (q_ptr->tval == TV_FLASK)
+                               {
+#ifdef JP
+                                       msg_print("¥ª¥¤¥ë¤òÊäµë¤·¤¿¡£");
+#else
+                                       msg_print("You replenish yourself with the oil.");
+#endif
+                                       set_food(p_ptr->food + 5000);
+                               }
+                               else
+                               {
+                                       set_food(p_ptr->food + ((o_ptr->pval) / 20));
+                               }
+                               break;
+                       case RACE_ENT:
+#ifdef JP
+                               msg_print("¿åʬ¤ò¼è¤ê¹þ¤ó¤À¡£");
+#else
+                               msg_print("You are moistened.");
+#endif
+                               set_food(MIN(p_ptr->food + o_ptr->pval + MAX(0, o_ptr->pval * 10) + 2000, PY_FOOD_MAX - 1));
+                               break;
                        default:
                                (void)set_food(p_ptr->food + o_ptr->pval);
                                break;
@@ -1451,6 +1512,26 @@ msg_print("
 }
 
 
+/*
+ * Hook to determine if an object can be quaffed
+ */
+static bool item_tester_hook_quaff(object_type *o_ptr)
+{
+       if (o_ptr->tval == TV_POTION) return TRUE;
+
+       if (prace_is_(RACE_ANDROID))
+       {
+               if (o_ptr->tval == TV_FLASK && o_ptr->sval == SV_FLASK_OIL)
+                       return TRUE;
+       }
+
+       return FALSE;
+}
+
+
+/*
+ * Quaff some potion (from the pack or floor)
+ */
 void do_cmd_quaff_potion(void)
 {
        int  item;
@@ -1462,7 +1543,7 @@ void do_cmd_quaff_potion(void)
        }
 
        /* Restrict choices to potions */
-       item_tester_tval = TV_POTION;
+       item_tester_hook = item_tester_hook_quaff;
 
        /* Get an item */
 #ifdef JP
@@ -1487,7 +1568,7 @@ void do_cmd_quaff_potion(void)
  * include scrolls with no effects but recharge or identify, which are
  * cancelled before use.  XXX Reading them still takes a turn, though.
  */
-static void do_cmd_read_scroll_aux(int item)
+static void do_cmd_read_scroll_aux(int item, bool known)
 {
        int         k, used_up, ident, lev;
        object_type *o_ptr;
@@ -1533,16 +1614,13 @@ static void do_cmd_read_scroll_aux(int item)
                return;
        }
 
-        if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
-        {
-                stop_singing();
-        }
+       if (music_singing_any()) stop_singing();
 
        /* Not identified yet */
        ident = FALSE;
 
        /* Object level */
-       lev = get_object_level(o_ptr);
+       lev = k_info[o_ptr->k_idx].level;
 
        /* Assume the scroll will get used up */
        used_up = TRUE;
@@ -1556,7 +1634,7 @@ static void do_cmd_read_scroll_aux(int item)
                {
                        if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
                        {
-                               (void)set_blind(p_ptr->blind + 3 + randint(5));
+                               (void)set_blind(p_ptr->blind + 3 + randint1(5));
                        }
                        if (unlite_area(10, 3)) ident = TRUE;
                        break;
@@ -1583,15 +1661,22 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_CURSE_WEAPON:
                {
-                       if (curse_weapon(FALSE, INVEN_RARM)) ident = TRUE;
+                       k = 0;
+                       if (buki_motteruka(INVEN_RARM))
+                       {
+                               k = INVEN_RARM;
+                               if (buki_motteruka(INVEN_LARM) && one_in_(2)) k = INVEN_LARM;
+                       }
+                       else if (buki_motteruka(INVEN_LARM)) k = INVEN_LARM;
+                       if (k && curse_weapon(FALSE, k)) ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_SUMMON_MONSTER:
                {
-                       for (k = 0; k < randint(3); k++)
+                       for (k = 0; k < randint1(3); k++)
                        {
-                               if (summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, TRUE))
+                               if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                                {
                                        ident = TRUE;
                                }
@@ -1601,9 +1686,9 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_SUMMON_UNDEAD:
                {
-                       for (k = 0; k < randint(3); k++)
+                       for (k = 0; k < randint1(3); k++)
                        {
-                               if (summon_specific(0, py, px, dun_level, SUMMON_UNDEAD, TRUE, FALSE, FALSE, TRUE, TRUE))
+                               if (summon_specific(0, py, px, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                                {
                                        ident = TRUE;
                                }
@@ -1613,7 +1698,7 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_SUMMON_PET:
                {
-                       if (summon_specific(-1, py, px, dun_level, 0, TRUE, TRUE, TRUE, FALSE, FALSE))
+                       if (summon_specific(-1, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET)))
                        {
                                ident = TRUE;
                        }
@@ -1622,7 +1707,7 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_SUMMON_KIN:
                {
-                       if (summon_kin_player(TRUE, p_ptr->lev, py, px, TRUE))
+                       if (summon_kin_player(p_ptr->lev, py, px, (PM_FORCE_PET | PM_ALLOW_GROUP)))
                        {
                                ident = TRUE;
                        }
@@ -1637,21 +1722,21 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_PHASE_DOOR:
                {
-                       teleport_player(10);
+                       teleport_player(10, 0L);
                        ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_TELEPORT:
                {
-                       teleport_player(100);
+                       teleport_player(100, 0L);
                        ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_TELEPORT_LEVEL:
                {
-                       (void)teleport_player_level();
+                       (void)teleport_level(0);
                        ident = TRUE;
                        break;
                }
@@ -1665,15 +1750,15 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_IDENTIFY:
                {
-                       ident = TRUE;
                        if (!ident_spell(FALSE)) used_up = FALSE;
+                       ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_STAR_IDENTIFY:
                {
-                       ident = TRUE;
                        if (!identify_fully(FALSE)) used_up = FALSE;
+                       ident = TRUE;
                        break;
                }
 
@@ -1729,14 +1814,14 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_STAR_ENCHANT_ARMOR:
                {
-                       if (!enchant_spell(0, 0, randint(3) + 2)) used_up = FALSE;
+                       if (!enchant_spell(0, 0, randint1(3) + 2)) used_up = FALSE;
                        ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_STAR_ENCHANT_WEAPON:
                {
-                       if (!enchant_spell(randint(3), randint(3), 0)) used_up = FALSE;
+                       if (!enchant_spell(randint1(3), randint1(3), 0)) used_up = FALSE;
                        ident = TRUE;
                        break;
                }
@@ -1783,7 +1868,7 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_DETECT_TRAP:
                {
-                       if (detect_traps(DETECT_RAD_DEFAULT)) ident = TRUE;
+                       if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
                        break;
                }
 
@@ -1808,19 +1893,19 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_BLESSING:
                {
-                       if (set_blessed(p_ptr->blessed + randint(12) + 6, FALSE)) ident = TRUE;
+                       if (set_blessed(p_ptr->blessed + randint1(12) + 6, FALSE)) ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_HOLY_CHANT:
                {
-                       if (set_blessed(p_ptr->blessed + randint(24) + 12, FALSE)) ident = TRUE;
+                       if (set_blessed(p_ptr->blessed + randint1(24) + 12, FALSE)) ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_HOLY_PRAYER:
                {
-                       if (set_blessed(p_ptr->blessed + randint(48) + 24, FALSE)) ident = TRUE;
+                       if (set_blessed(p_ptr->blessed + randint1(48) + 24, FALSE)) ident = TRUE;
                        break;
                }
 
@@ -1844,7 +1929,7 @@ static void do_cmd_read_scroll_aux(int item)
                case SV_SCROLL_PROTECTION_FROM_EVIL:
                {
                        k = 3 * p_ptr->lev;
-                       if (set_protevil(p_ptr->protevil + randint(25) + k, FALSE)) ident = TRUE;
+                       if (set_protevil(p_ptr->protevil + randint1(25) + k, FALSE)) ident = TRUE;
                        break;
                }
 
@@ -1863,7 +1948,7 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_STAR_DESTRUCTION:
                {
-                       if (destroy_area(py, px, 13+rand_int(5), TRUE))
+                       if (destroy_area(py, px, 13 + randint0(5), FALSE))
                                ident = TRUE;
                        else
 #ifdef JP
@@ -1884,7 +1969,7 @@ msg_print("
 
                case SV_SCROLL_SPELL:
                {
-                       if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_IMITATOR) || (p_ptr->pclass == CLASS_MINDCRAFTER) || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_MAGIC_EATER) || (p_ptr->pclass == CLASS_RED_MAGE) || (p_ptr->pclass == CLASS_SAMURAI) || (p_ptr->pclass == CLASS_BLUE_MAGE) || (p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BERSERKER) || (p_ptr->pclass == CLASS_SMITH) || (p_ptr->pclass == CLASS_MIRROR_MASTER)) break;
+                       if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_IMITATOR) || (p_ptr->pclass == CLASS_MINDCRAFTER) || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_MAGIC_EATER) || (p_ptr->pclass == CLASS_RED_MAGE) || (p_ptr->pclass == CLASS_SAMURAI) || (p_ptr->pclass == CLASS_BLUE_MAGE) || (p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BERSERKER) || (p_ptr->pclass == CLASS_SMITH) || (p_ptr->pclass == CLASS_MIRROR_MASTER) || (p_ptr->pclass == CLASS_NINJA)) break;
                        p_ptr->add_spells++;
                        p_ptr->update |= (PU_SPELLS);
                        ident = TRUE;
@@ -1914,7 +1999,7 @@ msg_print("
 
                case SV_SCROLL_STAR_ACQUIREMENT:
                {
-                       acquirement(py, px, randint(2) + 1, TRUE, FALSE);
+                       acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
                        ident = TRUE;
                        break;
                }
@@ -1924,11 +2009,11 @@ msg_print("
                {
                        fire_ball(GF_FIRE, 0, 666, 4);
                        /* Note: "Double" damage since it is centered on the player ... */
-                       if (!(p_ptr->oppose_fire || p_ptr->resist_fire || p_ptr->immune_fire))
+                       if (!(IS_OPPOSE_FIRE() || p_ptr->resist_fire || p_ptr->immune_fire))
 #ifdef JP
-take_hit(DAMAGE_NOESCAPE, 50+randint(50), "±ê¤Î´¬Êª", -1);
+take_hit(DAMAGE_NOESCAPE, 50+randint1(50), "±ê¤Î´¬Êª", -1);
 #else
-                               take_hit(DAMAGE_NOESCAPE, 50 + randint(50), "a Scroll of Fire", -1);
+                               take_hit(DAMAGE_NOESCAPE, 50 + randint1(50), "a Scroll of Fire", -1);
 #endif
 
                        ident = TRUE;
@@ -1939,11 +2024,11 @@ take_hit(DAMAGE_NOESCAPE, 50+randint(50), "
                case SV_SCROLL_ICE:
                {
                        fire_ball(GF_ICE, 0, 777, 4);
-                       if (!(p_ptr->oppose_cold || p_ptr->resist_cold || p_ptr->immune_cold))
+                       if (!(IS_OPPOSE_COLD() || p_ptr->resist_cold || p_ptr->immune_cold))
 #ifdef JP
-take_hit(DAMAGE_NOESCAPE, 100+randint(100), "ɹ¤Î´¬Êª", -1);
+take_hit(DAMAGE_NOESCAPE, 100+randint1(100), "ɹ¤Î´¬Êª", -1);
 #else
-                               take_hit(DAMAGE_NOESCAPE, 100 + randint(100), "a Scroll of Ice", -1);
+                               take_hit(DAMAGE_NOESCAPE, 100 + randint1(100), "a Scroll of Ice", -1);
 #endif
 
                        ident = TRUE;
@@ -1955,9 +2040,9 @@ take_hit(DAMAGE_NOESCAPE, 100+randint(100), "ɹ
                        fire_ball(GF_CHAOS, 0, 1000, 4);
                        if (!p_ptr->resist_chaos)
 #ifdef JP
-take_hit(DAMAGE_NOESCAPE, 111+randint(111), "¥í¥°¥ë¥¹¤Î´¬Êª", -1);
+take_hit(DAMAGE_NOESCAPE, 111+randint1(111), "¥í¥°¥ë¥¹¤Î´¬Êª", -1);
 #else
-                               take_hit(DAMAGE_NOESCAPE, 111 + randint(111), "a Scroll of Logrus", -1);
+                               take_hit(DAMAGE_NOESCAPE, 111 + randint1(111), "a Scroll of Logrus", -1);
 #endif
 
                        ident = TRUE;
@@ -1968,7 +2053,7 @@ take_hit(DAMAGE_NOESCAPE, 111+randint(111), "
                {
                        errr err = 0;
 
-                       switch (randint(20))
+                       switch (randint1(20))
                        {
                                case 1:
 #ifdef JP
@@ -2048,7 +2133,7 @@ msg_print("
                }
        }
        }
-       else if (o_ptr->tval == TV_SOFT_ARMOR)
+       else if (o_ptr->name1 == ART_GHB)
        {
 #ifdef JP
                msg_print("»ä¤Ï¶ìÏ«¤·¤Æ¡Ø¥°¥ì¡¼¥¿¡¼¡¦¥Ø¥ë=¥Ó¡¼¥¹¥È¡Ù¤òÅݤ·¤¿¡£");
@@ -2070,7 +2155,7 @@ msg_print("
                msg_print(NULL);
                msg_print("°Å°Ç¤ÎÃæ¤Ë·Ò¤®¤È¤á¤ë¡£¡×");
 #else
-               msg_print("'One Ring to rule them all, ");
+               msg_print("'One Ring to rule them all, ");
                msg_print(NULL);
                msg_print("One Ring to find them, ");
                msg_print(NULL);
@@ -2080,7 +2165,7 @@ msg_print("
 #endif
                used_up = FALSE;
        }
-       else
+       else if (o_ptr->tval==TV_PARCHMENT)
        {
                cptr q;
                char o_name[MAX_NLEN];
@@ -2092,10 +2177,10 @@ msg_print("
                q=format("book-%d_jp.txt",o_ptr->sval);
 
                /* Display object description */
-               object_desc(o_name, o_ptr, TRUE, 0);
+               object_desc(o_name, o_ptr, OD_NAME_ONLY);
 
                /* Build the filename */
-               path_build(buf, 1024, ANGBAND_DIR_FILE, q);
+               path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, q);
 
                /* Peruse the help file */
                (void)show_file(TRUE, buf, o_name, 0, 0);
@@ -2110,7 +2195,7 @@ msg_print("
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
 
-       if (!(object_aware_p(o_ptr)))
+       if (!(object_is_aware(o_ptr)))
        {
                chg_virtue(V_PATIENCE, -1);
                chg_virtue(V_CHANCE, 1);
@@ -2121,7 +2206,7 @@ msg_print("
        object_tried(o_ptr);
 
        /* An identification was made */
-       if (ident && !object_aware_p(o_ptr))
+       if (ident && !object_is_aware(o_ptr))
        {
                object_aware(o_ptr);
                gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
@@ -2154,8 +2239,6 @@ msg_print("
                floor_item_describe(0 - item);
                floor_item_optimize(0 - item);
        }
-
-       /* Can save again */
 }
 
 
@@ -2164,7 +2247,7 @@ msg_print("
  */
 static bool item_tester_hook_readable(object_type *o_ptr)
 {
-       if ((o_ptr->tval==TV_SCROLL) || (o_ptr->tval==TV_PARCHEMENT) || ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_T_SHIRT)) || (o_ptr->name1 == ART_POWER)) return (TRUE);
+       if ((o_ptr->tval==TV_SCROLL) || (o_ptr->tval==TV_PARCHMENT) || (o_ptr->name1 == ART_GHB) || (o_ptr->name1 == ART_POWER)) return (TRUE);
 
        /* Assume not */
        return (FALSE);
@@ -2173,6 +2256,7 @@ static bool item_tester_hook_readable(object_type *o_ptr)
 
 void do_cmd_read_scroll(void)
 {
+       object_type *o_ptr;
        int  item;
        cptr q, s;
 
@@ -2226,14 +2310,26 @@ void do_cmd_read_scroll(void)
        s = "You have no scrolls to read.";
 #endif
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
+       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
+
+       /* Get the item (in the pack) */
+       if (item >= 0)
+       {
+               o_ptr = &inventory[item];
+       }
+
+       /* Get the item (on the floor) */
+       else
+       {
+               o_ptr = &o_list[0 - item];
+       }
 
        /* Read the scroll */
-       do_cmd_read_scroll_aux(item);
+       do_cmd_read_scroll_aux(item, object_is_aware(o_ptr));
 }
 
 
-static int staff_effect(int sval, bool *use_charge, bool magic)
+static int staff_effect(int sval, bool *use_charge, bool magic, bool known)
 {
        int k;
        int ident = FALSE;
@@ -2245,7 +2341,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
                {
                        if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
                        {
-                               if (set_blind(p_ptr->blind + 3 + randint(5))) ident = TRUE;
+                               if (set_blind(p_ptr->blind + 3 + randint1(5))) ident = TRUE;
                        }
                        if (unlite_area(10, 3)) ident = TRUE;
                        break;
@@ -2253,7 +2349,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
 
                case SV_STAFF_SLOWNESS:
                {
-                       if (set_slow(p_ptr->slow + randint(30) + 15, FALSE)) ident = TRUE;
+                       if (set_slow(p_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
                        break;
                }
 
@@ -2265,9 +2361,9 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
 
                case SV_STAFF_SUMMONING:
                {
-                       for (k = 0; k < randint(4); k++)
+                       for (k = 0; k < randint1(4); k++)
                        {
-                               if (summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, TRUE))
+                               if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                                {
                                        ident = TRUE;
                                }
@@ -2277,7 +2373,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
 
                case SV_STAFF_TELEPORTATION:
                {
-                       teleport_player(100);
+                       teleport_player(100, 0L);
                        ident = TRUE;
                        break;
                }
@@ -2332,15 +2428,15 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
                        }
                        for (k = 0; k < num; k++)
                        {
-               attempts = 1000;
+                               attempts = 1000;
 
-                               while(attempts--)
+                               while (attempts--)
                                {
                                        scatter(&y, &x, py, px, 4, 0);
 
-                                       if (!cave_floor_bold(y, x)) continue;
+                                       if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
 
-                                       if ((y != py) || (x != px)) break;
+                                       if (!player_bold(y, x)) break;
                                }
 
                                project(0, 0, y, x, damroll(6 + p_ptr->lev / 8, 10), GF_LITE_WEAK,
@@ -2378,7 +2474,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
 
                case SV_STAFF_DETECT_TRAP:
                {
-                       if (detect_traps(DETECT_RAD_DEFAULT)) ident = TRUE;
+                       if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
                        break;
                }
 
@@ -2440,7 +2536,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
 #ifdef JP
                                msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
 #else
-                               msg_print("Your feel your head clear.");
+                               msg_print("You feel your head clear.");
 #endif
 
                                p_ptr->redraw |= (PR_MANA);
@@ -2465,7 +2561,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
 
                case SV_STAFF_SPEED:
                {
-                       if (set_fast(randint(30) + 15, FALSE)) ident = TRUE;
+                       if (set_fast(randint1(30) + 15, FALSE)) ident = TRUE;
                        break;
                }
 
@@ -2492,7 +2588,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
                {
                        if (dispel_evil(150)) ident = TRUE;
                        k = 3 * p_ptr->lev;
-                       if (set_protevil((magic ? 0 : p_ptr->protevil) + randint(25) + k, FALSE)) ident = TRUE;
+                       if (set_protevil((magic ? 0 : p_ptr->protevil) + randint1(25) + k, FALSE)) ident = TRUE;
                        if (set_poisoned(0)) ident = TRUE;
                        if (set_afraid(0)) ident = TRUE;
                        if (hp_player(50)) ident = TRUE;
@@ -2525,7 +2621,7 @@ msg_print("
 
                case SV_STAFF_DESTRUCTION:
                {
-                       if (destroy_area(py, px, 13+rand_int(5), TRUE))
+                       if (destroy_area(py, px, 13 + randint0(5), FALSE))
                                ident = TRUE;
 
                        break;
@@ -2547,7 +2643,7 @@ msg_print("
                        msg_print("Mighty magics rend your enemies!");
 #endif
                        project(0, 5, py, px,
-                               (randint(200) + 300) * 2, GF_MANA, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID | PROJECT_NO_REF, -1);
+                               (randint1(200) + 300) * 2, GF_MANA, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID, -1);
                        if ((p_ptr->pclass != CLASS_MAGE) && (p_ptr->pclass != CLASS_HIGH_MAGE) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_MAGIC_EATER) && (p_ptr->pclass != CLASS_BLUE_MAGE))
                        {
 #ifdef JP
@@ -2560,6 +2656,23 @@ msg_print("
 
                        break;
                }
+
+               case SV_STAFF_NOTHING:
+               {
+#ifdef JP
+                       msg_print("²¿¤âµ¯¤é¤Ê¤«¤Ã¤¿¡£");
+#else
+                       msg_print("Nothing happen.");
+#endif
+                       if (prace_is_(RACE_SKELETON) || prace_is_(RACE_GOLEM) ||
+                               prace_is_(RACE_ZOMBIE) || prace_is_(RACE_SPECTRE))
+#ifdef JP
+                               msg_print("¤â¤Ã¤¿¤¤¤Ê¤¤»ö¤ò¤·¤¿¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£¿©¤Ùʪ¤ÏÂçÀڤˤ·¤Ê¤¯¤Æ¤Ï¡£");
+#else
+                               msg_print("What a waste.  It's your food!");
+#endif
+                       break;
+               }
        }
        return ident;
 }
@@ -2611,7 +2724,7 @@ static void do_cmd_use_staff_aux(int item)
        energy_use = 100;
 
        /* Extract the item level */
-       lev = get_object_level(o_ptr);
+       lev = k_info[o_ptr->k_idx].level;
        if (lev > 50) lev = 50 + (lev - 50)/2;
 
        /* Base chance of success */
@@ -2624,7 +2737,7 @@ static void do_cmd_use_staff_aux(int item)
        chance = chance - lev;
 
        /* Give everyone a (slight) chance */
-       if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0))
+       if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
        {
                chance = USE_DEVICE;
        }
@@ -2643,7 +2756,7 @@ static void do_cmd_use_staff_aux(int item)
        }
 
        /* Roll for usage */
-       if ((chance < USE_DEVICE) || (randint(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
+       if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
        {
                if (flush_failure) flush();
 #ifdef JP
@@ -2670,6 +2783,7 @@ static void do_cmd_use_staff_aux(int item)
 
                /* Combine / Reorder the pack (later) */
                p_ptr->notice |= (PN_COMBINE | PN_REORDER);
+               p_ptr->window |= (PW_INVEN);
 
                return;
        }
@@ -2678,9 +2792,9 @@ static void do_cmd_use_staff_aux(int item)
        /* Sound */
        sound(SOUND_ZAP);
 
-       ident = staff_effect(o_ptr->sval, &use_charge, FALSE);
+       ident = staff_effect(o_ptr->sval, &use_charge, FALSE, object_is_aware(o_ptr));
 
-       if (!(object_aware_p(o_ptr)))
+       if (!(object_is_aware(o_ptr)))
        {
                chg_virtue(V_PATIENCE, -1);
                chg_virtue(V_CHANCE, 1);
@@ -2694,7 +2808,7 @@ static void do_cmd_use_staff_aux(int item)
        object_tried(o_ptr);
 
        /* An identification was made */
-       if (ident && !object_aware_p(o_ptr))
+       if (ident && !object_is_aware(o_ptr))
        {
                object_aware(o_ptr);
                gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
@@ -2793,19 +2907,19 @@ static int wand_effect(int sval, int dir, bool magic)
        if (sval == SV_WAND_WONDER)
        {
                int vir = virtue_number(V_CHANCE);
-               sval = rand_int(SV_WAND_WONDER);
+               sval = randint0(SV_WAND_WONDER);
 
                if (vir)
                {
                        if (p_ptr->virtues[vir - 1] > 0)
                        {
-                               while (randint(300) < p_ptr->virtues[vir - 1]) sval++;
-                               if (sval > SV_WAND_COLD_BALL) sval = rand_int(4) + SV_WAND_ACID_BALL;
+                               while (randint1(300) < p_ptr->virtues[vir - 1]) sval++;
+                               if (sval > SV_WAND_COLD_BALL) sval = randint0(4) + SV_WAND_ACID_BALL;
                        }
                        else
                        {
-                               while (randint(300) < (0-p_ptr->virtues[vir - 1])) sval--;
-                               if (sval < SV_WAND_HEAL_MONSTER) sval = rand_int(3) + SV_WAND_HEAL_MONSTER;
+                               while (randint1(300) < (0-p_ptr->virtues[vir - 1])) sval--;
+                               if (sval < SV_WAND_HEAL_MONSTER) sval = randint0(3) + SV_WAND_HEAL_MONSTER;
                        }
                }
                if (sval < SV_WAND_TELEPORT_AWAY)
@@ -3003,7 +3117,7 @@ static int wand_effect(int sval, int dir, bool magic)
 
                case SV_WAND_DRAGON_BREATH:
                {
-                       switch (randint(5))
+                       switch (randint1(5))
                        {
                                case 1:
                                {
@@ -3040,10 +3154,9 @@ static int wand_effect(int sval, int dir, bool magic)
                        break;
                }
 
-//             case SV_WAND_ANNIHILATION:
                case SV_WAND_DISINTEGRATE:
                {
-                       fire_ball(GF_DISINTEGRATE, dir, 200 + randint(p_ptr->lev * 2), 2);
+                       fire_ball(GF_DISINTEGRATE, dir, 200 + randint1(p_ptr->lev * 2), 2);
                        ident = TRUE;
                        break;
                }
@@ -3131,7 +3244,7 @@ static void do_cmd_aim_wand_aux(int item)
 
 
        /* Allow direction to be cancelled for free */
-       if (object_aware_p(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
+       if (object_is_aware(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
                                      || o_ptr->sval == SV_WAND_HASTE_MONSTER))
                        target_pet = TRUE;
        if (!get_aim_dir(&dir))
@@ -3145,7 +3258,7 @@ static void do_cmd_aim_wand_aux(int item)
        energy_use = 100;
 
        /* Get the level */
-       lev = get_object_level(o_ptr);
+       lev = k_info[o_ptr->k_idx].level;
        if (lev > 50) lev = 50 + (lev - 50)/2;
 
        /* Base chance of success */
@@ -3158,7 +3271,7 @@ static void do_cmd_aim_wand_aux(int item)
        chance = chance - lev;
 
        /* Give everyone a (slight) chance */
-       if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0))
+       if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
        {
                chance = USE_DEVICE;
        }
@@ -3177,7 +3290,7 @@ static void do_cmd_aim_wand_aux(int item)
        }
 
        /* Roll for usage */
-       if ((chance < USE_DEVICE) || (randint(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
+       if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
        {
                if (flush_failure) flush();
 #ifdef JP
@@ -3204,6 +3317,7 @@ static void do_cmd_aim_wand_aux(int item)
 
                /* Combine / Reorder the pack (later) */
                p_ptr->notice |= (PN_COMBINE | PN_REORDER);
+               p_ptr->window |= (PW_INVEN);
 
                return;
        }
@@ -3216,7 +3330,7 @@ static void do_cmd_aim_wand_aux(int item)
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
 
-       if (!(object_aware_p(o_ptr)))
+       if (!(object_is_aware(o_ptr)))
        {
                chg_virtue(V_PATIENCE, -1);
                chg_virtue(V_CHANCE, 1);
@@ -3227,7 +3341,7 @@ static void do_cmd_aim_wand_aux(int item)
        object_tried(o_ptr);
 
        /* Apply identification */
-       if (ident && !object_aware_p(o_ptr))
+       if (ident && !object_is_aware(o_ptr))
        {
                object_aware(o_ptr);
                gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
@@ -3287,12 +3401,15 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
 {
        int ident = FALSE;
 
+       /* Unused */
+       (void)magic;
+
        /* Analyze the rod */
        switch (sval)
        {
                case SV_ROD_DETECT_TRAP:
                {
-                       if (detect_traps(DETECT_RAD_DEFAULT)) ident = TRUE;
+                       if (detect_traps(DETECT_RAD_DEFAULT, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
                        break;
                }
 
@@ -3305,8 +3422,8 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
 
                case SV_ROD_IDENTIFY:
                {
-                       ident = TRUE;
                        if (!ident_spell(FALSE)) *use_charge = FALSE;
+                       ident = TRUE;
                        break;
                }
 
@@ -3379,14 +3496,13 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
 
                case SV_ROD_SPEED:
                {
-                       if (set_fast(randint(30) + 15, FALSE)) ident = TRUE;
+                       if (set_fast(randint1(30) + 15, FALSE)) ident = TRUE;
                        break;
                }
 
                case SV_ROD_PESTICIDE:
                {
-                       fire_ball(GF_POIS, dir, 10, 3);
-                       ident = TRUE;
+                       if (dispel_monsters(4)) ident = TRUE;
                        break;
                }
 
@@ -3530,7 +3646,8 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
  */
 static void do_cmd_zap_rod_aux(int item)
 {
-       int         ident, chance, dir, lev, fail;
+       int ident, chance, lev, fail;
+       int dir = 0;
        object_type *o_ptr;
        bool success;
 
@@ -3566,8 +3683,8 @@ static void do_cmd_zap_rod_aux(int item)
 
 
        /* Get a direction (unless KNOWN not to need it) */
-       if (((o_ptr->sval >= SV_ROD_MIN_DIRECTION) && (o_ptr->sval != SV_ROD_HAVOC) && (o_ptr->sval != SV_ROD_AGGRAVATE)) ||
-            !object_aware_p(o_ptr))
+       if (((o_ptr->sval >= SV_ROD_MIN_DIRECTION) && (o_ptr->sval != SV_ROD_HAVOC) && (o_ptr->sval != SV_ROD_AGGRAVATE) && (o_ptr->sval != SV_ROD_PESTICIDE)) ||
+            !object_is_aware(o_ptr))
        {
                /* Get a direction, allow cancel */
                if (!get_aim_dir(&dir)) return;
@@ -3578,7 +3695,7 @@ static void do_cmd_zap_rod_aux(int item)
        energy_use = 100;
 
        /* Extract the item level */
-       lev = get_object_level(o_ptr);
+       lev = k_info[o_ptr->k_idx].level;
 
        /* Base chance of success */
        chance = p_ptr->skill_dev;
@@ -3608,12 +3725,12 @@ static void do_cmd_zap_rod_aux(int item)
        if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
        else if (chance > fail)
        {
-               if (rand_int(chance*2) < fail) success = FALSE;
+               if (randint0(chance*2) < fail) success = FALSE;
                else success = TRUE;
        }
        else
        {
-               if (rand_int(fail*2) < chance) success = TRUE;
+               if (randint0(fail*2) < chance) success = TRUE;
                else success = FALSE;
        }
 
@@ -3669,7 +3786,7 @@ msg_print("
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
 
-       if (!(object_aware_p(o_ptr)))
+       if (!(object_is_aware(o_ptr)))
        {
                chg_virtue(V_PATIENCE, -1);
                chg_virtue(V_CHANCE, 1);
@@ -3680,7 +3797,7 @@ msg_print("
        object_tried(o_ptr);
 
        /* Successfully determined the object function */
-       if (ident && !object_aware_p(o_ptr))
+       if (ident && !object_is_aware(o_ptr))
        {
                object_aware(o_ptr);
                gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
@@ -3725,27 +3842,16 @@ void do_cmd_zap_rod(void)
  */
 static bool item_tester_hook_activate(object_type *o_ptr)
 {
-       u32b f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
 
        /* Not known */
-       if (!object_known_p(o_ptr)) return (FALSE);
+       if (!object_is_known(o_ptr)) return (FALSE);
 
        /* Extract the flags */
-       object_flags(o_ptr, &f1, &f2, &f3);
+       object_flags(o_ptr, flgs);
 
        /* Check activation flag */
-       if (f3 & (TR3_ACTIVATE)) return (TRUE);
-
-       if ((o_ptr->tval > TV_CAPTURE) && o_ptr->xtra3)
-       {
-               switch(o_ptr->xtra3)
-               case ESSENCE_TMP_RES_ACID:
-               case ESSENCE_TMP_RES_ELEC:
-               case ESSENCE_TMP_RES_FIRE:
-               case ESSENCE_TMP_RES_COLD:
-               case ESSENCE_EARTHQUAKE:
-                       return (TRUE);
-       }
+       if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
 
        /* Assume not */
        return (FALSE);
@@ -3758,7 +3864,7 @@ static bool item_tester_hook_activate(object_type *o_ptr)
 void ring_of_power(int dir)
 {
        /* Pick a random effect */
-       switch (randint(10))
+       switch (randint1(10))
        {
                case 1:
                case 2:
@@ -3840,6 +3946,9 @@ static bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
        monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
        monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
 
+       /* Unused */
+       (void)v;
+
        if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
        if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
 
@@ -3888,10 +3997,108 @@ static void do_cmd_activate_aux(int item)
        energy_use = 100;
 
        /* Extract the item level */
-       lev = get_object_level(o_ptr);
+       lev = k_info[o_ptr->k_idx].level;
 
        /* Hack -- use artifact level instead */
-       if (artifact_p(o_ptr)) lev = a_info[o_ptr->name1].level;
+       if (object_is_fixed_artifact(o_ptr)) lev = a_info[o_ptr->name1].level;
+       else if (o_ptr->art_name)
+       {
+               switch (o_ptr->xtra2)
+               {
+                       case ACT_SUNLIGHT:
+                       case ACT_BO_MISS_1:
+                       case ACT_BA_POIS_1:
+                       case ACT_CONFUSE:
+                       case ACT_SLEEP:
+                       case ACT_CURE_LW:
+                       case ACT_CURE_POISON:
+                       case ACT_BERSERK:
+                       case ACT_LIGHT:
+                       case ACT_DEST_DOOR:
+                       case ACT_TELEPORT:
+                               lev = 10;
+                               break;
+                       case ACT_BO_ELEC_1:
+                       case ACT_BO_ACID_1:
+                       case ACT_BO_COLD_1:
+                       case ACT_BO_FIRE_1:
+                       case ACT_MAP_LIGHT:
+                       case ACT_STONE_MUD:
+                       case ACT_CURE_MW:
+                       case ACT_QUAKE:
+                               lev = 20;
+                               break;
+                       case ACT_DRAIN_1:
+                       case ACT_TELE_AWAY:
+                       case ACT_ESP:
+                       case ACT_RESIST_ALL:
+                       case ACT_DETECT_ALL:
+                       case ACT_RECALL:
+                       case ACT_SATIATE:
+                       case ACT_RECHARGE:
+                               lev = 30;
+                               break;
+                       case ACT_BA_COLD_1:
+                       case ACT_BA_FIRE_1:
+                       case ACT_TERROR:
+                       case ACT_PROT_EVIL:
+                       case ACT_ID_PLAIN:
+                       case ACT_REST_LIFE:
+                       case ACT_SPEED:
+                       case ACT_BANISH_EVIL:
+                               lev = 40;
+                               break;
+                       case ACT_DRAIN_2:
+                       case ACT_VAMPIRE_1:
+                       case ACT_BO_MISS_2:
+                       case ACT_BA_FIRE_2:
+                       case ACT_WHIRLWIND:
+                       case ACT_CHARM_ANIMAL:
+                       case ACT_SUMMON_ANIMAL:
+                       case ACT_DISP_EVIL:
+                       case ACT_DISP_GOOD:
+                       case ACT_XTRA_SPEED:
+                       case ACT_DETECT_XTRA:
+                       case ACT_ID_FULL:
+                               lev = 50;
+                               break;
+                       case ACT_VAMPIRE_2:
+                       case ACT_BA_COLD_3:
+                       case ACT_BA_ELEC_3:
+                       case ACT_GENOCIDE:
+                       case ACT_CHARM_UNDEAD:
+                       case ACT_CHARM_OTHER:
+                       case ACT_SUMMON_PHANTOM:
+                       case ACT_SUMMON_ELEMENTAL:
+                       case ACT_RUNE_EXPLO:
+                               lev = 60;
+                               break;
+                       case ACT_MASS_GENO:
+                       case ACT_CHARM_ANIMALS:
+                       case ACT_CHARM_OTHERS:
+                       case ACT_CURE_700:
+                       case ACT_RUNE_PROT:
+                       case ACT_ALCHEMY:
+                       case ACT_REST_ALL:
+                               lev = 70;
+                               break;
+                       case ACT_CALL_CHAOS:
+                       case ACT_ROCKET:
+                       case ACT_BA_MISS_3:
+                       case ACT_CURE_1000:
+                       case ACT_DIM_DOOR:
+                       case ACT_SUMMON_UNDEAD:
+                       case ACT_SUMMON_DEMON:
+                               lev = 80;
+                               break;
+                       case ACT_WRAITH:
+                       case ACT_INVULN:
+                               lev = 100;
+                               break;
+                       default:
+                               lev = 0;
+               }
+       }
        else if (((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) && o_ptr->name2) lev = e_info[o_ptr->name2].level;
 
        /* Base chance of success */
@@ -3922,12 +4129,12 @@ static void do_cmd_activate_aux(int item)
        if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
        else if (chance > fail)
        {
-               if (rand_int(chance*2) < fail) success = FALSE;
+               if (randint0(chance*2) < fail) success = FALSE;
                else success = TRUE;
        }
        else
        {
-               if (rand_int(fail*2) < chance) success = TRUE;
+               if (randint0(fail*2) < chance) success = TRUE;
                else success = FALSE;
        }
 
@@ -3982,7 +4189,7 @@ static void do_cmd_activate_aux(int item)
        }
 
        /* Artifacts */
-       else if (o_ptr->name1)
+       else if (object_is_fixed_artifact(o_ptr))
        {
                /* Choose effect */
                switch (o_ptr->name1)
@@ -3990,13 +4197,13 @@ static void do_cmd_activate_aux(int item)
                        case ART_GALADRIEL:
                        {
 #ifdef JP
-                               msg_print("ààÎÜÉÓ¤«¤éÀ¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...");
+                               msg_print("ààÍþÉÓ¤«¤éÀ¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...");
 #else
                                msg_print("The phial wells with clear light...");
 #endif
 
                                lite_area(damroll(2, 15), 3);
-                               o_ptr->timeout = rand_int(10) + 10;
+                               o_ptr->timeout = randint0(10) + 10;
                                break;
                        }
 
@@ -4010,11 +4217,11 @@ static void do_cmd_activate_aux(int item)
 
                                map_area(DETECT_RAD_MAP);
                                lite_area(damroll(2, 15), 3);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        }
 
-                       case ART_THRAIN:
+                       case ART_JUDGE:
                        {
 #ifdef JP
 msg_print("¤½¤ÎÊõÀФÏÀÖ¤¯ÌÀ¤ë¤¯¸÷¤Ã¤¿¡ª");
@@ -4024,7 +4231,7 @@ msg_print("
 
                                chg_virtue(V_KNOWLEDGE, 1);
                                chg_virtue(V_ENLIGHTEN, 1);
-                               wiz_lite(FALSE, FALSE);
+                               wiz_lite(FALSE);
 #ifdef JP
 msg_print("¤½¤ÎÊõÀФϤ¢¤Ê¤¿¤ÎÂÎÎϤòÃ¥¤Ã¤¿...");
 take_hit(DAMAGE_LOSELIFE, damroll(3,8), "¿³È½¤ÎÊõÀÐ", -1);
@@ -4033,7 +4240,7 @@ take_hit(DAMAGE_LOSELIFE, damroll(3,8), "
                                take_hit(DAMAGE_LOSELIFE, damroll(3, 8), "the Jewel of Judgement", -1);
 #endif
 
-                               (void)detect_traps(DETECT_RAD_DEFAULT);
+                               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                                (void)detect_doors(DETECT_RAD_DEFAULT);
                                (void)detect_stairs(DETECT_RAD_DEFAULT);
 
@@ -4047,7 +4254,7 @@ if (get_check("
                                        (void)word_of_recall();
                                }
 
-                               o_ptr->timeout = rand_int(20) + 20;
+                               o_ptr->timeout = randint0(20) + 20;
                                break;
                        }
 
@@ -4060,8 +4267,8 @@ if (get_check("
 #endif
 
                                k = 3 * p_ptr->lev;
-                               (void)set_protevil(randint(25) + k, FALSE);
-                               o_ptr->timeout = rand_int(225) + 225;
+                               (void)set_protevil(randint1(25) + k, FALSE);
+                               o_ptr->timeout = randint0(225) + 225;
                                break;
                        }
 
@@ -4074,7 +4281,7 @@ if (get_check("
 #endif
 
                                dispel_evil(p_ptr->lev * 5);
-                               o_ptr->timeout = rand_int(200) + 200;
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
@@ -4087,11 +4294,11 @@ if (get_check("
 #endif
 
                                dispel_evil(p_ptr->lev * 5);
-                               o_ptr->timeout = rand_int(200) + 200;
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
-                       case ART_BARAHIR:
+                       case ART_FRAKIR:
                        {
 #ifdef JP
 msg_print("¤¢¤Ê¤¿¤Ï¥Õ¥é¥­¥¢¤ËŨ¤òÄù¤á»¦¤¹¤è¤¦Ì¿¤¸¤¿¡£");
@@ -4101,7 +4308,7 @@ msg_print("
 
                                if (!get_aim_dir(&dir)) return;
                                if (drain_life(dir, 100))
-                               o_ptr->timeout = rand_int(100) + 100;
+                               o_ptr->timeout = randint0(100) + 100;
                                break;
                        }
 
@@ -4113,8 +4320,8 @@ msg_print("
                                msg_print("The ring glows brightly...");
 #endif
 
-                               (void)set_fast(randint(75) + 75, FALSE);
-                               o_ptr->timeout = rand_int(150) + 150;
+                               (void)set_fast(randint1(75) + 75, FALSE);
+                               o_ptr->timeout = randint0(150) + 150;
                                break;
                        }
 
@@ -4128,7 +4335,7 @@ msg_print("
 
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_FIRE, dir, 300, 3);
-                               o_ptr->timeout = rand_int(225) + 225;
+                               o_ptr->timeout = randint0(225) + 225;
                                break;
                        }
 
@@ -4142,7 +4349,7 @@ msg_print("
 
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_COLD, dir, 400, 3);
-                               o_ptr->timeout = rand_int(325) + 325;
+                               o_ptr->timeout = randint0(325) + 325;
                                break;
                        }
 
@@ -4150,14 +4357,14 @@ msg_print("
                        case ART_GOURYU:
                        {
 #ifdef JP
-                               msg_print("»ØÎؤϿ¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
+                               msg_format("%s¤Ï¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...", o_ptr->name1 == ART_VILYA ? "»ØÎØ" : "¥½¡¼¥É");
 #else
-                               msg_print("The ring glows deep blue...");
+                               msg_format("The %s glows deep blue...", o_ptr->name1 == ART_VILYA ? "ring" : "sword");
 #endif
 
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_ELEC, dir, 500, 3);
-                               o_ptr->timeout = rand_int(425) + 425;
+                               o_ptr->timeout = randint0(425) + 425;
                                break;
                        }
 
@@ -4172,7 +4379,7 @@ msg_print("
 
                                if (!get_aim_dir(&dir)) return;
                                ring_of_power(dir);
-                               o_ptr->timeout = rand_int(450) + 450;
+                               o_ptr->timeout = randint0(450) + 450;
                                break;
                        }
 
@@ -4191,15 +4398,15 @@ msg_print("
 
                                for (k = 0; k < num; k++)
                                {
-               attempts = 1000;
+                                       attempts = 1000;
 
-                                       while(attempts--)
+                                       while (attempts--)
                                        {
                                                scatter(&y, &x, py, px, 4, 0);
 
-                                               if (!cave_floor_bold(y, x)) continue;
+                                               if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
 
-                                               if ((y != py) || (x != px)) break;
+                                               if (!player_bold(y, x)) break;
                                        }
 
                                        project(0, 3, y, x, 150, GF_ELEC,
@@ -4221,20 +4428,20 @@ msg_print("
 
                                fire_ball(GF_MISSILE, dir, 300, 4);
 #ifdef JP
-                               msg_print("¥¢¡¼¥Þ¡¼¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...");
+                               msg_print("³»¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...");
 #else
                                msg_print("Your armor glows many colours...");
 #endif
 
                                (void)set_afraid(0);
-                               (void)set_hero(randint(50) + 50, FALSE);
+                               (void)set_hero(randint1(50) + 50, FALSE);
                                (void)hp_player(10);
-                               (void)set_blessed(randint(50) + 50, FALSE);
-                               (void)set_oppose_acid(randint(50) + 50, FALSE);
-                               (void)set_oppose_elec(randint(50) + 50, FALSE);
-                               (void)set_oppose_fire(randint(50) + 50, FALSE);
-                               (void)set_oppose_cold(randint(50) + 50, FALSE);
-                               (void)set_oppose_pois(randint(50) + 50, FALSE);
+                               (void)set_blessed(randint1(50) + 50, FALSE);
+                               (void)set_oppose_acid(randint1(50) + 50, FALSE);
+                               (void)set_oppose_elec(randint1(50) + 50, FALSE);
+                               (void)set_oppose_fire(randint1(50) + 50, FALSE);
+                               (void)set_oppose_cold(randint1(50) + 50, FALSE);
+                               (void)set_oppose_pois(randint1(50) + 50, FALSE);
                                o_ptr->timeout = 400;
                                break;
                        }
@@ -4242,7 +4449,7 @@ msg_print("
                        case ART_SOULKEEPER:
                        {
 #ifdef JP
-                               msg_print("¥¢¡¼¥Þ¡¼¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
+                               msg_print("³»¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
                                msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬¤è¤¤...");
 #else
                                msg_print("Your armor glows a bright white...");
@@ -4255,7 +4462,7 @@ msg_print("
                                break;
                        }
 
-                       case ART_BELEGENNON:
+                       case ART_LOHENGRIN:
                        {
 #ifdef JP
 msg_print("Å·¹ñ¤Î²Î¤¬Ê¹¤³¤¨¤ë...");
@@ -4268,16 +4475,17 @@ msg_print("ŷ
                                (void)set_stun(0);
                                (void)set_confused(0);
                                (void)set_blind(0);
-                               (void)set_hero(randint(25) + 25, FALSE);
+                               (void)set_afraid(0);
+                               (void)set_hero(randint1(25) + 25, FALSE);
                                (void)hp_player(777);
                                o_ptr->timeout = 300;
                                break;
                        }
 
-                       case ART_CELEBORN:
+                       case ART_JULIAN:
                        {
 #ifdef JP
-                               msg_print("¥¢¡¼¥Þ¡¼¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
+                               msg_print("³»¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
 #else
                                msg_print("Your armor glows deep blue...");
 #endif
@@ -4290,7 +4498,7 @@ msg_print("ŷ
                        case ART_CASPANION:
                        {
 #ifdef JP
-                               msg_print("¥¢¡¼¥Þ¡¼¤¬ÀÖ¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
+                               msg_print("³»¤¬ÀÖ¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
 #else
                                msg_print("Your armor glows bright red...");
 #endif
@@ -4321,11 +4529,11 @@ msg_print("ŷ
 #endif
 
                                detect_all(DETECT_RAD_DEFAULT);
-                               o_ptr->timeout = rand_int(55) + 55;
+                               o_ptr->timeout = randint0(55) + 55;
                                break;
                        }
 
-                       case ART_GONDOR:
+                       case ART_AMBER:
                        {
 #ifdef JP
                                msg_print("²¦´§¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
@@ -4347,14 +4555,14 @@ msg_print("ŷ
 #ifdef JP
                                msg_format("%s¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...", o_ptr->name1 == ART_COLLUIN ? "¥¯¥í¡¼¥¯" : "³»");
 #else
-                               msg_format("Your cloak glows many colours...");
+                               msg_format("Your %s glows many colours...", o_ptr->name1 == ART_COLLUIN ? "cloak" : "armor");
 #endif
 
-                               (void)set_oppose_acid(randint(20) + 20, FALSE);
-                               (void)set_oppose_elec(randint(20) + 20, FALSE);
-                               (void)set_oppose_fire(randint(20) + 20, FALSE);
-                               (void)set_oppose_cold(randint(20) + 20, FALSE);
-                               (void)set_oppose_pois(randint(20) + 20, FALSE);
+                               (void)set_oppose_acid(randint1(20) + 20, FALSE);
+                               (void)set_oppose_elec(randint1(20) + 20, FALSE);
+                               (void)set_oppose_fire(randint1(20) + 20, FALSE);
+                               (void)set_oppose_cold(randint1(20) + 20, FALSE);
+                               (void)set_oppose_pois(randint1(20) + 20, FALSE);
                                o_ptr->timeout = 111;
                                break;
                        }
@@ -4393,7 +4601,7 @@ msg_print("ŷ
                                msg_print("Your cloak twists space around you...");
 #endif
 
-                               teleport_player(100);
+                               teleport_player(100, 0L);
                                o_ptr->timeout = 45;
                                break;
                        }
@@ -4435,7 +4643,7 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_FIRE, dir, damroll(9, 8));
-                               o_ptr->timeout = rand_int(8) + 8;
+                               o_ptr->timeout = randint0(8) + 8;
                                break;
                        }
 
@@ -4449,7 +4657,7 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_COLD, dir, damroll(6, 8));
-                               o_ptr->timeout = rand_int(7) + 7;
+                               o_ptr->timeout = randint0(7) + 7;
                                break;
                        }
 
@@ -4463,7 +4671,7 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_ELEC, dir, damroll(4, 8));
-                               o_ptr->timeout = rand_int(5) + 5;
+                               o_ptr->timeout = randint0(5) + 5;
                                break;
                        }
 
@@ -4477,7 +4685,7 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_ACID, dir, damroll(5, 8));
-                               o_ptr->timeout = rand_int(6) + 6;
+                               o_ptr->timeout = randint0(6) + 6;
                                break;
                        }
 
@@ -4491,7 +4699,7 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_ARROW, dir, 150);
-                               o_ptr->timeout = rand_int(90) + 90;
+                               o_ptr->timeout = randint0(90) + 90;
                                break;
                        }
 
@@ -4503,12 +4711,12 @@ msg_print("ŷ
                                msg_print("Your boots glow bright green...");
 #endif
 
-                               (void)set_fast(randint(20) + 20, FALSE);
+                               (void)set_fast(randint1(20) + 20, FALSE);
                                o_ptr->timeout = 200;
                                break;
                        }
 
-                       case ART_DAL:
+                       case ART_FLORA:
                        {
 #ifdef JP
                                msg_print("¥Ö¡¼¥Ä¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
@@ -4532,7 +4740,7 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_FIRE, dir, damroll(9, 8));
-                               o_ptr->timeout = rand_int(8) + 8;
+                               o_ptr->timeout = randint0(8) + 8;
                                break;
                        }
 
@@ -4546,7 +4754,7 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_COLD, dir, damroll(6, 8));
-                               o_ptr->timeout = rand_int(7) + 7;
+                               o_ptr->timeout = randint0(7) + 7;
                                break;
                        }
 
@@ -4560,7 +4768,7 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_ELEC, dir, damroll(4, 8));
-                               o_ptr->timeout = rand_int(5) + 5;
+                               o_ptr->timeout = randint0(5) + 5;
                                break;
                        }
 
@@ -4574,7 +4782,7 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_POIS, dir, 12, 3);
-                               o_ptr->timeout = rand_int(4) + 4;
+                               o_ptr->timeout = randint0(4) + 4;
                                break;
                        }
 
@@ -4592,7 +4800,7 @@ msg_print("ŷ
                                break;
                        }
 
-                       case ART_BELANGIL:
+                       case ART_FIONA:
                        {
 #ifdef JP
                                msg_print("¥À¥¬¡¼¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
@@ -4602,20 +4810,20 @@ msg_print("ŷ
 
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_COLD, dir, 48, 2);
-                               o_ptr->timeout = rand_int(5) + 5;
+                               o_ptr->timeout = randint0(5) + 5;
                                break;
                        }
 
                        case ART_KUSANAGI:
-                       case ART_ANGUIREL:
+                       case ART_WEREWINDLE:
                        {
-                               switch (randint(13))
+                               switch (randint1(13))
                                {
                                case 1: case 2: case 3: case 4: case 5:
-                                       teleport_player(10);
+                                       teleport_player(10, 0L);
                                        break;
                                case 6: case 7: case 8: case 9: case 10:
-                                       teleport_player(222);
+                                       teleport_player(222, 0L);
                                        break;
                                case 11: case 12:
                                        (void)stair_creation();
@@ -4640,7 +4848,7 @@ if (get_check("
 
                        case ART_KAMUI:
                        {
-                               teleport_player(222);
+                               teleport_player(222, 0L);
                                o_ptr->timeout = 25;
                                break;
                        }
@@ -4667,8 +4875,8 @@ msg_print("
                                msg_print("You summon the Legion of the Dawn.");
 #endif
 
-                               (void)summon_specific(-1, py, px, dun_level, SUMMON_DAWN, TRUE, TRUE, TRUE, FALSE, FALSE);
-                               o_ptr->timeout = 500 + randint(500);
+                               (void)summon_specific(-1, py, px, dun_level, SUMMON_DAWN, (PM_ALLOW_GROUP | PM_FORCE_PET));
+                               o_ptr->timeout = 500 + randint1(500);
                                break;
                        }
 
@@ -4728,7 +4936,7 @@ msg_print("
                                break;
                        }
 
-                       case ART_OROME:
+                       case ART_DESTINY:
                        {
 #ifdef JP
                                msg_print("¥¹¥Ô¥¢¤¬¸ÝÆ°¤·¤¿...");
@@ -4779,7 +4987,7 @@ msg_print("
 
                                hp_player(damroll(4, 8));
                                (void)set_cut((p_ptr->cut / 2) - 50);
-                               o_ptr->timeout = rand_int(3) + 3;
+                               o_ptr->timeout = randint0(3) + 3;
                                break;
                        }
 
@@ -4871,8 +5079,8 @@ msg_print("
                                msg_print("Your mace glows bright green...");
 #endif
 
-                               (void)set_fast(randint(20) + 20, FALSE);
-                               o_ptr->timeout = rand_int(100) + 100;
+                               (void)set_fast(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = randint0(100) + 100;
                                break;
                        }
 
@@ -4889,7 +5097,7 @@ msg_print("
                                break;
                        }
 
-                       case ART_OLORIN:
+                       case ART_GANDALF:
                        {
 #ifdef JP
                                msg_print("¾ó¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
@@ -4900,7 +5108,7 @@ msg_print("
                                detect_all(DETECT_RAD_DEFAULT);
                                probing();
                                identify_fully(FALSE);
-                               o_ptr->timeout = 1000;
+                               o_ptr->timeout = 100;
                                break;
                        }
 
@@ -4934,7 +5142,7 @@ msg_print("
                        {
                                int num = 1;
                                int i;
-                               int flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_NO_REF;
+                               int flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
                                int tx, ty;
 #ifdef JP
                                msg_print("¤»¤Ã¤«¤¯¤À¤«¤é¡Ø¥¯¥ê¥à¥¾¥ó¡Ù¤ò¤Ö¤Ã¤Ñ¤Ê¤¹¤¼¡ª");
@@ -4968,45 +5176,45 @@ msg_print("
                                }
 
                                for (i = 0; i < num; i++)
-                                       project(0, p_ptr->lev/20+1, ty, tx, p_ptr->lev*6, GF_ROCKET, flg, -1);
+                                       project(0, p_ptr->lev/20+1, ty, tx, p_ptr->lev*p_ptr->lev*6/50, GF_ROCKET, flg, -1);
                                o_ptr->timeout = 15;
                                break;
                        }
-                        case ART_PALANTIR:
-                        {
-                                monster_type *m_ptr;
-                                monster_race *r_ptr;
-                                int i;
+                       case ART_PALANTIR:
+                       {
+                               monster_type *m_ptr;
+                               monster_race *r_ptr;
+                               int i;
 
 #ifdef JP
-                                msg_print("´ñ̯¤Ê¾ì½ê¤¬Æ¬¤ÎÃæ¤ËÉ⤫¤ó¤À¡¥¡¥¡¥");
+                               msg_print("´ñ̯¤Ê¾ì½ê¤¬Æ¬¤ÎÃæ¤ËÉ⤫¤ó¤À¡¥¡¥¡¥");
 #else
-                                msg_print("Some strange places show up in your mind. And you see ...");
+                               msg_print("Some strange places show up in your mind. And you see ...");
 #endif
 
-                                /* Process the monsters (backwards) */
-                                for (i = m_max - 1; i >= 1; i--)
-                                {
-                                        /* Access the monster */
-                                        m_ptr = &m_list[i];
+                               /* Process the monsters (backwards) */
+                               for (i = m_max - 1; i >= 1; i--)
+                               {
+                                       /* Access the monster */
+                                       m_ptr = &m_list[i];
 
-                                        /* Ignore "dead" monsters */
-                                        if (!m_ptr->r_idx) continue;
+                                       /* Ignore "dead" monsters */
+                                       if (!m_ptr->r_idx) continue;
 
-                                        r_ptr = &r_info[m_ptr->r_idx];
+                                       r_ptr = &r_info[m_ptr->r_idx];
 
-                                        if(r_ptr->flags1 & RF1_UNIQUE)
-                                        {
+                                       if(r_ptr->flags1 & RF1_UNIQUE)
+                                       {
 #ifdef JP
                                                msg_format("%s¡¥ ",r_name + r_ptr->name);
 #else
-                                                msg_format("%s. ",r_name + r_ptr->name);
+                                               msg_format("%s. ",r_name + r_ptr->name);
 #endif
-                                        }
-                                }
-                                o_ptr->timeout = 200;
-                                break;
-                        }
+                                       }
+                               }
+                               o_ptr->timeout = 200;
+                               break;
+                       }
 
                        case ART_STONE_LORE:
                        {
@@ -5044,11 +5252,11 @@ msg_print("
 
                                                /* Hack -- Bypass free action */
                                                (void)set_paralyzed(p_ptr->paralyzed +
-                                                       randint(5 * oops + 1));
+                                                       randint1(5 * oops + 1));
 
                                                /* Confusing. */
                                                (void)set_confused(p_ptr->confused +
-                                                       randint(5 * oops + 1));
+                                                       randint1(5 * oops + 1));
                                        }
 
                                        /* Redraw mana */
@@ -5062,11 +5270,11 @@ msg_print("
 #endif
 
                                /* Confusing. */
-                               if (rand_int(5) == 0) (void)set_confused(p_ptr->confused +
-                                       randint(10));
+                               if (one_in_(5)) (void)set_confused(p_ptr->confused +
+                                       randint1(10));
 
                                /* Exercise a little care... */
-                               if (rand_int(20) == 0)
+                               if (one_in_(20))
 #ifdef JP
                                        take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "´í¸±¤ÊÈëÌ©", -1);
 #else
@@ -5078,9 +5286,14 @@ msg_print("
 
                        case ART_BOROMIR:
                        {
+                               if (music_singing_any()) stop_singing();
+#ifdef JP
+                               msg_print("¤¢¤Ê¤¿¤ÏÎ϶¯¤¤ÆÍÉ÷¤ò¿á¤­ÌĤ餷¤¿¡£¼þ°Ï¤ÎŨ¤¬¿Ì¤¨¾å¤Ã¤Æ¤¤¤ë!");
+#else
                                msg_print("You wind a mighty blast; your enemies tremble!");
+#endif
                                (void)turn_monsters((3 * p_ptr->lev / 2) + 10);
-                               o_ptr->timeout = rand_int(40) + 40;
+                               o_ptr->timeout = randint0(40) + 40;
                                break;
                        }
                        case ART_FARAMIR:
@@ -5091,7 +5304,7 @@ msg_print("
                                msg_print("You exterminate small life.");
 #endif
                                (void)dispel_monsters(4);
-                               o_ptr->timeout = rand_int(55) + 55;
+                               o_ptr->timeout = randint0(55) + 55;
                                break;
                        }
 
@@ -5102,8 +5315,8 @@ msg_print("
 #else
                                msg_print("A shrill wailing sound surrounds you.");
 #endif
-                               (void)set_protevil(randint(25) + p_ptr->lev, FALSE);
-                               o_ptr->timeout = rand_int(200) + 200;
+                               (void)set_protevil(randint1(25) + p_ptr->lev, FALSE);
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
@@ -5117,16 +5330,16 @@ msg_print("
 #endif
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_MANA, dir, 120);
-                               o_ptr->timeout = rand_int(120) + 120;
+                               o_ptr->timeout = randint0(120) + 120;
                                break;
                        }
-                       case ART_HURIN:
+                       case ART_HURIN:
                        {
-                               (void)set_fast(randint(50) + 50, FALSE);
+                               (void)set_fast(randint1(50) + 50, FALSE);
                                hp_player(10);
                                set_afraid(0);
-                               set_hero(randint(50) + 50, FALSE);
-                               o_ptr->timeout = rand_int(200) + 100;
+                               set_hero(randint1(50) + 50, FALSE);
+                               o_ptr->timeout = randint0(200) + 100;
                                break;
                        }
                        case ART_GIL_GALAD:
@@ -5154,7 +5367,11 @@ msg_print("
                        }
                        case ART_MURAMASA:
                        {
+#ifdef JP
                                if (get_check("ËÜÅö¤Ë»È¤¤¤Þ¤¹¤«¡©"))
+#else
+                               if (get_check("Are you sure?!"))
+#endif
                                {
 #ifdef JP
                                        msg_print("¼Àµ¤¬¿Ì¤¨¤¿¡¥¡¥¡¥");
@@ -5184,7 +5401,7 @@ msg_print("
 
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_MANA, dir, 400, 4);
-                               o_ptr->timeout = rand_int(250) + 250;
+                               o_ptr->timeout = randint0(250) + 250;
                                break;
                        }
                        case ART_TAIKOBO:
@@ -5195,10 +5412,10 @@ msg_print("
                                y = py+ddy[dir];
                                x = px+ddx[dir];
                                tsuri_dir = dir;
-                               if (!(cave[y][x].feat == FEAT_DEEP_WATER) && !(cave[y][x].feat == FEAT_SHAL_WATER))
+                               if (!cave_have_flag_bold(y, x, FF_WATER))
                                {
 #ifdef JP
-                                       msg_print("¤½¤³¤ÏΦÃϤÀ¡£");
+                                       msg_print("¤½¤³¤Ï¿åÊդǤϤʤ¤¡£");
 #else
                                        msg_print("There is no fishing place.");
 #endif
@@ -5226,18 +5443,21 @@ msg_print("
 #ifdef JP
                                msg_print("¥à¥Á¤ò¿­¤Ð¤·¤¿¡£");
 #else
-                               msg_print("You stretched your wip.");
+                               msg_print("You stretched your whip.");
 #endif
 
                                fetch(dir, 500, TRUE);
-                               o_ptr->timeout = rand_int(25) + 25;
+                               o_ptr->timeout = randint0(25) + 25;
                                break;
                        }
                        case ART_ARRYU:
                        {
-                               bool pet = (randint(5) != 1);
+                               u32b mode = PM_ALLOW_GROUP;
+                               bool pet = !one_in_(5);
+                               if (pet) mode |= PM_FORCE_PET;
+                               else mode |= PM_NO_PET;
 
-                               if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, TRUE, FALSE, pet, FALSE, !pet))
+                               if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, mode))
                                {
 
                                        if (pet)
@@ -5256,7 +5476,7 @@ msg_print("
 
                                }
 
-                               o_ptr->timeout = 300 + randint(150);
+                               o_ptr->timeout = 300 + randint1(150);
                                break;
                        }
 
@@ -5270,7 +5490,7 @@ msg_print("
 
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_LITE, dir, 200, 3);
-                               o_ptr->timeout = rand_int(200) + 200;
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
@@ -5282,7 +5502,7 @@ msg_print("
                                cptr kakusan = "";
 #endif
 
-                               if (summon_named_creature(py, px, MON_SUKE, FALSE, FALSE, TRUE, TRUE))
+                               if (summon_named_creature(0, py, px, MON_SUKE, PM_FORCE_PET))
                                {
 #ifdef JP
                                        msg_print("¡Ø½õ¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
@@ -5292,7 +5512,7 @@ msg_print("
 #endif
                                        count++;
                                }
-                               if (summon_named_creature(py, px, MON_KAKU, FALSE, FALSE, TRUE, TRUE))
+                               if (summon_named_creature(0, py, px, MON_KAKU, PM_FORCE_PET))
                                {
 #ifdef JP
                                        msg_print("¡Ø³Ê¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
@@ -5310,6 +5530,7 @@ msg_print("
                                                if (!m_ptr->r_idx) continue;
                                                if (!((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) continue;
                                                if (!los(m_ptr->fy, m_ptr->fx, py, px)) continue;
+                                               if (!projectable(m_ptr->fy, m_ptr->fx, py, px)) continue;
                                                count++;
                                                break;
                                        }
@@ -5338,7 +5559,7 @@ msg_print("
                                        msg_print("Nothing happen.");
 #endif
                                }
-                               o_ptr->timeout = rand_int(150) + 150;
+                               o_ptr->timeout = randint0(150) + 150;
                                break;
                        }
 
@@ -5356,9 +5577,10 @@ msg_print("
                        case ART_MATOI:
                        case ART_AEGISFANG:
                        {
-                               set_hero(randint(25)+25, FALSE);
+                               (void)set_afraid(0);
+                               set_hero(randint1(25)+25, FALSE);
                                hp_player(10);
-                               o_ptr->timeout = rand_int(30) + 30;
+                               o_ptr->timeout = randint0(30) + 30;
                                break;
                        }
 
@@ -5372,7 +5594,7 @@ msg_print("
                                (void)set_image(0);
 
                                o_ptr->timeout = 100;
-                               break;
+                               break;
                        }
 
                        case ART_BOLISHOI:
@@ -5381,7 +5603,7 @@ msg_print("
                                (void)charm_animal(dir, p_ptr->lev);
 
                                o_ptr->timeout = 200;
-                               break;
+                               break;
                        }
 
                        case ART_ARUNRUTH:
@@ -5398,27 +5620,12 @@ msg_print("
                        }
                        case ART_BLOOD:
                        {
-                               int dummy, i;
 #ifdef JP
                                msg_print("³ù¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
 #else
                                msg_print("Your scythe glows brightly!");
 #endif
-                               o_ptr->art_flags1 = a_info[ART_BLOOD].flags1;
-                               o_ptr->art_flags2 = a_info[ART_BLOOD].flags2;
-                               dummy = randint(2)+randint(2);
-                               for (i = 0; i < dummy; i++)
-                                       o_ptr->art_flags1 |= (TR1_CHAOTIC << rand_int(18));
-                               dummy = randint(2);
-                               for (i = 0; i < dummy; i++)
-                                       random_resistance(o_ptr, FALSE, randint(34) + 4);
-                               dummy = 2;
-                               for (i = 0; i < dummy; i++)
-                               {
-                                       int tmp = rand_int(11);
-                                       if (tmp < 6) o_ptr->art_flags1 |= (TR1_STR << tmp);
-                                       else o_ptr->art_flags1 |= (TR1_STEALTH << (tmp - 6));
-                               }
+                               get_bloody_moon_flags(o_ptr);
                                o_ptr->timeout = 3333;
                                if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
                                p_ptr->update |= (PU_BONUS | PU_HP);
@@ -5431,9 +5638,10 @@ msg_print("
 #else
                                msg_print("You stamp. (as if you are in a ring.)");
 #endif
-                               (void)set_hero(randint(20) + 20, FALSE);
+                               (void)set_afraid(0);
+                               (void)set_hero(randint1(20) + 20, FALSE);
                                dispel_evil(p_ptr->lev * 3);
-                               o_ptr->timeout = 100 + randint(100);
+                               o_ptr->timeout = 100 + randint1(100);
                                break;
                        }
                        case ART_MOOK:
@@ -5443,11 +5651,11 @@ msg_print("
 #else
                                msg_print("Your cloak grows white.");
 #endif
-                               (void)set_oppose_cold(randint(20) + 20, FALSE);
-                               o_ptr->timeout = 40 + randint(40);
+                               (void)set_oppose_cold(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = 40 + randint1(40);
                                break;
                        }
-                       case ART_VIOLET:
+                       case ART_HERMIT:
                        {
 #ifdef JP
                                msg_print("¥à¥Á¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
@@ -5456,15 +5664,17 @@ msg_print("
 #endif
 
                                k = 3 * p_ptr->lev;
-                               (void)set_protevil(randint(25) + k, FALSE);
-                               o_ptr->timeout = rand_int(225) + 225;
+                               (void)set_protevil(randint1(25) + k, FALSE);
+                               o_ptr->timeout = randint0(225) + 225;
                                break;
                        }
                        case ART_JIZO:
                        {
-                               bool pet = (randint(5) != 1);
+                               u32b mode = PM_ALLOW_GROUP;
+                               bool pet = !one_in_(5);
+                               if (pet) mode |= PM_FORCE_PET;
 
-                               if (summon_named_creature(py, px, MON_JIZOTAKO, FALSE, TRUE, FALSE, pet))
+                               if (summon_named_creature(0, py, px, MON_JIZOTAKO, mode))
                                {
                                        if (pet)
 #ifdef JP
@@ -5482,7 +5692,7 @@ msg_print("
 
                                }
 
-                               o_ptr->timeout = 300 + randint(150);
+                               o_ptr->timeout = 300 + randint1(150);
                                break;
                        }
 
@@ -5495,7 +5705,7 @@ msg_print("
 #endif
 
                                dispel_evil(p_ptr->lev * 5);
-                               o_ptr->timeout = rand_int(100) + 100;
+                               o_ptr->timeout = randint0(100) + 100;
                                break;
                        }
 
@@ -5504,11 +5714,86 @@ msg_print("
 #ifdef JP
                                msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...");
 #else
-                               msg_print("nanka.");
+                               msg_print("Your amulet is coverd in pitch-darkness...");
+#endif
+                               if (!get_aim_dir(&dir)) return;
+                               fire_ball(GF_DARK, dir, 250, 4);
+                               o_ptr->timeout = randint0(150) + 150;
+                               break;
+                       }
+                       case ART_HELL:
+                       {
+#ifdef JP
+                               msg_print("¼óÎؤ¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...");
+#else
+                               msg_print("Your collar harness is coverd in pitch-darkness...");
 #endif
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_DARK, dir, 250, 4);
-                               o_ptr->timeout = rand_int(150) + 150;
+                               o_ptr->timeout = randint0(150) + 150;
+                               break;
+                       }
+                       case ART_SACRED_KNIGHTS:
+                       {
+#ifdef JP
+                               msg_print("¼ó¾þ¤ê¤¬¿¿¼Â¤ò¾È¤é¤·½Ð¤¹...");
+#else
+                               msg_print("Your amulet exhibits the truth...");
+#endif
+                               if (remove_all_curse())
+                               {
+#ifdef JP
+                                       msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
+#else
+                                       msg_print("You feel as if someone is watching over you.");
+#endif
+                               }
+                               (void)probing();
+                               break;
+                       }
+                       case ART_CHARMED:
+                       {
+#ifdef JP
+                               msg_print("¥Ú¥ó¥À¥ó¥È¤¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥");
+#else
+                               msg_print("Your pendant glows pale...");
+#endif
+                               if (p_ptr->pclass == CLASS_MAGIC_EATER)
+                               {
+                                       int i;
+                                       for (i = 0; i < EATER_EXT*2; i++)
+                                       {
+                                               p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i]*EATER_CHARGE/3;
+                                               if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i]*EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
+                                       }
+                                       for (; i < EATER_EXT*3; i++)
+                                       {
+                                               int k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
+                                               p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE*3 : p_ptr->magic_num2[i]*EATER_ROD_CHARGE/3)*k_info[k_idx].pval;
+                                               if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
+                                       }
+#ifdef JP
+                                       msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
+#else
+                                       msg_print("You feel your head clear.");
+#endif
+                                       p_ptr->window |= (PW_PLAYER);
+                               }
+                               else if (p_ptr->csp < p_ptr->msp)
+                               {
+                                       p_ptr->csp = p_ptr->msp;
+                                       p_ptr->csp_frac = 0;
+#ifdef JP
+                                       msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
+#else
+                                       msg_print("You feel your head clear.");
+#endif
+
+                                       p_ptr->redraw |= (PR_MANA);
+                                       p_ptr->window |= (PW_PLAYER);
+                                       p_ptr->window |= (PW_SPELL);
+                               }
+                               o_ptr->timeout = 777;
                                break;
                        }
                }
@@ -5520,51 +5805,47 @@ msg_print("
                return;
        }
 
-       else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_TMP_RES_ACID))
-       {
-               (void)set_oppose_acid(randint(20) + 20, FALSE);
-               o_ptr->timeout = rand_int(50) + 50;
-               return;
-       }
-
-       else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_TMP_RES_ELEC))
+       if (object_is_smith(o_ptr))
        {
-               (void)set_oppose_elec(randint(20) + 20, FALSE);
-               o_ptr->timeout = rand_int(50) + 50;
-               return;
-       }
+               switch (o_ptr->xtra3-1)
+               {
+               case ESSENCE_TMP_RES_ACID:
+                       (void)set_oppose_acid(randint1(20) + 20, FALSE);
+                       o_ptr->timeout = randint0(50) + 50;
+                       return;
 
-       else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_TMP_RES_FIRE))
-       {
-               (void)set_oppose_fire(randint(20) + 20, FALSE);
-               o_ptr->timeout = rand_int(50) + 50;
-               return;
-       }
+               case ESSENCE_TMP_RES_ELEC:
+                       (void)set_oppose_elec(randint1(20) + 20, FALSE);
+                       o_ptr->timeout = randint0(50) + 50;
+                       return;
 
-       else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_TMP_RES_COLD))
-       {
-               (void)set_oppose_cold(randint(20) + 20, FALSE);
-               o_ptr->timeout = rand_int(50) + 50;
-               return;
-       }
+               case ESSENCE_TMP_RES_FIRE:
+                       (void)set_oppose_fire(randint1(20) + 20, FALSE);
+                       o_ptr->timeout = randint0(50) + 50;
+                       return;
 
-       else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_EARTHQUAKE))
-       {
-               earthquake(py, px, 5);
-               o_ptr->timeout = 100 + randint(100);
+               case ESSENCE_TMP_RES_COLD:
+                       (void)set_oppose_cold(randint1(20) + 20, FALSE);
+                       o_ptr->timeout = randint0(50) + 50;
+                       return;
 
-               /* Window stuff */
-               p_ptr->window |= (PW_INVEN | PW_EQUIP);
+               case TR_IMPACT:
+                       earthquake(py, px, 5);
+                       o_ptr->timeout = 100 + randint1(100);
+                       
+                       /* Window stuff */
+                       p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
-               /* Done */
-               return;
+                       /* Done */
+                       return;
+               }
        }
 
 
-       else if (o_ptr->name2 == EGO_TRUMP)
+       if (o_ptr->name2 == EGO_TRUMP)
        {
-               teleport_player(100);
-               o_ptr->timeout = 50 + randint(50);
+               teleport_player(100, 0L);
+               o_ptr->timeout = 50 + randint1(50);
 
                /* Window stuff */
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
@@ -5574,16 +5855,20 @@ msg_print("
        }
 
 
-       else if (o_ptr->name2 == EGO_LITE_ILLUMINATION)
+       if (o_ptr->name2 == EGO_LITE_ILLUMINATION)
        {
                if (!o_ptr->xtra4 && ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
                {
+#ifdef JP
                        msg_print("dzÎÁ¤¬¤Ê¤¤¡£");
+#else
+                       msg_print("It has no fuel.");
+#endif
                        energy_use = 0;
                        return;
                }
                lite_area(damroll(2, 15), 3);
-               o_ptr->timeout = rand_int(10) + 10;
+               o_ptr->timeout = randint0(10) + 10;
 
                /* Window stuff */
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
@@ -5592,10 +5877,10 @@ msg_print("
        }
 
 
-       else if (o_ptr->name2 == EGO_EARTHQUAKES)
+       if (o_ptr->name2 == EGO_EARTHQUAKES)
        {
                earthquake(py, px, 5);
-               o_ptr->timeout = 100 + randint(100);
+               o_ptr->timeout = 100 + randint1(100);
 
                /* Window stuff */
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
@@ -5605,10 +5890,10 @@ msg_print("
        }
 
 
-       else if (o_ptr->name2 == EGO_JUMP)
+       if (o_ptr->name2 == EGO_JUMP)
        {
-               teleport_player(10);
-               o_ptr->timeout = 10 + randint(10);
+               teleport_player(10, 0L);
+               o_ptr->timeout = 10 + randint1(10);
 
                /* Window stuff */
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
@@ -5619,11 +5904,13 @@ msg_print("
 
 
        /* Hack -- Dragon Scale Mail can be activated as well */
-       else if (o_ptr->tval == TV_DRAG_ARMOR)
+       if (o_ptr->tval == TV_DRAG_ARMOR)
        {
                /* Get a direction for breathing (or abort) */
                if (!get_aim_dir(&dir)) return;
 
+               if (music_singing_any()) stop_singing();
+
                /* Branch on the sub-type */
                switch (o_ptr->sval)
                {
@@ -5636,7 +5923,7 @@ msg_print("
 #endif
 
                                fire_ball(GF_ELEC, dir, 100, -2);
-                               o_ptr->timeout = rand_int(150) + 150;
+                               o_ptr->timeout = randint0(150) + 150;
                                break;
                        }
 
@@ -5649,7 +5936,7 @@ msg_print("
 #endif
 
                                fire_ball(GF_COLD, dir, 110, -2);
-                               o_ptr->timeout = rand_int(150) + 150;
+                               o_ptr->timeout = randint0(150) + 150;
                                break;
                        }
 
@@ -5662,7 +5949,7 @@ msg_print("
 #endif
 
                                fire_ball(GF_ACID, dir, 130, -2);
-                               o_ptr->timeout = rand_int(150) + 150;
+                               o_ptr->timeout = randint0(150) + 150;
                                break;
                        }
 
@@ -5675,7 +5962,7 @@ msg_print("
 #endif
 
                                fire_ball(GF_POIS, dir, 150, -2);
-                               o_ptr->timeout = rand_int(180) + 180;
+                               o_ptr->timeout = randint0(180) + 180;
                                break;
                        }
 
@@ -5688,33 +5975,33 @@ msg_print("
 #endif
 
                                fire_ball(GF_FIRE, dir, 200, -2);
-                               o_ptr->timeout = rand_int(200) + 200;
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
                        case SV_DRAGON_MULTIHUED:
                        {
-                               chance = rand_int(5);
+                               chance = randint0(5);
 #ifdef JP
                                msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
-                                          ((chance == 1) ? "°ðºÊ" :
-                                           ((chance == 2) ? "Î䵤" :
-                                            ((chance == 3) ? "»À" :
-                                             ((chance == 4) ? "ÆÇ¥¬¥¹" : "²Ð±ê")))));
+                                          ((chance == 1) ? "°ðºÊ" :
+                                           ((chance == 2) ? "Î䵤" :
+                                            ((chance == 3) ? "»À" :
+                                             ((chance == 4) ? "ÆÇ¥¬¥¹" : "²Ð±ê")))));
 #else
                                msg_format("You breathe %s.",
-                                          ((chance == 1) ? "lightning" :
-                                           ((chance == 2) ? "frost" :
-                                            ((chance == 3) ? "acid" :
-                                             ((chance == 4) ? "poison gas" : "fire")))));
+                                          ((chance == 1) ? "lightning" :
+                                           ((chance == 2) ? "frost" :
+                                            ((chance == 3) ? "acid" :
+                                             ((chance == 4) ? "poison gas" : "fire")))));
 #endif
 
                                fire_ball(((chance == 1) ? GF_ELEC :
-                                          ((chance == 2) ? GF_COLD :
-                                           ((chance == 3) ? GF_ACID :
-                                            ((chance == 4) ? GF_POIS : GF_FIRE)))),
-                                         dir, 250, -2);
-                               o_ptr->timeout = rand_int(200) + 200;
+                                          ((chance == 2) ? GF_COLD :
+                                           ((chance == 3) ? GF_ACID :
+                                            ((chance == 4) ? GF_POIS : GF_FIRE)))),
+                                         dir, 250, -2);
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
@@ -5727,7 +6014,7 @@ msg_print("
 #endif
 
                                fire_ball(GF_CONFUSION, dir, 120, -2);
-                               o_ptr->timeout = rand_int(180) + 180;
+                               o_ptr->timeout = randint0(180) + 180;
                                break;
                        }
 
@@ -5740,80 +6027,80 @@ msg_print("
 #endif
 
                                fire_ball(GF_SOUND, dir, 130, -2);
-                               o_ptr->timeout = rand_int(180) + 180;
+                               o_ptr->timeout = randint0(180) + 180;
                                break;
                        }
 
                        case SV_DRAGON_CHAOS:
                        {
-                               chance = rand_int(2);
+                               chance = randint0(2);
 #ifdef JP
                                msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
-                                          ((chance == 1 ? "¥«¥ª¥¹" : "Îô²½")));
+                                          ((chance == 1 ? "¥«¥ª¥¹" : "Îô²½")));
 #else
                                msg_format("You breathe %s.",
-                                          ((chance == 1 ? "chaos" : "disenchantment")));
+                                          ((chance == 1 ? "chaos" : "disenchantment")));
 #endif
 
                                fire_ball((chance == 1 ? GF_CHAOS : GF_DISENCHANT),
-                                         dir, 220, -2);
-                               o_ptr->timeout = rand_int(200) + 200;
+                                         dir, 220, -2);
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
                        case SV_DRAGON_LAW:
                        {
-                               chance = rand_int(2);
+                               chance = randint0(2);
 #ifdef JP
                                msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
-                                          ((chance == 1 ? "¹ì²»" : "ÇËÊÒ")));
+                                          ((chance == 1 ? "¹ì²»" : "ÇËÊÒ")));
 #else
                                msg_format("You breathe %s.",
-                                          ((chance == 1 ? "sound" : "shards")));
+                                          ((chance == 1 ? "sound" : "shards")));
 #endif
 
                                fire_ball((chance == 1 ? GF_SOUND : GF_SHARDS),
-                                         dir, 230, -2);
-                               o_ptr->timeout = rand_int(200) + 200;
+                                         dir, 230, -2);
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
                        case SV_DRAGON_BALANCE:
                        {
-                               chance = rand_int(4);
+                               chance = randint0(4);
 #ifdef JP
                                msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿",
-                                          ((chance == 1) ? "¥«¥ª¥¹" :
-                                           ((chance == 2) ? "Îô²½" :
-                                            ((chance == 3) ? "¹ì²»" : "ÇËÊÒ"))));
+                                          ((chance == 1) ? "¥«¥ª¥¹" :
+                                           ((chance == 2) ? "Îô²½" :
+                                            ((chance == 3) ? "¹ì²»" : "ÇËÊÒ"))));
 #else
                                msg_format("You breathe %s.",
-                                          ((chance == 1) ? "chaos" :
-                                           ((chance == 2) ? "disenchantment" :
-                                            ((chance == 3) ? "sound" : "shards"))));
+                                          ((chance == 1) ? "chaos" :
+                                           ((chance == 2) ? "disenchantment" :
+                                            ((chance == 3) ? "sound" : "shards"))));
 #endif
 
                                fire_ball(((chance == 1) ? GF_CHAOS :
-                                          ((chance == 2) ? GF_DISENCHANT :
-                                           ((chance == 3) ? GF_SOUND : GF_SHARDS))),
-                                         dir, 250, -2);
-                               o_ptr->timeout = rand_int(200) + 200;
+                                          ((chance == 2) ? GF_DISENCHANT :
+                                           ((chance == 3) ? GF_SOUND : GF_SHARDS))),
+                                         dir, 250, -2);
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
                        case SV_DRAGON_SHINING:
                        {
-                               chance = rand_int(2);
+                               chance = randint0(2);
 #ifdef JP
                                msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
-                                          ((chance == 0 ? "Á®¸÷" : "°Å¹õ")));
+                                          ((chance == 0 ? "Á®¸÷" : "°Å¹õ")));
 #else
                                msg_format("You breathe %s.",
-                                          ((chance == 0 ? "light" : "darkness")));
+                                          ((chance == 0 ? "light" : "darkness")));
 #endif
 
                                fire_ball((chance == 0 ? GF_LITE : GF_DARK), dir, 200, -2);
-                               o_ptr->timeout = rand_int(200) + 200;
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
 
@@ -5826,7 +6113,7 @@ msg_print("
 #endif
 
                                fire_ball(GF_MISSILE, dir, 300, -3);
-                               o_ptr->timeout = rand_int(200) + 200;
+                               o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
                }
@@ -5840,7 +6127,7 @@ msg_print("
 
        else if (o_ptr->tval == TV_RING)
        {
-               if (o_ptr->name2)
+               if (object_is_ego(o_ptr))
                {
                        bool success = TRUE;
 
@@ -5848,9 +6135,9 @@ msg_print("
                        {
                        case EGO_RING_HERO:
                                (void)set_afraid(0);
-                               (void)set_hero(randint(25) + 25, FALSE);
+                               (void)set_hero(randint1(25) + 25, FALSE);
                                (void)hp_player(10);
-                               o_ptr->timeout = randint(100)+100;
+                               o_ptr->timeout = randint1(100)+100;
                                break;
                        case EGO_RING_MAGIC_MIS:
                                if (!get_aim_dir(&dir)) return;
@@ -5860,47 +6147,47 @@ msg_print("
                        case EGO_RING_FIRE_BOLT:
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_FIRE, dir, damroll(9, 8));
-                               o_ptr->timeout = rand_int(8) + 8;
+                               o_ptr->timeout = randint0(8) + 8;
                                break;
                        case EGO_RING_COLD_BOLT:
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_COLD, dir, damroll(6, 8));
-                               o_ptr->timeout = rand_int(7) + 7;
+                               o_ptr->timeout = randint0(7) + 7;
                                break;
                        case EGO_RING_ELEC_BOLT:
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_ELEC, dir, damroll(4, 8));
-                               o_ptr->timeout = rand_int(5) + 5;
+                               o_ptr->timeout = randint0(5) + 5;
                                break;
                        case EGO_RING_ACID_BOLT:
                                if (!get_aim_dir(&dir)) return;
-                               fire_bolt(GF_FIRE, dir, damroll(5, 8));
-                               o_ptr->timeout = rand_int(6) + 6;
+                               fire_bolt(GF_ACID, dir, damroll(5, 8));
+                               o_ptr->timeout = randint0(6) + 6;
                                break;
                        case EGO_RING_MANA_BOLT:
                                if (!get_aim_dir(&dir)) return;
                                fire_bolt(GF_MANA, dir, 120);
-                               o_ptr->timeout = rand_int(120)+120;
+                               o_ptr->timeout = randint0(120)+120;
                                break;
                        case EGO_RING_FIRE_BALL:
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_FIRE, dir, 100, 2);
-                               o_ptr->timeout = rand_int(80) + 80;
+                               o_ptr->timeout = randint0(80) + 80;
                                break;
                        case EGO_RING_COLD_BALL:
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_COLD, dir, 100, 2);
-                               o_ptr->timeout = rand_int(80) + 80;
+                               o_ptr->timeout = randint0(80) + 80;
                                break;
                        case EGO_RING_ELEC_BALL:
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_ELEC, dir, 100, 2);
-                               o_ptr->timeout = rand_int(80) + 80;
+                               o_ptr->timeout = randint0(80) + 80;
                                break;
                        case EGO_RING_ACID_BALL:
                                if (!get_aim_dir(&dir)) return;
                                fire_ball(GF_ACID, dir, 100, 2);
-                               o_ptr->timeout = rand_int(80) + 80;
+                               o_ptr->timeout = randint0(80) + 80;
                                break;
                        case EGO_RING_MANA_BALL:
                                if (!get_aim_dir(&dir)) return;
@@ -5912,7 +6199,7 @@ msg_print("
                                fire_ball(GF_FIRE, dir, 200, -2);
                                if (o_ptr->sval == SV_RING_FLAMES)
                                {
-                                       (void)set_oppose_fire(randint(20) + 20, FALSE);
+                                       (void)set_oppose_fire(randint1(20) + 20, FALSE);
                                        o_ptr->timeout = 200;
                                }
                                else o_ptr->timeout = 250;
@@ -5922,7 +6209,7 @@ msg_print("
                                fire_ball(GF_COLD, dir, 200, -2);
                                if (o_ptr->sval == SV_RING_ICE)
                                {
-                                       (void)set_oppose_cold(randint(20) + 20, FALSE);
+                                       (void)set_oppose_cold(randint1(20) + 20, FALSE);
                                        o_ptr->timeout = 200;
                                }
                                else o_ptr->timeout = 250;
@@ -5933,12 +6220,13 @@ msg_print("
                                o_ptr->timeout = 150;
                                break;
                        case EGO_RING_D_SPEED:
-                               (void)set_fast(randint(30) + 15, FALSE);
+                               (void)set_fast(randint1(30) + 15, FALSE);
                                o_ptr->timeout = 100;
                                break;
                        case EGO_RING_BERSERKER:
-                               (void)set_shero(randint(25) + 25, FALSE);
-                               o_ptr->timeout = rand_int(75)+75;
+                               (void)set_afraid(0);
+                               (void)set_shero(randint1(25) + 25, FALSE);
+                               o_ptr->timeout = randint0(75)+75;
                                break;
                        case EGO_RING_TELE_AWAY:
                                if (!get_aim_dir(&dir)) return;
@@ -5947,7 +6235,7 @@ msg_print("
                                break;
                        case EGO_RING_TRUE:
                        {
-                               int v = randint(25)+25;
+                               int v = randint1(25)+25;
                                (void)set_afraid(0);
                                (void)set_hero(v, FALSE);
                                (void)hp_player(10);
@@ -5976,32 +6264,32 @@ msg_print("
                        case SV_RING_ACID:
                        {
                                fire_ball(GF_ACID, dir, 100, 2);
-                               (void)set_oppose_acid(randint(20) + 20, FALSE);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               (void)set_oppose_acid(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        }
 
                        case SV_RING_ICE:
                        {
                                fire_ball(GF_COLD, dir, 100, 2);
-                               (void)set_oppose_cold(randint(20) + 20, FALSE);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               (void)set_oppose_cold(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        }
 
                        case SV_RING_FLAMES:
                        {
                                fire_ball(GF_FIRE, dir, 100, 2);
-                               (void)set_oppose_fire(randint(20) + 20, FALSE);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               (void)set_oppose_fire(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        }
 
                        case SV_RING_ELEC:
                        {
                                fire_ball(GF_ELEC, dir, 100, 2);
-                               (void)set_oppose_elec(randint(20) + 20, FALSE);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               (void)set_oppose_elec(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        }
                }
@@ -6015,7 +6303,7 @@ msg_print("
 
        else if (o_ptr->tval == TV_AMULET)
        {
-               if (o_ptr->name2)
+               if (object_is_ego(o_ptr))
                {
                        switch (o_ptr->name2)
                        {
@@ -6029,36 +6317,36 @@ msg_print("
                                o_ptr->timeout = 200;
                                break;
                        case EGO_AMU_JUMP:
-                               teleport_player(10);
-                               o_ptr->timeout = rand_int(10) + 10;
+                               teleport_player(10, 0L);
+                               o_ptr->timeout = randint0(10) + 10;
                                break;
                        case EGO_AMU_TELEPORT:
-                               teleport_player(100);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               teleport_player(100, 0L);
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        case EGO_AMU_D_DOOR:
                                (void)dimension_door();
                                o_ptr->timeout = 200;
                                break;
                        case EGO_AMU_RES_FIRE_:
-                               (void)set_oppose_fire(randint(20) + 20, FALSE);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               (void)set_oppose_fire(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        case EGO_AMU_RES_COLD_:
-                               (void)set_oppose_cold(randint(20) + 20, FALSE);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               (void)set_oppose_cold(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        case EGO_AMU_RES_ELEC_:
-                               (void)set_oppose_elec(randint(20) + 20, FALSE);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               (void)set_oppose_elec(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        case EGO_AMU_RES_ACID_:
-                               (void)set_oppose_acid(randint(20) + 20, FALSE);
-                               o_ptr->timeout = rand_int(50) + 50;
+                               (void)set_oppose_acid(randint1(20) + 20, FALSE);
+                               o_ptr->timeout = randint0(50) + 50;
                                break;
                        case EGO_AMU_DETECTION:
                                detect_all(DETECT_RAD_DEFAULT);
-                               o_ptr->timeout = rand_int(55)+55;
+                               o_ptr->timeout = randint0(55)+55;
                                break;
                        }
                }
@@ -6067,8 +6355,10 @@ msg_print("
 
        else if (o_ptr->tval == TV_WHISTLE)
        {
+               if (music_singing_any()) stop_singing();
+
 #if 0
-               if (cursed_p(o_ptr))
+               if (object_is_cursed(o_ptr))
                {
 #ifdef JP
                        msg_print("¥«¥ó¹â¤¤²»¤¬¶Á¤­ÅϤä¿¡£");
@@ -6105,10 +6395,13 @@ msg_print("
                        for (i = 0; i < max_pet; i++)
                        {
                                pet_ctr = who[i];
-                               teleport_to_player(pet_ctr, 100);
+                               teleport_monster_to(pet_ctr, py, px, 100, TELEPORT_PASSIVE);
                        }
+
+                       /* Free the "who" array */
+                       C_KILL(who, max_m_idx, u16b);
                }
-               o_ptr->timeout = 100+randint(100);
+               o_ptr->timeout = 100+randint1(100);
                return;
        }
        else if (o_ptr->tval == TV_CAPTURE)
@@ -6173,9 +6466,9 @@ msg_print("
                {
                        bool success = FALSE;
                        if (!get_rep_dir2(&dir)) return;
-                       if (cave_floor_bold(py+ddy[dir],px+ddx[dir]))
+                       if (monster_can_enter(py + ddy[dir], px + ddx[dir], &r_info[o_ptr->pval], 0))
                        {
-                               if (place_monster_aux(py + ddy[dir], px + ddx[dir], o_ptr->pval, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE))
+                               if (place_monster_aux(0, py + ddy[dir], px + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
                                {
                                        if (o_ptr->xtra3) m_list[hack_m_idx_ii].mspeed = o_ptr->xtra3;
                                        if (o_ptr->xtra5) m_list[hack_m_idx_ii].max_maxhp = o_ptr->xtra5;
@@ -6298,7 +6591,7 @@ void do_cmd_activate(void)
  */
 static bool item_tester_hook_use(object_type *o_ptr)
 {
-       u32b f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
 
        /* Ammo */
        if (o_ptr->tval == p_ptr->tval_ammo)
@@ -6323,7 +6616,7 @@ static bool item_tester_hook_use(object_type *o_ptr)
                        int i;
 
                        /* Not known */
-                       if (!object_known_p(o_ptr)) return (FALSE);
+                       if (!object_is_known(o_ptr)) return (FALSE);
 
                        /* HACK - only items from the equipment can be activated */
                        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
@@ -6331,10 +6624,10 @@ static bool item_tester_hook_use(object_type *o_ptr)
                                if (&inventory[i] == o_ptr)
                                {
                                        /* Extract the flags */
-                                       object_flags(o_ptr, &f1, &f2, &f3);
+                                       object_flags(o_ptr, flgs);
 
                                        /* Check activation flag */
-                                       if (f3 & TR3_ACTIVATE) return (TRUE);
+                                       if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
                                }
                        }
                }
@@ -6465,7 +6758,7 @@ msg_print("
                                return;
                        }
 
-                 do_cmd_read_scroll_aux(item);
+                 do_cmd_read_scroll_aux(item, TRUE);
                  break;
                }
 
@@ -6487,11 +6780,11 @@ msg_print("
        }
 }
 
-static bool select_magic_eater(int mode)
+static int select_magic_eater(bool only_browse)
 {
        int ext=0;
        char choice;
-       bool flag, redraw;
+       bool flag, request_list;
        int tval = 0;
        int             ask = TRUE, i = 0;
        char            out_val[160];
@@ -6503,9 +6796,9 @@ static bool select_magic_eater(int mode)
        if (repeat_pull(&sn))
        {
                /* Verify the spell */
-               if (sn > 71 && !(p_ptr->magic_num1[sn] > k_info[lookup_kind(TV_ROD, i)].pval * (p_ptr->magic_num2[sn] - 1) * 0x10000L))
+               if (sn >= EATER_EXT*2 && !(p_ptr->magic_num1[sn] > k_info[lookup_kind(TV_ROD, sn-EATER_EXT*2)].pval * (p_ptr->magic_num2[sn] - 1) * EATER_ROD_CHARGE))
                        return sn;
-               else if (sn < 72 && !(p_ptr->magic_num1[sn] < 0x10000))
+               else if (sn < EATER_EXT*2 && !(p_ptr->magic_num1[sn] < EATER_CHARGE))
                        return sn;
        }
        
@@ -6540,7 +6833,7 @@ static bool select_magic_eater(int mode)
                        prt(format(" %s staff", (menu_line == 1) ? "> " : "  "), 2, 14);
                        prt(format(" %s wand", (menu_line == 2) ? "> " : "  "), 3, 14);
                        prt(format(" %s rod", (menu_line == 3) ? "> " : "  "), 4, 14);
-                       prt("Which type of magic do you usu?", 0, 0);
+                       prt("Which type of magic do you use?", 0, 0);
 #endif
                        choice = inkey();
                        switch(choice)
@@ -6563,7 +6856,7 @@ static bool select_magic_eater(int mode)
                        case '\r':
                        case 'x':
                        case 'X':
-                               ext = (menu_line-1)*36;
+                               ext = (menu_line-1)*EATER_EXT;
                                if (menu_line == 1) tval = TV_STAFF;
                                else if (menu_line == 2) tval = TV_WAND;
                                else tval = TV_ROD;
@@ -6593,19 +6886,19 @@ static bool select_magic_eater(int mode)
                }
                if (choice == 'B' || choice == 'b')
                {
-                       ext = 36;
+                       ext = EATER_EXT;
                        tval = TV_WAND;
                        break;
                }
                if (choice == 'C' || choice == 'c')
                {
-                       ext = 72;
+                       ext = EATER_EXT*2;
                        tval = TV_ROD;
                        break;
                }
        }
        }
-       for (i = ext; i < ext + 36; i++)
+       for (i = ext; i < ext + EATER_EXT; i++)
        {
                if (p_ptr->magic_num2[i])
                {
@@ -6613,7 +6906,7 @@ static bool select_magic_eater(int mode)
                        break;
                }
        }
-       if (i == ext+36)
+       if (i == ext+EATER_EXT)
        {
 #ifdef JP
                msg_print("¤½¤Î¼ïÎà¤ÎËâË¡¤Ï³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
@@ -6626,34 +6919,133 @@ static bool select_magic_eater(int mode)
        /* Nothing chosen yet */
        flag = FALSE;
 
-       /* No redraw yet */
-       redraw = FALSE;
-
        /* Build a prompt */
 #ifdef JP
 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎËâÎϤò»È¤¤¤Þ¤¹¤«¡©");
 #else
        (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Use which power? ");
 #endif
-       if (use_menu) screen_save();
+       
+       /* Save the screen */
+       screen_save();
+
+       request_list = always_show_list;
 
        /* Get a spell from the user */
+       while (!flag)
+       {
+               /* Show the list */
+               if (request_list || use_menu)
+               {
+                       byte y, x = 0;
+                       int ctr, chance;
+                       int k_idx;
+                       char dummy[80];
+                       int x1, y1, level;
+                       byte col;
+
+                       strcpy(dummy, "");
+
+                       for (y = 1; y < 20; y++)
+                               prt("", y, x);
+
+                       y = 1;
+
+                       /* Print header(s) */
+#ifdef JP
+                       prt(format("                           %s ¼ºÎ¨                           %s ¼ºÎ¨", (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô")), y++, x);
+#else
+                       prt(format("                           %s Fail                           %s Fail", (tval == TV_ROD ? "  Stat  " : " Charges"), (tval == TV_ROD ? "  Stat  " : " Charges")), y++, x);
+#endif
+
+                       /* Print list */
+                       for (ctr = 0; ctr < EATER_EXT; ctr++)
+                       {
+                               if (!p_ptr->magic_num2[ctr+ext]) continue;
+
+                               k_idx = lookup_kind(tval, ctr);
+
+                               if (use_menu)
+                               {
+                                       if (ctr == (menu_line-1))
+#ifdef JP
+                                               strcpy(dummy, "¡Õ");
+#else
+                                       strcpy(dummy, "> ");
+#endif
+                                       else strcpy(dummy, "  ");
+                                               
+                               }
+                               /* letter/number for power selection */
+                               else
+                               {
+                                       char letter;
+                                       if (ctr < 26)
+                                               letter = I2A(ctr);
+                                       else
+                                               letter = '0' + ctr - 26;
+                                       sprintf(dummy, "%c)",letter);
+                               }
+                               x1 = ((ctr < EATER_EXT/2) ? x : x + 40);
+                               y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2);
+                               level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
+                               chance = level * 4 / 5 + 20;
+                               chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
+                               level /= 2;
+                               if (p_ptr->lev > level)
+                               {
+                                       chance -= 3 * (p_ptr->lev - level);
+                               }
+                               chance = mod_spell_chance_1(chance);
+                               chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
+                               /* Stunning makes spells harder */
+                               if (p_ptr->stun > 50) chance += 25;
+                               else if (p_ptr->stun) chance += 15;
+
+                               if (chance > 95) chance = 95;
+
+                               chance = mod_spell_chance_2(chance);
+
+                               col = TERM_WHITE;
+
+                               if (k_idx)
+                               {
+                                       if (tval == TV_ROD)
+                                       {
+                                               strcat(dummy, format(
+#ifdef JP
+                                                              " %-22.22s ½¼Å¶:%2d/%2d%3d%%",
+#else
+                                                              " %-22.22s   (%2d/%2d) %3d%%",
+#endif
+                                                              k_name + k_info[k_idx].name, 
+                                                              p_ptr->magic_num1[ctr+ext] ? 
+                                                              (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, 
+                                                              p_ptr->magic_num2[ctr+ext], chance));
+                                               if (p_ptr->magic_num1[ctr+ext] > k_info[k_idx].pval * (p_ptr->magic_num2[ctr+ext]-1) * EATER_ROD_CHARGE) col = TERM_RED;
+                                       }
+                                       else
+                                       {
+                                               strcat(dummy, format(" %-22.22s    %2d/%2d %3d%%", k_name + k_info[k_idx].name, (s16b)(p_ptr->magic_num1[ctr+ext]/EATER_CHARGE), p_ptr->magic_num2[ctr+ext], chance));
+                                               if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED;
+                                       }
+                               }
+                               else
+                                       strcpy(dummy, "");
+                               c_prt(col, dummy, y1, x1);
+                       }
+               }
 
-        choice = (always_show_list || use_menu) ? ESCAPE:1;
-        while (!flag)
-        {
-               if( choice==ESCAPE ) choice = ' '; 
-               else if( !get_com(out_val, &choice, FALSE) )break; 
+               if (!get_com(out_val, &choice, FALSE)) break;
 
                if (use_menu && choice != ' ')
                {
-                       switch(choice)
+                       switch (choice)
                        {
                                case '0':
                                {
                                        screen_load();
-                                       return (FALSE);
-                                       break;
+                                       return 0;
                                }
 
                                case '8':
@@ -6662,8 +7054,8 @@ static bool select_magic_eater(int mode)
                                {
                                        do
                                        {
-                                               menu_line += 35;
-                                               if (menu_line > 36) menu_line -= 36;
+                                               menu_line += EATER_EXT - 1;
+                                               if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
                                        } while(!p_ptr->magic_num2[menu_line+ext-1]);
                                        break;
                                }
@@ -6675,7 +7067,7 @@ static bool select_magic_eater(int mode)
                                        do
                                        {
                                                menu_line++;
-                                               if (menu_line > 36) menu_line -= 36;
+                                               if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
                                        } while(!p_ptr->magic_num2[menu_line+ext-1]);
                                        break;
                                }
@@ -6689,12 +7081,12 @@ static bool select_magic_eater(int mode)
                                {
                                        bool reverse = FALSE;
                                        if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
-                                       if (menu_line > 18)
+                                       if (menu_line > EATER_EXT/2)
                                        {
-                                               menu_line -= 18;
+                                               menu_line -= EATER_EXT/2;
                                                reverse = TRUE;
                                        }
-                                       else menu_line+=18;
+                                       else menu_line+=EATER_EXT/2;
                                        while(!p_ptr->magic_num2[menu_line+ext-1])
                                        {
                                                if (reverse)
@@ -6705,7 +7097,7 @@ static bool select_magic_eater(int mode)
                                                else
                                                {
                                                        menu_line++;
-                                                       if (menu_line > 35) reverse = TRUE;
+                                                       if (menu_line > EATER_EXT-1) reverse = TRUE;
                                                }
                                        }
                                        break;
@@ -6721,122 +7113,25 @@ static bool select_magic_eater(int mode)
                                }
                        }
                }
-               /* Request redraw */
-               if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
-               {
-                       /* Show the list */
-                       if (!redraw || use_menu)
-                       {
-                               byte y, x = 0;
-                               int ctr, chance;
-                               int k_idx;
-                               char dummy[80];
-                               int x1, y1, level;
-                               byte col;
-
-                               strcpy(dummy, "");
-
-                               /* Show list */
-                               redraw = TRUE;
-
-                               /* Save the screen */
-                               if (!use_menu) screen_save();
-
-                               for (y = 1; y < 20; y++)
-                                       prt("", y, x);
-
-                               y = 1;
-
-                               /* Print header(s) */
-#ifdef JP
-                               prt(format("                           %s ¼ºÎ¨                           %s ¼ºÎ¨", (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô")), y++, x);
-#else
-                               prt(format("                           %s Fail                           %s Fail", (tval == TV_ROD ? "  Stat  " : " Charges"), (tval == TV_ROD ? "  Stat  " : " Charges")), y++, x);
-#endif
-
-                               /* Print list */
-                               for (ctr = 0; ctr < 36; ctr++)
-                               {
-                                       if (!p_ptr->magic_num2[ctr+ext]) continue;
-
-                                       k_idx = lookup_kind(tval, ctr);
-
-                                       if (use_menu)
-                                       {
-                                               if (ctr == (menu_line-1))
-#ifdef JP
-                                                       strcpy(dummy, "¡Õ");
-#else
-                                                       strcpy(dummy, "> ");
-#endif
-                                               else strcpy(dummy, "  ");
-                                               
-                                       }
-                                       /* letter/number for power selection */
-                                       else
-                                       {
-                                               char letter;
-                                               if (ctr < 26)
-                                                       letter = I2A(ctr);
-                                               else
-                                                       letter = '0' + ctr - 26;
-                                               sprintf(dummy, "%c)",letter);
-                                       }
-                                       x1 = ((ctr < 18) ? x : x + 40);
-                                       y1 = ((ctr < 18) ? y + ctr : y + ctr - 18);
-                                       level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
-                                       chance = level * 4 / 5 + 20;
-                                       chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
-                                       level /= 2;
-                                       if (p_ptr->lev > level)
-                                       {
-                                               chance -= 3 * (p_ptr->lev - level);
-                                       }
-                                       if (p_ptr->pseikaku == SEIKAKU_NAMAKE) chance += 10;
-                                       if (p_ptr->heavy_spell) chance += 20;
-                                       if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
-                                       else if (p_ptr->easy_spell) chance-=3;
-                                       else if (p_ptr->dec_mana) chance-=2;
-                                       chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
-                                       /* Stunning makes spells harder */
-                                       if (p_ptr->stun > 50) chance += 25;
-                                       else if (p_ptr->stun) chance += 15;
-
-                                       if (chance > 95) chance = 95;
 
-                                       if(p_ptr->dec_mana) chance--;
-                                       if (p_ptr->heavy_spell) chance += 5;
-
-                                       col = TERM_WHITE;
-
-                                       if (k_idx)
-                                       {
-                                               if (tval == TV_ROD)
-                                               {
-                                                       strcat(dummy, format(" %-22.22s ½¼Å¶:%2d/%2d%3d%%", k_name + k_info[k_idx].name, p_ptr->magic_num1[ctr+ext] ? (p_ptr->magic_num1[ctr+ext] - 1) / (0x10000L * k_info[k_idx].pval) +1 : 0, p_ptr->magic_num2[ctr+ext], chance));
-                                                       if (p_ptr->magic_num1[ctr+ext] > k_info[k_idx].pval * (p_ptr->magic_num2[ctr+ext]-1) * 0x10000L) col = TERM_RED;
-                                               }
-                                               else
-                                               {
-                                                       strcat(dummy, format(" %-22.22s    %2d/%2d %3d%%", k_name + k_info[k_idx].name, (s16b)(p_ptr->magic_num1[ctr+ext]/0x10000), p_ptr->magic_num2[ctr+ext], chance));
-                                                       if (p_ptr->magic_num1[ctr+ext] < 0x10000L) col = TERM_RED;
-                                               }
-                                       }
-                                       else
-                                               strcpy(dummy, "");
-                                       c_prt(col, dummy, y1, x1);
-                               }
-                       }
+               /* Request redraw */
+               if (use_menu && ask) continue;
 
+               /* Request redraw */
+               if (!use_menu && ((choice == ' ') || (choice == '*') || (choice == '?')))
+               {
                        /* Hide the list */
-                       else
+                       if (request_list)
                        {
                                /* Hide list */
-                               redraw = FALSE;
-
+                               request_list = FALSE;
+                               
                                /* Restore the screen */
                                screen_load();
+                               screen_save();
                        }
+                       else
+                               request_list = TRUE;
 
                        /* Redo asking */
                        continue;
@@ -6864,13 +7159,13 @@ static bool select_magic_eater(int mode)
                }
 
                /* Totally Illegal */
-               if ((i < 0) || (i > 36) || !p_ptr->magic_num2[i+ext])
+               if ((i < 0) || (i > EATER_EXT) || !p_ptr->magic_num2[i+ext])
                {
                        bell();
                        continue;
                }
 
-               if (mode == 0)
+               if (!only_browse)
                {
                        /* Verify it */
                        if (ask)
@@ -6889,7 +7184,7 @@ static bool select_magic_eater(int mode)
                        }
                        if (tval == TV_ROD)
                        {
-                               if (p_ptr->magic_num1[ext+i]  > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * 0x10000L)
+                               if (p_ptr->magic_num1[ext+i]  > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * EATER_ROD_CHARGE)
                                {
 #ifdef JP
                                        msg_print("¤½¤ÎËâË¡¤Ï¤Þ¤À½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
@@ -6903,7 +7198,7 @@ static bool select_magic_eater(int mode)
                        }
                        else
                        {
-                               if (p_ptr->magic_num1[ext+i] < 0x10000L)
+                               if (p_ptr->magic_num1[ext+i] < EATER_CHARGE)
                                {
 #ifdef JP
                                        msg_print("¤½¤ÎËâË¡¤Ï»ÈÍѲó¿ô¤¬ÀÚ¤ì¤Æ¤¤¤ë¡£");
@@ -6917,12 +7212,40 @@ static bool select_magic_eater(int mode)
                        }
                }
 
+               /* Browse */
+               else
+               {
+                       int line, j;
+                       char temp[70 * 20];
+
+                       /* Clear lines, position cursor  (really should use strlen here) */
+                       Term_erase(7, 23, 255);
+                       Term_erase(7, 22, 255);
+                       Term_erase(7, 21, 255);
+                       Term_erase(7, 20, 255);
+
+                       roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp, sizeof(temp));
+                       for (j = 0, line = 21; temp[j]; j += 1 + strlen(&temp[j]))
+                       {
+                               prt(&temp[j], line, 10);
+                               line++;
+                       }
+       
+#ifdef JP
+                       prt("²¿¤«¥­¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£",0,0);
+#else
+                       prt("Hit any key.",0,0);
+#endif
+                       (void)inkey();
+                       continue;
+               }
+
                /* Stop the loop */
                flag = TRUE;
        }
 
        /* Restore the screen */
-       if (redraw) screen_load();
+       screen_load();
 
        if (!flag) return -1;
 
@@ -6932,13 +7255,17 @@ static bool select_magic_eater(int mode)
        return ext+i;
 }
 
-void do_cmd_magic_eater(void)
+
+/*
+ *  Use eaten rod, wand or staff
+ */
+void do_cmd_magic_eater(bool only_browse)
 {
-       int item, dir, chance, level, k_idx, tval, sval;
+       int item, chance, level, k_idx, tval, sval;
        bool use_charge = TRUE;
 
        /* Not when confused */
-       if (p_ptr->confused)
+       if (!only_browse && p_ptr->confused)
        {
 #ifdef JP
 msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
@@ -6949,14 +7276,14 @@ msg_print("
                return;
        }
 
-       item = select_magic_eater(0);
+       item = select_magic_eater(only_browse);
        if (item == -1)
        {
                energy_use = 0;
                return;
        }
-       if (item > 71) {tval = TV_ROD;sval = item - 72;}
-       else if (item > 35) {tval = TV_WAND;sval = item - 36;}
+       if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
+       else if (item >= EATER_EXT) {tval = TV_WAND;sval = item - EATER_EXT;}
        else {tval = TV_STAFF;sval = item;}
        k_idx = lookup_kind(tval, sval);
 
@@ -6968,11 +7295,7 @@ msg_print("
        {
                chance -= 3 * (p_ptr->lev - level);
        }
-       if (p_ptr->pseikaku == SEIKAKU_NAMAKE) chance += 10;
-       if (p_ptr->heavy_spell) chance += 20;
-       if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
-       else if (p_ptr->easy_spell) chance-=3;
-       else if (p_ptr->dec_mana) chance-=2;
+       chance = mod_spell_chance_1(chance);
        chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
        /* Stunning makes spells harder */
        if (p_ptr->stun > 50) chance += 25;
@@ -6980,10 +7303,9 @@ msg_print("
 
        if (chance > 95) chance = 95;
 
-       if(p_ptr->dec_mana) chance--;
-       if (p_ptr->heavy_spell) chance += 5;
+       chance = mod_spell_chance_2(chance);
 
-       if (rand_int(100) < chance)
+       if (randint0(100) < chance)
        {
                if (flush_failure) flush();
 
@@ -6994,7 +7316,7 @@ msg_print("
 #endif
 
                sound(SOUND_FAIL);
-               if (randint(100) >= chance)
+               if (randint1(100) >= chance)
                        chg_virtue(V_CHANCE,-1);
                energy_use = 100;
 
@@ -7002,9 +7324,11 @@ msg_print("
        }
        else
        {
+               int dir = 0;
+
                if (tval == TV_ROD)
                {
-                       if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC))
+                       if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC) && (sval != SV_ROD_AGGRAVATE) && (sval != SV_ROD_PESTICIDE))
                                if (!get_aim_dir(&dir)) return;
                        rod_effect(sval, dir, &use_charge, TRUE);
                        if (!use_charge) return;
@@ -7016,13 +7340,13 @@ msg_print("
                }
                else
                {
-                       staff_effect(sval, &use_charge, TRUE);
+                       staff_effect(sval, &use_charge, TRUE, TRUE);
                        if (!use_charge) return;
                }
-               if (randint(100) < chance)
+               if (randint1(100) < chance)
                        chg_virtue(V_CHANCE,1);
        }
        energy_use = 100;
-       if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * 0x10000L;
-       else p_ptr->magic_num1[item] -= 0x10000L;
+       if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * EATER_ROD_CHARGE;
+       else p_ptr->magic_num1[item] -= EATER_CHARGE;
 }