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;
56 bool cmd_limit_arena(player_type *creature_ptr)
58 if (p_ptr->inside_arena)
60 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
68 * @brief 階段を使って階層を昇る処理 / Go up one level
71 void do_cmd_go_up(void)
76 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
77 feature_type *f_ptr = &f_info[c_ptr->feat];
81 if (p_ptr->special_defense & KATA_MUSOU)
83 set_action(ACTION_NONE);
87 if (!have_flag(f_ptr->flags, FF_LESS))
89 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
94 if (have_flag(f_ptr->flags, FF_QUEST))
96 /* Cancel the command */
97 if (!confirm_leave_level(FALSE)) return;
101 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
102 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
104 msg_print(_("上の階に登った。", "You enter the up staircase."));
108 p_ptr->inside_quest = c_ptr->special;
110 /* Activate the quest */
111 if (!quest[p_ptr->inside_quest].status)
113 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
115 init_flags = INIT_ASSIGN;
116 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
118 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
121 /* Leaving a quest */
122 if (!p_ptr->inside_quest)
128 p_ptr->leaving = TRUE;
133 /* Hack -- take a turn */
134 p_ptr->energy_use = 100;
136 /* End the command */
146 go_up = confirm_leave_level(FALSE);
149 /* Cancel the command */
152 /* Hack -- take a turn */
153 p_ptr->energy_use = 100;
155 if (autosave_l) do_cmd_save_game(TRUE);
157 /* For a random quest */
158 if (p_ptr->inside_quest &&
159 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
163 p_ptr->inside_quest = 0;
166 /* For a fixed quest */
167 if (p_ptr->inside_quest &&
168 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
172 p_ptr->inside_quest = c_ptr->special;
177 /* For normal dungeon and random quest */
181 if (have_flag(f_ptr->flags, FF_SHAFT))
183 /* Create a way back */
184 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
190 /* Create a way back */
191 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
196 /* Get out from current dungeon */
197 if (dun_level - up_num < d_info[dungeon_type].mindepth)
200 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
203 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
204 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
205 else if (up_num == dun_level)
206 msg_print(_("地上に戻った。", "You go back to the surface."));
208 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
211 p_ptr->leaving = TRUE;
216 * @brief 階段を使って階層を降りる処理 / Go down one level
219 void do_cmd_go_down(void)
222 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
223 feature_type *f_ptr = &f_info[c_ptr->feat];
225 bool fall_trap = FALSE;
228 if (p_ptr->special_defense & KATA_MUSOU)
230 set_action(ACTION_NONE);
234 if (!have_flag(f_ptr->flags, FF_MORE))
236 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
240 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
243 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
248 /* Quest down stairs */
249 else if (have_flag(f_ptr->flags, FF_QUEST))
251 /* Confirm Leaving */
252 if(!confirm_leave_level(TRUE)) return;
254 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
255 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
257 msg_print(_("下の階に降りた。", "You enter the down staircase."));
262 p_ptr->inside_quest = c_ptr->special;
264 /* Activate the quest */
265 if (!quest[p_ptr->inside_quest].status)
267 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
269 init_flags = INIT_ASSIGN;
270 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
272 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
275 /* Leaving a quest */
276 if (!p_ptr->inside_quest)
282 p_ptr->leaving = TRUE;
288 /* Hack -- take a turn */
289 p_ptr->energy_use = 100;
294 DUNGEON_IDX target_dungeon = 0;
298 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
300 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
302 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
305 if (!max_dlv[target_dungeon])
307 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
308 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
309 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
312 /* Save old player position */
313 p_ptr->oldpx = p_ptr->x;
314 p_ptr->oldpy = p_ptr->y;
315 dungeon_type = target_dungeon;
318 * Clear all saved floors
319 * and create a first saved floor
321 prepare_change_floor_mode(CFM_FIRST_FLOOR);
324 /* Hack -- take a turn */
325 p_ptr->energy_use = 100;
327 if (autosave_l) do_cmd_save_game(TRUE);
330 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
335 /* Enter the dungeon just now */
336 p_ptr->enter_dungeon = TRUE;
337 down_num = d_info[dungeon_type].mindepth;
342 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
343 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
348 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
355 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
359 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
360 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
362 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
368 p_ptr->leaving = TRUE;
372 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
376 if (have_flag(f_ptr->flags, FF_SHAFT))
378 /* Create a way back */
379 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
383 /* Create a way back */
384 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
392 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
395 void do_cmd_search(void)
397 /* Allow repeated command */
400 /* Set repeat count */
401 command_rep = command_arg - 1;
402 p_ptr->redraw |= (PR_STATE);
407 p_ptr->energy_use = 100;
415 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
416 * @param y 走査対象にしたいマスのY座標
417 * @param x 走査対象にしたいマスのX座標
418 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
419 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
421 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
423 cave_type *c_ptr = &cave[y][x];
424 OBJECT_IDX this_o_idx, next_o_idx = 0;
426 /* Scan all objects in the grid */
427 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
431 o_ptr = &o_list[this_o_idx];
432 next_o_idx = o_ptr->next_o_idx;
434 /* Skip unknown chests XXX XXX */
435 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
437 /* Check for non empty chest */
438 if ((o_ptr->tval == TV_CHEST) &&
439 (((!trapped) && (o_ptr->pval)) || /* non empty */
440 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
449 * @brief 箱を開けるコマンドのメインルーチン /
450 * Attempt to open the given chest at the given location
451 * @param y 箱の存在するマスのY座標
452 * @param x 箱の存在するマスのX座標
453 * @param o_idx 箱のオブジェクトID
454 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
456 * Assume there is no monster blocking the destination
458 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
463 object_type *o_ptr = &o_list[o_idx];
465 p_ptr->energy_use = 100;
467 /* Attempt to unlock it */
470 /* Assume locked, and thus not open */
473 /* Get the "disarm" factor */
474 i = p_ptr->skill_dis;
476 /* Penalize some conditions */
477 if (p_ptr->blind || no_lite()) i = i / 10;
478 if (p_ptr->confused || p_ptr->image) i = i / 10;
480 /* Extract the difficulty */
483 /* Always have a small chance of success */
486 /* Success -- May still have traps */
487 if (randint0(100) < j)
489 msg_print(_("鍵をはずした。", "You have picked the lock."));
494 /* Failure -- Keep trying */
497 /* We may continue repeating */
499 if (flush_failure) flush();
500 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
505 /* Allowed to open */
508 /* Apply chest traps, if any */
509 chest_trap(y, x, o_idx);
511 /* Let the Chest drop items */
512 chest_death(FALSE, y, x, o_idx);
518 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
519 * Attempt to open the given chest at the given location
520 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
521 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
522 * @param test 地形条件を判定するための関数ポインタ
523 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
525 * @details Return the number of features around (or under) the character.
526 * Usually look for doors and floor traps.
528 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
530 int d, count, xx, yy;
532 /* Count how many matches */
535 /* Check around (and under) the character */
536 for (d = 0; d < 9; d++)
541 /* if not searching under player continue */
542 if ((d == 8) && !under) continue;
544 /* Extract adjacent (legal) location */
545 yy = p_ptr->y + ddy_ddd[d];
546 xx = p_ptr->x + ddx_ddd[d];
549 c_ptr = &cave[yy][xx];
551 /* Must have knowledge */
552 if (!(c_ptr->info & (CAVE_MARK))) continue;
554 /* Feature code (applying "mimic" field) */
555 feat = get_feat_mimic(c_ptr);
557 /* Not looking for this feature */
558 if (!((*test)(feat))) continue;
563 /* Remember the location. Only useful if only one match */
574 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
575 * Return the number of chests around (or under) the character.
576 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
577 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
578 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
581 * If requested, count only trapped chests.
583 static int count_chests(POSITION *y, POSITION *x, bool trapped)
590 /* Count how many matches */
593 /* Check around (and under) the character */
594 for (d = 0; d < 9; d++)
596 /* Extract adjacent (legal) location */
597 POSITION yy = p_ptr->y + ddy_ddd[d];
598 POSITION xx = p_ptr->x + ddx_ddd[d];
600 /* No (visible) chest is there */
601 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
603 /* Grab the object */
604 o_ptr = &o_list[o_idx];
607 if (o_ptr->pval == 0) continue;
609 /* No (known) traps here */
610 if (trapped && (!object_is_known(o_ptr) ||
611 !chest_traps[o_ptr->pval])) continue;
616 /* Remember the location. Only useful if only one match */
627 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
628 * Convert an adjacent location to a direction.
629 * @param y 方角を確認したY座標
630 * @param x 方角を確認したX座標
633 static DIRECTION coords_to_dir(POSITION y, POSITION x)
635 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
642 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
644 return d[dx + 1][dy + 1];
648 * @brief 「開ける」動作コマンドのサブルーチン /
649 * Perform the basic "open" command on doors
650 * @param y 対象を行うマスのY座標
651 * @param x 対象を行うマスのX座標
652 * @return 実際に処理が行われた場合TRUEを返す。
654 * Assume destination is a closed/locked/jammed door
655 * Assume there is no monster blocking the destination
656 * Returns TRUE if repeated commands may continue
658 static bool do_cmd_open_aux(POSITION y, POSITION x)
662 /* Get requested grid */
663 cave_type *c_ptr = &cave[y][x];
664 feature_type *f_ptr = &f_info[c_ptr->feat];
667 p_ptr->energy_use = 100;
669 /* Seeing true feature code (ignore mimic) */
672 if (!have_flag(f_ptr->flags, FF_OPEN))
675 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
679 else if (f_ptr->power)
682 i = p_ptr->skill_dis;
684 /* Penalize some conditions */
685 if (p_ptr->blind || no_lite()) i = i / 10;
686 if (p_ptr->confused || p_ptr->image) i = i / 10;
688 /* Extract the lock power */
691 /* Extract the difficulty */
694 /* Always have a small chance of success */
698 if (randint0(100) < j)
700 msg_print(_("鍵をはずした。", "You have picked the lock."));
703 cave_alter_feat(y, x, FF_OPEN);
705 sound(SOUND_OPENDOOR);
715 if (flush_failure) flush();
717 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
719 /* We may keep trying */
728 cave_alter_feat(y, x, FF_OPEN);
730 sound(SOUND_OPENDOOR);
736 * @brief 「開ける」コマンドのメインルーチン /
737 * Open a closed/locked/jammed door or a closed/locked chest.
740 * Unlocking a locked door/chest is worth one experience point.
742 void do_cmd_open(void)
750 if (p_ptr->wild_mode) return;
752 if (p_ptr->special_defense & KATA_MUSOU)
754 set_action(ACTION_NONE);
757 /* Option: Pick a direction */
760 int num_doors, num_chests;
762 /* Count closed doors (locked or jammed) */
763 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
765 /* Count chests (locked) */
766 num_chests = count_chests(&y, &x, FALSE);
768 /* See if only one target */
769 if (num_doors || num_chests)
771 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
773 if (!too_many) command_dir = coords_to_dir(y, x);
777 /* Allow repeated command */
780 /* Set repeat count */
781 command_rep = command_arg - 1;
782 p_ptr->redraw |= (PR_STATE);
788 /* Get a "repeated" direction */
789 if (get_rep_dir(&dir, TRUE))
794 /* Get requested location */
795 y = p_ptr->y + ddy[dir];
796 x = p_ptr->x + ddx[dir];
798 /* Get requested grid */
801 /* Feature code (applying "mimic" field) */
802 feat = get_feat_mimic(c_ptr);
804 /* Check for chest */
805 o_idx = chest_check(y, x, FALSE);
808 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
810 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
813 /* Monster in the way */
814 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
816 p_ptr->energy_use = 100;
817 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
825 more = do_cmd_open_chest(y, x, o_idx);
832 more = do_cmd_open_aux(y, x);
836 /* Cancel repeat unless we may continue */
837 if (!more) disturb(FALSE, FALSE);
843 * @brief 「閉じる」動作コマンドのサブルーチン /
844 * Perform the basic "close" command
845 * @param y 対象を行うマスのY座標
846 * @param x 対象を行うマスのX座標
847 * @return 実際に処理が行われた場合TRUEを返す。
849 * Assume destination is an open/broken door
850 * Assume there is no monster blocking the destination
851 * Returns TRUE if repeated commands may continue
853 static bool do_cmd_close_aux(POSITION y, POSITION x)
855 cave_type *c_ptr = &cave[y][x];
856 FEAT_IDX old_feat = c_ptr->feat;
859 p_ptr->energy_use = 100;
861 /* Seeing true feature code (ignore mimic) */
864 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
866 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
868 /* Hack -- object in the way */
869 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
870 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
872 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
877 cave_alter_feat(y, x, FF_CLOSE);
880 if (old_feat == c_ptr->feat)
882 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
886 sound(SOUND_SHUTDOOR);
895 * @brief 「閉じる」コマンドのメインルーチン /
896 * Close an open door.
899 * Unlocking a locked door/chest is worth one experience point.
901 void do_cmd_close(void)
908 if (p_ptr->wild_mode) return;
910 if (p_ptr->special_defense & KATA_MUSOU)
912 set_action(ACTION_NONE);
915 /* Option: Pick a direction */
918 /* Count open doors */
919 if (count_dt(&y, &x, is_open, FALSE) == 1)
921 command_dir = coords_to_dir(y, x);
925 /* Allow repeated command */
928 /* Set repeat count */
929 command_rep = command_arg - 1;
930 p_ptr->redraw |= (PR_STATE);
936 /* Get a "repeated" direction */
937 if (get_rep_dir(&dir, FALSE))
942 y = p_ptr->y + ddy[dir];
943 x = p_ptr->x + ddx[dir];
946 /* Feature code (applying "mimic" field) */
947 feat = get_feat_mimic(c_ptr);
949 /* Require open/broken door */
950 if (!have_flag(f_info[feat].flags, FF_CLOSE))
952 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
955 /* Monster in the way */
956 else if (c_ptr->m_idx)
958 p_ptr->energy_use = 100;
960 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
970 more = do_cmd_close_aux(y, x);
974 /* Cancel repeat unless we may continue */
975 if (!more) disturb(FALSE, FALSE);
980 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
981 * Determine if a given grid may be "tunneled"
982 * @param y 対象を行うマスのY座標
983 * @param x 対象を行うマスのX座標
986 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
988 cave_type *c_ptr = &cave[y][x];
990 /* Must have knowledge */
991 if (!(c_ptr->info & CAVE_MARK))
993 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
998 /* Must be a wall/door/etc */
999 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1001 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1011 * @brief 「掘る」動作コマンドのサブルーチン /
1012 * Perform the basic "tunnel" command
1013 * @param y 対象を行うマスのY座標
1014 * @param x 対象を行うマスのX座標
1015 * @return 実際に処理が行われた場合TRUEを返す。
1017 * Assumes that no monster is blocking the destination
1018 * Do not use twall anymore
1019 * Returns TRUE if repeated commands may continue
1021 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1024 feature_type *f_ptr, *mimic_f_ptr;
1029 /* Verify legality */
1030 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1032 p_ptr->energy_use = 100;
1035 c_ptr = &cave[y][x];
1036 f_ptr = &f_info[c_ptr->feat];
1037 power = f_ptr->power;
1039 /* Feature code (applying "mimic" field) */
1040 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1042 name = f_name + mimic_f_ptr->name;
1046 if (have_flag(f_ptr->flags, FF_PERMANENT))
1049 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1051 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1054 /* Map border (mimiccing Permanent wall) */
1057 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1062 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1065 if (p_ptr->skill_dig > randint0(20 * power))
1067 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1069 /* Remove the feature */
1070 cave_alter_feat(y, x, FF_TUNNEL);
1072 /* Update some things */
1073 p_ptr->update |= (PU_FLOW);
1077 /* Message, keep digging */
1078 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1086 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1089 if (p_ptr->skill_dig > power + randint0(40 * power))
1091 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1094 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1095 p_ptr->update |= (PU_FLOW);
1098 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1100 /* Remove the feature */
1101 cave_alter_feat(y, x, FF_TUNNEL);
1103 chg_virtue(V_DILIGENCE, 1);
1104 chg_virtue(V_NATURE, -1);
1112 /* We may continue chopping */
1113 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1114 /* Occasional Search XXX XXX */
1115 if (randint0(100) < 25) search();
1119 /* We may continue tunelling */
1120 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1127 if (is_hidden_door(c_ptr))
1129 /* Occasional Search XXX XXX */
1130 if (randint0(100) < 25) search();
1137 * @brief 「掘る」動作コマンドのメインルーチン /
1138 * Tunnels through "walls" (including rubble and closed doors)
1142 * Note that you must tunnel in order to hit invisible monsters
1143 * in walls, though moving into walls still takes a turn anyway.
1145 * Digging is very difficult without a "digger" weapon, but can be
1146 * accomplished by strong players using heavy weapons.
1149 void do_cmd_tunnel(void)
1159 if (p_ptr->special_defense & KATA_MUSOU)
1161 set_action(ACTION_NONE);
1164 /* Allow repeated command */
1167 /* Set repeat count */
1168 command_rep = command_arg - 1;
1169 p_ptr->redraw |= (PR_STATE);
1171 /* Cancel the arg */
1175 /* Get a direction to tunnel, or Abort */
1176 if (get_rep_dir(&dir,FALSE))
1179 y = p_ptr->y + ddy[dir];
1180 x = p_ptr->x + ddx[dir];
1183 c_ptr = &cave[y][x];
1185 /* Feature code (applying "mimic" field) */
1186 feat = get_feat_mimic(c_ptr);
1188 /* No tunnelling through doors */
1189 if (have_flag(f_info[feat].flags, FF_DOOR))
1191 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1194 /* No tunnelling through most features */
1195 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1197 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1200 /* A monster is in the way */
1201 else if (c_ptr->m_idx)
1203 p_ptr->energy_use = 100;
1205 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1214 /* Tunnel through walls */
1215 more = do_cmd_tunnel_aux(y, x);
1219 /* Cancel repetition unless we can continue */
1220 if (!more) disturb(FALSE, FALSE);
1224 * @brief 移動処理による簡易な「開く」処理 /
1226 * @return 開く処理が実際に試みられた場合TRUEを返す
1229 * If there is a jammed/closed/locked door at the given location,
1230 * then attempt to unlock/open it. Return TRUE if an attempt was
1231 * made (successful or not), otherwise return FALSE.
1233 * The code here should be nearly identical to that in
1234 * do_cmd_open_test() and do_cmd_open_aux().
1237 bool easy_open_door(POSITION y, POSITION x)
1241 cave_type *c_ptr = &cave[y][x];
1242 feature_type *f_ptr = &f_info[c_ptr->feat];
1244 /* Must be a closed door */
1245 if (!is_closed_door(c_ptr->feat))
1251 if (!have_flag(f_ptr->flags, FF_OPEN))
1254 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1259 else if (f_ptr->power)
1262 i = p_ptr->skill_dis;
1264 /* Penalize some conditions */
1265 if (p_ptr->blind || no_lite()) i = i / 10;
1266 if (p_ptr->confused || p_ptr->image) i = i / 10;
1268 /* Extract the lock power */
1271 /* Extract the difficulty */
1274 /* Always have a small chance of success */
1278 if (randint0(100) < j)
1280 msg_print(_("鍵をはずした。", "You have picked the lock."));
1283 cave_alter_feat(y, x, FF_OPEN);
1285 sound(SOUND_OPENDOOR);
1295 if (flush_failure) flush();
1297 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1306 cave_alter_feat(y, x, FF_OPEN);
1308 sound(SOUND_OPENDOOR);
1314 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1315 * Perform the basic "disarm" command
1316 * @param y 解除を行うマスのY座標
1317 * @param x 解除を行うマスのX座標
1318 * @param o_idx 箱のオブジェクトID
1319 * @return ターンを消費する処理が行われた場合TRUEを返す
1322 * Assume destination is a visible trap
1323 * Assume there is no monster blocking the destination
1324 * Returns TRUE if repeated commands may continue
1327 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1331 object_type *o_ptr = &o_list[o_idx];
1333 p_ptr->energy_use = 100;
1335 /* Get the "disarm" factor */
1336 i = p_ptr->skill_dis;
1338 /* Penalize some conditions */
1339 if (p_ptr->blind || no_lite()) i = i / 10;
1340 if (p_ptr->confused || p_ptr->image) i = i / 10;
1342 /* Extract the difficulty */
1343 j = i - o_ptr->pval;
1345 /* Always have a small chance of success */
1348 /* Must find the trap first. */
1349 if (!object_is_known(o_ptr))
1351 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1355 /* Already disarmed/unlocked */
1356 else if (o_ptr->pval <= 0)
1358 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1361 /* No traps to find. */
1362 else if (!chest_traps[o_ptr->pval])
1364 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1367 /* Success (get a lot of experience) */
1368 else if (randint0(100) < j)
1370 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1371 gain_exp(o_ptr->pval);
1372 o_ptr->pval = (0 - o_ptr->pval);
1375 /* Failure -- Keep trying */
1376 else if ((i > 5) && (randint1(i) > 5))
1378 /* We may keep trying */
1380 if (flush_failure) flush();
1381 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1384 /* Failure -- Set off the trap */
1387 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1389 chest_trap(y, x, o_idx);
1396 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1397 * Perform the basic "disarm" command
1398 * @param y 解除を行うマスのY座標
1399 * @param x 解除を行うマスのX座標
1400 * @param dir プレイヤーからみた方向ID
1401 * @return ターンを消費する処理が行われた場合TRUEを返す
1404 * Assume destination is a visible trap
1405 * Assume there is no monster blocking the destination
1406 * Returns TRUE if repeated commands may continue
1410 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1412 cave_type *c_ptr = &cave[y][x];
1415 feature_type *f_ptr = &f_info[c_ptr->feat];
1417 /* Access trap name */
1418 concptr name = (f_name + f_ptr->name);
1420 /* Extract trap "power" */
1421 int power = f_ptr->power;
1424 /* Get the "disarm" factor */
1425 int i = p_ptr->skill_dis;
1428 p_ptr->energy_use = 100;
1430 /* Penalize some conditions */
1431 if (p_ptr->blind || no_lite()) i = i / 10;
1432 if (p_ptr->confused || p_ptr->image) i = i / 10;
1434 /* Extract the difficulty */
1437 /* Always have a small chance of success */
1441 if (randint0(100) < j)
1443 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1448 /* Remove the trap */
1449 cave_alter_feat(y, x, FF_DISARM);
1451 /* Move the player onto the trap */
1452 move_player(dir, easy_disarm, FALSE);
1455 /* Failure -- Keep trying */
1456 else if ((i > 5) && (randint1(i) > 5))
1459 if (flush_failure) flush();
1461 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1463 /* We may keep trying */
1467 /* Failure -- Set off the trap */
1470 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1471 /* Move the player onto the trap */
1472 move_player(dir, easy_disarm, FALSE);
1479 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1480 * Disarms a trap, or chest
1483 void do_cmd_disarm(void)
1491 if (p_ptr->wild_mode) return;
1493 if (p_ptr->special_defense & KATA_MUSOU)
1495 set_action(ACTION_NONE);
1498 /* Option: Pick a direction */
1501 int num_traps, num_chests;
1503 /* Count visible traps */
1504 num_traps = count_dt(&y, &x, is_trap, TRUE);
1506 /* Count chests (trapped) */
1507 num_chests = count_chests(&y, &x, TRUE);
1509 /* See if only one target */
1510 if (num_traps || num_chests)
1512 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1513 if (!too_many) command_dir = coords_to_dir(y, x);
1518 /* Allow repeated command */
1521 /* Set repeat count */
1522 command_rep = command_arg - 1;
1523 p_ptr->redraw |= (PR_STATE);
1525 /* Cancel the arg */
1529 /* Get a direction (or abort) */
1530 if (get_rep_dir(&dir,TRUE))
1535 y = p_ptr->y + ddy[dir];
1536 x = p_ptr->x + ddx[dir];
1537 c_ptr = &cave[y][x];
1539 /* Feature code (applying "mimic" field) */
1540 feat = get_feat_mimic(c_ptr);
1542 /* Check for chests */
1543 o_idx = chest_check(y, x, TRUE);
1546 if (!is_trap(feat) && !o_idx)
1548 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1551 /* Monster in the way */
1552 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1554 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1563 more = do_cmd_disarm_chest(y, x, o_idx);
1569 more = do_cmd_disarm_aux(y, x, dir);
1573 /* Cancel repeat unless told not to */
1574 if (!more) disturb(FALSE, FALSE);
1579 * @brief 「打ち破る」動作コマンドのサブルーチン /
1580 * Perform the basic "bash" command
1581 * @param y 対象を行うマスのY座標
1582 * @param x 対象を行うマスのX座標
1583 * @param dir プレイヤーから見たターゲットの方角ID
1584 * @return 実際に処理が行われた場合TRUEを返す。
1587 * Assume destination is a closed/locked/jammed door
1588 * Assume there is no monster blocking the destination
1589 * Returns TRUE if repeated commands may continue
1592 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1595 cave_type *c_ptr = &cave[y][x];
1598 feature_type *f_ptr = &f_info[c_ptr->feat];
1600 /* Hack -- Bash power based on strength */
1601 /* (Ranges from 3 to 20 to 100 to 200) */
1602 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1604 /* Extract door power */
1605 int temp = f_ptr->power;
1609 concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1611 p_ptr->energy_use = 100;
1613 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1615 /* Compare bash power to door power */
1616 temp = (bash - (temp * 10));
1618 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1620 /* Hack -- always have a chance */
1621 if (temp < 1) temp = 1;
1623 /* Hack -- attempt to bash down the door */
1624 if (randint0(100) < temp)
1626 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1628 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1630 /* Break down the door */
1631 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1633 cave_alter_feat(y, x, FF_BASH);
1639 cave_alter_feat(y, x, FF_OPEN);
1642 /* Hack -- Fall through the door */
1643 move_player(dir, FALSE, FALSE);
1646 /* Saving throw against stun */
1647 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1650 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1652 /* Allow repeated bashing */
1656 /* High dexterity yields coolness */
1659 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1661 /* Hack -- Lose balance ala paralysis */
1662 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1669 * @brief 「打ち破る」動作コマンドのメインルーチン /
1670 * Bash open a door, success based on character strength
1674 * For a closed door, pval is positive if locked; negative if stuck.
1676 * For an open door, pval is positive for a broken door.
1678 * A closed door can be opened - harder if locked. Any door might be
1679 * bashed open (and thereby broken). Bashing a door is (potentially)
1680 * faster! You move into the door way. To open a stuck door, it must
1681 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1683 * Creatures can also open or bash doors, see elsewhere.
1686 void do_cmd_bash(void)
1692 if (p_ptr->wild_mode) return;
1694 if (p_ptr->special_defense & KATA_MUSOU)
1696 set_action(ACTION_NONE);
1699 /* Allow repeated command */
1702 /* Set repeat count */
1703 command_rep = command_arg - 1;
1704 p_ptr->redraw |= (PR_STATE);
1706 /* Cancel the arg */
1710 /* Get a "repeated" direction */
1711 if (get_rep_dir(&dir,FALSE))
1716 y = p_ptr->y + ddy[dir];
1717 x = p_ptr->x + ddx[dir];
1720 c_ptr = &cave[y][x];
1722 /* Feature code (applying "mimic" field) */
1723 feat = get_feat_mimic(c_ptr);
1725 /* Nothing useful */
1726 if (!have_flag(f_info[feat].flags, FF_BASH))
1728 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1731 /* Monster in the way */
1732 else if (c_ptr->m_idx)
1734 p_ptr->energy_use = 100;
1736 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1742 /* Bash a closed door */
1746 more = do_cmd_bash_aux(y, x, dir);
1750 /* Unless valid action taken, cancel bash */
1751 if (!more) disturb(FALSE, FALSE);
1756 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1760 * Manipulate an adjacent grid in some way
1762 * Attack monsters, tunnel through walls, disarm traps, open doors.
1764 * Consider confusion
1766 * This command must always take a turn, to prevent free detection
1767 * of invisible monsters.
1770 void do_cmd_alter(void)
1777 if (p_ptr->special_defense & KATA_MUSOU)
1779 set_action(ACTION_NONE);
1782 /* Allow repeated command */
1785 /* Set repeat count */
1786 command_rep = command_arg - 1;
1787 p_ptr->redraw |= (PR_STATE);
1789 /* Cancel the arg */
1793 /* Get a direction */
1794 if (get_rep_dir(&dir,TRUE))
1797 feature_type *f_ptr;
1799 y = p_ptr->y + ddy[dir];
1800 x = p_ptr->x + ddx[dir];
1803 c_ptr = &cave[y][x];
1805 /* Feature code (applying "mimic" field) */
1806 feat = get_feat_mimic(c_ptr);
1807 f_ptr = &f_info[feat];
1809 p_ptr->energy_use = 100;
1817 else if (have_flag(f_ptr->flags, FF_OPEN))
1819 more = do_cmd_open_aux(y, x);
1822 /* Bash jammed doors */
1823 else if (have_flag(f_ptr->flags, FF_BASH))
1825 more = do_cmd_bash_aux(y, x, dir);
1828 /* Tunnel through walls */
1829 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1831 more = do_cmd_tunnel_aux(y, x);
1834 /* Close open doors */
1835 else if (have_flag(f_ptr->flags, FF_CLOSE))
1837 more = do_cmd_close_aux(y, x);
1841 else if (have_flag(f_ptr->flags, FF_DISARM))
1843 more = do_cmd_disarm_aux(y, x, dir);
1848 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1852 /* Cancel repetition unless we can continue */
1853 if (!more) disturb(FALSE, FALSE);
1859 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1860 * Find the index of some "spikes", if possible.
1861 * @param ip くさびとして打てるオブジェクトのID
1862 * @return オブジェクトがある場合TRUEを返す
1865 * Let user choose a pile of spikes, perhaps?
1868 static bool get_spike(INVENTORY_IDX *ip)
1872 /* Check every item in the pack */
1873 for (i = 0; i < INVEN_PACK; i++)
1875 object_type *o_ptr = &inventory[i];
1877 /* Skip non-objects */
1878 if (!o_ptr->k_idx) continue;
1880 /* Check the "tval" code */
1881 if (o_ptr->tval == TV_SPIKE)
1883 /* Save the spike index */
1896 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1897 * Jam a closed door with a spike
1901 * This command may NOT be repeated
1904 void do_cmd_spike(void)
1908 if (p_ptr->wild_mode) return;
1910 if (p_ptr->special_defense & KATA_MUSOU)
1912 set_action(ACTION_NONE);
1915 /* Get a "repeated" direction */
1916 if (get_rep_dir(&dir, FALSE))
1923 y = p_ptr->y + ddy[dir];
1924 x = p_ptr->x + ddx[dir];
1925 c_ptr = &cave[y][x];
1927 /* Feature code (applying "mimic" field) */
1928 feat = get_feat_mimic(c_ptr);
1930 /* Require closed door */
1931 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1933 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1937 else if (!get_spike(&item))
1939 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1942 /* Is a monster in the way? */
1943 else if (c_ptr->m_idx)
1945 p_ptr->energy_use = 100;
1947 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1956 p_ptr->energy_use = 100;
1958 /* Successful jamming */
1959 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1960 cave_alter_feat(y, x, FF_SPIKE);
1962 /* Use up, and describe, a single spike, from the bottom */
1963 inven_item_increase(item, -1);
1964 inven_item_describe(item);
1965 inven_item_optimize(item);
1973 * @brief 「歩く」動作コマンドのメインルーチン /
1974 * Support code for the "Walk" and "Jump" commands
1975 * @param pickup アイテムの自動拾いを行うならTRUE
1978 void do_cmd_walk(bool pickup)
1985 /* Allow repeated command */
1988 /* Set repeat count */
1989 command_rep = command_arg - 1;
1990 p_ptr->redraw |= (PR_STATE);
1992 /* Cancel the arg */
1996 /* Get a "repeated" direction */
1997 if (get_rep_dir(&dir, FALSE))
1999 p_ptr->energy_use = 100;
2001 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2003 set_action(ACTION_NONE);
2006 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2007 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2008 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2010 /* Actually move the character */
2011 move_player(dir, pickup, FALSE);
2013 /* Allow more walking */
2017 /* Hack again -- Is there a special encounter ??? */
2018 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2020 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2023 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2025 /* Inform the player of his horrible fate :=) */
2026 msg_print(_("襲撃だ!", "You are ambushed !"));
2028 /* Go into large wilderness view */
2029 p_ptr->oldpy = randint1(MAX_HGT-2);
2030 p_ptr->oldpx = randint1(MAX_WID-2);
2033 /* Give first move to monsters */
2034 p_ptr->energy_use = 100;
2036 /* HACk -- set the encouter flag for the wilderness generation */
2037 generate_encounter = TRUE;
2041 /* Cancel repeat unless we may continue */
2042 if (!more) disturb(FALSE, FALSE);
2047 * @brief 「走る」動作コマンドのメインルーチン /
2051 void do_cmd_run(void)
2055 /* Hack -- no running when confused */
2056 if (p_ptr->confused)
2058 msg_print(_("混乱していて走れない!", "You are too confused!"));
2062 if (p_ptr->special_defense & KATA_MUSOU)
2064 set_action(ACTION_NONE);
2067 /* Get a "repeated" direction */
2068 if (get_rep_dir(&dir,FALSE))
2070 /* Hack -- Set the run counter */
2071 running = (command_arg ? command_arg : 1000);
2080 * @brief 「留まる」動作コマンドのメインルーチン /
2081 * Stay still. Search. Enter stores.
2082 * Pick up treasure if "pickup" is true.
2083 * @param pickup アイテムの自動拾いを行うならTRUE
2086 void do_cmd_stay(bool pickup)
2088 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2090 /* Allow repeated command */
2093 /* Set repeat count */
2094 command_rep = command_arg - 1;
2095 p_ptr->redraw |= (PR_STATE);
2097 /* Cancel the arg */
2101 p_ptr->energy_use = 100;
2103 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2104 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2109 * @brief 「休む」動作コマンドのメインルーチン /
2110 * Resting allows a player to safely restore his hp -RAK-
2113 void do_cmd_rest(void)
2116 set_action(ACTION_NONE);
2118 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2124 if (hex_spelling_any()) stop_hex_spell_all();
2126 /* Prompt for time if needed */
2127 if (command_arg <= 0)
2129 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2130 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2136 strcpy(out_val, "&");
2138 /* Ask for duration */
2139 if (!get_string(p, out_val, 4)) return;
2141 /* Rest until done */
2142 if (out_val[0] == '&')
2144 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2148 else if (out_val[0] == '*')
2150 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2156 command_arg = (COMMAND_ARG)atoi(out_val);
2157 if (command_arg <= 0) return;
2163 if (command_arg > 9999) command_arg = 9999;
2165 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2167 /* Take a turn (?) */
2168 p_ptr->energy_use = 100;
2170 /* The sin of sloth */
2171 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2173 /* Why are you sleeping when there's no need? WAKE UP!*/
2174 if ((p_ptr->chp == p_ptr->mhp) &&
2175 (p_ptr->csp == p_ptr->msp) &&
2176 !p_ptr->blind && !p_ptr->confused &&
2177 !p_ptr->poisoned && !p_ptr->afraid &&
2178 !p_ptr->stun && !p_ptr->cut &&
2179 !p_ptr->slow && !p_ptr->paralyzed &&
2180 !p_ptr->image && !p_ptr->word_recall &&
2181 !p_ptr->alter_reality)
2182 chg_virtue(V_DILIGENCE, -1);
2184 /* Save the rest code */
2185 resting = command_arg;
2186 p_ptr->action = ACTION_REST;
2187 p_ptr->update |= (PU_BONUS);
2188 update_creature(p_ptr);
2190 p_ptr->redraw |= (PR_STATE);
2199 * @brief 射撃処理のメインルーチン
2202 void do_cmd_fire(void)
2205 object_type *j_ptr, *ammo_ptr;
2208 if(p_ptr->wild_mode) return;
2210 is_fired = FALSE; /* not fired yet */
2212 /* Get the "bow" (if any) */
2213 j_ptr = &inventory[INVEN_BOW];
2215 /* Require a launcher */
2218 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2223 if (j_ptr->sval == SV_CRIMSON)
2225 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2230 if (j_ptr->sval == SV_HARP)
2232 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2238 if (p_ptr->special_defense & KATA_MUSOU)
2240 set_action(ACTION_NONE);
2243 /* Require proper missile */
2244 item_tester_tval = p_ptr->tval_ammo;
2246 q = _("どれを撃ちますか? ", "Fire which item? ");
2247 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2250 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2258 exe_fire(item, j_ptr);
2260 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2262 /* Sniper actions after some shootings */
2263 if (snipe_type == SP_AWAY)
2265 teleport_player(10 + (p_ptr->concent * 2), 0L);
2267 if (snipe_type == SP_FINAL)
2269 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2270 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2271 (void)set_stun(p_ptr->stun + randint1(25));
2277 * @brief 投射処理メインルーチン /
2278 * Throw an object from the pack or floor.
2280 * @param boomerang ブーメラン処理ならばTRUE
2281 * @param shuriken 忍者の手裏剣処理ならばTRUE
2282 * @return ターンを消費した場合TRUEを返す
2285 * Note: "unseen" monsters are very hard to hit.
2287 * Should throwing a weapon do full damage? Should it allow the magic
2288 * to hit bonus of the weapon to have an effect? Should it ever cause
2289 * the item to be destroyed? Should it do any damage at all?
2292 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2297 POSITION y, x, ty, tx, prev_y, prev_x;
2298 POSITION ny[19], nx[19];
2299 int chance, tdam, tdis;
2300 int mul, div, dd, ds;
2301 int cur_dis, visible;
2308 bool hit_body = FALSE;
2309 bool hit_wall = FALSE;
2310 bool equiped_item = FALSE;
2311 bool return_when_thrown = FALSE;
2313 GAME_TEXT o_name[MAX_NLEN];
2315 int msec = delay_factor * delay_factor * delay_factor;
2317 BIT_FLAGS flgs[TR_FLAG_SIZE];
2319 bool come_back = FALSE;
2320 bool do_drop = TRUE;
2322 if (p_ptr->wild_mode) return FALSE;
2324 if (p_ptr->special_defense & KATA_MUSOU)
2326 set_action(ACTION_NONE);
2332 o_ptr = &inventory[item];
2336 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2338 item_tester_hook = item_tester_hook_boomerang;
2339 q = _("どの武器を投げますか? ", "Throw which item? ");
2340 s = _("投げる武器がない。", "You have nothing to throw.");
2341 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2348 else if (has_melee_weapon(INVEN_LARM))
2351 o_ptr = &inventory[item];
2356 o_ptr = &inventory[item];
2361 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2362 s = _("投げるアイテムがない。", "You have nothing to throw.");
2363 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2371 /* Item is cursed */
2372 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2374 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2379 if (p_ptr->inside_arena && !boomerang)
2381 if (o_ptr->tval != TV_SPIKE)
2383 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2392 /* Obtain a local object */
2393 object_copy(q_ptr, o_ptr);
2395 /* Extract the thrown object's flags. */
2396 object_flags(q_ptr, flgs);
2397 torch_flags(q_ptr, flgs);
2399 /* Distribute the charges of rods/wands between the stacks */
2400 distribute_charges(o_ptr, q_ptr, 1);
2405 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2407 if (p_ptr->mighty_throw) mult += 3;
2409 /* Extract a "distance multiplier" */
2410 /* Changed for 'launcher' mutation */
2411 mul = 10 + 2 * (mult - 1);
2413 /* Enforce a minimum "weight" of one pound */
2414 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2415 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2417 /* Hack -- Distance -- Reward strength, penalize weight */
2418 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2420 /* Max distance of 10-18 */
2421 if (tdis > mul) tdis = mul;
2425 ty = randint0(101) - 50 + p_ptr->y;
2426 tx = randint0(101) - 50 + p_ptr->x;
2430 project_length = tdis + 1;
2432 /* Get a direction (or cancel) */
2433 if (!get_aim_dir(&dir)) return FALSE;
2435 /* Predict the "target" location */
2436 tx = p_ptr->x + 99 * ddx[dir];
2437 ty = p_ptr->y + 99 * ddy[dir];
2439 /* Check for "target request" */
2440 if ((dir == 5) && target_okay())
2446 project_length = 0; /* reset to default */
2449 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2450 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2451 return_when_thrown = TRUE;
2453 /* Reduce and describe inventory */
2456 inven_item_increase(item, -1);
2457 if (!return_when_thrown)
2458 inven_item_describe(item);
2459 inven_item_optimize(item);
2462 /* Reduce and describe floor item */
2465 floor_item_increase(0 - item, -1);
2466 floor_item_optimize(0 - item);
2468 if (item >= INVEN_RARM)
2470 equiped_item = TRUE;
2471 p_ptr->redraw |= (PR_EQUIPPY);
2474 p_ptr->energy_use = 100;
2476 /* Rogue and Ninja gets bonus */
2477 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2478 p_ptr->energy_use -= p_ptr->lev;
2480 /* Start at the player */
2486 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2487 else shuriken = FALSE;
2489 /* Chance of hitting */
2490 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2491 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2492 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2494 if (shuriken) chance *= 2;
2499 /* Travel until stopped */
2500 for (cur_dis = 0; cur_dis <= tdis; )
2502 /* Hack -- Stop at the target */
2503 if ((y == ty) && (x == tx)) break;
2505 /* Calculate the new location (see "project()") */
2508 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2510 /* Stopped by walls/doors */
2511 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2514 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2517 /* The player can see the (on screen) missile */
2518 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2520 SYMBOL_CODE c = object_char(q_ptr);
2521 TERM_COLOR a = object_attr(q_ptr);
2523 /* Draw, Hilite, Fresh, Pause, Erase */
2524 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2525 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2527 Term_xtra(TERM_XTRA_DELAY, msec);
2528 lite_spot(ny[cur_dis], nx[cur_dis]);
2532 /* The player cannot see the missile */
2535 /* Pause anyway, for consistancy */
2536 Term_xtra(TERM_XTRA_DELAY, msec);
2542 /* Save the new location */
2546 /* Advance the distance */
2549 /* Monster here, Try to hit it */
2550 if (cave[y][x].m_idx)
2552 cave_type *c_ptr = &cave[y][x];
2553 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2555 /* Check the visibility */
2556 visible = m_ptr->ml;
2558 /* Note the collision */
2561 /* Did we hit it (penalize range) */
2562 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2566 /* Handle unseen monster */
2569 /* Invisible monster */
2570 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2573 /* Handle visible monster */
2576 GAME_TEXT m_name[MAX_NLEN];
2577 monster_desc(m_name, m_ptr, 0);
2578 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2582 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2583 health_track(c_ptr->m_idx);
2587 /* Hack -- Base damage from thrown object */
2590 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2591 tdam = damroll(dd, ds);
2592 /* Apply special damage */
2593 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2594 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2595 if (q_ptr->to_d > 0)
2596 tdam += q_ptr->to_d;
2598 tdam += -q_ptr->to_d;
2602 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2603 tdam += p_ptr->to_d_m;
2605 else if (have_flag(flgs, TR_THROW))
2608 tdam += p_ptr->to_d_m;
2616 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2619 /* No negative damage */
2620 if (tdam < 0) tdam = 0;
2622 /* Modify the damage */
2623 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2625 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2626 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2628 /* Hit the monster, check for death */
2629 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2637 message_pain(c_ptr->m_idx, tdam);
2639 /* Anger the monster */
2640 if ((tdam > 0) && !object_is_potion(q_ptr))
2641 anger_monster(m_ptr);
2643 if (fear && m_ptr->ml)
2646 GAME_TEXT m_name[MAX_NLEN];
2647 monster_desc(m_name, m_ptr, 0);
2648 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2658 /* decrease toach's fuel */
2659 if (hit_body) torch_lost_fuel(q_ptr);
2661 /* Chance of breakage (during attacks) */
2662 j = (hit_body ? breakage_chance(q_ptr) : 0);
2664 /* Figurines transform */
2665 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2669 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2670 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2671 else if (object_is_cursed(q_ptr))
2672 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2677 /* Potions smash open */
2678 if (object_is_potion(q_ptr))
2680 if (hit_body || hit_wall || (randint1(100) < j))
2682 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2684 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2686 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
2688 /* ToDo (Robert): fix the invulnerability */
2689 if (cave[y][x].m_idx &&
2690 is_friendly(&m_list[cave[y][x].m_idx]) &&
2691 !MON_INVULNER(m_ptr))
2693 GAME_TEXT m_name[MAX_NLEN];
2694 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
2695 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2696 set_hostile(&m_list[cave[y][x].m_idx]);
2707 if (return_when_thrown)
2709 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2710 char o2_name[MAX_NLEN];
2711 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2714 if (boomerang) back_chance += 4+randint1(5);
2715 if (super_boomerang) back_chance += 100;
2716 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2718 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2720 for (i = cur_dis - 1; i > 0; i--)
2722 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2724 char c = object_char(q_ptr);
2725 byte a = object_attr(q_ptr);
2727 /* Draw, Hilite, Fresh, Pause, Erase */
2728 print_rel(c, a, ny[i], nx[i]);
2729 move_cursor_relative(ny[i], nx[i]);
2731 Term_xtra(TERM_XTRA_DELAY, msec);
2732 lite_spot(ny[i], nx[i]);
2737 /* Pause anyway, for consistancy */
2738 Term_xtra(TERM_XTRA_DELAY, msec);
2741 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2743 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2750 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2754 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2762 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2768 if (item == INVEN_RARM || item == INVEN_LARM)
2770 /* Access the wield slot */
2771 o_ptr = &inventory[item];
2773 /* Wear the new stuff */
2774 object_copy(o_ptr, q_ptr);
2776 p_ptr->total_weight += q_ptr->weight;
2778 /* Increment the equip counter by hand */
2781 /* Recalculate torch */
2782 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2783 p_ptr->window |= (PW_EQUIP);
2791 else if (equiped_item)
2799 if (cave_have_flag_bold(y, x, FF_PROJECT))
2801 (void)drop_near(q_ptr, j, y, x);
2805 (void)drop_near(q_ptr, j, prev_y, prev_x);
2815 * Hack: travel command
2817 #define TRAVEL_UNABLE 9999
2819 static int flow_head = 0;
2820 static int flow_tail = 0;
2821 static POSITION temp2_x[MAX_SHORT];
2822 static POSITION temp2_y[MAX_SHORT];
2825 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
2828 void forget_travel_flow(void)
2831 /* Check the entire dungeon / Forget the old data */
2832 for (y = 0; y < cur_hgt; y++)
2834 for (x = 0; x < cur_wid; x++)
2837 travel.cost[y][x] = MAX_SHORT;
2840 travel.y = travel.x = 0;
2844 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
2849 static int travel_flow_cost(POSITION y, POSITION x)
2851 feature_type *f_ptr = &f_info[cave[y][x].feat];
2854 /* Avoid obstacles (ex. trees) */
2855 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
2858 if (have_flag(f_ptr->flags, FF_WATER))
2860 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
2864 if (have_flag(f_ptr->flags, FF_LAVA))
2867 if (!p_ptr->resist_fire) lava *= 2;
2868 if (!p_ptr->levitation) lava *= 2;
2869 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
2874 /* Detected traps and doors */
2875 if (cave[y][x].info & (CAVE_MARK))
2877 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
2878 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
2885 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
2889 * @param wall プレイヤーが壁の中にいるならばTRUE
2892 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
2894 cave_type *c_ptr = &cave[y][x];
2895 feature_type *f_ptr = &f_info[c_ptr->feat];
2896 int old_head = flow_head;
2898 int base_cost = (n % TRAVEL_UNABLE);
2899 int from_wall = (n / TRAVEL_UNABLE);
2902 /* Ignore out of bounds */
2903 if (!in_bounds(y, x)) return;
2905 /* Ignore unknown grid except in wilderness */
2906 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
2908 /* Ignore "walls" and "rubble" (include "secret doors") */
2909 if (have_flag(f_ptr->flags, FF_WALL) ||
2910 have_flag(f_ptr->flags, FF_CAN_DIG) ||
2911 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
2912 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
2914 if (!wall || !from_wall) return;
2915 add_cost += TRAVEL_UNABLE;
2919 add_cost = travel_flow_cost(y, x);
2922 cost = base_cost + add_cost;
2924 /* Ignore lower cost entries */
2925 if (travel.cost[y][x] <= cost) return;
2927 /* Save the flow cost */
2928 travel.cost[y][x] = cost;
2930 /* Enqueue that entry */
2931 temp2_y[flow_head] = y;
2932 temp2_x[flow_head] = x;
2934 /* Advance the queue */
2935 if (++flow_head == MAX_SHORT) flow_head = 0;
2937 /* Hack -- notice overflow by forgetting new entry */
2938 if (flow_head == flow_tail) flow_head = old_head;
2944 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
2945 * @param ty 目標地点のY座標
2946 * @param tx 目標地点のX座標
2949 static void travel_flow(POSITION ty, POSITION tx)
2953 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
2955 /* Reset the "queue" */
2956 flow_head = flow_tail = 0;
2958 /* is player in the wall? */
2959 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
2961 /* Start at the target grid */
2962 travel_flow_aux(ty, tx, 0, wall);
2964 /* Now process the queue */
2965 while (flow_head != flow_tail)
2967 /* Extract the next entry */
2968 y = temp2_y[flow_tail];
2969 x = temp2_x[flow_tail];
2971 /* Forget that entry */
2972 if (++flow_tail == MAX_SHORT) flow_tail = 0;
2974 /* Ignore too far entries */
2975 //if (distance(ty, tx, y, x) > 100) continue;
2977 /* Add the "children" */
2978 for (d = 0; d < 8; d++)
2980 /* Add that child if "legal" */
2981 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
2985 /* Forget the flow info */
2986 flow_head = flow_tail = 0;
2990 * @brief トラベル処理のメインルーチン
2993 void do_cmd_travel(void)
2997 POSITION dx, dy, sx, sy;
2998 feature_type *f_ptr;
3000 if (travel.x != 0 && travel.y != 0 &&
3001 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3006 else if (!tgt_pt(&x, &y)) return;
3008 if ((x == p_ptr->x) && (y == p_ptr->y))
3010 msg_print(_("すでにそこにいます!", "You are already there!!"));
3014 f_ptr = &f_info[cave[y][x].feat];
3016 if ((cave[y][x].info & CAVE_MARK) &&
3017 (have_flag(f_ptr->flags, FF_WALL) ||
3018 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3019 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3021 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3025 forget_travel_flow();
3031 /* Travel till 255 steps */
3037 /* Decides first direction */
3038 dx = abs(p_ptr->x - x);
3039 dy = abs(p_ptr->y - y);
3040 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3041 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3043 for (i = 1; i <= 9; i++)
3045 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;