OSDN Git Service

los()やplayer_has_los_*()の使用に関する変更. 主に透明な壁の作成を想定
[hengband/hengband.git] / src / cmd6.c
index 1a38b46..e085d19 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"
 
 
@@ -90,7 +90,7 @@ static void do_cmd_eat_food_aux(int item)
                {
                        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 + randint0(10) + 10))
                                        {
@@ -386,7 +386,7 @@ 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))
@@ -418,8 +418,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)))
                {
@@ -449,12 +582,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
@@ -465,8 +598,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);
        }
 
@@ -493,8 +632,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);
@@ -561,10 +726,10 @@ static void do_cmd_quaff_potion_aux(int item)
                return;
        }
 
-        if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
-        {
-                stop_singing();
-        }
+       if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
+       {
+               stop_singing();
+       }
 
        /* Get the item (in the pack) */
        if (item >= 0)
@@ -614,67 +779,68 @@ static void do_cmd_quaff_potion_aux(int item)
        lev = get_object_level(q_ptr);
 
        /* 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(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 + randint0(15) + 10))
                                {
@@ -682,10 +848,8 @@ static void do_cmd_quaff_potion_aux(int item)
                                }
                        }
                        break;
-               }
 
                case SV_POTION_BLINDNESS:
-               {
                        if (!p_ptr->resist_blind)
                        {
                                if (set_blind(p_ptr->blind + randint0(100) + 100))
@@ -694,10 +858,8 @@ static void do_cmd_quaff_potion_aux(int item)
                                }
                        }
                        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)
@@ -735,16 +897,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
 
 
@@ -772,10 +932,8 @@ msg_print("
                                }
                        }
                        break;
-               }
 
                case SV_POTION_LOSE_MEMORIES:
-               {
                        if (!p_ptr->hold_life && (p_ptr->exp > 0))
                        {
 #ifdef JP
@@ -789,10 +947,8 @@ msg_print("
                                ident = TRUE;
                        }
                        break;
-               }
 
                case SV_POTION_RUINATION:
-               {
 #ifdef JP
                        msg_print("¿È¤â¿´¤â¼å¤Ã¤Æ¤­¤Æ¡¢Àºµ¤¤¬È´¤±¤Æ¤¤¤¯¤è¤¦¤À¡£");
                        take_hit(DAMAGE_LOSELIFE, damroll(10, 10), "ÇËÌǤÎÌô", -1);
@@ -809,46 +965,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);
@@ -861,10 +1003,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
@@ -877,46 +1017,34 @@ msg_print("
 
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_INFRAVISION:
-               {
                        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 + 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(randint1(25) + 15, FALSE)) ident = TRUE;
@@ -926,63 +1054,49 @@ msg_print("
                                (void)set_fast(p_ptr->fast + 5, FALSE);
                        }
                        break;
-               }
 
                case SV_POTION_RESIST_HEAT:
-               {
                        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 + randint1(10) + 10, FALSE))
                        {
                                ident = TRUE;
                        }
                        break;
-               }
 
                case SV_POTION_HEROISM:
-               {
                        if (set_afraid(0)) 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 + 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;
@@ -991,10 +1105,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;
@@ -1003,10 +1115,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;
@@ -1015,10 +1125,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
@@ -1045,28 +1153,26 @@ msg_print("
                        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;
@@ -1078,7 +1184,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);
@@ -1088,88 +1194,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;
@@ -1177,11 +1255,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
@@ -1190,13 +1265,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
@@ -1204,12 +1277,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);
@@ -1219,10 +1292,8 @@ msg_print("
                        self_knowledge();
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_SELF_KNOWLEDGE:
-               {
 #ifdef JP
                        msg_print("¼«Ê¬¼«¿È¤Î¤³¤È¤¬¾¯¤·¤Ïʬ¤«¤Ã¤¿µ¤¤¬¤¹¤ë...");
 #else
@@ -1233,10 +1304,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)
@@ -1253,10 +1322,8 @@ msg_print("
                                ident = TRUE;
                        }
                        break;
-               }
 
                case SV_POTION_RESISTANCE:
-               {
                        (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);
@@ -1264,10 +1331,8 @@ msg_print("
                        (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;
@@ -1276,17 +1341,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 + randint1(4) + 4, FALSE);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_NEW_LIFE:
-               {
                        do_cmd_rerate(FALSE);
                        get_max_stats();
                        p_ptr->update |= PU_BONUS;
@@ -1306,18 +1367,14 @@ msg_print("
                        }
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_NEO_TSUYOSHI:
-               {
                        (void)set_image(0);
                        (void)set_tsuyoshi(p_ptr->tsuyoshi + randint1(100) + 100, FALSE);
                        ident = TRUE;
                        break;
-               }
 
                case SV_POTION_TSUYOSHI:
-               {
 #ifdef JP
 msg_print("¡Ö¥ª¥¯¥ì·»¤µ¤ó¡ª¡×");
 #else
@@ -1332,10 +1389,8 @@ msg_print("
                        }
                        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);
@@ -1364,7 +1419,7 @@ msg_print("
                }
        }
 
-       if (p_ptr->prace == RACE_SKELETON)
+       if (prace_is_(RACE_SKELETON))
        {
 #ifdef JP
 msg_print("±ÕÂΤΰìÉô¤Ï¤¢¤Ê¤¿¤Î¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¤¿¡ª");
@@ -1412,12 +1467,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 (o_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;
@@ -1437,6 +1513,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;
@@ -1448,7 +1544,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
@@ -1473,7 +1569,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;
@@ -1519,10 +1615,10 @@ static void do_cmd_read_scroll_aux(int item)
                return;
        }
 
-        if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
-        {
-                stop_singing();
-        }
+       if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
+       {
+               stop_singing();
+       }
 
        /* Not identified yet */
        ident = FALSE;
@@ -1577,7 +1673,7 @@ static void do_cmd_read_scroll_aux(int item)
                {
                        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;
                                }
@@ -1589,7 +1685,7 @@ static void do_cmd_read_scroll_aux(int item)
                {
                        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;
                                }
@@ -1599,7 +1695,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;
                        }
@@ -1608,7 +1704,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,7 +1733,7 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_TELEPORT_LEVEL:
                {
-                       (void)teleport_player_level();
+                       (void)teleport_level(0);
                        ident = TRUE;
                        break;
                }
@@ -1651,15 +1747,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;
                }
 
@@ -1769,7 +1865,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;
                }
 
@@ -1849,7 +1945,7 @@ static void do_cmd_read_scroll_aux(int item)
 
                case SV_SCROLL_STAR_DESTRUCTION:
                {
-                       if (destroy_area(py, px, 13+randint0(5), TRUE))
+                       if (destroy_area(py, px, 13 + randint0(5), FALSE))
                                ident = TRUE;
                        else
 #ifdef JP
@@ -1910,7 +2006,7 @@ 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+randint1(50), "±ê¤Î´¬Êª", -1);
 #else
@@ -1925,7 +2021,7 @@ take_hit(DAMAGE_NOESCAPE, 50+randint1(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+randint1(100), "ɹ¤Î´¬Êª", -1);
 #else
@@ -2056,7 +2152,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);
@@ -2066,7 +2162,7 @@ msg_print("
 #endif
                used_up = FALSE;
        }
-       else if (o_ptr->tval==TV_PARCHEMENT)
+       else if (o_ptr->tval==TV_PARCHMENT)
        {
                cptr q;
                char o_name[MAX_NLEN];
@@ -2078,10 +2174,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);
@@ -2140,8 +2236,6 @@ msg_print("
                floor_item_describe(0 - item);
                floor_item_optimize(0 - item);
        }
-
-       /* Can save again */
 }
 
 
@@ -2150,7 +2244,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->name1 == ART_GHB) || (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);
@@ -2159,6 +2253,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;
 
@@ -2214,12 +2309,24 @@ void do_cmd_read_scroll(void)
 
        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_aware_p(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;
@@ -2253,7 +2360,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
                {
                        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;
                                }
@@ -2318,15 +2425,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 (!have_flag(f_flags_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,
@@ -2364,7 +2471,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;
                }
 
@@ -2426,7 +2533,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);
@@ -2511,7 +2618,7 @@ msg_print("
 
                case SV_STAFF_DESTRUCTION:
                {
-                       if (destroy_area(py, px, 13+randint0(5), TRUE))
+                       if (destroy_area(py, px, 13 + randint0(5), FALSE))
                                ident = TRUE;
 
                        break;
@@ -2533,7 +2640,7 @@ msg_print("
                        msg_print("Mighty magics rend your enemies!");
 #endif
                        project(0, 5, py, px,
-                               (randint1(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
@@ -2546,6 +2653,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;
 }
@@ -2656,6 +2780,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;
        }
@@ -2664,7 +2789,7 @@ 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_aware_p(o_ptr));
 
        if (!(object_aware_p(o_ptr)))
        {
@@ -3189,6 +3314,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;
        }
@@ -3272,12 +3398,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;
                }
 
@@ -3290,8 +3419,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;
                }
 
@@ -3514,7 +3643,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;
 
@@ -3709,27 +3839,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);
 
        /* 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);
@@ -3824,6 +3943,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;
 
@@ -4106,7 +4228,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);
@@ -4115,7 +4237,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);
 
@@ -4273,15 +4395,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 (!have_flag(f_flags_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,
@@ -4749,7 +4871,7 @@ 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);
+                               (void)summon_specific(-1, py, px, dun_level, SUMMON_DAWN, (PM_ALLOW_GROUP | PM_FORCE_PET));
                                o_ptr->timeout = 500 + randint1(500);
                                break;
                        }
@@ -4982,7 +5104,7 @@ msg_print("
                                detect_all(DETECT_RAD_DEFAULT);
                                probing();
                                identify_fully(FALSE);
-                               o_ptr->timeout = 1000;
+                               o_ptr->timeout = 100;
                                break;
                        }
 
@@ -5016,7 +5138,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("¤»¤Ã¤«¤¯¤À¤«¤é¡Ø¥¯¥ê¥à¥¾¥ó¡Ù¤ò¤Ö¤Ã¤Ñ¤Ê¤¹¤¼¡ª");
@@ -5054,41 +5176,41 @@ msg_print("
                                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:
                        {
@@ -5160,7 +5282,11 @@ msg_print("
 
                        case ART_BOROMIR:
                        {
+#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 = randint0(40) + 40;
                                break;
@@ -5202,7 +5328,7 @@ msg_print("
                                o_ptr->timeout = randint0(120) + 120;
                                break;
                        }
-                       case ART_HURIN:
+                       case ART_HURIN:
                        {
                                (void)set_fast(randint1(50) + 50, FALSE);
                                hp_player(10);
@@ -5281,10 +5407,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 (!have_flag(f_flags_bold(y, x), FF_WATER))
                                {
 #ifdef JP
-                                       msg_print("¤½¤³¤ÏΦÃϤÀ¡£");
+                                       msg_print("¤½¤³¤Ï¿åÊդǤϤʤ¤¡£");
 #else
                                        msg_print("There is no fishing place.");
 #endif
@@ -5321,9 +5447,12 @@ msg_print("
                        }
                        case ART_ARRYU:
                        {
+                               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, (bool)(!pet)))
+                               if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, mode))
                                {
 
                                        if (pet)
@@ -5368,7 +5497,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("¡Ø½õ¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
@@ -5378,7 +5507,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("¡Ø³Ê¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
@@ -5396,6 +5525,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;
                                        }
@@ -5458,7 +5588,7 @@ msg_print("
                                (void)set_image(0);
 
                                o_ptr->timeout = 100;
-                               break;
+                               break;
                        }
 
                        case ART_BOLISHOI:
@@ -5467,7 +5597,7 @@ msg_print("
                                (void)charm_animal(dir, p_ptr->lev);
 
                                o_ptr->timeout = 200;
-                               break;
+                               break;
                        }
 
                        case ART_ARUNRUTH:
@@ -5490,11 +5620,16 @@ 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;
+                               for (i = 0; i < TR_FLAG_SIZE; i++)
+                                       o_ptr->art_flags[i] = a_info[ART_BLOOD].flags[i];
+
                                dummy = randint1(2)+randint1(2);
                                for (i = 0; i < dummy; i++)
-                                       o_ptr->art_flags1 |= (TR1_CHAOTIC << randint0(18));
+                               {
+                                       int flag = randint0(19);
+                                       if (flag == 18) add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
+                                       else add_flag(o_ptr->art_flags, TR_CHAOTIC + flag);
+                               }
                                dummy = randint1(2);
                                for (i = 0; i < dummy; i++)
                                        one_resistance(o_ptr);
@@ -5502,8 +5637,8 @@ msg_print("
                                for (i = 0; i < dummy; i++)
                                {
                                        int tmp = randint0(11);
-                                       if (tmp < 6) o_ptr->art_flags1 |= (TR1_STR << tmp);
-                                       else o_ptr->art_flags1 |= (TR1_STEALTH << (tmp - 6));
+                                       if (tmp < 6) add_flag(o_ptr->art_flags, TR_STR + tmp);
+                                       else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6);
                                }
                                o_ptr->timeout = 3333;
                                if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
@@ -5548,9 +5683,11 @@ msg_print("
                        }
                        case ART_JIZO:
                        {
+                               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
@@ -5597,6 +5734,81 @@ msg_print("
                                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 = 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;
+                       }
                }
 
                /* Window stuff */
@@ -5606,48 +5818,44 @@ msg_print("
                return;
        }
 
-       else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == 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_ELEC))
+       if (item_tester_hook_smith(o_ptr))
        {
-               (void)set_oppose_elec(randint1(20) + 20, FALSE);
-               o_ptr->timeout = randint0(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(randint1(20) + 20, FALSE);
-               o_ptr->timeout = randint0(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(randint1(20) + 20, FALSE);
-               o_ptr->timeout = randint0(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 + randint1(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 + randint1(50);
@@ -5660,7 +5868,7 @@ 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)))
                {
@@ -5682,7 +5890,7 @@ msg_print("
        }
 
 
-       else if (o_ptr->name2 == EGO_EARTHQUAKES)
+       if (o_ptr->name2 == EGO_EARTHQUAKES)
        {
                earthquake(py, px, 5);
                o_ptr->timeout = 100 + randint1(100);
@@ -5695,7 +5903,7 @@ msg_print("
        }
 
 
-       else if (o_ptr->name2 == EGO_JUMP)
+       if (o_ptr->name2 == EGO_JUMP)
        {
                teleport_player(10);
                o_ptr->timeout = 10 + randint1(10);
@@ -5709,7 +5917,7 @@ 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;
@@ -5787,23 +5995,23 @@ msg_print("
                                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);
+                                          ((chance == 2) ? GF_COLD :
+                                           ((chance == 3) ? GF_ACID :
+                                            ((chance == 4) ? GF_POIS : GF_FIRE)))),
+                                         dir, 250, -2);
                                o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
@@ -5839,14 +6047,14 @@ msg_print("
                                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);
+                                         dir, 220, -2);
                                o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
@@ -5856,14 +6064,14 @@ msg_print("
                                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);
+                                         dir, 230, -2);
                                o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
@@ -5873,20 +6081,20 @@ msg_print("
                                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);
+                                          ((chance == 2) ? GF_DISENCHANT :
+                                           ((chance == 3) ? GF_SOUND : GF_SHARDS))),
+                                         dir, 250, -2);
                                o_ptr->timeout = randint0(200) + 200;
                                break;
                        }
@@ -5896,10 +6104,10 @@ msg_print("
                                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);
@@ -6195,7 +6403,7 @@ 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);
                        }
 
                        /* Free the "who" array */
@@ -6266,9 +6474,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;
@@ -6391,7 +6599,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)
@@ -6424,10 +6632,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);
                                }
                        }
                }
@@ -6558,7 +6766,7 @@ msg_print("
                                return;
                        }
 
-                 do_cmd_read_scroll_aux(item);
+                 do_cmd_read_scroll_aux(item, TRUE);
                  break;
                }
 
@@ -6580,11 +6788,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];
@@ -6596,9 +6804,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, sn-72)].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;
        }
        
@@ -6656,7 +6864,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;
@@ -6686,19 +6894,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])
                {
@@ -6706,7 +6914,7 @@ static bool select_magic_eater(int mode)
                        break;
                }
        }
-       if (i == ext+36)
+       if (i == ext+EATER_EXT)
        {
 #ifdef JP
                msg_print("¤½¤Î¼ïÎà¤ÎËâË¡¤Ï³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
@@ -6719,34 +6927,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, "");
 
-        choice = (always_show_list || use_menu) ? ESCAPE:1;
-        while (!flag)
-        {
-               if( choice==ESCAPE ) choice = ' '; 
-               else if( !get_com(out_val, &choice, FALSE) )break; 
+                       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);
+                       }
+               }
+
+               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':
@@ -6755,8 +7062,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;
                                }
@@ -6768,7 +7075,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;
                                }
@@ -6782,12 +7089,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)
@@ -6798,7 +7105,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;
@@ -6814,131 +7121,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);
-                                       }
-                                       chance += p_ptr->to_m_chance;
-                                       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(
-#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) / (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;
@@ -6966,13 +7167,13 @@ strcat(dummy, format(
                }
 
                /* 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)
@@ -6991,7 +7192,7 @@ strcat(dummy, format(
                        }
                        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("¤½¤ÎËâË¡¤Ï¤Þ¤À½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
@@ -7005,7 +7206,7 @@ strcat(dummy, format(
                        }
                        else
                        {
-                               if (p_ptr->magic_num1[ext+i] < 0x10000L)
+                               if (p_ptr->magic_num1[ext+i] < EATER_CHARGE)
                                {
 #ifdef JP
                                        msg_print("¤½¤ÎËâË¡¤Ï»ÈÍѲó¿ô¤¬ÀÚ¤ì¤Æ¤¤¤ë¡£");
@@ -7019,12 +7220,40 @@ strcat(dummy, format(
                        }
                }
 
+               /* 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;
 
@@ -7034,13 +7263,17 @@ strcat(dummy, format(
        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("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
@@ -7051,14 +7284,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);
 
@@ -7070,11 +7303,7 @@ msg_print("
        {
                chance -= 3 * (p_ptr->lev - level);
        }
-       chance += p_ptr->to_m_chance;
-       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;
@@ -7082,8 +7311,7 @@ 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 (randint0(100) < chance)
        {
@@ -7104,6 +7332,8 @@ msg_print("
        }
        else
        {
+               int dir = 0;
+
                if (tval == TV_ROD)
                {
                        if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC) && (sval != SV_ROD_AGGRAVATE) && (sval != SV_ROD_PESTICIDE))
@@ -7118,13 +7348,13 @@ msg_print("
                }
                else
                {
-                       staff_effect(sval, &use_charge, TRUE);
+                       staff_effect(sval, &use_charge, TRUE, TRUE);
                        if (!use_charge) return;
                }
                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;
 }