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"
20 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
21 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
22 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
24 bool confirm_leave_level(bool down_stair)
26 quest_type *q_ptr = &quest[p_ptr->inside_quest];
28 /* Confirm leaving from once only quest */
29 if (confirm_quest && p_ptr->inside_quest &&
30 (q_ptr->type == QUEST_TYPE_RANDOM ||
31 (q_ptr->flags & QUEST_FLAG_ONCE &&
32 q_ptr->status != QUEST_STATUS_COMPLETED) ||
33 (q_ptr->flags & QUEST_FLAG_TOWER &&
34 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
35 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
37 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
38 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
48 * @brief 階段を使って階層を昇る処理 / Go up one level
51 void do_cmd_go_up(void)
56 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
57 feature_type *f_ptr = &f_info[c_ptr->feat];
61 if (p_ptr->special_defense & KATA_MUSOU)
63 set_action(ACTION_NONE);
67 if (!have_flag(f_ptr->flags, FF_LESS))
69 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
74 if (have_flag(f_ptr->flags, FF_QUEST))
76 /* Cancel the command */
77 if (!confirm_leave_level(FALSE)) return;
81 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
82 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
84 msg_print(_("上の階に登った。", "You enter the up staircase."));
88 p_ptr->inside_quest = c_ptr->special;
90 /* Activate the quest */
91 if (!quest[p_ptr->inside_quest].status)
93 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
95 init_flags = INIT_ASSIGN;
96 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
98 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
101 /* Leaving a quest */
102 if (!p_ptr->inside_quest)
108 p_ptr->leaving = TRUE;
113 /* Hack -- take a turn */
114 p_ptr->energy_use = 100;
116 /* End the command */
126 go_up = confirm_leave_level(FALSE);
129 /* Cancel the command */
132 /* Hack -- take a turn */
133 p_ptr->energy_use = 100;
135 if (autosave_l) do_cmd_save_game(TRUE);
137 /* For a random quest */
138 if (p_ptr->inside_quest &&
139 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
143 p_ptr->inside_quest = 0;
146 /* For a fixed quest */
147 if (p_ptr->inside_quest &&
148 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
152 p_ptr->inside_quest = c_ptr->special;
157 /* For normal dungeon and random quest */
161 if (have_flag(f_ptr->flags, FF_SHAFT))
163 /* Create a way back */
164 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
170 /* Create a way back */
171 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
176 /* Get out from current dungeon */
177 if (dun_level - up_num < d_info[dungeon_type].mindepth)
180 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
183 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
184 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
185 else if (up_num == dun_level)
186 msg_print(_("地上に戻った。", "You go back to the surface."));
188 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
191 p_ptr->leaving = TRUE;
196 * @brief 階段を使って階層を降りる処理 / Go down one level
199 void do_cmd_go_down(void)
202 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
203 feature_type *f_ptr = &f_info[c_ptr->feat];
205 bool fall_trap = FALSE;
208 if (p_ptr->special_defense & KATA_MUSOU)
210 set_action(ACTION_NONE);
214 if (!have_flag(f_ptr->flags, FF_MORE))
216 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
220 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
223 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
228 /* Quest down stairs */
229 else if (have_flag(f_ptr->flags, FF_QUEST))
231 /* Confirm Leaving */
232 if(!confirm_leave_level(TRUE)) return;
234 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
235 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
237 msg_print(_("下の階に降りた。", "You enter the down staircase."));
242 p_ptr->inside_quest = c_ptr->special;
244 /* Activate the quest */
245 if (!quest[p_ptr->inside_quest].status)
247 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
249 init_flags = INIT_ASSIGN;
250 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
252 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
255 /* Leaving a quest */
256 if (!p_ptr->inside_quest)
262 p_ptr->leaving = TRUE;
268 /* Hack -- take a turn */
269 p_ptr->energy_use = 100;
274 int target_dungeon = 0;
278 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
280 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
282 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
285 if (!max_dlv[target_dungeon])
287 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
288 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
289 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
292 /* Save old player position */
293 p_ptr->oldpx = p_ptr->x;
294 p_ptr->oldpy = p_ptr->y;
295 dungeon_type = (byte)target_dungeon;
298 * Clear all saved floors
299 * and create a first saved floor
301 prepare_change_floor_mode(CFM_FIRST_FLOOR);
304 /* Hack -- take a turn */
305 p_ptr->energy_use = 100;
307 if (autosave_l) do_cmd_save_game(TRUE);
310 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
315 /* Enter the dungeon just now */
316 p_ptr->enter_dungeon = TRUE;
317 down_num = d_info[dungeon_type].mindepth;
322 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
323 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
328 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
335 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
339 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
340 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
342 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
348 p_ptr->leaving = TRUE;
352 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
356 if (have_flag(f_ptr->flags, FF_SHAFT))
358 /* Create a way back */
359 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
363 /* Create a way back */
364 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
372 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
375 void do_cmd_search(void)
377 /* Allow repeated command */
380 /* Set repeat count */
381 command_rep = command_arg - 1;
382 p_ptr->redraw |= (PR_STATE);
387 p_ptr->energy_use = 100;
395 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
396 * @param y 走査対象にしたいマスのY座標
397 * @param x 走査対象にしたいマスのX座標
398 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
399 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
401 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
403 cave_type *c_ptr = &cave[y][x];
404 OBJECT_IDX this_o_idx, next_o_idx = 0;
406 /* Scan all objects in the grid */
407 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
411 o_ptr = &o_list[this_o_idx];
412 next_o_idx = o_ptr->next_o_idx;
414 /* Skip unknown chests XXX XXX */
415 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
417 /* Check for non empty chest */
418 if ((o_ptr->tval == TV_CHEST) &&
419 (((!trapped) && (o_ptr->pval)) || /* non empty */
420 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
429 * @brief 箱を開けるコマンドのメインルーチン /
430 * Attempt to open the given chest at the given location
431 * @param y 箱の存在するマスのY座標
432 * @param x 箱の存在するマスのX座標
433 * @param o_idx 箱のオブジェクトID
434 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
436 * Assume there is no monster blocking the destination
438 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
443 object_type *o_ptr = &o_list[o_idx];
445 p_ptr->energy_use = 100;
447 /* Attempt to unlock it */
450 /* Assume locked, and thus not open */
453 /* Get the "disarm" factor */
454 i = p_ptr->skill_dis;
456 /* Penalize some conditions */
457 if (p_ptr->blind || no_lite()) i = i / 10;
458 if (p_ptr->confused || p_ptr->image) i = i / 10;
460 /* Extract the difficulty */
463 /* Always have a small chance of success */
466 /* Success -- May still have traps */
467 if (randint0(100) < j)
469 msg_print(_("鍵をはずした。", "You have picked the lock."));
474 /* Failure -- Keep trying */
477 /* We may continue repeating */
479 if (flush_failure) flush();
480 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
485 /* Allowed to open */
488 /* Apply chest traps, if any */
489 chest_trap(y, x, o_idx);
491 /* Let the Chest drop items */
492 chest_death(FALSE, y, x, o_idx);
498 * @brief 地形は開くものであって、かつ開かれているかを返す /
499 * Attempt to open the given chest at the given location
501 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
503 static bool is_open(IDX feat)
505 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
510 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
511 * Attempt to open the given chest at the given location
512 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
513 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
514 * @param test 地形条件を判定するための関数ポインタ
515 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
517 * @details Return the number of features around (or under) the character.
518 * Usually look for doors and floor traps.
520 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
522 int d, count, xx, yy;
524 /* Count how many matches */
527 /* Check around (and under) the character */
528 for (d = 0; d < 9; d++)
533 /* if not searching under player continue */
534 if ((d == 8) && !under) continue;
536 /* Extract adjacent (legal) location */
537 yy = p_ptr->y + ddy_ddd[d];
538 xx = p_ptr->x + ddx_ddd[d];
541 c_ptr = &cave[yy][xx];
543 /* Must have knowledge */
544 if (!(c_ptr->info & (CAVE_MARK))) continue;
546 /* Feature code (applying "mimic" field) */
547 feat = get_feat_mimic(c_ptr);
549 /* Not looking for this feature */
550 if (!((*test)(feat))) continue;
555 /* Remember the location. Only useful if only one match */
566 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
567 * Return the number of chests around (or under) the character.
568 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
569 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
570 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
573 * If requested, count only trapped chests.
575 static int count_chests(POSITION *y, POSITION *x, bool trapped)
582 /* Count how many matches */
585 /* Check around (and under) the character */
586 for (d = 0; d < 9; d++)
588 /* Extract adjacent (legal) location */
589 POSITION yy = p_ptr->y + ddy_ddd[d];
590 POSITION xx = p_ptr->x + ddx_ddd[d];
592 /* No (visible) chest is there */
593 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
595 /* Grab the object */
596 o_ptr = &o_list[o_idx];
599 if (o_ptr->pval == 0) continue;
601 /* No (known) traps here */
602 if (trapped && (!object_is_known(o_ptr) ||
603 !chest_traps[o_ptr->pval])) continue;
608 /* Remember the location. Only useful if only one match */
619 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
620 * Convert an adjacent location to a direction.
621 * @param y 方角を確認したY座標
622 * @param x 方角を確認したX座標
625 static DIRECTION coords_to_dir(POSITION y, POSITION x)
627 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
634 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
636 return d[dx + 1][dy + 1];
640 * @brief 「開ける」動作コマンドのサブルーチン /
641 * Perform the basic "open" command on doors
642 * @param y 対象を行うマスのY座標
643 * @param x 対象を行うマスのX座標
644 * @return 実際に処理が行われた場合TRUEを返す。
646 * Assume destination is a closed/locked/jammed door
647 * Assume there is no monster blocking the destination
648 * Returns TRUE if repeated commands may continue
650 static bool do_cmd_open_aux(POSITION y, POSITION x)
654 /* Get requested grid */
655 cave_type *c_ptr = &cave[y][x];
656 feature_type *f_ptr = &f_info[c_ptr->feat];
659 p_ptr->energy_use = 100;
661 /* Seeing true feature code (ignore mimic) */
664 if (!have_flag(f_ptr->flags, FF_OPEN))
667 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
671 else if (f_ptr->power)
674 i = p_ptr->skill_dis;
676 /* Penalize some conditions */
677 if (p_ptr->blind || no_lite()) i = i / 10;
678 if (p_ptr->confused || p_ptr->image) i = i / 10;
680 /* Extract the lock power */
683 /* Extract the difficulty */
686 /* Always have a small chance of success */
690 if (randint0(100) < j)
692 msg_print(_("鍵をはずした。", "You have picked the lock."));
695 cave_alter_feat(y, x, FF_OPEN);
697 sound(SOUND_OPENDOOR);
707 if (flush_failure) flush();
709 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
711 /* We may keep trying */
720 cave_alter_feat(y, x, FF_OPEN);
722 sound(SOUND_OPENDOOR);
728 * @brief 「開ける」コマンドのメインルーチン /
729 * Open a closed/locked/jammed door or a closed/locked chest.
732 * Unlocking a locked door/chest is worth one experience point.
734 void do_cmd_open(void)
742 if (p_ptr->wild_mode) return;
744 if (p_ptr->special_defense & KATA_MUSOU)
746 set_action(ACTION_NONE);
749 /* Option: Pick a direction */
752 int num_doors, num_chests;
754 /* Count closed doors (locked or jammed) */
755 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
757 /* Count chests (locked) */
758 num_chests = count_chests(&y, &x, FALSE);
760 /* See if only one target */
761 if (num_doors || num_chests)
763 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
765 if (!too_many) command_dir = coords_to_dir(y, x);
769 /* Allow repeated command */
772 /* Set repeat count */
773 command_rep = command_arg - 1;
774 p_ptr->redraw |= (PR_STATE);
780 /* Get a "repeated" direction */
781 if (get_rep_dir(&dir, TRUE))
786 /* Get requested location */
787 y = p_ptr->y + ddy[dir];
788 x = p_ptr->x + ddx[dir];
790 /* Get requested grid */
793 /* Feature code (applying "mimic" field) */
794 feat = get_feat_mimic(c_ptr);
796 /* Check for chest */
797 o_idx = chest_check(y, x, FALSE);
800 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
802 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
805 /* Monster in the way */
806 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
808 p_ptr->energy_use = 100;
809 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
817 more = do_cmd_open_chest(y, x, o_idx);
824 more = do_cmd_open_aux(y, x);
828 /* Cancel repeat unless we may continue */
829 if (!more) disturb(FALSE, FALSE);
835 * @brief 「閉じる」動作コマンドのサブルーチン /
836 * Perform the basic "close" command
837 * @param y 対象を行うマスのY座標
838 * @param x 対象を行うマスのX座標
839 * @return 実際に処理が行われた場合TRUEを返す。
841 * Assume destination is an open/broken door
842 * Assume there is no monster blocking the destination
843 * Returns TRUE if repeated commands may continue
845 static bool do_cmd_close_aux(POSITION y, POSITION x)
847 cave_type *c_ptr = &cave[y][x];
848 FEAT_IDX old_feat = c_ptr->feat;
851 p_ptr->energy_use = 100;
853 /* Seeing true feature code (ignore mimic) */
856 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
858 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
860 /* Hack -- object in the way */
861 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
862 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
864 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
869 cave_alter_feat(y, x, FF_CLOSE);
872 if (old_feat == c_ptr->feat)
874 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
878 sound(SOUND_SHUTDOOR);
887 * @brief 「閉じる」コマンドのメインルーチン /
888 * Close an open door.
891 * Unlocking a locked door/chest is worth one experience point.
893 void do_cmd_close(void)
900 if (p_ptr->wild_mode) return;
902 if (p_ptr->special_defense & KATA_MUSOU)
904 set_action(ACTION_NONE);
907 /* Option: Pick a direction */
910 /* Count open doors */
911 if (count_dt(&y, &x, is_open, FALSE) == 1)
913 command_dir = coords_to_dir(y, x);
917 /* Allow repeated command */
920 /* Set repeat count */
921 command_rep = command_arg - 1;
922 p_ptr->redraw |= (PR_STATE);
928 /* Get a "repeated" direction */
929 if (get_rep_dir(&dir, FALSE))
934 y = p_ptr->y + ddy[dir];
935 x = p_ptr->x + ddx[dir];
938 /* Feature code (applying "mimic" field) */
939 feat = get_feat_mimic(c_ptr);
941 /* Require open/broken door */
942 if (!have_flag(f_info[feat].flags, FF_CLOSE))
944 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
947 /* Monster in the way */
948 else if (c_ptr->m_idx)
950 p_ptr->energy_use = 100;
952 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
962 more = do_cmd_close_aux(y, x);
966 /* Cancel repeat unless we may continue */
967 if (!more) disturb(FALSE, FALSE);
972 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
973 * Determine if a given grid may be "tunneled"
974 * @param y 対象を行うマスのY座標
975 * @param x 対象を行うマスのX座標
978 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
980 cave_type *c_ptr = &cave[y][x];
982 /* Must have knowledge */
983 if (!(c_ptr->info & CAVE_MARK))
985 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
990 /* Must be a wall/door/etc */
991 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
993 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1003 * @brief 「掘る」動作コマンドのサブルーチン /
1004 * Perform the basic "tunnel" command
1005 * @param y 対象を行うマスのY座標
1006 * @param x 対象を行うマスのX座標
1007 * @return 実際に処理が行われた場合TRUEを返す。
1009 * Assumes that no monster is blocking the destination
1010 * Do not use twall anymore
1011 * Returns TRUE if repeated commands may continue
1013 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1016 feature_type *f_ptr, *mimic_f_ptr;
1021 /* Verify legality */
1022 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1024 p_ptr->energy_use = 100;
1027 c_ptr = &cave[y][x];
1028 f_ptr = &f_info[c_ptr->feat];
1029 power = f_ptr->power;
1031 /* Feature code (applying "mimic" field) */
1032 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1034 name = f_name + mimic_f_ptr->name;
1038 if (have_flag(f_ptr->flags, FF_PERMANENT))
1041 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1043 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1046 /* Map border (mimiccing Permanent wall) */
1049 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1054 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1057 if (p_ptr->skill_dig > randint0(20 * power))
1059 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1061 /* Remove the feature */
1062 cave_alter_feat(y, x, FF_TUNNEL);
1064 /* Update some things */
1065 p_ptr->update |= (PU_FLOW);
1069 /* Message, keep digging */
1070 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1078 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1081 if (p_ptr->skill_dig > power + randint0(40 * power))
1083 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1086 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1087 p_ptr->update |= (PU_FLOW);
1090 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1092 /* Remove the feature */
1093 cave_alter_feat(y, x, FF_TUNNEL);
1095 chg_virtue(V_DILIGENCE, 1);
1096 chg_virtue(V_NATURE, -1);
1104 /* We may continue chopping */
1105 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1106 /* Occasional Search XXX XXX */
1107 if (randint0(100) < 25) search();
1111 /* We may continue tunelling */
1112 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1119 if (is_hidden_door(c_ptr))
1121 /* Occasional Search XXX XXX */
1122 if (randint0(100) < 25) search();
1129 * @brief 「掘る」動作コマンドのメインルーチン /
1130 * Tunnels through "walls" (including rubble and closed doors)
1134 * Note that you must tunnel in order to hit invisible monsters
1135 * in walls, though moving into walls still takes a turn anyway.
1137 * Digging is very difficult without a "digger" weapon, but can be
1138 * accomplished by strong players using heavy weapons.
1141 void do_cmd_tunnel(void)
1151 if (p_ptr->special_defense & KATA_MUSOU)
1153 set_action(ACTION_NONE);
1156 /* Allow repeated command */
1159 /* Set repeat count */
1160 command_rep = command_arg - 1;
1161 p_ptr->redraw |= (PR_STATE);
1163 /* Cancel the arg */
1167 /* Get a direction to tunnel, or Abort */
1168 if (get_rep_dir(&dir,FALSE))
1171 y = p_ptr->y + ddy[dir];
1172 x = p_ptr->x + ddx[dir];
1175 c_ptr = &cave[y][x];
1177 /* Feature code (applying "mimic" field) */
1178 feat = get_feat_mimic(c_ptr);
1180 /* No tunnelling through doors */
1181 if (have_flag(f_info[feat].flags, FF_DOOR))
1183 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1186 /* No tunnelling through most features */
1187 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1189 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1192 /* A monster is in the way */
1193 else if (c_ptr->m_idx)
1195 p_ptr->energy_use = 100;
1197 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1206 /* Tunnel through walls */
1207 more = do_cmd_tunnel_aux(y, x);
1211 /* Cancel repetition unless we can continue */
1212 if (!more) disturb(FALSE, FALSE);
1216 * @brief 移動処理による簡易な「開く」処理 /
1218 * @return 開く処理が実際に試みられた場合TRUEを返す
1221 * If there is a jammed/closed/locked door at the given location,
1222 * then attempt to unlock/open it. Return TRUE if an attempt was
1223 * made (successful or not), otherwise return FALSE.
1225 * The code here should be nearly identical to that in
1226 * do_cmd_open_test() and do_cmd_open_aux().
1229 bool easy_open_door(POSITION y, POSITION x)
1233 cave_type *c_ptr = &cave[y][x];
1234 feature_type *f_ptr = &f_info[c_ptr->feat];
1236 /* Must be a closed door */
1237 if (!is_closed_door(c_ptr->feat))
1243 if (!have_flag(f_ptr->flags, FF_OPEN))
1246 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1251 else if (f_ptr->power)
1254 i = p_ptr->skill_dis;
1256 /* Penalize some conditions */
1257 if (p_ptr->blind || no_lite()) i = i / 10;
1258 if (p_ptr->confused || p_ptr->image) i = i / 10;
1260 /* Extract the lock power */
1263 /* Extract the difficulty */
1266 /* Always have a small chance of success */
1270 if (randint0(100) < j)
1272 msg_print(_("鍵をはずした。", "You have picked the lock."));
1275 cave_alter_feat(y, x, FF_OPEN);
1277 sound(SOUND_OPENDOOR);
1287 if (flush_failure) flush();
1289 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1298 cave_alter_feat(y, x, FF_OPEN);
1300 sound(SOUND_OPENDOOR);
1306 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1307 * Perform the basic "disarm" command
1308 * @param y 解除を行うマスのY座標
1309 * @param x 解除を行うマスのX座標
1310 * @param o_idx 箱のオブジェクトID
1311 * @return ターンを消費する処理が行われた場合TRUEを返す
1314 * Assume destination is a visible trap
1315 * Assume there is no monster blocking the destination
1316 * Returns TRUE if repeated commands may continue
1319 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1323 object_type *o_ptr = &o_list[o_idx];
1325 p_ptr->energy_use = 100;
1327 /* Get the "disarm" factor */
1328 i = p_ptr->skill_dis;
1330 /* Penalize some conditions */
1331 if (p_ptr->blind || no_lite()) i = i / 10;
1332 if (p_ptr->confused || p_ptr->image) i = i / 10;
1334 /* Extract the difficulty */
1335 j = i - o_ptr->pval;
1337 /* Always have a small chance of success */
1340 /* Must find the trap first. */
1341 if (!object_is_known(o_ptr))
1343 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1347 /* Already disarmed/unlocked */
1348 else if (o_ptr->pval <= 0)
1350 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1353 /* No traps to find. */
1354 else if (!chest_traps[o_ptr->pval])
1356 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1359 /* Success (get a lot of experience) */
1360 else if (randint0(100) < j)
1362 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1363 gain_exp(o_ptr->pval);
1364 o_ptr->pval = (0 - o_ptr->pval);
1367 /* Failure -- Keep trying */
1368 else if ((i > 5) && (randint1(i) > 5))
1370 /* We may keep trying */
1372 if (flush_failure) flush();
1373 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1376 /* Failure -- Set off the trap */
1379 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1381 chest_trap(y, x, o_idx);
1388 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1389 * Perform the basic "disarm" command
1390 * @param y 解除を行うマスのY座標
1391 * @param x 解除を行うマスのX座標
1392 * @param dir プレイヤーからみた方向ID
1393 * @return ターンを消費する処理が行われた場合TRUEを返す
1396 * Assume destination is a visible trap
1397 * Assume there is no monster blocking the destination
1398 * Returns TRUE if repeated commands may continue
1402 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1404 cave_type *c_ptr = &cave[y][x];
1407 feature_type *f_ptr = &f_info[c_ptr->feat];
1409 /* Access trap name */
1410 concptr name = (f_name + f_ptr->name);
1412 /* Extract trap "power" */
1413 int power = f_ptr->power;
1416 /* Get the "disarm" factor */
1417 int i = p_ptr->skill_dis;
1420 p_ptr->energy_use = 100;
1422 /* Penalize some conditions */
1423 if (p_ptr->blind || no_lite()) i = i / 10;
1424 if (p_ptr->confused || p_ptr->image) i = i / 10;
1426 /* Extract the difficulty */
1429 /* Always have a small chance of success */
1433 if (randint0(100) < j)
1435 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1440 /* Remove the trap */
1441 cave_alter_feat(y, x, FF_DISARM);
1443 /* Move the player onto the trap */
1444 move_player(dir, easy_disarm, FALSE);
1447 /* Failure -- Keep trying */
1448 else if ((i > 5) && (randint1(i) > 5))
1451 if (flush_failure) flush();
1453 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1455 /* We may keep trying */
1459 /* Failure -- Set off the trap */
1462 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1463 /* Move the player onto the trap */
1464 move_player(dir, easy_disarm, FALSE);
1471 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1472 * Disarms a trap, or chest
1475 void do_cmd_disarm(void)
1483 if (p_ptr->wild_mode) return;
1485 if (p_ptr->special_defense & KATA_MUSOU)
1487 set_action(ACTION_NONE);
1490 /* Option: Pick a direction */
1493 int num_traps, num_chests;
1495 /* Count visible traps */
1496 num_traps = count_dt(&y, &x, is_trap, TRUE);
1498 /* Count chests (trapped) */
1499 num_chests = count_chests(&y, &x, TRUE);
1501 /* See if only one target */
1502 if (num_traps || num_chests)
1504 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1505 if (!too_many) command_dir = coords_to_dir(y, x);
1510 /* Allow repeated command */
1513 /* Set repeat count */
1514 command_rep = command_arg - 1;
1515 p_ptr->redraw |= (PR_STATE);
1517 /* Cancel the arg */
1521 /* Get a direction (or abort) */
1522 if (get_rep_dir(&dir,TRUE))
1527 y = p_ptr->y + ddy[dir];
1528 x = p_ptr->x + ddx[dir];
1529 c_ptr = &cave[y][x];
1531 /* Feature code (applying "mimic" field) */
1532 feat = get_feat_mimic(c_ptr);
1534 /* Check for chests */
1535 o_idx = chest_check(y, x, TRUE);
1538 if (!is_trap(feat) && !o_idx)
1540 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1543 /* Monster in the way */
1544 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1546 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1555 more = do_cmd_disarm_chest(y, x, o_idx);
1561 more = do_cmd_disarm_aux(y, x, dir);
1565 /* Cancel repeat unless told not to */
1566 if (!more) disturb(FALSE, FALSE);
1571 * @brief 「打ち破る」動作コマンドのサブルーチン /
1572 * Perform the basic "bash" command
1573 * @param y 対象を行うマスのY座標
1574 * @param x 対象を行うマスのX座標
1575 * @param dir プレイヤーから見たターゲットの方角ID
1576 * @return 実際に処理が行われた場合TRUEを返す。
1579 * Assume destination is a closed/locked/jammed door
1580 * Assume there is no monster blocking the destination
1581 * Returns TRUE if repeated commands may continue
1584 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1587 cave_type *c_ptr = &cave[y][x];
1590 feature_type *f_ptr = &f_info[c_ptr->feat];
1592 /* Hack -- Bash power based on strength */
1593 /* (Ranges from 3 to 20 to 100 to 200) */
1594 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1596 /* Extract door power */
1597 int temp = f_ptr->power;
1601 concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1603 p_ptr->energy_use = 100;
1605 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1607 /* Compare bash power to door power */
1608 temp = (bash - (temp * 10));
1610 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1612 /* Hack -- always have a chance */
1613 if (temp < 1) temp = 1;
1615 /* Hack -- attempt to bash down the door */
1616 if (randint0(100) < temp)
1618 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1620 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1622 /* Break down the door */
1623 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1625 cave_alter_feat(y, x, FF_BASH);
1631 cave_alter_feat(y, x, FF_OPEN);
1634 /* Hack -- Fall through the door */
1635 move_player(dir, FALSE, FALSE);
1638 /* Saving throw against stun */
1639 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1642 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1644 /* Allow repeated bashing */
1648 /* High dexterity yields coolness */
1651 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1653 /* Hack -- Lose balance ala paralysis */
1654 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1661 * @brief 「打ち破る」動作コマンドのメインルーチン /
1662 * Bash open a door, success based on character strength
1666 * For a closed door, pval is positive if locked; negative if stuck.
1668 * For an open door, pval is positive for a broken door.
1670 * A closed door can be opened - harder if locked. Any door might be
1671 * bashed open (and thereby broken). Bashing a door is (potentially)
1672 * faster! You move into the door way. To open a stuck door, it must
1673 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1675 * Creatures can also open or bash doors, see elsewhere.
1678 void do_cmd_bash(void)
1684 if (p_ptr->wild_mode) return;
1686 if (p_ptr->special_defense & KATA_MUSOU)
1688 set_action(ACTION_NONE);
1691 /* Allow repeated command */
1694 /* Set repeat count */
1695 command_rep = command_arg - 1;
1696 p_ptr->redraw |= (PR_STATE);
1698 /* Cancel the arg */
1702 /* Get a "repeated" direction */
1703 if (get_rep_dir(&dir,FALSE))
1708 y = p_ptr->y + ddy[dir];
1709 x = p_ptr->x + ddx[dir];
1712 c_ptr = &cave[y][x];
1714 /* Feature code (applying "mimic" field) */
1715 feat = get_feat_mimic(c_ptr);
1717 /* Nothing useful */
1718 if (!have_flag(f_info[feat].flags, FF_BASH))
1720 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1723 /* Monster in the way */
1724 else if (c_ptr->m_idx)
1726 p_ptr->energy_use = 100;
1728 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1734 /* Bash a closed door */
1738 more = do_cmd_bash_aux(y, x, dir);
1742 /* Unless valid action taken, cancel bash */
1743 if (!more) disturb(FALSE, FALSE);
1748 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1752 * Manipulate an adjacent grid in some way
1754 * Attack monsters, tunnel through walls, disarm traps, open doors.
1756 * Consider confusion
1758 * This command must always take a turn, to prevent free detection
1759 * of invisible monsters.
1762 void do_cmd_alter(void)
1769 if (p_ptr->special_defense & KATA_MUSOU)
1771 set_action(ACTION_NONE);
1774 /* Allow repeated command */
1777 /* Set repeat count */
1778 command_rep = command_arg - 1;
1779 p_ptr->redraw |= (PR_STATE);
1781 /* Cancel the arg */
1785 /* Get a direction */
1786 if (get_rep_dir(&dir,TRUE))
1789 feature_type *f_ptr;
1791 y = p_ptr->y + ddy[dir];
1792 x = p_ptr->x + ddx[dir];
1795 c_ptr = &cave[y][x];
1797 /* Feature code (applying "mimic" field) */
1798 feat = get_feat_mimic(c_ptr);
1799 f_ptr = &f_info[feat];
1801 p_ptr->energy_use = 100;
1809 else if (have_flag(f_ptr->flags, FF_OPEN))
1811 more = do_cmd_open_aux(y, x);
1814 /* Bash jammed doors */
1815 else if (have_flag(f_ptr->flags, FF_BASH))
1817 more = do_cmd_bash_aux(y, x, dir);
1820 /* Tunnel through walls */
1821 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1823 more = do_cmd_tunnel_aux(y, x);
1826 /* Close open doors */
1827 else if (have_flag(f_ptr->flags, FF_CLOSE))
1829 more = do_cmd_close_aux(y, x);
1833 else if (have_flag(f_ptr->flags, FF_DISARM))
1835 more = do_cmd_disarm_aux(y, x, dir);
1840 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1844 /* Cancel repetition unless we can continue */
1845 if (!more) disturb(FALSE, FALSE);
1851 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1852 * Find the index of some "spikes", if possible.
1853 * @param ip くさびとして打てるオブジェクトのID
1854 * @return オブジェクトがある場合TRUEを返す
1857 * Let user choose a pile of spikes, perhaps?
1860 static bool get_spike(INVENTORY_IDX *ip)
1864 /* Check every item in the pack */
1865 for (i = 0; i < INVEN_PACK; i++)
1867 object_type *o_ptr = &inventory[i];
1869 /* Skip non-objects */
1870 if (!o_ptr->k_idx) continue;
1872 /* Check the "tval" code */
1873 if (o_ptr->tval == TV_SPIKE)
1875 /* Save the spike index */
1888 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1889 * Jam a closed door with a spike
1893 * This command may NOT be repeated
1896 void do_cmd_spike(void)
1900 if (p_ptr->wild_mode) return;
1902 if (p_ptr->special_defense & KATA_MUSOU)
1904 set_action(ACTION_NONE);
1907 /* Get a "repeated" direction */
1908 if (get_rep_dir(&dir, FALSE))
1915 y = p_ptr->y + ddy[dir];
1916 x = p_ptr->x + ddx[dir];
1917 c_ptr = &cave[y][x];
1919 /* Feature code (applying "mimic" field) */
1920 feat = get_feat_mimic(c_ptr);
1922 /* Require closed door */
1923 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1925 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1929 else if (!get_spike(&item))
1931 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1934 /* Is a monster in the way? */
1935 else if (c_ptr->m_idx)
1937 p_ptr->energy_use = 100;
1939 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1948 p_ptr->energy_use = 100;
1950 /* Successful jamming */
1951 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1952 cave_alter_feat(y, x, FF_SPIKE);
1954 /* Use up, and describe, a single spike, from the bottom */
1955 inven_item_increase(item, -1);
1956 inven_item_describe(item);
1957 inven_item_optimize(item);
1965 * @brief 「歩く」動作コマンドのメインルーチン /
1966 * Support code for the "Walk" and "Jump" commands
1967 * @param pickup アイテムの自動拾いを行うならTRUE
1970 void do_cmd_walk(bool pickup)
1977 /* Allow repeated command */
1980 /* Set repeat count */
1981 command_rep = command_arg - 1;
1982 p_ptr->redraw |= (PR_STATE);
1984 /* Cancel the arg */
1988 /* Get a "repeated" direction */
1989 if (get_rep_dir(&dir, FALSE))
1991 p_ptr->energy_use = 100;
1993 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
1995 set_action(ACTION_NONE);
1998 /* Hack -- In small scale wilderness it takes MUCH more time to move */
1999 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2000 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2002 /* Actually move the character */
2003 move_player(dir, pickup, FALSE);
2005 /* Allow more walking */
2009 /* Hack again -- Is there a special encounter ??? */
2010 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2012 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2015 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2017 /* Inform the player of his horrible fate :=) */
2018 msg_print(_("襲撃だ!", "You are ambushed !"));
2020 /* Go into large wilderness view */
2021 p_ptr->oldpy = randint1(MAX_HGT-2);
2022 p_ptr->oldpx = randint1(MAX_WID-2);
2025 /* Give first move to monsters */
2026 p_ptr->energy_use = 100;
2028 /* HACk -- set the encouter flag for the wilderness generation */
2029 generate_encounter = TRUE;
2033 /* Cancel repeat unless we may continue */
2034 if (!more) disturb(FALSE, FALSE);
2039 * @brief 「走る」動作コマンドのメインルーチン /
2043 void do_cmd_run(void)
2047 /* Hack -- no running when confused */
2048 if (p_ptr->confused)
2050 msg_print(_("混乱していて走れない!", "You are too confused!"));
2054 if (p_ptr->special_defense & KATA_MUSOU)
2056 set_action(ACTION_NONE);
2059 /* Get a "repeated" direction */
2060 if (get_rep_dir(&dir,FALSE))
2062 /* Hack -- Set the run counter */
2063 running = (command_arg ? command_arg : 1000);
2072 * @brief 「留まる」動作コマンドのメインルーチン /
2073 * Stay still. Search. Enter stores.
2074 * Pick up treasure if "pickup" is true.
2075 * @param pickup アイテムの自動拾いを行うならTRUE
2078 void do_cmd_stay(bool pickup)
2080 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2082 /* Allow repeated command */
2085 /* Set repeat count */
2086 command_rep = command_arg - 1;
2087 p_ptr->redraw |= (PR_STATE);
2089 /* Cancel the arg */
2093 p_ptr->energy_use = 100;
2095 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2096 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2101 * @brief 「休む」動作コマンドのメインルーチン /
2102 * Resting allows a player to safely restore his hp -RAK-
2105 void do_cmd_rest(void)
2108 set_action(ACTION_NONE);
2110 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2116 if (hex_spelling_any()) stop_hex_spell_all();
2118 /* Prompt for time if needed */
2119 if (command_arg <= 0)
2121 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2122 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2128 strcpy(out_val, "&");
2130 /* Ask for duration */
2131 if (!get_string(p, out_val, 4)) return;
2133 /* Rest until done */
2134 if (out_val[0] == '&')
2136 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2140 else if (out_val[0] == '*')
2142 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2148 command_arg = (COMMAND_ARG)atoi(out_val);
2149 if (command_arg <= 0) return;
2155 if (command_arg > 9999) command_arg = 9999;
2157 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2159 /* Take a turn (?) */
2160 p_ptr->energy_use = 100;
2162 /* The sin of sloth */
2163 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2165 /* Why are you sleeping when there's no need? WAKE UP!*/
2166 if ((p_ptr->chp == p_ptr->mhp) &&
2167 (p_ptr->csp == p_ptr->msp) &&
2168 !p_ptr->blind && !p_ptr->confused &&
2169 !p_ptr->poisoned && !p_ptr->afraid &&
2170 !p_ptr->stun && !p_ptr->cut &&
2171 !p_ptr->slow && !p_ptr->paralyzed &&
2172 !p_ptr->image && !p_ptr->word_recall &&
2173 !p_ptr->alter_reality)
2174 chg_virtue(V_DILIGENCE, -1);
2176 /* Save the rest code */
2177 resting = command_arg;
2178 p_ptr->action = ACTION_REST;
2179 p_ptr->update |= (PU_BONUS);
2180 update_creature(p_ptr);
2182 p_ptr->redraw |= (PR_STATE);
2190 * @brief 矢弾を射撃した場合の破損確率を返す /
2191 * Determines the odds of an object breaking when thrown at a monster
2192 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2195 * Note that artifacts never break, see the "drop_near()" function.
2197 static PERCENTAGE breakage_chance(object_type *o_ptr)
2199 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2201 /* Examine the snipe type */
2204 if (snipe_type == SP_KILL_WALL) return (100);
2205 if (snipe_type == SP_EXPLODE) return (100);
2206 if (snipe_type == SP_PIERCE) return (100);
2207 if (snipe_type == SP_FINAL) return (100);
2208 if (snipe_type == SP_NEEDLE) return (100);
2209 if (snipe_type == SP_EVILNESS) return (40);
2210 if (snipe_type == SP_HOLYNESS) return (40);
2213 /* Examine the item type */
2214 switch (o_ptr->tval)
2230 /* Sometimes break */
2235 return (20 - archer_bonus * 2);
2240 return (10 - archer_bonus);
2248 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2249 * Determines the odds of an object breaking when thrown at a monster
2250 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2251 * @param tdam 計算途中のダメージ量
2252 * @param m_ptr 目標モンスターの構造体参照ポインタ
2253 * @return スレイ倍率をかけたダメージ量
2255 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2259 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2261 BIT_FLAGS flgs[TR_FLAG_SIZE];
2262 object_flags(o_ptr, flgs);
2264 /* Some "weapons" and "ammo" do extra damage */
2265 switch (o_ptr->tval)
2271 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2273 if (is_original_ap_and_seen(m_ptr))
2275 r_ptr->r_flags3 |= RF3_ANIMAL;
2277 if (mult < 17) mult = 17;
2280 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2282 if (is_original_ap_and_seen(m_ptr))
2284 r_ptr->r_flags3 |= RF3_ANIMAL;
2286 if (mult < 27) mult = 27;
2289 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2291 if (is_original_ap_and_seen(m_ptr))
2293 r_ptr->r_flags3 |= RF3_EVIL;
2295 if (mult < 15) mult = 15;
2298 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2300 if (is_original_ap_and_seen(m_ptr))
2302 r_ptr->r_flags3 |= RF3_EVIL;
2304 if (mult < 25) mult = 25;
2307 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2309 if (is_original_ap_and_seen(m_ptr))
2311 r_ptr->r_flags2 |= RF2_HUMAN;
2313 if (mult < 17) mult = 17;
2316 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2318 if (is_original_ap_and_seen(m_ptr))
2320 r_ptr->r_flags2 |= RF2_HUMAN;
2322 if (mult < 27) mult = 27;
2325 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2327 if (is_original_ap_and_seen(m_ptr))
2329 r_ptr->r_flags3 |= RF3_UNDEAD;
2331 if (mult < 20) mult = 20;
2334 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2336 if (is_original_ap_and_seen(m_ptr))
2338 r_ptr->r_flags3 |= RF3_UNDEAD;
2340 if (mult < 30) mult = 30;
2343 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2345 if (is_original_ap_and_seen(m_ptr))
2347 r_ptr->r_flags3 |= RF3_DEMON;
2349 if (mult < 20) mult = 20;
2352 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2354 if (is_original_ap_and_seen(m_ptr))
2356 r_ptr->r_flags3 |= RF3_DEMON;
2358 if (mult < 30) mult = 30;
2361 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
2363 if (is_original_ap_and_seen(m_ptr))
2365 r_ptr->r_flags3 |= RF3_ORC;
2367 if (mult < 20) mult = 20;
2370 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
2372 if (is_original_ap_and_seen(m_ptr))
2374 r_ptr->r_flags3 |= RF3_ORC;
2376 if (mult < 30) mult = 30;
2379 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2381 if (is_original_ap_and_seen(m_ptr))
2383 r_ptr->r_flags3 |= RF3_TROLL;
2386 if (mult < 20) mult = 20;
2389 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2391 if (is_original_ap_and_seen(m_ptr))
2393 r_ptr->r_flags3 |= RF3_TROLL;
2395 if (mult < 30) mult = 30;
2398 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2400 if (is_original_ap_and_seen(m_ptr))
2402 r_ptr->r_flags3 |= RF3_GIANT;
2404 if (mult < 20) mult = 20;
2407 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2409 if (is_original_ap_and_seen(m_ptr))
2411 r_ptr->r_flags3 |= RF3_GIANT;
2413 if (mult < 30) mult = 30;
2416 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2418 if (is_original_ap_and_seen(m_ptr))
2420 r_ptr->r_flags3 |= RF3_DRAGON;
2422 if (mult < 20) mult = 20;
2425 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2427 if (is_original_ap_and_seen(m_ptr))
2429 r_ptr->r_flags3 |= RF3_DRAGON;
2431 if (mult < 30) mult = 30;
2432 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
2433 (inventory[INVEN_BOW].name1 == ART_BARD))
2437 if (have_flag(flgs, TR_BRAND_ACID))
2439 /* Notice immunity */
2440 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2442 if (is_original_ap_and_seen(m_ptr))
2444 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2449 if (mult < 17) mult = 17;
2453 if (have_flag(flgs, TR_BRAND_ELEC))
2455 /* Notice immunity */
2456 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2458 if (is_original_ap_and_seen(m_ptr))
2460 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2465 if (mult < 17) mult = 17;
2469 if (have_flag(flgs, TR_BRAND_FIRE))
2471 /* Notice immunity */
2472 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2474 if (is_original_ap_and_seen(m_ptr))
2476 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2479 /* Otherwise, take the damage */
2482 if (r_ptr->flags3 & RF3_HURT_FIRE)
2484 if (mult < 25) mult = 25;
2485 if (is_original_ap_and_seen(m_ptr))
2487 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2490 else if (mult < 17) mult = 17;
2494 if (have_flag(flgs, TR_BRAND_COLD))
2496 /* Notice immunity */
2497 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2499 if (is_original_ap_and_seen(m_ptr))
2501 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2504 /* Otherwise, take the damage */
2507 if (r_ptr->flags3 & RF3_HURT_COLD)
2509 if (mult < 25) mult = 25;
2510 if (is_original_ap_and_seen(m_ptr))
2512 r_ptr->r_flags3 |= RF3_HURT_COLD;
2515 else if (mult < 17) mult = 17;
2519 if (have_flag(flgs, TR_BRAND_POIS))
2521 /* Notice immunity */
2522 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2524 if (is_original_ap_and_seen(m_ptr))
2526 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2529 /* Otherwise, take the damage */
2532 if (mult < 17) mult = 17;
2536 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2538 p_ptr->csp -= (1+(p_ptr->msp / 30));
2539 p_ptr->redraw |= (PR_MANA);
2540 mult = mult * 5 / 2;
2547 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2549 /* Return the total damage */
2550 return (tdam * mult / 10);
2555 * @brief 射撃処理のサブルーチン /
2556 * Fire an object from the pack or floor.
2557 * @param item 射撃するオブジェクトの所持ID
2558 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2562 * You may only fire items that "match" your missile launcher.
2564 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2566 * See "calc_bonuses()" for more calculations and such.
2568 * Note that "firing" a missile is MUCH better than "throwing" it.
2570 * Note: "unseen" monsters are very hard to hit.
2572 * Objects are more likely to break if they "attempt" to hit a monster.
2574 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2576 * The "extra shot" code works by decreasing the amount of energy
2577 * required to make each shot, spreading the shots out over time.
2579 * Note that when firing missiles, the launcher multiplier is applied
2580 * after all the bonuses are added in, making multipliers very useful.
2582 * Note that Bows of "Extra Might" get extra range and an extra bonus
2583 * for the damage multiplier.
2585 * Note that Bows of "Extra Shots" give an extra shot.
2588 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2592 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2593 int tdam_base, tdis, thits, tmul;
2595 int cur_dis, visible;
2603 bool hit_body = FALSE;
2605 GAME_TEXT o_name[MAX_NLEN];
2607 u16b path_g[512]; /* For calcuration of path length */
2609 int msec = delay_factor * delay_factor * delay_factor;
2612 bool stick_to = FALSE;
2614 /* Access the item (if in the pack) */
2617 o_ptr = &inventory[item];
2621 o_ptr = &o_list[0 - item];
2624 /* Sniper - Cannot shot a single arrow twice */
2625 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2627 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2629 /* Use the proper number of shots */
2630 thits = p_ptr->num_fire;
2632 /* Use a base distance */
2635 /* Base damage from thrown object plus launcher bonus */
2636 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2638 /* Actually "fire" the object */
2639 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2640 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2641 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2643 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2645 p_ptr->energy_use = bow_energy(j_ptr->sval);
2646 tmul = bow_tmul(j_ptr->sval);
2648 /* Get extra "power" from "extra might" */
2649 if (p_ptr->xtra_might) tmul++;
2651 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2653 /* Boost the damage */
2658 tdis = 13 + tmul/80;
2659 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2662 tdis -= (5 - (p_ptr->concent + 1) / 2);
2667 project_length = tdis + 1;
2669 /* Get a direction (or cancel) */
2670 if (!get_aim_dir(&dir))
2672 p_ptr->energy_use = 0;
2674 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2676 /* need not to reset project_length (already did)*/
2681 /* Predict the "target" location */
2682 tx = p_ptr->x + 99 * ddx[dir];
2683 ty = p_ptr->y + 99 * ddy[dir];
2685 /* Check for "target request" */
2686 if ((dir == 5) && target_okay())
2692 /* Get projection path length */
2693 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2695 project_length = 0; /* reset to default */
2697 /* Don't shoot at my feet */
2698 if (tx == p_ptr->x && ty == p_ptr->y)
2700 p_ptr->energy_use = 0;
2702 /* project_length is already reset to 0 */
2708 /* Take a (partial) turn */
2709 p_ptr->energy_use = (p_ptr->energy_use / thits);
2712 /* Sniper - Difficult to shot twice at 1 turn */
2713 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2715 /* Sniper - Repeat shooting when double shots */
2716 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2719 /* Start at the player */
2724 /* Obtain a local object */
2725 object_copy(q_ptr, o_ptr);
2730 /* Reduce and describe inventory */
2733 inven_item_increase(item, -1);
2734 inven_item_describe(item);
2735 inven_item_optimize(item);
2738 /* Reduce and describe floor item */
2741 floor_item_increase(0 - item, -1);
2742 floor_item_optimize(0 - item);
2748 /* Save the old location */
2752 /* The shot does not hit yet */
2755 /* Travel until stopped */
2756 for (cur_dis = 0; cur_dis <= tdis; )
2760 /* Hack -- Stop at the target */
2761 if ((y == ty) && (x == tx)) break;
2763 /* Calculate the new location (see "project()") */
2766 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2769 if (snipe_type == SP_KILL_WALL)
2771 c_ptr = &cave[ny][nx];
2773 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2775 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2776 /* Forget the wall */
2777 c_ptr->info &= ~(CAVE_MARK);
2778 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2780 /* Destroy the wall */
2781 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2788 /* Stopped by walls/doors */
2789 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2791 /* Advance the distance */
2795 if (snipe_type == SP_LITE)
2797 cave[ny][nx].info |= (CAVE_GLOW);
2802 /* The player can see the (on screen) missile */
2803 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2805 char c = object_char(q_ptr);
2806 byte a = object_attr(q_ptr);
2808 /* Draw, Hilite, Fresh, Pause, Erase */
2809 print_rel(c, a, ny, nx);
2810 move_cursor_relative(ny, nx);
2812 Term_xtra(TERM_XTRA_DELAY, msec);
2817 /* The player cannot see the missile */
2820 /* Pause anyway, for consistancy */
2821 Term_xtra(TERM_XTRA_DELAY, msec);
2825 if (snipe_type == SP_KILL_TRAP)
2827 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
2828 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
2832 if (snipe_type == SP_EVILNESS)
2834 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
2839 /* Save the old location */
2843 /* Save the new location */
2847 /* Monster here, Try to hit it */
2848 if (cave[y][x].m_idx)
2850 cave_type *c_mon_ptr = &cave[y][x];
2852 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
2853 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2855 /* Check the visibility */
2856 visible = m_ptr->ml;
2858 /* Note the collision */
2861 if (MON_CSLEEP(m_ptr))
2863 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
2864 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
2867 if ((r_ptr->level + 10) > p_ptr->lev)
2869 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
2870 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
2873 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
2874 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
2875 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
2876 else if (p_ptr->lev > 34) amount = 2;
2877 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
2878 p_ptr->update |= (PU_BONUS);
2884 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
2885 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
2888 p_ptr->skill_exp[GINOU_RIDING] += 1;
2889 p_ptr->update |= (PU_BONUS);
2893 /* Did we hit it (penalize range) */
2894 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2897 int tdam = tdam_base;
2899 /* Get extra damage from concentration */
2900 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
2902 /* Handle unseen monster */
2905 /* Invisible monster */
2906 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2909 /* Handle visible monster */
2912 GAME_TEXT m_name[MAX_NLEN];
2914 /* Get "the monster" or "it" */
2915 monster_desc(m_name, m_ptr, 0);
2917 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2921 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2922 health_track(c_mon_ptr->m_idx);
2926 if (snipe_type == SP_NEEDLE)
2928 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
2929 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
2931 GAME_TEXT m_name[MAX_NLEN];
2933 /* Get "the monster" or "it" */
2934 monster_desc(m_name, m_ptr, 0);
2936 tdam = m_ptr->hp + 1;
2937 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
2943 /* Apply special damage */
2944 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
2945 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
2947 /* No negative damage */
2948 if (tdam < 0) tdam = 0;
2950 /* Modify the damage */
2951 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2954 msg_format_wizard(CHEAT_MONSTER,
2955 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2956 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2959 if (snipe_type == SP_EXPLODE)
2961 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
2963 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
2964 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
2969 if (snipe_type == SP_HOLYNESS)
2971 cave[ny][nx].info |= (CAVE_GLOW);
2976 /* Hit the monster, check for death */
2977 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2986 if (object_is_fixed_artifact(q_ptr) &&
2987 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
2989 GAME_TEXT m_name[MAX_NLEN];
2991 monster_desc(m_name, m_ptr, 0);
2994 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
2997 message_pain(c_mon_ptr->m_idx, tdam);
2999 /* Anger the monster */
3000 if (tdam > 0) anger_monster(m_ptr);
3002 if (fear && m_ptr->ml)
3004 GAME_TEXT m_name[MAX_NLEN];
3006 monster_desc(m_name, m_ptr, 0);
3007 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3010 set_target(m_ptr, p_ptr->y, p_ptr->x);
3013 if (snipe_type == SP_RUSH)
3015 int n = randint1(5) + 3;
3016 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3018 for ( ; cur_dis <= tdis; )
3025 /* Calculate the new location (see "project()") */
3026 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3028 /* Stopped by wilderness boundary */
3029 if (!in_bounds2(ny, nx)) break;
3031 /* Stopped by walls/doors */
3032 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3034 /* Stopped by monsters */
3035 if (!cave_empty_bold(ny, nx)) break;
3037 cave[ny][nx].m_idx = m_idx;
3038 cave[oy][ox].m_idx = 0;
3043 update_monster(c_mon_ptr->m_idx, TRUE);
3049 Term_xtra(TERM_XTRA_DELAY, msec);
3061 if (snipe_type == SP_PIERCE)
3063 if(p_ptr->concent < 1) break;
3073 /* Chance of breakage (during attacks) */
3074 j = (hit_body ? breakage_chance(q_ptr) : 0);
3078 MONSTER_IDX m_idx = cave[y][x].m_idx;
3079 monster_type *m_ptr = &m_list[m_idx];
3080 OBJECT_IDX o_idx = o_pop();
3084 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3085 if (object_is_fixed_artifact(q_ptr))
3087 a_info[j_ptr->name1].cur_num = 0;
3092 o_ptr = &o_list[o_idx];
3093 object_copy(o_ptr, q_ptr);
3096 o_ptr->marked &= OM_TOUCHED;
3098 /* Forget location */
3099 o_ptr->iy = o_ptr->ix = 0;
3101 /* Memorize monster */
3102 o_ptr->held_m_idx = m_idx;
3105 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3108 m_ptr->hold_o_idx = o_idx;
3110 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3112 /* Drop (or break) near that location */
3113 (void)drop_near(q_ptr, j, y, x);
3117 /* Drop (or break) near that location */
3118 (void)drop_near(q_ptr, j, prev_y, prev_x);
3121 /* Sniper - Repeat shooting when double shots */
3124 /* Sniper - Loose his/her concentration after any shot */
3125 if (p_ptr->concent) reset_concentration(FALSE);
3129 * @brief 射撃処理のメインルーチン
3132 void do_cmd_fire(void)
3135 object_type *j_ptr, *ammo_ptr;
3138 if(p_ptr->wild_mode) return;
3140 is_fired = FALSE; /* not fired yet */
3142 /* Get the "bow" (if any) */
3143 j_ptr = &inventory[INVEN_BOW];
3145 /* Require a launcher */
3148 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3153 if (j_ptr->sval == SV_CRIMSON)
3155 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3160 if (j_ptr->sval == SV_HARP)
3162 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3168 if (p_ptr->special_defense & KATA_MUSOU)
3170 set_action(ACTION_NONE);
3173 /* Require proper missile */
3174 item_tester_tval = p_ptr->tval_ammo;
3176 q = _("どれを撃ちますか? ", "Fire which item? ");
3177 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3180 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3188 do_cmd_fire_aux(item, j_ptr);
3190 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3192 /* Sniper actions after some shootings */
3193 if (snipe_type == SP_AWAY)
3195 teleport_player(10 + (p_ptr->concent * 2), 0L);
3197 if (snipe_type == SP_FINAL)
3199 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3200 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3201 (void)set_stun(p_ptr->stun + randint1(25));
3207 * @brief 投射処理メインルーチン /
3208 * Throw an object from the pack or floor.
3210 * @param boomerang ブーメラン処理ならばTRUE
3211 * @param shuriken 忍者の手裏剣処理ならばTRUE
3212 * @return ターンを消費した場合TRUEを返す
3215 * Note: "unseen" monsters are very hard to hit.
3217 * Should throwing a weapon do full damage? Should it allow the magic
3218 * to hit bonus of the weapon to have an effect? Should it ever cause
3219 * the item to be destroyed? Should it do any damage at all?
3222 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3227 POSITION y, x, ty, tx, prev_y, prev_x;
3228 POSITION ny[19], nx[19];
3229 int chance, tdam, tdis;
3230 int mul, div, dd, ds;
3231 int cur_dis, visible;
3238 bool hit_body = FALSE;
3239 bool hit_wall = FALSE;
3240 bool equiped_item = FALSE;
3241 bool return_when_thrown = FALSE;
3243 GAME_TEXT o_name[MAX_NLEN];
3245 int msec = delay_factor * delay_factor * delay_factor;
3247 BIT_FLAGS flgs[TR_FLAG_SIZE];
3249 bool come_back = FALSE;
3250 bool do_drop = TRUE;
3252 if (p_ptr->wild_mode) return FALSE;
3254 if (p_ptr->special_defense & KATA_MUSOU)
3256 set_action(ACTION_NONE);
3262 o_ptr = &inventory[item];
3266 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3268 item_tester_hook = item_tester_hook_boomerang;
3269 q = _("どの武器を投げますか? ", "Throw which item? ");
3270 s = _("投げる武器がない。", "You have nothing to throw.");
3271 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
3278 else if (buki_motteruka(INVEN_LARM))
3281 o_ptr = &inventory[item];
3286 o_ptr = &inventory[item];
3291 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3292 s = _("投げるアイテムがない。", "You have nothing to throw.");
3293 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
3301 /* Item is cursed */
3302 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3304 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3309 if (p_ptr->inside_arena && !boomerang)
3311 if (o_ptr->tval != TV_SPIKE)
3313 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3322 /* Obtain a local object */
3323 object_copy(q_ptr, o_ptr);
3325 /* Extract the thrown object's flags. */
3326 object_flags(q_ptr, flgs);
3327 torch_flags(q_ptr, flgs);
3329 /* Distribute the charges of rods/wands between the stacks */
3330 distribute_charges(o_ptr, q_ptr, 1);
3335 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3337 if (p_ptr->mighty_throw) mult += 3;
3339 /* Extract a "distance multiplier" */
3340 /* Changed for 'launcher' mutation */
3341 mul = 10 + 2 * (mult - 1);
3343 /* Enforce a minimum "weight" of one pound */
3344 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3345 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3347 /* Hack -- Distance -- Reward strength, penalize weight */
3348 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3350 /* Max distance of 10-18 */
3351 if (tdis > mul) tdis = mul;
3355 ty = randint0(101) - 50 + p_ptr->y;
3356 tx = randint0(101) - 50 + p_ptr->x;
3360 project_length = tdis + 1;
3362 /* Get a direction (or cancel) */
3363 if (!get_aim_dir(&dir)) return FALSE;
3365 /* Predict the "target" location */
3366 tx = p_ptr->x + 99 * ddx[dir];
3367 ty = p_ptr->y + 99 * ddy[dir];
3369 /* Check for "target request" */
3370 if ((dir == 5) && target_okay())
3376 project_length = 0; /* reset to default */
3379 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3380 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3381 return_when_thrown = TRUE;
3383 /* Reduce and describe inventory */
3386 inven_item_increase(item, -1);
3387 if (!return_when_thrown)
3388 inven_item_describe(item);
3389 inven_item_optimize(item);
3392 /* Reduce and describe floor item */
3395 floor_item_increase(0 - item, -1);
3396 floor_item_optimize(0 - item);
3398 if (item >= INVEN_RARM)
3400 equiped_item = TRUE;
3401 p_ptr->redraw |= (PR_EQUIPPY);
3404 p_ptr->energy_use = 100;
3406 /* Rogue and Ninja gets bonus */
3407 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3408 p_ptr->energy_use -= p_ptr->lev;
3410 /* Start at the player */
3416 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3417 else shuriken = FALSE;
3419 /* Chance of hitting */
3420 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3421 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3422 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3424 if (shuriken) chance *= 2;
3426 /* Save the old location */
3430 /* Travel until stopped */
3431 for (cur_dis = 0; cur_dis <= tdis; )
3433 /* Hack -- Stop at the target */
3434 if ((y == ty) && (x == tx)) break;
3436 /* Calculate the new location (see "project()") */
3439 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3441 /* Stopped by walls/doors */
3442 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3445 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3448 /* The player can see the (on screen) missile */
3449 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3451 SYMBOL_CODE c = object_char(q_ptr);
3452 TERM_COLOR a = object_attr(q_ptr);
3454 /* Draw, Hilite, Fresh, Pause, Erase */
3455 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3456 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3458 Term_xtra(TERM_XTRA_DELAY, msec);
3459 lite_spot(ny[cur_dis], nx[cur_dis]);
3463 /* The player cannot see the missile */
3466 /* Pause anyway, for consistancy */
3467 Term_xtra(TERM_XTRA_DELAY, msec);
3470 /* Save the old location */
3474 /* Save the new location */
3478 /* Advance the distance */
3481 /* Monster here, Try to hit it */
3482 if (cave[y][x].m_idx)
3484 cave_type *c_ptr = &cave[y][x];
3485 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3487 /* Check the visibility */
3488 visible = m_ptr->ml;
3490 /* Note the collision */
3493 /* Did we hit it (penalize range) */
3494 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3498 /* Handle unseen monster */
3501 /* Invisible monster */
3502 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3505 /* Handle visible monster */
3508 GAME_TEXT m_name[MAX_NLEN];
3509 monster_desc(m_name, m_ptr, 0);
3510 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3514 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3515 health_track(c_ptr->m_idx);
3519 /* Hack -- Base damage from thrown object */
3522 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3523 tdam = damroll(dd, ds);
3524 /* Apply special damage */
3525 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3526 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3527 if (q_ptr->to_d > 0)
3528 tdam += q_ptr->to_d;
3530 tdam += -q_ptr->to_d;
3534 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3535 tdam += p_ptr->to_d_m;
3537 else if (have_flag(flgs, TR_THROW))
3540 tdam += p_ptr->to_d_m;
3548 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3551 /* No negative damage */
3552 if (tdam < 0) tdam = 0;
3554 /* Modify the damage */
3555 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3557 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3558 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3560 /* Hit the monster, check for death */
3561 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
3569 message_pain(c_ptr->m_idx, tdam);
3571 /* Anger the monster */
3572 if ((tdam > 0) && !object_is_potion(q_ptr))
3573 anger_monster(m_ptr);
3575 if (fear && m_ptr->ml)
3578 GAME_TEXT m_name[MAX_NLEN];
3579 monster_desc(m_name, m_ptr, 0);
3580 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3590 /* decrease toach's fuel */
3591 if (hit_body) torch_lost_fuel(q_ptr);
3593 /* Chance of breakage (during attacks) */
3594 j = (hit_body ? breakage_chance(q_ptr) : 0);
3596 /* Figurines transform */
3597 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3601 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3602 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3603 else if (object_is_cursed(q_ptr))
3604 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3609 /* Potions smash open */
3610 if (object_is_potion(q_ptr))
3612 if (hit_body || hit_wall || (randint1(100) < j))
3614 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3616 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3618 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3620 /* ToDo (Robert): fix the invulnerability */
3621 if (cave[y][x].m_idx &&
3622 is_friendly(&m_list[cave[y][x].m_idx]) &&
3623 !MON_INVULNER(m_ptr))
3625 GAME_TEXT m_name[MAX_NLEN];
3626 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3627 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3628 set_hostile(&m_list[cave[y][x].m_idx]);
3639 if (return_when_thrown)
3641 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3642 char o2_name[MAX_NLEN];
3643 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3646 if (boomerang) back_chance += 4+randint1(5);
3647 if (super_boomerang) back_chance += 100;
3648 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3650 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3652 for (i = cur_dis - 1; i > 0; i--)
3654 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3656 char c = object_char(q_ptr);
3657 byte a = object_attr(q_ptr);
3659 /* Draw, Hilite, Fresh, Pause, Erase */
3660 print_rel(c, a, ny[i], nx[i]);
3661 move_cursor_relative(ny[i], nx[i]);
3663 Term_xtra(TERM_XTRA_DELAY, msec);
3664 lite_spot(ny[i], nx[i]);
3669 /* Pause anyway, for consistancy */
3670 Term_xtra(TERM_XTRA_DELAY, msec);
3673 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3675 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3682 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3686 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3694 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3700 if (item == INVEN_RARM || item == INVEN_LARM)
3702 /* Access the wield slot */
3703 o_ptr = &inventory[item];
3705 /* Wear the new stuff */
3706 object_copy(o_ptr, q_ptr);
3708 p_ptr->total_weight += q_ptr->weight;
3710 /* Increment the equip counter by hand */
3713 /* Recalculate torch */
3714 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
3715 p_ptr->window |= (PW_EQUIP);
3723 else if (equiped_item)
3731 if (cave_have_flag_bold(y, x, FF_PROJECT))
3733 (void)drop_near(q_ptr, j, y, x);
3737 (void)drop_near(q_ptr, j, prev_y, prev_x);
3747 * Hack: travel command
3749 #define TRAVEL_UNABLE 9999
3751 static int flow_head = 0;
3752 static int flow_tail = 0;
3753 static POSITION temp2_x[MAX_SHORT];
3754 static POSITION temp2_y[MAX_SHORT];
3757 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3760 void forget_travel_flow(void)
3763 /* Check the entire dungeon / Forget the old data */
3764 for (y = 0; y < cur_hgt; y++)
3766 for (x = 0; x < cur_wid; x++)
3769 travel.cost[y][x] = MAX_SHORT;
3772 travel.y = travel.x = 0;
3776 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
3781 static int travel_flow_cost(POSITION y, POSITION x)
3783 feature_type *f_ptr = &f_info[cave[y][x].feat];
3786 /* Avoid obstacles (ex. trees) */
3787 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
3790 if (have_flag(f_ptr->flags, FF_WATER))
3792 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
3796 if (have_flag(f_ptr->flags, FF_LAVA))
3799 if (!p_ptr->resist_fire) lava *= 2;
3800 if (!p_ptr->levitation) lava *= 2;
3801 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
3806 /* Detected traps and doors */
3807 if (cave[y][x].info & (CAVE_MARK))
3809 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
3810 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
3817 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
3821 * @param wall プレイヤーが壁の中にいるならばTRUE
3824 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
3826 cave_type *c_ptr = &cave[y][x];
3827 feature_type *f_ptr = &f_info[c_ptr->feat];
3828 int old_head = flow_head;
3830 int base_cost = (n % TRAVEL_UNABLE);
3831 int from_wall = (n / TRAVEL_UNABLE);
3834 /* Ignore out of bounds */
3835 if (!in_bounds(y, x)) return;
3837 /* Ignore unknown grid except in wilderness */
3838 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
3840 /* Ignore "walls" and "rubble" (include "secret doors") */
3841 if (have_flag(f_ptr->flags, FF_WALL) ||
3842 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3843 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
3844 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
3846 if (!wall || !from_wall) return;
3847 add_cost += TRAVEL_UNABLE;
3851 add_cost = travel_flow_cost(y, x);
3854 cost = base_cost + add_cost;
3856 /* Ignore lower cost entries */
3857 if (travel.cost[y][x] <= cost) return;
3859 /* Save the flow cost */
3860 travel.cost[y][x] = cost;
3862 /* Enqueue that entry */
3863 temp2_y[flow_head] = y;
3864 temp2_x[flow_head] = x;
3866 /* Advance the queue */
3867 if (++flow_head == MAX_SHORT) flow_head = 0;
3869 /* Hack -- notice overflow by forgetting new entry */
3870 if (flow_head == flow_tail) flow_head = old_head;
3876 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
3877 * @param ty 目標地点のY座標
3878 * @param tx 目標地点のX座標
3881 static void travel_flow(POSITION ty, POSITION tx)
3885 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
3887 /* Reset the "queue" */
3888 flow_head = flow_tail = 0;
3890 /* is player in the wall? */
3891 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
3893 /* Start at the target grid */
3894 travel_flow_aux(ty, tx, 0, wall);
3896 /* Now process the queue */
3897 while (flow_head != flow_tail)
3899 /* Extract the next entry */
3900 y = temp2_y[flow_tail];
3901 x = temp2_x[flow_tail];
3903 /* Forget that entry */
3904 if (++flow_tail == MAX_SHORT) flow_tail = 0;
3906 /* Ignore too far entries */
3907 //if (distance(ty, tx, y, x) > 100) continue;
3909 /* Add the "children" */
3910 for (d = 0; d < 8; d++)
3912 /* Add that child if "legal" */
3913 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
3917 /* Forget the flow info */
3918 flow_head = flow_tail = 0;
3922 * @brief トラベル処理のメインルーチン
3925 void do_cmd_travel(void)
3929 POSITION dx, dy, sx, sy;
3930 feature_type *f_ptr;
3932 if (travel.x != 0 && travel.y != 0 &&
3933 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3938 else if (!tgt_pt(&x, &y)) return;
3940 if ((x == p_ptr->x) && (y == p_ptr->y))
3942 msg_print(_("すでにそこにいます!", "You are already there!!"));
3946 f_ptr = &f_info[cave[y][x].feat];
3948 if ((cave[y][x].info & CAVE_MARK) &&
3949 (have_flag(f_ptr->flags, FF_WALL) ||
3950 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3951 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3953 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3957 forget_travel_flow();
3963 /* Travel till 255 steps */
3969 /* Decides first direction */
3970 dx = abs(p_ptr->x - x);
3971 dy = abs(p_ptr->y - y);
3972 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3973 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3975 for (i = 1; i <= 9; i++)
3977 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;