OSDN Git Service

Weaponsmiths can drain lite essence according to lite radius of draining objects
[hengband/hengband.git] / src / xtra1.c
index a8a8314..0969c8b 100644 (file)
@@ -129,8 +129,8 @@ bool is_daytime(void)
  */
 void extract_day_hour_min(int *day, int *hour, int *min)
 {
-       s32b len = TURNS_PER_TICK * TOWN_DAWN;
-       s32b tick = turn % len + len / 4;
+       const s32b A_DAY = TURNS_PER_TICK * TOWN_DAWN;
+       s32b turn_in_today = (turn + A_DAY / 4) % A_DAY;
 
        switch (p_ptr->start_race)
        {
@@ -138,14 +138,14 @@ void extract_day_hour_min(int *day, int *hour, int *min)
        case RACE_SKELETON:
        case RACE_ZOMBIE:
        case RACE_SPECTRE:
-               *day = (turn - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4)) / len + 1;
+               *day = (turn - A_DAY * 3 / 4) / A_DAY + 1;
                break;
        default:
-               *day = (turn + (TURNS_PER_TICK * TOWN_DAWN / 4)) / len + 1;
+               *day = (turn + A_DAY / 4) / A_DAY + 1;
                break;
        }
-       *hour = (24 * tick / len) % 24;
-       *min = (1440 * tick / len) % 60;
+       *hour = (24 * turn_in_today / A_DAY) % 24;
+       *min = (1440 * turn_in_today / A_DAY) % 60;
 }
 
 /*
@@ -161,14 +161,14 @@ void prt_time(void)
        extract_day_hour_min(&day, &hour, &min);
 
        /* Dump the info itself */
-       c_put_str(TERM_WHITE, format(
 #ifdef JP
-               "%2dÆüÌÜ",
+       if (day < 1000) c_put_str(TERM_WHITE, format("%2dÆüÌÜ", day), ROW_DAY, COL_DAY);
+       else c_put_str(TERM_WHITE, "***ÆüÌÜ", ROW_DAY, COL_DAY);
 #else
-               "Day %-2d",
+       if (day < 1000) c_put_str(TERM_WHITE, format("Day%3d", day), ROW_DAY, COL_DAY);
+       else c_put_str(TERM_WHITE, "Day***", ROW_DAY, COL_DAY);
 #endif
-               day), ROW_DAY, COL_DAY);
-       
+
        c_put_str(TERM_WHITE, format("%2d:%02d", hour, min), ROW_DAY, COL_DAY+7);
 }
 
@@ -323,7 +323,20 @@ static void prt_stat(int stat)
 #define BAR_SUPERSTEALTH 50
 #define BAR_RECALL 51
 #define BAR_ALTER 52
-
+#define BAR_SHCOLD 53
+#define BAR_SHELEC 54
+#define BAR_SHSHADOW 55
+#define BAR_MIGHT 56
+#define BAR_BUILD 57
+#define BAR_ANTIMULTI 58
+#define BAR_ANTITELE 59
+#define BAR_ANTIMAGIC 60
+#define BAR_PATIENCE 61
+#define BAR_REVENGE 62
+#define BAR_RUNESWORD 63
+#define BAR_VAMPILIC 64
+#define BAR_CURE 65
+#define BAR_ESP_EVIL 66
 
 static struct {
        byte attr;
@@ -385,12 +398,27 @@ static struct {
        {TERM_YELLOW, "±£", "Ķ±£Ì©"},
        {TERM_WHITE, "µ¢", "µ¢´Ô"},
        {TERM_WHITE, "¸½", "¸½¼ÂÊÑÍÆ"},
+       /* Hex */
+       {TERM_WHITE, "¥ª", "ɹ¥ª¡¼¥é"},
+       {TERM_BLUE, "¥ª", "ÅÅ¥ª¡¼¥é"},
+       {TERM_L_DARK, "¥ª", "±Æ¥ª¡¼¥é"},
+       {TERM_YELLOW, "ÏÓ", "ÏÓÎ϶¯²½"},
+       {TERM_RED, "Æù", "ÆùÂζ¯²½"},
+       {TERM_L_DARK, "¿£", "È¿Áý¿£"},
+       {TERM_ORANGE, "¥Æ", "È¿¥Æ¥ì¥Ý"},
+       {TERM_RED, "Ëâ", "È¿ËâË¡"},
+       {TERM_SLATE, "²æ", "²æËý"},
+       {TERM_SLATE, "Àë", "Àë¹ð"},
+       {TERM_L_DARK, "·õ", "Ëâ·õ²½"},
+       {TERM_RED, "µÛ", "µÛ·ìÂÇ·â"},
+       {TERM_WHITE, "²ó", "²óÉü"},
+       {TERM_L_DARK, "´¶", "¼Ù°­´¶ÃÎ"},
        {0, NULL, NULL}
 };
 #else
 = {
        {TERM_YELLOW, "Ts", "Tsuyoshi"},
-       {TERM_VIOLET, "Hu", "Hullc"},
+       {TERM_VIOLET, "Ha", "Halluc"},
        {TERM_L_DARK, "Bl", "Blind"},
        {TERM_RED, "Pa", "Paralyzed"},
        {TERM_VIOLET, "Cf", "Confused"},
@@ -442,6 +470,21 @@ static struct {
        {TERM_YELLOW, "Stlt", "Stealth"},
        {TERM_WHITE, "Rc", "Recall"},
        {TERM_WHITE, "Al", "Alter"},
+       /* Hex */
+       {TERM_WHITE, "SCo", "SCold"},
+       {TERM_BLUE, "SEl", "SElec"},
+       {TERM_L_DARK, "SSh", "SShadow"},
+       {TERM_YELLOW, "EMi", "ExMight"},
+       {TERM_RED, "Bu", "BuildUp"},
+       {TERM_L_DARK, "AMl", "AntiMulti"},
+       {TERM_ORANGE, "AT", "AntiTele"},
+       {TERM_RED, "AM", "AntiMagic"},
+       {TERM_SLATE, "Pa", "Patience"},
+       {TERM_SLATE, "Rv", "Revenge"},
+       {TERM_L_DARK, "Rs", "RuneSword"},
+       {TERM_RED, "Vm", "Vampiric"},
+       {TERM_WHITE, "Cu", "Cure"},
+       {TERM_L_DARK, "ET", "EvilTele"},
        {0, NULL, NULL}
 };
 #endif
@@ -455,7 +498,7 @@ static struct {
  */
 static void prt_status(void)
 {
-       u32b bar_flags[2];
+       u32b bar_flags[3];
        int wid, hgt, row_statbar, max_col_statbar;
        int i, col = 0, num = 0;
        int space = 2;
@@ -466,7 +509,7 @@ static void prt_status(void)
 
        Term_erase(0, row_statbar, max_col_statbar);
 
-       bar_flags[0] = bar_flags[1] = 0L;
+       bar_flags[0] = bar_flags[1] = bar_flags[2] = 0L;
 
        /* Tsuyoshi  */
        if (p_ptr->tsuyoshi) ADD_FLG(BAR_TSUYOSHI);
@@ -572,7 +615,7 @@ static void prt_status(void)
        if (p_ptr->ult_res) ADD_FLG(BAR_ULTIMATE);
 
        /* tim levitation */
-       if (p_ptr->tim_ffall) ADD_FLG(BAR_LEVITATE);
+       if (p_ptr->tim_levitation) ADD_FLG(BAR_LEVITATE);
 
        if (p_ptr->tim_res_nether) ADD_FLG(BAR_RESNETH);
 
@@ -599,6 +642,35 @@ static void prt_status(void)
        /* An Eye for an Eye */
        if (p_ptr->tim_eyeeye) ADD_FLG(BAR_EYEEYE);
 
+       /* Hex spells */
+       if (p_ptr->realm1 == REALM_HEX)
+       {
+               if (hex_spelling(HEX_BLESS)) ADD_FLG(BAR_BLESSED);
+               if (hex_spelling(HEX_DEMON_AURA)) { ADD_FLG(BAR_SHFIRE); ADD_FLG(BAR_REGENERATION); }
+               if (hex_spelling(HEX_XTRA_MIGHT)) ADD_FLG(BAR_MIGHT);
+               if (hex_spelling(HEX_DETECT_EVIL)) ADD_FLG(BAR_ESP_EVIL);
+               if (hex_spelling(HEX_ICE_ARMOR)) ADD_FLG(BAR_SHCOLD);
+               if (hex_spelling(HEX_RUNESWORD)) ADD_FLG(BAR_RUNESWORD);
+               if (hex_spelling(HEX_BUILDING)) ADD_FLG(BAR_BUILD);
+               if (hex_spelling(HEX_ANTI_TELE)) ADD_FLG(BAR_ANTITELE);
+               if (hex_spelling(HEX_SHOCK_CLOAK)) ADD_FLG(BAR_SHELEC);
+               if (hex_spelling(HEX_SHADOW_CLOAK)) ADD_FLG(BAR_SHSHADOW);
+               if (hex_spelling(HEX_CONFUSION)) ADD_FLG(BAR_ATTKCONF);
+               if (hex_spelling(HEX_EYE_FOR_EYE)) ADD_FLG(BAR_EYEEYE);
+               if (hex_spelling(HEX_ANTI_MULTI)) ADD_FLG(BAR_ANTIMULTI);
+               if (hex_spelling(HEX_VAMP_BLADE)) ADD_FLG(BAR_VAMPILIC);
+               if (hex_spelling(HEX_ANTI_MAGIC)) ADD_FLG(BAR_ANTIMAGIC);
+               if (hex_spelling(HEX_CURE_LIGHT) ||
+                       hex_spelling(HEX_CURE_SERIOUS) ||
+                       hex_spelling(HEX_CURE_CRITICAL)) ADD_FLG(BAR_CURE);
+
+               if (p_ptr->magic_num2[2])
+               {
+                       if (p_ptr->magic_num2[1] == 1) ADD_FLG(BAR_PATIENCE);
+                       if (p_ptr->magic_num2[1] == 2) ADD_FLG(BAR_REVENGE);
+               }
+       }
+
        /* Calcurate length */
        for (i = 0; bar[i].sstr; i++)
        {
@@ -754,12 +826,29 @@ static void prt_exp(void)
 {
        char out_val[32];
 
+       if ((!exp_need)||(p_ptr->prace == RACE_ANDROID))
+       {
 #ifdef JP
-(void)sprintf(out_val, "%7ld", (long)p_ptr->exp);
+       (void)sprintf(out_val, "%7ld", (long)p_ptr->exp);
 #else
        (void)sprintf(out_val, "%8ld", (long)p_ptr->exp);
 #endif
-
+       }
+       else
+       {
+               if (p_ptr->lev >= PY_MAX_LEVEL)
+               {
+                       (void)sprintf(out_val, "********");
+               }
+               else
+               {
+#ifdef JP
+                       (void)sprintf(out_val, "%7ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp);
+#else      
+                       (void)sprintf(out_val, "%8ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp);
+#endif
+               }
+       }
 
        if (p_ptr->exp >= p_ptr->max_exp)
        {
@@ -787,7 +876,6 @@ static void prt_exp(void)
        }
 }
 
-
 /*
  * Prints current gold
  */
@@ -844,7 +932,7 @@ static void prt_hp(void)
        put_str("HP", ROW_CURHP, COL_CURHP);
 
        /* ¸½ºß¤Î¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */
-       sprintf(tmp, "%4d", p_ptr->chp);
+       sprintf(tmp, "%4ld", (long int)p_ptr->chp);
 
        if (p_ptr->chp >= p_ptr->mhp)
        {
@@ -865,7 +953,7 @@ static void prt_hp(void)
        put_str( "/", ROW_CURHP, COL_CURHP + 7 );
 
        /* ºÇÂç¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */
-       sprintf(tmp, "%4d", p_ptr->mhp);
+       sprintf(tmp, "%4ld", (long int)p_ptr->mhp);
        color = TERM_L_GREEN;
 
        c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 8 );
@@ -895,13 +983,13 @@ static void prt_sp(void)
 #endif
 
        /* ¸½ºß¤Î¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */
-       sprintf(tmp, "%4d", p_ptr->csp);
+       sprintf(tmp, "%4ld", (long int)p_ptr->csp);
 
        if (p_ptr->csp >= p_ptr->msp)
        {
                color = TERM_L_GREEN;
        }
-       else if (p_ptr->csp > p_ptr->msp / 5)
+       else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10)
        {
                color = TERM_YELLOW;
        }
@@ -916,7 +1004,7 @@ static void prt_sp(void)
        put_str( "/", ROW_CURSP, COL_CURSP + 7 );
 
        /* ºÇÂç¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */
-       sprintf(tmp, "%4d", p_ptr->msp);
+       sprintf(tmp, "%4ld", (long int)p_ptr->msp);
        color = TERM_L_GREEN;
 
        c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 8);
@@ -930,6 +1018,7 @@ static void prt_depth(void)
 {
        char depths[32];
        int wid, hgt, row_depth, col_depth;
+       byte attr = TERM_WHITE;
 
        Term_get_size(&wid, &hgt);
        col_depth = wid + COL_DEPTH;
@@ -946,33 +1035,41 @@ static void prt_depth(void)
        else if (p_ptr->inside_quest && !dungeon_type)
        {
 #ifdef JP
-strcpy(depths, "ÃϾå");
+               strcpy(depths, "ÃϾå");
 #else
                strcpy(depths, "Quest");
 #endif
-
-       }
-       else if (depth_in_feet)
-       {
-#ifdef JP
-(void)sprintf(depths, "%d ft", dun_level * 50);
-#else
-               (void)sprintf(depths, "%d ft", dun_level * 50);
-#endif
-
        }
        else
        {
 #ifdef JP
-sprintf(depths, "%d ³¬", dun_level);
+               if (depth_in_feet) (void)sprintf(depths, "%d ft", dun_level * 50);
+               else (void)sprintf(depths, "%d ³¬", dun_level);
 #else
-               (void)sprintf(depths, "Lev %d", dun_level);
+               if (depth_in_feet) (void)sprintf(depths, "%d ft", dun_level * 50);
+               else (void)sprintf(depths, "Lev %d", dun_level);
 #endif
 
+
+               /* Get color of level based on feeling  -JSV- */
+               switch (p_ptr->feeling)
+               {
+               case  0: attr = TERM_SLATE;   break; /* Unknown */
+               case  1: attr = TERM_L_BLUE;  break; /* Special */
+               case  2: attr = TERM_VIOLET;  break; /* Horrible visions */
+               case  3: attr = TERM_RED;     break; /* Very dangerous */
+               case  4: attr = TERM_L_RED;   break; /* Very bad feeling */
+               case  5: attr = TERM_ORANGE;  break; /* Bad feeling */
+               case  6: attr = TERM_YELLOW;  break; /* Nervous */
+               case  7: attr = TERM_L_UMBER; break; /* Luck is turning */
+               case  8: attr = TERM_L_WHITE; break; /* Don't like */
+               case  9: attr = TERM_WHITE;   break; /* Reasonably safe */
+               case 10: attr = TERM_WHITE;   break; /* Boring place */
+               }
        }
 
        /* Right-Adjust the "depth", and clear old values */
-       prt(format("%7s", depths), row_depth, col_depth);
+       c_prt(attr, format("%7s", depths), row_depth, col_depth);
 }
 
 
@@ -1214,6 +1311,15 @@ sprintf(text, "  %2d", command_rep);
 #endif
                                break;
                        }
+                       case ACTION_SPELL:
+                       {
+#ifdef JP
+                               strcpy(text, "±Ó¾§");
+#else
+                               strcpy(text, "Spel");
+#endif
+                               break;
+                       }
                        default:
                        {
                                strcpy(text, "    ");
@@ -1244,15 +1350,16 @@ static void prt_speed(void)
        row_speed = hgt + ROW_SPEED;
 
        /* Hack -- Visually "undo" the Search Mode Slowdown */
-       if (p_ptr->action == ACTION_SEARCH) i += 10;
+       if (p_ptr->action == ACTION_SEARCH && !p_ptr->lightspeed) i += 10;
 
        /* Fast */
        if (i > 110)
        {
                if (p_ptr->riding)
                {
-                       if (m_list[p_ptr->riding].fast && !m_list[p_ptr->riding].slow) attr = TERM_L_BLUE;
-                       else if (m_list[p_ptr->riding].slow && !m_list[p_ptr->riding].fast) attr = TERM_VIOLET;
+                       monster_type *m_ptr = &m_list[p_ptr->riding];
+                       if (MON_FAST(m_ptr) && !MON_SLOW(m_ptr)) attr = TERM_L_BLUE;
+                       else if (MON_SLOW(m_ptr) && !MON_FAST(m_ptr)) attr = TERM_VIOLET;
                        else attr = TERM_GREEN;
                }
                else if ((is_fast && !p_ptr->slow) || p_ptr->lightspeed) attr = TERM_YELLOW;
@@ -1271,8 +1378,9 @@ static void prt_speed(void)
        {
                if (p_ptr->riding)
                {
-                       if (m_list[p_ptr->riding].fast && !m_list[p_ptr->riding].slow) attr = TERM_L_BLUE;
-                       else if (m_list[p_ptr->riding].slow && !m_list[p_ptr->riding].fast) attr = TERM_VIOLET;
+                       monster_type *m_ptr = &m_list[p_ptr->riding];
+                       if (MON_FAST(m_ptr) && !MON_SLOW(m_ptr)) attr = TERM_L_BLUE;
+                       else if (MON_SLOW(m_ptr) && !MON_FAST(m_ptr)) attr = TERM_VIOLET;
                        else attr = TERM_RED;
                }
                else if (is_fast && !p_ptr->slow) attr = TERM_YELLOW;
@@ -1323,7 +1431,7 @@ static void prt_study(void)
 }
 
 
-static void prt_mane(void)
+static void prt_imitation(void)
 {
        int wid, hgt, row_study, col_study;
 
@@ -1341,7 +1449,7 @@ static void prt_mane(void)
 #ifdef JP
                        c_put_str(attr, "¤Þ¤Í", row_study, col_study);
 #else
-                       c_put_str(attr, "Mane", row_study, col_study);
+                       c_put_str(attr, "Imit", row_study, col_study);
 #endif
                }
                else
@@ -1480,163 +1588,95 @@ static void prt_stun(void)
  * Auto-track current target monster when bored.  Note that the
  * health-bar stops tracking any monster that "disappears".
  */
-static void health_redraw(void)
+static void health_redraw(bool riding)
 {
+       s16b health_who;
+       int row, col;
+       monster_type *m_ptr;
 
-#ifdef DRS_SHOW_HEALTH_BAR
+       if (riding)
+       {
+               health_who = p_ptr->riding;
+               row = ROW_RIDING_INFO;
+               col = COL_RIDING_INFO;
+       }
+       else
+       {
+               health_who = p_ptr->health_who;
+               row = ROW_INFO;
+               col = COL_INFO;
+       }
+
+       m_ptr = &m_list[health_who];
 
        /* Not tracking */
-       if (!p_ptr->health_who)
+       if (!health_who)
        {
                /* Erase the health bar */
-               Term_erase(COL_INFO, ROW_INFO, 12);
+               Term_erase(col, row, 12);
        }
 
        /* Tracking an unseen monster */
-       else if (!m_list[p_ptr->health_who].ml)
+       else if (!m_ptr->ml)
        {
                /* Indicate that the monster health is "unknown" */
-               Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
+               Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
        }
 
        /* Tracking a hallucinatory monster */
        else if (p_ptr->image)
        {
                /* Indicate that the monster health is "unknown" */
-               Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
+               Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
        }
 
        /* Tracking a dead monster (???) */
-       else if (!m_list[p_ptr->health_who].hp < 0)
+       else if (m_ptr->hp < 0)
        {
                /* Indicate that the monster health is "unknown" */
-               Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
+               Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
        }
 
        /* Tracking a visible monster */
        else
        {
-               int pct, pct2, len;
-
-               monster_type *m_ptr = &m_list[p_ptr->health_who];
-
-               /* Default to almost dead */
-               byte attr = TERM_RED;
-
                /* Extract the "percent" of health */
-               pct = 100L * m_ptr->hp / m_ptr->maxhp;
-               pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
-
-               /* Badly wounded */
-               if (pct >= 10) attr = TERM_L_RED;
-
-               /* Wounded */
-               if (pct >= 25) attr = TERM_ORANGE;
-
-               /* Somewhat Wounded */
-               if (pct >= 60) attr = TERM_YELLOW;
-
-               /* Healthy */
-               if (pct >= 100) attr = TERM_L_GREEN;
-
-               /* Afraid */
-               if (m_ptr->monfear) attr = TERM_VIOLET;
-
-               /* Asleep */
-               if (m_ptr->csleep) attr = TERM_BLUE;
-
-               /* Invulnerable */
-               if (m_ptr->invulner) attr = TERM_WHITE;
+               int pct = 100L * m_ptr->hp / m_ptr->maxhp;
+               int pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
 
                /* Convert percent into "health" */
-               len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
-
-               /* Default to "unknown" */
-               Term_putstr(COL_INFO, ROW_INFO, 12, TERM_WHITE, "[----------]");
-
-               /* Dump the current "health" (use '*' symbols) */
-               Term_putstr(COL_INFO + 1, ROW_INFO, len, attr, "**********");
-       }
-
-#endif
-
-}
-
-
-
-static void riding_health_redraw(void)
-{
-
-#ifdef DRS_SHOW_HEALTH_BAR
-
-       /* Not tracking */
-       if (!p_ptr->riding)
-       {
-               /* Erase the health bar */
-               Term_erase(COL_RIDING_INFO, ROW_RIDING_INFO, 12);
-       }
-
-       /* Tracking a hallucinatory monster */
-       else if (p_ptr->image)
-       {
-               /* Indicate that the monster health is "unknown" */
-               Term_putstr(COL_RIDING_INFO, ROW_RIDING_INFO, 12, TERM_WHITE, "[----------]");
-       }
-
-       /* Tracking a dead monster (???) */
-       else if (!m_list[p_ptr->health_who].hp < 0)
-       {
-               /* Indicate that the monster health is "unknown" */
-               Term_putstr(COL_RIDING_INFO, ROW_RIDING_INFO, 12, TERM_WHITE, "[----------]");
-       }
-
-       /* Tracking a visible monster */
-       else
-       {
-               int pct, pct2, len;
-
-               monster_type *m_ptr = &m_list[p_ptr->riding];
+               int len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
 
                /* Default to almost dead */
                byte attr = TERM_RED;
 
-               /* Extract the "percent" of health */
-               pct = 100L * m_ptr->hp / m_ptr->maxhp;
-               pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
-
-               /* Badly wounded */
-               if (pct >= 10) attr = TERM_L_RED;
+               /* Invulnerable */
+               if (MON_INVULNER(m_ptr)) attr = TERM_WHITE;
 
-               /* Wounded */
-               if (pct >= 25) attr = TERM_ORANGE;
+               /* Asleep */
+               else if (MON_CSLEEP(m_ptr)) attr = TERM_BLUE;
 
-               /* Somewhat Wounded */
-               if (pct >= 60) attr = TERM_YELLOW;
+               /* Afraid */
+               else if (MON_MONFEAR(m_ptr)) attr = TERM_VIOLET;
 
                /* Healthy */
-               if (pct >= 100) attr = TERM_L_GREEN;
+               else if (pct >= 100) attr = TERM_L_GREEN;
 
-               /* Afraid */
-               if (m_ptr->monfear) attr = TERM_VIOLET;
-
-               /* Asleep */
-               if (m_ptr->csleep) attr = TERM_BLUE;
+               /* Somewhat Wounded */
+               else if (pct >= 60) attr = TERM_YELLOW;
 
-               /* Invulnerable */
-               if (m_ptr->invulner) attr = TERM_WHITE;
+               /* Wounded */
+               else if (pct >= 25) attr = TERM_ORANGE;
 
-               /* Convert percent into "health" */
-               len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
+               /* Badly wounded */
+               else if (pct >= 10) attr = TERM_L_RED;
 
                /* Default to "unknown" */
-               Term_putstr(COL_RIDING_INFO, ROW_RIDING_INFO, 12, TERM_WHITE, "[----------]");
+               Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
 
                /* Dump the current "health" (use '*' symbols) */
-               Term_putstr(COL_RIDING_INFO + 1, ROW_RIDING_INFO, len, attr, "**********");
+               Term_putstr(col + 1, row, len, attr, "**********");
        }
-
-#endif
-
 }
 
 
@@ -1687,8 +1727,8 @@ static void prt_frame_basic(void)
        prt_depth();
 
        /* Special */
-       health_redraw();
-       riding_health_redraw();
+       health_redraw(FALSE);
+       health_redraw(TRUE);
 }
 
 
@@ -1713,7 +1753,7 @@ static void prt_frame_extra(void)
        /* Study spells */
        prt_study();
 
-       prt_mane();
+       prt_imitation();
 
        prt_status();
 }
@@ -1752,6 +1792,153 @@ static void fix_inven(void)
 }
 
 
+/*
+ * Print monster info in line
+ * nnn X LV name
+ *  nnn : number or unique(U) or wanted unique(W)
+ *  X   : symbol of monster
+ *  LV  : monster lv if known
+ *  name: name of monster
+ */
+static void print_monster_line(int x, int y, monster_type* m_ptr, int n_same){
+       char buf[256];
+       int i;
+       int r_idx = m_ptr->ap_r_idx;
+       monster_race* r_ptr = &r_info[r_idx];
+       Term_gotoxy(x, y);
+       if(!r_ptr)return;
+       //Number of 'U'nique
+       if(r_ptr->flags1&RF1_UNIQUE){//unique
+               bool is_kubi = FALSE;
+               for(i=0;i<MAX_KUBI;i++){
+                       if(kubi_r_idx[i] == r_idx){
+                               is_kubi = TRUE;
+                               break;
+                       }
+               }
+               Term_addstr(-1, TERM_WHITE, is_kubi?"  W":"  U");
+       }else{
+               sprintf(buf, "%3d", n_same);
+               Term_addstr(-1, TERM_WHITE, buf);
+       }
+       //symbol
+       Term_addstr(-1, TERM_WHITE, " ");
+       //Term_add_bigch(r_ptr->d_attr, r_ptr->d_char);
+       //Term_addstr(-1, TERM_WHITE, "/");
+       Term_add_bigch(r_ptr->x_attr, r_ptr->x_char);
+       //LV
+       if (r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE)){
+               sprintf(buf, " %2d", r_ptr->level);
+       }else{
+               strcpy(buf, " ??");
+       }
+       Term_addstr(-1, TERM_WHITE, buf);
+       //name
+       sprintf(buf, " %s ", r_name+r_ptr->name);
+       Term_addstr(-1, TERM_WHITE, buf);
+       //Term_addstr(-1, TERM_WHITE, look_mon_desc(m_ptr, 0));
+}
+
+ /*
+       max_lines : ºÇÂ粿¹ÔÉÁ²è¤¹¤ë¤«¡¥
+*/
+void print_monster_list(int x, int y, int max_lines){
+       int line = y;
+       monster_type* last_mons = NULL;
+       monster_type* m_ptr = NULL;
+       int n_same = 0;
+       int i;
+
+       for(i=0;i<temp_n;i++){
+               cave_type* c_ptr = &cave[temp_y[i]][temp_x[i]];
+               if(!c_ptr->m_idx || !m_list[c_ptr->m_idx].ml)continue;//no mons or cannot look
+               m_ptr = &m_list[c_ptr->m_idx];
+               if(is_pet(m_ptr))continue;//pet
+               if(!m_ptr->r_idx)continue;//dead?
+               {
+                       /*
+                       int r_idx = m_ptr->ap_r_idx;
+                       monster_race* r_ptr = &r_info[r_idx];
+                       cptr name = (r_name + r_ptr->name);
+                       cptr ename = (r_name + r_ptr->name);
+                       //¥ß¥ß¥Ã¥¯Îà¤ä¡Ö¤½¤ì¡×Åù¤Ï¡¢°ìÍ÷¤Ë½Ð¤Æ¤Ï¤¤¤±¤Ê¤¤
+                       if(r_ptr->flags1&RF1_CHAR_CLEAR)continue;
+                       if((r_ptr->flags1&RF1_NEVER_MOVE)&&(r_ptr->flags2&RF2_CHAR_MULTI))continue;
+                       //¡Ø¥Ì¥ë¡Ù¤Ï¡¢°ìÍ÷¤Ë½Ð¤Æ¤Ï¤¤¤±¤Ê¤¤
+                       if((strcmp(name, "À¸¤±¤ëµõ̵¡Ø¥Ì¥ë¡Ù")==0)||
+                          (strcmp(ename, "Null the Living Void")==0))continue;
+                       //"¶â̵¹¤¤Î»ØÎØ"¤Ï¡¢°ìÍ÷¤Ë½Ð¤Æ¤Ï¤¤¤±¤Ê¤¤
+                       if((strcmp(name, "¶â̵¹¤¤Î»ØÎØ")==0)||
+                               (strcmp(ename, "Plain Gold Ring")==0))continue;
+                       */
+               }
+
+               //¥½¡¼¥ÈºÑ¤ß¤Ê¤Î¤ÇƱ¤¸¥â¥ó¥¹¥¿¡¼¤ÏϢ³¤¹¤ë¡¥¤³¤ì¤òÍøÍѤ·¤ÆƱ¤¸¥â¥ó¥¹¥¿¡¼¤ò¥«¥¦¥ó¥È¡¤¤Þ¤È¤á¤Æɽ¼¨¤¹¤ë¡¥
+               if(!last_mons){//ÀèƬ¥â¥ó¥¹¥¿¡¼
+                       last_mons = m_ptr;
+                       n_same = 1;
+                       continue;
+               }
+               //same race?
+               if(last_mons->ap_r_idx == m_ptr->ap_r_idx){
+                       n_same++;
+                       continue;//ɽ¼¨½èÍý¤ò¼¡¤Ë²ó¤¹
+               }
+               //print last mons info
+               print_monster_line(x, line++, last_mons, n_same);
+               n_same = 1;
+               last_mons = m_ptr;
+               if(line-y-1==max_lines){//»Ä¤ê1¹Ô
+                       break;
+               }
+       }
+       if(line-y-1==max_lines && i!=temp_n){
+               Term_gotoxy(x, line);
+               Term_addstr(-1, TERM_WHITE, "-- and more --");
+       }else{
+               if(last_mons)print_monster_line(x, line++, last_mons, n_same);
+       }
+}
+/*
+ * Hack -- display monster list in sub-windows
+ */
+static void fix_monster_list(void)
+{
+       int j;
+       int w, h;
+
+       /* Scan windows */
+       for (j = 0; j < 8; j++)
+       {
+               term *old = Term;
+
+               /* No window */
+               if (!angband_term[j]) continue;
+
+               /* No relevant flags */
+               if (!(window_flag[j] & (PW_MONSTER_LIST))) continue;
+
+               /* Activate */
+               Term_activate(angband_term[j]);
+               Term_get_size(&w, &h);
+
+               Term_clear();
+
+               target_set_prepare_look();//¥â¥ó¥¹¥¿¡¼°ìÍ÷¤òÀ¸À®¡¤¥½¡¼¥È
+               print_monster_list(0, 0, h);
+
+               /* Fresh */
+               Term_fresh();
+
+               /* Restore */
+               Term_activate(old);
+       }
+}
+
+
+
 
 /*
  * Hack -- display equipment in sub-windows
@@ -2058,9 +2245,9 @@ static void calc_spells(void)
 {
        int                     i, j, k, levels;
        int                     num_allowed;
-       int                     num_boukyaku = 0;
+       int         num_boukyaku = 0;
 
-       magic_type              *s_ptr;
+       const magic_type        *s_ptr;
        int which;
        int bonus = 0;
 
@@ -2191,10 +2378,10 @@ static void calc_spells(void)
                        /* Message */
 #ifdef JP
                        msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
-                                  spell_names[technic2magic(which)-1][j%32], p );
+                                  do_spell(which, j%32, SPELL_NAME), p );
 #else
                        msg_format("You have forgotten the %s of %s.", p,
-                       spell_names[technic2magic(which)-1][j%32]);
+                       do_spell(which, j%32, SPELL_NAME));
 #endif
 
 
@@ -2251,10 +2438,10 @@ static void calc_spells(void)
                        /* Message */
 #ifdef JP
                        msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
-                                  spell_names[technic2magic(which)-1][j%32], p );
+                                  do_spell(which, j%32, SPELL_NAME), p );
 #else
                        msg_format("You have forgotten the %s of %s.", p,
-                                  spell_names[technic2magic(which)-1][j%32]);
+                                  do_spell(which, j%32, SPELL_NAME));
 #endif
 
 
@@ -2327,10 +2514,10 @@ static void calc_spells(void)
                        /* Message */
 #ifdef JP
                        msg_format("%s¤Î%s¤ò»×¤¤½Ð¤·¤¿¡£",
-                                  spell_names[technic2magic(which)-1][j%32], p );
+                                  do_spell(which, j%32, SPELL_NAME), p );
 #else
                        msg_format("You have remembered the %s of %s.",
-                                  p, spell_names[technic2magic(which)-1][j%32]);
+                                  p, do_spell(which, j%32, SPELL_NAME));
 #endif
 
 
@@ -2361,7 +2548,7 @@ static void calc_spells(void)
                        /* Count it */
                        k++;
                }
-               if (k>32) k = 32;
+               if (k > 32) k = 32;
                if ((p_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) p_ptr->new_spells = k;
        }
 
@@ -2478,7 +2665,9 @@ static void calc_mana(void)
                /* Normal gloves hurt mage-type spells */
                if (o_ptr->k_idx &&
                    !(have_flag(flgs, TR_FREE_ACT)) &&
-                   !(have_flag(flgs, TR_MAGIC_MASTERY)) &&
+                       !(have_flag(flgs, TR_DEC_MANA)) &&
+                       !(have_flag(flgs, TR_EASY_SPELL)) &&
+                       !((have_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) &&
                    !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
                {
                        /* Encumbered */
@@ -2784,6 +2973,10 @@ static void calc_hitpoints(void)
        if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
        if (p_ptr->tsuyoshi) mhp += 50;
 
+       /* Factor in the hex spell settings */
+       if (hex_spelling(HEX_XTRA_MIGHT)) mhp += 15;
+       if (hex_spelling(HEX_BUILDING)) mhp += 60;
+
        /* New maximum hitpoints */
        if (p_ptr->mhp != mhp)
        {
@@ -2823,7 +3016,7 @@ static void calc_hitpoints(void)
  */
 static void calc_torch(void)
 {
-       int i;
+       int i, rad;
        object_type *o_ptr;
        u32b flgs[TR_FLAG_SIZE];
 
@@ -2834,69 +3027,34 @@ static void calc_torch(void)
        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
                o_ptr = &inventory[i];
-
-               /* Examine actual lites */
-               if ((i == INVEN_LITE) && (o_ptr->k_idx) && (o_ptr->tval == TV_LITE))
+               /* Skip empty slots */
+               if (!o_ptr->k_idx) continue;
+               
+               if (o_ptr->name2 == EGO_LITE_SHINE) p_ptr->cur_lite++;
+               
+               /* Need Fuels */
+               if (o_ptr->name2 != EGO_LITE_DARKNESS)
                {
-                       if (o_ptr->name2 == EGO_LITE_DARKNESS)
+                       if (o_ptr->tval == TV_LITE)
                        {
-                               if (o_ptr->sval == SV_LITE_TORCH)
-                               {
-                                       p_ptr->cur_lite -= 1;
-                               }
-
-                               /* Lanterns (with fuel) provide more lite */
-                               else if (o_ptr->sval == SV_LITE_LANTERN)
-                               {
-                                       p_ptr->cur_lite -= 2;
-                               }
-
-                               else if (o_ptr->sval == SV_LITE_FEANOR)
-                               {
-                                       p_ptr->cur_lite -= 3;
-                               }
-                       }
-                       /* Torches (with fuel) provide some lite */
-                       else if ((o_ptr->sval == SV_LITE_TORCH) && (o_ptr->xtra4 > 0))
-                       {
-                               p_ptr->cur_lite += 1;
-                       }
-
-                       /* Lanterns (with fuel) provide more lite */
-                       else if ((o_ptr->sval == SV_LITE_LANTERN) && (o_ptr->xtra4 > 0))
-                       {
-                               p_ptr->cur_lite += 2;
-                       }
-
-                       else if (o_ptr->sval == SV_LITE_FEANOR)
-                       {
-                               p_ptr->cur_lite += 2;
+                               if((o_ptr->sval == SV_LITE_TORCH) && !(o_ptr->xtra4 > 0)) continue;
+                               if((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
                        }
-
-                       /* Artifact Lites provide permanent, bright, lite */
-                       else if (artifact_p(o_ptr))
-                       {
-                               p_ptr->cur_lite += 3;
-                       }
-
-                       if (o_ptr->name2 == EGO_LITE_SHINE) p_ptr->cur_lite++;
                }
-               else
-               {
-                       /* Skip empty slots */
-                       if (!o_ptr->k_idx) continue;
 
-                       /* Extract the flags */
-                       object_flags(o_ptr, flgs);
-
-                       /* does this item glow? */
-                       if (have_flag(flgs, TR_LITE))
-                       {
-                               if ((o_ptr->name2 == EGO_DARK) || (o_ptr->name1 == ART_NIGHT)) p_ptr->cur_lite--;
-                               else p_ptr->cur_lite++;
-                       }
-               }
+               /* Extract the flags */
+               object_flags(o_ptr, flgs);
 
+               /* calc the lite_radius */
+               
+               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;
+               if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
+               if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
+               if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
+               p_ptr->cur_lite += rad;
        }
 
        /* max radius is 14 (was 5) without rewriting other code -- */
@@ -2915,21 +3073,12 @@ static void calc_torch(void)
 
        /* end experimental mods */
 
-       /* Reduce lite when running if requested */
-       if (running && view_reduce_lite)
-       {
-               /* Reduce the lite radius if needed */
-               if (p_ptr->cur_lite > 1) p_ptr->cur_lite = 1;
-       }
-
        /* Notice changes in the "lite radius" */
        if (p_ptr->old_lite != p_ptr->cur_lite)
        {
-               /* Update the lite */
-               p_ptr->update |= (PU_LITE);
-
-               /* Update the monsters */
-               p_ptr->update |= (PU_MONSTERS);
+               /* Update stuff */
+               /* Hack -- PU_MON_LITE for monsters' darkness */
+               p_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
 
                /* Remember the old lite */
                p_ptr->old_lite = p_ptr->cur_lite;
@@ -2944,22 +3093,137 @@ static void calc_torch(void)
 /*
  * Computes current weight limit.
  */
-static int weight_limit(void)
+u32b weight_limit(void)
 {
-       int i;
+       u32b i;
 
        /* Weight limit based only on strength */
-       i = adj_str_wgt[p_ptr->stat_ind[A_STR]] * 100;
-       if (p_ptr->pclass == CLASS_BERSERKER) i = i*3/2;
+       i = (u32b)adj_str_wgt[p_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
+       if (p_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
 
        /* Return the result */
-       return (i);
+       return i;
 }
 
 
 bool buki_motteruka(int i)
 {
-       return ((inventory[i].k_idx && inventory[i].tval >= TV_DIGGING && inventory[i].tval <= TV_SWORD) ? TRUE : FALSE);
+       return ((inventory[i].k_idx && object_is_melee_weapon(&inventory[i])) ? TRUE : FALSE);
+}
+
+bool is_heavy_shoot(object_type *o_ptr)
+{
+       int hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
+       /* It is hard to carholdry a heavy bow */
+       return (hold < o_ptr->weight / 10);
+}
+
+int bow_tval_ammo(object_type *o_ptr)
+{
+       /* Analyze the launcher */
+       switch (o_ptr->sval)
+       {
+               case SV_SLING:
+               {
+                       return TV_SHOT;
+               }
+
+               case SV_SHORT_BOW:
+               case SV_LONG_BOW:
+               case SV_NAMAKE_BOW:
+               {
+                       return TV_ARROW;
+               }
+
+               case SV_LIGHT_XBOW:
+               case SV_HEAVY_XBOW:
+               {
+                       return TV_BOLT;
+               }
+               case SV_CRIMSON:
+               {
+                       return TV_NO_AMMO;
+               }
+       }
+       
+       return 0;
+}
+
+/* calcurate the fire rate of target object */
+s16b calc_num_fire(object_type *o_ptr)
+{
+       int extra_shots = 0;
+       int i;
+       int num = 0;
+       int tval_ammo = bow_tval_ammo(o_ptr);
+       object_type *q_ptr;
+       u32b flgs[TR_FLAG_SIZE];
+       
+       /* Scan the usable inventory */
+       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
+       {
+               q_ptr = &inventory[i];
+
+               /* Skip non-objects */
+               if (!q_ptr->k_idx) continue;
+               
+               /* Do not apply current equip */
+               if (i == INVEN_BOW) continue;
+
+               /* Extract the item flags */
+               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(o_ptr))
+       {
+               num = 100;
+               /* Extra shots */
+               num += (extra_shots * 100);
+
+               /* Hack -- Rangers love Bows */
+               if ((p_ptr->pclass == CLASS_RANGER) && 
+                                       (tval_ammo == TV_ARROW))
+               {
+                       num += (p_ptr->lev * 4);
+               }
+
+               if ((p_ptr->pclass == CLASS_CAVALRY) &&
+                   (tval_ammo == TV_ARROW))
+               {
+                       num += (p_ptr->lev * 3);
+               }
+
+               if (p_ptr->pclass == CLASS_ARCHER)
+               {
+                       if (tval_ammo == TV_ARROW)
+                               num += ((p_ptr->lev * 5)+50);
+                       else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
+                               num += (p_ptr->lev * 4);
+               }
+
+               /*
+                * Addendum -- also "Reward" high level warriors,
+                * with _any_ missile weapon -- TY
+                */
+               if (p_ptr->pclass == CLASS_WARRIOR &&
+                  (tval_ammo <= TV_BOLT) &&
+                  (tval_ammo >= TV_SHOT))
+               {
+                       num += (p_ptr->lev * 2);
+               }
+               if ((p_ptr->pclass == CLASS_ROGUE) &&
+                   (tval_ammo == TV_SHOT))
+               {
+                       num += (p_ptr->lev * 4);
+               }
+       }
+       return num;
 }
 
 /*
@@ -2986,24 +3250,9 @@ void calc_bonuses(void)
 {
        int             i, j, hold, neutral[2];
        int             new_speed;
-       bool old_telepathy;
-       bool old_esp_animal;
-       bool old_esp_undead;
-       bool old_esp_demon;
-       bool old_esp_orc;
-       bool old_esp_troll;
-       bool old_esp_giant;
-       bool old_esp_dragon;
-       bool old_esp_human;
-       bool old_esp_evil;
-       bool old_esp_good;
-       bool old_esp_nonliving;
-       bool old_esp_unique;
-       int             old_see_inv;
-       int             old_dis_ac;
-       int             old_dis_to_a;
+       int             default_hand = 0;
+       int             empty_hands_status = empty_hands(TRUE);
        int             extra_blows[2];
-       int             extra_shots;
        object_type     *o_ptr;
        u32b flgs[TR_FLAG_SIZE];
        bool            omoi = FALSE;
@@ -3014,34 +3263,34 @@ void calc_bonuses(void)
 #endif
        bool            have_sw = FALSE, have_kabe = FALSE;
        bool            easy_2weapon = FALSE;
+       bool            riding_levitation = FALSE;
        s16b this_o_idx, next_o_idx = 0;
-       player_race *tmp_rp_ptr;
-
+       const player_race *tmp_rp_ptr;
 
        /* Save the old vision stuff */
-       old_telepathy = p_ptr->telepathy;
-       old_esp_animal = p_ptr->esp_animal;
-       old_esp_undead = p_ptr->esp_undead;
-       old_esp_demon = p_ptr->esp_demon;
-       old_esp_orc = p_ptr->esp_orc;
-       old_esp_troll = p_ptr->esp_troll;
-       old_esp_giant = p_ptr->esp_giant;
-       old_esp_dragon = p_ptr->esp_dragon;
-       old_esp_human = p_ptr->esp_human;
-       old_esp_evil = p_ptr->esp_evil;
-       old_esp_good = p_ptr->esp_good;
-       old_esp_nonliving = p_ptr->esp_nonliving;
-       old_esp_unique = p_ptr->esp_unique;
-
-       old_see_inv = p_ptr->see_inv;
+       bool old_telepathy = p_ptr->telepathy;
+       bool old_esp_animal = p_ptr->esp_animal;
+       bool old_esp_undead = p_ptr->esp_undead;
+       bool old_esp_demon = p_ptr->esp_demon;
+       bool old_esp_orc = p_ptr->esp_orc;
+       bool old_esp_troll = p_ptr->esp_troll;
+       bool old_esp_giant = p_ptr->esp_giant;
+       bool old_esp_dragon = p_ptr->esp_dragon;
+       bool old_esp_human = p_ptr->esp_human;
+       bool old_esp_evil = p_ptr->esp_evil;
+       bool old_esp_good = p_ptr->esp_good;
+       bool old_esp_nonliving = p_ptr->esp_nonliving;
+       bool old_esp_unique = p_ptr->esp_unique;
+       bool old_see_inv = p_ptr->see_inv;
+       bool old_mighty_throw = p_ptr->mighty_throw;
 
        /* Save the old armor class */
-       old_dis_ac = p_ptr->dis_ac;
-       old_dis_to_a = p_ptr->dis_to_a;
+       bool old_dis_ac = p_ptr->dis_ac;
+       bool old_dis_to_a = p_ptr->dis_to_a;
 
 
        /* Clear extra blows/shots */
-       extra_blows[0] = extra_blows[1] = extra_shots = 0;
+       extra_blows[0] = extra_blows[1] = 0;
 
        /* Clear the stat modifiers */
        for (i = 0; i < 6; i++) p_ptr->stat_add[i] = 0;
@@ -3098,7 +3347,7 @@ void calc_bonuses(void)
        p_ptr->slow_digest = FALSE;
        p_ptr->regenerate = FALSE;
        p_ptr->can_swim = FALSE;
-       p_ptr->ffall = FALSE;
+       p_ptr->levitation = FALSE;
        p_ptr->hold_life = FALSE;
        p_ptr->telepathy = FALSE;
        p_ptr->esp_animal = FALSE;
@@ -3145,6 +3394,7 @@ void calc_bonuses(void)
        p_ptr->anti_tele = FALSE;
        p_ptr->warning = FALSE;
        p_ptr->mighty_throw = FALSE;
+       p_ptr->see_nocto = FALSE;
 
        p_ptr->immune_acid = FALSE;
        p_ptr->immune_elec = FALSE;
@@ -3156,7 +3406,7 @@ void calc_bonuses(void)
        p_ptr->hidarite = FALSE;
        p_ptr->no_flowed = FALSE;
 
-       p_ptr->align = 0;
+       p_ptr->align = friend_align;
 
        if (p_ptr->mimic_form) tmp_rp_ptr = &mimic_info[p_ptr->mimic_form];
        else tmp_rp_ptr = &race_info[p_ptr->prace];
@@ -3194,14 +3444,55 @@ void calc_bonuses(void)
        /* Base skill -- digging */
        p_ptr->skill_dig = 0;
 
-       if (buki_motteruka(INVEN_RARM) && (empty_hands(FALSE) & 0x00000001) && ((inventory[INVEN_RARM].weight > 99) || (inventory[INVEN_RARM].tval == TV_POLEARM)) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE))) p_ptr->ryoute = TRUE;
-       if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) == 3) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE))) p_ptr->ryoute = TRUE;
-       if (buki_motteruka(INVEN_RARM) || !buki_motteruka(INVEN_LARM)) p_ptr->migite = TRUE;
-       if (buki_motteruka(INVEN_LARM)) p_ptr->hidarite = TRUE;
+       if (buki_motteruka(INVEN_RARM)) p_ptr->migite = TRUE;
+       if (buki_motteruka(INVEN_LARM))
+       {
+               p_ptr->hidarite = TRUE;
+               if (!p_ptr->migite) default_hand = 1;
+       }
+
+       if (CAN_TWO_HANDS_WIELDING())
+       {
+               if (p_ptr->migite && (empty_hands(FALSE) == EMPTY_HAND_LARM) &&
+                       object_allow_two_hands_wielding(&inventory[INVEN_RARM]))
+               {
+                       p_ptr->ryoute = TRUE;
+               }
+               else if (p_ptr->hidarite && (empty_hands(FALSE) == EMPTY_HAND_RARM) &&
+                       object_allow_two_hands_wielding(&inventory[INVEN_LARM]))
+               {
+                       p_ptr->ryoute = TRUE;
+               }
+               else
+               {
+                       switch (p_ptr->pclass)
+                       {
+                       case CLASS_MONK:
+                       case CLASS_FORCETRAINER:
+                       case CLASS_BERSERKER:
+                               if (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
+                               {
+                                       p_ptr->migite = TRUE;
+                                       p_ptr->ryoute = TRUE;
+                               }
+                               break;
+                       }
+               }
+       }
+
+       if (!p_ptr->migite && !p_ptr->hidarite)
+       {
+               if (empty_hands_status & EMPTY_HAND_RARM) p_ptr->migite = TRUE;
+               else if (empty_hands_status == EMPTY_HAND_LARM)
+               {
+                       p_ptr->hidarite = TRUE;
+                       default_hand = 1;
+               }
+       }
 
        if (p_ptr->special_defense & KAMAE_MASK)
        {
-               if (empty_hands(TRUE) < 2)
+               if (!(empty_hands_status & EMPTY_HAND_RARM))
                {
                        set_action(ACTION_NONE);
                }
@@ -3273,13 +3564,14 @@ void calc_bonuses(void)
                        if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
                        break;
                case CLASS_NINJA:
-                       /* Unencumbered Monks become faster every 10 levels */
+                       /* Unencumbered Ninjas become faster every 10 levels */
                        if (heavy_armor())
                        {
                                new_speed -= (p_ptr->lev) / 10;
                                p_ptr->skill_stl -= (p_ptr->lev)/10;
                        }
-                       else if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
+                       else if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
+                                (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
                        {
                                new_speed += 3;
                                if (!(prace_is_(RACE_KLACKON) ||
@@ -3292,7 +3584,8 @@ void calc_bonuses(void)
                                if  (p_ptr->lev > 24)
                                        p_ptr->free_act = TRUE;
                        }
-                       if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
+                       if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
+                           (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
                        {
                                p_ptr->to_a += p_ptr->lev/2+5;
                                p_ptr->dis_to_a += p_ptr->lev/2+5;
@@ -3307,33 +3600,35 @@ void calc_bonuses(void)
                                p_ptr->oppose_pois = 1;
                                p_ptr->redraw |= PR_STATUS;
                        }
+                       p_ptr->see_nocto = TRUE;
                        break;
        }
 
        /***** Races ****/
        if (p_ptr->mimic_form)
        {
-               switch(p_ptr->mimic_form)
+               switch (p_ptr->mimic_form)
                {
                case MIMIC_DEMON:
-                       p_ptr->hold_life=TRUE;
-                       p_ptr->resist_chaos=TRUE;
-                       p_ptr->resist_neth=TRUE;
-                       p_ptr->resist_fire=TRUE;
+                       p_ptr->hold_life = TRUE;
+                       p_ptr->resist_chaos = TRUE;
+                       p_ptr->resist_neth = TRUE;
+                       p_ptr->resist_fire = TRUE;
                        p_ptr->oppose_fire = 1;
                        p_ptr->see_inv=TRUE;
                        new_speed += 3;
                        p_ptr->redraw |= PR_STATUS;
                        p_ptr->to_a += 10;
                        p_ptr->dis_to_a += 10;
+                       p_ptr->align -= 200;
                        break;
                case MIMIC_DEMON_LORD:
-                       p_ptr->hold_life=TRUE;
-                       p_ptr->resist_chaos=TRUE;
-                       p_ptr->resist_neth=TRUE;
-                       p_ptr->immune_fire=TRUE;
+                       p_ptr->hold_life = TRUE;
+                       p_ptr->resist_chaos = TRUE;
+                       p_ptr->resist_neth = TRUE;
+                       p_ptr->immune_fire = TRUE;
                        p_ptr->resist_acid = TRUE;
-                       p_ptr->resist_fire=TRUE;
+                       p_ptr->resist_fire = TRUE;
                        p_ptr->resist_cold = TRUE;
                        p_ptr->resist_elec = TRUE;
                        p_ptr->resist_pois = TRUE;
@@ -3344,11 +3639,12 @@ void calc_bonuses(void)
                        p_ptr->sh_fire = TRUE;
                        p_ptr->see_inv = TRUE;
                        p_ptr->telepathy = TRUE;
-                       p_ptr->ffall = TRUE;
+                       p_ptr->levitation = TRUE;
                        p_ptr->kill_wall = TRUE;
                        new_speed += 5;
                        p_ptr->to_a += 20;
                        p_ptr->dis_to_a += 20;
+                       p_ptr->align -= 200;
                        break;
                case MIMIC_VAMPIRE:
                        p_ptr->resist_dark = TRUE;
@@ -3366,13 +3662,13 @@ void calc_bonuses(void)
        }
        else
        {
-       switch (p_ptr->prace)
-       {
+               switch (p_ptr->prace)
+               {
                case RACE_ELF:
                        p_ptr->resist_lite = TRUE;
                        break;
                case RACE_HOBBIT:
-                       p_ptr->sustain_dex = TRUE;
+                       p_ptr->hold_life = TRUE;
                        break;
                case RACE_GNOME:
                        p_ptr->free_act = TRUE;
@@ -3450,7 +3746,7 @@ void calc_bonuses(void)
                        if (p_ptr->lev > 19) p_ptr->see_inv = TRUE;
                        break;
                case RACE_DRACONIAN:
-                       p_ptr->ffall = TRUE;
+                       p_ptr->levitation = TRUE;
                        if (p_ptr->lev >  4) p_ptr->resist_fire = TRUE;
                        if (p_ptr->lev >  9) p_ptr->resist_cold = TRUE;
                        if (p_ptr->lev > 14) p_ptr->resist_acid = TRUE;
@@ -3498,7 +3794,7 @@ void calc_bonuses(void)
                        if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
                        break;
                case RACE_SPECTRE:
-                       p_ptr->ffall = TRUE;
+                       p_ptr->levitation = TRUE;
                        p_ptr->free_act = TRUE;
                        p_ptr->resist_neth = TRUE;
                        p_ptr->hold_life = TRUE;
@@ -3510,7 +3806,7 @@ void calc_bonuses(void)
                        if (p_ptr->lev > 34) p_ptr->telepathy = TRUE;
                        break;
                case RACE_SPRITE:
-                       p_ptr->ffall = TRUE;
+                       p_ptr->levitation = TRUE;
                        p_ptr->resist_lite = TRUE;
 
                        /* Sprites become faster */
@@ -3538,28 +3834,29 @@ void calc_bonuses(void)
                        if (p_ptr->lev > 45) p_ptr->stat_add[A_CON]++;
                        break;
                case RACE_ANGEL:
-                       p_ptr->ffall = TRUE;
+                       p_ptr->levitation = TRUE;
                        p_ptr->see_inv = TRUE;
+                       p_ptr->align += 200;
                        break;
                case RACE_DEMON:
                        p_ptr->resist_fire  = TRUE;
                        p_ptr->resist_neth  = TRUE;
                        p_ptr->hold_life = TRUE;
-                       if (p_ptr->lev > 9)
-                               p_ptr->see_inv = TRUE;
+                       if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
                        if (p_ptr->lev > 44)
                        {
                                p_ptr->oppose_fire = 1;
                                p_ptr->redraw |= PR_STATUS;
                        }
+                       p_ptr->align -= 200;
                        break;
                case RACE_DUNADAN:
                        p_ptr->sustain_con = TRUE;
                        break;
                case RACE_S_FAIRY:
-                       p_ptr->ffall = TRUE;
+                       p_ptr->levitation = TRUE;
                        break;
-               case RACE_KUTA:
+               case RACE_KUTAR:
                        p_ptr->resist_conf = TRUE;
                        break;
                case RACE_ANDROID:
@@ -3571,7 +3868,7 @@ void calc_bonuses(void)
                default:
                        /* Do nothing */
                        ;
-       }
+               }
        }
 
        if (p_ptr->ult_res || (p_ptr->special_defense & KATA_MUSOU))
@@ -3580,7 +3877,7 @@ void calc_bonuses(void)
                p_ptr->free_act = TRUE;
                p_ptr->slow_digest = TRUE;
                p_ptr->regenerate = TRUE;
-               p_ptr->ffall = TRUE;
+               p_ptr->levitation = TRUE;
                p_ptr->hold_life = TRUE;
                p_ptr->telepathy = TRUE;
                p_ptr->lite = TRUE;
@@ -3654,16 +3951,10 @@ void calc_bonuses(void)
                        new_speed += (p_ptr->lev) / 10 + 5;
        }
 
-       if (p_ptr->riding)
+       if (music_singing(MUSIC_WALL))
        {
-               if (!(r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_PASS_WALL))
-                       p_ptr->pass_wall = FALSE;
-               if (r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_KILL_WALL)
-                       p_ptr->pass_wall = TRUE;
+               p_ptr->kill_wall = TRUE;
        }
-       if (music_singing(MUSIC_WALL)) p_ptr->kill_wall = TRUE;
-
-       if (p_ptr->kill_wall) p_ptr->pass_wall = TRUE;
 
        /* Hack -- apply racial/class stat maxes */
        /* Apply the racial modifiers */
@@ -3802,7 +4093,7 @@ void calc_bonuses(void)
 
                if (p_ptr->muta3 & MUT3_WINGS)
                {
-                       p_ptr->ffall = TRUE;
+                       p_ptr->levitation = TRUE;
                }
 
                if (p_ptr->muta3 & MUT3_FEARLESS)
@@ -3902,13 +4193,24 @@ void calc_bonuses(void)
                /* Hack -- cause earthquakes */
                if (have_flag(flgs, TR_IMPACT)) p_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
 
-               /* Boost shots */
-               if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
-
                /* Various flags */
                if (have_flag(flgs, TR_AGGRAVATE))   p_ptr->cursed |= TRC_AGGRAVATE;
                if (have_flag(flgs, TR_DRAIN_EXP))   p_ptr->cursed |= TRC_DRAIN_EXP;
                if (have_flag(flgs, TR_TY_CURSE))    p_ptr->cursed |= TRC_TY_CURSE;
+               if (have_flag(flgs, TR_ADD_L_CURSE)) p_ptr->cursed |= TRC_ADD_L_CURSE;
+               if (have_flag(flgs, TR_ADD_H_CURSE)) p_ptr->cursed |= TRC_ADD_H_CURSE;
+               if (have_flag(flgs, TR_DRAIN_HP))    p_ptr->cursed |= TRC_DRAIN_HP;
+               if (have_flag(flgs, TR_DRAIN_MANA))  p_ptr->cursed |= TRC_DRAIN_MANA;
+               if (have_flag(flgs, TR_CALL_ANIMAL)) p_ptr->cursed |= TRC_CALL_ANIMAL;
+               if (have_flag(flgs, TR_CALL_DEMON))  p_ptr->cursed |= TRC_CALL_DEMON;
+               if (have_flag(flgs, TR_CALL_DRAGON)) p_ptr->cursed |= TRC_CALL_DRAGON;
+               if (have_flag(flgs, TR_CALL_UNDEAD)) p_ptr->cursed |= TRC_CALL_UNDEAD;
+               if (have_flag(flgs, TR_COWARDICE))   p_ptr->cursed |= TRC_COWARDICE;
+               if (have_flag(flgs, TR_LOW_MELEE))   p_ptr->cursed |= TRC_LOW_MELEE;
+               if (have_flag(flgs, TR_LOW_AC))      p_ptr->cursed |= TRC_LOW_AC;
+               if (have_flag(flgs, TR_LOW_MAGIC))   p_ptr->cursed |= TRC_LOW_MAGIC;
+               if (have_flag(flgs, TR_FAST_DIGEST)) p_ptr->cursed |= TRC_FAST_DIGEST;
+               if (have_flag(flgs, TR_SLOW_REGEN))  p_ptr->cursed |= TRC_SLOW_REGEN;
                if (have_flag(flgs, TR_DEC_MANA))    p_ptr->dec_mana = TRUE;
                if (have_flag(flgs, TR_BLESSED))     p_ptr->bless_blade = TRUE;
                if (have_flag(flgs, TR_XTRA_MIGHT))  p_ptr->xtra_might = TRUE;
@@ -3929,27 +4231,25 @@ void calc_bonuses(void)
                if (have_flag(flgs, TR_ESP_UNIQUE))  p_ptr->esp_unique = TRUE;
 
                if (have_flag(flgs, TR_SEE_INVIS))   p_ptr->see_inv = TRUE;
-               if (have_flag(flgs, TR_FEATHER))     p_ptr->ffall = TRUE;
+               if (have_flag(flgs, TR_LEVITATION))     p_ptr->levitation = TRUE;
                if (have_flag(flgs, TR_FREE_ACT))    p_ptr->free_act = TRUE;
                if (have_flag(flgs, TR_HOLD_LIFE))   p_ptr->hold_life = TRUE;
                if (have_flag(flgs, TR_WARNING)){
-                       if (!o_ptr->inscription || !(strchr(quark_str(o_ptr->inscription),'$')))
+                       if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription),'$')))
                          p_ptr->warning = TRUE;
                }
 
                if (have_flag(flgs, TR_TELEPORT))
                {
-                       if (cursed_p(o_ptr)) p_ptr->cursed |= TRC_TELEPORT;
+                       if (object_is_cursed(o_ptr)) p_ptr->cursed |= TRC_TELEPORT;
                        else
                        {
                                cptr insc = quark_str(o_ptr->inscription);
 
-                               if (o_ptr->inscription &&
-                                   (strchr(insc, '.') || strchr(insc, '%')))
+                               if (o_ptr->inscription && my_strchr(insc, '.'))
                                {
                                        /*
                                         * {.} will stop random teleportation.
-                                        * {%} includes '.' after conversion.
                                         */
                                }
                                else
@@ -4031,7 +4331,7 @@ void calc_bonuses(void)
                p_ptr->to_a += o_ptr->to_a;
 
                /* Apply the mental bonuses to armor class, if known */
-               if (object_known_p(o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
+               if (object_is_known(o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
 
                if (o_ptr->curse_flags & TRC_LOW_MELEE)
                {
@@ -4102,7 +4402,7 @@ void calc_bonuses(void)
                p_ptr->to_d_m += bonus_to_d;
 
                /* Apply the mental bonuses tp hit/damage, if known */
-               if (object_known_p(o_ptr)) p_ptr->dis_to_h_b += bonus_to_h;
+               if (object_is_known(o_ptr)) p_ptr->dis_to_h_b += bonus_to_h;
 
                /* To Melee */
                if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !p_ptr->ryoute)
@@ -4112,7 +4412,7 @@ void calc_bonuses(void)
                        p_ptr->to_d[i-INVEN_RIGHT] += bonus_to_d;
 
                        /* Apply the mental bonuses tp hit/damage, if known */
-                       if (object_known_p(o_ptr))
+                       if (object_is_known(o_ptr))
                        {
                                p_ptr->dis_to_h[i-INVEN_RIGHT] += bonus_to_h;
                                p_ptr->dis_to_d[i-INVEN_RIGHT] += bonus_to_d;
@@ -4127,7 +4427,7 @@ void calc_bonuses(void)
                        p_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d/2 : bonus_to_d;
 
                        /* Apply the mental bonuses tp hit/damage, if known */
-                       if (object_known_p(o_ptr))
+                       if (object_is_known(o_ptr))
                        {
                                p_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h+1)/2 : bonus_to_h;
                                p_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h/2 : bonus_to_h;
@@ -4138,18 +4438,24 @@ void calc_bonuses(void)
                else
                {
                        /* Apply the bonuses to hit/damage */
-                       p_ptr->to_h[0] += bonus_to_h;
-                       p_ptr->to_d[0] += bonus_to_d;
+                       p_ptr->to_h[default_hand] += bonus_to_h;
+                       p_ptr->to_d[default_hand] += bonus_to_d;
 
-                       /* Apply the mental bonuses tp hit/damage, if known */
-                       if (object_known_p(o_ptr))
+                       /* Apply the mental bonuses to hit/damage, if known */
+                       if (object_is_known(o_ptr))
                        {
-                               p_ptr->dis_to_h[0] += bonus_to_h;
-                               p_ptr->dis_to_d[0] += bonus_to_d;
+                               p_ptr->dis_to_h[default_hand] += bonus_to_h;
+                               p_ptr->dis_to_d[default_hand] += bonus_to_d;
                        }
                }
        }
 
+       if (old_mighty_throw != p_ptr->mighty_throw)
+       {
+               /* Redraw average damege display of Shuriken */
+               p_ptr->window |= PW_INVEN;
+       }
+
        if (p_ptr->cursed & TRC_TELEPORT) p_ptr->cursed &= ~(TRC_TELEPORT_SELF);
 
        /* Monks get extra ac for armour _not worn_ */
@@ -4229,6 +4535,49 @@ void calc_bonuses(void)
                p_ptr->dis_to_a += 10 + (p_ptr->lev * 2 / 5);
        }
 
+       /* Hex bonuses */
+       if (p_ptr->realm1 == REALM_HEX)
+       {
+               if (hex_spelling_any()) p_ptr->skill_stl -= (1 + p_ptr->magic_num2[0]);
+               if (hex_spelling(HEX_DETECT_EVIL)) p_ptr->esp_evil = TRUE;
+               if (hex_spelling(HEX_XTRA_MIGHT)) p_ptr->stat_add[A_STR] += 4;
+               if (hex_spelling(HEX_BUILDING))
+               {
+                       p_ptr->stat_add[A_STR] += 4;
+                       p_ptr->stat_add[A_DEX] += 4;
+                       p_ptr->stat_add[A_CON] += 4;
+               }
+               if (hex_spelling(HEX_DEMON_AURA))
+               {
+                       p_ptr->sh_fire = TRUE;
+                       p_ptr->regenerate = TRUE;
+               }
+               if (hex_spelling(HEX_ICE_ARMOR))
+               {
+                       p_ptr->sh_cold = TRUE; 
+                       p_ptr->to_a += 30;
+                       p_ptr->dis_to_a += 30;
+               }
+               if (hex_spelling(HEX_SHOCK_CLOAK))
+               {
+                       p_ptr->sh_elec = TRUE;
+                       new_speed += 3;
+               }
+               for (i = INVEN_RARM; i <= INVEN_FEET; i++)
+               {
+                       int ac = 0;
+                       o_ptr = &inventory[i];
+                       if (!o_ptr->k_idx) continue;
+                       if (!object_is_armour(o_ptr)) continue;
+                       if (!object_is_cursed(o_ptr)) continue;
+                       ac += 5;
+                       if (o_ptr->curse_flags & TRC_HEAVY_CURSE) ac += 7;
+                       if (o_ptr->curse_flags & TRC_PERMA_CURSE) ac += 13;
+                       p_ptr->to_a += ac;
+                       p_ptr->dis_to_a += ac;
+               }
+       }
+
        /* Calculate stats */
        for (i = 0; i < 6; i++)
        {
@@ -4363,10 +4712,16 @@ void calc_bonuses(void)
                p_ptr->dis_to_d[1] -= 5;
        }
 
-       /* wraith_form */
+       /* Wraith form */
        if (p_ptr->wraith_form)
        {
                p_ptr->reflect = TRUE;
+               p_ptr->pass_wall = TRUE;
+       }
+
+       if (p_ptr->kabenuke)
+       {
+               p_ptr->pass_wall = TRUE;
        }
 
        /* Temporary blessing */
@@ -4389,7 +4744,7 @@ void calc_bonuses(void)
                p_ptr->resist_conf = TRUE;
                p_ptr->reflect = TRUE;
                p_ptr->free_act = TRUE;
-               p_ptr->ffall = TRUE;
+               p_ptr->levitation = TRUE;
        }
 
        /* Temporary "Hero" */
@@ -4479,9 +4834,9 @@ void calc_bonuses(void)
        }
 
        /* Temporary levitation */
-       if (p_ptr->tim_ffall)
+       if (p_ptr->tim_levitation)
        {
-               p_ptr->ffall = TRUE;
+               p_ptr->levitation = TRUE;
        }
 
        /* Temporary reflection */
@@ -4530,10 +4885,11 @@ void calc_bonuses(void)
 
        if (p_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
 
-       if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
+       if ((p_ptr->migite && (empty_hands_status & EMPTY_HAND_RARM)) ||
+           (p_ptr->hidarite && (empty_hands_status & EMPTY_HAND_LARM)))
        {
-               p_ptr->to_h[0] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
-               p_ptr->dis_to_h[0] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
+               p_ptr->to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
+               p_ptr->dis_to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
        }
 
        if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
@@ -4584,13 +4940,18 @@ void calc_bonuses(void)
        /* Extract the current weight (in tenth pounds) */
        j = p_ptr->total_weight;
 
-       /* Extract the "weight limit" (in tenth pounds) */
-       i = weight_limit();
-
-       if (p_ptr->riding)
+       if (!p_ptr->riding)
+       {
+               /* Extract the "weight limit" (in tenth pounds) */
+               i = (int)weight_limit();
+       }
+       else
        {
-               int speed = m_list[p_ptr->riding].mspeed;
-               if (m_list[p_ptr->riding].mspeed > 110)
+               monster_type *riding_m_ptr = &m_list[p_ptr->riding];
+               monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
+               int speed = riding_m_ptr->mspeed;
+
+               if (riding_m_ptr->mspeed > 110)
                {
                        new_speed = 110 + (s16b)((speed - 110) * (p_ptr->skill_exp[GINOU_RIDING] * 3 + p_ptr->lev * 160L - 10000L) / (22000L));
                        if (new_speed < 110) new_speed = 110;
@@ -4599,18 +4960,23 @@ void calc_bonuses(void)
                {
                        new_speed = speed;
                }
-               if (m_list[p_ptr->riding].fast) new_speed += 10;
-               if (m_list[p_ptr->riding].slow) new_speed -= 10;
-               if (r_info[m_list[p_ptr->riding].r_idx].flags7 & RF7_CAN_FLY) p_ptr->ffall = TRUE;
-               if (r_info[m_list[p_ptr->riding].r_idx].flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) p_ptr->can_swim = TRUE;
+               new_speed += (p_ptr->skill_exp[GINOU_RIDING] + p_ptr->lev *160L)/3200;
+               if (MON_FAST(riding_m_ptr)) new_speed += 10;
+               if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
+               riding_levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
+               if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) p_ptr->can_swim = TRUE;
+
+               if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) p_ptr->pass_wall = FALSE;
+               if (riding_r_ptr->flags2 & RF2_KILL_WALL) p_ptr->kill_wall = TRUE;
 
                if (p_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED) j += (p_ptr->wt * 3 * (RIDING_EXP_SKILLED - p_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
 
-               i = 3000 + r_info[m_list[p_ptr->riding].r_idx].level * 50;
+               /* Extract the "weight limit" */
+               i = 1500 + riding_r_ptr->level * 25;
        }
 
        /* XXX XXX XXX Apply "encumbrance" from weight */
-       if (j > i/2) new_speed -= ((j - (i/2)) / (i / 10));
+       if (j > i) new_speed -= ((j - i) / (i / 5));
 
        /* Searching slows the player down */
        if (p_ptr->action == ACTION_SEARCH) new_speed -= 10;
@@ -4648,96 +5014,32 @@ void calc_bonuses(void)
        /* Examine the "current bow" */
        o_ptr = &inventory[INVEN_BOW];
 
-
-       /* Assume not heavy */
-       p_ptr->heavy_shoot = FALSE;
-
        /* It is hard to carholdry a heavy bow */
-       if (hold < o_ptr->weight / 10)
+       p_ptr->heavy_shoot = is_heavy_shoot(o_ptr);
+       if (p_ptr->heavy_shoot)
        {
                /* Hard to wield a heavy bow */
                p_ptr->to_h_b  += 2 * (hold - o_ptr->weight / 10);
                p_ptr->dis_to_h_b  += 2 * (hold - o_ptr->weight / 10);
-
-               /* Heavy Bow */
-               p_ptr->heavy_shoot = TRUE;
        }
 
-
        /* Compute "extra shots" if needed */
        if (o_ptr->k_idx)
        {
-               /* Analyze the launcher */
-               switch (o_ptr->sval)
-               {
-                       case SV_SLING:
-                       {
-                               p_ptr->tval_ammo = TV_SHOT;
-                               break;
-                       }
-
-                       case SV_SHORT_BOW:
-                       case SV_LONG_BOW:
-                       case SV_NAMAKE_BOW:
-                       {
-                               p_ptr->tval_ammo = TV_ARROW;
-                               break;
-                       }
-
-                       case SV_LIGHT_XBOW:
-                       case SV_HEAVY_XBOW:
-                       {
-                               p_ptr->tval_ammo = TV_BOLT;
-                               break;
-                       }
-                       case SV_CRIMSON:
-                       {
-                               p_ptr->tval_ammo = TV_NO_AMMO;
-                               break;
-                       }
-               }
+               p_ptr->tval_ammo = bow_tval_ammo(o_ptr);
 
                /* Apply special flags */
                if (o_ptr->k_idx && !p_ptr->heavy_shoot)
                {
                        /* Extra shots */
-                       p_ptr->num_fire += (extra_shots * 100);
+                       p_ptr->num_fire = calc_num_fire(o_ptr);
 
-                       /* Hack -- Rangers love Bows */
-                       if ((p_ptr->pclass == CLASS_RANGER) &&
-                           (p_ptr->tval_ammo == TV_ARROW))
+                       /* Snipers love Cross bows */
+                       if ((p_ptr->pclass == CLASS_SNIPER) &&
+                               (p_ptr->tval_ammo == TV_BOLT))
                        {
-                               p_ptr->num_fire += (p_ptr->lev * 4);
-                       }
-
-                       if ((p_ptr->pclass == CLASS_CAVALRY) &&
-                           (p_ptr->tval_ammo == TV_ARROW))
-                       {
-                               p_ptr->num_fire += (p_ptr->lev * 3);
-                       }
-
-                       if (p_ptr->pclass == CLASS_ARCHER)
-                       {
-                               if (p_ptr->tval_ammo == TV_ARROW)
-                                       p_ptr->num_fire += ((p_ptr->lev * 5)+50);
-                               else if ((p_ptr->tval_ammo == TV_BOLT) || (p_ptr->tval_ammo == TV_SHOT))
-                                       p_ptr->num_fire += (p_ptr->lev * 4);
-                       }
-
-                       /*
-                        * Addendum -- also "Reward" high level warriors,
-                        * with _any_ missile weapon -- TY
-                        */
-                       if (p_ptr->pclass == CLASS_WARRIOR &&
-                          (p_ptr->tval_ammo <= TV_BOLT) &&
-                          (p_ptr->tval_ammo >= TV_SHOT))
-                       {
-                               p_ptr->num_fire += (p_ptr->lev * 2);
-                       }
-                       if ((p_ptr->pclass == CLASS_ROGUE) &&
-                           (p_ptr->tval_ammo == TV_SHOT))
-                       {
-                               p_ptr->num_fire += (p_ptr->lev * 4);
+                               p_ptr->to_h_b += (10 + (p_ptr->lev / 5));
+                               p_ptr->dis_to_h_b += (10 + (p_ptr->lev / 5));
                        }
                }
        }
@@ -4800,7 +5102,7 @@ void calc_bonuses(void)
                                case CLASS_BLUE_MAGE:
                                        num = 3; wgt = 100; mul = 2; break;
 
-                               /* Priest, Mindcrafter */
+                               /* Priest, Mindcrafter, Magic-Eater */
                                case CLASS_PRIEST:
                                case CLASS_MAGIC_EATER:
                                case CLASS_MINDCRAFTER:
@@ -4819,7 +5121,7 @@ void calc_bonuses(void)
                                case CLASS_SAMURAI:
                                        num = 5; wgt = 70; mul = 4; break;
 
-                               /* Kaji */
+                               /* Weaponsmith */
                                case CLASS_SMITH:
                                        num = 5; wgt = 150; mul = 5; break;
 
@@ -4848,6 +5150,7 @@ void calc_bonuses(void)
                                case CLASS_BEASTMASTER:
                                        num = 5; wgt = 70; mul = 3; break;
 
+                               /* Cavalry */
                                case CLASS_CAVALRY:
                                        if ((p_ptr->riding) && (have_flag(flgs, TR_RIDING))) {num = 5; wgt = 70; mul = 4;}
                                        else {num = 5; wgt = 100; mul = 3;}
@@ -4857,9 +5160,10 @@ void calc_bonuses(void)
                                case CLASS_SORCERER:
                                        num = 1; wgt = 1; mul = 1; break;
 
-                               /* Archer, Magic eater */
+                               /* Archer, Bard, Sniper */
                                case CLASS_ARCHER:
                                case CLASS_BARD:
+                               case CLASS_SNIPER:
                                        num = 4; wgt = 70; mul = 2; break;
 
                                /* ForceTrainer */
@@ -4875,6 +5179,9 @@ void calc_bonuses(void)
                                        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; }
+
                        /* Enforce a minimum "weight" (tenth pounds) */
                        div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
 
@@ -4944,7 +5251,7 @@ void calc_bonuses(void)
                        p_ptr->to_d[i] += p_ptr->lev/6;
                        p_ptr->dis_to_h[i] += p_ptr->lev/5;
                        p_ptr->dis_to_d[i] += p_ptr->lev/6;
-                       if (!p_ptr->hidarite || p_ptr->ryoute)
+                       if (((i == 0) && !p_ptr->hidarite) || p_ptr->ryoute)
                        {
                                p_ptr->to_h[i] += p_ptr->lev/5;
                                p_ptr->to_d[i] += p_ptr->lev/6;
@@ -4978,6 +5285,23 @@ void calc_bonuses(void)
                                p_ptr->dis_to_d[i] -= 10;
                        }
                }
+               /* Hex bonuses */
+               if (p_ptr->realm1 == REALM_HEX)
+               {
+                       if (object_is_cursed(o_ptr))
+                       {
+                               if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
+                               if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_h[i] += 7; p_ptr->dis_to_h[i] += 7; }
+                               if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_h[i] += 13; p_ptr->dis_to_h[i] += 13; }
+                               if (o_ptr->curse_flags & (TRC_TY_CURSE)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
+                               if (hex_spelling(HEX_RUNESWORD))
+                               {
+                                       if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_d[i] += 5; p_ptr->dis_to_d[i] += 5; }
+                                       if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_d[i] += 7; p_ptr->dis_to_d[i] += 7; }
+                                       if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_d[i] += 13; p_ptr->dis_to_d[i] += 13; }
+                               }
+                       }
+               }
                if (p_ptr->riding)
                {
                        if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
@@ -5013,7 +5337,20 @@ void calc_bonuses(void)
                int penalty = 0;
 
                p_ptr->riding_ryoute = FALSE;
-               if (p_ptr->ryoute || !empty_hands(FALSE)) p_ptr->riding_ryoute = TRUE;
+
+               if (p_ptr->ryoute || (empty_hands(FALSE) == EMPTY_HAND_NONE)) p_ptr->riding_ryoute = TRUE;
+               else if (p_ptr->pet_extra_flags & PF_RYOUTE)
+               {
+                       switch (p_ptr->pclass)
+                       {
+                       case CLASS_MONK:
+                       case CLASS_FORCETRAINER:
+                       case CLASS_BERSERKER:
+                               if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
+                                       p_ptr->riding_ryoute = TRUE;
+                               break;
+                       }
+               }
 
                if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
                {
@@ -5031,7 +5368,8 @@ void calc_bonuses(void)
        }
 
        /* Different calculation for monks with empty hands */
-       if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) > 1))
+       if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) &&
+               (empty_hands_status & EMPTY_HAND_RARM) && !p_ptr->hidarite)
        {
                int blow_base = p_ptr->lev + adj_dex_blow[p_ptr->stat_ind[A_DEX]];
                p_ptr->num_blow[0] = 0;
@@ -5088,7 +5426,7 @@ void calc_bonuses(void)
                        p_ptr->sh_fire = TRUE;
                        p_ptr->sh_elec = TRUE;
                        p_ptr->sh_cold = TRUE;
-                       p_ptr->ffall = TRUE;
+                       p_ptr->levitation = TRUE;
                }
                else if (p_ptr->special_defense & KAMAE_GENBU)
                {
@@ -5107,12 +5445,14 @@ void calc_bonuses(void)
                        p_ptr->dis_to_h[0] -= (p_ptr->lev / 3);
                        p_ptr->dis_to_d[0] -= (p_ptr->lev / 6);
                        p_ptr->num_blow[0] /= 2;
-                       p_ptr->ffall = TRUE;
+                       p_ptr->levitation = TRUE;
                }
 
                p_ptr->num_blow[0] += 1+extra_blows[0];
        }
 
+       if (p_ptr->riding) p_ptr->levitation = riding_levitation;
+
        monk_armour_aux = FALSE;
 
        if (heavy_armor())
@@ -5120,26 +5460,23 @@ void calc_bonuses(void)
                monk_armour_aux = TRUE;
        }
 
-       for (i = 0 ; i < 2 ; i++)
+       for (i = 0; i < 2; i++)
        {
                if (buki_motteruka(INVEN_RARM+i))
                {
-                       int tval = inventory[INVEN_RARM+i].tval - TV_BOW;
+                       int tval = inventory[INVEN_RARM+i].tval - TV_WEAPON_BEGIN;
                        int sval = inventory[INVEN_RARM+i].sval;
 
                        p_ptr->to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
                        p_ptr->dis_to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
-                       if ((p_ptr->pclass == CLASS_MONK) && !(s_info[CLASS_MONK].w_max[tval][sval]))
-                       {
-                               p_ptr->to_h[i] -= 40;
-                               p_ptr->dis_to_h[i] -= 40;
-                               p_ptr->icky_wield[i] = TRUE;
-                       }
-                       else if ((p_ptr->pclass == CLASS_FORCETRAINER) && !(s_info[CLASS_FORCETRAINER].w_max[tval][sval]))
+                       if ((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER))
                        {
-                               p_ptr->to_h[i] -= 40;
-                               p_ptr->dis_to_h[i] -= 40;
-                               p_ptr->icky_wield[i] = TRUE;
+                               if (!s_info[p_ptr->pclass].w_max[tval][sval])
+                               {
+                                       p_ptr->to_h[i] -= 40;
+                                       p_ptr->dis_to_h[i] -= 40;
+                                       p_ptr->icky_wield[i] = TRUE;
+                               }
                        }
                        else if (p_ptr->pclass == CLASS_NINJA)
                        {
@@ -5152,6 +5489,8 @@ void calc_bonuses(void)
                                        if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
                                }
                        }
+
+                       if (inventory[INVEN_RARM + i].name1 == ART_IRON_BALL) p_ptr->align -= 1000;
                }
        }
 
@@ -5197,13 +5536,13 @@ void calc_bonuses(void)
                bonus_to_d = ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128)/2;
                bonus_to_h = ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128) + ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
 
-               p_ptr->to_h[0] += MAX(bonus_to_h,1);
-               p_ptr->dis_to_h[0] += MAX(bonus_to_h,1);
-               p_ptr->to_d[0] += MAX(bonus_to_d,1);
-               p_ptr->dis_to_d[0] += MAX(bonus_to_d,1);
+               p_ptr->to_h[default_hand] += MAX(bonus_to_h,1);
+               p_ptr->dis_to_h[default_hand] += MAX(bonus_to_h,1);
+               p_ptr->to_d[default_hand] += MAX(bonus_to_d,1);
+               p_ptr->dis_to_d[default_hand] += MAX(bonus_to_d,1);
        }
 
-       if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) == 3)) p_ptr->ryoute = FALSE;
+       if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))) p_ptr->ryoute = FALSE;
 
        /* Affect Skill -- stealth (bonus one) */
        p_ptr->skill_stl += 1;
@@ -5278,6 +5617,44 @@ void calc_bonuses(void)
        if (p_ptr->immune_fire) p_ptr->resist_fire = TRUE;
        if (p_ptr->immune_cold) p_ptr->resist_cold = TRUE;
 
+       /* Determine player alignment */
+       for (i = 0, j = 0; i < 8; i++)
+       {
+               switch (p_ptr->vir_types[i])
+               {
+               case V_JUSTICE:
+                       p_ptr->align += p_ptr->virtues[i] * 2;
+                       break;
+               case V_CHANCE:
+                       /* Do nothing */
+                       break;
+               case V_NATURE:
+               case V_HARMONY:
+                       neutral[j++] = i;
+                       break;
+               case V_UNLIFE:
+                       p_ptr->align -= p_ptr->virtues[i];
+                       break;
+               default:
+                       p_ptr->align += p_ptr->virtues[i];
+                       break;
+               }
+       }
+
+       for (i = 0; i < j; i++)
+       {
+               if (p_ptr->align > 0)
+               {
+                       p_ptr->align -= p_ptr->virtues[neutral[i]] / 2;
+                       if (p_ptr->align < 0) p_ptr->align = 0;
+               }
+               else if (p_ptr->align < 0)
+               {
+                       p_ptr->align += p_ptr->virtues[neutral[i]] / 2;
+                       if (p_ptr->align > 0) p_ptr->align = 0;
+               }
+       }
+
        /* Hack -- handle "xtra" mode */
        if (character_xtra) return;
 
@@ -5317,7 +5694,7 @@ void calc_bonuses(void)
                p_ptr->old_heavy_shoot = p_ptr->heavy_shoot;
        }
 
-       for(i = 0 ; i < 2 ; i++)
+       for (i = 0 ; i < 2 ; i++)
        {
                /* Take note when "heavy weapon" changes */
                if (p_ptr->old_heavy_wield[i] != p_ptr->heavy_wield[i])
@@ -5445,7 +5822,7 @@ void calc_bonuses(void)
                if (p_ptr->riding_ryoute)
                {
 #ifdef JP
-                       msg_print("ξ¼ê¤¬¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ÆÇϤòÁà¤ì¤Ê¤¤¡£");
+                       msg_format("%sÇϤòÁà¤ì¤Ê¤¤¡£", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "ξ¼ê¤¬¤Õ¤µ¤¬¤Ã¤Æ¤¤¤Æ" : "");
 #else
                        msg_print("You are using both hand for fighting, and you can't control a riding pet.");
 #endif
@@ -5453,7 +5830,7 @@ void calc_bonuses(void)
                else
                {
 #ifdef JP
-                       msg_print("¼ê¤¬¶õ¤¤¤ÆÇϤòÁà¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
+                       msg_format("%sÇϤòÁà¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "¼ê¤¬¶õ¤¤¤Æ" : "");
 #else
                        msg_print("You began to control riding pet with one hand.");
 #endif
@@ -5487,39 +5864,6 @@ msg_print("
                monk_notify_aux = monk_armour_aux;
        }
 
-       j = 0;
-       p_ptr->align = friend_align;
-
-       /* Determine player alignment */
-       for (i = 0; i < 8; i++)
-       {
-               if ((p_ptr->vir_types[i] == V_HARMONY) || (p_ptr->vir_types[i] == V_NATURE))
-               {
-                       neutral[j] = i;
-                       j++;
-               }
-               else if (p_ptr->vir_types[i] == V_UNLIFE) p_ptr->align -= p_ptr->virtues[i];
-               else if (p_ptr->vir_types[i] == V_JUSTICE) p_ptr->align += (p_ptr->virtues[i]*2);
-               else if (p_ptr->vir_types[i] != V_CHANCE) p_ptr->align += p_ptr->virtues[i];
-       }
-       if ((inventory[INVEN_RARM].name1 == ART_IRON_BALL) || (inventory[INVEN_LARM].name1 == ART_IRON_BALL)) p_ptr->align -= 1000;
-       if (prace_is_(RACE_ANGEL)) p_ptr->align += 200;
-       if ((prace_is_(RACE_DEMON)) || (p_ptr->mimic_form == MIMIC_DEMON_LORD) || (p_ptr->mimic_form == MIMIC_DEMON)) p_ptr->align -= 200;
-       while (j)
-       {
-               j--;
-               if (p_ptr->align > 0)
-               {
-                       p_ptr->align -= (p_ptr->virtues[neutral[j]]/2);
-                       if (p_ptr->align < 0) p_ptr->align = 0;
-               }
-               else if (p_ptr->align < 0)
-               {
-                       p_ptr->align += (p_ptr->virtues[neutral[j]]/2);
-                       if (p_ptr->align > 0) p_ptr->align = 0;
-               }
-       }
-
        for (i = 0; i < INVEN_PACK; i++)
        {
 #if 0
@@ -5527,7 +5871,7 @@ msg_print("
                if ((inventory[i].tval == TV_TRUMP_BOOK) && (inventory[i].sval == 1)) have_dd_t = TRUE;
 #endif
                if ((inventory[i].tval == TV_NATURE_BOOK) && (inventory[i].sval == 2)) have_sw = TRUE;
-               if ((inventory[i].tval == TV_ENCHANT_BOOK) && (inventory[i].sval == 2)) have_kabe = TRUE;
+               if ((inventory[i].tval == TV_CRAFT_BOOK) && (inventory[i].sval == 2)) have_kabe = TRUE;
        }
        for (this_o_idx = cave[py][px].o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
@@ -5544,32 +5888,32 @@ msg_print("
                if ((o_ptr->tval == TV_TRUMP_BOOK) && (o_ptr->sval == 1)) have_dd_t = TRUE;
 #endif
                if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
-               if ((o_ptr->tval == TV_ENCHANT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
+               if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
        }
 
-       if ((p_ptr->pass_wall && !p_ptr->kill_wall) || p_ptr->kabenuke || p_ptr->wraith_form) p_ptr->no_flowed = TRUE;
+       if (p_ptr->pass_wall && !p_ptr->kill_wall) p_ptr->no_flowed = TRUE;
 #if 0
        if (have_dd_s && ((p_ptr->realm1 == REALM_SORCERY) || (p_ptr->realm2 == REALM_SORCERY) || (p_ptr->pclass == CLASS_SORCERER)))
        {
-               magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY-1][SPELL_DD_S];
+               const magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY-1][SPELL_DD_S];
                if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
        }
 
        if (have_dd_t && ((p_ptr->realm1 == REALM_TRUMP) || (p_ptr->realm2 == REALM_TRUMP) || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)))
        {
-               magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP-1][SPELL_DD_T];
+               const magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP-1][SPELL_DD_T];
                if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
        }
 #endif
        if (have_sw && ((p_ptr->realm1 == REALM_NATURE) || (p_ptr->realm2 == REALM_NATURE) || (p_ptr->pclass == CLASS_SORCERER)))
        {
-               magic_type *s_ptr = &mp_ptr->info[REALM_NATURE-1][SPELL_SW];
+               const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE-1][SPELL_SW];
                if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
        }
 
-       if (have_kabe && ((p_ptr->realm1 == REALM_ENCHANT) || (p_ptr->realm2 == REALM_ENCHANT) || (p_ptr->pclass == CLASS_SORCERER)))
+       if (have_kabe && ((p_ptr->realm1 == REALM_CRAFT) || (p_ptr->realm2 == REALM_CRAFT) || (p_ptr->pclass == CLASS_SORCERER)))
        {
-               magic_type *s_ptr = &mp_ptr->info[REALM_ENCHANT-1][SPELL_KABE];
+               const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT-1][SPELL_KABE];
                if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
        }
 }
@@ -5589,7 +5933,7 @@ void notice_stuff(void)
        if (p_ptr->notice & (PN_AUTODESTROY))
        {
                p_ptr->notice &= ~(PN_AUTODESTROY);
-               delayed_auto_destroy();
+               autopick_delayed_alter();
        }
 
        /* Combine the pack */
@@ -5849,13 +6193,13 @@ void redraw_stuff(void)
        if (p_ptr->redraw & (PR_HEALTH))
        {
                p_ptr->redraw &= ~(PR_HEALTH);
-               health_redraw();
+               health_redraw(FALSE);
        }
 
        if (p_ptr->redraw & (PR_UHEALTH))
        {
                p_ptr->redraw &= ~(PR_UHEALTH);
-               riding_health_redraw();
+               health_redraw(TRUE);
        }
 
 
@@ -5864,7 +6208,7 @@ void redraw_stuff(void)
                p_ptr->redraw &= ~(PR_EXTRA);
                p_ptr->redraw &= ~(PR_CUT | PR_STUN);
                p_ptr->redraw &= ~(PR_HUNGER);
-               p_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_MANE | PR_STATUS);
+               p_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_IMITATION | PR_STATUS);
                prt_frame_extra();
        }
 
@@ -5900,10 +6244,10 @@ void redraw_stuff(void)
 
        if (p_ptr->pclass == CLASS_IMITATOR)
        {
-               if (p_ptr->redraw & (PR_MANE))
+               if (p_ptr->redraw & (PR_IMITATION))
                {
-                       p_ptr->redraw &= ~(PR_MANE);
-                       prt_mane();
+                       p_ptr->redraw &= ~(PR_IMITATION);
+                       prt_imitation();
                }
        }
        else if (p_ptr->redraw & (PR_STUDY))
@@ -5968,7 +6312,14 @@ void window_stuff(void)
                p_ptr->window &= ~(PW_PLAYER);
                fix_player();
        }
-
+       
+       /* Display monster list */
+       if (p_ptr->window & (PW_MONSTER_LIST))
+       {
+               p_ptr->window &= ~(PW_MONSTER_LIST);
+               fix_monster_list();
+       }
+       
        /* Display overhead view */
        if (p_ptr->window & (PW_MESSAGE))
        {
@@ -6022,14 +6373,20 @@ void handle_stuff(void)
 }
 
 
-s16b empty_hands(bool is_monk)
+s16b empty_hands(bool riding_control)
 {
-       s16b kaerichi = 0;
-       if (is_monk && (p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_BERSERKER)) return FALSE;
+       s16b status = EMPTY_HAND_NONE;
+
+       if (!inventory[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
+       if (!inventory[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
+
+       if (riding_control && (status != EMPTY_HAND_NONE) && p_ptr->riding && !(p_ptr->pet_extra_flags & PF_RYOUTE))
+       {
+               if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
+               else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
+       }
 
-       if (!(inventory[INVEN_RARM].k_idx)) kaerichi +=2;
-       if (!(inventory[INVEN_LARM].k_idx)) kaerichi +=1;
-       return kaerichi;
+       return status;
 }
 
 
@@ -6051,22 +6408,13 @@ bool heavy_armor(void)
        return (monk_arm_wgt > (100 + (p_ptr->lev * 4)));
 }
 
-int number_of_quests(void)
+void update_playtime(void)
 {
-       int i, j;
-
-       /* Clear the counter */
-       i = 0;
-
-       for (j = MIN_RANDOM_QUEST; j < MAX_RANDOM_QUEST+1; j++)
+       /* Check if the game has started */
+       if (start_time != 0)
        {
-               if (quest[j].status != QUEST_STATUS_UNTAKEN)
-               {
-                       /* Increment count of quests taken. */
-                       i++;
-               }
+               u32b tmp = time(NULL);
+               playtime += (tmp - start_time);
+               start_time = tmp;
        }
-
-       /* Return the number of quests taken */
-       return (i);
 }