3 * @brief プレイヤーのコマンド処理2 / Movement commands (part 2)
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
16 #include "object-hook.h"
19 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
20 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
21 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
23 bool confirm_leave_level(bool down_stair)
25 quest_type *q_ptr = &quest[p_ptr->inside_quest];
27 /* Confirm leaving from once only quest */
28 if (confirm_quest && p_ptr->inside_quest &&
29 (q_ptr->type == QUEST_TYPE_RANDOM ||
30 (q_ptr->flags & QUEST_FLAG_ONCE &&
31 q_ptr->status != QUEST_STATUS_COMPLETED) ||
32 (q_ptr->flags & QUEST_FLAG_TOWER &&
33 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
34 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
36 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
37 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
47 * @brief 階段を使って階層を昇る処理 / Go up one level
50 void do_cmd_go_up(void)
55 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
56 feature_type *f_ptr = &f_info[c_ptr->feat];
60 if (p_ptr->special_defense & KATA_MUSOU)
62 set_action(ACTION_NONE);
66 if (!have_flag(f_ptr->flags, FF_LESS))
68 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
73 if (have_flag(f_ptr->flags, FF_QUEST))
75 /* Cancel the command */
76 if (!confirm_leave_level(FALSE)) return;
80 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
81 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
83 msg_print(_("上の階に登った。", "You enter the up staircase."));
87 p_ptr->inside_quest = c_ptr->special;
89 /* Activate the quest */
90 if (!quest[p_ptr->inside_quest].status)
92 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
94 init_flags = INIT_ASSIGN;
95 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
97 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
100 /* Leaving a quest */
101 if (!p_ptr->inside_quest)
107 p_ptr->leaving = TRUE;
112 /* Hack -- take a turn */
113 p_ptr->energy_use = 100;
115 /* End the command */
125 go_up = confirm_leave_level(FALSE);
128 /* Cancel the command */
131 /* Hack -- take a turn */
132 p_ptr->energy_use = 100;
134 if (autosave_l) do_cmd_save_game(TRUE);
136 /* For a random quest */
137 if (p_ptr->inside_quest &&
138 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
142 p_ptr->inside_quest = 0;
145 /* For a fixed quest */
146 if (p_ptr->inside_quest &&
147 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
151 p_ptr->inside_quest = c_ptr->special;
156 /* For normal dungeon and random quest */
160 if (have_flag(f_ptr->flags, FF_SHAFT))
162 /* Create a way back */
163 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
169 /* Create a way back */
170 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
175 /* Get out from current dungeon */
176 if (dun_level - up_num < d_info[dungeon_type].mindepth)
179 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
182 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
183 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
184 else if (up_num == dun_level)
185 msg_print(_("地上に戻った。", "You go back to the surface."));
187 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
190 p_ptr->leaving = TRUE;
195 * @brief 階段を使って階層を降りる処理 / Go down one level
198 void do_cmd_go_down(void)
201 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
202 feature_type *f_ptr = &f_info[c_ptr->feat];
204 bool fall_trap = FALSE;
207 if (p_ptr->special_defense & KATA_MUSOU)
209 set_action(ACTION_NONE);
213 if (!have_flag(f_ptr->flags, FF_MORE))
215 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
219 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
222 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
227 /* Quest down stairs */
228 else if (have_flag(f_ptr->flags, FF_QUEST))
230 /* Confirm Leaving */
231 if(!confirm_leave_level(TRUE)) return;
233 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
234 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
236 msg_print(_("下の階に降りた。", "You enter the down staircase."));
241 p_ptr->inside_quest = c_ptr->special;
243 /* Activate the quest */
244 if (!quest[p_ptr->inside_quest].status)
246 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
248 init_flags = INIT_ASSIGN;
249 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
251 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
254 /* Leaving a quest */
255 if (!p_ptr->inside_quest)
261 p_ptr->leaving = TRUE;
267 /* Hack -- take a turn */
268 p_ptr->energy_use = 100;
273 int target_dungeon = 0;
277 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
279 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
281 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
284 if (!max_dlv[target_dungeon])
286 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
287 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
288 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
291 /* Save old player position */
292 p_ptr->oldpx = p_ptr->x;
293 p_ptr->oldpy = p_ptr->y;
294 dungeon_type = (byte)target_dungeon;
297 * Clear all saved floors
298 * and create a first saved floor
300 prepare_change_floor_mode(CFM_FIRST_FLOOR);
303 /* Hack -- take a turn */
304 p_ptr->energy_use = 100;
306 if (autosave_l) do_cmd_save_game(TRUE);
309 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
314 /* Enter the dungeon just now */
315 p_ptr->enter_dungeon = TRUE;
316 down_num = d_info[dungeon_type].mindepth;
321 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
322 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
327 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
334 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
338 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
339 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
341 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
347 p_ptr->leaving = TRUE;
351 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
355 if (have_flag(f_ptr->flags, FF_SHAFT))
357 /* Create a way back */
358 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
362 /* Create a way back */
363 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
371 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
374 void do_cmd_search(void)
376 /* Allow repeated command */
379 /* Set repeat count */
380 command_rep = command_arg - 1;
381 p_ptr->redraw |= (PR_STATE);
386 p_ptr->energy_use = 100;
394 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
395 * @param y 走査対象にしたいマスのY座標
396 * @param x 走査対象にしたいマスのX座標
397 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
398 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
400 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
402 cave_type *c_ptr = &cave[y][x];
403 OBJECT_IDX this_o_idx, next_o_idx = 0;
405 /* Scan all objects in the grid */
406 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
410 o_ptr = &o_list[this_o_idx];
411 next_o_idx = o_ptr->next_o_idx;
413 /* Skip unknown chests XXX XXX */
414 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
416 /* Check for non empty chest */
417 if ((o_ptr->tval == TV_CHEST) &&
418 (((!trapped) && (o_ptr->pval)) || /* non empty */
419 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
428 * @brief 箱を開けるコマンドのメインルーチン /
429 * Attempt to open the given chest at the given location
430 * @param y 箱の存在するマスのY座標
431 * @param x 箱の存在するマスのX座標
432 * @param o_idx 箱のオブジェクトID
433 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
435 * Assume there is no monster blocking the destination
437 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
442 object_type *o_ptr = &o_list[o_idx];
444 p_ptr->energy_use = 100;
446 /* Attempt to unlock it */
449 /* Assume locked, and thus not open */
452 /* Get the "disarm" factor */
453 i = p_ptr->skill_dis;
455 /* Penalize some conditions */
456 if (p_ptr->blind || no_lite()) i = i / 10;
457 if (p_ptr->confused || p_ptr->image) i = i / 10;
459 /* Extract the difficulty */
462 /* Always have a small chance of success */
465 /* Success -- May still have traps */
466 if (randint0(100) < j)
468 msg_print(_("鍵をはずした。", "You have picked the lock."));
473 /* Failure -- Keep trying */
476 /* We may continue repeating */
478 if (flush_failure) flush();
479 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
484 /* Allowed to open */
487 /* Apply chest traps, if any */
488 chest_trap(y, x, o_idx);
490 /* Let the Chest drop items */
491 chest_death(FALSE, y, x, o_idx);
497 * @brief 地形は開くものであって、かつ開かれているかを返す /
498 * Attempt to open the given chest at the given location
500 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
502 static bool is_open(IDX feat)
504 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
509 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
510 * Attempt to open the given chest at the given location
511 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
512 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
513 * @param test 地形条件を判定するための関数ポインタ
514 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
516 * @details Return the number of features around (or under) the character.
517 * Usually look for doors and floor traps.
519 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
521 int d, count, xx, yy;
523 /* Count how many matches */
526 /* Check around (and under) the character */
527 for (d = 0; d < 9; d++)
532 /* if not searching under player continue */
533 if ((d == 8) && !under) continue;
535 /* Extract adjacent (legal) location */
536 yy = p_ptr->y + ddy_ddd[d];
537 xx = p_ptr->x + ddx_ddd[d];
540 c_ptr = &cave[yy][xx];
542 /* Must have knowledge */
543 if (!(c_ptr->info & (CAVE_MARK))) continue;
545 /* Feature code (applying "mimic" field) */
546 feat = get_feat_mimic(c_ptr);
548 /* Not looking for this feature */
549 if (!((*test)(feat))) continue;
554 /* Remember the location. Only useful if only one match */
565 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
566 * Return the number of chests around (or under) the character.
567 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
568 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
569 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
572 * If requested, count only trapped chests.
574 static int count_chests(POSITION *y, POSITION *x, bool trapped)
581 /* Count how many matches */
584 /* Check around (and under) the character */
585 for (d = 0; d < 9; d++)
587 /* Extract adjacent (legal) location */
588 POSITION yy = p_ptr->y + ddy_ddd[d];
589 POSITION xx = p_ptr->x + ddx_ddd[d];
591 /* No (visible) chest is there */
592 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
594 /* Grab the object */
595 o_ptr = &o_list[o_idx];
598 if (o_ptr->pval == 0) continue;
600 /* No (known) traps here */
601 if (trapped && (!object_is_known(o_ptr) ||
602 !chest_traps[o_ptr->pval])) continue;
607 /* Remember the location. Only useful if only one match */
618 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
619 * Convert an adjacent location to a direction.
620 * @param y 方角を確認したY座標
621 * @param x 方角を確認したX座標
624 static DIRECTION coords_to_dir(POSITION y, POSITION x)
626 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
633 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
635 return d[dx + 1][dy + 1];
639 * @brief 「開ける」動作コマンドのサブルーチン /
640 * Perform the basic "open" command on doors
641 * @param y 対象を行うマスのY座標
642 * @param x 対象を行うマスのX座標
643 * @return 実際に処理が行われた場合TRUEを返す。
645 * Assume destination is a closed/locked/jammed door
646 * Assume there is no monster blocking the destination
647 * Returns TRUE if repeated commands may continue
649 static bool do_cmd_open_aux(POSITION y, POSITION x)
653 /* Get requested grid */
654 cave_type *c_ptr = &cave[y][x];
655 feature_type *f_ptr = &f_info[c_ptr->feat];
658 p_ptr->energy_use = 100;
660 /* Seeing true feature code (ignore mimic) */
663 if (!have_flag(f_ptr->flags, FF_OPEN))
666 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
670 else if (f_ptr->power)
673 i = p_ptr->skill_dis;
675 /* Penalize some conditions */
676 if (p_ptr->blind || no_lite()) i = i / 10;
677 if (p_ptr->confused || p_ptr->image) i = i / 10;
679 /* Extract the lock power */
682 /* Extract the difficulty */
685 /* Always have a small chance of success */
689 if (randint0(100) < j)
691 msg_print(_("鍵をはずした。", "You have picked the lock."));
694 cave_alter_feat(y, x, FF_OPEN);
696 sound(SOUND_OPENDOOR);
706 if (flush_failure) flush();
708 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
710 /* We may keep trying */
719 cave_alter_feat(y, x, FF_OPEN);
721 sound(SOUND_OPENDOOR);
727 * @brief 「開ける」コマンドのメインルーチン /
728 * Open a closed/locked/jammed door or a closed/locked chest.
731 * Unlocking a locked door/chest is worth one experience point.
733 void do_cmd_open(void)
741 if (p_ptr->special_defense & KATA_MUSOU)
743 set_action(ACTION_NONE);
746 /* Option: Pick a direction */
749 int num_doors, num_chests;
751 /* Count closed doors (locked or jammed) */
752 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
754 /* Count chests (locked) */
755 num_chests = count_chests(&y, &x, FALSE);
757 /* See if only one target */
758 if (num_doors || num_chests)
760 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
762 if (!too_many) command_dir = coords_to_dir(y, x);
766 /* Allow repeated command */
769 /* Set repeat count */
770 command_rep = command_arg - 1;
771 p_ptr->redraw |= (PR_STATE);
777 /* Get a "repeated" direction */
778 if (get_rep_dir(&dir, TRUE))
783 /* Get requested location */
784 y = p_ptr->y + ddy[dir];
785 x = p_ptr->x + ddx[dir];
787 /* Get requested grid */
790 /* Feature code (applying "mimic" field) */
791 feat = get_feat_mimic(c_ptr);
793 /* Check for chest */
794 o_idx = chest_check(y, x, FALSE);
797 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
799 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
802 /* Monster in the way */
803 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
805 p_ptr->energy_use = 100;
806 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
814 more = do_cmd_open_chest(y, x, o_idx);
821 more = do_cmd_open_aux(y, x);
825 /* Cancel repeat unless we may continue */
826 if (!more) disturb(FALSE, FALSE);
832 * @brief 「閉じる」動作コマンドのサブルーチン /
833 * Perform the basic "close" command
834 * @param y 対象を行うマスのY座標
835 * @param x 対象を行うマスのX座標
836 * @return 実際に処理が行われた場合TRUEを返す。
838 * Assume destination is an open/broken door
839 * Assume there is no monster blocking the destination
840 * Returns TRUE if repeated commands may continue
842 static bool do_cmd_close_aux(POSITION y, POSITION x)
844 cave_type *c_ptr = &cave[y][x];
845 FEAT_IDX old_feat = c_ptr->feat;
848 p_ptr->energy_use = 100;
850 /* Seeing true feature code (ignore mimic) */
853 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
855 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
857 /* Hack -- object in the way */
858 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
859 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
861 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
866 cave_alter_feat(y, x, FF_CLOSE);
869 if (old_feat == c_ptr->feat)
871 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
875 sound(SOUND_SHUTDOOR);
884 * @brief 「閉じる」コマンドのメインルーチン /
885 * Close an open door.
888 * Unlocking a locked door/chest is worth one experience point.
890 void do_cmd_close(void)
897 if (p_ptr->special_defense & KATA_MUSOU)
899 set_action(ACTION_NONE);
902 /* Option: Pick a direction */
905 /* Count open doors */
906 if (count_dt(&y, &x, is_open, FALSE) == 1)
908 command_dir = coords_to_dir(y, x);
912 /* Allow repeated command */
915 /* Set repeat count */
916 command_rep = command_arg - 1;
917 p_ptr->redraw |= (PR_STATE);
923 /* Get a "repeated" direction */
924 if (get_rep_dir(&dir, FALSE))
929 y = p_ptr->y + ddy[dir];
930 x = p_ptr->x + ddx[dir];
933 /* Feature code (applying "mimic" field) */
934 feat = get_feat_mimic(c_ptr);
936 /* Require open/broken door */
937 if (!have_flag(f_info[feat].flags, FF_CLOSE))
939 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
942 /* Monster in the way */
943 else if (c_ptr->m_idx)
945 p_ptr->energy_use = 100;
947 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
957 more = do_cmd_close_aux(y, x);
961 /* Cancel repeat unless we may continue */
962 if (!more) disturb(FALSE, FALSE);
967 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
968 * Determine if a given grid may be "tunneled"
969 * @param y 対象を行うマスのY座標
970 * @param x 対象を行うマスのX座標
973 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
975 cave_type *c_ptr = &cave[y][x];
977 /* Must have knowledge */
978 if (!(c_ptr->info & CAVE_MARK))
980 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
985 /* Must be a wall/door/etc */
986 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
988 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
998 * @brief 「掘る」動作コマンドのサブルーチン /
999 * Perform the basic "tunnel" command
1000 * @param y 対象を行うマスのY座標
1001 * @param x 対象を行うマスのX座標
1002 * @return 実際に処理が行われた場合TRUEを返す。
1004 * Assumes that no monster is blocking the destination
1005 * Do not use twall anymore
1006 * Returns TRUE if repeated commands may continue
1008 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1011 feature_type *f_ptr, *mimic_f_ptr;
1016 /* Verify legality */
1017 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1019 p_ptr->energy_use = 100;
1022 c_ptr = &cave[y][x];
1023 f_ptr = &f_info[c_ptr->feat];
1024 power = f_ptr->power;
1026 /* Feature code (applying "mimic" field) */
1027 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1029 name = f_name + mimic_f_ptr->name;
1033 if (have_flag(f_ptr->flags, FF_PERMANENT))
1036 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1038 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1041 /* Map border (mimiccing Permanent wall) */
1044 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1049 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1052 if (p_ptr->skill_dig > randint0(20 * power))
1054 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1056 /* Remove the feature */
1057 cave_alter_feat(y, x, FF_TUNNEL);
1059 /* Update some things */
1060 p_ptr->update |= (PU_FLOW);
1064 /* Message, keep digging */
1065 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1073 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1076 if (p_ptr->skill_dig > power + randint0(40 * power))
1078 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1081 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1082 p_ptr->update |= (PU_FLOW);
1085 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1087 /* Remove the feature */
1088 cave_alter_feat(y, x, FF_TUNNEL);
1090 chg_virtue(V_DILIGENCE, 1);
1091 chg_virtue(V_NATURE, -1);
1099 /* We may continue chopping */
1100 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1101 /* Occasional Search XXX XXX */
1102 if (randint0(100) < 25) search();
1106 /* We may continue tunelling */
1107 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1114 if (is_hidden_door(c_ptr))
1116 /* Occasional Search XXX XXX */
1117 if (randint0(100) < 25) search();
1124 * @brief 「掘る」動作コマンドのメインルーチン /
1125 * Tunnels through "walls" (including rubble and closed doors)
1129 * Note that you must tunnel in order to hit invisible monsters
1130 * in walls, though moving into walls still takes a turn anyway.
1132 * Digging is very difficult without a "digger" weapon, but can be
1133 * accomplished by strong players using heavy weapons.
1136 void do_cmd_tunnel(void)
1146 if (p_ptr->special_defense & KATA_MUSOU)
1148 set_action(ACTION_NONE);
1151 /* Allow repeated command */
1154 /* Set repeat count */
1155 command_rep = command_arg - 1;
1156 p_ptr->redraw |= (PR_STATE);
1158 /* Cancel the arg */
1162 /* Get a direction to tunnel, or Abort */
1163 if (get_rep_dir(&dir,FALSE))
1166 y = p_ptr->y + ddy[dir];
1167 x = p_ptr->x + ddx[dir];
1170 c_ptr = &cave[y][x];
1172 /* Feature code (applying "mimic" field) */
1173 feat = get_feat_mimic(c_ptr);
1175 /* No tunnelling through doors */
1176 if (have_flag(f_info[feat].flags, FF_DOOR))
1178 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1181 /* No tunnelling through most features */
1182 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1184 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1187 /* A monster is in the way */
1188 else if (c_ptr->m_idx)
1190 p_ptr->energy_use = 100;
1192 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1201 /* Tunnel through walls */
1202 more = do_cmd_tunnel_aux(y, x);
1206 /* Cancel repetition unless we can continue */
1207 if (!more) disturb(FALSE, FALSE);
1211 * @brief 移動処理による簡易な「開く」処理 /
1213 * @return 開く処理が実際に試みられた場合TRUEを返す
1216 * If there is a jammed/closed/locked door at the given location,
1217 * then attempt to unlock/open it. Return TRUE if an attempt was
1218 * made (successful or not), otherwise return FALSE.
1220 * The code here should be nearly identical to that in
1221 * do_cmd_open_test() and do_cmd_open_aux().
1224 bool easy_open_door(POSITION y, POSITION x)
1228 cave_type *c_ptr = &cave[y][x];
1229 feature_type *f_ptr = &f_info[c_ptr->feat];
1231 /* Must be a closed door */
1232 if (!is_closed_door(c_ptr->feat))
1238 if (!have_flag(f_ptr->flags, FF_OPEN))
1241 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1246 else if (f_ptr->power)
1249 i = p_ptr->skill_dis;
1251 /* Penalize some conditions */
1252 if (p_ptr->blind || no_lite()) i = i / 10;
1253 if (p_ptr->confused || p_ptr->image) i = i / 10;
1255 /* Extract the lock power */
1258 /* Extract the difficulty */
1261 /* Always have a small chance of success */
1265 if (randint0(100) < j)
1267 msg_print(_("鍵をはずした。", "You have picked the lock."));
1270 cave_alter_feat(y, x, FF_OPEN);
1272 sound(SOUND_OPENDOOR);
1282 if (flush_failure) flush();
1284 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1293 cave_alter_feat(y, x, FF_OPEN);
1295 sound(SOUND_OPENDOOR);
1301 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1302 * Perform the basic "disarm" command
1303 * @param y 解除を行うマスのY座標
1304 * @param x 解除を行うマスのX座標
1305 * @param o_idx 箱のオブジェクトID
1306 * @return ターンを消費する処理が行われた場合TRUEを返す
1309 * Assume destination is a visible trap
1310 * Assume there is no monster blocking the destination
1311 * Returns TRUE if repeated commands may continue
1314 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1318 object_type *o_ptr = &o_list[o_idx];
1320 p_ptr->energy_use = 100;
1322 /* Get the "disarm" factor */
1323 i = p_ptr->skill_dis;
1325 /* Penalize some conditions */
1326 if (p_ptr->blind || no_lite()) i = i / 10;
1327 if (p_ptr->confused || p_ptr->image) i = i / 10;
1329 /* Extract the difficulty */
1330 j = i - o_ptr->pval;
1332 /* Always have a small chance of success */
1335 /* Must find the trap first. */
1336 if (!object_is_known(o_ptr))
1338 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1342 /* Already disarmed/unlocked */
1343 else if (o_ptr->pval <= 0)
1345 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1348 /* No traps to find. */
1349 else if (!chest_traps[o_ptr->pval])
1351 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1354 /* Success (get a lot of experience) */
1355 else if (randint0(100) < j)
1357 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1358 gain_exp(o_ptr->pval);
1359 o_ptr->pval = (0 - o_ptr->pval);
1362 /* Failure -- Keep trying */
1363 else if ((i > 5) && (randint1(i) > 5))
1365 /* We may keep trying */
1367 if (flush_failure) flush();
1368 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1371 /* Failure -- Set off the trap */
1374 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1376 chest_trap(y, x, o_idx);
1383 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1384 * Perform the basic "disarm" command
1385 * @param y 解除を行うマスのY座標
1386 * @param x 解除を行うマスのX座標
1387 * @param dir プレイヤーからみた方向ID
1388 * @return ターンを消費する処理が行われた場合TRUEを返す
1391 * Assume destination is a visible trap
1392 * Assume there is no monster blocking the destination
1393 * Returns TRUE if repeated commands may continue
1397 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1399 cave_type *c_ptr = &cave[y][x];
1402 feature_type *f_ptr = &f_info[c_ptr->feat];
1404 /* Access trap name */
1405 cptr name = (f_name + f_ptr->name);
1407 /* Extract trap "power" */
1408 int power = f_ptr->power;
1411 /* Get the "disarm" factor */
1412 int i = p_ptr->skill_dis;
1415 p_ptr->energy_use = 100;
1417 /* Penalize some conditions */
1418 if (p_ptr->blind || no_lite()) i = i / 10;
1419 if (p_ptr->confused || p_ptr->image) i = i / 10;
1421 /* Extract the difficulty */
1424 /* Always have a small chance of success */
1428 if (randint0(100) < j)
1430 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1435 /* Remove the trap */
1436 cave_alter_feat(y, x, FF_DISARM);
1438 /* Move the player onto the trap */
1439 move_player(dir, easy_disarm, FALSE);
1442 /* Failure -- Keep trying */
1443 else if ((i > 5) && (randint1(i) > 5))
1446 if (flush_failure) flush();
1448 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1450 /* We may keep trying */
1454 /* Failure -- Set off the trap */
1457 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1458 /* Move the player onto the trap */
1459 move_player(dir, easy_disarm, FALSE);
1466 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1467 * Disarms a trap, or chest
1470 void do_cmd_disarm(void)
1478 if (p_ptr->special_defense & KATA_MUSOU)
1480 set_action(ACTION_NONE);
1484 /* Option: Pick a direction */
1487 int num_traps, num_chests;
1489 /* Count visible traps */
1490 num_traps = count_dt(&y, &x, is_trap, TRUE);
1492 /* Count chests (trapped) */
1493 num_chests = count_chests(&y, &x, TRUE);
1495 /* See if only one target */
1496 if (num_traps || num_chests)
1498 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1499 if (!too_many) command_dir = coords_to_dir(y, x);
1504 /* Allow repeated command */
1507 /* Set repeat count */
1508 command_rep = command_arg - 1;
1509 p_ptr->redraw |= (PR_STATE);
1511 /* Cancel the arg */
1515 /* Get a direction (or abort) */
1516 if (get_rep_dir(&dir,TRUE))
1521 y = p_ptr->y + ddy[dir];
1522 x = p_ptr->x + ddx[dir];
1523 c_ptr = &cave[y][x];
1525 /* Feature code (applying "mimic" field) */
1526 feat = get_feat_mimic(c_ptr);
1528 /* Check for chests */
1529 o_idx = chest_check(y, x, TRUE);
1532 if (!is_trap(feat) && !o_idx)
1534 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1537 /* Monster in the way */
1538 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1540 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1549 /* Disarm the chest */
1550 more = do_cmd_disarm_chest(y, x, o_idx);
1556 /* Disarm the trap */
1557 more = do_cmd_disarm_aux(y, x, dir);
1561 /* Cancel repeat unless told not to */
1562 if (!more) disturb(FALSE, FALSE);
1567 * @brief 「打ち破る」動作コマンドのサブルーチン /
1568 * Perform the basic "bash" command
1569 * @param y 対象を行うマスのY座標
1570 * @param x 対象を行うマスのX座標
1571 * @param dir プレイヤーから見たターゲットの方角ID
1572 * @return 実際に処理が行われた場合TRUEを返す。
1575 * Assume destination is a closed/locked/jammed door
1576 * Assume there is no monster blocking the destination
1577 * Returns TRUE if repeated commands may continue
1580 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1583 cave_type *c_ptr = &cave[y][x];
1586 feature_type *f_ptr = &f_info[c_ptr->feat];
1588 /* Hack -- Bash power based on strength */
1589 /* (Ranges from 3 to 20 to 100 to 200) */
1590 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1592 /* Extract door power */
1593 int temp = f_ptr->power;
1597 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1599 p_ptr->energy_use = 100;
1601 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1603 /* Compare bash power to door power */
1604 temp = (bash - (temp * 10));
1606 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1608 /* Hack -- always have a chance */
1609 if (temp < 1) temp = 1;
1611 /* Hack -- attempt to bash down the door */
1612 if (randint0(100) < temp)
1614 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1616 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1618 /* Break down the door */
1619 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1621 cave_alter_feat(y, x, FF_BASH);
1627 cave_alter_feat(y, x, FF_OPEN);
1630 /* Hack -- Fall through the door */
1631 move_player(dir, FALSE, FALSE);
1634 /* Saving throw against stun */
1635 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1638 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1640 /* Allow repeated bashing */
1644 /* High dexterity yields coolness */
1647 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1649 /* Hack -- Lose balance ala paralysis */
1650 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1657 * @brief 「打ち破る」動作コマンドのメインルーチン /
1658 * Bash open a door, success based on character strength
1662 * For a closed door, pval is positive if locked; negative if stuck.
1664 * For an open door, pval is positive for a broken door.
1666 * A closed door can be opened - harder if locked. Any door might be
1667 * bashed open (and thereby broken). Bashing a door is (potentially)
1668 * faster! You move into the door way. To open a stuck door, it must
1669 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1671 * Creatures can also open or bash doors, see elsewhere.
1674 void do_cmd_bash(void)
1683 if (p_ptr->special_defense & KATA_MUSOU)
1685 set_action(ACTION_NONE);
1688 /* Allow repeated command */
1691 /* Set repeat count */
1692 command_rep = command_arg - 1;
1693 p_ptr->redraw |= (PR_STATE);
1695 /* Cancel the arg */
1699 /* Get a "repeated" direction */
1700 if (get_rep_dir(&dir,FALSE))
1705 y = p_ptr->y + ddy[dir];
1706 x = p_ptr->x + ddx[dir];
1709 c_ptr = &cave[y][x];
1711 /* Feature code (applying "mimic" field) */
1712 feat = get_feat_mimic(c_ptr);
1714 /* Nothing useful */
1715 if (!have_flag(f_info[feat].flags, FF_BASH))
1717 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1720 /* Monster in the way */
1721 else if (c_ptr->m_idx)
1723 p_ptr->energy_use = 100;
1725 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1731 /* Bash a closed door */
1735 more = do_cmd_bash_aux(y, x, dir);
1739 /* Unless valid action taken, cancel bash */
1740 if (!more) disturb(FALSE, FALSE);
1745 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1749 * Manipulate an adjacent grid in some way
1751 * Attack monsters, tunnel through walls, disarm traps, open doors.
1753 * Consider confusion
1755 * This command must always take a turn, to prevent free detection
1756 * of invisible monsters.
1759 void do_cmd_alter(void)
1766 if (p_ptr->special_defense & KATA_MUSOU)
1768 set_action(ACTION_NONE);
1771 /* Allow repeated command */
1774 /* Set repeat count */
1775 command_rep = command_arg - 1;
1776 p_ptr->redraw |= (PR_STATE);
1778 /* Cancel the arg */
1782 /* Get a direction */
1783 if (get_rep_dir(&dir,TRUE))
1786 feature_type *f_ptr;
1788 y = p_ptr->y + ddy[dir];
1789 x = p_ptr->x + ddx[dir];
1792 c_ptr = &cave[y][x];
1794 /* Feature code (applying "mimic" field) */
1795 feat = get_feat_mimic(c_ptr);
1796 f_ptr = &f_info[feat];
1798 p_ptr->energy_use = 100;
1806 else if (have_flag(f_ptr->flags, FF_OPEN))
1808 more = do_cmd_open_aux(y, x);
1811 /* Bash jammed doors */
1812 else if (have_flag(f_ptr->flags, FF_BASH))
1814 more = do_cmd_bash_aux(y, x, dir);
1817 /* Tunnel through walls */
1818 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1820 more = do_cmd_tunnel_aux(y, x);
1823 /* Close open doors */
1824 else if (have_flag(f_ptr->flags, FF_CLOSE))
1826 more = do_cmd_close_aux(y, x);
1830 else if (have_flag(f_ptr->flags, FF_DISARM))
1832 more = do_cmd_disarm_aux(y, x, dir);
1837 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1841 /* Cancel repetition unless we can continue */
1842 if (!more) disturb(FALSE, FALSE);
1848 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1849 * Find the index of some "spikes", if possible.
1850 * @param ip くさびとして打てるオブジェクトのID
1851 * @return オブジェクトがある場合TRUEを返す
1854 * Let user choose a pile of spikes, perhaps?
1857 static bool get_spike(INVENTORY_IDX *ip)
1861 /* Check every item in the pack */
1862 for (i = 0; i < INVEN_PACK; i++)
1864 object_type *o_ptr = &inventory[i];
1866 /* Skip non-objects */
1867 if (!o_ptr->k_idx) continue;
1869 /* Check the "tval" code */
1870 if (o_ptr->tval == TV_SPIKE)
1872 /* Save the spike index */
1885 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1886 * Jam a closed door with a spike
1890 * This command may NOT be repeated
1893 void do_cmd_spike(void)
1897 if (p_ptr->special_defense & KATA_MUSOU)
1899 set_action(ACTION_NONE);
1902 /* Get a "repeated" direction */
1903 if (get_rep_dir(&dir,FALSE))
1910 y = p_ptr->y + ddy[dir];
1911 x = p_ptr->x + ddx[dir];
1912 c_ptr = &cave[y][x];
1914 /* Feature code (applying "mimic" field) */
1915 feat = get_feat_mimic(c_ptr);
1917 /* Require closed door */
1918 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1920 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1924 else if (!get_spike(&item))
1926 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1929 /* Is a monster in the way? */
1930 else if (c_ptr->m_idx)
1932 p_ptr->energy_use = 100;
1934 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1943 p_ptr->energy_use = 100;
1945 /* Successful jamming */
1946 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1947 cave_alter_feat(y, x, FF_SPIKE);
1949 /* Use up, and describe, a single spike, from the bottom */
1950 inven_item_increase(item, -1);
1951 inven_item_describe(item);
1952 inven_item_optimize(item);
1960 * @brief 「歩く」動作コマンドのメインルーチン /
1961 * Support code for the "Walk" and "Jump" commands
1962 * @param pickup アイテムの自動拾いを行うならTRUE
1965 void do_cmd_walk(bool pickup)
1972 /* Allow repeated command */
1975 /* Set repeat count */
1976 command_rep = command_arg - 1;
1977 p_ptr->redraw |= (PR_STATE);
1979 /* Cancel the arg */
1983 /* Get a "repeated" direction */
1984 if (get_rep_dir(&dir, FALSE))
1986 p_ptr->energy_use = 100;
1988 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
1990 set_action(ACTION_NONE);
1993 /* Hack -- In small scale wilderness it takes MUCH more time to move */
1994 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
1995 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
1997 /* Actually move the character */
1998 move_player(dir, pickup, FALSE);
2000 /* Allow more walking */
2004 /* Hack again -- Is there a special encounter ??? */
2005 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2007 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2010 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2012 /* Inform the player of his horrible fate :=) */
2013 msg_print(_("襲撃だ!", "You are ambushed !"));
2015 /* Go into large wilderness view */
2016 p_ptr->oldpy = randint1(MAX_HGT-2);
2017 p_ptr->oldpx = randint1(MAX_WID-2);
2020 /* Give first move to monsters */
2021 p_ptr->energy_use = 100;
2023 /* HACk -- set the encouter flag for the wilderness generation */
2024 generate_encounter = TRUE;
2028 /* Cancel repeat unless we may continue */
2029 if (!more) disturb(FALSE, FALSE);
2034 * @brief 「走る」動作コマンドのメインルーチン /
2038 void do_cmd_run(void)
2042 /* Hack -- no running when confused */
2043 if (p_ptr->confused)
2045 msg_print(_("混乱していて走れない!", "You are too confused!"));
2049 if (p_ptr->special_defense & KATA_MUSOU)
2051 set_action(ACTION_NONE);
2054 /* Get a "repeated" direction */
2055 if (get_rep_dir(&dir,FALSE))
2057 /* Hack -- Set the run counter */
2058 running = (command_arg ? command_arg : 1000);
2067 * @brief 「留まる」動作コマンドのメインルーチン /
2068 * Stay still. Search. Enter stores.
2069 * Pick up treasure if "pickup" is true.
2070 * @param pickup アイテムの自動拾いを行うならTRUE
2073 void do_cmd_stay(bool pickup)
2075 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2077 /* Allow repeated command */
2080 /* Set repeat count */
2081 command_rep = command_arg - 1;
2082 p_ptr->redraw |= (PR_STATE);
2084 /* Cancel the arg */
2088 p_ptr->energy_use = 100;
2090 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2091 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2096 * @brief 「休む」動作コマンドのメインルーチン /
2097 * Resting allows a player to safely restore his hp -RAK-
2100 void do_cmd_rest(void)
2103 set_action(ACTION_NONE);
2105 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2111 if (hex_spelling_any()) stop_hex_spell_all();
2113 /* Prompt for time if needed */
2114 if (command_arg <= 0)
2116 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2117 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2123 strcpy(out_val, "&");
2125 /* Ask for duration */
2126 if (!get_string(p, out_val, 4)) return;
2128 /* Rest until done */
2129 if (out_val[0] == '&')
2131 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2135 else if (out_val[0] == '*')
2137 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2143 command_arg = (COMMAND_ARG)atoi(out_val);
2144 if (command_arg <= 0) return;
2150 if (command_arg > 9999) command_arg = 9999;
2152 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2154 /* Take a turn (?) */
2155 p_ptr->energy_use = 100;
2157 /* The sin of sloth */
2158 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2160 /* Why are you sleeping when there's no need? WAKE UP!*/
2161 if ((p_ptr->chp == p_ptr->mhp) &&
2162 (p_ptr->csp == p_ptr->msp) &&
2163 !p_ptr->blind && !p_ptr->confused &&
2164 !p_ptr->poisoned && !p_ptr->afraid &&
2165 !p_ptr->stun && !p_ptr->cut &&
2166 !p_ptr->slow && !p_ptr->paralyzed &&
2167 !p_ptr->image && !p_ptr->word_recall &&
2168 !p_ptr->alter_reality)
2169 chg_virtue(V_DILIGENCE, -1);
2171 /* Save the rest code */
2172 resting = command_arg;
2173 p_ptr->action = ACTION_REST;
2174 p_ptr->update |= (PU_BONUS);
2175 p_ptr->redraw |= (PR_STATE);
2183 * @brief 矢弾を射撃した場合の破損確率を返す /
2184 * Determines the odds of an object breaking when thrown at a monster
2185 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2188 * Note that artifacts never break, see the "drop_near()" function.
2190 static PERCENTAGE breakage_chance(object_type *o_ptr)
2192 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2194 /* Examine the snipe type */
2197 if (snipe_type == SP_KILL_WALL) return (100);
2198 if (snipe_type == SP_EXPLODE) return (100);
2199 if (snipe_type == SP_PIERCE) return (100);
2200 if (snipe_type == SP_FINAL) return (100);
2201 if (snipe_type == SP_NEEDLE) return (100);
2202 if (snipe_type == SP_EVILNESS) return (40);
2203 if (snipe_type == SP_HOLYNESS) return (40);
2206 /* Examine the item type */
2207 switch (o_ptr->tval)
2223 /* Sometimes break */
2228 return (20 - archer_bonus * 2);
2233 return (10 - archer_bonus);
2241 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2242 * Determines the odds of an object breaking when thrown at a monster
2243 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2244 * @param tdam 計算途中のダメージ量
2245 * @param m_ptr 目標モンスターの構造体参照ポインタ
2246 * @return スレイ倍率をかけたダメージ量
2248 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2252 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2254 BIT_FLAGS flgs[TR_FLAG_SIZE];
2256 /* Extract the flags */
2257 object_flags(o_ptr, flgs);
2259 /* Some "weapons" and "ammo" do extra damage */
2260 switch (o_ptr->tval)
2266 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2268 if (is_original_ap_and_seen(m_ptr))
2270 r_ptr->r_flags3 |= RF3_ANIMAL;
2272 if (mult < 17) mult = 17;
2275 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2277 if (is_original_ap_and_seen(m_ptr))
2279 r_ptr->r_flags3 |= RF3_ANIMAL;
2281 if (mult < 27) mult = 27;
2284 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2286 if (is_original_ap_and_seen(m_ptr))
2288 r_ptr->r_flags3 |= RF3_EVIL;
2290 if (mult < 15) mult = 15;
2293 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2295 if (is_original_ap_and_seen(m_ptr))
2297 r_ptr->r_flags3 |= RF3_EVIL;
2299 if (mult < 25) mult = 25;
2302 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2304 if (is_original_ap_and_seen(m_ptr))
2306 r_ptr->r_flags2 |= RF2_HUMAN;
2308 if (mult < 17) mult = 17;
2311 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2313 if (is_original_ap_and_seen(m_ptr))
2315 r_ptr->r_flags2 |= RF2_HUMAN;
2317 if (mult < 27) mult = 27;
2320 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2322 if (is_original_ap_and_seen(m_ptr))
2324 r_ptr->r_flags3 |= RF3_UNDEAD;
2326 if (mult < 20) mult = 20;
2329 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2331 if (is_original_ap_and_seen(m_ptr))
2333 r_ptr->r_flags3 |= RF3_UNDEAD;
2335 if (mult < 30) mult = 30;
2338 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2340 if (is_original_ap_and_seen(m_ptr))
2342 r_ptr->r_flags3 |= RF3_DEMON;
2344 if (mult < 20) mult = 20;
2347 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2349 if (is_original_ap_and_seen(m_ptr))
2351 r_ptr->r_flags3 |= RF3_DEMON;
2353 if (mult < 30) mult = 30;
2356 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
2358 if (is_original_ap_and_seen(m_ptr))
2360 r_ptr->r_flags3 |= RF3_ORC;
2362 if (mult < 20) mult = 20;
2365 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
2367 if (is_original_ap_and_seen(m_ptr))
2369 r_ptr->r_flags3 |= RF3_ORC;
2371 if (mult < 30) mult = 30;
2374 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2376 if (is_original_ap_and_seen(m_ptr))
2378 r_ptr->r_flags3 |= RF3_TROLL;
2381 if (mult < 20) mult = 20;
2384 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2386 if (is_original_ap_and_seen(m_ptr))
2388 r_ptr->r_flags3 |= RF3_TROLL;
2390 if (mult < 30) mult = 30;
2393 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2395 if (is_original_ap_and_seen(m_ptr))
2397 r_ptr->r_flags3 |= RF3_GIANT;
2399 if (mult < 20) mult = 20;
2402 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2404 if (is_original_ap_and_seen(m_ptr))
2406 r_ptr->r_flags3 |= RF3_GIANT;
2408 if (mult < 30) mult = 30;
2411 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2413 if (is_original_ap_and_seen(m_ptr))
2415 r_ptr->r_flags3 |= RF3_DRAGON;
2417 if (mult < 20) mult = 20;
2420 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2422 if (is_original_ap_and_seen(m_ptr))
2424 r_ptr->r_flags3 |= RF3_DRAGON;
2426 if (mult < 30) mult = 30;
2427 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
2428 (inventory[INVEN_BOW].name1 == ART_BARD))
2432 if (have_flag(flgs, TR_BRAND_ACID))
2434 /* Notice immunity */
2435 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2437 if (is_original_ap_and_seen(m_ptr))
2439 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2444 if (mult < 17) mult = 17;
2448 if (have_flag(flgs, TR_BRAND_ELEC))
2450 /* Notice immunity */
2451 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2453 if (is_original_ap_and_seen(m_ptr))
2455 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2460 if (mult < 17) mult = 17;
2464 if (have_flag(flgs, TR_BRAND_FIRE))
2466 /* Notice immunity */
2467 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2469 if (is_original_ap_and_seen(m_ptr))
2471 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2474 /* Otherwise, take the damage */
2477 if (r_ptr->flags3 & RF3_HURT_FIRE)
2479 if (mult < 25) mult = 25;
2480 if (is_original_ap_and_seen(m_ptr))
2482 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2485 else if (mult < 17) mult = 17;
2489 if (have_flag(flgs, TR_BRAND_COLD))
2491 /* Notice immunity */
2492 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2494 if (is_original_ap_and_seen(m_ptr))
2496 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2499 /* Otherwise, take the damage */
2502 if (r_ptr->flags3 & RF3_HURT_COLD)
2504 if (mult < 25) mult = 25;
2505 if (is_original_ap_and_seen(m_ptr))
2507 r_ptr->r_flags3 |= RF3_HURT_COLD;
2510 else if (mult < 17) mult = 17;
2514 if (have_flag(flgs, TR_BRAND_POIS))
2516 /* Notice immunity */
2517 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2519 if (is_original_ap_and_seen(m_ptr))
2521 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2524 /* Otherwise, take the damage */
2527 if (mult < 17) mult = 17;
2531 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2533 p_ptr->csp -= (1+(p_ptr->msp / 30));
2534 p_ptr->redraw |= (PR_MANA);
2535 mult = mult * 5 / 2;
2542 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2544 /* Return the total damage */
2545 return (tdam * mult / 10);
2550 * @brief 射撃処理のサブルーチン /
2551 * Fire an object from the pack or floor.
2552 * @param item 射撃するオブジェクトの所持ID
2553 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2557 * You may only fire items that "match" your missile launcher.
2559 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2561 * See "calc_bonuses()" for more calculations and such.
2563 * Note that "firing" a missile is MUCH better than "throwing" it.
2565 * Note: "unseen" monsters are very hard to hit.
2567 * Objects are more likely to break if they "attempt" to hit a monster.
2569 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2571 * The "extra shot" code works by decreasing the amount of energy
2572 * required to make each shot, spreading the shots out over time.
2574 * Note that when firing missiles, the launcher multiplier is applied
2575 * after all the bonuses are added in, making multipliers very useful.
2577 * Note that Bows of "Extra Might" get extra range and an extra bonus
2578 * for the damage multiplier.
2580 * Note that Bows of "Extra Shots" give an extra shot.
2583 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2587 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2588 int tdam_base, tdis, thits, tmul;
2590 int cur_dis, visible;
2598 bool hit_body = FALSE;
2600 GAME_TEXT o_name[MAX_NLEN];
2602 u16b path_g[512]; /* For calcuration of path length */
2604 int msec = delay_factor * delay_factor * delay_factor;
2607 bool stick_to = FALSE;
2609 /* Access the item (if in the pack) */
2612 o_ptr = &inventory[item];
2616 o_ptr = &o_list[0 - item];
2619 /* Sniper - Cannot shot a single arrow twice */
2620 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2622 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2624 /* Use the proper number of shots */
2625 thits = p_ptr->num_fire;
2627 /* Use a base distance */
2630 /* Base damage from thrown object plus launcher bonus */
2631 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2633 /* Actually "fire" the object */
2634 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2635 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2636 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2638 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2640 p_ptr->energy_use = bow_energy(j_ptr->sval);
2641 tmul = bow_tmul(j_ptr->sval);
2643 /* Get extra "power" from "extra might" */
2644 if (p_ptr->xtra_might) tmul++;
2646 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2648 /* Boost the damage */
2653 tdis = 13 + tmul/80;
2654 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2657 tdis -= (5 - (p_ptr->concent + 1) / 2);
2662 project_length = tdis + 1;
2664 /* Get a direction (or cancel) */
2665 if (!get_aim_dir(&dir))
2667 p_ptr->energy_use = 0;
2669 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2671 /* need not to reset project_length (already did)*/
2676 /* Predict the "target" location */
2677 tx = p_ptr->x + 99 * ddx[dir];
2678 ty = p_ptr->y + 99 * ddy[dir];
2680 /* Check for "target request" */
2681 if ((dir == 5) && target_okay())
2687 /* Get projection path length */
2688 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2690 project_length = 0; /* reset to default */
2692 /* Don't shoot at my feet */
2693 if (tx == p_ptr->x && ty == p_ptr->y)
2695 p_ptr->energy_use = 0;
2697 /* project_length is already reset to 0 */
2703 /* Take a (partial) turn */
2704 p_ptr->energy_use = (p_ptr->energy_use / thits);
2707 /* Sniper - Difficult to shot twice at 1 turn */
2708 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2710 /* Sniper - Repeat shooting when double shots */
2711 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2714 /* Start at the player */
2719 /* Obtain a local object */
2720 object_copy(q_ptr, o_ptr);
2725 /* Reduce and describe inventory */
2728 inven_item_increase(item, -1);
2729 inven_item_describe(item);
2730 inven_item_optimize(item);
2733 /* Reduce and describe floor item */
2736 floor_item_increase(0 - item, -1);
2737 floor_item_optimize(0 - item);
2743 /* Save the old location */
2747 /* The shot does not hit yet */
2750 /* Travel until stopped */
2751 for (cur_dis = 0; cur_dis <= tdis; )
2755 /* Hack -- Stop at the target */
2756 if ((y == ty) && (x == tx)) break;
2758 /* Calculate the new location (see "project()") */
2761 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2764 if (snipe_type == SP_KILL_WALL)
2766 c_ptr = &cave[ny][nx];
2768 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2770 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2771 /* Forget the wall */
2772 c_ptr->info &= ~(CAVE_MARK);
2773 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2775 /* Destroy the wall */
2776 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2783 /* Stopped by walls/doors */
2784 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2786 /* Advance the distance */
2790 if (snipe_type == SP_LITE)
2792 cave[ny][nx].info |= (CAVE_GLOW);
2797 /* The player can see the (on screen) missile */
2798 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2800 char c = object_char(q_ptr);
2801 byte a = object_attr(q_ptr);
2803 /* Draw, Hilite, Fresh, Pause, Erase */
2804 print_rel(c, a, ny, nx);
2805 move_cursor_relative(ny, nx);
2807 Term_xtra(TERM_XTRA_DELAY, msec);
2812 /* The player cannot see the missile */
2815 /* Pause anyway, for consistancy */
2816 Term_xtra(TERM_XTRA_DELAY, msec);
2820 if (snipe_type == SP_KILL_TRAP)
2822 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
2823 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
2827 if (snipe_type == SP_EVILNESS)
2829 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
2834 /* Save the old location */
2838 /* Save the new location */
2842 /* Monster here, Try to hit it */
2843 if (cave[y][x].m_idx)
2845 cave_type *c_mon_ptr = &cave[y][x];
2847 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
2848 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2850 /* Check the visibility */
2851 visible = m_ptr->ml;
2853 /* Note the collision */
2856 if (MON_CSLEEP(m_ptr))
2858 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
2859 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
2862 if ((r_ptr->level + 10) > p_ptr->lev)
2864 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
2865 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
2868 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
2869 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
2870 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
2871 else if (p_ptr->lev > 34) amount = 2;
2872 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
2873 p_ptr->update |= (PU_BONUS);
2879 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
2880 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
2883 p_ptr->skill_exp[GINOU_RIDING] += 1;
2884 p_ptr->update |= (PU_BONUS);
2888 /* Did we hit it (penalize range) */
2889 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2892 int tdam = tdam_base;
2894 /* Get extra damage from concentration */
2895 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
2897 /* Handle unseen monster */
2900 /* Invisible monster */
2901 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2904 /* Handle visible monster */
2907 GAME_TEXT m_name[MAX_NLEN];
2909 /* Get "the monster" or "it" */
2910 monster_desc(m_name, m_ptr, 0);
2912 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2916 /* Hack -- Track this monster race */
2917 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2919 /* Hack -- Track this monster */
2920 health_track(c_mon_ptr->m_idx);
2924 if (snipe_type == SP_NEEDLE)
2926 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
2927 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
2929 GAME_TEXT m_name[MAX_NLEN];
2931 /* Get "the monster" or "it" */
2932 monster_desc(m_name, m_ptr, 0);
2934 tdam = m_ptr->hp + 1;
2935 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
2941 /* Apply special damage */
2942 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
2943 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
2945 /* No negative damage */
2946 if (tdam < 0) tdam = 0;
2948 /* Modify the damage */
2949 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2952 msg_format_wizard(CHEAT_MONSTER,
2953 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2954 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2957 if (snipe_type == SP_EXPLODE)
2959 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
2961 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
2962 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
2967 if (snipe_type == SP_HOLYNESS)
2969 cave[ny][nx].info |= (CAVE_GLOW);
2974 /* Hit the monster, check for death */
2975 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2984 if (object_is_fixed_artifact(q_ptr) &&
2985 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
2987 GAME_TEXT m_name[MAX_NLEN];
2989 monster_desc(m_name, m_ptr, 0);
2992 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
2995 message_pain(c_mon_ptr->m_idx, tdam);
2997 /* Anger the monster */
2998 if (tdam > 0) anger_monster(m_ptr);
3000 if (fear && m_ptr->ml)
3002 GAME_TEXT m_name[MAX_NLEN];
3004 monster_desc(m_name, m_ptr, 0);
3005 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3008 set_target(m_ptr, p_ptr->y, p_ptr->x);
3011 if (snipe_type == SP_RUSH)
3013 int n = randint1(5) + 3;
3014 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3016 for ( ; cur_dis <= tdis; )
3023 /* Calculate the new location (see "project()") */
3024 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3026 /* Stopped by wilderness boundary */
3027 if (!in_bounds2(ny, nx)) break;
3029 /* Stopped by walls/doors */
3030 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3032 /* Stopped by monsters */
3033 if (!cave_empty_bold(ny, nx)) break;
3035 cave[ny][nx].m_idx = m_idx;
3036 cave[oy][ox].m_idx = 0;
3041 update_monster(c_mon_ptr->m_idx, TRUE);
3047 Term_xtra(TERM_XTRA_DELAY, msec);
3059 if (snipe_type == SP_PIERCE)
3061 if(p_ptr->concent < 1) break;
3071 /* Chance of breakage (during attacks) */
3072 j = (hit_body ? breakage_chance(q_ptr) : 0);
3076 MONSTER_IDX m_idx = cave[y][x].m_idx;
3077 monster_type *m_ptr = &m_list[m_idx];
3078 OBJECT_IDX o_idx = o_pop();
3082 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3083 if (object_is_fixed_artifact(q_ptr))
3085 a_info[j_ptr->name1].cur_num = 0;
3090 o_ptr = &o_list[o_idx];
3091 object_copy(o_ptr, q_ptr);
3094 o_ptr->marked &= OM_TOUCHED;
3096 /* Forget location */
3097 o_ptr->iy = o_ptr->ix = 0;
3099 /* Memorize monster */
3100 o_ptr->held_m_idx = m_idx;
3103 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3106 m_ptr->hold_o_idx = o_idx;
3108 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3110 /* Drop (or break) near that location */
3111 (void)drop_near(q_ptr, j, y, x);
3115 /* Drop (or break) near that location */
3116 (void)drop_near(q_ptr, j, prev_y, prev_x);
3119 /* Sniper - Repeat shooting when double shots */
3122 /* Sniper - Loose his/her concentration after any shot */
3123 if (p_ptr->concent) reset_concentration(FALSE);
3127 * @brief 射撃処理のメインルーチン
3130 void do_cmd_fire(void)
3133 object_type *j_ptr, *ammo_ptr;
3136 is_fired = FALSE; /* not fired yet */
3138 /* Get the "bow" (if any) */
3139 j_ptr = &inventory[INVEN_BOW];
3141 /* Require a launcher */
3144 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3149 if (j_ptr->sval == SV_CRIMSON)
3151 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3156 if (j_ptr->sval == SV_HARP)
3158 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3164 if (p_ptr->special_defense & KATA_MUSOU)
3166 set_action(ACTION_NONE);
3169 /* Require proper missile */
3170 item_tester_tval = p_ptr->tval_ammo;
3172 q = _("どれを撃ちますか? ", "Fire which item? ");
3173 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3176 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3184 do_cmd_fire_aux(item, j_ptr);
3186 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3188 /* Sniper actions after some shootings */
3189 if (snipe_type == SP_AWAY)
3191 teleport_player(10 + (p_ptr->concent * 2), 0L);
3193 if (snipe_type == SP_FINAL)
3195 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3196 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3197 (void)set_stun(p_ptr->stun + randint1(25));
3203 * @brief 投射処理メインルーチン /
3204 * Throw an object from the pack or floor.
3206 * @param boomerang ブーメラン処理ならばTRUE
3207 * @param shuriken 忍者の手裏剣処理ならばTRUE
3208 * @return ターンを消費した場合TRUEを返す
3211 * Note: "unseen" monsters are very hard to hit.
3213 * Should throwing a weapon do full damage? Should it allow the magic
3214 * to hit bonus of the weapon to have an effect? Should it ever cause
3215 * the item to be destroyed? Should it do any damage at all?
3218 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3223 POSITION y, x, ty, tx, prev_y, prev_x;
3224 POSITION ny[19], nx[19];
3225 int chance, tdam, tdis;
3226 int mul, div, dd, ds;
3227 int cur_dis, visible;
3234 bool hit_body = FALSE;
3235 bool hit_wall = FALSE;
3236 bool equiped_item = FALSE;
3237 bool return_when_thrown = FALSE;
3239 GAME_TEXT o_name[MAX_NLEN];
3241 int msec = delay_factor * delay_factor * delay_factor;
3243 BIT_FLAGS flgs[TR_FLAG_SIZE];
3245 bool come_back = FALSE;
3246 bool do_drop = TRUE;
3249 if (p_ptr->special_defense & KATA_MUSOU)
3251 set_action(ACTION_NONE);
3260 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3262 item_tester_hook = item_tester_hook_boomerang;
3263 q = _("どの武器を投げますか? ", "Throw which item? ");
3264 s = _("投げる武器がない。", "You have nothing to throw.");
3265 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
3272 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3273 else item = INVEN_RARM;
3277 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3278 s = _("投げるアイテムがない。", "You have nothing to throw.");
3279 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
3287 /* Item is cursed */
3288 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3290 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3295 if (p_ptr->inside_arena && !boomerang)
3297 if (o_ptr->tval != TV_SPIKE)
3299 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3308 /* Obtain a local object */
3309 object_copy(q_ptr, o_ptr);
3311 /* Extract the thrown object's flags. */
3312 object_flags(q_ptr, flgs);
3313 torch_flags(q_ptr, flgs);
3315 /* Distribute the charges of rods/wands between the stacks */
3316 distribute_charges(o_ptr, q_ptr, 1);
3322 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3324 if (p_ptr->mighty_throw) mult += 3;
3326 /* Extract a "distance multiplier" */
3327 /* Changed for 'launcher' mutation */
3328 mul = 10 + 2 * (mult - 1);
3330 /* Enforce a minimum "weight" of one pound */
3331 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3332 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3334 /* Hack -- Distance -- Reward strength, penalize weight */
3335 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3337 /* Max distance of 10-18 */
3338 if (tdis > mul) tdis = mul;
3342 ty = randint0(101) - 50 + p_ptr->y;
3343 tx = randint0(101) - 50 + p_ptr->x;
3347 project_length = tdis + 1;
3349 /* Get a direction (or cancel) */
3350 if (!get_aim_dir(&dir)) return FALSE;
3352 /* Predict the "target" location */
3353 tx = p_ptr->x + 99 * ddx[dir];
3354 ty = p_ptr->y + 99 * ddy[dir];
3356 /* Check for "target request" */
3357 if ((dir == 5) && target_okay())
3363 project_length = 0; /* reset to default */
3366 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3367 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3368 return_when_thrown = TRUE;
3370 /* Reduce and describe inventory */
3373 inven_item_increase(item, -1);
3374 if (!return_when_thrown)
3375 inven_item_describe(item);
3376 inven_item_optimize(item);
3379 /* Reduce and describe floor item */
3382 floor_item_increase(0 - item, -1);
3383 floor_item_optimize(0 - item);
3385 if (item >= INVEN_RARM)
3387 equiped_item = TRUE;
3388 p_ptr->redraw |= (PR_EQUIPPY);
3391 p_ptr->energy_use = 100;
3393 /* Rogue and Ninja gets bonus */
3394 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3395 p_ptr->energy_use -= p_ptr->lev;
3397 /* Start at the player */
3403 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3404 else shuriken = FALSE;
3406 /* Chance of hitting */
3407 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3408 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3409 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3411 if (shuriken) chance *= 2;
3413 /* Save the old location */
3417 /* Travel until stopped */
3418 for (cur_dis = 0; cur_dis <= tdis; )
3420 /* Hack -- Stop at the target */
3421 if ((y == ty) && (x == tx)) break;
3423 /* Calculate the new location (see "project()") */
3426 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3428 /* Stopped by walls/doors */
3429 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3432 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3435 /* The player can see the (on screen) missile */
3436 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3438 char c = object_char(q_ptr);
3439 byte a = object_attr(q_ptr);
3441 /* Draw, Hilite, Fresh, Pause, Erase */
3442 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3443 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3445 Term_xtra(TERM_XTRA_DELAY, msec);
3446 lite_spot(ny[cur_dis], nx[cur_dis]);
3450 /* The player cannot see the missile */
3453 /* Pause anyway, for consistancy */
3454 Term_xtra(TERM_XTRA_DELAY, msec);
3457 /* Save the old location */
3461 /* Save the new location */
3465 /* Advance the distance */
3468 /* Monster here, Try to hit it */
3469 if (cave[y][x].m_idx)
3471 cave_type *c_ptr = &cave[y][x];
3472 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3474 /* Check the visibility */
3475 visible = m_ptr->ml;
3477 /* Note the collision */
3480 /* Did we hit it (penalize range) */
3481 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3485 /* Handle unseen monster */
3488 /* Invisible monster */
3489 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3492 /* Handle visible monster */
3495 GAME_TEXT m_name[MAX_NLEN];
3496 monster_desc(m_name, m_ptr, 0);
3497 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3501 /* Hack -- Track this monster race */
3502 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3504 /* Hack -- Track this monster */
3505 health_track(c_ptr->m_idx);
3509 /* Hack -- Base damage from thrown object */
3512 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3513 tdam = damroll(dd, ds);
3514 /* Apply special damage */
3515 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3516 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3517 if (q_ptr->to_d > 0)
3518 tdam += q_ptr->to_d;
3520 tdam += -q_ptr->to_d;
3524 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3525 tdam += p_ptr->to_d_m;
3527 else if (have_flag(flgs, TR_THROW))
3530 tdam += p_ptr->to_d_m;
3538 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3541 /* No negative damage */
3542 if (tdam < 0) tdam = 0;
3544 /* Modify the damage */
3545 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3547 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3548 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3550 /* Hit the monster, check for death */
3551 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
3559 message_pain(c_ptr->m_idx, tdam);
3561 /* Anger the monster */
3562 if ((tdam > 0) && !object_is_potion(q_ptr))
3563 anger_monster(m_ptr);
3565 if (fear && m_ptr->ml)
3568 GAME_TEXT m_name[MAX_NLEN];
3569 monster_desc(m_name, m_ptr, 0);
3570 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3580 /* decrease toach's fuel */
3581 if (hit_body) torch_lost_fuel(q_ptr);
3583 /* Chance of breakage (during attacks) */
3584 j = (hit_body ? breakage_chance(q_ptr) : 0);
3586 /* Figurines transform */
3587 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3591 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3592 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3593 else if (object_is_cursed(q_ptr))
3594 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3599 /* Potions smash open */
3600 if (object_is_potion(q_ptr))
3602 if (hit_body || hit_wall || (randint1(100) < j))
3604 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3606 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3608 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3610 /* ToDo (Robert): fix the invulnerability */
3611 if (cave[y][x].m_idx &&
3612 is_friendly(&m_list[cave[y][x].m_idx]) &&
3613 !MON_INVULNER(m_ptr))
3615 GAME_TEXT m_name[MAX_NLEN];
3616 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3617 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3618 set_hostile(&m_list[cave[y][x].m_idx]);
3629 if (return_when_thrown)
3631 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3632 char o2_name[MAX_NLEN];
3633 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3636 if (boomerang) back_chance += 4+randint1(5);
3637 if (super_boomerang) back_chance += 100;
3638 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3640 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3642 for (i = cur_dis - 1; i > 0; i--)
3644 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3646 char c = object_char(q_ptr);
3647 byte a = object_attr(q_ptr);
3649 /* Draw, Hilite, Fresh, Pause, Erase */
3650 print_rel(c, a, ny[i], nx[i]);
3651 move_cursor_relative(ny[i], nx[i]);
3653 Term_xtra(TERM_XTRA_DELAY, msec);
3654 lite_spot(ny[i], nx[i]);
3659 /* Pause anyway, for consistancy */
3660 Term_xtra(TERM_XTRA_DELAY, msec);
3663 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3665 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3672 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3676 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3684 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3690 if (item == INVEN_RARM || item == INVEN_LARM)
3692 /* Access the wield slot */
3693 o_ptr = &inventory[item];
3695 /* Wear the new stuff */
3696 object_copy(o_ptr, q_ptr);
3698 /* Increase the weight */
3699 p_ptr->total_weight += q_ptr->weight;
3701 /* Increment the equip counter by hand */
3704 /* Recalculate torch */
3705 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
3706 p_ptr->window |= (PW_EQUIP);
3714 else if (equiped_item)
3722 if (cave_have_flag_bold(y, x, FF_PROJECT))
3724 (void)drop_near(q_ptr, j, y, x);
3728 (void)drop_near(q_ptr, j, prev_y, prev_x);
3738 * Hack: travel command
3740 #define TRAVEL_UNABLE 9999
3742 static int flow_head = 0;
3743 static int flow_tail = 0;
3744 static POSITION temp2_x[MAX_SHORT];
3745 static POSITION temp2_y[MAX_SHORT];
3748 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3751 void forget_travel_flow(void)
3754 /* Check the entire dungeon / Forget the old data */
3755 for (y = 0; y < cur_hgt; y++)
3757 for (x = 0; x < cur_wid; x++)
3760 travel.cost[y][x] = MAX_SHORT;
3763 travel.y = travel.x = 0;
3767 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
3772 static int travel_flow_cost(POSITION y, POSITION x)
3774 feature_type *f_ptr = &f_info[cave[y][x].feat];
3777 /* Avoid obstacles (ex. trees) */
3778 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
3781 if (have_flag(f_ptr->flags, FF_WATER))
3783 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
3787 if (have_flag(f_ptr->flags, FF_LAVA))
3790 if (!p_ptr->resist_fire) lava *= 2;
3791 if (!p_ptr->levitation) lava *= 2;
3792 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
3797 /* Detected traps and doors */
3798 if (cave[y][x].info & (CAVE_MARK))
3800 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
3801 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
3808 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
3812 * @param wall プレイヤーが壁の中にいるならばTRUE
3815 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
3817 cave_type *c_ptr = &cave[y][x];
3818 feature_type *f_ptr = &f_info[c_ptr->feat];
3819 int old_head = flow_head;
3821 int base_cost = (n % TRAVEL_UNABLE);
3822 int from_wall = (n / TRAVEL_UNABLE);
3825 /* Ignore out of bounds */
3826 if (!in_bounds(y, x)) return;
3828 /* Ignore unknown grid except in wilderness */
3829 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
3831 /* Ignore "walls" and "rubble" (include "secret doors") */
3832 if (have_flag(f_ptr->flags, FF_WALL) ||
3833 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3834 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
3835 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
3837 if (!wall || !from_wall) return;
3838 add_cost += TRAVEL_UNABLE;
3842 add_cost = travel_flow_cost(y, x);
3845 cost = base_cost + add_cost;
3847 /* Ignore lower cost entries */
3848 if (travel.cost[y][x] <= cost) return;
3850 /* Save the flow cost */
3851 travel.cost[y][x] = cost;
3853 /* Enqueue that entry */
3854 temp2_y[flow_head] = y;
3855 temp2_x[flow_head] = x;
3857 /* Advance the queue */
3858 if (++flow_head == MAX_SHORT) flow_head = 0;
3860 /* Hack -- notice overflow by forgetting new entry */
3861 if (flow_head == flow_tail) flow_head = old_head;
3867 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
3868 * @param ty 目標地点のY座標
3869 * @param tx 目標地点のX座標
3872 static void travel_flow(POSITION ty, POSITION tx)
3876 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
3878 /* Reset the "queue" */
3879 flow_head = flow_tail = 0;
3881 /* is player in the wall? */
3882 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
3884 /* Start at the target grid */
3885 travel_flow_aux(ty, tx, 0, wall);
3887 /* Now process the queue */
3888 while (flow_head != flow_tail)
3890 /* Extract the next entry */
3891 y = temp2_y[flow_tail];
3892 x = temp2_x[flow_tail];
3894 /* Forget that entry */
3895 if (++flow_tail == MAX_SHORT) flow_tail = 0;
3897 /* Ignore too far entries */
3898 //if (distance(ty, tx, y, x) > 100) continue;
3900 /* Add the "children" */
3901 for (d = 0; d < 8; d++)
3903 /* Add that child if "legal" */
3904 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
3908 /* Forget the flow info */
3909 flow_head = flow_tail = 0;
3913 * @brief トラベル処理のメインルーチン
3916 void do_cmd_travel(void)
3920 POSITION dx, dy, sx, sy;
3921 feature_type *f_ptr;
3923 if (travel.x != 0 && travel.y != 0 &&
3924 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3929 else if (!tgt_pt(&x, &y)) return;
3931 if ((x == p_ptr->x) && (y == p_ptr->y))
3933 msg_print(_("すでにそこにいます!", "You are already there!!"));
3937 f_ptr = &f_info[cave[y][x].feat];
3939 if ((cave[y][x].info & CAVE_MARK) &&
3940 (have_flag(f_ptr->flags, FF_WALL) ||
3941 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3942 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3944 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3948 forget_travel_flow();
3954 /* Travel till 255 steps */
3960 /* Decides first direction */
3961 dx = abs(p_ptr->x - x);
3962 dy = abs(p_ptr->y - y);
3963 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3964 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3966 for (i = 1; i <= 9; i++)
3968 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;