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;
382 /* Redraw the state */
383 p_ptr->redraw |= (PR_STATE);
388 p_ptr->energy_use = 100;
396 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
397 * @param y 走査対象にしたいマスのY座標
398 * @param x 走査対象にしたいマスのX座標
399 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
400 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
402 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
404 cave_type *c_ptr = &cave[y][x];
405 OBJECT_IDX this_o_idx, next_o_idx = 0;
407 /* Scan all objects in the grid */
408 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
412 o_ptr = &o_list[this_o_idx];
413 next_o_idx = o_ptr->next_o_idx;
415 /* Skip unknown chests XXX XXX */
416 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
418 /* Check for non empty chest */
419 if ((o_ptr->tval == TV_CHEST) &&
420 (((!trapped) && (o_ptr->pval)) || /* non empty */
421 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
430 * @brief 箱を開けるコマンドのメインルーチン /
431 * Attempt to open the given chest at the given location
432 * @param y 箱の存在するマスのY座標
433 * @param x 箱の存在するマスのX座標
434 * @param o_idx 箱のオブジェクトID
435 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
437 * Assume there is no monster blocking the destination
439 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
444 object_type *o_ptr = &o_list[o_idx];
446 p_ptr->energy_use = 100;
448 /* Attempt to unlock it */
451 /* Assume locked, and thus not open */
454 /* Get the "disarm" factor */
455 i = p_ptr->skill_dis;
457 /* Penalize some conditions */
458 if (p_ptr->blind || no_lite()) i = i / 10;
459 if (p_ptr->confused || p_ptr->image) i = i / 10;
461 /* Extract the difficulty */
464 /* Always have a small chance of success */
467 /* Success -- May still have traps */
468 if (randint0(100) < j)
470 msg_print(_("鍵をはずした。", "You have picked the lock."));
475 /* Failure -- Keep trying */
478 /* We may continue repeating */
480 if (flush_failure) flush();
481 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
486 /* Allowed to open */
489 /* Apply chest traps, if any */
490 chest_trap(y, x, o_idx);
492 /* Let the Chest drop items */
493 chest_death(FALSE, y, x, o_idx);
499 * @brief 地形は開くものであって、かつ開かれているかを返す /
500 * Attempt to open the given chest at the given location
502 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
504 static bool is_open(IDX feat)
506 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
511 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
512 * Attempt to open the given chest at the given location
513 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
514 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
515 * @param test 地形条件を判定するための関数ポインタ
516 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
518 * @details Return the number of features around (or under) the character.
519 * Usually look for doors and floor traps.
521 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
523 int d, count, xx, yy;
525 /* Count how many matches */
528 /* Check around (and under) the character */
529 for (d = 0; d < 9; d++)
534 /* if not searching under player continue */
535 if ((d == 8) && !under) continue;
537 /* Extract adjacent (legal) location */
538 yy = p_ptr->y + ddy_ddd[d];
539 xx = p_ptr->x + ddx_ddd[d];
542 c_ptr = &cave[yy][xx];
544 /* Must have knowledge */
545 if (!(c_ptr->info & (CAVE_MARK))) continue;
547 /* Feature code (applying "mimic" field) */
548 feat = get_feat_mimic(c_ptr);
550 /* Not looking for this feature */
551 if (!((*test)(feat))) continue;
556 /* Remember the location. Only useful if only one match */
567 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
568 * Return the number of chests around (or under) the character.
569 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
570 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
571 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
574 * If requested, count only trapped chests.
576 static int count_chests(POSITION *y, POSITION *x, bool trapped)
583 /* Count how many matches */
586 /* Check around (and under) the character */
587 for (d = 0; d < 9; d++)
589 /* Extract adjacent (legal) location */
590 POSITION yy = p_ptr->y + ddy_ddd[d];
591 POSITION xx = p_ptr->x + ddx_ddd[d];
593 /* No (visible) chest is there */
594 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
596 /* Grab the object */
597 o_ptr = &o_list[o_idx];
600 if (o_ptr->pval == 0) continue;
602 /* No (known) traps here */
603 if (trapped && (!object_is_known(o_ptr) ||
604 !chest_traps[o_ptr->pval])) continue;
609 /* Remember the location. Only useful if only one match */
620 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
621 * Convert an adjacent location to a direction.
622 * @param y 方角を確認したY座標
623 * @param x 方角を確認したX座標
626 static DIRECTION coords_to_dir(POSITION y, POSITION x)
628 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
635 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
637 return d[dx + 1][dy + 1];
641 * @brief 「開ける」動作コマンドのサブルーチン /
642 * Perform the basic "open" command on doors
643 * @param y 対象を行うマスのY座標
644 * @param x 対象を行うマスのX座標
645 * @return 実際に処理が行われた場合TRUEを返す。
647 * Assume destination is a closed/locked/jammed door
648 * Assume there is no monster blocking the destination
649 * Returns TRUE if repeated commands may continue
651 static bool do_cmd_open_aux(POSITION y, POSITION x)
655 /* Get requested grid */
656 cave_type *c_ptr = &cave[y][x];
657 feature_type *f_ptr = &f_info[c_ptr->feat];
660 p_ptr->energy_use = 100;
662 /* Seeing true feature code (ignore mimic) */
665 if (!have_flag(f_ptr->flags, FF_OPEN))
668 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
672 else if (f_ptr->power)
675 i = p_ptr->skill_dis;
677 /* Penalize some conditions */
678 if (p_ptr->blind || no_lite()) i = i / 10;
679 if (p_ptr->confused || p_ptr->image) i = i / 10;
681 /* Extract the lock power */
684 /* Extract the difficulty */
687 /* Always have a small chance of success */
691 if (randint0(100) < j)
693 msg_print(_("鍵をはずした。", "You have picked the lock."));
696 cave_alter_feat(y, x, FF_OPEN);
698 sound(SOUND_OPENDOOR);
708 if (flush_failure) flush();
710 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
712 /* We may keep trying */
721 cave_alter_feat(y, x, FF_OPEN);
723 sound(SOUND_OPENDOOR);
729 * @brief 「開ける」コマンドのメインルーチン /
730 * Open a closed/locked/jammed door or a closed/locked chest.
733 * Unlocking a locked door/chest is worth one experience point.
735 void do_cmd_open(void)
743 if (p_ptr->special_defense & KATA_MUSOU)
745 set_action(ACTION_NONE);
748 /* Option: Pick a direction */
751 int num_doors, num_chests;
753 /* Count closed doors (locked or jammed) */
754 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
756 /* Count chests (locked) */
757 num_chests = count_chests(&y, &x, FALSE);
759 /* See if only one target */
760 if (num_doors || num_chests)
762 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
764 if (!too_many) command_dir = coords_to_dir(y, x);
768 /* Allow repeated command */
771 /* Set repeat count */
772 command_rep = command_arg - 1;
774 /* Redraw the state */
775 p_ptr->redraw |= (PR_STATE);
781 /* Get a "repeated" direction */
782 if (get_rep_dir(&dir, TRUE))
787 /* Get requested location */
788 y = p_ptr->y + ddy[dir];
789 x = p_ptr->x + ddx[dir];
791 /* Get requested grid */
794 /* Feature code (applying "mimic" field) */
795 feat = get_feat_mimic(c_ptr);
797 /* Check for chest */
798 o_idx = chest_check(y, x, FALSE);
801 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
803 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
806 /* Monster in the way */
807 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
809 p_ptr->energy_use = 100;
810 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
818 more = do_cmd_open_chest(y, x, o_idx);
825 more = do_cmd_open_aux(y, x);
829 /* Cancel repeat unless we may continue */
830 if (!more) disturb(FALSE, FALSE);
836 * @brief 「閉じる」動作コマンドのサブルーチン /
837 * Perform the basic "close" command
838 * @param y 対象を行うマスのY座標
839 * @param x 対象を行うマスのX座標
840 * @return 実際に処理が行われた場合TRUEを返す。
842 * Assume destination is an open/broken door
843 * Assume there is no monster blocking the destination
844 * Returns TRUE if repeated commands may continue
846 static bool do_cmd_close_aux(POSITION y, POSITION x)
848 cave_type *c_ptr = &cave[y][x];
849 FEAT_IDX old_feat = c_ptr->feat;
852 p_ptr->energy_use = 100;
854 /* Seeing true feature code (ignore mimic) */
857 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
859 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
861 /* Hack -- object in the way */
862 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
863 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
865 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
870 cave_alter_feat(y, x, FF_CLOSE);
873 if (old_feat == c_ptr->feat)
875 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
879 sound(SOUND_SHUTDOOR);
888 * @brief 「閉じる」コマンドのメインルーチン /
889 * Close an open door.
892 * Unlocking a locked door/chest is worth one experience point.
894 void do_cmd_close(void)
901 if (p_ptr->special_defense & KATA_MUSOU)
903 set_action(ACTION_NONE);
906 /* Option: Pick a direction */
909 /* Count open doors */
910 if (count_dt(&y, &x, is_open, FALSE) == 1)
912 command_dir = coords_to_dir(y, x);
916 /* Allow repeated command */
919 /* Set repeat count */
920 command_rep = command_arg - 1;
922 /* Redraw the state */
923 p_ptr->redraw |= (PR_STATE);
929 /* Get a "repeated" direction */
930 if (get_rep_dir(&dir, FALSE))
935 y = p_ptr->y + ddy[dir];
936 x = p_ptr->x + ddx[dir];
939 /* Feature code (applying "mimic" field) */
940 feat = get_feat_mimic(c_ptr);
942 /* Require open/broken door */
943 if (!have_flag(f_info[feat].flags, FF_CLOSE))
945 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
948 /* Monster in the way */
949 else if (c_ptr->m_idx)
951 p_ptr->energy_use = 100;
953 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
963 more = do_cmd_close_aux(y, x);
967 /* Cancel repeat unless we may continue */
968 if (!more) disturb(FALSE, FALSE);
973 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
974 * Determine if a given grid may be "tunneled"
975 * @param y 対象を行うマスのY座標
976 * @param x 対象を行うマスのX座標
979 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
981 cave_type *c_ptr = &cave[y][x];
983 /* Must have knowledge */
984 if (!(c_ptr->info & CAVE_MARK))
986 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
991 /* Must be a wall/door/etc */
992 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
994 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1004 * @brief 「掘る」動作コマンドのサブルーチン /
1005 * Perform the basic "tunnel" command
1006 * @param y 対象を行うマスのY座標
1007 * @param x 対象を行うマスのX座標
1008 * @return 実際に処理が行われた場合TRUEを返す。
1010 * Assumes that no monster is blocking the destination
1011 * Do not use twall anymore
1012 * Returns TRUE if repeated commands may continue
1014 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1017 feature_type *f_ptr, *mimic_f_ptr;
1022 /* Verify legality */
1023 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1025 p_ptr->energy_use = 100;
1028 c_ptr = &cave[y][x];
1029 f_ptr = &f_info[c_ptr->feat];
1030 power = f_ptr->power;
1032 /* Feature code (applying "mimic" field) */
1033 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1035 name = f_name + mimic_f_ptr->name;
1039 if (have_flag(f_ptr->flags, FF_PERMANENT))
1042 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1044 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1047 /* Map border (mimiccing Permanent wall) */
1050 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1055 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1058 if (p_ptr->skill_dig > randint0(20 * power))
1060 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1062 /* Remove the feature */
1063 cave_alter_feat(y, x, FF_TUNNEL);
1065 /* Update some things */
1066 p_ptr->update |= (PU_FLOW);
1070 /* Message, keep digging */
1071 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1079 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1082 if (p_ptr->skill_dig > power + randint0(40 * power))
1084 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1087 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1088 p_ptr->update |= (PU_FLOW);
1091 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1093 /* Remove the feature */
1094 cave_alter_feat(y, x, FF_TUNNEL);
1096 chg_virtue(V_DILIGENCE, 1);
1097 chg_virtue(V_NATURE, -1);
1105 /* We may continue chopping */
1106 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1107 /* Occasional Search XXX XXX */
1108 if (randint0(100) < 25) search();
1112 /* We may continue tunelling */
1113 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1120 if (is_hidden_door(c_ptr))
1122 /* Occasional Search XXX XXX */
1123 if (randint0(100) < 25) search();
1130 * @brief 「掘る」動作コマンドのメインルーチン /
1131 * Tunnels through "walls" (including rubble and closed doors)
1135 * Note that you must tunnel in order to hit invisible monsters
1136 * in walls, though moving into walls still takes a turn anyway.
1138 * Digging is very difficult without a "digger" weapon, but can be
1139 * accomplished by strong players using heavy weapons.
1142 void do_cmd_tunnel(void)
1152 if (p_ptr->special_defense & KATA_MUSOU)
1154 set_action(ACTION_NONE);
1157 /* Allow repeated command */
1160 /* Set repeat count */
1161 command_rep = command_arg - 1;
1163 /* Redraw the state */
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 cptr 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->special_defense & KATA_MUSOU)
1488 set_action(ACTION_NONE);
1492 /* Option: Pick a direction */
1495 int num_traps, num_chests;
1497 /* Count visible traps */
1498 num_traps = count_dt(&y, &x, is_trap, TRUE);
1500 /* Count chests (trapped) */
1501 num_chests = count_chests(&y, &x, TRUE);
1503 /* See if only one target */
1504 if (num_traps || num_chests)
1506 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1507 if (!too_many) command_dir = coords_to_dir(y, x);
1512 /* Allow repeated command */
1515 /* Set repeat count */
1516 command_rep = command_arg - 1;
1518 /* Redraw the state */
1519 p_ptr->redraw |= (PR_STATE);
1521 /* Cancel the arg */
1525 /* Get a direction (or abort) */
1526 if (get_rep_dir(&dir,TRUE))
1531 y = p_ptr->y + ddy[dir];
1532 x = p_ptr->x + ddx[dir];
1533 c_ptr = &cave[y][x];
1535 /* Feature code (applying "mimic" field) */
1536 feat = get_feat_mimic(c_ptr);
1538 /* Check for chests */
1539 o_idx = chest_check(y, x, TRUE);
1542 if (!is_trap(feat) && !o_idx)
1544 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1547 /* Monster in the way */
1548 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1550 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1559 /* Disarm the chest */
1560 more = do_cmd_disarm_chest(y, x, o_idx);
1566 /* Disarm the trap */
1567 more = do_cmd_disarm_aux(y, x, dir);
1571 /* Cancel repeat unless told not to */
1572 if (!more) disturb(FALSE, FALSE);
1577 * @brief 「打ち破る」動作コマンドのサブルーチン /
1578 * Perform the basic "bash" command
1579 * @param y 対象を行うマスのY座標
1580 * @param x 対象を行うマスのX座標
1581 * @param dir プレイヤーから見たターゲットの方角ID
1582 * @return 実際に処理が行われた場合TRUEを返す。
1585 * Assume destination is a closed/locked/jammed door
1586 * Assume there is no monster blocking the destination
1587 * Returns TRUE if repeated commands may continue
1590 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1593 cave_type *c_ptr = &cave[y][x];
1596 feature_type *f_ptr = &f_info[c_ptr->feat];
1598 /* Hack -- Bash power based on strength */
1599 /* (Ranges from 3 to 20 to 100 to 200) */
1600 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1602 /* Extract door power */
1603 int temp = f_ptr->power;
1607 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1609 p_ptr->energy_use = 100;
1611 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1613 /* Compare bash power to door power */
1614 temp = (bash - (temp * 10));
1616 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1618 /* Hack -- always have a chance */
1619 if (temp < 1) temp = 1;
1621 /* Hack -- attempt to bash down the door */
1622 if (randint0(100) < temp)
1624 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1626 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1628 /* Break down the door */
1629 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1631 cave_alter_feat(y, x, FF_BASH);
1637 cave_alter_feat(y, x, FF_OPEN);
1640 /* Hack -- Fall through the door */
1641 move_player(dir, FALSE, FALSE);
1644 /* Saving throw against stun */
1645 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1648 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1650 /* Allow repeated bashing */
1654 /* High dexterity yields coolness */
1657 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1659 /* Hack -- Lose balance ala paralysis */
1660 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1667 * @brief 「打ち破る」動作コマンドのメインルーチン /
1668 * Bash open a door, success based on character strength
1672 * For a closed door, pval is positive if locked; negative if stuck.
1674 * For an open door, pval is positive for a broken door.
1676 * A closed door can be opened - harder if locked. Any door might be
1677 * bashed open (and thereby broken). Bashing a door is (potentially)
1678 * faster! You move into the door way. To open a stuck door, it must
1679 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1681 * Creatures can also open or bash doors, see elsewhere.
1684 void do_cmd_bash(void)
1693 if (p_ptr->special_defense & KATA_MUSOU)
1695 set_action(ACTION_NONE);
1698 /* Allow repeated command */
1701 /* Set repeat count */
1702 command_rep = command_arg - 1;
1704 /* Redraw the state */
1705 p_ptr->redraw |= (PR_STATE);
1707 /* Cancel the arg */
1711 /* Get a "repeated" direction */
1712 if (get_rep_dir(&dir,FALSE))
1717 y = p_ptr->y + ddy[dir];
1718 x = p_ptr->x + ddx[dir];
1721 c_ptr = &cave[y][x];
1723 /* Feature code (applying "mimic" field) */
1724 feat = get_feat_mimic(c_ptr);
1726 /* Nothing useful */
1727 if (!have_flag(f_info[feat].flags, FF_BASH))
1729 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1732 /* Monster in the way */
1733 else if (c_ptr->m_idx)
1735 p_ptr->energy_use = 100;
1737 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1743 /* Bash a closed door */
1747 more = do_cmd_bash_aux(y, x, dir);
1751 /* Unless valid action taken, cancel bash */
1752 if (!more) disturb(FALSE, FALSE);
1757 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1761 * Manipulate an adjacent grid in some way
1763 * Attack monsters, tunnel through walls, disarm traps, open doors.
1765 * Consider confusion
1767 * This command must always take a turn, to prevent free detection
1768 * of invisible monsters.
1771 void do_cmd_alter(void)
1778 if (p_ptr->special_defense & KATA_MUSOU)
1780 set_action(ACTION_NONE);
1783 /* Allow repeated command */
1786 /* Set repeat count */
1787 command_rep = command_arg - 1;
1789 /* Redraw the state */
1790 p_ptr->redraw |= (PR_STATE);
1792 /* Cancel the arg */
1796 /* Get a direction */
1797 if (get_rep_dir(&dir,TRUE))
1800 feature_type *f_ptr;
1802 y = p_ptr->y + ddy[dir];
1803 x = p_ptr->x + ddx[dir];
1806 c_ptr = &cave[y][x];
1808 /* Feature code (applying "mimic" field) */
1809 feat = get_feat_mimic(c_ptr);
1810 f_ptr = &f_info[feat];
1812 p_ptr->energy_use = 100;
1820 else if (have_flag(f_ptr->flags, FF_OPEN))
1822 more = do_cmd_open_aux(y, x);
1825 /* Bash jammed doors */
1826 else if (have_flag(f_ptr->flags, FF_BASH))
1828 more = do_cmd_bash_aux(y, x, dir);
1831 /* Tunnel through walls */
1832 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1834 more = do_cmd_tunnel_aux(y, x);
1837 /* Close open doors */
1838 else if (have_flag(f_ptr->flags, FF_CLOSE))
1840 more = do_cmd_close_aux(y, x);
1844 else if (have_flag(f_ptr->flags, FF_DISARM))
1846 more = do_cmd_disarm_aux(y, x, dir);
1851 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1855 /* Cancel repetition unless we can continue */
1856 if (!more) disturb(FALSE, FALSE);
1862 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1863 * Find the index of some "spikes", if possible.
1864 * @param ip くさびとして打てるオブジェクトのID
1865 * @return オブジェクトがある場合TRUEを返す
1868 * Let user choose a pile of spikes, perhaps?
1871 static bool get_spike(INVENTORY_IDX *ip)
1875 /* Check every item in the pack */
1876 for (i = 0; i < INVEN_PACK; i++)
1878 object_type *o_ptr = &inventory[i];
1880 /* Skip non-objects */
1881 if (!o_ptr->k_idx) continue;
1883 /* Check the "tval" code */
1884 if (o_ptr->tval == TV_SPIKE)
1886 /* Save the spike index */
1899 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1900 * Jam a closed door with a spike
1904 * This command may NOT be repeated
1907 void do_cmd_spike(void)
1911 if (p_ptr->special_defense & KATA_MUSOU)
1913 set_action(ACTION_NONE);
1916 /* Get a "repeated" direction */
1917 if (get_rep_dir(&dir,FALSE))
1924 y = p_ptr->y + ddy[dir];
1925 x = p_ptr->x + ddx[dir];
1926 c_ptr = &cave[y][x];
1928 /* Feature code (applying "mimic" field) */
1929 feat = get_feat_mimic(c_ptr);
1931 /* Require closed door */
1932 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1934 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1938 else if (!get_spike(&item))
1940 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1943 /* Is a monster in the way? */
1944 else if (c_ptr->m_idx)
1946 p_ptr->energy_use = 100;
1948 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1957 p_ptr->energy_use = 100;
1959 /* Successful jamming */
1960 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1961 cave_alter_feat(y, x, FF_SPIKE);
1963 /* Use up, and describe, a single spike, from the bottom */
1964 inven_item_increase(item, -1);
1965 inven_item_describe(item);
1966 inven_item_optimize(item);
1974 * @brief 「歩く」動作コマンドのメインルーチン /
1975 * Support code for the "Walk" and "Jump" commands
1976 * @param pickup アイテムの自動拾いを行うならTRUE
1979 void do_cmd_walk(bool pickup)
1986 /* Allow repeated command */
1989 /* Set repeat count */
1990 command_rep = command_arg - 1;
1992 /* Redraw the state */
1993 p_ptr->redraw |= (PR_STATE);
1995 /* Cancel the arg */
1999 /* Get a "repeated" direction */
2000 if (get_rep_dir(&dir, FALSE))
2002 p_ptr->energy_use = 100;
2004 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2006 set_action(ACTION_NONE);
2009 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2010 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2011 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2013 /* Actually move the character */
2014 move_player(dir, pickup, FALSE);
2016 /* Allow more walking */
2020 /* Hack again -- Is there a special encounter ??? */
2021 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2023 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2026 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2028 /* Inform the player of his horrible fate :=) */
2029 msg_print(_("襲撃だ!", "You are ambushed !"));
2031 /* Go into large wilderness view */
2032 p_ptr->oldpy = randint1(MAX_HGT-2);
2033 p_ptr->oldpx = randint1(MAX_WID-2);
2036 /* Give first move to monsters */
2037 p_ptr->energy_use = 100;
2039 /* HACk -- set the encouter flag for the wilderness generation */
2040 generate_encounter = TRUE;
2044 /* Cancel repeat unless we may continue */
2045 if (!more) disturb(FALSE, FALSE);
2050 * @brief 「走る」動作コマンドのメインルーチン /
2054 void do_cmd_run(void)
2058 /* Hack -- no running when confused */
2059 if (p_ptr->confused)
2061 msg_print(_("混乱していて走れない!", "You are too confused!"));
2065 if (p_ptr->special_defense & KATA_MUSOU)
2067 set_action(ACTION_NONE);
2070 /* Get a "repeated" direction */
2071 if (get_rep_dir(&dir,FALSE))
2073 /* Hack -- Set the run counter */
2074 running = (command_arg ? command_arg : 1000);
2083 * @brief 「留まる」動作コマンドのメインルーチン /
2084 * Stay still. Search. Enter stores.
2085 * Pick up treasure if "pickup" is true.
2086 * @param pickup アイテムの自動拾いを行うならTRUE
2089 void do_cmd_stay(bool pickup)
2091 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2093 /* Allow repeated command */
2096 /* Set repeat count */
2097 command_rep = command_arg - 1;
2099 /* Redraw the state */
2100 p_ptr->redraw |= (PR_STATE);
2102 /* Cancel the arg */
2106 p_ptr->energy_use = 100;
2108 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2109 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2114 * @brief 「休む」動作コマンドのメインルーチン /
2115 * Resting allows a player to safely restore his hp -RAK-
2118 void do_cmd_rest(void)
2121 set_action(ACTION_NONE);
2123 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2129 if (hex_spelling_any()) stop_hex_spell_all();
2131 /* Prompt for time if needed */
2132 if (command_arg <= 0)
2134 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2135 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2141 strcpy(out_val, "&");
2143 /* Ask for duration */
2144 if (!get_string(p, out_val, 4)) return;
2146 /* Rest until done */
2147 if (out_val[0] == '&')
2149 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2153 else if (out_val[0] == '*')
2155 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2161 command_arg = (COMMAND_ARG)atoi(out_val);
2162 if (command_arg <= 0) return;
2168 if (command_arg > 9999) command_arg = 9999;
2170 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2172 /* Take a turn (?) */
2173 p_ptr->energy_use = 100;
2175 /* The sin of sloth */
2176 if (command_arg > 100)
2177 chg_virtue(V_DILIGENCE, -1);
2179 /* Why are you sleeping when there's no need? WAKE UP!*/
2180 if ((p_ptr->chp == p_ptr->mhp) &&
2181 (p_ptr->csp == p_ptr->msp) &&
2182 !p_ptr->blind && !p_ptr->confused &&
2183 !p_ptr->poisoned && !p_ptr->afraid &&
2184 !p_ptr->stun && !p_ptr->cut &&
2185 !p_ptr->slow && !p_ptr->paralyzed &&
2186 !p_ptr->image && !p_ptr->word_recall &&
2187 !p_ptr->alter_reality)
2188 chg_virtue(V_DILIGENCE, -1);
2190 /* Save the rest code */
2191 resting = command_arg;
2192 p_ptr->action = ACTION_REST;
2194 /* Recalculate bonuses */
2195 p_ptr->update |= (PU_BONUS);
2197 /* Redraw the state */
2198 p_ptr->redraw |= (PR_STATE);
2207 * @brief 矢弾を射撃した場合の破損確率を返す /
2208 * Determines the odds of an object breaking when thrown at a monster
2209 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2212 * Note that artifacts never break, see the "drop_near()" function.
2214 static PERCENTAGE breakage_chance(object_type *o_ptr)
2216 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2218 /* Examine the snipe type */
2221 if (snipe_type == SP_KILL_WALL) return (100);
2222 if (snipe_type == SP_EXPLODE) return (100);
2223 if (snipe_type == SP_PIERCE) return (100);
2224 if (snipe_type == SP_FINAL) return (100);
2225 if (snipe_type == SP_NEEDLE) return (100);
2226 if (snipe_type == SP_EVILNESS) return (40);
2227 if (snipe_type == SP_HOLYNESS) return (40);
2230 /* Examine the item type */
2231 switch (o_ptr->tval)
2247 /* Sometimes break */
2252 return (20 - archer_bonus * 2);
2257 return (10 - archer_bonus);
2265 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2266 * Determines the odds of an object breaking when thrown at a monster
2267 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2268 * @param tdam 計算途中のダメージ量
2269 * @param m_ptr 目標モンスターの構造体参照ポインタ
2270 * @return スレイ倍率をかけたダメージ量
2272 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2276 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2278 BIT_FLAGS flgs[TR_FLAG_SIZE];
2280 /* Extract the flags */
2281 object_flags(o_ptr, flgs);
2283 /* Some "weapons" and "ammo" do extra damage */
2284 switch (o_ptr->tval)
2291 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2292 (r_ptr->flags3 & RF3_ANIMAL))
2294 if (is_original_ap_and_seen(m_ptr))
2296 r_ptr->r_flags3 |= RF3_ANIMAL;
2299 if (mult < 17) mult = 17;
2303 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2304 (r_ptr->flags3 & RF3_ANIMAL))
2306 if (is_original_ap_and_seen(m_ptr))
2308 r_ptr->r_flags3 |= RF3_ANIMAL;
2311 if (mult < 27) mult = 27;
2315 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2316 (r_ptr->flags3 & RF3_EVIL))
2318 if (is_original_ap_and_seen(m_ptr))
2320 r_ptr->r_flags3 |= RF3_EVIL;
2323 if (mult < 15) mult = 15;
2327 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2328 (r_ptr->flags3 & RF3_EVIL))
2330 if (is_original_ap_and_seen(m_ptr))
2332 r_ptr->r_flags3 |= RF3_EVIL;
2335 if (mult < 25) mult = 25;
2339 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2340 (r_ptr->flags2 & RF2_HUMAN))
2342 if (is_original_ap_and_seen(m_ptr))
2344 r_ptr->r_flags2 |= RF2_HUMAN;
2347 if (mult < 17) mult = 17;
2351 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2352 (r_ptr->flags2 & RF2_HUMAN))
2354 if (is_original_ap_and_seen(m_ptr))
2356 r_ptr->r_flags2 |= RF2_HUMAN;
2359 if (mult < 27) mult = 27;
2363 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2364 (r_ptr->flags3 & RF3_UNDEAD))
2366 if (is_original_ap_and_seen(m_ptr))
2368 r_ptr->r_flags3 |= RF3_UNDEAD;
2371 if (mult < 20) mult = 20;
2375 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2376 (r_ptr->flags3 & RF3_UNDEAD))
2378 if (is_original_ap_and_seen(m_ptr))
2380 r_ptr->r_flags3 |= RF3_UNDEAD;
2383 if (mult < 30) mult = 30;
2387 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2388 (r_ptr->flags3 & RF3_DEMON))
2390 if (is_original_ap_and_seen(m_ptr))
2392 r_ptr->r_flags3 |= RF3_DEMON;
2395 if (mult < 20) mult = 20;
2399 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2400 (r_ptr->flags3 & RF3_DEMON))
2402 if (is_original_ap_and_seen(m_ptr))
2404 r_ptr->r_flags3 |= RF3_DEMON;
2407 if (mult < 30) mult = 30;
2411 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2412 (r_ptr->flags3 & RF3_ORC))
2414 if (is_original_ap_and_seen(m_ptr))
2416 r_ptr->r_flags3 |= RF3_ORC;
2419 if (mult < 20) mult = 20;
2423 if ((have_flag(flgs, TR_KILL_ORC)) &&
2424 (r_ptr->flags3 & RF3_ORC))
2426 if (is_original_ap_and_seen(m_ptr))
2428 r_ptr->r_flags3 |= RF3_ORC;
2431 if (mult < 30) mult = 30;
2435 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2436 (r_ptr->flags3 & RF3_TROLL))
2438 if (is_original_ap_and_seen(m_ptr))
2440 r_ptr->r_flags3 |= RF3_TROLL;
2443 if (mult < 20) mult = 20;
2447 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2448 (r_ptr->flags3 & RF3_TROLL))
2450 if (is_original_ap_and_seen(m_ptr))
2452 r_ptr->r_flags3 |= RF3_TROLL;
2455 if (mult < 30) mult = 30;
2459 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2460 (r_ptr->flags3 & RF3_GIANT))
2462 if (is_original_ap_and_seen(m_ptr))
2464 r_ptr->r_flags3 |= RF3_GIANT;
2467 if (mult < 20) mult = 20;
2471 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2472 (r_ptr->flags3 & RF3_GIANT))
2474 if (is_original_ap_and_seen(m_ptr))
2476 r_ptr->r_flags3 |= RF3_GIANT;
2479 if (mult < 30) mult = 30;
2483 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
2484 (r_ptr->flags3 & RF3_DRAGON))
2486 if (is_original_ap_and_seen(m_ptr))
2488 r_ptr->r_flags3 |= RF3_DRAGON;
2491 if (mult < 20) mult = 20;
2494 /* Execute Dragon */
2495 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
2496 (r_ptr->flags3 & RF3_DRAGON))
2498 if (is_original_ap_and_seen(m_ptr))
2500 r_ptr->r_flags3 |= RF3_DRAGON;
2503 if (mult < 30) mult = 30;
2505 if ((o_ptr->name1 == ART_BARD_ARROW) &&
2506 (m_ptr->r_idx == MON_SMAUG) &&
2507 (inventory[INVEN_BOW].name1 == ART_BARD))
2512 if (have_flag(flgs, TR_BRAND_ACID))
2514 /* Notice immunity */
2515 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2517 if (is_original_ap_and_seen(m_ptr))
2519 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2523 /* Otherwise, take the damage */
2526 if (mult < 17) mult = 17;
2531 if (have_flag(flgs, TR_BRAND_ELEC))
2533 /* Notice immunity */
2534 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2536 if (is_original_ap_and_seen(m_ptr))
2538 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2542 /* Otherwise, take the damage */
2545 if (mult < 17) mult = 17;
2550 if (have_flag(flgs, TR_BRAND_FIRE))
2552 /* Notice immunity */
2553 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2555 if (is_original_ap_and_seen(m_ptr))
2557 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2561 /* Otherwise, take the damage */
2564 if (r_ptr->flags3 & RF3_HURT_FIRE)
2566 if (mult < 25) mult = 25;
2567 if (is_original_ap_and_seen(m_ptr))
2569 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2572 else if (mult < 17) mult = 17;
2577 if (have_flag(flgs, TR_BRAND_COLD))
2579 /* Notice immunity */
2580 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2582 if (is_original_ap_and_seen(m_ptr))
2584 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2587 /* Otherwise, take the damage */
2590 if (r_ptr->flags3 & RF3_HURT_COLD)
2592 if (mult < 25) mult = 25;
2593 if (is_original_ap_and_seen(m_ptr))
2595 r_ptr->r_flags3 |= RF3_HURT_COLD;
2598 else if (mult < 17) mult = 17;
2602 /* Brand (Poison) */
2603 if (have_flag(flgs, TR_BRAND_POIS))
2605 /* Notice immunity */
2606 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2608 if (is_original_ap_and_seen(m_ptr))
2610 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2614 /* Otherwise, take the damage */
2617 if (mult < 17) mult = 17;
2621 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2623 p_ptr->csp -= (1+(p_ptr->msp / 30));
2624 p_ptr->redraw |= (PR_MANA);
2625 mult = mult * 5 / 2;
2632 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2634 /* Return the total damage */
2635 return (tdam * mult / 10);
2640 * @brief 射撃処理のサブルーチン /
2641 * Fire an object from the pack or floor.
2642 * @param item 射撃するオブジェクトの所持ID
2643 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2647 * You may only fire items that "match" your missile launcher.
2649 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2651 * See "calc_bonuses()" for more calculations and such.
2653 * Note that "firing" a missile is MUCH better than "throwing" it.
2655 * Note: "unseen" monsters are very hard to hit.
2657 * Objects are more likely to break if they "attempt" to hit a monster.
2659 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2661 * The "extra shot" code works by decreasing the amount of energy
2662 * required to make each shot, spreading the shots out over time.
2664 * Note that when firing missiles, the launcher multiplier is applied
2665 * after all the bonuses are added in, making multipliers very useful.
2667 * Note that Bows of "Extra Might" get extra range and an extra bonus
2668 * for the damage multiplier.
2670 * Note that Bows of "Extra Shots" give an extra shot.
2673 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2677 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2678 int tdam_base, tdis, thits, tmul;
2680 int cur_dis, visible;
2688 bool hit_body = FALSE;
2690 char o_name[MAX_NLEN];
2692 u16b path_g[512]; /* For calcuration of path length */
2694 int msec = delay_factor * delay_factor * delay_factor;
2697 bool stick_to = FALSE;
2699 /* Access the item (if in the pack) */
2702 o_ptr = &inventory[item];
2706 o_ptr = &o_list[0 - item];
2709 /* Sniper - Cannot shot a single arrow twice */
2710 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2712 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2714 /* Use the proper number of shots */
2715 thits = p_ptr->num_fire;
2717 /* Use a base distance */
2720 /* Base damage from thrown object plus launcher bonus */
2721 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2723 /* Actually "fire" the object */
2724 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2725 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2726 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2728 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2730 p_ptr->energy_use = bow_energy(j_ptr->sval);
2731 tmul = bow_tmul(j_ptr->sval);
2733 /* Get extra "power" from "extra might" */
2734 if (p_ptr->xtra_might) tmul++;
2736 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2738 /* Boost the damage */
2743 tdis = 13 + tmul/80;
2744 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2747 tdis -= (5 - (p_ptr->concent + 1) / 2);
2752 project_length = tdis + 1;
2754 /* Get a direction (or cancel) */
2755 if (!get_aim_dir(&dir))
2757 p_ptr->energy_use = 0;
2759 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2761 /* need not to reset project_length (already did)*/
2766 /* Predict the "target" location */
2767 tx = p_ptr->x + 99 * ddx[dir];
2768 ty = p_ptr->y + 99 * ddy[dir];
2770 /* Check for "target request" */
2771 if ((dir == 5) && target_okay())
2777 /* Get projection path length */
2778 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2780 project_length = 0; /* reset to default */
2782 /* Don't shoot at my feet */
2783 if (tx == p_ptr->x && ty == p_ptr->y)
2785 p_ptr->energy_use = 0;
2787 /* project_length is already reset to 0 */
2793 /* Take a (partial) turn */
2794 p_ptr->energy_use = (p_ptr->energy_use / thits);
2797 /* Sniper - Difficult to shot twice at 1 turn */
2798 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2800 /* Sniper - Repeat shooting when double shots */
2801 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2804 /* Start at the player */
2809 /* Obtain a local object */
2810 object_copy(q_ptr, o_ptr);
2815 /* Reduce and describe inventory */
2818 inven_item_increase(item, -1);
2819 inven_item_describe(item);
2820 inven_item_optimize(item);
2823 /* Reduce and describe floor item */
2826 floor_item_increase(0 - item, -1);
2827 floor_item_optimize(0 - item);
2833 /* Save the old location */
2837 /* The shot does not hit yet */
2840 /* Travel until stopped */
2841 for (cur_dis = 0; cur_dis <= tdis; )
2845 /* Hack -- Stop at the target */
2846 if ((y == ty) && (x == tx)) break;
2848 /* Calculate the new location (see "project()") */
2851 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2854 if (snipe_type == SP_KILL_WALL)
2856 c_ptr = &cave[ny][nx];
2858 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2860 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2861 /* Forget the wall */
2862 c_ptr->info &= ~(CAVE_MARK);
2863 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2865 /* Destroy the wall */
2866 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2873 /* Stopped by walls/doors */
2874 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2876 /* Advance the distance */
2880 if (snipe_type == SP_LITE)
2882 cave[ny][nx].info |= (CAVE_GLOW);
2887 /* The player can see the (on screen) missile */
2888 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2890 char c = object_char(q_ptr);
2891 byte a = object_attr(q_ptr);
2893 /* Draw, Hilite, Fresh, Pause, Erase */
2894 print_rel(c, a, ny, nx);
2895 move_cursor_relative(ny, nx);
2897 Term_xtra(TERM_XTRA_DELAY, msec);
2902 /* The player cannot see the missile */
2905 /* Pause anyway, for consistancy */
2906 Term_xtra(TERM_XTRA_DELAY, msec);
2910 if (snipe_type == SP_KILL_TRAP)
2912 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
2913 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
2917 if (snipe_type == SP_EVILNESS)
2919 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
2924 /* Save the old location */
2928 /* Save the new location */
2932 /* Monster here, Try to hit it */
2933 if (cave[y][x].m_idx)
2935 cave_type *c_mon_ptr = &cave[y][x];
2937 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
2938 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2940 /* Check the visibility */
2941 visible = m_ptr->ml;
2943 /* Note the collision */
2946 if (MON_CSLEEP(m_ptr))
2948 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
2949 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
2952 if ((r_ptr->level + 10) > p_ptr->lev)
2954 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
2955 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
2958 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
2959 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
2960 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
2961 else if (p_ptr->lev > 34) amount = 2;
2962 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
2963 p_ptr->update |= (PU_BONUS);
2969 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
2970 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
2973 p_ptr->skill_exp[GINOU_RIDING] += 1;
2974 p_ptr->update |= (PU_BONUS);
2978 /* Did we hit it (penalize range) */
2979 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2982 int tdam = tdam_base;
2984 /* Get extra damage from concentration */
2985 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
2987 /* Handle unseen monster */
2990 /* Invisible monster */
2991 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2994 /* Handle visible monster */
2999 /* Get "the monster" or "it" */
3000 monster_desc(m_name, m_ptr, 0);
3002 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3006 /* Hack -- Track this monster race */
3007 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3009 /* Hack -- Track this monster */
3010 health_track(c_mon_ptr->m_idx);
3014 if (snipe_type == SP_NEEDLE)
3016 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3017 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3021 /* Get "the monster" or "it" */
3022 monster_desc(m_name, m_ptr, 0);
3024 tdam = m_ptr->hp + 1;
3025 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3031 /* Apply special damage */
3032 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3033 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3035 /* No negative damage */
3036 if (tdam < 0) tdam = 0;
3038 /* Modify the damage */
3039 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3042 msg_format_wizard(CHEAT_MONSTER,
3043 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3044 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3047 if (snipe_type == SP_EXPLODE)
3049 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3051 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3052 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3057 if (snipe_type == SP_HOLYNESS)
3059 cave[ny][nx].info |= (CAVE_GLOW);
3064 /* Hit the monster, check for death */
3065 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
3074 if (object_is_fixed_artifact(q_ptr) &&
3075 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3079 monster_desc(m_name, m_ptr, 0);
3082 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3085 message_pain(c_mon_ptr->m_idx, tdam);
3087 /* Anger the monster */
3088 if (tdam > 0) anger_monster(m_ptr);
3091 if (fear && m_ptr->ml)
3097 /* Get the monster name (or "it") */
3098 monster_desc(m_name, m_ptr, 0);
3100 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3103 set_target(m_ptr, p_ptr->y, p_ptr->x);
3106 if (snipe_type == SP_RUSH)
3108 int n = randint1(5) + 3;
3109 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3111 for ( ; cur_dis <= tdis; )
3118 /* Calculate the new location (see "project()") */
3119 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3121 /* Stopped by wilderness boundary */
3122 if (!in_bounds2(ny, nx)) break;
3124 /* Stopped by walls/doors */
3125 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3127 /* Stopped by monsters */
3128 if (!cave_empty_bold(ny, nx)) break;
3130 cave[ny][nx].m_idx = m_idx;
3131 cave[oy][ox].m_idx = 0;
3136 /* Update the monster (new location) */
3137 update_monster(c_mon_ptr->m_idx, TRUE);
3143 Term_xtra(TERM_XTRA_DELAY, msec);
3155 if (snipe_type == SP_PIERCE)
3157 if(p_ptr->concent < 1) break;
3167 /* Chance of breakage (during attacks) */
3168 j = (hit_body ? breakage_chance(q_ptr) : 0);
3172 MONSTER_IDX m_idx = cave[y][x].m_idx;
3173 monster_type *m_ptr = &m_list[m_idx];
3174 OBJECT_IDX o_idx = o_pop();
3178 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3179 if (object_is_fixed_artifact(q_ptr))
3181 a_info[j_ptr->name1].cur_num = 0;
3186 o_ptr = &o_list[o_idx];
3187 object_copy(o_ptr, q_ptr);
3190 o_ptr->marked &= OM_TOUCHED;
3192 /* Forget location */
3193 o_ptr->iy = o_ptr->ix = 0;
3195 /* Memorize monster */
3196 o_ptr->held_m_idx = m_idx;
3199 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3202 m_ptr->hold_o_idx = o_idx;
3204 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3206 /* Drop (or break) near that location */
3207 (void)drop_near(q_ptr, j, y, x);
3211 /* Drop (or break) near that location */
3212 (void)drop_near(q_ptr, j, prev_y, prev_x);
3215 /* Sniper - Repeat shooting when double shots */
3218 /* Sniper - Loose his/her concentration after any shot */
3219 if (p_ptr->concent) reset_concentration(FALSE);
3223 * @brief 射撃処理のメインルーチン
3226 void do_cmd_fire(void)
3229 object_type *j_ptr, *ammo_ptr;
3232 is_fired = FALSE; /* not fired yet */
3234 /* Get the "bow" (if any) */
3235 j_ptr = &inventory[INVEN_BOW];
3237 /* Require a launcher */
3240 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3245 if (j_ptr->sval == SV_CRIMSON)
3247 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3252 if (j_ptr->sval == SV_HARP)
3254 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3260 if (p_ptr->special_defense & KATA_MUSOU)
3262 set_action(ACTION_NONE);
3265 /* Require proper missile */
3266 item_tester_tval = p_ptr->tval_ammo;
3268 q = _("どれを撃ちますか? ", "Fire which item? ");
3269 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3272 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
3280 do_cmd_fire_aux(item, j_ptr);
3282 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3284 /* Sniper actions after some shootings */
3285 if (snipe_type == SP_AWAY)
3287 teleport_player(10 + (p_ptr->concent * 2), 0L);
3289 if (snipe_type == SP_FINAL)
3291 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3292 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3293 (void)set_stun(p_ptr->stun + randint1(25));
3299 * @brief 投射処理メインルーチン /
3300 * Throw an object from the pack or floor.
3302 * @param boomerang ブーメラン処理ならばTRUE
3303 * @param shuriken 忍者の手裏剣処理ならばTRUE
3304 * @return ターンを消費した場合TRUEを返す
3307 * Note: "unseen" monsters are very hard to hit.
3309 * Should throwing a weapon do full damage? Should it allow the magic
3310 * to hit bonus of the weapon to have an effect? Should it ever cause
3311 * the item to be destroyed? Should it do any damage at all?
3314 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3319 POSITION y, x, ty, tx, prev_y, prev_x;
3320 POSITION ny[19], nx[19];
3321 int chance, tdam, tdis;
3322 int mul, div, dd, ds;
3323 int cur_dis, visible;
3331 bool hit_body = FALSE;
3332 bool hit_wall = FALSE;
3333 bool equiped_item = FALSE;
3334 bool return_when_thrown = FALSE;
3336 char o_name[MAX_NLEN];
3338 int msec = delay_factor * delay_factor * delay_factor;
3340 BIT_FLAGS flgs[TR_FLAG_SIZE];
3342 bool come_back = FALSE;
3343 bool do_drop = TRUE;
3346 if (p_ptr->special_defense & KATA_MUSOU)
3348 set_action(ACTION_NONE);
3357 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3359 item_tester_hook = item_tester_hook_boomerang;
3360 q = _("どの武器を投げますか? ", "Throw which item? ");
3361 s = _("投げる武器がない。", "You have nothing to throw.");
3362 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
3369 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3370 else item = INVEN_RARM;
3374 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3375 s = _("投げるアイテムがない。", "You have nothing to throw.");
3376 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
3384 /* Item is cursed */
3385 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3387 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3392 if (p_ptr->inside_arena && !boomerang)
3394 if (o_ptr->tval != TV_SPIKE)
3396 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3405 /* Obtain a local object */
3406 object_copy(q_ptr, o_ptr);
3408 /* Extract the thrown object's flags. */
3409 object_flags(q_ptr, flgs);
3410 torch_flags(q_ptr, flgs);
3412 /* Distribute the charges of rods/wands between the stacks */
3413 distribute_charges(o_ptr, q_ptr, 1);
3419 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3421 if (p_ptr->mighty_throw) mult += 3;
3423 /* Extract a "distance multiplier" */
3424 /* Changed for 'launcher' mutation */
3425 mul = 10 + 2 * (mult - 1);
3427 /* Enforce a minimum "weight" of one pound */
3428 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3429 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3431 /* Hack -- Distance -- Reward strength, penalize weight */
3432 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3434 /* Max distance of 10-18 */
3435 if (tdis > mul) tdis = mul;
3439 ty = randint0(101) - 50 + p_ptr->y;
3440 tx = randint0(101) - 50 + p_ptr->x;
3444 project_length = tdis + 1;
3446 /* Get a direction (or cancel) */
3447 if (!get_aim_dir(&dir)) return FALSE;
3449 /* Predict the "target" location */
3450 tx = p_ptr->x + 99 * ddx[dir];
3451 ty = p_ptr->y + 99 * ddy[dir];
3453 /* Check for "target request" */
3454 if ((dir == 5) && target_okay())
3460 project_length = 0; /* reset to default */
3463 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3464 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3465 return_when_thrown = TRUE;
3467 /* Reduce and describe inventory */
3470 inven_item_increase(item, -1);
3471 if (!return_when_thrown)
3472 inven_item_describe(item);
3473 inven_item_optimize(item);
3476 /* Reduce and describe floor item */
3479 floor_item_increase(0 - item, -1);
3480 floor_item_optimize(0 - item);
3482 if (item >= INVEN_RARM)
3484 equiped_item = TRUE;
3485 p_ptr->redraw |= (PR_EQUIPPY);
3488 p_ptr->energy_use = 100;
3490 /* Rogue and Ninja gets bonus */
3491 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3492 p_ptr->energy_use -= p_ptr->lev;
3494 /* Start at the player */
3500 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3501 else shuriken = FALSE;
3503 /* Chance of hitting */
3504 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3505 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3506 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3508 if (shuriken) chance *= 2;
3510 /* Save the old location */
3514 /* Travel until stopped */
3515 for (cur_dis = 0; cur_dis <= tdis; )
3517 /* Hack -- Stop at the target */
3518 if ((y == ty) && (x == tx)) break;
3520 /* Calculate the new location (see "project()") */
3523 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3525 /* Stopped by walls/doors */
3526 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3529 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3532 /* The player can see the (on screen) missile */
3533 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3535 char c = object_char(q_ptr);
3536 byte a = object_attr(q_ptr);
3538 /* Draw, Hilite, Fresh, Pause, Erase */
3539 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3540 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3542 Term_xtra(TERM_XTRA_DELAY, msec);
3543 lite_spot(ny[cur_dis], nx[cur_dis]);
3547 /* The player cannot see the missile */
3550 /* Pause anyway, for consistancy */
3551 Term_xtra(TERM_XTRA_DELAY, msec);
3554 /* Save the old location */
3558 /* Save the new location */
3562 /* Advance the distance */
3565 /* Monster here, Try to hit it */
3566 if (cave[y][x].m_idx)
3568 cave_type *c_ptr = &cave[y][x];
3569 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3571 /* Check the visibility */
3572 visible = m_ptr->ml;
3574 /* Note the collision */
3577 /* Did we hit it (penalize range) */
3578 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3582 /* Handle unseen monster */
3585 /* Invisible monster */
3586 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3589 /* Handle visible monster */
3594 /* Get "the monster" or "it" */
3595 monster_desc(m_name, m_ptr, 0);
3597 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3601 /* Hack -- Track this monster race */
3602 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3604 /* Hack -- Track this monster */
3605 health_track(c_ptr->m_idx);
3609 /* Hack -- Base damage from thrown object */
3612 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3613 tdam = damroll(dd, ds);
3614 /* Apply special damage */
3615 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3616 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3617 if (q_ptr->to_d > 0)
3618 tdam += q_ptr->to_d;
3620 tdam += -q_ptr->to_d;
3624 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3625 tdam += p_ptr->to_d_m;
3627 else if (have_flag(flgs, TR_THROW))
3630 tdam += p_ptr->to_d_m;
3638 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3641 /* No negative damage */
3642 if (tdam < 0) tdam = 0;
3644 /* Modify the damage */
3645 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3647 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3648 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3650 /* Hit the monster, check for death */
3651 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
3659 message_pain(c_ptr->m_idx, tdam);
3661 /* Anger the monster */
3662 if ((tdam > 0) && !object_is_potion(q_ptr))
3663 anger_monster(m_ptr);
3666 if (fear && m_ptr->ml)
3672 /* Get the monster name (or "it") */
3673 monster_desc(m_name, m_ptr, 0);
3675 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3685 /* decrease toach's fuel */
3686 if (hit_body) torch_lost_fuel(q_ptr);
3688 /* Chance of breakage (during attacks) */
3689 j = (hit_body ? breakage_chance(q_ptr) : 0);
3691 /* Figurines transform */
3692 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3696 if (!(summon_named_creature(0, y, x, q_ptr->pval,
3697 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3698 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3699 else if (object_is_cursed(q_ptr))
3700 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3705 /* Potions smash open */
3706 if (object_is_potion(q_ptr))
3708 if (hit_body || hit_wall || (randint1(100) < j))
3710 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3712 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3714 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3716 /* ToDo (Robert): fix the invulnerability */
3717 if (cave[y][x].m_idx &&
3718 is_friendly(&m_list[cave[y][x].m_idx]) &&
3719 !MON_INVULNER(m_ptr))
3722 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3723 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3724 set_hostile(&m_list[cave[y][x].m_idx]);
3735 if (return_when_thrown)
3737 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3738 char o2_name[MAX_NLEN];
3739 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3742 if (boomerang) back_chance += 4+randint1(5);
3743 if (super_boomerang) back_chance += 100;
3744 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3746 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3748 for (i = cur_dis - 1; i > 0; i--)
3750 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3752 char c = object_char(q_ptr);
3753 byte a = object_attr(q_ptr);
3755 /* Draw, Hilite, Fresh, Pause, Erase */
3756 print_rel(c, a, ny[i], nx[i]);
3757 move_cursor_relative(ny[i], nx[i]);
3759 Term_xtra(TERM_XTRA_DELAY, msec);
3760 lite_spot(ny[i], nx[i]);
3765 /* Pause anyway, for consistancy */
3766 Term_xtra(TERM_XTRA_DELAY, msec);
3769 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3771 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3778 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3782 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3790 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3796 if (item == INVEN_RARM || item == INVEN_LARM)
3798 /* Access the wield slot */
3799 o_ptr = &inventory[item];
3801 /* Wear the new stuff */
3802 object_copy(o_ptr, q_ptr);
3804 /* Increase the weight */
3805 p_ptr->total_weight += q_ptr->weight;
3807 /* Increment the equip counter by hand */
3810 /* Recalculate bonuses */
3811 p_ptr->update |= (PU_BONUS);
3813 /* Recalculate torch */
3814 p_ptr->update |= (PU_TORCH);
3816 /* Recalculate mana XXX */
3817 p_ptr->update |= (PU_MANA);
3819 p_ptr->window |= (PW_EQUIP);
3827 else if (equiped_item)
3833 /* Drop (or break) near that location */
3836 if (cave_have_flag_bold(y, x, FF_PROJECT))
3838 /* Drop (or break) near that location */
3839 (void)drop_near(q_ptr, j, y, x);
3843 /* Drop (or break) near that location */
3844 (void)drop_near(q_ptr, j, prev_y, prev_x);
3854 * Hack: travel command
3856 #define TRAVEL_UNABLE 9999
3858 static int flow_head = 0;
3859 static int flow_tail = 0;
3860 static POSITION temp2_x[MAX_SHORT];
3861 static POSITION temp2_y[MAX_SHORT];
3864 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3867 void forget_travel_flow(void)
3871 /* Check the entire dungeon */
3872 for (y = 0; y < cur_hgt; y++)
3874 for (x = 0; x < cur_wid; x++)
3876 /* Forget the old data */
3877 travel.cost[y][x] = MAX_SHORT;
3881 travel.y = travel.x = 0;
3885 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
3890 static int travel_flow_cost(POSITION y, POSITION x)
3892 feature_type *f_ptr = &f_info[cave[y][x].feat];
3895 /* Avoid obstacles (ex. trees) */
3896 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
3899 if (have_flag(f_ptr->flags, FF_WATER))
3901 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
3905 if (have_flag(f_ptr->flags, FF_LAVA))
3908 if (!p_ptr->resist_fire) lava *= 2;
3909 if (!p_ptr->levitation) lava *= 2;
3910 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
3915 /* Detected traps and doors */
3916 if (cave[y][x].info & (CAVE_MARK))
3918 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
3919 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
3926 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
3930 * @param wall プレイヤーが壁の中にいるならばTRUE
3933 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
3935 cave_type *c_ptr = &cave[y][x];
3936 feature_type *f_ptr = &f_info[c_ptr->feat];
3937 int old_head = flow_head;
3939 int base_cost = (n % TRAVEL_UNABLE);
3940 int from_wall = (n / TRAVEL_UNABLE);
3943 /* Ignore out of bounds */
3944 if (!in_bounds(y, x)) return;
3946 /* Ignore unknown grid except in wilderness */
3947 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
3949 /* Ignore "walls" and "rubble" (include "secret doors") */
3950 if (have_flag(f_ptr->flags, FF_WALL) ||
3951 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3952 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
3953 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
3955 if (!wall || !from_wall) return;
3956 add_cost += TRAVEL_UNABLE;
3960 add_cost = travel_flow_cost(y, x);
3963 cost = base_cost + add_cost;
3965 /* Ignore lower cost entries */
3966 if (travel.cost[y][x] <= cost) return;
3968 /* Save the flow cost */
3969 travel.cost[y][x] = cost;
3971 /* Enqueue that entry */
3972 temp2_y[flow_head] = y;
3973 temp2_x[flow_head] = x;
3975 /* Advance the queue */
3976 if (++flow_head == MAX_SHORT) flow_head = 0;
3978 /* Hack -- notice overflow by forgetting new entry */
3979 if (flow_head == flow_tail) flow_head = old_head;
3985 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
3986 * @param ty 目標地点のY座標
3987 * @param tx 目標地点のX座標
3990 static void travel_flow(POSITION ty, POSITION tx)
3994 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
3996 /* Reset the "queue" */
3997 flow_head = flow_tail = 0;
3999 /* is player in the wall? */
4000 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4002 /* Start at the target grid */
4003 travel_flow_aux(ty, tx, 0, wall);
4005 /* Now process the queue */
4006 while (flow_head != flow_tail)
4008 /* Extract the next entry */
4009 y = temp2_y[flow_tail];
4010 x = temp2_x[flow_tail];
4012 /* Forget that entry */
4013 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4015 /* Ignore too far entries */
4016 //if (distance(ty, tx, y, x) > 100) continue;
4018 /* Add the "children" */
4019 for (d = 0; d < 8; d++)
4021 /* Add that child if "legal" */
4022 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4026 /* Forget the flow info */
4027 flow_head = flow_tail = 0;
4031 * @brief トラベル処理のメインルーチン
4034 void do_cmd_travel(void)
4039 feature_type *f_ptr;
4041 if (travel.x != 0 && travel.y != 0 &&
4042 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4047 else if (!tgt_pt(&x, &y)) return;
4049 if ((x == p_ptr->x) && (y == p_ptr->y))
4051 msg_print(_("すでにそこにいます!", "You are already there!!"));
4055 f_ptr = &f_info[cave[y][x].feat];
4057 if ((cave[y][x].info & CAVE_MARK) &&
4058 (have_flag(f_ptr->flags, FF_WALL) ||
4059 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4060 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4062 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4066 forget_travel_flow();
4072 /* Travel till 255 steps */
4078 /* Decides first direction */
4079 dx = abs(p_ptr->x - x);
4080 dy = abs(p_ptr->y - y);
4081 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4082 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4084 for (i = 1; i <= 9; i++)
4086 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;