OSDN Git Service

[Refactor] #38997 update_monsters() にplayer_type * 引数追加 / Added player_type * argumen...
[hengband/hengband.git] / src / player-status.c
index 2e32daf..e103ab4 100644 (file)
@@ -218,7 +218,6 @@ static concptr funny_comments[MAX_SAN_COMMENT] =
 
 };
 
-
 /*!
  * @brief 基本必要経験値テーブル /
  * Base experience levels, may be adjusted up for race and/or class
@@ -277,7 +276,6 @@ const s32b player_exp[PY_MAX_LEVEL] =
        5000000L
 };
 
-
 /*!
  * @brief 基本必要強化値テーブル(アンドロイド専用)
  */
@@ -335,7 +333,6 @@ const s32b player_exp_a[PY_MAX_LEVEL] =
        5000000L
 };
 
-
 /*!
  * 知力/賢さによるレベル毎の習得可能魔法数テーブル
  * Stat Table (INT/WIS) -- Number of half-spells per level
@@ -382,7 +379,6 @@ const byte adj_mag_study[] =
        6       /* 18/220+ */
 };
 
-
 /*!
  * 知力/賢さによるMP修正テーブル
  * Stat Table (INT/WIS) -- extra 1/4-mana-points per level
@@ -429,7 +425,6 @@ const byte adj_mag_mana[] =
        30      /* 18/220+ */
 };
 
-
 /*!
  * 知力/賢さによる最低魔法失敗率テーブル
  * Stat Table (INT/WIS) -- Minimum failure rate (percentage)
@@ -476,7 +471,6 @@ const byte adj_mag_fail[] =
        0       /* 18/220+ */
 };
 
-
 /*!
  * 知力/賢さによる魔法失敗率修正テーブル
  * Stat Table (INT/WIS) -- Various things
@@ -523,7 +517,6 @@ const byte adj_mag_stat[] =
        20      /* 18/220+ */
 };
 
-
 /*!
  * 魅力による店での取引修正テーブル
  * Stat Table (CHR) -- payment percentages
@@ -570,7 +563,6 @@ const byte adj_chr_gold[] =
        78      /* 18/220+ */
 };
 
-
 /*!
  * 知力による魔道具使用修正テーブル
  * Stat Table (INT) -- Magic devices
@@ -617,7 +609,6 @@ const byte adj_int_dev[] =
        20      /* 18/220+ */
 };
 
-
 /*!
  * 賢さによる魔法防御修正テーブル
  * Stat Table (WIS) -- Saving throw
@@ -664,7 +655,6 @@ const byte adj_wis_sav[] =
        19      /* 18/220+ */
 };
 
-
 /*!
  * 器用さによるトラップ解除修正テーブル
  * Stat Table (DEX) -- disarming
@@ -711,7 +701,6 @@ const byte adj_dex_dis[] =
        10      /* 18/220+ */
 };
 
-
 /*!
  * 知力によるトラップ解除修正テーブル
  * Stat Table (INT) -- disarming
@@ -758,7 +747,6 @@ const byte adj_int_dis[] =
        20      /* 18/220+ */
 };
 
-
 /*!
  * 器用さによるAC修正テーブル
  * Stat Table (DEX) -- bonus to ac (plus 128)
@@ -805,7 +793,6 @@ const byte adj_dex_ta[] =
        128 + 16    /* 18/220+ */
 };
 
-
 /*!
  * 腕力によるダメージ修正テーブル
  * Stat Table (STR) -- bonus to dam (plus 128)
@@ -852,7 +839,6 @@ const byte adj_str_td[] =
        128 + 20    /* 18/220+ */
 };
 
-
 /*!
  * 器用度による命中修正テーブル
  * Stat Table (DEX) -- bonus to hit (plus 128)
@@ -899,7 +885,6 @@ const byte adj_dex_th[] =
        128 + 16        /* 18/220+ */
 };
 
-
 /*!
  * 腕力による命中修正テーブル
  * Stat Table (STR) -- bonus to hit (plus 128)
@@ -946,7 +931,6 @@ const byte adj_str_th[] =
        128 + 16        /* 18/220+ */
 };
 
-
 /*!
  * 腕力による基本所持重量値テーブル
  * Stat Table (STR) -- weight limit in deca-pounds
@@ -993,7 +977,6 @@ const byte adj_str_wgt[] =
        39      /* 18/220+ */
 };
 
-
 /*!
  * 腕力による武器重量限界値テーブル
  * Stat Table (STR) -- weapon weight limit in pounds
@@ -1040,7 +1023,6 @@ const byte adj_str_hold[] =
        50     /* 18/220+ */
 };
 
-
 /*!
  * 腕力による採掘能力修正値テーブル
  * Stat Table (STR) -- digging value
@@ -1133,7 +1115,6 @@ const byte adj_dex_safe[] =
        100     /* 18/220+ */
 };
 
-
 /*!
  * 耐久による基本HP自然治癒値テーブル /
  * Stat Table (CON) -- base regeneration rate
@@ -1180,7 +1161,6 @@ const byte adj_con_fix[] =
        9       /* 18/220+ */
 };
 
-
 /*!
  * 耐久による基本HP自然治癒値テーブル /
  * Stat Table (CON) -- extra 1/4-hitpoints per level (plus 128)
@@ -1227,7 +1207,6 @@ const byte adj_con_mhp[] =
        128 + 48        /* 18/220+ */
 };
 
-
 /*!
  * 魅力による魅了能力修正テーブル /
  * Stat Table (CHR) -- charm
@@ -1274,7 +1253,6 @@ const byte adj_chr_chm[] =
        85      /* 18/220+ */
 };
 
-
 /*** Player information ***/
 
 /*
@@ -1367,7 +1345,7 @@ int spell_exp_level(int spell_exp)
  */
 void calc_bonuses(player_type *creature_ptr)
 {
-       int i, j, hold;
+       int hold;
        int new_speed;
        int default_hand = 0;
        int empty_hands_status = empty_hands(creature_ptr, TRUE);
@@ -1378,9 +1356,6 @@ void calc_bonuses(player_type *creature_ptr)
        bool yoiyami = FALSE;
        bool down_saving = FALSE;
 
-#if 0
-       bool have_dd_s = FALSE, have_dd_t = FALSE;
-#endif
        bool have_sw = FALSE, have_kabe = FALSE;
        bool easy_2weapon = FALSE;
        bool riding_levitation = FALSE;
@@ -1405,18 +1380,18 @@ void calc_bonuses(player_type *creature_ptr)
        bool old_mighty_throw = creature_ptr->mighty_throw;
 
        /* Current feature under player. */
-       feature_type *f_ptr = &f_info[current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       feature_type *f_ptr = &f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
 
        /* Save the old armor class */
        ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
        ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
 
-
        /* Clear extra blows/shots */
        extra_blows[0] = extra_blows[1] = 0;
 
        /* Clear the stat modifiers */
-       for (i = 0; i < A_MAX; i++) creature_ptr->stat_add[i] = 0;
+       for (int i = 0; i < A_MAX; i++) creature_ptr->stat_add[i] = 0;
 
 
        /* Clear the Displayed/Real armor class */
@@ -1441,11 +1416,11 @@ void calc_bonuses(player_type *creature_ptr)
        /* Start with "normal" speed */
        new_speed = 110;
 
-       /* Start with a single blow per current_world_ptr->game_turn */
+       /* Start with a single blow per turn */
        creature_ptr->num_blow[0] = 1;
        creature_ptr->num_blow[1] = 1;
 
-       /* Start with a single shot per current_world_ptr->game_turn */
+       /* Start with a single shot per turn */
        creature_ptr->num_fire = 100;
 
        /* Reset the "xtra" tval */
@@ -1573,7 +1548,7 @@ void calc_bonuses(player_type *creature_ptr)
                if (!creature_ptr->migite) default_hand = 1;
        }
 
-       if (CAN_TWO_HANDS_WIELDING())
+       if (can_two_hands_wielding(creature_ptr))
        {
                if (creature_ptr->migite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) &&
                        object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM]))
@@ -2042,10 +2017,12 @@ void calc_bonuses(player_type *creature_ptr)
        {
                creature_ptr->resist_neth = TRUE;
        }
+
        if (creature_ptr->tim_sh_fire)
        {
                creature_ptr->sh_fire = TRUE;
        }
+
        if (creature_ptr->tim_res_time)
        {
                creature_ptr->resist_time = TRUE;
@@ -2079,20 +2056,19 @@ void calc_bonuses(player_type *creature_ptr)
                        new_speed += (creature_ptr->lev) / 10 + 5;
        }
 
-       if (music_singing(p_ptr, MUSIC_WALL))
+       if (music_singing(creature_ptr, MUSIC_WALL))
        {
                creature_ptr->kill_wall = TRUE;
        }
 
        /* Hack -- apply racial/class stat maxes */
        /* Apply the racial modifiers */
-       for (i = 0; i < A_MAX; i++)
+       for (int i = 0; i < A_MAX; i++)
        {
                /* Modify the stats for "race" */
                creature_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
        }
 
-
        /* I'm adding the mutations here for the lack of a better place... */
        if (creature_ptr->muta3)
        {
@@ -2268,7 +2244,7 @@ void calc_bonuses(player_type *creature_ptr)
        }
 
        /* Scan the usable creature_ptr->inventory_list */
-       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
+       for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
                int bonus_to_h, bonus_to_d;
                o_ptr = &creature_ptr->inventory_list[i];
@@ -2542,8 +2518,11 @@ void calc_bonuses(player_type *creature_ptr)
                                creature_ptr->dis_to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
                                creature_ptr->dis_to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
                        }
+
+                       continue;
                }
-               else if (creature_ptr->migite && creature_ptr->hidarite)
+
+               if (creature_ptr->migite && creature_ptr->hidarite)
                {
                        /* Apply the bonuses to hit/damage */
                        creature_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
@@ -2552,27 +2531,24 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
 
                        /* Apply the mental bonuses tp hit/damage, if known */
-                       if (object_is_known(o_ptr))
-                       {
-                               creature_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
-                               creature_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
-                               creature_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
-                               creature_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
-                       }
-               }
-               else
-               {
-                       /* Apply the bonuses to hit/damage */
-                       creature_ptr->to_h[default_hand] += (s16b)bonus_to_h;
-                       creature_ptr->to_d[default_hand] += (s16b)bonus_to_d;
+                       if (!object_is_known(o_ptr)) continue;
 
-                       /* Apply the mental bonuses to hit/damage, if known */
-                       if (object_is_known(o_ptr))
-                       {
-                               creature_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
-                               creature_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
-                       }
+                       creature_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
+                       creature_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
+                       creature_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
+                       creature_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
+                       continue;
                }
+
+               /* Apply the bonuses to hit/damage */
+               creature_ptr->to_h[default_hand] += (s16b)bonus_to_h;
+               creature_ptr->to_d[default_hand] += (s16b)bonus_to_d;
+
+               /* Apply the mental bonuses to hit/damage, if known */
+               if (!object_is_known(o_ptr)) continue;
+
+               creature_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
+               creature_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
        }
 
        /* Shield skill bonus */
@@ -2651,7 +2627,7 @@ void calc_bonuses(player_type *creature_ptr)
 
        if (creature_ptr->special_defense & KATA_KOUKIJIN)
        {
-               for (i = 0; i < A_MAX; i++)
+               for (int i = 0; i < A_MAX; i++)
                        creature_ptr->stat_add[i] += 5;
                creature_ptr->to_a -= 50;
                creature_ptr->dis_to_a -= 50;
@@ -2670,32 +2646,36 @@ void calc_bonuses(player_type *creature_ptr)
        /* Hex bonuses */
        if (creature_ptr->realm1 == REALM_HEX)
        {
-               if (hex_spelling_any(p_ptr)) creature_ptr->skill_stl -= (1 + CASTING_HEX_NUM(creature_ptr));
-               if (hex_spelling(HEX_DETECT_EVIL)) creature_ptr->esp_evil = TRUE;
-               if (hex_spelling(HEX_XTRA_MIGHT)) creature_ptr->stat_add[A_STR] += 4;
-               if (hex_spelling(HEX_BUILDING))
+               if (hex_spelling_any(creature_ptr)) creature_ptr->skill_stl -= (1 + CASTING_HEX_NUM(creature_ptr));
+               if (hex_spelling(creature_ptr, HEX_DETECT_EVIL)) creature_ptr->esp_evil = TRUE;
+               if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) creature_ptr->stat_add[A_STR] += 4;
+               if (hex_spelling(creature_ptr, HEX_BUILDING))
                {
                        creature_ptr->stat_add[A_STR] += 4;
                        creature_ptr->stat_add[A_DEX] += 4;
                        creature_ptr->stat_add[A_CON] += 4;
                }
-               if (hex_spelling(HEX_DEMON_AURA))
+
+               if (hex_spelling(creature_ptr, HEX_DEMON_AURA))
                {
                        creature_ptr->sh_fire = TRUE;
                        creature_ptr->regenerate = TRUE;
                }
-               if (hex_spelling(HEX_ICE_ARMOR))
+
+               if (hex_spelling(creature_ptr, HEX_ICE_ARMOR))
                {
                        creature_ptr->sh_cold = TRUE;
                        creature_ptr->to_a += 30;
                        creature_ptr->dis_to_a += 30;
                }
-               if (hex_spelling(HEX_SHOCK_CLOAK))
+
+               if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK))
                {
                        creature_ptr->sh_elec = TRUE;
                        new_speed += 3;
                }
-               for (i = INVEN_RARM; i <= INVEN_FEET; i++)
+
+               for (int i = INVEN_RARM; i <= INVEN_FEET; i++)
                {
                        ARMOUR_CLASS ac = 0;
                        o_ptr = &creature_ptr->inventory_list[i];
@@ -2711,7 +2691,8 @@ void calc_bonuses(player_type *creature_ptr)
        }
 
        /* Calculate stats */
-       for (i = 0; i < A_MAX; i++)
+       int count = 0;
+       for (int i = 0; i < A_MAX; i++)
        {
                int top, use, ind;
 
@@ -2727,7 +2708,6 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->window |= (PW_PLAYER);
                }
 
-
                /* Extract the new "stat_use" value for the stat */
                use = modify_stat_value(creature_ptr->stat_cur[i], creature_ptr->stat_add[i]);
 
@@ -2749,7 +2729,6 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->window |= (PW_PLAYER);
                }
 
-
                /* Values: 3, 4, ..., 17 */
                if (use <= 18) ind = (use - 3);
 
@@ -2760,48 +2739,47 @@ void calc_bonuses(player_type *creature_ptr)
                else ind = (37);
 
                /* Notice changes */
-               if (creature_ptr->stat_ind[i] != ind)
-               {
-                       /* Save the new index */
-                       creature_ptr->stat_ind[i] = (s16b)ind;
+               if (creature_ptr->stat_ind[i] == ind) continue;
 
-                       /* Change in CON affects Hitpoints */
-                       if (i == A_CON)
-                       {
-                               creature_ptr->update |= (PU_HP);
-                       }
+               /* Save the new index */
+               creature_ptr->stat_ind[i] = (s16b)ind;
 
-                       /* Change in INT may affect Mana/Spells */
-                       else if (i == A_INT)
+               /* Change in CON affects Hitpoints */
+               if (i == A_CON)
+               {
+                       creature_ptr->update |= (PU_HP);
+               }
+
+               /* Change in INT may affect Mana/Spells */
+               else if (i == A_INT)
+               {
+                       if (mp_ptr->spell_stat == A_INT)
                        {
-                               if (mp_ptr->spell_stat == A_INT)
-                               {
-                                       creature_ptr->update |= (PU_MANA | PU_SPELLS);
-                               }
+                               creature_ptr->update |= (PU_MANA | PU_SPELLS);
                        }
+               }
 
-                       /* Change in WIS may affect Mana/Spells */
-                       else if (i == A_WIS)
+               /* Change in WIS may affect Mana/Spells */
+               else if (i == A_WIS)
+               {
+                       if (mp_ptr->spell_stat == A_WIS)
                        {
-                               if (mp_ptr->spell_stat == A_WIS)
-                               {
-                                       creature_ptr->update |= (PU_MANA | PU_SPELLS);
-                               }
+                               creature_ptr->update |= (PU_MANA | PU_SPELLS);
                        }
+               }
 
-                       /* Change in WIS may affect Mana/Spells */
-                       else if (i == A_CHR)
+               /* Change in WIS may affect Mana/Spells */
+               else if (i == A_CHR)
+               {
+                       if (mp_ptr->spell_stat == A_CHR)
                        {
-                               if (mp_ptr->spell_stat == A_CHR)
-                               {
-                                       creature_ptr->update |= (PU_MANA | PU_SPELLS);
-                               }
+                               creature_ptr->update |= (PU_MANA | PU_SPELLS);
                        }
-
-                       creature_ptr->window |= (PW_PLAYER);
                }
-       }
 
+               creature_ptr->window |= (PW_PLAYER);
+               count++;
+       }
 
        /* Apply temporary "stun" */
        if (creature_ptr->stun > 50)
@@ -2848,7 +2826,7 @@ void calc_bonuses(player_type *creature_ptr)
        }
 
        /* Temporary blessing */
-       if (IS_BLESSED())
+       if (is_blessed(creature_ptr))
        {
                creature_ptr->to_a += 5;
                creature_ptr->dis_to_a += 5;
@@ -2871,7 +2849,7 @@ void calc_bonuses(player_type *creature_ptr)
        }
 
        /* Temporary "Hero" */
-       if (IS_HERO())
+       if (IS_HERO(creature_ptr))
        {
                creature_ptr->to_h[0] += 12;
                creature_ptr->to_h[1] += 12;
@@ -2909,7 +2887,7 @@ void calc_bonuses(player_type *creature_ptr)
        }
 
        /* Temporary "fast" */
-       if (IS_FAST())
+       if (IS_FAST(creature_ptr))
        {
                new_speed += 10;
        }
@@ -2921,7 +2899,7 @@ void calc_bonuses(player_type *creature_ptr)
        }
 
        /* Temporary "telepathy" */
-       if (IS_TIM_ESP())
+       if (is_time_limit_esp(creature_ptr))
        {
                creature_ptr->telepathy = TRUE;
        }
@@ -2969,12 +2947,11 @@ void calc_bonuses(player_type *creature_ptr)
        }
 
        /* Hack -- Hero/Shero -> Res fear */
-       if (IS_HERO() || creature_ptr->shero)
+       if (IS_HERO(creature_ptr) || creature_ptr->shero)
        {
                creature_ptr->resist_fear = TRUE;
        }
 
-
        /* Hack -- Telepathy Change */
        if (creature_ptr->telepathy != old_telepathy)
        {
@@ -3052,6 +3029,7 @@ void calc_bonuses(player_type *creature_ptr)
                        if ((creature_ptr->inventory_list[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
                                penalty2 /= 2;
                }
+
                if (creature_ptr->inventory_list[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
                if (creature_ptr->inventory_list[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
                creature_ptr->to_h[0] -= (s16b)penalty1;
@@ -3061,16 +3039,16 @@ void calc_bonuses(player_type *creature_ptr)
        }
 
        /* Extract the current weight (in tenth pounds) */
-       j = creature_ptr->total_weight;
+       int j = creature_ptr->total_weight;
 
        if (!creature_ptr->riding)
        {
                /* Extract the "weight limit" (in tenth pounds) */
-               i = (int)weight_limit(creature_ptr);
+               count = (int)weight_limit(creature_ptr);
        }
        else
        {
-               monster_type *riding_m_ptr = &current_floor_ptr->m_list[creature_ptr->riding];
+               monster_type *riding_m_ptr = &floor_ptr->m_list[creature_ptr->riding];
                monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
                SPEED speed = riding_m_ptr->mspeed;
 
@@ -3095,11 +3073,11 @@ void calc_bonuses(player_type *creature_ptr)
                if (creature_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED) j += (creature_ptr->wt * 3 * (RIDING_EXP_SKILLED - creature_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
 
                /* Extract the "weight limit" */
-               i = 1500 + riding_r_ptr->level * 25;
+               count = 1500 + riding_r_ptr->level * 25;
        }
 
        /* Apply "encumbrance" from weight */
-       if (j > i) new_speed -= ((j - i) / (i / 5));
+       if (j > count) new_speed -= ((j - count) / (count / 5));
 
        /* Searching slows the player down */
        if (creature_ptr->action == ACTION_SEARCH) new_speed -= 10;
@@ -3117,7 +3095,6 @@ void calc_bonuses(player_type *creature_ptr)
                }
        }
 
-
        /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
        creature_ptr->to_a += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
        creature_ptr->to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
@@ -3143,11 +3120,9 @@ void calc_bonuses(player_type *creature_ptr)
        creature_ptr->dis_to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
        creature_ptr->dis_to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
 
-
        /* Obtain the "hold" value */
        hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
 
-
        /* Examine the "current bow" */
        o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
 
@@ -3183,7 +3158,7 @@ void calc_bonuses(player_type *creature_ptr)
 
        if (creature_ptr->ryoute) hold *= 2;
 
-       for (i = 0; i < 2; i++)
+       for (int i = 0; i < 2; i++)
        {
                /* Examine the "main weapon" */
                o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
@@ -3200,6 +3175,7 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->num_blow[i] = 1;
                        continue;
                }
+
                /* It is hard to hold a heavy weapon */
                if (hold < o_ptr->weight / 10)
                {
@@ -3300,7 +3276,7 @@ void calc_bonuses(player_type *creature_ptr)
                        }
 
                        /* Hex - extra mights gives +1 bonus to max blows */
-                       if (hex_spelling(HEX_XTRA_MIGHT) || hex_spelling(HEX_BUILDING)) { num++; wgt /= 2; mul += 2; }
+                       if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT) || hex_spelling(creature_ptr, HEX_BUILDING)) { num++; wgt /= 2; mul += 2; }
 
                        /* Enforce a minimum "weight" (tenth pounds) */
                        div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
@@ -3339,7 +3315,7 @@ void calc_bonuses(player_type *creature_ptr)
 
                        if (creature_ptr->special_defense & KATA_FUUJIN) creature_ptr->num_blow[i] -= 1;
 
-                       if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) creature_ptr->num_blow[i] = 1;
+                       if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) creature_ptr->num_blow[i] = 1;
 
 
                        /* Require at least one blow */
@@ -3405,51 +3381,51 @@ void calc_bonuses(player_type *creature_ptr)
                                creature_ptr->dis_to_d[i] -= 10;
                        }
                }
+
                /* Hex bonuses */
-               if (creature_ptr->realm1 == REALM_HEX)
+               if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr))
                {
-                       if (object_is_cursed(o_ptr))
+                       if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
+                       if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_h[i] += 7; creature_ptr->dis_to_h[i] += 7; }
+                       if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_h[i] += 13; creature_ptr->dis_to_h[i] += 13; }
+                       if (o_ptr->curse_flags & (TRC_TY_CURSE)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
+                       if (hex_spelling(creature_ptr, HEX_RUNESWORD))
                        {
-                               if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
-                               if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_h[i] += 7; creature_ptr->dis_to_h[i] += 7; }
-                               if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_h[i] += 13; creature_ptr->dis_to_h[i] += 13; }
-                               if (o_ptr->curse_flags & (TRC_TY_CURSE)) { creature_ptr->to_h[i] += 5; creature_ptr->dis_to_h[i] += 5; }
-                               if (hex_spelling(HEX_RUNESWORD))
-                               {
-                                       if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_d[i] += 5; creature_ptr->dis_to_d[i] += 5; }
-                                       if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_d[i] += 7; creature_ptr->dis_to_d[i] += 7; }
-                                       if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_d[i] += 13; creature_ptr->dis_to_d[i] += 13; }
-                               }
+                               if (o_ptr->curse_flags & (TRC_CURSED)) { creature_ptr->to_d[i] += 5; creature_ptr->dis_to_d[i] += 5; }
+                               if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { creature_ptr->to_d[i] += 7; creature_ptr->dis_to_d[i] += 7; }
+                               if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { creature_ptr->to_d[i] += 13; creature_ptr->dis_to_d[i] += 13; }
                        }
                }
-               if (creature_ptr->riding)
+
+               if (creature_ptr->riding == 0) continue;
+
+               if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
                {
-                       if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
-                       {
-                               creature_ptr->to_h[i] += 15;
-                               creature_ptr->dis_to_h[i] += 15;
-                               creature_ptr->to_dd[i] += 2;
-                       }
-                       else if (!(have_flag(flgs, TR_RIDING)))
-                       {
-                               int penalty;
-                               if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY))
-                               {
-                                       penalty = 5;
-                               }
-                               else
-                               {
-                                       penalty = r_info[current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
-                                       penalty += 30;
-                                       if (penalty < 30) penalty = 30;
-                               }
-                               creature_ptr->to_h[i] -= (s16b)penalty;
-                               creature_ptr->dis_to_h[i] -= (s16b)penalty;
+                       creature_ptr->to_h[i] += 15;
+                       creature_ptr->dis_to_h[i] += 15;
+                       creature_ptr->to_dd[i] += 2;
+                       continue;
+               }
 
-                               /* Riding weapon */
-                               creature_ptr->riding_wield[i] = TRUE;
-                       }
+               if (have_flag(flgs, TR_RIDING)) continue;
+
+               int penalty;
+               if ((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY))
+               {
+                       penalty = 5;
+               }
+               else
+               {
+                       penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
+                       penalty += 30;
+                       if (penalty < 30) penalty = 30;
                }
+
+               creature_ptr->to_h[i] -= (s16b)penalty;
+               creature_ptr->dis_to_h[i] -= (s16b)penalty;
+
+               /* Riding weapon */
+               creature_ptr->riding_wield[i] = TRUE;
        }
 
        if (creature_ptr->riding)
@@ -3459,7 +3435,7 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->riding_ryoute = FALSE;
 
                if (creature_ptr->ryoute || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE)) creature_ptr->riding_ryoute = TRUE;
-               else if (creature_ptr->pet_extra_flags & PF_RYOUTE)
+               else if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
                {
                        switch (creature_ptr->pclass)
                        {
@@ -3478,10 +3454,11 @@ void calc_bonuses(player_type *creature_ptr)
                }
                else
                {
-                       penalty = r_info[current_floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
+                       penalty = r_info[floor_ptr->m_list[creature_ptr->riding].r_idx].level - creature_ptr->skill_exp[GINOU_RIDING] / 80;
                        penalty += 30;
                        if (penalty < 30) penalty = 30;
                }
+
                if (creature_ptr->tval_ammo == TV_BOLT) penalty *= 2;
                creature_ptr->to_h_b -= (s16b)penalty;
                creature_ptr->dis_to_h_b -= (s16b)penalty;
@@ -3580,36 +3557,37 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->monk_armour_aux = TRUE;
        }
 
-       for (i = 0; i < 2; i++)
+       for (int i = 0; i < 2; i++)
        {
-               if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
-               {
-                       OBJECT_TYPE_VALUE tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
-                       OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
+               if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) continue;
 
-                       creature_ptr->to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
-                       creature_ptr->dis_to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
-                       if ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER))
-                       {
-                               if (!s_info[creature_ptr->pclass].w_max[tval][sval])
-                               {
-                                       creature_ptr->to_h[i] -= 40;
-                                       creature_ptr->dis_to_h[i] -= 40;
-                                       creature_ptr->icky_wield[i] = TRUE;
-                               }
-                       }
-                       else if (creature_ptr->pclass == CLASS_NINJA)
+               OBJECT_TYPE_VALUE tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
+               OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
+
+               creature_ptr->to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
+               creature_ptr->dis_to_h[i] += (creature_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
+               if ((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER))
+               {
+                       if (!s_info[creature_ptr->pclass].w_max[tval][sval])
                        {
-                               if ((s_info[CLASS_NINJA].w_max[tval][sval] <= WEAPON_EXP_BEGINNER) || (creature_ptr->inventory_list[INVEN_LARM - i].tval == TV_SHIELD))
-                               {
-                                       creature_ptr->to_h[i] -= 40;
-                                       creature_ptr->dis_to_h[i] -= 40;
-                                       creature_ptr->icky_wield[i] = TRUE;
-                                       creature_ptr->num_blow[i] /= 2;
-                                       if (creature_ptr->num_blow[i] < 1) creature_ptr->num_blow[i] = 1;
-                               }
+                               creature_ptr->to_h[i] -= 40;
+                               creature_ptr->dis_to_h[i] -= 40;
+                               creature_ptr->icky_wield[i] = TRUE;
                        }
+
+                       continue;
                }
+
+               if (creature_ptr->pclass != CLASS_NINJA) continue;
+
+               if ((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD))
+                       continue;
+
+               creature_ptr->to_h[i] -= 40;
+               creature_ptr->dis_to_h[i] -= 40;
+               creature_ptr->icky_wield[i] = TRUE;
+               creature_ptr->num_blow[i] /= 2;
+               if (creature_ptr->num_blow[i] < 1) creature_ptr->num_blow[i] = 1;
        }
 
        /* Maximum speed is (+99). (internally it's 110 + 99) */
@@ -3656,12 +3634,16 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->dis_to_d[default_hand] += MAX(bonus_to_d, 1);
        }
 
-       if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) || (creature_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))) creature_ptr->ryoute = FALSE;
+       bool is_special_class = creature_ptr->pclass == CLASS_MONK;
+       is_special_class |= creature_ptr->pclass == CLASS_FORCETRAINER;
+       is_special_class |= creature_ptr->pclass == CLASS_BERSERKER;
+       if (is_special_class && (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)))
+               creature_ptr->ryoute = FALSE;
 
        /* Affect Skill -- stealth (bonus one) */
        creature_ptr->skill_stl += 1;
 
-       if (IS_TIM_STEALTH()) creature_ptr->skill_stl += 99;
+       if (is_time_limit_stealth(creature_ptr)) creature_ptr->skill_stl += 99;
 
        /* Affect Skill -- disarming (DEX and INT) */
        creature_ptr->skill_dis += adj_dex_dis[creature_ptr->stat_ind[A_DEX]];
@@ -3703,7 +3685,6 @@ void calc_bonuses(player_type *creature_ptr)
        /* Affect Skill -- combat (throwing) (Level, by Class) */
        creature_ptr->skill_tht += ((cp_ptr->x_thb * creature_ptr->lev / 10) + (ap_ptr->a_thb * creature_ptr->lev / 50));
 
-
        if ((PRACE_IS_(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != SEIKAKU_SEXY) && (creature_ptr->cursed & TRC_AGGRAVATE))
        {
                creature_ptr->cursed &= ~(TRC_AGGRAVATE);
@@ -3731,7 +3712,6 @@ void calc_bonuses(player_type *creature_ptr)
        if (creature_ptr->immune_fire) creature_ptr->resist_fire = TRUE;
        if (creature_ptr->immune_cold) creature_ptr->resist_cold = TRUE;
 
-
        /* Hack -- handle "xtra" mode */
        if (current_world_ptr->character_xtra) return;
 
@@ -3751,11 +3731,10 @@ void calc_bonuses(player_type *creature_ptr)
                        msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
                }
 
-               /* Save it */
                creature_ptr->old_heavy_shoot = creature_ptr->heavy_shoot;
        }
 
-       for (i = 0; i < 2; i++)
+       for (int i = 0; i < 2; i++)
        {
                /* Take note when "heavy weapon" changes */
                if (creature_ptr->old_heavy_wield[i] != creature_ptr->heavy_wield[i])
@@ -3777,7 +3756,6 @@ void calc_bonuses(player_type *creature_ptr)
                                msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
                        }
 
-                       /* Save it */
                        creature_ptr->old_heavy_wield[i] = creature_ptr->heavy_wield[i];
                }
 
@@ -3796,33 +3774,31 @@ void calc_bonuses(player_type *creature_ptr)
                        {
                                msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
                        }
-                       /* Save it */
+
                        creature_ptr->old_riding_wield[i] = creature_ptr->riding_wield[i];
                }
 
                /* Take note when "illegal weapon" changes */
-               if (creature_ptr->old_icky_wield[i] != creature_ptr->icky_wield[i])
+               if (creature_ptr->old_icky_wield[i] == creature_ptr->icky_wield[i]) continue;
+
+               if (creature_ptr->icky_wield[i])
                {
-                       if (creature_ptr->icky_wield[i])
-                       {
-                               msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
-                               if (current_world_ptr->is_loading_now)
-                               {
-                                       chg_virtue(creature_ptr, V_FAITH, -1);
-                               }
-                       }
-                       else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
-                       {
-                               msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
-                       }
-                       else
+                       msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
+                       if (current_world_ptr->is_loading_now)
                        {
-                               msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
+                               chg_virtue(creature_ptr, V_FAITH, -1);
                        }
-
-                       /* Save it */
-                       creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
                }
+               else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
+               {
+                       msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
+               }
+               else
+               {
+                       msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
+               }
+
+               creature_ptr->old_icky_wield[i] = creature_ptr->icky_wield[i];
        }
 
        if (creature_ptr->riding && (creature_ptr->old_riding_ryoute != creature_ptr->riding_ryoute))
@@ -3865,43 +3841,23 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->monk_notify_aux = creature_ptr->monk_armour_aux;
        }
 
-       for (i = 0; i < INVEN_PACK; i++)
+       for (int i = 0; i < INVEN_PACK; i++)
        {
-#if 0
-               if ((creature_ptr->inventory_list[i].tval == TV_SORCERY_BOOK) && (creature_ptr->inventory_list[i].sval == 2)) have_dd_s = TRUE;
-               if ((creature_ptr->inventory_list[i].tval == TV_TRUMP_BOOK) && (creature_ptr->inventory_list[i].sval == 1)) have_dd_t = TRUE;
-#endif
                if ((creature_ptr->inventory_list[i].tval == TV_NATURE_BOOK) && (creature_ptr->inventory_list[i].sval == 2)) have_sw = TRUE;
                if ((creature_ptr->inventory_list[i].tval == TV_CRAFT_BOOK) && (creature_ptr->inventory_list[i].sval == 2)) have_kabe = TRUE;
        }
 
-       for (this_o_idx = current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
+       for (this_o_idx = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
-               o_ptr = &current_floor_ptr->o_list[this_o_idx];
+               o_ptr = &floor_ptr->o_list[this_o_idx];
                next_o_idx = o_ptr->next_o_idx;
 
-#if 0
-               if ((o_ptr->tval == TV_SORCERY_BOOK) && (o_ptr->sval == 3)) have_dd_s = TRUE;
-               if ((o_ptr->tval == TV_TRUMP_BOOK) && (o_ptr->sval == 1)) have_dd_t = TRUE;
-#endif
                if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
                if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
        }
 
        if (creature_ptr->pass_wall && !creature_ptr->kill_wall) creature_ptr->no_flowed = TRUE;
-#if 0
-       if (have_dd_s && ((creature_ptr->realm1 == REALM_SORCERY) || (creature_ptr->realm2 == REALM_SORCERY) || (creature_ptr->pclass == CLASS_SORCERER)))
-       {
-               const magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY - 1][SPELL_DD_S];
-               if (creature_ptr->lev >= s_ptr->slevel) creature_ptr->no_flowed = TRUE;
-       }
 
-       if (have_dd_t && ((creature_ptr->realm1 == REALM_TRUMP) || (creature_ptr->realm2 == REALM_TRUMP) || (creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE)))
-       {
-               const magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP - 1][SPELL_DD_T];
-               if (creature_ptr->lev >= s_ptr->slevel) creature_ptr->no_flowed = TRUE;
-       }
-#endif
        if (have_sw && ((creature_ptr->realm1 == REALM_NATURE) || (creature_ptr->realm2 == REALM_NATURE) || (creature_ptr->pclass == CLASS_SORCERER)))
        {
                const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
@@ -3918,23 +3874,20 @@ void calc_bonuses(player_type *creature_ptr)
 
 static void calc_alignment(player_type *creature_ptr)
 {
-       MONSTER_IDX m_idx;
        creature_ptr->align = 0;
-       int i, j, neutral[2];
-
-       for (m_idx = current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
        {
                monster_type *m_ptr;
                monster_race *r_ptr;
-               m_ptr = &current_floor_ptr->m_list[m_idx];
+               m_ptr = &floor_ptr->m_list[m_idx];
                if (!monster_is_valid(m_ptr)) continue;
                r_ptr = &r_info[m_ptr->r_idx];
 
-               if (is_pet(m_ptr))
-               {
-                       if (r_ptr->flags3 & RF3_GOOD) creature_ptr->align += r_ptr->level;
-                       if (r_ptr->flags3 & RF3_EVIL) creature_ptr->align -= r_ptr->level;
-               }
+               if (!is_pet(m_ptr)) continue;
+
+               if (r_ptr->flags3 & RF3_GOOD) creature_ptr->align += r_ptr->level;
+               if (r_ptr->flags3 & RF3_EVIL) creature_ptr->align -= r_ptr->level;
        }
 
        if (creature_ptr->mimic_form)
@@ -3962,16 +3915,17 @@ static void calc_alignment(player_type *creature_ptr)
                }
        }
 
-       for (i = 0; i < 2; i++)
+       for (int i = 0; i < 2; i++)
        {
-               if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
-               {
-                       if (creature_ptr->inventory_list[INVEN_RARM + i].name1 == ART_IRON_BALL) creature_ptr->align -= 1000;
-               }
+               if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) continue;
+               if (creature_ptr->inventory_list[INVEN_RARM + i].name1 != ART_IRON_BALL) continue;
+               creature_ptr->align -= 1000;
        }
 
        /* Determine player alignment */
-       for (i = 0, j = 0; i < 8; i++)
+       int j = 0;
+       int neutral[2];
+       for (int i = 0; i < 8; i++)
        {
                switch (creature_ptr->vir_types[i])
                {
@@ -3994,7 +3948,7 @@ static void calc_alignment(player_type *creature_ptr)
                }
        }
 
-       for (i = 0; i < j; i++)
+       for (int i = 0; i < j; i++)
        {
                if (creature_ptr->align > 0)
                {
@@ -4009,6 +3963,7 @@ static void calc_alignment(player_type *creature_ptr)
        }
 }
 
+
 /*!
  * @brief プレイヤーの最大HPを計算する /
  * Calculate the players (maximal) hit points
@@ -4018,15 +3973,13 @@ static void calc_alignment(player_type *creature_ptr)
  */
 static void calc_hitpoints(player_type *creature_ptr)
 {
-       int bonus, mhp;
-       byte tmp_hitdie;
-
        /* Un-inflate "half-hitpoint bonus per level" value */
-       bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
+       int bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
 
        /* Calculate hitpoints */
-       mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
+       int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
 
+       byte tmp_hitdie;
        if (creature_ptr->mimic_form)
        {
                if (creature_ptr->pclass == CLASS_SORCERER)
@@ -4056,40 +4009,38 @@ static void calc_hitpoints(player_type *creature_ptr)
        if (mhp < creature_ptr->lev + 1) mhp = creature_ptr->lev + 1;
 
        /* Factor in the hero / superhero settings */
-       if (IS_HERO()) mhp += 10;
+       if (IS_HERO(creature_ptr)) mhp += 10;
        if (creature_ptr->shero && (creature_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
        if (creature_ptr->tsuyoshi) mhp += 50;
 
        /* Factor in the hex spell settings */
-       if (hex_spelling(HEX_XTRA_MIGHT)) mhp += 15;
-       if (hex_spelling(HEX_BUILDING)) mhp += 60;
+       if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) mhp += 15;
+       if (hex_spelling(creature_ptr, HEX_BUILDING)) mhp += 60;
 
        /* New maximum hitpoints */
-       if (creature_ptr->mhp != mhp)
+       if (creature_ptr->mhp == mhp) return;
+
+       /* Enforce maximum */
+       if (creature_ptr->chp >= mhp)
        {
-               /* Enforce maximum */
-               if (creature_ptr->chp >= mhp)
-               {
-                       creature_ptr->chp = mhp;
-                       creature_ptr->chp_frac = 0;
-               }
+               creature_ptr->chp = mhp;
+               creature_ptr->chp_frac = 0;
+       }
 
 #ifdef JP
-               /* レベルアップの時は上昇量を表示する */
-               if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp))
-               {
-                       msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
-               }
+       /* レベルアップの時は上昇量を表示する */
+       if (creature_ptr->level_up_message && (mhp > creature_ptr->mhp))
+       {
+               msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - creature_ptr->mhp));
+       }
 #endif
-               /* Save the new max-hitpoints */
-               creature_ptr->mhp = mhp;
+       creature_ptr->mhp = mhp;
 
-               /* Display hitpoints (later) */
-               creature_ptr->redraw |= (PR_HP);
-               creature_ptr->window |= (PW_PLAYER);
-       }
+       creature_ptr->redraw |= PR_HP;
+       creature_ptr->window |= PW_PLAYER;
 }
 
+
 /*!
  * @brief プレイヤーの光源半径を計算する / Extract and set the current "lite radius"
  * @return なし
@@ -4098,17 +4049,12 @@ static void calc_hitpoints(player_type *creature_ptr)
  */
 static void calc_torch(player_type *creature_ptr)
 {
-       int i;
-       POSITION rad;
-       object_type *o_ptr;
-       BIT_FLAGS flgs[TR_FLAG_SIZE];
-
-       /* Assume no light */
        creature_ptr->cur_lite = 0;
 
        /* Loop through all wielded items */
-       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
+       for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
+               object_type *o_ptr;
                o_ptr = &creature_ptr->inventory_list[i];
                /* Skip empty slots */
                if (!o_ptr->k_idx) continue;
@@ -4124,11 +4070,11 @@ static void calc_torch(player_type *creature_ptr)
                                if ((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
                        }
                }
-               object_flags(o_ptr, flgs);
 
-               /* calc the lite_radius */
+               BIT_FLAGS flgs[TR_FLAG_SIZE];
+               object_flags(o_ptr, flgs);
 
-               rad = 0;
+               POSITION rad = 0;
                if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 1;
                if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 2;
                if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 3;
@@ -4151,22 +4097,21 @@ static void calc_torch(player_type *creature_ptr)
        if (creature_ptr->cur_lite > 14) creature_ptr->cur_lite = 14;
        if (creature_ptr->cur_lite < 0) creature_ptr->cur_lite = 0;
 
-       /* end experimental mods */
-
        /* Notice changes in the "lite radius" */
-       if (creature_ptr->old_lite != creature_ptr->cur_lite)
-       {
-               /* Hack -- PU_MON_LITE for monsters' darkness */
-               creature_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
+       if (creature_ptr->old_lite == creature_ptr->cur_lite) return;
 
-               /* Remember the old lite */
-               creature_ptr->old_lite = creature_ptr->cur_lite;
+       /* Hack -- PU_MON_LITE for monsters' darkness */
+       creature_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
+
+       /* Remember the old lite */
+       creature_ptr->old_lite = creature_ptr->cur_lite;
+
+       if ((creature_ptr->cur_lite > 0) && (creature_ptr->special_defense & NINJA_S_STEALTH))
+               set_superstealth(creature_ptr, FALSE);
 
-               if ((creature_ptr->cur_lite > 0) && (creature_ptr->special_defense & NINJA_S_STEALTH))
-                       set_superstealth(creature_ptr, FALSE);
-       }
 }
 
+
 /*!
  * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
  * Calculate number of spells player should have, and forget,
@@ -4178,16 +4123,6 @@ static void calc_torch(player_type *creature_ptr)
  */
 static void calc_spells(player_type *creature_ptr)
 {
-       int i, j, k, levels;
-       int num_allowed;
-       int num_boukyaku = 0;
-
-       const magic_type        *s_ptr;
-       REALM_IDX which;
-       int bonus = 0;
-
-       concptr p;
-
        /* Hack -- must be literate */
        if (!mp_ptr->spell_book) return;
 
@@ -4203,21 +4138,23 @@ static void calc_spells(player_type *creature_ptr)
                return;
        }
 
-       p = spell_category_name(mp_ptr->spell_book);
+       concptr p = spell_category_name(mp_ptr->spell_book);
 
        /* Determine the number of spells allowed */
-       levels = creature_ptr->lev - mp_ptr->spell_first + 1;
+       int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
 
        /* Hack -- no negative spells */
        if (levels < 0) levels = 0;
 
        /* Extract total allowed spells */
-       num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
+       int num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
 
+       int bonus = 0;
        if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
        {
                bonus = 4;
        }
+
        if (creature_ptr->pclass == CLASS_SAMURAI)
        {
                num_allowed = 32;
@@ -4237,7 +4174,8 @@ static void calc_spells(player_type *creature_ptr)
        }
 
        /* Count the number of spells we know */
-       for (j = 0; j < 64; j++)
+       int num_boukyaku = 0;
+       for (int j = 0; j < 64; j++)
        {
                /* Count known spells */
                if ((j < 32) ?
@@ -4252,19 +4190,19 @@ static void calc_spells(player_type *creature_ptr)
        creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
 
        /* Forget spells which are too hard */
-       for (i = 63; i >= 0; i--)
+       for (int i = 63; i >= 0; i--)
        {
                /* Efficiency -- all done */
                if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
 
                /* Access the spell */
-               j = creature_ptr->spell_order[i];
+               int j = creature_ptr->spell_order[i];
 
                /* Skip non-spells */
                if (j >= 99) continue;
 
-
                /* Get the spell */
+               const magic_type *s_ptr;
                if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
                {
                        if (j < 32)
@@ -4281,49 +4219,46 @@ static void calc_spells(player_type *creature_ptr)
                if (s_ptr->slevel <= creature_ptr->lev) continue;
 
                /* Is it known? */
-               if ((j < 32) ?
+               bool is_spell_learned = (j < 32) ?
                        (creature_ptr->spell_learned1 & (1L << j)) :
-                       (creature_ptr->spell_learned2 & (1L << (j - 32))))
+                       (creature_ptr->spell_learned2 & (1L << (j - 32)));
+               if (!is_spell_learned) continue;
+
+               /* Mark as forgotten */
+               REALM_IDX which;
+               if (j < 32)
                {
-                       /* Mark as forgotten */
-                       if (j < 32)
-                       {
-                               creature_ptr->spell_forgotten1 |= (1L << j);
-                               which = creature_ptr->realm1;
-                       }
-                       else
-                       {
-                               creature_ptr->spell_forgotten2 |= (1L << (j - 32));
-                               which = creature_ptr->realm2;
-                       }
+                       creature_ptr->spell_forgotten1 |= (1L << j);
+                       which = creature_ptr->realm1;
+               }
+               else
+               {
+                       creature_ptr->spell_forgotten2 |= (1L << (j - 32));
+                       which = creature_ptr->realm2;
+               }
 
-                       /* No longer known */
-                       if (j < 32)
-                       {
-                               creature_ptr->spell_learned1 &= ~(1L << j);
-                               which = creature_ptr->realm1;
-                       }
-                       else
-                       {
-                               creature_ptr->spell_learned2 &= ~(1L << (j - 32));
-                               which = creature_ptr->realm2;
-                       }
+               /* No longer known */
+               if (j < 32)
+               {
+                       creature_ptr->spell_learned1 &= ~(1L << j);
+                       which = creature_ptr->realm1;
+               }
+               else
+               {
+                       creature_ptr->spell_learned2 &= ~(1L << (j - 32));
+                       which = creature_ptr->realm2;
+               }
 
 #ifdef JP
-                       msg_format("%sの%sを忘れてしまった。", exe_spell(p_ptr, which, j % 32, SPELL_NAME), p);
+               msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
 #else
-                       msg_format("You have forgotten the %s of %s.", p, exe_spell(p_ptr, which, j % 32, SPELL_NAME));
+               msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
 #endif
-
-
-                       /* One more can be learned */
-                       creature_ptr->new_spells++;
-               }
+               creature_ptr->new_spells++;
        }
 
-
        /* Forget spells if we know too many spells */
-       for (i = 63; i >= 0; i--)
+       for (int i = 63; i >= 0; i--)
        {
                /* Stop when possible */
                if (creature_ptr->new_spells >= 0) break;
@@ -4332,55 +4267,51 @@ static void calc_spells(player_type *creature_ptr)
                if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
 
                /* Get the (i+1)th spell learned */
-               j = creature_ptr->spell_order[i];
+               int j = creature_ptr->spell_order[i];
 
                /* Skip unknown spells */
                if (j >= 99) continue;
 
-               /* Forget it (if learned) */
-               if ((j < 32) ?
+               bool is_spell_learned = (j < 32) ?
                        (creature_ptr->spell_learned1 & (1L << j)) :
-                       (creature_ptr->spell_learned2 & (1L << (j - 32))))
+                       (creature_ptr->spell_learned2 & (1L << (j - 32)));
+               if (!is_spell_learned) continue;
+
+               /* Mark as forgotten */
+               REALM_IDX which;
+               if (j < 32)
                {
-                       /* Mark as forgotten */
-                       if (j < 32)
-                       {
-                               creature_ptr->spell_forgotten1 |= (1L << j);
-                               which = creature_ptr->realm1;
-                       }
-                       else
-                       {
-                               creature_ptr->spell_forgotten2 |= (1L << (j - 32));
-                               which = creature_ptr->realm2;
-                       }
+                       creature_ptr->spell_forgotten1 |= (1L << j);
+                       which = creature_ptr->realm1;
+               }
+               else
+               {
+                       creature_ptr->spell_forgotten2 |= (1L << (j - 32));
+                       which = creature_ptr->realm2;
+               }
 
-                       /* No longer known */
-                       if (j < 32)
-                       {
-                               creature_ptr->spell_learned1 &= ~(1L << j);
-                               which = creature_ptr->realm1;
-                       }
-                       else
-                       {
-                               creature_ptr->spell_learned2 &= ~(1L << (j - 32));
-                               which = creature_ptr->realm2;
-                       }
+               /* No longer known */
+               if (j < 32)
+               {
+                       creature_ptr->spell_learned1 &= ~(1L << j);
+                       which = creature_ptr->realm1;
+               }
+               else
+               {
+                       creature_ptr->spell_learned2 &= ~(1L << (j - 32));
+                       which = creature_ptr->realm2;
+               }
 
 #ifdef JP
-                       msg_format("%sの%sを忘れてしまった。", exe_spell(p_ptr, which, j % 32, SPELL_NAME), p);
+               msg_format("%sの%sを忘れてしまった。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
 #else
-                       msg_format("You have forgotten the %s of %s.", p, exe_spell(p_ptr, which, j % 32, SPELL_NAME));
+               msg_format("You have forgotten the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
 #endif
-
-
-                       /* One more can be learned */
-                       creature_ptr->new_spells++;
-               }
+               creature_ptr->new_spells++;
        }
 
-
        /* Check for spells to remember */
-       for (i = 0; i < 64; i++)
+       for (int i = 0; i < 64; i++)
        {
                /* None left to remember */
                if (creature_ptr->new_spells <= 0) break;
@@ -4389,12 +4320,13 @@ static void calc_spells(player_type *creature_ptr)
                if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2) break;
 
                /* Get the next spell we learned */
-               j = creature_ptr->spell_order[i];
+               int j = creature_ptr->spell_order[i];
 
                /* Skip unknown spells */
                if (j >= 99) break;
 
                /* Access the spell */
+               const magic_type *s_ptr;
                if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
                {
                        if (j < 32)
@@ -4410,54 +4342,51 @@ static void calc_spells(player_type *creature_ptr)
                /* Skip spells we cannot remember */
                if (s_ptr->slevel > creature_ptr->lev) continue;
 
-               /* First set of spells */
-               if ((j < 32) ?
+               bool is_spell_learned = (j < 32) ?
                        (creature_ptr->spell_forgotten1 & (1L << j)) :
-                       (creature_ptr->spell_forgotten2 & (1L << (j - 32))))
+                       (creature_ptr->spell_forgotten2 & (1L << (j - 32)));
+               if (!is_spell_learned) continue;
+
+               /* No longer forgotten */
+               REALM_IDX which;
+               if (j < 32)
                {
-                       /* No longer forgotten */
-                       if (j < 32)
-                       {
-                               creature_ptr->spell_forgotten1 &= ~(1L << j);
-                               which = creature_ptr->realm1;
-                       }
-                       else
-                       {
-                               creature_ptr->spell_forgotten2 &= ~(1L << (j - 32));
-                               which = creature_ptr->realm2;
-                       }
+                       creature_ptr->spell_forgotten1 &= ~(1L << j);
+                       which = creature_ptr->realm1;
+               }
+               else
+               {
+                       creature_ptr->spell_forgotten2 &= ~(1L << (j - 32));
+                       which = creature_ptr->realm2;
+               }
 
-                       /* Known once more */
-                       if (j < 32)
-                       {
-                               creature_ptr->spell_learned1 |= (1L << j);
-                               which = creature_ptr->realm1;
-                       }
-                       else
-                       {
-                               creature_ptr->spell_learned2 |= (1L << (j - 32));
-                               which = creature_ptr->realm2;
-                       }
+               /* Known once more */
+               if (j < 32)
+               {
+                       creature_ptr->spell_learned1 |= (1L << j);
+                       which = creature_ptr->realm1;
+               }
+               else
+               {
+                       creature_ptr->spell_learned2 |= (1L << (j - 32));
+                       which = creature_ptr->realm2;
+               }
 
 #ifdef JP
-                       msg_format("%sの%sを思い出した。", exe_spell(p_ptr, which, j % 32, SPELL_NAME), p);
+               msg_format("%sの%sを思い出した。", exe_spell(creature_ptr, which, j % 32, SPELL_NAME), p);
 #else
-                       msg_format("You have remembered the %s of %s.", p, exe_spell(p_ptr, which, j % 32, SPELL_NAME));
+               msg_format("You have remembered the %s of %s.", p, exe_spell(creature_ptr, which, j % 32, SPELL_NAME));
 #endif
-
-
-                       /* One less can be learned */
-                       creature_ptr->new_spells--;
-               }
+               creature_ptr->new_spells--;
        }
 
-       k = 0;
-
        if (creature_ptr->realm2 == REALM_NONE)
        {
                /* Count spells that can be learned */
-               for (j = 0; j < 32; j++)
+               int k = 0;
+               for (int j = 0; j < 32; j++)
                {
+                       const magic_type *s_ptr;
                        if (!is_magic(creature_ptr->realm1)) s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
                        else s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
 
@@ -4473,6 +4402,7 @@ static void calc_spells(player_type *creature_ptr)
                        /* Count it */
                        k++;
                }
+
                if (k > 32) k = 32;
                if ((creature_ptr->new_spells > k) &&
                        ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
@@ -4484,37 +4414,31 @@ static void calc_spells(player_type *creature_ptr)
        if (creature_ptr->new_spells < 0) creature_ptr->new_spells = 0;
 
        /* Spell count changed */
-       if (creature_ptr->old_spells != creature_ptr->new_spells)
+       if (creature_ptr->old_spells == creature_ptr->new_spells) return;
+
+       /* Message if needed */
+       if (creature_ptr->new_spells)
        {
-               /* Message if needed */
-               if (creature_ptr->new_spells)
-               {
 #ifdef JP
-                       if (creature_ptr->new_spells < 10) {
-                               msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
-                       }
-                       else {
-                               msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
-                       }
+               if (creature_ptr->new_spells < 10) {
+                       msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
+               }
+               else {
+                       msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
+               }
 #else
-                       msg_format("You can learn %d more %s%s.",
-                               creature_ptr->new_spells, p,
-                               (creature_ptr->new_spells != 1) ? "s" : "");
+               msg_format("You can learn %d more %s%s.",
+                       creature_ptr->new_spells, p,
+                       (creature_ptr->new_spells != 1) ? "s" : "");
 #endif
-
-               }
-
-               /* Save the new_spells value */
-               creature_ptr->old_spells = creature_ptr->new_spells;
-
-               /* Redraw Study Status */
-               creature_ptr->redraw |= (PR_STUDY);
-
-               /* Redraw object recall */
-               creature_ptr->window |= (PW_OBJECT);
        }
+
+       creature_ptr->old_spells = creature_ptr->new_spells;
+       creature_ptr->redraw |= PR_STUDY;
+       creature_ptr->window |= PW_OBJECT;
 }
 
+
 /*!
  * @brief プレイヤーの最大MPを計算する /
  * Calculate maximum mana.  You do not need to know any spells.
@@ -4525,14 +4449,10 @@ static void calc_spells(player_type *creature_ptr)
  */
 static void calc_mana(player_type *creature_ptr)
 {
-       int msp, levels, cur_wgt, max_wgt;
-
-       object_type *o_ptr;
-
-
        /* Hack -- Must be literate */
        if (!mp_ptr->spell_book) return;
 
+       int levels;
        if ((creature_ptr->pclass == CLASS_MINDCRAFTER) ||
                (creature_ptr->pclass == CLASS_MIRROR_MASTER) ||
                (creature_ptr->pclass == CLASS_BLUE_MAGE))
@@ -4555,6 +4475,7 @@ static void calc_mana(player_type *creature_ptr)
                levels = (creature_ptr->lev - mp_ptr->spell_first) + 1;
        }
 
+       int msp;
        if (creature_ptr->pclass == CLASS_SAMURAI)
        {
                msp = (adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
@@ -4587,6 +4508,7 @@ static void calc_mana(player_type *creature_ptr)
                creature_ptr->cumber_glove = FALSE;
 
                /* Get the gloves */
+               object_type *o_ptr;
                o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
 
                /* Examine the gloves */
@@ -4608,12 +4530,11 @@ static void calc_mana(player_type *creature_ptr)
                }
        }
 
-
        /* Assume player not encumbered by armor */
        creature_ptr->cumber_armor = FALSE;
 
        /* Weigh the armor */
-       cur_wgt = 0;
+       int cur_wgt = 0;
        if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
        if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
        cur_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
@@ -4686,7 +4607,7 @@ static void calc_mana(player_type *creature_ptr)
        }
 
        /* Determine the weight allowance */
-       max_wgt = mp_ptr->spell_weight;
+       int max_wgt = mp_ptr->spell_weight;
 
        /* Heavy armor penalizes mana by a percentage.  -LM- */
        if ((cur_wgt - max_wgt) > 0)
@@ -4763,7 +4684,6 @@ static void calc_mana(player_type *creature_ptr)
        /* Mana can never be negative */
        if (msp < 0) msp = 0;
 
-
        /* Maximum mana has changed */
        if (creature_ptr->msp != msp)
        {
@@ -4789,7 +4709,6 @@ static void calc_mana(player_type *creature_ptr)
                creature_ptr->window |= (PW_PLAYER | PW_SPELL);
        }
 
-
        /* Hack -- handle "xtra" mode */
        if (current_world_ptr->character_xtra) return;
 
@@ -4805,28 +4724,25 @@ static void calc_mana(player_type *creature_ptr)
                        msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
                }
 
-               /* Save it */
                creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
        }
 
-
        /* Take note when "armor state" changes */
-       if (creature_ptr->old_cumber_armor != creature_ptr->cumber_armor)
-       {
-               if (creature_ptr->cumber_armor)
-               {
-                       msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
-               }
-               else
-               {
-                       msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
-               }
+       if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor) return;
 
-               /* Save it */
-               creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
+       if (creature_ptr->cumber_armor)
+       {
+               msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
+       }
+       else
+       {
+               msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
        }
+
+       creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
 }
 
+
 /*!
  * @brief 装備中の射撃武器の威力倍率を返す /
  * calcurate the fire rate of target object
@@ -4835,16 +4751,12 @@ static void calc_mana(player_type *creature_ptr)
  */
 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
 {
+       /* Scan the usable creature_ptr->inventory_list */
        int extra_shots = 0;
-       int i;
-       int num = 0;
-       OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
-       object_type *q_ptr;
        BIT_FLAGS flgs[TR_FLAG_SIZE];
-
-       /* Scan the usable creature_ptr->inventory_list */
-       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
+       for (int i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
+               object_type *q_ptr;
                q_ptr = &creature_ptr->inventory_list[i];
                if (!q_ptr->k_idx) continue;
 
@@ -4860,52 +4772,56 @@ s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
        object_flags(o_ptr, flgs);
        if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
 
-       if (o_ptr->k_idx && !is_heavy_shoot(creature_ptr, o_ptr))
-       {
-               num = 100;
-               /* Extra shots */
-               num += (extra_shots * 100);
+       int num = 0;
+       if (o_ptr->k_idx == 0 || is_heavy_shoot(creature_ptr, o_ptr))
+               return (s16b)num;
 
-               /* Hack -- Rangers love Bows */
-               if ((creature_ptr->pclass == CLASS_RANGER) &&
-                       (tval_ammo == TV_ARROW))
-               {
-                       num += (creature_ptr->lev * 4);
-               }
+       num = 100;
+       /* Extra shots */
+       num += (extra_shots * 100);
 
-               if ((creature_ptr->pclass == CLASS_CAVALRY) &&
-                       (tval_ammo == TV_ARROW))
-               {
-                       num += (creature_ptr->lev * 3);
-               }
+       /* Hack -- Rangers love Bows */
+       OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
+       if ((creature_ptr->pclass == CLASS_RANGER) &&
+               (tval_ammo == TV_ARROW))
+       {
+               num += (creature_ptr->lev * 4);
+       }
 
-               if (creature_ptr->pclass == CLASS_ARCHER)
-               {
-                       if (tval_ammo == TV_ARROW)
-                               num += ((creature_ptr->lev * 5) + 50);
-                       else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
-                               num += (creature_ptr->lev * 4);
-               }
+       if ((creature_ptr->pclass == CLASS_CAVALRY) &&
+               (tval_ammo == TV_ARROW))
+       {
+               num += (creature_ptr->lev * 3);
+       }
 
-               /*
-                * Addendum -- also "Reward" high level warriors,
-                * with _any_ missile weapon -- TY
-                */
-               if (creature_ptr->pclass == CLASS_WARRIOR &&
-                       (tval_ammo <= TV_BOLT) &&
-                       (tval_ammo >= TV_SHOT))
-               {
-                       num += (creature_ptr->lev * 2);
-               }
-               if ((creature_ptr->pclass == CLASS_ROGUE) &&
-                       (tval_ammo == TV_SHOT))
-               {
+       if (creature_ptr->pclass == CLASS_ARCHER)
+       {
+               if (tval_ammo == TV_ARROW)
+                       num += ((creature_ptr->lev * 5) + 50);
+               else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
                        num += (creature_ptr->lev * 4);
-               }
        }
+
+       /*
+        * Addendum -- also "Reward" high level warriors,
+        * with _any_ missile weapon -- TY
+        */
+       if (creature_ptr->pclass == CLASS_WARRIOR &&
+               (tval_ammo <= TV_BOLT) &&
+               (tval_ammo >= TV_SHOT))
+       {
+               num += (creature_ptr->lev * 2);
+       }
+       if ((creature_ptr->pclass == CLASS_ROGUE) &&
+               (tval_ammo == TV_SHOT))
+       {
+               num += (creature_ptr->lev * 4);
+       }
+
        return (s16b)num;
 }
 
+
 /*!
  * @brief プレイヤーの所持重量制限を計算する /
  * Computes current weight limit.
@@ -4913,16 +4829,15 @@ s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
  */
 WEIGHT weight_limit(player_type *creature_ptr)
 {
-       WEIGHT i;
-
        /* Weight limit based only on strength */
-       i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
+       WEIGHT i = (WEIGHT)adj_str_wgt[creature_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
        if (creature_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
 
        /* Return the result */
        return i;
 }
 
+
 /*!
  * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
  * @param i 判定する手のID(右手:0 左手:1)
@@ -4933,6 +4848,7 @@ bool has_melee_weapon(player_type *creature_ptr, int i)
        return ((creature_ptr->inventory_list[i].k_idx && object_is_melee_weapon(&creature_ptr->inventory_list[i])) ? TRUE : FALSE);
 }
 
+
 /*!
  * @brief プレイヤーの現在開いている手の状態を返す
  * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
@@ -4941,11 +4857,10 @@ bool has_melee_weapon(player_type *creature_ptr, int i)
 BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
 {
        BIT_FLAGS16 status = EMPTY_HAND_NONE;
-
        if (!creature_ptr->inventory_list[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
        if (!creature_ptr->inventory_list[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
 
-       if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_RYOUTE))
+       if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_TWO_HANDS))
        {
                if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
                else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
@@ -4961,11 +4876,10 @@ BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control)
  */
 bool heavy_armor(player_type *creature_ptr)
 {
-       WEIGHT monk_arm_wgt = 0;
-
        if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA)) return FALSE;
 
        /* Weight the armor */
+       WEIGHT monk_arm_wgt = 0;
        if (creature_ptr->inventory_list[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += creature_ptr->inventory_list[INVEN_RARM].weight;
        if (creature_ptr->inventory_list[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
        monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight;
@@ -4977,6 +4891,7 @@ bool heavy_armor(player_type *creature_ptr)
        return (monk_arm_wgt > (100 + (creature_ptr->lev * 4)));
 }
 
+
 /*!
  * @brief update のフラグに応じた更新をまとめて行う / Handle "update"
  * @return なし
@@ -4986,23 +4901,24 @@ void update_creature(player_type *creature_ptr)
 {
        if (!creature_ptr->update) return;
 
-       /* Actually do auto-destroy */
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
        if (creature_ptr->update & (PU_AUTODESTROY))
        {
                creature_ptr->update &= ~(PU_AUTODESTROY);
-               autopick_delayed_alter();
+               autopick_delayed_alter(creature_ptr);
        }
+
        if (creature_ptr->update & (PU_COMBINE))
        {
                creature_ptr->update &= ~(PU_COMBINE);
-               combine_pack();
+               combine_pack(creature_ptr);
        }
 
        /* Reorder the pack */
        if (creature_ptr->update & (PU_REORDER))
        {
                creature_ptr->update &= ~(PU_REORDER);
-               reorder_pack();
+               reorder_pack(creature_ptr);
        }
 
        if (creature_ptr->update & (PU_BONUS))
@@ -5045,48 +4961,44 @@ void update_creature(player_type *creature_ptr)
        if (creature_ptr->update & (PU_UN_LITE))
        {
                creature_ptr->update &= ~(PU_UN_LITE);
-               forget_lite();
+               forget_lite(floor_ptr);
        }
 
        if (creature_ptr->update & (PU_UN_VIEW))
        {
                creature_ptr->update &= ~(PU_UN_VIEW);
-               forget_view();
+               forget_view(floor_ptr);
        }
 
        if (creature_ptr->update & (PU_VIEW))
        {
                creature_ptr->update &= ~(PU_VIEW);
-               update_view();
+               update_view(creature_ptr, floor_ptr);
        }
 
        if (creature_ptr->update & (PU_LITE))
        {
                creature_ptr->update &= ~(PU_LITE);
-               update_lite();
+               update_lite(creature_ptr);
        }
 
-
        if (creature_ptr->update & (PU_FLOW))
        {
                creature_ptr->update &= ~(PU_FLOW);
-               update_flow();
+               update_flow(creature_ptr);
        }
 
        if (creature_ptr->update & (PU_DISTANCE))
        {
                creature_ptr->update &= ~(PU_DISTANCE);
 
-               /* Still need to call update_monsters(FALSE) after update_mon_lite() */
-               /* creature_ptr->update &= ~(PU_MONSTERS); */
-
-               update_monsters(TRUE);
+               update_monsters(creature_ptr, TRUE);
        }
 
        if (creature_ptr->update & (PU_MON_LITE))
        {
                creature_ptr->update &= ~(PU_MON_LITE);
-               update_mon_lite(current_floor_ptr);
+               update_mon_lite(creature_ptr);
        }
 
        /*
@@ -5096,50 +5008,53 @@ void update_creature(player_type *creature_ptr)
        if (creature_ptr->update & (PU_DELAY_VIS))
        {
                creature_ptr->update &= ~(PU_DELAY_VIS);
-               delayed_visual_update();
+               delayed_visual_update(creature_ptr);
        }
 
        if (creature_ptr->update & (PU_MONSTERS))
        {
                creature_ptr->update &= ~(PU_MONSTERS);
-               update_monsters(FALSE);
+               update_monsters(creature_ptr, FALSE);
        }
 }
 
+
 /*!
  * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
  * @return 魔道書を一冊も持っていないならTRUEを返す
  */
 bool player_has_no_spellbooks(player_type *creature_ptr)
 {
-       int i;
        object_type *o_ptr;
-
-       for (i = 0; i < INVEN_PACK; i++)
+       for (int i = 0; i < INVEN_PACK; i++)
        {
                o_ptr = &creature_ptr->inventory_list[i];
-               if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
+               if (o_ptr->k_idx && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval)) return FALSE;
        }
 
-       for (i = current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
        {
-               o_ptr = &current_floor_ptr->o_list[i];
-               if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
+               o_ptr = &floor_ptr->o_list[i];
+               if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(creature_ptr, o_ptr->tval, o_ptr->sval)) return FALSE;
        }
 
        return TRUE;
 }
 
+
 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
 {
        creature_ptr->energy_use = (ENERGY)need_cost;
 }
 
+
 void free_turn(player_type *creature_ptr)
 {
        creature_ptr->energy_use = 0;
 }
 
+
 /*!
  * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
  * @param x 配置先X座標
@@ -5148,51 +5063,45 @@ void free_turn(player_type *creature_ptr)
  */
 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
 {
-       /* Paranoia XXX XXX */
-       if (current_floor_ptr->grid_array[y][x].m_idx != 0) return FALSE;
+       if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx != 0) return FALSE;
 
        /* Save player location */
        creature_ptr->y = y;
        creature_ptr->x = x;
-
-       /* Success */
        return TRUE;
 }
 
+
 /*!
  * @brief 種族アンバライトが出血時パターンの上に乗った際のペナルティ処理
  * @return なし
  */
 void wreck_the_pattern(player_type *creature_ptr)
 {
-       int to_ruin = 0;
-       POSITION r_y, r_x;
-       int pattern_type = f_info[current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
-
-       if (pattern_type == PATTERN_TILE_WRECKED)
-       {
-               /* Ruined already */
-               return;
-       }
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       int pattern_type = f_info[floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat].subtype;
+       if (pattern_type == PATTERN_TILE_WRECKED) return;
 
        msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
        msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
 
-       if (!IS_INVULN()) take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
-       to_ruin = randint1(45) + 35;
+       if (!IS_INVULN(creature_ptr))
+               take_hit(creature_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"), -1);
 
+       int to_ruin = randint1(45) + 35;
        while (to_ruin--)
        {
-               scatter(&r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, 0);
+               POSITION r_y, r_x;
+               scatter(creature_ptr, &r_y, &r_x, creature_ptr->y, creature_ptr->x, 4, 0);
 
                if (pattern_tile(r_y, r_x) &&
-                       (f_info[current_floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
+                       (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
                {
-                       cave_set_feat(r_y, r_x, feat_pattern_corrupted);
+                       cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
                }
        }
 
-       cave_set_feat(creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
+       cave_set_feat(creature_ptr, creature_ptr->y, creature_ptr->x, feat_pattern_corrupted);
 }
 
 
@@ -5204,10 +5113,9 @@ void wreck_the_pattern(player_type *creature_ptr)
  */
 void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
 {
-       int power = 100;
-
        if (creature_ptr->phase_out || !current_world_ptr->character_dungeon) return;
 
+       int power = 100;
        if (!necro && m_ptr)
        {
                GAME_TEXT m_name[MAX_NLEN];
@@ -5215,7 +5123,7 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
 
                power = r_ptr->level / 2;
 
-               monster_desc(m_name, m_ptr, 0);
+               monster_desc(creature_ptr, m_name, m_ptr, 0);
 
                if (!(r_ptr->flags1 & RF1_UNIQUE))
                {
@@ -5282,15 +5190,17 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                GAME_TEXT m_name[MAX_NLEN];
                concptr desc;
 
-               get_mon_num_prep(get_nightmare, NULL);
+               get_mon_num_prep(creature_ptr, get_nightmare, NULL);
 
-               r_ptr = &r_info[get_mon_num(MAX_DEPTH)];
+               r_ptr = &r_info[get_mon_num(creature_ptr, MAX_DEPTH)];
                power = r_ptr->level + 10;
                desc = r_name + r_ptr->name;
 
-               get_mon_num_prep(NULL, NULL);
+               get_mon_num_prep(creature_ptr, NULL, NULL);
+
+#ifdef JP
+#else
 
-#ifndef JP
                if (!(r_ptr->flags1 & RF1_UNIQUE))
                        sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
                else
@@ -5369,31 +5279,29 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
        }
 
-       if (saving_throw(creature_ptr->skill_sav - power))
+       /* 過去の効果無効率再現のため5回saving_throw 実行 */
+       if (saving_throw(creature_ptr->skill_sav - power)
+               && saving_throw(creature_ptr->skill_sav - power)
+               && saving_throw(creature_ptr->skill_sav - power)
+               && saving_throw(creature_ptr->skill_sav - power)
+               && saving_throw(creature_ptr->skill_sav - power)
+               )
        {
                return;
        }
 
-       do {
-               (void)do_dec_stat(creature_ptr, A_INT);
-       } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
-
-       do {
-               (void)do_dec_stat(creature_ptr, A_WIS);
-       } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
-
-       switch (randint1(21))
+       switch (randint1(22))
        {
        case 1:
-               if (!(creature_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
+               if (!(creature_ptr->muta3 & MUT3_MORONIC))
                {
                        if ((creature_ptr->stat_use[A_INT] < 4) && (creature_ptr->stat_use[A_WIS] < 4))
                        {
-                               msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You current_world_ptr->game_turn into an utter moron!"));
+                               msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
                        }
                        else
                        {
-                               msg_print(_("あなたは完璧な馬鹿になった!", "You current_world_ptr->game_turn into an utter moron!"));
+                               msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
                        }
 
                        if (creature_ptr->muta3 & MUT3_HYPER_INT)
@@ -5405,8 +5313,6 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                }
                break;
        case 2:
-       case 3:
-       case 4:
                if (!(creature_ptr->muta2 & MUT2_COWARDICE) && !creature_ptr->resist_fear)
                {
                        msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
@@ -5421,30 +5327,42 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                        creature_ptr->muta2 |= MUT2_COWARDICE;
                }
                break;
-       case 5:
-       case 6:
-       case 7:
+       case 3:
                if (!(creature_ptr->muta2 & MUT2_HALLU) && !creature_ptr->resist_chaos)
                {
                        msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
                        creature_ptr->muta2 |= MUT2_HALLU;
                }
                break;
-       case 8:
-       case 9:
-       case 10:
-               if (!(creature_ptr->muta2 & MUT2_BERS_RAGE))
+       case 4:
+               if (!(creature_ptr->muta2 & MUT2_BERS_RAGE) && !creature_ptr->resist_conf)
                {
                        msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
                        creature_ptr->muta2 |= MUT2_BERS_RAGE;
                }
                break;
+       case 5:
+       case 6:
+       case 7:
+       case 8:
+       case 9:
+       case 10:
        case 11:
        case 12:
+               /* Mind blast */
+               if (!creature_ptr->resist_conf)
+               {
+                       (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
+               }
+               if (!creature_ptr->resist_chaos && one_in_(3))
+               {
+                       (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
+               }
+               return;
+               break;
        case 13:
        case 14:
        case 15:
-       case 16:
                /* Brain smash */
                if (!creature_ptr->resist_conf)
                {
@@ -5458,20 +5376,36 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                {
                        (void)set_image(creature_ptr, creature_ptr->image + randint0(250) + 150);
                }
+               do {
+                       (void)do_dec_stat(creature_ptr, A_INT);
+               } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
+
+               do {
+                       (void)do_dec_stat(creature_ptr, A_WIS);
+               } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
+
                break;
+       case 16:
        case 17:
+               /* Amnesia */
+               if (lose_all_info(creature_ptr))
+                       msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
+               break;
        case 18:
        case 19:
        case 20:
        case 21:
-               /* Amnesia */
-               if (lose_all_info(creature_ptr))
-                       msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
+       case 22:
+               /* Lose int & wis */
+               do_dec_stat(creature_ptr, A_INT);
+               do_dec_stat(creature_ptr, A_WIS);
+               break;
+       default:
                break;
        }
 
        creature_ptr->update |= PU_BONUS;
-       handle_stuff();
+       handle_stuff(creature_ptr);
 }
 
 
@@ -5482,12 +5416,6 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
  */
 void check_experience(player_type *creature_ptr)
 {
-       bool level_reward = FALSE;
-       bool level_mutation = FALSE;
-       bool level_inc_stat = FALSE;
-       bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
-       PLAYER_LEVEL old_lev = creature_ptr->lev;
-
        /* Hack -- lower limit */
        if (creature_ptr->exp < 0) creature_ptr->exp = 0;
        if (creature_ptr->max_exp < 0) creature_ptr->max_exp = 0;
@@ -5506,10 +5434,11 @@ void check_experience(player_type *creature_ptr)
 
        /* Redraw experience */
        creature_ptr->redraw |= (PR_EXP);
-       handle_stuff();
-
+       handle_stuff(creature_ptr);
 
        /* Lose levels while possible */
+       bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
+       PLAYER_LEVEL old_lev = creature_ptr->lev;
        while ((creature_ptr->lev > 1) &&
                (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L)))
        {
@@ -5518,11 +5447,13 @@ void check_experience(player_type *creature_ptr)
                creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
                creature_ptr->redraw |= (PR_LEV | PR_TITLE);
                creature_ptr->window |= (PW_PLAYER);
-               handle_stuff();
+               handle_stuff(creature_ptr);
        }
 
-
        /* Gain levels while possible */
+       bool level_reward = FALSE;
+       bool level_mutation = FALSE;
+       bool level_inc_stat = FALSE;
        while ((creature_ptr->lev < PY_MAX_LEVEL) &&
                (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L)))
        {
@@ -5545,7 +5476,7 @@ void check_experience(player_type *creature_ptr)
                        }
                        level_inc_stat = TRUE;
 
-                       exe_write_diary(p_ptr, NIKKI_LEVELUP, creature_ptr->lev, NULL);
+                       exe_write_diary(creature_ptr, DIARY_LEVELUP, creature_ptr->lev, NULL);
                }
 
                sound(SOUND_LEVEL);
@@ -5558,7 +5489,7 @@ void check_experience(player_type *creature_ptr)
 
                /* HPとMPの上昇量を表示 */
                creature_ptr->level_up_message = TRUE;
-               handle_stuff();
+               handle_stuff(creature_ptr);
 
                creature_ptr->level_up_message = FALSE;
 
@@ -5568,7 +5499,7 @@ void check_experience(player_type *creature_ptr)
                        {
                                int choice;
                                screen_save();
-                               while (1)
+                               while (TRUE)
                                {
                                        int n;
                                        char tmp[32];
@@ -5576,20 +5507,20 @@ void check_experience(player_type *creature_ptr)
                                        cnv_stat(creature_ptr->stat_max[0], tmp);
                                        prt(format(_("        a) 腕力 (現在値 %s)", "        a) Str (cur %s)"), tmp), 2, 14);
                                        cnv_stat(creature_ptr->stat_max[1], tmp);
-                                       prt(format(_("        b) 知能 (現在値 %s)", "        a) Int (cur %s)"), tmp), 3, 14);
+                                       prt(format(_("        b) 知能 (現在値 %s)", "        b) Int (cur %s)"), tmp), 3, 14);
                                        cnv_stat(creature_ptr->stat_max[2], tmp);
-                                       prt(format(_("        c) 賢さ (現在値 %s)", "        a) Wis (cur %s)"), tmp), 4, 14);
+                                       prt(format(_("        c) 賢さ (現在値 %s)", "        c) Wis (cur %s)"), tmp), 4, 14);
                                        cnv_stat(creature_ptr->stat_max[3], tmp);
-                                       prt(format(_("        d) 器用 (現在値 %s)", "        a) Dex (cur %s)"), tmp), 5, 14);
+                                       prt(format(_("        d) 器用 (現在値 %s)", "        d) Dex (cur %s)"), tmp), 5, 14);
                                        cnv_stat(creature_ptr->stat_max[4], tmp);
-                                       prt(format(_("        e) 耐久 (現在値 %s)", "        a) Con (cur %s)"), tmp), 6, 14);
+                                       prt(format(_("        e) 耐久 (現在値 %s)", "        e) Con (cur %s)"), tmp), 6, 14);
                                        cnv_stat(creature_ptr->stat_max[5], tmp);
-                                       prt(format(_("        f) 魅力 (現在値 %s)", "        a) Chr (cur %s)"), tmp), 7, 14);
+                                       prt(format(_("        f) 魅力 (現在値 %s)", "        f) Chr (cur %s)"), tmp), 7, 14);
 
                                        prt("", 8, 14);
                                        prt(_("        どの能力値を上げますか?", "        Which stat do you want to raise?"), 1, 14);
 
-                                       while (1)
+                                       while (TRUE)
                                        {
                                                choice = inkey();
                                                if ((choice >= 'a') && (choice <= 'f')) break;
@@ -5626,13 +5557,14 @@ void check_experience(player_type *creature_ptr)
                creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
                creature_ptr->redraw |= (PR_LEV | PR_TITLE);
                creature_ptr->window |= (PW_PLAYER | PW_SPELL);
-               handle_stuff();
+               handle_stuff(creature_ptr);
        }
 
        /* Load an autopick preference file */
-       if (old_lev != creature_ptr->lev) autopick_load_pref(FALSE);
+       if (old_lev != creature_ptr->lev) autopick_load_pref(creature_ptr, FALSE);
 }
 
+
 /*!
  * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
  * @param val 能力値
@@ -5641,32 +5573,28 @@ void check_experience(player_type *creature_ptr)
  */
 void cnv_stat(int val, char *out_val)
 {
-       /* Above 18 */
-       if (val > 18)
+       if (val <= 18)
        {
-               int bonus = (val - 18);
-
-               if (bonus >= 220)
-               {
-                       sprintf(out_val, "18/%3s", "***");
-               }
-               else if (bonus >= 100)
-               {
-                       sprintf(out_val, "18/%03d", bonus);
-               }
-               else
-               {
-                       sprintf(out_val, " 18/%02d", bonus);
-               }
+               sprintf(out_val, "    %2d", val);
+               return;
        }
 
-       /* From 3 to 18 */
+       int bonus = (val - 18);
+       if (bonus >= 220)
+       {
+               sprintf(out_val, "18/%3s", "***");
+       }
+       else if (bonus >= 100)
+       {
+               sprintf(out_val, "18/%03d", bonus);
+       }
        else
        {
-               sprintf(out_val, "    %2d", val);
+               sprintf(out_val, " 18/%02d", bonus);
        }
 }
 
+
 /*!
  * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
  * Modify a stat value by a "modifier", return new value
@@ -5683,13 +5611,11 @@ void cnv_stat(int val, char *out_val)
  */
 s16b modify_stat_value(int value, int amount)
 {
-       int    i;
-
        /* Reward */
        if (amount > 0)
        {
                /* Apply each point */
-               for (i = 0; i < amount; i++)
+               for (int i = 0; i < amount; i++)
                {
                        /* One point at a time */
                        if (value < 18) value++;
@@ -5703,7 +5629,7 @@ s16b modify_stat_value(int value, int amount)
        else if (amount < 0)
        {
                /* Apply each point */
-               for (i = 0; i < (0 - amount); i++)
+               for (int i = 0; i < (0 - amount); i++)
                {
                        /* Ten points at a time */
                        if (value >= 18 + 10) value -= 10;
@@ -5717,7 +5643,7 @@ s16b modify_stat_value(int value, int amount)
        }
 
        /* Return new value */
-       return (s16b)(value);
+       return (s16b)value;
 }
 
 
@@ -5729,11 +5655,9 @@ s16b modify_stat_value(int value, int amount)
  */
 long calc_score(player_type *creature_ptr)
 {
-       int i, mult = 100;
-       DEPTH max_dl = 0;
-       u32b point, point_h, point_l;
        int arena_win = MIN(creature_ptr->arena_number, MAX_ARENA_MONS);
 
+       int mult = 100;
        if (!preserve_mode) mult += 10;
        if (!autoroller) mult += 10;
        if (!smart_learn) mult -= 20;
@@ -5747,12 +5671,13 @@ long calc_score(player_type *creature_ptr)
 
        if (mult < 5) mult = 5;
 
-       for (i = 0; i < max_d_idx; i++)
+       DEPTH max_dl = 0;
+       for (int i = 0; i < current_world_ptr->max_d_idx; i++)
                if (max_dlv[i] > max_dl)
                        max_dl = max_dlv[i];
 
-       point_l = (creature_ptr->max_max_exp + (100 * max_dl));
-       point_h = point_l / 0x10000L;
+       u32b point_l = (creature_ptr->max_max_exp + (100 * max_dl));
+       u32b point_h = point_l / 0x10000L;
        point_l = point_l % 0x10000L;
        point_h *= mult;
        point_l *= mult;
@@ -5763,7 +5688,7 @@ long calc_score(player_type *creature_ptr)
        point_h /= 100;
        point_l /= 100;
 
-       point = (point_h << 16) + (point_l);
+       u32b point = (point_h << 16) + (point_l);
        if (creature_ptr->arena_number >= 0)
                point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
 
@@ -5777,8 +5702,9 @@ long calc_score(player_type *creature_ptr)
        if ((creature_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
        {
                point = 1;
-               if (creature_ptr->total_winner) point = 2;
+               if (current_world_ptr->total_winner) point = 2;
        }
+
        if (easy_band) point = (0 - point);
 
        return point;
@@ -5794,7 +5720,7 @@ void cheat_death(player_type *creature_ptr)
        creature_ptr->age++;
 
        /* Mark savefile */
-       creature_ptr->noscore |= 0x0001;
+       current_world_ptr->noscore |= 0x0001;
 
        msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
        msg_print(NULL);
@@ -5846,11 +5772,12 @@ void cheat_death(player_type *creature_ptr)
        /* Hack -- Prevent starvation */
        (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
 
-       current_floor_ptr->dun_level = 0;
-       creature_ptr->inside_arena = FALSE;
+       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
+       floor_ptr->dun_level = 0;
+       floor_ptr->inside_arena = FALSE;
        creature_ptr->phase_out = FALSE;
        leaving_quest = 0;
-       creature_ptr->inside_quest = 0;
+       floor_ptr->inside_quest = 0;
        if (creature_ptr->dungeon_idx) creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
        creature_ptr->dungeon_idx = 0;
        if (lite_town || vanilla_town)
@@ -5875,15 +5802,85 @@ void cheat_death(player_type *creature_ptr)
                creature_ptr->oldpy = 33;
                creature_ptr->oldpx = 131;
        }
+
        creature_ptr->wild_mode = FALSE;
        creature_ptr->leaving = TRUE;
 
-       exe_write_diary(p_ptr, NIKKI_BUNSHOU, 1,
+       exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1,
                _("                            しかし、生き返った。",
                        "                            but revived."));
 
        /* Prepare next floor */
-       leave_floor(creature_ptr->change_floor_mode);
-       wipe_m_list();
+       leave_floor(creature_ptr);
+       wipe_monsters_list(creature_ptr);
+}
+
+
+/*!
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return 祝福状態ならばTRUE
+ */
+bool is_blessed(player_type *creature_ptr)
+{
+       return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
+}
+
+
+bool is_oppose_acid(player_type *creature_ptr)
+{
+       return creature_ptr->oppose_acid || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
+}
+
+
+bool is_oppose_elec(player_type *creature_ptr)
+{
+       return creature_ptr->oppose_elec || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
+}
 
+
+bool is_oppose_fire(player_type *creature_ptr)
+{
+       return creature_ptr->oppose_fire || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
+}
+
+
+bool is_oppose_cold(player_type *creature_ptr)
+{
+       return creature_ptr->oppose_cold || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
+}
+
+
+bool is_oppose_pois(player_type *creature_ptr)
+{
+       return creature_ptr->oppose_pois || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU);
+}
+
+
+bool is_tim_esp(player_type *creature_ptr)
+{
+       return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
+}
+
+
+bool is_tim_stealth(player_type *creature_ptr)
+{
+       return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
+}
+
+
+bool is_time_limit_esp(player_type *creature_ptr)
+{
+       return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD);
+}
+
+
+bool is_time_limit_stealth(player_type *creature_ptr)
+{
+       return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH);
+}
+
+
+bool can_two_hands_wielding(player_type *creature_ptr)
+{
+       return !creature_ptr->riding || (creature_ptr->pet_extra_flags & PF_TWO_HANDS);
 }