OSDN Git Service

[Refactor] #37353 chest_traps を trap.c へ移動。
[hengband/hengband.git] / src / cmd2.c
index d64b54c..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"
@@ -28,6 +29,8 @@
 #include "wild.h"
 #include "grid.h"
 #include "feature.h"
+#include "player-move.h"
+#include "object-broken.h"
 
 /*!
  * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
@@ -93,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)
@@ -190,8 +213,6 @@ void do_cmd_go_up(void)
                {
                        current_floor_ptr->dun_level = 0;
                }
-
-               /* Leaving */
                p_ptr->leaving = TRUE;
 
                p_ptr->oldpx = 0;
@@ -271,8 +292,6 @@ void do_cmd_go_up(void)
                msg_print(_("地上に戻った。", "You go back to the surface."));
        else
                msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
-
-       /* Leaving */
        p_ptr->leaving = TRUE;
 }
 
@@ -342,8 +361,6 @@ void do_cmd_go_down(void)
                {
                        current_floor_ptr->dun_level = 0;
                }
-
-               /* Leaving */
                p_ptr->leaving = TRUE;
                p_ptr->oldpx = 0;
                p_ptr->oldpy = 0;
@@ -424,8 +441,6 @@ void do_cmd_go_down(void)
                        }
                }
 
-
-               /* Leaving */
                p_ptr->leaving = TRUE;
 
                if (fall_trap)
@@ -1110,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
@@ -2189,8 +2202,6 @@ void do_cmd_rest(void)
                }
        }
 
-
-       /* Paranoia */
        if (command_arg > 9999) command_arg = 9999;
 
        if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
@@ -2213,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);
@@ -2230,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;
@@ -2286,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;
 
@@ -2689,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))
@@ -2808,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);
                }
@@ -2838,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"));
+}