OSDN Git Service

射撃武器の熟練度の記号定数化を間違えており, 熟練度が[初心者]から上が
[hengband/hengband.git] / src / cmd2.c
index d67a4f2..0a40e15 100644 (file)
@@ -1,15 +1,15 @@
 /* File: cmd2.c */
 
-/* Purpose: Movement commands (part 2) */
-
 /*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
  *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.  Other copyrights may also apply.
  */
 
+/* Purpose: Movement commands (part 2) */
+
 #include "angband.h"
 
 
@@ -35,15 +35,14 @@ void do_cmd_go_up(void)
        {
                /* Success */
 #ifdef JP
-       if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
-               msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
-       else
-               msg_print("¾å¤Î³¬¤ËÅФä¿¡£");
+               if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
+                       msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
+               else
+                       msg_print("¾å¤Î³¬¤ËÅФä¿¡£");
 #else
                msg_print("You enter the up staircase.");
 #endif
 
-
                leave_quest_check();
 
                p_ptr->inside_quest = c_ptr->special;
@@ -66,127 +65,121 @@ void do_cmd_go_up(void)
 
                p_ptr->oldpx = 0;
                p_ptr->oldpy = 0;
+
+               /* End the command */
+               return;
        }
-       /* Normal up stairs */
-       else if ((c_ptr->feat == FEAT_LESS) || (c_ptr->feat == FEAT_LESS_LESS))
+
+       /* Normal up stairs? */
+       if (c_ptr->feat != FEAT_LESS && c_ptr->feat != FEAT_LESS_LESS)
        {
-               if (!dun_level)
-               {
-                       go_up = TRUE;
-               }
-               else
-               {
-                       if (confirm_stairs)
-                       {
 #ifdef JP
-if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
+               msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
 #else
-                               if (get_check("Really leave the level? "))
+               msg_print("I see no up staircase here.");
 #endif
 
-                                       go_up = TRUE;
-                       }
-                       else
-                       {
-                               go_up = TRUE;
-                       }
-               }
+               return;
+       }
+
+       if (!dun_level)
+       {
+               go_up = TRUE;
+       }
+       else
+       {
+               quest_type *q_ptr = &quest[p_ptr->inside_quest];
 
-               if (go_up)
+               /* Confirm leaving from once only quest */
+               if (confirm_quest && p_ptr->inside_quest &&
+                   (q_ptr->type == QUEST_TYPE_RANDOM ||
+                    (q_ptr->flags & QUEST_FLAG_ONCE &&
+                     q_ptr->status != QUEST_STATUS_COMPLETED)))
+               {
+#ifdef JP
+                       msg_print("¤³¤Î³¬¤ò°ìÅÙµî¤ë¤ÈÆóÅÙ¤ÈÌá¤Ã¤ÆÍè¤é¤ì¤Þ¤»¤ó¡£");
+                       if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©")) go_up = TRUE;
+#else
+                       msg_print("You can't come back here once you leave this floor.");
+                       if (get_check("Really leave this floor? ")) go_up = TRUE;
+#endif
+               }
+               else
                {
+                       go_up = TRUE;
+               }
+       }
 
-                       /* Hack -- take a turn */
-                       energy_use = 100;
+       /* Cancel the command */
+       if (!go_up) return;
 
-                       if (autosave_l) do_cmd_save_game(TRUE);
+       /* Hack -- take a turn */
+       energy_use = 100;
 
-                       if (p_ptr->inside_quest)
-                       {
-                               if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
+       if (autosave_l) do_cmd_save_game(TRUE);
 
-                               leave_quest_check();
+       if (p_ptr->inside_quest)
+       {
+               leave_quest_check();
 
-                               p_ptr->inside_quest = c_ptr->special;
-                       }
+               if (quest[leaving_quest].type != QUEST_TYPE_RANDOM)
+               {
+                       p_ptr->inside_quest = c_ptr->special;
+                       dun_level = 0;
+               }
+               else
+               {
+                       p_ptr->inside_quest = 0;
+               }
 
-                       /* New depth */
-                       if (c_ptr->feat == FEAT_LESS_LESS)
-                       {
-                               /* Create a way back */
-                               create_down_stair = 2;
+               up_num = 0;
+       }
+       else
+       {
+               /* New depth */
+               if (c_ptr->feat == FEAT_LESS_LESS)
+               {
+                       /* Create a way back */
+                       prepare_change_floor_mode(CFM_UP | CFM_SHAFT);
 
-                               up_num += 2;
-                       }
-                       else
-                       {
-                               /* Create a way back */
-                               create_down_stair = 1;
+                       up_num = 2;
+               }
+               else
+               {
+                       /* Create a way back */
+                       prepare_change_floor_mode(CFM_UP);
 
-                               up_num += 1;
-                       }
-                       if (!c_ptr->special && dungeon_type && ((dun_level - up_num + 1) > d_info[dungeon_type].mindepth) && one_in_(13))
-                       {
-                               up_num++;
-#ifdef JP
-                               if (c_ptr->feat == FEAT_LESS_LESS) msg_print("Ť¤¹£Æ»¤ò¾å¤Ã¤¿¡£");
-                               else msg_print("Ť¤³¬Ãʤò¾å¤Ã¤¿¡£");
-#else
-                               msg_print("These were very long stairs.");
-#endif
-                               msg_print(NULL);
-                       }
-                       if (dun_level-up_num+1 == d_info[dungeon_type].mindepth) up_num = dun_level;
-#ifdef JP
-                       if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
-#else
-                       if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "go up the stairs to");
-#endif
-                       dun_level -= up_num;
+                       up_num = 1;
+               }
+
+               /* Get out from current dungeon */
+               if (dun_level - up_num < d_info[dungeon_type].mindepth)
+                       up_num = dun_level;
+       }
 
-                       /* Success */
 #ifdef JP
-                       if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
-                               msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
-                       else if (0 == dun_level)
-                               msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
-                        else
-                               msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤÈ­¤òƧ¤ßÆþ¤ì¤¿¡£");
+       if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
 #else
-                        if (0 == dun_level)
-                               msg_print("You go back to the surface.");
-                        else
-                                msg_print("You enter a maze of up staircases.");
+       if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "climbed up the stairs to");
 #endif
 
-
-                       /* Leaving the dungeon to town */
-                       if (!dun_level && dungeon_type)
-                       {
-                               p_ptr->leaving_dungeon = TRUE;
-                               if (!vanilla_town && !lite_town)
-                               {
-                                       p_ptr->wilderness_y = d_info[dungeon_type].dy;
-                                       p_ptr->wilderness_x = d_info[dungeon_type].dx;
-                               }
-                               p_ptr->recall_dungeon = dungeon_type;
-                       }
-
-                       if (!dun_level) dungeon_type = 0;
-
-                       /* Leaving */
-                       p_ptr->leaving = TRUE;
-               }
-       }
-       else
-       {
+       /* Success */
 #ifdef JP
-               msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
+       if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
+               msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
+       else if (up_num == dun_level)
+               msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
+       else
+               msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤÈ­¤òƧ¤ßÆþ¤ì¤¿¡£");
 #else
-               msg_print("I see no up staircase here.");
+       if (up_num == dun_level)
+               msg_print("You go back to the surface.");
+       else
+               msg_print("You enter a maze of up staircases.");
 #endif
 
-               return;
-       }
+       /* Leaving */
+       p_ptr->leaving = TRUE;
 }
 
 
@@ -196,7 +189,6 @@ if (get_check("
 void do_cmd_go_down(void)
 {
        cave_type *c_ptr;
-       bool go_down = FALSE;
        bool fall_trap = FALSE;
        int down_num = 0;
 
@@ -280,116 +272,92 @@ void do_cmd_go_down(void)
                                if (!get_check("Do you really get in this dungeon? ")) return;
 #endif
                        }
-                       go_down = TRUE;
 
                        /* Save old player position */
                        p_ptr->oldpx = px;
                        p_ptr->oldpy = py;
                        dungeon_type = (byte)c_ptr->special;
                }
-               else
-               {
-                       if (confirm_stairs)
-                       {
-#ifdef JP
-if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
-#else
-                               if (get_check("Really leave the level? "))
-#endif
 
-                                       go_down = TRUE;
-                       }
-                       else
-                       {
-                               go_down = TRUE;
-                       }
-               }
+               /* Hack -- take a turn */
+               energy_use = 100;
 
-               if (go_down)
-               {
+               if (autosave_l) do_cmd_save_game(TRUE);
 
-                       /* Hack -- take a turn */
-                       energy_use = 100;
+               /* Go down */
+               if (c_ptr->feat == FEAT_MORE_MORE) down_num += 2;
+               else down_num += 1;
 
-                       if (autosave_l) do_cmd_save_game(TRUE);
 
-                       /* Go down */
-                       if (c_ptr->feat == FEAT_MORE_MORE) down_num += 2;
-                       else down_num += 1;
-                       if (!quest_number(dun_level+down_num) && (dun_level < d_info[dungeon_type].maxdepth - 1 - down_num) && one_in_(13) && !fall_trap && dun_level && !ironman_downward)
-                       {
-                               down_num++;
+               if (!dun_level)
+               {
+                       /* Enter the dungeon just now */
+                       p_ptr->enter_dungeon = TRUE;
+                       down_num = d_info[c_ptr->special].mindepth;
+               }
+
+               if (record_stair)
+               {
 #ifdef JP
-                               if (c_ptr->feat == FEAT_MORE_MORE) msg_print("Ť¤¹£Æ»¤ò²¼¤ê¤¿¡£");
-                               else msg_print("Ť¤³¬Ãʤò²¼¤ê¤¿¡£");
+                       if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
+                       else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
 #else
-                               msg_print("These were very long stairs.");
+                       if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fell through a trap door");
+                       else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed down the stairs to");
 #endif
-                               msg_print(NULL);
-                       }
-                       else if (!dun_level) down_num = d_info[c_ptr->special].mindepth;
-                       if (record_stair)
-                       {
+               }
+
+               if (fall_trap)
+               {
 #ifdef JP
-                               if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
-                               else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
+                       msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
 #else
-                               if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fall from trap door");
-                               else do_cmd_write_nikki(NIKKI_STAIR, down_num, "go down the stairs to");
+                       msg_print("You deliberately jump through the trap door.");
 #endif
-                       }
-
-                       if (fall_trap)
+               }
+               else
+               {
+                       /* Success */
+                       if(c_ptr->feat == FEAT_ENTRANCE)
                        {
-                               dun_level += down_num;
 #ifdef JP
-                               msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
+                               msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
 #else
-                               msg_print("You deliberately jump through the trap door.");
+                               msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
 #endif
                        }
                        else
                        {
-                               /* Success */
-                               if(c_ptr->feat == FEAT_ENTRANCE)
-                               {
-                                       dun_level = d_info[c_ptr->special].mindepth;
 #ifdef JP
-                                       msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
-#else
-                                       msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
-#endif
-                               }
+                               if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
+                                       msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
                                else
-                               {
-                                       dun_level += down_num;
-#ifdef JP
-                                       if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
-                                               msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
-                                       else
-                                               msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤÈ­¤òƧ¤ßÆþ¤ì¤¿¡£");
+                                       msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤÈ­¤òƧ¤ßÆþ¤ì¤¿¡£");
 #else
-                                       msg_print("You enter a maze of down staircases.");
+                               msg_print("You enter a maze of down staircases.");
 #endif
-                               }
                        }
+               }
 
 
-                       /* Leaving */
-                       p_ptr->leaving = TRUE;
+               /* Leaving */
+               p_ptr->leaving = TRUE;
 
-                       if (!fall_trap)
+               if (fall_trap)
+               {
+                       prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
+               }
+               else
+               {
+                       if (c_ptr->feat == FEAT_MORE_MORE)
                        {
-                               if (c_ptr->feat == FEAT_MORE_MORE)
-                               {
-                                       /* Create a way back */
-                                       create_up_stair = 2;
-                               }
-                               else
-                               {
-                                       /* Create a way back */
-                                       create_up_stair = 1;
-                               }
+                               /* Create a way back */
+                               prepare_change_floor_mode(CFM_DOWN | CFM_SHAFT);
+                       }
+                       else
+                       {
+                               /* Create a way back */
+                               prepare_change_floor_mode(CFM_DOWN);
                        }
                }
        }
@@ -472,7 +440,7 @@ static void chest_death(bool scatter, int y, int x, s16b o_idx)
        int number;
 
        bool small;
-       bool great = FALSE;
+       u32b mode = AM_GOOD;
 
        object_type forge;
        object_type *q_ptr;
@@ -490,7 +458,7 @@ static void chest_death(bool scatter, int y, int x, s16b o_idx)
        {
                number = 5;
                small = FALSE;
-               great = TRUE;
+               mode |= AM_GREAT;
                object_level = o_ptr->xtra3;
        }
        else
@@ -525,7 +493,7 @@ static void chest_death(bool scatter, int y, int x, s16b o_idx)
                else
                {
                        /* Make a good object */
-                       if (!make_object(q_ptr, TRUE, great)) continue;
+                       if (!make_object(q_ptr, mode)) continue;
                }
 
                /* If chest scatters its contents, pick any floor square. */
@@ -623,7 +591,7 @@ static void chest_trap(int y, int x, s16b o_idx)
                msg_print("A puff of green gas surrounds you!");
 #endif
 
-               if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
+               if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
                {
                        (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
                }
@@ -964,25 +932,25 @@ static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
        /* Check around (and under) the character */
        for (d = 0; d < 9; d++)
        {
-                cave_type *c_ptr;
-                byte feat;
+               cave_type *c_ptr;
+               byte feat;
 
-                /* if not searching under player continue */
-                if ((d == 8) && !under) continue;
+               /* if not searching under player continue */
+               if ((d == 8) && !under) continue;
 
                /* Extract adjacent (legal) location */
                yy = py + ddy_ddd[d];
                xx = px + ddx_ddd[d];
 
-                /* Get the cave */
-                c_ptr = &cave[yy][xx];
+               /* Get the cave */
+               c_ptr = &cave[yy][xx];
 
                /* Must have knowledge */
                if (!(c_ptr->info & (CAVE_MARK))) continue;
 
-                /* Feature code (applying "mimic" field) */
-                feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
-                
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+               
                /* Not looking for this feature */
                if (!((*test)(feat))) continue;
 
@@ -1074,7 +1042,7 @@ static int coords_to_dir(int y, int x)
  *
  * Returns TRUE if repeated commands may continue
  */
-static bool do_cmd_open_aux(int y, int x, int dir)
+static bool do_cmd_open_aux(int y, int x)
 {
        int i, j;
 
@@ -1089,6 +1057,8 @@ static bool do_cmd_open_aux(int y, int x, int dir)
        /* Get requested grid */
        c_ptr = &cave[y][x];
 
+       /* Seeing true feature code (ignore mimic) */
+               
        /* Jammed door */
        if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
        {
@@ -1164,7 +1134,7 @@ static bool do_cmd_open_aux(int y, int x, int dir)
        }
 
        /* Closed door */
-       else
+       else if (c_ptr->feat == FEAT_DOOR_HEAD)
        {
                /* Open the door */
                cave_set_feat(y, x, FEAT_OPEN);
@@ -1193,8 +1163,6 @@ void do_cmd_open(void)
 
        s16b o_idx;
 
-       cave_type *c_ptr;
-
        bool more = FALSE;
 
        if (p_ptr->special_defense & KATA_MUSOU)
@@ -1242,6 +1210,9 @@ void do_cmd_open(void)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir, TRUE))
        {
+               byte feat;
+               cave_type *c_ptr;
+
                /* Get requested location */
                y = py + ddy[dir];
                x = px + ddx[dir];
@@ -1249,12 +1220,14 @@ void do_cmd_open(void)
                /* Get requested grid */
                c_ptr = &cave[y][x];
 
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+               
                /* Check for chest */
                o_idx = chest_check(y, x);
 
                /* Nothing useful */
-               if (!(is_closed_door(c_ptr->feat) && !c_ptr->mimic) &&
-                    !o_idx)
+               if (!is_closed_door(feat) && !o_idx)
                {
                        /* Message */
 #ifdef JP
@@ -1294,7 +1267,7 @@ void do_cmd_open(void)
                else
                {
                        /* Open the door */
-                       more = do_cmd_open_aux(y, x, dir);
+                       more = do_cmd_open_aux(y, x);
                }
        }
 
@@ -1313,19 +1286,19 @@ void do_cmd_open(void)
  *
  * Returns TRUE if repeated commands may continue
  */
-static bool do_cmd_close_aux(int y, int x, int dir)
+static bool do_cmd_close_aux(int y, int x)
 {
        cave_type       *c_ptr;
-
        bool            more = FALSE;
 
-
        /* Take a turn */
        energy_use = 100;
 
        /* Get grid and contents */
        c_ptr = &cave[y][x];
 
+       /* Seeing true feature code (ignore mimic) */
+
        /* Broken door */
        if (c_ptr->feat == FEAT_BROKEN)
        {
@@ -1339,7 +1312,7 @@ static bool do_cmd_close_aux(int y, int x, int dir)
        }
 
        /* Open door */
-       else
+       else if (c_ptr->feat == FEAT_OPEN)
        {
                /* Close the door */
                cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
@@ -1363,8 +1336,6 @@ void do_cmd_close(void)
 {
        int y, x, dir;
 
-       cave_type *c_ptr;
-
        bool more = FALSE;
 
        if (p_ptr->special_defense & KATA_MUSOU)
@@ -1402,6 +1373,9 @@ void do_cmd_close(void)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir,FALSE))
        {
+               cave_type *c_ptr;
+               byte feat;
+
                /* Get requested location */
                y = py + ddy[dir];
                x = px + ddx[dir];
@@ -1409,12 +1383,15 @@ void do_cmd_close(void)
                /* Get grid and contents */
                c_ptr = &cave[y][x];
 
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+               
                /* Require open/broken door */
-               if ((c_ptr->feat != FEAT_OPEN) && (c_ptr->feat != FEAT_BROKEN))
+               if ((feat != FEAT_OPEN) && (feat != FEAT_BROKEN))
                {
                        /* Message */
 #ifdef JP
-               msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
+                       msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
 #else
                        msg_print("You see nothing there to close.");
 #endif
@@ -1443,7 +1420,7 @@ void do_cmd_close(void)
                else
                {
                        /* Close the door */
-                       more = do_cmd_close_aux(y, x, dir);
+                       more = do_cmd_close_aux(y, x);
                }
        }
 
@@ -1534,7 +1511,7 @@ static bool twall(int y, int x, byte feat)
  *
  * Returns TRUE if repeated commands may continue
  */
-static bool do_cmd_tunnel_aux(int y, int x, int dir)
+static bool do_cmd_tunnel_aux(int y, int x)
 {
        cave_type *c_ptr;
        byte feat;
@@ -1550,8 +1527,8 @@ static bool do_cmd_tunnel_aux(int y, int x, int dir)
        /* Get grid */
        c_ptr = &cave[y][x];
 
-        /* Feature code (applying "mimic" field) */
-        feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+       /* Feature code (applying "mimic" field) */
+       feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
 
        /* Sound */
        sound(SOUND_DIG);
@@ -1568,8 +1545,10 @@ static bool do_cmd_tunnel_aux(int y, int x, int dir)
 
        }
 
-       /* No tunnelling through mountains */
-       else if (feat == FEAT_MOUNTAIN)
+       /* Map border (mimiccing Permanent wall) */
+       else if ((c_ptr->feat >= FEAT_PERM_EXTRA &&
+                 c_ptr->feat <= FEAT_PERM_SOLID) ||
+                c_ptr->feat == FEAT_MOUNTAIN)
        {
 #ifdef JP
                msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
@@ -1613,7 +1592,7 @@ static bool do_cmd_tunnel_aux(int y, int x, int dir)
 
        /* Granite */
        else if ((feat >= FEAT_WALL_EXTRA) &&
-                (feat <= FEAT_WALL_SOLID))
+                (feat <= FEAT_WALL_SOLID))
        {
                /* Tunnel */
                if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
@@ -1650,8 +1629,9 @@ static bool do_cmd_tunnel_aux(int y, int x, int dir)
                bool gold = FALSE;
                bool hard = FALSE;
 
-               /* Found gold */
-               if (feat >= FEAT_MAGMA_H) gold = TRUE;
+               /* Found gold (ignore mimic; maybe a hidden treasure) */
+               if (c_ptr->feat >= FEAT_MAGMA_H &&
+                   c_ptr->feat <= FEAT_QUARTZ_K) gold = TRUE;
 
                /* Extract "quartz" flag XXX XXX XXX */
                if ((feat - FEAT_MAGMA) & 0x01) hard = TRUE;
@@ -1744,7 +1724,7 @@ static bool do_cmd_tunnel_aux(int y, int x, int dir)
                        if (randint0(100) < (15 - dun_level/2))
                        {
                                /* Create a simple object */
-                               place_object(y, x, FALSE, FALSE);
+                               place_object(y, x, 0L);
 
                                /* Observe new object */
                                if (player_can_see_bold(y, x))
@@ -1800,17 +1780,10 @@ static bool do_cmd_tunnel_aux(int y, int x, int dir)
                }
        }
 
-        if (is_hidden_door(c_ptr))
-        {
-                /* Occasional Search XXX XXX */
-                if (randint0(100) < 25) search();
-        }
-
-       /* Notice new floor grids */
-       if (!cave_floor_bold(y, x))
+       if (is_hidden_door(c_ptr))
        {
-               /* Update some things */
-               p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
+               /* Occasional Search XXX XXX */
+               if (randint0(100) < 25) search();
        }
 
        /* Result */
@@ -1865,8 +1838,8 @@ void do_cmd_tunnel(void)
                /* Get grid */
                c_ptr = &cave[y][x];
 
-                /* Feature code (applying "mimic" field) */
-                feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
 
                /* No tunnelling through doors */
                if (((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL)) ||
@@ -1929,7 +1902,7 @@ void do_cmd_tunnel(void)
                else
                {
                        /* Tunnel through walls */
-                       more = do_cmd_tunnel_aux(y, x, dir);
+                       more = do_cmd_tunnel_aux(y, x);
                }
        }
 
@@ -2000,7 +1973,7 @@ bool easy_open_door(int y, int x)
                {
                        /* Message */
 #ifdef JP
-                        msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
+                       msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
 #else
                        msg_print("You have picked the lock.");
 #endif
@@ -2010,7 +1983,7 @@ bool easy_open_door(int y, int x)
                        cave_set_feat(y, x, FEAT_OPEN);
 
                        /* Update some things */
-                       p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
+                       p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
 
                        /* Sound */
                        sound(SOUND_OPENDOOR);
@@ -2027,7 +2000,7 @@ bool easy_open_door(int y, int x)
 
                        /* Message */
 #ifdef JP
-                        msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
+                       msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
 #else
                        msg_print("You failed to pick the lock.");
 #endif
@@ -2042,7 +2015,7 @@ bool easy_open_door(int y, int x)
                cave_set_feat(y, x, FEAT_OPEN);
 
                /* Update some things */
-               p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
+               p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
 
                /* Sound */
                sound(SOUND_OPENDOOR);
@@ -2211,10 +2184,21 @@ static bool do_cmd_disarm_aux(int y, int x, int dir)
        if (p_ptr->blind || no_lite()) i = i / 10;
        if (p_ptr->confused || p_ptr->image) i = i / 10;
 
-       /* XXX XXX XXX Variable power? */
+       /* Variable power! */
 
        /* Extract trap "power" */
-       power = 5;
+       switch (c_ptr->feat)
+       {
+       case FEAT_TRAP_OPEN:
+       case FEAT_TRAP_ARMAGEDDON:
+       case FEAT_TRAP_PIRANHA:
+               /* Special traps are very difficult to disarm */
+               power = 100;
+               break;
+       default:
+               power = 5;
+               break;
+       }
 
        /* Extract the difficulty */
        j = i - power;
@@ -2240,9 +2224,7 @@ static bool do_cmd_disarm_aux(int y, int x, int dir)
                c_ptr->info &= ~(CAVE_MARK);
 
                /* Remove the trap */
-               c_ptr->feat = floor_type[randint0(100)];
-               note_spot(y, x);
-               lite_spot(y, x);
+               cave_set_feat(y, x, floor_type[randint0(100)]);
 
 #ifdef ALLOW_EASY_DISARM /* TNB */
 
@@ -2313,8 +2295,6 @@ void do_cmd_disarm(void)
 
        s16b o_idx;
 
-       cave_type *c_ptr;
-
        bool more = FALSE;
 
        if (p_ptr->special_defense & KATA_MUSOU)
@@ -2362,6 +2342,9 @@ void do_cmd_disarm(void)
        /* Get a direction (or abort) */
        if (get_rep_dir(&dir,TRUE))
        {
+               cave_type *c_ptr;
+               byte feat;
+
                /* Get location */
                y = py + ddy[dir];
                x = px + ddx[dir];
@@ -2369,15 +2352,18 @@ void do_cmd_disarm(void)
                /* Get grid and contents */
                c_ptr = &cave[y][x];
 
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+
                /* Check for chests */
                o_idx = chest_check(y, x);
 
                /* Disarm a trap */
-               if (!is_trap(c_ptr->feat) && !o_idx)
+               if (!is_trap(feat) && !o_idx)
                {
                        /* Message */
 #ifdef JP
-               msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
+                       msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
 #else
                        msg_print("You see nothing there to disarm.");
 #endif
@@ -2496,13 +2482,13 @@ static bool do_cmd_bash_aux(int y, int x, int dir)
                move_player(dir, FALSE, FALSE);
 
                /* Update some things */
-               p_ptr->update |= (PU_VIEW | PU_LITE);
+               p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
                p_ptr->update |= (PU_DISTANCE);
        }
 
        /* Saving throw against stun */
        else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
-                p_ptr->lev)
+                p_ptr->lev)
        {
                /* Message */
 #ifdef JP
@@ -2580,6 +2566,8 @@ void do_cmd_bash(void)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir,FALSE))
        {
+               byte feat;
+
                /* Bash location */
                y = py + ddy[dir];
                x = px + ddx[dir];
@@ -2587,9 +2575,12 @@ void do_cmd_bash(void)
                /* Get grid */
                c_ptr = &cave[y][x];
 
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+
                /* Nothing useful */
-               if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
-                     (c_ptr->feat <= FEAT_DOOR_TAIL)))
+               if (!((feat >= FEAT_DOOR_HEAD) &&
+                     (feat <= FEAT_DOOR_TAIL)))
                {
                        /* Message */
 #ifdef JP
@@ -2671,6 +2662,8 @@ void do_cmd_alter(void)
        /* Get a direction */
        if (get_rep_dir(&dir,TRUE))
        {
+               byte feat;
+
                /* Get location */
                y = py + ddy[dir];
                x = px + ddx[dir];
@@ -2678,6 +2671,9 @@ void do_cmd_alter(void)
                /* Get grid */
                c_ptr = &cave[y][x];
 
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+
                /* Take a turn */
                energy_use = 100;
 
@@ -2689,44 +2685,38 @@ void do_cmd_alter(void)
                }
 
                /* Tunnel through walls */
-               else if (((c_ptr->feat >= FEAT_RUBBLE) &&
-                         (c_ptr->feat < FEAT_MINOR_GLYPH)) ||
-                        ((c_ptr->feat == FEAT_TREES) ||
-                         (c_ptr->feat == FEAT_MOUNTAIN)))
+               else if (((feat >= FEAT_RUBBLE) &&
+                         (feat < FEAT_MINOR_GLYPH)) ||
+                        ((feat == FEAT_TREES) ||
+                         (feat == FEAT_MOUNTAIN)))
                {
-                       more = do_cmd_tunnel_aux(y, x, dir);
+                       more = do_cmd_tunnel_aux(y, x);
                }
 
-                else if (is_closed_door(c_ptr->feat))
-                {
-                        /* Tunnel hidden door */
-                        if (c_ptr->mimic)
-                        {
-                                more = do_cmd_tunnel_aux(y, x, dir);
-                        }
-
-                        /* Bash jammed doors */
-                        else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
-                        {
-                                more = do_cmd_bash_aux(y, x, dir);
-                        }
-
-                        /* Locked doors */
-                        else
-                        {
-                                more = do_cmd_open_aux(y, x, dir);
-                        }
-                }
+               else if (is_closed_door(feat))
+               {
+                       /* Bash jammed doors */
+                       if (feat >= FEAT_DOOR_HEAD + 0x08)
+                       {
+                               more = do_cmd_bash_aux(y, x, dir);
+                       }
+
+                       /* Locked doors */
+                       else
+                       {
+                               more = do_cmd_open_aux(y, x);
+                       }
+               }
 
                /* Close open doors */
-               else if ((c_ptr->feat == FEAT_OPEN) ||
-                        (c_ptr->feat == FEAT_BROKEN))
+               else if ((feat == FEAT_OPEN) ||
+                        (feat == FEAT_BROKEN))
                {
-                       more = do_cmd_close_aux(y, x, dir);
+                       more = do_cmd_close_aux(y, x);
                }
 
                /* Disarm traps */
-               else if (is_trap(c_ptr->feat))
+               else if (is_trap(feat))
                {
                        more = do_cmd_disarm_aux(y, x, dir);
                }
@@ -2789,10 +2779,7 @@ static bool get_spike(int *ip)
  */
 void do_cmd_spike(void)
 {
-       int y, x, dir, item;
-
-       cave_type *c_ptr;
-
+       int dir;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -2802,6 +2789,10 @@ void do_cmd_spike(void)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir,FALSE))
        {
+               int y, x, item;
+               cave_type *c_ptr;
+               byte feat;
+
                /* Get location */
                y = py + ddy[dir];
                x = px + ddx[dir];
@@ -2809,9 +2800,12 @@ void do_cmd_spike(void)
                /* Get grid and contents */
                c_ptr = &cave[y][x];
 
+               /* Feature code (applying "mimic" field) */
+               feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+
                /* Require closed door */
-               if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
-                     (c_ptr->feat <= FEAT_DOOR_TAIL)))
+               if (!((feat >= FEAT_DOOR_HEAD) &&
+                     (feat <= FEAT_DOOR_TAIL)))
                {
                        /* Message */
 #ifdef JP
@@ -2927,9 +2921,9 @@ void do_cmd_walk(int pickup)
                more = TRUE;
        }
 
-        /* Hack again -- Is there a special encounter ??? */
+       /* Hack again -- Is there a special encounter ??? */
        if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
-        {
+       {
                int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
                if (tmp < 1) 
                        tmp = 1;
@@ -2937,9 +2931,9 @@ void do_cmd_walk(int pickup)
                {
                        /* Inform the player of his horrible fate :=) */
 #ifdef JP
-                       msg_print("½±·â¤À¡ª");
+                       msg_print("½±·â¤À¡ª");
 #else
-                       msg_print("You are ambushed !");
+                       msg_print("You are ambushed !");
 #endif
 
                        /* Go into large wilderness view */
@@ -3164,12 +3158,13 @@ void do_cmd_rest(void)
        
        /* Why are you sleeping when there's no need?  WAKE UP!*/
        if ((p_ptr->chp == p_ptr->mhp) &&
-               (p_ptr->csp == p_ptr->msp) &&
-               !p_ptr->blind && !p_ptr->confused &&
-               !p_ptr->poisoned && !p_ptr->afraid &&
-               !p_ptr->stun && !p_ptr->cut &&
-               !p_ptr->slow && !p_ptr->paralyzed &&
-               !p_ptr->image && !p_ptr->word_recall)
+           (p_ptr->csp == p_ptr->msp) &&
+           !p_ptr->blind && !p_ptr->confused &&
+           !p_ptr->poisoned && !p_ptr->afraid &&
+           !p_ptr->stun && !p_ptr->cut &&
+           !p_ptr->slow && !p_ptr->paralyzed &&
+           !p_ptr->image && !p_ptr->word_recall &&
+           !p_ptr->alter_reality)
                        chg_virtue(V_DILIGENCE, -1);
 
        /* Save the rest code */
@@ -3255,7 +3250,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
                            (r_ptr->flags3 & RF3_ANIMAL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ANIMAL;
                                }
@@ -3267,7 +3262,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
                            (r_ptr->flags3 & RF3_ANIMAL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ANIMAL;
                                }
@@ -3279,7 +3274,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_SLAY_EVIL)) &&
                            (r_ptr->flags3 & RF3_EVIL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_EVIL;
                                }
@@ -3291,7 +3286,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_KILL_EVIL)) &&
                            (r_ptr->flags3 & RF3_EVIL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_EVIL;
                                }
@@ -3303,7 +3298,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
                            (r_ptr->flags2 & RF2_HUMAN))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags2 |= RF2_HUMAN;
                                }
@@ -3315,7 +3310,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_KILL_HUMAN)) &&
                            (r_ptr->flags2 & RF2_HUMAN))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags2 |= RF2_HUMAN;
                                }
@@ -3327,7 +3322,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
                            (r_ptr->flags3 & RF3_UNDEAD))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_UNDEAD;
                                }
@@ -3339,7 +3334,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
                            (r_ptr->flags3 & RF3_UNDEAD))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_UNDEAD;
                                }
@@ -3351,7 +3346,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_SLAY_DEMON)) &&
                            (r_ptr->flags3 & RF3_DEMON))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DEMON;
                                }
@@ -3363,7 +3358,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_KILL_DEMON)) &&
                            (r_ptr->flags3 & RF3_DEMON))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DEMON;
                                }
@@ -3375,7 +3370,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_SLAY_ORC)) &&
                            (r_ptr->flags3 & RF3_ORC))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ORC;
                                }
@@ -3387,7 +3382,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_KILL_ORC)) &&
                            (r_ptr->flags3 & RF3_ORC))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_ORC;
                                }
@@ -3399,7 +3394,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_SLAY_TROLL)) &&
                            (r_ptr->flags3 & RF3_TROLL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_TROLL;
                                }
@@ -3411,7 +3406,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_KILL_TROLL)) &&
                            (r_ptr->flags3 & RF3_TROLL))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_TROLL;
                                }
@@ -3423,7 +3418,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_SLAY_GIANT)) &&
                            (r_ptr->flags3 & RF3_GIANT))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_GIANT;
                                }
@@ -3435,7 +3430,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_KILL_GIANT)) &&
                            (r_ptr->flags3 & RF3_GIANT))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_GIANT;
                                }
@@ -3447,7 +3442,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
                            (r_ptr->flags3 & RF3_DRAGON))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DRAGON;
                                }
@@ -3459,7 +3454,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        if ((have_flag(flgs, TR_KILL_DRAGON)) &&
                            (r_ptr->flags3 & RF3_DRAGON))
                        {
-                               if (m_ptr->ml)
+                               if (m_ptr->ml && is_original_ap(m_ptr))
                                {
                                        r_ptr->r_flags3 |= RF3_DRAGON;
                                }
@@ -3473,14 +3468,14 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        }
 
                        /* Brand (Acid) */
-                       if ((have_flag(flgs, TR_BRAND_ACID)) || (p_ptr->special_attack & (ATTACK_ACID)))
+                       if (have_flag(flgs, TR_BRAND_ACID))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_ACID)
+                               if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_ACID;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
                                        }
                                }
 
@@ -3492,14 +3487,14 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        }
 
                        /* Brand (Elec) */
-                       if ((have_flag(flgs, TR_BRAND_ELEC)) || (p_ptr->special_attack & (ATTACK_ELEC)))
+                       if (have_flag(flgs, TR_BRAND_ELEC))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_ELEC)
+                               if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_ELEC;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
                                        }
                                }
 
@@ -3511,51 +3506,67 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
                        }
 
                        /* Brand (Fire) */
-                       if ((have_flag(flgs, TR_BRAND_FIRE)) || (p_ptr->special_attack & (ATTACK_FIRE)))
+                       if (have_flag(flgs, TR_BRAND_FIRE))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_FIRE)
+                               if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_FIRE;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
                                        }
                                }
 
                                /* Otherwise, take the damage */
                                else
                                {
-                                       if (mult < 17) mult = 17;
+                                       if (r_ptr->flags3 & RF3_HURT_FIRE)
+                                       {
+                                               if (mult < 25) mult = 25;
+                                               if (m_ptr->ml && is_original_ap(m_ptr))
+                                               {
+                                                       r_ptr->r_flags3 |= RF3_HURT_FIRE;
+                                               }
+                                       }
+                                       else if (mult < 17) mult = 17;
                                }
                        }
 
                        /* Brand (Cold) */
-                       if ((have_flag(flgs, TR_BRAND_COLD)) || (p_ptr->special_attack & (ATTACK_COLD)))
+                       if (have_flag(flgs, TR_BRAND_COLD))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_COLD)
+                               if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_COLD;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
                                        }
                                }
                                /* Otherwise, take the damage */
                                else
                                {
-                                       if (mult < 17) mult = 17;
+                                       if (r_ptr->flags3 & RF3_HURT_COLD)
+                                       {
+                                               if (mult < 25) mult = 25;
+                                               if (m_ptr->ml && is_original_ap(m_ptr))
+                                               {
+                                                       r_ptr->r_flags3 |= RF3_HURT_COLD;
+                                               }
+                                       }
+                                       else if (mult < 17) mult = 17;
                                }
                        }
 
                        /* Brand (Poison) */
-                       if ((have_flag(flgs, TR_BRAND_POIS)) || (p_ptr->special_attack & (ATTACK_POIS)))
+                       if (have_flag(flgs, TR_BRAND_POIS))
                        {
                                /* Notice immunity */
-                               if (r_ptr->flags3 & RF3_IM_POIS)
+                               if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
                                {
-                                       if (m_ptr->ml)
+                                       if (m_ptr->ml && is_original_ap(m_ptr))
                                        {
-                                               r_ptr->r_flags3 |= RF3_IM_POIS;
+                                               r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
                                        }
                                }
 
@@ -3657,9 +3668,9 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
        /* Actually "fire" the object */
        bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
        if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
-               chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval])/400 + bonus) * BTH_PLUS_ADJ);
+               chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
        else
-               chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
+               chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
 
        energy_use = bow_energy(j_ptr->sval);
        tmul = bow_tmul(j_ptr->sval);
@@ -3689,7 +3700,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
 
                return;
        }
-       project_length = 0; /* reset to default */
 
        /* Get local object */
        q_ptr = &forge;
@@ -3739,6 +3749,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                ty = target_row;
        }
 
+       project_length = 0; /* reset to default */
 
        /* Hack -- Handle stuff */
        handle_stuff();
@@ -3815,9 +3826,9 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                                if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
                                {
                                        int amount = 0;
-                                       if (now_exp < 4000) amount = 80;
-                                       else if (now_exp <  6000) amount = 25;
-                                       else if ((now_exp < 7000) && (p_ptr->lev > 19)) amount = 10;
+                                       if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
+                                       else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
+                                       else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
                                        else if (p_ptr->lev > 34) amount = 2;
                                        p_ptr->weapon_exp[0][j_ptr->sval] += amount;
                                        p_ptr->update |= (PU_BONUS);
@@ -3826,9 +3837,11 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
 
                        if (p_ptr->riding)
                        {
-                               if (p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING] && ((p_ptr->skill_exp[GINOU_RIDING] - 1000) / 200 < r_info[m_list[p_ptr->riding].r_idx].level) && one_in_(2))
+                               if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
+                                       && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
+                                       && one_in_(2))
                                {
-                                       p_ptr->skill_exp[GINOU_RIDING]+=1;
+                                       p_ptr->skill_exp[GINOU_RIDING] += 1;
                                        p_ptr->update |= (PU_BONUS);
                                }
                        }
@@ -3838,40 +3851,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr)
                        {
                                bool fear = FALSE;
 
-                               /* Assume a default death */
-#ifdef JP
-                               cptr note_dies = "¤Ï»à¤ó¤À¡£";
-#else
-                               cptr note_dies = " dies.";
-#endif
-
-                               /* Some monsters get "destroyed" */
-                               if (!monster_living(r_ptr))
-                               {
-                                       int i;
-                                       bool explode = FALSE;
-
-                                       for (i = 0; i < 4; i++)
-                                       {
-                                               if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
-                                       }
-
-                                       /* Special note at death */
-                                       if (explode)
-#ifdef JP
-note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
-#else
-                                               note_dies = " explodes into tiny shreds.";
-#endif
-                                       else
-#ifdef JP
-                                               note_dies = "¤òÅݤ·¤¿¡£";
-#else
-                                               note_dies = " is destroyed.";
-#endif
-
-                               }
-
                                /* Handle unseen monster */
                                if (!visible)
                                {
@@ -3922,16 +3901,16 @@ note_dies = "
                                {
 #ifdef JP
                                        msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
-                                                  tdam, m_ptr->hp);
+                                                  tdam, m_ptr->hp);
 #else
                                        msg_format("You do %d (out of %d) damage.",
-                                                  tdam, m_ptr->hp);
+                                                  tdam, m_ptr->hp);
 #endif
 
                                }
 
                                /* Hit the monster, check for death */
-                               if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
+                               if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
                                {
                                        /* Dead monster */
                                }
@@ -4285,8 +4264,6 @@ bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
                /* Get a direction (or cancel) */
                if (!get_aim_dir(&dir)) return FALSE;
 
-               project_length = 0;  /* reset to default */
-
                /* Predict the "target" location */
                tx = px + 99 * ddx[dir];
                ty = py + 99 * ddy[dir];
@@ -4297,6 +4274,8 @@ bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
                        tx = target_col;
                        ty = target_row;
                }
+
+               project_length = 0;  /* reset to default */
        }
 
        if ((q_ptr->name1 == ART_MJOLLNIR) ||
@@ -4311,7 +4290,7 @@ bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
                        inven_item_describe(item);
                inven_item_optimize(item);
        }
-       
+
        /* Reduce and describe floor item */
        else
        {
@@ -4323,7 +4302,7 @@ bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
                equiped_item = TRUE;
                p_ptr->redraw |= (PR_EQUIPPY);
        }
-       
+
        /* Take a turn */
        energy_use = 100;
 
@@ -4416,42 +4395,6 @@ bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
                        {
                                bool fear = FALSE;
 
-                               /* Assume a default death */
-#ifdef JP
-                               cptr note_dies = "¤Ï»à¤ó¤À¡£";
-#else
-                               cptr note_dies = " dies.";
-#endif
-
-
-                               /* Some monsters get "destroyed" */
-                               if (!monster_living(r_ptr))
-                               {
-                                       int i;
-                                       bool explode = FALSE;
-
-                                       for (i = 0; i < 4; i++)
-                                       {
-                                               if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
-                                       }
-
-                                       /* Special note at death */
-                                       if (explode)
-#ifdef JP
-note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
-#else
-                                               note_dies = " explodes into tiny shreds.";
-#endif
-                                       else
-#ifdef JP
-                                               note_dies = "¤òÅݤ·¤¿¡£";
-#else
-                                               note_dies = " is destroyed.";
-#endif
-
-                               }
-
-
                                /* Handle unseen monster */
                                if (!visible)
                                {
@@ -4490,7 +4433,7 @@ note_dies = "
                                /* Hack -- Base damage from thrown object */
                                tdam = damroll(q_ptr->dd, q_ptr->ds);
                                /* Apply special damage XXX XXX XXX */
-                               tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
+                               tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
                                tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
                                if (q_ptr->to_d > 0)
                                        tdam += q_ptr->to_d;
@@ -4527,16 +4470,16 @@ note_dies = "
                                {
 #ifdef JP
                                        msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
-                                                  tdam, m_ptr->hp);
+                                                  tdam, m_ptr->hp);
 #else
                                        msg_format("You do %d (out of %d) damage.",
-                                                  tdam, m_ptr->hp);
+                                                  tdam, m_ptr->hp);
 #endif
 
                                }
 
                                /* Hit the monster, check for death */
-                               if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
+                               if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
                                {
                                        /* Dead monster */
                                }