1 #include "action/tunnel-execution.h"
2 #include "core/player-update-types.h"
3 #include "floor/cave.h"
4 #include "grid/feature.h"
6 #include "main/sound-definitions-table.h"
7 #include "main/sound-of-music.h"
8 #include "player-info/avatar.h"
9 #include "player/player-move.h"
10 #include "system/floor-type-definition.h"
11 #include "util/bit-flags-calculator.h"
12 #include "view/display-messages.h"
15 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
16 * Determine if a given grid may be "tunneled"
17 * @param y 対象を行うマスのY座標
18 * @param x 対象を行うマスのX座標
21 static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
23 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
24 if (!(g_ptr->info & CAVE_MARK)) {
25 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
29 if (!cave_has_flag_grid(g_ptr, FF_TUNNEL)) {
30 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
38 * @brief 「掘る」動作コマンドのサブルーチン /
39 * Perform the basic "tunnel" command
40 * @param y 対象を行うマスのY座標
41 * @param x 対象を行うマスのX座標
42 * @return 実際に処理が行われた場合TRUEを返す。
44 * Assumes that no monster is blocking the destination
45 * Do not use twall anymore
46 * Returns TRUE if repeated commands may continue
48 bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
51 feature_type *f_ptr, *mimic_f_ptr;
55 if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x))
58 take_turn(creature_ptr, 100);
59 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
60 f_ptr = &f_info[g_ptr->feat];
62 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
63 name = f_name + mimic_f_ptr->name;
65 if (has_flag(f_ptr->flags, FF_PERMANENT)) {
66 if (has_flag(mimic_f_ptr->flags, FF_PERMANENT))
67 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
69 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
70 } else if (has_flag(f_ptr->flags, FF_CAN_DIG)) {
71 if (creature_ptr->skill_dig > randint0(20 * power)) {
72 msg_format(_("%sをくずした。", "You have removed the %s."), name);
73 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
74 creature_ptr->update |= PU_FLOW;
76 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
80 bool tree = has_flag(mimic_f_ptr->flags, FF_TREE);
81 if (creature_ptr->skill_dig > power + randint0(40 * power)) {
83 msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
85 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
86 creature_ptr->update |= (PU_FLOW);
89 if (has_flag(f_ptr->flags, FF_GLASS))
92 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
93 chg_virtue(creature_ptr, V_DILIGENCE, 1);
94 chg_virtue(creature_ptr, V_NATURE, -1);
97 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
98 if (randint0(100) < 25)
101 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
108 if (is_hidden_door(creature_ptr, g_ptr) && (randint0(100) < 25))
109 search(creature_ptr);