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"
22 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
23 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
24 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
26 bool confirm_leave_level(bool down_stair)
28 quest_type *q_ptr = &quest[p_ptr->inside_quest];
30 /* Confirm leaving from once only quest */
31 if (confirm_quest && p_ptr->inside_quest &&
32 (q_ptr->type == QUEST_TYPE_RANDOM ||
33 (q_ptr->flags & QUEST_FLAG_ONCE &&
34 q_ptr->status != QUEST_STATUS_COMPLETED) ||
35 (q_ptr->flags & QUEST_FLAG_TOWER &&
36 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
37 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
39 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
40 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
50 * @brief 階段を使って階層を昇る処理 / Go up one level
53 void do_cmd_go_up(void)
58 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
59 feature_type *f_ptr = &f_info[c_ptr->feat];
63 if (p_ptr->special_defense & KATA_MUSOU)
65 set_action(ACTION_NONE);
69 if (!have_flag(f_ptr->flags, FF_LESS))
71 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
76 if (have_flag(f_ptr->flags, FF_QUEST))
78 /* Cancel the command */
79 if (!confirm_leave_level(FALSE)) return;
83 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
84 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
86 msg_print(_("上の階に登った。", "You enter the up staircase."));
90 p_ptr->inside_quest = c_ptr->special;
92 /* Activate the quest */
93 if (!quest[p_ptr->inside_quest].status)
95 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
97 init_flags = INIT_ASSIGN;
98 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
100 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
103 /* Leaving a quest */
104 if (!p_ptr->inside_quest)
110 p_ptr->leaving = TRUE;
115 /* Hack -- take a turn */
116 p_ptr->energy_use = 100;
118 /* End the command */
128 go_up = confirm_leave_level(FALSE);
131 /* Cancel the command */
134 /* Hack -- take a turn */
135 p_ptr->energy_use = 100;
137 if (autosave_l) do_cmd_save_game(TRUE);
139 /* For a random quest */
140 if (p_ptr->inside_quest &&
141 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
145 p_ptr->inside_quest = 0;
148 /* For a fixed quest */
149 if (p_ptr->inside_quest &&
150 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
154 p_ptr->inside_quest = c_ptr->special;
159 /* For normal dungeon and random quest */
163 if (have_flag(f_ptr->flags, FF_SHAFT))
165 /* Create a way back */
166 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
172 /* Create a way back */
173 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
178 /* Get out from current dungeon */
179 if (dun_level - up_num < d_info[dungeon_type].mindepth)
182 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
185 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
186 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
187 else if (up_num == dun_level)
188 msg_print(_("地上に戻った。", "You go back to the surface."));
190 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
193 p_ptr->leaving = TRUE;
198 * @brief 階段を使って階層を降りる処理 / Go down one level
201 void do_cmd_go_down(void)
204 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
205 feature_type *f_ptr = &f_info[c_ptr->feat];
207 bool fall_trap = FALSE;
210 if (p_ptr->special_defense & KATA_MUSOU)
212 set_action(ACTION_NONE);
216 if (!have_flag(f_ptr->flags, FF_MORE))
218 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
222 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
225 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
230 /* Quest down stairs */
231 else if (have_flag(f_ptr->flags, FF_QUEST))
233 /* Confirm Leaving */
234 if(!confirm_leave_level(TRUE)) return;
236 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
237 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
239 msg_print(_("下の階に降りた。", "You enter the down staircase."));
244 p_ptr->inside_quest = c_ptr->special;
246 /* Activate the quest */
247 if (!quest[p_ptr->inside_quest].status)
249 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
251 init_flags = INIT_ASSIGN;
252 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
254 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
257 /* Leaving a quest */
258 if (!p_ptr->inside_quest)
264 p_ptr->leaving = TRUE;
270 /* Hack -- take a turn */
271 p_ptr->energy_use = 100;
276 DUNGEON_IDX target_dungeon = 0;
280 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
282 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
284 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
287 if (!max_dlv[target_dungeon])
289 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
290 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
291 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
294 /* Save old player position */
295 p_ptr->oldpx = p_ptr->x;
296 p_ptr->oldpy = p_ptr->y;
297 dungeon_type = target_dungeon;
300 * Clear all saved floors
301 * and create a first saved floor
303 prepare_change_floor_mode(CFM_FIRST_FLOOR);
306 /* Hack -- take a turn */
307 p_ptr->energy_use = 100;
309 if (autosave_l) do_cmd_save_game(TRUE);
312 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
317 /* Enter the dungeon just now */
318 p_ptr->enter_dungeon = TRUE;
319 down_num = d_info[dungeon_type].mindepth;
324 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
325 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
330 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
337 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
341 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
342 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
344 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
350 p_ptr->leaving = TRUE;
354 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
358 if (have_flag(f_ptr->flags, FF_SHAFT))
360 /* Create a way back */
361 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
365 /* Create a way back */
366 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
374 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
377 void do_cmd_search(void)
379 /* Allow repeated command */
382 /* Set repeat count */
383 command_rep = command_arg - 1;
384 p_ptr->redraw |= (PR_STATE);
389 p_ptr->energy_use = 100;
397 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
398 * @param y 走査対象にしたいマスのY座標
399 * @param x 走査対象にしたいマスのX座標
400 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
401 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
403 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
405 cave_type *c_ptr = &cave[y][x];
406 OBJECT_IDX this_o_idx, next_o_idx = 0;
408 /* Scan all objects in the grid */
409 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
413 o_ptr = &o_list[this_o_idx];
414 next_o_idx = o_ptr->next_o_idx;
416 /* Skip unknown chests XXX XXX */
417 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
419 /* Check for non empty chest */
420 if ((o_ptr->tval == TV_CHEST) &&
421 (((!trapped) && (o_ptr->pval)) || /* non empty */
422 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
431 * @brief 箱を開けるコマンドのメインルーチン /
432 * Attempt to open the given chest at the given location
433 * @param y 箱の存在するマスのY座標
434 * @param x 箱の存在するマスのX座標
435 * @param o_idx 箱のオブジェクトID
436 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
438 * Assume there is no monster blocking the destination
440 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
445 object_type *o_ptr = &o_list[o_idx];
447 p_ptr->energy_use = 100;
449 /* Attempt to unlock it */
452 /* Assume locked, and thus not open */
455 /* Get the "disarm" factor */
456 i = p_ptr->skill_dis;
458 /* Penalize some conditions */
459 if (p_ptr->blind || no_lite()) i = i / 10;
460 if (p_ptr->confused || p_ptr->image) i = i / 10;
462 /* Extract the difficulty */
465 /* Always have a small chance of success */
468 /* Success -- May still have traps */
469 if (randint0(100) < j)
471 msg_print(_("鍵をはずした。", "You have picked the lock."));
476 /* Failure -- Keep trying */
479 /* We may continue repeating */
481 if (flush_failure) flush();
482 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
487 /* Allowed to open */
490 /* Apply chest traps, if any */
491 chest_trap(y, x, o_idx);
493 /* Let the Chest drop items */
494 chest_death(FALSE, y, x, o_idx);
500 * @brief 地形は開くものであって、かつ開かれているかを返す /
501 * Attempt to open the given chest at the given location
503 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
505 static bool is_open(IDX feat)
507 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
512 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
513 * Attempt to open the given chest at the given location
514 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
515 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
516 * @param test 地形条件を判定するための関数ポインタ
517 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
519 * @details Return the number of features around (or under) the character.
520 * Usually look for doors and floor traps.
522 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
524 int d, count, xx, yy;
526 /* Count how many matches */
529 /* Check around (and under) the character */
530 for (d = 0; d < 9; d++)
535 /* if not searching under player continue */
536 if ((d == 8) && !under) continue;
538 /* Extract adjacent (legal) location */
539 yy = p_ptr->y + ddy_ddd[d];
540 xx = p_ptr->x + ddx_ddd[d];
543 c_ptr = &cave[yy][xx];
545 /* Must have knowledge */
546 if (!(c_ptr->info & (CAVE_MARK))) continue;
548 /* Feature code (applying "mimic" field) */
549 feat = get_feat_mimic(c_ptr);
551 /* Not looking for this feature */
552 if (!((*test)(feat))) continue;
557 /* Remember the location. Only useful if only one match */
568 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
569 * Return the number of chests around (or under) the character.
570 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
571 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
572 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
575 * If requested, count only trapped chests.
577 static int count_chests(POSITION *y, POSITION *x, bool trapped)
584 /* Count how many matches */
587 /* Check around (and under) the character */
588 for (d = 0; d < 9; d++)
590 /* Extract adjacent (legal) location */
591 POSITION yy = p_ptr->y + ddy_ddd[d];
592 POSITION xx = p_ptr->x + ddx_ddd[d];
594 /* No (visible) chest is there */
595 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
597 /* Grab the object */
598 o_ptr = &o_list[o_idx];
601 if (o_ptr->pval == 0) continue;
603 /* No (known) traps here */
604 if (trapped && (!object_is_known(o_ptr) ||
605 !chest_traps[o_ptr->pval])) continue;
610 /* Remember the location. Only useful if only one match */
621 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
622 * Convert an adjacent location to a direction.
623 * @param y 方角を確認したY座標
624 * @param x 方角を確認したX座標
627 static DIRECTION coords_to_dir(POSITION y, POSITION x)
629 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
636 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
638 return d[dx + 1][dy + 1];
642 * @brief 「開ける」動作コマンドのサブルーチン /
643 * Perform the basic "open" command on doors
644 * @param y 対象を行うマスのY座標
645 * @param x 対象を行うマスのX座標
646 * @return 実際に処理が行われた場合TRUEを返す。
648 * Assume destination is a closed/locked/jammed door
649 * Assume there is no monster blocking the destination
650 * Returns TRUE if repeated commands may continue
652 static bool do_cmd_open_aux(POSITION y, POSITION x)
656 /* Get requested grid */
657 cave_type *c_ptr = &cave[y][x];
658 feature_type *f_ptr = &f_info[c_ptr->feat];
661 p_ptr->energy_use = 100;
663 /* Seeing true feature code (ignore mimic) */
666 if (!have_flag(f_ptr->flags, FF_OPEN))
669 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
673 else if (f_ptr->power)
676 i = p_ptr->skill_dis;
678 /* Penalize some conditions */
679 if (p_ptr->blind || no_lite()) i = i / 10;
680 if (p_ptr->confused || p_ptr->image) i = i / 10;
682 /* Extract the lock power */
685 /* Extract the difficulty */
688 /* Always have a small chance of success */
692 if (randint0(100) < j)
694 msg_print(_("鍵をはずした。", "You have picked the lock."));
697 cave_alter_feat(y, x, FF_OPEN);
699 sound(SOUND_OPENDOOR);
709 if (flush_failure) flush();
711 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
713 /* We may keep trying */
722 cave_alter_feat(y, x, FF_OPEN);
724 sound(SOUND_OPENDOOR);
730 * @brief 「開ける」コマンドのメインルーチン /
731 * Open a closed/locked/jammed door or a closed/locked chest.
734 * Unlocking a locked door/chest is worth one experience point.
736 void do_cmd_open(void)
744 if (p_ptr->wild_mode) return;
746 if (p_ptr->special_defense & KATA_MUSOU)
748 set_action(ACTION_NONE);
751 /* Option: Pick a direction */
754 int num_doors, num_chests;
756 /* Count closed doors (locked or jammed) */
757 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
759 /* Count chests (locked) */
760 num_chests = count_chests(&y, &x, FALSE);
762 /* See if only one target */
763 if (num_doors || num_chests)
765 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
767 if (!too_many) command_dir = coords_to_dir(y, x);
771 /* Allow repeated command */
774 /* Set repeat count */
775 command_rep = command_arg - 1;
776 p_ptr->redraw |= (PR_STATE);
782 /* Get a "repeated" direction */
783 if (get_rep_dir(&dir, TRUE))
788 /* Get requested location */
789 y = p_ptr->y + ddy[dir];
790 x = p_ptr->x + ddx[dir];
792 /* Get requested grid */
795 /* Feature code (applying "mimic" field) */
796 feat = get_feat_mimic(c_ptr);
798 /* Check for chest */
799 o_idx = chest_check(y, x, FALSE);
802 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
804 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
807 /* Monster in the way */
808 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
810 p_ptr->energy_use = 100;
811 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
819 more = do_cmd_open_chest(y, x, o_idx);
826 more = do_cmd_open_aux(y, x);
830 /* Cancel repeat unless we may continue */
831 if (!more) disturb(FALSE, FALSE);
837 * @brief 「閉じる」動作コマンドのサブルーチン /
838 * Perform the basic "close" command
839 * @param y 対象を行うマスのY座標
840 * @param x 対象を行うマスのX座標
841 * @return 実際に処理が行われた場合TRUEを返す。
843 * Assume destination is an open/broken door
844 * Assume there is no monster blocking the destination
845 * Returns TRUE if repeated commands may continue
847 static bool do_cmd_close_aux(POSITION y, POSITION x)
849 cave_type *c_ptr = &cave[y][x];
850 FEAT_IDX old_feat = c_ptr->feat;
853 p_ptr->energy_use = 100;
855 /* Seeing true feature code (ignore mimic) */
858 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
860 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
862 /* Hack -- object in the way */
863 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
864 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
866 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
871 cave_alter_feat(y, x, FF_CLOSE);
874 if (old_feat == c_ptr->feat)
876 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
880 sound(SOUND_SHUTDOOR);
889 * @brief 「閉じる」コマンドのメインルーチン /
890 * Close an open door.
893 * Unlocking a locked door/chest is worth one experience point.
895 void do_cmd_close(void)
902 if (p_ptr->wild_mode) return;
904 if (p_ptr->special_defense & KATA_MUSOU)
906 set_action(ACTION_NONE);
909 /* Option: Pick a direction */
912 /* Count open doors */
913 if (count_dt(&y, &x, is_open, FALSE) == 1)
915 command_dir = coords_to_dir(y, x);
919 /* Allow repeated command */
922 /* Set repeat count */
923 command_rep = command_arg - 1;
924 p_ptr->redraw |= (PR_STATE);
930 /* Get a "repeated" direction */
931 if (get_rep_dir(&dir, FALSE))
936 y = p_ptr->y + ddy[dir];
937 x = p_ptr->x + ddx[dir];
940 /* Feature code (applying "mimic" field) */
941 feat = get_feat_mimic(c_ptr);
943 /* Require open/broken door */
944 if (!have_flag(f_info[feat].flags, FF_CLOSE))
946 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
949 /* Monster in the way */
950 else if (c_ptr->m_idx)
952 p_ptr->energy_use = 100;
954 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
964 more = do_cmd_close_aux(y, x);
968 /* Cancel repeat unless we may continue */
969 if (!more) disturb(FALSE, FALSE);
974 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
975 * Determine if a given grid may be "tunneled"
976 * @param y 対象を行うマスのY座標
977 * @param x 対象を行うマスのX座標
980 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
982 cave_type *c_ptr = &cave[y][x];
984 /* Must have knowledge */
985 if (!(c_ptr->info & CAVE_MARK))
987 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
992 /* Must be a wall/door/etc */
993 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
995 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1005 * @brief 「掘る」動作コマンドのサブルーチン /
1006 * Perform the basic "tunnel" command
1007 * @param y 対象を行うマスのY座標
1008 * @param x 対象を行うマスのX座標
1009 * @return 実際に処理が行われた場合TRUEを返す。
1011 * Assumes that no monster is blocking the destination
1012 * Do not use twall anymore
1013 * Returns TRUE if repeated commands may continue
1015 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1018 feature_type *f_ptr, *mimic_f_ptr;
1023 /* Verify legality */
1024 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1026 p_ptr->energy_use = 100;
1029 c_ptr = &cave[y][x];
1030 f_ptr = &f_info[c_ptr->feat];
1031 power = f_ptr->power;
1033 /* Feature code (applying "mimic" field) */
1034 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1036 name = f_name + mimic_f_ptr->name;
1040 if (have_flag(f_ptr->flags, FF_PERMANENT))
1043 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1045 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1048 /* Map border (mimiccing Permanent wall) */
1051 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1056 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1059 if (p_ptr->skill_dig > randint0(20 * power))
1061 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1063 /* Remove the feature */
1064 cave_alter_feat(y, x, FF_TUNNEL);
1066 /* Update some things */
1067 p_ptr->update |= (PU_FLOW);
1071 /* Message, keep digging */
1072 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1080 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1083 if (p_ptr->skill_dig > power + randint0(40 * power))
1085 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1088 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1089 p_ptr->update |= (PU_FLOW);
1092 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1094 /* Remove the feature */
1095 cave_alter_feat(y, x, FF_TUNNEL);
1097 chg_virtue(V_DILIGENCE, 1);
1098 chg_virtue(V_NATURE, -1);
1106 /* We may continue chopping */
1107 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1108 /* Occasional Search XXX XXX */
1109 if (randint0(100) < 25) search();
1113 /* We may continue tunelling */
1114 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1121 if (is_hidden_door(c_ptr))
1123 /* Occasional Search XXX XXX */
1124 if (randint0(100) < 25) search();
1131 * @brief 「掘る」動作コマンドのメインルーチン /
1132 * Tunnels through "walls" (including rubble and closed doors)
1136 * Note that you must tunnel in order to hit invisible monsters
1137 * in walls, though moving into walls still takes a turn anyway.
1139 * Digging is very difficult without a "digger" weapon, but can be
1140 * accomplished by strong players using heavy weapons.
1143 void do_cmd_tunnel(void)
1153 if (p_ptr->special_defense & KATA_MUSOU)
1155 set_action(ACTION_NONE);
1158 /* Allow repeated command */
1161 /* Set repeat count */
1162 command_rep = command_arg - 1;
1163 p_ptr->redraw |= (PR_STATE);
1165 /* Cancel the arg */
1169 /* Get a direction to tunnel, or Abort */
1170 if (get_rep_dir(&dir,FALSE))
1173 y = p_ptr->y + ddy[dir];
1174 x = p_ptr->x + ddx[dir];
1177 c_ptr = &cave[y][x];
1179 /* Feature code (applying "mimic" field) */
1180 feat = get_feat_mimic(c_ptr);
1182 /* No tunnelling through doors */
1183 if (have_flag(f_info[feat].flags, FF_DOOR))
1185 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1188 /* No tunnelling through most features */
1189 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1191 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1194 /* A monster is in the way */
1195 else if (c_ptr->m_idx)
1197 p_ptr->energy_use = 100;
1199 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1208 /* Tunnel through walls */
1209 more = do_cmd_tunnel_aux(y, x);
1213 /* Cancel repetition unless we can continue */
1214 if (!more) disturb(FALSE, FALSE);
1218 * @brief 移動処理による簡易な「開く」処理 /
1220 * @return 開く処理が実際に試みられた場合TRUEを返す
1223 * If there is a jammed/closed/locked door at the given location,
1224 * then attempt to unlock/open it. Return TRUE if an attempt was
1225 * made (successful or not), otherwise return FALSE.
1227 * The code here should be nearly identical to that in
1228 * do_cmd_open_test() and do_cmd_open_aux().
1231 bool easy_open_door(POSITION y, POSITION x)
1235 cave_type *c_ptr = &cave[y][x];
1236 feature_type *f_ptr = &f_info[c_ptr->feat];
1238 /* Must be a closed door */
1239 if (!is_closed_door(c_ptr->feat))
1245 if (!have_flag(f_ptr->flags, FF_OPEN))
1248 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1253 else if (f_ptr->power)
1256 i = p_ptr->skill_dis;
1258 /* Penalize some conditions */
1259 if (p_ptr->blind || no_lite()) i = i / 10;
1260 if (p_ptr->confused || p_ptr->image) i = i / 10;
1262 /* Extract the lock power */
1265 /* Extract the difficulty */
1268 /* Always have a small chance of success */
1272 if (randint0(100) < j)
1274 msg_print(_("鍵をはずした。", "You have picked the lock."));
1277 cave_alter_feat(y, x, FF_OPEN);
1279 sound(SOUND_OPENDOOR);
1289 if (flush_failure) flush();
1291 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1300 cave_alter_feat(y, x, FF_OPEN);
1302 sound(SOUND_OPENDOOR);
1308 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1309 * Perform the basic "disarm" command
1310 * @param y 解除を行うマスのY座標
1311 * @param x 解除を行うマスのX座標
1312 * @param o_idx 箱のオブジェクトID
1313 * @return ターンを消費する処理が行われた場合TRUEを返す
1316 * Assume destination is a visible trap
1317 * Assume there is no monster blocking the destination
1318 * Returns TRUE if repeated commands may continue
1321 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1325 object_type *o_ptr = &o_list[o_idx];
1327 p_ptr->energy_use = 100;
1329 /* Get the "disarm" factor */
1330 i = p_ptr->skill_dis;
1332 /* Penalize some conditions */
1333 if (p_ptr->blind || no_lite()) i = i / 10;
1334 if (p_ptr->confused || p_ptr->image) i = i / 10;
1336 /* Extract the difficulty */
1337 j = i - o_ptr->pval;
1339 /* Always have a small chance of success */
1342 /* Must find the trap first. */
1343 if (!object_is_known(o_ptr))
1345 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1349 /* Already disarmed/unlocked */
1350 else if (o_ptr->pval <= 0)
1352 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1355 /* No traps to find. */
1356 else if (!chest_traps[o_ptr->pval])
1358 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1361 /* Success (get a lot of experience) */
1362 else if (randint0(100) < j)
1364 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1365 gain_exp(o_ptr->pval);
1366 o_ptr->pval = (0 - o_ptr->pval);
1369 /* Failure -- Keep trying */
1370 else if ((i > 5) && (randint1(i) > 5))
1372 /* We may keep trying */
1374 if (flush_failure) flush();
1375 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1378 /* Failure -- Set off the trap */
1381 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1383 chest_trap(y, x, o_idx);
1390 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1391 * Perform the basic "disarm" command
1392 * @param y 解除を行うマスのY座標
1393 * @param x 解除を行うマスのX座標
1394 * @param dir プレイヤーからみた方向ID
1395 * @return ターンを消費する処理が行われた場合TRUEを返す
1398 * Assume destination is a visible trap
1399 * Assume there is no monster blocking the destination
1400 * Returns TRUE if repeated commands may continue
1404 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1406 cave_type *c_ptr = &cave[y][x];
1409 feature_type *f_ptr = &f_info[c_ptr->feat];
1411 /* Access trap name */
1412 concptr name = (f_name + f_ptr->name);
1414 /* Extract trap "power" */
1415 int power = f_ptr->power;
1418 /* Get the "disarm" factor */
1419 int i = p_ptr->skill_dis;
1422 p_ptr->energy_use = 100;
1424 /* Penalize some conditions */
1425 if (p_ptr->blind || no_lite()) i = i / 10;
1426 if (p_ptr->confused || p_ptr->image) i = i / 10;
1428 /* Extract the difficulty */
1431 /* Always have a small chance of success */
1435 if (randint0(100) < j)
1437 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1442 /* Remove the trap */
1443 cave_alter_feat(y, x, FF_DISARM);
1445 /* Move the player onto the trap */
1446 move_player(dir, easy_disarm, FALSE);
1449 /* Failure -- Keep trying */
1450 else if ((i > 5) && (randint1(i) > 5))
1453 if (flush_failure) flush();
1455 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1457 /* We may keep trying */
1461 /* Failure -- Set off the trap */
1464 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1465 /* Move the player onto the trap */
1466 move_player(dir, easy_disarm, FALSE);
1473 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1474 * Disarms a trap, or chest
1477 void do_cmd_disarm(void)
1485 if (p_ptr->wild_mode) return;
1487 if (p_ptr->special_defense & KATA_MUSOU)
1489 set_action(ACTION_NONE);
1492 /* Option: Pick a direction */
1495 int num_traps, num_chests;
1497 /* Count visible traps */
1498 num_traps = count_dt(&y, &x, is_trap, TRUE);
1500 /* Count chests (trapped) */
1501 num_chests = count_chests(&y, &x, TRUE);
1503 /* See if only one target */
1504 if (num_traps || num_chests)
1506 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1507 if (!too_many) command_dir = coords_to_dir(y, x);
1512 /* Allow repeated command */
1515 /* Set repeat count */
1516 command_rep = command_arg - 1;
1517 p_ptr->redraw |= (PR_STATE);
1519 /* Cancel the arg */
1523 /* Get a direction (or abort) */
1524 if (get_rep_dir(&dir,TRUE))
1529 y = p_ptr->y + ddy[dir];
1530 x = p_ptr->x + ddx[dir];
1531 c_ptr = &cave[y][x];
1533 /* Feature code (applying "mimic" field) */
1534 feat = get_feat_mimic(c_ptr);
1536 /* Check for chests */
1537 o_idx = chest_check(y, x, TRUE);
1540 if (!is_trap(feat) && !o_idx)
1542 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1545 /* Monster in the way */
1546 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1548 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1557 more = do_cmd_disarm_chest(y, x, o_idx);
1563 more = do_cmd_disarm_aux(y, x, dir);
1567 /* Cancel repeat unless told not to */
1568 if (!more) disturb(FALSE, FALSE);
1573 * @brief 「打ち破る」動作コマンドのサブルーチン /
1574 * Perform the basic "bash" command
1575 * @param y 対象を行うマスのY座標
1576 * @param x 対象を行うマスのX座標
1577 * @param dir プレイヤーから見たターゲットの方角ID
1578 * @return 実際に処理が行われた場合TRUEを返す。
1581 * Assume destination is a closed/locked/jammed door
1582 * Assume there is no monster blocking the destination
1583 * Returns TRUE if repeated commands may continue
1586 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1589 cave_type *c_ptr = &cave[y][x];
1592 feature_type *f_ptr = &f_info[c_ptr->feat];
1594 /* Hack -- Bash power based on strength */
1595 /* (Ranges from 3 to 20 to 100 to 200) */
1596 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1598 /* Extract door power */
1599 int temp = f_ptr->power;
1603 concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1605 p_ptr->energy_use = 100;
1607 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1609 /* Compare bash power to door power */
1610 temp = (bash - (temp * 10));
1612 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1614 /* Hack -- always have a chance */
1615 if (temp < 1) temp = 1;
1617 /* Hack -- attempt to bash down the door */
1618 if (randint0(100) < temp)
1620 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1622 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1624 /* Break down the door */
1625 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1627 cave_alter_feat(y, x, FF_BASH);
1633 cave_alter_feat(y, x, FF_OPEN);
1636 /* Hack -- Fall through the door */
1637 move_player(dir, FALSE, FALSE);
1640 /* Saving throw against stun */
1641 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1644 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1646 /* Allow repeated bashing */
1650 /* High dexterity yields coolness */
1653 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1655 /* Hack -- Lose balance ala paralysis */
1656 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1663 * @brief 「打ち破る」動作コマンドのメインルーチン /
1664 * Bash open a door, success based on character strength
1668 * For a closed door, pval is positive if locked; negative if stuck.
1670 * For an open door, pval is positive for a broken door.
1672 * A closed door can be opened - harder if locked. Any door might be
1673 * bashed open (and thereby broken). Bashing a door is (potentially)
1674 * faster! You move into the door way. To open a stuck door, it must
1675 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1677 * Creatures can also open or bash doors, see elsewhere.
1680 void do_cmd_bash(void)
1686 if (p_ptr->wild_mode) return;
1688 if (p_ptr->special_defense & KATA_MUSOU)
1690 set_action(ACTION_NONE);
1693 /* Allow repeated command */
1696 /* Set repeat count */
1697 command_rep = command_arg - 1;
1698 p_ptr->redraw |= (PR_STATE);
1700 /* Cancel the arg */
1704 /* Get a "repeated" direction */
1705 if (get_rep_dir(&dir,FALSE))
1710 y = p_ptr->y + ddy[dir];
1711 x = p_ptr->x + ddx[dir];
1714 c_ptr = &cave[y][x];
1716 /* Feature code (applying "mimic" field) */
1717 feat = get_feat_mimic(c_ptr);
1719 /* Nothing useful */
1720 if (!have_flag(f_info[feat].flags, FF_BASH))
1722 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1725 /* Monster in the way */
1726 else if (c_ptr->m_idx)
1728 p_ptr->energy_use = 100;
1730 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1736 /* Bash a closed door */
1740 more = do_cmd_bash_aux(y, x, dir);
1744 /* Unless valid action taken, cancel bash */
1745 if (!more) disturb(FALSE, FALSE);
1750 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1754 * Manipulate an adjacent grid in some way
1756 * Attack monsters, tunnel through walls, disarm traps, open doors.
1758 * Consider confusion
1760 * This command must always take a turn, to prevent free detection
1761 * of invisible monsters.
1764 void do_cmd_alter(void)
1771 if (p_ptr->special_defense & KATA_MUSOU)
1773 set_action(ACTION_NONE);
1776 /* Allow repeated command */
1779 /* Set repeat count */
1780 command_rep = command_arg - 1;
1781 p_ptr->redraw |= (PR_STATE);
1783 /* Cancel the arg */
1787 /* Get a direction */
1788 if (get_rep_dir(&dir,TRUE))
1791 feature_type *f_ptr;
1793 y = p_ptr->y + ddy[dir];
1794 x = p_ptr->x + ddx[dir];
1797 c_ptr = &cave[y][x];
1799 /* Feature code (applying "mimic" field) */
1800 feat = get_feat_mimic(c_ptr);
1801 f_ptr = &f_info[feat];
1803 p_ptr->energy_use = 100;
1811 else if (have_flag(f_ptr->flags, FF_OPEN))
1813 more = do_cmd_open_aux(y, x);
1816 /* Bash jammed doors */
1817 else if (have_flag(f_ptr->flags, FF_BASH))
1819 more = do_cmd_bash_aux(y, x, dir);
1822 /* Tunnel through walls */
1823 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1825 more = do_cmd_tunnel_aux(y, x);
1828 /* Close open doors */
1829 else if (have_flag(f_ptr->flags, FF_CLOSE))
1831 more = do_cmd_close_aux(y, x);
1835 else if (have_flag(f_ptr->flags, FF_DISARM))
1837 more = do_cmd_disarm_aux(y, x, dir);
1842 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1846 /* Cancel repetition unless we can continue */
1847 if (!more) disturb(FALSE, FALSE);
1853 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1854 * Find the index of some "spikes", if possible.
1855 * @param ip くさびとして打てるオブジェクトのID
1856 * @return オブジェクトがある場合TRUEを返す
1859 * Let user choose a pile of spikes, perhaps?
1862 static bool get_spike(INVENTORY_IDX *ip)
1866 /* Check every item in the pack */
1867 for (i = 0; i < INVEN_PACK; i++)
1869 object_type *o_ptr = &inventory[i];
1871 /* Skip non-objects */
1872 if (!o_ptr->k_idx) continue;
1874 /* Check the "tval" code */
1875 if (o_ptr->tval == TV_SPIKE)
1877 /* Save the spike index */
1890 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1891 * Jam a closed door with a spike
1895 * This command may NOT be repeated
1898 void do_cmd_spike(void)
1902 if (p_ptr->wild_mode) return;
1904 if (p_ptr->special_defense & KATA_MUSOU)
1906 set_action(ACTION_NONE);
1909 /* Get a "repeated" direction */
1910 if (get_rep_dir(&dir, FALSE))
1917 y = p_ptr->y + ddy[dir];
1918 x = p_ptr->x + ddx[dir];
1919 c_ptr = &cave[y][x];
1921 /* Feature code (applying "mimic" field) */
1922 feat = get_feat_mimic(c_ptr);
1924 /* Require closed door */
1925 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1927 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1931 else if (!get_spike(&item))
1933 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1936 /* Is a monster in the way? */
1937 else if (c_ptr->m_idx)
1939 p_ptr->energy_use = 100;
1941 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1950 p_ptr->energy_use = 100;
1952 /* Successful jamming */
1953 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1954 cave_alter_feat(y, x, FF_SPIKE);
1956 /* Use up, and describe, a single spike, from the bottom */
1957 inven_item_increase(item, -1);
1958 inven_item_describe(item);
1959 inven_item_optimize(item);
1967 * @brief 「歩く」動作コマンドのメインルーチン /
1968 * Support code for the "Walk" and "Jump" commands
1969 * @param pickup アイテムの自動拾いを行うならTRUE
1972 void do_cmd_walk(bool pickup)
1979 /* Allow repeated command */
1982 /* Set repeat count */
1983 command_rep = command_arg - 1;
1984 p_ptr->redraw |= (PR_STATE);
1986 /* Cancel the arg */
1990 /* Get a "repeated" direction */
1991 if (get_rep_dir(&dir, FALSE))
1993 p_ptr->energy_use = 100;
1995 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
1997 set_action(ACTION_NONE);
2000 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2001 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2002 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2004 /* Actually move the character */
2005 move_player(dir, pickup, FALSE);
2007 /* Allow more walking */
2011 /* Hack again -- Is there a special encounter ??? */
2012 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2014 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2017 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2019 /* Inform the player of his horrible fate :=) */
2020 msg_print(_("襲撃だ!", "You are ambushed !"));
2022 /* Go into large wilderness view */
2023 p_ptr->oldpy = randint1(MAX_HGT-2);
2024 p_ptr->oldpx = randint1(MAX_WID-2);
2027 /* Give first move to monsters */
2028 p_ptr->energy_use = 100;
2030 /* HACk -- set the encouter flag for the wilderness generation */
2031 generate_encounter = TRUE;
2035 /* Cancel repeat unless we may continue */
2036 if (!more) disturb(FALSE, FALSE);
2041 * @brief 「走る」動作コマンドのメインルーチン /
2045 void do_cmd_run(void)
2049 /* Hack -- no running when confused */
2050 if (p_ptr->confused)
2052 msg_print(_("混乱していて走れない!", "You are too confused!"));
2056 if (p_ptr->special_defense & KATA_MUSOU)
2058 set_action(ACTION_NONE);
2061 /* Get a "repeated" direction */
2062 if (get_rep_dir(&dir,FALSE))
2064 /* Hack -- Set the run counter */
2065 running = (command_arg ? command_arg : 1000);
2074 * @brief 「留まる」動作コマンドのメインルーチン /
2075 * Stay still. Search. Enter stores.
2076 * Pick up treasure if "pickup" is true.
2077 * @param pickup アイテムの自動拾いを行うならTRUE
2080 void do_cmd_stay(bool pickup)
2082 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2084 /* Allow repeated command */
2087 /* Set repeat count */
2088 command_rep = command_arg - 1;
2089 p_ptr->redraw |= (PR_STATE);
2091 /* Cancel the arg */
2095 p_ptr->energy_use = 100;
2097 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2098 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2103 * @brief 「休む」動作コマンドのメインルーチン /
2104 * Resting allows a player to safely restore his hp -RAK-
2107 void do_cmd_rest(void)
2110 set_action(ACTION_NONE);
2112 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2118 if (hex_spelling_any()) stop_hex_spell_all();
2120 /* Prompt for time if needed */
2121 if (command_arg <= 0)
2123 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2124 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2130 strcpy(out_val, "&");
2132 /* Ask for duration */
2133 if (!get_string(p, out_val, 4)) return;
2135 /* Rest until done */
2136 if (out_val[0] == '&')
2138 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2142 else if (out_val[0] == '*')
2144 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2150 command_arg = (COMMAND_ARG)atoi(out_val);
2151 if (command_arg <= 0) return;
2157 if (command_arg > 9999) command_arg = 9999;
2159 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2161 /* Take a turn (?) */
2162 p_ptr->energy_use = 100;
2164 /* The sin of sloth */
2165 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2167 /* Why are you sleeping when there's no need? WAKE UP!*/
2168 if ((p_ptr->chp == p_ptr->mhp) &&
2169 (p_ptr->csp == p_ptr->msp) &&
2170 !p_ptr->blind && !p_ptr->confused &&
2171 !p_ptr->poisoned && !p_ptr->afraid &&
2172 !p_ptr->stun && !p_ptr->cut &&
2173 !p_ptr->slow && !p_ptr->paralyzed &&
2174 !p_ptr->image && !p_ptr->word_recall &&
2175 !p_ptr->alter_reality)
2176 chg_virtue(V_DILIGENCE, -1);
2178 /* Save the rest code */
2179 resting = command_arg;
2180 p_ptr->action = ACTION_REST;
2181 p_ptr->update |= (PU_BONUS);
2182 update_creature(p_ptr);
2184 p_ptr->redraw |= (PR_STATE);
2192 * @brief 矢弾を射撃した場合の破損確率を返す /
2193 * Determines the odds of an object breaking when thrown at a monster
2194 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2197 * Note that artifacts never break, see the "drop_near()" function.
2199 static PERCENTAGE breakage_chance(object_type *o_ptr)
2201 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2203 /* Examine the snipe type */
2206 if (snipe_type == SP_KILL_WALL) return (100);
2207 if (snipe_type == SP_EXPLODE) return (100);
2208 if (snipe_type == SP_PIERCE) return (100);
2209 if (snipe_type == SP_FINAL) return (100);
2210 if (snipe_type == SP_NEEDLE) return (100);
2211 if (snipe_type == SP_EVILNESS) return (40);
2212 if (snipe_type == SP_HOLYNESS) return (40);
2215 /* Examine the item type */
2216 switch (o_ptr->tval)
2232 /* Sometimes break */
2237 return (20 - archer_bonus * 2);
2242 return (10 - archer_bonus);
2250 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2251 * Determines the odds of an object breaking when thrown at a monster
2252 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2253 * @param tdam 計算途中のダメージ量
2254 * @param m_ptr 目標モンスターの構造体参照ポインタ
2255 * @return スレイ倍率をかけたダメージ量
2257 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2261 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2263 BIT_FLAGS flgs[TR_FLAG_SIZE];
2264 object_flags(o_ptr, flgs);
2266 /* Some "weapons" and "ammo" do extra damage */
2267 switch (o_ptr->tval)
2273 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2275 if (is_original_ap_and_seen(m_ptr))
2277 r_ptr->r_flags3 |= RF3_ANIMAL;
2279 if (mult < 17) mult = 17;
2282 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2284 if (is_original_ap_and_seen(m_ptr))
2286 r_ptr->r_flags3 |= RF3_ANIMAL;
2288 if (mult < 27) mult = 27;
2291 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2293 if (is_original_ap_and_seen(m_ptr))
2295 r_ptr->r_flags3 |= RF3_EVIL;
2297 if (mult < 15) mult = 15;
2300 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2302 if (is_original_ap_and_seen(m_ptr))
2304 r_ptr->r_flags3 |= RF3_EVIL;
2306 if (mult < 25) mult = 25;
2309 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2311 if (is_original_ap_and_seen(m_ptr))
2313 r_ptr->r_flags2 |= RF2_HUMAN;
2315 if (mult < 17) mult = 17;
2318 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2320 if (is_original_ap_and_seen(m_ptr))
2322 r_ptr->r_flags2 |= RF2_HUMAN;
2324 if (mult < 27) mult = 27;
2327 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2329 if (is_original_ap_and_seen(m_ptr))
2331 r_ptr->r_flags3 |= RF3_UNDEAD;
2333 if (mult < 20) mult = 20;
2336 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2338 if (is_original_ap_and_seen(m_ptr))
2340 r_ptr->r_flags3 |= RF3_UNDEAD;
2342 if (mult < 30) mult = 30;
2345 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2347 if (is_original_ap_and_seen(m_ptr))
2349 r_ptr->r_flags3 |= RF3_DEMON;
2351 if (mult < 20) mult = 20;
2354 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2356 if (is_original_ap_and_seen(m_ptr))
2358 r_ptr->r_flags3 |= RF3_DEMON;
2360 if (mult < 30) mult = 30;
2363 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
2365 if (is_original_ap_and_seen(m_ptr))
2367 r_ptr->r_flags3 |= RF3_ORC;
2369 if (mult < 20) mult = 20;
2372 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
2374 if (is_original_ap_and_seen(m_ptr))
2376 r_ptr->r_flags3 |= RF3_ORC;
2378 if (mult < 30) mult = 30;
2381 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2383 if (is_original_ap_and_seen(m_ptr))
2385 r_ptr->r_flags3 |= RF3_TROLL;
2388 if (mult < 20) mult = 20;
2391 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2393 if (is_original_ap_and_seen(m_ptr))
2395 r_ptr->r_flags3 |= RF3_TROLL;
2397 if (mult < 30) mult = 30;
2400 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2402 if (is_original_ap_and_seen(m_ptr))
2404 r_ptr->r_flags3 |= RF3_GIANT;
2406 if (mult < 20) mult = 20;
2409 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2411 if (is_original_ap_and_seen(m_ptr))
2413 r_ptr->r_flags3 |= RF3_GIANT;
2415 if (mult < 30) mult = 30;
2418 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2420 if (is_original_ap_and_seen(m_ptr))
2422 r_ptr->r_flags3 |= RF3_DRAGON;
2424 if (mult < 20) mult = 20;
2427 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2429 if (is_original_ap_and_seen(m_ptr))
2431 r_ptr->r_flags3 |= RF3_DRAGON;
2433 if (mult < 30) mult = 30;
2434 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
2435 (inventory[INVEN_BOW].name1 == ART_BARD))
2439 if (have_flag(flgs, TR_BRAND_ACID))
2441 /* Notice immunity */
2442 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2444 if (is_original_ap_and_seen(m_ptr))
2446 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2451 if (mult < 17) mult = 17;
2455 if (have_flag(flgs, TR_BRAND_ELEC))
2457 /* Notice immunity */
2458 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2460 if (is_original_ap_and_seen(m_ptr))
2462 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2467 if (mult < 17) mult = 17;
2471 if (have_flag(flgs, TR_BRAND_FIRE))
2473 /* Notice immunity */
2474 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2476 if (is_original_ap_and_seen(m_ptr))
2478 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2481 /* Otherwise, take the damage */
2484 if (r_ptr->flags3 & RF3_HURT_FIRE)
2486 if (mult < 25) mult = 25;
2487 if (is_original_ap_and_seen(m_ptr))
2489 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2492 else if (mult < 17) mult = 17;
2496 if (have_flag(flgs, TR_BRAND_COLD))
2498 /* Notice immunity */
2499 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2501 if (is_original_ap_and_seen(m_ptr))
2503 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2506 /* Otherwise, take the damage */
2509 if (r_ptr->flags3 & RF3_HURT_COLD)
2511 if (mult < 25) mult = 25;
2512 if (is_original_ap_and_seen(m_ptr))
2514 r_ptr->r_flags3 |= RF3_HURT_COLD;
2517 else if (mult < 17) mult = 17;
2521 if (have_flag(flgs, TR_BRAND_POIS))
2523 /* Notice immunity */
2524 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2526 if (is_original_ap_and_seen(m_ptr))
2528 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2531 /* Otherwise, take the damage */
2534 if (mult < 17) mult = 17;
2538 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2540 p_ptr->csp -= (1+(p_ptr->msp / 30));
2541 p_ptr->redraw |= (PR_MANA);
2542 mult = mult * 5 / 2;
2549 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2551 /* Return the total damage */
2552 return (tdam * mult / 10);
2557 * @brief 射撃処理のサブルーチン /
2558 * Fire an object from the pack or floor.
2559 * @param item 射撃するオブジェクトの所持ID
2560 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2564 * You may only fire items that "match" your missile launcher.
2566 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2568 * See "calc_bonuses()" for more calculations and such.
2570 * Note that "firing" a missile is MUCH better than "throwing" it.
2572 * Note: "unseen" monsters are very hard to hit.
2574 * Objects are more likely to break if they "attempt" to hit a monster.
2576 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2578 * The "extra shot" code works by decreasing the amount of energy
2579 * required to make each shot, spreading the shots out over time.
2581 * Note that when firing missiles, the launcher multiplier is applied
2582 * after all the bonuses are added in, making multipliers very useful.
2584 * Note that Bows of "Extra Might" get extra range and an extra bonus
2585 * for the damage multiplier.
2587 * Note that Bows of "Extra Shots" give an extra shot.
2590 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2594 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2595 int tdam_base, tdis, thits, tmul;
2597 int cur_dis, visible;
2605 bool hit_body = FALSE;
2607 GAME_TEXT o_name[MAX_NLEN];
2609 u16b path_g[512]; /* For calcuration of path length */
2611 int msec = delay_factor * delay_factor * delay_factor;
2614 bool stick_to = FALSE;
2616 /* Access the item (if in the pack) */
2619 o_ptr = &inventory[item];
2623 o_ptr = &o_list[0 - item];
2626 /* Sniper - Cannot shot a single arrow twice */
2627 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2629 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2631 /* Use the proper number of shots */
2632 thits = p_ptr->num_fire;
2634 /* Use a base distance */
2637 /* Base damage from thrown object plus launcher bonus */
2638 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2640 /* Actually "fire" the object */
2641 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2642 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2643 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2645 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2647 p_ptr->energy_use = bow_energy(j_ptr->sval);
2648 tmul = bow_tmul(j_ptr->sval);
2650 /* Get extra "power" from "extra might" */
2651 if (p_ptr->xtra_might) tmul++;
2653 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2655 /* Boost the damage */
2660 tdis = 13 + tmul/80;
2661 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2664 tdis -= (5 - (p_ptr->concent + 1) / 2);
2669 project_length = tdis + 1;
2671 /* Get a direction (or cancel) */
2672 if (!get_aim_dir(&dir))
2674 p_ptr->energy_use = 0;
2676 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2678 /* need not to reset project_length (already did)*/
2683 /* Predict the "target" location */
2684 tx = p_ptr->x + 99 * ddx[dir];
2685 ty = p_ptr->y + 99 * ddy[dir];
2687 /* Check for "target request" */
2688 if ((dir == 5) && target_okay())
2694 /* Get projection path length */
2695 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2697 project_length = 0; /* reset to default */
2699 /* Don't shoot at my feet */
2700 if (tx == p_ptr->x && ty == p_ptr->y)
2702 p_ptr->energy_use = 0;
2704 /* project_length is already reset to 0 */
2710 /* Take a (partial) turn */
2711 p_ptr->energy_use = (p_ptr->energy_use / thits);
2714 /* Sniper - Difficult to shot twice at 1 turn */
2715 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2717 /* Sniper - Repeat shooting when double shots */
2718 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2721 /* Start at the player */
2726 /* Obtain a local object */
2727 object_copy(q_ptr, o_ptr);
2732 /* Reduce and describe inventory */
2735 inven_item_increase(item, -1);
2736 inven_item_describe(item);
2737 inven_item_optimize(item);
2740 /* Reduce and describe floor item */
2743 floor_item_increase(0 - item, -1);
2744 floor_item_optimize(0 - item);
2750 /* Save the old location */
2754 /* The shot does not hit yet */
2757 /* Travel until stopped */
2758 for (cur_dis = 0; cur_dis <= tdis; )
2762 /* Hack -- Stop at the target */
2763 if ((y == ty) && (x == tx)) break;
2765 /* Calculate the new location (see "project()") */
2768 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2771 if (snipe_type == SP_KILL_WALL)
2773 c_ptr = &cave[ny][nx];
2775 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2777 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2778 /* Forget the wall */
2779 c_ptr->info &= ~(CAVE_MARK);
2780 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2782 /* Destroy the wall */
2783 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2790 /* Stopped by walls/doors */
2791 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2793 /* Advance the distance */
2797 if (snipe_type == SP_LITE)
2799 cave[ny][nx].info |= (CAVE_GLOW);
2804 /* The player can see the (on screen) missile */
2805 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2807 char c = object_char(q_ptr);
2808 byte a = object_attr(q_ptr);
2810 /* Draw, Hilite, Fresh, Pause, Erase */
2811 print_rel(c, a, ny, nx);
2812 move_cursor_relative(ny, nx);
2814 Term_xtra(TERM_XTRA_DELAY, msec);
2819 /* The player cannot see the missile */
2822 /* Pause anyway, for consistancy */
2823 Term_xtra(TERM_XTRA_DELAY, msec);
2827 if (snipe_type == SP_KILL_TRAP)
2829 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
2830 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
2834 if (snipe_type == SP_EVILNESS)
2836 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
2841 /* Save the old location */
2845 /* Save the new location */
2849 /* Monster here, Try to hit it */
2850 if (cave[y][x].m_idx)
2852 cave_type *c_mon_ptr = &cave[y][x];
2854 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
2855 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2857 /* Check the visibility */
2858 visible = m_ptr->ml;
2860 /* Note the collision */
2863 if (MON_CSLEEP(m_ptr))
2865 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
2866 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
2869 if ((r_ptr->level + 10) > p_ptr->lev)
2871 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
2872 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
2875 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
2876 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
2877 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
2878 else if (p_ptr->lev > 34) amount = 2;
2879 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
2880 p_ptr->update |= (PU_BONUS);
2886 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
2887 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
2890 p_ptr->skill_exp[GINOU_RIDING] += 1;
2891 p_ptr->update |= (PU_BONUS);
2895 /* Did we hit it (penalize range) */
2896 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2899 int tdam = tdam_base;
2901 /* Get extra damage from concentration */
2902 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
2904 /* Handle unseen monster */
2907 /* Invisible monster */
2908 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2911 /* Handle visible monster */
2914 GAME_TEXT m_name[MAX_NLEN];
2916 /* Get "the monster" or "it" */
2917 monster_desc(m_name, m_ptr, 0);
2919 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2923 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
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);
3264 o_ptr = &inventory[item];
3268 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3270 item_tester_hook = item_tester_hook_boomerang;
3271 q = _("どの武器を投げますか? ", "Throw which item? ");
3272 s = _("投げる武器がない。", "You have nothing to throw.");
3273 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
3280 else if (buki_motteruka(INVEN_LARM))
3283 o_ptr = &inventory[item];
3288 o_ptr = &inventory[item];
3293 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3294 s = _("投げるアイテムがない。", "You have nothing to throw.");
3295 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
3303 /* Item is cursed */
3304 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3306 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3311 if (p_ptr->inside_arena && !boomerang)
3313 if (o_ptr->tval != TV_SPIKE)
3315 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3324 /* Obtain a local object */
3325 object_copy(q_ptr, o_ptr);
3327 /* Extract the thrown object's flags. */
3328 object_flags(q_ptr, flgs);
3329 torch_flags(q_ptr, flgs);
3331 /* Distribute the charges of rods/wands between the stacks */
3332 distribute_charges(o_ptr, q_ptr, 1);
3337 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3339 if (p_ptr->mighty_throw) mult += 3;
3341 /* Extract a "distance multiplier" */
3342 /* Changed for 'launcher' mutation */
3343 mul = 10 + 2 * (mult - 1);
3345 /* Enforce a minimum "weight" of one pound */
3346 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3347 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3349 /* Hack -- Distance -- Reward strength, penalize weight */
3350 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3352 /* Max distance of 10-18 */
3353 if (tdis > mul) tdis = mul;
3357 ty = randint0(101) - 50 + p_ptr->y;
3358 tx = randint0(101) - 50 + p_ptr->x;
3362 project_length = tdis + 1;
3364 /* Get a direction (or cancel) */
3365 if (!get_aim_dir(&dir)) return FALSE;
3367 /* Predict the "target" location */
3368 tx = p_ptr->x + 99 * ddx[dir];
3369 ty = p_ptr->y + 99 * ddy[dir];
3371 /* Check for "target request" */
3372 if ((dir == 5) && target_okay())
3378 project_length = 0; /* reset to default */
3381 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3382 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3383 return_when_thrown = TRUE;
3385 /* Reduce and describe inventory */
3388 inven_item_increase(item, -1);
3389 if (!return_when_thrown)
3390 inven_item_describe(item);
3391 inven_item_optimize(item);
3394 /* Reduce and describe floor item */
3397 floor_item_increase(0 - item, -1);
3398 floor_item_optimize(0 - item);
3400 if (item >= INVEN_RARM)
3402 equiped_item = TRUE;
3403 p_ptr->redraw |= (PR_EQUIPPY);
3406 p_ptr->energy_use = 100;
3408 /* Rogue and Ninja gets bonus */
3409 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3410 p_ptr->energy_use -= p_ptr->lev;
3412 /* Start at the player */
3418 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3419 else shuriken = FALSE;
3421 /* Chance of hitting */
3422 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3423 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3424 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3426 if (shuriken) chance *= 2;
3428 /* Save the old location */
3432 /* Travel until stopped */
3433 for (cur_dis = 0; cur_dis <= tdis; )
3435 /* Hack -- Stop at the target */
3436 if ((y == ty) && (x == tx)) break;
3438 /* Calculate the new location (see "project()") */
3441 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3443 /* Stopped by walls/doors */
3444 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3447 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3450 /* The player can see the (on screen) missile */
3451 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3453 SYMBOL_CODE c = object_char(q_ptr);
3454 TERM_COLOR a = object_attr(q_ptr);
3456 /* Draw, Hilite, Fresh, Pause, Erase */
3457 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3458 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3460 Term_xtra(TERM_XTRA_DELAY, msec);
3461 lite_spot(ny[cur_dis], nx[cur_dis]);
3465 /* The player cannot see the missile */
3468 /* Pause anyway, for consistancy */
3469 Term_xtra(TERM_XTRA_DELAY, msec);
3472 /* Save the old location */
3476 /* Save the new location */
3480 /* Advance the distance */
3483 /* Monster here, Try to hit it */
3484 if (cave[y][x].m_idx)
3486 cave_type *c_ptr = &cave[y][x];
3487 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3489 /* Check the visibility */
3490 visible = m_ptr->ml;
3492 /* Note the collision */
3495 /* Did we hit it (penalize range) */
3496 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3500 /* Handle unseen monster */
3503 /* Invisible monster */
3504 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3507 /* Handle visible monster */
3510 GAME_TEXT m_name[MAX_NLEN];
3511 monster_desc(m_name, m_ptr, 0);
3512 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3516 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3517 health_track(c_ptr->m_idx);
3521 /* Hack -- Base damage from thrown object */
3524 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3525 tdam = damroll(dd, ds);
3526 /* Apply special damage */
3527 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3528 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3529 if (q_ptr->to_d > 0)
3530 tdam += q_ptr->to_d;
3532 tdam += -q_ptr->to_d;
3536 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3537 tdam += p_ptr->to_d_m;
3539 else if (have_flag(flgs, TR_THROW))
3542 tdam += p_ptr->to_d_m;
3550 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3553 /* No negative damage */
3554 if (tdam < 0) tdam = 0;
3556 /* Modify the damage */
3557 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3559 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3560 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3562 /* Hit the monster, check for death */
3563 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
3571 message_pain(c_ptr->m_idx, tdam);
3573 /* Anger the monster */
3574 if ((tdam > 0) && !object_is_potion(q_ptr))
3575 anger_monster(m_ptr);
3577 if (fear && m_ptr->ml)
3580 GAME_TEXT m_name[MAX_NLEN];
3581 monster_desc(m_name, m_ptr, 0);
3582 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3592 /* decrease toach's fuel */
3593 if (hit_body) torch_lost_fuel(q_ptr);
3595 /* Chance of breakage (during attacks) */
3596 j = (hit_body ? breakage_chance(q_ptr) : 0);
3598 /* Figurines transform */
3599 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3603 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3604 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3605 else if (object_is_cursed(q_ptr))
3606 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3611 /* Potions smash open */
3612 if (object_is_potion(q_ptr))
3614 if (hit_body || hit_wall || (randint1(100) < j))
3616 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3618 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3620 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3622 /* ToDo (Robert): fix the invulnerability */
3623 if (cave[y][x].m_idx &&
3624 is_friendly(&m_list[cave[y][x].m_idx]) &&
3625 !MON_INVULNER(m_ptr))
3627 GAME_TEXT m_name[MAX_NLEN];
3628 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3629 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3630 set_hostile(&m_list[cave[y][x].m_idx]);
3641 if (return_when_thrown)
3643 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3644 char o2_name[MAX_NLEN];
3645 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3648 if (boomerang) back_chance += 4+randint1(5);
3649 if (super_boomerang) back_chance += 100;
3650 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3652 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3654 for (i = cur_dis - 1; i > 0; i--)
3656 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3658 char c = object_char(q_ptr);
3659 byte a = object_attr(q_ptr);
3661 /* Draw, Hilite, Fresh, Pause, Erase */
3662 print_rel(c, a, ny[i], nx[i]);
3663 move_cursor_relative(ny[i], nx[i]);
3665 Term_xtra(TERM_XTRA_DELAY, msec);
3666 lite_spot(ny[i], nx[i]);
3671 /* Pause anyway, for consistancy */
3672 Term_xtra(TERM_XTRA_DELAY, msec);
3675 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3677 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3684 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3688 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3696 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3702 if (item == INVEN_RARM || item == INVEN_LARM)
3704 /* Access the wield slot */
3705 o_ptr = &inventory[item];
3707 /* Wear the new stuff */
3708 object_copy(o_ptr, q_ptr);
3710 p_ptr->total_weight += q_ptr->weight;
3712 /* Increment the equip counter by hand */
3715 /* Recalculate torch */
3716 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
3717 p_ptr->window |= (PW_EQUIP);
3725 else if (equiped_item)
3733 if (cave_have_flag_bold(y, x, FF_PROJECT))
3735 (void)drop_near(q_ptr, j, y, x);
3739 (void)drop_near(q_ptr, j, prev_y, prev_x);
3749 * Hack: travel command
3751 #define TRAVEL_UNABLE 9999
3753 static int flow_head = 0;
3754 static int flow_tail = 0;
3755 static POSITION temp2_x[MAX_SHORT];
3756 static POSITION temp2_y[MAX_SHORT];
3759 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3762 void forget_travel_flow(void)
3765 /* Check the entire dungeon / Forget the old data */
3766 for (y = 0; y < cur_hgt; y++)
3768 for (x = 0; x < cur_wid; x++)
3771 travel.cost[y][x] = MAX_SHORT;
3774 travel.y = travel.x = 0;
3778 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
3783 static int travel_flow_cost(POSITION y, POSITION x)
3785 feature_type *f_ptr = &f_info[cave[y][x].feat];
3788 /* Avoid obstacles (ex. trees) */
3789 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
3792 if (have_flag(f_ptr->flags, FF_WATER))
3794 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
3798 if (have_flag(f_ptr->flags, FF_LAVA))
3801 if (!p_ptr->resist_fire) lava *= 2;
3802 if (!p_ptr->levitation) lava *= 2;
3803 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
3808 /* Detected traps and doors */
3809 if (cave[y][x].info & (CAVE_MARK))
3811 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
3812 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
3819 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
3823 * @param wall プレイヤーが壁の中にいるならばTRUE
3826 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
3828 cave_type *c_ptr = &cave[y][x];
3829 feature_type *f_ptr = &f_info[c_ptr->feat];
3830 int old_head = flow_head;
3832 int base_cost = (n % TRAVEL_UNABLE);
3833 int from_wall = (n / TRAVEL_UNABLE);
3836 /* Ignore out of bounds */
3837 if (!in_bounds(y, x)) return;
3839 /* Ignore unknown grid except in wilderness */
3840 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
3842 /* Ignore "walls" and "rubble" (include "secret doors") */
3843 if (have_flag(f_ptr->flags, FF_WALL) ||
3844 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3845 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
3846 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
3848 if (!wall || !from_wall) return;
3849 add_cost += TRAVEL_UNABLE;
3853 add_cost = travel_flow_cost(y, x);
3856 cost = base_cost + add_cost;
3858 /* Ignore lower cost entries */
3859 if (travel.cost[y][x] <= cost) return;
3861 /* Save the flow cost */
3862 travel.cost[y][x] = cost;
3864 /* Enqueue that entry */
3865 temp2_y[flow_head] = y;
3866 temp2_x[flow_head] = x;
3868 /* Advance the queue */
3869 if (++flow_head == MAX_SHORT) flow_head = 0;
3871 /* Hack -- notice overflow by forgetting new entry */
3872 if (flow_head == flow_tail) flow_head = old_head;
3878 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
3879 * @param ty 目標地点のY座標
3880 * @param tx 目標地点のX座標
3883 static void travel_flow(POSITION ty, POSITION tx)
3887 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
3889 /* Reset the "queue" */
3890 flow_head = flow_tail = 0;
3892 /* is player in the wall? */
3893 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
3895 /* Start at the target grid */
3896 travel_flow_aux(ty, tx, 0, wall);
3898 /* Now process the queue */
3899 while (flow_head != flow_tail)
3901 /* Extract the next entry */
3902 y = temp2_y[flow_tail];
3903 x = temp2_x[flow_tail];
3905 /* Forget that entry */
3906 if (++flow_tail == MAX_SHORT) flow_tail = 0;
3908 /* Ignore too far entries */
3909 //if (distance(ty, tx, y, x) > 100) continue;
3911 /* Add the "children" */
3912 for (d = 0; d < 8; d++)
3914 /* Add that child if "legal" */
3915 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
3919 /* Forget the flow info */
3920 flow_head = flow_tail = 0;
3924 * @brief トラベル処理のメインルーチン
3927 void do_cmd_travel(void)
3931 POSITION dx, dy, sx, sy;
3932 feature_type *f_ptr;
3934 if (travel.x != 0 && travel.y != 0 &&
3935 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3940 else if (!tgt_pt(&x, &y)) return;
3942 if ((x == p_ptr->x) && (y == p_ptr->y))
3944 msg_print(_("すでにそこにいます!", "You are already there!!"));
3948 f_ptr = &f_info[cave[y][x].feat];
3950 if ((cave[y][x].info & CAVE_MARK) &&
3951 (have_flag(f_ptr->flags, FF_WALL) ||
3952 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3953 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3955 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3959 forget_travel_flow();
3965 /* Travel till 255 steps */
3971 /* Decides first direction */
3972 dx = abs(p_ptr->x - x);
3973 dy = abs(p_ptr->y - y);
3974 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3975 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3977 for (i = 1; i <= 9; i++)
3979 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;