OSDN Git Service

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