OSDN Git Service

RF3_NONLIVINGの参照をmonster_living()でまとめられる部分をまとめた. こ
[hengband/hengband.git] / src / cmd1.c
index 3efd8f0..754d37e 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;
 
@@ -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)
                                        {
-                                               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)
                                        {
-                                               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,19 +507,19 @@ 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)
                                        {
-                                               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)
                                        {
@@ -546,18 +546,18 @@ 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)
                                        {
-                                               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)
                                        {
@@ -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)
                                        {
-                                               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);
@@ -624,7 +624,7 @@ 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;
@@ -1123,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;
@@ -1271,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("¤·¤«¤·ÆǤαƶÁ¤Ï¤Ê¤«¤Ã¤¿¡ª");
@@ -1530,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);
                        }
@@ -1626,6 +1626,7 @@ msg_print("
                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
@@ -1652,8 +1653,24 @@ msg_print("
                                        /* Require line of sight */
                                        if (!player_has_los_bold(y1, x1)) continue;
 
-                                       (void)summon_specific(0, y1, x1, lev, SUMMON_DEMON, (PM_NO_PET));
-                                       (void)summon_specific(0, y1, x1, lev, SUMMON_ANGEL, (PM_NO_PET));
+                                       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;
@@ -1708,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("ÆÍÁ³¤È¤Æ¤âÇ®¤¯¤Ê¤Ã¤¿¡ª");
@@ -1717,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) r_ptr->r_flags2 |= RF2_AURA_FIRE;
                        handle_stuff();
                }
        }
@@ -1735,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("ÆÍÁ³¤È¤Æ¤â´¨¤¯¤Ê¤Ã¤¿¡ª");
@@ -1744,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) r_ptr->r_flags3 |= RF3_AURA_COLD;
                        handle_stuff();
                }
        }
@@ -1762,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
@@ -1774,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) r_ptr->r_flags2 |= RF2_AURA_ELEC;
                        handle_stuff();
                }
        }
@@ -2001,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;
                }
@@ -2017,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);
                        }
                }
@@ -2039,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);
                        }
@@ -2051,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") */
@@ -2102,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 */
@@ -2369,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)
                                {
@@ -2425,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
@@ -2450,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);
@@ -2519,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;
                        }
@@ -2832,11 +2843,11 @@ 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) r_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
                                                msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
 #else
@@ -2847,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) r_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
                                                msg_format("%^s¤ÏÄñ¹³ÎϤò»ý¤Ã¤Æ¤¤¤ë¡ª", m_name);
 #else
@@ -2867,7 +2878,7 @@ 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;
                                }
                        }
@@ -2875,9 +2886,8 @@ msg_format("
                        else if ((chaos_effect == 5) && cave_floor_bold(y, x) &&
                                 (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))
                                        {
@@ -2903,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
@@ -3006,15 +3016,15 @@ 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)))
@@ -3226,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;
@@ -3408,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 */
@@ -3876,7 +3902,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("ÍÏ´ä¤Î¾å¤Ë¹Ô¤±¤Ê¤¤¡£");
@@ -3945,13 +3971,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);
@@ -3971,7 +4007,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;
 
@@ -3996,6 +4031,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;
@@ -4005,19 +4052,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 */
@@ -4041,7 +4087,7 @@ msg_format("%s
 
                if (p_ptr->warning)
                {
-                       if(!process_frakir(x,y))
+                       if(!process_warning(x, y))
                        {
                                energy_use = 25;
                                return;
@@ -4115,6 +4161,9 @@ msg_format("%s
                        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);
 
@@ -4807,7 +4856,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;
@@ -5169,7 +5218,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;