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