3 * @brief プレイヤーのコマンド処理2 / Movement commands (part 2)
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
17 #include "object-hook.h"
18 #include "projection.h"
19 #include "spells-summon.h"
20 #include "spells-status.h"
21 #include "monster-status.h"
25 #include "player-status.h"
26 #include "realm-hex.h"
29 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
30 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
31 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
33 bool confirm_leave_level(bool down_stair)
35 quest_type *q_ptr = &quest[p_ptr->inside_quest];
37 /* Confirm leaving from once only quest */
38 if (confirm_quest && p_ptr->inside_quest &&
39 (q_ptr->type == QUEST_TYPE_RANDOM ||
40 (q_ptr->flags & QUEST_FLAG_ONCE &&
41 q_ptr->status != QUEST_STATUS_COMPLETED) ||
42 (q_ptr->flags & QUEST_FLAG_TOWER &&
43 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
44 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
46 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
47 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
57 * @brief 魔法系コマンドが制限されているかを返す。
58 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
60 bool cmd_limit_cast(player_type *creature_ptr)
62 if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
64 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
68 else if (creature_ptr->anti_magic)
70 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
73 else if (creature_ptr->shero)
75 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
82 bool cmd_limit_confused(player_type *creature_ptr)
84 if (creature_ptr->confused)
86 msg_print(_("混乱していてできない!", "You are too confused!"));
92 bool cmd_limit_arena(player_type *creature_ptr)
94 if (creature_ptr->inside_arena)
96 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
103 bool cmd_limit_time_walk(player_type *creature_ptr)
105 if (creature_ptr->timewalk)
107 if (flush_failure) flush();
108 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
116 * @brief 階段を使って階層を昇る処理 / Go up one level
119 void do_cmd_go_up(void)
124 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
125 feature_type *f_ptr = &f_info[c_ptr->feat];
129 if (p_ptr->special_defense & KATA_MUSOU)
131 set_action(ACTION_NONE);
135 if (!have_flag(f_ptr->flags, FF_LESS))
137 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
141 /* Quest up stairs */
142 if (have_flag(f_ptr->flags, FF_QUEST))
144 /* Cancel the command */
145 if (!confirm_leave_level(FALSE)) return;
149 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
150 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
152 msg_print(_("上の階に登った。", "You enter the up staircase."));
156 p_ptr->inside_quest = c_ptr->special;
158 /* Activate the quest */
159 if (!quest[p_ptr->inside_quest].status)
161 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
163 init_flags = INIT_ASSIGN;
164 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
166 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
169 /* Leaving a quest */
170 if (!p_ptr->inside_quest)
176 p_ptr->leaving = TRUE;
181 take_turn(p_ptr, 100);
183 /* End the command */
193 go_up = confirm_leave_level(FALSE);
196 /* Cancel the command */
199 take_turn(p_ptr, 100);
201 if (autosave_l) do_cmd_save_game(TRUE);
203 /* For a random quest */
204 if (p_ptr->inside_quest &&
205 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
209 p_ptr->inside_quest = 0;
212 /* For a fixed quest */
213 if (p_ptr->inside_quest &&
214 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
218 p_ptr->inside_quest = c_ptr->special;
223 /* For normal dungeon and random quest */
227 if (have_flag(f_ptr->flags, FF_SHAFT))
229 /* Create a way back */
230 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
236 /* Create a way back */
237 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
242 /* Get out from current dungeon */
243 if (dun_level - up_num < d_info[dungeon_type].mindepth)
246 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
249 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
250 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
251 else if (up_num == dun_level)
252 msg_print(_("地上に戻った。", "You go back to the surface."));
254 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
257 p_ptr->leaving = TRUE;
262 * @brief 階段を使って階層を降りる処理 / Go down one level
265 void do_cmd_go_down(void)
268 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
269 feature_type *f_ptr = &f_info[c_ptr->feat];
271 bool fall_trap = FALSE;
274 if (p_ptr->special_defense & KATA_MUSOU)
276 set_action(ACTION_NONE);
280 if (!have_flag(f_ptr->flags, FF_MORE))
282 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
286 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
289 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
294 /* Quest down stairs */
295 else if (have_flag(f_ptr->flags, FF_QUEST))
297 /* Confirm Leaving */
298 if(!confirm_leave_level(TRUE)) return;
300 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
301 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
303 msg_print(_("下の階に降りた。", "You enter the down staircase."));
308 p_ptr->inside_quest = c_ptr->special;
310 /* Activate the quest */
311 if (!quest[p_ptr->inside_quest].status)
313 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
315 init_flags = INIT_ASSIGN;
316 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
318 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
321 /* Leaving a quest */
322 if (!p_ptr->inside_quest)
328 p_ptr->leaving = TRUE;
332 take_turn(p_ptr, 100);
337 DUNGEON_IDX target_dungeon = 0;
341 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
343 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
345 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
348 if (!max_dlv[target_dungeon])
350 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
351 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
352 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
355 /* Save old player position */
356 p_ptr->oldpx = p_ptr->x;
357 p_ptr->oldpy = p_ptr->y;
358 dungeon_type = target_dungeon;
361 * Clear all saved floors
362 * and create a first saved floor
364 prepare_change_floor_mode(CFM_FIRST_FLOOR);
367 take_turn(p_ptr, 100);
369 if (autosave_l) do_cmd_save_game(TRUE);
372 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
377 /* Enter the dungeon just now */
378 p_ptr->enter_dungeon = TRUE;
379 down_num = d_info[dungeon_type].mindepth;
384 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
385 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
390 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
397 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
401 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
402 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
404 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
410 p_ptr->leaving = TRUE;
414 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
418 if (have_flag(f_ptr->flags, FF_SHAFT))
420 /* Create a way back */
421 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
425 /* Create a way back */
426 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
434 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
437 void do_cmd_search(void)
439 /* Allow repeated command */
442 /* Set repeat count */
443 command_rep = command_arg - 1;
444 p_ptr->redraw |= (PR_STATE);
449 take_turn(p_ptr, 100);;
457 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
458 * @param y 走査対象にしたいマスのY座標
459 * @param x 走査対象にしたいマスのX座標
460 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
461 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
463 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
465 cave_type *c_ptr = &cave[y][x];
466 OBJECT_IDX this_o_idx, next_o_idx = 0;
468 /* Scan all objects in the grid */
469 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
473 o_ptr = &o_list[this_o_idx];
474 next_o_idx = o_ptr->next_o_idx;
476 /* Skip unknown chests XXX XXX */
477 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
479 /* Check for non empty chest */
480 if ((o_ptr->tval == TV_CHEST) &&
481 (((!trapped) && (o_ptr->pval)) || /* non empty */
482 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
491 * @brief 箱を開けるコマンドのメインルーチン /
492 * Attempt to open the given chest at the given location
493 * @param y 箱の存在するマスのY座標
494 * @param x 箱の存在するマスのX座標
495 * @param o_idx 箱のオブジェクトID
496 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
498 * Assume there is no monster blocking the destination
500 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
505 object_type *o_ptr = &o_list[o_idx];
507 take_turn(p_ptr, 100);;
509 /* Attempt to unlock it */
512 /* Assume locked, and thus not open */
515 /* Get the "disarm" factor */
516 i = p_ptr->skill_dis;
518 /* Penalize some conditions */
519 if (p_ptr->blind || no_lite()) i = i / 10;
520 if (p_ptr->confused || p_ptr->image) i = i / 10;
522 /* Extract the difficulty */
525 /* Always have a small chance of success */
528 /* Success -- May still have traps */
529 if (randint0(100) < j)
531 msg_print(_("鍵をはずした。", "You have picked the lock."));
536 /* Failure -- Keep trying */
539 /* We may continue repeating */
541 if (flush_failure) flush();
542 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
547 /* Allowed to open */
550 /* Apply chest traps, if any */
551 chest_trap(y, x, o_idx);
553 /* Let the Chest drop items */
554 chest_death(FALSE, y, x, o_idx);
560 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
561 * Attempt to open the given chest at the given location
562 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
563 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
564 * @param test 地形条件を判定するための関数ポインタ
565 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
567 * @details Return the number of features around (or under) the character.
568 * Usually look for doors and floor traps.
570 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
572 int d, count, xx, yy;
574 /* Count how many matches */
577 /* Check around (and under) the character */
578 for (d = 0; d < 9; d++)
583 /* if not searching under player continue */
584 if ((d == 8) && !under) continue;
586 /* Extract adjacent (legal) location */
587 yy = p_ptr->y + ddy_ddd[d];
588 xx = p_ptr->x + ddx_ddd[d];
591 c_ptr = &cave[yy][xx];
593 /* Must have knowledge */
594 if (!(c_ptr->info & (CAVE_MARK))) continue;
596 /* Feature code (applying "mimic" field) */
597 feat = get_feat_mimic(c_ptr);
599 /* Not looking for this feature */
600 if (!((*test)(feat))) continue;
605 /* Remember the location. Only useful if only one match */
616 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
617 * Return the number of chests around (or under) the character.
618 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
619 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
620 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
623 * If requested, count only trapped chests.
625 static int count_chests(POSITION *y, POSITION *x, bool trapped)
632 /* Count how many matches */
635 /* Check around (and under) the character */
636 for (d = 0; d < 9; d++)
638 /* Extract adjacent (legal) location */
639 POSITION yy = p_ptr->y + ddy_ddd[d];
640 POSITION xx = p_ptr->x + ddx_ddd[d];
642 /* No (visible) chest is there */
643 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
645 /* Grab the object */
646 o_ptr = &o_list[o_idx];
649 if (o_ptr->pval == 0) continue;
651 /* No (known) traps here */
652 if (trapped && (!object_is_known(o_ptr) ||
653 !chest_traps[o_ptr->pval])) continue;
658 /* Remember the location. Only useful if only one match */
669 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
670 * Convert an adjacent location to a direction.
671 * @param y 方角を確認したY座標
672 * @param x 方角を確認したX座標
675 static DIRECTION coords_to_dir(POSITION y, POSITION x)
677 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
684 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
686 return d[dx + 1][dy + 1];
690 * @brief 「開ける」動作コマンドのサブルーチン /
691 * Perform the basic "open" command on doors
692 * @param y 対象を行うマスのY座標
693 * @param x 対象を行うマスのX座標
694 * @return 実際に処理が行われた場合TRUEを返す。
696 * Assume destination is a closed/locked/jammed door
697 * Assume there is no monster blocking the destination
698 * Returns TRUE if repeated commands may continue
700 static bool do_cmd_open_aux(POSITION y, POSITION x)
704 /* Get requested grid */
705 cave_type *c_ptr = &cave[y][x];
706 feature_type *f_ptr = &f_info[c_ptr->feat];
709 take_turn(p_ptr, 100);;
711 /* Seeing true feature code (ignore mimic) */
714 if (!have_flag(f_ptr->flags, FF_OPEN))
717 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
721 else if (f_ptr->power)
724 i = p_ptr->skill_dis;
726 /* Penalize some conditions */
727 if (p_ptr->blind || no_lite()) i = i / 10;
728 if (p_ptr->confused || p_ptr->image) i = i / 10;
730 /* Extract the lock power */
733 /* Extract the difficulty */
736 /* Always have a small chance of success */
740 if (randint0(100) < j)
742 msg_print(_("鍵をはずした。", "You have picked the lock."));
745 cave_alter_feat(y, x, FF_OPEN);
747 sound(SOUND_OPENDOOR);
757 if (flush_failure) flush();
759 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
761 /* We may keep trying */
770 cave_alter_feat(y, x, FF_OPEN);
772 sound(SOUND_OPENDOOR);
778 * @brief 「開ける」コマンドのメインルーチン /
779 * Open a closed/locked/jammed door or a closed/locked chest.
782 * Unlocking a locked door/chest is worth one experience point.
784 void do_cmd_open(void)
792 if (p_ptr->wild_mode) return;
794 if (p_ptr->special_defense & KATA_MUSOU)
796 set_action(ACTION_NONE);
799 /* Option: Pick a direction */
802 int num_doors, num_chests;
804 /* Count closed doors (locked or jammed) */
805 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
807 /* Count chests (locked) */
808 num_chests = count_chests(&y, &x, FALSE);
810 /* See if only one target */
811 if (num_doors || num_chests)
813 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
815 if (!too_many) command_dir = coords_to_dir(y, x);
819 /* Allow repeated command */
822 /* Set repeat count */
823 command_rep = command_arg - 1;
824 p_ptr->redraw |= (PR_STATE);
830 /* Get a "repeated" direction */
831 if (get_rep_dir(&dir, TRUE))
836 /* Get requested location */
837 y = p_ptr->y + ddy[dir];
838 x = p_ptr->x + ddx[dir];
840 /* Get requested grid */
843 /* Feature code (applying "mimic" field) */
844 feat = get_feat_mimic(c_ptr);
846 /* Check for chest */
847 o_idx = chest_check(y, x, FALSE);
850 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
852 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
855 /* Monster in the way */
856 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
858 take_turn(p_ptr, 100);;
859 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
867 more = do_cmd_open_chest(y, x, o_idx);
874 more = do_cmd_open_aux(y, x);
878 /* Cancel repeat unless we may continue */
879 if (!more) disturb(FALSE, FALSE);
885 * @brief 「閉じる」動作コマンドのサブルーチン /
886 * Perform the basic "close" command
887 * @param y 対象を行うマスのY座標
888 * @param x 対象を行うマスのX座標
889 * @return 実際に処理が行われた場合TRUEを返す。
891 * Assume destination is an open/broken door
892 * Assume there is no monster blocking the destination
893 * Returns TRUE if repeated commands may continue
895 static bool do_cmd_close_aux(POSITION y, POSITION x)
897 cave_type *c_ptr = &cave[y][x];
898 FEAT_IDX old_feat = c_ptr->feat;
901 take_turn(p_ptr, 100);;
903 /* Seeing true feature code (ignore mimic) */
906 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
908 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
910 /* Hack -- object in the way */
911 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
912 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
914 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
919 cave_alter_feat(y, x, FF_CLOSE);
922 if (old_feat == c_ptr->feat)
924 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
928 sound(SOUND_SHUTDOOR);
937 * @brief 「閉じる」コマンドのメインルーチン /
938 * Close an open door.
941 * Unlocking a locked door/chest is worth one experience point.
943 void do_cmd_close(void)
950 if (p_ptr->wild_mode) return;
952 if (p_ptr->special_defense & KATA_MUSOU)
954 set_action(ACTION_NONE);
957 /* Option: Pick a direction */
960 /* Count open doors */
961 if (count_dt(&y, &x, is_open, FALSE) == 1)
963 command_dir = coords_to_dir(y, x);
967 /* Allow repeated command */
970 /* Set repeat count */
971 command_rep = command_arg - 1;
972 p_ptr->redraw |= (PR_STATE);
978 /* Get a "repeated" direction */
979 if (get_rep_dir(&dir, FALSE))
984 y = p_ptr->y + ddy[dir];
985 x = p_ptr->x + ddx[dir];
988 /* Feature code (applying "mimic" field) */
989 feat = get_feat_mimic(c_ptr);
991 /* Require open/broken door */
992 if (!have_flag(f_info[feat].flags, FF_CLOSE))
994 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
997 /* Monster in the way */
998 else if (c_ptr->m_idx)
1000 take_turn(p_ptr, 100);;
1002 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1008 /* Close the door */
1011 /* Close the door */
1012 more = do_cmd_close_aux(y, x);
1016 /* Cancel repeat unless we may continue */
1017 if (!more) disturb(FALSE, FALSE);
1022 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1023 * Determine if a given grid may be "tunneled"
1024 * @param y 対象を行うマスのY座標
1025 * @param x 対象を行うマスのX座標
1028 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1030 cave_type *c_ptr = &cave[y][x];
1032 /* Must have knowledge */
1033 if (!(c_ptr->info & CAVE_MARK))
1035 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1040 /* Must be a wall/door/etc */
1041 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1043 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1053 * @brief 「掘る」動作コマンドのサブルーチン /
1054 * Perform the basic "tunnel" command
1055 * @param y 対象を行うマスのY座標
1056 * @param x 対象を行うマスのX座標
1057 * @return 実際に処理が行われた場合TRUEを返す。
1059 * Assumes that no monster is blocking the destination
1060 * Do not use twall anymore
1061 * Returns TRUE if repeated commands may continue
1063 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1066 feature_type *f_ptr, *mimic_f_ptr;
1071 /* Verify legality */
1072 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1074 take_turn(p_ptr, 100);;
1077 c_ptr = &cave[y][x];
1078 f_ptr = &f_info[c_ptr->feat];
1079 power = f_ptr->power;
1081 /* Feature code (applying "mimic" field) */
1082 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1084 name = f_name + mimic_f_ptr->name;
1088 if (have_flag(f_ptr->flags, FF_PERMANENT))
1091 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1093 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1096 /* Map border (mimiccing Permanent wall) */
1099 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1104 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1107 if (p_ptr->skill_dig > randint0(20 * power))
1109 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1111 /* Remove the feature */
1112 cave_alter_feat(y, x, FF_TUNNEL);
1114 /* Update some things */
1115 p_ptr->update |= (PU_FLOW);
1119 /* Message, keep digging */
1120 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1128 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1131 if (p_ptr->skill_dig > power + randint0(40 * power))
1133 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1136 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1137 p_ptr->update |= (PU_FLOW);
1140 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1142 /* Remove the feature */
1143 cave_alter_feat(y, x, FF_TUNNEL);
1145 chg_virtue(V_DILIGENCE, 1);
1146 chg_virtue(V_NATURE, -1);
1154 /* We may continue chopping */
1155 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1156 /* Occasional Search XXX XXX */
1157 if (randint0(100) < 25) search();
1161 /* We may continue tunelling */
1162 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1169 if (is_hidden_door(c_ptr))
1171 /* Occasional Search XXX XXX */
1172 if (randint0(100) < 25) search();
1179 * @brief 「掘る」動作コマンドのメインルーチン /
1180 * Tunnels through "walls" (including rubble and closed doors)
1184 * Note that you must tunnel in order to hit invisible monsters
1185 * in walls, though moving into walls still takes a turn anyway.
1187 * Digging is very difficult without a "digger" weapon, but can be
1188 * accomplished by strong players using heavy weapons.
1191 void do_cmd_tunnel(void)
1201 if (p_ptr->special_defense & KATA_MUSOU)
1203 set_action(ACTION_NONE);
1206 /* Allow repeated command */
1209 /* Set repeat count */
1210 command_rep = command_arg - 1;
1211 p_ptr->redraw |= (PR_STATE);
1213 /* Cancel the arg */
1217 /* Get a direction to tunnel, or Abort */
1218 if (get_rep_dir(&dir,FALSE))
1221 y = p_ptr->y + ddy[dir];
1222 x = p_ptr->x + ddx[dir];
1225 c_ptr = &cave[y][x];
1227 /* Feature code (applying "mimic" field) */
1228 feat = get_feat_mimic(c_ptr);
1230 /* No tunnelling through doors */
1231 if (have_flag(f_info[feat].flags, FF_DOOR))
1233 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1236 /* No tunnelling through most features */
1237 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1239 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1242 /* A monster is in the way */
1243 else if (c_ptr->m_idx)
1245 take_turn(p_ptr, 100);;
1247 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1256 /* Tunnel through walls */
1257 more = do_cmd_tunnel_aux(y, x);
1261 /* Cancel repetition unless we can continue */
1262 if (!more) disturb(FALSE, FALSE);
1266 * @brief 移動処理による簡易な「開く」処理 /
1268 * @return 開く処理が実際に試みられた場合TRUEを返す
1271 * If there is a jammed/closed/locked door at the given location,
1272 * then attempt to unlock/open it. Return TRUE if an attempt was
1273 * made (successful or not), otherwise return FALSE.
1275 * The code here should be nearly identical to that in
1276 * do_cmd_open_test() and do_cmd_open_aux().
1279 bool easy_open_door(POSITION y, POSITION x)
1283 cave_type *c_ptr = &cave[y][x];
1284 feature_type *f_ptr = &f_info[c_ptr->feat];
1286 /* Must be a closed door */
1287 if (!is_closed_door(c_ptr->feat))
1293 if (!have_flag(f_ptr->flags, FF_OPEN))
1296 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1301 else if (f_ptr->power)
1304 i = p_ptr->skill_dis;
1306 /* Penalize some conditions */
1307 if (p_ptr->blind || no_lite()) i = i / 10;
1308 if (p_ptr->confused || p_ptr->image) i = i / 10;
1310 /* Extract the lock power */
1313 /* Extract the difficulty */
1316 /* Always have a small chance of success */
1320 if (randint0(100) < j)
1322 msg_print(_("鍵をはずした。", "You have picked the lock."));
1325 cave_alter_feat(y, x, FF_OPEN);
1327 sound(SOUND_OPENDOOR);
1337 if (flush_failure) flush();
1339 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1348 cave_alter_feat(y, x, FF_OPEN);
1350 sound(SOUND_OPENDOOR);
1356 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1357 * Perform the basic "disarm" command
1358 * @param y 解除を行うマスのY座標
1359 * @param x 解除を行うマスのX座標
1360 * @param o_idx 箱のオブジェクトID
1361 * @return ターンを消費する処理が行われた場合TRUEを返す
1364 * Assume destination is a visible trap
1365 * Assume there is no monster blocking the destination
1366 * Returns TRUE if repeated commands may continue
1369 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1373 object_type *o_ptr = &o_list[o_idx];
1375 take_turn(p_ptr, 100);;
1377 /* Get the "disarm" factor */
1378 i = p_ptr->skill_dis;
1380 /* Penalize some conditions */
1381 if (p_ptr->blind || no_lite()) i = i / 10;
1382 if (p_ptr->confused || p_ptr->image) i = i / 10;
1384 /* Extract the difficulty */
1385 j = i - o_ptr->pval;
1387 /* Always have a small chance of success */
1390 /* Must find the trap first. */
1391 if (!object_is_known(o_ptr))
1393 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1397 /* Already disarmed/unlocked */
1398 else if (o_ptr->pval <= 0)
1400 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1403 /* No traps to find. */
1404 else if (!chest_traps[o_ptr->pval])
1406 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1409 /* Success (get a lot of experience) */
1410 else if (randint0(100) < j)
1412 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1413 gain_exp(o_ptr->pval);
1414 o_ptr->pval = (0 - o_ptr->pval);
1417 /* Failure -- Keep trying */
1418 else if ((i > 5) && (randint1(i) > 5))
1420 /* We may keep trying */
1422 if (flush_failure) flush();
1423 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1426 /* Failure -- Set off the trap */
1429 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1431 chest_trap(y, x, o_idx);
1438 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1439 * Perform the basic "disarm" command
1440 * @param y 解除を行うマスのY座標
1441 * @param x 解除を行うマスのX座標
1442 * @param dir プレイヤーからみた方向ID
1443 * @return ターンを消費する処理が行われた場合TRUEを返す
1446 * Assume destination is a visible trap
1447 * Assume there is no monster blocking the destination
1448 * Returns TRUE if repeated commands may continue
1452 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1454 cave_type *c_ptr = &cave[y][x];
1457 feature_type *f_ptr = &f_info[c_ptr->feat];
1459 /* Access trap name */
1460 concptr name = (f_name + f_ptr->name);
1462 /* Extract trap "power" */
1463 int power = f_ptr->power;
1466 /* Get the "disarm" factor */
1467 int i = p_ptr->skill_dis;
1470 take_turn(p_ptr, 100);;
1472 /* Penalize some conditions */
1473 if (p_ptr->blind || no_lite()) i = i / 10;
1474 if (p_ptr->confused || p_ptr->image) i = i / 10;
1476 /* Extract the difficulty */
1479 /* Always have a small chance of success */
1483 if (randint0(100) < j)
1485 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1490 /* Remove the trap */
1491 cave_alter_feat(y, x, FF_DISARM);
1493 /* Move the player onto the trap */
1494 move_player(dir, easy_disarm, FALSE);
1497 /* Failure -- Keep trying */
1498 else if ((i > 5) && (randint1(i) > 5))
1501 if (flush_failure) flush();
1503 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1505 /* We may keep trying */
1509 /* Failure -- Set off the trap */
1512 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1513 /* Move the player onto the trap */
1514 move_player(dir, easy_disarm, FALSE);
1521 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1522 * Disarms a trap, or chest
1525 void do_cmd_disarm(void)
1533 if (p_ptr->wild_mode) return;
1535 if (p_ptr->special_defense & KATA_MUSOU)
1537 set_action(ACTION_NONE);
1540 /* Option: Pick a direction */
1543 int num_traps, num_chests;
1545 /* Count visible traps */
1546 num_traps = count_dt(&y, &x, is_trap, TRUE);
1548 /* Count chests (trapped) */
1549 num_chests = count_chests(&y, &x, TRUE);
1551 /* See if only one target */
1552 if (num_traps || num_chests)
1554 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1555 if (!too_many) command_dir = coords_to_dir(y, x);
1560 /* Allow repeated command */
1563 /* Set repeat count */
1564 command_rep = command_arg - 1;
1565 p_ptr->redraw |= (PR_STATE);
1567 /* Cancel the arg */
1571 /* Get a direction (or abort) */
1572 if (get_rep_dir(&dir,TRUE))
1577 y = p_ptr->y + ddy[dir];
1578 x = p_ptr->x + ddx[dir];
1579 c_ptr = &cave[y][x];
1581 /* Feature code (applying "mimic" field) */
1582 feat = get_feat_mimic(c_ptr);
1584 /* Check for chests */
1585 o_idx = chest_check(y, x, TRUE);
1588 if (!is_trap(feat) && !o_idx)
1590 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1593 /* Monster in the way */
1594 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1596 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1605 more = do_cmd_disarm_chest(y, x, o_idx);
1611 more = do_cmd_disarm_aux(y, x, dir);
1615 /* Cancel repeat unless told not to */
1616 if (!more) disturb(FALSE, FALSE);
1621 * @brief 「打ち破る」動作コマンドのサブルーチン /
1622 * Perform the basic "bash" command
1623 * @param y 対象を行うマスのY座標
1624 * @param x 対象を行うマスのX座標
1625 * @param dir プレイヤーから見たターゲットの方角ID
1626 * @return 実際に処理が行われた場合TRUEを返す。
1629 * Assume destination is a closed/locked/jammed door
1630 * Assume there is no monster blocking the destination
1631 * Returns TRUE if repeated commands may continue
1634 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1637 cave_type *c_ptr = &cave[y][x];
1640 feature_type *f_ptr = &f_info[c_ptr->feat];
1642 /* Hack -- Bash power based on strength */
1643 /* (Ranges from 3 to 20 to 100 to 200) */
1644 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1646 /* Extract door power */
1647 int temp = f_ptr->power;
1651 concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1653 take_turn(p_ptr, 100);;
1655 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1657 /* Compare bash power to door power */
1658 temp = (bash - (temp * 10));
1660 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1662 /* Hack -- always have a chance */
1663 if (temp < 1) temp = 1;
1665 /* Hack -- attempt to bash down the door */
1666 if (randint0(100) < temp)
1668 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1670 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1672 /* Break down the door */
1673 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1675 cave_alter_feat(y, x, FF_BASH);
1681 cave_alter_feat(y, x, FF_OPEN);
1684 /* Hack -- Fall through the door */
1685 move_player(dir, FALSE, FALSE);
1688 /* Saving throw against stun */
1689 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1692 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1694 /* Allow repeated bashing */
1698 /* High dexterity yields coolness */
1701 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1703 /* Hack -- Lose balance ala paralysis */
1704 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1711 * @brief 「打ち破る」動作コマンドのメインルーチン /
1712 * Bash open a door, success based on character strength
1716 * For a closed door, pval is positive if locked; negative if stuck.
1718 * For an open door, pval is positive for a broken door.
1720 * A closed door can be opened - harder if locked. Any door might be
1721 * bashed open (and thereby broken). Bashing a door is (potentially)
1722 * faster! You move into the door way. To open a stuck door, it must
1723 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1725 * Creatures can also open or bash doors, see elsewhere.
1728 void do_cmd_bash(void)
1734 if (p_ptr->wild_mode) return;
1736 if (p_ptr->special_defense & KATA_MUSOU)
1738 set_action(ACTION_NONE);
1741 /* Allow repeated command */
1744 /* Set repeat count */
1745 command_rep = command_arg - 1;
1746 p_ptr->redraw |= (PR_STATE);
1748 /* Cancel the arg */
1752 /* Get a "repeated" direction */
1753 if (get_rep_dir(&dir,FALSE))
1758 y = p_ptr->y + ddy[dir];
1759 x = p_ptr->x + ddx[dir];
1762 c_ptr = &cave[y][x];
1764 /* Feature code (applying "mimic" field) */
1765 feat = get_feat_mimic(c_ptr);
1767 /* Nothing useful */
1768 if (!have_flag(f_info[feat].flags, FF_BASH))
1770 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1773 /* Monster in the way */
1774 else if (c_ptr->m_idx)
1776 take_turn(p_ptr, 100);;
1778 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1784 /* Bash a closed door */
1788 more = do_cmd_bash_aux(y, x, dir);
1792 /* Unless valid action taken, cancel bash */
1793 if (!more) disturb(FALSE, FALSE);
1798 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1802 * Manipulate an adjacent grid in some way
1804 * Attack monsters, tunnel through walls, disarm traps, open doors.
1806 * Consider confusion
1808 * This command must always take a turn, to prevent free detection
1809 * of invisible monsters.
1812 void do_cmd_alter(void)
1819 if (p_ptr->special_defense & KATA_MUSOU)
1821 set_action(ACTION_NONE);
1824 /* Allow repeated command */
1827 /* Set repeat count */
1828 command_rep = command_arg - 1;
1829 p_ptr->redraw |= (PR_STATE);
1831 /* Cancel the arg */
1835 /* Get a direction */
1836 if (get_rep_dir(&dir,TRUE))
1839 feature_type *f_ptr;
1841 y = p_ptr->y + ddy[dir];
1842 x = p_ptr->x + ddx[dir];
1845 c_ptr = &cave[y][x];
1847 /* Feature code (applying "mimic" field) */
1848 feat = get_feat_mimic(c_ptr);
1849 f_ptr = &f_info[feat];
1851 take_turn(p_ptr, 100);;
1859 else if (have_flag(f_ptr->flags, FF_OPEN))
1861 more = do_cmd_open_aux(y, x);
1864 /* Bash jammed doors */
1865 else if (have_flag(f_ptr->flags, FF_BASH))
1867 more = do_cmd_bash_aux(y, x, dir);
1870 /* Tunnel through walls */
1871 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1873 more = do_cmd_tunnel_aux(y, x);
1876 /* Close open doors */
1877 else if (have_flag(f_ptr->flags, FF_CLOSE))
1879 more = do_cmd_close_aux(y, x);
1883 else if (have_flag(f_ptr->flags, FF_DISARM))
1885 more = do_cmd_disarm_aux(y, x, dir);
1890 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1894 /* Cancel repetition unless we can continue */
1895 if (!more) disturb(FALSE, FALSE);
1901 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1902 * Find the index of some "spikes", if possible.
1903 * @param ip くさびとして打てるオブジェクトのID
1904 * @return オブジェクトがある場合TRUEを返す
1907 * Let user choose a pile of spikes, perhaps?
1910 static bool get_spike(INVENTORY_IDX *ip)
1914 /* Check every item in the pack */
1915 for (i = 0; i < INVEN_PACK; i++)
1917 object_type *o_ptr = &inventory[i];
1919 /* Skip non-objects */
1920 if (!o_ptr->k_idx) continue;
1922 /* Check the "tval" code */
1923 if (o_ptr->tval == TV_SPIKE)
1925 /* Save the spike index */
1938 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1939 * Jam a closed door with a spike
1943 * This command may NOT be repeated
1946 void do_cmd_spike(void)
1950 if (p_ptr->wild_mode) return;
1952 if (p_ptr->special_defense & KATA_MUSOU)
1954 set_action(ACTION_NONE);
1957 /* Get a "repeated" direction */
1958 if (get_rep_dir(&dir, FALSE))
1965 y = p_ptr->y + ddy[dir];
1966 x = p_ptr->x + ddx[dir];
1967 c_ptr = &cave[y][x];
1969 /* Feature code (applying "mimic" field) */
1970 feat = get_feat_mimic(c_ptr);
1972 /* Require closed door */
1973 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1975 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1979 else if (!get_spike(&item))
1981 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1984 /* Is a monster in the way? */
1985 else if (c_ptr->m_idx)
1987 take_turn(p_ptr, 100);;
1989 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1998 take_turn(p_ptr, 100);;
2000 /* Successful jamming */
2001 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2002 cave_alter_feat(y, x, FF_SPIKE);
2004 /* Use up, and describe, a single spike, from the bottom */
2005 inven_item_increase(item, -1);
2006 inven_item_describe(item);
2007 inven_item_optimize(item);
2015 * @brief 「歩く」動作コマンドのメインルーチン /
2016 * Support code for the "Walk" and "Jump" commands
2017 * @param pickup アイテムの自動拾いを行うならTRUE
2020 void do_cmd_walk(bool pickup)
2027 /* Allow repeated command */
2030 /* Set repeat count */
2031 command_rep = command_arg - 1;
2032 p_ptr->redraw |= (PR_STATE);
2034 /* Cancel the arg */
2038 /* Get a "repeated" direction */
2039 if (get_rep_dir(&dir, FALSE))
2041 take_turn(p_ptr, 100);;
2043 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2045 set_action(ACTION_NONE);
2048 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2049 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2050 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2052 /* Actually move the character */
2053 move_player(dir, pickup, FALSE);
2055 /* Allow more walking */
2059 /* Hack again -- Is there a special encounter ??? */
2060 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2062 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2065 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2067 /* Inform the player of his horrible fate :=) */
2068 msg_print(_("襲撃だ!", "You are ambushed !"));
2070 /* Go into large wilderness view */
2071 p_ptr->oldpy = randint1(MAX_HGT-2);
2072 p_ptr->oldpx = randint1(MAX_WID-2);
2075 /* Give first move to monsters */
2076 take_turn(p_ptr, 100);;
2078 /* HACk -- set the encouter flag for the wilderness generation */
2079 generate_encounter = TRUE;
2083 /* Cancel repeat unless we may continue */
2084 if (!more) disturb(FALSE, FALSE);
2089 * @brief 「走る」動作コマンドのメインルーチン /
2093 void do_cmd_run(void)
2096 if (cmd_limit_confused(p_ptr)) return;
2098 if (p_ptr->special_defense & KATA_MUSOU)
2100 set_action(ACTION_NONE);
2103 /* Get a "repeated" direction */
2104 if (get_rep_dir(&dir,FALSE))
2106 /* Hack -- Set the run counter */
2107 running = (command_arg ? command_arg : 1000);
2116 * @brief 「留まる」動作コマンドのメインルーチン /
2117 * Stay still. Search. Enter stores.
2118 * Pick up treasure if "pickup" is true.
2119 * @param pickup アイテムの自動拾いを行うならTRUE
2122 void do_cmd_stay(bool pickup)
2124 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2126 /* Allow repeated command */
2129 /* Set repeat count */
2130 command_rep = command_arg - 1;
2131 p_ptr->redraw |= (PR_STATE);
2133 /* Cancel the arg */
2137 take_turn(p_ptr, 100);;
2139 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2140 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2145 * @brief 「休む」動作コマンドのメインルーチン /
2146 * Resting allows a player to safely restore his hp -RAK-
2149 void do_cmd_rest(void)
2152 set_action(ACTION_NONE);
2154 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2160 if (hex_spelling_any()) stop_hex_spell_all();
2162 /* Prompt for time if needed */
2163 if (command_arg <= 0)
2165 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2166 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2172 strcpy(out_val, "&");
2174 /* Ask for duration */
2175 if (!get_string(p, out_val, 4)) return;
2177 /* Rest until done */
2178 if (out_val[0] == '&')
2180 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2184 else if (out_val[0] == '*')
2186 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2192 command_arg = (COMMAND_ARG)atoi(out_val);
2193 if (command_arg <= 0) return;
2199 if (command_arg > 9999) command_arg = 9999;
2201 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2203 /* Take a turn (?) */
2204 take_turn(p_ptr, 100);;
2206 /* The sin of sloth */
2207 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2209 /* Why are you sleeping when there's no need? WAKE UP!*/
2210 if ((p_ptr->chp == p_ptr->mhp) &&
2211 (p_ptr->csp == p_ptr->msp) &&
2212 !p_ptr->blind && !p_ptr->confused &&
2213 !p_ptr->poisoned && !p_ptr->afraid &&
2214 !p_ptr->stun && !p_ptr->cut &&
2215 !p_ptr->slow && !p_ptr->paralyzed &&
2216 !p_ptr->image && !p_ptr->word_recall &&
2217 !p_ptr->alter_reality)
2218 chg_virtue(V_DILIGENCE, -1);
2220 /* Save the rest code */
2221 resting = command_arg;
2222 p_ptr->action = ACTION_REST;
2223 p_ptr->update |= (PU_BONUS);
2224 update_creature(p_ptr);
2226 p_ptr->redraw |= (PR_STATE);
2235 * @brief 射撃処理のメインルーチン
2238 void do_cmd_fire(void)
2241 object_type *j_ptr, *ammo_ptr;
2244 if(p_ptr->wild_mode) return;
2246 is_fired = FALSE; /* not fired yet */
2248 /* Get the "bow" (if any) */
2249 j_ptr = &inventory[INVEN_BOW];
2251 /* Require a launcher */
2254 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2259 if (j_ptr->sval == SV_CRIMSON)
2261 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2266 if (j_ptr->sval == SV_HARP)
2268 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2274 if (p_ptr->special_defense & KATA_MUSOU)
2276 set_action(ACTION_NONE);
2279 /* Require proper missile */
2280 item_tester_tval = p_ptr->tval_ammo;
2282 q = _("どれを撃ちますか? ", "Fire which item? ");
2283 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2286 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2294 exe_fire(item, j_ptr);
2296 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2298 /* Sniper actions after some shootings */
2299 if (snipe_type == SP_AWAY)
2301 teleport_player(10 + (p_ptr->concent * 2), 0L);
2303 if (snipe_type == SP_FINAL)
2305 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2306 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2307 (void)set_stun(p_ptr->stun + randint1(25));
2313 * @brief 投射処理メインルーチン /
2314 * Throw an object from the pack or floor.
2316 * @param boomerang ブーメラン処理ならばTRUE
2317 * @param shuriken 忍者の手裏剣処理ならばTRUE
2318 * @return ターンを消費した場合TRUEを返す
2321 * Note: "unseen" monsters are very hard to hit.
2323 * Should throwing a weapon do full damage? Should it allow the magic
2324 * to hit bonus of the weapon to have an effect? Should it ever cause
2325 * the item to be destroyed? Should it do any damage at all?
2328 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2333 POSITION y, x, ty, tx, prev_y, prev_x;
2334 POSITION ny[19], nx[19];
2335 int chance, tdam, tdis;
2336 int mul, div, dd, ds;
2337 int cur_dis, visible;
2344 bool hit_body = FALSE;
2345 bool hit_wall = FALSE;
2346 bool equiped_item = FALSE;
2347 bool return_when_thrown = FALSE;
2349 GAME_TEXT o_name[MAX_NLEN];
2351 int msec = delay_factor * delay_factor * delay_factor;
2353 BIT_FLAGS flgs[TR_FLAG_SIZE];
2355 bool come_back = FALSE;
2356 bool do_drop = TRUE;
2358 if (p_ptr->wild_mode) return FALSE;
2360 if (p_ptr->special_defense & KATA_MUSOU)
2362 set_action(ACTION_NONE);
2368 o_ptr = &inventory[item];
2372 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2374 item_tester_hook = item_tester_hook_boomerang;
2375 q = _("どの武器を投げますか? ", "Throw which item? ");
2376 s = _("投げる武器がない。", "You have nothing to throw.");
2377 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2384 else if (has_melee_weapon(INVEN_LARM))
2387 o_ptr = &inventory[item];
2392 o_ptr = &inventory[item];
2397 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2398 s = _("投げるアイテムがない。", "You have nothing to throw.");
2399 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2407 /* Item is cursed */
2408 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2410 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2415 if (p_ptr->inside_arena && !boomerang)
2417 if (o_ptr->tval != TV_SPIKE)
2419 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2428 /* Obtain a local object */
2429 object_copy(q_ptr, o_ptr);
2431 /* Extract the thrown object's flags. */
2432 object_flags(q_ptr, flgs);
2433 torch_flags(q_ptr, flgs);
2435 /* Distribute the charges of rods/wands between the stacks */
2436 distribute_charges(o_ptr, q_ptr, 1);
2441 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2443 if (p_ptr->mighty_throw) mult += 3;
2445 /* Extract a "distance multiplier" */
2446 /* Changed for 'launcher' mutation */
2447 mul = 10 + 2 * (mult - 1);
2449 /* Enforce a minimum "weight" of one pound */
2450 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2451 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2453 /* Hack -- Distance -- Reward strength, penalize weight */
2454 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2456 /* Max distance of 10-18 */
2457 if (tdis > mul) tdis = mul;
2461 ty = randint0(101) - 50 + p_ptr->y;
2462 tx = randint0(101) - 50 + p_ptr->x;
2466 project_length = tdis + 1;
2468 /* Get a direction (or cancel) */
2469 if (!get_aim_dir(&dir)) return FALSE;
2471 /* Predict the "target" location */
2472 tx = p_ptr->x + 99 * ddx[dir];
2473 ty = p_ptr->y + 99 * ddy[dir];
2475 /* Check for "target request" */
2476 if ((dir == 5) && target_okay())
2482 project_length = 0; /* reset to default */
2485 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2486 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2487 return_when_thrown = TRUE;
2489 /* Reduce and describe inventory */
2492 inven_item_increase(item, -1);
2493 if (!return_when_thrown)
2494 inven_item_describe(item);
2495 inven_item_optimize(item);
2498 /* Reduce and describe floor item */
2501 floor_item_increase(0 - item, -1);
2502 floor_item_optimize(0 - item);
2504 if (item >= INVEN_RARM)
2506 equiped_item = TRUE;
2507 p_ptr->redraw |= (PR_EQUIPPY);
2510 take_turn(p_ptr, 100);;
2512 /* Rogue and Ninja gets bonus */
2513 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2514 p_ptr->energy_use -= p_ptr->lev;
2516 /* Start at the player */
2522 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2523 else shuriken = FALSE;
2525 /* Chance of hitting */
2526 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2527 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2528 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2530 if (shuriken) chance *= 2;
2535 /* Travel until stopped */
2536 for (cur_dis = 0; cur_dis <= tdis; )
2538 /* Hack -- Stop at the target */
2539 if ((y == ty) && (x == tx)) break;
2541 /* Calculate the new location (see "project()") */
2544 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2546 /* Stopped by walls/doors */
2547 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2550 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2553 /* The player can see the (on screen) missile */
2554 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2556 SYMBOL_CODE c = object_char(q_ptr);
2557 TERM_COLOR a = object_attr(q_ptr);
2559 /* Draw, Hilite, Fresh, Pause, Erase */
2560 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2561 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2563 Term_xtra(TERM_XTRA_DELAY, msec);
2564 lite_spot(ny[cur_dis], nx[cur_dis]);
2568 /* The player cannot see the missile */
2571 /* Pause anyway, for consistancy */
2572 Term_xtra(TERM_XTRA_DELAY, msec);
2578 /* Save the new location */
2582 /* Advance the distance */
2585 /* Monster here, Try to hit it */
2586 if (cave[y][x].m_idx)
2588 cave_type *c_ptr = &cave[y][x];
2589 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2591 /* Check the visibility */
2592 visible = m_ptr->ml;
2594 /* Note the collision */
2597 /* Did we hit it (penalize range) */
2598 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2602 /* Handle unseen monster */
2605 /* Invisible monster */
2606 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2609 /* Handle visible monster */
2612 GAME_TEXT m_name[MAX_NLEN];
2613 monster_desc(m_name, m_ptr, 0);
2614 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2618 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2619 health_track(c_ptr->m_idx);
2623 /* Hack -- Base damage from thrown object */
2626 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2627 tdam = damroll(dd, ds);
2628 /* Apply special damage */
2629 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2630 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2631 if (q_ptr->to_d > 0)
2632 tdam += q_ptr->to_d;
2634 tdam += -q_ptr->to_d;
2638 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2639 tdam += p_ptr->to_d_m;
2641 else if (have_flag(flgs, TR_THROW))
2644 tdam += p_ptr->to_d_m;
2652 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2655 /* No negative damage */
2656 if (tdam < 0) tdam = 0;
2658 /* Modify the damage */
2659 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2661 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2662 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2664 /* Hit the monster, check for death */
2665 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2673 message_pain(c_ptr->m_idx, tdam);
2675 /* Anger the monster */
2676 if ((tdam > 0) && !object_is_potion(q_ptr))
2677 anger_monster(m_ptr);
2679 if (fear && m_ptr->ml)
2682 GAME_TEXT m_name[MAX_NLEN];
2683 monster_desc(m_name, m_ptr, 0);
2684 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2694 /* decrease toach's fuel */
2695 if (hit_body) torch_lost_fuel(q_ptr);
2697 /* Chance of breakage (during attacks) */
2698 j = (hit_body ? breakage_chance(q_ptr) : 0);
2700 /* Figurines transform */
2701 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2705 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2706 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2707 else if (object_is_cursed(q_ptr))
2708 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2713 /* Potions smash open */
2714 if (object_is_potion(q_ptr))
2716 if (hit_body || hit_wall || (randint1(100) < j))
2718 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2720 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2722 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
2724 /* ToDo (Robert): fix the invulnerability */
2725 if (cave[y][x].m_idx &&
2726 is_friendly(&m_list[cave[y][x].m_idx]) &&
2727 !MON_INVULNER(m_ptr))
2729 GAME_TEXT m_name[MAX_NLEN];
2730 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
2731 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2732 set_hostile(&m_list[cave[y][x].m_idx]);
2743 if (return_when_thrown)
2745 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2746 char o2_name[MAX_NLEN];
2747 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2750 if (boomerang) back_chance += 4+randint1(5);
2751 if (super_boomerang) back_chance += 100;
2752 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2754 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2756 for (i = cur_dis - 1; i > 0; i--)
2758 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2760 char c = object_char(q_ptr);
2761 byte a = object_attr(q_ptr);
2763 /* Draw, Hilite, Fresh, Pause, Erase */
2764 print_rel(c, a, ny[i], nx[i]);
2765 move_cursor_relative(ny[i], nx[i]);
2767 Term_xtra(TERM_XTRA_DELAY, msec);
2768 lite_spot(ny[i], nx[i]);
2773 /* Pause anyway, for consistancy */
2774 Term_xtra(TERM_XTRA_DELAY, msec);
2777 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2779 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2786 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2790 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2798 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2804 if (item == INVEN_RARM || item == INVEN_LARM)
2806 /* Access the wield slot */
2807 o_ptr = &inventory[item];
2809 /* Wear the new stuff */
2810 object_copy(o_ptr, q_ptr);
2812 p_ptr->total_weight += q_ptr->weight;
2814 /* Increment the equip counter by hand */
2817 /* Recalculate torch */
2818 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2819 p_ptr->window |= (PW_EQUIP);
2827 else if (equiped_item)
2835 if (cave_have_flag_bold(y, x, FF_PROJECT))
2837 (void)drop_near(q_ptr, j, y, x);
2841 (void)drop_near(q_ptr, j, prev_y, prev_x);
2851 * Hack: travel command
2853 #define TRAVEL_UNABLE 9999
2855 static int flow_head = 0;
2856 static int flow_tail = 0;
2857 static POSITION temp2_x[MAX_SHORT];
2858 static POSITION temp2_y[MAX_SHORT];
2861 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
2864 void forget_travel_flow(void)
2867 /* Check the entire dungeon / Forget the old data */
2868 for (y = 0; y < cur_hgt; y++)
2870 for (x = 0; x < cur_wid; x++)
2873 travel.cost[y][x] = MAX_SHORT;
2876 travel.y = travel.x = 0;
2880 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
2885 static int travel_flow_cost(POSITION y, POSITION x)
2887 feature_type *f_ptr = &f_info[cave[y][x].feat];
2890 /* Avoid obstacles (ex. trees) */
2891 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
2894 if (have_flag(f_ptr->flags, FF_WATER))
2896 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
2900 if (have_flag(f_ptr->flags, FF_LAVA))
2903 if (!p_ptr->resist_fire) lava *= 2;
2904 if (!p_ptr->levitation) lava *= 2;
2905 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
2910 /* Detected traps and doors */
2911 if (cave[y][x].info & (CAVE_MARK))
2913 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
2914 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
2921 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
2925 * @param wall プレイヤーが壁の中にいるならばTRUE
2928 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
2930 cave_type *c_ptr = &cave[y][x];
2931 feature_type *f_ptr = &f_info[c_ptr->feat];
2932 int old_head = flow_head;
2934 int base_cost = (n % TRAVEL_UNABLE);
2935 int from_wall = (n / TRAVEL_UNABLE);
2938 /* Ignore out of bounds */
2939 if (!in_bounds(y, x)) return;
2941 /* Ignore unknown grid except in wilderness */
2942 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
2944 /* Ignore "walls" and "rubble" (include "secret doors") */
2945 if (have_flag(f_ptr->flags, FF_WALL) ||
2946 have_flag(f_ptr->flags, FF_CAN_DIG) ||
2947 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
2948 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
2950 if (!wall || !from_wall) return;
2951 add_cost += TRAVEL_UNABLE;
2955 add_cost = travel_flow_cost(y, x);
2958 cost = base_cost + add_cost;
2960 /* Ignore lower cost entries */
2961 if (travel.cost[y][x] <= cost) return;
2963 /* Save the flow cost */
2964 travel.cost[y][x] = cost;
2966 /* Enqueue that entry */
2967 temp2_y[flow_head] = y;
2968 temp2_x[flow_head] = x;
2970 /* Advance the queue */
2971 if (++flow_head == MAX_SHORT) flow_head = 0;
2973 /* Hack -- notice overflow by forgetting new entry */
2974 if (flow_head == flow_tail) flow_head = old_head;
2980 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
2981 * @param ty 目標地点のY座標
2982 * @param tx 目標地点のX座標
2985 static void travel_flow(POSITION ty, POSITION tx)
2989 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
2991 /* Reset the "queue" */
2992 flow_head = flow_tail = 0;
2994 /* is player in the wall? */
2995 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
2997 /* Start at the target grid */
2998 travel_flow_aux(ty, tx, 0, wall);
3000 /* Now process the queue */
3001 while (flow_head != flow_tail)
3003 /* Extract the next entry */
3004 y = temp2_y[flow_tail];
3005 x = temp2_x[flow_tail];
3007 /* Forget that entry */
3008 if (++flow_tail == MAX_SHORT) flow_tail = 0;
3010 /* Ignore too far entries */
3011 //if (distance(ty, tx, y, x) > 100) continue;
3013 /* Add the "children" */
3014 for (d = 0; d < 8; d++)
3016 /* Add that child if "legal" */
3017 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
3021 /* Forget the flow info */
3022 flow_head = flow_tail = 0;
3026 * @brief トラベル処理のメインルーチン
3029 void do_cmd_travel(void)
3033 POSITION dx, dy, sx, sy;
3034 feature_type *f_ptr;
3036 if (travel.x != 0 && travel.y != 0 &&
3037 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3042 else if (!tgt_pt(&x, &y)) return;
3044 if ((x == p_ptr->x) && (y == p_ptr->y))
3046 msg_print(_("すでにそこにいます!", "You are already there!!"));
3050 f_ptr = &f_info[cave[y][x].feat];
3052 if ((cave[y][x].info & CAVE_MARK) &&
3053 (have_flag(f_ptr->flags, FF_WALL) ||
3054 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3055 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3057 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3061 forget_travel_flow();
3067 /* Travel till 255 steps */
3073 /* Decides first direction */
3074 dx = abs(p_ptr->x - x);
3075 dy = abs(p_ptr->y - y);
3076 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3077 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3079 for (i = 1; i <= 9; i++)
3081 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;