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.
16 #include "object-hook.h"
19 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
20 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
21 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
23 bool confirm_leave_level(bool down_stair)
25 quest_type *q_ptr = &quest[p_ptr->inside_quest];
27 /* Confirm leaving from once only quest */
28 if (confirm_quest && p_ptr->inside_quest &&
29 (q_ptr->type == QUEST_TYPE_RANDOM ||
30 (q_ptr->flags & QUEST_FLAG_ONCE &&
31 q_ptr->status != QUEST_STATUS_COMPLETED) ||
32 (q_ptr->flags & QUEST_FLAG_TOWER &&
33 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
34 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
36 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
37 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
47 * @brief 階段を使って階層を昇る処理 / Go up one level
50 void do_cmd_go_up(void)
55 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
56 feature_type *f_ptr = &f_info[c_ptr->feat];
60 if (p_ptr->special_defense & KATA_MUSOU)
62 set_action(ACTION_NONE);
66 if (!have_flag(f_ptr->flags, FF_LESS))
68 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
73 if (have_flag(f_ptr->flags, FF_QUEST))
75 /* Cancel the command */
76 if (!confirm_leave_level(FALSE)) return;
80 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
81 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
83 msg_print(_("上の階に登った。", "You enter the up staircase."));
87 p_ptr->inside_quest = c_ptr->special;
89 /* Activate the quest */
90 if (!quest[p_ptr->inside_quest].status)
92 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
94 init_flags = INIT_ASSIGN;
95 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
97 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
100 /* Leaving a quest */
101 if (!p_ptr->inside_quest)
107 p_ptr->leaving = TRUE;
112 /* Hack -- take a turn */
113 p_ptr->energy_use = 100;
115 /* End the command */
125 go_up = confirm_leave_level(FALSE);
128 /* Cancel the command */
131 /* Hack -- take a turn */
132 p_ptr->energy_use = 100;
134 if (autosave_l) do_cmd_save_game(TRUE);
136 /* For a random quest */
137 if (p_ptr->inside_quest &&
138 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
142 p_ptr->inside_quest = 0;
145 /* For a fixed quest */
146 if (p_ptr->inside_quest &&
147 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
151 p_ptr->inside_quest = c_ptr->special;
156 /* For normal dungeon and random quest */
160 if (have_flag(f_ptr->flags, FF_SHAFT))
162 /* Create a way back */
163 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
169 /* Create a way back */
170 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
175 /* Get out from current dungeon */
176 if (dun_level - up_num < d_info[dungeon_type].mindepth)
179 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
182 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
183 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
184 else if (up_num == dun_level)
185 msg_print(_("地上に戻った。", "You go back to the surface."));
187 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
190 p_ptr->leaving = TRUE;
195 * @brief 階段を使って階層を降りる処理 / Go down one level
198 void do_cmd_go_down(void)
201 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
202 feature_type *f_ptr = &f_info[c_ptr->feat];
204 bool fall_trap = FALSE;
207 if (p_ptr->special_defense & KATA_MUSOU)
209 set_action(ACTION_NONE);
213 if (!have_flag(f_ptr->flags, FF_MORE))
215 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
219 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
222 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
227 /* Quest down stairs */
228 else if (have_flag(f_ptr->flags, FF_QUEST))
230 /* Confirm Leaving */
231 if(!confirm_leave_level(TRUE)) return;
233 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
234 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
236 msg_print(_("下の階に降りた。", "You enter the down staircase."));
241 p_ptr->inside_quest = c_ptr->special;
243 /* Activate the quest */
244 if (!quest[p_ptr->inside_quest].status)
246 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
248 init_flags = INIT_ASSIGN;
249 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
251 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
254 /* Leaving a quest */
255 if (!p_ptr->inside_quest)
261 p_ptr->leaving = TRUE;
267 /* Hack -- take a turn */
268 p_ptr->energy_use = 100;
273 int target_dungeon = 0;
277 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
279 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
281 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
284 if (!max_dlv[target_dungeon])
286 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
287 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
288 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
291 /* Save old player position */
292 p_ptr->oldpx = p_ptr->x;
293 p_ptr->oldpy = p_ptr->y;
294 dungeon_type = (byte)target_dungeon;
297 * Clear all saved floors
298 * and create a first saved floor
300 prepare_change_floor_mode(CFM_FIRST_FLOOR);
303 /* Hack -- take a turn */
304 p_ptr->energy_use = 100;
306 if (autosave_l) do_cmd_save_game(TRUE);
309 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
314 /* Enter the dungeon just now */
315 p_ptr->enter_dungeon = TRUE;
316 down_num = d_info[dungeon_type].mindepth;
321 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
322 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
327 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
334 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
338 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
339 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
341 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
347 p_ptr->leaving = TRUE;
351 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
355 if (have_flag(f_ptr->flags, FF_SHAFT))
357 /* Create a way back */
358 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
362 /* Create a way back */
363 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
371 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
374 void do_cmd_search(void)
376 /* Allow repeated command */
379 /* Set repeat count */
380 command_rep = command_arg - 1;
381 p_ptr->redraw |= (PR_STATE);
386 p_ptr->energy_use = 100;
394 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
395 * @param y 走査対象にしたいマスのY座標
396 * @param x 走査対象にしたいマスのX座標
397 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
398 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
400 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
402 cave_type *c_ptr = &cave[y][x];
403 OBJECT_IDX this_o_idx, next_o_idx = 0;
405 /* Scan all objects in the grid */
406 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
410 o_ptr = &o_list[this_o_idx];
411 next_o_idx = o_ptr->next_o_idx;
413 /* Skip unknown chests XXX XXX */
414 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
416 /* Check for non empty chest */
417 if ((o_ptr->tval == TV_CHEST) &&
418 (((!trapped) && (o_ptr->pval)) || /* non empty */
419 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
428 * @brief 箱を開けるコマンドのメインルーチン /
429 * Attempt to open the given chest at the given location
430 * @param y 箱の存在するマスのY座標
431 * @param x 箱の存在するマスのX座標
432 * @param o_idx 箱のオブジェクトID
433 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
435 * Assume there is no monster blocking the destination
437 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
442 object_type *o_ptr = &o_list[o_idx];
444 p_ptr->energy_use = 100;
446 /* Attempt to unlock it */
449 /* Assume locked, and thus not open */
452 /* Get the "disarm" factor */
453 i = p_ptr->skill_dis;
455 /* Penalize some conditions */
456 if (p_ptr->blind || no_lite()) i = i / 10;
457 if (p_ptr->confused || p_ptr->image) i = i / 10;
459 /* Extract the difficulty */
462 /* Always have a small chance of success */
465 /* Success -- May still have traps */
466 if (randint0(100) < j)
468 msg_print(_("鍵をはずした。", "You have picked the lock."));
473 /* Failure -- Keep trying */
476 /* We may continue repeating */
478 if (flush_failure) flush();
479 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
484 /* Allowed to open */
487 /* Apply chest traps, if any */
488 chest_trap(y, x, o_idx);
490 /* Let the Chest drop items */
491 chest_death(FALSE, y, x, o_idx);
497 * @brief 地形は開くものであって、かつ開かれているかを返す /
498 * Attempt to open the given chest at the given location
500 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
502 static bool is_open(IDX feat)
504 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
509 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
510 * Attempt to open the given chest at the given location
511 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
512 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
513 * @param test 地形条件を判定するための関数ポインタ
514 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
516 * @details Return the number of features around (or under) the character.
517 * Usually look for doors and floor traps.
519 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
521 int d, count, xx, yy;
523 /* Count how many matches */
526 /* Check around (and under) the character */
527 for (d = 0; d < 9; d++)
532 /* if not searching under player continue */
533 if ((d == 8) && !under) continue;
535 /* Extract adjacent (legal) location */
536 yy = p_ptr->y + ddy_ddd[d];
537 xx = p_ptr->x + ddx_ddd[d];
540 c_ptr = &cave[yy][xx];
542 /* Must have knowledge */
543 if (!(c_ptr->info & (CAVE_MARK))) continue;
545 /* Feature code (applying "mimic" field) */
546 feat = get_feat_mimic(c_ptr);
548 /* Not looking for this feature */
549 if (!((*test)(feat))) continue;
554 /* Remember the location. Only useful if only one match */
565 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
566 * Return the number of chests around (or under) the character.
567 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
568 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
569 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
572 * If requested, count only trapped chests.
574 static int count_chests(POSITION *y, POSITION *x, bool trapped)
581 /* Count how many matches */
584 /* Check around (and under) the character */
585 for (d = 0; d < 9; d++)
587 /* Extract adjacent (legal) location */
588 POSITION yy = p_ptr->y + ddy_ddd[d];
589 POSITION xx = p_ptr->x + ddx_ddd[d];
591 /* No (visible) chest is there */
592 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
594 /* Grab the object */
595 o_ptr = &o_list[o_idx];
598 if (o_ptr->pval == 0) continue;
600 /* No (known) traps here */
601 if (trapped && (!object_is_known(o_ptr) ||
602 !chest_traps[o_ptr->pval])) continue;
607 /* Remember the location. Only useful if only one match */
618 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
619 * Convert an adjacent location to a direction.
620 * @param y 方角を確認したY座標
621 * @param x 方角を確認したX座標
624 static DIRECTION coords_to_dir(POSITION y, POSITION x)
626 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
633 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
635 return d[dx + 1][dy + 1];
639 * @brief 「開ける」動作コマンドのサブルーチン /
640 * Perform the basic "open" command on doors
641 * @param y 対象を行うマスのY座標
642 * @param x 対象を行うマスのX座標
643 * @return 実際に処理が行われた場合TRUEを返す。
645 * Assume destination is a closed/locked/jammed door
646 * Assume there is no monster blocking the destination
647 * Returns TRUE if repeated commands may continue
649 static bool do_cmd_open_aux(POSITION y, POSITION x)
653 /* Get requested grid */
654 cave_type *c_ptr = &cave[y][x];
655 feature_type *f_ptr = &f_info[c_ptr->feat];
658 p_ptr->energy_use = 100;
660 /* Seeing true feature code (ignore mimic) */
663 if (!have_flag(f_ptr->flags, FF_OPEN))
666 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
670 else if (f_ptr->power)
673 i = p_ptr->skill_dis;
675 /* Penalize some conditions */
676 if (p_ptr->blind || no_lite()) i = i / 10;
677 if (p_ptr->confused || p_ptr->image) i = i / 10;
679 /* Extract the lock power */
682 /* Extract the difficulty */
685 /* Always have a small chance of success */
689 if (randint0(100) < j)
691 msg_print(_("鍵をはずした。", "You have picked the lock."));
694 cave_alter_feat(y, x, FF_OPEN);
696 sound(SOUND_OPENDOOR);
706 if (flush_failure) flush();
708 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
710 /* We may keep trying */
719 cave_alter_feat(y, x, FF_OPEN);
721 sound(SOUND_OPENDOOR);
727 * @brief 「開ける」コマンドのメインルーチン /
728 * Open a closed/locked/jammed door or a closed/locked chest.
731 * Unlocking a locked door/chest is worth one experience point.
733 void do_cmd_open(void)
741 if (p_ptr->wild_mode) return;
743 if (p_ptr->special_defense & KATA_MUSOU)
745 set_action(ACTION_NONE);
748 /* Option: Pick a direction */
751 int num_doors, num_chests;
753 /* Count closed doors (locked or jammed) */
754 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
756 /* Count chests (locked) */
757 num_chests = count_chests(&y, &x, FALSE);
759 /* See if only one target */
760 if (num_doors || num_chests)
762 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
764 if (!too_many) command_dir = coords_to_dir(y, x);
768 /* Allow repeated command */
771 /* Set repeat count */
772 command_rep = command_arg - 1;
773 p_ptr->redraw |= (PR_STATE);
779 /* Get a "repeated" direction */
780 if (get_rep_dir(&dir, TRUE))
785 /* Get requested location */
786 y = p_ptr->y + ddy[dir];
787 x = p_ptr->x + ddx[dir];
789 /* Get requested grid */
792 /* Feature code (applying "mimic" field) */
793 feat = get_feat_mimic(c_ptr);
795 /* Check for chest */
796 o_idx = chest_check(y, x, FALSE);
799 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
801 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
804 /* Monster in the way */
805 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
807 p_ptr->energy_use = 100;
808 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
816 more = do_cmd_open_chest(y, x, o_idx);
823 more = do_cmd_open_aux(y, x);
827 /* Cancel repeat unless we may continue */
828 if (!more) disturb(FALSE, FALSE);
834 * @brief 「閉じる」動作コマンドのサブルーチン /
835 * Perform the basic "close" command
836 * @param y 対象を行うマスのY座標
837 * @param x 対象を行うマスのX座標
838 * @return 実際に処理が行われた場合TRUEを返す。
840 * Assume destination is an open/broken door
841 * Assume there is no monster blocking the destination
842 * Returns TRUE if repeated commands may continue
844 static bool do_cmd_close_aux(POSITION y, POSITION x)
846 cave_type *c_ptr = &cave[y][x];
847 FEAT_IDX old_feat = c_ptr->feat;
850 p_ptr->energy_use = 100;
852 /* Seeing true feature code (ignore mimic) */
855 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
857 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
859 /* Hack -- object in the way */
860 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
861 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
863 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
868 cave_alter_feat(y, x, FF_CLOSE);
871 if (old_feat == c_ptr->feat)
873 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
877 sound(SOUND_SHUTDOOR);
886 * @brief 「閉じる」コマンドのメインルーチン /
887 * Close an open door.
890 * Unlocking a locked door/chest is worth one experience point.
892 void do_cmd_close(void)
899 if (p_ptr->wild_mode) return;
901 if (p_ptr->special_defense & KATA_MUSOU)
903 set_action(ACTION_NONE);
906 /* Option: Pick a direction */
909 /* Count open doors */
910 if (count_dt(&y, &x, is_open, FALSE) == 1)
912 command_dir = coords_to_dir(y, x);
916 /* Allow repeated command */
919 /* Set repeat count */
920 command_rep = command_arg - 1;
921 p_ptr->redraw |= (PR_STATE);
927 /* Get a "repeated" direction */
928 if (get_rep_dir(&dir, FALSE))
933 y = p_ptr->y + ddy[dir];
934 x = p_ptr->x + ddx[dir];
937 /* Feature code (applying "mimic" field) */
938 feat = get_feat_mimic(c_ptr);
940 /* Require open/broken door */
941 if (!have_flag(f_info[feat].flags, FF_CLOSE))
943 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
946 /* Monster in the way */
947 else if (c_ptr->m_idx)
949 p_ptr->energy_use = 100;
951 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
961 more = do_cmd_close_aux(y, x);
965 /* Cancel repeat unless we may continue */
966 if (!more) disturb(FALSE, FALSE);
971 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
972 * Determine if a given grid may be "tunneled"
973 * @param y 対象を行うマスのY座標
974 * @param x 対象を行うマスのX座標
977 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
979 cave_type *c_ptr = &cave[y][x];
981 /* Must have knowledge */
982 if (!(c_ptr->info & CAVE_MARK))
984 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
989 /* Must be a wall/door/etc */
990 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
992 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1002 * @brief 「掘る」動作コマンドのサブルーチン /
1003 * Perform the basic "tunnel" command
1004 * @param y 対象を行うマスのY座標
1005 * @param x 対象を行うマスのX座標
1006 * @return 実際に処理が行われた場合TRUEを返す。
1008 * Assumes that no monster is blocking the destination
1009 * Do not use twall anymore
1010 * Returns TRUE if repeated commands may continue
1012 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1015 feature_type *f_ptr, *mimic_f_ptr;
1020 /* Verify legality */
1021 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1023 p_ptr->energy_use = 100;
1026 c_ptr = &cave[y][x];
1027 f_ptr = &f_info[c_ptr->feat];
1028 power = f_ptr->power;
1030 /* Feature code (applying "mimic" field) */
1031 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1033 name = f_name + mimic_f_ptr->name;
1037 if (have_flag(f_ptr->flags, FF_PERMANENT))
1040 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1042 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1045 /* Map border (mimiccing Permanent wall) */
1048 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1053 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1056 if (p_ptr->skill_dig > randint0(20 * power))
1058 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1060 /* Remove the feature */
1061 cave_alter_feat(y, x, FF_TUNNEL);
1063 /* Update some things */
1064 p_ptr->update |= (PU_FLOW);
1068 /* Message, keep digging */
1069 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1077 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1080 if (p_ptr->skill_dig > power + randint0(40 * power))
1082 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1085 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1086 p_ptr->update |= (PU_FLOW);
1089 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1091 /* Remove the feature */
1092 cave_alter_feat(y, x, FF_TUNNEL);
1094 chg_virtue(V_DILIGENCE, 1);
1095 chg_virtue(V_NATURE, -1);
1103 /* We may continue chopping */
1104 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1105 /* Occasional Search XXX XXX */
1106 if (randint0(100) < 25) search();
1110 /* We may continue tunelling */
1111 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1118 if (is_hidden_door(c_ptr))
1120 /* Occasional Search XXX XXX */
1121 if (randint0(100) < 25) search();
1128 * @brief 「掘る」動作コマンドのメインルーチン /
1129 * Tunnels through "walls" (including rubble and closed doors)
1133 * Note that you must tunnel in order to hit invisible monsters
1134 * in walls, though moving into walls still takes a turn anyway.
1136 * Digging is very difficult without a "digger" weapon, but can be
1137 * accomplished by strong players using heavy weapons.
1140 void do_cmd_tunnel(void)
1150 if (p_ptr->special_defense & KATA_MUSOU)
1152 set_action(ACTION_NONE);
1155 /* Allow repeated command */
1158 /* Set repeat count */
1159 command_rep = command_arg - 1;
1160 p_ptr->redraw |= (PR_STATE);
1162 /* Cancel the arg */
1166 /* Get a direction to tunnel, or Abort */
1167 if (get_rep_dir(&dir,FALSE))
1170 y = p_ptr->y + ddy[dir];
1171 x = p_ptr->x + ddx[dir];
1174 c_ptr = &cave[y][x];
1176 /* Feature code (applying "mimic" field) */
1177 feat = get_feat_mimic(c_ptr);
1179 /* No tunnelling through doors */
1180 if (have_flag(f_info[feat].flags, FF_DOOR))
1182 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1185 /* No tunnelling through most features */
1186 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1188 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1191 /* A monster is in the way */
1192 else if (c_ptr->m_idx)
1194 p_ptr->energy_use = 100;
1196 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1205 /* Tunnel through walls */
1206 more = do_cmd_tunnel_aux(y, x);
1210 /* Cancel repetition unless we can continue */
1211 if (!more) disturb(FALSE, FALSE);
1215 * @brief 移動処理による簡易な「開く」処理 /
1217 * @return 開く処理が実際に試みられた場合TRUEを返す
1220 * If there is a jammed/closed/locked door at the given location,
1221 * then attempt to unlock/open it. Return TRUE if an attempt was
1222 * made (successful or not), otherwise return FALSE.
1224 * The code here should be nearly identical to that in
1225 * do_cmd_open_test() and do_cmd_open_aux().
1228 bool easy_open_door(POSITION y, POSITION x)
1232 cave_type *c_ptr = &cave[y][x];
1233 feature_type *f_ptr = &f_info[c_ptr->feat];
1235 /* Must be a closed door */
1236 if (!is_closed_door(c_ptr->feat))
1242 if (!have_flag(f_ptr->flags, FF_OPEN))
1245 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1250 else if (f_ptr->power)
1253 i = p_ptr->skill_dis;
1255 /* Penalize some conditions */
1256 if (p_ptr->blind || no_lite()) i = i / 10;
1257 if (p_ptr->confused || p_ptr->image) i = i / 10;
1259 /* Extract the lock power */
1262 /* Extract the difficulty */
1265 /* Always have a small chance of success */
1269 if (randint0(100) < j)
1271 msg_print(_("鍵をはずした。", "You have picked the lock."));
1274 cave_alter_feat(y, x, FF_OPEN);
1276 sound(SOUND_OPENDOOR);
1286 if (flush_failure) flush();
1288 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1297 cave_alter_feat(y, x, FF_OPEN);
1299 sound(SOUND_OPENDOOR);
1305 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1306 * Perform the basic "disarm" command
1307 * @param y 解除を行うマスのY座標
1308 * @param x 解除を行うマスのX座標
1309 * @param o_idx 箱のオブジェクトID
1310 * @return ターンを消費する処理が行われた場合TRUEを返す
1313 * Assume destination is a visible trap
1314 * Assume there is no monster blocking the destination
1315 * Returns TRUE if repeated commands may continue
1318 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1322 object_type *o_ptr = &o_list[o_idx];
1324 p_ptr->energy_use = 100;
1326 /* Get the "disarm" factor */
1327 i = p_ptr->skill_dis;
1329 /* Penalize some conditions */
1330 if (p_ptr->blind || no_lite()) i = i / 10;
1331 if (p_ptr->confused || p_ptr->image) i = i / 10;
1333 /* Extract the difficulty */
1334 j = i - o_ptr->pval;
1336 /* Always have a small chance of success */
1339 /* Must find the trap first. */
1340 if (!object_is_known(o_ptr))
1342 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1346 /* Already disarmed/unlocked */
1347 else if (o_ptr->pval <= 0)
1349 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1352 /* No traps to find. */
1353 else if (!chest_traps[o_ptr->pval])
1355 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1358 /* Success (get a lot of experience) */
1359 else if (randint0(100) < j)
1361 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1362 gain_exp(o_ptr->pval);
1363 o_ptr->pval = (0 - o_ptr->pval);
1366 /* Failure -- Keep trying */
1367 else if ((i > 5) && (randint1(i) > 5))
1369 /* We may keep trying */
1371 if (flush_failure) flush();
1372 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1375 /* Failure -- Set off the trap */
1378 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1380 chest_trap(y, x, o_idx);
1387 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1388 * Perform the basic "disarm" command
1389 * @param y 解除を行うマスのY座標
1390 * @param x 解除を行うマスのX座標
1391 * @param dir プレイヤーからみた方向ID
1392 * @return ターンを消費する処理が行われた場合TRUEを返す
1395 * Assume destination is a visible trap
1396 * Assume there is no monster blocking the destination
1397 * Returns TRUE if repeated commands may continue
1401 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1403 cave_type *c_ptr = &cave[y][x];
1406 feature_type *f_ptr = &f_info[c_ptr->feat];
1408 /* Access trap name */
1409 cptr name = (f_name + f_ptr->name);
1411 /* Extract trap "power" */
1412 int power = f_ptr->power;
1415 /* Get the "disarm" factor */
1416 int i = p_ptr->skill_dis;
1419 p_ptr->energy_use = 100;
1421 /* Penalize some conditions */
1422 if (p_ptr->blind || no_lite()) i = i / 10;
1423 if (p_ptr->confused || p_ptr->image) i = i / 10;
1425 /* Extract the difficulty */
1428 /* Always have a small chance of success */
1432 if (randint0(100) < j)
1434 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1439 /* Remove the trap */
1440 cave_alter_feat(y, x, FF_DISARM);
1442 /* Move the player onto the trap */
1443 move_player(dir, easy_disarm, FALSE);
1446 /* Failure -- Keep trying */
1447 else if ((i > 5) && (randint1(i) > 5))
1450 if (flush_failure) flush();
1452 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1454 /* We may keep trying */
1458 /* Failure -- Set off the trap */
1461 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1462 /* Move the player onto the trap */
1463 move_player(dir, easy_disarm, FALSE);
1470 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1471 * Disarms a trap, or chest
1474 void do_cmd_disarm(void)
1482 if (p_ptr->wild_mode) return;
1484 if (p_ptr->special_defense & KATA_MUSOU)
1486 set_action(ACTION_NONE);
1489 /* Option: Pick a direction */
1492 int num_traps, num_chests;
1494 /* Count visible traps */
1495 num_traps = count_dt(&y, &x, is_trap, TRUE);
1497 /* Count chests (trapped) */
1498 num_chests = count_chests(&y, &x, TRUE);
1500 /* See if only one target */
1501 if (num_traps || num_chests)
1503 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1504 if (!too_many) command_dir = coords_to_dir(y, x);
1509 /* Allow repeated command */
1512 /* Set repeat count */
1513 command_rep = command_arg - 1;
1514 p_ptr->redraw |= (PR_STATE);
1516 /* Cancel the arg */
1520 /* Get a direction (or abort) */
1521 if (get_rep_dir(&dir,TRUE))
1526 y = p_ptr->y + ddy[dir];
1527 x = p_ptr->x + ddx[dir];
1528 c_ptr = &cave[y][x];
1530 /* Feature code (applying "mimic" field) */
1531 feat = get_feat_mimic(c_ptr);
1533 /* Check for chests */
1534 o_idx = chest_check(y, x, TRUE);
1537 if (!is_trap(feat) && !o_idx)
1539 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1542 /* Monster in the way */
1543 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1545 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1554 more = do_cmd_disarm_chest(y, x, o_idx);
1560 more = do_cmd_disarm_aux(y, x, dir);
1564 /* Cancel repeat unless told not to */
1565 if (!more) disturb(FALSE, FALSE);
1570 * @brief 「打ち破る」動作コマンドのサブルーチン /
1571 * Perform the basic "bash" command
1572 * @param y 対象を行うマスのY座標
1573 * @param x 対象を行うマスのX座標
1574 * @param dir プレイヤーから見たターゲットの方角ID
1575 * @return 実際に処理が行われた場合TRUEを返す。
1578 * Assume destination is a closed/locked/jammed door
1579 * Assume there is no monster blocking the destination
1580 * Returns TRUE if repeated commands may continue
1583 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1586 cave_type *c_ptr = &cave[y][x];
1589 feature_type *f_ptr = &f_info[c_ptr->feat];
1591 /* Hack -- Bash power based on strength */
1592 /* (Ranges from 3 to 20 to 100 to 200) */
1593 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1595 /* Extract door power */
1596 int temp = f_ptr->power;
1600 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1602 p_ptr->energy_use = 100;
1604 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1606 /* Compare bash power to door power */
1607 temp = (bash - (temp * 10));
1609 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1611 /* Hack -- always have a chance */
1612 if (temp < 1) temp = 1;
1614 /* Hack -- attempt to bash down the door */
1615 if (randint0(100) < temp)
1617 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1619 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1621 /* Break down the door */
1622 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1624 cave_alter_feat(y, x, FF_BASH);
1630 cave_alter_feat(y, x, FF_OPEN);
1633 /* Hack -- Fall through the door */
1634 move_player(dir, FALSE, FALSE);
1637 /* Saving throw against stun */
1638 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1641 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1643 /* Allow repeated bashing */
1647 /* High dexterity yields coolness */
1650 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1652 /* Hack -- Lose balance ala paralysis */
1653 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1660 * @brief 「打ち破る」動作コマンドのメインルーチン /
1661 * Bash open a door, success based on character strength
1665 * For a closed door, pval is positive if locked; negative if stuck.
1667 * For an open door, pval is positive for a broken door.
1669 * A closed door can be opened - harder if locked. Any door might be
1670 * bashed open (and thereby broken). Bashing a door is (potentially)
1671 * faster! You move into the door way. To open a stuck door, it must
1672 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1674 * Creatures can also open or bash doors, see elsewhere.
1677 void do_cmd_bash(void)
1683 if (p_ptr->wild_mode) return;
1685 if (p_ptr->special_defense & KATA_MUSOU)
1687 set_action(ACTION_NONE);
1690 /* Allow repeated command */
1693 /* Set repeat count */
1694 command_rep = command_arg - 1;
1695 p_ptr->redraw |= (PR_STATE);
1697 /* Cancel the arg */
1701 /* Get a "repeated" direction */
1702 if (get_rep_dir(&dir,FALSE))
1707 y = p_ptr->y + ddy[dir];
1708 x = p_ptr->x + ddx[dir];
1711 c_ptr = &cave[y][x];
1713 /* Feature code (applying "mimic" field) */
1714 feat = get_feat_mimic(c_ptr);
1716 /* Nothing useful */
1717 if (!have_flag(f_info[feat].flags, FF_BASH))
1719 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1722 /* Monster in the way */
1723 else if (c_ptr->m_idx)
1725 p_ptr->energy_use = 100;
1727 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1733 /* Bash a closed door */
1737 more = do_cmd_bash_aux(y, x, dir);
1741 /* Unless valid action taken, cancel bash */
1742 if (!more) disturb(FALSE, FALSE);
1747 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1751 * Manipulate an adjacent grid in some way
1753 * Attack monsters, tunnel through walls, disarm traps, open doors.
1755 * Consider confusion
1757 * This command must always take a turn, to prevent free detection
1758 * of invisible monsters.
1761 void do_cmd_alter(void)
1768 if (p_ptr->special_defense & KATA_MUSOU)
1770 set_action(ACTION_NONE);
1773 /* Allow repeated command */
1776 /* Set repeat count */
1777 command_rep = command_arg - 1;
1778 p_ptr->redraw |= (PR_STATE);
1780 /* Cancel the arg */
1784 /* Get a direction */
1785 if (get_rep_dir(&dir,TRUE))
1788 feature_type *f_ptr;
1790 y = p_ptr->y + ddy[dir];
1791 x = p_ptr->x + ddx[dir];
1794 c_ptr = &cave[y][x];
1796 /* Feature code (applying "mimic" field) */
1797 feat = get_feat_mimic(c_ptr);
1798 f_ptr = &f_info[feat];
1800 p_ptr->energy_use = 100;
1808 else if (have_flag(f_ptr->flags, FF_OPEN))
1810 more = do_cmd_open_aux(y, x);
1813 /* Bash jammed doors */
1814 else if (have_flag(f_ptr->flags, FF_BASH))
1816 more = do_cmd_bash_aux(y, x, dir);
1819 /* Tunnel through walls */
1820 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1822 more = do_cmd_tunnel_aux(y, x);
1825 /* Close open doors */
1826 else if (have_flag(f_ptr->flags, FF_CLOSE))
1828 more = do_cmd_close_aux(y, x);
1832 else if (have_flag(f_ptr->flags, FF_DISARM))
1834 more = do_cmd_disarm_aux(y, x, dir);
1839 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1843 /* Cancel repetition unless we can continue */
1844 if (!more) disturb(FALSE, FALSE);
1850 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1851 * Find the index of some "spikes", if possible.
1852 * @param ip くさびとして打てるオブジェクトのID
1853 * @return オブジェクトがある場合TRUEを返す
1856 * Let user choose a pile of spikes, perhaps?
1859 static bool get_spike(INVENTORY_IDX *ip)
1863 /* Check every item in the pack */
1864 for (i = 0; i < INVEN_PACK; i++)
1866 object_type *o_ptr = &inventory[i];
1868 /* Skip non-objects */
1869 if (!o_ptr->k_idx) continue;
1871 /* Check the "tval" code */
1872 if (o_ptr->tval == TV_SPIKE)
1874 /* Save the spike index */
1887 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1888 * Jam a closed door with a spike
1892 * This command may NOT be repeated
1895 void do_cmd_spike(void)
1899 if (p_ptr->wild_mode) return;
1901 if (p_ptr->special_defense & KATA_MUSOU)
1903 set_action(ACTION_NONE);
1906 /* Get a "repeated" direction */
1907 if (get_rep_dir(&dir, FALSE))
1914 y = p_ptr->y + ddy[dir];
1915 x = p_ptr->x + ddx[dir];
1916 c_ptr = &cave[y][x];
1918 /* Feature code (applying "mimic" field) */
1919 feat = get_feat_mimic(c_ptr);
1921 /* Require closed door */
1922 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1924 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1928 else if (!get_spike(&item))
1930 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1933 /* Is a monster in the way? */
1934 else if (c_ptr->m_idx)
1936 p_ptr->energy_use = 100;
1938 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1947 p_ptr->energy_use = 100;
1949 /* Successful jamming */
1950 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1951 cave_alter_feat(y, x, FF_SPIKE);
1953 /* Use up, and describe, a single spike, from the bottom */
1954 inven_item_increase(item, -1);
1955 inven_item_describe(item);
1956 inven_item_optimize(item);
1964 * @brief 「歩く」動作コマンドのメインルーチン /
1965 * Support code for the "Walk" and "Jump" commands
1966 * @param pickup アイテムの自動拾いを行うならTRUE
1969 void do_cmd_walk(bool pickup)
1976 /* Allow repeated command */
1979 /* Set repeat count */
1980 command_rep = command_arg - 1;
1981 p_ptr->redraw |= (PR_STATE);
1983 /* Cancel the arg */
1987 /* Get a "repeated" direction */
1988 if (get_rep_dir(&dir, FALSE))
1990 p_ptr->energy_use = 100;
1992 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
1994 set_action(ACTION_NONE);
1997 /* Hack -- In small scale wilderness it takes MUCH more time to move */
1998 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
1999 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2001 /* Actually move the character */
2002 move_player(dir, pickup, FALSE);
2004 /* Allow more walking */
2008 /* Hack again -- Is there a special encounter ??? */
2009 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2011 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2014 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2016 /* Inform the player of his horrible fate :=) */
2017 msg_print(_("襲撃だ!", "You are ambushed !"));
2019 /* Go into large wilderness view */
2020 p_ptr->oldpy = randint1(MAX_HGT-2);
2021 p_ptr->oldpx = randint1(MAX_WID-2);
2024 /* Give first move to monsters */
2025 p_ptr->energy_use = 100;
2027 /* HACk -- set the encouter flag for the wilderness generation */
2028 generate_encounter = TRUE;
2032 /* Cancel repeat unless we may continue */
2033 if (!more) disturb(FALSE, FALSE);
2038 * @brief 「走る」動作コマンドのメインルーチン /
2042 void do_cmd_run(void)
2046 /* Hack -- no running when confused */
2047 if (p_ptr->confused)
2049 msg_print(_("混乱していて走れない!", "You are too confused!"));
2053 if (p_ptr->special_defense & KATA_MUSOU)
2055 set_action(ACTION_NONE);
2058 /* Get a "repeated" direction */
2059 if (get_rep_dir(&dir,FALSE))
2061 /* Hack -- Set the run counter */
2062 running = (command_arg ? command_arg : 1000);
2071 * @brief 「留まる」動作コマンドのメインルーチン /
2072 * Stay still. Search. Enter stores.
2073 * Pick up treasure if "pickup" is true.
2074 * @param pickup アイテムの自動拾いを行うならTRUE
2077 void do_cmd_stay(bool pickup)
2079 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2081 /* Allow repeated command */
2084 /* Set repeat count */
2085 command_rep = command_arg - 1;
2086 p_ptr->redraw |= (PR_STATE);
2088 /* Cancel the arg */
2092 p_ptr->energy_use = 100;
2094 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2095 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2100 * @brief 「休む」動作コマンドのメインルーチン /
2101 * Resting allows a player to safely restore his hp -RAK-
2104 void do_cmd_rest(void)
2107 set_action(ACTION_NONE);
2109 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2115 if (hex_spelling_any()) stop_hex_spell_all();
2117 /* Prompt for time if needed */
2118 if (command_arg <= 0)
2120 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2121 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2127 strcpy(out_val, "&");
2129 /* Ask for duration */
2130 if (!get_string(p, out_val, 4)) return;
2132 /* Rest until done */
2133 if (out_val[0] == '&')
2135 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2139 else if (out_val[0] == '*')
2141 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2147 command_arg = (COMMAND_ARG)atoi(out_val);
2148 if (command_arg <= 0) return;
2154 if (command_arg > 9999) command_arg = 9999;
2156 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2158 /* Take a turn (?) */
2159 p_ptr->energy_use = 100;
2161 /* The sin of sloth */
2162 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2164 /* Why are you sleeping when there's no need? WAKE UP!*/
2165 if ((p_ptr->chp == p_ptr->mhp) &&
2166 (p_ptr->csp == p_ptr->msp) &&
2167 !p_ptr->blind && !p_ptr->confused &&
2168 !p_ptr->poisoned && !p_ptr->afraid &&
2169 !p_ptr->stun && !p_ptr->cut &&
2170 !p_ptr->slow && !p_ptr->paralyzed &&
2171 !p_ptr->image && !p_ptr->word_recall &&
2172 !p_ptr->alter_reality)
2173 chg_virtue(V_DILIGENCE, -1);
2175 /* Save the rest code */
2176 resting = command_arg;
2177 p_ptr->action = ACTION_REST;
2178 p_ptr->update |= (PU_BONUS);
2179 update_creature(p_ptr);
2181 p_ptr->redraw |= (PR_STATE);
2189 * @brief 矢弾を射撃した場合の破損確率を返す /
2190 * Determines the odds of an object breaking when thrown at a monster
2191 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2194 * Note that artifacts never break, see the "drop_near()" function.
2196 static PERCENTAGE breakage_chance(object_type *o_ptr)
2198 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2200 /* Examine the snipe type */
2203 if (snipe_type == SP_KILL_WALL) return (100);
2204 if (snipe_type == SP_EXPLODE) return (100);
2205 if (snipe_type == SP_PIERCE) return (100);
2206 if (snipe_type == SP_FINAL) return (100);
2207 if (snipe_type == SP_NEEDLE) return (100);
2208 if (snipe_type == SP_EVILNESS) return (40);
2209 if (snipe_type == SP_HOLYNESS) return (40);
2212 /* Examine the item type */
2213 switch (o_ptr->tval)
2229 /* Sometimes break */
2234 return (20 - archer_bonus * 2);
2239 return (10 - archer_bonus);
2247 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2248 * Determines the odds of an object breaking when thrown at a monster
2249 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2250 * @param tdam 計算途中のダメージ量
2251 * @param m_ptr 目標モンスターの構造体参照ポインタ
2252 * @return スレイ倍率をかけたダメージ量
2254 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2258 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2260 BIT_FLAGS flgs[TR_FLAG_SIZE];
2261 object_flags(o_ptr, flgs);
2263 /* Some "weapons" and "ammo" do extra damage */
2264 switch (o_ptr->tval)
2270 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2272 if (is_original_ap_and_seen(m_ptr))
2274 r_ptr->r_flags3 |= RF3_ANIMAL;
2276 if (mult < 17) mult = 17;
2279 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2281 if (is_original_ap_and_seen(m_ptr))
2283 r_ptr->r_flags3 |= RF3_ANIMAL;
2285 if (mult < 27) mult = 27;
2288 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2290 if (is_original_ap_and_seen(m_ptr))
2292 r_ptr->r_flags3 |= RF3_EVIL;
2294 if (mult < 15) mult = 15;
2297 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2299 if (is_original_ap_and_seen(m_ptr))
2301 r_ptr->r_flags3 |= RF3_EVIL;
2303 if (mult < 25) mult = 25;
2306 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2308 if (is_original_ap_and_seen(m_ptr))
2310 r_ptr->r_flags2 |= RF2_HUMAN;
2312 if (mult < 17) mult = 17;
2315 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2317 if (is_original_ap_and_seen(m_ptr))
2319 r_ptr->r_flags2 |= RF2_HUMAN;
2321 if (mult < 27) mult = 27;
2324 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2326 if (is_original_ap_and_seen(m_ptr))
2328 r_ptr->r_flags3 |= RF3_UNDEAD;
2330 if (mult < 20) mult = 20;
2333 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2335 if (is_original_ap_and_seen(m_ptr))
2337 r_ptr->r_flags3 |= RF3_UNDEAD;
2339 if (mult < 30) mult = 30;
2342 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2344 if (is_original_ap_and_seen(m_ptr))
2346 r_ptr->r_flags3 |= RF3_DEMON;
2348 if (mult < 20) mult = 20;
2351 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2353 if (is_original_ap_and_seen(m_ptr))
2355 r_ptr->r_flags3 |= RF3_DEMON;
2357 if (mult < 30) mult = 30;
2360 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
2362 if (is_original_ap_and_seen(m_ptr))
2364 r_ptr->r_flags3 |= RF3_ORC;
2366 if (mult < 20) mult = 20;
2369 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
2371 if (is_original_ap_and_seen(m_ptr))
2373 r_ptr->r_flags3 |= RF3_ORC;
2375 if (mult < 30) mult = 30;
2378 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2380 if (is_original_ap_and_seen(m_ptr))
2382 r_ptr->r_flags3 |= RF3_TROLL;
2385 if (mult < 20) mult = 20;
2388 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2390 if (is_original_ap_and_seen(m_ptr))
2392 r_ptr->r_flags3 |= RF3_TROLL;
2394 if (mult < 30) mult = 30;
2397 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2399 if (is_original_ap_and_seen(m_ptr))
2401 r_ptr->r_flags3 |= RF3_GIANT;
2403 if (mult < 20) mult = 20;
2406 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2408 if (is_original_ap_and_seen(m_ptr))
2410 r_ptr->r_flags3 |= RF3_GIANT;
2412 if (mult < 30) mult = 30;
2415 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2417 if (is_original_ap_and_seen(m_ptr))
2419 r_ptr->r_flags3 |= RF3_DRAGON;
2421 if (mult < 20) mult = 20;
2424 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2426 if (is_original_ap_and_seen(m_ptr))
2428 r_ptr->r_flags3 |= RF3_DRAGON;
2430 if (mult < 30) mult = 30;
2431 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
2432 (inventory[INVEN_BOW].name1 == ART_BARD))
2436 if (have_flag(flgs, TR_BRAND_ACID))
2438 /* Notice immunity */
2439 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2441 if (is_original_ap_and_seen(m_ptr))
2443 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2448 if (mult < 17) mult = 17;
2452 if (have_flag(flgs, TR_BRAND_ELEC))
2454 /* Notice immunity */
2455 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2457 if (is_original_ap_and_seen(m_ptr))
2459 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2464 if (mult < 17) mult = 17;
2468 if (have_flag(flgs, TR_BRAND_FIRE))
2470 /* Notice immunity */
2471 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2473 if (is_original_ap_and_seen(m_ptr))
2475 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2478 /* Otherwise, take the damage */
2481 if (r_ptr->flags3 & RF3_HURT_FIRE)
2483 if (mult < 25) mult = 25;
2484 if (is_original_ap_and_seen(m_ptr))
2486 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2489 else if (mult < 17) mult = 17;
2493 if (have_flag(flgs, TR_BRAND_COLD))
2495 /* Notice immunity */
2496 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2498 if (is_original_ap_and_seen(m_ptr))
2500 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2503 /* Otherwise, take the damage */
2506 if (r_ptr->flags3 & RF3_HURT_COLD)
2508 if (mult < 25) mult = 25;
2509 if (is_original_ap_and_seen(m_ptr))
2511 r_ptr->r_flags3 |= RF3_HURT_COLD;
2514 else if (mult < 17) mult = 17;
2518 if (have_flag(flgs, TR_BRAND_POIS))
2520 /* Notice immunity */
2521 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2523 if (is_original_ap_and_seen(m_ptr))
2525 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2528 /* Otherwise, take the damage */
2531 if (mult < 17) mult = 17;
2535 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2537 p_ptr->csp -= (1+(p_ptr->msp / 30));
2538 p_ptr->redraw |= (PR_MANA);
2539 mult = mult * 5 / 2;
2546 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2548 /* Return the total damage */
2549 return (tdam * mult / 10);
2554 * @brief 射撃処理のサブルーチン /
2555 * Fire an object from the pack or floor.
2556 * @param item 射撃するオブジェクトの所持ID
2557 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2561 * You may only fire items that "match" your missile launcher.
2563 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2565 * See "calc_bonuses()" for more calculations and such.
2567 * Note that "firing" a missile is MUCH better than "throwing" it.
2569 * Note: "unseen" monsters are very hard to hit.
2571 * Objects are more likely to break if they "attempt" to hit a monster.
2573 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2575 * The "extra shot" code works by decreasing the amount of energy
2576 * required to make each shot, spreading the shots out over time.
2578 * Note that when firing missiles, the launcher multiplier is applied
2579 * after all the bonuses are added in, making multipliers very useful.
2581 * Note that Bows of "Extra Might" get extra range and an extra bonus
2582 * for the damage multiplier.
2584 * Note that Bows of "Extra Shots" give an extra shot.
2587 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2591 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2592 int tdam_base, tdis, thits, tmul;
2594 int cur_dis, visible;
2602 bool hit_body = FALSE;
2604 GAME_TEXT o_name[MAX_NLEN];
2606 u16b path_g[512]; /* For calcuration of path length */
2608 int msec = delay_factor * delay_factor * delay_factor;
2611 bool stick_to = FALSE;
2613 /* Access the item (if in the pack) */
2616 o_ptr = &inventory[item];
2620 o_ptr = &o_list[0 - item];
2623 /* Sniper - Cannot shot a single arrow twice */
2624 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2626 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2628 /* Use the proper number of shots */
2629 thits = p_ptr->num_fire;
2631 /* Use a base distance */
2634 /* Base damage from thrown object plus launcher bonus */
2635 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2637 /* Actually "fire" the object */
2638 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2639 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2640 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2642 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2644 p_ptr->energy_use = bow_energy(j_ptr->sval);
2645 tmul = bow_tmul(j_ptr->sval);
2647 /* Get extra "power" from "extra might" */
2648 if (p_ptr->xtra_might) tmul++;
2650 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2652 /* Boost the damage */
2657 tdis = 13 + tmul/80;
2658 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2661 tdis -= (5 - (p_ptr->concent + 1) / 2);
2666 project_length = tdis + 1;
2668 /* Get a direction (or cancel) */
2669 if (!get_aim_dir(&dir))
2671 p_ptr->energy_use = 0;
2673 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2675 /* need not to reset project_length (already did)*/
2680 /* Predict the "target" location */
2681 tx = p_ptr->x + 99 * ddx[dir];
2682 ty = p_ptr->y + 99 * ddy[dir];
2684 /* Check for "target request" */
2685 if ((dir == 5) && target_okay())
2691 /* Get projection path length */
2692 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2694 project_length = 0; /* reset to default */
2696 /* Don't shoot at my feet */
2697 if (tx == p_ptr->x && ty == p_ptr->y)
2699 p_ptr->energy_use = 0;
2701 /* project_length is already reset to 0 */
2707 /* Take a (partial) turn */
2708 p_ptr->energy_use = (p_ptr->energy_use / thits);
2711 /* Sniper - Difficult to shot twice at 1 turn */
2712 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2714 /* Sniper - Repeat shooting when double shots */
2715 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2718 /* Start at the player */
2723 /* Obtain a local object */
2724 object_copy(q_ptr, o_ptr);
2729 /* Reduce and describe inventory */
2732 inven_item_increase(item, -1);
2733 inven_item_describe(item);
2734 inven_item_optimize(item);
2737 /* Reduce and describe floor item */
2740 floor_item_increase(0 - item, -1);
2741 floor_item_optimize(0 - item);
2747 /* Save the old location */
2751 /* The shot does not hit yet */
2754 /* Travel until stopped */
2755 for (cur_dis = 0; cur_dis <= tdis; )
2759 /* Hack -- Stop at the target */
2760 if ((y == ty) && (x == tx)) break;
2762 /* Calculate the new location (see "project()") */
2765 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2768 if (snipe_type == SP_KILL_WALL)
2770 c_ptr = &cave[ny][nx];
2772 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2774 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2775 /* Forget the wall */
2776 c_ptr->info &= ~(CAVE_MARK);
2777 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2779 /* Destroy the wall */
2780 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2787 /* Stopped by walls/doors */
2788 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2790 /* Advance the distance */
2794 if (snipe_type == SP_LITE)
2796 cave[ny][nx].info |= (CAVE_GLOW);
2801 /* The player can see the (on screen) missile */
2802 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2804 char c = object_char(q_ptr);
2805 byte a = object_attr(q_ptr);
2807 /* Draw, Hilite, Fresh, Pause, Erase */
2808 print_rel(c, a, ny, nx);
2809 move_cursor_relative(ny, nx);
2811 Term_xtra(TERM_XTRA_DELAY, msec);
2816 /* The player cannot see the missile */
2819 /* Pause anyway, for consistancy */
2820 Term_xtra(TERM_XTRA_DELAY, msec);
2824 if (snipe_type == SP_KILL_TRAP)
2826 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
2827 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
2831 if (snipe_type == SP_EVILNESS)
2833 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
2838 /* Save the old location */
2842 /* Save the new location */
2846 /* Monster here, Try to hit it */
2847 if (cave[y][x].m_idx)
2849 cave_type *c_mon_ptr = &cave[y][x];
2851 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
2852 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2854 /* Check the visibility */
2855 visible = m_ptr->ml;
2857 /* Note the collision */
2860 if (MON_CSLEEP(m_ptr))
2862 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
2863 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
2866 if ((r_ptr->level + 10) > p_ptr->lev)
2868 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
2869 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
2872 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
2873 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
2874 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
2875 else if (p_ptr->lev > 34) amount = 2;
2876 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
2877 p_ptr->update |= (PU_BONUS);
2883 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
2884 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
2887 p_ptr->skill_exp[GINOU_RIDING] += 1;
2888 p_ptr->update |= (PU_BONUS);
2892 /* Did we hit it (penalize range) */
2893 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2896 int tdam = tdam_base;
2898 /* Get extra damage from concentration */
2899 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
2901 /* Handle unseen monster */
2904 /* Invisible monster */
2905 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2908 /* Handle visible monster */
2911 GAME_TEXT m_name[MAX_NLEN];
2913 /* Get "the monster" or "it" */
2914 monster_desc(m_name, m_ptr, 0);
2916 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2920 /* Hack -- Track this monster race */
2921 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2923 /* Hack -- Track this monster */
2924 health_track(c_mon_ptr->m_idx);
2928 if (snipe_type == SP_NEEDLE)
2930 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
2931 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
2933 GAME_TEXT m_name[MAX_NLEN];
2935 /* Get "the monster" or "it" */
2936 monster_desc(m_name, m_ptr, 0);
2938 tdam = m_ptr->hp + 1;
2939 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
2945 /* Apply special damage */
2946 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
2947 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
2949 /* No negative damage */
2950 if (tdam < 0) tdam = 0;
2952 /* Modify the damage */
2953 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2956 msg_format_wizard(CHEAT_MONSTER,
2957 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2958 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2961 if (snipe_type == SP_EXPLODE)
2963 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
2965 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
2966 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
2971 if (snipe_type == SP_HOLYNESS)
2973 cave[ny][nx].info |= (CAVE_GLOW);
2978 /* Hit the monster, check for death */
2979 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2988 if (object_is_fixed_artifact(q_ptr) &&
2989 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
2991 GAME_TEXT m_name[MAX_NLEN];
2993 monster_desc(m_name, m_ptr, 0);
2996 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
2999 message_pain(c_mon_ptr->m_idx, tdam);
3001 /* Anger the monster */
3002 if (tdam > 0) anger_monster(m_ptr);
3004 if (fear && m_ptr->ml)
3006 GAME_TEXT m_name[MAX_NLEN];
3008 monster_desc(m_name, m_ptr, 0);
3009 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3012 set_target(m_ptr, p_ptr->y, p_ptr->x);
3015 if (snipe_type == SP_RUSH)
3017 int n = randint1(5) + 3;
3018 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3020 for ( ; cur_dis <= tdis; )
3027 /* Calculate the new location (see "project()") */
3028 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3030 /* Stopped by wilderness boundary */
3031 if (!in_bounds2(ny, nx)) break;
3033 /* Stopped by walls/doors */
3034 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3036 /* Stopped by monsters */
3037 if (!cave_empty_bold(ny, nx)) break;
3039 cave[ny][nx].m_idx = m_idx;
3040 cave[oy][ox].m_idx = 0;
3045 update_monster(c_mon_ptr->m_idx, TRUE);
3051 Term_xtra(TERM_XTRA_DELAY, msec);
3063 if (snipe_type == SP_PIERCE)
3065 if(p_ptr->concent < 1) break;
3075 /* Chance of breakage (during attacks) */
3076 j = (hit_body ? breakage_chance(q_ptr) : 0);
3080 MONSTER_IDX m_idx = cave[y][x].m_idx;
3081 monster_type *m_ptr = &m_list[m_idx];
3082 OBJECT_IDX o_idx = o_pop();
3086 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3087 if (object_is_fixed_artifact(q_ptr))
3089 a_info[j_ptr->name1].cur_num = 0;
3094 o_ptr = &o_list[o_idx];
3095 object_copy(o_ptr, q_ptr);
3098 o_ptr->marked &= OM_TOUCHED;
3100 /* Forget location */
3101 o_ptr->iy = o_ptr->ix = 0;
3103 /* Memorize monster */
3104 o_ptr->held_m_idx = m_idx;
3107 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3110 m_ptr->hold_o_idx = o_idx;
3112 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3114 /* Drop (or break) near that location */
3115 (void)drop_near(q_ptr, j, y, x);
3119 /* Drop (or break) near that location */
3120 (void)drop_near(q_ptr, j, prev_y, prev_x);
3123 /* Sniper - Repeat shooting when double shots */
3126 /* Sniper - Loose his/her concentration after any shot */
3127 if (p_ptr->concent) reset_concentration(FALSE);
3131 * @brief 射撃処理のメインルーチン
3134 void do_cmd_fire(void)
3137 object_type *j_ptr, *ammo_ptr;
3140 if(p_ptr->wild_mode) return;
3142 is_fired = FALSE; /* not fired yet */
3144 /* Get the "bow" (if any) */
3145 j_ptr = &inventory[INVEN_BOW];
3147 /* Require a launcher */
3150 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3155 if (j_ptr->sval == SV_CRIMSON)
3157 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3162 if (j_ptr->sval == SV_HARP)
3164 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3170 if (p_ptr->special_defense & KATA_MUSOU)
3172 set_action(ACTION_NONE);
3175 /* Require proper missile */
3176 item_tester_tval = p_ptr->tval_ammo;
3178 q = _("どれを撃ちますか? ", "Fire which item? ");
3179 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3182 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3190 do_cmd_fire_aux(item, j_ptr);
3192 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3194 /* Sniper actions after some shootings */
3195 if (snipe_type == SP_AWAY)
3197 teleport_player(10 + (p_ptr->concent * 2), 0L);
3199 if (snipe_type == SP_FINAL)
3201 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3202 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3203 (void)set_stun(p_ptr->stun + randint1(25));
3209 * @brief 投射処理メインルーチン /
3210 * Throw an object from the pack or floor.
3212 * @param boomerang ブーメラン処理ならばTRUE
3213 * @param shuriken 忍者の手裏剣処理ならばTRUE
3214 * @return ターンを消費した場合TRUEを返す
3217 * Note: "unseen" monsters are very hard to hit.
3219 * Should throwing a weapon do full damage? Should it allow the magic
3220 * to hit bonus of the weapon to have an effect? Should it ever cause
3221 * the item to be destroyed? Should it do any damage at all?
3224 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3229 POSITION y, x, ty, tx, prev_y, prev_x;
3230 POSITION ny[19], nx[19];
3231 int chance, tdam, tdis;
3232 int mul, div, dd, ds;
3233 int cur_dis, visible;
3240 bool hit_body = FALSE;
3241 bool hit_wall = FALSE;
3242 bool equiped_item = FALSE;
3243 bool return_when_thrown = FALSE;
3245 GAME_TEXT o_name[MAX_NLEN];
3247 int msec = delay_factor * delay_factor * delay_factor;
3249 BIT_FLAGS flgs[TR_FLAG_SIZE];
3251 bool come_back = FALSE;
3252 bool do_drop = TRUE;
3254 if (p_ptr->wild_mode) return FALSE;
3256 if (p_ptr->special_defense & KATA_MUSOU)
3258 set_action(ACTION_NONE);
3267 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3269 item_tester_hook = item_tester_hook_boomerang;
3270 q = _("どの武器を投げますか? ", "Throw which item? ");
3271 s = _("投げる武器がない。", "You have nothing to throw.");
3272 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
3279 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3280 else item = INVEN_RARM;
3284 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3285 s = _("投げるアイテムがない。", "You have nothing to throw.");
3286 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
3294 /* Item is cursed */
3295 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3297 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3302 if (p_ptr->inside_arena && !boomerang)
3304 if (o_ptr->tval != TV_SPIKE)
3306 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3315 /* Obtain a local object */
3316 object_copy(q_ptr, o_ptr);
3318 /* Extract the thrown object's flags. */
3319 object_flags(q_ptr, flgs);
3320 torch_flags(q_ptr, flgs);
3322 /* Distribute the charges of rods/wands between the stacks */
3323 distribute_charges(o_ptr, q_ptr, 1);
3328 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3330 if (p_ptr->mighty_throw) mult += 3;
3332 /* Extract a "distance multiplier" */
3333 /* Changed for 'launcher' mutation */
3334 mul = 10 + 2 * (mult - 1);
3336 /* Enforce a minimum "weight" of one pound */
3337 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3338 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3340 /* Hack -- Distance -- Reward strength, penalize weight */
3341 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3343 /* Max distance of 10-18 */
3344 if (tdis > mul) tdis = mul;
3348 ty = randint0(101) - 50 + p_ptr->y;
3349 tx = randint0(101) - 50 + p_ptr->x;
3353 project_length = tdis + 1;
3355 /* Get a direction (or cancel) */
3356 if (!get_aim_dir(&dir)) return FALSE;
3358 /* Predict the "target" location */
3359 tx = p_ptr->x + 99 * ddx[dir];
3360 ty = p_ptr->y + 99 * ddy[dir];
3362 /* Check for "target request" */
3363 if ((dir == 5) && target_okay())
3369 project_length = 0; /* reset to default */
3372 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3373 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3374 return_when_thrown = TRUE;
3376 /* Reduce and describe inventory */
3379 inven_item_increase(item, -1);
3380 if (!return_when_thrown)
3381 inven_item_describe(item);
3382 inven_item_optimize(item);
3385 /* Reduce and describe floor item */
3388 floor_item_increase(0 - item, -1);
3389 floor_item_optimize(0 - item);
3391 if (item >= INVEN_RARM)
3393 equiped_item = TRUE;
3394 p_ptr->redraw |= (PR_EQUIPPY);
3397 p_ptr->energy_use = 100;
3399 /* Rogue and Ninja gets bonus */
3400 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3401 p_ptr->energy_use -= p_ptr->lev;
3403 /* Start at the player */
3409 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3410 else shuriken = FALSE;
3412 /* Chance of hitting */
3413 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3414 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3415 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3417 if (shuriken) chance *= 2;
3419 /* Save the old location */
3423 /* Travel until stopped */
3424 for (cur_dis = 0; cur_dis <= tdis; )
3426 /* Hack -- Stop at the target */
3427 if ((y == ty) && (x == tx)) break;
3429 /* Calculate the new location (see "project()") */
3432 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3434 /* Stopped by walls/doors */
3435 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3438 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3441 /* The player can see the (on screen) missile */
3442 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3444 char c = object_char(q_ptr);
3445 byte a = object_attr(q_ptr);
3447 /* Draw, Hilite, Fresh, Pause, Erase */
3448 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3449 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3451 Term_xtra(TERM_XTRA_DELAY, msec);
3452 lite_spot(ny[cur_dis], nx[cur_dis]);
3456 /* The player cannot see the missile */
3459 /* Pause anyway, for consistancy */
3460 Term_xtra(TERM_XTRA_DELAY, msec);
3463 /* Save the old location */
3467 /* Save the new location */
3471 /* Advance the distance */
3474 /* Monster here, Try to hit it */
3475 if (cave[y][x].m_idx)
3477 cave_type *c_ptr = &cave[y][x];
3478 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3480 /* Check the visibility */
3481 visible = m_ptr->ml;
3483 /* Note the collision */
3486 /* Did we hit it (penalize range) */
3487 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3491 /* Handle unseen monster */
3494 /* Invisible monster */
3495 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3498 /* Handle visible monster */
3501 GAME_TEXT m_name[MAX_NLEN];
3502 monster_desc(m_name, m_ptr, 0);
3503 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3507 /* Hack -- Track this monster race */
3508 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3510 /* Hack -- Track this monster */
3511 health_track(c_ptr->m_idx);
3515 /* Hack -- Base damage from thrown object */
3518 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3519 tdam = damroll(dd, ds);
3520 /* Apply special damage */
3521 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3522 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3523 if (q_ptr->to_d > 0)
3524 tdam += q_ptr->to_d;
3526 tdam += -q_ptr->to_d;
3530 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3531 tdam += p_ptr->to_d_m;
3533 else if (have_flag(flgs, TR_THROW))
3536 tdam += p_ptr->to_d_m;
3544 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3547 /* No negative damage */
3548 if (tdam < 0) tdam = 0;
3550 /* Modify the damage */
3551 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3553 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3554 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3556 /* Hit the monster, check for death */
3557 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
3565 message_pain(c_ptr->m_idx, tdam);
3567 /* Anger the monster */
3568 if ((tdam > 0) && !object_is_potion(q_ptr))
3569 anger_monster(m_ptr);
3571 if (fear && m_ptr->ml)
3574 GAME_TEXT m_name[MAX_NLEN];
3575 monster_desc(m_name, m_ptr, 0);
3576 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3586 /* decrease toach's fuel */
3587 if (hit_body) torch_lost_fuel(q_ptr);
3589 /* Chance of breakage (during attacks) */
3590 j = (hit_body ? breakage_chance(q_ptr) : 0);
3592 /* Figurines transform */
3593 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3597 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3598 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3599 else if (object_is_cursed(q_ptr))
3600 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3605 /* Potions smash open */
3606 if (object_is_potion(q_ptr))
3608 if (hit_body || hit_wall || (randint1(100) < j))
3610 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3612 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3614 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3616 /* ToDo (Robert): fix the invulnerability */
3617 if (cave[y][x].m_idx &&
3618 is_friendly(&m_list[cave[y][x].m_idx]) &&
3619 !MON_INVULNER(m_ptr))
3621 GAME_TEXT m_name[MAX_NLEN];
3622 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3623 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3624 set_hostile(&m_list[cave[y][x].m_idx]);
3635 if (return_when_thrown)
3637 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3638 char o2_name[MAX_NLEN];
3639 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3642 if (boomerang) back_chance += 4+randint1(5);
3643 if (super_boomerang) back_chance += 100;
3644 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3646 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3648 for (i = cur_dis - 1; i > 0; i--)
3650 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3652 char c = object_char(q_ptr);
3653 byte a = object_attr(q_ptr);
3655 /* Draw, Hilite, Fresh, Pause, Erase */
3656 print_rel(c, a, ny[i], nx[i]);
3657 move_cursor_relative(ny[i], nx[i]);
3659 Term_xtra(TERM_XTRA_DELAY, msec);
3660 lite_spot(ny[i], nx[i]);
3665 /* Pause anyway, for consistancy */
3666 Term_xtra(TERM_XTRA_DELAY, msec);
3669 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3671 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3678 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3682 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3690 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3696 if (item == INVEN_RARM || item == INVEN_LARM)
3698 /* Access the wield slot */
3699 o_ptr = &inventory[item];
3701 /* Wear the new stuff */
3702 object_copy(o_ptr, q_ptr);
3704 /* Increase the weight */
3705 p_ptr->total_weight += q_ptr->weight;
3707 /* Increment the equip counter by hand */
3710 /* Recalculate torch */
3711 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
3712 p_ptr->window |= (PW_EQUIP);
3720 else if (equiped_item)
3728 if (cave_have_flag_bold(y, x, FF_PROJECT))
3730 (void)drop_near(q_ptr, j, y, x);
3734 (void)drop_near(q_ptr, j, prev_y, prev_x);
3744 * Hack: travel command
3746 #define TRAVEL_UNABLE 9999
3748 static int flow_head = 0;
3749 static int flow_tail = 0;
3750 static POSITION temp2_x[MAX_SHORT];
3751 static POSITION temp2_y[MAX_SHORT];
3754 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3757 void forget_travel_flow(void)
3760 /* Check the entire dungeon / Forget the old data */
3761 for (y = 0; y < cur_hgt; y++)
3763 for (x = 0; x < cur_wid; x++)
3766 travel.cost[y][x] = MAX_SHORT;
3769 travel.y = travel.x = 0;
3773 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
3778 static int travel_flow_cost(POSITION y, POSITION x)
3780 feature_type *f_ptr = &f_info[cave[y][x].feat];
3783 /* Avoid obstacles (ex. trees) */
3784 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
3787 if (have_flag(f_ptr->flags, FF_WATER))
3789 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
3793 if (have_flag(f_ptr->flags, FF_LAVA))
3796 if (!p_ptr->resist_fire) lava *= 2;
3797 if (!p_ptr->levitation) lava *= 2;
3798 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
3803 /* Detected traps and doors */
3804 if (cave[y][x].info & (CAVE_MARK))
3806 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
3807 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
3814 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
3818 * @param wall プレイヤーが壁の中にいるならばTRUE
3821 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
3823 cave_type *c_ptr = &cave[y][x];
3824 feature_type *f_ptr = &f_info[c_ptr->feat];
3825 int old_head = flow_head;
3827 int base_cost = (n % TRAVEL_UNABLE);
3828 int from_wall = (n / TRAVEL_UNABLE);
3831 /* Ignore out of bounds */
3832 if (!in_bounds(y, x)) return;
3834 /* Ignore unknown grid except in wilderness */
3835 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
3837 /* Ignore "walls" and "rubble" (include "secret doors") */
3838 if (have_flag(f_ptr->flags, FF_WALL) ||
3839 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3840 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
3841 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
3843 if (!wall || !from_wall) return;
3844 add_cost += TRAVEL_UNABLE;
3848 add_cost = travel_flow_cost(y, x);
3851 cost = base_cost + add_cost;
3853 /* Ignore lower cost entries */
3854 if (travel.cost[y][x] <= cost) return;
3856 /* Save the flow cost */
3857 travel.cost[y][x] = cost;
3859 /* Enqueue that entry */
3860 temp2_y[flow_head] = y;
3861 temp2_x[flow_head] = x;
3863 /* Advance the queue */
3864 if (++flow_head == MAX_SHORT) flow_head = 0;
3866 /* Hack -- notice overflow by forgetting new entry */
3867 if (flow_head == flow_tail) flow_head = old_head;
3873 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
3874 * @param ty 目標地点のY座標
3875 * @param tx 目標地点のX座標
3878 static void travel_flow(POSITION ty, POSITION tx)
3882 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
3884 /* Reset the "queue" */
3885 flow_head = flow_tail = 0;
3887 /* is player in the wall? */
3888 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
3890 /* Start at the target grid */
3891 travel_flow_aux(ty, tx, 0, wall);
3893 /* Now process the queue */
3894 while (flow_head != flow_tail)
3896 /* Extract the next entry */
3897 y = temp2_y[flow_tail];
3898 x = temp2_x[flow_tail];
3900 /* Forget that entry */
3901 if (++flow_tail == MAX_SHORT) flow_tail = 0;
3903 /* Ignore too far entries */
3904 //if (distance(ty, tx, y, x) > 100) continue;
3906 /* Add the "children" */
3907 for (d = 0; d < 8; d++)
3909 /* Add that child if "legal" */
3910 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
3914 /* Forget the flow info */
3915 flow_head = flow_tail = 0;
3919 * @brief トラベル処理のメインルーチン
3922 void do_cmd_travel(void)
3926 POSITION dx, dy, sx, sy;
3927 feature_type *f_ptr;
3929 if (travel.x != 0 && travel.y != 0 &&
3930 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3935 else if (!tgt_pt(&x, &y)) return;
3937 if ((x == p_ptr->x) && (y == p_ptr->y))
3939 msg_print(_("すでにそこにいます!", "You are already there!!"));
3943 f_ptr = &f_info[cave[y][x].feat];
3945 if ((cave[y][x].info & CAVE_MARK) &&
3946 (have_flag(f_ptr->flags, FF_WALL) ||
3947 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3948 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3950 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3954 forget_travel_flow();
3960 /* Travel till 255 steps */
3966 /* Decides first direction */
3967 dx = abs(p_ptr->x - x);
3968 dy = abs(p_ptr->y - y);
3969 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3970 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3972 for (i = 1; i <= 9; i++)
3974 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;