OSDN Git Service

[Refactor] #38862 Moved floor*.c to floor/
[hengband/hengband.git] / src / player-status.c
index 9045769..914b2e9 100644 (file)
@@ -1,23 +1,25 @@
 #include "angband.h"
-#include "core.h"
+#include "core/stuff-handler.h"
 #include "util.h"
+#include "main/sound-definitions-table.h"
 
-#include "bldg.h"
+#include "market/building.h"
 #include "quest.h"
 #include "player-move.h"
 #include "player-status.h"
 #include "player-effects.h"
 #include "player-skill.h"
-#include "player-race.h"
+#include "player/race-info-table.h"
+#include "player/mimic-info-table.h"
 #include "player-class.h"
 #include "player-personality.h"
 #include "player-damage.h"
-#include "floor.h"
-#include "floor-events.h"
+#include "floor/floor.h"
+#include "floor/floor-events.h"
 #include "feature.h"
 #include "artifact.h"
 #include "avatar.h"
-#include "spells.h"
+#include "spell/technic-info-table.h"
 #include "spells-status.h"
 #include "object.h"
 #include "object-hook.h"
 #include "monster.h"
 #include "monster-status.h"
 #include "monsterrace-hook.h"
-#include "mutation.h"
+#include "mutation/mutation.h"
 #include "patron.h"
-#include "realm-hex.h"
-#include "realm-song.h"
-#include "cmd-pet.h"
-#include "cmd-spell.h"
-#include "dungeon.h"
-#include "objectkind.h"
+#include "realm/realm-hex.h"
+#include "realm/realm-song.h"
+#include "cmd/cmd-pet.h"
+#include "cmd/cmd-spell.h"
+#include "dungeon/dungeon.h"
+#include "object/object-kind.h"
 #include "monsterrace.h"
-#include "autopick.h"
-#include "cmd-dump.h"
+#include "autopick/autopick.h"
+#include "autopick/autopick-reader-writer.h"
+#include "io/write-diary.h"
+#include "cmd/cmd-dump.h"
 #include "melee.h"
-#include "world.h"
-#include "view-mainwindow.h"
+#include "world/world.h"
+#include "view/display-main-window.h"
 #include "files.h"
 #include "cmd-magiceat.h"
 
+#include "horror-descriptions.h"
+#include "market/arena-info-table.h"
+#include "spell/spells-util.h"
+#include "spell/spells-execution.h"
+
 /*!
  * @brief 能力値テーブル / Abbreviations of healthy stats
  */
@@ -52,7 +61,6 @@ const concptr stat_names[6] =
 #else
        "STR : ", "INT : ", "WIS : ", "DEX : ", "CON : ", "CHR : "
 #endif
-
 };
 
 /*!
@@ -65,160 +73,8 @@ const concptr stat_names_reduced[6] =
 #else
        "Str : ", "Int : ", "Wis : ", "Dex : ", "Con : ", "Chr : "
 #endif
-
-};
-
-/* ELDRITCH_HORRORによるsanity blast処理に関するメッセージの最大数 / Number of entries in the sanity-blast descriptions */
-#define MAX_SAN_HORROR 20 /*!< 恐ろしい対象の形容数(正常時) */
-#define MAX_SAN_FUNNY 22  /*!< 恐ろしい対象の形容数(幻覚時) */
-#define MAX_SAN_COMMENT 5 /*!< 恐ろしい対象を見たときの絶叫メッセージ数(幻覚時) */
-
-/*!
- * @var horror_desc
- * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
- */
-static concptr horror_desc[MAX_SAN_HORROR] =
-{
-#ifdef JP
-       "忌まわしい",
-       "底知れぬ",
-       "ぞっとする",
-       "破滅的な",
-       "冒涜的な",
-
-       "いやな",
-       "恐ろしい",
-       "不潔な",
-       "容赦のない",
-       "おぞましい",
-
-       "地獄の",
-       "身の毛もよだつ",
-       "地獄の",
-       "忌まわしい",
-       "悪夢のような",
-
-       "嫌悪を感じる",
-       "罰当たりな",
-       "恐い",
-       "不浄な",
-       "言うもおぞましい",
-#else
-       "abominable",
-       "abysmal",
-       "appalling",
-       "baleful",
-       "blasphemous",
-
-       "disgusting",
-       "dreadful",
-       "filthy",
-       "grisly",
-       "hideous",
-
-       "hellish",
-       "horrible",
-       "infernal",
-       "loathsome",
-       "nightmarish",
-
-       "repulsive",
-       "sacrilegious",
-       "terrible",
-       "unclean",
-       "unspeakable",
-#endif
-
-};
-
-/*!
- * @var funny_desc
- * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
- */
-static concptr funny_desc[MAX_SAN_FUNNY] =
-{
-#ifdef JP
-       "間抜けな",
-       "滑稽な",
-       "ばからしい",
-       "無味乾燥な",
-       "馬鹿げた",
-
-       "笑える",
-       "ばかばかしい",
-       "ぶっとんだ",
-       "いかした",
-       "ポストモダンな",
-
-       "ファンタスティックな",
-       "ダダイズム的な",
-       "キュビズム的な",
-       "宇宙的な",
-       "卓越した",
-
-       "理解不能な",
-       "ものすごい",
-       "驚くべき",
-       "信じられない",
-       "カオティックな",
-
-       "野性的な",
-       "非常識な",
-#else
-       "silly",
-       "hilarious",
-       "absurd",
-       "insipid",
-       "ridiculous",
-
-       "laughable",
-       "ludicrous",
-       "far-out",
-       "groovy",
-       "postmodern",
-
-       "fantastic",
-       "dadaistic",
-       "cubistic",
-       "cosmic",
-       "awesome",
-
-       "incomprehensible",
-       "fabulous",
-       "amazing",
-       "incredible",
-       "chaotic",
-
-       "wild",
-       "preposterous",
-#endif
-
-};
-
-/*!
- * @var funny_comments
- * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
- */
-static concptr funny_comments[MAX_SAN_COMMENT] =
-{
-#ifdef JP
-       /* nuke me */
-         "最高だぜ!",
-         "うひょー!",
-         "いかすぜ!",
-         "すんばらしい!",
-         "ぶっとびー!"
-  #else
-         "Wow, cosmic, man!",
-         "Rad!",
-         "Groovy!",
-         "Cool!",
-         "Far out!"
-  #endif
-
 };
 
-
 /*!
  * @brief 基本必要経験値テーブル /
  * Base experience levels, may be adjusted up for race and/or class
@@ -277,7 +133,6 @@ const s32b player_exp[PY_MAX_LEVEL] =
        5000000L
 };
 
-
 /*!
  * @brief 基本必要強化値テーブル(アンドロイド専用)
  */
@@ -335,7 +190,6 @@ const s32b player_exp_a[PY_MAX_LEVEL] =
        5000000L
 };
 
-
 /*!
  * 知力/賢さによるレベル毎の習得可能魔法数テーブル
  * Stat Table (INT/WIS) -- Number of half-spells per level
@@ -382,7 +236,6 @@ const byte adj_mag_study[] =
        6       /* 18/220+ */
 };
 
-
 /*!
  * 知力/賢さによるMP修正テーブル
  * Stat Table (INT/WIS) -- extra 1/4-mana-points per level
@@ -429,7 +282,6 @@ const byte adj_mag_mana[] =
        30      /* 18/220+ */
 };
 
-
 /*!
  * 知力/賢さによる最低魔法失敗率テーブル
  * Stat Table (INT/WIS) -- Minimum failure rate (percentage)
@@ -476,7 +328,6 @@ const byte adj_mag_fail[] =
        0       /* 18/220+ */
 };
 
-
 /*!
  * 知力/賢さによる魔法失敗率修正テーブル
  * Stat Table (INT/WIS) -- Various things
@@ -523,7 +374,6 @@ const byte adj_mag_stat[] =
        20      /* 18/220+ */
 };
 
-
 /*!
  * 魅力による店での取引修正テーブル
  * Stat Table (CHR) -- payment percentages
@@ -570,7 +420,6 @@ const byte adj_chr_gold[] =
        78      /* 18/220+ */
 };
 
-
 /*!
  * 知力による魔道具使用修正テーブル
  * Stat Table (INT) -- Magic devices
@@ -617,7 +466,6 @@ const byte adj_int_dev[] =
        20      /* 18/220+ */
 };
 
-
 /*!
  * 賢さによる魔法防御修正テーブル
  * Stat Table (WIS) -- Saving throw
@@ -664,7 +512,6 @@ const byte adj_wis_sav[] =
        19      /* 18/220+ */
 };
 
-
 /*!
  * 器用さによるトラップ解除修正テーブル
  * Stat Table (DEX) -- disarming
@@ -711,7 +558,6 @@ const byte adj_dex_dis[] =
        10      /* 18/220+ */
 };
 
-
 /*!
  * 知力によるトラップ解除修正テーブル
  * Stat Table (INT) -- disarming
@@ -758,7 +604,6 @@ const byte adj_int_dis[] =
        20      /* 18/220+ */
 };
 
-
 /*!
  * 器用さによるAC修正テーブル
  * Stat Table (DEX) -- bonus to ac (plus 128)
@@ -805,7 +650,6 @@ const byte adj_dex_ta[] =
        128 + 16    /* 18/220+ */
 };
 
-
 /*!
  * 腕力によるダメージ修正テーブル
  * Stat Table (STR) -- bonus to dam (plus 128)
@@ -852,7 +696,6 @@ const byte adj_str_td[] =
        128 + 20    /* 18/220+ */
 };
 
-
 /*!
  * 器用度による命中修正テーブル
  * Stat Table (DEX) -- bonus to hit (plus 128)
@@ -899,7 +742,6 @@ const byte adj_dex_th[] =
        128 + 16        /* 18/220+ */
 };
 
-
 /*!
  * 腕力による命中修正テーブル
  * Stat Table (STR) -- bonus to hit (plus 128)
@@ -946,7 +788,6 @@ const byte adj_str_th[] =
        128 + 16        /* 18/220+ */
 };
 
-
 /*!
  * 腕力による基本所持重量値テーブル
  * Stat Table (STR) -- weight limit in deca-pounds
@@ -993,7 +834,6 @@ const byte adj_str_wgt[] =
        39      /* 18/220+ */
 };
 
-
 /*!
  * 腕力による武器重量限界値テーブル
  * Stat Table (STR) -- weapon weight limit in pounds
@@ -1040,7 +880,6 @@ const byte adj_str_hold[] =
        50     /* 18/220+ */
 };
 
-
 /*!
  * 腕力による採掘能力修正値テーブル
  * Stat Table (STR) -- digging value
@@ -1133,7 +972,6 @@ const byte adj_dex_safe[] =
        100     /* 18/220+ */
 };
 
-
 /*!
  * 耐久による基本HP自然治癒値テーブル /
  * Stat Table (CON) -- base regeneration rate
@@ -1180,7 +1018,6 @@ const byte adj_con_fix[] =
        9       /* 18/220+ */
 };
 
-
 /*!
  * 耐久による基本HP自然治癒値テーブル /
  * Stat Table (CON) -- extra 1/4-hitpoints per level (plus 128)
@@ -1227,7 +1064,6 @@ const byte adj_con_mhp[] =
        128 + 48        /* 18/220+ */
 };
 
-
 /*!
  * 魅力による魅了能力修正テーブル /
  * Stat Table (CHR) -- charm
@@ -1274,7 +1110,6 @@ const byte adj_chr_chm[] =
        85      /* 18/220+ */
 };
 
-
 /*** Player information ***/
 
 /*
@@ -1367,7 +1202,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);
@@ -1401,25 +1236,17 @@ void calc_bonuses(player_type *creature_ptr)
        bool old_see_inv = creature_ptr->see_inv;
        bool old_mighty_throw = creature_ptr->mighty_throw;
 
-       /* Current feature under player. */
        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 */
        creature_ptr->dis_ac = creature_ptr->ac = 0;
-
-       /* Clear the Displayed/Real Bonuses */
        creature_ptr->dis_to_h[0] = creature_ptr->to_h[0] = 0;
        creature_ptr->dis_to_h[1] = creature_ptr->to_h[1] = 0;
        creature_ptr->dis_to_d[0] = creature_ptr->to_d[0] = 0;
@@ -1428,30 +1255,16 @@ void calc_bonuses(player_type *creature_ptr)
        creature_ptr->dis_to_a = creature_ptr->to_a = 0;
        creature_ptr->to_h_m = 0;
        creature_ptr->to_d_m = 0;
-
        creature_ptr->to_m_chance = 0;
-
-       /* Clear the Extra Dice Bonuses */
        creature_ptr->to_dd[0] = creature_ptr->to_ds[0] = 0;
        creature_ptr->to_dd[1] = creature_ptr->to_ds[1] = 0;
 
-       /* Start with "normal" speed */
        new_speed = 110;
-
-       /* 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 turn */
        creature_ptr->num_fire = 100;
-
-       /* Reset the "xtra" tval */
        creature_ptr->tval_xtra = 0;
-
-       /* Reset the "ammo" tval */
        creature_ptr->tval_ammo = 0;
-
-       /* Clear all the flags */
        creature_ptr->cursed = 0L;
        creature_ptr->bless_blade = FALSE;
        creature_ptr->xtra_might = FALSE;
@@ -1516,12 +1329,10 @@ void calc_bonuses(player_type *creature_ptr)
        creature_ptr->warning = FALSE;
        creature_ptr->mighty_throw = FALSE;
        creature_ptr->see_nocto = FALSE;
-
        creature_ptr->immune_acid = FALSE;
        creature_ptr->immune_elec = FALSE;
        creature_ptr->immune_fire = FALSE;
        creature_ptr->immune_cold = FALSE;
-
        creature_ptr->ryoute = FALSE;
        creature_ptr->migite = FALSE;
        creature_ptr->hidarite = FALSE;
@@ -1530,37 +1341,16 @@ void calc_bonuses(player_type *creature_ptr)
        if (creature_ptr->mimic_form) tmp_rp_ptr = &mimic_info[creature_ptr->mimic_form];
        else tmp_rp_ptr = &race_info[creature_ptr->prace];
 
-       /* Base infravision (purely racial) */
        creature_ptr->see_infra = tmp_rp_ptr->infra;
-
-       /* Base skill -- disarming */
        creature_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
-
-       /* Base skill -- magic devices */
        creature_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
-
-       /* Base skill -- saving throw */
        creature_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
-
-       /* Base skill -- stealth */
        creature_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
-
-       /* Base skill -- searching ability */
        creature_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
-
-       /* Base skill -- searching frequency */
        creature_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
-
-       /* Base skill -- combat (normal) */
        creature_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
-
-       /* Base skill -- combat (shooting) */
        creature_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
-
-       /* Base skill -- combat (throwing) */
        creature_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
-
-       /* Base skill -- digging */
        creature_ptr->skill_dig = 0;
 
        if (has_melee_weapon(creature_ptr, INVEN_RARM)) creature_ptr->migite = TRUE;
@@ -1638,7 +1428,6 @@ void calc_bonuses(player_type *creature_ptr)
                break;
        case CLASS_MONK:
        case CLASS_FORCETRAINER:
-               /* Unencumbered Monks become faster every 10 levels */
                if (!(heavy_armor(creature_ptr)))
                {
                        if (!(PRACE_IS_(creature_ptr, RACE_KLACKON) ||
@@ -1646,10 +1435,10 @@ void calc_bonuses(player_type *creature_ptr)
                                (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
                                new_speed += (creature_ptr->lev) / 10;
 
-                       /* Free action if unencumbered at level 25 */
                        if (creature_ptr->lev > 24)
                                creature_ptr->free_act = TRUE;
                }
+
                break;
        case CLASS_SORCERER:
                creature_ptr->to_a -= 50;
@@ -1683,7 +1472,6 @@ void calc_bonuses(player_type *creature_ptr)
                if (creature_ptr->lev > 39) creature_ptr->reflect = TRUE;
                break;
        case CLASS_NINJA:
-               /* Unencumbered Ninjas become faster every 10 levels */
                if (heavy_armor(creature_ptr))
                {
                        new_speed -= (creature_ptr->lev) / 10;
@@ -1698,17 +1486,17 @@ void calc_bonuses(player_type *creature_ptr)
                                (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
                                new_speed += (creature_ptr->lev) / 10;
                        creature_ptr->skill_stl += (creature_ptr->lev) / 10;
-
-                       /* Free action if unencumbered at level 25 */
                        if (creature_ptr->lev > 24)
                                creature_ptr->free_act = TRUE;
                }
+
                if ((!creature_ptr->inventory_list[INVEN_RARM].k_idx || creature_ptr->migite) &&
                        (!creature_ptr->inventory_list[INVEN_LARM].k_idx || creature_ptr->hidarite))
                {
                        creature_ptr->to_a += creature_ptr->lev / 2 + 5;
                        creature_ptr->dis_to_a += creature_ptr->lev / 2 + 5;
                }
+
                creature_ptr->slow_digest = TRUE;
                creature_ptr->resist_fear = TRUE;
                if (creature_ptr->lev > 19) creature_ptr->resist_pois = TRUE;
@@ -1719,11 +1507,11 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->oppose_pois = 1;
                        creature_ptr->redraw |= PR_STATUS;
                }
+
                creature_ptr->see_nocto = TRUE;
                break;
        }
 
-       /***** Races ****/
        if (creature_ptr->mimic_form)
        {
                switch (creature_ptr->mimic_form)
@@ -1801,9 +1589,7 @@ void calc_bonuses(player_type *creature_ptr)
 
                        if (creature_ptr->lev > 14)
                        {
-                               /* High level trolls heal fast... */
                                creature_ptr->regenerate = TRUE;
-
                                if (creature_ptr->pclass == CLASS_WARRIOR || creature_ptr->pclass == CLASS_BERSERKER)
                                {
                                        creature_ptr->slow_digest = TRUE;
@@ -1817,7 +1603,7 @@ void calc_bonuses(player_type *creature_ptr)
                        break;
                case RACE_AMBERITE:
                        creature_ptr->sustain_con = TRUE;
-                       creature_ptr->regenerate = TRUE;  /* Amberites heal fast... */
+                       creature_ptr->regenerate = TRUE;
                        break;
                case RACE_HIGH_ELF:
                        creature_ptr->resist_lite = TRUE;
@@ -1847,8 +1633,6 @@ void calc_bonuses(player_type *creature_ptr)
                case RACE_KLACKON:
                        creature_ptr->resist_conf = TRUE;
                        creature_ptr->resist_acid = TRUE;
-
-                       /* Klackons become faster */
                        new_speed += (creature_ptr->lev) / 10;
                        break;
                case RACE_KOBOLD:
@@ -1926,7 +1710,6 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->levitation = TRUE;
                        creature_ptr->resist_lite = TRUE;
 
-                       /* Sprites become faster */
                        new_speed += (creature_ptr->lev) / 10;
                        break;
                case RACE_BEASTMAN:
@@ -1934,10 +1717,9 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->resist_sound = TRUE;
                        break;
                case RACE_ENT:
-                       /* Ents dig like maniacs, but only with their hands. */
                        if (!creature_ptr->inventory_list[INVEN_RARM].k_idx)
                                creature_ptr->skill_dig += creature_ptr->lev * 10;
-                       /* Ents get tougher and stronger as they age, but lose dexterity. */
+
                        if (creature_ptr->lev > 25) creature_ptr->stat_add[A_STR]++;
                        if (creature_ptr->lev > 40) creature_ptr->stat_add[A_STR]++;
                        if (creature_ptr->lev > 45) creature_ptr->stat_add[A_STR]++;
@@ -1964,6 +1746,7 @@ void calc_bonuses(player_type *creature_ptr)
                                creature_ptr->oppose_fire = 1;
                                creature_ptr->redraw |= PR_STATUS;
                        }
+
                        break;
                case RACE_DUNADAN:
                        creature_ptr->sustain_con = TRUE;
@@ -1984,8 +1767,7 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->resist_water = TRUE;
                        break;
                default:
-                       /* Do nothing */
-                       ;
+                       break;
                }
        }
 
@@ -2028,7 +1810,6 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->to_a += 100;
                creature_ptr->dis_to_a += 100;
        }
-       /* Temporary shield */
        else if (creature_ptr->tsubureru || creature_ptr->shield || creature_ptr->magicdef)
        {
                creature_ptr->to_a += 50;
@@ -2050,22 +1831,17 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->resist_time = TRUE;
        }
 
-       /* Sexy Gal */
        if (creature_ptr->pseikaku == SEIKAKU_SEXY) creature_ptr->cursed |= (TRC_AGGRAVATE);
-
        if (creature_ptr->pseikaku == SEIKAKU_NAMAKE) creature_ptr->to_m_chance += 10;
        if (creature_ptr->pseikaku == SEIKAKU_KIREMONO) creature_ptr->to_m_chance -= 3;
        if ((creature_ptr->pseikaku == SEIKAKU_GAMAN) || (creature_ptr->pseikaku == SEIKAKU_CHIKARA)) creature_ptr->to_m_chance++;
-
        if (creature_ptr->pseikaku == SEIKAKU_CHARGEMAN)
        {
                creature_ptr->to_m_chance += 5;
                creature_ptr->resist_conf = TRUE;
        }
 
-       /* Lucky man */
        if (creature_ptr->pseikaku == SEIKAKU_LUCKY) creature_ptr->muta3 |= MUT3_GOOD_LUCK;
-
        if (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)
        {
                creature_ptr->resist_blind = TRUE;
@@ -2074,7 +1850,6 @@ void calc_bonuses(player_type *creature_ptr)
                if (creature_ptr->pclass != CLASS_NINJA) creature_ptr->lite = TRUE;
 
                if ((creature_ptr->prace != RACE_KLACKON) && (creature_ptr->prace != RACE_SPRITE))
-                       /* Munchkin become faster */
                        new_speed += (creature_ptr->lev) / 10 + 5;
        }
 
@@ -2083,37 +1858,29 @@ void calc_bonuses(player_type *creature_ptr)
                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)
        {
-               /* Hyper Strength */
                if (creature_ptr->muta3 & MUT3_HYPER_STR)
                {
                        creature_ptr->stat_add[A_STR] += 4;
                }
 
-               /* Puny */
                if (creature_ptr->muta3 & MUT3_PUNY)
                {
                        creature_ptr->stat_add[A_STR] -= 4;
                }
 
-               /* Living computer */
                if (creature_ptr->muta3 & MUT3_HYPER_INT)
                {
                        creature_ptr->stat_add[A_INT] += 4;
                        creature_ptr->stat_add[A_WIS] += 4;
                }
 
-               /* Moronic */
                if (creature_ptr->muta3 & MUT3_MORONIC)
                {
                        creature_ptr->stat_add[A_INT] -= 4;
@@ -2141,7 +1908,6 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->stat_add[A_CON] -= 2;
                        creature_ptr->stat_add[A_CHR] -= 1;
                        creature_ptr->regenerate = FALSE;
-                       /* Cancel innate regeneration */
                }
 
                if (creature_ptr->muta3 & MUT3_SILLY_VOI)
@@ -2265,8 +2031,7 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->stat_add[A_CON] += 4;
        }
 
-       /* 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];
@@ -2277,35 +2042,19 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
                if (o_ptr->name1 == ART_CHAINSWORD) creature_ptr->cursed |= TRC_CHAINSWORD;
 
-               /* Affect stats */
                if (have_flag(flgs, TR_STR)) creature_ptr->stat_add[A_STR] += o_ptr->pval;
                if (have_flag(flgs, TR_INT)) creature_ptr->stat_add[A_INT] += o_ptr->pval;
                if (have_flag(flgs, TR_WIS)) creature_ptr->stat_add[A_WIS] += o_ptr->pval;
                if (have_flag(flgs, TR_DEX)) creature_ptr->stat_add[A_DEX] += o_ptr->pval;
                if (have_flag(flgs, TR_CON)) creature_ptr->stat_add[A_CON] += o_ptr->pval;
                if (have_flag(flgs, TR_CHR)) creature_ptr->stat_add[A_CHR] += o_ptr->pval;
-
-               if (have_flag(flgs, TR_MAGIC_MASTERY))    creature_ptr->skill_dev += 8 * o_ptr->pval;
-
-               /* Affect stealth */
+               if (have_flag(flgs, TR_MAGIC_MASTERY)) creature_ptr->skill_dev += 8 * o_ptr->pval;
                if (have_flag(flgs, TR_STEALTH)) creature_ptr->skill_stl += o_ptr->pval;
-
-               /* Affect searching ability (factor of five) */
                if (have_flag(flgs, TR_SEARCH)) creature_ptr->skill_srh += (o_ptr->pval * 5);
-
-               /* Affect searching frequency (factor of five) */
                if (have_flag(flgs, TR_SEARCH)) creature_ptr->skill_fos += (o_ptr->pval * 5);
-
-               /* Affect infravision */
                if (have_flag(flgs, TR_INFRA)) creature_ptr->see_infra += o_ptr->pval;
-
-               /* Affect digging (factor of 20) */
                if (have_flag(flgs, TR_TUNNEL)) creature_ptr->skill_dig += (o_ptr->pval * 20);
-
-               /* Affect speed */
                if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
-
-               /* Affect blows */
                if (have_flag(flgs, TR_BLOWS))
                {
                        if ((i == INVEN_RARM || i == INVEN_RIGHT) && !creature_ptr->ryoute) extra_blows[0] += o_ptr->pval;
@@ -2313,10 +2062,7 @@ void calc_bonuses(player_type *creature_ptr)
                        else { extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval; }
                }
 
-               /* Hack -- cause earthquakes */
                if (have_flag(flgs, TR_IMPACT)) creature_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
-
-               /* Various flags */
                if (have_flag(flgs, TR_AGGRAVATE))   creature_ptr->cursed |= TRC_AGGRAVATE;
                if (have_flag(flgs, TR_DRAIN_EXP))   creature_ptr->cursed |= TRC_DRAIN_EXP;
                if (have_flag(flgs, TR_TY_CURSE))    creature_ptr->cursed |= TRC_TY_CURSE;
@@ -2369,27 +2115,22 @@ void calc_bonuses(player_type *creature_ptr)
                        {
                                concptr insc = quark_str(o_ptr->inscription);
 
+                               /* {.} will stop random teleportation. */
                                if (o_ptr->inscription && my_strchr(insc, '.'))
                                {
-                                       /*
-                                        * {.} will stop random teleportation.
-                                        */
                                }
                                else
                                {
-                                       /* Controlled random teleportation */
                                        creature_ptr->cursed |= TRC_TELEPORT_SELF;
                                }
                        }
                }
 
-               /* Immunity flags */
                if (have_flag(flgs, TR_IM_FIRE)) creature_ptr->immune_fire = TRUE;
                if (have_flag(flgs, TR_IM_ACID)) creature_ptr->immune_acid = TRUE;
                if (have_flag(flgs, TR_IM_COLD)) creature_ptr->immune_cold = TRUE;
                if (have_flag(flgs, TR_IM_ELEC)) creature_ptr->immune_elec = TRUE;
 
-               /* Resistance flags */
                if (have_flag(flgs, TR_RES_ACID))   creature_ptr->resist_acid = TRUE;
                if (have_flag(flgs, TR_RES_ELEC))   creature_ptr->resist_elec = TRUE;
                if (have_flag(flgs, TR_RES_FIRE))   creature_ptr->resist_fire = TRUE;
@@ -2414,7 +2155,6 @@ void calc_bonuses(player_type *creature_ptr)
                if (have_flag(flgs, TR_NO_MAGIC)) creature_ptr->anti_magic = TRUE;
                if (have_flag(flgs, TR_NO_TELE))  creature_ptr->anti_tele = TRUE;
 
-               /* Sustain flags */
                if (have_flag(flgs, TR_SUST_STR)) creature_ptr->sustain_str = TRUE;
                if (have_flag(flgs, TR_SUST_INT)) creature_ptr->sustain_int = TRUE;
                if (have_flag(flgs, TR_SUST_WIS)) creature_ptr->sustain_wis = TRUE;
@@ -2444,16 +2184,9 @@ void calc_bonuses(player_type *creature_ptr)
 
                if (o_ptr->tval == TV_CAPTURE) continue;
 
-               /* Modify the base armor class */
                creature_ptr->ac += o_ptr->ac;
-
-               /* The base armor class is always known */
                creature_ptr->dis_ac += o_ptr->ac;
-
-               /* Apply the bonuses to armor class */
                creature_ptr->to_a += o_ptr->to_a;
-
-               /* Apply the mental bonuses to armor class, if known */
                if (object_is_known(o_ptr)) creature_ptr->dis_to_a += o_ptr->to_a;
 
                if (o_ptr->curse_flags & TRC_LOW_MELEE)
@@ -2464,12 +2197,12 @@ void calc_bonuses(player_type *creature_ptr)
                                if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
                                {
                                        creature_ptr->to_h[slot] -= 15;
-                                       if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h[slot] -= 15;
+                                       if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_h[slot] -= 15;
                                }
                                else
                                {
                                        creature_ptr->to_h[slot] -= 5;
-                                       if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h[slot] -= 5;
+                                       if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_h[slot] -= 5;
                                }
                        }
                        else
@@ -2477,12 +2210,12 @@ void calc_bonuses(player_type *creature_ptr)
                                if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
                                {
                                        creature_ptr->to_h_b -= 15;
-                                       if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h_b -= 15;
+                                       if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_h_b -= 15;
                                }
                                else
                                {
                                        creature_ptr->to_h_b -= 5;
-                                       if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_h_b -= 5;
+                                       if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_h_b -= 5;
                                }
                        }
                }
@@ -2492,20 +2225,17 @@ void calc_bonuses(player_type *creature_ptr)
                        if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
                        {
                                creature_ptr->to_a -= 30;
-                               if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_a -= 30;
+                               if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_a -= 30;
                        }
                        else
                        {
                                creature_ptr->to_a -= 10;
-                               if (o_ptr->ident & IDENT_MENTAL) creature_ptr->dis_to_a -= 10;
+                               if (OBJECT_IS_FULL_KNOWN(o_ptr)) creature_ptr->dis_to_a -= 10;
                        }
                }
 
-               /* Hack -- do not apply "weapon" bonuses */
                if (i == INVEN_RARM && has_melee_weapon(creature_ptr, i)) continue;
                if (i == INVEN_LARM && has_melee_weapon(creature_ptr, i)) continue;
-
-               /* Hack -- do not apply "bow" bonuses */
                if (i == INVEN_BOW) continue;
 
                bonus_to_h = o_ptr->to_h;
@@ -2517,63 +2247,49 @@ void calc_bonuses(player_type *creature_ptr)
                        if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d + 1) / 2;
                }
 
-               /* To Bow and Natural attack */
-
-               /* Apply the bonuses to hit/damage */
                creature_ptr->to_h_b += (s16b)bonus_to_h;
                creature_ptr->to_h_m += (s16b)bonus_to_h;
                creature_ptr->to_d_m += (s16b)bonus_to_d;
 
-               /* Apply the mental bonuses tp hit/damage, if known */
                if (object_is_known(o_ptr)) creature_ptr->dis_to_h_b += (s16b)bonus_to_h;
 
-               /* To Melee */
                if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !creature_ptr->ryoute)
                {
-                       /* Apply the bonuses to hit/damage */
                        creature_ptr->to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
                        creature_ptr->to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
-
-                       /* Apply the mental bonuses tp hit/damage, if known */
                        if (object_is_known(o_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;
                        creature_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
                        creature_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
                        creature_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
+                       if (!object_is_known(o_ptr)) continue;
 
-                       /* 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;
-                       }
+                       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;
                }
-               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;
 
-                       /* 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->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;
+
+               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 */
        if (object_is_armour(&creature_ptr->inventory_list[INVEN_RARM]) || object_is_armour(&creature_ptr->inventory_list[INVEN_LARM]))
        {
                creature_ptr->ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
@@ -2582,13 +2298,11 @@ void calc_bonuses(player_type *creature_ptr)
 
        if (old_mighty_throw != creature_ptr->mighty_throw)
        {
-               /* Redraw average damege display of Shuriken */
                creature_ptr->window |= PW_INVEN;
        }
 
        if (creature_ptr->cursed & TRC_TELEPORT) creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
 
-       /* Monks get extra ac for armour _not worn_ */
        if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor(creature_ptr))
        {
                if (!(creature_ptr->inventory_list[INVEN_BODY].k_idx))
@@ -2649,51 +2363,52 @@ 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;
        }
 
-       /* Hack -- aura of fire also provides light */
        if (creature_ptr->sh_fire) creature_ptr->lite = TRUE;
 
-       /* Golems also get an intrinsic AC bonus */
        if (PRACE_IS_(creature_ptr, RACE_GOLEM) || PRACE_IS_(creature_ptr, RACE_ANDROID))
        {
                creature_ptr->to_a += 10 + (creature_ptr->lev * 2 / 5);
                creature_ptr->dis_to_a += 10 + (creature_ptr->lev * 2 / 5);
        }
 
-       /* Hex bonuses */
        if (creature_ptr->realm1 == REALM_HEX)
        {
                if (hex_spelling_any(creature_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(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];
@@ -2708,26 +2423,20 @@ 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;
+               int ind;
+               int top = modify_stat_value(creature_ptr->stat_max[i], creature_ptr->stat_add[i]);
 
-               /* Extract the new "stat_use" value for the stat */
-               top = modify_stat_value(creature_ptr->stat_max[i], creature_ptr->stat_add[i]);
-
-               /* Notice changes */
                if (creature_ptr->stat_top[i] != top)
                {
-                       /* Save the new value */
                        creature_ptr->stat_top[i] = (s16b)top;
                        creature_ptr->redraw |= (PR_STATS);
                        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]);
+               int use = modify_stat_value(creature_ptr->stat_cur[i], creature_ptr->stat_add[i]);
 
                if ((i == A_CHR) && (creature_ptr->muta3 & MUT3_ILL_NORM))
                {
@@ -2738,69 +2447,49 @@ void calc_bonuses(player_type *creature_ptr)
                        }
                }
 
-               /* Notice changes */
                if (creature_ptr->stat_use[i] != use)
                {
-                       /* Save the new value */
                        creature_ptr->stat_use[i] = (s16b)use;
                        creature_ptr->redraw |= (PR_STATS);
                        creature_ptr->window |= (PW_PLAYER);
                }
 
-
-               /* Values: 3, 4, ..., 17 */
                if (use <= 18) ind = (use - 3);
-
-               /* Ranges: 18/00-18/09, ..., 18/210-18/219 */
                else if (use <= 18 + 219) ind = (15 + (use - 18) / 10);
-
-               /* Range: 18/220+ */
                else ind = (37);
 
-               /* Notice changes */
-               if (creature_ptr->stat_ind[i] != ind)
+               if (creature_ptr->stat_ind[i] == ind) continue;
+               creature_ptr->stat_ind[i] = (s16b)ind;
+               if (i == A_CON)
                {
-                       /* Save the new index */
-                       creature_ptr->stat_ind[i] = (s16b)ind;
-
-                       /* 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)
+                       creature_ptr->update |= (PU_HP);
+               }
+               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)
+               }
+               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)
+               }
+               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)
        {
                creature_ptr->to_h[0] -= 20;
@@ -2832,7 +2521,6 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->dis_to_d[1] -= 5;
        }
 
-       /* Wraith form */
        if (creature_ptr->wraith_form)
        {
                creature_ptr->reflect = TRUE;
@@ -2844,7 +2532,6 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->pass_wall = TRUE;
        }
 
-       /* Temporary blessing */
        if (is_blessed(creature_ptr))
        {
                creature_ptr->to_a += 5;
@@ -2867,7 +2554,6 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->levitation = TRUE;
        }
 
-       /* Temporary "Hero" */
        if (IS_HERO(creature_ptr))
        {
                creature_ptr->to_h[0] += 12;
@@ -2879,7 +2565,6 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->dis_to_h_b += 12;
        }
 
-       /* Temporary "Beserk" */
        if (creature_ptr->shero)
        {
                creature_ptr->to_h[0] += 12;
@@ -2905,19 +2590,16 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->skill_dig += 30;
        }
 
-       /* Temporary "fast" */
        if (IS_FAST(creature_ptr))
        {
                new_speed += 10;
        }
 
-       /* Temporary "slow" */
        if (creature_ptr->slow)
        {
                new_speed -= 10;
        }
 
-       /* Temporary "telepathy" */
        if (is_time_limit_esp(creature_ptr))
        {
                creature_ptr->telepathy = TRUE;
@@ -2935,43 +2617,36 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->immune_cold = TRUE;
        }
 
-       /* Temporary see invisible */
        if (creature_ptr->tim_invis)
        {
                creature_ptr->see_inv = TRUE;
        }
 
-       /* Temporary infravision boost */
        if (creature_ptr->tim_infra)
        {
                creature_ptr->see_infra += 3;
        }
 
-       /* Temporary regeneration boost */
        if (creature_ptr->tim_regen)
        {
                creature_ptr->regenerate = TRUE;
        }
 
-       /* Temporary levitation */
        if (creature_ptr->tim_levitation)
        {
                creature_ptr->levitation = TRUE;
        }
 
-       /* Temporary reflection */
        if (creature_ptr->tim_reflect)
        {
                creature_ptr->reflect = TRUE;
        }
 
-       /* Hack -- Hero/Shero -> Res fear */
        if (IS_HERO(creature_ptr) || creature_ptr->shero)
        {
                creature_ptr->resist_fear = TRUE;
        }
 
-       /* Hack -- Telepathy Change */
        if (creature_ptr->telepathy != old_telepathy)
        {
                creature_ptr->update |= (PU_MONSTERS);
@@ -2993,13 +2668,11 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->update |= (PU_MONSTERS);
        }
 
-       /* Hack -- See Invis Change */
        if (creature_ptr->see_inv != old_see_inv)
        {
                creature_ptr->update |= (PU_MONSTERS);
        }
 
-       /* Bloating slows the player down (a little) */
        if (creature_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
 
        if (creature_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
@@ -3048,6 +2721,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;
@@ -3056,13 +2730,10 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->dis_to_h[1] -= (s16b)penalty2;
        }
 
-       /* 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
        {
@@ -3079,6 +2750,7 @@ void calc_bonuses(player_type *creature_ptr)
                {
                        new_speed = speed;
                }
+
                new_speed += (creature_ptr->skill_exp[GINOU_RIDING] + creature_ptr->lev * 160L) / 3200;
                if (MON_FAST(riding_m_ptr)) new_speed += 10;
                if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
@@ -3088,19 +2760,14 @@ void calc_bonuses(player_type *creature_ptr)
                if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) creature_ptr->pass_wall = FALSE;
                if (riding_r_ptr->flags2 & RF2_KILL_WALL) creature_ptr->kill_wall = TRUE;
 
-               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;
+               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));
-
-       /* Searching slows the player down */
+       if (j > count) new_speed -= ((j - count) / (count / 5));
        if (creature_ptr->action == ACTION_SEARCH) new_speed -= 10;
-
-       /* Feature bonus */
        if (creature_ptr->prace == RACE_MERFOLK)
        {
                if (have_flag(f_ptr->flags, FF_WATER))
@@ -3113,7 +2780,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);
        creature_ptr->to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
@@ -3126,8 +2792,6 @@ void calc_bonuses(player_type *creature_ptr)
        creature_ptr->to_h[1] += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
        creature_ptr->to_h_b += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
        creature_ptr->to_h_m += ((int)(adj_str_th[creature_ptr->stat_ind[A_STR]]) - 128);
-
-       /* Displayed Modifier Bonuses (Un-inflate stat bonuses) */
        creature_ptr->dis_to_a += ((int)(adj_dex_ta[creature_ptr->stat_ind[A_DEX]]) - 128);
        creature_ptr->dis_to_d[0] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
        creature_ptr->dis_to_d[1] += ((int)(adj_str_td[creature_ptr->stat_ind[A_STR]]) - 128);
@@ -3138,35 +2802,21 @@ 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];
-
-       /* It is hard to carholdry a heavy bow */
        creature_ptr->heavy_shoot = is_heavy_shoot(creature_ptr, o_ptr);
        if (creature_ptr->heavy_shoot)
        {
-               /* Hard to wield a heavy bow */
                creature_ptr->to_h_b += 2 * (hold - o_ptr->weight / 10);
                creature_ptr->dis_to_h_b += 2 * (hold - o_ptr->weight / 10);
        }
 
-       /* Compute "extra shots" if needed */
        if (o_ptr->k_idx)
        {
-               creature_ptr->tval_ammo = (byte_hack)bow_tval_ammo(o_ptr);
-
-               /* Apply special flags */
+               creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
                if (o_ptr->k_idx && !creature_ptr->heavy_shoot)
                {
-                       /* Extra shots */
                        creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
-
-                       /* Snipers love Cross bows */
                        if ((creature_ptr->pclass == CLASS_SNIPER) &&
                                (creature_ptr->tval_ammo == TV_BOLT))
                        {
@@ -3177,32 +2827,23 @@ 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];
-
                object_flags(o_ptr, flgs);
-
-               /* Assume not heavy */
                creature_ptr->heavy_wield[i] = FALSE;
                creature_ptr->icky_wield[i] = FALSE;
                creature_ptr->riding_wield[i] = FALSE;
-
                if (!has_melee_weapon(creature_ptr, INVEN_RARM + i))
                {
                        creature_ptr->num_blow[i] = 1;
                        continue;
                }
-               /* It is hard to hold a heavy weapon */
+
                if (hold < o_ptr->weight / 10)
                {
-                       /* Hard to wield a heavy weapon */
                        creature_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
                        creature_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
-
-                       /* Heavy weapon */
                        creature_ptr->heavy_wield[i] = TRUE;
                }
                else if (creature_ptr->ryoute && (hold < o_ptr->weight / 5)) omoi = TRUE;
@@ -3213,14 +2854,10 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->dis_to_a += 5;
                }
 
-               /* Normal weapons */
                if (o_ptr->k_idx && !creature_ptr->heavy_wield[i])
                {
                        int str_index, dex_index;
-
                        int num = 0, wgt = 0, mul = 0, div = 0;
-
-                       /* Analyze the class */
                        switch (creature_ptr->pclass)
                        {
                        case CLASS_WARRIOR:
@@ -3294,70 +2931,52 @@ void calc_bonuses(player_type *creature_ptr)
                                num = 4; wgt = 20; mul = 1; break;
                        }
 
-                       /* 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);
-
-                       /* Access the strength vs weight */
                        str_index = (adj_str_blow[creature_ptr->stat_ind[A_STR]] * mul / div);
 
                        if (creature_ptr->ryoute && !omoi) str_index++;
                        if (creature_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index - 1);
-
-                       /* Maximal value */
                        if (str_index > 11) str_index = 11;
 
-                       /* Index by dexterity */
                        dex_index = (adj_dex_blow[creature_ptr->stat_ind[A_DEX]]);
-
-                       /* Maximal value */
                        if (dex_index > 11) dex_index = 11;
 
-                       /* Use the blows table */
                        creature_ptr->num_blow[i] = blows_table[str_index][dex_index];
-
-                       /* Maximal value */
                        if (creature_ptr->num_blow[i] > num) creature_ptr->num_blow[i] = (s16b)num;
 
-                       /* Add in the "bonus blows" */
                        creature_ptr->num_blow[i] += (s16b)extra_blows[i];
-
-
                        if (creature_ptr->pclass == CLASS_WARRIOR) creature_ptr->num_blow[i] += (creature_ptr->lev / 40);
                        else if (creature_ptr->pclass == CLASS_BERSERKER)
-                       {
                                creature_ptr->num_blow[i] += (creature_ptr->lev / 23);
-                       }
-                       else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30)) creature_ptr->num_blow[i] ++;
-
-                       if (creature_ptr->special_defense & KATA_FUUJIN) creature_ptr->num_blow[i] -= 1;
+                       else if ((creature_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (creature_ptr->stat_ind[A_DEX] >= 30))
+                               creature_ptr->num_blow[i] ++;
 
-                       if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) creature_ptr->num_blow[i] = 1;
+                       if (creature_ptr->special_defense & KATA_FUUJIN)
+                               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 */
-                       if (creature_ptr->num_blow[i] < 1) creature_ptr->num_blow[i] = 1;
+                       if (creature_ptr->num_blow[i] < 1)
+                               creature_ptr->num_blow[i] = 1;
 
-                       /* Boost digging skill by weapon weight */
                        creature_ptr->skill_dig += (o_ptr->weight / 10);
                }
 
-               /* Assume okay */
-               /* Priest weapon penalty for non-blessed edged weapons */
                if ((creature_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
                        ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
                {
-                       /* Reduce the real bonuses */
                        creature_ptr->to_h[i] -= 2;
                        creature_ptr->to_d[i] -= 2;
-
-                       /* Reduce the mental bonuses */
                        creature_ptr->dis_to_h[i] -= 2;
                        creature_ptr->dis_to_d[i] -= 2;
-
-                       /* Icky weapon */
                        creature_ptr->icky_wield[i] = TRUE;
                }
                else if (creature_ptr->pclass == CLASS_BERSERKER)
@@ -3378,73 +2997,62 @@ void calc_bonuses(player_type *creature_ptr)
                {
                        if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
                        {
-                               /* Reduce the real bonuses */
                                creature_ptr->to_h[i] -= 200;
                                creature_ptr->to_d[i] -= 200;
-
-                               /* Reduce the mental bonuses */
                                creature_ptr->dis_to_h[i] -= 200;
                                creature_ptr->dis_to_d[i] -= 200;
-
-                               /* Icky weapon */
                                creature_ptr->icky_wield[i] = TRUE;
                        }
                        else
                        {
-                               /* Reduce the real bonuses */
                                creature_ptr->to_h[i] -= 30;
                                creature_ptr->to_d[i] -= 10;
-
-                               /* Reduce the mental bonuses */
                                creature_ptr->dis_to_h[i] -= 30;
                                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[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;
+               creature_ptr->riding_wield[i] = TRUE;
        }
 
        if (creature_ptr->riding)
@@ -3477,6 +3085,7 @@ void calc_bonuses(player_type *creature_ptr)
                        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;
@@ -3575,36 +3184,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) */
@@ -3617,7 +3227,6 @@ void calc_bonuses(player_type *creature_ptr)
        /* Minimum speed is (-99). (internally it's 110 - 99) */
        if (new_speed < 11) new_speed = 11;
 
-       /* Display the speed (if needed) */
        if (creature_ptr->pspeed != (byte)new_speed)
        {
                creature_ptr->pspeed = (byte)new_speed;
@@ -3632,7 +3241,6 @@ void calc_bonuses(player_type *creature_ptr)
                        creature_ptr->dis_to_a = 0 - creature_ptr->dis_ac;
        }
 
-       /* Redraw armor (if needed) */
        if ((creature_ptr->dis_ac != old_dis_ac) || (creature_ptr->dis_to_a != old_dis_to_a))
        {
                creature_ptr->redraw |= (PR_ARMOR);
@@ -3651,51 +3259,30 @@ 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_time_limit_stealth(creature_ptr)) 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]];
        creature_ptr->skill_dis += adj_int_dis[creature_ptr->stat_ind[A_INT]];
-
-       /* Affect Skill -- magic devices (INT) */
        creature_ptr->skill_dev += adj_int_dev[creature_ptr->stat_ind[A_INT]];
-
-       /* Affect Skill -- saving throw (WIS) */
        creature_ptr->skill_sav += adj_wis_sav[creature_ptr->stat_ind[A_WIS]];
-
-       /* Affect Skill -- digging (STR) */
        creature_ptr->skill_dig += adj_str_dig[creature_ptr->stat_ind[A_STR]];
-
-       /* Affect Skill -- disarming (Level, by Class) */
        creature_ptr->skill_dis += ((cp_ptr->x_dis * creature_ptr->lev / 10) + (ap_ptr->a_dis * creature_ptr->lev / 50));
-
-       /* Affect Skill -- magic devices (Level, by Class) */
        creature_ptr->skill_dev += ((cp_ptr->x_dev * creature_ptr->lev / 10) + (ap_ptr->a_dev * creature_ptr->lev / 50));
-
-       /* Affect Skill -- saving throw (Level, by Class) */
        creature_ptr->skill_sav += ((cp_ptr->x_sav * creature_ptr->lev / 10) + (ap_ptr->a_sav * creature_ptr->lev / 50));
-
-       /* Affect Skill -- stealth (Level, by Class) */
        creature_ptr->skill_stl += (cp_ptr->x_stl * creature_ptr->lev / 10);
-
-       /* Affect Skill -- search ability (Level, by Class) */
        creature_ptr->skill_srh += (cp_ptr->x_srh * creature_ptr->lev / 10);
-
-       /* Affect Skill -- search frequency (Level, by Class) */
        creature_ptr->skill_fos += (cp_ptr->x_fos * creature_ptr->lev / 10);
-
-       /* Affect Skill -- combat (normal) (Level, by Class) */
        creature_ptr->skill_thn += ((cp_ptr->x_thn * creature_ptr->lev / 10) + (ap_ptr->a_thn * creature_ptr->lev / 50));
-
-       /* Affect Skill -- combat (shooting) (Level, by Class) */
        creature_ptr->skill_thb += ((cp_ptr->x_thb * creature_ptr->lev / 10) + (ap_ptr->a_thb * creature_ptr->lev / 50));
-
-       /* 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))
@@ -3704,31 +3291,24 @@ void calc_bonuses(player_type *creature_ptr)
                creature_ptr->skill_stl = MIN(creature_ptr->skill_stl - 3, (creature_ptr->skill_stl + 2) / 2);
        }
 
-       /* Limit Skill -- stealth from 0 to 30 */
        if (creature_ptr->skill_stl > 30) creature_ptr->skill_stl = 30;
        if (creature_ptr->skill_stl < 0) creature_ptr->skill_stl = 0;
-
-       /* Limit Skill -- digging from 1 up */
        if (creature_ptr->skill_dig < 1) creature_ptr->skill_dig = 1;
-
-       if (creature_ptr->anti_magic && (creature_ptr->skill_sav < (90 + creature_ptr->lev))) creature_ptr->skill_sav = 90 + creature_ptr->lev;
-
+       if (creature_ptr->anti_magic && (creature_ptr->skill_sav < (90 + creature_ptr->lev)))
+               creature_ptr->skill_sav = 90 + creature_ptr->lev;
        if (creature_ptr->tsubureru) creature_ptr->skill_sav = 10;
-
-       if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (creature_ptr->skill_sav < (95 + creature_ptr->lev))) creature_ptr->skill_sav = 95 + creature_ptr->lev;
+       if ((creature_ptr->ult_res || creature_ptr->resist_magic || creature_ptr->magicdef) && (creature_ptr->skill_sav < (95 + creature_ptr->lev)))
+               creature_ptr->skill_sav = 95 + creature_ptr->lev;
 
        if (down_saving) creature_ptr->skill_sav /= 2;
 
-       /* Hack -- Each elemental immunity includes resistance */
        if (creature_ptr->immune_acid) creature_ptr->resist_acid = TRUE;
        if (creature_ptr->immune_elec) creature_ptr->resist_elec = TRUE;
        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;
 
-       /* Take note when "heavy bow" changes */
        if (creature_ptr->old_heavy_shoot != creature_ptr->heavy_shoot)
        {
                if (creature_ptr->heavy_shoot)
@@ -3744,13 +3324,11 @@ 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])
                {
                        if (creature_ptr->heavy_wield[i])
@@ -3770,11 +3348,9 @@ 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];
                }
 
-               /* Take note when "heavy weapon" changes */
                if (creature_ptr->old_riding_wield[i] != creature_ptr->riding_wield[i])
                {
                        if (creature_ptr->riding_wield[i])
@@ -3783,40 +3359,38 @@ void calc_bonuses(player_type *creature_ptr)
                        }
                        else if (!creature_ptr->riding)
                        {
-                               msg_print(_("この武器は徒歩で使いやすい。", "This weapon was not suitable for use while riding."));
+                               msg_print(_("この武器は徒歩で使いやすい。", "This weapon is suitable for use on foot."));
                        }
                        else if (has_melee_weapon(creature_ptr, INVEN_RARM + i))
                        {
                                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))
        {
@@ -3825,7 +3399,7 @@ void calc_bonuses(player_type *creature_ptr)
 #ifdef JP
                        msg_format("%s馬を操れない。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
 #else
-                       msg_print("You are using both hand for fighting, and you can't control a riding pet.");
+                       msg_print("You are using both hand for fighting, and you can't control the pet you're riding.");
 #endif
                }
                else
@@ -3833,7 +3407,7 @@ void calc_bonuses(player_type *creature_ptr)
 #ifdef JP
                        msg_format("%s馬を操れるようになった。", (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
 #else
-                       msg_print("You began to control riding pet with one hand.");
+                       msg_print("You began to control the pet you're riding with one hand.");
 #endif
                }
 
@@ -3858,7 +3432,7 @@ 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 ((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;
@@ -3891,12 +3465,9 @@ 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];
-
        floor_type *floor_ptr = creature_ptr->current_floor_ptr;
-       for (m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
+       for (MONSTER_IDX m_idx = floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
        {
                monster_type *m_ptr;
                monster_race *r_ptr;
@@ -3904,11 +3475,10 @@ static void calc_alignment(player_type *creature_ptr)
                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)
@@ -3936,16 +3506,16 @@ 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])
                {
@@ -3953,7 +3523,6 @@ static void calc_alignment(player_type *creature_ptr)
                        creature_ptr->align += creature_ptr->virtues[i] * 2;
                        break;
                case V_CHANCE:
-                       /* Do nothing */
                        break;
                case V_NATURE:
                case V_HARMONY:
@@ -3968,7 +3537,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)
                {
@@ -3993,15 +3562,10 @@ 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;
-
-       /* Calculate hitpoints */
-       mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
+       int bonus = ((int)(adj_con_mhp[creature_ptr->stat_ind[A_CON]]) - 128) * creature_ptr->lev / 4;
+       int mhp = creature_ptr->player_hp[creature_ptr->lev - 1];
 
+       byte tmp_hitdie;
        if (creature_ptr->mimic_form)
        {
                if (creature_ptr->pclass == CLASS_SORCERER)
@@ -4027,42 +3591,30 @@ static void calc_hitpoints(player_type *creature_ptr)
                mhp = mhp * (110 + (((creature_ptr->lev + 40) * (creature_ptr->lev + 40) - 1550) / 110)) / 100;
        }
 
-       /* Always have at least one hitpoint per level */
        if (mhp < creature_ptr->lev + 1) mhp = creature_ptr->lev + 1;
-
-       /* Factor in the hero / superhero settings */
        if (IS_HERO(creature_ptr)) mhp += 10;
        if (creature_ptr->shero && (creature_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
        if (creature_ptr->tsuyoshi) mhp += 50;
+       if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) mhp += 15;
+       if (hex_spelling(creature_ptr, HEX_BUILDING)) mhp += 60;
+       if (creature_ptr->mhp == mhp) return;
 
-       /* Factor in the hex spell settings */
-       if (hex_spelling(HEX_XTRA_MIGHT)) mhp += 15;
-       if (hex_spelling(HEX_BUILDING)) mhp += 60;
-
-       /* New maximum hitpoints */
-       if (creature_ptr->mhp != mhp)
+       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;
 }
 
 
@@ -4074,24 +3626,14 @@ 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;
 
                if (o_ptr->name2 == EGO_LITE_SHINE) creature_ptr->cur_lite++;
-
-               /* Need Fuels */
                if (o_ptr->name2 != EGO_LITE_DARKNESS)
                {
                        if (o_ptr->tval == TV_LITE)
@@ -4100,11 +3642,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;
@@ -4114,33 +3656,26 @@ static void calc_torch(player_type *creature_ptr)
                creature_ptr->cur_lite += rad;
        }
 
-       /* max radius is 14 (was 5) without rewriting other code -- */
        if (d_info[creature_ptr->dungeon_idx].flags1 & DF1_DARKNESS && creature_ptr->cur_lite > 1)
                creature_ptr->cur_lite = 1;
 
-       /*
-        * check if the player doesn't have light radius,
-        * but does weakly glow as an intrinsic.
-        */
-       if (creature_ptr->cur_lite <= 0 && creature_ptr->lite) creature_ptr->cur_lite++;
+       if (creature_ptr->cur_lite <= 0 && creature_ptr->lite)
+               creature_ptr->cur_lite++;
 
-       if (creature_ptr->cur_lite > 14) creature_ptr->cur_lite = 14;
-       if (creature_ptr->cur_lite < 0) creature_ptr->cur_lite = 0;
+       if (creature_ptr->cur_lite > 14)
+               creature_ptr->cur_lite = 14;
 
-       /* end experimental mods */
+       if (creature_ptr->cur_lite < 0)
+               creature_ptr->cur_lite = 0;
 
-       /* 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;
+       creature_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
+       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);
 }
 
 
@@ -4155,46 +3690,26 @@ 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;
-
-       /* Hack -- wait for creation */
        if (!current_world_ptr->character_generated) return;
-
-       /* Hack -- handle "xtra" mode */
        if (current_world_ptr->character_xtra) return;
-
        if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE))
        {
                creature_ptr->new_spells = 0;
                return;
        }
 
-       p = spell_category_name(mp_ptr->spell_book);
-
-       /* Determine the number of spells allowed */
-       levels = creature_ptr->lev - mp_ptr->spell_first + 1;
-
-       /* Hack -- no negative spells */
+       concptr p = spell_category_name(mp_ptr->spell_book);
+       int levels = creature_ptr->lev - mp_ptr->spell_first + 1;
        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;
@@ -4213,10 +3728,9 @@ static void calc_spells(player_type *creature_ptr)
                if (num_allowed > (80 + bonus)) num_allowed = 80 + bonus;
        }
 
-       /* 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) ?
                        (creature_ptr->spell_forgotten1 & (1L << j)) :
                        (creature_ptr->spell_forgotten2 & (1L << (j - 32))))
@@ -4225,23 +3739,15 @@ static void calc_spells(player_type *creature_ptr)
                }
        }
 
-       /* See how many spells we must forget or may learn */
        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];
-
-               /* Skip non-spells */
+               int j = creature_ptr->spell_order[i];
                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)
@@ -4254,121 +3760,98 @@ static void calc_spells(player_type *creature_ptr)
                else
                        s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
 
-               /* Skip spells we are allowed to know */
                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;
+
+               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;
-                       }
+               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(creature_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(creature_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;
-
-               /* Efficiency -- all done */
                if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
 
-               /* Get the (i+1)th spell learned */
-               j = creature_ptr->spell_order[i];
-
-               /* Skip unknown spells */
+               int j = creature_ptr->spell_order[i];
                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;
+
+               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;
-                       }
+               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(creature_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(creature_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;
-
-               /* Efficiency -- all done */
                if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2) break;
-
-               /* Get the next spell we learned */
-               j = creature_ptr->spell_order[i];
-
-               /* Skip unknown spells */
+               int j = creature_ptr->spell_order[i];
                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)
@@ -4381,71 +3864,63 @@ static void calc_spells(player_type *creature_ptr)
                else
                        s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
 
-               /* 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;
+
+               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;
-                       }
+               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(creature_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(creature_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];
 
-                       /* Skip spells we cannot remember */
                        if (s_ptr->slevel > creature_ptr->lev) continue;
 
-                       /* Skip spells we already know */
                        if (creature_ptr->spell_learned1 & (1L << j))
                        {
                                continue;
                        }
 
-                       /* 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)))
@@ -4456,36 +3931,27 @@ 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;
+
+       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;
 }
 
 
@@ -4499,14 +3965,9 @@ 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))
@@ -4517,18 +3978,15 @@ static void calc_mana(player_type *creature_ptr)
        {
                if (mp_ptr->spell_first > creature_ptr->lev)
                {
-                       /* Save new mana */
                        creature_ptr->msp = 0;
-
-                       /* Display mana later */
                        creature_ptr->redraw |= (PR_MANA);
                        return;
                }
 
-               /* Extract "effective" player level */
                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;
@@ -4536,37 +3994,21 @@ static void calc_mana(player_type *creature_ptr)
        }
        else
        {
-               /* Extract total mana */
                msp = adj_mag_mana[creature_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
-
-               /* Hack -- usually add one mana */
                if (msp) msp++;
-
                if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
-
                if (msp && (creature_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp / 2;
-
-               /* Hack: High mages have a 25% mana bonus */
                if (msp && (creature_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
-
                if (msp && (creature_ptr->pclass == CLASS_SORCERER)) msp += msp * (25 + creature_ptr->lev) / 100;
        }
 
-       /* Only mages are affected */
        if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
        {
                BIT_FLAGS flgs[TR_FLAG_SIZE];
-
-               /* Assume player is not encumbered by gloves */
                creature_ptr->cumber_glove = FALSE;
-
-               /* Get the gloves */
+               object_type *o_ptr;
                o_ptr = &creature_ptr->inventory_list[INVEN_HANDS];
-
-               /* Examine the gloves */
                object_flags(o_ptr, flgs);
-
-               /* Normal gloves hurt mage-type spells */
                if (o_ptr->k_idx &&
                        !(have_flag(flgs, TR_FREE_ACT)) &&
                        !(have_flag(flgs, TR_DEC_MANA)) &&
@@ -4574,19 +4016,14 @@ static void calc_mana(player_type *creature_ptr)
                        !((have_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) &&
                        !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
                {
-                       /* Encumbered */
                        creature_ptr->cumber_glove = TRUE;
-
-                       /* Reduce mana */
                        msp = (3 * msp) / 4;
                }
        }
 
-       /* 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;
@@ -4595,11 +4032,8 @@ static void calc_mana(player_type *creature_ptr)
        cur_wgt += creature_ptr->inventory_list[INVEN_HANDS].weight;
        cur_wgt += creature_ptr->inventory_list[INVEN_FEET].weight;
 
-       /* Subtract a percentage of maximum mana. */
        switch (creature_ptr->pclass)
        {
-               /* For these classes, mana is halved if armour
-                * is 30 pounds over their weight limit. */
        case CLASS_MAGE:
        case CLASS_HIGH_MAGE:
        case CLASS_BLUE_MAGE:
@@ -4611,8 +4045,6 @@ static void calc_mana(player_type *creature_ptr)
                if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight;
                break;
        }
-
-       /* Mana halved if armour is 40 pounds over weight limit. */
        case CLASS_PRIEST:
        case CLASS_BARD:
        case CLASS_TOURIST:
@@ -4621,7 +4053,6 @@ static void calc_mana(player_type *creature_ptr)
                if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight * 2 / 3;
                break;
        }
-
        case CLASS_MINDCRAFTER:
        case CLASS_BEASTMASTER:
        case CLASS_MIRROR_MASTER:
@@ -4630,8 +4061,6 @@ static void calc_mana(player_type *creature_ptr)
                if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 2;
                break;
        }
-
-       /* Mana halved if armour is 50 pounds over weight limit. */
        case CLASS_ROGUE:
        case CLASS_RANGER:
        case CLASS_RED_MAGE:
@@ -4641,8 +4070,6 @@ static void calc_mana(player_type *creature_ptr)
                if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 3;
                break;
        }
-
-       /* Mana halved if armour is 60 pounds over weight limit. */
        case CLASS_PALADIN:
        case CLASS_CHAOS_WARRIOR:
        {
@@ -4650,28 +4077,18 @@ static void calc_mana(player_type *creature_ptr)
                if (creature_ptr->inventory_list[INVEN_LARM].tval <= TV_SWORD) cur_wgt += creature_ptr->inventory_list[INVEN_LARM].weight / 5;
                break;
        }
-
-       /* For new classes created, but not yet added to this formula. */
        default:
        {
                break;
        }
        }
 
-       /* Determine the weight allowance */
-       max_wgt = mp_ptr->spell_weight;
-
-       /* Heavy armor penalizes mana by a percentage.  -LM- */
+       int max_wgt = mp_ptr->spell_weight;
        if ((cur_wgt - max_wgt) > 0)
        {
-               /* Encumbered */
                creature_ptr->cumber_armor = TRUE;
-
-               /* Subtract a percentage of maximum mana. */
                switch (creature_ptr->pclass)
                {
-                       /* For these classes, mana is halved if armour
-                        * is 30 pounds over their weight limit. */
                case CLASS_MAGE:
                case CLASS_HIGH_MAGE:
                case CLASS_BLUE_MAGE:
@@ -4679,8 +4096,6 @@ static void calc_mana(player_type *creature_ptr)
                        msp -= msp * (cur_wgt - max_wgt) / 600;
                        break;
                }
-
-               /* Mana halved if armour is 40 pounds over weight limit. */
                case CLASS_PRIEST:
                case CLASS_MINDCRAFTER:
                case CLASS_BEASTMASTER:
@@ -4692,14 +4107,11 @@ static void calc_mana(player_type *creature_ptr)
                        msp -= msp * (cur_wgt - max_wgt) / 800;
                        break;
                }
-
                case CLASS_SORCERER:
                {
                        msp -= msp * (cur_wgt - max_wgt) / 900;
                        break;
                }
-
-               /* Mana halved if armour is 50 pounds over weight limit. */
                case CLASS_ROGUE:
                case CLASS_RANGER:
                case CLASS_MONK:
@@ -4708,8 +4120,6 @@ static void calc_mana(player_type *creature_ptr)
                        msp -= msp * (cur_wgt - max_wgt) / 1000;
                        break;
                }
-
-               /* Mana halved if armour is 60 pounds over weight limit. */
                case CLASS_PALADIN:
                case CLASS_CHAOS_WARRIOR:
                case CLASS_WARRIOR_MAGE:
@@ -4717,14 +4127,11 @@ static void calc_mana(player_type *creature_ptr)
                        msp -= msp * (cur_wgt - max_wgt) / 1200;
                        break;
                }
-
                case CLASS_SAMURAI:
                {
                        creature_ptr->cumber_armor = FALSE;
                        break;
                }
-
-               /* For new classes created, but not yet added to this formula. */
                default:
                {
                        msp -= msp * (cur_wgt - max_wgt) / 800;
@@ -4733,14 +4140,10 @@ 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)
        {
-               /* Enforce maximum */
                if ((creature_ptr->csp >= msp) && (creature_ptr->pclass != CLASS_SAMURAI))
                {
                        creature_ptr->csp = msp;
@@ -4748,56 +4151,36 @@ static void calc_mana(player_type *creature_ptr)
                }
 
 #ifdef JP
-               /* レベルアップの時は上昇量を表示する */
                if (creature_ptr->level_up_message && (msp > creature_ptr->msp))
                {
                        msg_format("最大マジック・ポイントが %d 増加した!", (msp - creature_ptr->msp));
                }
 #endif
-               /* Save new mana */
                creature_ptr->msp = msp;
-
-               /* Display mana later */
                creature_ptr->redraw |= (PR_MANA);
                creature_ptr->window |= (PW_PLAYER | PW_SPELL);
        }
 
-
-       /* Hack -- handle "xtra" mode */
        if (current_world_ptr->character_xtra) return;
 
-       /* Take note when "glove state" changes */
        if (creature_ptr->old_cumber_glove != creature_ptr->cumber_glove)
        {
                if (creature_ptr->cumber_glove)
-               {
                        msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
-               }
                else
-               {
                        msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
-               }
 
-               /* Save it */
                creature_ptr->old_cumber_glove = creature_ptr->cumber_glove;
        }
 
+       if (creature_ptr->old_cumber_armor == creature_ptr->cumber_armor) return;
 
-       /* 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->cumber_armor)
+               msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
+       else
+               msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
 
-               /* Save it */
-               creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
-       }
+       creature_ptr->old_cumber_armor = creature_ptr->cumber_armor;
 }
 
 
@@ -4810,73 +4193,63 @@ static void calc_mana(player_type *creature_ptr)
 s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
 {
        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;
 
-               /* Do not apply current equip */
                if (i == INVEN_BOW) continue;
 
                object_flags(q_ptr, flgs);
-
-               /* Boost shots */
                if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
        }
 
        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;
+       num += (extra_shots * 100);
 
-               if ((creature_ptr->pclass == CLASS_CAVALRY) &&
-                       (tval_ammo == TV_ARROW))
-               {
-                       num += (creature_ptr->lev * 3);
-               }
+       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);
-               }
        }
+
+       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;
 }
 
@@ -4888,13 +4261,8 @@ 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;
        if (creature_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
-
-       /* Return the result */
        return i;
 }
 
@@ -4918,7 +4286,6 @@ 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;
 
@@ -4938,11 +4305,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;
 
-       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,7 +4343,6 @@ void update_creature(player_type *creature_ptr)
                combine_pack(creature_ptr);
        }
 
-       /* Reorder the pack */
        if (creature_ptr->update & (PU_REORDER))
        {
                creature_ptr->update &= ~(PU_REORDER);
@@ -5015,12 +4380,8 @@ void update_creature(player_type *creature_ptr)
                calc_spells(creature_ptr);
        }
 
-       /* Character is not ready yet, no screen updates */
        if (!current_world_ptr->character_generated) return;
-
-       /* Character is in "icky" mode, no screen updates */
        if (current_world_ptr->character_icky) return;
-
        if (creature_ptr->update & (PU_UN_LITE))
        {
                creature_ptr->update &= ~(PU_UN_LITE);
@@ -5036,7 +4397,7 @@ void update_creature(player_type *creature_ptr)
        if (creature_ptr->update & (PU_VIEW))
        {
                creature_ptr->update &= ~(PU_VIEW);
-               update_view(creature_ptr, floor_ptr);
+               update_view(creature_ptr);
        }
 
        if (creature_ptr->update & (PU_LITE))
@@ -5055,10 +4416,7 @@ void update_creature(player_type *creature_ptr)
        {
                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))
@@ -5067,10 +4425,6 @@ void update_creature(player_type *creature_ptr)
                update_mon_lite(creature_ptr);
        }
 
-       /*
-        * Mega-Hack -- Delayed visual update
-        * Only used if update_view(), update_lite() or update_mon_lite() was called
-        */
        if (creature_ptr->update & (PU_DELAY_VIS))
        {
                creature_ptr->update &= ~(PU_DELAY_VIS);
@@ -5080,7 +4434,7 @@ void update_creature(player_type *creature_ptr)
        if (creature_ptr->update & (PU_MONSTERS))
        {
                creature_ptr->update &= ~(PU_MONSTERS);
-               update_monsters(FALSE);
+               update_monsters(creature_ptr, FALSE);
        }
 }
 
@@ -5091,20 +4445,18 @@ void update_creature(player_type *creature_ptr)
  */
 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;
        }
 
        floor_type *floor_ptr = creature_ptr->current_floor_ptr;
-       for (i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
+       for (int i = floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
        {
                o_ptr = &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;
+               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;
@@ -5131,14 +4483,11 @@ void free_turn(player_type *creature_ptr)
  */
 bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
 {
-       /* Paranoia XXX XXX */
        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;
 }
 
@@ -5149,28 +4498,23 @@ bool player_place(player_type *creature_ptr, POSITION y, POSITION x)
  */
 void wreck_the_pattern(player_type *creature_ptr)
 {
-       int to_ruin = 0;
-       POSITION r_y, r_x;
        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)
-       {
-               /* Ruined already */
-               return;
-       }
+       if (pattern_type == PATTERN_TILE_WRECKED) return;
 
        msg_print(_("パターンを血で汚してしまった!", "You bleed on the Pattern!"));
        msg_print(_("何か恐ろしい事が起こった!", "Something terrible happens!"));
 
-       if (!IS_INVULN(creature_ptr)) 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--)
        {
+               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) &&
+               if (pattern_tile(floor_ptr, r_y, r_x) &&
                        (f_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED))
                {
                        cave_set_feat(creature_ptr, r_y, r_x, feat_pattern_corrupted);
@@ -5182,26 +4526,73 @@ void wreck_the_pattern(player_type *creature_ptr)
 
 
 /*!
+ * @brief エルドリッチホラーの形容詞種別を決める
+ * @param r_ptr モンスター情報への参照ポインタ
+ * @return 
+ */
+concptr decide_horror_message(monster_race *r_ptr)
+{
+       int horror_num = randint0(MAX_SAN_HORROR_SUM);
+       if (horror_num < MAX_SAN_HORROR_COMMON)
+       {
+               return horror_desc_common[horror_num];
+       }
+       
+       if ((r_ptr->flags3 & RF3_EVIL) != 0)
+       {
+               return horror_desc_evil[horror_num - MAX_SAN_HORROR_COMMON];
+       }
+
+       return horror_desc_neutral[horror_num - MAX_SAN_HORROR_COMMON];
+}
+
+
+/*!
+ * todo m_nameとdescで何が違うのかは良く分からない
+ * @brief エルドリッチホラー持ちのモンスターを見た時の反応 (モンスター名版)
+ * @param m_name モンスター名
+ * @param r_ptr モンスター情報への参照ポインタ
+ * @return なし
+ */
+void see_eldritch_horror(GAME_TEXT *m_name, monster_race *r_ptr)
+{
+       concptr horror_message = decide_horror_message(r_ptr);
+       msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), horror_message, m_name);
+       r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
+}
+
+
+/*!
+ * @brief エルドリッチホラー持ちのモンスターを見た時の反応 (モンスター名版)
+ * @param desc モンスター名 (エルドリッチホラー持ちの全モンスターからランダム…のはず)
+ * @param r_ptr モンスターへの参照ポインタ
+ * @return なし
+ */
+void feel_eldritch_horror(concptr desc, monster_race *r_ptr)
+{
+       concptr horror_message = decide_horror_message(r_ptr);
+       msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"), horror_message, desc);
+       r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
+}
+
+
+/*!
  * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
- * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
+ * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ。薬・罠・魔法の影響ならNULL
  * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
  * @return なし
  */
 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];
                monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
-
                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))
                {
                        if (r_ptr->flags1 & RF1_FRIENDS)
@@ -5210,27 +4601,24 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                else power *= 2;
 
                if (!current_world_ptr->is_loading_now)
-                       return; /* No effect yet, just loaded... */
+                       return;
 
                if (!m_ptr->ml)
-                       return; /* Cannot see it for some reason */
+                       return;
 
                if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
                        return;
 
                if (is_pet(m_ptr))
-                       return; /* Pet eldritch horrors are safe most of the time */
+                       return;
 
                if (randint1(100) > power) return;
 
                if (saving_throw(creature_ptr->skill_sav - power))
-               {
-                       return; /* Save, no adverse effects */
-               }
+                       return;
 
                if (creature_ptr->image)
                {
-                       /* Something silly happens... */
                        msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
                                funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
 
@@ -5240,20 +4628,16 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                                creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
                        }
 
-                       return; /* Never mind; we can't see it clearly enough */
+                       return;
                }
 
-               /* Something frightening happens... */
-               msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
-                       horror_desc[randint0(MAX_SAN_HORROR)], m_name);
-
-               r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
-
-               /* Demon characters are unaffected */
-               if (PRACE_IS_(creature_ptr, RACE_IMP) || PRACE_IS_(creature_ptr, RACE_DEMON) || (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
-               if (current_world_ptr->wizard) return;
+               see_eldritch_horror(m_name, r_ptr);
+               if (PRACE_IS_(creature_ptr, RACE_IMP) ||
+                       PRACE_IS_(creature_ptr, RACE_DEMON) ||
+                       (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON) ||
+                       current_world_ptr->wizard)
+                       return;
 
-               /* Undead characters are 50% likely to be unaffected */
                if (PRACE_IS_(creature_ptr, RACE_SKELETON) || PRACE_IS_(creature_ptr, RACE_ZOMBIE)
                        || PRACE_IS_(creature_ptr, RACE_VAMPIRE) || PRACE_IS_(creature_ptr, RACE_SPECTRE) ||
                        (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
@@ -5266,15 +4650,11 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                monster_race *r_ptr;
                GAME_TEXT m_name[MAX_NLEN];
                concptr desc;
-
-               get_mon_num_prep(get_nightmare, NULL);
-
-               r_ptr = &r_info[get_mon_num(MAX_DEPTH)];
+               get_mon_num_prep(creature_ptr, get_nightmare, NULL);
+               r_ptr = &r_info[get_mon_num(creature_ptr, MAX_DEPTH, 0)];
                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
 
@@ -5293,13 +4673,11 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                if (saving_throw(creature_ptr->skill_sav * 100 / power))
                {
                        msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
-                       /* Safe */
                        return;
                }
 
                if (creature_ptr->image)
                {
-                       /* Something silly happens... */
                        msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
                                funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
 
@@ -5309,26 +4687,18 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                                creature_ptr->image = creature_ptr->image + randint1(r_ptr->level);
                        }
 
-                       /* Never mind; we can't see it clearly enough */
                        return;
                }
 
-               /* Something frightening happens... */
-               msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
-                       horror_desc[randint0(MAX_SAN_HORROR)], desc);
-
-               r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
-
+               feel_eldritch_horror(desc, r_ptr);
                if (!creature_ptr->mimic_form)
                {
                        switch (creature_ptr->prace)
                        {
-                               /* Demons may make a saving throw */
                        case RACE_IMP:
                        case RACE_DEMON:
                                if (saving_throw(20 + creature_ptr->lev)) return;
                                break;
-                               /* Undead may make a saving throw */
                        case RACE_SKELETON:
                        case RACE_ZOMBIE:
                        case RACE_SPECTRE:
@@ -5339,12 +4709,10 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                }
                else
                {
-                       /* Demons may make a saving throw */
                        if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
                        {
                                if (saving_throw(20 + creature_ptr->lev)) return;
                        }
-                       /* Undead may make a saving throw */
                        else if (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
                        {
                                if (saving_throw(10 + creature_ptr->lev)) return;
@@ -5361,8 +4729,7 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                && 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;
        }
@@ -5370,6 +4737,7 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
        switch (randint1(22))
        {
        case 1:
+       {
                if (!(creature_ptr->muta3 & MUT3_MORONIC))
                {
                        if ((creature_ptr->stat_use[A_INT] < 4) && (creature_ptr->stat_use[A_WIS] < 4))
@@ -5386,15 +4754,17 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
                                msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
                                creature_ptr->muta3 &= ~(MUT3_HYPER_INT);
                        }
+
                        creature_ptr->muta3 |= MUT3_MORONIC;
                }
+
                break;
+       }
        case 2:
+       {
                if (!(creature_ptr->muta2 & MUT2_COWARDICE) && !creature_ptr->resist_fear)
                {
                        msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
-
-                       /* Duh, the following should never happen, but anyway... */
                        if (creature_ptr->muta3 & MUT3_FEARLESS)
                        {
                                msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
@@ -5403,21 +4773,29 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
 
                        creature_ptr->muta2 |= MUT2_COWARDICE;
                }
+
                break;
+       }
        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 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:
@@ -5426,21 +4804,25 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
        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);
                }
+
+               /* todo いつからかは不明だがreturnとbreakが同時に存在している。どちらがデッドコードか不明瞭なので保留 */
                return;
                break;
+       }
        case 13:
        case 14:
        case 15:
-               /* Brain smash */
+       {
                if (!creature_ptr->resist_conf)
                {
                        (void)set_confused(creature_ptr, creature_ptr->confused + randint0(4) + 4);
@@ -5453,29 +4835,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 {
+
+               do
+               {
                        (void)do_dec_stat(creature_ptr, A_INT);
                } while (randint0(100) > creature_ptr->skill_sav && one_in_(2));
 
-               do {
+               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:
        case 22:
-               /* Lose int & wis */
+       {
                do_dec_stat(creature_ptr, A_INT);
                do_dec_stat(creature_ptr, A_WIS);
                break;
+       }
        default:
                break;
        }
@@ -5492,38 +4881,25 @@ 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;
        if (creature_ptr->max_max_exp < 0) creature_ptr->max_max_exp = 0;
 
-       /* Hack -- upper limit */
        if (creature_ptr->exp > PY_MAX_EXP) creature_ptr->exp = PY_MAX_EXP;
        if (creature_ptr->max_exp > PY_MAX_EXP) creature_ptr->max_exp = PY_MAX_EXP;
        if (creature_ptr->max_max_exp > PY_MAX_EXP) creature_ptr->max_max_exp = PY_MAX_EXP;
 
-       /* Hack -- maintain "max" experience */
        if (creature_ptr->exp > creature_ptr->max_exp) creature_ptr->max_exp = creature_ptr->exp;
-
-       /* Hack -- maintain "max max" experience */
        if (creature_ptr->max_exp > creature_ptr->max_max_exp) creature_ptr->max_max_exp = creature_ptr->max_exp;
 
-       /* Redraw experience */
        creature_ptr->redraw |= (PR_EXP);
        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)))
        {
-               /* Lose a level */
                creature_ptr->lev--;
                creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
                creature_ptr->redraw |= (PR_LEV | PR_TITLE);
@@ -5531,15 +4907,13 @@ void check_experience(player_type *creature_ptr)
                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)))
        {
-               /* Gain a level */
                creature_ptr->lev++;
-
-               /* Save the highest level */
                if (creature_ptr->lev > creature_ptr->max_plv)
                {
                        creature_ptr->max_plv = creature_ptr->lev;
@@ -5559,19 +4933,14 @@ void check_experience(player_type *creature_ptr)
                }
 
                sound(SOUND_LEVEL);
-
                msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev);
-
                creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
                creature_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
                creature_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
-
-               /* HPとMPの上昇量を表示 */
                creature_ptr->level_up_message = TRUE;
                handle_stuff(creature_ptr);
 
                creature_ptr->level_up_message = FALSE;
-
                if (level_inc_stat)
                {
                        if (!(creature_ptr->max_plv % 10))
@@ -5639,8 +5008,8 @@ void check_experience(player_type *creature_ptr)
                handle_stuff(creature_ptr);
        }
 
-       /* Load an autopick preference file */
-       if (old_lev != creature_ptr->lev) autopick_load_pref(creature_ptr, FALSE);
+       if (old_lev != creature_ptr->lev)
+               autopick_load_pref(creature_ptr, FALSE);
 }
 
 
@@ -5652,29 +5021,24 @@ 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);
        }
 }
 
@@ -5695,41 +5059,25 @@ 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++;
-
-                       /* Ten "points" at a time */
                        else value += 10;
                }
        }
-
-       /* Penalty */
        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;
-
-                       /* Hack -- prevent weirdness */
                        else if (value > 18) value = 18;
-
-                       /* One point at a time */
                        else if (value > 3) value--;
                }
        }
 
-       /* Return new value */
-       return (s16b)(value);
+       return (s16b)value;
 }
 
 
@@ -5741,11 +5089,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;
@@ -5759,12 +5105,13 @@ long calc_score(player_type *creature_ptr)
 
        if (mult < 5) mult = 5;
 
-       for (i = 0; i < current_world_ptr->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;
@@ -5775,7 +5122,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));
 
@@ -5791,6 +5138,7 @@ long calc_score(player_type *creature_ptr)
                point = 1;
                if (current_world_ptr->total_winner) point = 2;
        }
+
        if (easy_band) point = (0 - point);
 
        return point;
@@ -5799,20 +5147,15 @@ long calc_score(player_type *creature_ptr)
 
 void cheat_death(player_type *creature_ptr)
 {
-       /* Mark social class, reset age, if needed */
-       if (creature_ptr->sc) creature_ptr->sc = creature_ptr->age = 0;
-
-       /* Increase age */
+       if (creature_ptr->sc)
+               creature_ptr->sc = creature_ptr->age = 0;
        creature_ptr->age++;
 
-       /* Mark savefile */
        current_world_ptr->noscore |= 0x0001;
-
        msg_print(_("ウィザードモードに念を送り、死を欺いた。", "You invoke wizard mode and cheat death."));
        msg_print(NULL);
 
        (void)life_stream(creature_ptr, FALSE, FALSE);
-
        if (creature_ptr->pclass == CLASS_MAGIC_EATER)
        {
                int magic_idx;
@@ -5826,36 +5169,24 @@ void cheat_death(player_type *creature_ptr)
                }
        }
 
-       /* Restore spell points */
        creature_ptr->csp = creature_ptr->msp;
        creature_ptr->csp_frac = 0;
-
-       /* Hack -- cancel recall */
        if (creature_ptr->word_recall)
        {
                msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
                msg_print(NULL);
-
-               /* Hack -- Prevent recall */
                creature_ptr->word_recall = 0;
                creature_ptr->redraw |= (PR_STATUS);
        }
 
-       /* Hack -- cancel alter */
        if (creature_ptr->alter_reality)
        {
-               /* Hack -- Prevent alter */
                creature_ptr->alter_reality = 0;
                creature_ptr->redraw |= (PR_STATUS);
        }
 
-       /* Note cause of death */
        (void)strcpy(creature_ptr->died_from, _("死の欺き", "Cheating death"));
-
-       /* Do not die */
        creature_ptr->is_dead = FALSE;
-
-       /* Hack -- Prevent starvation */
        (void)set_food(creature_ptr, PY_FOOD_MAX - 1);
 
        floor_type *floor_ptr = creature_ptr->current_floor_ptr;
@@ -5888,6 +5219,7 @@ void cheat_death(player_type *creature_ptr)
                creature_ptr->oldpy = 33;
                creature_ptr->oldpx = 131;
        }
+
        creature_ptr->wild_mode = FALSE;
        creature_ptr->leaving = TRUE;
 
@@ -5895,9 +5227,8 @@ void cheat_death(player_type *creature_ptr)
                _("                            しかし、生き返った。",
                        "                            but revived."));
 
-       /* Prepare next floor */
        leave_floor(creature_ptr);
-       wipe_m_list();
+       wipe_monsters_list(creature_ptr);
 }
 
 
@@ -5907,7 +5238,7 @@ void cheat_death(player_type *creature_ptr)
  */
 bool is_blessed(player_type *creature_ptr)
 {
-       return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(HEX_BLESS);
+       return creature_ptr->blessed || music_singing(creature_ptr, MUSIC_BLESS) || hex_spelling(creature_ptr, HEX_BLESS);
 }
 
 
@@ -5969,3 +5300,110 @@ bool can_two_hands_wielding(player_type *creature_ptr)
 {
        return !creature_ptr->riding || (creature_ptr->pet_extra_flags & PF_TWO_HANDS);
 }
+
+
+
+/*!
+* @brief 歌の停止を処理する / Stop singing if the player is a Bard
+* @return なし
+*/
+void stop_singing(player_type *creature_ptr)
+{
+       if (creature_ptr->pclass != CLASS_BARD) return;
+
+       /* Are there interupted song? */
+       if (INTERUPTING_SONG_EFFECT(creature_ptr))
+       {
+               /* Forget interupted song */
+               INTERUPTING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
+               return;
+       }
+
+       /* The player is singing? */
+       if (!SINGING_SONG_EFFECT(creature_ptr)) return;
+
+       /* Hack -- if called from set_action(), avoid recursive loop */
+       if (creature_ptr->action == ACTION_SING) set_action(creature_ptr, ACTION_NONE);
+
+       /* Message text of each song or etc. */
+       exe_spell(creature_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
+
+       SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
+       SINGING_SONG_ID(creature_ptr) = 0;
+       creature_ptr->update |= (PU_BONUS);
+       creature_ptr->redraw |= (PR_STATUS);
+}
+
+/*!
+ * @brief 口を使う継続的な処理を中断する
+ * @param caster_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void stop_mouth(player_type *caster_ptr)
+{
+       if (music_singing_any(caster_ptr)) stop_singing(caster_ptr);
+       if (hex_spelling_any(caster_ptr)) stop_hex_spell_all(caster_ptr);
+}
+
+
+/*!
+* @brief ペットの維持コスト計算
+* @return 維持コスト(%)
+*/
+PERCENTAGE calculate_upkeep(player_type *creature_ptr)
+{
+       MONSTER_IDX m_idx;
+       bool have_a_unique = FALSE;
+       DEPTH total_friend_levels = 0;
+
+       total_friends = 0;
+
+       for (m_idx = creature_ptr->current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
+       {
+               monster_type *m_ptr;
+               monster_race *r_ptr;
+
+               m_ptr = &creature_ptr->current_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))
+               {
+                       total_friends++;
+                       if (r_ptr->flags1 & RF1_UNIQUE)
+                       {
+                               if (creature_ptr->pclass == CLASS_CAVALRY)
+                               {
+                                       if (creature_ptr->riding == m_idx)
+                                               total_friend_levels += (r_ptr->level + 5) * 2;
+                                       else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
+                                               total_friend_levels += (r_ptr->level + 5) * 7 / 2;
+                                       else
+                                               total_friend_levels += (r_ptr->level + 5) * 10;
+                                       have_a_unique = TRUE;
+                               }
+                               else
+                                       total_friend_levels += (r_ptr->level + 5) * 10;
+                       }
+                       else
+                               total_friend_levels += r_ptr->level;
+
+               }
+       }
+
+       if (total_friends)
+       {
+               int upkeep_factor;
+               upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
+               if (upkeep_factor < 0) upkeep_factor = 0;
+               if (upkeep_factor > 1000) upkeep_factor = 1000;
+               return upkeep_factor;
+       }
+       else
+               return 0;
+}
+
+bool music_singing(player_type *caster_ptr, int music_songs)
+{
+       return (caster_ptr->pclass == CLASS_BARD) && (caster_ptr->magic_num1[0] == music_songs);
+}