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 "monster-status.h"
24 #include "player-status.h"
27 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
28 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
29 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
31 bool confirm_leave_level(bool down_stair)
33 quest_type *q_ptr = &quest[p_ptr->inside_quest];
35 /* Confirm leaving from once only quest */
36 if (confirm_quest && p_ptr->inside_quest &&
37 (q_ptr->type == QUEST_TYPE_RANDOM ||
38 (q_ptr->flags & QUEST_FLAG_ONCE &&
39 q_ptr->status != QUEST_STATUS_COMPLETED) ||
40 (q_ptr->flags & QUEST_FLAG_TOWER &&
41 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
42 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
44 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
45 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
55 * @brief 階段を使って階層を昇る処理 / Go up one level
58 void do_cmd_go_up(void)
63 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
64 feature_type *f_ptr = &f_info[c_ptr->feat];
68 if (p_ptr->special_defense & KATA_MUSOU)
70 set_action(ACTION_NONE);
74 if (!have_flag(f_ptr->flags, FF_LESS))
76 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
81 if (have_flag(f_ptr->flags, FF_QUEST))
83 /* Cancel the command */
84 if (!confirm_leave_level(FALSE)) return;
88 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
89 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
91 msg_print(_("上の階に登った。", "You enter the up staircase."));
95 p_ptr->inside_quest = c_ptr->special;
97 /* Activate the quest */
98 if (!quest[p_ptr->inside_quest].status)
100 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
102 init_flags = INIT_ASSIGN;
103 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
105 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
108 /* Leaving a quest */
109 if (!p_ptr->inside_quest)
115 p_ptr->leaving = TRUE;
120 /* Hack -- take a turn */
121 p_ptr->energy_use = 100;
123 /* End the command */
133 go_up = confirm_leave_level(FALSE);
136 /* Cancel the command */
139 /* Hack -- take a turn */
140 p_ptr->energy_use = 100;
142 if (autosave_l) do_cmd_save_game(TRUE);
144 /* For a random quest */
145 if (p_ptr->inside_quest &&
146 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
150 p_ptr->inside_quest = 0;
153 /* For a fixed quest */
154 if (p_ptr->inside_quest &&
155 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
159 p_ptr->inside_quest = c_ptr->special;
164 /* For normal dungeon and random quest */
168 if (have_flag(f_ptr->flags, FF_SHAFT))
170 /* Create a way back */
171 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
177 /* Create a way back */
178 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
183 /* Get out from current dungeon */
184 if (dun_level - up_num < d_info[dungeon_type].mindepth)
187 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
190 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
191 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
192 else if (up_num == dun_level)
193 msg_print(_("地上に戻った。", "You go back to the surface."));
195 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
198 p_ptr->leaving = TRUE;
203 * @brief 階段を使って階層を降りる処理 / Go down one level
206 void do_cmd_go_down(void)
209 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
210 feature_type *f_ptr = &f_info[c_ptr->feat];
212 bool fall_trap = FALSE;
215 if (p_ptr->special_defense & KATA_MUSOU)
217 set_action(ACTION_NONE);
221 if (!have_flag(f_ptr->flags, FF_MORE))
223 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
227 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
230 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
235 /* Quest down stairs */
236 else if (have_flag(f_ptr->flags, FF_QUEST))
238 /* Confirm Leaving */
239 if(!confirm_leave_level(TRUE)) return;
241 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
242 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
244 msg_print(_("下の階に降りた。", "You enter the down staircase."));
249 p_ptr->inside_quest = c_ptr->special;
251 /* Activate the quest */
252 if (!quest[p_ptr->inside_quest].status)
254 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
256 init_flags = INIT_ASSIGN;
257 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
259 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
262 /* Leaving a quest */
263 if (!p_ptr->inside_quest)
269 p_ptr->leaving = TRUE;
275 /* Hack -- take a turn */
276 p_ptr->energy_use = 100;
281 DUNGEON_IDX target_dungeon = 0;
285 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
287 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
289 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
292 if (!max_dlv[target_dungeon])
294 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
295 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
296 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
299 /* Save old player position */
300 p_ptr->oldpx = p_ptr->x;
301 p_ptr->oldpy = p_ptr->y;
302 dungeon_type = target_dungeon;
305 * Clear all saved floors
306 * and create a first saved floor
308 prepare_change_floor_mode(CFM_FIRST_FLOOR);
311 /* Hack -- take a turn */
312 p_ptr->energy_use = 100;
314 if (autosave_l) do_cmd_save_game(TRUE);
317 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
322 /* Enter the dungeon just now */
323 p_ptr->enter_dungeon = TRUE;
324 down_num = d_info[dungeon_type].mindepth;
329 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
330 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
335 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
342 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
346 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
347 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
349 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
355 p_ptr->leaving = TRUE;
359 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
363 if (have_flag(f_ptr->flags, FF_SHAFT))
365 /* Create a way back */
366 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
370 /* Create a way back */
371 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
379 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
382 void do_cmd_search(void)
384 /* Allow repeated command */
387 /* Set repeat count */
388 command_rep = command_arg - 1;
389 p_ptr->redraw |= (PR_STATE);
394 p_ptr->energy_use = 100;
402 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
403 * @param y 走査対象にしたいマスのY座標
404 * @param x 走査対象にしたいマスのX座標
405 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
406 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
408 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
410 cave_type *c_ptr = &cave[y][x];
411 OBJECT_IDX this_o_idx, next_o_idx = 0;
413 /* Scan all objects in the grid */
414 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
418 o_ptr = &o_list[this_o_idx];
419 next_o_idx = o_ptr->next_o_idx;
421 /* Skip unknown chests XXX XXX */
422 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
424 /* Check for non empty chest */
425 if ((o_ptr->tval == TV_CHEST) &&
426 (((!trapped) && (o_ptr->pval)) || /* non empty */
427 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
436 * @brief 箱を開けるコマンドのメインルーチン /
437 * Attempt to open the given chest at the given location
438 * @param y 箱の存在するマスのY座標
439 * @param x 箱の存在するマスのX座標
440 * @param o_idx 箱のオブジェクトID
441 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
443 * Assume there is no monster blocking the destination
445 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
450 object_type *o_ptr = &o_list[o_idx];
452 p_ptr->energy_use = 100;
454 /* Attempt to unlock it */
457 /* Assume locked, and thus not open */
460 /* Get the "disarm" factor */
461 i = p_ptr->skill_dis;
463 /* Penalize some conditions */
464 if (p_ptr->blind || no_lite()) i = i / 10;
465 if (p_ptr->confused || p_ptr->image) i = i / 10;
467 /* Extract the difficulty */
470 /* Always have a small chance of success */
473 /* Success -- May still have traps */
474 if (randint0(100) < j)
476 msg_print(_("鍵をはずした。", "You have picked the lock."));
481 /* Failure -- Keep trying */
484 /* We may continue repeating */
486 if (flush_failure) flush();
487 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
492 /* Allowed to open */
495 /* Apply chest traps, if any */
496 chest_trap(y, x, o_idx);
498 /* Let the Chest drop items */
499 chest_death(FALSE, y, x, o_idx);
505 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
506 * Attempt to open the given chest at the given location
507 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
508 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
509 * @param test 地形条件を判定するための関数ポインタ
510 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
512 * @details Return the number of features around (or under) the character.
513 * Usually look for doors and floor traps.
515 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
517 int d, count, xx, yy;
519 /* Count how many matches */
522 /* Check around (and under) the character */
523 for (d = 0; d < 9; d++)
528 /* if not searching under player continue */
529 if ((d == 8) && !under) continue;
531 /* Extract adjacent (legal) location */
532 yy = p_ptr->y + ddy_ddd[d];
533 xx = p_ptr->x + ddx_ddd[d];
536 c_ptr = &cave[yy][xx];
538 /* Must have knowledge */
539 if (!(c_ptr->info & (CAVE_MARK))) continue;
541 /* Feature code (applying "mimic" field) */
542 feat = get_feat_mimic(c_ptr);
544 /* Not looking for this feature */
545 if (!((*test)(feat))) continue;
550 /* Remember the location. Only useful if only one match */
561 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
562 * Return the number of chests around (or under) the character.
563 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
564 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
565 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
568 * If requested, count only trapped chests.
570 static int count_chests(POSITION *y, POSITION *x, bool trapped)
577 /* Count how many matches */
580 /* Check around (and under) the character */
581 for (d = 0; d < 9; d++)
583 /* Extract adjacent (legal) location */
584 POSITION yy = p_ptr->y + ddy_ddd[d];
585 POSITION xx = p_ptr->x + ddx_ddd[d];
587 /* No (visible) chest is there */
588 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
590 /* Grab the object */
591 o_ptr = &o_list[o_idx];
594 if (o_ptr->pval == 0) continue;
596 /* No (known) traps here */
597 if (trapped && (!object_is_known(o_ptr) ||
598 !chest_traps[o_ptr->pval])) continue;
603 /* Remember the location. Only useful if only one match */
614 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
615 * Convert an adjacent location to a direction.
616 * @param y 方角を確認したY座標
617 * @param x 方角を確認したX座標
620 static DIRECTION coords_to_dir(POSITION y, POSITION x)
622 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
629 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
631 return d[dx + 1][dy + 1];
635 * @brief 「開ける」動作コマンドのサブルーチン /
636 * Perform the basic "open" command on doors
637 * @param y 対象を行うマスのY座標
638 * @param x 対象を行うマスのX座標
639 * @return 実際に処理が行われた場合TRUEを返す。
641 * Assume destination is a closed/locked/jammed door
642 * Assume there is no monster blocking the destination
643 * Returns TRUE if repeated commands may continue
645 static bool do_cmd_open_aux(POSITION y, POSITION x)
649 /* Get requested grid */
650 cave_type *c_ptr = &cave[y][x];
651 feature_type *f_ptr = &f_info[c_ptr->feat];
654 p_ptr->energy_use = 100;
656 /* Seeing true feature code (ignore mimic) */
659 if (!have_flag(f_ptr->flags, FF_OPEN))
662 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
666 else if (f_ptr->power)
669 i = p_ptr->skill_dis;
671 /* Penalize some conditions */
672 if (p_ptr->blind || no_lite()) i = i / 10;
673 if (p_ptr->confused || p_ptr->image) i = i / 10;
675 /* Extract the lock power */
678 /* Extract the difficulty */
681 /* Always have a small chance of success */
685 if (randint0(100) < j)
687 msg_print(_("鍵をはずした。", "You have picked the lock."));
690 cave_alter_feat(y, x, FF_OPEN);
692 sound(SOUND_OPENDOOR);
702 if (flush_failure) flush();
704 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
706 /* We may keep trying */
715 cave_alter_feat(y, x, FF_OPEN);
717 sound(SOUND_OPENDOOR);
723 * @brief 「開ける」コマンドのメインルーチン /
724 * Open a closed/locked/jammed door or a closed/locked chest.
727 * Unlocking a locked door/chest is worth one experience point.
729 void do_cmd_open(void)
737 if (p_ptr->wild_mode) return;
739 if (p_ptr->special_defense & KATA_MUSOU)
741 set_action(ACTION_NONE);
744 /* Option: Pick a direction */
747 int num_doors, num_chests;
749 /* Count closed doors (locked or jammed) */
750 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
752 /* Count chests (locked) */
753 num_chests = count_chests(&y, &x, FALSE);
755 /* See if only one target */
756 if (num_doors || num_chests)
758 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
760 if (!too_many) command_dir = coords_to_dir(y, x);
764 /* Allow repeated command */
767 /* Set repeat count */
768 command_rep = command_arg - 1;
769 p_ptr->redraw |= (PR_STATE);
775 /* Get a "repeated" direction */
776 if (get_rep_dir(&dir, TRUE))
781 /* Get requested location */
782 y = p_ptr->y + ddy[dir];
783 x = p_ptr->x + ddx[dir];
785 /* Get requested grid */
788 /* Feature code (applying "mimic" field) */
789 feat = get_feat_mimic(c_ptr);
791 /* Check for chest */
792 o_idx = chest_check(y, x, FALSE);
795 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
797 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
800 /* Monster in the way */
801 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
803 p_ptr->energy_use = 100;
804 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
812 more = do_cmd_open_chest(y, x, o_idx);
819 more = do_cmd_open_aux(y, x);
823 /* Cancel repeat unless we may continue */
824 if (!more) disturb(FALSE, FALSE);
830 * @brief 「閉じる」動作コマンドのサブルーチン /
831 * Perform the basic "close" command
832 * @param y 対象を行うマスのY座標
833 * @param x 対象を行うマスのX座標
834 * @return 実際に処理が行われた場合TRUEを返す。
836 * Assume destination is an open/broken door
837 * Assume there is no monster blocking the destination
838 * Returns TRUE if repeated commands may continue
840 static bool do_cmd_close_aux(POSITION y, POSITION x)
842 cave_type *c_ptr = &cave[y][x];
843 FEAT_IDX old_feat = c_ptr->feat;
846 p_ptr->energy_use = 100;
848 /* Seeing true feature code (ignore mimic) */
851 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
853 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
855 /* Hack -- object in the way */
856 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
857 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
859 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
864 cave_alter_feat(y, x, FF_CLOSE);
867 if (old_feat == c_ptr->feat)
869 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
873 sound(SOUND_SHUTDOOR);
882 * @brief 「閉じる」コマンドのメインルーチン /
883 * Close an open door.
886 * Unlocking a locked door/chest is worth one experience point.
888 void do_cmd_close(void)
895 if (p_ptr->wild_mode) return;
897 if (p_ptr->special_defense & KATA_MUSOU)
899 set_action(ACTION_NONE);
902 /* Option: Pick a direction */
905 /* Count open doors */
906 if (count_dt(&y, &x, is_open, FALSE) == 1)
908 command_dir = coords_to_dir(y, x);
912 /* Allow repeated command */
915 /* Set repeat count */
916 command_rep = command_arg - 1;
917 p_ptr->redraw |= (PR_STATE);
923 /* Get a "repeated" direction */
924 if (get_rep_dir(&dir, FALSE))
929 y = p_ptr->y + ddy[dir];
930 x = p_ptr->x + ddx[dir];
933 /* Feature code (applying "mimic" field) */
934 feat = get_feat_mimic(c_ptr);
936 /* Require open/broken door */
937 if (!have_flag(f_info[feat].flags, FF_CLOSE))
939 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
942 /* Monster in the way */
943 else if (c_ptr->m_idx)
945 p_ptr->energy_use = 100;
947 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
957 more = do_cmd_close_aux(y, x);
961 /* Cancel repeat unless we may continue */
962 if (!more) disturb(FALSE, FALSE);
967 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
968 * Determine if a given grid may be "tunneled"
969 * @param y 対象を行うマスのY座標
970 * @param x 対象を行うマスのX座標
973 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
975 cave_type *c_ptr = &cave[y][x];
977 /* Must have knowledge */
978 if (!(c_ptr->info & CAVE_MARK))
980 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
985 /* Must be a wall/door/etc */
986 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
988 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
998 * @brief 「掘る」動作コマンドのサブルーチン /
999 * Perform the basic "tunnel" command
1000 * @param y 対象を行うマスのY座標
1001 * @param x 対象を行うマスのX座標
1002 * @return 実際に処理が行われた場合TRUEを返す。
1004 * Assumes that no monster is blocking the destination
1005 * Do not use twall anymore
1006 * Returns TRUE if repeated commands may continue
1008 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1011 feature_type *f_ptr, *mimic_f_ptr;
1016 /* Verify legality */
1017 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1019 p_ptr->energy_use = 100;
1022 c_ptr = &cave[y][x];
1023 f_ptr = &f_info[c_ptr->feat];
1024 power = f_ptr->power;
1026 /* Feature code (applying "mimic" field) */
1027 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1029 name = f_name + mimic_f_ptr->name;
1033 if (have_flag(f_ptr->flags, FF_PERMANENT))
1036 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1038 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1041 /* Map border (mimiccing Permanent wall) */
1044 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1049 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1052 if (p_ptr->skill_dig > randint0(20 * power))
1054 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1056 /* Remove the feature */
1057 cave_alter_feat(y, x, FF_TUNNEL);
1059 /* Update some things */
1060 p_ptr->update |= (PU_FLOW);
1064 /* Message, keep digging */
1065 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1073 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1076 if (p_ptr->skill_dig > power + randint0(40 * power))
1078 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1081 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1082 p_ptr->update |= (PU_FLOW);
1085 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1087 /* Remove the feature */
1088 cave_alter_feat(y, x, FF_TUNNEL);
1090 chg_virtue(V_DILIGENCE, 1);
1091 chg_virtue(V_NATURE, -1);
1099 /* We may continue chopping */
1100 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1101 /* Occasional Search XXX XXX */
1102 if (randint0(100) < 25) search();
1106 /* We may continue tunelling */
1107 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1114 if (is_hidden_door(c_ptr))
1116 /* Occasional Search XXX XXX */
1117 if (randint0(100) < 25) search();
1124 * @brief 「掘る」動作コマンドのメインルーチン /
1125 * Tunnels through "walls" (including rubble and closed doors)
1129 * Note that you must tunnel in order to hit invisible monsters
1130 * in walls, though moving into walls still takes a turn anyway.
1132 * Digging is very difficult without a "digger" weapon, but can be
1133 * accomplished by strong players using heavy weapons.
1136 void do_cmd_tunnel(void)
1146 if (p_ptr->special_defense & KATA_MUSOU)
1148 set_action(ACTION_NONE);
1151 /* Allow repeated command */
1154 /* Set repeat count */
1155 command_rep = command_arg - 1;
1156 p_ptr->redraw |= (PR_STATE);
1158 /* Cancel the arg */
1162 /* Get a direction to tunnel, or Abort */
1163 if (get_rep_dir(&dir,FALSE))
1166 y = p_ptr->y + ddy[dir];
1167 x = p_ptr->x + ddx[dir];
1170 c_ptr = &cave[y][x];
1172 /* Feature code (applying "mimic" field) */
1173 feat = get_feat_mimic(c_ptr);
1175 /* No tunnelling through doors */
1176 if (have_flag(f_info[feat].flags, FF_DOOR))
1178 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1181 /* No tunnelling through most features */
1182 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1184 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1187 /* A monster is in the way */
1188 else if (c_ptr->m_idx)
1190 p_ptr->energy_use = 100;
1192 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1201 /* Tunnel through walls */
1202 more = do_cmd_tunnel_aux(y, x);
1206 /* Cancel repetition unless we can continue */
1207 if (!more) disturb(FALSE, FALSE);
1211 * @brief 移動処理による簡易な「開く」処理 /
1213 * @return 開く処理が実際に試みられた場合TRUEを返す
1216 * If there is a jammed/closed/locked door at the given location,
1217 * then attempt to unlock/open it. Return TRUE if an attempt was
1218 * made (successful or not), otherwise return FALSE.
1220 * The code here should be nearly identical to that in
1221 * do_cmd_open_test() and do_cmd_open_aux().
1224 bool easy_open_door(POSITION y, POSITION x)
1228 cave_type *c_ptr = &cave[y][x];
1229 feature_type *f_ptr = &f_info[c_ptr->feat];
1231 /* Must be a closed door */
1232 if (!is_closed_door(c_ptr->feat))
1238 if (!have_flag(f_ptr->flags, FF_OPEN))
1241 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1246 else if (f_ptr->power)
1249 i = p_ptr->skill_dis;
1251 /* Penalize some conditions */
1252 if (p_ptr->blind || no_lite()) i = i / 10;
1253 if (p_ptr->confused || p_ptr->image) i = i / 10;
1255 /* Extract the lock power */
1258 /* Extract the difficulty */
1261 /* Always have a small chance of success */
1265 if (randint0(100) < j)
1267 msg_print(_("鍵をはずした。", "You have picked the lock."));
1270 cave_alter_feat(y, x, FF_OPEN);
1272 sound(SOUND_OPENDOOR);
1282 if (flush_failure) flush();
1284 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1293 cave_alter_feat(y, x, FF_OPEN);
1295 sound(SOUND_OPENDOOR);
1301 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1302 * Perform the basic "disarm" command
1303 * @param y 解除を行うマスのY座標
1304 * @param x 解除を行うマスのX座標
1305 * @param o_idx 箱のオブジェクトID
1306 * @return ターンを消費する処理が行われた場合TRUEを返す
1309 * Assume destination is a visible trap
1310 * Assume there is no monster blocking the destination
1311 * Returns TRUE if repeated commands may continue
1314 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1318 object_type *o_ptr = &o_list[o_idx];
1320 p_ptr->energy_use = 100;
1322 /* Get the "disarm" factor */
1323 i = p_ptr->skill_dis;
1325 /* Penalize some conditions */
1326 if (p_ptr->blind || no_lite()) i = i / 10;
1327 if (p_ptr->confused || p_ptr->image) i = i / 10;
1329 /* Extract the difficulty */
1330 j = i - o_ptr->pval;
1332 /* Always have a small chance of success */
1335 /* Must find the trap first. */
1336 if (!object_is_known(o_ptr))
1338 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1342 /* Already disarmed/unlocked */
1343 else if (o_ptr->pval <= 0)
1345 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1348 /* No traps to find. */
1349 else if (!chest_traps[o_ptr->pval])
1351 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1354 /* Success (get a lot of experience) */
1355 else if (randint0(100) < j)
1357 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1358 gain_exp(o_ptr->pval);
1359 o_ptr->pval = (0 - o_ptr->pval);
1362 /* Failure -- Keep trying */
1363 else if ((i > 5) && (randint1(i) > 5))
1365 /* We may keep trying */
1367 if (flush_failure) flush();
1368 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1371 /* Failure -- Set off the trap */
1374 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1376 chest_trap(y, x, o_idx);
1383 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1384 * Perform the basic "disarm" command
1385 * @param y 解除を行うマスのY座標
1386 * @param x 解除を行うマスのX座標
1387 * @param dir プレイヤーからみた方向ID
1388 * @return ターンを消費する処理が行われた場合TRUEを返す
1391 * Assume destination is a visible trap
1392 * Assume there is no monster blocking the destination
1393 * Returns TRUE if repeated commands may continue
1397 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1399 cave_type *c_ptr = &cave[y][x];
1402 feature_type *f_ptr = &f_info[c_ptr->feat];
1404 /* Access trap name */
1405 concptr name = (f_name + f_ptr->name);
1407 /* Extract trap "power" */
1408 int power = f_ptr->power;
1411 /* Get the "disarm" factor */
1412 int i = p_ptr->skill_dis;
1415 p_ptr->energy_use = 100;
1417 /* Penalize some conditions */
1418 if (p_ptr->blind || no_lite()) i = i / 10;
1419 if (p_ptr->confused || p_ptr->image) i = i / 10;
1421 /* Extract the difficulty */
1424 /* Always have a small chance of success */
1428 if (randint0(100) < j)
1430 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1435 /* Remove the trap */
1436 cave_alter_feat(y, x, FF_DISARM);
1438 /* Move the player onto the trap */
1439 move_player(dir, easy_disarm, FALSE);
1442 /* Failure -- Keep trying */
1443 else if ((i > 5) && (randint1(i) > 5))
1446 if (flush_failure) flush();
1448 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1450 /* We may keep trying */
1454 /* Failure -- Set off the trap */
1457 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1458 /* Move the player onto the trap */
1459 move_player(dir, easy_disarm, FALSE);
1466 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1467 * Disarms a trap, or chest
1470 void do_cmd_disarm(void)
1478 if (p_ptr->wild_mode) return;
1480 if (p_ptr->special_defense & KATA_MUSOU)
1482 set_action(ACTION_NONE);
1485 /* Option: Pick a direction */
1488 int num_traps, num_chests;
1490 /* Count visible traps */
1491 num_traps = count_dt(&y, &x, is_trap, TRUE);
1493 /* Count chests (trapped) */
1494 num_chests = count_chests(&y, &x, TRUE);
1496 /* See if only one target */
1497 if (num_traps || num_chests)
1499 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1500 if (!too_many) command_dir = coords_to_dir(y, x);
1505 /* Allow repeated command */
1508 /* Set repeat count */
1509 command_rep = command_arg - 1;
1510 p_ptr->redraw |= (PR_STATE);
1512 /* Cancel the arg */
1516 /* Get a direction (or abort) */
1517 if (get_rep_dir(&dir,TRUE))
1522 y = p_ptr->y + ddy[dir];
1523 x = p_ptr->x + ddx[dir];
1524 c_ptr = &cave[y][x];
1526 /* Feature code (applying "mimic" field) */
1527 feat = get_feat_mimic(c_ptr);
1529 /* Check for chests */
1530 o_idx = chest_check(y, x, TRUE);
1533 if (!is_trap(feat) && !o_idx)
1535 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1538 /* Monster in the way */
1539 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1541 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1550 more = do_cmd_disarm_chest(y, x, o_idx);
1556 more = do_cmd_disarm_aux(y, x, dir);
1560 /* Cancel repeat unless told not to */
1561 if (!more) disturb(FALSE, FALSE);
1566 * @brief 「打ち破る」動作コマンドのサブルーチン /
1567 * Perform the basic "bash" command
1568 * @param y 対象を行うマスのY座標
1569 * @param x 対象を行うマスのX座標
1570 * @param dir プレイヤーから見たターゲットの方角ID
1571 * @return 実際に処理が行われた場合TRUEを返す。
1574 * Assume destination is a closed/locked/jammed door
1575 * Assume there is no monster blocking the destination
1576 * Returns TRUE if repeated commands may continue
1579 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1582 cave_type *c_ptr = &cave[y][x];
1585 feature_type *f_ptr = &f_info[c_ptr->feat];
1587 /* Hack -- Bash power based on strength */
1588 /* (Ranges from 3 to 20 to 100 to 200) */
1589 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1591 /* Extract door power */
1592 int temp = f_ptr->power;
1596 concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1598 p_ptr->energy_use = 100;
1600 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1602 /* Compare bash power to door power */
1603 temp = (bash - (temp * 10));
1605 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1607 /* Hack -- always have a chance */
1608 if (temp < 1) temp = 1;
1610 /* Hack -- attempt to bash down the door */
1611 if (randint0(100) < temp)
1613 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1615 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1617 /* Break down the door */
1618 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1620 cave_alter_feat(y, x, FF_BASH);
1626 cave_alter_feat(y, x, FF_OPEN);
1629 /* Hack -- Fall through the door */
1630 move_player(dir, FALSE, FALSE);
1633 /* Saving throw against stun */
1634 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1637 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1639 /* Allow repeated bashing */
1643 /* High dexterity yields coolness */
1646 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1648 /* Hack -- Lose balance ala paralysis */
1649 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1656 * @brief 「打ち破る」動作コマンドのメインルーチン /
1657 * Bash open a door, success based on character strength
1661 * For a closed door, pval is positive if locked; negative if stuck.
1663 * For an open door, pval is positive for a broken door.
1665 * A closed door can be opened - harder if locked. Any door might be
1666 * bashed open (and thereby broken). Bashing a door is (potentially)
1667 * faster! You move into the door way. To open a stuck door, it must
1668 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1670 * Creatures can also open or bash doors, see elsewhere.
1673 void do_cmd_bash(void)
1679 if (p_ptr->wild_mode) return;
1681 if (p_ptr->special_defense & KATA_MUSOU)
1683 set_action(ACTION_NONE);
1686 /* Allow repeated command */
1689 /* Set repeat count */
1690 command_rep = command_arg - 1;
1691 p_ptr->redraw |= (PR_STATE);
1693 /* Cancel the arg */
1697 /* Get a "repeated" direction */
1698 if (get_rep_dir(&dir,FALSE))
1703 y = p_ptr->y + ddy[dir];
1704 x = p_ptr->x + ddx[dir];
1707 c_ptr = &cave[y][x];
1709 /* Feature code (applying "mimic" field) */
1710 feat = get_feat_mimic(c_ptr);
1712 /* Nothing useful */
1713 if (!have_flag(f_info[feat].flags, FF_BASH))
1715 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1718 /* Monster in the way */
1719 else if (c_ptr->m_idx)
1721 p_ptr->energy_use = 100;
1723 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1729 /* Bash a closed door */
1733 more = do_cmd_bash_aux(y, x, dir);
1737 /* Unless valid action taken, cancel bash */
1738 if (!more) disturb(FALSE, FALSE);
1743 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1747 * Manipulate an adjacent grid in some way
1749 * Attack monsters, tunnel through walls, disarm traps, open doors.
1751 * Consider confusion
1753 * This command must always take a turn, to prevent free detection
1754 * of invisible monsters.
1757 void do_cmd_alter(void)
1764 if (p_ptr->special_defense & KATA_MUSOU)
1766 set_action(ACTION_NONE);
1769 /* Allow repeated command */
1772 /* Set repeat count */
1773 command_rep = command_arg - 1;
1774 p_ptr->redraw |= (PR_STATE);
1776 /* Cancel the arg */
1780 /* Get a direction */
1781 if (get_rep_dir(&dir,TRUE))
1784 feature_type *f_ptr;
1786 y = p_ptr->y + ddy[dir];
1787 x = p_ptr->x + ddx[dir];
1790 c_ptr = &cave[y][x];
1792 /* Feature code (applying "mimic" field) */
1793 feat = get_feat_mimic(c_ptr);
1794 f_ptr = &f_info[feat];
1796 p_ptr->energy_use = 100;
1804 else if (have_flag(f_ptr->flags, FF_OPEN))
1806 more = do_cmd_open_aux(y, x);
1809 /* Bash jammed doors */
1810 else if (have_flag(f_ptr->flags, FF_BASH))
1812 more = do_cmd_bash_aux(y, x, dir);
1815 /* Tunnel through walls */
1816 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1818 more = do_cmd_tunnel_aux(y, x);
1821 /* Close open doors */
1822 else if (have_flag(f_ptr->flags, FF_CLOSE))
1824 more = do_cmd_close_aux(y, x);
1828 else if (have_flag(f_ptr->flags, FF_DISARM))
1830 more = do_cmd_disarm_aux(y, x, dir);
1835 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1839 /* Cancel repetition unless we can continue */
1840 if (!more) disturb(FALSE, FALSE);
1846 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1847 * Find the index of some "spikes", if possible.
1848 * @param ip くさびとして打てるオブジェクトのID
1849 * @return オブジェクトがある場合TRUEを返す
1852 * Let user choose a pile of spikes, perhaps?
1855 static bool get_spike(INVENTORY_IDX *ip)
1859 /* Check every item in the pack */
1860 for (i = 0; i < INVEN_PACK; i++)
1862 object_type *o_ptr = &inventory[i];
1864 /* Skip non-objects */
1865 if (!o_ptr->k_idx) continue;
1867 /* Check the "tval" code */
1868 if (o_ptr->tval == TV_SPIKE)
1870 /* Save the spike index */
1883 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1884 * Jam a closed door with a spike
1888 * This command may NOT be repeated
1891 void do_cmd_spike(void)
1895 if (p_ptr->wild_mode) return;
1897 if (p_ptr->special_defense & KATA_MUSOU)
1899 set_action(ACTION_NONE);
1902 /* Get a "repeated" direction */
1903 if (get_rep_dir(&dir, FALSE))
1910 y = p_ptr->y + ddy[dir];
1911 x = p_ptr->x + ddx[dir];
1912 c_ptr = &cave[y][x];
1914 /* Feature code (applying "mimic" field) */
1915 feat = get_feat_mimic(c_ptr);
1917 /* Require closed door */
1918 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1920 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1924 else if (!get_spike(&item))
1926 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1929 /* Is a monster in the way? */
1930 else if (c_ptr->m_idx)
1932 p_ptr->energy_use = 100;
1934 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1943 p_ptr->energy_use = 100;
1945 /* Successful jamming */
1946 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1947 cave_alter_feat(y, x, FF_SPIKE);
1949 /* Use up, and describe, a single spike, from the bottom */
1950 inven_item_increase(item, -1);
1951 inven_item_describe(item);
1952 inven_item_optimize(item);
1960 * @brief 「歩く」動作コマンドのメインルーチン /
1961 * Support code for the "Walk" and "Jump" commands
1962 * @param pickup アイテムの自動拾いを行うならTRUE
1965 void do_cmd_walk(bool pickup)
1972 /* Allow repeated command */
1975 /* Set repeat count */
1976 command_rep = command_arg - 1;
1977 p_ptr->redraw |= (PR_STATE);
1979 /* Cancel the arg */
1983 /* Get a "repeated" direction */
1984 if (get_rep_dir(&dir, FALSE))
1986 p_ptr->energy_use = 100;
1988 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
1990 set_action(ACTION_NONE);
1993 /* Hack -- In small scale wilderness it takes MUCH more time to move */
1994 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
1995 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
1997 /* Actually move the character */
1998 move_player(dir, pickup, FALSE);
2000 /* Allow more walking */
2004 /* Hack again -- Is there a special encounter ??? */
2005 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2007 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2010 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2012 /* Inform the player of his horrible fate :=) */
2013 msg_print(_("襲撃だ!", "You are ambushed !"));
2015 /* Go into large wilderness view */
2016 p_ptr->oldpy = randint1(MAX_HGT-2);
2017 p_ptr->oldpx = randint1(MAX_WID-2);
2020 /* Give first move to monsters */
2021 p_ptr->energy_use = 100;
2023 /* HACk -- set the encouter flag for the wilderness generation */
2024 generate_encounter = TRUE;
2028 /* Cancel repeat unless we may continue */
2029 if (!more) disturb(FALSE, FALSE);
2034 * @brief 「走る」動作コマンドのメインルーチン /
2038 void do_cmd_run(void)
2042 /* Hack -- no running when confused */
2043 if (p_ptr->confused)
2045 msg_print(_("混乱していて走れない!", "You are too confused!"));
2049 if (p_ptr->special_defense & KATA_MUSOU)
2051 set_action(ACTION_NONE);
2054 /* Get a "repeated" direction */
2055 if (get_rep_dir(&dir,FALSE))
2057 /* Hack -- Set the run counter */
2058 running = (command_arg ? command_arg : 1000);
2067 * @brief 「留まる」動作コマンドのメインルーチン /
2068 * Stay still. Search. Enter stores.
2069 * Pick up treasure if "pickup" is true.
2070 * @param pickup アイテムの自動拾いを行うならTRUE
2073 void do_cmd_stay(bool pickup)
2075 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2077 /* Allow repeated command */
2080 /* Set repeat count */
2081 command_rep = command_arg - 1;
2082 p_ptr->redraw |= (PR_STATE);
2084 /* Cancel the arg */
2088 p_ptr->energy_use = 100;
2090 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2091 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2096 * @brief 「休む」動作コマンドのメインルーチン /
2097 * Resting allows a player to safely restore his hp -RAK-
2100 void do_cmd_rest(void)
2103 set_action(ACTION_NONE);
2105 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2111 if (hex_spelling_any()) stop_hex_spell_all();
2113 /* Prompt for time if needed */
2114 if (command_arg <= 0)
2116 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2117 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2123 strcpy(out_val, "&");
2125 /* Ask for duration */
2126 if (!get_string(p, out_val, 4)) return;
2128 /* Rest until done */
2129 if (out_val[0] == '&')
2131 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2135 else if (out_val[0] == '*')
2137 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2143 command_arg = (COMMAND_ARG)atoi(out_val);
2144 if (command_arg <= 0) return;
2150 if (command_arg > 9999) command_arg = 9999;
2152 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2154 /* Take a turn (?) */
2155 p_ptr->energy_use = 100;
2157 /* The sin of sloth */
2158 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2160 /* Why are you sleeping when there's no need? WAKE UP!*/
2161 if ((p_ptr->chp == p_ptr->mhp) &&
2162 (p_ptr->csp == p_ptr->msp) &&
2163 !p_ptr->blind && !p_ptr->confused &&
2164 !p_ptr->poisoned && !p_ptr->afraid &&
2165 !p_ptr->stun && !p_ptr->cut &&
2166 !p_ptr->slow && !p_ptr->paralyzed &&
2167 !p_ptr->image && !p_ptr->word_recall &&
2168 !p_ptr->alter_reality)
2169 chg_virtue(V_DILIGENCE, -1);
2171 /* Save the rest code */
2172 resting = command_arg;
2173 p_ptr->action = ACTION_REST;
2174 p_ptr->update |= (PU_BONUS);
2175 update_creature(p_ptr);
2177 p_ptr->redraw |= (PR_STATE);
2186 * @brief 射撃処理のメインルーチン
2189 void do_cmd_fire(void)
2192 object_type *j_ptr, *ammo_ptr;
2195 if(p_ptr->wild_mode) return;
2197 is_fired = FALSE; /* not fired yet */
2199 /* Get the "bow" (if any) */
2200 j_ptr = &inventory[INVEN_BOW];
2202 /* Require a launcher */
2205 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2210 if (j_ptr->sval == SV_CRIMSON)
2212 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2217 if (j_ptr->sval == SV_HARP)
2219 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2225 if (p_ptr->special_defense & KATA_MUSOU)
2227 set_action(ACTION_NONE);
2230 /* Require proper missile */
2231 item_tester_tval = p_ptr->tval_ammo;
2233 q = _("どれを撃ちますか? ", "Fire which item? ");
2234 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2237 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2245 exe_fire(item, j_ptr);
2247 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2249 /* Sniper actions after some shootings */
2250 if (snipe_type == SP_AWAY)
2252 teleport_player(10 + (p_ptr->concent * 2), 0L);
2254 if (snipe_type == SP_FINAL)
2256 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2257 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2258 (void)set_stun(p_ptr->stun + randint1(25));
2264 * @brief 投射処理メインルーチン /
2265 * Throw an object from the pack or floor.
2267 * @param boomerang ブーメラン処理ならばTRUE
2268 * @param shuriken 忍者の手裏剣処理ならばTRUE
2269 * @return ターンを消費した場合TRUEを返す
2272 * Note: "unseen" monsters are very hard to hit.
2274 * Should throwing a weapon do full damage? Should it allow the magic
2275 * to hit bonus of the weapon to have an effect? Should it ever cause
2276 * the item to be destroyed? Should it do any damage at all?
2279 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2284 POSITION y, x, ty, tx, prev_y, prev_x;
2285 POSITION ny[19], nx[19];
2286 int chance, tdam, tdis;
2287 int mul, div, dd, ds;
2288 int cur_dis, visible;
2295 bool hit_body = FALSE;
2296 bool hit_wall = FALSE;
2297 bool equiped_item = FALSE;
2298 bool return_when_thrown = FALSE;
2300 GAME_TEXT o_name[MAX_NLEN];
2302 int msec = delay_factor * delay_factor * delay_factor;
2304 BIT_FLAGS flgs[TR_FLAG_SIZE];
2306 bool come_back = FALSE;
2307 bool do_drop = TRUE;
2309 if (p_ptr->wild_mode) return FALSE;
2311 if (p_ptr->special_defense & KATA_MUSOU)
2313 set_action(ACTION_NONE);
2319 o_ptr = &inventory[item];
2323 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2325 item_tester_hook = item_tester_hook_boomerang;
2326 q = _("どの武器を投げますか? ", "Throw which item? ");
2327 s = _("投げる武器がない。", "You have nothing to throw.");
2328 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2335 else if (has_melee_weapon(INVEN_LARM))
2338 o_ptr = &inventory[item];
2343 o_ptr = &inventory[item];
2348 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2349 s = _("投げるアイテムがない。", "You have nothing to throw.");
2350 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2358 /* Item is cursed */
2359 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2361 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2366 if (p_ptr->inside_arena && !boomerang)
2368 if (o_ptr->tval != TV_SPIKE)
2370 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2379 /* Obtain a local object */
2380 object_copy(q_ptr, o_ptr);
2382 /* Extract the thrown object's flags. */
2383 object_flags(q_ptr, flgs);
2384 torch_flags(q_ptr, flgs);
2386 /* Distribute the charges of rods/wands between the stacks */
2387 distribute_charges(o_ptr, q_ptr, 1);
2392 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2394 if (p_ptr->mighty_throw) mult += 3;
2396 /* Extract a "distance multiplier" */
2397 /* Changed for 'launcher' mutation */
2398 mul = 10 + 2 * (mult - 1);
2400 /* Enforce a minimum "weight" of one pound */
2401 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2402 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2404 /* Hack -- Distance -- Reward strength, penalize weight */
2405 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2407 /* Max distance of 10-18 */
2408 if (tdis > mul) tdis = mul;
2412 ty = randint0(101) - 50 + p_ptr->y;
2413 tx = randint0(101) - 50 + p_ptr->x;
2417 project_length = tdis + 1;
2419 /* Get a direction (or cancel) */
2420 if (!get_aim_dir(&dir)) return FALSE;
2422 /* Predict the "target" location */
2423 tx = p_ptr->x + 99 * ddx[dir];
2424 ty = p_ptr->y + 99 * ddy[dir];
2426 /* Check for "target request" */
2427 if ((dir == 5) && target_okay())
2433 project_length = 0; /* reset to default */
2436 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2437 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2438 return_when_thrown = TRUE;
2440 /* Reduce and describe inventory */
2443 inven_item_increase(item, -1);
2444 if (!return_when_thrown)
2445 inven_item_describe(item);
2446 inven_item_optimize(item);
2449 /* Reduce and describe floor item */
2452 floor_item_increase(0 - item, -1);
2453 floor_item_optimize(0 - item);
2455 if (item >= INVEN_RARM)
2457 equiped_item = TRUE;
2458 p_ptr->redraw |= (PR_EQUIPPY);
2461 p_ptr->energy_use = 100;
2463 /* Rogue and Ninja gets bonus */
2464 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2465 p_ptr->energy_use -= p_ptr->lev;
2467 /* Start at the player */
2473 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2474 else shuriken = FALSE;
2476 /* Chance of hitting */
2477 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2478 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2479 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2481 if (shuriken) chance *= 2;
2486 /* Travel until stopped */
2487 for (cur_dis = 0; cur_dis <= tdis; )
2489 /* Hack -- Stop at the target */
2490 if ((y == ty) && (x == tx)) break;
2492 /* Calculate the new location (see "project()") */
2495 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2497 /* Stopped by walls/doors */
2498 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2501 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2504 /* The player can see the (on screen) missile */
2505 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2507 SYMBOL_CODE c = object_char(q_ptr);
2508 TERM_COLOR a = object_attr(q_ptr);
2510 /* Draw, Hilite, Fresh, Pause, Erase */
2511 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2512 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2514 Term_xtra(TERM_XTRA_DELAY, msec);
2515 lite_spot(ny[cur_dis], nx[cur_dis]);
2519 /* The player cannot see the missile */
2522 /* Pause anyway, for consistancy */
2523 Term_xtra(TERM_XTRA_DELAY, msec);
2529 /* Save the new location */
2533 /* Advance the distance */
2536 /* Monster here, Try to hit it */
2537 if (cave[y][x].m_idx)
2539 cave_type *c_ptr = &cave[y][x];
2540 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2542 /* Check the visibility */
2543 visible = m_ptr->ml;
2545 /* Note the collision */
2548 /* Did we hit it (penalize range) */
2549 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2553 /* Handle unseen monster */
2556 /* Invisible monster */
2557 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2560 /* Handle visible monster */
2563 GAME_TEXT m_name[MAX_NLEN];
2564 monster_desc(m_name, m_ptr, 0);
2565 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2569 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2570 health_track(c_ptr->m_idx);
2574 /* Hack -- Base damage from thrown object */
2577 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2578 tdam = damroll(dd, ds);
2579 /* Apply special damage */
2580 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2581 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2582 if (q_ptr->to_d > 0)
2583 tdam += q_ptr->to_d;
2585 tdam += -q_ptr->to_d;
2589 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2590 tdam += p_ptr->to_d_m;
2592 else if (have_flag(flgs, TR_THROW))
2595 tdam += p_ptr->to_d_m;
2603 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2606 /* No negative damage */
2607 if (tdam < 0) tdam = 0;
2609 /* Modify the damage */
2610 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2612 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2613 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2615 /* Hit the monster, check for death */
2616 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2624 message_pain(c_ptr->m_idx, tdam);
2626 /* Anger the monster */
2627 if ((tdam > 0) && !object_is_potion(q_ptr))
2628 anger_monster(m_ptr);
2630 if (fear && m_ptr->ml)
2633 GAME_TEXT m_name[MAX_NLEN];
2634 monster_desc(m_name, m_ptr, 0);
2635 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2645 /* decrease toach's fuel */
2646 if (hit_body) torch_lost_fuel(q_ptr);
2648 /* Chance of breakage (during attacks) */
2649 j = (hit_body ? breakage_chance(q_ptr) : 0);
2651 /* Figurines transform */
2652 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2656 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2657 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2658 else if (object_is_cursed(q_ptr))
2659 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2664 /* Potions smash open */
2665 if (object_is_potion(q_ptr))
2667 if (hit_body || hit_wall || (randint1(100) < j))
2669 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2671 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2673 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
2675 /* ToDo (Robert): fix the invulnerability */
2676 if (cave[y][x].m_idx &&
2677 is_friendly(&m_list[cave[y][x].m_idx]) &&
2678 !MON_INVULNER(m_ptr))
2680 GAME_TEXT m_name[MAX_NLEN];
2681 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
2682 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2683 set_hostile(&m_list[cave[y][x].m_idx]);
2694 if (return_when_thrown)
2696 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2697 char o2_name[MAX_NLEN];
2698 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2701 if (boomerang) back_chance += 4+randint1(5);
2702 if (super_boomerang) back_chance += 100;
2703 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2705 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2707 for (i = cur_dis - 1; i > 0; i--)
2709 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2711 char c = object_char(q_ptr);
2712 byte a = object_attr(q_ptr);
2714 /* Draw, Hilite, Fresh, Pause, Erase */
2715 print_rel(c, a, ny[i], nx[i]);
2716 move_cursor_relative(ny[i], nx[i]);
2718 Term_xtra(TERM_XTRA_DELAY, msec);
2719 lite_spot(ny[i], nx[i]);
2724 /* Pause anyway, for consistancy */
2725 Term_xtra(TERM_XTRA_DELAY, msec);
2728 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2730 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2737 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2741 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2749 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2755 if (item == INVEN_RARM || item == INVEN_LARM)
2757 /* Access the wield slot */
2758 o_ptr = &inventory[item];
2760 /* Wear the new stuff */
2761 object_copy(o_ptr, q_ptr);
2763 p_ptr->total_weight += q_ptr->weight;
2765 /* Increment the equip counter by hand */
2768 /* Recalculate torch */
2769 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2770 p_ptr->window |= (PW_EQUIP);
2778 else if (equiped_item)
2786 if (cave_have_flag_bold(y, x, FF_PROJECT))
2788 (void)drop_near(q_ptr, j, y, x);
2792 (void)drop_near(q_ptr, j, prev_y, prev_x);
2802 * Hack: travel command
2804 #define TRAVEL_UNABLE 9999
2806 static int flow_head = 0;
2807 static int flow_tail = 0;
2808 static POSITION temp2_x[MAX_SHORT];
2809 static POSITION temp2_y[MAX_SHORT];
2812 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
2815 void forget_travel_flow(void)
2818 /* Check the entire dungeon / Forget the old data */
2819 for (y = 0; y < cur_hgt; y++)
2821 for (x = 0; x < cur_wid; x++)
2824 travel.cost[y][x] = MAX_SHORT;
2827 travel.y = travel.x = 0;
2831 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
2836 static int travel_flow_cost(POSITION y, POSITION x)
2838 feature_type *f_ptr = &f_info[cave[y][x].feat];
2841 /* Avoid obstacles (ex. trees) */
2842 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
2845 if (have_flag(f_ptr->flags, FF_WATER))
2847 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
2851 if (have_flag(f_ptr->flags, FF_LAVA))
2854 if (!p_ptr->resist_fire) lava *= 2;
2855 if (!p_ptr->levitation) lava *= 2;
2856 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
2861 /* Detected traps and doors */
2862 if (cave[y][x].info & (CAVE_MARK))
2864 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
2865 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
2872 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
2876 * @param wall プレイヤーが壁の中にいるならばTRUE
2879 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
2881 cave_type *c_ptr = &cave[y][x];
2882 feature_type *f_ptr = &f_info[c_ptr->feat];
2883 int old_head = flow_head;
2885 int base_cost = (n % TRAVEL_UNABLE);
2886 int from_wall = (n / TRAVEL_UNABLE);
2889 /* Ignore out of bounds */
2890 if (!in_bounds(y, x)) return;
2892 /* Ignore unknown grid except in wilderness */
2893 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
2895 /* Ignore "walls" and "rubble" (include "secret doors") */
2896 if (have_flag(f_ptr->flags, FF_WALL) ||
2897 have_flag(f_ptr->flags, FF_CAN_DIG) ||
2898 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
2899 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
2901 if (!wall || !from_wall) return;
2902 add_cost += TRAVEL_UNABLE;
2906 add_cost = travel_flow_cost(y, x);
2909 cost = base_cost + add_cost;
2911 /* Ignore lower cost entries */
2912 if (travel.cost[y][x] <= cost) return;
2914 /* Save the flow cost */
2915 travel.cost[y][x] = cost;
2917 /* Enqueue that entry */
2918 temp2_y[flow_head] = y;
2919 temp2_x[flow_head] = x;
2921 /* Advance the queue */
2922 if (++flow_head == MAX_SHORT) flow_head = 0;
2924 /* Hack -- notice overflow by forgetting new entry */
2925 if (flow_head == flow_tail) flow_head = old_head;
2931 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
2932 * @param ty 目標地点のY座標
2933 * @param tx 目標地点のX座標
2936 static void travel_flow(POSITION ty, POSITION tx)
2940 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
2942 /* Reset the "queue" */
2943 flow_head = flow_tail = 0;
2945 /* is player in the wall? */
2946 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
2948 /* Start at the target grid */
2949 travel_flow_aux(ty, tx, 0, wall);
2951 /* Now process the queue */
2952 while (flow_head != flow_tail)
2954 /* Extract the next entry */
2955 y = temp2_y[flow_tail];
2956 x = temp2_x[flow_tail];
2958 /* Forget that entry */
2959 if (++flow_tail == MAX_SHORT) flow_tail = 0;
2961 /* Ignore too far entries */
2962 //if (distance(ty, tx, y, x) > 100) continue;
2964 /* Add the "children" */
2965 for (d = 0; d < 8; d++)
2967 /* Add that child if "legal" */
2968 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
2972 /* Forget the flow info */
2973 flow_head = flow_tail = 0;
2977 * @brief トラベル処理のメインルーチン
2980 void do_cmd_travel(void)
2984 POSITION dx, dy, sx, sy;
2985 feature_type *f_ptr;
2987 if (travel.x != 0 && travel.y != 0 &&
2988 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
2993 else if (!tgt_pt(&x, &y)) return;
2995 if ((x == p_ptr->x) && (y == p_ptr->y))
2997 msg_print(_("すでにそこにいます!", "You are already there!!"));
3001 f_ptr = &f_info[cave[y][x].feat];
3003 if ((cave[y][x].info & CAVE_MARK) &&
3004 (have_flag(f_ptr->flags, FF_WALL) ||
3005 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3006 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3008 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3012 forget_travel_flow();
3018 /* Travel till 255 steps */
3024 /* Decides first direction */
3025 dx = abs(p_ptr->x - x);
3026 dy = abs(p_ptr->y - y);
3027 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3028 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3030 for (i = 1; i <= 9; i++)
3032 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;