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