OSDN Git Service

[implement] #37674 (2.2.1.5) REFLECT効果音を新規定義。HIT_WALL効果音を走る時にも指定。HIT_WALLに魔王魂の効果音指定を追...
[hengband/hengband.git] / src / cmd1.c
index 77b418a..ee3358e 100644 (file)
@@ -158,18 +158,16 @@ bool test_hit_fire(int chance, monster_type *m_ptr, int vis, char* o_name)
 {
        int k, ac;
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
-       
-       ac = r_ptr->ac;
-       if(m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
 
        /* Percentile dice */
-       k = randint0(100);
+       k = randint1(100);
        
        /* Snipers with high-concentration reduce instant miss percentage.*/
        k += p_ptr->concent;
        
        /* Hack -- Instant miss or hit */
-       if (k < 10) return (k < 5);
+       if (k <= 5) return (FALSE);
+       if (k > 95) return (TRUE);
 
        if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
                if (one_in_(20)) return (FALSE);
@@ -177,6 +175,15 @@ bool test_hit_fire(int chance, monster_type *m_ptr, int vis, char* o_name)
        /* Never hit */
        if (chance <= 0) return (FALSE);
 
+       ac = r_ptr->ac;
+       if (p_ptr->concent)
+       {
+               ac *= (8 - p_ptr->concent);
+               ac /= 8;
+       }
+
+       if(m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
+
        /* Invisible monsters are harder to hit */
        if (!vis) chance = (chance + 1) / 2;
 
@@ -246,7 +253,7 @@ bool test_hit_norm(int chance, int ac, int vis)
  * @param dam 現在算出中のダメージ値
  * @return クリティカル修正が入ったダメージ値
  */
-s16b critical_shot(int weight, int plus_ammo, int plus_bow, int dam)
+HIT_POINT critical_shot(int weight, int plus_ammo, int plus_bow, HIT_POINT dam)
 {
        int i, k;
        object_type *j_ptr =  &inventory[INVEN_BOW];
@@ -304,7 +311,7 @@ s16b critical_shot(int weight, int plus_ammo, int plus_bow, int dam)
  * @param mode オプションフラグ
  * @return クリティカル修正が入ったダメージ値
  */
-s16b critical_norm(int weight, int plus, int dam, s16b meichuu, int mode)
+HIT_POINT critical_norm(int weight, int plus, HIT_POINT dam, s16b meichuu, BIT_FLAGS mode)
 {
        int i, k;
        
@@ -357,12 +364,12 @@ s16b critical_norm(int weight, int plus, int dam, s16b meichuu, int mode)
  * @param m_ptr 目標モンスターの構造体参照ポインタ
  * @return スレイング加味後の倍率(/10倍)
  */
-static int mult_slaying(int mult, const u32b* flgs, const monster_type* m_ptr)
+static MULTIPLY mult_slaying(MULTIPLY mult, const BIT_FLAGS* flgs, const monster_type* m_ptr)
 {
        static const struct slay_table_t {
                int slay_flag;
-               u32b affect_race_flag;
-               int slay_mult;
+               BIT_FLAGS affect_race_flag;
+               MULTIPLY slay_mult;
                size_t flag_offset;
                size_t r_flag_offset;
        } slay_table[] = {
@@ -418,12 +425,12 @@ static int mult_slaying(int mult, const u32b* flgs, const monster_type* m_ptr)
  * @param m_ptr 目標モンスターの構造体参照ポインタ
  * @return スレイング加味後の倍率(/10倍)
  */
-static int mult_brand(int mult, const u32b* flgs, const monster_type* m_ptr)
+static MULTIPLY mult_brand(MULTIPLY mult, const BIT_FLAGS* flgs, const monster_type* m_ptr)
 {
        static const struct brand_table_t {
                int brand_flag;
-               u32b resist_mask;
-               u32b hurt_flag;
+               BIT_FLAGS resist_mask;
+               BIT_FLAGS hurt_flag;
        } brand_table[] = {
                {TR_BRAND_ACID, RFR_EFF_IM_ACID_MASK, 0U           },
                {TR_BRAND_ELEC, RFR_EFF_IM_ELEC_MASK, 0U           },
@@ -485,11 +492,11 @@ static int mult_brand(int mult, const u32b* flgs, const monster_type* m_ptr)
  * Note that most brands and slays are x3, except Slay Animal (x2),\n
  * Slay Evil (x2), and Kill dragon (x5).\n
  */
-s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bool thrown)
+s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, BIT_FLAGS mode, bool thrown)
 {
-       int mult = 10;
+       MULTIPLY mult = 10;
 
-       u32b flgs[TR_FLAG_SIZE];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
 
        /* Extract the flags */
        object_flags(o_ptr, flgs);
@@ -560,10 +567,9 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bo
  * @param x 対象となるマスのX座標
  * @return なし
  */
-static void discover_hidden_things(int y, int x)
+static void discover_hidden_things(POSITION y, POSITION x)
 {
-       s16b this_o_idx, next_o_idx = 0;
-
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
        cave_type *c_ptr;
 
        /* Access the grid */
@@ -633,7 +639,8 @@ static void discover_hidden_things(int y, int x)
  */
 void search(void)
 {
-       int i, chance;
+       DIRECTION i;
+       PERCENTAGE chance;
 
        /* Start with base search ability */
        chance = p_ptr->skill_srh;
@@ -648,7 +655,7 @@ void search(void)
                /* Sometimes, notice things */
                if (randint0(100) < chance)
                {
-                       discover_hidden_things(py + ddy_ddd[i], px + ddx_ddd[i]);
+                       discover_hidden_things(p_ptr->y + ddy_ddd[i], p_ptr->x + ddx_ddd[i]);
                }
        }
 }
@@ -718,9 +725,9 @@ void py_pickup_aux(int o_idx)
 #ifdef JP
        if ((o_ptr->name1 == ART_CRIMSON) && (p_ptr->pseikaku == SEIKAKU_COMBAT))
        {
-               msg_format("こうして、%sは『クリムゾン』を手に入れた。", player_name);
+               msg_format("こうして、%sは『クリムゾン』を手に入れた。", p_ptr->name);
                msg_print("しかし今、『混沌のサーペント』の放ったモンスターが、");
-               msg_format("%sに襲いかかる...", player_name);
+               msg_format("%sに襲いかかる...", p_ptr->name);
        }
        else
        {
@@ -761,7 +768,7 @@ void py_pickup_aux(int o_idx)
  */
 void carry(bool pickup)
 {
-       cave_type *c_ptr = &cave[py][px];
+       cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
 
        s16b this_o_idx, next_o_idx = 0;
 
@@ -943,7 +950,7 @@ static int check_hit(int power)
  */
 static void hit_trap_pit(int trap_feat_type)
 {
-       int dam;
+       HIT_POINT dam;
        cptr trap_name = "";
        cptr spike_name = "";
 
@@ -1058,13 +1065,13 @@ static void hit_trap_slow(void)
  * @param turn 状態異常の追加ターン量
  * @return なし
  */
-static void hit_trap_set_abnormal_status(cptr trap_message, bool resist, bool (*set_status)(int turn), int turn)
+static void hit_trap_set_abnormal_status(cptr trap_message, bool resist, bool (*set_status)(IDX), IDX turn_aux)
 {
        msg_print(trap_message);
 
        if (!resist)
        {
-               set_status(turn);
+               set_status(turn_aux);
        }
 }
 
@@ -1077,7 +1084,7 @@ static void hit_trap_set_abnormal_status(cptr trap_message, bool resist, bool (*
 static void hit_trap(bool break_trap)
 {
        int i, num, dam;
-       int x = px, y = py;
+       int x = p_ptr->x, y = p_ptr->y;
 
        /* Get the cave grid */
        cave_type *c_ptr = &cave[y][x];
@@ -1207,7 +1214,7 @@ static void hit_trap(bool break_trap)
                        hit_trap_set_abnormal_status(
                                _("黒いガスに包み込まれた!", "A black gas surrounds you!"),
                                p_ptr->resist_blind,
-                               set_blind, p_ptr->blind + randint0(50) + 25);
+                               set_blind, p_ptr->blind + (TIME_EFFECT)randint0(50) + 25);
                        break;
                }
 
@@ -1216,7 +1223,7 @@ static void hit_trap(bool break_trap)
                        hit_trap_set_abnormal_status(
                                _("きらめくガスに包み込まれた!", "A gas of scintillating colors surrounds you!"),
                                p_ptr->resist_conf,
-                               set_confused, p_ptr->confused + randint0(20) + 10);
+                               set_confused, p_ptr->confused + (TIME_EFFECT)randint0(20) + 10);
                        break;
                }
 
@@ -1225,7 +1232,7 @@ static void hit_trap(bool break_trap)
                        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);
+                               set_poisoned, p_ptr->poisoned + (TIME_EFFECT)randint0(20) + 10);
                        break;
                }
 
@@ -1240,14 +1247,9 @@ static void hit_trap(bool break_trap)
                                {
                                        msg_print(_("身の毛もよだつ光景が頭に浮かんだ。", "A horrible vision enters your mind."));
 
-                                       /* Pick a nightmare */
-                                       get_mon_num_prep(get_nightmare, NULL);
-
                                        /* Have some nightmares */
-                                       have_nightmare(get_mon_num(MAX_DEPTH));
+                                       sanity_blast(NULL, FALSE);
 
-                                       /* Remove the monster restriction */
-                                       get_mon_num_prep(NULL, NULL);
                                }
                                (void)set_paralyzed(p_ptr->paralyzed + randint0(10) + 5);
                        }
@@ -1304,7 +1306,7 @@ static void hit_trap(bool break_trap)
                                        if (!in_bounds(y1, x1)) continue;
 
                                        /* Require line of projection */
-                                       if (!projectable(py, px, y1, x1)) continue;
+                                       if (!projectable(p_ptr->y, p_ptr->x, y1, x1)) continue;
 
                                        if (summon_specific(0, y1, x1, lev, SUMMON_ARMAGE_EVIL, (PM_NO_PET)))
                                                evil_idx = hack_m_idx_ii;
@@ -1366,7 +1368,7 @@ static void hit_trap(bool break_trap)
  * @return なし
  */
 static void touch_zap_player_aux(monster_type *m_ptr, bool immune, int flags_offset, int r_flags_offset, u32b aura_flag,
-                                int (*dam_func)(int dam, cptr kb_str, int monspell, bool aura), cptr message)
+                                int (*dam_func)(HIT_POINT dam, cptr kb_str, int monspell, bool aura), cptr message)
 {
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
@@ -1417,55 +1419,56 @@ static void touch_zap_player(monster_type *m_ptr)
  */
 static void natural_attack(s16b m_idx, int attack, bool *fear, bool *mdeath)
 {
-       int             k, bonus, chance;
+       HIT_POINT k;
+       int bonus, chance;
        int             n_weight = 0;
        monster_type    *m_ptr = &m_list[m_idx];
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
        char            m_name[80];
 
-       int             dss, ddd;
+       int             dice_num, dice_side;
 
        cptr            atk_desc;
 
        switch (attack)
        {
                case MUT2_SCOR_TAIL:
-                       dss = 3;
-                       ddd = 7;
+                       dice_num = 3;
+                       dice_side = 7;
                        n_weight = 5;
                        atk_desc = _("尻尾", "tail");
 
                        break;
                case MUT2_HORNS:
-                       dss = 2;
-                       ddd = 6;
+                       dice_num = 2;
+                       dice_side = 6;
                        n_weight = 15;
                        atk_desc = _("角", "horns");
 
                        break;
                case MUT2_BEAK:
-                       dss = 2;
-                       ddd = 4;
+                       dice_num = 2;
+                       dice_side = 4;
                        n_weight = 5;
                        atk_desc = _("クチバシ", "beak");
 
                        break;
                case MUT2_TRUNK:
-                       dss = 1;
-                       ddd = 4;
+                       dice_num = 1;
+                       dice_side = 4;
                        n_weight = 35;
                        atk_desc = _("象の鼻", "trunk");
 
                        break;
                case MUT2_TENTACLES:
-                       dss = 2;
-                       ddd = 5;
+                       dice_num = 2;
+                       dice_side = 5;
                        n_weight = 5;
                        atk_desc = _("触手", "tentacles");
 
                        break;
                default:
-                       dss = ddd = n_weight = 1;
+                       dice_num = dice_side = n_weight = 1;
                        atk_desc = _("未定義の部位", "undefined body part");
 
        }
@@ -1486,7 +1489,7 @@ static void natural_attack(s16b m_idx, int attack, bool *fear, bool *mdeath)
                sound(SOUND_HIT);
                msg_format(_("%sを%sで攻撃した。", "You hit %s with your %s."), m_name, atk_desc);
 
-               k = damroll(ddd, dss);
+               k = damroll(dice_num, dice_side);
                k = critical_norm(n_weight, bonus, k, (s16b)bonus, 0);
 
                /* Apply the player damage bonuses */
@@ -1499,10 +1502,9 @@ static void natural_attack(s16b m_idx, int attack, bool *fear, bool *mdeath)
                k = mon_damage_mod(m_ptr, k, FALSE);
 
                /* Complex message */
-               if (p_ptr->wizard)
-               {
-                       msg_format(_("%d/%d のダメージを与えた。", "You do %d (out of %d) damage."), k, m_ptr->hp);
-               }
+               msg_format_wizard(CHEAT_MONSTER,
+                       _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
+                       k, m_ptr->hp - k, m_ptr->maxhp, m_ptr->max_maxhp);
 
                /* Anger the monster */
                if (k > 0) anger_monster(m_ptr);
@@ -1557,9 +1559,10 @@ static void natural_attack(s16b m_idx, int attack, bool *fear, bool *mdeath)
  * @details
  * If no "weapon" is available, then "punch" the monster one time.
  */
-static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int mode)
+static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, BIT_FLAGS mode)
 {
-       int             num = 0, k, bonus, chance, vir;
+       int             num = 0, bonus, chance, vir;
+       HIT_POINT k;
 
        cave_type       *c_ptr = &cave[y][x];
 
@@ -1645,12 +1648,12 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
        {
                if ((r_ptr->level + 10) > p_ptr->lev)
                {
-                       int tval = inventory[INVEN_RARM+hand].tval - TV_WEAPON_BEGIN;
-                       int sval = inventory[INVEN_RARM+hand].sval;
+                       OBJECT_TYPE_VALUE tval = inventory[INVEN_RARM+hand].tval - TV_WEAPON_BEGIN;
+                       OBJECT_SUBTYPE_VALUE sval = inventory[INVEN_RARM+hand].sval;
                        int now_exp = p_ptr->weapon_exp[tval][sval];
                        if (now_exp < s_info[p_ptr->pclass].w_max[tval][sval])
                        {
-                               int amount = 0;
+                               SUB_EXP amount = 0;
                                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;
@@ -1881,9 +1884,9 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                }
 
                                if (p_ptr->special_defense & KAMAE_SUZAKU) weight = 4;
-                               if ((p_ptr->pclass == CLASS_FORCETRAINER) && (p_ptr->magic_num1[0]))
+                               if ((p_ptr->pclass == CLASS_FORCETRAINER) && P_PTR_KI)
                                {
-                                       weight += (p_ptr->magic_num1[0]/30);
+                                       weight += (P_PTR_KI / 30);
                                        if (weight > 20) weight = 20;
                                }
 
@@ -1981,7 +1984,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                                mult++;
                                        }
 
-                                       k *= mult;
+                                       k *= (HIT_POINT)mult;
 
                                        /* Ouch! */
                                        if (((r_ptr->flagsr & RFR_RES_ALL) ? k/100 : k) > m_ptr->hp)
@@ -2101,11 +2104,9 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                }
                        }
 
-                       /* Complex message */
-                       if (p_ptr->wizard || cheat_xtra)
-                       {
-                               msg_format(_("%d/%d のダメージを与えた。", "You do %d (out of %d) damage."), k, m_ptr->hp);
-                       }
+                       msg_format_wizard(CHEAT_MONSTER,
+                               _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"), k,
+                               m_ptr->hp - k, m_ptr->maxhp, m_ptr->max_maxhp);
 
                        if (k <= 0) can_drain = FALSE;
 
@@ -2116,16 +2117,16 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        if (mon_take_hit(c_ptr->m_idx, k, fear, NULL))
                        {
                                *mdeath = TRUE;
-                               if ((p_ptr->pclass == CLASS_BERSERKER) && energy_use)
+                               if ((p_ptr->pclass == CLASS_BERSERKER) && p_ptr->energy_use)
                                {
                                        if (p_ptr->migite && p_ptr->hidarite)
                                        {
-                                               if (hand) energy_use = energy_use*3/5+energy_use*num*2/(p_ptr->num_blow[hand]*5);
-                                               else energy_use = energy_use*num*3/(p_ptr->num_blow[hand]*5);
+                                               if (hand) p_ptr->energy_use = p_ptr->energy_use*3/5+p_ptr->energy_use*num*2/(p_ptr->num_blow[hand]*5);
+                                               else p_ptr->energy_use = p_ptr->energy_use*num*3/(p_ptr->num_blow[hand]*5);
                                        }
                                        else
                                        {
-                                               energy_use = energy_use*num/p_ptr->num_blow[hand];
+                                               p_ptr->energy_use = p_ptr->energy_use*num/p_ptr->num_blow[hand];
                                        }
                                }
                                if ((o_ptr->name1 == ART_ZANTETSU) && is_lowlevel)
@@ -2147,8 +2148,8 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                {
                                        if (is_human)
                                        {
-                                               int to_h = o_ptr->to_h;
-                                               int to_d = o_ptr->to_d;
+                                               HIT_PROB to_h = o_ptr->to_h;
+                                               HIT_POINT to_d = o_ptr->to_d;
                                                int i, flag;
 
                                                flag = 1;
@@ -2301,17 +2302,17 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                        }
                        else if (o_ptr->name1 == ART_G_HAMMER)
                        {
-                               monster_type *m_ptr = &m_list[c_ptr->m_idx];
+                               monster_type *target_ptr = &m_list[c_ptr->m_idx];
 
-                               if (m_ptr->hold_o_idx)
+                               if (target_ptr->hold_o_idx)
                                {
-                                       object_type *q_ptr = &o_list[m_ptr->hold_o_idx];
+                                       object_type *q_ptr = &o_list[target_ptr->hold_o_idx];
                                        char o_name[MAX_NLEN];
 
                                        object_desc(o_name, q_ptr, OD_NAME_ONLY);
                                        q_ptr->held_m_idx = 0;
                                        q_ptr->marked = OM_TOUCHED;
-                                       m_ptr->hold_o_idx = q_ptr->next_o_idx;
+                                       target_ptr->hold_o_idx = q_ptr->next_o_idx;
                                        q_ptr->next_o_idx = 0;
                                        msg_format(_("%sを奪った。", "You snatched %s."), o_name);
                                        inven_carry(q_ptr);
@@ -2327,7 +2328,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
 
                        if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE) && one_in_(3))
                        {
-                               u32b flgs[TR_FLAG_SIZE];
+                               u32b flgs_aux[TR_FLAG_SIZE];
 
                                /* Sound */
                                sound(SOUND_HIT);
@@ -2338,7 +2339,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                msg_print(_("振り回した大鎌が自分自身に返ってきた!", "Your scythe returns to you!"));
 
                                /* Extract the flags */
-                               object_flags(o_ptr, flgs);
+                               object_flags(o_ptr, flgs_aux);
 
                                k = damroll(o_ptr->dd + p_ptr->to_dd[hand], o_ptr->ds + p_ptr->to_ds[hand]);
                                {
@@ -2395,13 +2396,13 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        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)))
+                                       if ((p_ptr->pclass != CLASS_SAMURAI) && (have_flag(flgs_aux, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
                                        {
                                                p_ptr->csp -= (1+(p_ptr->msp / 30));
                                                p_ptr->redraw |= (PR_MANA);
                                                mult = mult * 3 / 2 + 20;
                                        }
-                                       k *= mult;
+                                       k *= (HIT_POINT)mult;
                                        k /= 10;
                                }
 
@@ -2416,7 +2417,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                                mult++;
                                        }
 
-                                       k *= mult;
+                                       k *= (HIT_POINT)mult;
                                }
                                k += (p_ptr->to_d[hand] + o_ptr->to_d);
                                if (k < 0) k = 0;
@@ -2452,7 +2453,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
        /* Mega-Hack -- apply earthquake brand */
        if (do_quake)
        {
-               earthquake(py, px, 10);
+               earthquake(p_ptr->y, p_ptr->x, 10);
                if (!cave[y][x].m_idx) *mdeath = TRUE;
        }
 }
@@ -2466,7 +2467,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
  * @details
  * If no "weapon" is available, then "punch" the monster one time.
  */
-bool py_attack(int y, int x, int mode)
+bool py_attack(int y, int x, BIT_FLAGS mode)
 {
        bool            fear = FALSE;
        bool            mdeath = FALSE;
@@ -2480,7 +2481,7 @@ bool py_attack(int y, int x, int mode)
        /* Disturb the player */
        disturb(0, 1);
 
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        if (!p_ptr->migite && !p_ptr->hidarite &&
            !(p_ptr->muta2 & (MUT2_HORNS | MUT2_BEAK | MUT2_SCOR_TAIL | MUT2_TRUNK | MUT2_TENTACLES)))
@@ -2822,22 +2823,22 @@ bool player_can_enter(s16b feature, u16b mode)
  * @param mpe_mode 移動オプションフラグ
  * @return プレイヤーが死亡やフロア離脱を行わず、実際に移動が可能ならばTRUEを返す。
  */
-bool move_player_effect(int ny, int nx, u32b mpe_mode)
+bool move_player_effect(POSITION ny, POSITION nx, u32b mpe_mode)
 {
        cave_type *c_ptr = &cave[ny][nx];
        feature_type *f_ptr = &f_info[c_ptr->feat];
 
        if (!(mpe_mode & MPE_STAYING))
        {
-               int oy = py;
-               int ox = px;
+               POSITION oy = p_ptr->y;
+               POSITION ox = p_ptr->x;
                cave_type *oc_ptr = &cave[oy][ox];
-               int om_idx = oc_ptr->m_idx;
-               int nm_idx = c_ptr->m_idx;
+               IDX om_idx = oc_ptr->m_idx;
+               IDX nm_idx = c_ptr->m_idx;
 
                /* Move the player */
-               py = ny;
-               px = nx;
+               p_ptr->y = ny;
+               p_ptr->x = nx;
 
                /* Hack -- For moving monster or riding player's moving */
                if (!(mpe_mode & MPE_DONT_SWAP_MON))
@@ -2917,7 +2918,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
        {
                if (music_singing(MUSIC_WALL))
                {
-                       (void)project(0, 0, py, px, (60 + p_ptr->lev), GF_DISINTEGRATE,
+                       (void)project(0, 0, p_ptr->y, p_ptr->x, (60 + p_ptr->lev), GF_DISINTEGRATE,
                                PROJECT_KILL | PROJECT_ITEM, -1);
 
                        if (!player_bold(ny, nx) || p_ptr->is_dead || p_ptr->leaving) return FALSE;
@@ -2948,7 +2949,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
                /* Disturb */
                disturb(0, 1);
 
-               energy_use = 0;
+               p_ptr->energy_use = 0;
                /* Hack -- Enter store */
                command_new = SPECIAL_KEY_STORE;
        }
@@ -2959,7 +2960,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
                /* Disturb */
                disturb(0, 1);
 
-               energy_use = 0;
+               p_ptr->energy_use = 0;
                /* Hack -- Enter building */
                command_new = SPECIAL_KEY_BUILDING;
        }
@@ -2970,7 +2971,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
                /* Disturb */
                disturb(0, 1);
 
-               energy_use = 0;
+               p_ptr->energy_use = 0;
                /* Hack -- Enter quest level */
                command_new = SPECIAL_KEY_QUEST;
        }
@@ -3005,7 +3006,7 @@ bool move_player_effect(int ny, int nx, u32b mpe_mode)
                        msg_print(_("トラップだ!", "You found a trap!"));
 
                        /* Pick a trap */
-                       disclose_grid(py, px);
+                       disclose_grid(p_ptr->y, p_ptr->x);
                }
 
                /* Hit the trap */
@@ -3106,11 +3107,11 @@ bool trap_can_be_ignored(int feat)
  * any monster which might be in the destination grid.  Previously,\n
  * moving into walls was "free" and did NOT hit invisible monsters.\n
  */
-void move_player(int dir, bool do_pickup, bool break_trap)
+void move_player(DIRECTION dir, bool do_pickup, bool break_trap)
 {
        /* Find the result of moving */
-       int y = py + ddy[dir];
-       int x = px + ddx[dir];
+       POSITION y = p_ptr->y + ddy[dir];
+       POSITION x = p_ptr->x + ddx[dir];
 
        /* Examine the destination */
        cave_type *c_ptr = &cave[y][x];
@@ -3209,7 +3210,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        }
 
                        p_ptr->leaving = TRUE;
-                       energy_use = 100;
+                       p_ptr->energy_use = 100;
 
                        return;
                }
@@ -3241,7 +3242,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                if (!is_hostile(m_ptr) &&
                    !(p_ptr->confused || p_ptr->image || !m_ptr->ml || p_ptr->stun ||
                    ((p_ptr->muta2 & MUT2_BERS_RAGE) && p_ptr->shero)) &&
-                   pattern_seq(py, px, y, x) && (p_can_enter || p_can_kill_walls))
+                   pattern_seq(p_ptr->y, p_ptr->x, y, x) && (p_can_enter || p_can_kill_walls))
                {
                        /* Disturb the monster */
                        (void)set_monster_csleep(c_ptr->m_idx, 0);
@@ -3264,14 +3265,14 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                                py_attack(y, x, 0);
                                oktomove = FALSE;
                        }
-                       else if (monster_can_cross_terrain(cave[py][px].feat, r_ptr, 0))
+                       else if (monster_can_cross_terrain(cave[p_ptr->y][p_ptr->x].feat, r_ptr, 0))
                        {
                                do_past = TRUE;
                        }
                        else
                        {
                                msg_format(_("%^sが邪魔だ!", "%^s is in your way!"), m_name);
-                               energy_use = 0;
+                               p_ptr->energy_use = 0;
                                oktomove = FALSE;
                        }
 
@@ -3289,19 +3290,19 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                if (riding_r_ptr->flags1 & RF1_NEVER_MOVE)
                {
                        msg_print(_("動けない!", "Can't move!"));
-                       energy_use = 0;
+                       p_ptr->energy_use = 0;
                        oktomove = FALSE;
                        disturb(0, 1);
                }
                else if (MON_MONFEAR(riding_m_ptr))
                {
-                       char m_name[80];
+                       char steed_name[80];
 
                        /* Acquire the monster name */
-                       monster_desc(m_name, riding_m_ptr, 0);
+                       monster_desc(steed_name, riding_m_ptr, 0);
 
                        /* Dump a message */
-                       msg_format(_("%sが恐怖していて制御できない。", "%^s is too scared to control."), m_name);
+                       msg_format(_("%sが恐怖していて制御できない。", "%^s is too scared to control."), steed_name);
                        oktomove = FALSE;
                        disturb(0, 1);
                }
@@ -3323,30 +3324,30 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        (have_flag(f_ptr->flags, FF_DEEP) || (riding_r_ptr->flags2 & RF2_AURA_FIRE)))
                {
                        msg_format(_("%sの上に行けない。", "Can't swim."), f_name + f_info[get_feat_mimic(c_ptr)].name);
-                       energy_use = 0;
+                       p_ptr->energy_use = 0;
                        oktomove = FALSE;
                        disturb(0, 1);
                }
                else if (!have_flag(f_ptr->flags, FF_WATER) && (riding_r_ptr->flags7 & RF7_AQUATIC))
                {
-                       msg_format(_("%sから上がれない。", "Can't land."), f_name + f_info[get_feat_mimic(&cave[py][px])].name);
-                       energy_use = 0;
+                       msg_format(_("%sから上がれない。", "Can't land."), f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name);
+                       p_ptr->energy_use = 0;
                        oktomove = FALSE;
                        disturb(0, 1);
                }
                else if (have_flag(f_ptr->flags, FF_LAVA) && !(riding_r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK))
                {
                        msg_format(_("%sの上に行けない。", "Too hot to go through."), f_name + f_info[get_feat_mimic(c_ptr)].name);
-                       energy_use = 0;
+                       p_ptr->energy_use = 0;
                        oktomove = FALSE;
                        disturb(0, 1);
                }
 
                if (oktomove && MON_STUNNED(riding_m_ptr) && one_in_(2))
                {
-                       char m_name[80];
-                       monster_desc(m_name, riding_m_ptr, 0);
-                       msg_format(_("%sが朦朧としていてうまく動けない!", "You cannot control stunned %s!"),m_name);
+                       char steed_name[80];
+                       monster_desc(steed_name, riding_m_ptr, 0);
+                       msg_format(_("%sが朦朧としていてうまく動けない!", "You cannot control stunned %s!"), steed_name);
                        oktomove = FALSE;
                        disturb(0, 1);
                }
@@ -3359,7 +3360,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
        else if (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation)
        {
                msg_format(_("空を飛ばないと%sの上には行けない。", "You need to fly to go through the %s."), f_name + f_info[get_feat_mimic(c_ptr)].name);
-               energy_use = 0;
+               p_ptr->energy_use = 0;
                running = 0;
                oktomove = FALSE;
        }
@@ -3371,7 +3372,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 && (!p_ptr->riding || !(riding_r_ptr->flags8 & RF8_WILD_WOOD))) energy_use *= 2;
+               if ((p_ptr->pclass != CLASS_RANGER) && !p_ptr->levitation && (!p_ptr->riding || !(riding_r_ptr->flags8 & RF8_WILD_WOOD))) p_ptr->energy_use *= 2;
        }
 
 #ifdef ALLOW_EASY_DISARM /* TNB */
@@ -3430,7 +3431,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                        {
                                msg_print(_("それ以上先には進めない。", "You cannot go any more."));
                                if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
-                                       energy_use = 0;
+                                       p_ptr->energy_use = 0;
                        }
 
                        /* Wall (or secret door) */
@@ -3454,7 +3455,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                                 * typing mistakes should not cost you a turn...
                                 */
                                if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
-                                       energy_use = 0;
+                                       p_ptr->energy_use = 0;
                        }
                }
 
@@ -3466,11 +3467,11 @@ void move_player(int dir, bool do_pickup, bool break_trap)
        }
 
        /* Normal movement */
-       if (oktomove && !pattern_seq(py, px, y, x))
+       if (oktomove && !pattern_seq(p_ptr->y, p_ptr->x, y, x))
        {
                if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
                {
-                       energy_use = 0;
+                       p_ptr->energy_use = 0;
                }
 
                /* To avoid a loop with running */
@@ -3488,7 +3489,7 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                {
                        if (!process_warning(x, y))
                        {
-                               energy_use = 25;
+                               p_ptr->energy_use = 25;
                                return;
                        }
                }
@@ -3632,12 +3633,12 @@ static byte chome[] =
 /*
  * The direction we are running
  */
-static byte find_current;
+static DIRECTION find_current;
 
 /*
  * The direction we came from
  */
-static byte find_prevdir;
+static DIRECTION find_prevdir;
 
 /*
  * We are looking for open area
@@ -3690,12 +3691,12 @@ static void run_init(int dir)
        deepleft = deepright = FALSE;
        shortright = shortleft = FALSE;
 
-       p_ptr->run_py = py;
-       p_ptr->run_px = px;
+       p_ptr->run_py = p_ptr->y;
+       p_ptr->run_px = p_ptr->x;
 
        /* Find the destination grid */
-       row = py + ddy[dir];
-       col = px + ddx[dir];
+       row = p_ptr->y + ddy[dir];
+       col = p_ptr->x + ddx[dir];
 
        ignore_avoid_run = cave_have_flag_bold(row, col, FF_AVOID_RUN);
 
@@ -3703,7 +3704,7 @@ static void run_init(int dir)
        i = chome[dir];
 
        /* Check for walls */
-       if (see_wall(cycle[i+1], py, px))
+       if (see_wall(cycle[i+1], p_ptr->y, p_ptr->x))
        {
                find_breakleft = TRUE;
                shortleft = TRUE;
@@ -3715,7 +3716,7 @@ static void run_init(int dir)
        }
 
        /* Check for walls */
-       if (see_wall(cycle[i-1], py, px))
+       if (see_wall(cycle[i-1], p_ptr->y, p_ptr->x))
        {
                find_breakright = TRUE;
                shortright = TRUE;
@@ -3787,13 +3788,13 @@ static bool run_test(void)
 
        /* break run when leaving trap detected region */
        if ((disturb_trap_detect || alert_trap_detect)
-           && p_ptr->dtrap && !(cave[py][px].info & CAVE_IN_DETECT))
+           && p_ptr->dtrap && !(cave[p_ptr->y][p_ptr->x].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 (!(cave[p_ptr->y][p_ptr->x].info & CAVE_UNSAFE))
                {
                        if (alert_trap_detect)
                        {
@@ -3817,8 +3818,8 @@ static bool run_test(void)
                new_dir = cycle[chome[prev_dir] + i];
 
                /* New location */
-               row = py + ddy[new_dir];
-               col = px + ddx[new_dir];
+               row = p_ptr->y + ddy[new_dir];
+               col = p_ptr->x + ddx[new_dir];
 
                /* Access grid */
                c_ptr = &cave[row][col];
@@ -3968,7 +3969,7 @@ static bool run_test(void)
                for (i = -max; i < 0; i++)
                {
                        /* Unknown grid or non-wall */
-                       if (!see_wall(cycle[chome[prev_dir] + i], py, px))
+                       if (!see_wall(cycle[chome[prev_dir] + i], p_ptr->y, p_ptr->x))
                        {
                                /* Looking to break right */
                                if (find_breakright)
@@ -3992,7 +3993,7 @@ static bool run_test(void)
                for (i = max; i > 0; i--)
                {
                        /* Unknown grid or non-wall */
-                       if (!see_wall(cycle[chome[prev_dir] + i], py, px))
+                       if (!see_wall(cycle[chome[prev_dir] + i], p_ptr->y, p_ptr->x))
                        {
                                /* Looking to break left */
                                if (find_breakleft)
@@ -4046,8 +4047,8 @@ static bool run_test(void)
                else
                {
                        /* Get next location */
-                       row = py + ddy[option];
-                       col = px + ddx[option];
+                       row = p_ptr->y + ddy[option];
+                       col = p_ptr->x + ddx[option];
 
                        /* Don't see that it is closed off. */
                        /* This could be a potential corner or an intersection. */
@@ -4088,7 +4089,7 @@ static bool run_test(void)
        }
 
        /* About to hit a known wall, stop */
-       if (see_wall(find_current, py, px))
+       if (see_wall(find_current, p_ptr->y, p_ptr->x))
        {
                return (TRUE);
        }
@@ -4114,8 +4115,10 @@ void run_step(int dir)
                ignore_avoid_run = TRUE;
 
                /* Hack -- do not start silly run */
-               if (see_wall(dir, py, px))
+               if (see_wall(dir, p_ptr->y, p_ptr->x))
                {
+                       sound(SOUND_HITWALL);
+
                        /* Message */
                        msg_print(_("その方向には走れません。", "You cannot run in that direction."));
 
@@ -4148,7 +4151,7 @@ void run_step(int dir)
        if (--running <= 0) return;
 
        /* Take time */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        /* Move the player, using the "pickup" flag */
 #ifdef ALLOW_EASY_DISARM /* TNB */
@@ -4194,13 +4197,13 @@ static int travel_test(int prev_dir)
 
        /* break run when leaving trap detected region */
        if ((disturb_trap_detect || alert_trap_detect)
-           && p_ptr->dtrap && !(cave[py][px].info & CAVE_IN_DETECT))
+           && p_ptr->dtrap && !(cave[p_ptr->y][p_ptr->x].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 (!(cave[p_ptr->y][p_ptr->x].info & CAVE_UNSAFE))
                {
                        if (alert_trap_detect)
                        {
@@ -4225,8 +4228,8 @@ static int travel_test(int prev_dir)
                int dir = cycle[chome[prev_dir] + i];
 
                /* New location */
-               int row = py + ddy[dir];
-               int col = px + ddx[dir];
+               int row = p_ptr->y + ddy[dir];
+               int col = p_ptr->x + ddx[dir];
 
                /* Access grid */
                c_ptr = &cave[row][col];
@@ -4243,11 +4246,11 @@ static int travel_test(int prev_dir)
        }
 
        /* Travel cost of current grid */
-       cost = travel.cost[py][px];
+       cost = travel.cost[p_ptr->y][p_ptr->x];
 
        /* Determine travel direction */
        for (i = 0; i < 8; ++ i) {
-               int dir_cost = travel.cost[py+ddy_ddd[i]][px+ddx_ddd[i]];
+               int dir_cost = travel.cost[p_ptr->y+ddy_ddd[i]][p_ptr->x+ddx_ddd[i]];
 
                if (dir_cost < cost)
                {
@@ -4259,7 +4262,7 @@ static int travel_test(int prev_dir)
        if (!new_dir) return (0);
 
        /* Access newly move grid */
-       c_ptr = &cave[py+ddy[new_dir]][px+ddx[new_dir]];
+       c_ptr = &cave[p_ptr->y+ddy[new_dir]][p_ptr->x+ddx[new_dir]];
 
        /* Close door abort traveling */
        if (!easy_open && is_closed_door(c_ptr->feat)) return (0);
@@ -4294,11 +4297,11 @@ void travel_step(void)
                return;
        }
 
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        move_player(travel.dir, always_pickup, FALSE);
 
-       if ((py == travel.y) && (px == travel.x))
+       if ((p_ptr->y == travel.y) && (p_ptr->x == travel.x))
        {
                travel.run = 0;
                travel.y = travel.x = 0;