OSDN Git Service

mimicのあるグリッドのmimicの地形にさらにデフォルトのmimicがある場合
[hengbandforosx/hengbandosx.git] / src / cmd1.c
index 385deba..88ee4c8 100644 (file)
@@ -1,15 +1,15 @@
 /* File: cmd1.c */
 
-/* Purpose: Movement commands (part 1) */
-
 /*
- * 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: Movement commands (part 1) */
+
 #include "angband.h"
 #define MAX_VAMPIRIC_DRAIN 50
 
@@ -216,7 +216,7 @@ s16b critical_norm(int weight, int plus, int dam, s16b meichuu, int mode)
  * Note that most brands and slays are x3, except Slay Animal (x2),
  * Slay Evil (x2), and Kill dragon (x5).
  */
-s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
+s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bool thrown)
 {
        int mult = 10;
 
@@ -242,7 +242,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
                            (r_ptr->flags3 & RF3_ANIMAL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ANIMAL;
                                }
@@ -254,7 +254,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
                            (r_ptr->flags3 & RF3_ANIMAL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ANIMAL;
                                }
@@ -266,7 +266,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_SLAY_EVIL)) &&
                            (r_ptr->flags3 & RF3_EVIL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_EVIL;
                                }
@@ -278,7 +278,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_KILL_EVIL)) &&
                            (r_ptr->flags3 & RF3_EVIL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_EVIL;
                                }
@@ -290,7 +290,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
                            (r_ptr->flags2 & RF2_HUMAN))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags2 |= RF2_HUMAN;
                                }
@@ -302,7 +302,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_KILL_HUMAN)) &&
                            (r_ptr->flags2 & RF2_HUMAN))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags2 |= RF2_HUMAN;
                                }
@@ -314,7 +314,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
                            (r_ptr->flags3 & RF3_UNDEAD))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_UNDEAD;
                                }
@@ -326,7 +326,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
                            (r_ptr->flags3 & RF3_UNDEAD))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_UNDEAD;
                                }
@@ -338,7 +338,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_SLAY_DEMON)) &&
                            (r_ptr->flags3 & RF3_DEMON))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DEMON;
                                }
@@ -350,7 +350,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_KILL_DEMON)) &&
                            (r_ptr->flags3 & RF3_DEMON))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DEMON;
                                }
@@ -362,7 +362,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_SLAY_ORC)) &&
                            (r_ptr->flags3 & RF3_ORC))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ORC;
                                }
@@ -374,7 +374,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_KILL_ORC)) &&
                            (r_ptr->flags3 & RF3_ORC))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ORC;
                                }
@@ -386,7 +386,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_SLAY_TROLL)) &&
                            (r_ptr->flags3 & RF3_TROLL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_TROLL;
                                }
@@ -398,7 +398,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_KILL_TROLL)) &&
                            (r_ptr->flags3 & RF3_TROLL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_TROLL;
                                }
@@ -410,7 +410,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_SLAY_GIANT)) &&
                            (r_ptr->flags3 & RF3_GIANT))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_GIANT;
                                }
@@ -424,7 +424,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_KILL_GIANT)) &&
                            (r_ptr->flags3 & RF3_GIANT))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_GIANT;
                                }
@@ -436,7 +436,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
                            (r_ptr->flags3 & RF3_DRAGON))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DRAGON;
                                }
@@ -448,7 +448,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        if ((have_flag(flgs, TR_KILL_DRAGON)) &&
                            (r_ptr->flags3 & RF3_DRAGON))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DRAGON;
                                }
@@ -460,14 +460,14 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        }
 
                        /* Brand (Acid) */
-                       if ((have_flag(flgs, TR_BRAND_ACID)) || (p_ptr->special_attack & (ATTACK_ACID)))
+                       if (have_flag(flgs, TR_BRAND_ACID) || ((p_ptr->special_attack & (ATTACK_ACID)) && !thrown))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_ACID)
+                               if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_ACID;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
                                        }
                                }
 
@@ -479,19 +479,19 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        }
 
                        /* Brand (Elec) */
-                       if ((have_flag(flgs, TR_BRAND_ELEC)) || (p_ptr->special_attack & (ATTACK_ELEC)) || (mode == HISSATSU_ELEC))
+                       if (have_flag(flgs, TR_BRAND_ELEC) || ((p_ptr->special_attack & (ATTACK_ELEC)) && !thrown) || (mode == HISSATSU_ELEC))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_ELEC)
+                               if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_ELEC;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
                                        }
                                }
 
                                /* Otherwise, take the damage */
-                               else if (((have_flag(flgs, TR_BRAND_ELEC)) || (p_ptr->special_attack & (ATTACK_ELEC))) && (mode == HISSATSU_ELEC))
+                               else if ((have_flag(flgs, TR_BRAND_ELEC) || ((p_ptr->special_attack & (ATTACK_ELEC)) && !thrown)) && (mode == HISSATSU_ELEC))
                                {
                                        if (mult < 70) mult = 70;
                                }
@@ -507,24 +507,24 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        }
 
                        /* Brand (Fire) */
-                       if ((have_flag(flgs, TR_BRAND_FIRE)) || (p_ptr->special_attack & (ATTACK_FIRE)) || (mode == HISSATSU_FIRE))
+                       if (have_flag(flgs, TR_BRAND_FIRE) || ((p_ptr->special_attack & (ATTACK_FIRE)) && !thrown) || (mode == HISSATSU_FIRE))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_FIRE)
+                               if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_FIRE;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
                                        }
                                }
 
                                /* Otherwise, take the damage */
-                               else if (((have_flag(flgs, TR_BRAND_FIRE)) || (p_ptr->special_attack & (ATTACK_FIRE))) && (mode == HISSATSU_FIRE))
+                               else if ((have_flag(flgs, TR_BRAND_FIRE) || ((p_ptr->special_attack & (ATTACK_FIRE)) && !thrown)) && (mode == HISSATSU_FIRE))
                                {
                                        if (r_ptr->flags3 & RF3_HURT_FIRE)
                                        {
                                                if (mult < 70) mult = 70;
-                                               if (m_ptr->ml)
+                                               if (m_ptr->ml && is_original_ap(m_ptr))
                                                {
                                                        r_ptr->r_flags3 |= RF3_HURT_FIRE;
                                                }
@@ -536,7 +536,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                                        if (r_ptr->flags3 & RF3_HURT_FIRE)
                                        {
                                                if (mult < 50) mult = 50;
-                                               if (m_ptr->ml)
+                                               if (m_ptr->ml && is_original_ap(m_ptr))
                                                {
                                                        r_ptr->r_flags3 |= RF3_HURT_FIRE;
                                                }
@@ -546,23 +546,23 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        }
 
                        /* Brand (Cold) */
-                       if ((have_flag(flgs, TR_BRAND_COLD)) || (p_ptr->special_attack & (ATTACK_COLD)) || (mode == HISSATSU_COLD))
+                       if (have_flag(flgs, TR_BRAND_COLD) || ((p_ptr->special_attack & (ATTACK_COLD)) && !thrown) || (mode == HISSATSU_COLD))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_COLD)
+                               if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_COLD;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
                                        }
                                }
                                /* Otherwise, take the damage */
-                               else if (((have_flag(flgs, TR_BRAND_COLD)) || (p_ptr->special_attack & (ATTACK_COLD))) && (mode == HISSATSU_COLD))
+                               else if ((have_flag(flgs, TR_BRAND_COLD) || ((p_ptr->special_attack & (ATTACK_COLD)) && !thrown)) && (mode == HISSATSU_COLD))
                                {
                                        if (r_ptr->flags3 & RF3_HURT_COLD)
                                        {
                                                if (mult < 70) mult = 70;
-                                               if (m_ptr->ml)
+                                               if (m_ptr->ml && is_original_ap(m_ptr))
                                                {
                                                        r_ptr->r_flags3 |= RF3_HURT_COLD;
                                                }
@@ -574,7 +574,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                                        if (r_ptr->flags3 & RF3_HURT_COLD)
                                        {
                                                if (mult < 50) mult = 50;
-                                               if (m_ptr->ml)
+                                               if (m_ptr->ml && is_original_ap(m_ptr))
                                                {
                                                        r_ptr->r_flags3 |= RF3_HURT_COLD;
                                                }
@@ -584,19 +584,19 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        }
 
                        /* Brand (Poison) */
-                       if ((have_flag(flgs, TR_BRAND_POIS)) || (p_ptr->special_attack & (ATTACK_POIS)) || (mode == HISSATSU_POISON))
+                       if (have_flag(flgs, TR_BRAND_POIS) || ((p_ptr->special_attack & (ATTACK_POIS)) && !thrown) || (mode == HISSATSU_POISON))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_POIS)
+                               if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_POIS;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
                                        }
                                }
 
                                /* Otherwise, take the damage */
-                               else if (((have_flag(flgs, TR_BRAND_POIS)) || (p_ptr->special_attack & (ATTACK_POIS))) && (mode == HISSATSU_POISON))
+                               else if ((have_flag(flgs, TR_BRAND_POIS) || ((p_ptr->special_attack & (ATTACK_POIS)) && !thrown)) && (mode == HISSATSU_POISON))
                                {
                                        if (mult < 35) mult = 35;
                                }
@@ -605,7 +605,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                                        if (mult < 25) mult = 25;
                                }
                        }
-                       if ((mode == HISSATSU_ZANMA) && (r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) && (r_ptr->flags3 & RF3_EVIL))
+                       if ((mode == HISSATSU_ZANMA) && !monster_living(r_ptr) && (r_ptr->flags3 & RF3_EVIL))
                        {
                                if (mult < 15) mult = 25;
                                else if (mult < 50) mult = MIN(50, mult+20);
@@ -614,7 +614,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        {
                                if (r_ptr->flags3 & RF3_UNDEAD)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
                                                r_ptr->r_flags3 |= RF3_UNDEAD;
                                        }
@@ -624,14 +624,14 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                                if (mult == 10) mult = 40;
                                else if (mult < 60) mult = MIN(60, mult+30);
                        }
-                       if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)))
+                       if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && monster_living(r_ptr))
                        {
                                int tmp = MIN(100, MAX(10, p_ptr->cut / 10));
                                if (mult < tmp) mult = tmp;
                        }
                        if ((mode == HISSATSU_HAGAN) && (r_ptr->flags3 & RF3_HURT_ROCK))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_HURT_ROCK;
                                }
@@ -642,7 +642,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
                        {
                                p_ptr->csp -= (1+(o_ptr->dd * o_ptr->ds / 5));
                                p_ptr->redraw |= (PR_MANA);
-                               mult = MIN(60, mult * 7 / 2);
+                               mult = mult * 3 / 2 + 20;
                        }
                        break;
                }
@@ -685,10 +685,10 @@ void search(void)
                                c_ptr = &cave[y][x];
 
                                /* Invisible trap */
-                               if (c_ptr->info & CAVE_TRAP)
+                               if (c_ptr->mimic && is_trap(c_ptr->feat))
                                {
                                        /* Pick a trap */
-                                       pick_trap(y, x);
+                                       disclose_grid(y, x);
 
                                        /* Message */
 #ifdef JP
@@ -703,7 +703,7 @@ void search(void)
                                }
 
                                /* Secret door */
-                               if (c_ptr->feat == FEAT_SECRET)
+                               if (is_hidden_door(c_ptr))
                                {
                                        /* Message */
 #ifdef JP
@@ -712,9 +712,8 @@ void search(void)
                                        msg_print("You have found a secret door.");
 #endif
 
-
-                                       /* Pick a door */
-                                       place_closed_door(y, x);
+                                       /* Disclose */
+                                       disclose_grid(y, x);
 
                                        /* Disturb */
                                        disturb(0, 0);
@@ -947,7 +946,7 @@ void carry(int pickup)
                        /* Message */
 #ifdef JP
                msg_format(" $%ld ¤Î²ÁÃͤ¬¤¢¤ë%s¤ò¸«¤Ä¤±¤¿¡£",
-                          (long)value, o_name);
+                          (long)value, o_name);
 #else
                        msg_format("You collect %ld gold pieces worth of %s.",
                                   (long)value, o_name);
@@ -969,8 +968,14 @@ void carry(int pickup)
                /* Pick up objects */
                else
                {
+                       /* Hack - some objects were handled in auto_pickup_items(). */
+                       if (o_ptr->marked & OM_NOMSG)
+                       {
+                               /* Clear the flag. */
+                               o_ptr->marked &= ~OM_NOMSG;
+                       }
                        /* Describe the object */
-                       if (!pickup)
+                       else if (!pickup)
 
                        {
 #ifdef JP
@@ -1118,11 +1123,11 @@ static void hit_trap(bool break_trap)
                                        do_cmd_save_game(TRUE);
 
 #ifdef JP
-                               do_cmd_write_nikki(NIKKI_STAIR, 1, "Í¸Í¤ËÍî¤Á¤¿");
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "Í¸Í¤ËÍî¤Á¤¿");
 #else
-                               do_cmd_write_nikki(NIKKI_STAIR, 1, "You have fallen through a trap door!");
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "You have fallen through a trap door!");
 #endif
-                               dun_level++;
+                               prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
 
                                /* Leaving */
                                p_ptr->leaving = TRUE;
@@ -1266,7 +1271,7 @@ static void hit_trap(bool break_trap)
                                        dam = dam * 2;
                                        (void)set_cut(p_ptr->cut + randint1(dam));
 
-                                       if (p_ptr->resist_pois || p_ptr->oppose_pois)
+                                       if (p_ptr->resist_pois || IS_OPPOSE_POIS())
                                        {
 #ifdef JP
                                                msg_print("¤·¤«¤·ÆǤαƶÁ¤Ï¤Ê¤«¤Ã¤¿¡ª");
@@ -1342,9 +1347,9 @@ static void hit_trap(bool break_trap)
 
                        dam = damroll(4, 6);
 #ifdef JP
-                       fire_dam(dam, "±ê¤Î¥È¥é¥Ã¥×", -1);
+                       (void)fire_dam(dam, "±ê¤Î¥È¥é¥Ã¥×", -1);
 #else
-                       fire_dam(dam, "a fire trap", -1);
+                       (void)fire_dam(dam, "a fire trap", -1);
 #endif
 
                        break;
@@ -1360,9 +1365,9 @@ static void hit_trap(bool break_trap)
 
                        dam = damroll(4, 6);
 #ifdef JP
-                       acid_dam(dam, "»À¤Î¥È¥é¥Ã¥×", -1);
+                       (void)acid_dam(dam, "»À¤Î¥È¥é¥Ã¥×", -1);
 #else
-                       acid_dam(dam, "an acid trap", -1);
+                       (void)acid_dam(dam, "an acid trap", -1);
 #endif
 
                        break;
@@ -1525,7 +1530,7 @@ static void hit_trap(bool break_trap)
                        msg_print("A pungent green gas surrounds you!");
 #endif
 
-                       if (!p_ptr->resist_pois && !p_ptr->oppose_pois)
+                       if (!p_ptr->resist_pois && !IS_OPPOSE_POIS())
                        {
                                (void)set_poisoned(p_ptr->poisoned + randint0(20) + 10);
                        }
@@ -1602,6 +1607,97 @@ msg_print("
 
                        break;
                }
+
+               case FEAT_TRAP_OPEN:
+               {
+#ifdef JP
+                       msg_print("Âç²»¶Á¤È¶¦¤Ë¤Þ¤ï¤ê¤ÎÊɤ¬Êø¤ì¤¿¡ª");
+#else
+                       msg_print("Suddenly, surrounding walls are opened!");
+#endif
+                       (void)project(0, 3, y, x, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE, -1);
+                       (void)project(0, 3, y, x - 4, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE, -1);
+                       (void)project(0, 3, y, x + 4, 0, GF_DISINTEGRATE, PROJECT_GRID | PROJECT_HIDE, -1);
+                       aggravate_monsters(0);
+
+                       break;
+               }
+
+               case FEAT_TRAP_ARMAGEDDON:
+               {
+                       static int levs[10] = {0, 0, 20, 10, 5, 3, 2, 1, 1, 1};
+                       int evil_idx = 0, good_idx = 0;
+
+                       int lev;
+#ifdef JP
+                       msg_print("ÆÍÁ³Å·³¦¤ÎÀïÁè¤Ë´¬¤­¹þ¤Þ¤ì¤¿¡ª");
+#else
+                       msg_print("Suddenly, you are surrounded by immotal beings!");
+#endif
+
+                       /* Destroy this trap */
+                       cave_set_feat(y, x, floor_type[randint0(100)]);
+
+                       /* Summon Demons and Angels */
+                       for (lev = dun_level; lev >= 20; lev -= 1 + lev/16)
+                       {
+                               num = levs[MIN(lev/10, 9)];
+                               for (i = 0; i < num; i++)
+                               {
+                                       int x1 = rand_spread(x, 7);
+                                       int y1 = rand_spread(y, 5);
+
+                                       /* Skip illegal grids */
+                                       if (!in_bounds(y1, x1)) continue;
+
+                                       /* Require line of sight */
+                                       if (!player_has_los_bold(y1, x1)) continue;
+
+                                       if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_EVIL, (PM_NO_PET)))
+                                               evil_idx = hack_m_idx_ii;
+
+                                       if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_GOOD, (PM_NO_PET)))
+                                       {
+                                               good_idx = hack_m_idx_ii;
+                                       }
+
+                                       /* Let them fight each other */
+                                       if (evil_idx && good_idx)
+                                       {
+                                               monster_type *evil_ptr = &m_list[evil_idx];
+                                               monster_type *good_ptr = &m_list[good_idx];
+                                               evil_ptr->target_y = good_ptr->fy;
+                                               evil_ptr->target_x = good_ptr->fx;
+                                               good_ptr->target_y = evil_ptr->fy;
+                                               good_ptr->target_x = evil_ptr->fx;
+                                       }
+                               }
+                       }
+                       break;
+               }
+
+               case FEAT_TRAP_PIRANHA:
+               {
+#ifdef JP
+                       msg_print("ÆÍÁ³Êɤ«¤é¿å¤¬°î¤ì½Ð¤·¤¿¡ª¥Ô¥é¥Ë¥¢¤¬¤¤¤ë¡ª");
+#else
+                       msg_print("Suddenly, the room is filled with water with piranhas!");
+#endif
+
+                       /* Destroy this trap */
+                       cave_set_feat(y, x, floor_type[randint0(100)]);
+
+                       /* Water fills room */
+                       fire_ball_hide(GF_WATER_FLOW, 0, 1, 10);
+
+                       /* Summon Piranhas */
+                       num = 1 + dun_level/20;
+                       for (i = 0; i < num; i++)
+                       {
+                               (void)summon_specific(0, y, x, dun_level, SUMMON_PIRANHAS, (PM_ALLOW_GROUP | PM_NO_PET));
+                       }
+                       break;
+               }
        }
        if (break_trap && is_trap(c_ptr->feat))
        {
@@ -1629,7 +1725,7 @@ static void touch_zap_player(monster_type *m_ptr)
                        aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
 
                        /* Hack -- Get the "died from" name */
-                       monster_desc(aura_dam, m_ptr, 0x288);
+                       monster_desc(aura_dam, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
 
 #ifdef JP
                        msg_print("ÆÍÁ³¤È¤Æ¤âÇ®¤¯¤Ê¤Ã¤¿¡ª");
@@ -1638,11 +1734,12 @@ static void touch_zap_player(monster_type *m_ptr)
 #endif
 
 
-                       if (p_ptr->oppose_fire) aura_damage = (aura_damage + 2) / 3;
+                       if (prace_is_(RACE_ENT)) aura_damage += aura_damage / 3;
+                       if (IS_OPPOSE_FIRE()) aura_damage = (aura_damage + 2) / 3;
                        if (p_ptr->resist_fire) aura_damage = (aura_damage + 2) / 3;
 
                        take_hit(DAMAGE_NOESCAPE, aura_damage, aura_dam, -1);
-                       r_ptr->r_flags2 |= RF2_AURA_FIRE;
+                       if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags2 |= RF2_AURA_FIRE;
                        handle_stuff();
                }
        }
@@ -1656,7 +1753,7 @@ static void touch_zap_player(monster_type *m_ptr)
                        aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
 
                        /* Hack -- Get the "died from" name */
-                       monster_desc(aura_dam, m_ptr, 0x288);
+                       monster_desc(aura_dam, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
 
 #ifdef JP
                        msg_print("ÆÍÁ³¤È¤Æ¤â´¨¤¯¤Ê¤Ã¤¿¡ª");
@@ -1665,11 +1762,11 @@ static void touch_zap_player(monster_type *m_ptr)
 #endif
 
 
-                       if (p_ptr->oppose_cold) aura_damage = (aura_damage + 2) / 3;
+                       if (IS_OPPOSE_COLD()) aura_damage = (aura_damage + 2) / 3;
                        if (p_ptr->resist_cold) aura_damage = (aura_damage + 2) / 3;
 
                        take_hit(DAMAGE_NOESCAPE, aura_damage, aura_dam, -1);
-                       r_ptr->r_flags3 |= RF3_AURA_COLD;
+                       if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags3 |= RF3_AURA_COLD;
                        handle_stuff();
                }
        }
@@ -1683,9 +1780,10 @@ static void touch_zap_player(monster_type *m_ptr)
                        aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
 
                        /* Hack -- Get the "died from" name */
-                       monster_desc(aura_dam, m_ptr, 0x288);
+                       monster_desc(aura_dam, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
 
-                       if (p_ptr->oppose_elec) aura_damage = (aura_damage + 2) / 3;
+                       if (prace_is_(RACE_ANDROID)) aura_damage += aura_damage / 3;
+                       if (IS_OPPOSE_ELEC()) aura_damage = (aura_damage + 2) / 3;
                        if (p_ptr->resist_elec) aura_damage = (aura_damage + 2) / 3;
 
 #ifdef JP
@@ -1695,7 +1793,7 @@ static void touch_zap_player(monster_type *m_ptr)
 #endif
 
                        take_hit(DAMAGE_NOESCAPE, aura_damage, aura_dam, -1);
-                       r_ptr->r_flags2 |= RF2_AURA_ELEC;
+                       if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flags2 |= RF2_AURA_ELEC;
                        handle_stuff();
                }
        }
@@ -1833,7 +1931,7 @@ static void natural_attack(s16b m_idx, int attack, bool *fear, bool *mdeath)
                switch (attack)
                {
                        case MUT2_SCOR_TAIL:
-                               project(0, 0, m_ptr->fy, m_ptr->fx, k, GF_POIS, PROJECT_KILL | PROJECT_NO_REF, -1);
+                               project(0, 0, m_ptr->fy, m_ptr->fx, k, GF_POIS, PROJECT_KILL, -1);
                                *mdeath = (m_ptr->r_idx == 0);
                                break;
                        case MUT2_HORNS:
@@ -1922,7 +2020,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        /* Can't backstab creatures that we can't see, right? */
                        backstab = TRUE;
                }
-               else if ((p_ptr->special_defense & NINJA_S_STEALTH) && (randint0(tmp) > (r_ptr->level+20)) && m_ptr->ml && !(r_ptr->flags3 & RF3_RES_ALL))
+               else if ((p_ptr->special_defense & NINJA_S_STEALTH) && (randint0(tmp) > (r_ptr->level+20)) && m_ptr->ml && !(r_ptr->flagsr & RFR_RES_ALL))
                {
                        fuiuchi = TRUE;
                }
@@ -1938,14 +2036,14 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                {
                        if (p_ptr->skill_exp[GINOU_SUDE] < s_info[p_ptr->pclass].s_max[GINOU_SUDE])
                        {
-                               if (p_ptr->skill_exp[GINOU_SUDE] < 4000)
-                                       p_ptr->skill_exp[GINOU_SUDE]+=40;
-                               else if((p_ptr->skill_exp[GINOU_SUDE] < 6000))
-                                       p_ptr->skill_exp[GINOU_SUDE]+=5;
-                               else if((p_ptr->skill_exp[GINOU_SUDE] < 7000) && (p_ptr->lev > 19))
-                                       p_ptr->skill_exp[GINOU_SUDE]+=1;
-                               else if((p_ptr->skill_exp[GINOU_SUDE] < 8000) && (p_ptr->lev > 34))
-                                       if (one_in_(3)) p_ptr->skill_exp[GINOU_SUDE]+=1;
+                               if (p_ptr->skill_exp[GINOU_SUDE] < WEAPON_EXP_BEGINNER)
+                                       p_ptr->skill_exp[GINOU_SUDE] += 40;
+                               else if ((p_ptr->skill_exp[GINOU_SUDE] < WEAPON_EXP_SKILLED))
+                                       p_ptr->skill_exp[GINOU_SUDE] += 5;
+                               else if ((p_ptr->skill_exp[GINOU_SUDE] < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19))
+                                       p_ptr->skill_exp[GINOU_SUDE] += 1;
+                               else if ((p_ptr->lev > 34))
+                                       if (one_in_(3)) p_ptr->skill_exp[GINOU_SUDE] += 1;
                                p_ptr->update |= (PU_BONUS);
                        }
                }
@@ -1960,10 +2058,10 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        if (now_exp < s_info[p_ptr->pclass].w_max[tval][sval])
                        {
                                int amount = 0;
-                               if (now_exp < 4000) amount = 80;
-                               else if(now_exp < 6000) amount = 10;
-                               else if((now_exp < 7000) && (p_ptr->lev > 19)) amount = 1;
-                               else if((p_ptr->lev > 34) && one_in_(2)) amount = 1;
+                               if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
+                               else if (now_exp < WEAPON_EXP_SKILLED) amount = 10;
+                               else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 1;
+                               else if ((p_ptr->lev > 34) && one_in_(2)) amount = 1;
                                p_ptr->weapon_exp[tval][sval] += amount;
                                p_ptr->update |= (PU_BONUS);
                        }
@@ -1972,7 +2070,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
 
        /* Disturb the monster */
        m_ptr->csleep = 0;
-       if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2))
+       if (r_ptr->flags7 & RF7_HAS_LD_MASK)
                p_ptr->update |= (PU_MON_LITE);
 
        /* Extract monster name (or "it") */
@@ -2023,7 +2121,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        }
                        else success_hit = old_success_hit;
                }
-               else if ((p_ptr->pclass == CLASS_NINJA) && ((backstab || fuiuchi) && !(r_ptr->flags3 & RF3_RES_ALL))) success_hit = TRUE;
+               else if ((p_ptr->pclass == CLASS_NINJA) && ((backstab || fuiuchi) && !(r_ptr->flagsr & RFR_RES_ALL))) success_hit = TRUE;
                else success_hit = test_hit_norm(chance, r_ptr->ac, m_ptr->ml);
 
                /* Test for hit */
@@ -2290,16 +2388,8 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        /* Handle normal weapon */
                        else if (o_ptr->k_idx)
                        {
-                               k = damroll(o_ptr->dd, o_ptr->ds);
-                               if (p_ptr->riding)
-                               {
-                                       if((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
-                                       {
-                                               k += damroll(2, o_ptr->ds);
-                                       }
-                               }
-
-                               k = tot_dam_aux(o_ptr, k, m_ptr, mode);
+                               k = damroll(o_ptr->dd + p_ptr->to_dd[hand], o_ptr->ds + p_ptr->to_ds[hand]);
+                               k = tot_dam_aux(o_ptr, k, m_ptr, mode, FALSE);
 
                                if (backstab)
                                {
@@ -2346,7 +2436,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        if (o_ptr->name1 == ART_VORPAL_BLADE)
                                        {
 #ifdef JP
-                                               msg_print("Ìܤˤâ»ß¤Þ¤é¤Ì¥Ü¡¼¥Ñ¥ë¡¦¥Ö¥ì¡¼¥É¡¢¼êÏ£¤ÎÁá¶È¡ª");
+                                               msg_print("Ìܤˤâ»ß¤Þ¤é¤Ì¥ô¥©¡¼¥Ñ¥ë¥Ö¥ì¡¼¥É¡¢¼êÏ£¤ÎÁá¶È¡ª");
 #else
                                                msg_print("Your Vorpal Blade goes snicker-snack!");
 #endif
@@ -2371,7 +2461,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        k *= mult;
 
                                        /* Ouch! */
-                                       if (((r_ptr->flags3 & RF3_RES_ALL) ? k/100 : k) > m_ptr->hp)
+                                       if (((r_ptr->flagsr & RFR_RES_ALL) ? k/100 : k) > m_ptr->hp)
                                        {
 #ifdef JP
                                                msg_format("%s¤ò¿¿¤ÃÆó¤Ä¤Ë¤·¤¿¡ª", m_name);
@@ -2440,13 +2530,13 @@ default:        msg_format("%s
                        drain_result += p_ptr->to_d[hand];
 
                        if ((mode == HISSATSU_SUTEMI) || (mode == HISSATSU_3DAN)) k *= 2;
-                       if ((mode == HISSATSU_SEKIRYUKA) && (r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON | RF3_NONLIVING))) k = 0;
+                       if ((mode == HISSATSU_SEKIRYUKA) && !monster_living(r_ptr)) k = 0;
                        if ((mode == HISSATSU_SEKIRYUKA) && !p_ptr->cut) k /= 2;
 
                        /* No negative damage */
                        if (k < 0) k = 0;
 
-                       if ((mode == HISSATSU_ZANMA) && !((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) && (r_ptr->flags3 & RF3_EVIL)))
+                       if ((mode == HISSATSU_ZANMA) && !(!monster_living(r_ptr) && (r_ptr->flags3 & RF3_EVIL)))
                        {
                                k = 0;
                        }
@@ -2579,7 +2669,7 @@ msg_format("
                        if (k <= 0) can_drain = FALSE;
 
                        if (drain_result > m_ptr->hp)
-                               drain_result = m_ptr->hp;
+                               drain_result = m_ptr->hp;
 
                        /* Damage, check for fear and death */
                        if (mon_take_hit(c_ptr->m_idx, k, fear, NULL))
@@ -2716,7 +2806,7 @@ msg_format("
                                /* Confuse the monster */
                                if (r_ptr->flags3 & RF3_NO_CONF)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
                                                r_ptr->r_flags3 |= RF3_NO_CONF;
                                        }
@@ -2753,13 +2843,13 @@ msg_format("
                        {
                                bool resists_tele = FALSE;
 
-                               if (r_ptr->flags3 & RF3_RES_TELE)
+                               if (r_ptr->flagsr & RFR_RES_TELE)
                                {
                                        if (r_ptr->flags1 & RF1_UNIQUE)
                                        {
-                                               if (m_ptr->ml) r_ptr->r_flags3 |= RF3_RES_TELE;
+                                               if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
-                                               msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
+                                               msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
 #else
                                                msg_format("%^s is unaffected!", m_name);
 #endif
@@ -2768,7 +2858,7 @@ msg_format("
                                        }
                                        else if (r_ptr->level > randint1(100))
                                        {
-                                               if (m_ptr->ml) r_ptr->r_flags3 |= RF3_RES_TELE;
+                                               if (m_ptr->ml && is_original_ap(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
                                                msg_format("%^s¤ÏÄñ¹³ÎϤò»ý¤Ã¤Æ¤¤¤ë¡ª", m_name);
 #else
@@ -2788,17 +2878,16 @@ msg_format("
 #endif
 
                                        teleport_away(c_ptr->m_idx, 50, FALSE);
-                                       num = p_ptr->num_blow[hand] + 1; /* Can't hit it anymore! */
+                                       num = num_blow + 1; /* Can't hit it anymore! */
                                        *mdeath = TRUE;
                                }
                        }
 
                        else if ((chaos_effect == 5) && cave_floor_bold(y, x) &&
-                                (randint1(90) > r_ptr->level))
+                                (randint1(90) > r_ptr->level))
                        {
-                               if (!(r_ptr->flags1 & RF1_UNIQUE) &&
-                                   !(r_ptr->flags4 & RF4_BR_CHAO) &&
-                                   !(r_ptr->flags1 & RF1_QUESTOR))
+                               if (!(r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) &&
+                                   !(r_ptr->flagsr & RFR_EFF_RES_CHAO_MASK))
                                {
                                        if (polymorph_monster(y, x))
                                        {
@@ -2824,7 +2913,7 @@ msg_format("
                                        else
                                        {
 #ifdef JP
-                                       msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
+                                               msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
 #else
                                                msg_format("%^s is unaffected.", m_name);
 #endif
@@ -2843,7 +2932,7 @@ msg_format("
 
                                        object_desc(o_name, q_ptr, TRUE, 0);
                                        q_ptr->held_m_idx = 0;
-                                       q_ptr->marked = FALSE;
+                                       q_ptr->marked = 0;
                                        m_ptr->hold_o_idx = q_ptr->next_o_idx;
                                        q_ptr->next_o_idx = 0;
 #ifdef JP
@@ -2895,7 +2984,6 @@ msg_format("
                                                {
                                                        case RACE_YEEK:
                                                        case RACE_KLACKON:
-                                                               mult = 20;break;
                                                        case RACE_HUMAN:
                                                        case RACE_AMBERITE:
                                                        case RACE_DUNADAN:
@@ -2907,17 +2995,15 @@ msg_format("
                                                        case RACE_HALF_TITAN:
                                                        case RACE_CYCLOPS:
                                                        case RACE_IMP:
-                                                       case RACE_GOLEM:
                                                        case RACE_SKELETON:
                                                        case RACE_ZOMBIE:
                                                        case RACE_VAMPIRE:
                                                        case RACE_SPECTRE:
                                                        case RACE_DEMON:
-                                                               mult = 30;break;
                                                        case RACE_DRACONIAN:
-                                                               mult = 50;break;
+                                                               mult = 30;break;
                                                        default:
-                                                               mult = 1;break;
+                                                               mult = 10;break;
                                                }
                                                break;
                                        case MIMIC_DEMON:
@@ -2930,22 +3016,22 @@ msg_format("
 
                                        if (p_ptr->align < 0 && mult < 20)
                                                mult = 20;
-                                       if (!(p_ptr->resist_acid || p_ptr->oppose_acid) && (mult < 25))
+                                       if (!(p_ptr->resist_acid || IS_OPPOSE_ACID() || p_ptr->immune_acid) && (mult < 25))
                                                mult = 25;
-                                       if (!(p_ptr->resist_elec || p_ptr->oppose_elec) && (mult < 25))
+                                       if (!(p_ptr->resist_elec || IS_OPPOSE_ELEC() || p_ptr->immune_elec) && (mult < 25))
                                                mult = 25;
-                                       if (!(p_ptr->resist_fire || p_ptr->oppose_fire) && (mult < 25))
+                                       if (!(p_ptr->resist_fire || IS_OPPOSE_FIRE() || p_ptr->immune_fire) && (mult < 25))
                                                mult = 25;
-                                       if (!(p_ptr->resist_cold || p_ptr->oppose_cold) && (mult < 25))
+                                       if (!(p_ptr->resist_cold || IS_OPPOSE_COLD() || p_ptr->immune_cold) && (mult < 25))
                                                mult = 25;
-                                       if (!(p_ptr->resist_pois || p_ptr->oppose_pois) && (mult < 25))
+                                       if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()) && (mult < 25))
                                                mult = 25;
 
                                        if ((p_ptr->pclass != CLASS_SAMURAI) && (have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
                                        {
                                                p_ptr->csp -= (1+(p_ptr->msp / 30));
                                                p_ptr->redraw |= (PR_MANA);
-                                               mult = mult * 35;
+                                               mult = mult * 3 / 2 + 20;
                                        }
                                        k *= mult;
                                        k /= 10;
@@ -2970,6 +3056,8 @@ msg_format("
                                }
                                k += (p_ptr->to_d[hand] + o_ptr->to_d);
 
+                               if (k < 0) k = 0;
+
 #ifdef JP
                                take_hit(DAMAGE_FORCE, k, "»à¤ÎÂç³ù", -1);
 #else
@@ -3148,30 +3236,46 @@ bool py_attack(int y, int x, int mode)
        {
                if ((p_ptr->skill_exp[GINOU_NITOURYU] < s_info[p_ptr->pclass].s_max[GINOU_NITOURYU]) && ((p_ptr->skill_exp[GINOU_NITOURYU] - 1000) / 200 < r_info[m_ptr->r_idx].level))
                {
-                       if (p_ptr->skill_exp[GINOU_NITOURYU] < 4000)
-                               p_ptr->skill_exp[GINOU_NITOURYU]+=80;
-                       else if(p_ptr->skill_exp[GINOU_NITOURYU] < 6000)
-                               p_ptr->skill_exp[GINOU_NITOURYU]+=4;
-                       else if(p_ptr->skill_exp[GINOU_NITOURYU] < 7000)
-                               p_ptr->skill_exp[GINOU_NITOURYU]+=1;
-                       else if(p_ptr->skill_exp[GINOU_NITOURYU] < 8000)
-                               if (one_in_(3)) p_ptr->skill_exp[GINOU_NITOURYU]+=1;
+                       if (p_ptr->skill_exp[GINOU_NITOURYU] < WEAPON_EXP_BEGINNER)
+                               p_ptr->skill_exp[GINOU_NITOURYU] += 80;
+                       else if(p_ptr->skill_exp[GINOU_NITOURYU] < WEAPON_EXP_SKILLED)
+                               p_ptr->skill_exp[GINOU_NITOURYU] += 4;
+                       else if(p_ptr->skill_exp[GINOU_NITOURYU] < WEAPON_EXP_EXPERT)
+                               p_ptr->skill_exp[GINOU_NITOURYU] += 1;
+                       else if(p_ptr->skill_exp[GINOU_NITOURYU] < WEAPON_EXP_MASTER)
+                               if (one_in_(3)) p_ptr->skill_exp[GINOU_NITOURYU] += 1;
                        p_ptr->update |= (PU_BONUS);
                }
        }
 
+       /* Gain riding experience */
        if (p_ptr->riding)
        {
-               int ridinglevel = r_info[m_list[p_ptr->riding].r_idx].level;
-               if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING]) && ((p_ptr->skill_exp[GINOU_RIDING] - 1000) / 200 < r_info[m_ptr->r_idx].level) && (p_ptr->skill_exp[GINOU_RIDING]/100 - 2000 < ridinglevel))
-                       p_ptr->skill_exp[GINOU_RIDING]++;
-               if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING]) && (p_ptr->skill_exp[GINOU_RIDING]/100 < ridinglevel))
+               int cur = p_ptr->skill_exp[GINOU_RIDING];
+               int max = s_info[p_ptr->pclass].s_max[GINOU_RIDING];
+
+               if (cur < max)
                {
-                       if (ridinglevel*100 > (p_ptr->skill_exp[GINOU_RIDING] + 1500))
-                               p_ptr->skill_exp[GINOU_RIDING] += (1+(ridinglevel - p_ptr->skill_exp[GINOU_RIDING]/100 - 15));
-                       else p_ptr->skill_exp[GINOU_RIDING]++;
+                       int ridinglevel = r_info[m_list[p_ptr->riding].r_idx].level;
+                       int targetlevel = r_info[m_ptr->r_idx].level;
+                       int inc = 0;
+
+                       if ((cur / 200 - 5) < targetlevel)
+                               inc += 1;
+
+                       /* Extra experience */
+                       if ((cur / 100) < ridinglevel)
+                       {
+                               if ((cur / 100 + 15) < ridinglevel)
+                                       inc += 1 + (ridinglevel - (cur / 100 + 15));
+                               else
+                                       inc += 1;
+                       }
+
+                       p_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
+
+                       p_ptr->update |= (PU_BONUS);
                }
-               p_ptr->update |= (PU_BONUS);
        }
 
        riding_t_m_idx = c_ptr->m_idx;
@@ -3241,8 +3345,8 @@ static bool pattern_seq(int c_y, int c_x, int n_y, int n_x)
                        return TRUE;
        }
        else if ((cave[n_y][n_x].feat == FEAT_PATTERN_OLD) ||
-                (cave[n_y][n_x].feat == FEAT_PATTERN_END) ||
-                (cave[n_y][n_x].feat == FEAT_PATTERN_XTRA2))
+                (cave[n_y][n_x].feat == FEAT_PATTERN_END) ||
+                (cave[n_y][n_x].feat == FEAT_PATTERN_XTRA2))
        {
                if (pattern_tile(c_y, c_x))
                {
@@ -3260,7 +3364,7 @@ static bool pattern_seq(int c_y, int c_x, int n_y, int n_x)
                }
        }
        else if ((cave[n_y][n_x].feat == FEAT_PATTERN_XTRA1) ||
-                (cave[c_y][c_x].feat == FEAT_PATTERN_XTRA1))
+                (cave[c_y][c_x].feat == FEAT_PATTERN_XTRA1))
        {
                return TRUE;
        }
@@ -3280,8 +3384,8 @@ static bool pattern_seq(int c_y, int c_x, int n_y, int n_x)
                }
        }
        else if ((cave[c_y][c_x].feat == FEAT_PATTERN_OLD) ||
-                (cave[c_y][c_x].feat == FEAT_PATTERN_END) ||
-                (cave[c_y][c_x].feat == FEAT_PATTERN_XTRA2))
+                (cave[c_y][c_x].feat == FEAT_PATTERN_END) ||
+                (cave[c_y][c_x].feat == FEAT_PATTERN_XTRA2))
        {
                if (!pattern_tile(n_y, n_x))
                {
@@ -3330,9 +3434,9 @@ static bool pattern_seq(int c_y, int c_x, int n_y, int n_x)
                                default:
                                        if (p_ptr->wizard)
 #ifdef JP
-                                               msg_format("¤ª¤«¤·¤Ê¥Ñ¥¿¡¼¥óÊâ¹Ô¡¢%d¡£", cave[c_y][c_x]);
+                                               msg_format("¤ª¤«¤·¤Ê¥Ñ¥¿¡¼¥óÊâ¹Ô¡¢%d¡£", cave[c_y][c_x].feat);
 #else
-                                               msg_format("Funny Pattern walking, %d.", cave[c_y][c_x]);
+                                               msg_format("Funny Pattern walking, %d.", cave[c_y][c_x].feat);
 #endif
 
                                        return TRUE; /* Goof-up */
@@ -3368,63 +3472,63 @@ static bool pattern_seq(int c_y, int c_x, int n_y, int n_x)
 
 bool player_can_enter(byte feature)
 {
-       bool pass_wall;
-
-       /* Player can not walk through "walls" unless in Shadow Form */
-       if (p_ptr->wraith_form || p_ptr->pass_wall || p_ptr->kabenuke)
-               pass_wall = TRUE;
-       else
-               pass_wall = FALSE;
-
        switch (feature)
        {
-               case FEAT_DEEP_WATER:
-               case FEAT_SHAL_LAVA:
-               case FEAT_DEEP_LAVA:
-                       return (TRUE);
-
-               case FEAT_DARK_PIT:
-               {
-                       if (p_ptr->ffall)
-                               return (TRUE);
-                       else
-                               return (FALSE);
-               }
-
-               case FEAT_TREES:
-               {
-                       return (TRUE);
-               }
+       case FEAT_DOOR_HEAD: /* Nasty hack -- Doors */
+       case FEAT_DOOR_HEAD + 0x01:
+       case FEAT_DOOR_HEAD + 0x02:
+       case FEAT_DOOR_HEAD + 0x03:
+       case FEAT_DOOR_HEAD + 0x04:
+       case FEAT_DOOR_HEAD + 0x05:
+       case FEAT_DOOR_HEAD + 0x06:
+       case FEAT_DOOR_HEAD + 0x07:
+       case FEAT_DOOR_HEAD + 0x08:
+       case FEAT_DOOR_HEAD + 0x09:
+       case FEAT_DOOR_HEAD + 0x0a:
+       case FEAT_DOOR_HEAD + 0x0b:
+       case FEAT_DOOR_HEAD + 0x0c:
+       case FEAT_DOOR_HEAD + 0x0d:
+       case FEAT_DOOR_HEAD + 0x0e:
+       case FEAT_DOOR_TAIL: /* Equals FEAT_DOOR_HEAD + 0x0f */
+       case FEAT_SECRET:
+       case FEAT_RUBBLE:
+       case FEAT_MAGMA:
+       case FEAT_QUARTZ:
+       case FEAT_MAGMA_H:
+       case FEAT_QUARTZ_H:
+       case FEAT_MAGMA_K:
+       case FEAT_QUARTZ_K:
+       case FEAT_WALL_EXTRA:
+       case FEAT_WALL_INNER:
+       case FEAT_WALL_OUTER:
+       case FEAT_WALL_SOLID:
+               /* Player can not walk through "walls" unless in Shadow Form */
+               return p_ptr->wraith_form || p_ptr->pass_wall || p_ptr->kabenuke;
+
+       case FEAT_PERM_EXTRA:
+       case FEAT_PERM_INNER:
+       case FEAT_PERM_OUTER:
+       case FEAT_PERM_SOLID:
+       case FEAT_PATTERN_START:
+       case FEAT_PATTERN_1:
+       case FEAT_PATTERN_2:
+       case FEAT_PATTERN_3:
+       case FEAT_PATTERN_4:
+       case FEAT_PATTERN_END:
+       case FEAT_PATTERN_OLD:
+       case FEAT_PATTERN_XTRA1:
+       case FEAT_PATTERN_XTRA2:
+               return FALSE;
 
-               case FEAT_RUBBLE:
-               case FEAT_MAGMA:
-               case FEAT_QUARTZ:
-               case FEAT_MAGMA_H:
-               case FEAT_QUARTZ_H:
-               case FEAT_MAGMA_K:
-               case FEAT_QUARTZ_K:
-               case FEAT_WALL_EXTRA:
-               case FEAT_WALL_INNER:
-               case FEAT_WALL_OUTER:
-               case FEAT_WALL_SOLID:
-               {
-                       return (pass_wall);
-               }
+       case FEAT_DARK_PIT:
+               return p_ptr->ffall;
 
-               case FEAT_MOUNTAIN:
-               {
-                       return (!dun_level && p_ptr->ffall);
-               }
-               case FEAT_PERM_EXTRA:
-               case FEAT_PERM_INNER:
-               case FEAT_PERM_OUTER:
-               case FEAT_PERM_SOLID:
-               {
-                       return (FALSE);
-               }
+       case FEAT_MOUNTAIN:
+               return !dun_level && p_ptr->ffall;
        }
 
-       return (TRUE);
+       /* Assume okay */
+       return TRUE;
 }
 
 
@@ -3459,7 +3563,6 @@ void move_player(int dir, int do_pickup, bool break_trap)
        /* Examine the destination */
        c_ptr = &cave[y][x];
 
-
        /* Exit the area */
        if (!dun_level && !p_ptr->wild_mode &&
                ((x == 0) || (x == MAX_WID - 1) ||
@@ -3475,7 +3578,7 @@ void move_player(int dir, int do_pickup, bool break_trap)
                                p_ptr->wilderness_x--;
                                p_ptr->oldpy = cur_hgt - 2;
                                p_ptr->oldpx = cur_wid - 2;
-                                ambush_flag = FALSE;
+                               ambush_flag = FALSE;
                        }
 
                        else if ((y == 0) && (x == MAX_WID - 1))
@@ -3484,7 +3587,7 @@ void move_player(int dir, int do_pickup, bool break_trap)
                                p_ptr->wilderness_x++;
                                p_ptr->oldpy = cur_hgt - 2;
                                p_ptr->oldpx = 1;
-                                ambush_flag = FALSE;
+                               ambush_flag = FALSE;
                        }
 
                        else if ((y == MAX_HGT - 1) && (x == 0))
@@ -3493,7 +3596,7 @@ void move_player(int dir, int do_pickup, bool break_trap)
                                p_ptr->wilderness_x--;
                                p_ptr->oldpy = 1;
                                p_ptr->oldpx = cur_wid - 2;
-                                ambush_flag = FALSE;
+                               ambush_flag = FALSE;
                        }
 
                        else if ((y == MAX_HGT - 1) && (x == MAX_WID - 1))
@@ -3502,7 +3605,7 @@ void move_player(int dir, int do_pickup, bool break_trap)
                                p_ptr->wilderness_x++;
                                p_ptr->oldpy = 1;
                                p_ptr->oldpx = 1;
-                                ambush_flag = FALSE;
+                               ambush_flag = FALSE;
                        }
 
                        else if (y == 0)
@@ -3510,7 +3613,7 @@ void move_player(int dir, int do_pickup, bool break_trap)
                                p_ptr->wilderness_y--;
                                p_ptr->oldpy = cur_hgt - 2;
                                p_ptr->oldpx = x;
-                                ambush_flag = FALSE;
+                               ambush_flag = FALSE;
                        }
 
                        else if (y == MAX_HGT - 1)
@@ -3518,7 +3621,7 @@ void move_player(int dir, int do_pickup, bool break_trap)
                                p_ptr->wilderness_y++;
                                p_ptr->oldpy = 1;
                                p_ptr->oldpx = x;
-                                ambush_flag = FALSE;
+                               ambush_flag = FALSE;
                        }
 
                        else if (x == 0)
@@ -3526,7 +3629,7 @@ void move_player(int dir, int do_pickup, bool break_trap)
                                p_ptr->wilderness_x--;
                                p_ptr->oldpx = cur_wid - 2;
                                p_ptr->oldpy = y;
-                                ambush_flag = FALSE;
+                               ambush_flag = FALSE;
                        }
 
                        else if (x == MAX_WID - 1)
@@ -3534,7 +3637,7 @@ void move_player(int dir, int do_pickup, bool break_trap)
                                p_ptr->wilderness_x++;
                                p_ptr->oldpx = 1;
                                p_ptr->oldpy = y;
-                                ambush_flag = FALSE;
+                               ambush_flag = FALSE;
                        }
 
                        p_ptr->leftbldg = TRUE;
@@ -3677,7 +3780,7 @@ void move_player(int dir, int do_pickup, bool break_trap)
 #ifdef ALLOW_EASY_DISARM /* TNB */
 
        /* Disarm a visible trap */
-       else if ((do_pickup != easy_disarm) && is_trap(c_ptr->feat))
+       else if ((do_pickup != easy_disarm) && is_known_trap(c_ptr))
        {
                bool ignore = FALSE;
                switch (c_ptr->feat)
@@ -3790,7 +3893,7 @@ msg_format("%s
                disturb(0, 0);
        }
 
-       else if ((p_ptr->riding && !(r_info[m_list[p_ptr->riding].r_idx].flags7 & (RF7_CAN_FLY)) && !(r_info[m_list[p_ptr->riding].r_idx].flags3 & (RF3_IM_FIRE))) && ((c_ptr->feat == FEAT_SHAL_LAVA) || (c_ptr->feat == FEAT_DEEP_LAVA)))
+       else if ((p_ptr->riding && !(r_info[m_list[p_ptr->riding].r_idx].flags7 & (RF7_CAN_FLY)) && !(r_info[m_list[p_ptr->riding].r_idx].flagsr & RFR_EFF_IM_FIRE_MASK)) && ((c_ptr->feat == FEAT_SHAL_LAVA) || (c_ptr->feat == FEAT_DEEP_LAVA)))
        {
 #ifdef JP
                msg_print("ÍÏ´ä¤Î¾å¤Ë¹Ô¤±¤Ê¤¤¡£");
@@ -3819,8 +3922,13 @@ msg_format("%s
        else if ((!cave_floor_bold(y, x)) &&
                (!p_can_pass_walls))
        {
+               byte feat;
+
                oktomove = FALSE;
 
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? f_info[c_ptr->mimic].mimic : f_info[c_ptr->feat].mimic;
+
                /* Disturb the player */
                disturb(0, 0);
 
@@ -3829,10 +3937,10 @@ msg_format("%s
                    (p_ptr->blind || !(c_ptr->info & (CAVE_LITE))))
                {
                        /* Rubble */
-                       if (c_ptr->feat == FEAT_RUBBLE)
+                       if (feat == FEAT_RUBBLE)
                        {
 #ifdef JP
-                                msg_print("´äÀФ¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¤è¤¦¤À¡£");
+                               msg_print("´äÀФ¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¤è¤¦¤À¡£");
 #else
                                msg_print("You feel some rubble blocking your way.");
 #endif
@@ -3842,10 +3950,10 @@ msg_format("%s
                        }
 
                        /* Closed door */
-                       else if (c_ptr->feat < FEAT_SECRET)
+                       else if (is_closed_door(feat))
                        {
 #ifdef JP
-                                msg_print("¥É¥¢¤¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¤è¤¦¤À¡£");
+                               msg_print("¥É¥¢¤¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¤è¤¦¤À¡£");
 #else
                                msg_print("You feel a closed door blocking your way.");
 #endif
@@ -3854,13 +3962,23 @@ msg_format("%s
                                lite_spot(y, x);
                        }
 
+                       /* Boundary floor mimic */
+                       else if (boundary_floor_grid(c_ptr))
+                       {
+#ifdef JP
+                               msg_print("¤½¤ì°Ê¾åÀè¤Ë¤Ï¿Ê¤á¤Ê¤¤¤è¤¦¤À¡£");
+#else
+                               msg_print("You feel you cannot go any more.");
+#endif
+                       }
+
                        /* Wall (or secret door) */
                        else
                        {
 #ifdef JP
-                               msg_print("Êɤ¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¤è¤¦¤À¡£");
+                               msg_format("%s¤¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¤è¤¦¤À¡£", (feat == FEAT_TREES) ? "ÌÚ" : "ÊÉ");
 #else
-                               msg_print("You feel a wall blocking your way.");
+                               msg_format("You feel a %s blocking your way.", (feat == FEAT_TREES) ? "tree" : "wall");
 #endif
 
                                c_ptr->info |= (CAVE_MARK);
@@ -3872,7 +3990,7 @@ msg_format("%s
                else
                {
                        /* Rubble */
-                       if (c_ptr->feat == FEAT_RUBBLE)
+                       if (feat == FEAT_RUBBLE)
                        {
 #ifdef JP
                                msg_print("´äÀФ¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¡£");
@@ -3880,7 +3998,6 @@ msg_format("%s
                                msg_print("There is rubble blocking your way.");
 #endif
 
-
                                if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
                                        energy_use = 0;
 
@@ -3891,7 +4008,7 @@ msg_format("%s
                                 */
                        }
                        /* Closed doors */
-                       else if (c_ptr->feat < FEAT_SECRET)
+                       else if (is_closed_door(feat))
                        {
 #ifdef ALLOW_EASY_OPEN
 
@@ -3905,6 +4022,18 @@ msg_format("%s
                                msg_print("There is a closed door blocking your way.");
 #endif
 
+                               if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
+                                       energy_use = 0;
+                       }
+
+                       /* Boundary floor mimic */
+                       else if (boundary_floor_grid(c_ptr))
+                       {
+#ifdef JP
+                               msg_print("¤½¤ì°Ê¾åÀè¤Ë¤Ï¿Ê¤á¤Ê¤¤¡£");
+#else
+                               msg_print("You cannot go any more.");
+#endif
 
                                if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
                                        energy_use = 0;
@@ -3914,19 +4043,18 @@ msg_format("%s
                        else
                        {
 #ifdef JP
-                               msg_print("Êɤ¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¡£");
+                               msg_format("%s¤¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¡£", (feat == FEAT_TREES) ? "ÌÚ" : "ÊÉ");
 #else
-                               msg_print("There is a wall blocking your way.");
+                               msg_format("There is a %s blocking your way.", (feat == FEAT_TREES) ? "tree" : "wall");
 #endif
 
-
                                if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
                                        energy_use = 0;
                        }
                }
 
                /* Sound */
-               sound(SOUND_HITWALL);
+               if (!boundary_floor_grid(c_ptr)) sound(SOUND_HITWALL);
        }
 
        /* Normal movement */
@@ -3950,7 +4078,7 @@ msg_format("%s
 
                if (p_ptr->warning)
                {
-                       if(!process_frakir(x,y))
+                       if(!process_warning(x, y))
                        {
                                energy_use = 25;
                                return;
@@ -3993,7 +4121,7 @@ msg_format("%s
 
                if (p_ptr->riding && (r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_KILL_WALL))
                {
-                       if (cave[py][px].feat > FEAT_SECRET && cave[py][px].feat < FEAT_PERM_SOLID)
+                       if (cave[py][px].feat >= FEAT_RUBBLE && cave[py][px].feat < FEAT_PERM_SOLID)
                        {
                                /* Forget the wall */
                                cave[py][px].info &= ~(CAVE_MARK);
@@ -4018,14 +4146,15 @@ msg_format("%s
                                if (cave[py][px].feat == FEAT_TREES)
                                        cave_set_feat(py, px, FEAT_GRASS);
                                else
-                               {
-                                       cave[py][px].feat = floor_type[randint0(100)];
-                               }
+                                       cave_set_feat(py, px, floor_type[randint0(100)]);
                        }
                                /* Update some things -- similar to GF_KILL_WALL */
                        p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
                }
 
+               /* Remove "unsafe" flag */
+               if ((!p_ptr->blind && !no_lite()) || !is_trap(c_ptr->feat)) c_ptr->info &= ~(CAVE_UNSAFE);
+
                /* Redraw new spot */
                lite_spot(py, px);
 
@@ -4038,11 +4167,11 @@ msg_format("%s
                /* Check for new panel (redraw map) */
                verify_panel();
 
-                /* For get everything when requested hehe I'm *NASTY* */
-                if (dun_level && (d_info[dungeon_type].flags1 & DF1_FORGET))
-                {
-                        wiz_dark();
-                }
+               /* For get everything when requested hehe I'm *NASTY* */
+               if (dun_level && (d_info[dungeon_type].flags1 & DF1_FORGET))
+               {
+                       wiz_dark();
+               }
 
                if ((p_ptr->pclass == CLASS_NINJA))
                {
@@ -4154,32 +4283,25 @@ msg_format("%s
                        p_ptr->leaving = TRUE;
                }
 
-               /* Discover invisible traps */
-               else if (c_ptr->info & CAVE_TRAP)
+               /* Set off a trap */
+               else if (is_trap(c_ptr->feat))
                {
                        /* Disturb */
                        disturb(0, 0);
 
-                       /* Message */
+                       /* Hidden trap */
+                       if (c_ptr->mimic)
+                       {
+                               /* Message */
 #ifdef JP
-                       msg_print("¥È¥é¥Ã¥×¤À¡ª");
+                               msg_print("¥È¥é¥Ã¥×¤À¡ª");
 #else
-                       msg_print("You found a trap!");
+                               msg_print("You found a trap!");
 #endif
 
-
-                       /* Pick a trap */
-                       pick_trap(py, px);
-
-                       /* Hit the trap */
-                       hit_trap(break_trap);
-               }
-
-               /* Set off an visible trap */
-               else if (is_trap(c_ptr->feat))
-               {
-                       /* Disturb */
-                       disturb(0, 0);
+                               /* Pick a trap */
+                               disclose_grid(py, px);
+                       }
 
                        /* Hit the trap */
                        hit_trap(break_trap);
@@ -4228,6 +4350,9 @@ msg_format("%s
  */
 static int see_wall(int dir, int y, int x)
 {
+       cave_type   *c_ptr;
+       byte feat;
+
        /* Get the new location */
        y += ddy[dir];
        x += ddx[dir];
@@ -4235,32 +4360,26 @@ static int see_wall(int dir, int y, int x)
        /* Illegal grids are not known walls */
        if (!in_bounds2(y, x)) return (FALSE);
 
-       /* Non-wall grids are not known walls */
-       if (cave[y][x].feat < FEAT_SECRET) return (FALSE);
-
-       if ((cave[y][x].feat >= FEAT_DEEP_WATER) &&
-           (cave[y][x].feat <= FEAT_GRASS)) return (FALSE);
-
-       if ((cave[y][x].feat >= FEAT_SHOP_HEAD) &&
-           (cave[y][x].feat <= FEAT_SHOP_TAIL)) return (FALSE);
-
-       if (cave[y][x].feat == FEAT_DEEP_GRASS) return (FALSE);
-       if (cave[y][x].feat == FEAT_FLOWER) return (FALSE);
-
-       if (cave[y][x].feat == FEAT_MUSEUM) return (FALSE);
-
-       if ((cave[y][x].feat >= FEAT_BLDG_HEAD) &&
-           (cave[y][x].feat <= FEAT_BLDG_TAIL)) return (FALSE);
+       /* Access grid */
+       c_ptr = &cave[y][x];
 
-/*     if (cave[y][x].feat == FEAT_TREES) return (FALSE); */
+       /* Feature code (applying "mimic" field) */
+       feat = c_ptr->mimic ? f_info[c_ptr->mimic].mimic : f_info[c_ptr->feat].mimic;
 
        /* Must be known to the player */
-       if (!(cave[y][x].info & (CAVE_MARK))) return (FALSE);
+       if (c_ptr->info & (CAVE_MARK))
+       {
+               /* Rubble, Magma, Quartz, Wall, Perm wall */
+               if (feat >= FEAT_RUBBLE && feat <= FEAT_PERM_SOLID) return TRUE;
 
-       if (cave[y][x].feat >= FEAT_TOWN) return (FALSE);
+               /* Tree */
+               if (feat == FEAT_TREES) return TRUE;
 
-       /* Default */
-       return (TRUE);
+               /* Mountain */
+               if (feat == FEAT_MOUNTAIN) return TRUE;
+       }
+
+       return FALSE;
 }
 
 
@@ -4577,6 +4696,7 @@ static bool run_test(void)
        int         i, max, inv;
        int         option = 0, option2 = 0;
        cave_type   *c_ptr;
+       byte feat;
 
        /* Where we came from */
        prev_dir = find_prevdir;
@@ -4628,6 +4748,8 @@ static bool run_test(void)
                /* Access grid */
                c_ptr = &cave[row][col];
 
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? f_info[c_ptr->mimic].mimic : f_info[c_ptr->feat].mimic;
 
                /* Visible monsters abort running */
                if (c_ptr->m_idx)
@@ -4663,7 +4785,7 @@ static bool run_test(void)
                        bool notice = TRUE;
 
                        /* Examine the terrain */
-                       switch (c_ptr->feat)
+                       switch (feat)
                        {
                                /* Floors */
                                case FEAT_FLOOR:
@@ -4671,9 +4793,6 @@ static bool run_test(void)
                                /* Invis traps */
                                case FEAT_INVIS:
 
-                               /* Secret doors */
-                               case FEAT_SECRET:
-
                                /* Normal veins */
                                case FEAT_MAGMA:
                                case FEAT_QUARTZ:
@@ -4728,7 +4847,7 @@ static bool run_test(void)
                                case FEAT_SHAL_LAVA:
                                {
                                        /* Ignore */
-                                       if (p_ptr->invuln || p_ptr->immune_fire) notice = FALSE;
+                                       if (IS_INVULN() || p_ptr->immune_fire) notice = FALSE;
 
                                        /* Done */
                                        break;
@@ -4776,10 +4895,8 @@ static bool run_test(void)
                        inv = FALSE;
                }
 
-               /* Analyze unknown grids and floors */
-/*             if (inv || cave_floor_bold(row, col) || */
-/*                 (cave[row][col].feat == FEAT_TREES)) */
-               if (inv || cave_floor_bold(row, col))
+               /* Analyze unknown grids and floors considering mimic */
+               if (inv || feat_floor(feat))
                {
                        /* Looking for open area */
                        if (find_openarea)
@@ -4856,13 +4973,16 @@ static bool run_test(void)
                        /* Access grid */
                        c_ptr = &cave[row][col];
 
+                       /* Feature code (applying "mimic" field) */
+                       feat = c_ptr->mimic ? f_info[c_ptr->mimic].mimic : f_info[c_ptr->feat].mimic;
+
                        /* Unknown grid or non-wall XXX XXX XXX cave_floor_grid(c_ptr)) */
                        if (!(c_ptr->info & (CAVE_MARK)) ||
-                           ((c_ptr->feat < FEAT_SECRET) ||
-                            (c_ptr->feat == FEAT_FLOWER) ||
-                            (c_ptr->feat == FEAT_DEEP_GRASS) ||
-                           ((c_ptr->feat >= FEAT_DEEP_WATER) &&
-                                (c_ptr->feat <= FEAT_GRASS))))
+                           ((feat <= FEAT_DOOR_TAIL) ||
+                            (feat == FEAT_FLOWER) ||
+                            (feat == FEAT_DEEP_GRASS) ||
+                            ((feat >= FEAT_DEEP_WATER) &&
+                             (feat <= FEAT_GRASS))))
 
                        {
                                /* Looking to break right */
@@ -4894,13 +5014,16 @@ static bool run_test(void)
                        /* Access grid */
                        c_ptr = &cave[row][col];
 
+                       /* Feature code (applying "mimic" field) */
+                       feat = c_ptr->mimic ? f_info[c_ptr->mimic].mimic : f_info[c_ptr->feat].mimic;
+
                        /* Unknown grid or non-wall XXX XXX XXX cave_floor_grid(c_ptr)) */
                        if (!(c_ptr->info & (CAVE_MARK)) ||
-                           ((c_ptr->feat < FEAT_SECRET) ||
-                            (c_ptr->feat == FEAT_FLOWER) ||
-                            (c_ptr->feat == FEAT_DEEP_GRASS) ||
-                           ((c_ptr->feat >= FEAT_DEEP_WATER) &&
-                                (c_ptr->feat <= FEAT_GRASS))))
+                           ((feat <= FEAT_DOOR_TAIL) ||
+                            (feat == FEAT_FLOWER) ||
+                            (feat == FEAT_DEEP_GRASS) ||
+                            ((feat >= FEAT_DEEP_WATER) &&
+                             (feat <= FEAT_GRASS))))
 
                        {
                                /* Looking to break left */
@@ -5020,9 +5143,18 @@ void run_step(int dir)
        /* Start running */
        if (dir)
        {
+               cave_type   *c_ptr;
+               byte feat;
+       
+               /* Access grid */
+               c_ptr = &cave[py+ddy[dir]][px+ddx[dir]];
+
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? f_info[c_ptr->mimic].mimic : f_info[c_ptr->feat].mimic;
+
                /* Hack -- do not start silly run */
                if (see_wall(dir, py, px) &&
-                  (cave[py+ddy[dir]][px+ddx[dir]].feat != FEAT_TREES))
+                  (feat != FEAT_TREES))
                {
                        /* Message */
 #ifdef JP
@@ -5077,7 +5209,7 @@ void run_step(int dir)
 
 #endif /* ALLOW_EASY_DISARM -- TNB */
 
-       if ((py == p_ptr->run_py) && (px == p_ptr->run_px))
+       if (player_bold(p_ptr->run_py, p_ptr->run_px))
        {
                p_ptr->run_py = 0;
                p_ptr->run_px = 0;