OSDN Git Service

6be6c3767c9a388ccafcacfdf4471fef6522b45b
[hengband/hengband.git] / src / cmd-action / cmd-tunnel.c
1 #include "cmd-action/cmd-tunnel.h"
2 #include "action/tunnel-execution.h"
3 #include "cmd-action/cmd-attack.h"
4 #include "core/disturbance.h"
5 #include "core/player-redraw-types.h"
6 #include "floor/geometry.h"
7 #include "grid/feature.h"
8 #include "grid/grid.h"
9 #include "io/input-key-requester.h"
10 #include "io/targeting.h"
11 #include "player/attack-defense-types.h"
12 #include "player/special-defense-types.h"
13 #include "status/action-setter.h"
14 #include "system/floor-type-definition.h"
15 #include "util/bit-flags-calculator.h"
16 #include "view/display-messages.h"
17
18 /*!
19  * @brief 「掘る」動作コマンドのメインルーチン /
20  * Tunnels through "walls" (including rubble and closed doors)
21  * @return なし
22  * @details
23  * <pre>
24  * Note that you must tunnel in order to hit invisible monsters
25  * in walls, though moving into walls still takes a turn anyway.
26  *
27  * Digging is very difficult without a "digger" weapon, but can be
28  * accomplished by strong players using heavy weapons.
29  * </pre>
30  */
31 void do_cmd_tunnel(player_type *creature_ptr)
32 {
33     bool more = FALSE;
34     if (creature_ptr->special_defense & KATA_MUSOU)
35         set_action(creature_ptr, ACTION_NONE);
36
37     if (command_arg) {
38         command_rep = command_arg - 1;
39         creature_ptr->redraw |= PR_STATE;
40         command_arg = 0;
41     }
42
43     DIRECTION dir;
44     if (!get_rep_dir(creature_ptr, &dir, FALSE)) {
45         if (!more)
46             disturb(creature_ptr, FALSE, FALSE);
47
48         return;
49     }
50
51     POSITION y = creature_ptr->y + ddy[dir];
52     POSITION x = creature_ptr->x + ddx[dir];
53     grid_type *g_ptr;
54     g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
55     FEAT_IDX feat = get_feat_mimic(g_ptr);
56     if (have_flag(f_info[feat].flags, FF_DOOR))
57         msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
58     else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
59         msg_print(_("そこは掘れない。", "You can't tunnel through that."));
60     else if (g_ptr->m_idx) {
61         take_turn(creature_ptr, 100);
62         msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
63         do_cmd_attack(creature_ptr, y, x, 0);
64     } else
65         more = exe_tunnel(creature_ptr, y, x);
66
67     if (!more)
68         disturb(creature_ptr, FALSE, FALSE);
69 }