OSDN Git Service

[Refactor] #37353 chest_traps を trap.c へ移動。
[hengband/hengband.git] / src / cmd2.c
index cc0f62b..c5e3e64 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "angband.h"
 #include "chest.h"
+#include "trap.h"
 #include "floor.h"
 #include "melee.h"
 #include "object-hook.h"
 #include "avatar.h"
 #include "player-status.h"
 #include "realm-hex.h"
+#include "geometry.h"
+#include "wild.h"
+#include "grid.h"
+#include "feature.h"
+#include "player-move.h"
+#include "object-broken.h"
 
 /*!
  * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
  * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
  * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
  */
-bool confirm_leave_level(bool down_stair)
+static bool confirm_leave_level(bool down_stair)
 {
        quest_type *q_ptr = &quest[p_ptr->inside_quest];
 
@@ -59,7 +66,7 @@ bool confirm_leave_level(bool down_stair)
  */
 bool cmd_limit_cast(player_type *creature_ptr)
 {
-       if (dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
+       if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
        {
                msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
                msg_print(NULL);
@@ -89,6 +96,26 @@ bool cmd_limit_confused(player_type *creature_ptr)
        return FALSE;
 }
 
+bool cmd_limit_image(player_type *creature_ptr)
+{
+       if (creature_ptr->image)
+       {
+               msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
+               return TRUE;
+       }
+       return FALSE;
+}
+
+bool cmd_limit_stun(player_type *creature_ptr)
+{
+       if (creature_ptr->stun)
+       {
+               msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
+               return TRUE;
+       }
+       return FALSE;
+}
+
 bool cmd_limit_arena(player_type *creature_ptr)
 {
        if (creature_ptr->inside_arena)
@@ -136,7 +163,7 @@ void do_cmd_go_up(void)
        bool go_up = FALSE;
 
        /* Player grid */
-       grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
 
        int up_num = 0;
@@ -184,10 +211,8 @@ void do_cmd_go_up(void)
                /* Leaving a quest */
                if (!p_ptr->inside_quest)
                {
-                       dun_level = 0;
+                       current_floor_ptr->dun_level = 0;
                }
-
-               /* Leaving */
                p_ptr->leaving = TRUE;
 
                p_ptr->oldpx = 0;
@@ -199,7 +224,7 @@ void do_cmd_go_up(void)
                return;
        }
 
-       if (!dun_level)
+       if (!current_floor_ptr->dun_level)
        {
                go_up = TRUE;
        }
@@ -231,7 +256,7 @@ void do_cmd_go_up(void)
                leave_quest_check();
 
                p_ptr->inside_quest = g_ptr->special;
-               dun_level = 0;
+               current_floor_ptr->dun_level = 0;
                up_num = 0;
        }
 
@@ -255,20 +280,18 @@ void do_cmd_go_up(void)
                }
 
                /* Get out from current dungeon */
-               if (dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
-                       up_num = dun_level;
+               if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
+                       up_num = current_floor_ptr->dun_level;
        }
        if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
 
        /* Success */
        if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
                msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
-       else if (up_num == dun_level)
+       else if (up_num == current_floor_ptr->dun_level)
                msg_print(_("地上に戻った。", "You go back to the surface."));
        else
                msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
-
-       /* Leaving */
        p_ptr->leaving = TRUE;
 }
 
@@ -280,7 +303,7 @@ void do_cmd_go_up(void)
 void do_cmd_go_down(void)
 {
        /* Player grid */
-       grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
 
        bool fall_trap = FALSE;
@@ -336,10 +359,8 @@ void do_cmd_go_down(void)
                /* Leaving a quest */
                if (!p_ptr->inside_quest)
                {
-                       dun_level = 0;
+                       current_floor_ptr->dun_level = 0;
                }
-
-               /* Leaving */
                p_ptr->leaving = TRUE;
                p_ptr->oldpx = 0;
                p_ptr->oldpy = 0;
@@ -351,7 +372,7 @@ void do_cmd_go_down(void)
        {
                DUNGEON_IDX target_dungeon = 0;
 
-               if (!dun_level)
+               if (!current_floor_ptr->dun_level)
                {
                        target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
 
@@ -387,7 +408,7 @@ void do_cmd_go_down(void)
                if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
                else down_num += 1;
 
-               if (!dun_level)
+               if (!current_floor_ptr->dun_level)
                {
                        /* Enter the dungeon just now */
                        p_ptr->enter_dungeon = TRUE;
@@ -420,8 +441,6 @@ void do_cmd_go_down(void)
                        }
                }
 
-
-               /* Leaving */
                p_ptr->leaving = TRUE;
 
                if (fall_trap)
@@ -446,7 +465,7 @@ void do_cmd_go_down(void)
 
 
 /*!
- * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
+ * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn
  * @return なし
  */
 void do_cmd_search(void)
@@ -461,7 +480,7 @@ void do_cmd_search(void)
                /* Cancel the arg */
                command_arg = 0;
        }
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Search */
        search();
@@ -477,7 +496,7 @@ void do_cmd_search(void)
  */
 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
 {
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
        OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        /* Scan all objects in the grid */
@@ -485,7 +504,7 @@ static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
        {
                object_type *o_ptr;
 
-               o_ptr = &o_list[this_o_idx];
+               o_ptr = &current_floor_ptr->o_list[this_o_idx];
                next_o_idx = o_ptr->next_o_idx;
 
                /* Skip unknown chests XXX XXX */
@@ -517,9 +536,9 @@ static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
        int i, j;
        bool flag = TRUE;
        bool more = FALSE;
-       object_type *o_ptr = &o_list[o_idx];
+       object_type *o_ptr = &current_floor_ptr->o_list[o_idx];
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Attempt to unlock it */
        if (o_ptr->pval > 0)
@@ -604,8 +623,8 @@ static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under
                yy = p_ptr->y + ddy_ddd[d];
                xx = p_ptr->x + ddx_ddd[d];
 
-               /* Get the grid_array */
-               g_ptr = &grid_array[yy][xx];
+               /* Get the current_floor_ptr->grid_array */
+               g_ptr = &current_floor_ptr->grid_array[yy][xx];
 
                /* Must have knowledge */
                if (!(g_ptr->info & (CAVE_MARK))) continue;
@@ -660,7 +679,7 @@ static int count_chests(POSITION *y, POSITION *x, bool trapped)
                if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
 
                /* Grab the object */
-               o_ptr = &o_list[o_idx];
+               o_ptr = &current_floor_ptr->o_list[o_idx];
 
                /* Already open */
                if (o_ptr->pval == 0) continue;
@@ -682,26 +701,6 @@ static int count_chests(POSITION *y, POSITION *x, bool trapped)
 }
 
 
-/*!
- * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
- * Convert an adjacent location to a direction.
- * @param y 方角を確認したY座標
- * @param x 方角を確認したX座標
- * @return 方向ID
- */
-static DIRECTION coords_to_dir(POSITION y, POSITION x)
-{
-       int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
-       DIRECTION dy, dx;
-
-       dy = y - p_ptr->y;
-       dx = x - p_ptr->x;
-
-       /* Paranoia */
-       if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
-
-       return d[dx + 1][dy + 1];
-}
 
 /*!
  * @brief 「開ける」動作コマンドのサブルーチン /
@@ -719,11 +718,11 @@ static bool do_cmd_open_aux(POSITION y, POSITION x)
        int i, j;
 
        /* Get requested grid */
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
        bool more = FALSE;
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Seeing true feature code (ignore mimic) */
 
@@ -855,7 +854,7 @@ void do_cmd_open(void)
                x = p_ptr->x + ddx[dir];
 
                /* Get requested grid */
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -872,7 +871,7 @@ void do_cmd_open(void)
                /* Monster in the way */
                else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
                        py_attack(y, x, 0);
                }
@@ -911,11 +910,11 @@ void do_cmd_open(void)
  */
 static bool do_cmd_close_aux(POSITION y, POSITION x)
 {
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
        FEAT_IDX old_feat = g_ptr->feat;
        bool more = FALSE;
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Seeing true feature code (ignore mimic) */
 
@@ -1000,7 +999,7 @@ void do_cmd_close(void)
 
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -1014,7 +1013,7 @@ void do_cmd_close(void)
                /* Monster in the way */
                else if (g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1044,7 +1043,7 @@ void do_cmd_close(void)
  */
 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
 {
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
 
        /* Must have knowledge */
        if (!(g_ptr->info & CAVE_MARK))
@@ -1088,9 +1087,9 @@ static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
        /* Verify legality */
        if (!do_cmd_tunnel_test(y, x)) return (FALSE);
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
-       g_ptr = &grid_array[y][x];
+       g_ptr = &current_floor_ptr->grid_array[y][x];
        f_ptr = &f_info[g_ptr->feat];
        power = f_ptr->power;
 
@@ -1126,8 +1125,6 @@ static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
 
                        /* Remove the feature */
                        cave_alter_feat(y, x, FF_TUNNEL);
-
-                       /* Update some things */
                        p_ptr->update |= (PU_FLOW);
                }
                else
@@ -1198,7 +1195,7 @@ static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
  * @details
  * <pre>
  * Note that you must tunnel in order to hit invisible monsters
- * in walls, though moving into walls still takes a turn anyway.
+ * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
  *
  * Digging is very difficult without a "digger" weapon, but can be
  * accomplished by strong players using heavy weapons.
@@ -1236,7 +1233,7 @@ void do_cmd_tunnel(void)
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
 
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -1256,7 +1253,7 @@ void do_cmd_tunnel(void)
                /* A monster is in the way */
                else if (g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1294,7 +1291,7 @@ bool easy_open_door(POSITION y, POSITION x)
 {
        int i, j;
 
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
 
        /* Must be a closed door */
@@ -1384,9 +1381,9 @@ static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
 {
        int i, j;
        bool more = FALSE;
-       object_type *o_ptr = &o_list[o_idx];
+       object_type *o_ptr = &current_floor_ptr->o_list[o_idx];
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Get the "disarm" factor */
        i = p_ptr->skill_dis;
@@ -1465,7 +1462,7 @@ static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
 
 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
 {
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
 
        /* Get feature */
        feature_type *f_ptr = &f_info[g_ptr->feat];
@@ -1481,7 +1478,7 @@ bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
        int i = p_ptr->skill_dis;
        int j;
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Penalize some conditions */
        if (p_ptr->blind || no_lite()) i = i / 10;
@@ -1590,7 +1587,7 @@ void do_cmd_disarm(void)
 
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -1647,7 +1644,7 @@ void do_cmd_disarm(void)
  */
 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
 {
-       grid_type       *g_ptr = &grid_array[y][x];
+       grid_type       *g_ptr = &current_floor_ptr->grid_array[y][x];
 
        /* Get feature */
        feature_type *f_ptr = &f_info[g_ptr->feat];
@@ -1663,7 +1660,7 @@ static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
 
        concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
 
@@ -1771,7 +1768,7 @@ void do_cmd_bash(void)
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
 
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -1785,7 +1782,7 @@ void do_cmd_bash(void)
                /* Monster in the way */
                else if (g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1817,7 +1814,7 @@ void do_cmd_bash(void)
  *
  * Consider confusion 
  *
- * This command must always take a turn, to prevent free detection
+ * This command must always take a current_world_ptr->game_turn, to prevent free detection
  * of invisible monsters.
  * </pre>
  */
@@ -1853,13 +1850,13 @@ void do_cmd_alter(void)
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
 
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
                f_ptr = &f_info[feat];
 
-               take_turn(p_ptr, 100);;
+               take_turn(p_ptr, 100);
 
                if (g_ptr->m_idx)
                {
@@ -1975,7 +1972,7 @@ void do_cmd_spike(void)
 
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-               g_ptr = &grid_array[y][x];
+               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                /* Feature code (applying "mimic" field) */
                feat = get_feat_mimic(g_ptr);
@@ -1995,7 +1992,7 @@ void do_cmd_spike(void)
                /* Is a monster in the way? */
                else if (g_ptr->m_idx)
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -2006,7 +2003,7 @@ void do_cmd_spike(void)
                /* Go for it */
                else
                {
-                       take_turn(p_ptr, 100);;
+                       take_turn(p_ptr, 100);
 
                        /* Successful jamming */
                        msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
@@ -2049,7 +2046,7 @@ void do_cmd_walk(bool pickup)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir, FALSE))
        {
-               take_turn(p_ptr, 100);;
+               take_turn(p_ptr, 100);
 
                if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
                {
@@ -2145,7 +2142,7 @@ void do_cmd_stay(bool pickup)
                command_arg = 0;
        }
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        if (pickup) mpe_mode |= MPE_DO_PICKUP;
        (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
@@ -2205,14 +2202,12 @@ void do_cmd_rest(void)
                }
        }
 
-
-       /* Paranoia */
        if (command_arg > 9999) command_arg = 9999;
 
        if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
 
-       /* Take a turn (?) */
-       take_turn(p_ptr, 100);;
+       /* Take a current_world_ptr->game_turn (?) */
+       take_turn(p_ptr, 100);
 
        /* The sin of sloth */
        if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
@@ -2229,7 +2224,7 @@ void do_cmd_rest(void)
                        chg_virtue(V_DILIGENCE, -1);
 
        /* Save the rest code */
-       resting = command_arg;
+       p_ptr->resting = command_arg;
        p_ptr->action = ACTION_REST;
        p_ptr->update |= (PU_BONUS);
        update_creature(p_ptr);
@@ -2246,7 +2241,7 @@ void do_cmd_rest(void)
  * @brief 射撃処理のメインルーチン
  * @return なし
  */
-void do_cmd_fire(void)
+void do_cmd_fire(SPELL_IDX snipe_type)
 {
        OBJECT_IDX item;
        object_type *j_ptr, *ammo_ptr;
@@ -2302,7 +2297,7 @@ void do_cmd_fire(void)
        }
 
        /* Fire the item */
-       exe_fire(item, j_ptr);
+       exe_fire(item, j_ptr, snipe_type);
 
        if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
 
@@ -2517,7 +2512,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                p_ptr->redraw |= (PR_EQUIPPY);
        }
 
-       take_turn(p_ptr, 100);;
+       take_turn(p_ptr, 100);
 
        /* Rogue and Ninja gets bonus */
        if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
@@ -2557,7 +2552,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
                {
                        hit_wall = TRUE;
-                       if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
+                       if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !current_floor_ptr->grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
                }
 
                /* The player can see the (on screen) missile */
@@ -2593,10 +2588,10 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                cur_dis++;
 
                /* Monster here, Try to hit it */
-               if (grid_array[y][x].m_idx)
+               if (current_floor_ptr->grid_array[y][x].m_idx)
                {
-                       grid_type *g_ptr = &grid_array[y][x];
-                       monster_type *m_ptr = &m_list[g_ptr->m_idx];
+                       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
+                       monster_type *m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
 
                        /* Check the visibility */
                        visible = m_ptr->ml;
@@ -2705,7 +2700,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        if (hit_body) torch_lost_fuel(q_ptr);
 
        /* Chance of breakage (during attacks) */
-       j = (hit_body ? breakage_chance(q_ptr) : 0);
+       j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
 
        /* Figurines transform */
        if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
@@ -2729,17 +2724,17 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
 
                        if (potion_smash_effect(0, y, x, q_ptr->k_idx))
                        {
-                               monster_type *m_ptr = &m_list[grid_array[y][x].m_idx];
+                               monster_type *m_ptr = &current_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
 
                                /* ToDo (Robert): fix the invulnerability */
-                               if (grid_array[y][x].m_idx &&
-                                   is_friendly(&m_list[grid_array[y][x].m_idx]) &&
+                               if (current_floor_ptr->grid_array[y][x].m_idx &&
+                                   is_friendly(&current_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]) &&
                                    !MON_INVULNER(m_ptr))
                                {
                                        GAME_TEXT m_name[MAX_NLEN];
-                                       monster_desc(m_name, &m_list[grid_array[y][x].m_idx], 0);
+                                       monster_desc(m_name, &current_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
                                        msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
-                                       set_hostile(&m_list[grid_array[y][x].m_idx]);
+                                       set_hostile(&current_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
                                }
                        }
                        do_drop = FALSE;
@@ -2824,7 +2819,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                        /* Increment the equip counter by hand */
                        equip_cnt++;
 
-                       /* Recalculate torch */
                        p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
                        p_ptr->window |= (PW_EQUIP);
                }
@@ -2854,3 +2848,83 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
 
        return TRUE;
 }
+
+/*!
+ * @brief 自殺するコマンドのメインルーチン
+ * Hack -- commit suicide
+ * @return なし
+ * @details
+ */
+void do_cmd_suicide(void)
+{
+       int i;
+
+       /* Flush input */
+       flush();
+
+       /* Verify Retirement */
+       if (p_ptr->total_winner)
+       {
+               /* Verify */
+               if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
+       }
+
+       /* Verify Suicide */
+       else
+       {
+               /* Verify */
+               if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
+       }
+
+
+       if (!p_ptr->noscore)
+       {
+               /* Special Verification for suicide */
+               prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
+
+               flush();
+               i = inkey();
+               prt("", 0, 0);
+               if (i != '@') return;
+
+               play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
+       }
+
+       /* Initialize "last message" buffer */
+       if (p_ptr->last_message) string_free(p_ptr->last_message);
+       p_ptr->last_message = NULL;
+
+       /* Hack -- Note *winning* message */
+       if (p_ptr->total_winner && last_words)
+       {
+               char buf[1024] = "";
+               play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
+               do
+               {
+                       while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
+               } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
+
+               if (buf[0])
+               {
+                       p_ptr->last_message = string_make(buf);
+                       msg_print(p_ptr->last_message);
+               }
+       }
+
+       /* Stop playing */
+       p_ptr->playing = FALSE;
+
+       /* Kill the player */
+       p_ptr->is_dead = TRUE;
+       p_ptr->leaving = TRUE;
+
+       if (!p_ptr->total_winner)
+       {
+               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
+               do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "--------   Game  Over   --------"));
+               do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
+       }
+
+       /* Cause of death */
+       (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));
+}