2 * @file travel-execution.cpp
6 #include "action/travel-execution.h"
7 #include "action/movement-execution.h"
8 #include "action/run-execution.h"
9 #include "core/disturbance.h"
10 #include "floor/geometry.h"
11 #include "game-option/disturbance-options.h"
12 #include "game-option/input-options.h"
13 #include "game-option/special-options.h"
14 #include "grid/feature.h"
15 #include "grid/grid.h"
16 #include "player-status/player-energy.h"
17 #include "player/player-move.h"
18 #include "system/floor-type-definition.h"
19 #include "system/grid-type-definition.h"
20 #include "system/monster-type-definition.h"
21 #include "system/player-type-definition.h"
22 #include "view/display-messages.h"
27 * @brief トラベル機能の判定処理 /
29 * @param player_ptr プレイヤーへの参照ポインタ
30 * @param prev_dir 前回移動を行った元の方角ID
33 static DIRECTION travel_test(PlayerType *player_ptr, DIRECTION prev_dir)
35 if (player_ptr->blind || no_lite(player_ptr)) {
36 msg_print(_("目が見えない!", "You cannot see!"));
40 auto *floor_ptr = player_ptr->current_floor_ptr;
41 if ((disturb_trap_detect || alert_trap_detect) && player_ptr->dtrap && !(floor_ptr->grid_array[player_ptr->y][player_ptr->x].info & CAVE_IN_DETECT)) {
42 player_ptr->dtrap = false;
43 if (!(floor_ptr->grid_array[player_ptr->y][player_ptr->x].info & CAVE_UNSAFE)) {
44 if (alert_trap_detect) {
45 msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
48 if (disturb_trap_detect) {
54 int max = (prev_dir & 0x01) + 1;
55 const grid_type *g_ptr;
56 for (int i = -max; i <= max; i++) {
57 DIRECTION dir = cycle[chome[prev_dir] + i];
58 POSITION row = player_ptr->y + ddy[dir];
59 POSITION col = player_ptr->x + ddx[dir];
60 g_ptr = &floor_ptr->grid_array[row][col];
62 auto *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
69 int cost = travel.cost[player_ptr->y][player_ptr->x];
70 DIRECTION new_dir = 0;
71 for (int i = 0; i < 8; ++i) {
72 int dir_cost = travel.cost[player_ptr->y + ddy_ddd[i]][player_ptr->x + ddx_ddd[i]];
73 if (dir_cost < cost) {
83 g_ptr = &floor_ptr->grid_array[player_ptr->y + ddy[new_dir]][player_ptr->x + ddx[new_dir]];
84 if (!easy_open && is_closed_door(player_ptr, g_ptr->feat)) {
88 if (!g_ptr->mimic && !trap_can_be_ignored(player_ptr, g_ptr->feat)) {
98 * @param player_ptr プレイヤーへの参照ポインタ
100 void travel_step(PlayerType *player_ptr)
102 travel.dir = travel_test(player_ptr, travel.dir);
104 if (travel.run == 255) {
105 msg_print(_("道筋が見つかりません!", "No route is found!"));
106 travel.y = travel.x = 0;
109 disturb(player_ptr, false, true);
113 PlayerEnergy(player_ptr).set_player_turn_energy(100);
114 exe_movement(player_ptr, travel.dir, always_pickup, false);
115 if ((player_ptr->y == travel.y) && (player_ptr->x == travel.x)) {
117 travel.y = travel.x = 0;
118 } else if (travel.run > 0) {
122 term_xtra(TERM_XTRA_DELAY, delay_factor);
126 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
127 * @param player_ptr プレイヤーへの参照ポインタ
129 void forget_travel_flow(floor_type *floor_ptr)
131 for (POSITION y = 0; y < floor_ptr->height; y++) {
132 for (POSITION x = 0; x < floor_ptr->width; x++) {
133 travel.cost[y][x] = MAX_SHORT;
137 travel.y = travel.x = 0;