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 (p_ptr->anti_magic)
70 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
73 else if (p_ptr->shero)
75 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
82 bool cmd_limit_confused(player_type *creature_ptr)
86 msg_print(_("混乱していてできない!", "You are too confused!"));
92 bool cmd_limit_arena(player_type *creature_ptr)
94 if (p_ptr->inside_arena)
96 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
103 bool cmd_limit_time_walk(player_type *creature_ptr)
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 /* Hack -- take a turn */
182 p_ptr->energy_use = 100;
184 /* End the command */
194 go_up = confirm_leave_level(FALSE);
197 /* Cancel the command */
200 /* Hack -- take a turn */
201 p_ptr->energy_use = 100;
203 if (autosave_l) do_cmd_save_game(TRUE);
205 /* For a random quest */
206 if (p_ptr->inside_quest &&
207 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
211 p_ptr->inside_quest = 0;
214 /* For a fixed quest */
215 if (p_ptr->inside_quest &&
216 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
220 p_ptr->inside_quest = c_ptr->special;
225 /* For normal dungeon and random quest */
229 if (have_flag(f_ptr->flags, FF_SHAFT))
231 /* Create a way back */
232 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
238 /* Create a way back */
239 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
244 /* Get out from current dungeon */
245 if (dun_level - up_num < d_info[dungeon_type].mindepth)
248 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
251 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
252 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
253 else if (up_num == dun_level)
254 msg_print(_("地上に戻った。", "You go back to the surface."));
256 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
259 p_ptr->leaving = TRUE;
264 * @brief 階段を使って階層を降りる処理 / Go down one level
267 void do_cmd_go_down(void)
270 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
271 feature_type *f_ptr = &f_info[c_ptr->feat];
273 bool fall_trap = FALSE;
276 if (p_ptr->special_defense & KATA_MUSOU)
278 set_action(ACTION_NONE);
282 if (!have_flag(f_ptr->flags, FF_MORE))
284 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
288 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
291 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
296 /* Quest down stairs */
297 else if (have_flag(f_ptr->flags, FF_QUEST))
299 /* Confirm Leaving */
300 if(!confirm_leave_level(TRUE)) return;
302 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
303 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
305 msg_print(_("下の階に降りた。", "You enter the down staircase."));
310 p_ptr->inside_quest = c_ptr->special;
312 /* Activate the quest */
313 if (!quest[p_ptr->inside_quest].status)
315 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
317 init_flags = INIT_ASSIGN;
318 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
320 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
323 /* Leaving a quest */
324 if (!p_ptr->inside_quest)
330 p_ptr->leaving = TRUE;
336 /* Hack -- take a turn */
337 p_ptr->energy_use = 100;
342 DUNGEON_IDX target_dungeon = 0;
346 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
348 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
350 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
353 if (!max_dlv[target_dungeon])
355 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
356 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
357 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
360 /* Save old player position */
361 p_ptr->oldpx = p_ptr->x;
362 p_ptr->oldpy = p_ptr->y;
363 dungeon_type = target_dungeon;
366 * Clear all saved floors
367 * and create a first saved floor
369 prepare_change_floor_mode(CFM_FIRST_FLOOR);
372 /* Hack -- take a turn */
373 p_ptr->energy_use = 100;
375 if (autosave_l) do_cmd_save_game(TRUE);
378 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
383 /* Enter the dungeon just now */
384 p_ptr->enter_dungeon = TRUE;
385 down_num = d_info[dungeon_type].mindepth;
390 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
391 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
396 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
403 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
407 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
408 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
410 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
416 p_ptr->leaving = TRUE;
420 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
424 if (have_flag(f_ptr->flags, FF_SHAFT))
426 /* Create a way back */
427 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
431 /* Create a way back */
432 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
440 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
443 void do_cmd_search(void)
445 /* Allow repeated command */
448 /* Set repeat count */
449 command_rep = command_arg - 1;
450 p_ptr->redraw |= (PR_STATE);
455 p_ptr->energy_use = 100;
463 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
464 * @param y 走査対象にしたいマスのY座標
465 * @param x 走査対象にしたいマスのX座標
466 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
467 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
469 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
471 cave_type *c_ptr = &cave[y][x];
472 OBJECT_IDX this_o_idx, next_o_idx = 0;
474 /* Scan all objects in the grid */
475 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
479 o_ptr = &o_list[this_o_idx];
480 next_o_idx = o_ptr->next_o_idx;
482 /* Skip unknown chests XXX XXX */
483 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
485 /* Check for non empty chest */
486 if ((o_ptr->tval == TV_CHEST) &&
487 (((!trapped) && (o_ptr->pval)) || /* non empty */
488 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
497 * @brief 箱を開けるコマンドのメインルーチン /
498 * Attempt to open the given chest at the given location
499 * @param y 箱の存在するマスのY座標
500 * @param x 箱の存在するマスのX座標
501 * @param o_idx 箱のオブジェクトID
502 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
504 * Assume there is no monster blocking the destination
506 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
511 object_type *o_ptr = &o_list[o_idx];
513 p_ptr->energy_use = 100;
515 /* Attempt to unlock it */
518 /* Assume locked, and thus not open */
521 /* Get the "disarm" factor */
522 i = p_ptr->skill_dis;
524 /* Penalize some conditions */
525 if (p_ptr->blind || no_lite()) i = i / 10;
526 if (p_ptr->confused || p_ptr->image) i = i / 10;
528 /* Extract the difficulty */
531 /* Always have a small chance of success */
534 /* Success -- May still have traps */
535 if (randint0(100) < j)
537 msg_print(_("鍵をはずした。", "You have picked the lock."));
542 /* Failure -- Keep trying */
545 /* We may continue repeating */
547 if (flush_failure) flush();
548 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
553 /* Allowed to open */
556 /* Apply chest traps, if any */
557 chest_trap(y, x, o_idx);
559 /* Let the Chest drop items */
560 chest_death(FALSE, y, x, o_idx);
566 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
567 * Attempt to open the given chest at the given location
568 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
569 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
570 * @param test 地形条件を判定するための関数ポインタ
571 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
573 * @details Return the number of features around (or under) the character.
574 * Usually look for doors and floor traps.
576 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
578 int d, count, xx, yy;
580 /* Count how many matches */
583 /* Check around (and under) the character */
584 for (d = 0; d < 9; d++)
589 /* if not searching under player continue */
590 if ((d == 8) && !under) continue;
592 /* Extract adjacent (legal) location */
593 yy = p_ptr->y + ddy_ddd[d];
594 xx = p_ptr->x + ddx_ddd[d];
597 c_ptr = &cave[yy][xx];
599 /* Must have knowledge */
600 if (!(c_ptr->info & (CAVE_MARK))) continue;
602 /* Feature code (applying "mimic" field) */
603 feat = get_feat_mimic(c_ptr);
605 /* Not looking for this feature */
606 if (!((*test)(feat))) continue;
611 /* Remember the location. Only useful if only one match */
622 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
623 * Return the number of chests around (or under) the character.
624 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
625 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
626 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
629 * If requested, count only trapped chests.
631 static int count_chests(POSITION *y, POSITION *x, bool trapped)
638 /* Count how many matches */
641 /* Check around (and under) the character */
642 for (d = 0; d < 9; d++)
644 /* Extract adjacent (legal) location */
645 POSITION yy = p_ptr->y + ddy_ddd[d];
646 POSITION xx = p_ptr->x + ddx_ddd[d];
648 /* No (visible) chest is there */
649 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
651 /* Grab the object */
652 o_ptr = &o_list[o_idx];
655 if (o_ptr->pval == 0) continue;
657 /* No (known) traps here */
658 if (trapped && (!object_is_known(o_ptr) ||
659 !chest_traps[o_ptr->pval])) continue;
664 /* Remember the location. Only useful if only one match */
675 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
676 * Convert an adjacent location to a direction.
677 * @param y 方角を確認したY座標
678 * @param x 方角を確認したX座標
681 static DIRECTION coords_to_dir(POSITION y, POSITION x)
683 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
690 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
692 return d[dx + 1][dy + 1];
696 * @brief 「開ける」動作コマンドのサブルーチン /
697 * Perform the basic "open" command on doors
698 * @param y 対象を行うマスのY座標
699 * @param x 対象を行うマスのX座標
700 * @return 実際に処理が行われた場合TRUEを返す。
702 * Assume destination is a closed/locked/jammed door
703 * Assume there is no monster blocking the destination
704 * Returns TRUE if repeated commands may continue
706 static bool do_cmd_open_aux(POSITION y, POSITION x)
710 /* Get requested grid */
711 cave_type *c_ptr = &cave[y][x];
712 feature_type *f_ptr = &f_info[c_ptr->feat];
715 p_ptr->energy_use = 100;
717 /* Seeing true feature code (ignore mimic) */
720 if (!have_flag(f_ptr->flags, FF_OPEN))
723 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
727 else if (f_ptr->power)
730 i = p_ptr->skill_dis;
732 /* Penalize some conditions */
733 if (p_ptr->blind || no_lite()) i = i / 10;
734 if (p_ptr->confused || p_ptr->image) i = i / 10;
736 /* Extract the lock power */
739 /* Extract the difficulty */
742 /* Always have a small chance of success */
746 if (randint0(100) < j)
748 msg_print(_("鍵をはずした。", "You have picked the lock."));
751 cave_alter_feat(y, x, FF_OPEN);
753 sound(SOUND_OPENDOOR);
763 if (flush_failure) flush();
765 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
767 /* We may keep trying */
776 cave_alter_feat(y, x, FF_OPEN);
778 sound(SOUND_OPENDOOR);
784 * @brief 「開ける」コマンドのメインルーチン /
785 * Open a closed/locked/jammed door or a closed/locked chest.
788 * Unlocking a locked door/chest is worth one experience point.
790 void do_cmd_open(void)
798 if (p_ptr->wild_mode) return;
800 if (p_ptr->special_defense & KATA_MUSOU)
802 set_action(ACTION_NONE);
805 /* Option: Pick a direction */
808 int num_doors, num_chests;
810 /* Count closed doors (locked or jammed) */
811 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
813 /* Count chests (locked) */
814 num_chests = count_chests(&y, &x, FALSE);
816 /* See if only one target */
817 if (num_doors || num_chests)
819 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
821 if (!too_many) command_dir = coords_to_dir(y, x);
825 /* Allow repeated command */
828 /* Set repeat count */
829 command_rep = command_arg - 1;
830 p_ptr->redraw |= (PR_STATE);
836 /* Get a "repeated" direction */
837 if (get_rep_dir(&dir, TRUE))
842 /* Get requested location */
843 y = p_ptr->y + ddy[dir];
844 x = p_ptr->x + ddx[dir];
846 /* Get requested grid */
849 /* Feature code (applying "mimic" field) */
850 feat = get_feat_mimic(c_ptr);
852 /* Check for chest */
853 o_idx = chest_check(y, x, FALSE);
856 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
858 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
861 /* Monster in the way */
862 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
864 p_ptr->energy_use = 100;
865 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
873 more = do_cmd_open_chest(y, x, o_idx);
880 more = do_cmd_open_aux(y, x);
884 /* Cancel repeat unless we may continue */
885 if (!more) disturb(FALSE, FALSE);
891 * @brief 「閉じる」動作コマンドのサブルーチン /
892 * Perform the basic "close" command
893 * @param y 対象を行うマスのY座標
894 * @param x 対象を行うマスのX座標
895 * @return 実際に処理が行われた場合TRUEを返す。
897 * Assume destination is an open/broken door
898 * Assume there is no monster blocking the destination
899 * Returns TRUE if repeated commands may continue
901 static bool do_cmd_close_aux(POSITION y, POSITION x)
903 cave_type *c_ptr = &cave[y][x];
904 FEAT_IDX old_feat = c_ptr->feat;
907 p_ptr->energy_use = 100;
909 /* Seeing true feature code (ignore mimic) */
912 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
914 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
916 /* Hack -- object in the way */
917 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
918 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
920 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
925 cave_alter_feat(y, x, FF_CLOSE);
928 if (old_feat == c_ptr->feat)
930 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
934 sound(SOUND_SHUTDOOR);
943 * @brief 「閉じる」コマンドのメインルーチン /
944 * Close an open door.
947 * Unlocking a locked door/chest is worth one experience point.
949 void do_cmd_close(void)
956 if (p_ptr->wild_mode) return;
958 if (p_ptr->special_defense & KATA_MUSOU)
960 set_action(ACTION_NONE);
963 /* Option: Pick a direction */
966 /* Count open doors */
967 if (count_dt(&y, &x, is_open, FALSE) == 1)
969 command_dir = coords_to_dir(y, x);
973 /* Allow repeated command */
976 /* Set repeat count */
977 command_rep = command_arg - 1;
978 p_ptr->redraw |= (PR_STATE);
984 /* Get a "repeated" direction */
985 if (get_rep_dir(&dir, FALSE))
990 y = p_ptr->y + ddy[dir];
991 x = p_ptr->x + ddx[dir];
994 /* Feature code (applying "mimic" field) */
995 feat = get_feat_mimic(c_ptr);
997 /* Require open/broken door */
998 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1000 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1003 /* Monster in the way */
1004 else if (c_ptr->m_idx)
1006 p_ptr->energy_use = 100;
1008 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1014 /* Close the door */
1017 /* Close the door */
1018 more = do_cmd_close_aux(y, x);
1022 /* Cancel repeat unless we may continue */
1023 if (!more) disturb(FALSE, FALSE);
1028 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1029 * Determine if a given grid may be "tunneled"
1030 * @param y 対象を行うマスのY座標
1031 * @param x 対象を行うマスのX座標
1034 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1036 cave_type *c_ptr = &cave[y][x];
1038 /* Must have knowledge */
1039 if (!(c_ptr->info & CAVE_MARK))
1041 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1046 /* Must be a wall/door/etc */
1047 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1049 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1059 * @brief 「掘る」動作コマンドのサブルーチン /
1060 * Perform the basic "tunnel" command
1061 * @param y 対象を行うマスのY座標
1062 * @param x 対象を行うマスのX座標
1063 * @return 実際に処理が行われた場合TRUEを返す。
1065 * Assumes that no monster is blocking the destination
1066 * Do not use twall anymore
1067 * Returns TRUE if repeated commands may continue
1069 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1072 feature_type *f_ptr, *mimic_f_ptr;
1077 /* Verify legality */
1078 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1080 p_ptr->energy_use = 100;
1083 c_ptr = &cave[y][x];
1084 f_ptr = &f_info[c_ptr->feat];
1085 power = f_ptr->power;
1087 /* Feature code (applying "mimic" field) */
1088 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1090 name = f_name + mimic_f_ptr->name;
1094 if (have_flag(f_ptr->flags, FF_PERMANENT))
1097 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1099 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1102 /* Map border (mimiccing Permanent wall) */
1105 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1110 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1113 if (p_ptr->skill_dig > randint0(20 * power))
1115 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1117 /* Remove the feature */
1118 cave_alter_feat(y, x, FF_TUNNEL);
1120 /* Update some things */
1121 p_ptr->update |= (PU_FLOW);
1125 /* Message, keep digging */
1126 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1134 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1137 if (p_ptr->skill_dig > power + randint0(40 * power))
1139 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1142 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1143 p_ptr->update |= (PU_FLOW);
1146 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1148 /* Remove the feature */
1149 cave_alter_feat(y, x, FF_TUNNEL);
1151 chg_virtue(V_DILIGENCE, 1);
1152 chg_virtue(V_NATURE, -1);
1160 /* We may continue chopping */
1161 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1162 /* Occasional Search XXX XXX */
1163 if (randint0(100) < 25) search();
1167 /* We may continue tunelling */
1168 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1175 if (is_hidden_door(c_ptr))
1177 /* Occasional Search XXX XXX */
1178 if (randint0(100) < 25) search();
1185 * @brief 「掘る」動作コマンドのメインルーチン /
1186 * Tunnels through "walls" (including rubble and closed doors)
1190 * Note that you must tunnel in order to hit invisible monsters
1191 * in walls, though moving into walls still takes a turn anyway.
1193 * Digging is very difficult without a "digger" weapon, but can be
1194 * accomplished by strong players using heavy weapons.
1197 void do_cmd_tunnel(void)
1207 if (p_ptr->special_defense & KATA_MUSOU)
1209 set_action(ACTION_NONE);
1212 /* Allow repeated command */
1215 /* Set repeat count */
1216 command_rep = command_arg - 1;
1217 p_ptr->redraw |= (PR_STATE);
1219 /* Cancel the arg */
1223 /* Get a direction to tunnel, or Abort */
1224 if (get_rep_dir(&dir,FALSE))
1227 y = p_ptr->y + ddy[dir];
1228 x = p_ptr->x + ddx[dir];
1231 c_ptr = &cave[y][x];
1233 /* Feature code (applying "mimic" field) */
1234 feat = get_feat_mimic(c_ptr);
1236 /* No tunnelling through doors */
1237 if (have_flag(f_info[feat].flags, FF_DOOR))
1239 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1242 /* No tunnelling through most features */
1243 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1245 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1248 /* A monster is in the way */
1249 else if (c_ptr->m_idx)
1251 p_ptr->energy_use = 100;
1253 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1262 /* Tunnel through walls */
1263 more = do_cmd_tunnel_aux(y, x);
1267 /* Cancel repetition unless we can continue */
1268 if (!more) disturb(FALSE, FALSE);
1272 * @brief 移動処理による簡易な「開く」処理 /
1274 * @return 開く処理が実際に試みられた場合TRUEを返す
1277 * If there is a jammed/closed/locked door at the given location,
1278 * then attempt to unlock/open it. Return TRUE if an attempt was
1279 * made (successful or not), otherwise return FALSE.
1281 * The code here should be nearly identical to that in
1282 * do_cmd_open_test() and do_cmd_open_aux().
1285 bool easy_open_door(POSITION y, POSITION x)
1289 cave_type *c_ptr = &cave[y][x];
1290 feature_type *f_ptr = &f_info[c_ptr->feat];
1292 /* Must be a closed door */
1293 if (!is_closed_door(c_ptr->feat))
1299 if (!have_flag(f_ptr->flags, FF_OPEN))
1302 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1307 else if (f_ptr->power)
1310 i = p_ptr->skill_dis;
1312 /* Penalize some conditions */
1313 if (p_ptr->blind || no_lite()) i = i / 10;
1314 if (p_ptr->confused || p_ptr->image) i = i / 10;
1316 /* Extract the lock power */
1319 /* Extract the difficulty */
1322 /* Always have a small chance of success */
1326 if (randint0(100) < j)
1328 msg_print(_("鍵をはずした。", "You have picked the lock."));
1331 cave_alter_feat(y, x, FF_OPEN);
1333 sound(SOUND_OPENDOOR);
1343 if (flush_failure) flush();
1345 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1354 cave_alter_feat(y, x, FF_OPEN);
1356 sound(SOUND_OPENDOOR);
1362 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1363 * Perform the basic "disarm" command
1364 * @param y 解除を行うマスのY座標
1365 * @param x 解除を行うマスのX座標
1366 * @param o_idx 箱のオブジェクトID
1367 * @return ターンを消費する処理が行われた場合TRUEを返す
1370 * Assume destination is a visible trap
1371 * Assume there is no monster blocking the destination
1372 * Returns TRUE if repeated commands may continue
1375 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1379 object_type *o_ptr = &o_list[o_idx];
1381 p_ptr->energy_use = 100;
1383 /* Get the "disarm" factor */
1384 i = p_ptr->skill_dis;
1386 /* Penalize some conditions */
1387 if (p_ptr->blind || no_lite()) i = i / 10;
1388 if (p_ptr->confused || p_ptr->image) i = i / 10;
1390 /* Extract the difficulty */
1391 j = i - o_ptr->pval;
1393 /* Always have a small chance of success */
1396 /* Must find the trap first. */
1397 if (!object_is_known(o_ptr))
1399 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1403 /* Already disarmed/unlocked */
1404 else if (o_ptr->pval <= 0)
1406 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1409 /* No traps to find. */
1410 else if (!chest_traps[o_ptr->pval])
1412 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1415 /* Success (get a lot of experience) */
1416 else if (randint0(100) < j)
1418 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1419 gain_exp(o_ptr->pval);
1420 o_ptr->pval = (0 - o_ptr->pval);
1423 /* Failure -- Keep trying */
1424 else if ((i > 5) && (randint1(i) > 5))
1426 /* We may keep trying */
1428 if (flush_failure) flush();
1429 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1432 /* Failure -- Set off the trap */
1435 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1437 chest_trap(y, x, o_idx);
1444 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1445 * Perform the basic "disarm" command
1446 * @param y 解除を行うマスのY座標
1447 * @param x 解除を行うマスのX座標
1448 * @param dir プレイヤーからみた方向ID
1449 * @return ターンを消費する処理が行われた場合TRUEを返す
1452 * Assume destination is a visible trap
1453 * Assume there is no monster blocking the destination
1454 * Returns TRUE if repeated commands may continue
1458 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1460 cave_type *c_ptr = &cave[y][x];
1463 feature_type *f_ptr = &f_info[c_ptr->feat];
1465 /* Access trap name */
1466 concptr name = (f_name + f_ptr->name);
1468 /* Extract trap "power" */
1469 int power = f_ptr->power;
1472 /* Get the "disarm" factor */
1473 int i = p_ptr->skill_dis;
1476 p_ptr->energy_use = 100;
1478 /* Penalize some conditions */
1479 if (p_ptr->blind || no_lite()) i = i / 10;
1480 if (p_ptr->confused || p_ptr->image) i = i / 10;
1482 /* Extract the difficulty */
1485 /* Always have a small chance of success */
1489 if (randint0(100) < j)
1491 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1496 /* Remove the trap */
1497 cave_alter_feat(y, x, FF_DISARM);
1499 /* Move the player onto the trap */
1500 move_player(dir, easy_disarm, FALSE);
1503 /* Failure -- Keep trying */
1504 else if ((i > 5) && (randint1(i) > 5))
1507 if (flush_failure) flush();
1509 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1511 /* We may keep trying */
1515 /* Failure -- Set off the trap */
1518 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1519 /* Move the player onto the trap */
1520 move_player(dir, easy_disarm, FALSE);
1527 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1528 * Disarms a trap, or chest
1531 void do_cmd_disarm(void)
1539 if (p_ptr->wild_mode) return;
1541 if (p_ptr->special_defense & KATA_MUSOU)
1543 set_action(ACTION_NONE);
1546 /* Option: Pick a direction */
1549 int num_traps, num_chests;
1551 /* Count visible traps */
1552 num_traps = count_dt(&y, &x, is_trap, TRUE);
1554 /* Count chests (trapped) */
1555 num_chests = count_chests(&y, &x, TRUE);
1557 /* See if only one target */
1558 if (num_traps || num_chests)
1560 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1561 if (!too_many) command_dir = coords_to_dir(y, x);
1566 /* Allow repeated command */
1569 /* Set repeat count */
1570 command_rep = command_arg - 1;
1571 p_ptr->redraw |= (PR_STATE);
1573 /* Cancel the arg */
1577 /* Get a direction (or abort) */
1578 if (get_rep_dir(&dir,TRUE))
1583 y = p_ptr->y + ddy[dir];
1584 x = p_ptr->x + ddx[dir];
1585 c_ptr = &cave[y][x];
1587 /* Feature code (applying "mimic" field) */
1588 feat = get_feat_mimic(c_ptr);
1590 /* Check for chests */
1591 o_idx = chest_check(y, x, TRUE);
1594 if (!is_trap(feat) && !o_idx)
1596 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1599 /* Monster in the way */
1600 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1602 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1611 more = do_cmd_disarm_chest(y, x, o_idx);
1617 more = do_cmd_disarm_aux(y, x, dir);
1621 /* Cancel repeat unless told not to */
1622 if (!more) disturb(FALSE, FALSE);
1627 * @brief 「打ち破る」動作コマンドのサブルーチン /
1628 * Perform the basic "bash" command
1629 * @param y 対象を行うマスのY座標
1630 * @param x 対象を行うマスのX座標
1631 * @param dir プレイヤーから見たターゲットの方角ID
1632 * @return 実際に処理が行われた場合TRUEを返す。
1635 * Assume destination is a closed/locked/jammed door
1636 * Assume there is no monster blocking the destination
1637 * Returns TRUE if repeated commands may continue
1640 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1643 cave_type *c_ptr = &cave[y][x];
1646 feature_type *f_ptr = &f_info[c_ptr->feat];
1648 /* Hack -- Bash power based on strength */
1649 /* (Ranges from 3 to 20 to 100 to 200) */
1650 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1652 /* Extract door power */
1653 int temp = f_ptr->power;
1657 concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1659 p_ptr->energy_use = 100;
1661 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1663 /* Compare bash power to door power */
1664 temp = (bash - (temp * 10));
1666 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1668 /* Hack -- always have a chance */
1669 if (temp < 1) temp = 1;
1671 /* Hack -- attempt to bash down the door */
1672 if (randint0(100) < temp)
1674 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1676 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1678 /* Break down the door */
1679 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1681 cave_alter_feat(y, x, FF_BASH);
1687 cave_alter_feat(y, x, FF_OPEN);
1690 /* Hack -- Fall through the door */
1691 move_player(dir, FALSE, FALSE);
1694 /* Saving throw against stun */
1695 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1698 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1700 /* Allow repeated bashing */
1704 /* High dexterity yields coolness */
1707 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1709 /* Hack -- Lose balance ala paralysis */
1710 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1717 * @brief 「打ち破る」動作コマンドのメインルーチン /
1718 * Bash open a door, success based on character strength
1722 * For a closed door, pval is positive if locked; negative if stuck.
1724 * For an open door, pval is positive for a broken door.
1726 * A closed door can be opened - harder if locked. Any door might be
1727 * bashed open (and thereby broken). Bashing a door is (potentially)
1728 * faster! You move into the door way. To open a stuck door, it must
1729 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1731 * Creatures can also open or bash doors, see elsewhere.
1734 void do_cmd_bash(void)
1740 if (p_ptr->wild_mode) return;
1742 if (p_ptr->special_defense & KATA_MUSOU)
1744 set_action(ACTION_NONE);
1747 /* Allow repeated command */
1750 /* Set repeat count */
1751 command_rep = command_arg - 1;
1752 p_ptr->redraw |= (PR_STATE);
1754 /* Cancel the arg */
1758 /* Get a "repeated" direction */
1759 if (get_rep_dir(&dir,FALSE))
1764 y = p_ptr->y + ddy[dir];
1765 x = p_ptr->x + ddx[dir];
1768 c_ptr = &cave[y][x];
1770 /* Feature code (applying "mimic" field) */
1771 feat = get_feat_mimic(c_ptr);
1773 /* Nothing useful */
1774 if (!have_flag(f_info[feat].flags, FF_BASH))
1776 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1779 /* Monster in the way */
1780 else if (c_ptr->m_idx)
1782 p_ptr->energy_use = 100;
1784 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1790 /* Bash a closed door */
1794 more = do_cmd_bash_aux(y, x, dir);
1798 /* Unless valid action taken, cancel bash */
1799 if (!more) disturb(FALSE, FALSE);
1804 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1808 * Manipulate an adjacent grid in some way
1810 * Attack monsters, tunnel through walls, disarm traps, open doors.
1812 * Consider confusion
1814 * This command must always take a turn, to prevent free detection
1815 * of invisible monsters.
1818 void do_cmd_alter(void)
1825 if (p_ptr->special_defense & KATA_MUSOU)
1827 set_action(ACTION_NONE);
1830 /* Allow repeated command */
1833 /* Set repeat count */
1834 command_rep = command_arg - 1;
1835 p_ptr->redraw |= (PR_STATE);
1837 /* Cancel the arg */
1841 /* Get a direction */
1842 if (get_rep_dir(&dir,TRUE))
1845 feature_type *f_ptr;
1847 y = p_ptr->y + ddy[dir];
1848 x = p_ptr->x + ddx[dir];
1851 c_ptr = &cave[y][x];
1853 /* Feature code (applying "mimic" field) */
1854 feat = get_feat_mimic(c_ptr);
1855 f_ptr = &f_info[feat];
1857 p_ptr->energy_use = 100;
1865 else if (have_flag(f_ptr->flags, FF_OPEN))
1867 more = do_cmd_open_aux(y, x);
1870 /* Bash jammed doors */
1871 else if (have_flag(f_ptr->flags, FF_BASH))
1873 more = do_cmd_bash_aux(y, x, dir);
1876 /* Tunnel through walls */
1877 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1879 more = do_cmd_tunnel_aux(y, x);
1882 /* Close open doors */
1883 else if (have_flag(f_ptr->flags, FF_CLOSE))
1885 more = do_cmd_close_aux(y, x);
1889 else if (have_flag(f_ptr->flags, FF_DISARM))
1891 more = do_cmd_disarm_aux(y, x, dir);
1896 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1900 /* Cancel repetition unless we can continue */
1901 if (!more) disturb(FALSE, FALSE);
1907 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1908 * Find the index of some "spikes", if possible.
1909 * @param ip くさびとして打てるオブジェクトのID
1910 * @return オブジェクトがある場合TRUEを返す
1913 * Let user choose a pile of spikes, perhaps?
1916 static bool get_spike(INVENTORY_IDX *ip)
1920 /* Check every item in the pack */
1921 for (i = 0; i < INVEN_PACK; i++)
1923 object_type *o_ptr = &inventory[i];
1925 /* Skip non-objects */
1926 if (!o_ptr->k_idx) continue;
1928 /* Check the "tval" code */
1929 if (o_ptr->tval == TV_SPIKE)
1931 /* Save the spike index */
1944 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1945 * Jam a closed door with a spike
1949 * This command may NOT be repeated
1952 void do_cmd_spike(void)
1956 if (p_ptr->wild_mode) return;
1958 if (p_ptr->special_defense & KATA_MUSOU)
1960 set_action(ACTION_NONE);
1963 /* Get a "repeated" direction */
1964 if (get_rep_dir(&dir, FALSE))
1971 y = p_ptr->y + ddy[dir];
1972 x = p_ptr->x + ddx[dir];
1973 c_ptr = &cave[y][x];
1975 /* Feature code (applying "mimic" field) */
1976 feat = get_feat_mimic(c_ptr);
1978 /* Require closed door */
1979 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1981 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1985 else if (!get_spike(&item))
1987 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1990 /* Is a monster in the way? */
1991 else if (c_ptr->m_idx)
1993 p_ptr->energy_use = 100;
1995 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2004 p_ptr->energy_use = 100;
2006 /* Successful jamming */
2007 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2008 cave_alter_feat(y, x, FF_SPIKE);
2010 /* Use up, and describe, a single spike, from the bottom */
2011 inven_item_increase(item, -1);
2012 inven_item_describe(item);
2013 inven_item_optimize(item);
2021 * @brief 「歩く」動作コマンドのメインルーチン /
2022 * Support code for the "Walk" and "Jump" commands
2023 * @param pickup アイテムの自動拾いを行うならTRUE
2026 void do_cmd_walk(bool pickup)
2033 /* Allow repeated command */
2036 /* Set repeat count */
2037 command_rep = command_arg - 1;
2038 p_ptr->redraw |= (PR_STATE);
2040 /* Cancel the arg */
2044 /* Get a "repeated" direction */
2045 if (get_rep_dir(&dir, FALSE))
2047 p_ptr->energy_use = 100;
2049 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2051 set_action(ACTION_NONE);
2054 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2055 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2056 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2058 /* Actually move the character */
2059 move_player(dir, pickup, FALSE);
2061 /* Allow more walking */
2065 /* Hack again -- Is there a special encounter ??? */
2066 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2068 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2071 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2073 /* Inform the player of his horrible fate :=) */
2074 msg_print(_("襲撃だ!", "You are ambushed !"));
2076 /* Go into large wilderness view */
2077 p_ptr->oldpy = randint1(MAX_HGT-2);
2078 p_ptr->oldpx = randint1(MAX_WID-2);
2081 /* Give first move to monsters */
2082 p_ptr->energy_use = 100;
2084 /* HACk -- set the encouter flag for the wilderness generation */
2085 generate_encounter = TRUE;
2089 /* Cancel repeat unless we may continue */
2090 if (!more) disturb(FALSE, FALSE);
2095 * @brief 「走る」動作コマンドのメインルーチン /
2099 void do_cmd_run(void)
2102 if (cmd_limit_confused(p_ptr)) return;
2104 if (p_ptr->special_defense & KATA_MUSOU)
2106 set_action(ACTION_NONE);
2109 /* Get a "repeated" direction */
2110 if (get_rep_dir(&dir,FALSE))
2112 /* Hack -- Set the run counter */
2113 running = (command_arg ? command_arg : 1000);
2122 * @brief 「留まる」動作コマンドのメインルーチン /
2123 * Stay still. Search. Enter stores.
2124 * Pick up treasure if "pickup" is true.
2125 * @param pickup アイテムの自動拾いを行うならTRUE
2128 void do_cmd_stay(bool pickup)
2130 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2132 /* Allow repeated command */
2135 /* Set repeat count */
2136 command_rep = command_arg - 1;
2137 p_ptr->redraw |= (PR_STATE);
2139 /* Cancel the arg */
2143 p_ptr->energy_use = 100;
2145 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2146 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2151 * @brief 「休む」動作コマンドのメインルーチン /
2152 * Resting allows a player to safely restore his hp -RAK-
2155 void do_cmd_rest(void)
2158 set_action(ACTION_NONE);
2160 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2166 if (hex_spelling_any()) stop_hex_spell_all();
2168 /* Prompt for time if needed */
2169 if (command_arg <= 0)
2171 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2172 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2178 strcpy(out_val, "&");
2180 /* Ask for duration */
2181 if (!get_string(p, out_val, 4)) return;
2183 /* Rest until done */
2184 if (out_val[0] == '&')
2186 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2190 else if (out_val[0] == '*')
2192 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2198 command_arg = (COMMAND_ARG)atoi(out_val);
2199 if (command_arg <= 0) return;
2205 if (command_arg > 9999) command_arg = 9999;
2207 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2209 /* Take a turn (?) */
2210 p_ptr->energy_use = 100;
2212 /* The sin of sloth */
2213 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2215 /* Why are you sleeping when there's no need? WAKE UP!*/
2216 if ((p_ptr->chp == p_ptr->mhp) &&
2217 (p_ptr->csp == p_ptr->msp) &&
2218 !p_ptr->blind && !p_ptr->confused &&
2219 !p_ptr->poisoned && !p_ptr->afraid &&
2220 !p_ptr->stun && !p_ptr->cut &&
2221 !p_ptr->slow && !p_ptr->paralyzed &&
2222 !p_ptr->image && !p_ptr->word_recall &&
2223 !p_ptr->alter_reality)
2224 chg_virtue(V_DILIGENCE, -1);
2226 /* Save the rest code */
2227 resting = command_arg;
2228 p_ptr->action = ACTION_REST;
2229 p_ptr->update |= (PU_BONUS);
2230 update_creature(p_ptr);
2232 p_ptr->redraw |= (PR_STATE);
2241 * @brief 射撃処理のメインルーチン
2244 void do_cmd_fire(void)
2247 object_type *j_ptr, *ammo_ptr;
2250 if(p_ptr->wild_mode) return;
2252 is_fired = FALSE; /* not fired yet */
2254 /* Get the "bow" (if any) */
2255 j_ptr = &inventory[INVEN_BOW];
2257 /* Require a launcher */
2260 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2265 if (j_ptr->sval == SV_CRIMSON)
2267 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2272 if (j_ptr->sval == SV_HARP)
2274 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2280 if (p_ptr->special_defense & KATA_MUSOU)
2282 set_action(ACTION_NONE);
2285 /* Require proper missile */
2286 item_tester_tval = p_ptr->tval_ammo;
2288 q = _("どれを撃ちますか? ", "Fire which item? ");
2289 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2292 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2300 exe_fire(item, j_ptr);
2302 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2304 /* Sniper actions after some shootings */
2305 if (snipe_type == SP_AWAY)
2307 teleport_player(10 + (p_ptr->concent * 2), 0L);
2309 if (snipe_type == SP_FINAL)
2311 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2312 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2313 (void)set_stun(p_ptr->stun + randint1(25));
2319 * @brief 投射処理メインルーチン /
2320 * Throw an object from the pack or floor.
2322 * @param boomerang ブーメラン処理ならばTRUE
2323 * @param shuriken 忍者の手裏剣処理ならばTRUE
2324 * @return ターンを消費した場合TRUEを返す
2327 * Note: "unseen" monsters are very hard to hit.
2329 * Should throwing a weapon do full damage? Should it allow the magic
2330 * to hit bonus of the weapon to have an effect? Should it ever cause
2331 * the item to be destroyed? Should it do any damage at all?
2334 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2339 POSITION y, x, ty, tx, prev_y, prev_x;
2340 POSITION ny[19], nx[19];
2341 int chance, tdam, tdis;
2342 int mul, div, dd, ds;
2343 int cur_dis, visible;
2350 bool hit_body = FALSE;
2351 bool hit_wall = FALSE;
2352 bool equiped_item = FALSE;
2353 bool return_when_thrown = FALSE;
2355 GAME_TEXT o_name[MAX_NLEN];
2357 int msec = delay_factor * delay_factor * delay_factor;
2359 BIT_FLAGS flgs[TR_FLAG_SIZE];
2361 bool come_back = FALSE;
2362 bool do_drop = TRUE;
2364 if (p_ptr->wild_mode) return FALSE;
2366 if (p_ptr->special_defense & KATA_MUSOU)
2368 set_action(ACTION_NONE);
2374 o_ptr = &inventory[item];
2378 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2380 item_tester_hook = item_tester_hook_boomerang;
2381 q = _("どの武器を投げますか? ", "Throw which item? ");
2382 s = _("投げる武器がない。", "You have nothing to throw.");
2383 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2390 else if (has_melee_weapon(INVEN_LARM))
2393 o_ptr = &inventory[item];
2398 o_ptr = &inventory[item];
2403 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2404 s = _("投げるアイテムがない。", "You have nothing to throw.");
2405 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2413 /* Item is cursed */
2414 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2416 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2421 if (p_ptr->inside_arena && !boomerang)
2423 if (o_ptr->tval != TV_SPIKE)
2425 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2434 /* Obtain a local object */
2435 object_copy(q_ptr, o_ptr);
2437 /* Extract the thrown object's flags. */
2438 object_flags(q_ptr, flgs);
2439 torch_flags(q_ptr, flgs);
2441 /* Distribute the charges of rods/wands between the stacks */
2442 distribute_charges(o_ptr, q_ptr, 1);
2447 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2449 if (p_ptr->mighty_throw) mult += 3;
2451 /* Extract a "distance multiplier" */
2452 /* Changed for 'launcher' mutation */
2453 mul = 10 + 2 * (mult - 1);
2455 /* Enforce a minimum "weight" of one pound */
2456 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2457 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2459 /* Hack -- Distance -- Reward strength, penalize weight */
2460 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2462 /* Max distance of 10-18 */
2463 if (tdis > mul) tdis = mul;
2467 ty = randint0(101) - 50 + p_ptr->y;
2468 tx = randint0(101) - 50 + p_ptr->x;
2472 project_length = tdis + 1;
2474 /* Get a direction (or cancel) */
2475 if (!get_aim_dir(&dir)) return FALSE;
2477 /* Predict the "target" location */
2478 tx = p_ptr->x + 99 * ddx[dir];
2479 ty = p_ptr->y + 99 * ddy[dir];
2481 /* Check for "target request" */
2482 if ((dir == 5) && target_okay())
2488 project_length = 0; /* reset to default */
2491 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2492 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2493 return_when_thrown = TRUE;
2495 /* Reduce and describe inventory */
2498 inven_item_increase(item, -1);
2499 if (!return_when_thrown)
2500 inven_item_describe(item);
2501 inven_item_optimize(item);
2504 /* Reduce and describe floor item */
2507 floor_item_increase(0 - item, -1);
2508 floor_item_optimize(0 - item);
2510 if (item >= INVEN_RARM)
2512 equiped_item = TRUE;
2513 p_ptr->redraw |= (PR_EQUIPPY);
2516 p_ptr->energy_use = 100;
2518 /* Rogue and Ninja gets bonus */
2519 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2520 p_ptr->energy_use -= p_ptr->lev;
2522 /* Start at the player */
2528 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2529 else shuriken = FALSE;
2531 /* Chance of hitting */
2532 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2533 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2534 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2536 if (shuriken) chance *= 2;
2541 /* Travel until stopped */
2542 for (cur_dis = 0; cur_dis <= tdis; )
2544 /* Hack -- Stop at the target */
2545 if ((y == ty) && (x == tx)) break;
2547 /* Calculate the new location (see "project()") */
2550 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2552 /* Stopped by walls/doors */
2553 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2556 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2559 /* The player can see the (on screen) missile */
2560 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2562 SYMBOL_CODE c = object_char(q_ptr);
2563 TERM_COLOR a = object_attr(q_ptr);
2565 /* Draw, Hilite, Fresh, Pause, Erase */
2566 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2567 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2569 Term_xtra(TERM_XTRA_DELAY, msec);
2570 lite_spot(ny[cur_dis], nx[cur_dis]);
2574 /* The player cannot see the missile */
2577 /* Pause anyway, for consistancy */
2578 Term_xtra(TERM_XTRA_DELAY, msec);
2584 /* Save the new location */
2588 /* Advance the distance */
2591 /* Monster here, Try to hit it */
2592 if (cave[y][x].m_idx)
2594 cave_type *c_ptr = &cave[y][x];
2595 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2597 /* Check the visibility */
2598 visible = m_ptr->ml;
2600 /* Note the collision */
2603 /* Did we hit it (penalize range) */
2604 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2608 /* Handle unseen monster */
2611 /* Invisible monster */
2612 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2615 /* Handle visible monster */
2618 GAME_TEXT m_name[MAX_NLEN];
2619 monster_desc(m_name, m_ptr, 0);
2620 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2624 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2625 health_track(c_ptr->m_idx);
2629 /* Hack -- Base damage from thrown object */
2632 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2633 tdam = damroll(dd, ds);
2634 /* Apply special damage */
2635 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2636 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2637 if (q_ptr->to_d > 0)
2638 tdam += q_ptr->to_d;
2640 tdam += -q_ptr->to_d;
2644 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2645 tdam += p_ptr->to_d_m;
2647 else if (have_flag(flgs, TR_THROW))
2650 tdam += p_ptr->to_d_m;
2658 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2661 /* No negative damage */
2662 if (tdam < 0) tdam = 0;
2664 /* Modify the damage */
2665 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2667 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2668 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2670 /* Hit the monster, check for death */
2671 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2679 message_pain(c_ptr->m_idx, tdam);
2681 /* Anger the monster */
2682 if ((tdam > 0) && !object_is_potion(q_ptr))
2683 anger_monster(m_ptr);
2685 if (fear && m_ptr->ml)
2688 GAME_TEXT m_name[MAX_NLEN];
2689 monster_desc(m_name, m_ptr, 0);
2690 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2700 /* decrease toach's fuel */
2701 if (hit_body) torch_lost_fuel(q_ptr);
2703 /* Chance of breakage (during attacks) */
2704 j = (hit_body ? breakage_chance(q_ptr) : 0);
2706 /* Figurines transform */
2707 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2711 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2712 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2713 else if (object_is_cursed(q_ptr))
2714 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2719 /* Potions smash open */
2720 if (object_is_potion(q_ptr))
2722 if (hit_body || hit_wall || (randint1(100) < j))
2724 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2726 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2728 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
2730 /* ToDo (Robert): fix the invulnerability */
2731 if (cave[y][x].m_idx &&
2732 is_friendly(&m_list[cave[y][x].m_idx]) &&
2733 !MON_INVULNER(m_ptr))
2735 GAME_TEXT m_name[MAX_NLEN];
2736 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
2737 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2738 set_hostile(&m_list[cave[y][x].m_idx]);
2749 if (return_when_thrown)
2751 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2752 char o2_name[MAX_NLEN];
2753 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2756 if (boomerang) back_chance += 4+randint1(5);
2757 if (super_boomerang) back_chance += 100;
2758 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2760 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2762 for (i = cur_dis - 1; i > 0; i--)
2764 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2766 char c = object_char(q_ptr);
2767 byte a = object_attr(q_ptr);
2769 /* Draw, Hilite, Fresh, Pause, Erase */
2770 print_rel(c, a, ny[i], nx[i]);
2771 move_cursor_relative(ny[i], nx[i]);
2773 Term_xtra(TERM_XTRA_DELAY, msec);
2774 lite_spot(ny[i], nx[i]);
2779 /* Pause anyway, for consistancy */
2780 Term_xtra(TERM_XTRA_DELAY, msec);
2783 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2785 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2792 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2796 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2804 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2810 if (item == INVEN_RARM || item == INVEN_LARM)
2812 /* Access the wield slot */
2813 o_ptr = &inventory[item];
2815 /* Wear the new stuff */
2816 object_copy(o_ptr, q_ptr);
2818 p_ptr->total_weight += q_ptr->weight;
2820 /* Increment the equip counter by hand */
2823 /* Recalculate torch */
2824 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2825 p_ptr->window |= (PW_EQUIP);
2833 else if (equiped_item)
2841 if (cave_have_flag_bold(y, x, FF_PROJECT))
2843 (void)drop_near(q_ptr, j, y, x);
2847 (void)drop_near(q_ptr, j, prev_y, prev_x);
2857 * Hack: travel command
2859 #define TRAVEL_UNABLE 9999
2861 static int flow_head = 0;
2862 static int flow_tail = 0;
2863 static POSITION temp2_x[MAX_SHORT];
2864 static POSITION temp2_y[MAX_SHORT];
2867 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
2870 void forget_travel_flow(void)
2873 /* Check the entire dungeon / Forget the old data */
2874 for (y = 0; y < cur_hgt; y++)
2876 for (x = 0; x < cur_wid; x++)
2879 travel.cost[y][x] = MAX_SHORT;
2882 travel.y = travel.x = 0;
2886 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
2891 static int travel_flow_cost(POSITION y, POSITION x)
2893 feature_type *f_ptr = &f_info[cave[y][x].feat];
2896 /* Avoid obstacles (ex. trees) */
2897 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
2900 if (have_flag(f_ptr->flags, FF_WATER))
2902 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
2906 if (have_flag(f_ptr->flags, FF_LAVA))
2909 if (!p_ptr->resist_fire) lava *= 2;
2910 if (!p_ptr->levitation) lava *= 2;
2911 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
2916 /* Detected traps and doors */
2917 if (cave[y][x].info & (CAVE_MARK))
2919 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
2920 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
2927 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
2931 * @param wall プレイヤーが壁の中にいるならばTRUE
2934 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
2936 cave_type *c_ptr = &cave[y][x];
2937 feature_type *f_ptr = &f_info[c_ptr->feat];
2938 int old_head = flow_head;
2940 int base_cost = (n % TRAVEL_UNABLE);
2941 int from_wall = (n / TRAVEL_UNABLE);
2944 /* Ignore out of bounds */
2945 if (!in_bounds(y, x)) return;
2947 /* Ignore unknown grid except in wilderness */
2948 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
2950 /* Ignore "walls" and "rubble" (include "secret doors") */
2951 if (have_flag(f_ptr->flags, FF_WALL) ||
2952 have_flag(f_ptr->flags, FF_CAN_DIG) ||
2953 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
2954 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
2956 if (!wall || !from_wall) return;
2957 add_cost += TRAVEL_UNABLE;
2961 add_cost = travel_flow_cost(y, x);
2964 cost = base_cost + add_cost;
2966 /* Ignore lower cost entries */
2967 if (travel.cost[y][x] <= cost) return;
2969 /* Save the flow cost */
2970 travel.cost[y][x] = cost;
2972 /* Enqueue that entry */
2973 temp2_y[flow_head] = y;
2974 temp2_x[flow_head] = x;
2976 /* Advance the queue */
2977 if (++flow_head == MAX_SHORT) flow_head = 0;
2979 /* Hack -- notice overflow by forgetting new entry */
2980 if (flow_head == flow_tail) flow_head = old_head;
2986 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
2987 * @param ty 目標地点のY座標
2988 * @param tx 目標地点のX座標
2991 static void travel_flow(POSITION ty, POSITION tx)
2995 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
2997 /* Reset the "queue" */
2998 flow_head = flow_tail = 0;
3000 /* is player in the wall? */
3001 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
3003 /* Start at the target grid */
3004 travel_flow_aux(ty, tx, 0, wall);
3006 /* Now process the queue */
3007 while (flow_head != flow_tail)
3009 /* Extract the next entry */
3010 y = temp2_y[flow_tail];
3011 x = temp2_x[flow_tail];
3013 /* Forget that entry */
3014 if (++flow_tail == MAX_SHORT) flow_tail = 0;
3016 /* Ignore too far entries */
3017 //if (distance(ty, tx, y, x) > 100) continue;
3019 /* Add the "children" */
3020 for (d = 0; d < 8; d++)
3022 /* Add that child if "legal" */
3023 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
3027 /* Forget the flow info */
3028 flow_head = flow_tail = 0;
3032 * @brief トラベル処理のメインルーチン
3035 void do_cmd_travel(void)
3039 POSITION dx, dy, sx, sy;
3040 feature_type *f_ptr;
3042 if (travel.x != 0 && travel.y != 0 &&
3043 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3048 else if (!tgt_pt(&x, &y)) return;
3050 if ((x == p_ptr->x) && (y == p_ptr->y))
3052 msg_print(_("すでにそこにいます!", "You are already there!!"));
3056 f_ptr = &f_info[cave[y][x].feat];
3058 if ((cave[y][x].info & CAVE_MARK) &&
3059 (have_flag(f_ptr->flags, FF_WALL) ||
3060 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3061 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3063 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3067 forget_travel_flow();
3073 /* Travel till 255 steps */
3079 /* Decides first direction */
3080 dx = abs(p_ptr->x - x);
3081 dy = abs(p_ptr->y - y);
3082 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3083 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3085 for (i = 1; i <= 9; i++)
3087 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;