OSDN Git Service

Refer to a struct's member at offset by atoffset macro
[hengband/hengband.git] / src / cmd1.c
index cd197ff..d32dd7e 100644 (file)
@@ -88,14 +88,18 @@ s16b critical_shot(int weight, int plus, int dam)
        int i, k;
 
        /* Extract "shot" power */
-       i = (weight + ((p_ptr->to_h_b + plus) * 4) + (p_ptr->lev * 2));
+       i = ((p_ptr->to_h_b + plus) * 4) + (p_ptr->lev * 2);
+
+       /* Snipers can shot more critically with crossbows */
+       if (p_ptr->concent) i += ((i * p_ptr->concent) / 5);
+       if ((p_ptr->pclass == CLASS_SNIPER) && (p_ptr->tval_ammo == TV_BOLT)) i *= 2;
 
        /* Critical hit */
        if (randint1(5000) <= i)
        {
-               k = weight + randint1(500);
+               k = weight * randint1(500);
 
-               if (k < 500)
+               if (k < 900)
                {
 #ifdef JP
                        msg_print("¼ê¤´¤¿¤¨¤¬¤¢¤Ã¤¿¡ª");
@@ -103,9 +107,9 @@ s16b critical_shot(int weight, int plus, int dam)
                        msg_print("It was a good hit!");
 #endif
 
-                       dam = 2 * dam + 5;
+                       dam += (dam / 2);
                }
-               else if (k < 1000)
+               else if (k < 1350)
                {
 #ifdef JP
                        msg_print("¤«¤Ê¤ê¤Î¼ê¤´¤¿¤¨¤¬¤¢¤Ã¤¿¡ª");
@@ -113,7 +117,7 @@ s16b critical_shot(int weight, int plus, int dam)
                        msg_print("It was a great hit!");
 #endif
 
-                       dam = 2 * dam + 10;
+                       dam *= 2;
                }
                else
                {
@@ -123,7 +127,7 @@ s16b critical_shot(int weight, int plus, int dam)
                        msg_print("It was a superb hit!");
 #endif
 
-                       dam = 3 * dam + 15;
+                       dam *= 3;
                }
        }
 
@@ -207,441 +211,177 @@ s16b critical_norm(int weight, int plus, int dam, s16b meichuu, int mode)
 
 
 
-/*
- * Extract the "total damage" from a given object hitting a given monster.
- *
- * Note that "flasks of oil" do NOT do fire damage, although they
- * certainly could be made to do so.  XXX XXX
- *
- * 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, bool thrown)
+static int mult_slaying(int mult, const u32b* flgs, const monster_type* m_ptr)
 {
-       int mult = 10;
-
-       monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-       u32b flgs[TR_FLAG_SIZE];
-
-       /* Extract the flags */
-       object_flags(o_ptr, flgs);
-
-       /* Some "weapons" and "ammo" do extra damage */
-       switch (o_ptr->tval)
+       static const struct slay_table_t {
+               int slay_flag;
+               u32b affect_race_flag;
+               int slay_mult;
+               size_t flag_offset;
+               size_t r_flag_offset;
+       } slay_table[] = {
+#define OFFSET(X) offsetof(monster_race, X)
+               {TR_SLAY_ANIMAL, RF3_ANIMAL, 25, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_KILL_ANIMAL, RF3_ANIMAL, 40, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_SLAY_EVIL,   RF3_EVIL,   20, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_KILL_EVIL,   RF3_EVIL,   35, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_SLAY_GOOD,   RF3_GOOD,   20, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_KILL_GOOD,   RF3_GOOD,   35, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_SLAY_HUMAN,  RF2_HUMAN,  25, OFFSET(flags2), OFFSET(r_flags2)},
+               {TR_KILL_HUMAN,  RF2_HUMAN,  40, OFFSET(flags2), OFFSET(r_flags2)},
+               {TR_SLAY_UNDEAD, RF3_UNDEAD, 30, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_KILL_UNDEAD, RF3_UNDEAD, 50, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_SLAY_DEMON,  RF3_DEMON,  30, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_KILL_DEMON,  RF3_DEMON,  50, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_SLAY_ORC,    RF3_ORC,    30, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_KILL_ORC,    RF3_ORC,    50, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_SLAY_TROLL,  RF3_TROLL,  30, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_KILL_TROLL,  RF3_TROLL,  50, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_SLAY_GIANT,  RF3_GIANT,  30, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_KILL_GIANT,  RF3_GIANT,  50, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_SLAY_DRAGON, RF3_DRAGON, 30, OFFSET(flags3), OFFSET(r_flags3)},
+               {TR_KILL_DRAGON, RF3_DRAGON, 50, OFFSET(flags3), OFFSET(r_flags3)},
+#undef OFFSET
+       };
+       int i;
+       monster_race* r_ptr = &r_info[m_ptr->r_idx];
+
+       for (i = 0; i < sizeof(slay_table) / sizeof(slay_table[0]); ++ i)
        {
-               case TV_SHOT:
-               case TV_ARROW:
-               case TV_BOLT:
-               case TV_HAFTED:
-               case TV_POLEARM:
-               case TV_SWORD:
-               case TV_DIGGING:
-               {
-                       /* Slay Animal */
-                       if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
-                           (r_ptr->flags3 & RF3_ANIMAL))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_ANIMAL;
-                               }
-
-                               if (mult < 25) mult = 25;
-                       }
+               const struct slay_table_t* p = &slay_table[i];
 
-                       /* Execute Animal */
-                       if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
-                           (r_ptr->flags3 & RF3_ANIMAL))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_ANIMAL;
-                               }
-
-                               if (mult < 40) mult = 40;
-                       }
-
-                       /* Slay Evil */
-                       if ((have_flag(flgs, TR_SLAY_EVIL)) &&
-                           (r_ptr->flags3 & RF3_EVIL))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_EVIL;
-                               }
-
-                               if (mult < 20) mult = 20;
-                       }
-
-                       /* Execute Evil */
-                       if ((have_flag(flgs, TR_KILL_EVIL)) &&
-                           (r_ptr->flags3 & RF3_EVIL))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_EVIL;
-                               }
-
-                               if (mult < 35) mult = 35;
-                       }
-
-                       /* Slay Human */
-                       if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
-                           (r_ptr->flags2 & RF2_HUMAN))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags2 |= RF2_HUMAN;
-                               }
-
-                               if (mult < 25) mult = 25;
-                       }
-
-                       /* Execute Human */
-                       if ((have_flag(flgs, TR_KILL_HUMAN)) &&
-                           (r_ptr->flags2 & RF2_HUMAN))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags2 |= RF2_HUMAN;
-                               }
-
-                               if (mult < 40) mult = 40;
-                       }
-
-                       /* Slay Undead */
-                       if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
-                           (r_ptr->flags3 & RF3_UNDEAD))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_UNDEAD;
-                               }
-
-                               if (mult < 30) mult = 30;
-                       }
-
-                       /* Execute Undead */
-                       if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
-                           (r_ptr->flags3 & RF3_UNDEAD))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_UNDEAD;
-                               }
-
-                               if (mult < 50) mult = 50;
-                       }
-
-                       /* Slay Demon */
-                       if ((have_flag(flgs, TR_SLAY_DEMON)) &&
-                           (r_ptr->flags3 & RF3_DEMON))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_DEMON;
-                               }
-
-                               if (mult < 30) mult = 30;
-                       }
-
-                       /* Execute Demon */
-                       if ((have_flag(flgs, TR_KILL_DEMON)) &&
-                           (r_ptr->flags3 & RF3_DEMON))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_DEMON;
-                               }
-
-                               if (mult < 50) mult = 50;
-                       }
-
-                       /* Slay Orc */
-                       if ((have_flag(flgs, TR_SLAY_ORC)) &&
-                           (r_ptr->flags3 & RF3_ORC))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_ORC;
-                               }
-
-                               if (mult < 30) mult = 30;
-                       }
-
-                       /* Execute Orc */
-                       if ((have_flag(flgs, TR_KILL_ORC)) &&
-                           (r_ptr->flags3 & RF3_ORC))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_ORC;
-                               }
-
-                               if (mult < 50) mult = 50;
-                       }
-
-                       /* Slay Troll */
-                       if ((have_flag(flgs, TR_SLAY_TROLL)) &&
-                           (r_ptr->flags3 & RF3_TROLL))
+               if ((have_flag(flgs, p->slay_flag)) &&
+                   (atoffset(u32b, r_ptr, p->flag_offset) & p->affect_race_flag))
+               {
+                       if (is_original_ap_and_seen(m_ptr))
                        {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_TROLL;
-                               }
-
-                               if (mult < 30) mult = 30;
+                               atoffset(u32b, r_ptr, p->r_flag_offset) |= p->affect_race_flag;
                        }
 
-                       /* Execute Troll */
-                       if ((have_flag(flgs, TR_KILL_TROLL)) &&
-                           (r_ptr->flags3 & RF3_TROLL))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_TROLL;
-                               }
-
-                               if (mult < 50) mult = 50;
-                       }
+                       mult = MAX(mult, p->slay_mult);
+               }
+       }
 
-                       /* Slay Giant */
-                       if ((have_flag(flgs, TR_SLAY_GIANT)) &&
-                           (r_ptr->flags3 & RF3_GIANT))
-                       {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_GIANT;
-                               }
+       return mult;
+}
 
-                               if (mult < 30) mult = 30;
-                       }
+static int mult_brand(int mult, const u32b* flgs, const monster_type* m_ptr)
+{
+       static const struct brand_table_t {
+               int brand_flag;
+               u32b resist_mask;
+               u32b hurt_flag;
+       } brand_table[] = {
+               {TR_BRAND_ACID, RFR_EFF_IM_ACID_MASK, 0U           },
+               {TR_BRAND_ELEC, RFR_EFF_IM_ELEC_MASK, 0U           },
+               {TR_BRAND_FIRE, RFR_EFF_IM_FIRE_MASK, RF3_HURT_FIRE},
+               {TR_BRAND_COLD, RFR_EFF_IM_COLD_MASK, RF3_HURT_COLD},
+               {TR_BRAND_POIS, RFR_EFF_IM_POIS_MASK, 0U           },
+       };
+       int i;
+       monster_race* r_ptr = &r_info[m_ptr->r_idx];
+
+       for (i = 0; i < sizeof(brand_table) / sizeof(brand_table[0]); ++ i)
+       {
+               const struct brand_table_t* p = &brand_table[i];
 
-                       /* Execute Giant */
-                       if ((have_flag(flgs, TR_KILL_GIANT)) &&
-                           (r_ptr->flags3 & RF3_GIANT))
+               if (have_flag(flgs, p->brand_flag))
+               {
+                       /* Notice immunity */
+                       if (r_ptr->flagsr & p->resist_mask)
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
-                                       r_ptr->r_flags3 |= RF3_GIANT;
+                                       r_ptr->r_flagsr |= (r_ptr->flagsr & p->resist_mask);
                                }
-
-                               if (mult < 50) mult = 50;
                        }
 
-                       /* Slay Dragon  */
-                       if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
-                           (r_ptr->flags3 & RF3_DRAGON))
+                       /* Otherwise, take the damage */
+                       else if (r_ptr->flags3 & p->hurt_flag)
                        {
                                if (is_original_ap_and_seen(m_ptr))
                                {
-                                       r_ptr->r_flags3 |= RF3_DRAGON;
+                                       r_ptr->r_flags3 |= p->hurt_flag;
                                }
 
-                               if (mult < 30) mult = 30;
+                               mult = MAX(mult, 50);
                        }
-
-                       /* Execute Dragon */
-                       if ((have_flag(flgs, TR_KILL_DRAGON)) &&
-                           (r_ptr->flags3 & RF3_DRAGON))
+                       else
                        {
-                               if (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_DRAGON;
-                               }
-
-                               if (mult < 50) mult = 50;
-
-                               if ((o_ptr->name1 == ART_NOTHUNG) && (m_ptr->r_idx == MON_FAFNER))
-                                       mult *= 3;
+                               mult = MAX(mult, 25);
                        }
+               }
+       }
 
-                       /* Brand (Acid) */
-                       if (have_flag(flgs, TR_BRAND_ACID) || ((p_ptr->special_attack & (ATTACK_ACID)) && !thrown))
-                       {
-                               /* Notice immunity */
-                               if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
-                               {
-                                       if (is_original_ap_and_seen(m_ptr))
-                                       {
-                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
-                                       }
-                               }
+       return mult;
+}
+/*
+ * Extract the "total damage" from a given object hitting a given monster.
+ *
+ * Note that "flasks of oil" do NOT do fire damage, although they
+ * certainly could be made to do so.  XXX XXX
+ *
+ * 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, bool thrown)
+{
+       int mult = 10;
 
-                               /* Otherwise, take the damage */
-                               else
-                               {
-                                       if (mult < 25) mult = 25;
-                               }
-                       }
+       u32b flgs[TR_FLAG_SIZE];
 
-                       /* Brand (Elec) */
-                       if (have_flag(flgs, TR_BRAND_ELEC) || ((p_ptr->special_attack & (ATTACK_ELEC)) && !thrown) || (mode == HISSATSU_ELEC))
-                       {
-                               /* Notice immunity */
-                               if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
-                               {
-                                       if (is_original_ap_and_seen(m_ptr))
-                                       {
-                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
-                                       }
-                               }
+       /* Extract the flags */
+       object_flags(o_ptr, flgs);
+       torch_flags(o_ptr, flgs); /* torches has secret flags */
 
-                               /* Otherwise, take the damage */
-                               else if ((have_flag(flgs, TR_BRAND_ELEC) || ((p_ptr->special_attack & (ATTACK_ELEC)) && !thrown)) && (mode == HISSATSU_ELEC))
-                               {
-                                       if (mult < 70) mult = 70;
-                               }
-                               else if (mode == HISSATSU_ELEC)
-                               {
-                                       if (mult < 50) mult = 50;
-                               }
+       if (!thrown)
+       {
+               /* Magical Swords */
+               if (p_ptr->special_attack & (ATTACK_ACID)) add_flag(flgs, TR_BRAND_ACID);
+               if (p_ptr->special_attack & (ATTACK_COLD)) add_flag(flgs, TR_BRAND_COLD);
+               if (p_ptr->special_attack & (ATTACK_ELEC)) add_flag(flgs, TR_BRAND_ELEC);
+               if (p_ptr->special_attack & (ATTACK_FIRE)) add_flag(flgs, TR_BRAND_FIRE);
+               if (p_ptr->special_attack & (ATTACK_POIS)) add_flag(flgs, TR_BRAND_POIS);
+       }
 
-                               else
-                               {
-                                       if (mult < 25) mult = 25;
-                               }
-                       }
+       /* Hex - Slay Good (Runesword) */
+       if (hex_spelling(HEX_RUNESWORD)) add_flag(flgs, TR_SLAY_GOOD);
 
-                       /* Brand (Fire) */
-                       if (have_flag(flgs, TR_BRAND_FIRE) || ((p_ptr->special_attack & (ATTACK_FIRE)) && !thrown) || (mode == HISSATSU_FIRE))
-                       {
-                               /* Notice immunity */
-                               if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
-                               {
-                                       if (is_original_ap_and_seen(m_ptr))
-                                       {
-                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
-                                       }
-                               }
+       /* Some "weapons" and "ammo" do extra damage */
+       switch (o_ptr->tval)
+       {
+               case TV_SHOT:
+               case TV_ARROW:
+               case TV_BOLT:
+               case TV_HAFTED:
+               case TV_POLEARM:
+               case TV_SWORD:
+               case TV_DIGGING:
+               case TV_LITE:
+               {
+                       /* Slaying */
+                       mult = mult_slaying(mult, flgs, m_ptr);
 
-                               /* Otherwise, take the damage */
-                               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 (is_original_ap_and_seen(m_ptr))
-                                               {
-                                                       r_ptr->r_flags3 |= RF3_HURT_FIRE;
-                                               }
-                                       }
-                                       else if (mult < 35) mult = 35;
-                               }
-                               else
-                               {
-                                       if (r_ptr->flags3 & RF3_HURT_FIRE)
-                                       {
-                                               if (mult < 50) mult = 50;
-                                               if (is_original_ap_and_seen(m_ptr))
-                                               {
-                                                       r_ptr->r_flags3 |= RF3_HURT_FIRE;
-                                               }
-                                       }
-                                       else if (mult < 25) mult = 25;
-                               }
-                       }
+                       /* Elemental Brand */
+                       mult = mult_brand(mult, flgs, m_ptr);
 
-                       /* Brand (Cold) */
-                       if (have_flag(flgs, TR_BRAND_COLD) || ((p_ptr->special_attack & (ATTACK_COLD)) && !thrown) || (mode == HISSATSU_COLD))
+                       /* Hissatsu */
+                       if (p_ptr->pclass == CLASS_SAMURAI)
                        {
-                               /* Notice immunity */
-                               if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
-                               {
-                                       if (is_original_ap_and_seen(m_ptr))
-                                       {
-                                               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)) && !thrown)) && (mode == HISSATSU_COLD))
-                               {
-                                       if (r_ptr->flags3 & RF3_HURT_COLD)
-                                       {
-                                               if (mult < 70) mult = 70;
-                                               if (is_original_ap_and_seen(m_ptr))
-                                               {
-                                                       r_ptr->r_flags3 |= RF3_HURT_COLD;
-                                               }
-                                       }
-                                       else if (mult < 35) mult = 35;
-                               }
-                               else
-                               {
-                                       if (r_ptr->flags3 & RF3_HURT_COLD)
-                                       {
-                                               if (mult < 50) mult = 50;
-                                               if (is_original_ap_and_seen(m_ptr))
-                                               {
-                                                       r_ptr->r_flags3 |= RF3_HURT_COLD;
-                                               }
-                                       }
-                                       else if (mult < 25) mult = 25;
-                               }
+                               mult = mult_hissatsu(mult, flgs, m_ptr, mode);
                        }
 
-                       /* Brand (Poison) */
-                       if (have_flag(flgs, TR_BRAND_POIS) || ((p_ptr->special_attack & (ATTACK_POIS)) && !thrown) || (mode == HISSATSU_POISON))
-                       {
-                               /* Notice immunity */
-                               if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
-                               {
-                                       if (is_original_ap_and_seen(m_ptr))
-                                       {
-                                               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)) && !thrown)) && (mode == HISSATSU_POISON))
-                               {
-                                       if (mult < 35) mult = 35;
-                               }
-                               else
-                               {
-                                       if (mult < 25) mult = 25;
-                               }
-                       }
-                       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);
-                       }
-                       if (mode == HISSATSU_UNDEAD)
-                       {
-                               if (r_ptr->flags3 & RF3_UNDEAD)
-                               {
-                                       if (is_original_ap_and_seen(m_ptr))
-                                       {
-                                               r_ptr->r_flags3 |= RF3_UNDEAD;
-                                       }
-                                       if (mult == 10) mult = 70;
-                                       else if (mult < 140) mult = MIN(140, mult+60);
-                               }
-                               if (mult == 10) mult = 40;
-                               else if (mult < 60) mult = MIN(60, mult+30);
-                       }
-                       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 (is_original_ap_and_seen(m_ptr))
-                               {
-                                       r_ptr->r_flags3 |= RF3_HURT_ROCK;
-                               }
-                               if (mult == 10) mult = 40;
-                               else if (mult < 60) mult = 60;
-                       }
+                       /* Force Weapon */
                        if ((p_ptr->pclass != CLASS_SAMURAI) && (have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
                        {
                                p_ptr->csp -= (1+(o_ptr->dd * o_ptr->ds / 5));
                                p_ptr->redraw |= (PR_MANA);
                                mult = mult * 3 / 2 + 20;
                        }
+
+                       /* Hack -- The Nothung cause special damage to Fafner */
+                       if ((o_ptr->name1 == ART_NOTHUNG) && (m_ptr->r_idx == MON_FAFNER))
+                               mult = 150;
                        break;
                }
        }
@@ -655,102 +395,91 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
 /*
  * Search for hidden things
  */
-void search(void)
+static void discover_hidden_things(int y, int x)
 {
-       int y, x, chance;
-
        s16b this_o_idx, next_o_idx = 0;
 
        cave_type *c_ptr;
 
+       /* Access the grid */
+       c_ptr = &cave[y][x];
 
-       /* Start with base search ability */
-       chance = p_ptr->skill_srh;
+       /* Invisible trap */
+       if (c_ptr->mimic && is_trap(c_ptr->feat))
+       {
+               /* Pick a trap */
+               disclose_grid(y, x);
 
-       /* Penalize various conditions */
-       if (p_ptr->blind || no_lite()) chance = chance / 10;
-       if (p_ptr->confused || p_ptr->image) chance = chance / 10;
+               /* Message */
+               msg_print(_("¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡£", "You have found a trap."));
 
-       /* Search the nearby grids, which are always in bounds */
-       for (y = (py - 1); y <= (py + 1); y++)
+               /* Disturb */
+               disturb(0, 1);
+       }
+
+       /* Secret door */
+       if (is_hidden_door(c_ptr))
        {
-               for (x = (px - 1); x <= (px + 1); x++)
-               {
-                       /* Sometimes, notice things */
-                       if (randint0(100) < chance)
-                       {
-                               /* Access the grid */
-                               c_ptr = &cave[y][x];
+               /* Message */
+               msg_print(_("±£¤·¥É¥¢¤òȯ¸«¤·¤¿¡£", "You have found a secret door."));
 
-                               /* Invisible trap */
-                               if (c_ptr->mimic && is_trap(c_ptr->feat))
-                               {
-                                       /* Pick a trap */
-                                       disclose_grid(y, x);
+               /* Disclose */
+               disclose_grid(y, x);
 
-                                       /* Message */
-#ifdef JP
-                                       msg_print("¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡£");
-#else
-                                       msg_print("You have found a trap.");
-#endif
+               /* Disturb */
+               disturb(0, 0);
+       }
 
-                                       /* Disturb */
-                                       disturb(0, 0);
-                               }
+       /* Scan all objects in the grid */
+       for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+       {
+               object_type *o_ptr;
 
-                               /* Secret door */
-                               if (is_hidden_door(c_ptr))
-                               {
-                                       /* Message */
-#ifdef JP
-                                       msg_print("±£¤·¥É¥¢¤òȯ¸«¤·¤¿¡£");
-#else
-                                       msg_print("You have found a secret door.");
-#endif
+               /* Acquire object */
+               o_ptr = &o_list[this_o_idx];
 
-                                       /* Disclose */
-                                       disclose_grid(y, x);
+               /* Acquire next object */
+               next_o_idx = o_ptr->next_o_idx;
 
-                                       /* Disturb */
-                                       disturb(0, 0);
-                               }
+               /* Skip non-chests */
+               if (o_ptr->tval != TV_CHEST) continue;
 
-                               /* Scan all objects in the grid */
-                               for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
-                               {
-                                       object_type *o_ptr;
+               /* Skip non-trapped chests */
+               if (!chest_traps[o_ptr->pval]) continue;
 
-                                       /* Acquire object */
-                                       o_ptr = &o_list[this_o_idx];
+               /* Identify once */
+               if (!object_is_known(o_ptr))
+               {
+                       /* Message */
+                       msg_print(_("È¢¤Ë»Å³Ý¤±¤é¤ì¤¿¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡ª", "You have discovered a trap on the chest!"));
 
-                                       /* Acquire next object */
-                                       next_o_idx = o_ptr->next_o_idx;
+                       /* Know the trap */
+                       object_known(o_ptr);
 
-                                       /* Skip non-chests */
-                                       if (o_ptr->tval != TV_CHEST) continue;
+                       /* Notice it */
+                       disturb(0, 0);
+               }
+       }
+}
 
-                                       /* Skip non-trapped chests */
-                                       if (!chest_traps[o_ptr->pval]) continue;
+void search(void)
+{
+       int i, chance;
 
-                                       /* Identify once */
-                                       if (!object_is_known(o_ptr))
-                                       {
-                                               /* Message */
-#ifdef JP
-                                               msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤¿¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡ª");
-#else
-                                               msg_print("You have discovered a trap on the chest!");
-#endif
+       /* Start with base search ability */
+       chance = p_ptr->skill_srh;
 
-                                               /* Know the trap */
-                                               object_known(o_ptr);
+       /* Penalize various conditions */
+       if (p_ptr->blind || no_lite()) chance = chance / 10;
+       if (p_ptr->confused || p_ptr->image) chance = chance / 10;
 
-                                               /* Notice it */
-                                               disturb(0, 0);
-                                       }
-                               }
-                       }
+       /* Search the nearby grids, which are always in bounds */
+       for (i = 0; i < 9; ++ i)
+       {
+               /* Sometimes, notice things */
+               if (randint0(100) < chance)
+               {
+                       discover_hidden_things(py + ddy_ddd[i], px + ddx_ddd[i]);
                }
        }
 }
@@ -765,7 +494,7 @@ void search(void)
  */
 void py_pickup_aux(int o_idx)
 {
-       int slot, i;
+       int slot;
 
 #ifdef JP
 /*
@@ -848,25 +577,7 @@ void py_pickup_aux(int o_idx)
        record_turn = turn;
 
 
-       /* Check if completed a quest */
-       for (i = 0; i < max_quests; i++)
-       {
-               if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
-                   (quest[i].status == QUEST_STATUS_TAKEN) &&
-                          (quest[i].k_idx == o_ptr->name1))
-               {
-                       if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
-                       quest[i].status = QUEST_STATUS_COMPLETED;
-                       quest[i].complev = (byte)p_ptr->lev;
-#ifdef JP
-                       msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
-#else
-                       msg_print("You completed your quest!");
-#endif
-
-                       msg_print(NULL);
-               }
-       }
+       check_find_art_quest_completion(o_ptr);
 }
 
 
@@ -1064,242 +775,196 @@ static int check_hit(int power)
 
 
 
-/*
- * Handle player hitting a real trap
- */
-static void hit_trap(bool break_trap)
+static void hit_trap_pit(int trap_feat_type)
 {
-       int i, num, dam;
-       int x = px, y = py;
+       int dam;
+       cptr trap_name = "";
+       cptr spike_name = "";
 
-       /* Get the cave grid */
-       cave_type *c_ptr = &cave[y][x];
-
-       int trap_feat = c_ptr->feat;
+       switch (trap_feat_type)
+       {
+       case TRAP_PIT:
+               trap_name = _("Íî¤È¤··ê", "a pit trap");
+               break;
+       case TRAP_SPIKED_PIT:
+               trap_name = _("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Íî¤È¤··ê", "a spiked pit");
+               spike_name = _("¥¹¥Ñ¥¤¥¯", "spikes");
+               break;
+       case TRAP_POISON_PIT:
+               trap_name = _("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Íî¤È¤··ê", "a spiked pit");
+               spike_name = _("ÆǤòÅɤé¤ì¤¿¥¹¥Ñ¥¤¥¯", "poisonous spikes");
+               break;
+       default:
+               return;
+       }
 
-#ifdef JP
-       cptr name = "¥È¥é¥Ã¥×";
-#else
-       cptr name = "a trap";
-#endif
+       if (p_ptr->levitation)
+       {
+               msg_format(_("%s¤òÈô¤Ó±Û¤¨¤¿¡£", "You fly over %s."), trap_name);
+               return;
+       }
 
-       /* Disturb the player */
-       disturb(0, 0);
+       msg_format(_("%s¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª", "You have fallen into %s!"), trap_name);
 
-       cave_alter_feat(y, x, FF_HIT_TRAP);
+       /* Base damage */
+       dam = damroll(2, 6);
 
-       /* Analyze XXX XXX XXX */
-       switch (trap_feat)
+       /* Extra spike damage */
+       if ((trap_feat_type == TRAP_SPIKED_PIT || trap_feat_type == TRAP_POISON_PIT) &&
+           one_in_(2))
        {
-               case FEAT_TRAP_TRAPDOOR:
-               {
-                       if (p_ptr->levitation)
-                       {
-#ifdef JP
-                               msg_print("Í¸Í¤òÈô¤Ó±Û¤¨¤¿¡£");
-#else
-                               msg_print("You fly over a trap door.");
-#endif
+               msg_format(_("%s¤¬»É¤µ¤Ã¤¿¡ª", "You are impaled on %s!"), spike_name);
+
+               dam = dam * 2;
+               (void)set_cut(p_ptr->cut + randint1(dam));
 
+               if (trap_feat_type == TRAP_POISON_PIT) {
+                       if (p_ptr->resist_pois || IS_OPPOSE_POIS())
+                       {
+                               msg_print(_("¤·¤«¤·ÆǤαƶÁ¤Ï¤Ê¤«¤Ã¤¿¡ª", "The poison does not affect you!"));
                        }
                        else
                        {
-#ifdef JP
-                               msg_print("Í¸Í¤ËÍî¤Á¤¿¡ª");
-                               if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
-                                       msg_print("¤¯¤Ã¤½¡Á¡ª");
-#else
-                               msg_print("You have fallen through a trap door!");
-#endif
-
-                               sound(SOUND_FALL);
-                               dam = damroll(2, 8);
-#ifdef JP
-                               name = "Í¸Í";
-#else
-                               name = "a trap door";
-#endif
-
-                               take_hit(DAMAGE_NOESCAPE, dam, name, -1);
-
-                               /* Still alive and autosave enabled */
-                               if (autosave_l && (p_ptr->chp >= 0))
-                                       do_cmd_save_game(TRUE);
-
-#ifdef JP
-                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "Í¸Í¤ËÍî¤Á¤¿");
-#else
-                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "You have fallen through a trap door!");
-#endif
-                               prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
-
-                               /* Leaving */
-                               p_ptr->leaving = TRUE;
+                               dam = dam * 2;
+                               (void)set_poisoned(p_ptr->poisoned + randint1(dam));
                        }
-                       break;
                }
+       }
 
-               case FEAT_TRAP_PIT:
-               {
-                       if (p_ptr->levitation)
-                       {
-#ifdef JP
-                               msg_print("Í·ê¤òÈô¤Ó±Û¤¨¤¿¡£");
-#else
-                               msg_print("You fly over a pit trap.");
-#endif
+       /* Take the damage */
+       take_hit(DAMAGE_NOESCAPE, dam, trap_name, -1);
+}
 
-                       }
-                       else
-                       {
-#ifdef JP
-                               msg_print("Í·ê¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª");
-#else
-                               msg_print("You have fallen into a pit!");
-#endif
+static bool hit_trap_dart(void)
+{
+       bool hit = FALSE;
 
-                               dam = damroll(2, 6);
-#ifdef JP
-                               name = "Í·ê";
-#else
-                               name = "a pit trap";
-#endif
+       if (check_hit(125))
+       {
+               msg_print(_("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤Æ»É¤µ¤Ã¤¿¡ª", "A small dart hits you!"));
 
-                               take_hit(DAMAGE_NOESCAPE, dam, name, -1);
-                       }
-                       break;
-               }
+               take_hit(DAMAGE_ATTACK, damroll(1, 4), _("¥À¡¼¥Ä¤Îæ«", "a dart trap"), -1);
 
-               case FEAT_TRAP_SPIKED_PIT:
-               {
-                       if (p_ptr->levitation)
-                       {
-#ifdef JP
-                               msg_print("¥È¥²¤Î¤¢¤ëÍ·ê¤òÈô¤Ó±Û¤¨¤¿¡£");
-#else
-                               msg_print("You fly over a spiked pit.");
-#endif
+               if (!CHECK_MULTISHADOW()) hit = TRUE;
+       }
+       else
+       {
+               msg_print(_("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£", "A small dart barely misses you."));
+       }
 
-                       }
-                       else
-                       {
-#ifdef JP
-                       msg_print("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Í·ê¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª");
-#else
-                               msg_print("You fall into a spiked pit!");
-#endif
+       return hit;
+}
 
+static void hit_trap_lose_stat(int stat)
+{
+       if (hit_trap_dart())
+       {
+               do_dec_stat(stat);
+       }
+}
 
-                               /* Base damage */
-#ifdef JP
-                               name = "Í·ê";
-#else
-                               name = "a pit trap";
-#endif
+static void hit_trap_slow(void)
+{
+       if (hit_trap_dart())
+       {
+               set_slow(p_ptr->slow + randint0(20) + 20, FALSE);
+       }
+}
 
-                               dam = damroll(2, 6);
+static void hit_trap_set_abnormal_status(cptr trap_message, bool resist, bool (*set_status)(int turn), int turn)
+{
+       msg_print(trap_message);
 
-                               /* Extra spike damage */
-                               if (randint0(100) < 50)
-                               {
-#ifdef JP
-                                       msg_print("¥¹¥Ñ¥¤¥¯¤¬»É¤µ¤Ã¤¿¡ª");
-#else
-                                       msg_print("You are impaled!");
-#endif
+       if (!resist)
+       {
+               set_status(turn);
+       }
+}
 
+/*
+ * Handle player hitting a real trap
+ */
+static void hit_trap(bool break_trap)
+{
+       int i, num, dam;
+       int x = px, y = py;
+
+       /* Get the cave grid */
+       cave_type *c_ptr = &cave[y][x];
+       feature_type *f_ptr = &f_info[c_ptr->feat];
+       int trap_feat_type = have_flag(f_ptr->flags, FF_TRAP) ? f_ptr->subtype : NOT_TRAP;
 
 #ifdef JP
-                                       name = "¥È¥²¤Î¤¢¤ëÍ·ê";
+       cptr name = "¥È¥é¥Ã¥×";
 #else
-                                       name = "a spiked pit";
+       cptr name = "a trap";
 #endif
 
-                                       dam = dam * 2;
-                                       (void)set_cut(p_ptr->cut + randint1(dam));
-                               }
+       /* Disturb the player */
+       disturb(0, 1);
 
-                               /* Take the damage */
-                               take_hit(DAMAGE_NOESCAPE, dam, name, -1);
-                       }
-                       break;
-               }
+       cave_alter_feat(y, x, FF_HIT_TRAP);
 
-               case FEAT_TRAP_POISON_PIT:
+       /* Analyze XXX XXX XXX */
+       switch (trap_feat_type)
+       {
+               case TRAP_TRAPDOOR:
                {
                        if (p_ptr->levitation)
                        {
 #ifdef JP
-                               msg_print("¥È¥²¤Î¤¢¤ëÍ·ê¤òÈô¤Ó±Û¤¨¤¿¡£");
+                               msg_print("Íî¤È¤·¸Í¤òÈô¤Ó±Û¤¨¤¿¡£");
 #else
-                               msg_print("You fly over a spiked pit.");
+                               msg_print("You fly over a trap door.");
 #endif
 
                        }
                        else
-                       {
-#ifdef JP
-                       msg_print("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Í·ê¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª");
-#else
-                               msg_print("You fall into a spiked pit!");
-#endif
-
-
-                               /* Base damage */
-                               dam = damroll(2, 6);
-
-#ifdef JP
-                               name = "Í·ê";
-#else
-                               name = "a pit trap";
-#endif
-
-
-                               /* Extra spike damage */
-                               if (randint0(100) < 50)
-                               {
+                       {
 #ifdef JP
-                                       msg_print("ÆǤòÅɤé¤ì¤¿¥¹¥Ñ¥¤¥¯¤¬»É¤µ¤Ã¤¿¡ª");
+                               msg_print("Íî¤È¤·¸Í¤ËÍî¤Á¤¿¡ª");
+                               if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
+                                       msg_print("¤¯¤Ã¤½¡Á¡ª");
 #else
-                                       msg_print("You are impaled on poisonous spikes!");
+                               msg_print("You have fallen through a trap door!");
 #endif
 
-
+                               sound(SOUND_FALL);
+                               dam = damroll(2, 8);
 #ifdef JP
-                                       name = "¥È¥²¤Î¤¢¤ëÍ·ê";
+                               name = "Íî¤È¤·¸Í";
 #else
-                                       name = "a spiked pit";
+                               name = "a trap door";
 #endif
 
+                               take_hit(DAMAGE_NOESCAPE, dam, name, -1);
 
-                                       dam = dam * 2;
-                                       (void)set_cut(p_ptr->cut + randint1(dam));
+                               /* Still alive and autosave enabled */
+                               if (autosave_l && (p_ptr->chp >= 0))
+                                       do_cmd_save_game(TRUE);
 
-                                       if (p_ptr->resist_pois || IS_OPPOSE_POIS())
-                                       {
 #ifdef JP
-                                               msg_print("¤·¤«¤·ÆǤαƶÁ¤Ï¤Ê¤«¤Ã¤¿¡ª");
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "Íî¤È¤·¸Í¤ËÍî¤Á¤¿");
 #else
-                                               msg_print("The poison does not affect you!");
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "You have fallen through a trap door!");
 #endif
+                               prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
 
-                                       }
-
-                                       else
-                                       {
-                                               dam = dam * 2;
-                                               (void)set_poisoned(p_ptr->poisoned + randint1(dam));
-                                       }
-                               }
-
-                               /* Take the damage */
-                               take_hit(DAMAGE_NOESCAPE, dam, name, -1);
+                               /* Leaving */
+                               p_ptr->leaving = TRUE;
                        }
+                       break;
+               }
 
+               case TRAP_PIT:
+               case TRAP_SPIKED_PIT:
+               case TRAP_POISON_PIT:
+               {
+                       hit_trap_pit(trap_feat_type);
                        break;
                }
 
-               case FEAT_TRAP_TY_CURSE:
+               case TRAP_TY_CURSE:
                {
 #ifdef JP
                        msg_print("²¿¤«¤¬¥Ô¥«¥Ã¤È¸÷¤Ã¤¿¡ª");
@@ -1327,7 +992,7 @@ static void hit_trap(bool break_trap)
                        break;
                }
 
-               case FEAT_TRAP_TELEPORT:
+               case TRAP_TELEPORT:
                {
 #ifdef JP
                        msg_print("¥Æ¥ì¥Ý¡¼¥È¡¦¥È¥é¥Ã¥×¤Ë¤Ò¤Ã¤«¤«¤Ã¤¿¡ª");
@@ -1335,11 +1000,11 @@ static void hit_trap(bool break_trap)
                        msg_print("You hit a teleport trap!");
 #endif
 
-                       teleport_player(100, TRUE);
+                       teleport_player(100, TELEPORT_PASSIVE);
                        break;
                }
 
-               case FEAT_TRAP_FIRE:
+               case TRAP_FIRE:
                {
 #ifdef JP
                        msg_print("±ê¤ËÊñ¤Þ¤ì¤¿¡ª");
@@ -1357,7 +1022,7 @@ static void hit_trap(bool break_trap)
                        break;
                }
 
-               case FEAT_TRAP_ACID:
+               case TRAP_ACID:
                {
 #ifdef JP
                        msg_print("»À¤¬¿á¤­¤«¤±¤é¤ì¤¿¡ª");
@@ -1375,171 +1040,58 @@ static void hit_trap(bool break_trap)
                        break;
                }
 
-               case FEAT_TRAP_SLOW:
+               case TRAP_SLOW:
                {
-                       if (check_hit(125))
-                       {
-#ifdef JP
-                               msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤Æ»É¤µ¤Ã¤¿¡ª");
-#else
-                               msg_print("A small dart hits you!");
-#endif
-
-                               dam = damroll(1, 4);
-                               take_hit(DAMAGE_ATTACK, dam, name, -1);
-                               (void)set_slow(p_ptr->slow + randint0(20) + 20, FALSE);
-                       }
-                       else
-                       {
-#ifdef JP
-                               msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
-#else
-                               msg_print("A small dart barely misses you.");
-#endif
-
-                       }
+                       hit_trap_slow();
                        break;
                }
 
-               case FEAT_TRAP_LOSE_STR:
+               case TRAP_LOSE_STR:
                {
-                       if (check_hit(125))
-                       {
-#ifdef JP
-                               msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤Æ»É¤µ¤Ã¤¿¡ª");
-#else
-                               msg_print("A small dart hits you!");
-#endif
-
-                               dam = damroll(1, 4);
-#ifdef JP
-                               take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
-#else
-                               take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
-#endif
-
-                               (void)do_dec_stat(A_STR);
-                       }
-                       else
-                       {
-#ifdef JP
-                               msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
-#else
-                               msg_print("A small dart barely misses you.");
-#endif
-
-                       }
+                       hit_trap_lose_stat(A_STR);
                        break;
                }
 
-               case FEAT_TRAP_LOSE_DEX:
+               case TRAP_LOSE_DEX:
                {
-                       if (check_hit(125))
-                       {
-#ifdef JP
-                               msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤Æ»É¤µ¤Ã¤¿¡ª");
-#else
-                               msg_print("A small dart hits you!");
-#endif
-
-                               dam = damroll(1, 4);
-#ifdef JP
-                               take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
-#else
-                               take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
-#endif
-
-                               (void)do_dec_stat(A_DEX);
-                       }
-                       else
-                       {
-#ifdef JP
-                               msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
-#else
-                               msg_print("A small dart barely misses you.");
-#endif
-
-                       }
+                       hit_trap_lose_stat(A_DEX);
                        break;
                }
 
-               case FEAT_TRAP_LOSE_CON:
+               case TRAP_LOSE_CON:
                {
-                       if (check_hit(125))
-                       {
-#ifdef JP
-                               msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤Æ»É¤µ¤Ã¤¿¡ª");
-#else
-                               msg_print("A small dart hits you!");
-#endif
-
-                               dam = damroll(1, 4);
-#ifdef JP
-                               take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
-#else
-                               take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
-#endif
-
-                               (void)do_dec_stat(A_CON);
-                       }
-                       else
-                       {
-#ifdef JP
-                               msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
-#else
-                               msg_print("A small dart barely misses you.");
-#endif
-
-                       }
+                       hit_trap_lose_stat(A_CON);
                        break;
                }
 
-               case FEAT_TRAP_BLIND:
+               case TRAP_BLIND:
                {
-#ifdef JP
-                       msg_print("¹õ¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
-#else
-                       msg_print("A black gas surrounds you!");
-#endif
-
-                       if (!p_ptr->resist_blind)
-                       {
-                               (void)set_blind(p_ptr->blind + randint0(50) + 25);
-                       }
+                       hit_trap_set_abnormal_status(
+                               _("¹õ¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª", "A black gas surrounds you!"),
+                               p_ptr->resist_blind,
+                               set_blind, p_ptr->blind + randint0(50) + 25);
                        break;
                }
 
-               case FEAT_TRAP_CONFUSE:
+               case TRAP_CONFUSE:
                {
-#ifdef JP
-                       msg_print("¤­¤é¤á¤¯¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
-#else
-                       msg_print("A gas of scintillating colors surrounds you!");
-#endif
-
-                       if (!p_ptr->resist_conf)
-                       {
-                               (void)set_confused(p_ptr->confused + randint0(20) + 10);
-                       }
+                       hit_trap_set_abnormal_status(
+                               _("¤­¤é¤á¤¯¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª", "A gas of scintillating colors surrounds you!"),
+                               p_ptr->resist_conf,
+                               set_confused, p_ptr->confused + randint0(20) + 10);
                        break;
                }
 
-               case FEAT_TRAP_POISON:
+               case TRAP_POISON:
                {
-#ifdef JP
-                       msg_print("»É·ãŪ¤ÊÎп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
-#else
-                       msg_print("A pungent green gas surrounds you!");
-#endif
-
-                       if (!p_ptr->resist_pois && !IS_OPPOSE_POIS())
-                       {
-                               (void)set_poisoned(p_ptr->poisoned + randint0(20) + 10);
-                       }
+                       hit_trap_set_abnormal_status(
+                               _("»É·ãŪ¤ÊÎп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª", "A pungent green gas surrounds you!"),
+                               p_ptr->resist_pois || IS_OPPOSE_POIS(),
+                               set_poisoned, p_ptr->poisoned + randint0(20) + 10);
                        break;
                }
 
-               case FEAT_TRAP_SLEEP:
+               case TRAP_SLEEP:
                {
 #ifdef JP
                        msg_print("´ñ̯¤ÊÇò¤¤Ì¸¤ËÊñ¤Þ¤ì¤¿¡ª");
@@ -1579,7 +1131,7 @@ msg_print("
                        break;
                }
 
-               case FEAT_TRAP_TRAPS:
+               case TRAP_TRAPS:
                {
 #ifdef JP
 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
@@ -1593,7 +1145,7 @@ msg_print("
                        break;
                }
 
-               case FEAT_TRAP_ALARM:
+               case TRAP_ALARM:
                {
 #ifdef JP
                        msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
@@ -1606,7 +1158,7 @@ msg_print("
                        break;
                }
 
-               case FEAT_TRAP_OPEN:
+               case TRAP_OPEN:
                {
 #ifdef JP
                        msg_print("Âç²»¶Á¤È¶¦¤Ë¤Þ¤ï¤ê¤ÎÊɤ¬Êø¤ì¤¿¡ª");
@@ -1621,7 +1173,7 @@ msg_print("
                        break;
                }
 
-               case FEAT_TRAP_ARMAGEDDON:
+               case TRAP_ARMAGEDDON:
                {
                        static int levs[10] = {0, 0, 20, 10, 5, 3, 2, 1, 1, 1};
                        int evil_idx = 0, good_idx = 0;
@@ -1671,7 +1223,7 @@ msg_print("
                        break;
                }
 
-               case FEAT_TRAP_PIRANHA:
+               case TRAP_PIRANHA:
                {
 #ifdef JP
                        msg_print("ÆÍÁ³Êɤ«¤é¿å¤¬°î¤ì½Ð¤·¤¿¡ª¥Ô¥é¥Ë¥¢¤¬¤¤¤ë¡ª");
@@ -1981,7 +1533,6 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
        char            m_name[80];
 
        bool            success_hit = FALSE;
-       bool            old_success_hit = FALSE;
        bool            backstab = FALSE;
        bool            vorpal_cut = FALSE;
        int             chaos_effect = 0;
@@ -2010,7 +1561,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        if (p_ptr->monlite && (mode != HISSATSU_NYUSIN)) tmp /= 3;
                        if (p_ptr->cursed & TRC_AGGRAVATE) tmp /= 2;
                        if (r_ptr->level > (p_ptr->lev * p_ptr->lev / 20 + 10)) tmp /= 3;
-                       if (m_ptr->csleep && m_ptr->ml)
+                       if (MON_CSLEEP(m_ptr) && m_ptr->ml)
                        {
                                /* Can't backstab creatures that we can't see, right? */
                                backstab = TRUE;
@@ -2019,7 +1570,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        {
                                fuiuchi = TRUE;
                        }
-                       else if (m_ptr->monfear && m_ptr->ml)
+                       else if (MON_MONFEAR(m_ptr) && m_ptr->ml)
                        {
                                stab_fleeing = TRUE;
                        }
@@ -2029,7 +1580,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
        case CLASS_MONK:
        case CLASS_FORCETRAINER:
        case CLASS_BERSERKER:
-               if (empty_hands(TRUE) & EMPTY_HAND_RARM) monk_attack = TRUE;
+               if ((empty_hands(TRUE) & EMPTY_HAND_RARM) && !p_ptr->riding) monk_attack = TRUE;
                break;
        }
 
@@ -2072,8 +1623,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_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+       (void)set_monster_csleep(c_ptr->m_idx, 0);
 
        /* Extract monster name (or "it") */
        monster_desc(m_name, m_ptr, 0);
@@ -2099,30 +1649,36 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
        else if (mode == HISSATSU_COLD) num_blow = p_ptr->num_blow[hand]+2;
        else num_blow = p_ptr->num_blow[hand];
 
+       /* Hack -- DOKUBARI always hit once */
+       if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) num_blow = 1;
+
        /* Attack once for each legal blow */
        while ((num++ < num_blow) && !p_ptr->is_dead)
        {
                if (((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) || (mode == HISSATSU_KYUSHO))
                {
+                       int n = 1;
+
                        if (p_ptr->migite && p_ptr->hidarite)
                        {
-                               success_hit = one_in_(2);
+                               n *= 2;
                        }
-                       else success_hit = TRUE;
-               }
-               else if (mode == HISSATSU_MAJIN)
-               {
-                       if (num == 1)
+                       if (mode == HISSATSU_3DAN)
                        {
-                               if (one_in_(2))
-                                       success_hit = FALSE;
-                               old_success_hit = success_hit;
+                               n *= 2;
                        }
-                       else success_hit = old_success_hit;
+
+                       success_hit = one_in_(n);
                }
                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);
 
+               if (mode == HISSATSU_MAJIN)
+               {
+                       if (one_in_(2))
+                               success_hit = FALSE;
+               }
+
                /* Test for hit */
                if (success_hit)
                {
@@ -2183,7 +1739,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        }
 
                        /* Vampiric drain */
-                       if ((have_flag(flgs, TR_VAMPIRIC)) || (chaos_effect == 1) || (mode == HISSATSU_DRAIN))
+                       if ((have_flag(flgs, TR_VAMPIRIC)) || (chaos_effect == 1) || (mode == HISSATSU_DRAIN) || hex_spelling(HEX_VAMP_BLADE))
                        {
                                /* Only drain "living" monsters */
                                if (monster_living(r_ptr))
@@ -2192,7 +1748,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        can_drain = FALSE;
                        }
 
-                       if ((have_flag(flgs, TR_VORPAL)) && (randint1(vorpal_chance*3/2) == 1) && !zantetsu_mukou)
+                       if ((have_flag(flgs, TR_VORPAL) || hex_spelling(HEX_RUNESWORD)) && (randint1(vorpal_chance*3/2) == 1) && !zantetsu_mukou)
                                vorpal_cut = TRUE;
                        else vorpal_cut = FALSE;
 
@@ -2200,7 +1756,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        {
                                int special_effect = 0, stun_effect = 0, times = 0, max_times;
                                int min_level = 1;
-                               martial_arts *ma_ptr = &ma_blows[0], *old_ptr = &ma_blows[0];
+                               const martial_arts *ma_ptr = &ma_blows[0], *old_ptr = &ma_blows[0];
                                int resist_stun = 0;
                                int weight = 8;
 
@@ -2340,15 +1896,22 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                {
                                        if (p_ptr->lev > randint1(r_ptr->level + resist_stun + 10))
                                        {
+                                               if (set_monster_stunned(c_ptr->m_idx, stun_effect + MON_STUNNED(m_ptr)))
+                                               {
 #ifdef JP
-                                               if (m_ptr->stunned) msg_format("%^s¤Ï¤µ¤é¤Ë¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
-                                               else msg_format("%^s¤Ï¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
+                                                       msg_format("%^s¤Ï¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
 #else
-                                               if (m_ptr->stunned) msg_format("%^s is more stunned.", m_name);
-                                               else msg_format("%^s is stunned.", m_name);
+                                                       msg_format("%^s is stunned.", m_name);
 #endif
-
-                                               m_ptr->stunned += stun_effect;
+                                               }
+                                               else
+                                               {
+#ifdef JP
+                                                       msg_format("%^s¤Ï¤µ¤é¤Ë¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
+#else
+                                                       msg_format("%^s is more stunned.", m_name);
+#endif
+                                               }
                                        }
                                }
                        }
@@ -2510,7 +2073,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                if (!(r_ptr->flags3 & (RF3_NO_STUN)))
                                {
                                        /* Get stunned */
-                                       if (m_ptr->stunned)
+                                       if (MON_STUNNED(m_ptr))
                                        {
 #ifdef JP
                                                msg_format("%s¤Ï¤Ò¤É¤¯¤â¤¦¤í¤¦¤È¤·¤¿¡£", m_name);
@@ -2530,7 +2093,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        }
 
                                        /* Apply stun */
-                                       m_ptr->stunned = (tmp < 200) ? tmp : 200;
+                                       (void)set_monster_stunned(c_ptr->m_idx, MON_STUNNED(m_ptr) + tmp);
                                }
                                else
                                {
@@ -2678,6 +2241,9 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        {
                                                drain_heal = damroll(2, drain_result / 6);
 
+                                               /* Hex */
+                                               if (hex_spelling(HEX_VAMP_BLADE)) drain_heal *= 2;
+
                                                if (cheat_xtra)
                                                {
 #ifdef JP
@@ -2720,13 +2286,14 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                }
                                m_ptr->maxhp -= (k+7)/8;
                                if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
+                               if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
                                weak = TRUE;
                        }
                        can_drain = FALSE;
                        drain_result = 0;
 
                        /* Confusion attack */
-                       if ((p_ptr->special_attack & ATTACK_CONFUSE) || (chaos_effect == 3) || (mode == HISSATSU_CONF))
+                       if ((p_ptr->special_attack & ATTACK_CONFUSE) || (chaos_effect == 3) || (mode == HISSATSU_CONF) || hex_spelling(HEX_CONFUSION))
                        {
                                /* Cancel glowing hands */
                                if (p_ptr->special_attack & ATTACK_CONFUSE)
@@ -2770,7 +2337,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        msg_format("%^s appears confused.", m_name);
 #endif
 
-                                       m_ptr->confused += 10 + randint0(p_ptr->lev) / 5;
+                                       (void)set_monster_confused(c_ptr->m_idx, MON_CONFUSED(m_ptr) + 10 + randint0(p_ptr->lev) / 5);
                                }
                        }
 
@@ -2812,7 +2379,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        msg_format("%^s disappears!", m_name);
 #endif
 
-                                       teleport_away(c_ptr->m_idx, 50, FALSE, TRUE);
+                                       teleport_away(c_ptr->m_idx, 50, TELEPORT_PASSIVE);
                                        num = num_blow + 1; /* Can't hit it anymore! */
                                        *mdeath = TRUE;
                                }
@@ -2831,16 +2398,6 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                                msg_format("%^s changes!", m_name);
 #endif
 
-
-                                               /* Hack -- Get new monster */
-                                               m_ptr = &m_list[c_ptr->m_idx];
-
-                                               /* Oops, we need a different name... */
-                                               monster_desc(m_name, m_ptr, 0);
-
-                                               /* Hack -- Get new race */
-                                               r_ptr = &r_info[m_ptr->r_idx];
-
                                                *fear = FALSE;
                                                weak = FALSE;
                                        }
@@ -2851,8 +2408,16 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
 #else
                                                msg_format("%^s is unaffected.", m_name);
 #endif
-
                                        }
+
+                                       /* Hack -- Get new monster */
+                                       m_ptr = &m_list[c_ptr->m_idx];
+
+                                       /* Oops, we need a different name... */
+                                       monster_desc(m_name, m_ptr, 0);
+
+                                       /* Hack -- Get new race */
+                                       r_ptr = &r_info[m_ptr->r_idx];
                                }
                        }
                        else if (o_ptr->name1 == ART_G_HAMMER)
@@ -2866,7 +2431,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
 
                                        object_desc(o_name, q_ptr, OD_NAME_ONLY);
                                        q_ptr->held_m_idx = 0;
-                                       q_ptr->marked = 0;
+                                       q_ptr->marked = OM_TOUCHED;
                                        m_ptr->hold_o_idx = q_ptr->next_o_idx;
                                        q_ptr->next_o_idx = 0;
 #ifdef JP
@@ -2921,6 +2486,8 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                                        case RACE_HUMAN:
                                                        case RACE_AMBERITE:
                                                        case RACE_DUNADAN:
+                                                       case RACE_BARBARIAN:
+                                                       case RACE_BEASTMAN:
                                                                mult = 25;break;
                                                        case RACE_HALF_ORC:
                                                        case RACE_HALF_TROLL:
@@ -3053,7 +2620,7 @@ bool py_attack(int y, int x, int mode)
        char            m_name[80];
 
        /* Disturb the player */
-       disturb(0, 0);
+       disturb(0, 1);
 
        energy_use = 100;
 
@@ -3074,7 +2641,7 @@ bool py_attack(int y, int x, int mode)
        if (m_ptr->ml)
        {
                /* Auto-Recall if possible and visible */
-               monster_race_track(m_ptr->ap_r_idx);
+               if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
 
                /* Track a new monster */
                health_track(c_ptr->m_idx);
@@ -3155,7 +2722,7 @@ bool py_attack(int y, int x, int mode)
                /* Message */
                if (m_ptr->ml)
 #ifdef JP
-               msg_format("¶²¤¯¤Æ%s¤ò¹¶·â¤Ç¤­¤Ê¤¤¡ª", m_name);
+                       msg_format("¶²¤¯¤Æ%s¤ò¹¶·â¤Ç¤­¤Ê¤¤¡ª", m_name);
 #else
                        msg_format("You are too afraid to attack %s!", m_name);
 #endif
@@ -3168,14 +2735,13 @@ bool py_attack(int y, int x, int mode)
 #endif
 
                /* Disturb the monster */
-               m_ptr->csleep = 0;
-               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+               (void)set_monster_csleep(c_ptr->m_idx, 0);
 
                /* Done */
                return FALSE;
        }
 
-       if (m_ptr->csleep) /* It is not honorable etc to attack helpless victims */
+       if (MON_CSLEEP(m_ptr)) /* It is not honorable etc to attack helpless victims */
        {
                if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
                if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
@@ -3280,8 +2846,8 @@ bool pattern_seq(int c_y, int c_x, int n_y, int n_x)
 
        if (!is_pattern_tile_cur && !is_pattern_tile_new) return TRUE;
 
-       pattern_type_cur = is_pattern_tile_cur ? cur_f_ptr->power : NOT_PATTERN_TILE;
-       pattern_type_new = is_pattern_tile_new ? new_f_ptr->power : NOT_PATTERN_TILE;
+       pattern_type_cur = is_pattern_tile_cur ? cur_f_ptr->subtype : NOT_PATTERN_TILE;
+       pattern_type_new = is_pattern_tile_new ? new_f_ptr->subtype : NOT_PATTERN_TILE;
 
        if (pattern_type_new == PATTERN_TILE_START)
        {
@@ -3495,11 +3061,20 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
                /* Redraw new spot */
                lite_spot(ny, nx);
 
-               if (mpe_mode & MPE_FORGET_FLOW) forget_flow();
-
                /* Check for new panel (redraw map) */
                verify_panel();
 
+               if (mpe_mode & MPE_FORGET_FLOW)
+               {
+                       forget_flow();
+
+                       /* Mega-Hack -- Forget the view */
+                       p_ptr->update |= (PU_UN_VIEW);
+
+                       /* Redraw map */
+                       p_ptr->redraw |= (PR_MAP);
+               }
+
                /* Update stuff */
                p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_DISTANCE);
 
@@ -3567,7 +3142,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        if (have_flag(f_ptr->flags, FF_STORE))
        {
                /* Disturb */
-               disturb(0, 0);
+               disturb(0, 1);
 
                energy_use = 0;
                /* Hack -- Enter store */
@@ -3578,7 +3153,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        else if (have_flag(f_ptr->flags, FF_BLDG))
        {
                /* Disturb */
-               disturb(0, 0);
+               disturb(0, 1);
 
                energy_use = 0;
                /* Hack -- Enter building */
@@ -3589,7 +3164,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        else if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
        {
                /* Disturb */
-               disturb(0, 0);
+               disturb(0, 1);
 
                energy_use = 0;
                /* Hack -- Enter quest level */
@@ -3600,16 +3175,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        {
                if (quest[p_ptr->inside_quest].type == QUEST_TYPE_FIND_EXIT)
                {
-                       if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, p_ptr->inside_quest, NULL);
-                       quest[p_ptr->inside_quest].status = QUEST_STATUS_COMPLETED;
-                       quest[p_ptr->inside_quest].complev = (byte)p_ptr->lev;
-#ifdef JP
-                       msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
-#else
-                       msg_print("You accomplished your quest!");
-#endif
-
-                       msg_print(NULL);
+                       complete_quest(p_ptr->inside_quest);
                }
 
                leave_quest_check();
@@ -3626,7 +3192,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        else if (have_flag(f_ptr->flags, FF_HIT_TRAP) && !(mpe_mode & MPE_STAYING))
        {
                /* Disturb */
-               disturb(0, 0);
+               disturb(0, 1);
 
                /* Hidden trap */
                if (c_ptr->mimic || have_flag(f_ptr->flags, FF_SECRET))
@@ -3667,7 +3233,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
 #endif
                        }
 
-                       if (disturb_trap_detect) disturb(0, 0);
+                       if (disturb_trap_detect) disturb(0, 1);
                }
        }
 
@@ -3677,33 +3243,37 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
 
 bool trap_can_be_ignored(int feat)
 {
-       switch (feat)
+       feature_type *f_ptr = &f_info[feat];
+
+       if (!have_flag(f_ptr->flags, FF_TRAP)) return TRUE;
+
+       switch (f_ptr->subtype)
        {
-       case FEAT_TRAP_TRAPDOOR:
-       case FEAT_TRAP_PIT:
-       case FEAT_TRAP_SPIKED_PIT:
-       case FEAT_TRAP_POISON_PIT:
+       case TRAP_TRAPDOOR:
+       case TRAP_PIT:
+       case TRAP_SPIKED_PIT:
+       case TRAP_POISON_PIT:
                if (p_ptr->levitation) return TRUE;
                break;
-       case FEAT_TRAP_TELEPORT:
+       case TRAP_TELEPORT:
                if (p_ptr->anti_tele) return TRUE;
                break;
-       case FEAT_TRAP_FIRE:
+       case TRAP_FIRE:
                if (p_ptr->immune_fire) return TRUE;
                break;
-       case FEAT_TRAP_ACID:
+       case TRAP_ACID:
                if (p_ptr->immune_acid) return TRUE;
                break;
-       case FEAT_TRAP_BLIND:
+       case TRAP_BLIND:
                if (p_ptr->resist_blind) return TRUE;
                break;
-       case FEAT_TRAP_CONFUSE:
+       case TRAP_CONFUSE:
                if (p_ptr->resist_conf) return TRUE;
                break;
-       case FEAT_TRAP_POISON:
+       case TRAP_POISON:
                if (p_ptr->resist_pois) return TRUE;
                break;
-       case FEAT_TRAP_SLEEP:
+       case TRAP_SLEEP:
                if (p_ptr->free_act) return TRUE;
                break;
        }
@@ -3852,7 +3422,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 
        /* Player can not walk through "walls"... */
        /* unless in Shadow Form */
-       p_can_kill_walls = p_ptr->kill_wall && have_flag(f_ptr->flags, FF_TUNNEL) &&
+       p_can_kill_walls = p_ptr->kill_wall && have_flag(f_ptr->flags, FF_HURT_DISI) &&
                (!p_can_enter || !have_flag(f_ptr->flags, FF_LOS)) &&
                !have_flag(f_ptr->flags, FF_PERMANENT);
 
@@ -3867,8 +3437,8 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                    ((p_ptr->muta2 & MUT2_BERS_RAGE) && p_ptr->shero)) &&
                    pattern_seq(py, px, y, x) && (p_can_enter || p_can_kill_walls))
                {
-                       m_ptr->csleep = 0;
-                       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                       /* Disturb the monster */
+                       (void)set_monster_csleep(c_ptr->m_idx, 0);
 
                        /* Extract monster name (or "it") */
                        monster_desc(m_name, m_ptr, 0);
@@ -3876,7 +3446,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        if (m_ptr->ml)
                        {
                                /* Auto-Recall if possible and visible */
-                               monster_race_track(m_ptr->ap_r_idx);
+                               if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
 
                                /* Track a new monster */
                                health_track(c_ptr->m_idx);
@@ -3924,9 +3494,9 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 #endif
                        energy_use = 0;
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
-               else if (riding_m_ptr->monfear)
+               else if (MON_MONFEAR(riding_m_ptr))
                {
                        char m_name[80];
 
@@ -3940,12 +3510,12 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        msg_format("%^s is too scared to control.", m_name);
 #endif
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
                else if (p_ptr->riding_ryoute)
                {
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
                else if (have_flag(f_ptr->flags, FF_CAN_FLY) && (riding_r_ptr->flags7 & RF7_CAN_FLY))
                {
@@ -3966,7 +3536,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 #endif
                        energy_use = 0;
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
                else if (!have_flag(f_ptr->flags, FF_WATER) && (riding_r_ptr->flags7 & RF7_AQUATIC))
                {
@@ -3977,7 +3547,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 #endif
                        energy_use = 0;
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
                else if (have_flag(f_ptr->flags, FF_LAVA) && !(riding_r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK))
                {
@@ -3988,10 +3558,10 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 #endif
                        energy_use = 0;
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
 
-               if (oktomove && riding_m_ptr->stunned && one_in_(2))
+               if (oktomove && MON_STUNNED(riding_m_ptr) && one_in_(2))
                {
                        char m_name[80];
                        monster_desc(m_name, riding_m_ptr, 0);
@@ -4001,7 +3571,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        msg_format("You cannot control stunned %s!",m_name);
 #endif
                        oktomove = FALSE;
-                       disturb(0, 0);
+                       disturb(0, 1);
                }
        }
 
@@ -4029,7 +3599,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
         */
        else if (have_flag(f_ptr->flags, FF_TREE) && !p_can_kill_walls)
        {
-               if ((p_ptr->pclass != CLASS_RANGER) && !p_ptr->levitation) energy_use *= 2;
+               if ((p_ptr->pclass != CLASS_RANGER) && !p_ptr->levitation && (!p_ptr->riding || !(riding_r_ptr->flags8 & RF8_WILD_WOOD))) energy_use *= 2;
        }
 
 #ifdef ALLOW_EASY_DISARM /* TNB */
@@ -4056,9 +3626,6 @@ void move_player(int dir, bool do_pickup, bool break_trap)
 
                oktomove = FALSE;
 
-               /* Disturb the player */
-               disturb(0, 0);
-
                /* Notice things in the dark */
                if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
                {
@@ -4128,6 +3695,9 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        }
                }
 
+               /* Disturb the player */
+               disturb(0, 1);
+
                /* Sound */
                if (!boundary_floor(c_ptr, f_ptr, mimic_f_ptr)) sound(SOUND_HITWALL);
        }
@@ -4141,7 +3711,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                }
 
                /* To avoid a loop with running */
-               disturb(0, 0);
+               disturb(0, 1);
 
                oktomove = FALSE;
        }
@@ -4961,3 +4531,147 @@ void run_step(int dir)
                disturb(0, 0);
        }
 }
+
+
+#ifdef TRAVEL
+/*
+ * Test for traveling
+ */
+static int travel_test(int prev_dir)
+{
+       int new_dir = 0;
+       int i, max;
+       const cave_type *c_ptr;
+       int cost;
+
+       /* Cannot travel when blind */
+       if (p_ptr->blind || no_lite())
+       {
+               msg_print(_("Ìܤ¬¸«¤¨¤Ê¤¤¡ª", "You cannot see!"));
+               return (0);
+       }
+
+       /* break run when leaving trap detected region */
+       if ((disturb_trap_detect || alert_trap_detect)
+           && p_ptr->dtrap && !(cave[py][px].info & CAVE_IN_DETECT))
+       {
+               /* No duplicate warning */
+               p_ptr->dtrap = FALSE;
+
+               /* You are just on the edge */
+               if (!(cave[py][px].info & CAVE_UNSAFE))
+               {
+                       if (alert_trap_detect)
+                       {
+#ifdef JP
+                               msg_print("* Ãí°Õ:¤³¤ÎÀè¤Ï¥È¥é¥Ã¥×¤Î´¶ÃÎÈϰϳ°¤Ç¤¹¡ª *");
+#else
+                               msg_print("*Leaving trap detect region!*");
+#endif
+                       }
+
+                       if (disturb_trap_detect)
+                       {
+                               /* Break Run */
+                               return (0);
+                       }
+               }
+       }
+
+       /* Range of newly adjacent grids */
+       max = (prev_dir & 0x01) + 1;
+
+       /* Look at every newly adjacent square. */
+       for (i = -max; i <= max; i++)
+       {
+               /* New direction */
+               int dir = cycle[chome[prev_dir] + i];
+
+               /* New location */
+               int row = py + ddy[dir];
+               int col = px + ddx[dir];
+
+               /* Access grid */
+               c_ptr = &cave[row][col];
+
+               /* Visible monsters abort running */
+               if (c_ptr->m_idx)
+               {
+                       monster_type *m_ptr = &m_list[c_ptr->m_idx];
+
+                       /* Visible monster */
+                       if (m_ptr->ml) return (0);
+               }
+
+       }
+
+       /* Travel cost of current grid */
+       cost = travel.cost[py][px];
+
+       /* Determine travel direction */
+       for (i = 0; i < 8; ++ i) {
+               int dir_cost = travel.cost[py+ddy_ddd[i]][px+ddx_ddd[i]];
+
+               if (dir_cost < cost)
+               {
+                       new_dir = ddd[i];
+                       cost = dir_cost;
+               }
+       }
+
+       if (!new_dir) return (0);
+
+       /* Access newly move grid */
+       c_ptr = &cave[py+ddy[new_dir]][px+ddx[new_dir]];
+
+       /* Close door abort traveling */
+       if (!easy_open && is_closed_door(c_ptr->feat)) return (0);
+
+       /* Visible and unignorable trap abort tarveling */
+       if (!c_ptr->mimic && !trap_can_be_ignored(c_ptr->feat)) return (0);
+
+       /* Move new grid */
+       return (new_dir);
+}
+
+
+/*
+ * Travel command
+ */
+void travel_step(void)
+{
+       /* Get travel direction */
+       travel.dir = travel_test(travel.dir);
+
+       /* disturb */
+       if (!travel.dir)
+       {
+               if (travel.run == 255)
+               {
+#ifdef JP
+                       msg_print("Æ»¶Ú¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡ª");
+#else
+                       msg_print("No route is found!");
+#endif
+                       travel.y = travel.x = 0;
+               }
+               disturb(0, 1);
+               return;
+       }
+
+       energy_use = 100;
+
+       move_player(travel.dir, always_pickup, FALSE);
+
+       if ((py == travel.y) && (px == travel.x))
+       {
+               travel.run = 0;
+               travel.y = travel.x = 0;
+       }
+       else if (travel.run > 0)
+               travel.run--;
+
+       /* Travel Delay */
+       Term_xtra(TERM_XTRA_DELAY, delay_factor);
+}
+#endif