1 #include "action/travel-execution.h"
2 #include "action/movement-execution.h"
3 #include "action/run-execution.h"
4 #include "core/disturbance.h"
5 #include "game-option/disturbance-options.h"
6 #include "game-option/input-options.h"
7 #include "game-option/special-options.h"
8 #include "grid/feature.h"
10 #include "player/player-move.h"
11 #include "system/floor-type-definition.h"
12 #include "view/display-messages.h"
17 * @brief トラベル機能の判定処理 /
19 * @param creature_ptr プレーヤーへの参照ポインタ
20 * @param prev_dir 前回移動を行った元の方角ID
23 static DIRECTION travel_test(player_type *creature_ptr, DIRECTION prev_dir)
25 if (creature_ptr->blind || no_lite(creature_ptr)) {
26 msg_print(_("目が見えない!", "You cannot see!"));
30 floor_type *floor_ptr = creature_ptr->current_floor_ptr;
31 if ((disturb_trap_detect || alert_trap_detect) && creature_ptr->dtrap && !(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & CAVE_IN_DETECT)) {
32 creature_ptr->dtrap = FALSE;
33 if (!(floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & CAVE_UNSAFE)) {
34 if (alert_trap_detect)
35 msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
37 if (disturb_trap_detect)
42 int max = (prev_dir & 0x01) + 1;
43 const grid_type *g_ptr;
44 for (int i = -max; i <= max; i++) {
45 DIRECTION dir = cycle[chome[prev_dir] + i];
46 POSITION row = creature_ptr->y + ddy[dir];
47 POSITION col = creature_ptr->x + ddx[dir];
48 g_ptr = &floor_ptr->grid_array[row][col];
50 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
56 int cost = travel.cost[creature_ptr->y][creature_ptr->x];
57 DIRECTION new_dir = 0;
58 for (int i = 0; i < 8; ++i) {
59 int dir_cost = travel.cost[creature_ptr->y + ddy_ddd[i]][creature_ptr->x + ddx_ddd[i]];
60 if (dir_cost < cost) {
69 g_ptr = &floor_ptr->grid_array[creature_ptr->y + ddy[new_dir]][creature_ptr->x + ddx[new_dir]];
70 if (!easy_open && is_closed_door(creature_ptr, g_ptr->feat))
73 if (!g_ptr->mimic && !trap_can_be_ignored(creature_ptr, g_ptr->feat))
82 * @param creature_ptr プレーヤーへの参照ポインタ
85 void travel_step(player_type *creature_ptr)
87 travel.dir = travel_test(creature_ptr, travel.dir);
89 if (travel.run == 255) {
90 msg_print(_("道筋が見つかりません!", "No route is found!"));
91 travel.y = travel.x = 0;
94 disturb(creature_ptr, FALSE, TRUE);
98 take_turn(creature_ptr, 100);
99 exe_movement(creature_ptr, travel.dir, always_pickup, FALSE);
100 if ((creature_ptr->y == travel.y) && (creature_ptr->x == travel.x)) {
102 travel.y = travel.x = 0;
103 } else if (travel.run > 0)
106 term_xtra(TERM_XTRA_DELAY, delay_factor);
110 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
111 * @param creature_ptr プレーヤーへの参照ポインタ
114 void forget_travel_flow(floor_type *floor_ptr)
116 for (POSITION y = 0; y < floor_ptr->height; y++)
117 for (POSITION x = 0; x < floor_ptr->width; x++)
118 travel.cost[y][x] = MAX_SHORT;
120 travel.y = travel.x = 0;