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.
15 #include "object-hook.h"
18 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
19 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
20 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
22 bool confirm_leave_level(bool down_stair)
24 quest_type *q_ptr = &quest[p_ptr->inside_quest];
26 /* Confirm leaving from once only quest */
27 if (confirm_quest && p_ptr->inside_quest &&
28 (q_ptr->type == QUEST_TYPE_RANDOM ||
29 (q_ptr->flags & QUEST_FLAG_ONCE &&
30 q_ptr->status != QUEST_STATUS_COMPLETED) ||
31 (q_ptr->flags & QUEST_FLAG_TOWER &&
32 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
33 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
35 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
36 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
46 * @brief 階段を使って階層を昇る処理 / Go up one level
49 void do_cmd_go_up(void)
54 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
55 feature_type *f_ptr = &f_info[c_ptr->feat];
59 if (p_ptr->special_defense & KATA_MUSOU)
61 set_action(ACTION_NONE);
65 if (!have_flag(f_ptr->flags, FF_LESS))
67 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
72 if (have_flag(f_ptr->flags, FF_QUEST))
74 /* Cancel the command */
75 if (!confirm_leave_level(FALSE)) return;
79 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
80 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
82 msg_print(_("上の階に登った。", "You enter the up staircase."));
86 p_ptr->inside_quest = c_ptr->special;
88 /* Activate the quest */
89 if (!quest[p_ptr->inside_quest].status)
91 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
93 init_flags = INIT_ASSIGN;
94 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
96 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
100 if (!p_ptr->inside_quest)
106 p_ptr->leaving = TRUE;
111 /* Hack -- take a turn */
112 p_ptr->energy_use = 100;
114 /* End the command */
124 go_up = confirm_leave_level(FALSE);
127 /* Cancel the command */
130 /* Hack -- take a turn */
131 p_ptr->energy_use = 100;
133 if (autosave_l) do_cmd_save_game(TRUE);
135 /* For a random quest */
136 if (p_ptr->inside_quest &&
137 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
141 p_ptr->inside_quest = 0;
144 /* For a fixed quest */
145 if (p_ptr->inside_quest &&
146 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
150 p_ptr->inside_quest = c_ptr->special;
155 /* For normal dungeon and random quest */
159 if (have_flag(f_ptr->flags, FF_SHAFT))
161 /* Create a way back */
162 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
168 /* Create a way back */
169 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
174 /* Get out from current dungeon */
175 if (dun_level - up_num < d_info[dungeon_type].mindepth)
178 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
181 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
182 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
183 else if (up_num == dun_level)
184 msg_print(_("地上に戻った。", "You go back to the surface."));
186 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
189 p_ptr->leaving = TRUE;
194 * @brief 階段を使って階層を降りる処理 / Go down one level
197 void do_cmd_go_down(void)
200 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
201 feature_type *f_ptr = &f_info[c_ptr->feat];
203 bool fall_trap = FALSE;
206 if (p_ptr->special_defense & KATA_MUSOU)
208 set_action(ACTION_NONE);
212 if (!have_flag(f_ptr->flags, FF_MORE))
214 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
218 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
221 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
226 /* Quest down stairs */
227 else if (have_flag(f_ptr->flags, FF_QUEST))
229 /* Confirm Leaving */
230 if(!confirm_leave_level(TRUE)) return;
232 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
233 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
235 msg_print(_("下の階に降りた。", "You enter the down staircase."));
240 p_ptr->inside_quest = c_ptr->special;
242 /* Activate the quest */
243 if (!quest[p_ptr->inside_quest].status)
245 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
247 init_flags = INIT_ASSIGN;
248 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
250 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
253 /* Leaving a quest */
254 if (!p_ptr->inside_quest)
260 p_ptr->leaving = TRUE;
266 /* Hack -- take a turn */
267 p_ptr->energy_use = 100;
272 int target_dungeon = 0;
276 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
278 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
280 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
283 if (!max_dlv[target_dungeon])
285 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
286 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
287 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
290 /* Save old player position */
291 p_ptr->oldpx = p_ptr->x;
292 p_ptr->oldpy = p_ptr->y;
293 dungeon_type = (byte)target_dungeon;
296 * Clear all saved floors
297 * and create a first saved floor
299 prepare_change_floor_mode(CFM_FIRST_FLOOR);
302 /* Hack -- take a turn */
303 p_ptr->energy_use = 100;
305 if (autosave_l) do_cmd_save_game(TRUE);
308 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
313 /* Enter the dungeon just now */
314 p_ptr->enter_dungeon = TRUE;
315 down_num = d_info[dungeon_type].mindepth;
320 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
321 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
326 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
333 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
337 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
338 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
340 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
346 p_ptr->leaving = TRUE;
350 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
354 if (have_flag(f_ptr->flags, FF_SHAFT))
356 /* Create a way back */
357 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
361 /* Create a way back */
362 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
370 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
373 void do_cmd_search(void)
375 /* Allow repeated command */
378 /* Set repeat count */
379 command_rep = command_arg - 1;
381 /* Redraw the state */
382 p_ptr->redraw |= (PR_STATE);
387 p_ptr->energy_use = 100;
395 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
396 * @param y 走査対象にしたいマスのY座標
397 * @param x 走査対象にしたいマスのX座標
398 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
399 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
401 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
403 cave_type *c_ptr = &cave[y][x];
404 OBJECT_IDX this_o_idx, next_o_idx = 0;
406 /* Scan all objects in the grid */
407 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
411 o_ptr = &o_list[this_o_idx];
412 next_o_idx = o_ptr->next_o_idx;
414 /* Skip unknown chests XXX XXX */
415 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
417 /* Check for non empty chest */
418 if ((o_ptr->tval == TV_CHEST) &&
419 (((!trapped) && (o_ptr->pval)) || /* non empty */
420 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
429 * @brief 箱を開けるコマンドのメインルーチン /
430 * Attempt to open the given chest at the given location
431 * @param y 箱の存在するマスのY座標
432 * @param x 箱の存在するマスのX座標
433 * @param o_idx 箱のオブジェクトID
434 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
436 * Assume there is no monster blocking the destination
438 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
443 object_type *o_ptr = &o_list[o_idx];
445 p_ptr->energy_use = 100;
447 /* Attempt to unlock it */
450 /* Assume locked, and thus not open */
453 /* Get the "disarm" factor */
454 i = p_ptr->skill_dis;
456 /* Penalize some conditions */
457 if (p_ptr->blind || no_lite()) i = i / 10;
458 if (p_ptr->confused || p_ptr->image) i = i / 10;
460 /* Extract the difficulty */
463 /* Always have a small chance of success */
466 /* Success -- May still have traps */
467 if (randint0(100) < j)
469 msg_print(_("鍵をはずした。", "You have picked the lock."));
474 /* Failure -- Keep trying */
477 /* We may continue repeating */
479 if (flush_failure) flush();
480 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
485 /* Allowed to open */
488 /* Apply chest traps, if any */
489 chest_trap(y, x, o_idx);
491 /* Let the Chest drop items */
492 chest_death(FALSE, y, x, o_idx);
498 * @brief 地形は開くものであって、かつ開かれているかを返す /
499 * Attempt to open the given chest at the given location
501 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
503 static bool is_open(IDX feat)
505 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
510 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
511 * Attempt to open the given chest at the given location
512 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
513 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
514 * @param test 地形条件を判定するための関数ポインタ
515 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
517 * @details Return the number of features around (or under) the character.
518 * Usually look for doors and floor traps.
520 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
522 int d, count, xx, yy;
524 /* Count how many matches */
527 /* Check around (and under) the character */
528 for (d = 0; d < 9; d++)
533 /* if not searching under player continue */
534 if ((d == 8) && !under) continue;
536 /* Extract adjacent (legal) location */
537 yy = p_ptr->y + ddy_ddd[d];
538 xx = p_ptr->x + ddx_ddd[d];
541 c_ptr = &cave[yy][xx];
543 /* Must have knowledge */
544 if (!(c_ptr->info & (CAVE_MARK))) continue;
546 /* Feature code (applying "mimic" field) */
547 feat = get_feat_mimic(c_ptr);
549 /* Not looking for this feature */
550 if (!((*test)(feat))) continue;
555 /* Remember the location. Only useful if only one match */
566 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
567 * Return the number of chests around (or under) the character.
568 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
569 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
570 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
573 * If requested, count only trapped chests.
575 static int count_chests(POSITION *y, POSITION *x, bool trapped)
582 /* Count how many matches */
585 /* Check around (and under) the character */
586 for (d = 0; d < 9; d++)
588 /* Extract adjacent (legal) location */
589 POSITION yy = p_ptr->y + ddy_ddd[d];
590 POSITION xx = p_ptr->x + ddx_ddd[d];
592 /* No (visible) chest is there */
593 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
595 /* Grab the object */
596 o_ptr = &o_list[o_idx];
599 if (o_ptr->pval == 0) continue;
601 /* No (known) traps here */
602 if (trapped && (!object_is_known(o_ptr) ||
603 !chest_traps[o_ptr->pval])) continue;
608 /* Remember the location. Only useful if only one match */
619 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
620 * Convert an adjacent location to a direction.
621 * @param y 方角を確認したY座標
622 * @param x 方角を確認したX座標
625 static DIRECTION coords_to_dir(POSITION y, POSITION x)
627 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
634 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
636 return d[dx + 1][dy + 1];
640 * @brief 「開ける」動作コマンドのサブルーチン /
641 * Perform the basic "open" command on doors
642 * @param y 対象を行うマスのY座標
643 * @param x 対象を行うマスのX座標
644 * @return 実際に処理が行われた場合TRUEを返す。
646 * Assume destination is a closed/locked/jammed door
647 * Assume there is no monster blocking the destination
648 * Returns TRUE if repeated commands may continue
650 static bool do_cmd_open_aux(POSITION y, POSITION x)
654 /* Get requested grid */
655 cave_type *c_ptr = &cave[y][x];
656 feature_type *f_ptr = &f_info[c_ptr->feat];
659 p_ptr->energy_use = 100;
661 /* Seeing true feature code (ignore mimic) */
664 if (!have_flag(f_ptr->flags, FF_OPEN))
667 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
671 else if (f_ptr->power)
674 i = p_ptr->skill_dis;
676 /* Penalize some conditions */
677 if (p_ptr->blind || no_lite()) i = i / 10;
678 if (p_ptr->confused || p_ptr->image) i = i / 10;
680 /* Extract the lock power */
683 /* Extract the difficulty */
686 /* Always have a small chance of success */
690 if (randint0(100) < j)
692 msg_print(_("鍵をはずした。", "You have picked the lock."));
695 cave_alter_feat(y, x, FF_OPEN);
697 sound(SOUND_OPENDOOR);
707 if (flush_failure) flush();
709 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
711 /* We may keep trying */
720 cave_alter_feat(y, x, FF_OPEN);
722 sound(SOUND_OPENDOOR);
728 * @brief 「開ける」コマンドのメインルーチン /
729 * Open a closed/locked/jammed door or a closed/locked chest.
732 * Unlocking a locked door/chest is worth one experience point.
734 void do_cmd_open(void)
742 if (p_ptr->special_defense & KATA_MUSOU)
744 set_action(ACTION_NONE);
747 /* Option: Pick a direction */
750 int num_doors, num_chests;
752 /* Count closed doors (locked or jammed) */
753 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
755 /* Count chests (locked) */
756 num_chests = count_chests(&y, &x, FALSE);
758 /* See if only one target */
759 if (num_doors || num_chests)
761 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
763 if (!too_many) command_dir = coords_to_dir(y, x);
767 /* Allow repeated command */
770 /* Set repeat count */
771 command_rep = command_arg - 1;
773 /* Redraw the state */
774 p_ptr->redraw |= (PR_STATE);
780 /* Get a "repeated" direction */
781 if (get_rep_dir(&dir, TRUE))
786 /* Get requested location */
787 y = p_ptr->y + ddy[dir];
788 x = p_ptr->x + ddx[dir];
790 /* Get requested grid */
793 /* Feature code (applying "mimic" field) */
794 feat = get_feat_mimic(c_ptr);
796 /* Check for chest */
797 o_idx = chest_check(y, x, FALSE);
800 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
802 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
805 /* Monster in the way */
806 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
808 p_ptr->energy_use = 100;
810 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->special_defense & KATA_MUSOU)
905 set_action(ACTION_NONE);
908 /* Option: Pick a direction */
911 /* Count open doors */
912 if (count_dt(&y, &x, is_open, FALSE) == 1)
914 command_dir = coords_to_dir(y, x);
918 /* Allow repeated command */
921 /* Set repeat count */
922 command_rep = command_arg - 1;
924 /* Redraw the state */
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;
1165 /* Redraw the state */
1166 p_ptr->redraw |= (PR_STATE);
1168 /* Cancel the arg */
1172 /* Get a direction to tunnel, or Abort */
1173 if (get_rep_dir(&dir,FALSE))
1176 y = p_ptr->y + ddy[dir];
1177 x = p_ptr->x + ddx[dir];
1180 c_ptr = &cave[y][x];
1182 /* Feature code (applying "mimic" field) */
1183 feat = get_feat_mimic(c_ptr);
1185 /* No tunnelling through doors */
1186 if (have_flag(f_info[feat].flags, FF_DOOR))
1188 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1191 /* No tunnelling through most features */
1192 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1194 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1197 /* A monster is in the way */
1198 else if (c_ptr->m_idx)
1200 p_ptr->energy_use = 100;
1202 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1211 /* Tunnel through walls */
1212 more = do_cmd_tunnel_aux(y, x);
1216 /* Cancel repetition unless we can continue */
1217 if (!more) disturb(FALSE, FALSE);
1221 * @brief 移動処理による簡易な「開く」処理 /
1223 * @return 開く処理が実際に試みられた場合TRUEを返す
1226 * If there is a jammed/closed/locked door at the given location,
1227 * then attempt to unlock/open it. Return TRUE if an attempt was
1228 * made (successful or not), otherwise return FALSE.
1230 * The code here should be nearly identical to that in
1231 * do_cmd_open_test() and do_cmd_open_aux().
1234 bool easy_open_door(POSITION y, POSITION x)
1238 cave_type *c_ptr = &cave[y][x];
1239 feature_type *f_ptr = &f_info[c_ptr->feat];
1241 /* Must be a closed door */
1242 if (!is_closed_door(c_ptr->feat))
1248 if (!have_flag(f_ptr->flags, FF_OPEN))
1251 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1256 else if (f_ptr->power)
1259 i = p_ptr->skill_dis;
1261 /* Penalize some conditions */
1262 if (p_ptr->blind || no_lite()) i = i / 10;
1263 if (p_ptr->confused || p_ptr->image) i = i / 10;
1265 /* Extract the lock power */
1268 /* Extract the difficulty */
1271 /* Always have a small chance of success */
1275 if (randint0(100) < j)
1277 msg_print(_("鍵をはずした。", "You have picked the lock."));
1280 cave_alter_feat(y, x, FF_OPEN);
1282 sound(SOUND_OPENDOOR);
1292 if (flush_failure) flush();
1294 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1303 cave_alter_feat(y, x, FF_OPEN);
1305 sound(SOUND_OPENDOOR);
1311 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1312 * Perform the basic "disarm" command
1313 * @param y 解除を行うマスのY座標
1314 * @param x 解除を行うマスのX座標
1315 * @param o_idx 箱のオブジェクトID
1316 * @return ターンを消費する処理が行われた場合TRUEを返す
1319 * Assume destination is a visible trap
1320 * Assume there is no monster blocking the destination
1321 * Returns TRUE if repeated commands may continue
1324 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1328 object_type *o_ptr = &o_list[o_idx];
1330 p_ptr->energy_use = 100;
1332 /* Get the "disarm" factor */
1333 i = p_ptr->skill_dis;
1335 /* Penalize some conditions */
1336 if (p_ptr->blind || no_lite()) i = i / 10;
1337 if (p_ptr->confused || p_ptr->image) i = i / 10;
1339 /* Extract the difficulty */
1340 j = i - o_ptr->pval;
1342 /* Always have a small chance of success */
1345 /* Must find the trap first. */
1346 if (!object_is_known(o_ptr))
1348 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1352 /* Already disarmed/unlocked */
1353 else if (o_ptr->pval <= 0)
1355 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1358 /* No traps to find. */
1359 else if (!chest_traps[o_ptr->pval])
1361 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1364 /* Success (get a lot of experience) */
1365 else if (randint0(100) < j)
1367 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1368 gain_exp(o_ptr->pval);
1369 o_ptr->pval = (0 - o_ptr->pval);
1372 /* Failure -- Keep trying */
1373 else if ((i > 5) && (randint1(i) > 5))
1375 /* We may keep trying */
1377 if (flush_failure) flush();
1378 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1381 /* Failure -- Set off the trap */
1384 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1386 chest_trap(y, x, o_idx);
1393 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1394 * Perform the basic "disarm" command
1395 * @param y 解除を行うマスのY座標
1396 * @param x 解除を行うマスのX座標
1397 * @param dir プレイヤーからみた方向ID
1398 * @return ターンを消費する処理が行われた場合TRUEを返す
1401 * Assume destination is a visible trap
1402 * Assume there is no monster blocking the destination
1403 * Returns TRUE if repeated commands may continue
1407 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1409 cave_type *c_ptr = &cave[y][x];
1412 feature_type *f_ptr = &f_info[c_ptr->feat];
1414 /* Access trap name */
1415 cptr name = (f_name + f_ptr->name);
1417 /* Extract trap "power" */
1418 int power = f_ptr->power;
1421 /* Get the "disarm" factor */
1422 int i = p_ptr->skill_dis;
1425 p_ptr->energy_use = 100;
1427 /* Penalize some conditions */
1428 if (p_ptr->blind || no_lite()) i = i / 10;
1429 if (p_ptr->confused || p_ptr->image) i = i / 10;
1431 /* Extract the difficulty */
1434 /* Always have a small chance of success */
1438 if (randint0(100) < j)
1440 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1445 /* Remove the trap */
1446 cave_alter_feat(y, x, FF_DISARM);
1448 /* Move the player onto the trap */
1449 move_player(dir, easy_disarm, FALSE);
1452 /* Failure -- Keep trying */
1453 else if ((i > 5) && (randint1(i) > 5))
1456 if (flush_failure) flush();
1458 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1460 /* We may keep trying */
1464 /* Failure -- Set off the trap */
1467 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1468 /* Move the player onto the trap */
1469 move_player(dir, easy_disarm, FALSE);
1476 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1477 * Disarms a trap, or chest
1480 void do_cmd_disarm(void)
1488 if (p_ptr->special_defense & KATA_MUSOU)
1490 set_action(ACTION_NONE);
1494 /* Option: Pick a direction */
1497 int num_traps, num_chests;
1499 /* Count visible traps */
1500 num_traps = count_dt(&y, &x, is_trap, TRUE);
1502 /* Count chests (trapped) */
1503 num_chests = count_chests(&y, &x, TRUE);
1505 /* See if only one target */
1506 if (num_traps || num_chests)
1508 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1509 if (!too_many) command_dir = coords_to_dir(y, x);
1514 /* Allow repeated command */
1517 /* Set repeat count */
1518 command_rep = command_arg - 1;
1520 /* Redraw the state */
1521 p_ptr->redraw |= (PR_STATE);
1523 /* Cancel the arg */
1527 /* Get a direction (or abort) */
1528 if (get_rep_dir(&dir,TRUE))
1533 y = p_ptr->y + ddy[dir];
1534 x = p_ptr->x + ddx[dir];
1535 c_ptr = &cave[y][x];
1537 /* Feature code (applying "mimic" field) */
1538 feat = get_feat_mimic(c_ptr);
1540 /* Check for chests */
1541 o_idx = chest_check(y, x, TRUE);
1544 if (!is_trap(feat) && !o_idx)
1546 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1549 /* Monster in the way */
1550 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1552 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1561 /* Disarm the chest */
1562 more = do_cmd_disarm_chest(y, x, o_idx);
1568 /* Disarm the trap */
1569 more = do_cmd_disarm_aux(y, x, dir);
1573 /* Cancel repeat unless told not to */
1574 if (!more) disturb(FALSE, FALSE);
1579 * @brief 「打ち破る」動作コマンドのサブルーチン /
1580 * Perform the basic "bash" command
1581 * @param y 対象を行うマスのY座標
1582 * @param x 対象を行うマスのX座標
1583 * @param dir プレイヤーから見たターゲットの方角ID
1584 * @return 実際に処理が行われた場合TRUEを返す。
1587 * Assume destination is a closed/locked/jammed door
1588 * Assume there is no monster blocking the destination
1589 * Returns TRUE if repeated commands may continue
1592 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1595 cave_type *c_ptr = &cave[y][x];
1598 feature_type *f_ptr = &f_info[c_ptr->feat];
1600 /* Hack -- Bash power based on strength */
1601 /* (Ranges from 3 to 20 to 100 to 200) */
1602 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1604 /* Extract door power */
1605 int temp = f_ptr->power;
1609 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1611 p_ptr->energy_use = 100;
1613 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1615 /* Compare bash power to door power */
1616 temp = (bash - (temp * 10));
1618 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1620 /* Hack -- always have a chance */
1621 if (temp < 1) temp = 1;
1623 /* Hack -- attempt to bash down the door */
1624 if (randint0(100) < temp)
1626 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1628 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1630 /* Break down the door */
1631 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1633 cave_alter_feat(y, x, FF_BASH);
1639 cave_alter_feat(y, x, FF_OPEN);
1642 /* Hack -- Fall through the door */
1643 move_player(dir, FALSE, FALSE);
1646 /* Saving throw against stun */
1647 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1650 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1652 /* Allow repeated bashing */
1656 /* High dexterity yields coolness */
1659 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1661 /* Hack -- Lose balance ala paralysis */
1662 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1669 * @brief 「打ち破る」動作コマンドのメインルーチン /
1670 * Bash open a door, success based on character strength
1674 * For a closed door, pval is positive if locked; negative if stuck.
1676 * For an open door, pval is positive for a broken door.
1678 * A closed door can be opened - harder if locked. Any door might be
1679 * bashed open (and thereby broken). Bashing a door is (potentially)
1680 * faster! You move into the door way. To open a stuck door, it must
1681 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1683 * Creatures can also open or bash doors, see elsewhere.
1686 void do_cmd_bash(void)
1695 if (p_ptr->special_defense & KATA_MUSOU)
1697 set_action(ACTION_NONE);
1700 /* Allow repeated command */
1703 /* Set repeat count */
1704 command_rep = command_arg - 1;
1706 /* Redraw the state */
1707 p_ptr->redraw |= (PR_STATE);
1709 /* Cancel the arg */
1713 /* Get a "repeated" direction */
1714 if (get_rep_dir(&dir,FALSE))
1719 y = p_ptr->y + ddy[dir];
1720 x = p_ptr->x + ddx[dir];
1723 c_ptr = &cave[y][x];
1725 /* Feature code (applying "mimic" field) */
1726 feat = get_feat_mimic(c_ptr);
1728 /* Nothing useful */
1729 if (!have_flag(f_info[feat].flags, FF_BASH))
1731 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1734 /* Monster in the way */
1735 else if (c_ptr->m_idx)
1737 p_ptr->energy_use = 100;
1739 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1745 /* Bash a closed door */
1749 more = do_cmd_bash_aux(y, x, dir);
1753 /* Unless valid action taken, cancel bash */
1754 if (!more) disturb(FALSE, FALSE);
1759 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1763 * Manipulate an adjacent grid in some way
1765 * Attack monsters, tunnel through walls, disarm traps, open doors.
1767 * Consider confusion
1769 * This command must always take a turn, to prevent free detection
1770 * of invisible monsters.
1773 void do_cmd_alter(void)
1780 if (p_ptr->special_defense & KATA_MUSOU)
1782 set_action(ACTION_NONE);
1785 /* Allow repeated command */
1788 /* Set repeat count */
1789 command_rep = command_arg - 1;
1791 /* Redraw the state */
1792 p_ptr->redraw |= (PR_STATE);
1794 /* Cancel the arg */
1798 /* Get a direction */
1799 if (get_rep_dir(&dir,TRUE))
1802 feature_type *f_ptr;
1804 y = p_ptr->y + ddy[dir];
1805 x = p_ptr->x + ddx[dir];
1808 c_ptr = &cave[y][x];
1810 /* Feature code (applying "mimic" field) */
1811 feat = get_feat_mimic(c_ptr);
1812 f_ptr = &f_info[feat];
1814 p_ptr->energy_use = 100;
1822 else if (have_flag(f_ptr->flags, FF_OPEN))
1824 more = do_cmd_open_aux(y, x);
1827 /* Bash jammed doors */
1828 else if (have_flag(f_ptr->flags, FF_BASH))
1830 more = do_cmd_bash_aux(y, x, dir);
1833 /* Tunnel through walls */
1834 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1836 more = do_cmd_tunnel_aux(y, x);
1839 /* Close open doors */
1840 else if (have_flag(f_ptr->flags, FF_CLOSE))
1842 more = do_cmd_close_aux(y, x);
1846 else if (have_flag(f_ptr->flags, FF_DISARM))
1848 more = do_cmd_disarm_aux(y, x, dir);
1853 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1857 /* Cancel repetition unless we can continue */
1858 if (!more) disturb(FALSE, FALSE);
1864 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1865 * Find the index of some "spikes", if possible.
1866 * @param ip くさびとして打てるオブジェクトのID
1867 * @return オブジェクトがある場合TRUEを返す
1870 * Let user choose a pile of spikes, perhaps?
1873 static bool get_spike(INVENTORY_IDX *ip)
1877 /* Check every item in the pack */
1878 for (i = 0; i < INVEN_PACK; i++)
1880 object_type *o_ptr = &inventory[i];
1882 /* Skip non-objects */
1883 if (!o_ptr->k_idx) continue;
1885 /* Check the "tval" code */
1886 if (o_ptr->tval == TV_SPIKE)
1888 /* Save the spike index */
1901 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1902 * Jam a closed door with a spike
1906 * This command may NOT be repeated
1909 void do_cmd_spike(void)
1913 if (p_ptr->special_defense & KATA_MUSOU)
1915 set_action(ACTION_NONE);
1918 /* Get a "repeated" direction */
1919 if (get_rep_dir(&dir,FALSE))
1926 y = p_ptr->y + ddy[dir];
1927 x = p_ptr->x + ddx[dir];
1928 c_ptr = &cave[y][x];
1930 /* Feature code (applying "mimic" field) */
1931 feat = get_feat_mimic(c_ptr);
1933 /* Require closed door */
1934 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1936 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1940 else if (!get_spike(&item))
1942 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1945 /* Is a monster in the way? */
1946 else if (c_ptr->m_idx)
1948 p_ptr->energy_use = 100;
1950 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1959 p_ptr->energy_use = 100;
1961 /* Successful jamming */
1962 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1963 cave_alter_feat(y, x, FF_SPIKE);
1965 /* Use up, and describe, a single spike, from the bottom */
1966 inven_item_increase(item, -1);
1967 inven_item_describe(item);
1968 inven_item_optimize(item);
1976 * @brief 「歩く」動作コマンドのメインルーチン /
1977 * Support code for the "Walk" and "Jump" commands
1978 * @param pickup アイテムの自動拾いを行うならTRUE
1981 void do_cmd_walk(bool pickup)
1988 /* Allow repeated command */
1991 /* Set repeat count */
1992 command_rep = command_arg - 1;
1994 /* Redraw the state */
1995 p_ptr->redraw |= (PR_STATE);
1997 /* Cancel the arg */
2001 /* Get a "repeated" direction */
2002 if (get_rep_dir(&dir, FALSE))
2004 p_ptr->energy_use = 100;
2006 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2008 set_action(ACTION_NONE);
2011 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2012 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2013 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2015 /* Actually move the character */
2016 move_player(dir, pickup, FALSE);
2018 /* Allow more walking */
2022 /* Hack again -- Is there a special encounter ??? */
2023 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2025 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2028 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2030 /* Inform the player of his horrible fate :=) */
2031 msg_print(_("襲撃だ!", "You are ambushed !"));
2033 /* Go into large wilderness view */
2034 p_ptr->oldpy = randint1(MAX_HGT-2);
2035 p_ptr->oldpx = randint1(MAX_WID-2);
2038 /* Give first move to monsters */
2039 p_ptr->energy_use = 100;
2041 /* HACk -- set the encouter flag for the wilderness generation */
2042 generate_encounter = TRUE;
2046 /* Cancel repeat unless we may continue */
2047 if (!more) disturb(FALSE, FALSE);
2052 * @brief 「走る」動作コマンドのメインルーチン /
2056 void do_cmd_run(void)
2060 /* Hack -- no running when confused */
2061 if (p_ptr->confused)
2063 msg_print(_("混乱していて走れない!", "You are too confused!"));
2067 if (p_ptr->special_defense & KATA_MUSOU)
2069 set_action(ACTION_NONE);
2072 /* Get a "repeated" direction */
2073 if (get_rep_dir(&dir,FALSE))
2075 /* Hack -- Set the run counter */
2076 running = (command_arg ? command_arg : 1000);
2085 * @brief 「留まる」動作コマンドのメインルーチン /
2086 * Stay still. Search. Enter stores.
2087 * Pick up treasure if "pickup" is true.
2088 * @param pickup アイテムの自動拾いを行うならTRUE
2091 void do_cmd_stay(bool pickup)
2093 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2095 /* Allow repeated command */
2098 /* Set repeat count */
2099 command_rep = command_arg - 1;
2101 /* Redraw the state */
2102 p_ptr->redraw |= (PR_STATE);
2104 /* Cancel the arg */
2108 p_ptr->energy_use = 100;
2110 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2111 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2116 * @brief 「休む」動作コマンドのメインルーチン /
2117 * Resting allows a player to safely restore his hp -RAK-
2120 void do_cmd_rest(void)
2123 set_action(ACTION_NONE);
2125 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2131 if (hex_spelling_any()) stop_hex_spell_all();
2133 /* Prompt for time if needed */
2134 if (command_arg <= 0)
2136 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2137 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2143 strcpy(out_val, "&");
2145 /* Ask for duration */
2146 if (!get_string(p, out_val, 4)) return;
2148 /* Rest until done */
2149 if (out_val[0] == '&')
2151 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2155 else if (out_val[0] == '*')
2157 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2163 command_arg = (COMMAND_ARG)atoi(out_val);
2164 if (command_arg <= 0) return;
2170 if (command_arg > 9999) command_arg = 9999;
2172 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2174 /* Take a turn (?) */
2175 p_ptr->energy_use = 100;
2177 /* The sin of sloth */
2178 if (command_arg > 100)
2179 chg_virtue(V_DILIGENCE, -1);
2181 /* Why are you sleeping when there's no need? WAKE UP!*/
2182 if ((p_ptr->chp == p_ptr->mhp) &&
2183 (p_ptr->csp == p_ptr->msp) &&
2184 !p_ptr->blind && !p_ptr->confused &&
2185 !p_ptr->poisoned && !p_ptr->afraid &&
2186 !p_ptr->stun && !p_ptr->cut &&
2187 !p_ptr->slow && !p_ptr->paralyzed &&
2188 !p_ptr->image && !p_ptr->word_recall &&
2189 !p_ptr->alter_reality)
2190 chg_virtue(V_DILIGENCE, -1);
2192 /* Save the rest code */
2193 resting = command_arg;
2194 p_ptr->action = ACTION_REST;
2196 /* Recalculate bonuses */
2197 p_ptr->update |= (PU_BONUS);
2199 /* Redraw the state */
2200 p_ptr->redraw |= (PR_STATE);
2209 * @brief 矢弾を射撃した場合の破損確率を返す /
2210 * Determines the odds of an object breaking when thrown at a monster
2211 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2214 * Note that artifacts never break, see the "drop_near()" function.
2216 static PERCENTAGE breakage_chance(object_type *o_ptr)
2218 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2220 /* Examine the snipe type */
2223 if (snipe_type == SP_KILL_WALL) return (100);
2224 if (snipe_type == SP_EXPLODE) return (100);
2225 if (snipe_type == SP_PIERCE) return (100);
2226 if (snipe_type == SP_FINAL) return (100);
2227 if (snipe_type == SP_NEEDLE) return (100);
2228 if (snipe_type == SP_EVILNESS) return (40);
2229 if (snipe_type == SP_HOLYNESS) return (40);
2232 /* Examine the item type */
2233 switch (o_ptr->tval)
2249 /* Sometimes break */
2254 return (20 - archer_bonus * 2);
2259 return (10 - archer_bonus);
2267 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2268 * Determines the odds of an object breaking when thrown at a monster
2269 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2270 * @param tdam 計算途中のダメージ量
2271 * @param m_ptr 目標モンスターの構造体参照ポインタ
2272 * @return スレイ倍率をかけたダメージ量
2274 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2278 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2280 BIT_FLAGS flgs[TR_FLAG_SIZE];
2282 /* Extract the flags */
2283 object_flags(o_ptr, flgs);
2285 /* Some "weapons" and "ammo" do extra damage */
2286 switch (o_ptr->tval)
2293 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2294 (r_ptr->flags3 & RF3_ANIMAL))
2296 if (is_original_ap_and_seen(m_ptr))
2298 r_ptr->r_flags3 |= RF3_ANIMAL;
2301 if (mult < 17) mult = 17;
2305 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2306 (r_ptr->flags3 & RF3_ANIMAL))
2308 if (is_original_ap_and_seen(m_ptr))
2310 r_ptr->r_flags3 |= RF3_ANIMAL;
2313 if (mult < 27) mult = 27;
2317 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2318 (r_ptr->flags3 & RF3_EVIL))
2320 if (is_original_ap_and_seen(m_ptr))
2322 r_ptr->r_flags3 |= RF3_EVIL;
2325 if (mult < 15) mult = 15;
2329 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2330 (r_ptr->flags3 & RF3_EVIL))
2332 if (is_original_ap_and_seen(m_ptr))
2334 r_ptr->r_flags3 |= RF3_EVIL;
2337 if (mult < 25) mult = 25;
2341 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2342 (r_ptr->flags2 & RF2_HUMAN))
2344 if (is_original_ap_and_seen(m_ptr))
2346 r_ptr->r_flags2 |= RF2_HUMAN;
2349 if (mult < 17) mult = 17;
2353 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2354 (r_ptr->flags2 & RF2_HUMAN))
2356 if (is_original_ap_and_seen(m_ptr))
2358 r_ptr->r_flags2 |= RF2_HUMAN;
2361 if (mult < 27) mult = 27;
2365 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2366 (r_ptr->flags3 & RF3_UNDEAD))
2368 if (is_original_ap_and_seen(m_ptr))
2370 r_ptr->r_flags3 |= RF3_UNDEAD;
2373 if (mult < 20) mult = 20;
2377 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2378 (r_ptr->flags3 & RF3_UNDEAD))
2380 if (is_original_ap_and_seen(m_ptr))
2382 r_ptr->r_flags3 |= RF3_UNDEAD;
2385 if (mult < 30) mult = 30;
2389 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2390 (r_ptr->flags3 & RF3_DEMON))
2392 if (is_original_ap_and_seen(m_ptr))
2394 r_ptr->r_flags3 |= RF3_DEMON;
2397 if (mult < 20) mult = 20;
2401 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2402 (r_ptr->flags3 & RF3_DEMON))
2404 if (is_original_ap_and_seen(m_ptr))
2406 r_ptr->r_flags3 |= RF3_DEMON;
2409 if (mult < 30) mult = 30;
2413 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2414 (r_ptr->flags3 & RF3_ORC))
2416 if (is_original_ap_and_seen(m_ptr))
2418 r_ptr->r_flags3 |= RF3_ORC;
2421 if (mult < 20) mult = 20;
2425 if ((have_flag(flgs, TR_KILL_ORC)) &&
2426 (r_ptr->flags3 & RF3_ORC))
2428 if (is_original_ap_and_seen(m_ptr))
2430 r_ptr->r_flags3 |= RF3_ORC;
2433 if (mult < 30) mult = 30;
2437 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2438 (r_ptr->flags3 & RF3_TROLL))
2440 if (is_original_ap_and_seen(m_ptr))
2442 r_ptr->r_flags3 |= RF3_TROLL;
2445 if (mult < 20) mult = 20;
2449 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2450 (r_ptr->flags3 & RF3_TROLL))
2452 if (is_original_ap_and_seen(m_ptr))
2454 r_ptr->r_flags3 |= RF3_TROLL;
2457 if (mult < 30) mult = 30;
2461 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2462 (r_ptr->flags3 & RF3_GIANT))
2464 if (is_original_ap_and_seen(m_ptr))
2466 r_ptr->r_flags3 |= RF3_GIANT;
2469 if (mult < 20) mult = 20;
2473 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2474 (r_ptr->flags3 & RF3_GIANT))
2476 if (is_original_ap_and_seen(m_ptr))
2478 r_ptr->r_flags3 |= RF3_GIANT;
2481 if (mult < 30) mult = 30;
2485 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
2486 (r_ptr->flags3 & RF3_DRAGON))
2488 if (is_original_ap_and_seen(m_ptr))
2490 r_ptr->r_flags3 |= RF3_DRAGON;
2493 if (mult < 20) mult = 20;
2496 /* Execute Dragon */
2497 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
2498 (r_ptr->flags3 & RF3_DRAGON))
2500 if (is_original_ap_and_seen(m_ptr))
2502 r_ptr->r_flags3 |= RF3_DRAGON;
2505 if (mult < 30) mult = 30;
2507 if ((o_ptr->name1 == ART_BARD_ARROW) &&
2508 (m_ptr->r_idx == MON_SMAUG) &&
2509 (inventory[INVEN_BOW].name1 == ART_BARD))
2514 if (have_flag(flgs, TR_BRAND_ACID))
2516 /* Notice immunity */
2517 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2519 if (is_original_ap_and_seen(m_ptr))
2521 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2525 /* Otherwise, take the damage */
2528 if (mult < 17) mult = 17;
2533 if (have_flag(flgs, TR_BRAND_ELEC))
2535 /* Notice immunity */
2536 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2538 if (is_original_ap_and_seen(m_ptr))
2540 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2544 /* Otherwise, take the damage */
2547 if (mult < 17) mult = 17;
2552 if (have_flag(flgs, TR_BRAND_FIRE))
2554 /* Notice immunity */
2555 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2557 if (is_original_ap_and_seen(m_ptr))
2559 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2563 /* Otherwise, take the damage */
2566 if (r_ptr->flags3 & RF3_HURT_FIRE)
2568 if (mult < 25) mult = 25;
2569 if (is_original_ap_and_seen(m_ptr))
2571 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2574 else if (mult < 17) mult = 17;
2579 if (have_flag(flgs, TR_BRAND_COLD))
2581 /* Notice immunity */
2582 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2584 if (is_original_ap_and_seen(m_ptr))
2586 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2589 /* Otherwise, take the damage */
2592 if (r_ptr->flags3 & RF3_HURT_COLD)
2594 if (mult < 25) mult = 25;
2595 if (is_original_ap_and_seen(m_ptr))
2597 r_ptr->r_flags3 |= RF3_HURT_COLD;
2600 else if (mult < 17) mult = 17;
2604 /* Brand (Poison) */
2605 if (have_flag(flgs, TR_BRAND_POIS))
2607 /* Notice immunity */
2608 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2610 if (is_original_ap_and_seen(m_ptr))
2612 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2616 /* Otherwise, take the damage */
2619 if (mult < 17) mult = 17;
2623 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2625 p_ptr->csp -= (1+(p_ptr->msp / 30));
2626 p_ptr->redraw |= (PR_MANA);
2627 mult = mult * 5 / 2;
2634 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2636 /* Return the total damage */
2637 return (tdam * mult / 10);
2642 * @brief 射撃処理のサブルーチン /
2643 * Fire an object from the pack or floor.
2644 * @param item 射撃するオブジェクトの所持ID
2645 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2649 * You may only fire items that "match" your missile launcher.
2651 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2653 * See "calc_bonuses()" for more calculations and such.
2655 * Note that "firing" a missile is MUCH better than "throwing" it.
2657 * Note: "unseen" monsters are very hard to hit.
2659 * Objects are more likely to break if they "attempt" to hit a monster.
2661 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2663 * The "extra shot" code works by decreasing the amount of energy
2664 * required to make each shot, spreading the shots out over time.
2666 * Note that when firing missiles, the launcher multiplier is applied
2667 * after all the bonuses are added in, making multipliers very useful.
2669 * Note that Bows of "Extra Might" get extra range and an extra bonus
2670 * for the damage multiplier.
2672 * Note that Bows of "Extra Shots" give an extra shot.
2675 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2679 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2680 int tdam_base, tdis, thits, tmul;
2682 int cur_dis, visible;
2690 bool hit_body = FALSE;
2692 char o_name[MAX_NLEN];
2694 u16b path_g[512]; /* For calcuration of path length */
2696 int msec = delay_factor * delay_factor * delay_factor;
2699 bool stick_to = FALSE;
2701 /* Access the item (if in the pack) */
2704 o_ptr = &inventory[item];
2708 o_ptr = &o_list[0 - item];
2711 /* Sniper - Cannot shot a single arrow twice */
2712 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2714 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2716 /* Use the proper number of shots */
2717 thits = p_ptr->num_fire;
2719 /* Use a base distance */
2722 /* Base damage from thrown object plus launcher bonus */
2723 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2725 /* Actually "fire" the object */
2726 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2727 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2728 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2730 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2732 p_ptr->energy_use = bow_energy(j_ptr->sval);
2733 tmul = bow_tmul(j_ptr->sval);
2735 /* Get extra "power" from "extra might" */
2736 if (p_ptr->xtra_might) tmul++;
2738 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2740 /* Boost the damage */
2745 tdis = 13 + tmul/80;
2746 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2749 tdis -= (5 - (p_ptr->concent + 1) / 2);
2754 project_length = tdis + 1;
2756 /* Get a direction (or cancel) */
2757 if (!get_aim_dir(&dir))
2759 p_ptr->energy_use = 0;
2761 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2763 /* need not to reset project_length (already did)*/
2768 /* Predict the "target" location */
2769 tx = p_ptr->x + 99 * ddx[dir];
2770 ty = p_ptr->y + 99 * ddy[dir];
2772 /* Check for "target request" */
2773 if ((dir == 5) && target_okay())
2779 /* Get projection path length */
2780 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2782 project_length = 0; /* reset to default */
2784 /* Don't shoot at my feet */
2785 if (tx == p_ptr->x && ty == p_ptr->y)
2787 p_ptr->energy_use = 0;
2789 /* project_length is already reset to 0 */
2795 /* Take a (partial) turn */
2796 p_ptr->energy_use = (p_ptr->energy_use / thits);
2799 /* Sniper - Difficult to shot twice at 1 turn */
2800 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2802 /* Sniper - Repeat shooting when double shots */
2803 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2806 /* Start at the player */
2811 /* Obtain a local object */
2812 object_copy(q_ptr, o_ptr);
2817 /* Reduce and describe inventory */
2820 inven_item_increase(item, -1);
2821 inven_item_describe(item);
2822 inven_item_optimize(item);
2825 /* Reduce and describe floor item */
2828 floor_item_increase(0 - item, -1);
2829 floor_item_optimize(0 - item);
2835 /* Save the old location */
2839 /* The shot does not hit yet */
2842 /* Travel until stopped */
2843 for (cur_dis = 0; cur_dis <= tdis; )
2847 /* Hack -- Stop at the target */
2848 if ((y == ty) && (x == tx)) break;
2850 /* Calculate the new location (see "project()") */
2853 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2856 if (snipe_type == SP_KILL_WALL)
2858 c_ptr = &cave[ny][nx];
2860 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2862 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2863 /* Forget the wall */
2864 c_ptr->info &= ~(CAVE_MARK);
2866 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2868 /* Destroy the wall */
2869 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2876 /* Stopped by walls/doors */
2877 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2879 /* Advance the distance */
2883 if (snipe_type == SP_LITE)
2885 cave[ny][nx].info |= (CAVE_GLOW);
2892 /* The player can see the (on screen) missile */
2893 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2895 char c = object_char(q_ptr);
2896 byte a = object_attr(q_ptr);
2898 /* Draw, Hilite, Fresh, Pause, Erase */
2899 print_rel(c, a, ny, nx);
2900 move_cursor_relative(ny, nx);
2902 Term_xtra(TERM_XTRA_DELAY, msec);
2907 /* The player cannot see the missile */
2910 /* Pause anyway, for consistancy */
2911 Term_xtra(TERM_XTRA_DELAY, msec);
2915 if (snipe_type == SP_KILL_TRAP)
2917 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
2918 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
2922 if (snipe_type == SP_EVILNESS)
2924 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
2931 /* Save the old location */
2935 /* Save the new location */
2940 /* Monster here, Try to hit it */
2941 if (cave[y][x].m_idx)
2943 cave_type *c_mon_ptr = &cave[y][x];
2945 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
2946 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2948 /* Check the visibility */
2949 visible = m_ptr->ml;
2951 /* Note the collision */
2954 if (MON_CSLEEP(m_ptr))
2956 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
2957 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
2960 if ((r_ptr->level + 10) > p_ptr->lev)
2962 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
2963 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
2966 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
2967 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
2968 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
2969 else if (p_ptr->lev > 34) amount = 2;
2970 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
2971 p_ptr->update |= (PU_BONUS);
2977 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
2978 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
2981 p_ptr->skill_exp[GINOU_RIDING] += 1;
2982 p_ptr->update |= (PU_BONUS);
2986 /* Did we hit it (penalize range) */
2987 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2990 int tdam = tdam_base;
2992 /* Get extra damage from concentration */
2993 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
2995 /* Handle unseen monster */
2998 /* Invisible monster */
2999 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3002 /* Handle visible monster */
3007 /* Get "the monster" or "it" */
3008 monster_desc(m_name, m_ptr, 0);
3010 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3014 /* Hack -- Track this monster race */
3015 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3017 /* Hack -- Track this monster */
3018 health_track(c_mon_ptr->m_idx);
3022 if (snipe_type == SP_NEEDLE)
3024 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3025 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3029 /* Get "the monster" or "it" */
3030 monster_desc(m_name, m_ptr, 0);
3032 tdam = m_ptr->hp + 1;
3033 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3039 /* Apply special damage */
3040 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3041 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3043 /* No negative damage */
3044 if (tdam < 0) tdam = 0;
3046 /* Modify the damage */
3047 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3050 msg_format_wizard(CHEAT_MONSTER,
3051 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3052 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3055 if (snipe_type == SP_EXPLODE)
3057 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3059 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3060 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3065 if (snipe_type == SP_HOLYNESS)
3067 cave[ny][nx].info |= (CAVE_GLOW);
3072 /* Hit the monster, check for death */
3073 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
3082 if (object_is_fixed_artifact(q_ptr) &&
3083 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3087 monster_desc(m_name, m_ptr, 0);
3090 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3093 message_pain(c_mon_ptr->m_idx, tdam);
3095 /* Anger the monster */
3096 if (tdam > 0) anger_monster(m_ptr);
3099 if (fear && m_ptr->ml)
3105 /* Get the monster name (or "it") */
3106 monster_desc(m_name, m_ptr, 0);
3108 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3111 set_target(m_ptr, p_ptr->y, p_ptr->x);
3114 if (snipe_type == SP_RUSH)
3116 int n = randint1(5) + 3;
3117 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3119 for ( ; cur_dis <= tdis; )
3126 /* Calculate the new location (see "project()") */
3127 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3129 /* Stopped by wilderness boundary */
3130 if (!in_bounds2(ny, nx)) break;
3132 /* Stopped by walls/doors */
3133 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3135 /* Stopped by monsters */
3136 if (!cave_empty_bold(ny, nx)) break;
3138 cave[ny][nx].m_idx = m_idx;
3139 cave[oy][ox].m_idx = 0;
3144 /* Update the monster (new location) */
3145 update_monster(c_mon_ptr->m_idx, TRUE);
3151 Term_xtra(TERM_XTRA_DELAY, msec);
3163 if (snipe_type == SP_PIERCE)
3165 if(p_ptr->concent < 1) break;
3175 /* Chance of breakage (during attacks) */
3176 j = (hit_body ? breakage_chance(q_ptr) : 0);
3180 MONSTER_IDX m_idx = cave[y][x].m_idx;
3181 monster_type *m_ptr = &m_list[m_idx];
3182 OBJECT_IDX o_idx = o_pop();
3186 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3187 if (object_is_fixed_artifact(q_ptr))
3189 a_info[j_ptr->name1].cur_num = 0;
3194 o_ptr = &o_list[o_idx];
3195 object_copy(o_ptr, q_ptr);
3198 o_ptr->marked &= OM_TOUCHED;
3200 /* Forget location */
3201 o_ptr->iy = o_ptr->ix = 0;
3203 /* Memorize monster */
3204 o_ptr->held_m_idx = m_idx;
3207 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3210 m_ptr->hold_o_idx = o_idx;
3212 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3214 /* Drop (or break) near that location */
3215 (void)drop_near(q_ptr, j, y, x);
3219 /* Drop (or break) near that location */
3220 (void)drop_near(q_ptr, j, prev_y, prev_x);
3223 /* Sniper - Repeat shooting when double shots */
3226 /* Sniper - Loose his/her concentration after any shot */
3227 if (p_ptr->concent) reset_concentration(FALSE);
3231 * @brief 射撃処理のメインルーチン
3234 void do_cmd_fire(void)
3240 is_fired = FALSE; /* not fired yet */
3242 /* Get the "bow" (if any) */
3243 j_ptr = &inventory[INVEN_BOW];
3245 /* Require a launcher */
3248 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3253 if (j_ptr->sval == SV_CRIMSON)
3255 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3260 if (j_ptr->sval == SV_HARP)
3262 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3268 if (p_ptr->special_defense & KATA_MUSOU)
3270 set_action(ACTION_NONE);
3273 /* Require proper missile */
3274 item_tester_tval = p_ptr->tval_ammo;
3276 q = _("どれを撃ちますか? ", "Fire which item? ");
3277 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3278 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3285 do_cmd_fire_aux(item, j_ptr);
3287 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3289 /* Sniper actions after some shootings */
3290 if (snipe_type == SP_AWAY)
3292 teleport_player(10 + (p_ptr->concent * 2), 0L);
3294 if (snipe_type == SP_FINAL)
3296 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3297 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3298 (void)set_stun(p_ptr->stun + randint1(25));
3304 * @brief 投射処理メインルーチン /
3305 * Throw an object from the pack or floor.
3307 * @param boomerang ブーメラン処理ならばTRUE
3308 * @param shuriken 忍者の手裏剣処理ならばTRUE
3309 * @return ターンを消費した場合TRUEを返す
3312 * Note: "unseen" monsters are very hard to hit.
3314 * Should throwing a weapon do full damage? Should it allow the magic
3315 * to hit bonus of the weapon to have an effect? Should it ever cause
3316 * the item to be destroyed? Should it do any damage at all?
3319 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3324 POSITION y, x, ty, tx, prev_y, prev_x;
3325 POSITION ny[19], nx[19];
3326 int chance, tdam, tdis;
3327 int mul, div, dd, ds;
3328 int cur_dis, visible;
3336 bool hit_body = FALSE;
3337 bool hit_wall = FALSE;
3338 bool equiped_item = FALSE;
3339 bool return_when_thrown = FALSE;
3341 char o_name[MAX_NLEN];
3343 int msec = delay_factor * delay_factor * delay_factor;
3345 BIT_FLAGS flgs[TR_FLAG_SIZE];
3347 bool come_back = FALSE;
3348 bool do_drop = TRUE;
3351 if (p_ptr->special_defense & KATA_MUSOU)
3353 set_action(ACTION_NONE);
3362 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3364 item_tester_hook = item_tester_hook_boomerang;
3365 q = _("どの武器を投げますか? ", "Throw which item? ");
3366 s = _("投げる武器がない。", "You have nothing to throw.");
3367 if (!get_item(&item, q, s, (USE_EQUIP)))
3373 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3374 else item = INVEN_RARM;
3378 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3379 s = _("投げるアイテムがない。", "You have nothing to throw.");
3380 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3387 /* Access the item (if in the pack) */
3390 o_ptr = &inventory[item];
3394 o_ptr = &o_list[0 - item];
3397 /* Item is cursed */
3398 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3400 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3405 if (p_ptr->inside_arena && !boomerang)
3407 if (o_ptr->tval != TV_SPIKE)
3409 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3418 /* Obtain a local object */
3419 object_copy(q_ptr, o_ptr);
3421 /* Extract the thrown object's flags. */
3422 object_flags(q_ptr, flgs);
3423 torch_flags(q_ptr, flgs);
3425 /* Distribute the charges of rods/wands between the stacks */
3426 distribute_charges(o_ptr, q_ptr, 1);
3432 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3434 if (p_ptr->mighty_throw) mult += 3;
3436 /* Extract a "distance multiplier" */
3437 /* Changed for 'launcher' mutation */
3438 mul = 10 + 2 * (mult - 1);
3440 /* Enforce a minimum "weight" of one pound */
3441 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3442 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3444 /* Hack -- Distance -- Reward strength, penalize weight */
3445 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3447 /* Max distance of 10-18 */
3448 if (tdis > mul) tdis = mul;
3452 ty = randint0(101) - 50 + p_ptr->y;
3453 tx = randint0(101) - 50 + p_ptr->x;
3457 project_length = tdis + 1;
3459 /* Get a direction (or cancel) */
3460 if (!get_aim_dir(&dir)) return FALSE;
3462 /* Predict the "target" location */
3463 tx = p_ptr->x + 99 * ddx[dir];
3464 ty = p_ptr->y + 99 * ddy[dir];
3466 /* Check for "target request" */
3467 if ((dir == 5) && target_okay())
3473 project_length = 0; /* reset to default */
3476 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3477 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3478 return_when_thrown = TRUE;
3480 /* Reduce and describe inventory */
3483 inven_item_increase(item, -1);
3484 if (!return_when_thrown)
3485 inven_item_describe(item);
3486 inven_item_optimize(item);
3489 /* Reduce and describe floor item */
3492 floor_item_increase(0 - item, -1);
3493 floor_item_optimize(0 - item);
3495 if (item >= INVEN_RARM)
3497 equiped_item = TRUE;
3498 p_ptr->redraw |= (PR_EQUIPPY);
3501 p_ptr->energy_use = 100;
3503 /* Rogue and Ninja gets bonus */
3504 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3505 p_ptr->energy_use -= p_ptr->lev;
3507 /* Start at the player */
3513 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3514 else shuriken = FALSE;
3516 /* Chance of hitting */
3517 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3518 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3519 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3521 if (shuriken) chance *= 2;
3523 /* Save the old location */
3527 /* Travel until stopped */
3528 for (cur_dis = 0; cur_dis <= tdis; )
3530 /* Hack -- Stop at the target */
3531 if ((y == ty) && (x == tx)) break;
3533 /* Calculate the new location (see "project()") */
3536 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3538 /* Stopped by walls/doors */
3539 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3542 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3545 /* The player can see the (on screen) missile */
3546 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3548 char c = object_char(q_ptr);
3549 byte a = object_attr(q_ptr);
3551 /* Draw, Hilite, Fresh, Pause, Erase */
3552 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3553 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3555 Term_xtra(TERM_XTRA_DELAY, msec);
3556 lite_spot(ny[cur_dis], nx[cur_dis]);
3560 /* The player cannot see the missile */
3563 /* Pause anyway, for consistancy */
3564 Term_xtra(TERM_XTRA_DELAY, msec);
3567 /* Save the old location */
3571 /* Save the new location */
3575 /* Advance the distance */
3578 /* Monster here, Try to hit it */
3579 if (cave[y][x].m_idx)
3581 cave_type *c_ptr = &cave[y][x];
3582 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3584 /* Check the visibility */
3585 visible = m_ptr->ml;
3587 /* Note the collision */
3590 /* Did we hit it (penalize range) */
3591 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3595 /* Handle unseen monster */
3598 /* Invisible monster */
3599 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3602 /* Handle visible monster */
3607 /* Get "the monster" or "it" */
3608 monster_desc(m_name, m_ptr, 0);
3610 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3614 /* Hack -- Track this monster race */
3615 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3617 /* Hack -- Track this monster */
3618 health_track(c_ptr->m_idx);
3622 /* Hack -- Base damage from thrown object */
3625 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3626 tdam = damroll(dd, ds);
3627 /* Apply special damage */
3628 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3629 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3630 if (q_ptr->to_d > 0)
3631 tdam += q_ptr->to_d;
3633 tdam += -q_ptr->to_d;
3637 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3638 tdam += p_ptr->to_d_m;
3640 else if (have_flag(flgs, TR_THROW))
3643 tdam += p_ptr->to_d_m;
3651 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3654 /* No negative damage */
3655 if (tdam < 0) tdam = 0;
3657 /* Modify the damage */
3658 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3660 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3661 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3663 /* Hit the monster, check for death */
3664 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
3672 message_pain(c_ptr->m_idx, tdam);
3674 /* Anger the monster */
3675 if ((tdam > 0) && !object_is_potion(q_ptr))
3676 anger_monster(m_ptr);
3679 if (fear && m_ptr->ml)
3685 /* Get the monster name (or "it") */
3686 monster_desc(m_name, m_ptr, 0);
3688 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3698 /* decrease toach's fuel */
3699 if (hit_body) torch_lost_fuel(q_ptr);
3701 /* Chance of breakage (during attacks) */
3702 j = (hit_body ? breakage_chance(q_ptr) : 0);
3704 /* Figurines transform */
3705 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3709 if (!(summon_named_creature(0, y, x, q_ptr->pval,
3710 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3711 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3712 else if (object_is_cursed(q_ptr))
3713 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3718 /* Potions smash open */
3719 if (object_is_potion(q_ptr))
3721 if (hit_body || hit_wall || (randint1(100) < j))
3723 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3725 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3727 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3729 /* ToDo (Robert): fix the invulnerability */
3730 if (cave[y][x].m_idx &&
3731 is_friendly(&m_list[cave[y][x].m_idx]) &&
3732 !MON_INVULNER(m_ptr))
3735 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3736 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3737 set_hostile(&m_list[cave[y][x].m_idx]);
3748 if (return_when_thrown)
3750 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3751 char o2_name[MAX_NLEN];
3752 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3755 if (boomerang) back_chance += 4+randint1(5);
3756 if (super_boomerang) back_chance += 100;
3757 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3759 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3761 for (i = cur_dis - 1; i > 0; i--)
3763 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3765 char c = object_char(q_ptr);
3766 byte a = object_attr(q_ptr);
3768 /* Draw, Hilite, Fresh, Pause, Erase */
3769 print_rel(c, a, ny[i], nx[i]);
3770 move_cursor_relative(ny[i], nx[i]);
3772 Term_xtra(TERM_XTRA_DELAY, msec);
3773 lite_spot(ny[i], nx[i]);
3778 /* Pause anyway, for consistancy */
3779 Term_xtra(TERM_XTRA_DELAY, msec);
3782 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3784 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3791 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3795 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3803 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3809 if (item == INVEN_RARM || item == INVEN_LARM)
3811 /* Access the wield slot */
3812 o_ptr = &inventory[item];
3814 /* Wear the new stuff */
3815 object_copy(o_ptr, q_ptr);
3817 /* Increase the weight */
3818 p_ptr->total_weight += q_ptr->weight;
3820 /* Increment the equip counter by hand */
3823 /* Recalculate bonuses */
3824 p_ptr->update |= (PU_BONUS);
3826 /* Recalculate torch */
3827 p_ptr->update |= (PU_TORCH);
3829 /* Recalculate mana XXX */
3830 p_ptr->update |= (PU_MANA);
3832 p_ptr->window |= (PW_EQUIP);
3840 else if (equiped_item)
3846 /* Drop (or break) near that location */
3849 if (cave_have_flag_bold(y, x, FF_PROJECT))
3851 /* Drop (or break) near that location */
3852 (void)drop_near(q_ptr, j, y, x);
3856 /* Drop (or break) near that location */
3857 (void)drop_near(q_ptr, j, prev_y, prev_x);
3867 * Hack: travel command
3869 #define TRAVEL_UNABLE 9999
3871 static int flow_head = 0;
3872 static int flow_tail = 0;
3873 static POSITION temp2_x[MAX_SHORT];
3874 static POSITION temp2_y[MAX_SHORT];
3877 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3880 void forget_travel_flow(void)
3884 /* Check the entire dungeon */
3885 for (y = 0; y < cur_hgt; y++)
3887 for (x = 0; x < cur_wid; x++)
3889 /* Forget the old data */
3890 travel.cost[y][x] = MAX_SHORT;
3894 travel.y = travel.x = 0;
3898 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
3903 static int travel_flow_cost(POSITION y, POSITION x)
3905 feature_type *f_ptr = &f_info[cave[y][x].feat];
3908 /* Avoid obstacles (ex. trees) */
3909 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
3912 if (have_flag(f_ptr->flags, FF_WATER))
3914 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
3918 if (have_flag(f_ptr->flags, FF_LAVA))
3921 if (!p_ptr->resist_fire) lava *= 2;
3922 if (!p_ptr->levitation) lava *= 2;
3923 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
3928 /* Detected traps and doors */
3929 if (cave[y][x].info & (CAVE_MARK))
3931 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
3932 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
3939 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
3943 * @param wall プレイヤーが壁の中にいるならばTRUE
3946 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
3948 cave_type *c_ptr = &cave[y][x];
3949 feature_type *f_ptr = &f_info[c_ptr->feat];
3950 int old_head = flow_head;
3952 int base_cost = (n % TRAVEL_UNABLE);
3953 int from_wall = (n / TRAVEL_UNABLE);
3956 /* Ignore out of bounds */
3957 if (!in_bounds(y, x)) return;
3959 /* Ignore unknown grid except in wilderness */
3960 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
3962 /* Ignore "walls" and "rubble" (include "secret doors") */
3963 if (have_flag(f_ptr->flags, FF_WALL) ||
3964 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3965 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
3966 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
3968 if (!wall || !from_wall) return;
3969 add_cost += TRAVEL_UNABLE;
3973 add_cost = travel_flow_cost(y, x);
3976 cost = base_cost + add_cost;
3978 /* Ignore lower cost entries */
3979 if (travel.cost[y][x] <= cost) return;
3981 /* Save the flow cost */
3982 travel.cost[y][x] = cost;
3984 /* Enqueue that entry */
3985 temp2_y[flow_head] = y;
3986 temp2_x[flow_head] = x;
3988 /* Advance the queue */
3989 if (++flow_head == MAX_SHORT) flow_head = 0;
3991 /* Hack -- notice overflow by forgetting new entry */
3992 if (flow_head == flow_tail) flow_head = old_head;
3998 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
3999 * @param ty 目標地点のY座標
4000 * @param tx 目標地点のX座標
4003 static void travel_flow(POSITION ty, POSITION tx)
4007 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
4009 /* Reset the "queue" */
4010 flow_head = flow_tail = 0;
4012 /* is player in the wall? */
4013 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4015 /* Start at the target grid */
4016 travel_flow_aux(ty, tx, 0, wall);
4018 /* Now process the queue */
4019 while (flow_head != flow_tail)
4021 /* Extract the next entry */
4022 y = temp2_y[flow_tail];
4023 x = temp2_x[flow_tail];
4025 /* Forget that entry */
4026 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4028 /* Ignore too far entries */
4029 //if (distance(ty, tx, y, x) > 100) continue;
4031 /* Add the "children" */
4032 for (d = 0; d < 8; d++)
4034 /* Add that child if "legal" */
4035 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4039 /* Forget the flow info */
4040 flow_head = flow_tail = 0;
4044 * @brief トラベル処理のメインルーチン
4047 void do_cmd_travel(void)
4052 feature_type *f_ptr;
4054 if (travel.x != 0 && travel.y != 0 &&
4055 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4060 else if (!tgt_pt(&x, &y)) return;
4062 if ((x == p_ptr->x) && (y == p_ptr->y))
4064 msg_print(_("すでにそこにいます!", "You are already there!!"));
4068 f_ptr = &f_info[cave[y][x].feat];
4070 if ((cave[y][x].info & CAVE_MARK) &&
4071 (have_flag(f_ptr->flags, FF_WALL) ||
4072 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4073 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4075 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4079 forget_travel_flow();
4085 /* Travel till 255 steps */
4091 /* Decides first direction */
4092 dx = abs(p_ptr->x - x);
4093 dy = abs(p_ptr->y - y);
4094 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4095 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4097 for (i = 1; i <= 9; i++)
4099 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;