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 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
140 feature_type *f_ptr = &f_info[c_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 = c_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 = c_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 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
284 feature_type *f_ptr = &f_info[c_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 = c_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) ? c_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 cave_type *c_ptr = &cave[y][x];
481 OBJECT_IDX this_o_idx, next_o_idx = 0;
483 /* Scan all objects in the grid */
484 for (this_o_idx = c_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)
587 int d, count, xx, yy;
589 /* Count how many matches */
592 /* Check around (and under) the character */
593 for (d = 0; d < 9; d++)
598 /* if not searching under player continue */
599 if ((d == 8) && !under) continue;
601 /* Extract adjacent (legal) location */
602 yy = p_ptr->y + ddy_ddd[d];
603 xx = p_ptr->x + ddx_ddd[d];
606 c_ptr = &cave[yy][xx];
608 /* Must have knowledge */
609 if (!(c_ptr->info & (CAVE_MARK))) continue;
611 /* Feature code (applying "mimic" field) */
612 feat = get_feat_mimic(c_ptr);
614 /* Not looking for this feature */
615 if (!((*test)(feat))) continue;
620 /* Remember the location. Only useful if only one match */
631 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
632 * Return the number of chests around (or under) the character.
633 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
634 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
635 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
638 * If requested, count only trapped chests.
640 static int count_chests(POSITION *y, POSITION *x, bool trapped)
647 /* Count how many matches */
650 /* Check around (and under) the character */
651 for (d = 0; d < 9; d++)
653 /* Extract adjacent (legal) location */
654 POSITION yy = p_ptr->y + ddy_ddd[d];
655 POSITION xx = p_ptr->x + ddx_ddd[d];
657 /* No (visible) chest is there */
658 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
660 /* Grab the object */
661 o_ptr = &o_list[o_idx];
664 if (o_ptr->pval == 0) continue;
666 /* No (known) traps here */
667 if (trapped && (!object_is_known(o_ptr) ||
668 !chest_traps[o_ptr->pval])) continue;
673 /* Remember the location. Only useful if only one match */
684 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
685 * Convert an adjacent location to a direction.
686 * @param y 方角を確認したY座標
687 * @param x 方角を確認したX座標
690 static DIRECTION coords_to_dir(POSITION y, POSITION x)
692 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
699 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
701 return d[dx + 1][dy + 1];
705 * @brief 「開ける」動作コマンドのサブルーチン /
706 * Perform the basic "open" command on doors
707 * @param y 対象を行うマスのY座標
708 * @param x 対象を行うマスのX座標
709 * @return 実際に処理が行われた場合TRUEを返す。
711 * Assume destination is a closed/locked/jammed door
712 * Assume there is no monster blocking the destination
713 * Returns TRUE if repeated commands may continue
715 static bool do_cmd_open_aux(POSITION y, POSITION x)
719 /* Get requested grid */
720 cave_type *c_ptr = &cave[y][x];
721 feature_type *f_ptr = &f_info[c_ptr->feat];
724 take_turn(p_ptr, 100);;
726 /* Seeing true feature code (ignore mimic) */
729 if (!have_flag(f_ptr->flags, FF_OPEN))
732 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
736 else if (f_ptr->power)
739 i = p_ptr->skill_dis;
741 /* Penalize some conditions */
742 if (p_ptr->blind || no_lite()) i = i / 10;
743 if (p_ptr->confused || p_ptr->image) i = i / 10;
745 /* Extract the lock power */
748 /* Extract the difficulty */
751 /* Always have a small chance of success */
755 if (randint0(100) < j)
757 msg_print(_("鍵をはずした。", "You have picked the lock."));
760 cave_alter_feat(y, x, FF_OPEN);
762 sound(SOUND_OPENDOOR);
772 if (flush_failure) flush();
774 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
776 /* We may keep trying */
785 cave_alter_feat(y, x, FF_OPEN);
787 sound(SOUND_OPENDOOR);
793 * @brief 「開ける」コマンドのメインルーチン /
794 * Open a closed/locked/jammed door or a closed/locked chest.
797 * Unlocking a locked door/chest is worth one experience point.
799 void do_cmd_open(void)
807 if (p_ptr->wild_mode) return;
809 if (p_ptr->special_defense & KATA_MUSOU)
811 set_action(ACTION_NONE);
814 /* Option: Pick a direction */
817 int num_doors, num_chests;
819 /* Count closed doors (locked or jammed) */
820 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
822 /* Count chests (locked) */
823 num_chests = count_chests(&y, &x, FALSE);
825 /* See if only one target */
826 if (num_doors || num_chests)
828 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
830 if (!too_many) command_dir = coords_to_dir(y, x);
834 /* Allow repeated command */
837 /* Set repeat count */
838 command_rep = command_arg - 1;
839 p_ptr->redraw |= (PR_STATE);
845 /* Get a "repeated" direction */
846 if (get_rep_dir(&dir, TRUE))
851 /* Get requested location */
852 y = p_ptr->y + ddy[dir];
853 x = p_ptr->x + ddx[dir];
855 /* Get requested grid */
858 /* Feature code (applying "mimic" field) */
859 feat = get_feat_mimic(c_ptr);
861 /* Check for chest */
862 o_idx = chest_check(y, x, FALSE);
865 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
867 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
870 /* Monster in the way */
871 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
873 take_turn(p_ptr, 100);;
874 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
882 more = do_cmd_open_chest(y, x, o_idx);
889 more = do_cmd_open_aux(y, x);
893 /* Cancel repeat unless we may continue */
894 if (!more) disturb(FALSE, FALSE);
900 * @brief 「閉じる」動作コマンドのサブルーチン /
901 * Perform the basic "close" command
902 * @param y 対象を行うマスのY座標
903 * @param x 対象を行うマスのX座標
904 * @return 実際に処理が行われた場合TRUEを返す。
906 * Assume destination is an open/broken door
907 * Assume there is no monster blocking the destination
908 * Returns TRUE if repeated commands may continue
910 static bool do_cmd_close_aux(POSITION y, POSITION x)
912 cave_type *c_ptr = &cave[y][x];
913 FEAT_IDX old_feat = c_ptr->feat;
916 take_turn(p_ptr, 100);;
918 /* Seeing true feature code (ignore mimic) */
921 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
923 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
925 /* Hack -- object in the way */
926 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
927 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
929 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
934 cave_alter_feat(y, x, FF_CLOSE);
937 if (old_feat == c_ptr->feat)
939 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
943 sound(SOUND_SHUTDOOR);
952 * @brief 「閉じる」コマンドのメインルーチン /
953 * Close an open door.
956 * Unlocking a locked door/chest is worth one experience point.
958 void do_cmd_close(void)
965 if (p_ptr->wild_mode) return;
967 if (p_ptr->special_defense & KATA_MUSOU)
969 set_action(ACTION_NONE);
972 /* Option: Pick a direction */
975 /* Count open doors */
976 if (count_dt(&y, &x, is_open, FALSE) == 1)
978 command_dir = coords_to_dir(y, x);
982 /* Allow repeated command */
985 /* Set repeat count */
986 command_rep = command_arg - 1;
987 p_ptr->redraw |= (PR_STATE);
993 /* Get a "repeated" direction */
994 if (get_rep_dir(&dir, FALSE))
999 y = p_ptr->y + ddy[dir];
1000 x = p_ptr->x + ddx[dir];
1001 c_ptr = &cave[y][x];
1003 /* Feature code (applying "mimic" field) */
1004 feat = get_feat_mimic(c_ptr);
1006 /* Require open/broken door */
1007 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1009 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1012 /* Monster in the way */
1013 else if (c_ptr->m_idx)
1015 take_turn(p_ptr, 100);;
1017 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1023 /* Close the door */
1026 /* Close the door */
1027 more = do_cmd_close_aux(y, x);
1031 /* Cancel repeat unless we may continue */
1032 if (!more) disturb(FALSE, FALSE);
1037 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1038 * Determine if a given grid may be "tunneled"
1039 * @param y 対象を行うマスのY座標
1040 * @param x 対象を行うマスのX座標
1043 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1045 cave_type *c_ptr = &cave[y][x];
1047 /* Must have knowledge */
1048 if (!(c_ptr->info & CAVE_MARK))
1050 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1055 /* Must be a wall/door/etc */
1056 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1058 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1068 * @brief 「掘る」動作コマンドのサブルーチン /
1069 * Perform the basic "tunnel" command
1070 * @param y 対象を行うマスのY座標
1071 * @param x 対象を行うマスのX座標
1072 * @return 実際に処理が行われた場合TRUEを返す。
1074 * Assumes that no monster is blocking the destination
1075 * Do not use twall anymore
1076 * Returns TRUE if repeated commands may continue
1078 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1081 feature_type *f_ptr, *mimic_f_ptr;
1086 /* Verify legality */
1087 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1089 take_turn(p_ptr, 100);;
1092 c_ptr = &cave[y][x];
1093 f_ptr = &f_info[c_ptr->feat];
1094 power = f_ptr->power;
1096 /* Feature code (applying "mimic" field) */
1097 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1099 name = f_name + mimic_f_ptr->name;
1103 if (have_flag(f_ptr->flags, FF_PERMANENT))
1106 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1108 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1111 /* Map border (mimiccing Permanent wall) */
1114 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1119 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1122 if (p_ptr->skill_dig > randint0(20 * power))
1124 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1126 /* Remove the feature */
1127 cave_alter_feat(y, x, FF_TUNNEL);
1129 /* Update some things */
1130 p_ptr->update |= (PU_FLOW);
1134 /* Message, keep digging */
1135 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1143 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1146 if (p_ptr->skill_dig > power + randint0(40 * power))
1148 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1151 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1152 p_ptr->update |= (PU_FLOW);
1155 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1157 /* Remove the feature */
1158 cave_alter_feat(y, x, FF_TUNNEL);
1160 chg_virtue(V_DILIGENCE, 1);
1161 chg_virtue(V_NATURE, -1);
1169 /* We may continue chopping */
1170 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1171 /* Occasional Search XXX XXX */
1172 if (randint0(100) < 25) search();
1176 /* We may continue tunelling */
1177 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1184 if (is_hidden_door(c_ptr))
1186 /* Occasional Search XXX XXX */
1187 if (randint0(100) < 25) search();
1194 * @brief 「掘る」動作コマンドのメインルーチン /
1195 * Tunnels through "walls" (including rubble and closed doors)
1199 * Note that you must tunnel in order to hit invisible monsters
1200 * in walls, though moving into walls still takes a turn anyway.
1202 * Digging is very difficult without a "digger" weapon, but can be
1203 * accomplished by strong players using heavy weapons.
1206 void do_cmd_tunnel(void)
1216 if (p_ptr->special_defense & KATA_MUSOU)
1218 set_action(ACTION_NONE);
1221 /* Allow repeated command */
1224 /* Set repeat count */
1225 command_rep = command_arg - 1;
1226 p_ptr->redraw |= (PR_STATE);
1228 /* Cancel the arg */
1232 /* Get a direction to tunnel, or Abort */
1233 if (get_rep_dir(&dir,FALSE))
1236 y = p_ptr->y + ddy[dir];
1237 x = p_ptr->x + ddx[dir];
1240 c_ptr = &cave[y][x];
1242 /* Feature code (applying "mimic" field) */
1243 feat = get_feat_mimic(c_ptr);
1245 /* No tunnelling through doors */
1246 if (have_flag(f_info[feat].flags, FF_DOOR))
1248 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1251 /* No tunnelling through most features */
1252 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1254 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1257 /* A monster is in the way */
1258 else if (c_ptr->m_idx)
1260 take_turn(p_ptr, 100);;
1262 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1271 /* Tunnel through walls */
1272 more = do_cmd_tunnel_aux(y, x);
1276 /* Cancel repetition unless we can continue */
1277 if (!more) disturb(FALSE, FALSE);
1281 * @brief 移動処理による簡易な「開く」処理 /
1283 * @return 開く処理が実際に試みられた場合TRUEを返す
1286 * If there is a jammed/closed/locked door at the given location,
1287 * then attempt to unlock/open it. Return TRUE if an attempt was
1288 * made (successful or not), otherwise return FALSE.
1290 * The code here should be nearly identical to that in
1291 * do_cmd_open_test() and do_cmd_open_aux().
1294 bool easy_open_door(POSITION y, POSITION x)
1298 cave_type *c_ptr = &cave[y][x];
1299 feature_type *f_ptr = &f_info[c_ptr->feat];
1301 /* Must be a closed door */
1302 if (!is_closed_door(c_ptr->feat))
1308 if (!have_flag(f_ptr->flags, FF_OPEN))
1311 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1316 else if (f_ptr->power)
1319 i = p_ptr->skill_dis;
1321 /* Penalize some conditions */
1322 if (p_ptr->blind || no_lite()) i = i / 10;
1323 if (p_ptr->confused || p_ptr->image) i = i / 10;
1325 /* Extract the lock power */
1328 /* Extract the difficulty */
1331 /* Always have a small chance of success */
1335 if (randint0(100) < j)
1337 msg_print(_("鍵をはずした。", "You have picked the lock."));
1340 cave_alter_feat(y, x, FF_OPEN);
1342 sound(SOUND_OPENDOOR);
1352 if (flush_failure) flush();
1354 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1363 cave_alter_feat(y, x, FF_OPEN);
1365 sound(SOUND_OPENDOOR);
1371 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1372 * Perform the basic "disarm" command
1373 * @param y 解除を行うマスのY座標
1374 * @param x 解除を行うマスのX座標
1375 * @param o_idx 箱のオブジェクトID
1376 * @return ターンを消費する処理が行われた場合TRUEを返す
1379 * Assume destination is a visible trap
1380 * Assume there is no monster blocking the destination
1381 * Returns TRUE if repeated commands may continue
1384 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1388 object_type *o_ptr = &o_list[o_idx];
1390 take_turn(p_ptr, 100);;
1392 /* Get the "disarm" factor */
1393 i = p_ptr->skill_dis;
1395 /* Penalize some conditions */
1396 if (p_ptr->blind || no_lite()) i = i / 10;
1397 if (p_ptr->confused || p_ptr->image) i = i / 10;
1399 /* Extract the difficulty */
1400 j = i - o_ptr->pval;
1402 /* Always have a small chance of success */
1405 /* Must find the trap first. */
1406 if (!object_is_known(o_ptr))
1408 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1412 /* Already disarmed/unlocked */
1413 else if (o_ptr->pval <= 0)
1415 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1418 /* No traps to find. */
1419 else if (!chest_traps[o_ptr->pval])
1421 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1424 /* Success (get a lot of experience) */
1425 else if (randint0(100) < j)
1427 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1428 gain_exp(o_ptr->pval);
1429 o_ptr->pval = (0 - o_ptr->pval);
1432 /* Failure -- Keep trying */
1433 else if ((i > 5) && (randint1(i) > 5))
1435 /* We may keep trying */
1437 if (flush_failure) flush();
1438 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1441 /* Failure -- Set off the trap */
1444 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1446 chest_trap(y, x, o_idx);
1453 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1454 * Perform the basic "disarm" command
1455 * @param y 解除を行うマスのY座標
1456 * @param x 解除を行うマスのX座標
1457 * @param dir プレイヤーからみた方向ID
1458 * @return ターンを消費する処理が行われた場合TRUEを返す
1461 * Assume destination is a visible trap
1462 * Assume there is no monster blocking the destination
1463 * Returns TRUE if repeated commands may continue
1467 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1469 cave_type *c_ptr = &cave[y][x];
1472 feature_type *f_ptr = &f_info[c_ptr->feat];
1474 /* Access trap name */
1475 concptr name = (f_name + f_ptr->name);
1477 /* Extract trap "power" */
1478 int power = f_ptr->power;
1481 /* Get the "disarm" factor */
1482 int i = p_ptr->skill_dis;
1485 take_turn(p_ptr, 100);;
1487 /* Penalize some conditions */
1488 if (p_ptr->blind || no_lite()) i = i / 10;
1489 if (p_ptr->confused || p_ptr->image) i = i / 10;
1491 /* Extract the difficulty */
1494 /* Always have a small chance of success */
1498 if (randint0(100) < j)
1500 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1505 /* Remove the trap */
1506 cave_alter_feat(y, x, FF_DISARM);
1508 /* Move the player onto the trap */
1509 move_player(dir, easy_disarm, FALSE);
1512 /* Failure -- Keep trying */
1513 else if ((i > 5) && (randint1(i) > 5))
1516 if (flush_failure) flush();
1518 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1520 /* We may keep trying */
1524 /* Failure -- Set off the trap */
1527 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1528 /* Move the player onto the trap */
1529 move_player(dir, easy_disarm, FALSE);
1536 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1537 * Disarms a trap, or chest
1540 void do_cmd_disarm(void)
1548 if (p_ptr->wild_mode) return;
1550 if (p_ptr->special_defense & KATA_MUSOU)
1552 set_action(ACTION_NONE);
1555 /* Option: Pick a direction */
1558 int num_traps, num_chests;
1560 /* Count visible traps */
1561 num_traps = count_dt(&y, &x, is_trap, TRUE);
1563 /* Count chests (trapped) */
1564 num_chests = count_chests(&y, &x, TRUE);
1566 /* See if only one target */
1567 if (num_traps || num_chests)
1569 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1570 if (!too_many) command_dir = coords_to_dir(y, x);
1575 /* Allow repeated command */
1578 /* Set repeat count */
1579 command_rep = command_arg - 1;
1580 p_ptr->redraw |= (PR_STATE);
1582 /* Cancel the arg */
1586 /* Get a direction (or abort) */
1587 if (get_rep_dir(&dir,TRUE))
1592 y = p_ptr->y + ddy[dir];
1593 x = p_ptr->x + ddx[dir];
1594 c_ptr = &cave[y][x];
1596 /* Feature code (applying "mimic" field) */
1597 feat = get_feat_mimic(c_ptr);
1599 /* Check for chests */
1600 o_idx = chest_check(y, x, TRUE);
1603 if (!is_trap(feat) && !o_idx)
1605 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1608 /* Monster in the way */
1609 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1611 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1620 more = do_cmd_disarm_chest(y, x, o_idx);
1626 more = do_cmd_disarm_aux(y, x, dir);
1630 /* Cancel repeat unless told not to */
1631 if (!more) disturb(FALSE, FALSE);
1636 * @brief 「打ち破る」動作コマンドのサブルーチン /
1637 * Perform the basic "bash" command
1638 * @param y 対象を行うマスのY座標
1639 * @param x 対象を行うマスのX座標
1640 * @param dir プレイヤーから見たターゲットの方角ID
1641 * @return 実際に処理が行われた場合TRUEを返す。
1644 * Assume destination is a closed/locked/jammed door
1645 * Assume there is no monster blocking the destination
1646 * Returns TRUE if repeated commands may continue
1649 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1652 cave_type *c_ptr = &cave[y][x];
1655 feature_type *f_ptr = &f_info[c_ptr->feat];
1657 /* Hack -- Bash power based on strength */
1658 /* (Ranges from 3 to 20 to 100 to 200) */
1659 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1661 /* Extract door power */
1662 int temp = f_ptr->power;
1666 concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1668 take_turn(p_ptr, 100);;
1670 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1672 /* Compare bash power to door power */
1673 temp = (bash - (temp * 10));
1675 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1677 /* Hack -- always have a chance */
1678 if (temp < 1) temp = 1;
1680 /* Hack -- attempt to bash down the door */
1681 if (randint0(100) < temp)
1683 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1685 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1687 /* Break down the door */
1688 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1690 cave_alter_feat(y, x, FF_BASH);
1696 cave_alter_feat(y, x, FF_OPEN);
1699 /* Hack -- Fall through the door */
1700 move_player(dir, FALSE, FALSE);
1703 /* Saving throw against stun */
1704 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1707 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1709 /* Allow repeated bashing */
1713 /* High dexterity yields coolness */
1716 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1718 /* Hack -- Lose balance ala paralysis */
1719 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1726 * @brief 「打ち破る」動作コマンドのメインルーチン /
1727 * Bash open a door, success based on character strength
1731 * For a closed door, pval is positive if locked; negative if stuck.
1733 * For an open door, pval is positive for a broken door.
1735 * A closed door can be opened - harder if locked. Any door might be
1736 * bashed open (and thereby broken). Bashing a door is (potentially)
1737 * faster! You move into the door way. To open a stuck door, it must
1738 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1740 * Creatures can also open or bash doors, see elsewhere.
1743 void do_cmd_bash(void)
1749 if (p_ptr->wild_mode) return;
1751 if (p_ptr->special_defense & KATA_MUSOU)
1753 set_action(ACTION_NONE);
1756 /* Allow repeated command */
1759 /* Set repeat count */
1760 command_rep = command_arg - 1;
1761 p_ptr->redraw |= (PR_STATE);
1763 /* Cancel the arg */
1767 /* Get a "repeated" direction */
1768 if (get_rep_dir(&dir,FALSE))
1773 y = p_ptr->y + ddy[dir];
1774 x = p_ptr->x + ddx[dir];
1777 c_ptr = &cave[y][x];
1779 /* Feature code (applying "mimic" field) */
1780 feat = get_feat_mimic(c_ptr);
1782 /* Nothing useful */
1783 if (!have_flag(f_info[feat].flags, FF_BASH))
1785 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1788 /* Monster in the way */
1789 else if (c_ptr->m_idx)
1791 take_turn(p_ptr, 100);;
1793 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1799 /* Bash a closed door */
1803 more = do_cmd_bash_aux(y, x, dir);
1807 /* Unless valid action taken, cancel bash */
1808 if (!more) disturb(FALSE, FALSE);
1813 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1817 * Manipulate an adjacent grid in some way
1819 * Attack monsters, tunnel through walls, disarm traps, open doors.
1821 * Consider confusion
1823 * This command must always take a turn, to prevent free detection
1824 * of invisible monsters.
1827 void do_cmd_alter(void)
1834 if (p_ptr->special_defense & KATA_MUSOU)
1836 set_action(ACTION_NONE);
1839 /* Allow repeated command */
1842 /* Set repeat count */
1843 command_rep = command_arg - 1;
1844 p_ptr->redraw |= (PR_STATE);
1846 /* Cancel the arg */
1850 /* Get a direction */
1851 if (get_rep_dir(&dir,TRUE))
1854 feature_type *f_ptr;
1856 y = p_ptr->y + ddy[dir];
1857 x = p_ptr->x + ddx[dir];
1860 c_ptr = &cave[y][x];
1862 /* Feature code (applying "mimic" field) */
1863 feat = get_feat_mimic(c_ptr);
1864 f_ptr = &f_info[feat];
1866 take_turn(p_ptr, 100);;
1874 else if (have_flag(f_ptr->flags, FF_OPEN))
1876 more = do_cmd_open_aux(y, x);
1879 /* Bash jammed doors */
1880 else if (have_flag(f_ptr->flags, FF_BASH))
1882 more = do_cmd_bash_aux(y, x, dir);
1885 /* Tunnel through walls */
1886 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1888 more = do_cmd_tunnel_aux(y, x);
1891 /* Close open doors */
1892 else if (have_flag(f_ptr->flags, FF_CLOSE))
1894 more = do_cmd_close_aux(y, x);
1898 else if (have_flag(f_ptr->flags, FF_DISARM))
1900 more = do_cmd_disarm_aux(y, x, dir);
1905 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1909 /* Cancel repetition unless we can continue */
1910 if (!more) disturb(FALSE, FALSE);
1916 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1917 * Find the index of some "spikes", if possible.
1918 * @param ip くさびとして打てるオブジェクトのID
1919 * @return オブジェクトがある場合TRUEを返す
1922 * Let user choose a pile of spikes, perhaps?
1925 static bool get_spike(INVENTORY_IDX *ip)
1929 /* Check every item in the pack */
1930 for (i = 0; i < INVEN_PACK; i++)
1932 object_type *o_ptr = &inventory[i];
1934 /* Skip non-objects */
1935 if (!o_ptr->k_idx) continue;
1937 /* Check the "tval" code */
1938 if (o_ptr->tval == TV_SPIKE)
1940 /* Save the spike index */
1953 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1954 * Jam a closed door with a spike
1958 * This command may NOT be repeated
1961 void do_cmd_spike(void)
1965 if (p_ptr->wild_mode) return;
1967 if (p_ptr->special_defense & KATA_MUSOU)
1969 set_action(ACTION_NONE);
1972 /* Get a "repeated" direction */
1973 if (get_rep_dir(&dir, FALSE))
1980 y = p_ptr->y + ddy[dir];
1981 x = p_ptr->x + ddx[dir];
1982 c_ptr = &cave[y][x];
1984 /* Feature code (applying "mimic" field) */
1985 feat = get_feat_mimic(c_ptr);
1987 /* Require closed door */
1988 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1990 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1994 else if (!get_spike(&item))
1996 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1999 /* Is a monster in the way? */
2000 else if (c_ptr->m_idx)
2002 take_turn(p_ptr, 100);;
2004 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2013 take_turn(p_ptr, 100);;
2015 /* Successful jamming */
2016 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2017 cave_alter_feat(y, x, FF_SPIKE);
2019 /* Use up, and describe, a single spike, from the bottom */
2020 inven_item_increase(item, -1);
2021 inven_item_describe(item);
2022 inven_item_optimize(item);
2030 * @brief 「歩く」動作コマンドのメインルーチン /
2031 * Support code for the "Walk" and "Jump" commands
2032 * @param pickup アイテムの自動拾いを行うならTRUE
2035 void do_cmd_walk(bool pickup)
2042 /* Allow repeated command */
2045 /* Set repeat count */
2046 command_rep = command_arg - 1;
2047 p_ptr->redraw |= (PR_STATE);
2049 /* Cancel the arg */
2053 /* Get a "repeated" direction */
2054 if (get_rep_dir(&dir, FALSE))
2056 take_turn(p_ptr, 100);;
2058 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2060 set_action(ACTION_NONE);
2063 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2064 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2065 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2067 /* Actually move the character */
2068 move_player(dir, pickup, FALSE);
2070 /* Allow more walking */
2074 /* Hack again -- Is there a special encounter ??? */
2075 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2077 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2080 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2082 /* Inform the player of his horrible fate :=) */
2083 msg_print(_("襲撃だ!", "You are ambushed !"));
2085 /* Go into large wilderness view */
2086 p_ptr->oldpy = randint1(MAX_HGT-2);
2087 p_ptr->oldpx = randint1(MAX_WID-2);
2090 /* Give first move to monsters */
2091 take_turn(p_ptr, 100);;
2093 /* HACk -- set the encouter flag for the wilderness generation */
2094 generate_encounter = TRUE;
2098 /* Cancel repeat unless we may continue */
2099 if (!more) disturb(FALSE, FALSE);
2104 * @brief 「走る」動作コマンドのメインルーチン /
2108 void do_cmd_run(void)
2111 if (cmd_limit_confused(p_ptr)) return;
2113 if (p_ptr->special_defense & KATA_MUSOU)
2115 set_action(ACTION_NONE);
2118 /* Get a "repeated" direction */
2119 if (get_rep_dir(&dir,FALSE))
2121 /* Hack -- Set the run counter */
2122 running = (command_arg ? command_arg : 1000);
2131 * @brief 「留まる」動作コマンドのメインルーチン /
2132 * Stay still. Search. Enter stores.
2133 * Pick up treasure if "pickup" is true.
2134 * @param pickup アイテムの自動拾いを行うならTRUE
2137 void do_cmd_stay(bool pickup)
2139 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2141 /* Allow repeated command */
2144 /* Set repeat count */
2145 command_rep = command_arg - 1;
2146 p_ptr->redraw |= (PR_STATE);
2148 /* Cancel the arg */
2152 take_turn(p_ptr, 100);;
2154 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2155 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2160 * @brief 「休む」動作コマンドのメインルーチン /
2161 * Resting allows a player to safely restore his hp -RAK-
2164 void do_cmd_rest(void)
2167 set_action(ACTION_NONE);
2169 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2175 if (hex_spelling_any()) stop_hex_spell_all();
2177 /* Prompt for time if needed */
2178 if (command_arg <= 0)
2180 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2181 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2187 strcpy(out_val, "&");
2189 /* Ask for duration */
2190 if (!get_string(p, out_val, 4)) return;
2192 /* Rest until done */
2193 if (out_val[0] == '&')
2195 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2199 else if (out_val[0] == '*')
2201 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2207 command_arg = (COMMAND_ARG)atoi(out_val);
2208 if (command_arg <= 0) return;
2214 if (command_arg > 9999) command_arg = 9999;
2216 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2218 /* Take a turn (?) */
2219 take_turn(p_ptr, 100);;
2221 /* The sin of sloth */
2222 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2224 /* Why are you sleeping when there's no need? WAKE UP!*/
2225 if ((p_ptr->chp == p_ptr->mhp) &&
2226 (p_ptr->csp == p_ptr->msp) &&
2227 !p_ptr->blind && !p_ptr->confused &&
2228 !p_ptr->poisoned && !p_ptr->afraid &&
2229 !p_ptr->stun && !p_ptr->cut &&
2230 !p_ptr->slow && !p_ptr->paralyzed &&
2231 !p_ptr->image && !p_ptr->word_recall &&
2232 !p_ptr->alter_reality)
2233 chg_virtue(V_DILIGENCE, -1);
2235 /* Save the rest code */
2236 resting = command_arg;
2237 p_ptr->action = ACTION_REST;
2238 p_ptr->update |= (PU_BONUS);
2239 update_creature(p_ptr);
2241 p_ptr->redraw |= (PR_STATE);
2250 * @brief 射撃処理のメインルーチン
2253 void do_cmd_fire(void)
2256 object_type *j_ptr, *ammo_ptr;
2259 if(p_ptr->wild_mode) return;
2261 is_fired = FALSE; /* not fired yet */
2263 /* Get the "bow" (if any) */
2264 j_ptr = &inventory[INVEN_BOW];
2266 /* Require a launcher */
2269 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2274 if (j_ptr->sval == SV_CRIMSON)
2276 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2281 if (j_ptr->sval == SV_HARP)
2283 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2289 if (p_ptr->special_defense & KATA_MUSOU)
2291 set_action(ACTION_NONE);
2294 /* Require proper missile */
2295 item_tester_tval = p_ptr->tval_ammo;
2297 q = _("どれを撃ちますか? ", "Fire which item? ");
2298 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2301 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2309 exe_fire(item, j_ptr);
2311 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2313 /* Sniper actions after some shootings */
2314 if (snipe_type == SP_AWAY)
2316 teleport_player(10 + (p_ptr->concent * 2), 0L);
2318 if (snipe_type == SP_FINAL)
2320 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2321 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2322 (void)set_stun(p_ptr->stun + randint1(25));
2328 * @brief 投射処理メインルーチン /
2329 * Throw an object from the pack or floor.
2331 * @param boomerang ブーメラン処理ならばTRUE
2332 * @param shuriken 忍者の手裏剣処理ならばTRUE
2333 * @return ターンを消費した場合TRUEを返す
2336 * Note: "unseen" monsters are very hard to hit.
2338 * Should throwing a weapon do full damage? Should it allow the magic
2339 * to hit bonus of the weapon to have an effect? Should it ever cause
2340 * the item to be destroyed? Should it do any damage at all?
2343 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2348 POSITION y, x, ty, tx, prev_y, prev_x;
2349 POSITION ny[19], nx[19];
2350 int chance, tdam, tdis;
2351 int mul, div, dd, ds;
2352 int cur_dis, visible;
2359 bool hit_body = FALSE;
2360 bool hit_wall = FALSE;
2361 bool equiped_item = FALSE;
2362 bool return_when_thrown = FALSE;
2364 GAME_TEXT o_name[MAX_NLEN];
2366 int msec = delay_factor * delay_factor * delay_factor;
2368 BIT_FLAGS flgs[TR_FLAG_SIZE];
2370 bool come_back = FALSE;
2371 bool do_drop = TRUE;
2373 if (p_ptr->wild_mode) return FALSE;
2375 if (p_ptr->special_defense & KATA_MUSOU)
2377 set_action(ACTION_NONE);
2383 o_ptr = &inventory[item];
2387 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2389 item_tester_hook = item_tester_hook_boomerang;
2390 q = _("どの武器を投げますか? ", "Throw which item? ");
2391 s = _("投げる武器がない。", "You have nothing to throw.");
2392 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2399 else if (has_melee_weapon(INVEN_LARM))
2402 o_ptr = &inventory[item];
2407 o_ptr = &inventory[item];
2412 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2413 s = _("投げるアイテムがない。", "You have nothing to throw.");
2414 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2422 /* Item is cursed */
2423 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2425 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2430 if (p_ptr->inside_arena && !boomerang)
2432 if (o_ptr->tval != TV_SPIKE)
2434 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2443 /* Obtain a local object */
2444 object_copy(q_ptr, o_ptr);
2446 /* Extract the thrown object's flags. */
2447 object_flags(q_ptr, flgs);
2448 torch_flags(q_ptr, flgs);
2450 /* Distribute the charges of rods/wands between the stacks */
2451 distribute_charges(o_ptr, q_ptr, 1);
2456 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2458 if (p_ptr->mighty_throw) mult += 3;
2460 /* Extract a "distance multiplier" */
2461 /* Changed for 'launcher' mutation */
2462 mul = 10 + 2 * (mult - 1);
2464 /* Enforce a minimum "weight" of one pound */
2465 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2466 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2468 /* Hack -- Distance -- Reward strength, penalize weight */
2469 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2471 /* Max distance of 10-18 */
2472 if (tdis > mul) tdis = mul;
2476 ty = randint0(101) - 50 + p_ptr->y;
2477 tx = randint0(101) - 50 + p_ptr->x;
2481 project_length = tdis + 1;
2483 /* Get a direction (or cancel) */
2484 if (!get_aim_dir(&dir)) return FALSE;
2486 /* Predict the "target" location */
2487 tx = p_ptr->x + 99 * ddx[dir];
2488 ty = p_ptr->y + 99 * ddy[dir];
2490 /* Check for "target request" */
2491 if ((dir == 5) && target_okay())
2497 project_length = 0; /* reset to default */
2500 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2501 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2502 return_when_thrown = TRUE;
2504 /* Reduce and describe inventory */
2507 inven_item_increase(item, -1);
2508 if (!return_when_thrown)
2509 inven_item_describe(item);
2510 inven_item_optimize(item);
2513 /* Reduce and describe floor item */
2516 floor_item_increase(0 - item, -1);
2517 floor_item_optimize(0 - item);
2519 if (item >= INVEN_RARM)
2521 equiped_item = TRUE;
2522 p_ptr->redraw |= (PR_EQUIPPY);
2525 take_turn(p_ptr, 100);;
2527 /* Rogue and Ninja gets bonus */
2528 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2529 p_ptr->energy_use -= p_ptr->lev;
2531 /* Start at the player */
2537 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2538 else shuriken = FALSE;
2540 /* Chance of hitting */
2541 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2542 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2543 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2545 if (shuriken) chance *= 2;
2550 /* Travel until stopped */
2551 for (cur_dis = 0; cur_dis <= tdis; )
2553 /* Hack -- Stop at the target */
2554 if ((y == ty) && (x == tx)) break;
2556 /* Calculate the new location (see "project()") */
2559 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2561 /* Stopped by walls/doors */
2562 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2565 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2568 /* The player can see the (on screen) missile */
2569 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2571 SYMBOL_CODE c = object_char(q_ptr);
2572 TERM_COLOR a = object_attr(q_ptr);
2574 /* Draw, Hilite, Fresh, Pause, Erase */
2575 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2576 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2578 Term_xtra(TERM_XTRA_DELAY, msec);
2579 lite_spot(ny[cur_dis], nx[cur_dis]);
2583 /* The player cannot see the missile */
2586 /* Pause anyway, for consistancy */
2587 Term_xtra(TERM_XTRA_DELAY, msec);
2593 /* Save the new location */
2597 /* Advance the distance */
2600 /* Monster here, Try to hit it */
2601 if (cave[y][x].m_idx)
2603 cave_type *c_ptr = &cave[y][x];
2604 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2606 /* Check the visibility */
2607 visible = m_ptr->ml;
2609 /* Note the collision */
2612 /* Did we hit it (penalize range) */
2613 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2617 /* Handle unseen monster */
2620 /* Invisible monster */
2621 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2624 /* Handle visible monster */
2627 GAME_TEXT m_name[MAX_NLEN];
2628 monster_desc(m_name, m_ptr, 0);
2629 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2633 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2634 health_track(c_ptr->m_idx);
2638 /* Hack -- Base damage from thrown object */
2641 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2642 tdam = damroll(dd, ds);
2643 /* Apply special damage */
2644 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2645 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2646 if (q_ptr->to_d > 0)
2647 tdam += q_ptr->to_d;
2649 tdam += -q_ptr->to_d;
2653 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2654 tdam += p_ptr->to_d_m;
2656 else if (have_flag(flgs, TR_THROW))
2659 tdam += p_ptr->to_d_m;
2667 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2670 /* No negative damage */
2671 if (tdam < 0) tdam = 0;
2673 /* Modify the damage */
2674 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2676 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2677 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2679 /* Hit the monster, check for death */
2680 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2688 message_pain(c_ptr->m_idx, tdam);
2690 /* Anger the monster */
2691 if ((tdam > 0) && !object_is_potion(q_ptr))
2692 anger_monster(m_ptr);
2694 if (fear && m_ptr->ml)
2697 GAME_TEXT m_name[MAX_NLEN];
2698 monster_desc(m_name, m_ptr, 0);
2699 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2709 /* decrease toach's fuel */
2710 if (hit_body) torch_lost_fuel(q_ptr);
2712 /* Chance of breakage (during attacks) */
2713 j = (hit_body ? breakage_chance(q_ptr) : 0);
2715 /* Figurines transform */
2716 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2720 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2721 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2722 else if (object_is_cursed(q_ptr))
2723 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2728 /* Potions smash open */
2729 if (object_is_potion(q_ptr))
2731 if (hit_body || hit_wall || (randint1(100) < j))
2733 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2735 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2737 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
2739 /* ToDo (Robert): fix the invulnerability */
2740 if (cave[y][x].m_idx &&
2741 is_friendly(&m_list[cave[y][x].m_idx]) &&
2742 !MON_INVULNER(m_ptr))
2744 GAME_TEXT m_name[MAX_NLEN];
2745 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
2746 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2747 set_hostile(&m_list[cave[y][x].m_idx]);
2758 if (return_when_thrown)
2760 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2761 char o2_name[MAX_NLEN];
2762 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2765 if (boomerang) back_chance += 4+randint1(5);
2766 if (super_boomerang) back_chance += 100;
2767 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2769 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2771 for (i = cur_dis - 1; i > 0; i--)
2773 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2775 char c = object_char(q_ptr);
2776 byte a = object_attr(q_ptr);
2778 /* Draw, Hilite, Fresh, Pause, Erase */
2779 print_rel(c, a, ny[i], nx[i]);
2780 move_cursor_relative(ny[i], nx[i]);
2782 Term_xtra(TERM_XTRA_DELAY, msec);
2783 lite_spot(ny[i], nx[i]);
2788 /* Pause anyway, for consistancy */
2789 Term_xtra(TERM_XTRA_DELAY, msec);
2792 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2794 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2801 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2805 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2813 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2819 if (item == INVEN_RARM || item == INVEN_LARM)
2821 /* Access the wield slot */
2822 o_ptr = &inventory[item];
2824 /* Wear the new stuff */
2825 object_copy(o_ptr, q_ptr);
2827 p_ptr->total_weight += q_ptr->weight;
2829 /* Increment the equip counter by hand */
2832 /* Recalculate torch */
2833 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2834 p_ptr->window |= (PW_EQUIP);
2842 else if (equiped_item)
2850 if (cave_have_flag_bold(y, x, FF_PROJECT))
2852 (void)drop_near(q_ptr, j, y, x);
2856 (void)drop_near(q_ptr, j, prev_y, prev_x);
2866 * Hack: travel command
2868 #define TRAVEL_UNABLE 9999
2870 static int flow_head = 0;
2871 static int flow_tail = 0;
2872 static POSITION temp2_x[MAX_SHORT];
2873 static POSITION temp2_y[MAX_SHORT];
2876 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
2879 void forget_travel_flow(void)
2882 /* Check the entire dungeon / Forget the old data */
2883 for (y = 0; y < cur_hgt; y++)
2885 for (x = 0; x < cur_wid; x++)
2888 travel.cost[y][x] = MAX_SHORT;
2891 travel.y = travel.x = 0;
2895 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
2900 static int travel_flow_cost(POSITION y, POSITION x)
2902 feature_type *f_ptr = &f_info[cave[y][x].feat];
2905 /* Avoid obstacles (ex. trees) */
2906 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
2909 if (have_flag(f_ptr->flags, FF_WATER))
2911 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
2915 if (have_flag(f_ptr->flags, FF_LAVA))
2918 if (!p_ptr->resist_fire) lava *= 2;
2919 if (!p_ptr->levitation) lava *= 2;
2920 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
2925 /* Detected traps and doors */
2926 if (cave[y][x].info & (CAVE_MARK))
2928 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
2929 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
2936 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
2940 * @param wall プレイヤーが壁の中にいるならばTRUE
2943 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
2945 cave_type *c_ptr = &cave[y][x];
2946 feature_type *f_ptr = &f_info[c_ptr->feat];
2947 int old_head = flow_head;
2949 int base_cost = (n % TRAVEL_UNABLE);
2950 int from_wall = (n / TRAVEL_UNABLE);
2953 /* Ignore out of bounds */
2954 if (!in_bounds(y, x)) return;
2956 /* Ignore unknown grid except in wilderness */
2957 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
2959 /* Ignore "walls" and "rubble" (include "secret doors") */
2960 if (have_flag(f_ptr->flags, FF_WALL) ||
2961 have_flag(f_ptr->flags, FF_CAN_DIG) ||
2962 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
2963 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
2965 if (!wall || !from_wall) return;
2966 add_cost += TRAVEL_UNABLE;
2970 add_cost = travel_flow_cost(y, x);
2973 cost = base_cost + add_cost;
2975 /* Ignore lower cost entries */
2976 if (travel.cost[y][x] <= cost) return;
2978 /* Save the flow cost */
2979 travel.cost[y][x] = cost;
2981 /* Enqueue that entry */
2982 temp2_y[flow_head] = y;
2983 temp2_x[flow_head] = x;
2985 /* Advance the queue */
2986 if (++flow_head == MAX_SHORT) flow_head = 0;
2988 /* Hack -- notice overflow by forgetting new entry */
2989 if (flow_head == flow_tail) flow_head = old_head;
2995 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
2996 * @param ty 目標地点のY座標
2997 * @param tx 目標地点のX座標
3000 static void travel_flow(POSITION ty, POSITION tx)
3004 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
3006 /* Reset the "queue" */
3007 flow_head = flow_tail = 0;
3009 /* is player in the wall? */
3010 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
3012 /* Start at the target grid */
3013 travel_flow_aux(ty, tx, 0, wall);
3015 /* Now process the queue */
3016 while (flow_head != flow_tail)
3018 /* Extract the next entry */
3019 y = temp2_y[flow_tail];
3020 x = temp2_x[flow_tail];
3022 /* Forget that entry */
3023 if (++flow_tail == MAX_SHORT) flow_tail = 0;
3025 /* Ignore too far entries */
3026 //if (distance(ty, tx, y, x) > 100) continue;
3028 /* Add the "children" */
3029 for (d = 0; d < 8; d++)
3031 /* Add that child if "legal" */
3032 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
3036 /* Forget the flow info */
3037 flow_head = flow_tail = 0;
3041 * @brief トラベル処理のメインルーチン
3044 void do_cmd_travel(void)
3048 POSITION dx, dy, sx, sy;
3049 feature_type *f_ptr;
3051 if (travel.x != 0 && travel.y != 0 &&
3052 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3057 else if (!tgt_pt(&x, &y)) return;
3059 if ((x == p_ptr->x) && (y == p_ptr->y))
3061 msg_print(_("すでにそこにいます!", "You are already there!!"));
3065 f_ptr = &f_info[cave[y][x].feat];
3067 if ((cave[y][x].info & CAVE_MARK) &&
3068 (have_flag(f_ptr->flags, FF_WALL) ||
3069 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3070 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3072 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3076 forget_travel_flow();
3082 /* Travel till 255 steps */
3088 /* Decides first direction */
3089 dx = abs(p_ptr->x - x);
3090 dy = abs(p_ptr->y - y);
3091 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3092 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3094 for (i = 1; i <= 9; i++)
3096 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;