3 * @brief プレイヤーのコマンド処理2 / Movement commands (part 2)
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
17 #include "object-hook.h"
18 #include "projection.h"
19 #include "spells-summon.h"
20 #include "spells-status.h"
21 #include "monster-status.h"
25 #include "player-status.h"
26 #include "realm-hex.h"
29 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
30 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
31 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
33 bool confirm_leave_level(bool down_stair)
35 quest_type *q_ptr = &quest[p_ptr->inside_quest];
37 /* Confirm leaving from once only quest */
38 if (confirm_quest && p_ptr->inside_quest &&
39 (q_ptr->type == QUEST_TYPE_RANDOM ||
40 (q_ptr->flags & QUEST_FLAG_ONCE &&
41 q_ptr->status != QUEST_STATUS_COMPLETED) ||
42 (q_ptr->flags & QUEST_FLAG_TOWER &&
43 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
44 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
46 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
47 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
57 * @brief 魔法系コマンドが制限されているかを返す。
58 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
60 bool cmd_limit_cast(player_type *creature_ptr)
62 if (dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
64 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
68 else if (creature_ptr->anti_magic)
70 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
73 else if (creature_ptr->shero)
75 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
82 bool cmd_limit_confused(player_type *creature_ptr)
84 if (creature_ptr->confused)
86 msg_print(_("混乱していてできない!", "You are too confused!"));
92 bool cmd_limit_arena(player_type *creature_ptr)
94 if (creature_ptr->inside_arena)
96 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
103 bool cmd_limit_blind(player_type *creature_ptr)
105 if (creature_ptr->blind)
107 msg_print(_("目が見えない。", "You can't see anything."));
112 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
118 bool cmd_limit_time_walk(player_type *creature_ptr)
120 if (creature_ptr->timewalk)
122 if (flush_failure) flush();
123 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
131 * @brief 階段を使って階層を昇る処理 / Go up one level
134 void do_cmd_go_up(void)
139 grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
140 feature_type *f_ptr = &f_info[g_ptr->feat];
144 if (p_ptr->special_defense & KATA_MUSOU)
146 set_action(ACTION_NONE);
150 if (!have_flag(f_ptr->flags, FF_LESS))
152 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
156 /* Quest up stairs */
157 if (have_flag(f_ptr->flags, FF_QUEST))
159 /* Cancel the command */
160 if (!confirm_leave_level(FALSE)) return;
164 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
165 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
167 msg_print(_("上の階に登った。", "You enter the up staircase."));
171 p_ptr->inside_quest = g_ptr->special;
173 /* Activate the quest */
174 if (!quest[p_ptr->inside_quest].status)
176 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
178 init_flags = INIT_ASSIGN;
179 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
181 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
184 /* Leaving a quest */
185 if (!p_ptr->inside_quest)
191 p_ptr->leaving = TRUE;
196 take_turn(p_ptr, 100);
198 /* End the command */
208 go_up = confirm_leave_level(FALSE);
211 /* Cancel the command */
214 take_turn(p_ptr, 100);
216 if (autosave_l) do_cmd_save_game(TRUE);
218 /* For a random quest */
219 if (p_ptr->inside_quest &&
220 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
224 p_ptr->inside_quest = 0;
227 /* For a fixed quest */
228 if (p_ptr->inside_quest &&
229 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
233 p_ptr->inside_quest = g_ptr->special;
238 /* For normal dungeon and random quest */
242 if (have_flag(f_ptr->flags, FF_SHAFT))
244 /* Create a way back */
245 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
251 /* Create a way back */
252 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
257 /* Get out from current dungeon */
258 if (dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
261 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
264 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
265 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
266 else if (up_num == dun_level)
267 msg_print(_("地上に戻った。", "You go back to the surface."));
269 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
272 p_ptr->leaving = TRUE;
277 * @brief 階段を使って階層を降りる処理 / Go down one level
280 void do_cmd_go_down(void)
283 grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
284 feature_type *f_ptr = &f_info[g_ptr->feat];
286 bool fall_trap = FALSE;
289 if (p_ptr->special_defense & KATA_MUSOU)
291 set_action(ACTION_NONE);
295 if (!have_flag(f_ptr->flags, FF_MORE))
297 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
301 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
304 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
309 /* Quest down stairs */
310 else if (have_flag(f_ptr->flags, FF_QUEST))
312 /* Confirm Leaving */
313 if(!confirm_leave_level(TRUE)) return;
315 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
316 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
318 msg_print(_("下の階に降りた。", "You enter the down staircase."));
323 p_ptr->inside_quest = g_ptr->special;
325 /* Activate the quest */
326 if (!quest[p_ptr->inside_quest].status)
328 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
330 init_flags = INIT_ASSIGN;
331 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
333 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
336 /* Leaving a quest */
337 if (!p_ptr->inside_quest)
343 p_ptr->leaving = TRUE;
347 take_turn(p_ptr, 100);
352 DUNGEON_IDX target_dungeon = 0;
356 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
358 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
360 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
363 if (!max_dlv[target_dungeon])
365 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
366 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
367 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
370 /* Save old player position */
371 p_ptr->oldpx = p_ptr->x;
372 p_ptr->oldpy = p_ptr->y;
373 p_ptr->dungeon_idx = target_dungeon;
376 * Clear all saved floors
377 * and create a first saved floor
379 prepare_change_floor_mode(CFM_FIRST_FLOOR);
382 take_turn(p_ptr, 100);
384 if (autosave_l) do_cmd_save_game(TRUE);
387 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
392 /* Enter the dungeon just now */
393 p_ptr->enter_dungeon = TRUE;
394 down_num = d_info[p_ptr->dungeon_idx].mindepth;
399 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
400 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
405 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
412 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
416 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
417 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
419 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
425 p_ptr->leaving = TRUE;
429 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
433 if (have_flag(f_ptr->flags, FF_SHAFT))
435 /* Create a way back */
436 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
440 /* Create a way back */
441 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
449 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
452 void do_cmd_search(void)
454 /* Allow repeated command */
457 /* Set repeat count */
458 command_rep = command_arg - 1;
459 p_ptr->redraw |= (PR_STATE);
464 take_turn(p_ptr, 100);;
472 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
473 * @param y 走査対象にしたいマスのY座標
474 * @param x 走査対象にしたいマスのX座標
475 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
476 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
478 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
480 grid_type *g_ptr = &grid_array[y][x];
481 OBJECT_IDX this_o_idx, next_o_idx = 0;
483 /* Scan all objects in the grid */
484 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
488 o_ptr = &o_list[this_o_idx];
489 next_o_idx = o_ptr->next_o_idx;
491 /* Skip unknown chests XXX XXX */
492 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
494 /* Check for non empty chest */
495 if ((o_ptr->tval == TV_CHEST) &&
496 (((!trapped) && (o_ptr->pval)) || /* non empty */
497 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
506 * @brief 箱を開けるコマンドのメインルーチン /
507 * Attempt to open the given chest at the given location
508 * @param y 箱の存在するマスのY座標
509 * @param x 箱の存在するマスのX座標
510 * @param o_idx 箱のオブジェクトID
511 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
513 * Assume there is no monster blocking the destination
515 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
520 object_type *o_ptr = &o_list[o_idx];
522 take_turn(p_ptr, 100);;
524 /* Attempt to unlock it */
527 /* Assume locked, and thus not open */
530 /* Get the "disarm" factor */
531 i = p_ptr->skill_dis;
533 /* Penalize some conditions */
534 if (p_ptr->blind || no_lite()) i = i / 10;
535 if (p_ptr->confused || p_ptr->image) i = i / 10;
537 /* Extract the difficulty */
540 /* Always have a small chance of success */
543 /* Success -- May still have traps */
544 if (randint0(100) < j)
546 msg_print(_("鍵をはずした。", "You have picked the lock."));
551 /* Failure -- Keep trying */
554 /* We may continue repeating */
556 if (flush_failure) flush();
557 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
562 /* Allowed to open */
565 /* Apply chest traps, if any */
566 chest_trap(y, x, o_idx);
568 /* Let the Chest drop items */
569 chest_death(FALSE, y, x, o_idx);
575 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
576 * Attempt to open the given chest at the given location
577 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
578 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
579 * @param test 地形条件を判定するための関数ポインタ
580 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
582 * @details Return the number of features around (or under) the character.
583 * Usually look for doors and floor traps.
585 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
591 /* Count how many matches */
594 /* Check around (and under) the character */
595 for (d = 0; d < 9; d++)
600 /* if not searching under player continue */
601 if ((d == 8) && !under) continue;
603 /* Extract adjacent (legal) location */
604 yy = p_ptr->y + ddy_ddd[d];
605 xx = p_ptr->x + ddx_ddd[d];
607 /* Get the grid_array */
608 g_ptr = &grid_array[yy][xx];
610 /* Must have knowledge */
611 if (!(g_ptr->info & (CAVE_MARK))) continue;
613 /* Feature code (applying "mimic" field) */
614 feat = get_feat_mimic(g_ptr);
616 /* Not looking for this feature */
617 if (!((*test)(feat))) continue;
622 /* Remember the location. Only useful if only one match */
633 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
634 * Return the number of chests around (or under) the character.
635 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
636 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
637 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
640 * If requested, count only trapped chests.
642 static int count_chests(POSITION *y, POSITION *x, bool trapped)
649 /* Count how many matches */
652 /* Check around (and under) the character */
653 for (d = 0; d < 9; d++)
655 /* Extract adjacent (legal) location */
656 POSITION yy = p_ptr->y + ddy_ddd[d];
657 POSITION xx = p_ptr->x + ddx_ddd[d];
659 /* No (visible) chest is there */
660 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
662 /* Grab the object */
663 o_ptr = &o_list[o_idx];
666 if (o_ptr->pval == 0) continue;
668 /* No (known) traps here */
669 if (trapped && (!object_is_known(o_ptr) ||
670 !chest_traps[o_ptr->pval])) continue;
675 /* Remember the location. Only useful if only one match */
686 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
687 * Convert an adjacent location to a direction.
688 * @param y 方角を確認したY座標
689 * @param x 方角を確認したX座標
692 static DIRECTION coords_to_dir(POSITION y, POSITION x)
694 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
701 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
703 return d[dx + 1][dy + 1];
707 * @brief 「開ける」動作コマンドのサブルーチン /
708 * Perform the basic "open" command on doors
709 * @param y 対象を行うマスのY座標
710 * @param x 対象を行うマスのX座標
711 * @return 実際に処理が行われた場合TRUEを返す。
713 * Assume destination is a closed/locked/jammed door
714 * Assume there is no monster blocking the destination
715 * Returns TRUE if repeated commands may continue
717 static bool do_cmd_open_aux(POSITION y, POSITION x)
721 /* Get requested grid */
722 grid_type *g_ptr = &grid_array[y][x];
723 feature_type *f_ptr = &f_info[g_ptr->feat];
726 take_turn(p_ptr, 100);;
728 /* Seeing true feature code (ignore mimic) */
731 if (!have_flag(f_ptr->flags, FF_OPEN))
734 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
738 else if (f_ptr->power)
741 i = p_ptr->skill_dis;
743 /* Penalize some conditions */
744 if (p_ptr->blind || no_lite()) i = i / 10;
745 if (p_ptr->confused || p_ptr->image) i = i / 10;
747 /* Extract the lock power */
750 /* Extract the difficulty */
753 /* Always have a small chance of success */
757 if (randint0(100) < j)
759 msg_print(_("鍵をはずした。", "You have picked the lock."));
762 cave_alter_feat(y, x, FF_OPEN);
764 sound(SOUND_OPENDOOR);
774 if (flush_failure) flush();
776 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
778 /* We may keep trying */
787 cave_alter_feat(y, x, FF_OPEN);
789 sound(SOUND_OPENDOOR);
795 * @brief 「開ける」コマンドのメインルーチン /
796 * Open a closed/locked/jammed door or a closed/locked chest.
799 * Unlocking a locked door/chest is worth one experience point.
801 void do_cmd_open(void)
809 if (p_ptr->wild_mode) return;
811 if (p_ptr->special_defense & KATA_MUSOU)
813 set_action(ACTION_NONE);
816 /* Option: Pick a direction */
819 int num_doors, num_chests;
821 /* Count closed doors (locked or jammed) */
822 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
824 /* Count chests (locked) */
825 num_chests = count_chests(&y, &x, FALSE);
827 /* See if only one target */
828 if (num_doors || num_chests)
830 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
832 if (!too_many) command_dir = coords_to_dir(y, x);
836 /* Allow repeated command */
839 /* Set repeat count */
840 command_rep = command_arg - 1;
841 p_ptr->redraw |= (PR_STATE);
847 /* Get a "repeated" direction */
848 if (get_rep_dir(&dir, TRUE))
853 /* Get requested location */
854 y = p_ptr->y + ddy[dir];
855 x = p_ptr->x + ddx[dir];
857 /* Get requested grid */
858 g_ptr = &grid_array[y][x];
860 /* Feature code (applying "mimic" field) */
861 feat = get_feat_mimic(g_ptr);
863 /* Check for chest */
864 o_idx = chest_check(y, x, FALSE);
867 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
869 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
872 /* Monster in the way */
873 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
875 take_turn(p_ptr, 100);;
876 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
884 more = do_cmd_open_chest(y, x, o_idx);
891 more = do_cmd_open_aux(y, x);
895 /* Cancel repeat unless we may continue */
896 if (!more) disturb(FALSE, FALSE);
902 * @brief 「閉じる」動作コマンドのサブルーチン /
903 * Perform the basic "close" command
904 * @param y 対象を行うマスのY座標
905 * @param x 対象を行うマスのX座標
906 * @return 実際に処理が行われた場合TRUEを返す。
908 * Assume destination is an open/broken door
909 * Assume there is no monster blocking the destination
910 * Returns TRUE if repeated commands may continue
912 static bool do_cmd_close_aux(POSITION y, POSITION x)
914 grid_type *g_ptr = &grid_array[y][x];
915 FEAT_IDX old_feat = g_ptr->feat;
918 take_turn(p_ptr, 100);;
920 /* Seeing true feature code (ignore mimic) */
923 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
925 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
927 /* Hack -- object in the way */
928 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
929 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
931 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
936 cave_alter_feat(y, x, FF_CLOSE);
939 if (old_feat == g_ptr->feat)
941 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
945 sound(SOUND_SHUTDOOR);
954 * @brief 「閉じる」コマンドのメインルーチン /
955 * Close an open door.
958 * Unlocking a locked door/chest is worth one experience point.
960 void do_cmd_close(void)
967 if (p_ptr->wild_mode) return;
969 if (p_ptr->special_defense & KATA_MUSOU)
971 set_action(ACTION_NONE);
974 /* Option: Pick a direction */
977 /* Count open doors */
978 if (count_dt(&y, &x, is_open, FALSE) == 1)
980 command_dir = coords_to_dir(y, x);
984 /* Allow repeated command */
987 /* Set repeat count */
988 command_rep = command_arg - 1;
989 p_ptr->redraw |= (PR_STATE);
995 /* Get a "repeated" direction */
996 if (get_rep_dir(&dir, FALSE))
1001 y = p_ptr->y + ddy[dir];
1002 x = p_ptr->x + ddx[dir];
1003 g_ptr = &grid_array[y][x];
1005 /* Feature code (applying "mimic" field) */
1006 feat = get_feat_mimic(g_ptr);
1008 /* Require open/broken door */
1009 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1011 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1014 /* Monster in the way */
1015 else if (g_ptr->m_idx)
1017 take_turn(p_ptr, 100);;
1019 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1025 /* Close the door */
1028 /* Close the door */
1029 more = do_cmd_close_aux(y, x);
1033 /* Cancel repeat unless we may continue */
1034 if (!more) disturb(FALSE, FALSE);
1039 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1040 * Determine if a given grid may be "tunneled"
1041 * @param y 対象を行うマスのY座標
1042 * @param x 対象を行うマスのX座標
1045 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1047 grid_type *g_ptr = &grid_array[y][x];
1049 /* Must have knowledge */
1050 if (!(g_ptr->info & CAVE_MARK))
1052 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1057 /* Must be a wall/door/etc */
1058 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1060 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1070 * @brief 「掘る」動作コマンドのサブルーチン /
1071 * Perform the basic "tunnel" command
1072 * @param y 対象を行うマスのY座標
1073 * @param x 対象を行うマスのX座標
1074 * @return 実際に処理が行われた場合TRUEを返す。
1076 * Assumes that no monster is blocking the destination
1077 * Do not use twall anymore
1078 * Returns TRUE if repeated commands may continue
1080 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1083 feature_type *f_ptr, *mimic_f_ptr;
1088 /* Verify legality */
1089 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1091 take_turn(p_ptr, 100);;
1094 g_ptr = &grid_array[y][x];
1095 f_ptr = &f_info[g_ptr->feat];
1096 power = f_ptr->power;
1098 /* Feature code (applying "mimic" field) */
1099 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1101 name = f_name + mimic_f_ptr->name;
1105 if (have_flag(f_ptr->flags, FF_PERMANENT))
1108 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1110 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1113 /* Map border (mimiccing Permanent wall) */
1116 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1121 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1124 if (p_ptr->skill_dig > randint0(20 * power))
1126 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1128 /* Remove the feature */
1129 cave_alter_feat(y, x, FF_TUNNEL);
1131 /* Update some things */
1132 p_ptr->update |= (PU_FLOW);
1136 /* Message, keep digging */
1137 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1145 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1148 if (p_ptr->skill_dig > power + randint0(40 * power))
1150 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1153 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1154 p_ptr->update |= (PU_FLOW);
1157 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1159 /* Remove the feature */
1160 cave_alter_feat(y, x, FF_TUNNEL);
1162 chg_virtue(V_DILIGENCE, 1);
1163 chg_virtue(V_NATURE, -1);
1171 /* We may continue chopping */
1172 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1173 /* Occasional Search XXX XXX */
1174 if (randint0(100) < 25) search();
1178 /* We may continue tunelling */
1179 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1186 if (is_hidden_door(g_ptr))
1188 /* Occasional Search XXX XXX */
1189 if (randint0(100) < 25) search();
1196 * @brief 「掘る」動作コマンドのメインルーチン /
1197 * Tunnels through "walls" (including rubble and closed doors)
1201 * Note that you must tunnel in order to hit invisible monsters
1202 * in walls, though moving into walls still takes a turn anyway.
1204 * Digging is very difficult without a "digger" weapon, but can be
1205 * accomplished by strong players using heavy weapons.
1208 void do_cmd_tunnel(void)
1217 if (p_ptr->special_defense & KATA_MUSOU)
1219 set_action(ACTION_NONE);
1222 /* Allow repeated command */
1225 /* Set repeat count */
1226 command_rep = command_arg - 1;
1227 p_ptr->redraw |= (PR_STATE);
1229 /* Cancel the arg */
1233 /* Get a direction to tunnel, or Abort */
1234 if (get_rep_dir(&dir,FALSE))
1237 y = p_ptr->y + ddy[dir];
1238 x = p_ptr->x + ddx[dir];
1241 g_ptr = &grid_array[y][x];
1243 /* Feature code (applying "mimic" field) */
1244 feat = get_feat_mimic(g_ptr);
1246 /* No tunnelling through doors */
1247 if (have_flag(f_info[feat].flags, FF_DOOR))
1249 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1252 /* No tunnelling through most features */
1253 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1255 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1258 /* A monster is in the way */
1259 else if (g_ptr->m_idx)
1261 take_turn(p_ptr, 100);;
1263 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1272 /* Tunnel through walls */
1273 more = do_cmd_tunnel_aux(y, x);
1277 /* Cancel repetition unless we can continue */
1278 if (!more) disturb(FALSE, FALSE);
1282 * @brief 移動処理による簡易な「開く」処理 /
1284 * @return 開く処理が実際に試みられた場合TRUEを返す
1287 * If there is a jammed/closed/locked door at the given location,
1288 * then attempt to unlock/open it. Return TRUE if an attempt was
1289 * made (successful or not), otherwise return FALSE.
1291 * The code here should be nearly identical to that in
1292 * do_cmd_open_test() and do_cmd_open_aux().
1295 bool easy_open_door(POSITION y, POSITION x)
1299 grid_type *g_ptr = &grid_array[y][x];
1300 feature_type *f_ptr = &f_info[g_ptr->feat];
1302 /* Must be a closed door */
1303 if (!is_closed_door(g_ptr->feat))
1309 if (!have_flag(f_ptr->flags, FF_OPEN))
1312 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1317 else if (f_ptr->power)
1320 i = p_ptr->skill_dis;
1322 /* Penalize some conditions */
1323 if (p_ptr->blind || no_lite()) i = i / 10;
1324 if (p_ptr->confused || p_ptr->image) i = i / 10;
1326 /* Extract the lock power */
1329 /* Extract the difficulty */
1332 /* Always have a small chance of success */
1336 if (randint0(100) < j)
1338 msg_print(_("鍵をはずした。", "You have picked the lock."));
1341 cave_alter_feat(y, x, FF_OPEN);
1343 sound(SOUND_OPENDOOR);
1353 if (flush_failure) flush();
1355 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1364 cave_alter_feat(y, x, FF_OPEN);
1366 sound(SOUND_OPENDOOR);
1372 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1373 * Perform the basic "disarm" command
1374 * @param y 解除を行うマスのY座標
1375 * @param x 解除を行うマスのX座標
1376 * @param o_idx 箱のオブジェクトID
1377 * @return ターンを消費する処理が行われた場合TRUEを返す
1380 * Assume destination is a visible trap
1381 * Assume there is no monster blocking the destination
1382 * Returns TRUE if repeated commands may continue
1385 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1389 object_type *o_ptr = &o_list[o_idx];
1391 take_turn(p_ptr, 100);;
1393 /* Get the "disarm" factor */
1394 i = p_ptr->skill_dis;
1396 /* Penalize some conditions */
1397 if (p_ptr->blind || no_lite()) i = i / 10;
1398 if (p_ptr->confused || p_ptr->image) i = i / 10;
1400 /* Extract the difficulty */
1401 j = i - o_ptr->pval;
1403 /* Always have a small chance of success */
1406 /* Must find the trap first. */
1407 if (!object_is_known(o_ptr))
1409 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1413 /* Already disarmed/unlocked */
1414 else if (o_ptr->pval <= 0)
1416 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1419 /* No traps to find. */
1420 else if (!chest_traps[o_ptr->pval])
1422 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1425 /* Success (get a lot of experience) */
1426 else if (randint0(100) < j)
1428 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1429 gain_exp(o_ptr->pval);
1430 o_ptr->pval = (0 - o_ptr->pval);
1433 /* Failure -- Keep trying */
1434 else if ((i > 5) && (randint1(i) > 5))
1436 /* We may keep trying */
1438 if (flush_failure) flush();
1439 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1442 /* Failure -- Set off the trap */
1445 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1447 chest_trap(y, x, o_idx);
1454 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1455 * Perform the basic "disarm" command
1456 * @param y 解除を行うマスのY座標
1457 * @param x 解除を行うマスのX座標
1458 * @param dir プレイヤーからみた方向ID
1459 * @return ターンを消費する処理が行われた場合TRUEを返す
1462 * Assume destination is a visible trap
1463 * Assume there is no monster blocking the destination
1464 * Returns TRUE if repeated commands may continue
1468 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1470 grid_type *g_ptr = &grid_array[y][x];
1473 feature_type *f_ptr = &f_info[g_ptr->feat];
1475 /* Access trap name */
1476 concptr name = (f_name + f_ptr->name);
1478 /* Extract trap "power" */
1479 int power = f_ptr->power;
1482 /* Get the "disarm" factor */
1483 int i = p_ptr->skill_dis;
1486 take_turn(p_ptr, 100);;
1488 /* Penalize some conditions */
1489 if (p_ptr->blind || no_lite()) i = i / 10;
1490 if (p_ptr->confused || p_ptr->image) i = i / 10;
1492 /* Extract the difficulty */
1495 /* Always have a small chance of success */
1499 if (randint0(100) < j)
1501 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1506 /* Remove the trap */
1507 cave_alter_feat(y, x, FF_DISARM);
1509 /* Move the player onto the trap */
1510 move_player(dir, easy_disarm, FALSE);
1513 /* Failure -- Keep trying */
1514 else if ((i > 5) && (randint1(i) > 5))
1517 if (flush_failure) flush();
1519 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1521 /* We may keep trying */
1525 /* Failure -- Set off the trap */
1528 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1529 /* Move the player onto the trap */
1530 move_player(dir, easy_disarm, FALSE);
1537 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1538 * Disarms a trap, or chest
1541 void do_cmd_disarm(void)
1549 if (p_ptr->wild_mode) return;
1551 if (p_ptr->special_defense & KATA_MUSOU)
1553 set_action(ACTION_NONE);
1556 /* Option: Pick a direction */
1559 int num_traps, num_chests;
1561 /* Count visible traps */
1562 num_traps = count_dt(&y, &x, is_trap, TRUE);
1564 /* Count chests (trapped) */
1565 num_chests = count_chests(&y, &x, TRUE);
1567 /* See if only one target */
1568 if (num_traps || num_chests)
1570 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1571 if (!too_many) command_dir = coords_to_dir(y, x);
1576 /* Allow repeated command */
1579 /* Set repeat count */
1580 command_rep = command_arg - 1;
1581 p_ptr->redraw |= (PR_STATE);
1583 /* Cancel the arg */
1587 /* Get a direction (or abort) */
1588 if (get_rep_dir(&dir,TRUE))
1593 y = p_ptr->y + ddy[dir];
1594 x = p_ptr->x + ddx[dir];
1595 g_ptr = &grid_array[y][x];
1597 /* Feature code (applying "mimic" field) */
1598 feat = get_feat_mimic(g_ptr);
1600 /* Check for chests */
1601 o_idx = chest_check(y, x, TRUE);
1604 if (!is_trap(feat) && !o_idx)
1606 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1609 /* Monster in the way */
1610 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1612 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1621 more = do_cmd_disarm_chest(y, x, o_idx);
1627 more = do_cmd_disarm_aux(y, x, dir);
1631 /* Cancel repeat unless told not to */
1632 if (!more) disturb(FALSE, FALSE);
1637 * @brief 「打ち破る」動作コマンドのサブルーチン /
1638 * Perform the basic "bash" command
1639 * @param y 対象を行うマスのY座標
1640 * @param x 対象を行うマスのX座標
1641 * @param dir プレイヤーから見たターゲットの方角ID
1642 * @return 実際に処理が行われた場合TRUEを返す。
1645 * Assume destination is a closed/locked/jammed door
1646 * Assume there is no monster blocking the destination
1647 * Returns TRUE if repeated commands may continue
1650 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1653 grid_type *g_ptr = &grid_array[y][x];
1656 feature_type *f_ptr = &f_info[g_ptr->feat];
1658 /* Hack -- Bash power based on strength */
1659 /* (Ranges from 3 to 20 to 100 to 200) */
1660 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1662 /* Extract door power */
1663 int temp = f_ptr->power;
1667 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1669 take_turn(p_ptr, 100);;
1671 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1673 /* Compare bash power to door power */
1674 temp = (bash - (temp * 10));
1676 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1678 /* Hack -- always have a chance */
1679 if (temp < 1) temp = 1;
1681 /* Hack -- attempt to bash down the door */
1682 if (randint0(100) < temp)
1684 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1686 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1688 /* Break down the door */
1689 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1691 cave_alter_feat(y, x, FF_BASH);
1697 cave_alter_feat(y, x, FF_OPEN);
1700 /* Hack -- Fall through the door */
1701 move_player(dir, FALSE, FALSE);
1704 /* Saving throw against stun */
1705 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1708 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1710 /* Allow repeated bashing */
1714 /* High dexterity yields coolness */
1717 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1719 /* Hack -- Lose balance ala paralysis */
1720 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1727 * @brief 「打ち破る」動作コマンドのメインルーチン /
1728 * Bash open a door, success based on character strength
1732 * For a closed door, pval is positive if locked; negative if stuck.
1734 * For an open door, pval is positive for a broken door.
1736 * A closed door can be opened - harder if locked. Any door might be
1737 * bashed open (and thereby broken). Bashing a door is (potentially)
1738 * faster! You move into the door way. To open a stuck door, it must
1739 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1741 * Creatures can also open or bash doors, see elsewhere.
1744 void do_cmd_bash(void)
1750 if (p_ptr->wild_mode) return;
1752 if (p_ptr->special_defense & KATA_MUSOU)
1754 set_action(ACTION_NONE);
1757 /* Allow repeated command */
1760 /* Set repeat count */
1761 command_rep = command_arg - 1;
1762 p_ptr->redraw |= (PR_STATE);
1764 /* Cancel the arg */
1768 /* Get a "repeated" direction */
1769 if (get_rep_dir(&dir,FALSE))
1774 y = p_ptr->y + ddy[dir];
1775 x = p_ptr->x + ddx[dir];
1778 g_ptr = &grid_array[y][x];
1780 /* Feature code (applying "mimic" field) */
1781 feat = get_feat_mimic(g_ptr);
1783 /* Nothing useful */
1784 if (!have_flag(f_info[feat].flags, FF_BASH))
1786 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1789 /* Monster in the way */
1790 else if (g_ptr->m_idx)
1792 take_turn(p_ptr, 100);;
1794 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1800 /* Bash a closed door */
1804 more = do_cmd_bash_aux(y, x, dir);
1808 /* Unless valid action taken, cancel bash */
1809 if (!more) disturb(FALSE, FALSE);
1814 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1818 * Manipulate an adjacent grid in some way
1820 * Attack monsters, tunnel through walls, disarm traps, open doors.
1822 * Consider confusion
1824 * This command must always take a turn, to prevent free detection
1825 * of invisible monsters.
1828 void do_cmd_alter(void)
1835 if (p_ptr->special_defense & KATA_MUSOU)
1837 set_action(ACTION_NONE);
1840 /* Allow repeated command */
1843 /* Set repeat count */
1844 command_rep = command_arg - 1;
1845 p_ptr->redraw |= (PR_STATE);
1847 /* Cancel the arg */
1851 /* Get a direction */
1852 if (get_rep_dir(&dir,TRUE))
1855 feature_type *f_ptr;
1857 y = p_ptr->y + ddy[dir];
1858 x = p_ptr->x + ddx[dir];
1861 g_ptr = &grid_array[y][x];
1863 /* Feature code (applying "mimic" field) */
1864 feat = get_feat_mimic(g_ptr);
1865 f_ptr = &f_info[feat];
1867 take_turn(p_ptr, 100);;
1875 else if (have_flag(f_ptr->flags, FF_OPEN))
1877 more = do_cmd_open_aux(y, x);
1880 /* Bash jammed doors */
1881 else if (have_flag(f_ptr->flags, FF_BASH))
1883 more = do_cmd_bash_aux(y, x, dir);
1886 /* Tunnel through walls */
1887 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1889 more = do_cmd_tunnel_aux(y, x);
1892 /* Close open doors */
1893 else if (have_flag(f_ptr->flags, FF_CLOSE))
1895 more = do_cmd_close_aux(y, x);
1899 else if (have_flag(f_ptr->flags, FF_DISARM))
1901 more = do_cmd_disarm_aux(y, x, dir);
1906 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1910 /* Cancel repetition unless we can continue */
1911 if (!more) disturb(FALSE, FALSE);
1917 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1918 * Find the index of some "spikes", if possible.
1919 * @param ip くさびとして打てるオブジェクトのID
1920 * @return オブジェクトがある場合TRUEを返す
1923 * Let user choose a pile of spikes, perhaps?
1926 static bool get_spike(INVENTORY_IDX *ip)
1930 /* Check every item in the pack */
1931 for (i = 0; i < INVEN_PACK; i++)
1933 object_type *o_ptr = &inventory[i];
1935 /* Skip non-objects */
1936 if (!o_ptr->k_idx) continue;
1938 /* Check the "tval" code */
1939 if (o_ptr->tval == TV_SPIKE)
1941 /* Save the spike index */
1954 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1955 * Jam a closed door with a spike
1959 * This command may NOT be repeated
1962 void do_cmd_spike(void)
1966 if (p_ptr->wild_mode) return;
1968 if (p_ptr->special_defense & KATA_MUSOU)
1970 set_action(ACTION_NONE);
1973 /* Get a "repeated" direction */
1974 if (get_rep_dir(&dir, FALSE))
1981 y = p_ptr->y + ddy[dir];
1982 x = p_ptr->x + ddx[dir];
1983 g_ptr = &grid_array[y][x];
1985 /* Feature code (applying "mimic" field) */
1986 feat = get_feat_mimic(g_ptr);
1988 /* Require closed door */
1989 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1991 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1995 else if (!get_spike(&item))
1997 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2000 /* Is a monster in the way? */
2001 else if (g_ptr->m_idx)
2003 take_turn(p_ptr, 100);;
2005 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2014 take_turn(p_ptr, 100);;
2016 /* Successful jamming */
2017 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2018 cave_alter_feat(y, x, FF_SPIKE);
2020 /* Use up, and describe, a single spike, from the bottom */
2021 inven_item_increase(item, -1);
2022 inven_item_describe(item);
2023 inven_item_optimize(item);
2031 * @brief 「歩く」動作コマンドのメインルーチン /
2032 * Support code for the "Walk" and "Jump" commands
2033 * @param pickup アイテムの自動拾いを行うならTRUE
2036 void do_cmd_walk(bool pickup)
2043 /* Allow repeated command */
2046 /* Set repeat count */
2047 command_rep = command_arg - 1;
2048 p_ptr->redraw |= (PR_STATE);
2050 /* Cancel the arg */
2054 /* Get a "repeated" direction */
2055 if (get_rep_dir(&dir, FALSE))
2057 take_turn(p_ptr, 100);;
2059 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2061 set_action(ACTION_NONE);
2064 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2065 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2066 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2068 /* Actually move the character */
2069 move_player(dir, pickup, FALSE);
2071 /* Allow more walking */
2075 /* Hack again -- Is there a special encounter ??? */
2076 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2078 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2081 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2083 /* Inform the player of his horrible fate :=) */
2084 msg_print(_("襲撃だ!", "You are ambushed !"));
2086 /* Go into large wilderness view */
2087 p_ptr->oldpy = randint1(MAX_HGT-2);
2088 p_ptr->oldpx = randint1(MAX_WID-2);
2091 /* Give first move to monsters */
2092 take_turn(p_ptr, 100);;
2094 /* HACk -- set the encouter flag for the wilderness generation */
2095 generate_encounter = TRUE;
2099 /* Cancel repeat unless we may continue */
2100 if (!more) disturb(FALSE, FALSE);
2105 * @brief 「走る」動作コマンドのメインルーチン /
2109 void do_cmd_run(void)
2112 if (cmd_limit_confused(p_ptr)) return;
2114 if (p_ptr->special_defense & KATA_MUSOU)
2116 set_action(ACTION_NONE);
2119 /* Get a "repeated" direction */
2120 if (get_rep_dir(&dir,FALSE))
2122 /* Hack -- Set the run counter */
2123 running = (command_arg ? command_arg : 1000);
2132 * @brief 「留まる」動作コマンドのメインルーチン /
2133 * Stay still. Search. Enter stores.
2134 * Pick up treasure if "pickup" is true.
2135 * @param pickup アイテムの自動拾いを行うならTRUE
2138 void do_cmd_stay(bool pickup)
2140 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2142 /* Allow repeated command */
2145 /* Set repeat count */
2146 command_rep = command_arg - 1;
2147 p_ptr->redraw |= (PR_STATE);
2149 /* Cancel the arg */
2153 take_turn(p_ptr, 100);;
2155 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2156 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2161 * @brief 「休む」動作コマンドのメインルーチン /
2162 * Resting allows a player to safely restore his hp -RAK-
2165 void do_cmd_rest(void)
2168 set_action(ACTION_NONE);
2170 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2172 stop_singing(p_ptr);
2176 if (hex_spelling_any()) stop_hex_spell_all();
2178 /* Prompt for time if needed */
2179 if (command_arg <= 0)
2181 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2182 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2188 strcpy(out_val, "&");
2190 /* Ask for duration */
2191 if (!get_string(p, out_val, 4)) return;
2193 /* Rest until done */
2194 if (out_val[0] == '&')
2196 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2200 else if (out_val[0] == '*')
2202 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2208 command_arg = (COMMAND_ARG)atoi(out_val);
2209 if (command_arg <= 0) return;
2215 if (command_arg > 9999) command_arg = 9999;
2217 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2219 /* Take a turn (?) */
2220 take_turn(p_ptr, 100);;
2222 /* The sin of sloth */
2223 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2225 /* Why are you sleeping when there's no need? WAKE UP!*/
2226 if ((p_ptr->chp == p_ptr->mhp) &&
2227 (p_ptr->csp == p_ptr->msp) &&
2228 !p_ptr->blind && !p_ptr->confused &&
2229 !p_ptr->poisoned && !p_ptr->afraid &&
2230 !p_ptr->stun && !p_ptr->cut &&
2231 !p_ptr->slow && !p_ptr->paralyzed &&
2232 !p_ptr->image && !p_ptr->word_recall &&
2233 !p_ptr->alter_reality)
2234 chg_virtue(V_DILIGENCE, -1);
2236 /* Save the rest code */
2237 resting = command_arg;
2238 p_ptr->action = ACTION_REST;
2239 p_ptr->update |= (PU_BONUS);
2240 update_creature(p_ptr);
2242 p_ptr->redraw |= (PR_STATE);
2251 * @brief 射撃処理のメインルーチン
2254 void do_cmd_fire(void)
2257 object_type *j_ptr, *ammo_ptr;
2260 if(p_ptr->wild_mode) return;
2262 is_fired = FALSE; /* not fired yet */
2264 /* Get the "bow" (if any) */
2265 j_ptr = &inventory[INVEN_BOW];
2267 /* Require a launcher */
2270 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2275 if (j_ptr->sval == SV_CRIMSON)
2277 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2282 if (j_ptr->sval == SV_HARP)
2284 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2290 if (p_ptr->special_defense & KATA_MUSOU)
2292 set_action(ACTION_NONE);
2295 /* Require proper missile */
2296 item_tester_tval = p_ptr->tval_ammo;
2298 q = _("どれを撃ちますか? ", "Fire which item? ");
2299 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2302 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2310 exe_fire(item, j_ptr);
2312 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2314 /* Sniper actions after some shootings */
2315 if (snipe_type == SP_AWAY)
2317 teleport_player(10 + (p_ptr->concent * 2), 0L);
2319 if (snipe_type == SP_FINAL)
2321 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2322 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2323 (void)set_stun(p_ptr->stun + randint1(25));
2329 * @brief 投射処理メインルーチン /
2330 * Throw an object from the pack or floor.
2332 * @param boomerang ブーメラン処理ならばTRUE
2333 * @param shuriken 忍者の手裏剣処理ならばTRUE
2334 * @return ターンを消費した場合TRUEを返す
2337 * Note: "unseen" monsters are very hard to hit.
2339 * Should throwing a weapon do full damage? Should it allow the magic
2340 * to hit bonus of the weapon to have an effect? Should it ever cause
2341 * the item to be destroyed? Should it do any damage at all?
2344 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2349 POSITION y, x, ty, tx, prev_y, prev_x;
2350 POSITION ny[19], nx[19];
2351 int chance, tdam, tdis;
2352 int mul, div, dd, ds;
2353 int cur_dis, visible;
2360 bool hit_body = FALSE;
2361 bool hit_wall = FALSE;
2362 bool equiped_item = FALSE;
2363 bool return_when_thrown = FALSE;
2365 GAME_TEXT o_name[MAX_NLEN];
2367 int msec = delay_factor * delay_factor * delay_factor;
2369 BIT_FLAGS flgs[TR_FLAG_SIZE];
2371 bool come_back = FALSE;
2372 bool do_drop = TRUE;
2374 if (p_ptr->wild_mode) return FALSE;
2376 if (p_ptr->special_defense & KATA_MUSOU)
2378 set_action(ACTION_NONE);
2384 o_ptr = &inventory[item];
2388 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2390 item_tester_hook = item_tester_hook_boomerang;
2391 q = _("どの武器を投げますか? ", "Throw which item? ");
2392 s = _("投げる武器がない。", "You have nothing to throw.");
2393 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2400 else if (has_melee_weapon(INVEN_LARM))
2403 o_ptr = &inventory[item];
2408 o_ptr = &inventory[item];
2413 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2414 s = _("投げるアイテムがない。", "You have nothing to throw.");
2415 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2423 /* Item is cursed */
2424 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2426 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2431 if (p_ptr->inside_arena && !boomerang)
2433 if (o_ptr->tval != TV_SPIKE)
2435 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2444 /* Obtain a local object */
2445 object_copy(q_ptr, o_ptr);
2447 /* Extract the thrown object's flags. */
2448 object_flags(q_ptr, flgs);
2449 torch_flags(q_ptr, flgs);
2451 /* Distribute the charges of rods/wands between the stacks */
2452 distribute_charges(o_ptr, q_ptr, 1);
2457 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2459 if (p_ptr->mighty_throw) mult += 3;
2461 /* Extract a "distance multiplier" */
2462 /* Changed for 'launcher' mutation */
2463 mul = 10 + 2 * (mult - 1);
2465 /* Enforce a minimum "weight" of one pound */
2466 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2467 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2469 /* Hack -- Distance -- Reward strength, penalize weight */
2470 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2472 /* Max distance of 10-18 */
2473 if (tdis > mul) tdis = mul;
2477 ty = randint0(101) - 50 + p_ptr->y;
2478 tx = randint0(101) - 50 + p_ptr->x;
2482 project_length = tdis + 1;
2484 /* Get a direction (or cancel) */
2485 if (!get_aim_dir(&dir)) return FALSE;
2487 /* Predict the "target" location */
2488 tx = p_ptr->x + 99 * ddx[dir];
2489 ty = p_ptr->y + 99 * ddy[dir];
2491 /* Check for "target request" */
2492 if ((dir == 5) && target_okay())
2498 project_length = 0; /* reset to default */
2501 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2502 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2503 return_when_thrown = TRUE;
2505 /* Reduce and describe inventory */
2508 inven_item_increase(item, -1);
2509 if (!return_when_thrown)
2510 inven_item_describe(item);
2511 inven_item_optimize(item);
2514 /* Reduce and describe floor item */
2517 floor_item_increase(0 - item, -1);
2518 floor_item_optimize(0 - item);
2520 if (item >= INVEN_RARM)
2522 equiped_item = TRUE;
2523 p_ptr->redraw |= (PR_EQUIPPY);
2526 take_turn(p_ptr, 100);;
2528 /* Rogue and Ninja gets bonus */
2529 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2530 p_ptr->energy_use -= p_ptr->lev;
2532 /* Start at the player */
2538 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2539 else shuriken = FALSE;
2541 /* Chance of hitting */
2542 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2543 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2544 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2546 if (shuriken) chance *= 2;
2551 /* Travel until stopped */
2552 for (cur_dis = 0; cur_dis <= tdis; )
2554 /* Hack -- Stop at the target */
2555 if ((y == ty) && (x == tx)) break;
2557 /* Calculate the new location (see "project()") */
2560 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2562 /* Stopped by walls/doors */
2563 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2566 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2569 /* The player can see the (on screen) missile */
2570 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2572 SYMBOL_CODE c = object_char(q_ptr);
2573 TERM_COLOR a = object_attr(q_ptr);
2575 /* Draw, Hilite, Fresh, Pause, Erase */
2576 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2577 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2579 Term_xtra(TERM_XTRA_DELAY, msec);
2580 lite_spot(ny[cur_dis], nx[cur_dis]);
2584 /* The player cannot see the missile */
2587 /* Pause anyway, for consistancy */
2588 Term_xtra(TERM_XTRA_DELAY, msec);
2594 /* Save the new location */
2598 /* Advance the distance */
2601 /* Monster here, Try to hit it */
2602 if (grid_array[y][x].m_idx)
2604 grid_type *g_ptr = &grid_array[y][x];
2605 monster_type *m_ptr = &m_list[g_ptr->m_idx];
2607 /* Check the visibility */
2608 visible = m_ptr->ml;
2610 /* Note the collision */
2613 /* Did we hit it (penalize range) */
2614 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2618 /* Handle unseen monster */
2621 /* Invisible monster */
2622 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2625 /* Handle visible monster */
2628 GAME_TEXT m_name[MAX_NLEN];
2629 monster_desc(m_name, m_ptr, 0);
2630 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2634 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2635 health_track(g_ptr->m_idx);
2639 /* Hack -- Base damage from thrown object */
2642 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2643 tdam = damroll(dd, ds);
2644 /* Apply special damage */
2645 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2646 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2647 if (q_ptr->to_d > 0)
2648 tdam += q_ptr->to_d;
2650 tdam += -q_ptr->to_d;
2654 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2655 tdam += p_ptr->to_d_m;
2657 else if (have_flag(flgs, TR_THROW))
2660 tdam += p_ptr->to_d_m;
2668 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2671 /* No negative damage */
2672 if (tdam < 0) tdam = 0;
2674 /* Modify the damage */
2675 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2677 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2678 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2680 /* Hit the monster, check for death */
2681 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2689 message_pain(g_ptr->m_idx, tdam);
2691 /* Anger the monster */
2692 if ((tdam > 0) && !object_is_potion(q_ptr))
2693 anger_monster(m_ptr);
2695 if (fear && m_ptr->ml)
2698 GAME_TEXT m_name[MAX_NLEN];
2699 monster_desc(m_name, m_ptr, 0);
2700 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2710 /* decrease toach's fuel */
2711 if (hit_body) torch_lost_fuel(q_ptr);
2713 /* Chance of breakage (during attacks) */
2714 j = (hit_body ? breakage_chance(q_ptr) : 0);
2716 /* Figurines transform */
2717 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2721 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2722 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2723 else if (object_is_cursed(q_ptr))
2724 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2729 /* Potions smash open */
2730 if (object_is_potion(q_ptr))
2732 if (hit_body || hit_wall || (randint1(100) < j))
2734 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2736 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2738 monster_type *m_ptr = &m_list[grid_array[y][x].m_idx];
2740 /* ToDo (Robert): fix the invulnerability */
2741 if (grid_array[y][x].m_idx &&
2742 is_friendly(&m_list[grid_array[y][x].m_idx]) &&
2743 !MON_INVULNER(m_ptr))
2745 GAME_TEXT m_name[MAX_NLEN];
2746 monster_desc(m_name, &m_list[grid_array[y][x].m_idx], 0);
2747 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2748 set_hostile(&m_list[grid_array[y][x].m_idx]);
2759 if (return_when_thrown)
2761 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2762 char o2_name[MAX_NLEN];
2763 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2766 if (boomerang) back_chance += 4+randint1(5);
2767 if (super_boomerang) back_chance += 100;
2768 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2770 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2772 for (i = cur_dis - 1; i > 0; i--)
2774 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2776 char c = object_char(q_ptr);
2777 byte a = object_attr(q_ptr);
2779 /* Draw, Hilite, Fresh, Pause, Erase */
2780 print_rel(c, a, ny[i], nx[i]);
2781 move_cursor_relative(ny[i], nx[i]);
2783 Term_xtra(TERM_XTRA_DELAY, msec);
2784 lite_spot(ny[i], nx[i]);
2789 /* Pause anyway, for consistancy */
2790 Term_xtra(TERM_XTRA_DELAY, msec);
2793 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2795 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2802 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2806 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2814 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2820 if (item == INVEN_RARM || item == INVEN_LARM)
2822 /* Access the wield slot */
2823 o_ptr = &inventory[item];
2825 /* Wear the new stuff */
2826 object_copy(o_ptr, q_ptr);
2828 p_ptr->total_weight += q_ptr->weight;
2830 /* Increment the equip counter by hand */
2833 /* Recalculate torch */
2834 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2835 p_ptr->window |= (PW_EQUIP);
2843 else if (equiped_item)
2851 if (cave_have_flag_bold(y, x, FF_PROJECT))
2853 (void)drop_near(q_ptr, j, y, x);
2857 (void)drop_near(q_ptr, j, prev_y, prev_x);
2867 * Hack: travel command
2869 #define TRAVEL_UNABLE 9999
2871 static int flow_head = 0;
2872 static int flow_tail = 0;
2873 static POSITION temp2_x[MAX_SHORT];
2874 static POSITION temp2_y[MAX_SHORT];
2877 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
2880 void forget_travel_flow(void)
2883 /* Check the entire dungeon / Forget the old data */
2884 for (y = 0; y < cur_hgt; y++)
2886 for (x = 0; x < cur_wid; x++)
2889 travel.cost[y][x] = MAX_SHORT;
2892 travel.y = travel.x = 0;
2896 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
2901 static int travel_flow_cost(POSITION y, POSITION x)
2903 feature_type *f_ptr = &f_info[grid_array[y][x].feat];
2906 /* Avoid obstacles (ex. trees) */
2907 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
2910 if (have_flag(f_ptr->flags, FF_WATER))
2912 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
2916 if (have_flag(f_ptr->flags, FF_LAVA))
2919 if (!p_ptr->resist_fire) lava *= 2;
2920 if (!p_ptr->levitation) lava *= 2;
2921 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
2926 /* Detected traps and doors */
2927 if (grid_array[y][x].info & (CAVE_MARK))
2929 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
2930 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
2937 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
2941 * @param wall プレイヤーが壁の中にいるならばTRUE
2944 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
2946 grid_type *g_ptr = &grid_array[y][x];
2947 feature_type *f_ptr = &f_info[g_ptr->feat];
2948 int old_head = flow_head;
2950 int base_cost = (n % TRAVEL_UNABLE);
2951 int from_wall = (n / TRAVEL_UNABLE);
2954 /* Ignore out of bounds */
2955 if (!in_bounds(y, x)) return;
2957 /* Ignore unknown grid except in wilderness */
2958 if (dun_level > 0 && !(g_ptr->info & CAVE_KNOWN)) return;
2960 /* Ignore "walls" and "rubble" (include "secret doors") */
2961 if (have_flag(f_ptr->flags, FF_WALL) ||
2962 have_flag(f_ptr->flags, FF_CAN_DIG) ||
2963 (have_flag(f_ptr->flags, FF_DOOR) && grid_array[y][x].mimic) ||
2964 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
2966 if (!wall || !from_wall) return;
2967 add_cost += TRAVEL_UNABLE;
2971 add_cost = travel_flow_cost(y, x);
2974 cost = base_cost + add_cost;
2976 /* Ignore lower cost entries */
2977 if (travel.cost[y][x] <= cost) return;
2979 /* Save the flow cost */
2980 travel.cost[y][x] = cost;
2982 /* Enqueue that entry */
2983 temp2_y[flow_head] = y;
2984 temp2_x[flow_head] = x;
2986 /* Advance the queue */
2987 if (++flow_head == MAX_SHORT) flow_head = 0;
2989 /* Hack -- notice overflow by forgetting new entry */
2990 if (flow_head == flow_tail) flow_head = old_head;
2996 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
2997 * @param ty 目標地点のY座標
2998 * @param tx 目標地点のX座標
3001 static void travel_flow(POSITION ty, POSITION tx)
3005 feature_type *f_ptr = &f_info[grid_array[p_ptr->y][p_ptr->x].feat];
3007 /* Reset the "queue" */
3008 flow_head = flow_tail = 0;
3010 /* is player in the wall? */
3011 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
3013 /* Start at the target grid */
3014 travel_flow_aux(ty, tx, 0, wall);
3016 /* Now process the queue */
3017 while (flow_head != flow_tail)
3019 /* Extract the next entry */
3020 y = temp2_y[flow_tail];
3021 x = temp2_x[flow_tail];
3023 /* Forget that entry */
3024 if (++flow_tail == MAX_SHORT) flow_tail = 0;
3026 /* Ignore too far entries */
3027 //if (distance(ty, tx, y, x) > 100) continue;
3029 /* Add the "children" */
3030 for (d = 0; d < 8; d++)
3032 /* Add that child if "legal" */
3033 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
3037 /* Forget the flow info */
3038 flow_head = flow_tail = 0;
3042 * @brief トラベル処理のメインルーチン
3045 void do_cmd_travel(void)
3049 POSITION dx, dy, sx, sy;
3050 feature_type *f_ptr;
3052 if (travel.x != 0 && travel.y != 0 &&
3053 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3058 else if (!tgt_pt(&x, &y)) return;
3060 if ((x == p_ptr->x) && (y == p_ptr->y))
3062 msg_print(_("すでにそこにいます!", "You are already there!!"));
3066 f_ptr = &f_info[grid_array[y][x].feat];
3068 if ((grid_array[y][x].info & CAVE_MARK) &&
3069 (have_flag(f_ptr->flags, FF_WALL) ||
3070 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3071 (have_flag(f_ptr->flags, FF_DOOR) && grid_array[y][x].mimic)))
3073 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3077 forget_travel_flow();
3083 /* Travel till 255 steps */
3089 /* Decides first direction */
3090 dx = abs(p_ptr->x - x);
3091 dy = abs(p_ptr->y - y);
3092 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3093 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3095 for (i = 1; i <= 9; i++)
3097 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;