3 * @brief プレイヤーのコマンド処理2 / Movement commands (part 2)
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
17 #include "object-hook.h"
18 #include "projection.h"
19 #include "spells-summon.h"
20 #include "monster-status.h"
23 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
24 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
25 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
27 bool confirm_leave_level(bool down_stair)
29 quest_type *q_ptr = &quest[p_ptr->inside_quest];
31 /* Confirm leaving from once only quest */
32 if (confirm_quest && p_ptr->inside_quest &&
33 (q_ptr->type == QUEST_TYPE_RANDOM ||
34 (q_ptr->flags & QUEST_FLAG_ONCE &&
35 q_ptr->status != QUEST_STATUS_COMPLETED) ||
36 (q_ptr->flags & QUEST_FLAG_TOWER &&
37 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
38 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
40 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
41 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
51 * @brief 階段を使って階層を昇る処理 / Go up one level
54 void do_cmd_go_up(void)
59 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
60 feature_type *f_ptr = &f_info[c_ptr->feat];
64 if (p_ptr->special_defense & KATA_MUSOU)
66 set_action(ACTION_NONE);
70 if (!have_flag(f_ptr->flags, FF_LESS))
72 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
77 if (have_flag(f_ptr->flags, FF_QUEST))
79 /* Cancel the command */
80 if (!confirm_leave_level(FALSE)) return;
84 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
85 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
87 msg_print(_("上の階に登った。", "You enter the up staircase."));
91 p_ptr->inside_quest = c_ptr->special;
93 /* Activate the quest */
94 if (!quest[p_ptr->inside_quest].status)
96 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
98 init_flags = INIT_ASSIGN;
99 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
101 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
104 /* Leaving a quest */
105 if (!p_ptr->inside_quest)
111 p_ptr->leaving = TRUE;
116 /* Hack -- take a turn */
117 p_ptr->energy_use = 100;
119 /* End the command */
129 go_up = confirm_leave_level(FALSE);
132 /* Cancel the command */
135 /* Hack -- take a turn */
136 p_ptr->energy_use = 100;
138 if (autosave_l) do_cmd_save_game(TRUE);
140 /* For a random quest */
141 if (p_ptr->inside_quest &&
142 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
146 p_ptr->inside_quest = 0;
149 /* For a fixed quest */
150 if (p_ptr->inside_quest &&
151 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
155 p_ptr->inside_quest = c_ptr->special;
160 /* For normal dungeon and random quest */
164 if (have_flag(f_ptr->flags, FF_SHAFT))
166 /* Create a way back */
167 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
173 /* Create a way back */
174 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
179 /* Get out from current dungeon */
180 if (dun_level - up_num < d_info[dungeon_type].mindepth)
183 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
186 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
187 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
188 else if (up_num == dun_level)
189 msg_print(_("地上に戻った。", "You go back to the surface."));
191 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
194 p_ptr->leaving = TRUE;
199 * @brief 階段を使って階層を降りる処理 / Go down one level
202 void do_cmd_go_down(void)
205 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
206 feature_type *f_ptr = &f_info[c_ptr->feat];
208 bool fall_trap = FALSE;
211 if (p_ptr->special_defense & KATA_MUSOU)
213 set_action(ACTION_NONE);
217 if (!have_flag(f_ptr->flags, FF_MORE))
219 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
223 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
226 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
231 /* Quest down stairs */
232 else if (have_flag(f_ptr->flags, FF_QUEST))
234 /* Confirm Leaving */
235 if(!confirm_leave_level(TRUE)) return;
237 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
238 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
240 msg_print(_("下の階に降りた。", "You enter the down staircase."));
245 p_ptr->inside_quest = c_ptr->special;
247 /* Activate the quest */
248 if (!quest[p_ptr->inside_quest].status)
250 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
252 init_flags = INIT_ASSIGN;
253 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
255 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
258 /* Leaving a quest */
259 if (!p_ptr->inside_quest)
265 p_ptr->leaving = TRUE;
271 /* Hack -- take a turn */
272 p_ptr->energy_use = 100;
277 DUNGEON_IDX target_dungeon = 0;
281 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
283 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
285 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
288 if (!max_dlv[target_dungeon])
290 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
291 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
292 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
295 /* Save old player position */
296 p_ptr->oldpx = p_ptr->x;
297 p_ptr->oldpy = p_ptr->y;
298 dungeon_type = target_dungeon;
301 * Clear all saved floors
302 * and create a first saved floor
304 prepare_change_floor_mode(CFM_FIRST_FLOOR);
307 /* Hack -- take a turn */
308 p_ptr->energy_use = 100;
310 if (autosave_l) do_cmd_save_game(TRUE);
313 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
318 /* Enter the dungeon just now */
319 p_ptr->enter_dungeon = TRUE;
320 down_num = d_info[dungeon_type].mindepth;
325 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
326 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
331 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
338 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
342 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
343 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
345 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
351 p_ptr->leaving = TRUE;
355 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
359 if (have_flag(f_ptr->flags, FF_SHAFT))
361 /* Create a way back */
362 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
366 /* Create a way back */
367 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
375 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
378 void do_cmd_search(void)
380 /* Allow repeated command */
383 /* Set repeat count */
384 command_rep = command_arg - 1;
385 p_ptr->redraw |= (PR_STATE);
390 p_ptr->energy_use = 100;
398 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
399 * @param y 走査対象にしたいマスのY座標
400 * @param x 走査対象にしたいマスのX座標
401 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
402 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
404 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
406 cave_type *c_ptr = &cave[y][x];
407 OBJECT_IDX this_o_idx, next_o_idx = 0;
409 /* Scan all objects in the grid */
410 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
414 o_ptr = &o_list[this_o_idx];
415 next_o_idx = o_ptr->next_o_idx;
417 /* Skip unknown chests XXX XXX */
418 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
420 /* Check for non empty chest */
421 if ((o_ptr->tval == TV_CHEST) &&
422 (((!trapped) && (o_ptr->pval)) || /* non empty */
423 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
432 * @brief 箱を開けるコマンドのメインルーチン /
433 * Attempt to open the given chest at the given location
434 * @param y 箱の存在するマスのY座標
435 * @param x 箱の存在するマスのX座標
436 * @param o_idx 箱のオブジェクトID
437 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
439 * Assume there is no monster blocking the destination
441 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
446 object_type *o_ptr = &o_list[o_idx];
448 p_ptr->energy_use = 100;
450 /* Attempt to unlock it */
453 /* Assume locked, and thus not open */
456 /* Get the "disarm" factor */
457 i = p_ptr->skill_dis;
459 /* Penalize some conditions */
460 if (p_ptr->blind || no_lite()) i = i / 10;
461 if (p_ptr->confused || p_ptr->image) i = i / 10;
463 /* Extract the difficulty */
466 /* Always have a small chance of success */
469 /* Success -- May still have traps */
470 if (randint0(100) < j)
472 msg_print(_("鍵をはずした。", "You have picked the lock."));
477 /* Failure -- Keep trying */
480 /* We may continue repeating */
482 if (flush_failure) flush();
483 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
488 /* Allowed to open */
491 /* Apply chest traps, if any */
492 chest_trap(y, x, o_idx);
494 /* Let the Chest drop items */
495 chest_death(FALSE, y, x, o_idx);
501 * @brief 地形は開くものであって、かつ開かれているかを返す /
502 * Attempt to open the given chest at the given location
504 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
506 static bool is_open(IDX feat)
508 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
513 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
514 * Attempt to open the given chest at the given location
515 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
516 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
517 * @param test 地形条件を判定するための関数ポインタ
518 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
520 * @details Return the number of features around (or under) the character.
521 * Usually look for doors and floor traps.
523 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
525 int d, count, xx, yy;
527 /* Count how many matches */
530 /* Check around (and under) the character */
531 for (d = 0; d < 9; d++)
536 /* if not searching under player continue */
537 if ((d == 8) && !under) continue;
539 /* Extract adjacent (legal) location */
540 yy = p_ptr->y + ddy_ddd[d];
541 xx = p_ptr->x + ddx_ddd[d];
544 c_ptr = &cave[yy][xx];
546 /* Must have knowledge */
547 if (!(c_ptr->info & (CAVE_MARK))) continue;
549 /* Feature code (applying "mimic" field) */
550 feat = get_feat_mimic(c_ptr);
552 /* Not looking for this feature */
553 if (!((*test)(feat))) continue;
558 /* Remember the location. Only useful if only one match */
569 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
570 * Return the number of chests around (or under) the character.
571 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
572 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
573 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
576 * If requested, count only trapped chests.
578 static int count_chests(POSITION *y, POSITION *x, bool trapped)
585 /* Count how many matches */
588 /* Check around (and under) the character */
589 for (d = 0; d < 9; d++)
591 /* Extract adjacent (legal) location */
592 POSITION yy = p_ptr->y + ddy_ddd[d];
593 POSITION xx = p_ptr->x + ddx_ddd[d];
595 /* No (visible) chest is there */
596 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
598 /* Grab the object */
599 o_ptr = &o_list[o_idx];
602 if (o_ptr->pval == 0) continue;
604 /* No (known) traps here */
605 if (trapped && (!object_is_known(o_ptr) ||
606 !chest_traps[o_ptr->pval])) continue;
611 /* Remember the location. Only useful if only one match */
622 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
623 * Convert an adjacent location to a direction.
624 * @param y 方角を確認したY座標
625 * @param x 方角を確認したX座標
628 static DIRECTION coords_to_dir(POSITION y, POSITION x)
630 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
637 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
639 return d[dx + 1][dy + 1];
643 * @brief 「開ける」動作コマンドのサブルーチン /
644 * Perform the basic "open" command on doors
645 * @param y 対象を行うマスのY座標
646 * @param x 対象を行うマスのX座標
647 * @return 実際に処理が行われた場合TRUEを返す。
649 * Assume destination is a closed/locked/jammed door
650 * Assume there is no monster blocking the destination
651 * Returns TRUE if repeated commands may continue
653 static bool do_cmd_open_aux(POSITION y, POSITION x)
657 /* Get requested grid */
658 cave_type *c_ptr = &cave[y][x];
659 feature_type *f_ptr = &f_info[c_ptr->feat];
662 p_ptr->energy_use = 100;
664 /* Seeing true feature code (ignore mimic) */
667 if (!have_flag(f_ptr->flags, FF_OPEN))
670 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
674 else if (f_ptr->power)
677 i = p_ptr->skill_dis;
679 /* Penalize some conditions */
680 if (p_ptr->blind || no_lite()) i = i / 10;
681 if (p_ptr->confused || p_ptr->image) i = i / 10;
683 /* Extract the lock power */
686 /* Extract the difficulty */
689 /* Always have a small chance of success */
693 if (randint0(100) < j)
695 msg_print(_("鍵をはずした。", "You have picked the lock."));
698 cave_alter_feat(y, x, FF_OPEN);
700 sound(SOUND_OPENDOOR);
710 if (flush_failure) flush();
712 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
714 /* We may keep trying */
723 cave_alter_feat(y, x, FF_OPEN);
725 sound(SOUND_OPENDOOR);
731 * @brief 「開ける」コマンドのメインルーチン /
732 * Open a closed/locked/jammed door or a closed/locked chest.
735 * Unlocking a locked door/chest is worth one experience point.
737 void do_cmd_open(void)
745 if (p_ptr->wild_mode) return;
747 if (p_ptr->special_defense & KATA_MUSOU)
749 set_action(ACTION_NONE);
752 /* Option: Pick a direction */
755 int num_doors, num_chests;
757 /* Count closed doors (locked or jammed) */
758 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
760 /* Count chests (locked) */
761 num_chests = count_chests(&y, &x, FALSE);
763 /* See if only one target */
764 if (num_doors || num_chests)
766 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
768 if (!too_many) command_dir = coords_to_dir(y, x);
772 /* Allow repeated command */
775 /* Set repeat count */
776 command_rep = command_arg - 1;
777 p_ptr->redraw |= (PR_STATE);
783 /* Get a "repeated" direction */
784 if (get_rep_dir(&dir, TRUE))
789 /* Get requested location */
790 y = p_ptr->y + ddy[dir];
791 x = p_ptr->x + ddx[dir];
793 /* Get requested grid */
796 /* Feature code (applying "mimic" field) */
797 feat = get_feat_mimic(c_ptr);
799 /* Check for chest */
800 o_idx = chest_check(y, x, FALSE);
803 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
805 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
808 /* Monster in the way */
809 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
811 p_ptr->energy_use = 100;
812 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
820 more = do_cmd_open_chest(y, x, o_idx);
827 more = do_cmd_open_aux(y, x);
831 /* Cancel repeat unless we may continue */
832 if (!more) disturb(FALSE, FALSE);
838 * @brief 「閉じる」動作コマンドのサブルーチン /
839 * Perform the basic "close" command
840 * @param y 対象を行うマスのY座標
841 * @param x 対象を行うマスのX座標
842 * @return 実際に処理が行われた場合TRUEを返す。
844 * Assume destination is an open/broken door
845 * Assume there is no monster blocking the destination
846 * Returns TRUE if repeated commands may continue
848 static bool do_cmd_close_aux(POSITION y, POSITION x)
850 cave_type *c_ptr = &cave[y][x];
851 FEAT_IDX old_feat = c_ptr->feat;
854 p_ptr->energy_use = 100;
856 /* Seeing true feature code (ignore mimic) */
859 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
861 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
863 /* Hack -- object in the way */
864 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
865 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
867 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
872 cave_alter_feat(y, x, FF_CLOSE);
875 if (old_feat == c_ptr->feat)
877 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
881 sound(SOUND_SHUTDOOR);
890 * @brief 「閉じる」コマンドのメインルーチン /
891 * Close an open door.
894 * Unlocking a locked door/chest is worth one experience point.
896 void do_cmd_close(void)
903 if (p_ptr->wild_mode) return;
905 if (p_ptr->special_defense & KATA_MUSOU)
907 set_action(ACTION_NONE);
910 /* Option: Pick a direction */
913 /* Count open doors */
914 if (count_dt(&y, &x, is_open, FALSE) == 1)
916 command_dir = coords_to_dir(y, x);
920 /* Allow repeated command */
923 /* Set repeat count */
924 command_rep = command_arg - 1;
925 p_ptr->redraw |= (PR_STATE);
931 /* Get a "repeated" direction */
932 if (get_rep_dir(&dir, FALSE))
937 y = p_ptr->y + ddy[dir];
938 x = p_ptr->x + ddx[dir];
941 /* Feature code (applying "mimic" field) */
942 feat = get_feat_mimic(c_ptr);
944 /* Require open/broken door */
945 if (!have_flag(f_info[feat].flags, FF_CLOSE))
947 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
950 /* Monster in the way */
951 else if (c_ptr->m_idx)
953 p_ptr->energy_use = 100;
955 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
965 more = do_cmd_close_aux(y, x);
969 /* Cancel repeat unless we may continue */
970 if (!more) disturb(FALSE, FALSE);
975 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
976 * Determine if a given grid may be "tunneled"
977 * @param y 対象を行うマスのY座標
978 * @param x 対象を行うマスのX座標
981 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
983 cave_type *c_ptr = &cave[y][x];
985 /* Must have knowledge */
986 if (!(c_ptr->info & CAVE_MARK))
988 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
993 /* Must be a wall/door/etc */
994 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
996 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1006 * @brief 「掘る」動作コマンドのサブルーチン /
1007 * Perform the basic "tunnel" command
1008 * @param y 対象を行うマスのY座標
1009 * @param x 対象を行うマスのX座標
1010 * @return 実際に処理が行われた場合TRUEを返す。
1012 * Assumes that no monster is blocking the destination
1013 * Do not use twall anymore
1014 * Returns TRUE if repeated commands may continue
1016 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1019 feature_type *f_ptr, *mimic_f_ptr;
1024 /* Verify legality */
1025 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1027 p_ptr->energy_use = 100;
1030 c_ptr = &cave[y][x];
1031 f_ptr = &f_info[c_ptr->feat];
1032 power = f_ptr->power;
1034 /* Feature code (applying "mimic" field) */
1035 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1037 name = f_name + mimic_f_ptr->name;
1041 if (have_flag(f_ptr->flags, FF_PERMANENT))
1044 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1046 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1049 /* Map border (mimiccing Permanent wall) */
1052 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1057 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1060 if (p_ptr->skill_dig > randint0(20 * power))
1062 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1064 /* Remove the feature */
1065 cave_alter_feat(y, x, FF_TUNNEL);
1067 /* Update some things */
1068 p_ptr->update |= (PU_FLOW);
1072 /* Message, keep digging */
1073 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1081 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1084 if (p_ptr->skill_dig > power + randint0(40 * power))
1086 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1089 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1090 p_ptr->update |= (PU_FLOW);
1093 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1095 /* Remove the feature */
1096 cave_alter_feat(y, x, FF_TUNNEL);
1098 chg_virtue(V_DILIGENCE, 1);
1099 chg_virtue(V_NATURE, -1);
1107 /* We may continue chopping */
1108 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1109 /* Occasional Search XXX XXX */
1110 if (randint0(100) < 25) search();
1114 /* We may continue tunelling */
1115 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1122 if (is_hidden_door(c_ptr))
1124 /* Occasional Search XXX XXX */
1125 if (randint0(100) < 25) search();
1132 * @brief 「掘る」動作コマンドのメインルーチン /
1133 * Tunnels through "walls" (including rubble and closed doors)
1137 * Note that you must tunnel in order to hit invisible monsters
1138 * in walls, though moving into walls still takes a turn anyway.
1140 * Digging is very difficult without a "digger" weapon, but can be
1141 * accomplished by strong players using heavy weapons.
1144 void do_cmd_tunnel(void)
1154 if (p_ptr->special_defense & KATA_MUSOU)
1156 set_action(ACTION_NONE);
1159 /* Allow repeated command */
1162 /* Set repeat count */
1163 command_rep = command_arg - 1;
1164 p_ptr->redraw |= (PR_STATE);
1166 /* Cancel the arg */
1170 /* Get a direction to tunnel, or Abort */
1171 if (get_rep_dir(&dir,FALSE))
1174 y = p_ptr->y + ddy[dir];
1175 x = p_ptr->x + ddx[dir];
1178 c_ptr = &cave[y][x];
1180 /* Feature code (applying "mimic" field) */
1181 feat = get_feat_mimic(c_ptr);
1183 /* No tunnelling through doors */
1184 if (have_flag(f_info[feat].flags, FF_DOOR))
1186 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1189 /* No tunnelling through most features */
1190 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1192 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1195 /* A monster is in the way */
1196 else if (c_ptr->m_idx)
1198 p_ptr->energy_use = 100;
1200 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1209 /* Tunnel through walls */
1210 more = do_cmd_tunnel_aux(y, x);
1214 /* Cancel repetition unless we can continue */
1215 if (!more) disturb(FALSE, FALSE);
1219 * @brief 移動処理による簡易な「開く」処理 /
1221 * @return 開く処理が実際に試みられた場合TRUEを返す
1224 * If there is a jammed/closed/locked door at the given location,
1225 * then attempt to unlock/open it. Return TRUE if an attempt was
1226 * made (successful or not), otherwise return FALSE.
1228 * The code here should be nearly identical to that in
1229 * do_cmd_open_test() and do_cmd_open_aux().
1232 bool easy_open_door(POSITION y, POSITION x)
1236 cave_type *c_ptr = &cave[y][x];
1237 feature_type *f_ptr = &f_info[c_ptr->feat];
1239 /* Must be a closed door */
1240 if (!is_closed_door(c_ptr->feat))
1246 if (!have_flag(f_ptr->flags, FF_OPEN))
1249 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1254 else if (f_ptr->power)
1257 i = p_ptr->skill_dis;
1259 /* Penalize some conditions */
1260 if (p_ptr->blind || no_lite()) i = i / 10;
1261 if (p_ptr->confused || p_ptr->image) i = i / 10;
1263 /* Extract the lock power */
1266 /* Extract the difficulty */
1269 /* Always have a small chance of success */
1273 if (randint0(100) < j)
1275 msg_print(_("鍵をはずした。", "You have picked the lock."));
1278 cave_alter_feat(y, x, FF_OPEN);
1280 sound(SOUND_OPENDOOR);
1290 if (flush_failure) flush();
1292 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1301 cave_alter_feat(y, x, FF_OPEN);
1303 sound(SOUND_OPENDOOR);
1309 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1310 * Perform the basic "disarm" command
1311 * @param y 解除を行うマスのY座標
1312 * @param x 解除を行うマスのX座標
1313 * @param o_idx 箱のオブジェクトID
1314 * @return ターンを消費する処理が行われた場合TRUEを返す
1317 * Assume destination is a visible trap
1318 * Assume there is no monster blocking the destination
1319 * Returns TRUE if repeated commands may continue
1322 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1326 object_type *o_ptr = &o_list[o_idx];
1328 p_ptr->energy_use = 100;
1330 /* Get the "disarm" factor */
1331 i = p_ptr->skill_dis;
1333 /* Penalize some conditions */
1334 if (p_ptr->blind || no_lite()) i = i / 10;
1335 if (p_ptr->confused || p_ptr->image) i = i / 10;
1337 /* Extract the difficulty */
1338 j = i - o_ptr->pval;
1340 /* Always have a small chance of success */
1343 /* Must find the trap first. */
1344 if (!object_is_known(o_ptr))
1346 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1350 /* Already disarmed/unlocked */
1351 else if (o_ptr->pval <= 0)
1353 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1356 /* No traps to find. */
1357 else if (!chest_traps[o_ptr->pval])
1359 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1362 /* Success (get a lot of experience) */
1363 else if (randint0(100) < j)
1365 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1366 gain_exp(o_ptr->pval);
1367 o_ptr->pval = (0 - o_ptr->pval);
1370 /* Failure -- Keep trying */
1371 else if ((i > 5) && (randint1(i) > 5))
1373 /* We may keep trying */
1375 if (flush_failure) flush();
1376 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1379 /* Failure -- Set off the trap */
1382 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1384 chest_trap(y, x, o_idx);
1391 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1392 * Perform the basic "disarm" command
1393 * @param y 解除を行うマスのY座標
1394 * @param x 解除を行うマスのX座標
1395 * @param dir プレイヤーからみた方向ID
1396 * @return ターンを消費する処理が行われた場合TRUEを返す
1399 * Assume destination is a visible trap
1400 * Assume there is no monster blocking the destination
1401 * Returns TRUE if repeated commands may continue
1405 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1407 cave_type *c_ptr = &cave[y][x];
1410 feature_type *f_ptr = &f_info[c_ptr->feat];
1412 /* Access trap name */
1413 concptr name = (f_name + f_ptr->name);
1415 /* Extract trap "power" */
1416 int power = f_ptr->power;
1419 /* Get the "disarm" factor */
1420 int i = p_ptr->skill_dis;
1423 p_ptr->energy_use = 100;
1425 /* Penalize some conditions */
1426 if (p_ptr->blind || no_lite()) i = i / 10;
1427 if (p_ptr->confused || p_ptr->image) i = i / 10;
1429 /* Extract the difficulty */
1432 /* Always have a small chance of success */
1436 if (randint0(100) < j)
1438 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1443 /* Remove the trap */
1444 cave_alter_feat(y, x, FF_DISARM);
1446 /* Move the player onto the trap */
1447 move_player(dir, easy_disarm, FALSE);
1450 /* Failure -- Keep trying */
1451 else if ((i > 5) && (randint1(i) > 5))
1454 if (flush_failure) flush();
1456 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1458 /* We may keep trying */
1462 /* Failure -- Set off the trap */
1465 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1466 /* Move the player onto the trap */
1467 move_player(dir, easy_disarm, FALSE);
1474 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1475 * Disarms a trap, or chest
1478 void do_cmd_disarm(void)
1486 if (p_ptr->wild_mode) return;
1488 if (p_ptr->special_defense & KATA_MUSOU)
1490 set_action(ACTION_NONE);
1493 /* Option: Pick a direction */
1496 int num_traps, num_chests;
1498 /* Count visible traps */
1499 num_traps = count_dt(&y, &x, is_trap, TRUE);
1501 /* Count chests (trapped) */
1502 num_chests = count_chests(&y, &x, TRUE);
1504 /* See if only one target */
1505 if (num_traps || num_chests)
1507 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1508 if (!too_many) command_dir = coords_to_dir(y, x);
1513 /* Allow repeated command */
1516 /* Set repeat count */
1517 command_rep = command_arg - 1;
1518 p_ptr->redraw |= (PR_STATE);
1520 /* Cancel the arg */
1524 /* Get a direction (or abort) */
1525 if (get_rep_dir(&dir,TRUE))
1530 y = p_ptr->y + ddy[dir];
1531 x = p_ptr->x + ddx[dir];
1532 c_ptr = &cave[y][x];
1534 /* Feature code (applying "mimic" field) */
1535 feat = get_feat_mimic(c_ptr);
1537 /* Check for chests */
1538 o_idx = chest_check(y, x, TRUE);
1541 if (!is_trap(feat) && !o_idx)
1543 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1546 /* Monster in the way */
1547 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1549 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1558 more = do_cmd_disarm_chest(y, x, o_idx);
1564 more = do_cmd_disarm_aux(y, x, dir);
1568 /* Cancel repeat unless told not to */
1569 if (!more) disturb(FALSE, FALSE);
1574 * @brief 「打ち破る」動作コマンドのサブルーチン /
1575 * Perform the basic "bash" command
1576 * @param y 対象を行うマスのY座標
1577 * @param x 対象を行うマスのX座標
1578 * @param dir プレイヤーから見たターゲットの方角ID
1579 * @return 実際に処理が行われた場合TRUEを返す。
1582 * Assume destination is a closed/locked/jammed door
1583 * Assume there is no monster blocking the destination
1584 * Returns TRUE if repeated commands may continue
1587 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1590 cave_type *c_ptr = &cave[y][x];
1593 feature_type *f_ptr = &f_info[c_ptr->feat];
1595 /* Hack -- Bash power based on strength */
1596 /* (Ranges from 3 to 20 to 100 to 200) */
1597 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1599 /* Extract door power */
1600 int temp = f_ptr->power;
1604 concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1606 p_ptr->energy_use = 100;
1608 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1610 /* Compare bash power to door power */
1611 temp = (bash - (temp * 10));
1613 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1615 /* Hack -- always have a chance */
1616 if (temp < 1) temp = 1;
1618 /* Hack -- attempt to bash down the door */
1619 if (randint0(100) < temp)
1621 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1623 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1625 /* Break down the door */
1626 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1628 cave_alter_feat(y, x, FF_BASH);
1634 cave_alter_feat(y, x, FF_OPEN);
1637 /* Hack -- Fall through the door */
1638 move_player(dir, FALSE, FALSE);
1641 /* Saving throw against stun */
1642 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1645 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1647 /* Allow repeated bashing */
1651 /* High dexterity yields coolness */
1654 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1656 /* Hack -- Lose balance ala paralysis */
1657 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1664 * @brief 「打ち破る」動作コマンドのメインルーチン /
1665 * Bash open a door, success based on character strength
1669 * For a closed door, pval is positive if locked; negative if stuck.
1671 * For an open door, pval is positive for a broken door.
1673 * A closed door can be opened - harder if locked. Any door might be
1674 * bashed open (and thereby broken). Bashing a door is (potentially)
1675 * faster! You move into the door way. To open a stuck door, it must
1676 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1678 * Creatures can also open or bash doors, see elsewhere.
1681 void do_cmd_bash(void)
1687 if (p_ptr->wild_mode) return;
1689 if (p_ptr->special_defense & KATA_MUSOU)
1691 set_action(ACTION_NONE);
1694 /* Allow repeated command */
1697 /* Set repeat count */
1698 command_rep = command_arg - 1;
1699 p_ptr->redraw |= (PR_STATE);
1701 /* Cancel the arg */
1705 /* Get a "repeated" direction */
1706 if (get_rep_dir(&dir,FALSE))
1711 y = p_ptr->y + ddy[dir];
1712 x = p_ptr->x + ddx[dir];
1715 c_ptr = &cave[y][x];
1717 /* Feature code (applying "mimic" field) */
1718 feat = get_feat_mimic(c_ptr);
1720 /* Nothing useful */
1721 if (!have_flag(f_info[feat].flags, FF_BASH))
1723 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1726 /* Monster in the way */
1727 else if (c_ptr->m_idx)
1729 p_ptr->energy_use = 100;
1731 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1737 /* Bash a closed door */
1741 more = do_cmd_bash_aux(y, x, dir);
1745 /* Unless valid action taken, cancel bash */
1746 if (!more) disturb(FALSE, FALSE);
1751 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1755 * Manipulate an adjacent grid in some way
1757 * Attack monsters, tunnel through walls, disarm traps, open doors.
1759 * Consider confusion
1761 * This command must always take a turn, to prevent free detection
1762 * of invisible monsters.
1765 void do_cmd_alter(void)
1772 if (p_ptr->special_defense & KATA_MUSOU)
1774 set_action(ACTION_NONE);
1777 /* Allow repeated command */
1780 /* Set repeat count */
1781 command_rep = command_arg - 1;
1782 p_ptr->redraw |= (PR_STATE);
1784 /* Cancel the arg */
1788 /* Get a direction */
1789 if (get_rep_dir(&dir,TRUE))
1792 feature_type *f_ptr;
1794 y = p_ptr->y + ddy[dir];
1795 x = p_ptr->x + ddx[dir];
1798 c_ptr = &cave[y][x];
1800 /* Feature code (applying "mimic" field) */
1801 feat = get_feat_mimic(c_ptr);
1802 f_ptr = &f_info[feat];
1804 p_ptr->energy_use = 100;
1812 else if (have_flag(f_ptr->flags, FF_OPEN))
1814 more = do_cmd_open_aux(y, x);
1817 /* Bash jammed doors */
1818 else if (have_flag(f_ptr->flags, FF_BASH))
1820 more = do_cmd_bash_aux(y, x, dir);
1823 /* Tunnel through walls */
1824 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1826 more = do_cmd_tunnel_aux(y, x);
1829 /* Close open doors */
1830 else if (have_flag(f_ptr->flags, FF_CLOSE))
1832 more = do_cmd_close_aux(y, x);
1836 else if (have_flag(f_ptr->flags, FF_DISARM))
1838 more = do_cmd_disarm_aux(y, x, dir);
1843 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1847 /* Cancel repetition unless we can continue */
1848 if (!more) disturb(FALSE, FALSE);
1854 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1855 * Find the index of some "spikes", if possible.
1856 * @param ip くさびとして打てるオブジェクトのID
1857 * @return オブジェクトがある場合TRUEを返す
1860 * Let user choose a pile of spikes, perhaps?
1863 static bool get_spike(INVENTORY_IDX *ip)
1867 /* Check every item in the pack */
1868 for (i = 0; i < INVEN_PACK; i++)
1870 object_type *o_ptr = &inventory[i];
1872 /* Skip non-objects */
1873 if (!o_ptr->k_idx) continue;
1875 /* Check the "tval" code */
1876 if (o_ptr->tval == TV_SPIKE)
1878 /* Save the spike index */
1891 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1892 * Jam a closed door with a spike
1896 * This command may NOT be repeated
1899 void do_cmd_spike(void)
1903 if (p_ptr->wild_mode) return;
1905 if (p_ptr->special_defense & KATA_MUSOU)
1907 set_action(ACTION_NONE);
1910 /* Get a "repeated" direction */
1911 if (get_rep_dir(&dir, FALSE))
1918 y = p_ptr->y + ddy[dir];
1919 x = p_ptr->x + ddx[dir];
1920 c_ptr = &cave[y][x];
1922 /* Feature code (applying "mimic" field) */
1923 feat = get_feat_mimic(c_ptr);
1925 /* Require closed door */
1926 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1928 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1932 else if (!get_spike(&item))
1934 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1937 /* Is a monster in the way? */
1938 else if (c_ptr->m_idx)
1940 p_ptr->energy_use = 100;
1942 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1951 p_ptr->energy_use = 100;
1953 /* Successful jamming */
1954 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1955 cave_alter_feat(y, x, FF_SPIKE);
1957 /* Use up, and describe, a single spike, from the bottom */
1958 inven_item_increase(item, -1);
1959 inven_item_describe(item);
1960 inven_item_optimize(item);
1968 * @brief 「歩く」動作コマンドのメインルーチン /
1969 * Support code for the "Walk" and "Jump" commands
1970 * @param pickup アイテムの自動拾いを行うならTRUE
1973 void do_cmd_walk(bool pickup)
1980 /* Allow repeated command */
1983 /* Set repeat count */
1984 command_rep = command_arg - 1;
1985 p_ptr->redraw |= (PR_STATE);
1987 /* Cancel the arg */
1991 /* Get a "repeated" direction */
1992 if (get_rep_dir(&dir, FALSE))
1994 p_ptr->energy_use = 100;
1996 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
1998 set_action(ACTION_NONE);
2001 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2002 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2003 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2005 /* Actually move the character */
2006 move_player(dir, pickup, FALSE);
2008 /* Allow more walking */
2012 /* Hack again -- Is there a special encounter ??? */
2013 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2015 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2018 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2020 /* Inform the player of his horrible fate :=) */
2021 msg_print(_("襲撃だ!", "You are ambushed !"));
2023 /* Go into large wilderness view */
2024 p_ptr->oldpy = randint1(MAX_HGT-2);
2025 p_ptr->oldpx = randint1(MAX_WID-2);
2028 /* Give first move to monsters */
2029 p_ptr->energy_use = 100;
2031 /* HACk -- set the encouter flag for the wilderness generation */
2032 generate_encounter = TRUE;
2036 /* Cancel repeat unless we may continue */
2037 if (!more) disturb(FALSE, FALSE);
2042 * @brief 「走る」動作コマンドのメインルーチン /
2046 void do_cmd_run(void)
2050 /* Hack -- no running when confused */
2051 if (p_ptr->confused)
2053 msg_print(_("混乱していて走れない!", "You are too confused!"));
2057 if (p_ptr->special_defense & KATA_MUSOU)
2059 set_action(ACTION_NONE);
2062 /* Get a "repeated" direction */
2063 if (get_rep_dir(&dir,FALSE))
2065 /* Hack -- Set the run counter */
2066 running = (command_arg ? command_arg : 1000);
2075 * @brief 「留まる」動作コマンドのメインルーチン /
2076 * Stay still. Search. Enter stores.
2077 * Pick up treasure if "pickup" is true.
2078 * @param pickup アイテムの自動拾いを行うならTRUE
2081 void do_cmd_stay(bool pickup)
2083 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2085 /* Allow repeated command */
2088 /* Set repeat count */
2089 command_rep = command_arg - 1;
2090 p_ptr->redraw |= (PR_STATE);
2092 /* Cancel the arg */
2096 p_ptr->energy_use = 100;
2098 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2099 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2104 * @brief 「休む」動作コマンドのメインルーチン /
2105 * Resting allows a player to safely restore his hp -RAK-
2108 void do_cmd_rest(void)
2111 set_action(ACTION_NONE);
2113 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2119 if (hex_spelling_any()) stop_hex_spell_all();
2121 /* Prompt for time if needed */
2122 if (command_arg <= 0)
2124 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2125 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2131 strcpy(out_val, "&");
2133 /* Ask for duration */
2134 if (!get_string(p, out_val, 4)) return;
2136 /* Rest until done */
2137 if (out_val[0] == '&')
2139 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2143 else if (out_val[0] == '*')
2145 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2151 command_arg = (COMMAND_ARG)atoi(out_val);
2152 if (command_arg <= 0) return;
2158 if (command_arg > 9999) command_arg = 9999;
2160 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2162 /* Take a turn (?) */
2163 p_ptr->energy_use = 100;
2165 /* The sin of sloth */
2166 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2168 /* Why are you sleeping when there's no need? WAKE UP!*/
2169 if ((p_ptr->chp == p_ptr->mhp) &&
2170 (p_ptr->csp == p_ptr->msp) &&
2171 !p_ptr->blind && !p_ptr->confused &&
2172 !p_ptr->poisoned && !p_ptr->afraid &&
2173 !p_ptr->stun && !p_ptr->cut &&
2174 !p_ptr->slow && !p_ptr->paralyzed &&
2175 !p_ptr->image && !p_ptr->word_recall &&
2176 !p_ptr->alter_reality)
2177 chg_virtue(V_DILIGENCE, -1);
2179 /* Save the rest code */
2180 resting = command_arg;
2181 p_ptr->action = ACTION_REST;
2182 p_ptr->update |= (PU_BONUS);
2183 update_creature(p_ptr);
2185 p_ptr->redraw |= (PR_STATE);
2193 * @brief 矢弾を射撃した場合の破損確率を返す /
2194 * Determines the odds of an object breaking when thrown at a monster
2195 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2198 * Note that artifacts never break, see the "drop_near()" function.
2200 static PERCENTAGE breakage_chance(object_type *o_ptr)
2202 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2204 /* Examine the snipe type */
2207 if (snipe_type == SP_KILL_WALL) return (100);
2208 if (snipe_type == SP_EXPLODE) return (100);
2209 if (snipe_type == SP_PIERCE) return (100);
2210 if (snipe_type == SP_FINAL) return (100);
2211 if (snipe_type == SP_NEEDLE) return (100);
2212 if (snipe_type == SP_EVILNESS) return (40);
2213 if (snipe_type == SP_HOLYNESS) return (40);
2216 /* Examine the item type */
2217 switch (o_ptr->tval)
2233 /* Sometimes break */
2238 return (20 - archer_bonus * 2);
2243 return (10 - archer_bonus);
2251 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2252 * Determines the odds of an object breaking when thrown at a monster
2253 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2254 * @param tdam 計算途中のダメージ量
2255 * @param m_ptr 目標モンスターの構造体参照ポインタ
2256 * @return スレイ倍率をかけたダメージ量
2258 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2262 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2264 BIT_FLAGS flgs[TR_FLAG_SIZE];
2265 object_flags(o_ptr, flgs);
2267 /* Some "weapons" and "ammo" do extra damage */
2268 switch (o_ptr->tval)
2274 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2276 if (is_original_ap_and_seen(m_ptr))
2278 r_ptr->r_flags3 |= RF3_ANIMAL;
2280 if (mult < 17) mult = 17;
2283 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
2285 if (is_original_ap_and_seen(m_ptr))
2287 r_ptr->r_flags3 |= RF3_ANIMAL;
2289 if (mult < 27) mult = 27;
2292 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2294 if (is_original_ap_and_seen(m_ptr))
2296 r_ptr->r_flags3 |= RF3_EVIL;
2298 if (mult < 15) mult = 15;
2301 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
2303 if (is_original_ap_and_seen(m_ptr))
2305 r_ptr->r_flags3 |= RF3_EVIL;
2307 if (mult < 25) mult = 25;
2310 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2312 if (is_original_ap_and_seen(m_ptr))
2314 r_ptr->r_flags2 |= RF2_HUMAN;
2316 if (mult < 17) mult = 17;
2319 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
2321 if (is_original_ap_and_seen(m_ptr))
2323 r_ptr->r_flags2 |= RF2_HUMAN;
2325 if (mult < 27) mult = 27;
2328 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2330 if (is_original_ap_and_seen(m_ptr))
2332 r_ptr->r_flags3 |= RF3_UNDEAD;
2334 if (mult < 20) mult = 20;
2337 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
2339 if (is_original_ap_and_seen(m_ptr))
2341 r_ptr->r_flags3 |= RF3_UNDEAD;
2343 if (mult < 30) mult = 30;
2346 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2348 if (is_original_ap_and_seen(m_ptr))
2350 r_ptr->r_flags3 |= RF3_DEMON;
2352 if (mult < 20) mult = 20;
2355 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
2357 if (is_original_ap_and_seen(m_ptr))
2359 r_ptr->r_flags3 |= RF3_DEMON;
2361 if (mult < 30) mult = 30;
2364 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
2366 if (is_original_ap_and_seen(m_ptr))
2368 r_ptr->r_flags3 |= RF3_ORC;
2370 if (mult < 20) mult = 20;
2373 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
2375 if (is_original_ap_and_seen(m_ptr))
2377 r_ptr->r_flags3 |= RF3_ORC;
2379 if (mult < 30) mult = 30;
2382 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2384 if (is_original_ap_and_seen(m_ptr))
2386 r_ptr->r_flags3 |= RF3_TROLL;
2389 if (mult < 20) mult = 20;
2392 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
2394 if (is_original_ap_and_seen(m_ptr))
2396 r_ptr->r_flags3 |= RF3_TROLL;
2398 if (mult < 30) mult = 30;
2401 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2403 if (is_original_ap_and_seen(m_ptr))
2405 r_ptr->r_flags3 |= RF3_GIANT;
2407 if (mult < 20) mult = 20;
2410 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
2412 if (is_original_ap_and_seen(m_ptr))
2414 r_ptr->r_flags3 |= RF3_GIANT;
2416 if (mult < 30) mult = 30;
2419 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2421 if (is_original_ap_and_seen(m_ptr))
2423 r_ptr->r_flags3 |= RF3_DRAGON;
2425 if (mult < 20) mult = 20;
2428 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
2430 if (is_original_ap_and_seen(m_ptr))
2432 r_ptr->r_flags3 |= RF3_DRAGON;
2434 if (mult < 30) mult = 30;
2435 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
2436 (inventory[INVEN_BOW].name1 == ART_BARD))
2440 if (have_flag(flgs, TR_BRAND_ACID))
2442 /* Notice immunity */
2443 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2445 if (is_original_ap_and_seen(m_ptr))
2447 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2452 if (mult < 17) mult = 17;
2456 if (have_flag(flgs, TR_BRAND_ELEC))
2458 /* Notice immunity */
2459 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2461 if (is_original_ap_and_seen(m_ptr))
2463 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2468 if (mult < 17) mult = 17;
2472 if (have_flag(flgs, TR_BRAND_FIRE))
2474 /* Notice immunity */
2475 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2477 if (is_original_ap_and_seen(m_ptr))
2479 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2482 /* Otherwise, take the damage */
2485 if (r_ptr->flags3 & RF3_HURT_FIRE)
2487 if (mult < 25) mult = 25;
2488 if (is_original_ap_and_seen(m_ptr))
2490 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2493 else if (mult < 17) mult = 17;
2497 if (have_flag(flgs, TR_BRAND_COLD))
2499 /* Notice immunity */
2500 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2502 if (is_original_ap_and_seen(m_ptr))
2504 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2507 /* Otherwise, take the damage */
2510 if (r_ptr->flags3 & RF3_HURT_COLD)
2512 if (mult < 25) mult = 25;
2513 if (is_original_ap_and_seen(m_ptr))
2515 r_ptr->r_flags3 |= RF3_HURT_COLD;
2518 else if (mult < 17) mult = 17;
2522 if (have_flag(flgs, TR_BRAND_POIS))
2524 /* Notice immunity */
2525 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2527 if (is_original_ap_and_seen(m_ptr))
2529 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2532 /* Otherwise, take the damage */
2535 if (mult < 17) mult = 17;
2539 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2541 p_ptr->csp -= (1+(p_ptr->msp / 30));
2542 p_ptr->redraw |= (PR_MANA);
2543 mult = mult * 5 / 2;
2550 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2552 /* Return the total damage */
2553 return (tdam * mult / 10);
2558 * @brief 射撃処理のサブルーチン /
2559 * Fire an object from the pack or floor.
2560 * @param item 射撃するオブジェクトの所持ID
2561 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2565 * You may only fire items that "match" your missile launcher.
2567 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2569 * See "calc_bonuses()" for more calculations and such.
2571 * Note that "firing" a missile is MUCH better than "throwing" it.
2573 * Note: "unseen" monsters are very hard to hit.
2575 * Objects are more likely to break if they "attempt" to hit a monster.
2577 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2579 * The "extra shot" code works by decreasing the amount of energy
2580 * required to make each shot, spreading the shots out over time.
2582 * Note that when firing missiles, the launcher multiplier is applied
2583 * after all the bonuses are added in, making multipliers very useful.
2585 * Note that Bows of "Extra Might" get extra range and an extra bonus
2586 * for the damage multiplier.
2588 * Note that Bows of "Extra Shots" give an extra shot.
2591 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2595 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2596 int tdam_base, tdis, thits, tmul;
2598 int cur_dis, visible;
2606 bool hit_body = FALSE;
2608 GAME_TEXT o_name[MAX_NLEN];
2610 u16b path_g[512]; /* For calcuration of path length */
2612 int msec = delay_factor * delay_factor * delay_factor;
2615 bool stick_to = FALSE;
2617 /* Access the item (if in the pack) */
2620 o_ptr = &inventory[item];
2624 o_ptr = &o_list[0 - item];
2627 /* Sniper - Cannot shot a single arrow twice */
2628 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2630 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2632 /* Use the proper number of shots */
2633 thits = p_ptr->num_fire;
2635 /* Use a base distance */
2638 /* Base damage from thrown object plus launcher bonus */
2639 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2641 /* Actually "fire" the object */
2642 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2643 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2644 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2646 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2648 p_ptr->energy_use = bow_energy(j_ptr->sval);
2649 tmul = bow_tmul(j_ptr->sval);
2651 /* Get extra "power" from "extra might" */
2652 if (p_ptr->xtra_might) tmul++;
2654 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2656 /* Boost the damage */
2661 tdis = 13 + tmul/80;
2662 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2665 tdis -= (5 - (p_ptr->concent + 1) / 2);
2670 project_length = tdis + 1;
2672 /* Get a direction (or cancel) */
2673 if (!get_aim_dir(&dir))
2675 p_ptr->energy_use = 0;
2677 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2679 /* need not to reset project_length (already did)*/
2684 /* Predict the "target" location */
2685 tx = p_ptr->x + 99 * ddx[dir];
2686 ty = p_ptr->y + 99 * ddy[dir];
2688 /* Check for "target request" */
2689 if ((dir == 5) && target_okay())
2695 /* Get projection path length */
2696 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2698 project_length = 0; /* reset to default */
2700 /* Don't shoot at my feet */
2701 if (tx == p_ptr->x && ty == p_ptr->y)
2703 p_ptr->energy_use = 0;
2705 /* project_length is already reset to 0 */
2711 /* Take a (partial) turn */
2712 p_ptr->energy_use = (p_ptr->energy_use / thits);
2715 /* Sniper - Difficult to shot twice at 1 turn */
2716 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2718 /* Sniper - Repeat shooting when double shots */
2719 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2722 /* Start at the player */
2727 /* Obtain a local object */
2728 object_copy(q_ptr, o_ptr);
2733 /* Reduce and describe inventory */
2736 inven_item_increase(item, -1);
2737 inven_item_describe(item);
2738 inven_item_optimize(item);
2741 /* Reduce and describe floor item */
2744 floor_item_increase(0 - item, -1);
2745 floor_item_optimize(0 - item);
2751 /* Save the old location */
2755 /* The shot does not hit yet */
2758 /* Travel until stopped */
2759 for (cur_dis = 0; cur_dis <= tdis; )
2763 /* Hack -- Stop at the target */
2764 if ((y == ty) && (x == tx)) break;
2766 /* Calculate the new location (see "project()") */
2769 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2772 if (snipe_type == SP_KILL_WALL)
2774 c_ptr = &cave[ny][nx];
2776 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2778 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2779 /* Forget the wall */
2780 c_ptr->info &= ~(CAVE_MARK);
2781 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2783 /* Destroy the wall */
2784 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2791 /* Stopped by walls/doors */
2792 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2794 /* Advance the distance */
2798 if (snipe_type == SP_LITE)
2800 cave[ny][nx].info |= (CAVE_GLOW);
2805 /* The player can see the (on screen) missile */
2806 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2808 char c = object_char(q_ptr);
2809 byte a = object_attr(q_ptr);
2811 /* Draw, Hilite, Fresh, Pause, Erase */
2812 print_rel(c, a, ny, nx);
2813 move_cursor_relative(ny, nx);
2815 Term_xtra(TERM_XTRA_DELAY, msec);
2820 /* The player cannot see the missile */
2823 /* Pause anyway, for consistancy */
2824 Term_xtra(TERM_XTRA_DELAY, msec);
2828 if (snipe_type == SP_KILL_TRAP)
2830 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
2831 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
2835 if (snipe_type == SP_EVILNESS)
2837 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
2842 /* Save the old location */
2846 /* Save the new location */
2850 /* Monster here, Try to hit it */
2851 if (cave[y][x].m_idx)
2853 cave_type *c_mon_ptr = &cave[y][x];
2855 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
2856 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2858 /* Check the visibility */
2859 visible = m_ptr->ml;
2861 /* Note the collision */
2864 if (MON_CSLEEP(m_ptr))
2866 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
2867 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
2870 if ((r_ptr->level + 10) > p_ptr->lev)
2872 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
2873 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
2876 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
2877 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
2878 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
2879 else if (p_ptr->lev > 34) amount = 2;
2880 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
2881 p_ptr->update |= (PU_BONUS);
2887 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
2888 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
2891 p_ptr->skill_exp[GINOU_RIDING] += 1;
2892 p_ptr->update |= (PU_BONUS);
2896 /* Did we hit it (penalize range) */
2897 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2900 int tdam = tdam_base;
2902 /* Get extra damage from concentration */
2903 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
2905 /* Handle unseen monster */
2908 /* Invisible monster */
2909 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2912 /* Handle visible monster */
2915 GAME_TEXT m_name[MAX_NLEN];
2917 /* Get "the monster" or "it" */
2918 monster_desc(m_name, m_ptr, 0);
2920 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2924 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2925 health_track(c_mon_ptr->m_idx);
2929 if (snipe_type == SP_NEEDLE)
2931 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
2932 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
2934 GAME_TEXT m_name[MAX_NLEN];
2936 /* Get "the monster" or "it" */
2937 monster_desc(m_name, m_ptr, 0);
2939 tdam = m_ptr->hp + 1;
2940 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
2946 /* Apply special damage */
2947 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
2948 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
2950 /* No negative damage */
2951 if (tdam < 0) tdam = 0;
2953 /* Modify the damage */
2954 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2957 msg_format_wizard(CHEAT_MONSTER,
2958 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2959 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2962 if (snipe_type == SP_EXPLODE)
2964 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
2966 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
2967 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
2972 if (snipe_type == SP_HOLYNESS)
2974 cave[ny][nx].info |= (CAVE_GLOW);
2979 /* Hit the monster, check for death */
2980 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2989 if (object_is_fixed_artifact(q_ptr) &&
2990 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
2992 GAME_TEXT m_name[MAX_NLEN];
2994 monster_desc(m_name, m_ptr, 0);
2997 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3000 message_pain(c_mon_ptr->m_idx, tdam);
3002 /* Anger the monster */
3003 if (tdam > 0) anger_monster(m_ptr);
3005 if (fear && m_ptr->ml)
3007 GAME_TEXT m_name[MAX_NLEN];
3009 monster_desc(m_name, m_ptr, 0);
3010 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3013 set_target(m_ptr, p_ptr->y, p_ptr->x);
3016 if (snipe_type == SP_RUSH)
3018 int n = randint1(5) + 3;
3019 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3021 for ( ; cur_dis <= tdis; )
3028 /* Calculate the new location (see "project()") */
3029 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3031 /* Stopped by wilderness boundary */
3032 if (!in_bounds2(ny, nx)) break;
3034 /* Stopped by walls/doors */
3035 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3037 /* Stopped by monsters */
3038 if (!cave_empty_bold(ny, nx)) break;
3040 cave[ny][nx].m_idx = m_idx;
3041 cave[oy][ox].m_idx = 0;
3046 update_monster(c_mon_ptr->m_idx, TRUE);
3052 Term_xtra(TERM_XTRA_DELAY, msec);
3064 if (snipe_type == SP_PIERCE)
3066 if(p_ptr->concent < 1) break;
3076 /* Chance of breakage (during attacks) */
3077 j = (hit_body ? breakage_chance(q_ptr) : 0);
3081 MONSTER_IDX m_idx = cave[y][x].m_idx;
3082 monster_type *m_ptr = &m_list[m_idx];
3083 OBJECT_IDX o_idx = o_pop();
3087 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3088 if (object_is_fixed_artifact(q_ptr))
3090 a_info[j_ptr->name1].cur_num = 0;
3095 o_ptr = &o_list[o_idx];
3096 object_copy(o_ptr, q_ptr);
3099 o_ptr->marked &= OM_TOUCHED;
3101 /* Forget location */
3102 o_ptr->iy = o_ptr->ix = 0;
3104 /* Memorize monster */
3105 o_ptr->held_m_idx = m_idx;
3108 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3111 m_ptr->hold_o_idx = o_idx;
3113 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3115 /* Drop (or break) near that location */
3116 (void)drop_near(q_ptr, j, y, x);
3120 /* Drop (or break) near that location */
3121 (void)drop_near(q_ptr, j, prev_y, prev_x);
3124 /* Sniper - Repeat shooting when double shots */
3127 /* Sniper - Loose his/her concentration after any shot */
3128 if (p_ptr->concent) reset_concentration(FALSE);
3132 * @brief 射撃処理のメインルーチン
3135 void do_cmd_fire(void)
3138 object_type *j_ptr, *ammo_ptr;
3141 if(p_ptr->wild_mode) return;
3143 is_fired = FALSE; /* not fired yet */
3145 /* Get the "bow" (if any) */
3146 j_ptr = &inventory[INVEN_BOW];
3148 /* Require a launcher */
3151 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3156 if (j_ptr->sval == SV_CRIMSON)
3158 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3163 if (j_ptr->sval == SV_HARP)
3165 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3171 if (p_ptr->special_defense & KATA_MUSOU)
3173 set_action(ACTION_NONE);
3176 /* Require proper missile */
3177 item_tester_tval = p_ptr->tval_ammo;
3179 q = _("どれを撃ちますか? ", "Fire which item? ");
3180 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3183 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3191 do_cmd_fire_aux(item, j_ptr);
3193 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3195 /* Sniper actions after some shootings */
3196 if (snipe_type == SP_AWAY)
3198 teleport_player(10 + (p_ptr->concent * 2), 0L);
3200 if (snipe_type == SP_FINAL)
3202 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3203 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3204 (void)set_stun(p_ptr->stun + randint1(25));
3210 * @brief 投射処理メインルーチン /
3211 * Throw an object from the pack or floor.
3213 * @param boomerang ブーメラン処理ならばTRUE
3214 * @param shuriken 忍者の手裏剣処理ならばTRUE
3215 * @return ターンを消費した場合TRUEを返す
3218 * Note: "unseen" monsters are very hard to hit.
3220 * Should throwing a weapon do full damage? Should it allow the magic
3221 * to hit bonus of the weapon to have an effect? Should it ever cause
3222 * the item to be destroyed? Should it do any damage at all?
3225 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3230 POSITION y, x, ty, tx, prev_y, prev_x;
3231 POSITION ny[19], nx[19];
3232 int chance, tdam, tdis;
3233 int mul, div, dd, ds;
3234 int cur_dis, visible;
3241 bool hit_body = FALSE;
3242 bool hit_wall = FALSE;
3243 bool equiped_item = FALSE;
3244 bool return_when_thrown = FALSE;
3246 GAME_TEXT o_name[MAX_NLEN];
3248 int msec = delay_factor * delay_factor * delay_factor;
3250 BIT_FLAGS flgs[TR_FLAG_SIZE];
3252 bool come_back = FALSE;
3253 bool do_drop = TRUE;
3255 if (p_ptr->wild_mode) return FALSE;
3257 if (p_ptr->special_defense & KATA_MUSOU)
3259 set_action(ACTION_NONE);
3265 o_ptr = &inventory[item];
3269 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3271 item_tester_hook = item_tester_hook_boomerang;
3272 q = _("どの武器を投げますか? ", "Throw which item? ");
3273 s = _("投げる武器がない。", "You have nothing to throw.");
3274 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
3281 else if (buki_motteruka(INVEN_LARM))
3284 o_ptr = &inventory[item];
3289 o_ptr = &inventory[item];
3294 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3295 s = _("投げるアイテムがない。", "You have nothing to throw.");
3296 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
3304 /* Item is cursed */
3305 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3307 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3312 if (p_ptr->inside_arena && !boomerang)
3314 if (o_ptr->tval != TV_SPIKE)
3316 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3325 /* Obtain a local object */
3326 object_copy(q_ptr, o_ptr);
3328 /* Extract the thrown object's flags. */
3329 object_flags(q_ptr, flgs);
3330 torch_flags(q_ptr, flgs);
3332 /* Distribute the charges of rods/wands between the stacks */
3333 distribute_charges(o_ptr, q_ptr, 1);
3338 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3340 if (p_ptr->mighty_throw) mult += 3;
3342 /* Extract a "distance multiplier" */
3343 /* Changed for 'launcher' mutation */
3344 mul = 10 + 2 * (mult - 1);
3346 /* Enforce a minimum "weight" of one pound */
3347 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3348 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3350 /* Hack -- Distance -- Reward strength, penalize weight */
3351 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3353 /* Max distance of 10-18 */
3354 if (tdis > mul) tdis = mul;
3358 ty = randint0(101) - 50 + p_ptr->y;
3359 tx = randint0(101) - 50 + p_ptr->x;
3363 project_length = tdis + 1;
3365 /* Get a direction (or cancel) */
3366 if (!get_aim_dir(&dir)) return FALSE;
3368 /* Predict the "target" location */
3369 tx = p_ptr->x + 99 * ddx[dir];
3370 ty = p_ptr->y + 99 * ddy[dir];
3372 /* Check for "target request" */
3373 if ((dir == 5) && target_okay())
3379 project_length = 0; /* reset to default */
3382 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3383 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3384 return_when_thrown = TRUE;
3386 /* Reduce and describe inventory */
3389 inven_item_increase(item, -1);
3390 if (!return_when_thrown)
3391 inven_item_describe(item);
3392 inven_item_optimize(item);
3395 /* Reduce and describe floor item */
3398 floor_item_increase(0 - item, -1);
3399 floor_item_optimize(0 - item);
3401 if (item >= INVEN_RARM)
3403 equiped_item = TRUE;
3404 p_ptr->redraw |= (PR_EQUIPPY);
3407 p_ptr->energy_use = 100;
3409 /* Rogue and Ninja gets bonus */
3410 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3411 p_ptr->energy_use -= p_ptr->lev;
3413 /* Start at the player */
3419 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3420 else shuriken = FALSE;
3422 /* Chance of hitting */
3423 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3424 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3425 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3427 if (shuriken) chance *= 2;
3429 /* Save the old location */
3433 /* Travel until stopped */
3434 for (cur_dis = 0; cur_dis <= tdis; )
3436 /* Hack -- Stop at the target */
3437 if ((y == ty) && (x == tx)) break;
3439 /* Calculate the new location (see "project()") */
3442 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3444 /* Stopped by walls/doors */
3445 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3448 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3451 /* The player can see the (on screen) missile */
3452 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3454 SYMBOL_CODE c = object_char(q_ptr);
3455 TERM_COLOR a = object_attr(q_ptr);
3457 /* Draw, Hilite, Fresh, Pause, Erase */
3458 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3459 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3461 Term_xtra(TERM_XTRA_DELAY, msec);
3462 lite_spot(ny[cur_dis], nx[cur_dis]);
3466 /* The player cannot see the missile */
3469 /* Pause anyway, for consistancy */
3470 Term_xtra(TERM_XTRA_DELAY, msec);
3473 /* Save the old location */
3477 /* Save the new location */
3481 /* Advance the distance */
3484 /* Monster here, Try to hit it */
3485 if (cave[y][x].m_idx)
3487 cave_type *c_ptr = &cave[y][x];
3488 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3490 /* Check the visibility */
3491 visible = m_ptr->ml;
3493 /* Note the collision */
3496 /* Did we hit it (penalize range) */
3497 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3501 /* Handle unseen monster */
3504 /* Invisible monster */
3505 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3508 /* Handle visible monster */
3511 GAME_TEXT m_name[MAX_NLEN];
3512 monster_desc(m_name, m_ptr, 0);
3513 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3517 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3518 health_track(c_ptr->m_idx);
3522 /* Hack -- Base damage from thrown object */
3525 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3526 tdam = damroll(dd, ds);
3527 /* Apply special damage */
3528 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3529 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3530 if (q_ptr->to_d > 0)
3531 tdam += q_ptr->to_d;
3533 tdam += -q_ptr->to_d;
3537 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3538 tdam += p_ptr->to_d_m;
3540 else if (have_flag(flgs, TR_THROW))
3543 tdam += p_ptr->to_d_m;
3551 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3554 /* No negative damage */
3555 if (tdam < 0) tdam = 0;
3557 /* Modify the damage */
3558 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3560 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3561 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3563 /* Hit the monster, check for death */
3564 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
3572 message_pain(c_ptr->m_idx, tdam);
3574 /* Anger the monster */
3575 if ((tdam > 0) && !object_is_potion(q_ptr))
3576 anger_monster(m_ptr);
3578 if (fear && m_ptr->ml)
3581 GAME_TEXT m_name[MAX_NLEN];
3582 monster_desc(m_name, m_ptr, 0);
3583 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3593 /* decrease toach's fuel */
3594 if (hit_body) torch_lost_fuel(q_ptr);
3596 /* Chance of breakage (during attacks) */
3597 j = (hit_body ? breakage_chance(q_ptr) : 0);
3599 /* Figurines transform */
3600 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3604 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3605 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3606 else if (object_is_cursed(q_ptr))
3607 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3612 /* Potions smash open */
3613 if (object_is_potion(q_ptr))
3615 if (hit_body || hit_wall || (randint1(100) < j))
3617 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3619 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3621 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3623 /* ToDo (Robert): fix the invulnerability */
3624 if (cave[y][x].m_idx &&
3625 is_friendly(&m_list[cave[y][x].m_idx]) &&
3626 !MON_INVULNER(m_ptr))
3628 GAME_TEXT m_name[MAX_NLEN];
3629 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3630 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3631 set_hostile(&m_list[cave[y][x].m_idx]);
3642 if (return_when_thrown)
3644 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3645 char o2_name[MAX_NLEN];
3646 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3649 if (boomerang) back_chance += 4+randint1(5);
3650 if (super_boomerang) back_chance += 100;
3651 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3653 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3655 for (i = cur_dis - 1; i > 0; i--)
3657 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3659 char c = object_char(q_ptr);
3660 byte a = object_attr(q_ptr);
3662 /* Draw, Hilite, Fresh, Pause, Erase */
3663 print_rel(c, a, ny[i], nx[i]);
3664 move_cursor_relative(ny[i], nx[i]);
3666 Term_xtra(TERM_XTRA_DELAY, msec);
3667 lite_spot(ny[i], nx[i]);
3672 /* Pause anyway, for consistancy */
3673 Term_xtra(TERM_XTRA_DELAY, msec);
3676 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3678 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3685 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3689 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3697 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3703 if (item == INVEN_RARM || item == INVEN_LARM)
3705 /* Access the wield slot */
3706 o_ptr = &inventory[item];
3708 /* Wear the new stuff */
3709 object_copy(o_ptr, q_ptr);
3711 p_ptr->total_weight += q_ptr->weight;
3713 /* Increment the equip counter by hand */
3716 /* Recalculate torch */
3717 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
3718 p_ptr->window |= (PW_EQUIP);
3726 else if (equiped_item)
3734 if (cave_have_flag_bold(y, x, FF_PROJECT))
3736 (void)drop_near(q_ptr, j, y, x);
3740 (void)drop_near(q_ptr, j, prev_y, prev_x);
3750 * Hack: travel command
3752 #define TRAVEL_UNABLE 9999
3754 static int flow_head = 0;
3755 static int flow_tail = 0;
3756 static POSITION temp2_x[MAX_SHORT];
3757 static POSITION temp2_y[MAX_SHORT];
3760 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3763 void forget_travel_flow(void)
3766 /* Check the entire dungeon / Forget the old data */
3767 for (y = 0; y < cur_hgt; y++)
3769 for (x = 0; x < cur_wid; x++)
3772 travel.cost[y][x] = MAX_SHORT;
3775 travel.y = travel.x = 0;
3779 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
3784 static int travel_flow_cost(POSITION y, POSITION x)
3786 feature_type *f_ptr = &f_info[cave[y][x].feat];
3789 /* Avoid obstacles (ex. trees) */
3790 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
3793 if (have_flag(f_ptr->flags, FF_WATER))
3795 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
3799 if (have_flag(f_ptr->flags, FF_LAVA))
3802 if (!p_ptr->resist_fire) lava *= 2;
3803 if (!p_ptr->levitation) lava *= 2;
3804 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
3809 /* Detected traps and doors */
3810 if (cave[y][x].info & (CAVE_MARK))
3812 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
3813 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
3820 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
3824 * @param wall プレイヤーが壁の中にいるならばTRUE
3827 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
3829 cave_type *c_ptr = &cave[y][x];
3830 feature_type *f_ptr = &f_info[c_ptr->feat];
3831 int old_head = flow_head;
3833 int base_cost = (n % TRAVEL_UNABLE);
3834 int from_wall = (n / TRAVEL_UNABLE);
3837 /* Ignore out of bounds */
3838 if (!in_bounds(y, x)) return;
3840 /* Ignore unknown grid except in wilderness */
3841 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
3843 /* Ignore "walls" and "rubble" (include "secret doors") */
3844 if (have_flag(f_ptr->flags, FF_WALL) ||
3845 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3846 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
3847 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
3849 if (!wall || !from_wall) return;
3850 add_cost += TRAVEL_UNABLE;
3854 add_cost = travel_flow_cost(y, x);
3857 cost = base_cost + add_cost;
3859 /* Ignore lower cost entries */
3860 if (travel.cost[y][x] <= cost) return;
3862 /* Save the flow cost */
3863 travel.cost[y][x] = cost;
3865 /* Enqueue that entry */
3866 temp2_y[flow_head] = y;
3867 temp2_x[flow_head] = x;
3869 /* Advance the queue */
3870 if (++flow_head == MAX_SHORT) flow_head = 0;
3872 /* Hack -- notice overflow by forgetting new entry */
3873 if (flow_head == flow_tail) flow_head = old_head;
3879 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
3880 * @param ty 目標地点のY座標
3881 * @param tx 目標地点のX座標
3884 static void travel_flow(POSITION ty, POSITION tx)
3888 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
3890 /* Reset the "queue" */
3891 flow_head = flow_tail = 0;
3893 /* is player in the wall? */
3894 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
3896 /* Start at the target grid */
3897 travel_flow_aux(ty, tx, 0, wall);
3899 /* Now process the queue */
3900 while (flow_head != flow_tail)
3902 /* Extract the next entry */
3903 y = temp2_y[flow_tail];
3904 x = temp2_x[flow_tail];
3906 /* Forget that entry */
3907 if (++flow_tail == MAX_SHORT) flow_tail = 0;
3909 /* Ignore too far entries */
3910 //if (distance(ty, tx, y, x) > 100) continue;
3912 /* Add the "children" */
3913 for (d = 0; d < 8; d++)
3915 /* Add that child if "legal" */
3916 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
3920 /* Forget the flow info */
3921 flow_head = flow_tail = 0;
3925 * @brief トラベル処理のメインルーチン
3928 void do_cmd_travel(void)
3932 POSITION dx, dy, sx, sy;
3933 feature_type *f_ptr;
3935 if (travel.x != 0 && travel.y != 0 &&
3936 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
3941 else if (!tgt_pt(&x, &y)) return;
3943 if ((x == p_ptr->x) && (y == p_ptr->y))
3945 msg_print(_("すでにそこにいます!", "You are already there!!"));
3949 f_ptr = &f_info[cave[y][x].feat];
3951 if ((cave[y][x].info & CAVE_MARK) &&
3952 (have_flag(f_ptr->flags, FF_WALL) ||
3953 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3954 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
3956 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
3960 forget_travel_flow();
3966 /* Travel till 255 steps */
3972 /* Decides first direction */
3973 dx = abs(p_ptr->x - x);
3974 dy = abs(p_ptr->y - y);
3975 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
3976 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
3978 for (i = 1; i <= 9; i++)
3980 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;