OSDN Git Service

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