OSDN Git Service

Broken weapon repairing service is improved at changing to base item with TR_BLOWS...
[hengband/hengband.git] / src / bldg.c
index 010d63c..ea331c7 100644 (file)
 /* hack as in leave_store in store.c */
 static bool leave_bldg = FALSE;
 
-/* remember building location */
-static int building_loc = 0;
-
-static bool reinit_wilderness = FALSE;
-
 static bool is_owner(building_type *bldg)
 {
        if (bldg->member_class[p_ptr->pclass] == BUILDING_OWNER)
@@ -134,9 +129,9 @@ static void show_building(building_type* bldg)
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->member_costs[i]);
+sprintf(buff, "($%ld)", (long int)bldg->member_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->member_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->member_costs[i]);
 #endif
 
                                }
@@ -144,9 +139,9 @@ sprintf(buff, "($%ld)", bldg->member_costs[i]);
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->other_costs[i]);
+sprintf(buff, "($%ld)", (long int)bldg->other_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->other_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->other_costs[i]);
 #endif
 
                                }
@@ -173,9 +168,9 @@ strcpy(buff, "(
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->member_costs[i]);
+sprintf(buff, "($%ld)", (long int)bldg->member_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->member_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->member_costs[i]);
 #endif
 
                                }
@@ -183,9 +178,9 @@ sprintf(buff, "($%ld)", bldg->member_costs[i]);
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->other_costs[i]);
+sprintf(buff, "($%ld)", (long int)bldg->other_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->other_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->other_costs[i]);
 #endif
 
                                }
@@ -206,9 +201,9 @@ strcpy(buff, "(
                                {
                                        action_color = TERM_YELLOW;
 #ifdef JP
-sprintf(buff, "($%ld)", bldg->member_costs[i]);
+sprintf(buff, "($%ld)", (long int)bldg->member_costs[i]);
 #else
-                                       sprintf(buff, "(%ldgp)", bldg->member_costs[i]);
+                                       sprintf(buff, "(%ldgp)", (long int)bldg->member_costs[i]);
 #endif
 
                                }
@@ -286,11 +281,21 @@ msg_print("
 #else
                                        if (get_check("Do you fight? "))
 #endif
-                                       {
-                                               p_ptr->leftbldg = TRUE;
-                                               p_ptr->inside_arena = TRUE;
+                                       {       
+#ifdef JP
+                        msg_print("»à¤Ì¤¬¤è¤¤¡£");
+#else
+                                           msg_print("Die, maggots.");
+#endif
+                                               msg_print(NULL);
+                                       
                                                p_ptr->exit_bldg = FALSE;
                                                reset_tim_flags();
+
+                                               /* Save the surface floor as saved floor */
+                                               prepare_change_floor_mode(CFM_SAVE_FLOORS);
+
+                                               p_ptr->inside_arena = TRUE;
                                                p_ptr->leaving = TRUE;
                                                leave_bldg = TRUE;
                                        }
@@ -326,10 +331,13 @@ msg_print("
                        }
                        else
                        {
-                               p_ptr->leftbldg = TRUE;
-                               p_ptr->inside_arena = TRUE;
                                p_ptr->exit_bldg = FALSE;
                                reset_tim_flags();
+
+                               /* Save the surface floor as saved floor */
+                               prepare_change_floor_mode(CFM_SAVE_FLOORS);
+
+                               p_ptr->inside_arena = TRUE;
                                p_ptr->leaving = TRUE;
                                leave_bldg = TRUE;
                        }
@@ -352,7 +360,7 @@ msg_print("
                        }
                        else
                        {
-                               r_ptr = &r_info[arena_monsters[p_ptr->arena_number]];
+                               r_ptr = &r_info[arena_info[p_ptr->arena_number].r_idx];
                                name = (r_name + r_ptr->name);
 #ifdef JP
 msg_format("%s ¤ËÄ©À魯¤ë¤â¤Î¤Ï¤¤¤Ê¤¤¤«¡©", name);
@@ -571,7 +579,7 @@ static void reset_deck(int deck[])
        }
 }
 
-static bool have_joker()
+static bool have_joker(void)
 {
        int i;
 
@@ -589,7 +597,7 @@ static bool find_card_num(int num)
        return FALSE;
 }
 
-static bool yaku_check_flush()
+static bool yaku_check_flush(void)
 {
        int i, suit;
        bool joker_is_used = FALSE;
@@ -607,7 +615,7 @@ static bool yaku_check_flush()
        return TRUE;
 }
 
-static int yaku_check_straight()
+static int yaku_check_straight(void)
 {
        int i, lowest = 99;
        bool joker_is_used = FALSE;
@@ -646,7 +654,7 @@ static int yaku_check_straight()
        joker_is_used = FALSE;
        for (i = 0; i < 5; i++)
        {
-               if (!find_card_num(lowest + i)){
+               if (!find_card_num(lowest + i)){
                  if( have_joker() && !joker_is_used )
                    joker_is_used = TRUE;
                  else
@@ -663,7 +671,7 @@ static int yaku_check_straight()
 /*
  * 0:nopair 1:1 pair 2:2 pair 3:3 cards 4:full house 6:4cards
  */
-static int yaku_check_pair()
+static int yaku_check_pair(void)
 {
        int i, i2, matching = 0;
 
@@ -714,7 +722,7 @@ static int yaku_check_pair()
 #define ODDS_3C 1
 #define ODDS_2P 1
 
-static int yaku_check()
+static int yaku_check(void)
 {
        prt("                            ", 4, 3);
 
@@ -853,7 +861,7 @@ static void display_kaeruka(int hoge, int kaeruka[])
 }
 
 
-static void display_cards()
+static void display_cards(void)
 {
        int i, j;
        char suitcolor[4] = {TERM_YELLOW, TERM_L_RED, TERM_L_BLUE, TERM_L_GREEN};
@@ -1100,7 +1108,7 @@ static void display_cards()
        }
 }
 
-static int do_poker()
+static int do_poker(void)
 {
        int i, k = 2;
        char cmd;
@@ -1269,9 +1277,9 @@ static bool gamble_comm(int cmd)
                /* Get the wager */
                strcpy(out_val, "");
 #ifdef JP
-sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", maxbet);
+sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", (long int)maxbet);
 #else
-               sprintf(tmp_str,"Your wager (1-%ld) ? ", maxbet);
+               sprintf(tmp_str,"Your wager (1-%ld) ? ", (long int)maxbet);
 #endif
 
 
@@ -1302,9 +1310,9 @@ msg_print("
                        else if (wager > maxbet)
                        {
 #ifdef JP
-msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", maxbet);
+msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", (long int)maxbet);
 #else
-                               msg_format("I'll take %ld gold of that. Keep the rest.", maxbet);
+                               msg_format("I'll take %ld gold of that. Keep the rest.", (long int)maxbet);
 #endif
 
                                wager = maxbet;
@@ -1326,17 +1334,17 @@ msg_print("
                        oldgold = p_ptr->au;
 
 #ifdef JP
-sprintf(tmp_str, "¥²¡¼¥àÁ°¤Î½ê»ý¶â: %9ld", oldgold);
+sprintf(tmp_str, "¥²¡¼¥àÁ°¤Î½ê»ý¶â: %9ld", (long int)oldgold);
 #else
-                       sprintf(tmp_str, "Gold before game: %9ld", oldgold);
+                       sprintf(tmp_str, "Gold before game: %9ld", (long int)oldgold);
 #endif
 
                        prt(tmp_str, 20, 2);
 
 #ifdef JP
-sprintf(tmp_str, "¸½ºß¤Î³Ý¤±¶â:     %9ld", wager);
+sprintf(tmp_str, "¸½ºß¤Î³Ý¤±¶â:     %9ld", (long int)wager);
 #else
-                       sprintf(tmp_str, "Current Wager:    %9ld", wager);
+                       sprintf(tmp_str, "Current Wager:    %9ld", (long int)wager);
 #endif
 
                        prt(tmp_str, 21, 2);
@@ -1605,9 +1613,9 @@ prt("
                                        prt("", 17, 37);
                                }
 #ifdef JP
-sprintf(tmp_str, "¸½ºß¤Î½ê»ý¶â:     %9ld", p_ptr->au);
+sprintf(tmp_str, "¸½ºß¤Î½ê»ý¶â:     %9ld", (long int)p_ptr->au);
 #else
-                               sprintf(tmp_str, "Current Gold:     %9ld", p_ptr->au);
+                               sprintf(tmp_str, "Current Gold:     %9ld", (long int)p_ptr->au);
 #endif
 
                                prt(tmp_str, 22, 2);
@@ -1674,11 +1682,11 @@ static bool vault_aux_battle(int r_idx)
        monster_race *r_ptr = &r_info[r_idx];
 
        /* Decline town monsters */
-/*     if (!monster_dungeon(r_idx)) return FALSE; */
+/*     if (!mon_hook_dungeon(r_idx)) return FALSE; */
 
        /* Decline unique monsters */
 /*     if (r_ptr->flags1 & (RF1_UNIQUE)) return (FALSE); */
-/*     if (r_ptr->flags7 & (RF7_UNIQUE_7)) return (FALSE); */
+/*     if (r_ptr->flags7 & (RF7_NAZGUL)) return (FALSE); */
 
        if (r_ptr->flags1 & (RF1_NEVER_MOVE)) return (FALSE);
        if (r_ptr->flags2 & (RF2_MULTIPLY)) return (FALSE);
@@ -1754,7 +1762,7 @@ void battle_monsters(void)
                for (i=0;i<4;i++)
                {
                        monster_race *r_ptr = &r_info[battle_mon[i]];
-                       int num_taisei = count_bits(r_ptr->flags3 & (RF3_IM_ACID | RF3_IM_ELEC | RF3_IM_FIRE | RF3_IM_COLD | RF3_IM_POIS));
+                       int num_taisei = count_bits(r_ptr->flagsr & (RFR_IM_ACID | RFR_IM_ELEC | RFR_IM_FIRE | RFR_IM_COLD | RFR_IM_POIS));
 
                        if (r_ptr->flags1 & RF1_FORCE_MAXHP)
                                power[i] = r_ptr->hdice * r_ptr->hside * 2;
@@ -1808,7 +1816,7 @@ void battle_monsters(void)
                                case MON_SHADOWLORD:
                                case MON_ARCHLICH:
                                case MON_BLEYS:
-                               case MON_CAIN:
+                               case MON_CAINE:
                                case MON_JULIAN:
                                case MON_VENOM_WYRM:
                                case MON_MASTER_MYS:
@@ -1836,7 +1844,7 @@ void battle_monsters(void)
                                case MON_BAZOOKER:
                                case MON_GCWADL:
                                case MON_KIRIN:
-                               case MON_HOUOU:
+                               case MON_FENGHUANG:
                                        power[i] = power[i] * 4 / 3;
                                        break;
                                case MON_UMBER_HULK:
@@ -1844,7 +1852,7 @@ void battle_monsters(void)
                                case MON_WATER_VOR:
                                case MON_COLD_VOR:
                                case MON_ENERGY_VOR:
-                               case MON_BARNEY:
+                               case MON_GACHAPIN:
                                case MON_REVENANT:
                                case MON_NEXUS_VOR:
                                case MON_PLASMA_VOR:
@@ -1921,7 +1929,7 @@ static bool kakutoujou(void)
        char out_val[160], tmp_str[80];
        cptr p;
 
-       if ((turn - old_battle) > 5000)
+       if ((turn - old_battle) > TURNS_PER_TICK*250)
        {
                battle_monsters();
                old_battle = turn;
@@ -1959,9 +1967,9 @@ static bool kakutoujou(void)
                        monster_race *r_ptr = &r_info[battle_mon[i]];
 
 #ifdef JP
-                       sprintf(buf,"%d) %-58s  %4ld.%02ldÇÜ", i+1, format("%s%s",r_name + r_ptr->name, (r_ptr->flags1 & RF1_UNIQUE) ? "¤â¤É¤­" : "      "), mon_odds[i]/100, mon_odds[i]%100);
+                       sprintf(buf,"%d) %-58s  %4ld.%02ldÇÜ", i+1, format("%s%s",r_name + r_ptr->name, (r_ptr->flags1 & RF1_UNIQUE) ? "¤â¤É¤­" : "      "), (long int)mon_odds[i]/100, (long int)mon_odds[i]%100);
 #else
-                       sprintf(buf,"%d) %-58s  %4ld.%02ld", i+1, format("%s%s", (r_ptr->flags1 & RF1_UNIQUE) ? "Fake " : "", r_name + r_ptr->name), mon_odds[i]/100, mon_odds[i]%100);
+                       sprintf(buf,"%d) %-58s  %4ld.%02ld", i+1, format("%s%s", (r_ptr->flags1 & RF1_UNIQUE) ? "Fake " : "", r_name + r_ptr->name), (long int)mon_odds[i]/100, (long int)mon_odds[i]%100);
 #endif
                        prt(buf, 5+i, 1);
                }
@@ -2001,9 +2009,9 @@ static bool kakutoujou(void)
                /* Get the wager */
                strcpy(out_val, "");
 #ifdef JP
-sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", maxbet);
+sprintf(tmp_str,"ÅÒ¤±¶â (1-%ld)¡©", (long int)maxbet);
 #else
-               sprintf(tmp_str,"Your wager (1-%ld) ? ", maxbet);
+               sprintf(tmp_str,"Your wager (1-%ld) ? ", (long int)maxbet);
 #endif
 
 
@@ -2034,9 +2042,9 @@ msg_print("
                        else if (wager > maxbet)
                        {
 #ifdef JP
-msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", maxbet);
+msg_format("%ld¥´¡¼¥ë¥É¤À¤±¼õ¤±¤è¤¦¡£»Ä¤ê¤Ï¼è¤Ã¤È¤­¤Ê¡£", (long int)maxbet);
 #else
-                               msg_format("I'll take %ld gold of that. Keep the rest.", maxbet);
+                               msg_format("I'll take %ld gold of that. Keep the rest.",(long int) maxbet);
 #endif
 
                                wager = maxbet;
@@ -2056,10 +2064,14 @@ msg_print("
                        battle_odds = MAX(wager+1, wager * battle_odds / 100);
                        kakekin = wager;
                        p_ptr->au -= wager;
-                       p_ptr->leftbldg = TRUE;
-                       p_ptr->inside_battle = TRUE;
                        reset_tim_flags();
+
+                       /* Save the surface floor as saved floor */
+                       prepare_change_floor_mode(CFM_SAVE_FLOORS);
+
+                       p_ptr->inside_battle = TRUE;
                        p_ptr->leaving = TRUE;
+
                        leave_bldg = TRUE;
                        screen_load();
 
@@ -2129,7 +2141,7 @@ static void shoukinkubi(void)
        clear_bldg(4,18);
 
 #ifdef JP
-       prt("»àÂΤò»ý¤Áµ¢¤ë¤È¾Þ¶â¤òº¹¤·¾å¤²¤Þ¤¹¡£",4 ,10);
+       prt("»àÂΤò»ý¤Áµ¢¤ì¤ÐÊó½·¤òº¹¤·¾å¤²¤Þ¤¹¡£",4 ,10);
 c_put_str(TERM_YELLOW, "¸½ºß¤Î¾Þ¶â¼ó", 6, 10);
 #else
        prt("Offer a prize when you bring a wanted monster's corpse",4 ,10);
@@ -2138,22 +2150,27 @@ c_put_str(TERM_YELLOW, "Wanted monsters", 6, 10);
 
        for (i = 0; i < MAX_KUBI; i++)
        {
-               char buf[160];
+               byte color;
+               cptr done_mark;
                monster_race *r_ptr = &r_info[(kubi_r_idx[i] > 10000 ? kubi_r_idx[i] - 10000 : kubi_r_idx[i])];
 
-               sprintf(buf,"%-40s ---- ",r_name + r_ptr->name);
-               prt(buf, y+7, 10);
                if (kubi_r_idx[i] > 10000)
+               {
+                       color = TERM_RED;
 #ifdef JP
-                       c_put_str(TERM_RED,"ºÑ", y+7, 56);
+                       done_mark = "(ºÑ)";
 #else
-                       c_put_str(TERM_RED,"done", y+7, 56);
+                       done_mark = "(done)";
 #endif
+               }
                else
                {
-                       sprintf(buf,"$%d", 300 * (r_ptr->level + 1));
-                       prt(buf, y+7, 56);
+                       color = TERM_WHITE;
+                       done_mark = "";
                }
+
+               c_prt(color, format("%s %s", r_name + r_ptr->name, done_mark), y+7, 10);
+
                y = (y+1) % 10;
                if (!y && (i < MAX_KUBI -1))
                {
@@ -2169,6 +2186,40 @@ c_put_str(TERM_YELLOW, "Wanted monsters", 6, 10);
        }
 }
 
+
+/* List of prize object */
+static struct {
+       s16b tval;
+       s16b sval;
+} prize_list[MAX_KUBI] = 
+{
+       {TV_POTION, SV_POTION_CURING},
+       {TV_POTION, SV_POTION_SPEED},
+       {TV_POTION, SV_POTION_SPEED},
+       {TV_POTION, SV_POTION_RESISTANCE},
+       {TV_POTION, SV_POTION_ENLIGHTENMENT},
+
+       {TV_POTION, SV_POTION_HEALING},
+       {TV_POTION, SV_POTION_RESTORE_MANA},
+       {TV_SCROLL, SV_SCROLL_STAR_DESTRUCTION},
+       {TV_POTION, SV_POTION_STAR_ENLIGHTENMENT},
+       {TV_SCROLL, SV_SCROLL_SUMMON_PET},
+
+       {TV_SCROLL, SV_SCROLL_GENOCIDE},
+       {TV_POTION, SV_POTION_STAR_HEALING},
+       {TV_POTION, SV_POTION_STAR_HEALING},
+       {TV_POTION, SV_POTION_NEW_LIFE},
+       {TV_SCROLL, SV_SCROLL_MASS_GENOCIDE},
+
+       {TV_POTION, SV_POTION_LIFE},
+       {TV_POTION, SV_POTION_LIFE},
+       {TV_POTION, SV_POTION_AUGMENTATION},
+       {TV_POTION, SV_POTION_INVULNERABILITY},
+       {TV_SCROLL, SV_SCROLL_ARTIFACT},
+};
+
+
+/* Get prize */
 static bool kankin(void)
 {
        int i, j;
@@ -2176,24 +2227,27 @@ static bool kankin(void)
        char o_name[MAX_NLEN];
        object_type *o_ptr;
 
-       for (i = 0;i <= INVEN_LARM; i++)
+       /* Loop for inventory and right/left arm */
+       for (i = 0; i <= INVEN_LARM; i++)
        {
                o_ptr = &inventory[i];
+
+               /* Living Tsuchinoko worthes $1000000 */
                if ((o_ptr->tval == TV_CAPTURE) && (o_ptr->pval == MON_TSUCHINOKO))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
-                       sprintf(buf, "Convert %s into maney? ",o_name);
+                       sprintf(buf, "Convert %s into money? ",o_name);
 #endif
                        if (get_check(buf))
                        {
 #ifdef JP
-                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", 1000000L * o_ptr->number);
+                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)(1000000L * o_ptr->number));
 #else
-                               msg_format("You get %ldgp.", 1000000L * o_ptr->number);
+                               msg_format("You get %ldgp.", (long int)(1000000L * o_ptr->number));
 #endif
                                p_ptr->au += 1000000L * o_ptr->number;
                                p_ptr->redraw |= (PR_GOLD);
@@ -2204,24 +2258,27 @@ static bool kankin(void)
                        change = TRUE;
                }
        }
-       for (i = 0;i <= INVEN_LARM; i++)
+
+       for (i = 0; i < INVEN_PACK; i++)
        {
                o_ptr = &inventory[i];
+
+               /* Corpse of Tsuchinoko worthes $200000 */
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (o_ptr->pval == MON_TSUCHINOKO))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
-                       sprintf(buf, "Convert %s into maney? ",o_name);
+                       sprintf(buf, "Convert %s into money? ",o_name);
 #endif
                        if (get_check(buf))
                        {
 #ifdef JP
-                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", 200000L * o_ptr->number);
+                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)(200000L * o_ptr->number));
 #else
-                               msg_format("You get %ldgp.", 200000L * o_ptr->number);
+                               msg_format("You get %ldgp.", (long int)(200000L * o_ptr->number));
 #endif
                                p_ptr->au += 200000L * o_ptr->number;
                                p_ptr->redraw |= (PR_GOLD);
@@ -2232,24 +2289,27 @@ static bool kankin(void)
                        change = TRUE;
                }
        }
-       for (i = 0;i <= INVEN_LARM; i++)
+
+       for (i = 0; i < INVEN_PACK; i++)
        {
                o_ptr = &inventory[i];
+
+               /* Bones of Tsuchinoko worthes $100000 */
                if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (o_ptr->pval == MON_TSUCHINOKO))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
-                       sprintf(buf, "Convert %s into maney? ",o_name);
+                       sprintf(buf, "Convert %s into money? ",o_name);
 #endif
                        if (get_check(buf))
                        {
 #ifdef JP
-                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", 100000L * o_ptr->number);
+                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)(100000L * o_ptr->number));
 #else
-                               msg_format("You get %ldgp.", 100000L * o_ptr->number);
+                               msg_format("You get %ldgp.", (long int)(100000L * o_ptr->number));
 #endif
                                p_ptr->au += 100000L * o_ptr->number;
                                p_ptr->redraw |= (PR_GOLD);
@@ -2261,24 +2321,24 @@ static bool kankin(void)
                }
        }
 
-       for (i = 0;i <= INVEN_LARM; i++)
+       for (i = 0; i < INVEN_PACK; i++)
        {
                o_ptr = &inventory[i];
-               if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (o_ptr->pval == today_mon))
+               if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
-                       sprintf(buf, "Convert %s into maney? ",o_name);
+                       sprintf(buf, "Convert %s into money? ",o_name);
 #endif
                        if (get_check(buf))
                        {
 #ifdef JP
-                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[today_mon].level * 50 + 100) * o_ptr->number);
+                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)((r_info[today_mon].level * 50 + 100) * o_ptr->number));
 #else
-                               msg_format("You get %ldgp.", (r_info[today_mon].level * 50 + 100) * o_ptr->number);
+                               msg_format("You get %ldgp.", (long int)((r_info[today_mon].level * 50 + 100) * o_ptr->number));
 #endif
                                p_ptr->au += (r_info[today_mon].level * 50 + 100) * o_ptr->number;
                                p_ptr->redraw |= (PR_GOLD);
@@ -2289,24 +2349,26 @@ static bool kankin(void)
                        change = TRUE;
                }
        }
-       for (i = 0;i <= INVEN_LARM; i++)
+
+       for (i = 0; i < INVEN_PACK; i++)
        {
                o_ptr = &inventory[i];
-               if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (o_ptr->pval == today_mon))
+
+               if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_SKELETON) && (streq(r_name + r_info[o_ptr->pval].name, r_name + r_info[today_mon].name)))
                {
                        char buf[MAX_NLEN+20];
-                       object_desc(o_name, o_ptr, TRUE, 3);
+                       object_desc(o_name, o_ptr, 0);
 #ifdef JP
                        sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
 #else
-                       sprintf(buf, "Convert %s into maney? ",o_name);
+                       sprintf(buf, "Convert %s into money? ",o_name);
 #endif
                        if (get_check(buf))
                        {
 #ifdef JP
-                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[today_mon].level * 30 + 60) * o_ptr->number);
+                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (long int)((r_info[today_mon].level * 30 + 60) * o_ptr->number));
 #else
-                               msg_format("You get %ldgp.", (r_info[today_mon].level * 30 + 60) * o_ptr->number);
+                               msg_format("You get %ldgp.", (long int)((r_info[today_mon].level * 30 + 60) * o_ptr->number));
 #endif
                                p_ptr->au += (r_info[today_mon].level * 30 + 60) * o_ptr->number;
                                p_ptr->redraw |= (PR_GOLD);
@@ -2320,33 +2382,90 @@ static bool kankin(void)
 
        for (j = 0; j < MAX_KUBI; j++)
        {
-               for (i = 0;i <= INVEN_LARM; i++)
+               /* Need reverse order --- Positions will be changed in the loop */
+               for (i = INVEN_PACK-1; i >= 0; i--)
                {
                        o_ptr = &inventory[i];
-                       if ((o_ptr->tval == TV_CORPSE) && (o_ptr->sval == SV_CORPSE) && (o_ptr->pval == kubi_r_idx[j]))
+                       if ((o_ptr->tval == TV_CORPSE) && (o_ptr->pval == kubi_r_idx[j]))
                        {
                                char buf[MAX_NLEN+20];
-                               object_desc(o_name, o_ptr, TRUE, 3);
+                               int num, k, item_new;
+                               object_type forge;
+
+                               object_desc(o_name, o_ptr, 0);
 #ifdef JP
-                               sprintf(buf, "%s ¤ò´¹¶â¤·¤Þ¤¹¤«¡©",o_name);
+                               sprintf(buf, "%s¤òÅϤ·¤Þ¤¹¤«¡©",o_name);
 #else
-                               sprintf(buf, "Convert %s into maney? ",o_name);
+                               sprintf(buf, "Hand %s over? ",o_name);
 #endif
-                               if (get_check(buf))
-                               {
+                               if (!get_check(buf)) continue;
+
+#if 0 /* Obsoleted */
 #ifdef JP
-                                       msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[kubi_r_idx[j]].level + 1) * 300 * o_ptr->number);
+                               msg_format("¾Þ¶â %ld¡ð¤ò¼ê¤ËÆþ¤ì¤¿¡£", (r_info[kubi_r_idx[j]].level + 1) * 300 * o_ptr->number);
 #else
-                                       msg_format("You get %ldgp.", (r_info[kubi_r_idx[j]].level + 1) * 300 * o_ptr->number);
+                               msg_format("You get %ldgp.", (r_info[kubi_r_idx[j]].level + 1) * 300 * o_ptr->number);
 #endif
-                                       p_ptr->au += (r_info[kubi_r_idx[j]].level+1) * 300 * o_ptr->number;
-                                       p_ptr->redraw |= (PR_GOLD);
-                                       inven_item_increase(i, -o_ptr->number);
-                                       inven_item_describe(i);
-                                       inven_item_optimize(i);
-                                       chg_virtue(V_JUSTICE, 5);
-                                       kubi_r_idx[j] += 10000;
+                               p_ptr->au += (r_info[kubi_r_idx[j]].level+1) * 300 * o_ptr->number;
+                               p_ptr->redraw |= (PR_GOLD);
+                               inven_item_increase(i, -o_ptr->number);
+                               inven_item_describe(i);
+                               inven_item_optimize(i);
+                               chg_virtue(V_JUSTICE, 5);
+                               kubi_r_idx[j] += 10000;
+
+                               change = TRUE;
+#endif /* Obsoleted */
+
+                               /* Hand it first */
+                               inven_item_increase(i, -o_ptr->number);
+                               inven_item_describe(i);
+                               inven_item_optimize(i);
+
+                               chg_virtue(V_JUSTICE, 5);
+                               kubi_r_idx[j] += 10000;
+
+                               /* Count number of unique corpses already handed */
+                               for (num = 0, k = 0; k < MAX_KUBI; k++)
+                               {
+                                       if (kubi_r_idx[k] >= 10000) num++;
                                }
+
+#ifdef JP
+                               msg_format("¤³¤ì¤Ç¹ç·× %d ¥Ý¥¤¥ó¥È³ÍÆÀ¤·¤Þ¤·¤¿¡£", num);
+#else
+                               msg_format("You earned %d point%s total.", num, (num > 1 ? "s" : ""));
+#endif
+
+                               /* Prepare to make a prize */
+                               object_prep(&forge, lookup_kind(prize_list[num-1].tval, prize_list[num-1].sval));
+                               apply_magic(&forge, object_level, AM_NO_FIXED_ART);
+
+                               /* Identify it fully */
+                               object_aware(&forge);
+                               object_known(&forge);
+
+                               /*
+                                * Hand it --- Assume there is an empty slot.
+                                * Since a corpse is handed at first,
+                                * there is at least one empty slot.
+                                */
+                               item_new = inven_carry(&forge);
+
+                               /* Describe the object */
+                               object_desc(o_name, &forge, 0);
+#ifdef JP
+                               msg_format("%s(%c)¤òÌã¤Ã¤¿¡£", o_name, index_to_label(item_new));
+#else
+                               msg_format("You get %s (%c). ", o_name, index_to_label(item_new));
+#endif
+
+                               /* Auto-inscription */
+                               autopick_alter_item(item_new, FALSE);
+
+                               /* Handle stuff */
+                               handle_stuff();
+
                                change = TRUE;
                        }
                }
@@ -2383,49 +2502,33 @@ bool get_nightmare(int r_idx)
 void have_nightmare(int r_idx)
 {
        bool happened = FALSE;
-
-       int power = 100;
-
        monster_race *r_ptr = &r_info[r_idx];
-
+       int power = r_ptr->level + 10;
        char m_name[80];
        cptr desc = r_name + r_ptr->name;
 
-
-       power = r_ptr->level + 10;
-
-#ifdef JP
-        if (0)
-#else
+       /* Describe it */
+#ifndef JP
        if (!(r_ptr->flags1 & RF1_UNIQUE))
-#endif
-
-       {
-               /* Describe it */
                sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
-
-               if (r_ptr->flags1 & RF1_FRIENDS)
-               {
-                       power /= 2;
-               }
-       }
        else
-       {
-               /* Describe it */
+#endif
                sprintf(m_name, "%s", desc);
 
-               power *= 2;
+       if (!(r_ptr->flags1 & RF1_UNIQUE))
+       {
+               if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
        }
+       else power *= 2;
 
        if (saving_throw(p_ptr->skill_sav * 100 / power))
        {
 #ifdef JP
-       msg_format("Ì´¤ÎÃæ¤Ç%s¤ËÄɤ¤¤«¤±¤é¤ì¤¿¡£", m_name);
+               msg_format("Ì´¤ÎÃæ¤Ç%s¤ËÄɤ¤¤«¤±¤é¤ì¤¿¡£", m_name);
 #else
-       msg_format("%^s chases you through your dreams.", m_name);
+               msg_format("%^s chases you through your dreams.", m_name);
 #endif
 
-
                /* Safe */
                return;
        }
@@ -2434,7 +2537,7 @@ void have_nightmare(int r_idx)
        {
                /* Something silly happens... */
 #ifdef JP
-msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
+               msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
 #else
                msg_format("You behold the %s visage of %s!",
 #endif
@@ -2453,7 +2556,7 @@ msg_format("%s%s
 
        /* Something frightening happens... */
 #ifdef JP
-msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
+       msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
 #else
        msg_format("You behold the %s visage of %s!",
 #endif
@@ -2462,19 +2565,33 @@ msg_format("%s%s
 
        r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
 
-       switch(p_ptr->prace)
+       if (!p_ptr->mimic_form)
        {
-               /* Imps may make a saving throw */
+               switch (p_ptr->prace)
+               {
+               /* Demons may make a saving throw */
                case RACE_IMP:
                case RACE_DEMON:
-               {
                        if (saving_throw(20 + p_ptr->lev)) return;
-               }
+                       break;
                /* Undead may make a saving throw */
                case RACE_SKELETON:
                case RACE_ZOMBIE:
                case RACE_SPECTRE:
                case RACE_VAMPIRE:
+                       if (saving_throw(10 + p_ptr->lev)) return;
+                       break;
+               }
+       }
+       else
+       {
+               /* Demons may make a saving throw */
+               if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
+               {
+                       if (saving_throw(20 + p_ptr->lev)) return;
+               }
+               /* Undead may make a saving throw */
+               else if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
                {
                        if (saving_throw(10 + p_ptr->lev)) return;
                }
@@ -2670,11 +2787,19 @@ msg_print("
  */
 static bool inn_comm(int cmd)
 {
-       int dawnval;
-
        switch (cmd)
        {
                case BACT_FOOD: /* Buy food & drink */
+                       if (p_ptr->food >= PY_FOOD_FULL)
+                       {
+#ifdef JP
+                               msg_print("º£¤ÏËþÊ¢¤À¡£");
+#else
+                               msg_print("You are full now.");
+#endif
+                               return FALSE;
+                       }
+
 #ifdef JP
 msg_print("¥Ð¡¼¥Æ¥ó¤Ï¤¤¤¯¤é¤«¤Î¿©¤Ùʪ¤È¥Ó¡¼¥ë¤ò¤¯¤ì¤¿¡£");
 #else
@@ -2685,132 +2810,122 @@ msg_print("
                        break;
 
                case BACT_REST: /* Rest for the night */
-                       dawnval = ((turn % (20L * TOWN_DAWN)));
-                       if (dawnval > 50000)
-                       {  /* nighttime */
-                               if ((p_ptr->poisoned) || (p_ptr->cut))
-                               {
+                       if ((p_ptr->poisoned) || (p_ptr->cut))
+                       {
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤ËɬÍפʤΤÏÉô²°¤Ç¤Ï¤Ê¤¯¡¢¼£ÎżԤǤ¹¡£");
+                               msg_print("¤¢¤Ê¤¿¤ËɬÍפʤΤÏÉô²°¤Ç¤Ï¤Ê¤¯¡¢¼£ÎżԤǤ¹¡£");
 #else
-                                       msg_print("You need a healer, not a room.");
+                               msg_print("You need a healer, not a room.");
 #endif
 
-                                       msg_print(NULL);
+                               msg_print(NULL);
 #ifdef JP
-msg_print("¤¹¤ß¤Þ¤»¤ó¡¢¤Ç¤â¤¦¤Á¤Ç狼¤Ë»à¤Ê¤ì¤Á¤ãº¤¤ê¤Þ¤¹¤ó¤Ç¡£");
+                               msg_print("¤¹¤ß¤Þ¤»¤ó¡¢¤Ç¤â¤¦¤Á¤Ç狼¤Ë»à¤Ê¤ì¤Á¤ãº¤¤ê¤Þ¤¹¤ó¤Ç¡£");
 #else
-                                       msg_print("Sorry, but don't want anyone dying in here.");
+                               msg_print("Sorry, but don't want anyone dying in here.");
 #endif
+                       }
+                       else
+                       {
+                               s32b oldturn = turn;
+                               int prev_day, prev_hour, prev_min;
 
-                               }
-                               else
-                               {
-                                       int oldturn = turn;
+                               extract_day_hour_min(&prev_day, &prev_hour, &prev_min);
 #ifdef JP
-                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "½É²°¤ËÇñ¤Þ¤Ã¤¿¡£");
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "½É²°¤ËÇñ¤Þ¤Ã¤¿¡£");
 #else
-                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "stay over night at the inn");
+                               if ((prev_hour >= 6) && (prev_hour <= 17)) do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "stay over daytime at the inn.");
+                               else do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "stay over night at the inn.");
 #endif
-                                       turn = ((turn / 100000) + 1) * 100000;
-                                       if (((oldturn + 5L * TOWN_DAWN) % (20L * TOWN_DAWN)) > 50000L) do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
-                                       p_ptr->chp = p_ptr->mhp;
+                               turn = (turn / (TURNS_PER_TICK*TOWN_DAWN/2) + 1) * (TURNS_PER_TICK*TOWN_DAWN/2);
+                               if (dungeon_turn < dungeon_turn_limit)
+                               {
+                                       dungeon_turn += MIN(turn - oldturn, TURNS_PER_TICK * 250);
+                                       if (dungeon_turn > dungeon_turn_limit) dungeon_turn = dungeon_turn_limit;
+                               }
 
-                                       dungeon_turn += MIN(turn - oldturn, 5000);
+                               prevent_turn_overflow();
 
-                                       if (ironman_nightmare)
-                                       {
+                               if ((prev_hour >= 18) && (prev_hour <= 23)) do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
+                               p_ptr->chp = p_ptr->mhp;
+
+                               if (ironman_nightmare)
+                               {
 #ifdef JP
-msg_print("̲¤ê¤Ë½¢¤¯¤È¶²¤í¤·¤¤¸÷·Ê¤¬¿´¤ò¤è¤®¤Ã¤¿¡£");
+                                       msg_print("̲¤ê¤Ë½¢¤¯¤È¶²¤í¤·¤¤¸÷·Ê¤¬¿´¤ò¤è¤®¤Ã¤¿¡£");
 #else
-                                               msg_print("Horrible visions flit through your mind as you sleep.");
+                                       msg_print("Horrible visions flit through your mind as you sleep.");
 #endif
 
+                                       /* Pick a nightmare */
+                                       get_mon_num_prep(get_nightmare, NULL);
 
-                                               /* Pick a nightmare */
-                                               get_mon_num_prep(get_nightmare, NULL);
-
-                                               /* Have some nightmares */
-                                               while(1)
-                                               {
-                                                       have_nightmare(get_mon_num(MAX_DEPTH));
+                                       /* Have some nightmares */
+                                       while(1)
+                                       {
+                                               have_nightmare(get_mon_num(MAX_DEPTH));
 
-                                                       if (!one_in_(3)) break;
-                                               }
+                                               if (!one_in_(3)) break;
+                                       }
 
-                                               /* Remove the monster restriction */
-                                               get_mon_num_prep(NULL, NULL);
+                                       /* Remove the monster restriction */
+                                       get_mon_num_prep(NULL, NULL);
 
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤ÏÀ䶫¤·¤ÆÌܤò³Ð¤Þ¤·¤¿¡£");
+                                       msg_print("¤¢¤Ê¤¿¤ÏÀ䶫¤·¤ÆÌܤò³Ð¤Þ¤·¤¿¡£");
+                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "°­Ì´¤Ë¤¦¤Ê¤µ¤ì¤Æ¤è¤¯Ì²¤ì¤Ê¤«¤Ã¤¿¡£");
 #else
-                                               msg_print("You awake screaming.");
+                                       msg_print("You awake screaming.");
+                                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "be troubled by a nightmare.");
 #endif
+                               }
+                               else
+                               {
+                                       set_blind(0);
+                                       set_confused(0);
+                                       p_ptr->stun = 0;
+                                       p_ptr->chp = p_ptr->mhp;
+                                       p_ptr->csp = p_ptr->msp;
+                                       if (p_ptr->pclass == CLASS_MAGIC_EATER)
+                                       {
+                                               int i;
+                                               for (i = 0; i < 72; i++)
+                                               {
+                                                       p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*EATER_CHARGE;
+                                               }
+                                               for (; i < 108; i++)
+                                               {
+                                                       p_ptr->magic_num1[i] = 0;
+                                               }
+                                       }
 
+                                       if ((prev_hour >= 6) && (prev_hour <= 17))
+                                       {
 #ifdef JP
-                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "°­Ì´¤Ë¤¦¤Ê¤µ¤ì¤Æ¤è¤¯Ì²¤ì¤Ê¤«¤Ã¤¿¡£");
+                                               msg_print("¤¢¤Ê¤¿¤Ï¥ê¥Õ¥ì¥Ã¥·¥å¤·¤ÆÌܳФᡢͼÊý¤ò·Þ¤¨¤¿¡£");
+                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "ͼÊý¤ò·Þ¤¨¤¿¡£");
 #else
-                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "be troubled by a nightmare.");
+                                               msg_print("You awake refreshed for the evening.");
+                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "awake refreshed.");
 #endif
                                        }
                                        else
                                        {
-                                               set_blind(0);
-                                               set_confused(0);
-                                               p_ptr->stun = 0;
-                                               p_ptr->chp = p_ptr->mhp;
-                                               p_ptr->csp = p_ptr->msp;
-                                               if (p_ptr->pclass == CLASS_MAGIC_EATER)
-                                               {
-                                                       int i;
-                                                       for (i = 0; i < 72; i++)
-                                                       {
-                                                               p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*0x10000;
-                                                       }
-                                                       for (; i < 108; i++)
-                                                       {
-                                                               p_ptr->magic_num1[i] = 0;
-                                                       }
-                                               }
-
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤Ï¥ê¥Õ¥ì¥Ã¥·¥å¤·¤ÆÌܳФᡢ¿·¤¿¤ÊÆü¤ò·Þ¤¨¤¿¡£");
+                                               msg_print("¤¢¤Ê¤¿¤Ï¥ê¥Õ¥ì¥Ã¥·¥å¤·¤ÆÌܳФᡢ¿·¤¿¤ÊÆü¤ò·Þ¤¨¤¿¡£");
+                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¤¹¤¬¤¹¤¬¤·¤¤Ä«¤ò·Þ¤¨¤¿¡£");
 #else
                                                msg_print("You awake refreshed for the new day.");
-#endif
-
-#ifdef JP
-                                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¤¹¤¬¤¹¤¬¤·¤¤Ä«¤ò¤à¤«¤¨¤¿¡£");
-#else
                                                do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "awake refreshed.");
 #endif
                                        }
-
-                                       p_ptr->leftbldg = TRUE;
                                }
                        }
-                       else
-                       {
-#ifdef JP
-msg_print("Éô²°¤ÏÌë¤À¤±»ÈÍѲÄǽ¤Ç¤¹¡£");
-#else
-                               msg_print("The rooms are available only at night.");
-#endif
-
-                               return (FALSE);
-                       }
                        break;
+
                case BACT_RUMORS: /* Listen for rumors */
                        {
-                               char Rumor[1024];
-
-#ifdef JP
-                               if (!get_rnd_line_jonly("rumors_j.txt", 0, Rumor, 10))
-#else
-                               if (!get_rnd_line("rumors.txt", 0, Rumor))
-#endif
-
-                                       msg_format("%s", Rumor);
+                               display_rumor(TRUE);
                                break;
                        }
        }
@@ -2820,25 +2935,9 @@ msg_print("
 
 
 /*
- * Share gold for thieves
- */
-static void share_gold(void)
-{
-       int i = (p_ptr->lev * 2) * 10;
-#ifdef JP
-msg_format("¡ð%d ¤ò¼ê¤ËÆþ¤ì¤¿¡£", i);
-#else
-       msg_format("You collect %d gold pieces", i);
-#endif
-
-       p_ptr->au += i;
-}
-
-
-/*
  * Display quest information
  */
-static void get_questinfo(int questnum)
+static void get_questinfo(int questnum, bool do_init)
 {
        int     i;
        int     old_quest;
@@ -2858,9 +2957,10 @@ static void get_questinfo(int questnum)
        p_ptr->inside_quest = questnum;
 
        /* Get the quest text */
-       init_flags = INIT_SHOW_TEXT | INIT_ASSIGN;
+       init_flags = INIT_SHOW_TEXT;
+       if (do_init) init_flags |= INIT_ASSIGN;
 
-process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
+       process_dungeon_file("q_info.txt", 0, 0, 0, 0);
 
        /* Reset the old quest number */
        p_ptr->inside_quest = old_quest;
@@ -2919,14 +3019,14 @@ put_str("
                /* Rewarded quest */
                q_ptr->status = QUEST_STATUS_REWARDED;
 
-               get_questinfo(q_index);
+               get_questinfo(q_index, FALSE);
 
                reinit_wilderness = TRUE;
        }
        /* Failed quest */
        else if (q_ptr->status == QUEST_STATUS_FAILED)
        {
-               get_questinfo(q_index);
+               get_questinfo(q_index, FALSE);
 
                /* Mark quest as done (but failed) */
                q_ptr->status = QUEST_STATUS_FAILED_DONE;
@@ -2999,7 +3099,7 @@ msg_format("
                }
                else
                {
-                       get_questinfo(q_index);
+                       get_questinfo(q_index, TRUE);
                }
        }
 }
@@ -3015,7 +3115,7 @@ static void town_history(void)
 
        /* Peruse the building help file */
 #ifdef JP
-(void)show_file(TRUE, "bldg_j.txt", NULL, 0, 0);
+(void)show_file(TRUE, "jbldg.txt", NULL, 0, 0);
 #else
        (void)show_file(TRUE, "bldg.txt", NULL, 0, 0);
 #endif
@@ -3026,6 +3126,60 @@ static void town_history(void)
 }
 
 
+static s16b calc_expext_cirt(int weight, int plus, int dam, s16b meichuu, bool dokubari)
+{
+       long i,k, num;
+       
+       if(dokubari) return dam;
+       
+       i = weight + (meichuu * 3 + plus * 5) + (p_ptr->lev * 3);
+       k = weight;
+       num=0;
+       
+       if (k < 400)                                            num += (2 * dam + 5) * (400 - k);
+       if (k < 700)                                            num += (2 * dam + 10) * (MIN(700, k+650) - MAX(400, k));
+       if (k > (700-650) && k < 900)           num += (3 * dam + 15) * (MIN(900, k+650) - MAX(700, k));
+       if (k > (900-650) && k < 1300)          num += (3 * dam + 20) * (MIN(1300, k+650) - MAX(900, k));
+       if (k > (1300-650))                                     num += (7 * dam / 2 + 25) * MIN(650, k-(1300-650));
+       
+       if(p_ptr->pclass == CLASS_NINJA)
+       {
+               num *= i;
+               num += (4444 - i) * dam * 650;
+               num /= 4444;
+       }
+       else
+       {
+               num *= i;
+               num += (5000 - i) * dam * 650;
+               num /= 5000;
+       }
+       num /= 650;
+       
+       return num;
+}
+
+static s16b calc_slaydam(int dam, int mult, int div, bool force)
+{
+       int tmp;
+       if(force)
+       {
+               tmp = dam * 60;
+               tmp *= mult * 3;
+               tmp /= div * 2;
+               tmp += dam * 60 * 2;
+               tmp /= 60;
+       }
+       else
+       {
+               tmp = dam * 60;
+               tmp *= mult; 
+               tmp /= div;
+               tmp /= 60;
+       }
+       return tmp;
+}
+
 /*
  * Display the damage figure of an object
  * (used by compare_weapon_aux1)
@@ -3033,25 +3187,22 @@ static void town_history(void)
  * Only accurate for the current weapon, because it includes
  * the current +dam of the player.
  */
-static void compare_weapon_aux2(object_type *o_ptr, int numblows,
-                                int r, int c, int mult, char attr[80],
-                                u32b f1, u32b f2, u32b f3, byte color)
+static void compare_weapon_aux2(int r, int c, int mindam, int maxdam, cptr attr, byte color)
 {
        char tmp_str[80];
 
+
        /* Print the intro text */
        c_put_str(color, attr, r, c);
 
        /* Calculate the min and max damage figures */
 #ifdef JP
-sprintf(tmp_str, "£±¥¿¡¼¥ó: %d-%d ¥À¥á¡¼¥¸",
+       sprintf(tmp_str, "£±¥¿¡¼¥ó: %d-%d ¥À¥á¡¼¥¸",
 #else
        sprintf(tmp_str, "Attack: %d-%d damage",
 #endif
-
-           (numblows * (mult * o_ptr->dd /60 + o_ptr->to_d + p_ptr->to_d[0])),
-           (numblows * (mult * o_ptr->ds * o_ptr->dd /60 + o_ptr->to_d + p_ptr->to_d[0])));
-
+                       mindam, maxdam);
+       
        /* Print the damage */
        put_str(tmp_str, r, c + 8);
 }
@@ -3066,87 +3217,594 @@ sprintf(tmp_str, "
 static void compare_weapon_aux1(object_type *o_ptr, int col, int r)
 {
        int mult = 60;
-       u32b f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
+       int blow = p_ptr->num_blow[0];
+       bool force = FALSE;
+       bool dokubari = FALSE;
+       
+       /* Effective dices */
+       int eff_dd = o_ptr->dd + p_ptr->to_dd[0];
+       int eff_ds = o_ptr->ds + p_ptr->to_ds[0];
+       
+       int mindice = eff_dd;
+       int maxdice = eff_ds * eff_dd;
+       int mindam = 0;
+       int maxdam = 0;
+       int slaydice_min = 0;
+       int slaydice_max = 0;
+       int critdice_min = 0;
+       int critdice_max = 0;
+       int vorpal_mult = 1;
+       int vorpal_div = 1;
+       
 
        /* Get the flags of the weapon */
-       object_flags(o_ptr, &f1, &f2, &f3);
-
-       if (p_ptr->riding)
+       object_flags(o_ptr, flgs);
+       
+       if((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) dokubari = TRUE;
+       
+       
+       /* Show Critical Damage*/
+       critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, mindice, p_ptr->to_h[0], dokubari);
+       critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, maxdice, p_ptr->to_h[0], dokubari);
+       
+       mindam = blow * (critdice_min+ o_ptr->to_d + p_ptr->to_d[0]);
+       maxdam = blow * (critdice_max+ o_ptr->to_d + p_ptr->to_d[0]);
+       
+#ifdef JP
+       compare_weapon_aux2(r++, col, mindam, maxdam, "²ñ¿´:", TERM_L_RED);
+#else
+       compare_weapon_aux2(r++, col, mindam, maxdam, "Critical:", TERM_L_RED);
+#endif
+       
+       /* Vorpal Hit*/
+       if ((have_flag(flgs, TR_VORPAL) || hex_spelling(HEX_RUNESWORD)))
+       {
+               if((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD))
+               {
+                       vorpal_mult = 5;
+                       vorpal_div = 3;
+               }
+               else
+               {
+                       vorpal_mult = 11;
+                       vorpal_div = 9;
+               }
+               
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, mindice, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, maxdice, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               
+               #ifdef JP
+                       compare_weapon_aux2(r++, col, mindam, maxdam, "ÀÚ¤ìÌ£:", TERM_L_RED);
+               #else
+                       compare_weapon_aux2(r++, col, mindam, maxdam, "Vorpal:", TERM_L_RED);
+               #endif
+       }       
+       
+       if ((p_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
        {
-               if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
-                       mult = mult * (o_ptr->dd + 2) / o_ptr->dd;
+               force = TRUE;
+               
+               slaydice_min = calc_slaydam(mindice, 1, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 1, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               
+               /* Print the relevant lines */
+#ifdef JP
+               compare_weapon_aux2(r++, col, mindam, maxdam, "ÍýÎÏ:", TERM_L_BLUE);
+#else
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Force  :", TERM_L_BLUE);
+#endif         
        }
-       if ((p_ptr->pclass != CLASS_SAMURAI) && (f1 & TR1_FORCE_WEPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5))) mult = mult * 7 / 2;
-
+               
        /* Print the relevant lines */
 #ifdef JP
-if (f1 & TR1_FORCE_WEPON)     compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 1*mult, "ÍýÎÏ:", f1, f2, f3, TERM_L_BLUE);
-if (f1 & TR1_SLAY_ANIMAL) compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 2*mult, "ưʪ:", f1, f2, f3, TERM_YELLOW);
-if (f1 & TR1_SLAY_EVIL)   compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 2*mult, "¼Ù°­:", f1, f2, f3, TERM_YELLOW);
-if (f1 & TR1_SLAY_UNDEAD) compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "ÉÔ»à:", f1, f2, f3, TERM_YELLOW);
-if (f1 & TR1_SLAY_DEMON)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "°­Ëâ:", f1, f2, f3, TERM_YELLOW);
-if (f1 & TR1_SLAY_ORC)    compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "¥ª¡¼¥¯:", f1, f2, f3, TERM_YELLOW);
-if (f1 & TR1_SLAY_TROLL)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "¥È¥í¥ë:", f1, f2, f3, TERM_YELLOW);
-if (f1 & TR1_SLAY_GIANT)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "µð¿Í:", f1, f2, f3, TERM_YELLOW);
-if (f1 & TR1_KILL_DRAGON) compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 5*mult, "ε:", f1, f2, f3, TERM_YELLOW);
-else if (f1 & TR1_SLAY_DRAGON) compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "ε:", f1, f2, f3, TERM_YELLOW);
-if (f1 & TR1_BRAND_ACID)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 5*mult/2, "»À°À­:", f1, f2, f3, TERM_RED);
-if (f1 & TR1_BRAND_ELEC)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 5*mult/2, "ÅÅ°À­:", f1, f2, f3, TERM_RED);
-if (f1 & TR1_BRAND_FIRE)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 5*mult/2, "±ê°À­:", f1, f2, f3, TERM_RED);
-if (f1 & TR1_BRAND_COLD)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 5*mult/2, "Îä°À­:", f1, f2, f3, TERM_RED);
-if (f1 & TR1_BRAND_POIS)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 5*mult/2, "ÆÇ°À­:", f1, f2, f3, TERM_RED);
-#else
-       if (f1 & TR1_FORCE_WEPON)     compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 1*mult, "Force  :", f1, f2, f3, TERM_L_BLUE);
-       if (f1 & TR1_SLAY_ANIMAL) compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 2*mult, "Animals:", f1, f2, f3, TERM_YELLOW);
-       if (f1 & TR1_SLAY_EVIL)   compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 2*mult, "Evil:", f1, f2, f3, TERM_YELLOW);
-       if (f1 & TR1_SLAY_UNDEAD) compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Undead:", f1, f2, f3, TERM_YELLOW);
-       if (f1 & TR1_SLAY_DEMON)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Demons:", f1, f2, f3, TERM_YELLOW);
-       if (f1 & TR1_SLAY_ORC)    compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Orcs:", f1, f2, f3, TERM_YELLOW);
-       if (f1 & TR1_SLAY_TROLL)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Trolls:", f1, f2, f3, TERM_YELLOW);
-       if (f1 & TR1_SLAY_GIANT)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Giants:", f1, f2, f3, TERM_YELLOW);
-       if (f1 & TR1_KILL_DRAGON) compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 5*mult, "Dragons:", f1, f2, f3, TERM_YELLOW);
-       else if (f1 & TR1_SLAY_DRAGON) compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Dragons:", f1, f2, f3, TERM_YELLOW);
-       if (f1 & TR1_BRAND_ACID)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Acid:", f1, f2, f3, TERM_RED);
-       if (f1 & TR1_BRAND_ELEC)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Elec:", f1, f2, f3, TERM_RED);
-       if (f1 & TR1_BRAND_FIRE)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Fire:", f1, f2, f3, TERM_RED);
-       if (f1 & TR1_BRAND_COLD)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Cold:", f1, f2, f3, TERM_RED);
-       if (f1 & TR1_BRAND_POIS)  compare_weapon_aux2(o_ptr, p_ptr->num_blow[0], r++, col, 3*mult, "Poison:", f1, f2, f3, TERM_RED);
-#endif
-
-}
-
-static int hit_chance(int to_h, int ac)
-{
-       int chance = 0;
-       int meichuu = p_ptr->skill_thn + (p_ptr->to_h[0] + to_h) * BTH_PLUS_ADJ;
-
-       if (meichuu <= 0) return 5;
-
-       chance = 100 - ((ac * 75) / meichuu);
-
-       if (chance > 95) chance = 95;
-       if (chance < 5) chance = 5;
-       if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
-               chance = (chance*19+9)/20;
-       return chance;
-}
-
-/*
- * Displays all info about a weapon
- *
- * Only accurate for the current weapon, because it includes
- * various info about the player's +to_dam and number of blows.
- */
-static void list_weapon(object_type *o_ptr, int row, int col)
-{
-       char o_name[MAX_NLEN];
-       char tmp_str[80];
-
-       /* Print the weapon name */
-       object_desc(o_name, o_ptr, TRUE, 0);
-       c_put_str(TERM_YELLOW, o_name, row, col);
-
-       /* Print the player's number of blows */
+       if (have_flag(flgs, TR_KILL_ANIMAL))
+       {
+               slaydice_min = calc_slaydam(mindice, 4, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 4, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "ưʪ:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_ANIMAL)) 
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "ưʪ:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_EVIL))
+       {       
+               slaydice_min = calc_slaydam(mindice, 7, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 7, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "¼Ù°­:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_EVIL))
+       {       
+               slaydice_min = calc_slaydam(mindice, 2, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 2, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "¼Ù°­:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_HUMAN))
+       {       
+               slaydice_min = calc_slaydam(mindice, 4, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 4, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "¿Í´Ö:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_HUMAN))
+       {       
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "¿Í´Ö:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_UNDEAD))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "ÉÔ»à:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_UNDEAD)) 
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "ÉÔ»à:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_DEMON))
+       {       
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "°­Ëâ:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_DEMON))
+       {       
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "°­Ëâ:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_ORC))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "¥ª¡¼¥¯:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_ORC))
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "¥ª¡¼¥¯:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_TROLL))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "¥È¥í¥ë:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_TROLL))
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "¥È¥í¥ë:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_GIANT))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "µð¿Í:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_GIANT))
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "µð¿Í:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_DRAGON))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "ε:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_DRAGON))
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "ε:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_BRAND_ACID))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "»À°À­:", TERM_RED);
+       }
+       if (have_flag(flgs, TR_BRAND_ELEC))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "ÅÅ°À­:", TERM_RED);
+       }
+       if (have_flag(flgs, TR_BRAND_FIRE))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "±ê°À­:", TERM_RED);
+       }
+       if (have_flag(flgs, TR_BRAND_COLD))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Îä°À­:", TERM_RED);
+       }
+       if (have_flag(flgs, TR_BRAND_POIS))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "ÆÇ°À­:", TERM_RED);
+       }
+#else
+       if (have_flag(flgs, TR_KILL_ANIMAL))
+       {
+               slaydice_min = calc_slaydam(mindice, 4, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 4, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Animals:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_ANIMAL)) 
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Animals:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_EVIL))
+       {       
+               slaydice_min = calc_slaydam(mindice, 7, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 7, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Evil:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_EVIL))
+       {       
+               slaydice_min = calc_slaydam(mindice, 2, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 2, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Evil:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_HUMAN))
+       {       
+               slaydice_min = calc_slaydam(mindice, 4, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 4, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Human:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_HUMAN))
+       {       
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Human:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_UNDEAD))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Undead:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_UNDEAD)) 
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Undead:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_DEMON))
+       {       
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Demons:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_DEMON))
+       {       
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Demons:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_ORC))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Orcs:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_ORC))
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Orcs:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_TROLL))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Trolls:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_TROLL))
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Trolls:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_GIANT))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Giants:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_GIANT))
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Giants:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_KILL_DRAGON))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Dragons:", TERM_YELLOW);
+       }
+       else if (have_flag(flgs, TR_SLAY_DRAGON))
+       {
+               slaydice_min = calc_slaydam(mindice, 3, 1, force);
+               slaydice_max = calc_slaydam(maxdice, 3, 1, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Dragons:", TERM_YELLOW);
+       }
+       if (have_flag(flgs, TR_BRAND_ACID))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Acid:", TERM_RED);
+       }
+       if (have_flag(flgs, TR_BRAND_ELEC))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Elec:", TERM_RED);
+       }
+       if (have_flag(flgs, TR_BRAND_FIRE))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Fire:", TERM_RED);
+       }
+       if (have_flag(flgs, TR_BRAND_COLD))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Cold:", TERM_RED);
+       }
+       if (have_flag(flgs, TR_BRAND_POIS))
+       {
+               slaydice_min = calc_slaydam(mindice, 5, 2, force);
+               slaydice_max = calc_slaydam(maxdice, 5, 2, force);
+               critdice_min = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_min, p_ptr->to_h[0], dokubari);
+               critdice_max = calc_expext_cirt(o_ptr->weight, o_ptr->to_h, slaydice_max, p_ptr->to_h[0], dokubari);
+               mindam = blow * (calc_slaydam(critdice_min, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               maxdam = blow * (calc_slaydam(critdice_max, vorpal_mult, vorpal_div, FALSE) + o_ptr->to_d + p_ptr->to_d[0]);
+               compare_weapon_aux2(r++, col, mindam, maxdam, "Poison:", TERM_RED);
+       }
+#endif
+       
+}
+
+static int hit_chance(int to_h, int ac)
+{
+       int chance = 0;
+       int meichuu = p_ptr->skill_thn + (p_ptr->to_h[0] + to_h) * BTH_PLUS_ADJ;
+
+       if (meichuu <= 0) return 5;
+
+       chance = 100 - ((ac * 75) / meichuu);
+
+       if (chance > 95) chance = 95;
+       if (chance < 5) chance = 5;
+       if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
+               chance = (chance*19+9)/20;
+       return chance;
+}
+
+/*
+ * Displays all info about a weapon
+ *
+ * Only accurate for the current weapon, because it includes
+ * various info about the player's +to_dam and number of blows.
+ */
+static void list_weapon(object_type *o_ptr, int row, int col)
+{
+       char o_name[MAX_NLEN];
+       char tmp_str[80];
+
+       /* Effective dices */
+       int eff_dd = o_ptr->dd + p_ptr->to_dd[0];
+       int eff_ds = o_ptr->ds + p_ptr->to_ds[0];
+
+       /* Print the weapon name */
+       object_desc(o_name, o_ptr, OD_NAME_ONLY);
+       c_put_str(TERM_YELLOW, o_name, row, col);
+
+       /* Print the player's number of blows */
 #ifdef JP
 sprintf(tmp_str, "¹¶·â²ó¿ô: %d", p_ptr->num_blow[0]);
 #else
@@ -3187,8 +3845,8 @@ sprintf(tmp_str, "
        sprintf(tmp_str, "One Strike: %d-%d damage",
 #endif
 
-           o_ptr->dd + o_ptr->to_d + p_ptr->to_d[0],
-           o_ptr->ds * o_ptr->dd + o_ptr->to_d + p_ptr->to_d[0]);
+           eff_dd + o_ptr->to_d + p_ptr->to_d[0],
+           eff_ds * eff_dd + o_ptr->to_d + p_ptr->to_d[0]);
        put_str(tmp_str, row+6, col+1);
 
        /* Damage for the complete attack (if all blows hit) */
@@ -3198,8 +3856,8 @@ sprintf(tmp_str, "
        sprintf(tmp_str, "One Attack: %d-%d damage",
 #endif
 
-           p_ptr->num_blow[0] * (o_ptr->dd + o_ptr->to_d + p_ptr->to_d[0]),
-           p_ptr->num_blow[0] * (o_ptr->ds * o_ptr->dd + o_ptr->to_d + p_ptr->to_d[0]));
+           p_ptr->num_blow[0] * (eff_dd + o_ptr->to_d + p_ptr->to_d[0]),
+           p_ptr->num_blow[0] * (eff_ds * eff_dd + o_ptr->to_d + p_ptr->to_d[0]));
        put_str(tmp_str, row+7, col+1);
 }
 
@@ -3252,16 +3910,24 @@ static bool item_tester_hook_ammo(object_type *o_ptr)
  * Copies the weapons to compare into the weapon-slot and
  * compares the values for both weapons.
  */
-static bool compare_weapons(void)
+static int compare_weapons(int bcost)
 {
+       int i, n;
        int item, item2;
-       object_type *o1_ptr, *o2_ptr;
+       object_type *o_ptr[2];
        object_type orig_weapon;
        object_type *i_ptr;
        cptr q, s;
        int row = 2;
+       int wid = 38, mgn = 2;
+       bool old_character_xtra = character_xtra;
+       char ch;
+       int total = 0;
+       int cost = 0; /* First time no price */
 
+       /* Save the screen */
        screen_save();
+
        /* Clear the screen */
        clear_bldg(0, 22);
 
@@ -3269,105 +3935,541 @@ static bool compare_weapons(void)
        i_ptr = &inventory[INVEN_RARM];
        object_copy(&orig_weapon, i_ptr);
 
-       item_tester_no_ryoute = TRUE;
        /* Only compare melee weapons */
+       item_tester_no_ryoute = TRUE;
        item_tester_hook = item_tester_hook_melee_weapon;
 
        /* Get the first weapon */
-#ifdef JP
-q = "Âè°ì¤ÎÉð´ï¤Ï¡©";
-s = "Èæ¤Ù¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
-#else
-       q = "What is your first weapon? ";
-       s = "You have nothing to compare.";
-#endif
+       q = _("Âè°ì¤ÎÉð´ï¤Ï¡©", "What is your first weapon? ");
+       s = _("Èæ¤Ù¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£", "You have nothing to compare.");
 
        if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN)))
        {
                screen_load();
-               return (FALSE);
+               return (0);
        }
 
        /* Get the item (in the pack) */
-       o1_ptr = &inventory[item];
+       o_ptr[0] = &inventory[item];
+       n = 1;
+       total = bcost;
 
-       /* Clear the screen */
+       while (TRUE)
+       {
+               /* Clear the screen */
+               clear_bldg(0, 22);
+
+               /* Only compare melee weapons */
+               item_tester_no_ryoute = TRUE;
+               item_tester_hook = item_tester_hook_melee_weapon;
+
+               /* Hack -- prevent "icky" message */
+               character_xtra = TRUE;
+
+               /* Diaplay selected weapon's infomation */
+               for (i = 0; i < n; i++)
+               {
+                       int col = (wid * i + mgn);
+
+                       /* Copy i-th weapon into the weapon slot (if it's not already there) */
+                       if (o_ptr[i] != i_ptr) object_copy(i_ptr, o_ptr[i]);
+
+                       /* Get the new values */
+                       calc_bonuses();
+
+                       /* List the new values */
+                       list_weapon(o_ptr[i], row, col);
+                       compare_weapon_aux1(o_ptr[i], col, row + 8);
+               }
+
+               character_xtra = old_character_xtra;
+
+#ifdef JP
+               put_str(format("[ Èæ³ÓÂоÝ: 's'¤ÇÊѹ¹ ($%d) ]", cost), 1, (wid + mgn));
+               put_str("(°ìÈֹ⤤¥À¥á¡¼¥¸¤¬Å¬ÍѤµ¤ì¤Þ¤¹¡£Ê£¿ô¤ÎÇÜÂǸú²Ì¤Ï­¤·»»¤µ¤ì¤Þ¤»¤ó¡£)", row + 4, 0);
+               prt("¸½ºß¤Îµ»Î̤«¤éȽÃǤ¹¤ë¤È¡¢¤¢¤Ê¤¿¤ÎÉð´ï¤Ï°Ê²¼¤Î¤è¤¦¤Ê°ÒÎϤòȯ´ø¤·¤Þ¤¹:", 0, 0);
+#else
+               put_str(format("[ 's' Select secondary weapon($%d) ]", cost), row + 1, (wid * i + mgn));
+               put_str("(Only highest damage applies per monster. Special damage not cumulative.)", row + 4, 0);
+               prt("Based on your current abilities, here is what your weapons will do", 0, 0);
+#endif
+
+               flush();
+               ch = inkey();
+
+               if (ch == 's')
+               {
+                       if (total + cost > p_ptr->au)
+                       {
+                               msg_print(_("¤ª¶â¤¬Â­¤ê¤Þ¤»¤ó¡ª", "You don't have enough money!"));
+                               msg_print(NULL);
+                               continue;
+                       }
+
+                       q = _("ÂèÆó¤ÎÉð´ï¤Ï¡©", "What is your second weapon? ");
+                       s = _("Èæ¤Ù¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£", "You have nothing to compare.");
+
+                       /* Get the second weapon */
+                       if (!get_item(&item2, q, s, (USE_EQUIP | USE_INVEN))) continue;
+
+                       total += cost;
+                       cost = bcost / 2;
+
+                       /* Get the item (in the pack) */
+                       o_ptr[1] = &inventory[item2];
+                       n = 2;
+               }
+               else
+               {
+                       break;
+               }
+       }
+
+       /* Copy back the original weapon into the weapon slot */
+       object_copy(i_ptr, &orig_weapon);
+
+       /* Reset the values for the old weapon */
+       calc_bonuses();
+       screen_load();
+
+       /* Done */
+       return (total);
+}
+
+
+/*
+ * Evaluate AC
+ *
+ * AC¤«¤é²óÈòΨ¡¢¥À¥á¡¼¥¸¸º¾¯Î¨¤ò·×»»¤·É½¼¨¤¹¤ë
+ * Calculate and display the dodge-rate and the protection-rate
+ * based on AC
+ */
+static bool eval_ac(int iAC)
+{
+#ifdef JP
+       const char memo[] =
+               "¥À¥á¡¼¥¸·Ú¸ºÎ¨¤È¤Ï¡¢Å¨¤Î¹¶·â¤¬Åö¤¿¤Ã¤¿»þ¤½¤Î¥À¥á¡¼¥¸¤ò\n"
+               "²¿¥Ñ¡¼¥»¥ó¥È·Ú¸º¤¹¤ë¤«¤ò¼¨¤·¤Þ¤¹¡£\n"
+               "¥À¥á¡¼¥¸·Ú¸º¤ÏÄ̾ï¤ÎľÀܹ¶·â(¼ïÎब¡Ö¹¶·â¤¹¤ë¡×¤È¡ÖÊ´ºÕ¤¹¤ë¡×¤Îʪ)\n"
+               "¤ËÂФ·¤Æ¤Î¤ß¸ú²Ì¤¬¤¢¤ê¤Þ¤¹¡£\n \n"
+               "Ũ¤Î¥ì¥Ù¥ë¤È¤Ï¡¢¤½¤ÎŨ¤¬Ä̾ﲿ³¬¤Ë¸½¤ì¤ë¤«¤ò¼¨¤·¤Þ¤¹¡£\n \n"
+               "²óÈòΨ¤ÏŨ¤ÎľÀܹ¶·â¤ò²¿¥Ñ¡¼¥»¥ó¥È¤Î³ÎΨ¤ÇÈò¤±¤ë¤«¤ò¼¨¤·¡¢\n"
+               "Ũ¤Î¥ì¥Ù¥ë¤È¤¢¤Ê¤¿¤ÎAC¤Ë¤è¤Ã¤Æ·èÄꤵ¤ì¤Þ¤¹¡£\n \n"
+               "¥À¥á¡¼¥¸´üÂÔÃͤȤϡ¢Å¨¤Î£±£°£°¥Ý¥¤¥ó¥È¤ÎÄ̾ﹶ·â¤ËÂФ·¡¢\n"
+               "²óÈòΨ¤È¥À¥á¡¼¥¸·Ú¸ºÎ¨¤ò¹Íθ¤·¤¿¥À¥á¡¼¥¸¤Î´üÂÔÃͤò¼¨¤·¤Þ¤¹¡£\n";
+#else
+       const char memo[] =
+               "'Protection Rate' means how much damage is reduced by your armor.\n"
+               "Note that the Protection rate is effective only against normal "
+               "'attack' and 'shatter' type melee attacks, "
+               "and has no effect against any other types such as 'poison'.\n \n"
+               "'Dodge Rate' indicates the success rate on dodging the "
+               "monster's melee attacks.  "
+               "It is depend on the level of the monster and your AC.\n \n"
+               "'Average Damage' indicates the expected amount of damage "
+               "when you are attacked by normal melee attacks with power=100.";
+#endif
+
+       int protection;
+       int col, row = 2;
+       int lvl;
+       char buf[80*20], *t;
+
+       /* AC lower than zero has no effect */
+       if (iAC < 0) iAC = 0;
+
+       /* ¥À¥á¡¼¥¸·Ú¸ºÎ¨¤ò·×»» */
+       protection = 100 * MIN(iAC, 150) / 250;
+
+       screen_save();
        clear_bldg(0, 22);
 
-       item_tester_no_ryoute = TRUE;
-       /* Only compare melee weapons */
-       item_tester_hook = item_tester_hook_melee_weapon;
+#ifdef JP
+       put_str(format("¤¢¤Ê¤¿¤Î¸½ºß¤ÎAC: %3d", iAC), row++, 0);
+       put_str(format("¥À¥á¡¼¥¸·Ú¸ºÎ¨  : %3d%%", protection), row++, 0);
+       row++;
+
+       put_str("Ũ¤Î¥ì¥Ù¥ë      :", row + 0, 0);
+       put_str("²óÈòΨ          :", row + 1, 0);
+       put_str("¥À¥á¡¼¥¸´üÂÔÃÍ  :", row + 2, 0);
+#else
+       put_str(format("Your current AC : %3d", iAC), row++, 0);
+       put_str(format("Protection rate : %3d%%", protection), row++, 0);
+       row++;
+
+       put_str("Level of Monster:", row + 0, 0);
+       put_str("Dodge Rate      :", row + 1, 0);
+       put_str("Average Damage  :", row + 2, 0);
+#endif
+    
+       for (col = 17 + 1, lvl = 0; lvl <= 100; lvl += 10, col += 5)
+       {
+               int quality = 60 + lvl * 3; /* attack quality with power 60 */
+               int dodge;   /* ²óÈòΨ(%) */
+               int average; /* ¥À¥á¡¼¥¸´üÂÔÃÍ */
+
+               put_str(format("%3d", lvl), row + 0, col);
+
+               /* ²óÈòΨ¤ò·×»» */
+               dodge = 5 + (MIN(100, 100 * (iAC * 3 / 4) / quality) * 9 + 5) / 10;
+               put_str(format("%3d%%", dodge), row + 1, col);
+
+               /* 100ÅÀ¤Î¹¶·â¤ËÂФ·¤Æ¤Î¥À¥á¡¼¥¸´üÂÔÃͤò·×»» */
+               average = (100 - dodge) * (100 - protection) / 100;
+               put_str(format("%3d", average), row + 2, col);
+       }
+
+       /* Display note */
+       roff_to_buf(memo, 70, buf, sizeof(buf));
+       for (t = buf; t[0]; t += strlen(t) + 1)
+               put_str(t, (row++) + 4, 4);
 
-       /* Get the second weapon */
 #ifdef JP
-q = "ÂèÆó¤ÎÉð´ï¤Ï¡©";
-s = "Èæ¤Ù¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
+       prt("¸½ºß¤Î¤¢¤Ê¤¿¤ÎÁõÈ÷¤«¤é¤¹¤ë¤È¡¢¤¢¤Ê¤¿¤ÎËɸæÎϤÏ"
+                  "¤³¤ì¤¯¤é¤¤¤Ç¤¹:", 0, 0);
 #else
-       q = "What is your second weapon? ";
-       s = "You have nothing to compare.";
+       prt("Defense abilities from your current Armor Class are evaluated below.", 0, 0);
 #endif
+  
+       flush();
+       (void)inkey();
+       screen_load();
+
+       /* Done */
+       return (TRUE);
+}
+
+
+/*
+ * Hook to specify "broken weapon"
+ */
+static bool item_tester_hook_broken_weapon(object_type *o_ptr)
+{
+       if (o_ptr->tval != TV_SWORD) return FALSE;
 
-       if (!get_item(&item2, q, s, (USE_EQUIP | USE_INVEN)))
+       switch (o_ptr->sval)
        {
-               screen_load();
-               return (FALSE);
+       case SV_BROKEN_DAGGER:
+       case SV_BROKEN_SWORD:
+               return TRUE;
        }
 
-       /* Get the item (in the pack) */
-       o2_ptr = &inventory[item2];
+       return FALSE;
+}
 
-       /* Clear the screen */
+static void give_one_ability_of_object(object_type *to_ptr, object_type *from_ptr)
+{
+       int i, n = 0;
+       int idx = 0;
+       int cand[TR_FLAG_MAX];
+       u32b to_flgs[TR_FLAG_SIZE];
+       u32b from_flgs[TR_FLAG_SIZE];
+
+       object_flags(to_ptr, to_flgs);
+       object_flags(from_ptr, from_flgs);
+
+       for (i = 0; i < TR_FLAG_MAX; i++)
+       {
+               switch (i)
+               {
+               case TR_IGNORE_ACID:
+               case TR_IGNORE_ELEC:
+               case TR_IGNORE_FIRE:
+               case TR_IGNORE_COLD:
+               case TR_ACTIVATE:
+               case TR_RIDING:
+               case TR_THROW:
+               case TR_SHOW_MODS:
+               case TR_HIDE_TYPE:
+               case TR_ES_ATTACK:
+               case TR_ES_AC:
+               case TR_FULL_NAME:
+               case TR_FIXED_FLAVOR:
+                       break;
+               default:
+                       if (have_flag(from_flgs, i) && !have_flag(to_flgs, i))
+                       {
+                               if (!(is_pval_flag(i) && (from_ptr->pval < 1))) cand[n++] = i;
+                       }
+               }
+       }
+
+       if (n > 0)
+       {
+               int bmax;
+               int tr_idx = cand[randint0(n)];
+               add_flag(to_ptr->art_flags, tr_idx);
+               if (is_pval_flag(tr_idx)) to_ptr->pval = MAX(to_ptr->pval, 1);
+               bmax = MIN(3, MAX(1, 40 / (to_ptr->dd * to_ptr->ds)));
+               if (tr_idx == TR_BLOWS) to_ptr->pval = MIN(to_ptr->pval, bmax);
+               if (tr_idx == TR_SPEED) to_ptr->pval = MIN(to_ptr->pval, 4);
+       }
+
+       return;
+}
+
+/*
+ * Repair broken weapon
+ */
+static int repair_broken_weapon_aux(int bcost)
+{
+       s32b cost;
+       int item, mater;
+       object_type *o_ptr, *mo_ptr; /* broken weapon and material weapon */
+       object_kind *k_ptr;
+       int i, k_idx, tr_idx, dd_bonus, ds_bonus;
+       char basenm[MAX_NLEN];
+       cptr q, s; /* For get_item prompt */
+       int row = 7;
+
+       /* Clear screen */
        clear_bldg(0, 22);
 
-       /* Copy first weapon into the weapon slot (if it's not already there) */
-       if (o1_ptr != i_ptr)
-               object_copy(i_ptr, o1_ptr);
+       /* Notice */
+       prt(_("½¤Éü¤Ë¤ÏºàÎÁ¤È¤Ê¤ë¤â¤¦1¤Ä¤ÎÉð´ï¤¬É¬ÍפǤ¹¡£", "Hand one material weapon to repair a broken weapon."), row, 2);
+       prt(_("ºàÎÁ¤Ë»ÈÍѤ·¤¿Éð´ï¤Ï¤Ê¤¯¤Ê¤ê¤Þ¤¹¡ª", "The material weapon will disappear after repairing!!"), row+1, 2);
 
-       /* Get the new values */
-       calc_bonuses();
+       /* Get an item */
+       q = _("¤É¤ÎÀޤ줿Éð´ï¤ò½¤Éü¤·¤Þ¤¹¤«¡©", "Repair which broken weapon? ");
+       s = _("½¤Éü¤Ç¤­¤ëÀޤ줿Éð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£", "You have no broken weapon to repair.");
 
-       /* List the new values */
-       list_weapon(o1_ptr, row, 2);
-       compare_weapon_aux1(o1_ptr, 2, row + 8);
+       /* Only forge broken weapons */
+       item_tester_hook = item_tester_hook_broken_weapon;
 
-       /* Copy second weapon into the weapon slot (if it's not already there) */
-       if (o2_ptr != i_ptr)
-               object_copy(i_ptr, o2_ptr);
-       else
-               object_copy(i_ptr, &orig_weapon);
+       if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP))) return (0);
 
-       /* Get the new values */
-       calc_bonuses();
+       /* Get the item (in the pack) */
+       o_ptr = &inventory[item];
 
-       /* List the new values */
-       list_weapon(o2_ptr, row, 40);
-       compare_weapon_aux1(o2_ptr, 40, row + 8);
+       /* It is worthless */
+       if (!object_is_ego(o_ptr) && !object_is_artifact(o_ptr))
+       {
+               msg_format(_("¤½¤ì¤Ïľ¤·¤Æ¤â¤·¤ç¤¦¤¬¤Ê¤¤¤¼¡£", "It is worthless to repair."));
+               return (0);
+       }
 
-       /* Copy back the original weapon into the weapon slot */
-       object_copy(i_ptr, &orig_weapon);
+       /* They are too many */
+       if (o_ptr->number > 1)
+       {
+               msg_format(_("°ìÅÙ¤ËÊ£¿ô¤ò½¤Éü¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡ª", "They are too many to repair at once!"));
+               return (0);
+       }
 
-       /* Reset the values for the old weapon */
-       calc_bonuses();
+       /* Display item name */
+       object_desc(basenm, o_ptr, OD_NAME_ONLY);
+       prt(format(_("½¤Éü¤¹¤ëÉð´ï¡¡¡§ %s", "Repairing: %s"), basenm), row+3, 2);
+
+       /* Get an item */
+       q = _("ºàÎÁ¤È¤Ê¤ëÉð´ï¤Ï¡©", "Which weapon for material? ");
+       s = _("ºàÎÁ¤È¤Ê¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£", "You have no material to repair.");
+
+       /* Only forge broken weapons */
+       item_tester_hook = item_tester_hook_melee_weapon;
+
+       if (!get_item(&mater, q, s, (USE_INVEN | USE_EQUIP))) return (0);
+       if (mater == item)
+       {
+               msg_print(_("¥¯¥é¥¤¥ó¤ÎÄÛ¤¸¤ã¤Ê¤¤¡ª", "This is not a klein bottle!"));
+               return (0);
+       }
+
+       /* Get the item (in the pack) */
+       mo_ptr = &inventory[mater];
+
+       /* Display item name */
+       object_desc(basenm, mo_ptr, OD_NAME_ONLY);
+       prt(format(_("ºàÎÁ¤È¤¹¤ëÉð´ï¡§ %s", "Material : %s"), basenm), row+4, 2);
+
+       /* Get the value of one of the items (except curses) */
+       cost = bcost + object_value_real(o_ptr) * 2;
 
 #ifdef JP
-put_str("(°ìÈֹ⤤¥À¥á¡¼¥¸¤¬Å¬ÍѤµ¤ì¤Þ¤¹¡£Ê£¿ô¤ÎÇÜÂǸú²Ì¤Ï­¤·»»¤µ¤ì¤Þ¤»¤ó¡£)", row + 4, 0);
+       if (!get_check(format("¡ð%d¤«¤«¤ê¤Þ¤¹¤¬¤è¤í¤·¤¤¤Ç¤¹¤«¡© ", cost))) return (0);
 #else
-       put_str("(Only highest damage applies per monster. Special damage not cumulative.)", row + 4, 0);
+       if (!get_check(format("Costs %d gold, okay? ", cost))) return (0);
 #endif
 
+       /* Check if the player has enough money */
+       if (p_ptr->au < cost)
+       {
+               object_desc(basenm, o_ptr, OD_NAME_ONLY);
+               msg_format(_("%s¤ò½¤Éü¤¹¤ë¤À¤±¤Î¥´¡¼¥ë¥É¤¬¤¢¤ê¤Þ¤»¤ó¡ª",
+                       "You do not have the gold to repair %s!"), basenm);
+               msg_print(NULL);
+               return (0);
+       }
+
+       if (o_ptr->sval == SV_BROKEN_DAGGER)
+       {
+               int i, n = 1;
+
+               for (i = 1; i < max_k_idx; i++)
+               {
+                       object_type forge;
+                       object_kind *k_ptr = &k_info[i];
+
+                       if (k_ptr->tval != TV_SWORD) continue;
+                       if ((k_ptr->sval == SV_BROKEN_DAGGER) ||
+                               (k_ptr->sval == SV_BROKEN_SWORD) ||
+                               (k_ptr->sval == SV_DOKUBARI)) continue;
+                       if (k_ptr->weight > 99) continue;
+
+                       if (one_in_(n)) 
+                       {
+                               k_idx = i;
+                               n++;
+                       }
+               }
+       }
+       else /* TV_BROKEN_SWORD */
+       {
+               /* Repair to a sword or sometimes material's type weapon */
+               int tval = (one_in_(5) ? mo_ptr->tval : TV_SWORD);
+
+               while(1)
+               {
+                       object_kind *ck_ptr;
+
+                       k_idx = lookup_kind(tval, SV_ANY);
+                       ck_ptr = &k_info[k_idx];
+
+                       if (tval == TV_SWORD)
+                       {
+                               if ((ck_ptr->sval == SV_BROKEN_DAGGER) ||
+                                       (ck_ptr->sval == SV_BROKEN_SWORD) ||
+                                       (ck_ptr->sval == SV_DIAMOND_EDGE) ||
+                                       (ck_ptr->sval == SV_DOKUBARI)) continue;
+                       }
+                       if (tval == TV_POLEARM)
+                       {
+                               if ((ck_ptr->sval == SV_DEATH_SCYTHE) ||
+                                       (ck_ptr->sval == SV_TSURIZAO)) continue;
+                       }
+                       if (tval == TV_HAFTED)
+                       {
+                               if ((ck_ptr->sval == SV_GROND) ||
+                                       (ck_ptr->sval == SV_WIZSTAFF) ||
+                                       (ck_ptr->sval == SV_NAMAKE_HAMMER)) continue;
+                       }
+
+                       break;
+               }
+       }
+
+       /* Calculate dice bonuses */
+       dd_bonus = o_ptr->dd - k_info[o_ptr->k_idx].dd;
+       ds_bonus = o_ptr->ds - k_info[o_ptr->k_idx].ds;
+       dd_bonus += mo_ptr->dd - k_info[mo_ptr->k_idx].dd;
+       ds_bonus += mo_ptr->ds - k_info[mo_ptr->k_idx].ds;
+
+       /* Change base object */
+       k_ptr = &k_info[k_idx];
+       o_ptr->k_idx = k_idx;
+       o_ptr->weight = k_ptr->weight;
+       o_ptr->tval = k_ptr->tval;
+       o_ptr->sval = k_ptr->sval;
+       o_ptr->dd = k_ptr->dd;
+       o_ptr->ds = k_ptr->ds;
+
+       /* Copy base object's ability */
+       for (i = 0; i < TR_FLAG_SIZE; i++) o_ptr->art_flags[i] |= k_ptr->flags[i];
+       if (k_ptr->pval) o_ptr->pval = MAX(o_ptr->pval, randint1(k_ptr->pval));
+       if (have_flag(k_ptr->flags, TR_ACTIVATE)) o_ptr->xtra2 = k_ptr->act_idx;
+
+       /* Dice up */
+       if (dd_bonus > 0)
+       {
+               o_ptr->dd++;
+               for (i = 0; i < dd_bonus; i++)
+               {
+                       if (one_in_(o_ptr->dd + i)) o_ptr->dd++;
+               }
+       }
+       if (ds_bonus > 0)
+       {
+               o_ptr->ds++;
+               for (i = 0; i < ds_bonus; i++)
+               {
+                       if (one_in_(o_ptr->ds + i)) o_ptr->ds++;
+               }
+       }
+
+       /* */
+       if (have_flag(k_ptr->flags, TR_BLOWS))
+       {
+               int bmax = MIN(3, MAX(1, 40 / (o_ptr->dd * o_ptr->ds)));
+               o_ptr->pval = MIN(o_ptr->pval, bmax);
+       }
+
+       /* Add one random ability from material weapon */
+       give_one_ability_of_object(o_ptr, mo_ptr);
+
+       /* Add to-dam, to-hit and to-ac from material weapon */
+       o_ptr->to_d += MAX(0, (mo_ptr->to_d / 3));
+       o_ptr->to_h += MAX(0, (mo_ptr->to_h / 3));
+       o_ptr->to_a += MAX(0, (mo_ptr->to_a));
+
+       if ((o_ptr->name1 == ART_NARSIL) ||
+               (object_is_random_artifact(o_ptr) && one_in_(1)) ||
+               (object_is_ego(o_ptr) && one_in_(7)))
+       {
+               /* Forge it */
+               if (object_is_ego(o_ptr))
+               {
+                       add_flag(o_ptr->art_flags, TR_IGNORE_FIRE);
+                       add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
+               }
+
+               /* Add one random ability from material weapon */
+               give_one_ability_of_object(o_ptr, mo_ptr);
+
+               /* Add one random activation */
+               if (!activation_index(o_ptr)) one_activation(o_ptr);
+
+               /* Narsil */
+               if (o_ptr->name1 == ART_NARSIL)
+               {
+                       one_high_resistance(o_ptr);
+                       one_ability(o_ptr);
+               }
+
+               msg_print(_("¤³¤ì¤Ï¤«¤Ê¤ê¤Î¶Èʪ¤À¤Ã¤¿¤è¤¦¤À¡£", "This blade seems to be exceptionally."));
+       }
+
+       object_desc(basenm, o_ptr, OD_NAME_ONLY);
 #ifdef JP
-msg_print("¸½ºß¤Îµ»Î̤«¤éȽÃǤ¹¤ë¤È¡¢¤¢¤Ê¤¿¤ÎÉð´ï¤Ï°Ê²¼¤Î¤è¤¦¤Ê°ÒÎϤòȯ´ø¤·¤Þ¤¹:");
+       msg_format("¡ð%d¤Ç%s¤Ë½¤Éü¤·¤Þ¤·¤¿¡£", cost, basenm);
 #else
-       msg_print("Based on your current abilities, here is what your weapons will do");
+       msg_format("Repaired into %s for %d gold.", basenm, cost);
 #endif
+       msg_print(NULL);
+
+       /* Remove BROKEN flag */
+       o_ptr->ident &= ~(IDENT_BROKEN);
+
+       /* Add repaired flag */
+       o_ptr->discount = 99;
+
+       /* Decrease material object */
+       inven_item_increase(mater, -1);
+       inven_item_optimize(mater);
+
+       /* Copyback */
+       p_ptr->update |= PU_BONUS;
+       handle_stuff();
+
+       /* Something happened */
+       return (cost);
+}
 
+static int repair_broken_weapon(int bcost)
+{
+       int cost;
 
-       flush();
-       (void)inkey();
+       screen_save();
+       cost = repair_broken_weapon_aux(bcost);
        screen_load();
-
-       /* Done */
-       return (TRUE);
+       return cost;
 }
 
 
@@ -3383,11 +4485,10 @@ static bool enchant_item(int cost, int to_hit, int to_dam, int to_ac)
        int         maxenchant = (p_ptr->lev / 5);
        char        tmp_str[MAX_NLEN];
 
-
        clear_bldg(4, 18);
 #ifdef JP
-prt(format("¸½ºß¤Î¤¢¤Ê¤¿¤Îµ»Î̤À¤È¡¢+%d ¤Þ¤Ç²þÎɤǤ­¤Þ¤¹¡£", maxenchant), 5, 0);
-prt(format(" ²þÎɤÎÎÁ¶â¤Ï°ì¸Ä¤Ë¤Ä¤­¡ð%d ¤Ç¤¹¡£", cost), 7, 0);
+       prt(format("¸½ºß¤Î¤¢¤Ê¤¿¤Îµ»Î̤À¤È¡¢+%d ¤Þ¤Ç²þÎɤǤ­¤Þ¤¹¡£", maxenchant), 5, 0);
+       prt(format(" ²þÎɤÎÎÁ¶â¤Ï°ì¸Ä¤Ë¤Ä¤­¡ð%d ¤Ç¤¹¡£", cost), 7, 0);
 #else
        prt(format("  Based on your skill, we can improve up to +%d.", maxenchant), 5, 0);
        prt(format("  The price for the service is %d gold per item.", cost), 7, 0);
@@ -3397,8 +4498,8 @@ prt(format(" 
 
        /* Get an item */
 #ifdef JP
-q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
-s = "²þÎɤǤ­¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
+       q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²þÎɤ·¤Þ¤¹¤«¡©";
+       s = "²þÎɤǤ­¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
 #else
        q = "Improve which item? ";
        s = "You have nothing to improve.";
@@ -3412,9 +4513,9 @@ s = "
        /* Check if the player has enough money */
        if (p_ptr->au < (cost * o_ptr->number))
        {
-               object_desc(tmp_str, o_ptr, TRUE, 0);
+               object_desc(tmp_str, o_ptr, OD_NAME_ONLY);
 #ifdef JP
-msg_format("%s¤ò²þÎɤ¹¤ë¤À¤±¤Î¥´¡¼¥ë¥É¤¬¤¢¤ê¤Þ¤»¤ó¡ª", tmp_str);
+               msg_format("%s¤ò²þÎɤ¹¤ë¤À¤±¤Î¥´¡¼¥ë¥É¤¬¤¢¤ê¤Þ¤»¤ó¡ª", tmp_str);
 #else
                msg_format("You do not have the gold to improve %s!", tmp_str);
 #endif
@@ -3469,21 +4570,20 @@ msg_format("%s
 
                /* Message */
 #ifdef JP
-msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
+               msg_print("²þÎɤ˼ºÇÔ¤·¤¿¡£");
 #else
                msg_print("The improvement failed.");
 #endif
 
-
                return (FALSE);
        }
        else
        {
-               object_desc(tmp_str, o_ptr, TRUE, 1);
+               object_desc(tmp_str, o_ptr, OD_NAME_AND_ENCHANT);
 #ifdef JP
-msg_format("¡ð%d ¤Ç%s¤ò²þÎɤ·¤Þ¤·¤¿¡£", cost * o_ptr->number, tmp_str );
+               msg_format("¡ð%d¤Ç%s¤Ë²þÎɤ·¤Þ¤·¤¿¡£", cost * o_ptr->number, tmp_str);
 #else
-               msg_format("Improved %s for %d gold.", tmp_str, cost * o_ptr->number);
+               msg_format("Improved into %s for %d gold.", tmp_str, cost * o_ptr->number);
 #endif
 
                /* Charge the money */
@@ -3562,7 +4662,7 @@ s = "
         * the level of the item or the number of charges.
         */
        /* The item must be "known" */
-       if (!object_known_p(o_ptr))
+       if (!object_is_known(o_ptr))
        {
 #ifdef JP
 msg_format("½¼Å¶¤¹¤ëÁ°¤Ë´ÕÄꤵ¤ì¤Æ¤¤¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡ª");
@@ -3587,7 +4687,7 @@ get_check("
                        identify_item(o_ptr);
 
                        /* Description */
-                       object_desc(tmp_str, o_ptr, TRUE, 3);
+                       object_desc(tmp_str, o_ptr, 0);
 
 #ifdef JP
 msg_format("%s ¤Ç¤¹¡£", tmp_str);
@@ -3595,6 +4695,8 @@ msg_format("%s 
                        msg_format("You have: %s.", tmp_str);
 #endif
 
+                       /* Auto-inscription */
+                       autopick_alter_item(item, FALSE);
 
                        /* Update the gold display */
                        building_prt_gold();
@@ -3606,7 +4708,7 @@ msg_format("%s 
        }
 
        /* Extract the object "level" */
-       lev = get_object_level(o_ptr);
+       lev = k_info[o_ptr->k_idx].level;
 
        /* Price for a rod */
        if (o_ptr->tval == TV_ROD)
@@ -3632,7 +4734,7 @@ msg_format("
        else if (o_ptr->tval == TV_STAFF)
        {
                /* Price per charge ( = double the price paid by shopkeepers for the charge) */
-               price = (get_object_cost(o_ptr) / 10) * o_ptr->number;
+               price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
 
                /* Pay at least 10 gold per charge */
                price = MAX(10, price);
@@ -3640,7 +4742,7 @@ msg_format("
        else
        {
                /* Price per charge ( = double the price paid by shopkeepers for the charge) */
-               price = (get_object_cost(o_ptr) / 10);
+               price = (k_info[o_ptr->k_idx].cost / 10);
 
                /* Pay at least 10 gold per charge */
                price = MAX(10, price);
@@ -3692,7 +4794,7 @@ msg_print("
        /* Check if the player has enough money */
        if (p_ptr->au < price)
        {
-               object_desc(tmp_str, o_ptr, TRUE, 0);
+               object_desc(tmp_str, o_ptr, OD_NAME_ONLY);
 #ifdef JP
 msg_format("%s¤òºÆ½¼Å¶¤¹¤ë¤Ë¤Ï¡ð%d É¬ÍפǤ¹¡ª", tmp_str,price );
 #else
@@ -3735,7 +4837,7 @@ charges = get_quantity(format("
                charges = get_quantity(format("Add how many charges for %d gold? ",
 #endif
 
-                             price), MIN(p_ptr->au / price, max_charges));
+                             price), MIN(p_ptr->au / price, max_charges));
 
                /* Do nothing */
                if (charges < 1) return;
@@ -3751,7 +4853,7 @@ charges = get_quantity(format("
        }
 
        /* Give feedback */
-       object_desc(tmp_str, o_ptr, TRUE, 3);
+       object_desc(tmp_str, o_ptr, 0);
 #ifdef JP
 msg_format("%s¤ò¡ð%d ¤ÇºÆ½¼Å¶¤·¤Þ¤·¤¿¡£", tmp_str, price);
 #else
@@ -3793,7 +4895,7 @@ static void building_recharge_all(void)
 
 
        /* Display some info */
-        msg_flag = FALSE;
+       msg_flag = FALSE;
        clear_bldg(4, 18);
 #ifdef JP
        prt("  ºÆ½¼Å¶¤ÎÈñÍѤϥ¢¥¤¥Æ¥à¤Î¼ïÎà¤Ë¤è¤ê¤Þ¤¹¡£", 6, 0);
@@ -3810,10 +4912,10 @@ static void building_recharge_all(void)
                if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
 
                /* need identified */
-               if (!object_known_p(o_ptr)) total_cost += 50;
+               if (!object_is_known(o_ptr)) total_cost += 50;
 
                /* Extract the object "level" */
-               lev = get_object_level(o_ptr);
+               lev = k_info[o_ptr->k_idx].level;
 
                k_ptr = &k_info[o_ptr->k_idx];
 
@@ -3825,7 +4927,7 @@ static void building_recharge_all(void)
 
                case TV_STAFF:
                        /* Price per charge ( = double the price paid by shopkeepers for the charge) */
-                       price = (get_object_cost(o_ptr) / 10) * o_ptr->number;
+                       price = (k_info[o_ptr->k_idx].cost / 10) * o_ptr->number;
 
                        /* Pay at least 10 gold per charge */
                        price = MAX(10, price);
@@ -3836,7 +4938,7 @@ static void building_recharge_all(void)
 
                case TV_WAND:
                        /* Price per charge ( = double the price paid by shopkeepers for the charge) */
-                       price = (get_object_cost(o_ptr) / 10);
+                       price = (k_info[o_ptr->k_idx].cost / 10);
 
                        /* Pay at least 10 gold per charge */
                        price = MAX(10, price);
@@ -3885,12 +4987,18 @@ static void building_recharge_all(void)
        {
                o_ptr = &inventory[i];
                k_ptr = &k_info[o_ptr->k_idx];
-                               
+
                /* skip non magic device */
                if (o_ptr->tval < TV_STAFF || o_ptr->tval > TV_ROD) continue;
 
                /* Identify it */
-               if (!object_known_p(o_ptr)) identify_item(o_ptr);
+               if (!object_is_known(o_ptr))
+               {
+                       identify_item(o_ptr);
+
+                       /* Auto-inscription */
+                       autopick_alter_item(i, FALSE);
+               }
 
                /* Recharge */
                switch (o_ptr->tval)
@@ -4017,7 +5125,7 @@ bool tele_town(void)
                        }
                }
        }
-       p_ptr->leftbldg = TRUE;
+
        p_ptr->leaving = TRUE;
        leave_bldg = TRUE;
        p_ptr->teleport_town = TRUE;
@@ -4027,6 +5135,306 @@ bool tele_town(void)
 
 
 /*
+ *  research_mon
+ *  -KMW-
+ */
+static bool research_mon(void)
+{
+       int i, n, r_idx;
+       char sym, query;
+       char buf[128];
+
+       bool notpicked;
+
+       bool recall = FALSE;
+
+       u16b why = 0;
+
+       u16b    *who;
+
+       /* XTRA HACK WHATSEARCH */
+       bool    all = FALSE;
+       bool    uniq = FALSE;
+       bool    norm = FALSE;
+       char temp[80] = "";
+
+       /* XTRA HACK REMEMBER_IDX */
+       static int old_sym = '\0';
+       static int old_i = 0;
+
+
+       /* Save the screen */
+       screen_save();
+
+       /* Get a character, or abort */
+#ifdef JP
+if (!get_com("¥â¥ó¥¹¥¿¡¼¤Îʸ»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤(µ­¹æ or ^AÁ´,^U¥æ,^NÈó¥æ,^M̾Á°):", &sym, FALSE)) 
+#else
+       if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym, FALSE))
+#endif
+
+       {
+               /* Restore */
+               screen_load();
+
+               return (FALSE);
+       }
+
+       /* Find that character info, and describe it */
+       for (i = 0; ident_info[i]; ++i)
+       {
+               if (sym == ident_info[i][0]) break;
+       }
+
+               /* XTRA HACK WHATSEARCH */
+       if (sym == KTRL('A'))
+       {
+               all = TRUE;
+#ifdef JP
+               strcpy(buf, "Á´¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
+#else
+               strcpy(buf, "Full monster list.");
+#endif
+       }
+       else if (sym == KTRL('U'))
+       {
+               all = uniq = TRUE;
+#ifdef JP
+               strcpy(buf, "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
+#else
+               strcpy(buf, "Unique monster list.");
+#endif
+       }
+       else if (sym == KTRL('N'))
+       {
+               all = norm = TRUE;
+#ifdef JP
+               strcpy(buf, "¥æ¥Ë¡¼¥¯³°¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
+#else
+               strcpy(buf, "Non-unique monster list.");
+#endif
+       }
+       else if (sym == KTRL('M'))
+       {
+               all = TRUE;
+#ifdef JP
+               if (!get_string("̾Á°(±Ñ¸ì¤Î¾ì¹ç¾®Ê¸»ú¤Ç²Ä)",temp, 70))
+#else
+               if (!get_string("Enter name:",temp, 70))
+#endif
+               {
+                       temp[0]=0;
+
+                       /* Restore */
+                       screen_load();
+
+                       return FALSE;
+               }
+#ifdef JP
+               sprintf(buf, "̾Á°:%s¤Ë¥Þ¥Ã¥Á",temp);
+#else
+               sprintf(buf, "Monsters with a name \"%s\"",temp);
+#endif
+       }
+       else if (ident_info[i])
+       {
+               sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
+       }
+       else
+       {
+#ifdef JP
+sprintf(buf, "%c - %s", sym, "̵¸ú¤Êʸ»ú");
+#else
+               sprintf(buf, "%c - %s.", sym, "Unknown Symbol");
+#endif
+
+       }
+
+       /* Display the result */
+       prt(buf, 16, 10);
+
+
+       /* Allocate the "who" array */
+       C_MAKE(who, max_r_idx, u16b);
+
+       /* Collect matching monsters */
+       for (n = 0, i = 1; i < max_r_idx; i++)
+       {
+               monster_race *r_ptr = &r_info[i];
+
+               /* Empty monster */
+               if (!r_ptr->name) continue;
+
+               /* XTRA HACK WHATSEARCH */
+               /* Require non-unique monsters if needed */
+               if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
+
+               /* Require unique monsters if needed */
+               if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
+
+               /* Ì¾Á°¸¡º÷ */
+               if (temp[0])
+               {
+                       int xx;
+                       char temp2[80];
+
+                       for (xx = 0; temp[xx] && xx < 80; xx++)
+                       {
+#ifdef JP
+                               if (iskanji(temp[xx]))
+                               {
+                                       xx++;
+                                       continue;
+                               }
+#endif
+                               if (isupper(temp[xx])) temp[xx] = tolower(temp[xx]);
+                       }
+  
+#ifdef JP
+                       strcpy(temp2, r_name + r_ptr->E_name);
+#else
+                       strcpy(temp2, r_name + r_ptr->name);
+#endif
+                       for (xx = 0; temp2[xx] && xx < 80; xx++)
+                               if (isupper(temp2[xx])) temp2[xx] = tolower(temp2[xx]);
+
+#ifdef JP
+                       if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
+#else
+                       if (my_strstr(temp2, temp))
+#endif
+                               who[n++] = i;
+               }
+               else if (all || (r_ptr->d_char == sym)) who[n++] = i;
+       }
+
+       /* Nothing to recall */
+       if (!n)
+       {
+               /* Free the "who" array */
+               C_KILL(who, max_r_idx, u16b);
+
+               /* Restore */
+               screen_load();
+
+               return (FALSE);
+       }
+
+       /* Sort by level */
+       why = 2;
+       query = 'y';
+
+       /* Sort if needed */
+       if (why)
+       {
+               /* Select the sort method */
+               ang_sort_comp = ang_sort_comp_hook;
+               ang_sort_swap = ang_sort_swap_hook;
+
+               /* Sort the array */
+               ang_sort(who, &why, n);
+       }
+
+
+       /* Start at the end */
+       /* XTRA HACK REMEMBER_IDX */
+       if (old_sym == sym && old_i < n) i = old_i;
+       else i = n - 1;
+
+       notpicked = TRUE;
+
+       /* Scan the monster memory */
+       while (notpicked)
+       {
+               /* Extract a race */
+               r_idx = who[i];
+
+               /* Hack -- Begin the prompt */
+               roff_top(r_idx);
+
+               /* Hack -- Complete the prompt */
+#ifdef JP
+Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ' '¤Ç³¹Ô, ESC]");
+#else
+               Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC, space to continue]");
+#endif
+
+
+               /* Interact */
+               while (1)
+               {
+                       /* Recall */
+                       if (recall)
+                       {
+                               /*** Recall on screen ***/
+
+                               /* Get maximal info about this monster */
+                               lore_do_probe(r_idx);
+
+                               /* Save this monster ID */
+                               monster_race_track(r_idx);
+
+                               /* Hack -- Handle stuff */
+                               handle_stuff();
+
+                               /* know every thing mode */
+                               screen_roff(r_idx, 0x01);
+                               notpicked = FALSE;
+
+                               /* XTRA HACK REMEMBER_IDX */
+                               old_sym = sym;
+                               old_i = i;
+                       }
+
+                       /* Command */
+                       query = inkey();
+
+                       /* Normal commands */
+                       if (query != 'r') break;
+
+                       /* Toggle recall */
+                       recall = !recall;
+               }
+
+               /* Stop scanning */
+               if (query == ESCAPE) break;
+
+               /* Move to "prev" monster */
+               if (query == '-')
+               {
+                       if (++i == n)
+                       {
+                               i = 0;
+                               if (!expand_list) break;
+                       }
+               }
+
+               /* Move to "next" monster */
+               else
+               {
+                       if (i-- == 0)
+                       {
+                               i = n - 1;
+                               if (!expand_list) break;
+                       }
+               }
+       }
+
+
+       /* Re-display the identity */
+       /* prt(buf, 5, 5);*/
+
+       /* Free the "who" array */
+       C_KILL(who, max_r_idx, u16b);
+
+       /* Restore */
+       screen_load();
+
+       return (!notpicked);
+}
+
+
+/*
  * Execute a building command
  */
 static void bldg_process_command(building_type *bldg, int i)
@@ -4034,7 +5442,6 @@ static void bldg_process_command(building_type *bldg, int i)
        int bact = bldg->actions[i];
        int bcost;
        bool paid = FALSE;
-       bool set_reward = FALSE;
        int amt;
 
        /* Flush messages XXX XXX XXX */
@@ -4071,12 +5478,10 @@ msg_print("
                return;
        }
 
-       if (!bcost) set_reward = TRUE;
-
        switch (bact)
        {
        case BACT_NOTHING:
-                               /* Do nothing */
+               /* Do nothing */
                break;
        case BACT_RESEARCH_ITEM:
                paid = identify_fully(FALSE);
@@ -4093,7 +5498,7 @@ msg_print("
        case BACT_KING_LEGENDS:
        case BACT_ARENA_LEGENDS:
        case BACT_LEGENDS:
-               show_highclass(building_loc);
+               show_highclass();
                break;
        case BACT_POSTER:
        case BACT_ARENA_RULES:
@@ -4117,14 +5522,15 @@ msg_print("
                paid = research_mon();
                break;
        case BACT_COMPARE_WEAPONS:
-               paid = compare_weapons();
+               paid = TRUE;
+               bcost = compare_weapons(bcost);
                break;
        case BACT_ENCHANT_WEAPON:
-               item_tester_hook = item_tester_hook_melee_weapon;
+               item_tester_hook = object_allow_enchant_melee_weapon;
                enchant_item(bcost, 1, 1, 0);
                break;
        case BACT_ENCHANT_ARMOR:
-               item_tester_hook = item_tester_hook_armour;
+               item_tester_hook = object_is_armour;
                enchant_item(bcost, 0, 0, 1);
                break;
        case BACT_RECHARGE:
@@ -4169,21 +5575,6 @@ msg_print("
                if (do_res_stat(A_CON)) paid = TRUE;
                if (do_res_stat(A_CHR)) paid = TRUE;
                break;
-       case BACT_GOLD: /* set timed reward flag */
-               if (!p_ptr->rewards[BACT_GOLD])
-               {
-                       share_gold();
-                       p_ptr->rewards[BACT_GOLD] = TRUE;
-               }
-               else
-               {
-#ifdef JP
-                       msg_print("º£Æü¤Îʬ¤±Á°¤Ï¤¹¤Ç¤Ë»Ùʧ¤Ã¤¿¤¾¡ª");
-#else
-                       msg_print("You just had your daily allowance!");
-#endif
-               }
-               break;
        case BACT_ENCHANT_ARROWS:
                item_tester_hook = item_tester_hook_ammo;
                enchant_item(bcost, 1, 1, 0);
@@ -4198,66 +5589,16 @@ msg_print("
        case BACT_TELEPORT_LEVEL:
        {
                int select_dungeon;
-               int i, num = 0;
-               s16b *dun;
                int max_depth;
 
-               /* Allocate the "dun" array */
-               C_MAKE(dun, max_d_idx, s16b);
-
-               screen_save();
                clear_bldg(4, 20);
-
-               for(i = 1; i < max_d_idx; i++)
-               {
-                       char buf[80];
-                       bool seiha = FALSE;
-
-                       if (!d_info[i].maxdepth) continue;
-                       if (!max_dlv[i]) continue;
-                       if (d_info[i].final_guardian)
-                       {
-                               if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
-                       }
-                       else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
-
-#ifdef JP
-                       sprintf(buf,"%c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
-#else
-                       sprintf(buf,"%c) %c%-12s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
-#endif
-                       put_str(buf, 4+num, 5);
-                       dun[num] = i;
-                       num++;
-               }
 #ifdef JP
-               prt("¤É¤Î¥À¥ó¥¸¥ç¥ó¤Ë¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤¹¤«:", 0, 0);
+               select_dungeon = choose_dungeon("¤Ë¥Æ¥ì¥Ý¡¼¥È", 4, 0);
 #else
-               prt("Which dungeon do you teleport?: ", 0, 0);
+               select_dungeon = choose_dungeon("teleport", 4, 0);
 #endif
-               while(1)
-               {
-                       i = inkey();
-
-                       if (i == ESCAPE)
-                       {
-                               /* Free the "dun" array */
-                               C_KILL(dun, max_d_idx, s16b);
-
-                               screen_load();
-                               return;
-                       }
-                       if (i >= 'a' && i <('a'+num))
-                       {
-                               select_dungeon = dun[i-'a'];
-                               break;
-                       }
-                       else bell();
-               }
-               screen_load();
-
-               /* Free the "dun" array */
-               C_KILL(dun, max_d_idx, s16b);
+               show_building(bldg);
+               if (!select_dungeon) return;
 
                max_depth = d_info[select_dungeon].maxdepth;
 
@@ -4279,7 +5620,7 @@ msg_print("
                        p_ptr->word_recall = 1;
                        p_ptr->recall_dungeon = select_dungeon;
                        max_dlv[p_ptr->recall_dungeon] = ((amt > d_info[select_dungeon].maxdepth) ? d_info[select_dungeon].maxdepth : ((amt < d_info[select_dungeon].mindepth) ? d_info[select_dungeon].mindepth : amt));
-                       if (record_maxdeapth)
+                       if (record_maxdepth)
 #ifdef JP
                                do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥È¥é¥ó¥×¥¿¥ï¡¼¤Ç");
 #else
@@ -4297,16 +5638,23 @@ msg_print("
                break;
        }
        case BACT_LOSE_MUTATION:
-               paid = lose_mutation(0);
-               /* ToDo: Better message text. */
-               if (!paid)
+               if (p_ptr->muta1 || p_ptr->muta2 ||
+                   (p_ptr->muta3 & ~MUT3_GOOD_LUCK) ||
+                   (p_ptr->pseikaku != SEIKAKU_LUCKY &&
+                    (p_ptr->muta3 & MUT3_GOOD_LUCK)))
+               {
+                       while(!lose_mutation(0));
+                       paid = TRUE;
+               }
+               else
+               {
 #ifdef JP
-                       msg_print("´ñ̯¤Ê¤¯¤é¤¤ÉáÄ̤ˤʤ俵¤¤¬¤¹¤ë¡£");
+                       msg_print("¼£¤¹¤Ù¤­ÆÍÁ³ÊÑ°Û¤¬Ìµ¤¤¡£");
 #else
-               msg_print("You feel oddly normal.");
+                       msg_print("You have no mutations.");
 #endif
-
-
+                       msg_print(NULL);
+               }
                break;
        case BACT_BATTLE:
                kakutoujou();
@@ -4353,6 +5701,13 @@ msg_print("
        case BACT_TELE_TOWN:
                paid = tele_town();
                break;
+       case BACT_EVAL_AC:
+               paid = eval_ac(p_ptr->dis_ac + p_ptr->dis_to_a);
+               break;
+       case BACT_BROKEN_WEAPON:
+               paid = TRUE;
+               bcost = repair_broken_weapon(bcost);
+               break;
        }
 
        if (paid)
@@ -4369,7 +5724,7 @@ void do_cmd_quest(void)
 {
        energy_use = 100;
 
-       if (cave[py][px].feat != FEAT_QUEST_ENTER)
+       if (!cave_have_flag_bold(py, px, FF_QUEST_ENTER))
        {
 #ifdef JP
 msg_print("¤³¤³¤Ë¤Ï¥¯¥¨¥¹¥È¤ÎÆþ¸ý¤Ï¤Ê¤¤¡£");
@@ -4395,27 +5750,11 @@ msg_print("
                p_ptr->oldpy = 0;
                p_ptr->oldpx = 0;
 
-               leaving_quest = p_ptr->inside_quest;
-
-               /* Leaving an 'only once' quest marks it as failed */
-               if (leaving_quest &&
-                       ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
-                       (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
-               {
-                       quest[leaving_quest].status = QUEST_STATUS_FAILED;
-                       quest[leaving_quest].complev = (byte)p_ptr->lev;
-                       if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
-                       {
-                               r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
-                               do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
-                       }
-                       else if (record_fix_quest)
-                               do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
-               }
+               leave_quest_check();
 
+               if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
                p_ptr->inside_quest = cave[py][px].special;
-               if(quest[leaving_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
-               p_ptr->leftbldg = TRUE;
+
                p_ptr->leaving = TRUE;
        }
 }
@@ -4434,11 +5773,10 @@ void do_cmd_bldg(void)
 
        energy_use = 100;
 
-       if (!((cave[py][px].feat >= FEAT_BLDG_HEAD) &&
-                 (cave[py][px].feat <= FEAT_BLDG_TAIL)))
+       if (!cave_have_flag_bold(py, px, FF_BLDG))
        {
 #ifdef JP
-msg_print("¤³¤³¤Ë¤Ï·úʪ¤Ï¤Ê¤¤¡£");
+               msg_print("¤³¤³¤Ë¤Ï·úʪ¤Ï¤Ê¤¤¡£");
 #else
                msg_print("You see no building here.");
 #endif
@@ -4446,42 +5784,64 @@ msg_print("
                return;
        }
 
-       which = (cave[py][px].feat - FEAT_BLDG_HEAD);
-       building_loc = which;
+       which = f_info[cave[py][px].feat].subtype;
 
        bldg = &building[which];
 
        /* Don't re-init the wilderness */
        reinit_wilderness = FALSE;
 
-       if ((which == 2) && (p_ptr->arena_number == 99))
+       if ((which == 2) && (p_ptr->arena_number < 0))
        {
 #ifdef JP
-msg_print("¡ÖÇÔ¼Ô¤ËÍѤϤʤ¤¡£¡×");
+               msg_print("¡ÖÇÔ¼Ô¤ËÍѤϤʤ¤¡£¡×");
 #else
-               msg_print("'There is no place for LOSER.'");
+               msg_print("'There's no place here for a LOSER like you!'");
 #endif
                return;
        }
-       else if ((which == 2) && p_ptr->inside_arena && !p_ptr->exit_bldg)
+       else if ((which == 2) && p_ptr->inside_arena)
        {
+               if (!p_ptr->exit_bldg && m_cnt > 0)
+               {
 #ifdef JP
-prt("¥²¡¼¥È¤ÏÊĤޤäƤ¤¤ë¡£¥â¥ó¥¹¥¿¡¼¤¬¤¢¤Ê¤¿¤òÂԤäƤ¤¤ë¡ª",0,0);
+                       prt("¥²¡¼¥È¤ÏÊĤޤäƤ¤¤ë¡£¥â¥ó¥¹¥¿¡¼¤¬¤¢¤Ê¤¿¤òÂԤäƤ¤¤ë¡ª", 0, 0);
 #else
-               prt("The gates are closed.  The monster awaits!", 0, 0);
+                       prt("The gates are closed.  The monster awaits!", 0, 0);
 #endif
+               }
+               else
+               {
+                       /* Don't save the arena as saved floor */
+                       prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_NO_RETURN);
+
+                       p_ptr->inside_arena = FALSE;
+                       p_ptr->leaving = TRUE;
+
+                       /* Re-enter the arena */
+                       command_new = SPECIAL_KEY_BUILDING;
+
+                       /* No energy needed to re-enter the arena */
+                       energy_use = 0;
+               }
 
                return;
        }
-       else if ((which == 2) && p_ptr->inside_arena)
-       {
-               p_ptr->leaving = TRUE;
-               p_ptr->inside_arena = FALSE;
-       }
        else if (p_ptr->inside_battle)
        {
+               /* Don't save the arena as saved floor */
+               prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_NO_RETURN);
+
                p_ptr->leaving = TRUE;
                p_ptr->inside_battle = FALSE;
+
+               /* Re-enter the monster arena */
+               command_new = SPECIAL_KEY_BUILDING;
+
+               /* No energy needed to re-enter the arena */
+               energy_use = 0;
+
+               return;
        }
        else
        {
@@ -4550,7 +5910,9 @@ prt("
 
        /* Reinit wilderness to activate quests ... */
        if (reinit_wilderness)
+       {
                p_ptr->leaving = TRUE;
+       }
 
        /* Hack -- Decrease "icky" depth */
        character_icky--;
@@ -4626,12 +5988,27 @@ void quest_discovery(int q_idx)
        if (q_num == 1)
        {
                /* Unique */
+
+               /* Hack -- "unique" monsters must be "unique" */
+               if ((r_ptr->flags1 & RF1_UNIQUE) &&
+                   (0 == r_ptr->max_num))
+               {
 #ifdef JP
-msg_format("Ãí°Õ¤»¤è¡ª¤³¤Î³¬¤Ï%s¤Ë¤è¤Ã¤Æ¼é¤é¤ì¤Æ¤¤¤ë¡ª", name);
+                       msg_print("¤³¤Î³¬¤Ï°ÊÁ°¤Ï狼¤Ë¤è¤Ã¤Æ¼é¤é¤ì¤Æ¤¤¤¿¤è¤¦¤À¡Ä¡£");
 #else
-               msg_format("Beware, this level is protected by %s!", name);
+                       msg_print("It seems that this level was protected by someone before...");
 #endif
-
+                       /* The unique is already dead */
+                       quest[q_idx].status = QUEST_STATUS_FINISHED;
+               }
+               else
+               {
+#ifdef JP
+                       msg_format("Ãí°Õ¤»¤è¡ª¤³¤Î³¬¤Ï%s¤Ë¤è¤Ã¤Æ¼é¤é¤ì¤Æ¤¤¤ë¡ª", name);
+#else
+                       msg_format("Beware, this level is protected by %s!", name);
+#endif
+               }
        }
        else
        {