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 /* Get grid and contents */
851 cave_type *c_ptr = &cave[y][x];
852 FEAT_IDX old_feat = c_ptr->feat;
855 p_ptr->energy_use = 100;
857 /* Seeing true feature code (ignore mimic) */
860 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
862 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
864 /* Hack -- object in the way */
865 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
866 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
868 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
873 cave_alter_feat(y, x, FF_CLOSE);
876 if (old_feat == c_ptr->feat)
878 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
882 sound(SOUND_SHUTDOOR);
891 * @brief 「閉じる」コマンドのメインルーチン /
892 * Close an open door.
895 * Unlocking a locked door/chest is worth one experience point.
897 void do_cmd_close(void)
904 if (p_ptr->special_defense & KATA_MUSOU)
906 set_action(ACTION_NONE);
909 /* Option: Pick a direction */
912 /* Count open doors */
913 if (count_dt(&y, &x, is_open, FALSE) == 1)
915 command_dir = coords_to_dir(y, x);
919 /* Allow repeated command */
922 /* Set repeat count */
923 command_rep = command_arg - 1;
925 /* Redraw the state */
926 p_ptr->redraw |= (PR_STATE);
932 /* Get a "repeated" direction */
933 if (get_rep_dir(&dir, FALSE))
938 /* Get requested location */
939 y = p_ptr->y + ddy[dir];
940 x = p_ptr->x + ddx[dir];
942 /* Get grid and contents */
945 /* Feature code (applying "mimic" field) */
946 feat = get_feat_mimic(c_ptr);
948 /* Require open/broken door */
949 if (!have_flag(f_info[feat].flags, FF_CLOSE))
951 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
954 /* Monster in the way */
955 else if (c_ptr->m_idx)
957 p_ptr->energy_use = 100;
959 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
969 more = do_cmd_close_aux(y, x);
973 /* Cancel repeat unless we may continue */
974 if (!more) disturb(FALSE, FALSE);
979 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
980 * Determine if a given grid may be "tunneled"
981 * @param y 対象を行うマスのY座標
982 * @param x 対象を行うマスのX座標
985 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
987 cave_type *c_ptr = &cave[y][x];
989 /* Must have knowledge */
990 if (!(c_ptr->info & CAVE_MARK))
992 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
997 /* Must be a wall/door/etc */
998 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1000 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1010 * @brief 「掘る」動作コマンドのサブルーチン /
1011 * Perform the basic "tunnel" command
1012 * @param y 対象を行うマスのY座標
1013 * @param x 対象を行うマスのX座標
1014 * @return 実際に処理が行われた場合TRUEを返す。
1016 * Assumes that no monster is blocking the destination
1017 * Do not use twall anymore
1018 * Returns TRUE if repeated commands may continue
1020 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1023 feature_type *f_ptr, *mimic_f_ptr;
1028 /* Verify legality */
1029 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1031 p_ptr->energy_use = 100;
1034 c_ptr = &cave[y][x];
1035 f_ptr = &f_info[c_ptr->feat];
1036 power = f_ptr->power;
1038 /* Feature code (applying "mimic" field) */
1039 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1041 name = f_name + mimic_f_ptr->name;
1045 if (have_flag(f_ptr->flags, FF_PERMANENT))
1048 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1050 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1053 /* Map border (mimiccing Permanent wall) */
1056 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1061 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1064 if (p_ptr->skill_dig > randint0(20 * power))
1066 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1068 /* Remove the feature */
1069 cave_alter_feat(y, x, FF_TUNNEL);
1071 /* Update some things */
1072 p_ptr->update |= (PU_FLOW);
1076 /* Message, keep digging */
1077 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1085 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1088 if (p_ptr->skill_dig > power + randint0(40 * power))
1090 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1093 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1094 p_ptr->update |= (PU_FLOW);
1097 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1099 /* Remove the feature */
1100 cave_alter_feat(y, x, FF_TUNNEL);
1102 chg_virtue(V_DILIGENCE, 1);
1103 chg_virtue(V_NATURE, -1);
1111 /* We may continue chopping */
1112 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1113 /* Occasional Search XXX XXX */
1114 if (randint0(100) < 25) search();
1118 /* We may continue tunelling */
1119 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1126 if (is_hidden_door(c_ptr))
1128 /* Occasional Search XXX XXX */
1129 if (randint0(100) < 25) search();
1136 * @brief 「掘る」動作コマンドのメインルーチン /
1137 * Tunnels through "walls" (including rubble and closed doors)
1141 * Note that you must tunnel in order to hit invisible monsters
1142 * in walls, though moving into walls still takes a turn anyway.
1144 * Digging is very difficult without a "digger" weapon, but can be
1145 * accomplished by strong players using heavy weapons.
1148 void do_cmd_tunnel(void)
1158 if (p_ptr->special_defense & KATA_MUSOU)
1160 set_action(ACTION_NONE);
1163 /* Allow repeated command */
1166 /* Set repeat count */
1167 command_rep = command_arg - 1;
1169 /* Redraw the state */
1170 p_ptr->redraw |= (PR_STATE);
1172 /* Cancel the arg */
1176 /* Get a direction to tunnel, or Abort */
1177 if (get_rep_dir(&dir,FALSE))
1180 y = p_ptr->y + ddy[dir];
1181 x = p_ptr->x + ddx[dir];
1184 c_ptr = &cave[y][x];
1186 /* Feature code (applying "mimic" field) */
1187 feat = get_feat_mimic(c_ptr);
1189 /* No tunnelling through doors */
1190 if (have_flag(f_info[feat].flags, FF_DOOR))
1192 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1195 /* No tunnelling through most features */
1196 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1198 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1201 /* A monster is in the way */
1202 else if (c_ptr->m_idx)
1204 p_ptr->energy_use = 100;
1206 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1215 /* Tunnel through walls */
1216 more = do_cmd_tunnel_aux(y, x);
1220 /* Cancel repetition unless we can continue */
1221 if (!more) disturb(FALSE, FALSE);
1225 * @brief 移動処理による簡易な「開く」処理 /
1227 * @return 開く処理が実際に試みられた場合TRUEを返す
1230 * If there is a jammed/closed/locked door at the given location,
1231 * then attempt to unlock/open it. Return TRUE if an attempt was
1232 * made (successful or not), otherwise return FALSE.
1234 * The code here should be nearly identical to that in
1235 * do_cmd_open_test() and do_cmd_open_aux().
1238 bool easy_open_door(POSITION y, POSITION x)
1242 cave_type *c_ptr = &cave[y][x];
1243 feature_type *f_ptr = &f_info[c_ptr->feat];
1245 /* Must be a closed door */
1246 if (!is_closed_door(c_ptr->feat))
1252 if (!have_flag(f_ptr->flags, FF_OPEN))
1255 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1260 else if (f_ptr->power)
1263 i = p_ptr->skill_dis;
1265 /* Penalize some conditions */
1266 if (p_ptr->blind || no_lite()) i = i / 10;
1267 if (p_ptr->confused || p_ptr->image) i = i / 10;
1269 /* Extract the lock power */
1272 /* Extract the difficulty */
1275 /* Always have a small chance of success */
1279 if (randint0(100) < j)
1281 msg_print(_("鍵をはずした。", "You have picked the lock."));
1284 cave_alter_feat(y, x, FF_OPEN);
1286 sound(SOUND_OPENDOOR);
1296 if (flush_failure) flush();
1298 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1307 cave_alter_feat(y, x, FF_OPEN);
1309 sound(SOUND_OPENDOOR);
1315 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1316 * Perform the basic "disarm" command
1317 * @param y 解除を行うマスのY座標
1318 * @param x 解除を行うマスのX座標
1319 * @param o_idx 箱のオブジェクトID
1320 * @return ターンを消費する処理が行われた場合TRUEを返す
1323 * Assume destination is a visible trap
1324 * Assume there is no monster blocking the destination
1325 * Returns TRUE if repeated commands may continue
1328 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1332 object_type *o_ptr = &o_list[o_idx];
1334 p_ptr->energy_use = 100;
1336 /* Get the "disarm" factor */
1337 i = p_ptr->skill_dis;
1339 /* Penalize some conditions */
1340 if (p_ptr->blind || no_lite()) i = i / 10;
1341 if (p_ptr->confused || p_ptr->image) i = i / 10;
1343 /* Extract the difficulty */
1344 j = i - o_ptr->pval;
1346 /* Always have a small chance of success */
1349 /* Must find the trap first. */
1350 if (!object_is_known(o_ptr))
1352 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1356 /* Already disarmed/unlocked */
1357 else if (o_ptr->pval <= 0)
1359 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1362 /* No traps to find. */
1363 else if (!chest_traps[o_ptr->pval])
1365 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1368 /* Success (get a lot of experience) */
1369 else if (randint0(100) < j)
1371 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1372 gain_exp(o_ptr->pval);
1373 o_ptr->pval = (0 - o_ptr->pval);
1376 /* Failure -- Keep trying */
1377 else if ((i > 5) && (randint1(i) > 5))
1379 /* We may keep trying */
1381 if (flush_failure) flush();
1382 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1385 /* Failure -- Set off the trap */
1388 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1390 chest_trap(y, x, o_idx);
1397 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1398 * Perform the basic "disarm" command
1399 * @param y 解除を行うマスのY座標
1400 * @param x 解除を行うマスのX座標
1401 * @param dir プレイヤーからみた方向ID
1402 * @return ターンを消費する処理が行われた場合TRUEを返す
1405 * Assume destination is a visible trap
1406 * Assume there is no monster blocking the destination
1407 * Returns TRUE if repeated commands may continue
1411 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1413 /* Get grid and contents */
1414 cave_type *c_ptr = &cave[y][x];
1417 feature_type *f_ptr = &f_info[c_ptr->feat];
1419 /* Access trap name */
1420 cptr name = (f_name + f_ptr->name);
1422 /* Extract trap "power" */
1423 int power = f_ptr->power;
1426 /* Get the "disarm" factor */
1427 int i = p_ptr->skill_dis;
1430 p_ptr->energy_use = 100;
1432 /* Penalize some conditions */
1433 if (p_ptr->blind || no_lite()) i = i / 10;
1434 if (p_ptr->confused || p_ptr->image) i = i / 10;
1436 /* Extract the difficulty */
1439 /* Always have a small chance of success */
1443 if (randint0(100) < j)
1445 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1450 /* Remove the trap */
1451 cave_alter_feat(y, x, FF_DISARM);
1453 /* Move the player onto the trap */
1454 move_player(dir, easy_disarm, FALSE);
1457 /* Failure -- Keep trying */
1458 else if ((i > 5) && (randint1(i) > 5))
1461 if (flush_failure) flush();
1463 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1465 /* We may keep trying */
1469 /* Failure -- Set off the trap */
1472 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1473 /* Move the player onto the trap */
1474 move_player(dir, easy_disarm, FALSE);
1481 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1482 * Disarms a trap, or chest
1485 void do_cmd_disarm(void)
1493 if (p_ptr->special_defense & KATA_MUSOU)
1495 set_action(ACTION_NONE);
1499 /* Option: Pick a direction */
1502 int num_traps, num_chests;
1504 /* Count visible traps */
1505 num_traps = count_dt(&y, &x, is_trap, TRUE);
1507 /* Count chests (trapped) */
1508 num_chests = count_chests(&y, &x, TRUE);
1510 /* See if only one target */
1511 if (num_traps || num_chests)
1513 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1514 if (!too_many) command_dir = coords_to_dir(y, x);
1519 /* Allow repeated command */
1522 /* Set repeat count */
1523 command_rep = command_arg - 1;
1525 /* Redraw the state */
1526 p_ptr->redraw |= (PR_STATE);
1528 /* Cancel the arg */
1532 /* Get a direction (or abort) */
1533 if (get_rep_dir(&dir,TRUE))
1539 y = p_ptr->y + ddy[dir];
1540 x = p_ptr->x + ddx[dir];
1542 /* Get grid and contents */
1543 c_ptr = &cave[y][x];
1545 /* Feature code (applying "mimic" field) */
1546 feat = get_feat_mimic(c_ptr);
1548 /* Check for chests */
1549 o_idx = chest_check(y, x, TRUE);
1552 if (!is_trap(feat) && !o_idx)
1554 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1557 /* Monster in the way */
1558 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1560 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1569 /* Disarm the chest */
1570 more = do_cmd_disarm_chest(y, x, o_idx);
1576 /* Disarm the trap */
1577 more = do_cmd_disarm_aux(y, x, dir);
1581 /* Cancel repeat unless told not to */
1582 if (!more) disturb(FALSE, FALSE);
1587 * @brief 「打ち破る」動作コマンドのサブルーチン /
1588 * Perform the basic "bash" command
1589 * @param y 対象を行うマスのY座標
1590 * @param x 対象を行うマスのX座標
1591 * @param dir プレイヤーから見たターゲットの方角ID
1592 * @return 実際に処理が行われた場合TRUEを返す。
1595 * Assume destination is a closed/locked/jammed door
1596 * Assume there is no monster blocking the destination
1597 * Returns TRUE if repeated commands may continue
1600 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1603 cave_type *c_ptr = &cave[y][x];
1606 feature_type *f_ptr = &f_info[c_ptr->feat];
1608 /* Hack -- Bash power based on strength */
1609 /* (Ranges from 3 to 20 to 100 to 200) */
1610 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1612 /* Extract door power */
1613 int temp = f_ptr->power;
1617 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1619 p_ptr->energy_use = 100;
1621 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1623 /* Compare bash power to door power */
1624 temp = (bash - (temp * 10));
1626 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1628 /* Hack -- always have a chance */
1629 if (temp < 1) temp = 1;
1631 /* Hack -- attempt to bash down the door */
1632 if (randint0(100) < temp)
1634 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1636 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1638 /* Break down the door */
1639 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1641 cave_alter_feat(y, x, FF_BASH);
1647 cave_alter_feat(y, x, FF_OPEN);
1650 /* Hack -- Fall through the door */
1651 move_player(dir, FALSE, FALSE);
1654 /* Saving throw against stun */
1655 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1658 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1660 /* Allow repeated bashing */
1664 /* High dexterity yields coolness */
1667 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1669 /* Hack -- Lose balance ala paralysis */
1670 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1677 * @brief 「打ち破る」動作コマンドのメインルーチン /
1678 * Bash open a door, success based on character strength
1682 * For a closed door, pval is positive if locked; negative if stuck.
1684 * For an open door, pval is positive for a broken door.
1686 * A closed door can be opened - harder if locked. Any door might be
1687 * bashed open (and thereby broken). Bashing a door is (potentially)
1688 * faster! You move into the door way. To open a stuck door, it must
1689 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1691 * Creatures can also open or bash doors, see elsewhere.
1694 void do_cmd_bash(void)
1703 if (p_ptr->special_defense & KATA_MUSOU)
1705 set_action(ACTION_NONE);
1708 /* Allow repeated command */
1711 /* Set repeat count */
1712 command_rep = command_arg - 1;
1714 /* Redraw the state */
1715 p_ptr->redraw |= (PR_STATE);
1717 /* Cancel the arg */
1721 /* Get a "repeated" direction */
1722 if (get_rep_dir(&dir,FALSE))
1727 y = p_ptr->y + ddy[dir];
1728 x = p_ptr->x + ddx[dir];
1731 c_ptr = &cave[y][x];
1733 /* Feature code (applying "mimic" field) */
1734 feat = get_feat_mimic(c_ptr);
1736 /* Nothing useful */
1737 if (!have_flag(f_info[feat].flags, FF_BASH))
1739 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1742 /* Monster in the way */
1743 else if (c_ptr->m_idx)
1745 p_ptr->energy_use = 100;
1747 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1753 /* Bash a closed door */
1757 more = do_cmd_bash_aux(y, x, dir);
1761 /* Unless valid action taken, cancel bash */
1762 if (!more) disturb(FALSE, FALSE);
1767 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1771 * Manipulate an adjacent grid in some way
1773 * Attack monsters, tunnel through walls, disarm traps, open doors.
1775 * Consider confusion
1777 * This command must always take a turn, to prevent free detection
1778 * of invisible monsters.
1781 void do_cmd_alter(void)
1790 if (p_ptr->special_defense & KATA_MUSOU)
1792 set_action(ACTION_NONE);
1795 /* Allow repeated command */
1798 /* Set repeat count */
1799 command_rep = command_arg - 1;
1801 /* Redraw the state */
1802 p_ptr->redraw |= (PR_STATE);
1804 /* Cancel the arg */
1808 /* Get a direction */
1809 if (get_rep_dir(&dir,TRUE))
1812 feature_type *f_ptr;
1815 y = p_ptr->y + ddy[dir];
1816 x = p_ptr->x + ddx[dir];
1819 c_ptr = &cave[y][x];
1821 /* Feature code (applying "mimic" field) */
1822 feat = get_feat_mimic(c_ptr);
1823 f_ptr = &f_info[feat];
1825 p_ptr->energy_use = 100;
1827 /* Attack monsters */
1835 else if (have_flag(f_ptr->flags, FF_OPEN))
1837 more = do_cmd_open_aux(y, x);
1840 /* Bash jammed doors */
1841 else if (have_flag(f_ptr->flags, FF_BASH))
1843 more = do_cmd_bash_aux(y, x, dir);
1846 /* Tunnel through walls */
1847 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1849 more = do_cmd_tunnel_aux(y, x);
1852 /* Close open doors */
1853 else if (have_flag(f_ptr->flags, FF_CLOSE))
1855 more = do_cmd_close_aux(y, x);
1859 else if (have_flag(f_ptr->flags, FF_DISARM))
1861 more = do_cmd_disarm_aux(y, x, dir);
1866 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1870 /* Cancel repetition unless we can continue */
1871 if (!more) disturb(FALSE, FALSE);
1877 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1878 * Find the index of some "spikes", if possible.
1879 * @param ip くさびとして打てるオブジェクトのID
1880 * @return オブジェクトがある場合TRUEを返す
1883 * Let user choose a pile of spikes, perhaps?
1886 static bool get_spike(INVENTORY_IDX *ip)
1890 /* Check every item in the pack */
1891 for (i = 0; i < INVEN_PACK; i++)
1893 object_type *o_ptr = &inventory[i];
1895 /* Skip non-objects */
1896 if (!o_ptr->k_idx) continue;
1898 /* Check the "tval" code */
1899 if (o_ptr->tval == TV_SPIKE)
1901 /* Save the spike index */
1914 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1915 * Jam a closed door with a spike
1919 * This command may NOT be repeated
1922 void do_cmd_spike(void)
1926 if (p_ptr->special_defense & KATA_MUSOU)
1928 set_action(ACTION_NONE);
1931 /* Get a "repeated" direction */
1932 if (get_rep_dir(&dir,FALSE))
1940 y = p_ptr->y + ddy[dir];
1941 x = p_ptr->x + ddx[dir];
1943 /* Get grid and contents */
1944 c_ptr = &cave[y][x];
1946 /* Feature code (applying "mimic" field) */
1947 feat = get_feat_mimic(c_ptr);
1949 /* Require closed door */
1950 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1952 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1956 else if (!get_spike(&item))
1958 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1961 /* Is a monster in the way? */
1962 else if (c_ptr->m_idx)
1964 p_ptr->energy_use = 100;
1966 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1975 p_ptr->energy_use = 100;
1977 /* Successful jamming */
1978 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1979 cave_alter_feat(y, x, FF_SPIKE);
1981 /* Use up, and describe, a single spike, from the bottom */
1982 inven_item_increase(item, -1);
1983 inven_item_describe(item);
1984 inven_item_optimize(item);
1992 * @brief 「歩く」動作コマンドのメインルーチン /
1993 * Support code for the "Walk" and "Jump" commands
1994 * @param pickup アイテムの自動拾いを行うならTRUE
1997 void do_cmd_walk(bool pickup)
2004 /* Allow repeated command */
2007 /* Set repeat count */
2008 command_rep = command_arg - 1;
2010 /* Redraw the state */
2011 p_ptr->redraw |= (PR_STATE);
2013 /* Cancel the arg */
2017 /* Get a "repeated" direction */
2018 if (get_rep_dir(&dir, FALSE))
2020 p_ptr->energy_use = 100;
2022 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2024 set_action(ACTION_NONE);
2027 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2028 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2029 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2031 /* Actually move the character */
2032 move_player(dir, pickup, FALSE);
2034 /* Allow more walking */
2038 /* Hack again -- Is there a special encounter ??? */
2039 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2041 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2044 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2046 /* Inform the player of his horrible fate :=) */
2047 msg_print(_("襲撃だ!", "You are ambushed !"));
2049 /* Go into large wilderness view */
2050 p_ptr->oldpy = randint1(MAX_HGT-2);
2051 p_ptr->oldpx = randint1(MAX_WID-2);
2054 /* Give first move to monsters */
2055 p_ptr->energy_use = 100;
2057 /* HACk -- set the encouter flag for the wilderness generation */
2058 generate_encounter = TRUE;
2062 /* Cancel repeat unless we may continue */
2063 if (!more) disturb(FALSE, FALSE);
2068 * @brief 「走る」動作コマンドのメインルーチン /
2072 void do_cmd_run(void)
2076 /* Hack -- no running when confused */
2077 if (p_ptr->confused)
2079 msg_print(_("混乱していて走れない!", "You are too confused!"));
2083 if (p_ptr->special_defense & KATA_MUSOU)
2085 set_action(ACTION_NONE);
2088 /* Get a "repeated" direction */
2089 if (get_rep_dir(&dir,FALSE))
2091 /* Hack -- Set the run counter */
2092 running = (command_arg ? command_arg : 1000);
2101 * @brief 「留まる」動作コマンドのメインルーチン /
2102 * Stay still. Search. Enter stores.
2103 * Pick up treasure if "pickup" is true.
2104 * @param pickup アイテムの自動拾いを行うならTRUE
2107 void do_cmd_stay(bool pickup)
2109 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2111 /* Allow repeated command */
2114 /* Set repeat count */
2115 command_rep = command_arg - 1;
2117 /* Redraw the state */
2118 p_ptr->redraw |= (PR_STATE);
2120 /* Cancel the arg */
2124 p_ptr->energy_use = 100;
2126 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2127 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2132 * @brief 「休む」動作コマンドのメインルーチン /
2133 * Resting allows a player to safely restore his hp -RAK-
2136 void do_cmd_rest(void)
2139 set_action(ACTION_NONE);
2141 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2147 if (hex_spelling_any()) stop_hex_spell_all();
2149 /* Prompt for time if needed */
2150 if (command_arg <= 0)
2152 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2153 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2159 strcpy(out_val, "&");
2161 /* Ask for duration */
2162 if (!get_string(p, out_val, 4)) return;
2164 /* Rest until done */
2165 if (out_val[0] == '&')
2167 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2171 else if (out_val[0] == '*')
2173 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2179 command_arg = (COMMAND_ARG)atoi(out_val);
2180 if (command_arg <= 0) return;
2186 if (command_arg > 9999) command_arg = 9999;
2188 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2190 /* Take a turn (?) */
2191 p_ptr->energy_use = 100;
2193 /* The sin of sloth */
2194 if (command_arg > 100)
2195 chg_virtue(V_DILIGENCE, -1);
2197 /* Why are you sleeping when there's no need? WAKE UP!*/
2198 if ((p_ptr->chp == p_ptr->mhp) &&
2199 (p_ptr->csp == p_ptr->msp) &&
2200 !p_ptr->blind && !p_ptr->confused &&
2201 !p_ptr->poisoned && !p_ptr->afraid &&
2202 !p_ptr->stun && !p_ptr->cut &&
2203 !p_ptr->slow && !p_ptr->paralyzed &&
2204 !p_ptr->image && !p_ptr->word_recall &&
2205 !p_ptr->alter_reality)
2206 chg_virtue(V_DILIGENCE, -1);
2208 /* Save the rest code */
2209 resting = command_arg;
2210 p_ptr->action = ACTION_REST;
2212 /* Recalculate bonuses */
2213 p_ptr->update |= (PU_BONUS);
2215 /* Redraw the state */
2216 p_ptr->redraw |= (PR_STATE);
2227 * @brief 矢弾を射撃した場合の破損確率を返す /
2228 * Determines the odds of an object breaking when thrown at a monster
2229 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2232 * Note that artifacts never break, see the "drop_near()" function.
2234 static PERCENTAGE breakage_chance(object_type *o_ptr)
2236 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2238 /* Examine the snipe type */
2241 if (snipe_type == SP_KILL_WALL) return (100);
2242 if (snipe_type == SP_EXPLODE) return (100);
2243 if (snipe_type == SP_PIERCE) return (100);
2244 if (snipe_type == SP_FINAL) return (100);
2245 if (snipe_type == SP_NEEDLE) return (100);
2246 if (snipe_type == SP_EVILNESS) return (40);
2247 if (snipe_type == SP_HOLYNESS) return (40);
2250 /* Examine the item type */
2251 switch (o_ptr->tval)
2267 /* Sometimes break */
2272 return (20 - archer_bonus * 2);
2277 return (10 - archer_bonus);
2285 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2286 * Determines the odds of an object breaking when thrown at a monster
2287 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2288 * @param tdam 計算途中のダメージ量
2289 * @param m_ptr 目標モンスターの構造体参照ポインタ
2290 * @return スレイ倍率をかけたダメージ量
2292 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2296 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2298 BIT_FLAGS flgs[TR_FLAG_SIZE];
2300 /* Extract the flags */
2301 object_flags(o_ptr, flgs);
2303 /* Some "weapons" and "ammo" do extra damage */
2304 switch (o_ptr->tval)
2311 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2312 (r_ptr->flags3 & RF3_ANIMAL))
2314 if (is_original_ap_and_seen(m_ptr))
2316 r_ptr->r_flags3 |= RF3_ANIMAL;
2319 if (mult < 17) mult = 17;
2323 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2324 (r_ptr->flags3 & RF3_ANIMAL))
2326 if (is_original_ap_and_seen(m_ptr))
2328 r_ptr->r_flags3 |= RF3_ANIMAL;
2331 if (mult < 27) mult = 27;
2335 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2336 (r_ptr->flags3 & RF3_EVIL))
2338 if (is_original_ap_and_seen(m_ptr))
2340 r_ptr->r_flags3 |= RF3_EVIL;
2343 if (mult < 15) mult = 15;
2347 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2348 (r_ptr->flags3 & RF3_EVIL))
2350 if (is_original_ap_and_seen(m_ptr))
2352 r_ptr->r_flags3 |= RF3_EVIL;
2355 if (mult < 25) mult = 25;
2359 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2360 (r_ptr->flags2 & RF2_HUMAN))
2362 if (is_original_ap_and_seen(m_ptr))
2364 r_ptr->r_flags2 |= RF2_HUMAN;
2367 if (mult < 17) mult = 17;
2371 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2372 (r_ptr->flags2 & RF2_HUMAN))
2374 if (is_original_ap_and_seen(m_ptr))
2376 r_ptr->r_flags2 |= RF2_HUMAN;
2379 if (mult < 27) mult = 27;
2383 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2384 (r_ptr->flags3 & RF3_UNDEAD))
2386 if (is_original_ap_and_seen(m_ptr))
2388 r_ptr->r_flags3 |= RF3_UNDEAD;
2391 if (mult < 20) mult = 20;
2395 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2396 (r_ptr->flags3 & RF3_UNDEAD))
2398 if (is_original_ap_and_seen(m_ptr))
2400 r_ptr->r_flags3 |= RF3_UNDEAD;
2403 if (mult < 30) mult = 30;
2407 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2408 (r_ptr->flags3 & RF3_DEMON))
2410 if (is_original_ap_and_seen(m_ptr))
2412 r_ptr->r_flags3 |= RF3_DEMON;
2415 if (mult < 20) mult = 20;
2419 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2420 (r_ptr->flags3 & RF3_DEMON))
2422 if (is_original_ap_and_seen(m_ptr))
2424 r_ptr->r_flags3 |= RF3_DEMON;
2427 if (mult < 30) mult = 30;
2431 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2432 (r_ptr->flags3 & RF3_ORC))
2434 if (is_original_ap_and_seen(m_ptr))
2436 r_ptr->r_flags3 |= RF3_ORC;
2439 if (mult < 20) mult = 20;
2443 if ((have_flag(flgs, TR_KILL_ORC)) &&
2444 (r_ptr->flags3 & RF3_ORC))
2446 if (is_original_ap_and_seen(m_ptr))
2448 r_ptr->r_flags3 |= RF3_ORC;
2451 if (mult < 30) mult = 30;
2455 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2456 (r_ptr->flags3 & RF3_TROLL))
2458 if (is_original_ap_and_seen(m_ptr))
2460 r_ptr->r_flags3 |= RF3_TROLL;
2463 if (mult < 20) mult = 20;
2467 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2468 (r_ptr->flags3 & RF3_TROLL))
2470 if (is_original_ap_and_seen(m_ptr))
2472 r_ptr->r_flags3 |= RF3_TROLL;
2475 if (mult < 30) mult = 30;
2479 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2480 (r_ptr->flags3 & RF3_GIANT))
2482 if (is_original_ap_and_seen(m_ptr))
2484 r_ptr->r_flags3 |= RF3_GIANT;
2487 if (mult < 20) mult = 20;
2491 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2492 (r_ptr->flags3 & RF3_GIANT))
2494 if (is_original_ap_and_seen(m_ptr))
2496 r_ptr->r_flags3 |= RF3_GIANT;
2499 if (mult < 30) mult = 30;
2503 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
2504 (r_ptr->flags3 & RF3_DRAGON))
2506 if (is_original_ap_and_seen(m_ptr))
2508 r_ptr->r_flags3 |= RF3_DRAGON;
2511 if (mult < 20) mult = 20;
2514 /* Execute Dragon */
2515 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
2516 (r_ptr->flags3 & RF3_DRAGON))
2518 if (is_original_ap_and_seen(m_ptr))
2520 r_ptr->r_flags3 |= RF3_DRAGON;
2523 if (mult < 30) mult = 30;
2525 if ((o_ptr->name1 == ART_BARD_ARROW) &&
2526 (m_ptr->r_idx == MON_SMAUG) &&
2527 (inventory[INVEN_BOW].name1 == ART_BARD))
2532 if (have_flag(flgs, TR_BRAND_ACID))
2534 /* Notice immunity */
2535 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2537 if (is_original_ap_and_seen(m_ptr))
2539 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2543 /* Otherwise, take the damage */
2546 if (mult < 17) mult = 17;
2551 if (have_flag(flgs, TR_BRAND_ELEC))
2553 /* Notice immunity */
2554 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2556 if (is_original_ap_and_seen(m_ptr))
2558 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2562 /* Otherwise, take the damage */
2565 if (mult < 17) mult = 17;
2570 if (have_flag(flgs, TR_BRAND_FIRE))
2572 /* Notice immunity */
2573 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2575 if (is_original_ap_and_seen(m_ptr))
2577 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2581 /* Otherwise, take the damage */
2584 if (r_ptr->flags3 & RF3_HURT_FIRE)
2586 if (mult < 25) mult = 25;
2587 if (is_original_ap_and_seen(m_ptr))
2589 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2592 else if (mult < 17) mult = 17;
2597 if (have_flag(flgs, TR_BRAND_COLD))
2599 /* Notice immunity */
2600 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2602 if (is_original_ap_and_seen(m_ptr))
2604 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2607 /* Otherwise, take the damage */
2610 if (r_ptr->flags3 & RF3_HURT_COLD)
2612 if (mult < 25) mult = 25;
2613 if (is_original_ap_and_seen(m_ptr))
2615 r_ptr->r_flags3 |= RF3_HURT_COLD;
2618 else if (mult < 17) mult = 17;
2622 /* Brand (Poison) */
2623 if (have_flag(flgs, TR_BRAND_POIS))
2625 /* Notice immunity */
2626 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2628 if (is_original_ap_and_seen(m_ptr))
2630 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2634 /* Otherwise, take the damage */
2637 if (mult < 17) mult = 17;
2641 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2643 p_ptr->csp -= (1+(p_ptr->msp / 30));
2644 p_ptr->redraw |= (PR_MANA);
2645 mult = mult * 5 / 2;
2652 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2654 /* Return the total damage */
2655 return (tdam * mult / 10);
2660 * @brief 射撃処理のサブルーチン /
2661 * Fire an object from the pack or floor.
2662 * @param item 射撃するオブジェクトの所持ID
2663 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2667 * You may only fire items that "match" your missile launcher.
2669 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2671 * See "calc_bonuses()" for more calculations and such.
2673 * Note that "firing" a missile is MUCH better than "throwing" it.
2675 * Note: "unseen" monsters are very hard to hit.
2677 * Objects are more likely to break if they "attempt" to hit a monster.
2679 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2681 * The "extra shot" code works by decreasing the amount of energy
2682 * required to make each shot, spreading the shots out over time.
2684 * Note that when firing missiles, the launcher multiplier is applied
2685 * after all the bonuses are added in, making multipliers very useful.
2687 * Note that Bows of "Extra Might" get extra range and an extra bonus
2688 * for the damage multiplier.
2690 * Note that Bows of "Extra Shots" give an extra shot.
2693 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2697 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2698 int tdam_base, tdis, thits, tmul;
2700 int cur_dis, visible;
2708 bool hit_body = FALSE;
2710 char o_name[MAX_NLEN];
2712 u16b path_g[512]; /* For calcuration of path length */
2714 int msec = delay_factor * delay_factor * delay_factor;
2717 bool stick_to = FALSE;
2719 /* Access the item (if in the pack) */
2722 o_ptr = &inventory[item];
2726 o_ptr = &o_list[0 - item];
2729 /* Sniper - Cannot shot a single arrow twice */
2730 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2732 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2734 /* Use the proper number of shots */
2735 thits = p_ptr->num_fire;
2737 /* Use a base distance */
2740 /* Base damage from thrown object plus launcher bonus */
2741 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2743 /* Actually "fire" the object */
2744 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2745 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2746 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2748 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2750 p_ptr->energy_use = bow_energy(j_ptr->sval);
2751 tmul = bow_tmul(j_ptr->sval);
2753 /* Get extra "power" from "extra might" */
2754 if (p_ptr->xtra_might) tmul++;
2756 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2758 /* Boost the damage */
2763 tdis = 13 + tmul/80;
2764 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2767 tdis -= (5 - (p_ptr->concent + 1) / 2);
2772 project_length = tdis + 1;
2774 /* Get a direction (or cancel) */
2775 if (!get_aim_dir(&dir))
2777 p_ptr->energy_use = 0;
2779 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2781 /* need not to reset project_length (already did)*/
2786 /* Predict the "target" location */
2787 tx = p_ptr->x + 99 * ddx[dir];
2788 ty = p_ptr->y + 99 * ddy[dir];
2790 /* Check for "target request" */
2791 if ((dir == 5) && target_okay())
2797 /* Get projection path length */
2798 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2800 project_length = 0; /* reset to default */
2802 /* Don't shoot at my feet */
2803 if (tx == p_ptr->x && ty == p_ptr->y)
2805 p_ptr->energy_use = 0;
2807 /* project_length is already reset to 0 */
2813 /* Take a (partial) turn */
2814 p_ptr->energy_use = (p_ptr->energy_use / thits);
2817 /* Sniper - Difficult to shot twice at 1 turn */
2818 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2820 /* Sniper - Repeat shooting when double shots */
2821 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2824 /* Start at the player */
2828 /* Get local object */
2831 /* Obtain a local object */
2832 object_copy(q_ptr, o_ptr);
2837 /* Reduce and describe inventory */
2840 inven_item_increase(item, -1);
2841 inven_item_describe(item);
2842 inven_item_optimize(item);
2845 /* Reduce and describe floor item */
2848 floor_item_increase(0 - item, -1);
2849 floor_item_optimize(0 - item);
2854 /* Hack -- Handle stuff */
2857 /* Save the old location */
2861 /* The shot does not hit yet */
2864 /* Travel until stopped */
2865 for (cur_dis = 0; cur_dis <= tdis; )
2869 /* Hack -- Stop at the target */
2870 if ((y == ty) && (x == tx)) break;
2872 /* Calculate the new location (see "project()") */
2875 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
2878 if (snipe_type == SP_KILL_WALL)
2880 c_ptr = &cave[ny][nx];
2882 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
2884 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
2885 /* Forget the wall */
2886 c_ptr->info &= ~(CAVE_MARK);
2888 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
2890 /* Destroy the wall */
2891 cave_alter_feat(ny, nx, FF_HURT_ROCK);
2898 /* Stopped by walls/doors */
2899 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
2901 /* Advance the distance */
2905 if (snipe_type == SP_LITE)
2907 cave[ny][nx].info |= (CAVE_GLOW);
2914 /* The player can see the (on screen) missile */
2915 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
2917 char c = object_char(q_ptr);
2918 byte a = object_attr(q_ptr);
2920 /* Draw, Hilite, Fresh, Pause, Erase */
2921 print_rel(c, a, ny, nx);
2922 move_cursor_relative(ny, nx);
2924 Term_xtra(TERM_XTRA_DELAY, msec);
2929 /* The player cannot see the missile */
2932 /* Pause anyway, for consistancy */
2933 Term_xtra(TERM_XTRA_DELAY, msec);
2937 if (snipe_type == SP_KILL_TRAP)
2939 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
2940 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
2944 if (snipe_type == SP_EVILNESS)
2946 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
2953 /* Save the old location */
2957 /* Save the new location */
2962 /* Monster here, Try to hit it */
2963 if (cave[y][x].m_idx)
2965 cave_type *c_mon_ptr = &cave[y][x];
2967 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
2968 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2970 /* Check the visibility */
2971 visible = m_ptr->ml;
2973 /* Note the collision */
2976 if (MON_CSLEEP(m_ptr))
2978 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
2979 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
2982 if ((r_ptr->level + 10) > p_ptr->lev)
2984 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
2985 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
2988 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
2989 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
2990 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
2991 else if (p_ptr->lev > 34) amount = 2;
2992 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
2993 p_ptr->update |= (PU_BONUS);
2999 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3000 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3003 p_ptr->skill_exp[GINOU_RIDING] += 1;
3004 p_ptr->update |= (PU_BONUS);
3008 /* Did we hit it (penalize range) */
3009 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3012 int tdam = tdam_base;
3014 /* Get extra damage from concentration */
3015 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3017 /* Handle unseen monster */
3020 /* Invisible monster */
3021 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3024 /* Handle visible monster */
3029 /* Get "the monster" or "it" */
3030 monster_desc(m_name, m_ptr, 0);
3032 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3036 /* Hack -- Track this monster race */
3037 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3039 /* Hack -- Track this monster */
3040 health_track(c_mon_ptr->m_idx);
3044 if (snipe_type == SP_NEEDLE)
3046 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3047 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3051 /* Get "the monster" or "it" */
3052 monster_desc(m_name, m_ptr, 0);
3054 tdam = m_ptr->hp + 1;
3055 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3061 /* Apply special damage */
3062 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3063 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3065 /* No negative damage */
3066 if (tdam < 0) tdam = 0;
3068 /* Modify the damage */
3069 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3072 msg_format_wizard(CHEAT_MONSTER,
3073 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3074 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3077 if (snipe_type == SP_EXPLODE)
3079 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3081 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3082 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3087 if (snipe_type == SP_HOLYNESS)
3089 cave[ny][nx].info |= (CAVE_GLOW);
3096 /* Hit the monster, check for death */
3097 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3106 if (object_is_fixed_artifact(q_ptr) &&
3107 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3111 monster_desc(m_name, m_ptr, 0);
3114 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3117 message_pain(c_mon_ptr->m_idx, tdam);
3119 /* Anger the monster */
3120 if (tdam > 0) anger_monster(m_ptr);
3123 if (fear && m_ptr->ml)
3129 /* Get the monster name (or "it") */
3130 monster_desc(m_name, m_ptr, 0);
3132 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3135 set_target(m_ptr, p_ptr->y, p_ptr->x);
3138 if (snipe_type == SP_RUSH)
3140 int n = randint1(5) + 3;
3141 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3143 for ( ; cur_dis <= tdis; )
3150 /* Calculate the new location (see "project()") */
3151 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3153 /* Stopped by wilderness boundary */
3154 if (!in_bounds2(ny, nx)) break;
3156 /* Stopped by walls/doors */
3157 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3159 /* Stopped by monsters */
3160 if (!cave_empty_bold(ny, nx)) break;
3162 cave[ny][nx].m_idx = m_idx;
3163 cave[oy][ox].m_idx = 0;
3168 /* Update the monster (new location) */
3169 update_monster(c_mon_ptr->m_idx, TRUE);
3175 Term_xtra(TERM_XTRA_DELAY, msec);
3187 if (snipe_type == SP_PIERCE)
3189 if(p_ptr->concent < 1) break;
3199 /* Chance of breakage (during attacks) */
3200 j = (hit_body ? breakage_chance(q_ptr) : 0);
3204 MONSTER_IDX m_idx = cave[y][x].m_idx;
3205 monster_type *m_ptr = &m_list[m_idx];
3206 OBJECT_IDX o_idx = o_pop();
3210 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3211 if (object_is_fixed_artifact(q_ptr))
3213 a_info[j_ptr->name1].cur_num = 0;
3218 o_ptr = &o_list[o_idx];
3219 object_copy(o_ptr, q_ptr);
3222 o_ptr->marked &= OM_TOUCHED;
3224 /* Forget location */
3225 o_ptr->iy = o_ptr->ix = 0;
3227 /* Memorize monster */
3228 o_ptr->held_m_idx = m_idx;
3231 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3234 m_ptr->hold_o_idx = o_idx;
3236 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3238 /* Drop (or break) near that location */
3239 (void)drop_near(q_ptr, j, y, x);
3243 /* Drop (or break) near that location */
3244 (void)drop_near(q_ptr, j, prev_y, prev_x);
3247 /* Sniper - Repeat shooting when double shots */
3250 /* Sniper - Loose his/her concentration after any shot */
3251 if (p_ptr->concent) reset_concentration(FALSE);
3255 * @brief 射撃処理のメインルーチン
3258 void do_cmd_fire(void)
3264 is_fired = FALSE; /* not fired yet */
3266 /* Get the "bow" (if any) */
3267 j_ptr = &inventory[INVEN_BOW];
3269 /* Require a launcher */
3272 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3277 if (j_ptr->sval == SV_CRIMSON)
3279 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3284 if (j_ptr->sval == SV_HARP)
3286 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3292 if (p_ptr->special_defense & KATA_MUSOU)
3294 set_action(ACTION_NONE);
3297 /* Require proper missile */
3298 item_tester_tval = p_ptr->tval_ammo;
3300 q = _("どれを撃ちますか? ", "Fire which item? ");
3301 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3302 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3309 do_cmd_fire_aux(item, j_ptr);
3311 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3313 /* Sniper actions after some shootings */
3314 if (snipe_type == SP_AWAY)
3316 teleport_player(10 + (p_ptr->concent * 2), 0L);
3318 if (snipe_type == SP_FINAL)
3320 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3321 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3322 (void)set_stun(p_ptr->stun + randint1(25));
3328 * @brief 投射処理メインルーチン /
3329 * Throw an object from the pack or floor.
3331 * @param boomerang ブーメラン処理ならばTRUE
3332 * @param shuriken 忍者の手裏剣処理ならばTRUE
3333 * @return ターンを消費した場合TRUEを返す
3336 * Note: "unseen" monsters are very hard to hit.
3338 * Should throwing a weapon do full damage? Should it allow the magic
3339 * to hit bonus of the weapon to have an effect? Should it ever cause
3340 * the item to be destroyed? Should it do any damage at all?
3343 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3348 POSITION y, x, ty, tx, prev_y, prev_x;
3349 POSITION ny[19], nx[19];
3350 int chance, tdam, tdis;
3351 int mul, div, dd, ds;
3352 int cur_dis, visible;
3360 bool hit_body = FALSE;
3361 bool hit_wall = FALSE;
3362 bool equiped_item = FALSE;
3363 bool return_when_thrown = FALSE;
3365 char o_name[MAX_NLEN];
3367 int msec = delay_factor * delay_factor * delay_factor;
3369 BIT_FLAGS flgs[TR_FLAG_SIZE];
3371 bool come_back = FALSE;
3372 bool do_drop = TRUE;
3375 if (p_ptr->special_defense & KATA_MUSOU)
3377 set_action(ACTION_NONE);
3386 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3388 item_tester_hook = item_tester_hook_boomerang;
3389 q = _("どの武器を投げますか? ", "Throw which item? ");
3390 s = _("投げる武器がない。", "You have nothing to throw.");
3391 if (!get_item(&item, q, s, (USE_EQUIP)))
3397 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3398 else item = INVEN_RARM;
3402 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3403 s = _("投げるアイテムがない。", "You have nothing to throw.");
3404 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3411 /* Access the item (if in the pack) */
3414 o_ptr = &inventory[item];
3418 o_ptr = &o_list[0 - item];
3421 /* Item is cursed */
3422 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3424 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3429 if (p_ptr->inside_arena && !boomerang)
3431 if (o_ptr->tval != TV_SPIKE)
3433 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3441 /* Get local object */
3444 /* Obtain a local object */
3445 object_copy(q_ptr, o_ptr);
3447 /* Extract the thrown object's flags. */
3448 object_flags(q_ptr, flgs);
3449 torch_flags(q_ptr, flgs);
3451 /* Distribute the charges of rods/wands between the stacks */
3452 distribute_charges(o_ptr, q_ptr, 1);
3458 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3460 if (p_ptr->mighty_throw) mult += 3;
3462 /* Extract a "distance multiplier" */
3463 /* Changed for 'launcher' mutation */
3464 mul = 10 + 2 * (mult - 1);
3466 /* Enforce a minimum "weight" of one pound */
3467 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3468 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3470 /* Hack -- Distance -- Reward strength, penalize weight */
3471 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3473 /* Max distance of 10-18 */
3474 if (tdis > mul) tdis = mul;
3478 ty = randint0(101) - 50 + p_ptr->y;
3479 tx = randint0(101) - 50 + p_ptr->x;
3483 project_length = tdis + 1;
3485 /* Get a direction (or cancel) */
3486 if (!get_aim_dir(&dir)) return FALSE;
3488 /* Predict the "target" location */
3489 tx = p_ptr->x + 99 * ddx[dir];
3490 ty = p_ptr->y + 99 * ddy[dir];
3492 /* Check for "target request" */
3493 if ((dir == 5) && target_okay())
3499 project_length = 0; /* reset to default */
3502 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3503 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3504 return_when_thrown = TRUE;
3506 /* Reduce and describe inventory */
3509 inven_item_increase(item, -1);
3510 if (!return_when_thrown)
3511 inven_item_describe(item);
3512 inven_item_optimize(item);
3515 /* Reduce and describe floor item */
3518 floor_item_increase(0 - item, -1);
3519 floor_item_optimize(0 - item);
3521 if (item >= INVEN_RARM)
3523 equiped_item = TRUE;
3524 p_ptr->redraw |= (PR_EQUIPPY);
3527 p_ptr->energy_use = 100;
3529 /* Rogue and Ninja gets bonus */
3530 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3531 p_ptr->energy_use -= p_ptr->lev;
3533 /* Start at the player */
3538 /* Hack -- Handle stuff */
3541 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3542 else shuriken = FALSE;
3544 /* Chance of hitting */
3545 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3546 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3547 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3549 if (shuriken) chance *= 2;
3551 /* Save the old location */
3555 /* Travel until stopped */
3556 for (cur_dis = 0; cur_dis <= tdis; )
3558 /* Hack -- Stop at the target */
3559 if ((y == ty) && (x == tx)) break;
3561 /* Calculate the new location (see "project()") */
3564 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3566 /* Stopped by walls/doors */
3567 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3570 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3573 /* The player can see the (on screen) missile */
3574 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3576 char c = object_char(q_ptr);
3577 byte a = object_attr(q_ptr);
3579 /* Draw, Hilite, Fresh, Pause, Erase */
3580 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3581 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3583 Term_xtra(TERM_XTRA_DELAY, msec);
3584 lite_spot(ny[cur_dis], nx[cur_dis]);
3588 /* The player cannot see the missile */
3591 /* Pause anyway, for consistancy */
3592 Term_xtra(TERM_XTRA_DELAY, msec);
3595 /* Save the old location */
3599 /* Save the new location */
3603 /* Advance the distance */
3606 /* Monster here, Try to hit it */
3607 if (cave[y][x].m_idx)
3609 cave_type *c_ptr = &cave[y][x];
3610 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3612 /* Check the visibility */
3613 visible = m_ptr->ml;
3615 /* Note the collision */
3618 /* Did we hit it (penalize range) */
3619 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3623 /* Handle unseen monster */
3626 /* Invisible monster */
3627 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3630 /* Handle visible monster */
3635 /* Get "the monster" or "it" */
3636 monster_desc(m_name, m_ptr, 0);
3638 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3642 /* Hack -- Track this monster race */
3643 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3645 /* Hack -- Track this monster */
3646 health_track(c_ptr->m_idx);
3650 /* Hack -- Base damage from thrown object */
3653 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3654 tdam = damroll(dd, ds);
3655 /* Apply special damage */
3656 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3657 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3658 if (q_ptr->to_d > 0)
3659 tdam += q_ptr->to_d;
3661 tdam += -q_ptr->to_d;
3665 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3666 tdam += p_ptr->to_d_m;
3668 else if (have_flag(flgs, TR_THROW))
3671 tdam += p_ptr->to_d_m;
3679 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3682 /* No negative damage */
3683 if (tdam < 0) tdam = 0;
3685 /* Modify the damage */
3686 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3688 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3689 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3691 /* Hit the monster, check for death */
3692 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3700 message_pain(c_ptr->m_idx, tdam);
3702 /* Anger the monster */
3703 if ((tdam > 0) && !object_is_potion(q_ptr))
3704 anger_monster(m_ptr);
3707 if (fear && m_ptr->ml)
3713 /* Get the monster name (or "it") */
3714 monster_desc(m_name, m_ptr, 0);
3716 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3726 /* decrease toach's fuel */
3727 if (hit_body) torch_lost_fuel(q_ptr);
3729 /* Chance of breakage (during attacks) */
3730 j = (hit_body ? breakage_chance(q_ptr) : 0);
3732 /* Figurines transform */
3733 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3737 if (!(summon_named_creature(0, y, x, q_ptr->pval,
3738 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3739 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3740 else if (object_is_cursed(q_ptr))
3741 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3746 /* Potions smash open */
3747 if (object_is_potion(q_ptr))
3749 if (hit_body || hit_wall || (randint1(100) < j))
3751 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3753 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3755 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3757 /* ToDo (Robert): fix the invulnerability */
3758 if (cave[y][x].m_idx &&
3759 is_friendly(&m_list[cave[y][x].m_idx]) &&
3760 !MON_INVULNER(m_ptr))
3763 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3764 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3765 set_hostile(&m_list[cave[y][x].m_idx]);
3776 if (return_when_thrown)
3778 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3779 char o2_name[MAX_NLEN];
3780 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3783 if (boomerang) back_chance += 4+randint1(5);
3784 if (super_boomerang) back_chance += 100;
3785 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3787 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3789 for (i = cur_dis - 1; i > 0; i--)
3791 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3793 char c = object_char(q_ptr);
3794 byte a = object_attr(q_ptr);
3796 /* Draw, Hilite, Fresh, Pause, Erase */
3797 print_rel(c, a, ny[i], nx[i]);
3798 move_cursor_relative(ny[i], nx[i]);
3800 Term_xtra(TERM_XTRA_DELAY, msec);
3801 lite_spot(ny[i], nx[i]);
3806 /* Pause anyway, for consistancy */
3807 Term_xtra(TERM_XTRA_DELAY, msec);
3810 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3812 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3819 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3823 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3831 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3837 if (item == INVEN_RARM || item == INVEN_LARM)
3839 /* Access the wield slot */
3840 o_ptr = &inventory[item];
3842 /* Wear the new stuff */
3843 object_copy(o_ptr, q_ptr);
3845 /* Increase the weight */
3846 p_ptr->total_weight += q_ptr->weight;
3848 /* Increment the equip counter by hand */
3851 /* Recalculate bonuses */
3852 p_ptr->update |= (PU_BONUS);
3854 /* Recalculate torch */
3855 p_ptr->update |= (PU_TORCH);
3857 /* Recalculate mana XXX */
3858 p_ptr->update |= (PU_MANA);
3860 p_ptr->window |= (PW_EQUIP);
3868 else if (equiped_item)
3874 /* Drop (or break) near that location */
3877 if (cave_have_flag_bold(y, x, FF_PROJECT))
3879 /* Drop (or break) near that location */
3880 (void)drop_near(q_ptr, j, y, x);
3884 /* Drop (or break) near that location */
3885 (void)drop_near(q_ptr, j, prev_y, prev_x);
3895 * Hack: travel command
3897 #define TRAVEL_UNABLE 9999
3899 static int flow_head = 0;
3900 static int flow_tail = 0;
3901 static POSITION temp2_x[MAX_SHORT];
3902 static POSITION temp2_y[MAX_SHORT];
3905 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
3908 void forget_travel_flow(void)
3912 /* Check the entire dungeon */
3913 for (y = 0; y < cur_hgt; y++)
3915 for (x = 0; x < cur_wid; x++)
3917 /* Forget the old data */
3918 travel.cost[y][x] = MAX_SHORT;
3922 travel.y = travel.x = 0;
3926 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
3931 static int travel_flow_cost(POSITION y, POSITION x)
3933 feature_type *f_ptr = &f_info[cave[y][x].feat];
3936 /* Avoid obstacles (ex. trees) */
3937 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
3940 if (have_flag(f_ptr->flags, FF_WATER))
3942 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
3946 if (have_flag(f_ptr->flags, FF_LAVA))
3949 if (!p_ptr->resist_fire) lava *= 2;
3950 if (!p_ptr->levitation) lava *= 2;
3951 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
3956 /* Detected traps and doors */
3957 if (cave[y][x].info & (CAVE_MARK))
3959 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
3960 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
3967 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
3971 * @param wall プレイヤーが壁の中にいるならばTRUE
3974 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
3976 cave_type *c_ptr = &cave[y][x];
3977 feature_type *f_ptr = &f_info[c_ptr->feat];
3978 int old_head = flow_head;
3980 int base_cost = (n % TRAVEL_UNABLE);
3981 int from_wall = (n / TRAVEL_UNABLE);
3984 /* Ignore out of bounds */
3985 if (!in_bounds(y, x)) return;
3987 /* Ignore unknown grid except in wilderness */
3988 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
3990 /* Ignore "walls" and "rubble" (include "secret doors") */
3991 if (have_flag(f_ptr->flags, FF_WALL) ||
3992 have_flag(f_ptr->flags, FF_CAN_DIG) ||
3993 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
3994 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
3996 if (!wall || !from_wall) return;
3997 add_cost += TRAVEL_UNABLE;
4001 add_cost = travel_flow_cost(y, x);
4004 cost = base_cost + add_cost;
4006 /* Ignore lower cost entries */
4007 if (travel.cost[y][x] <= cost) return;
4009 /* Save the flow cost */
4010 travel.cost[y][x] = cost;
4012 /* Enqueue that entry */
4013 temp2_y[flow_head] = y;
4014 temp2_x[flow_head] = x;
4016 /* Advance the queue */
4017 if (++flow_head == MAX_SHORT) flow_head = 0;
4019 /* Hack -- notice overflow by forgetting new entry */
4020 if (flow_head == flow_tail) flow_head = old_head;
4026 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
4027 * @param ty 目標地点のY座標
4028 * @param tx 目標地点のX座標
4031 static void travel_flow(POSITION ty, POSITION tx)
4035 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
4037 /* Reset the "queue" */
4038 flow_head = flow_tail = 0;
4040 /* is player in the wall? */
4041 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4043 /* Start at the target grid */
4044 travel_flow_aux(ty, tx, 0, wall);
4046 /* Now process the queue */
4047 while (flow_head != flow_tail)
4049 /* Extract the next entry */
4050 y = temp2_y[flow_tail];
4051 x = temp2_x[flow_tail];
4053 /* Forget that entry */
4054 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4056 /* Ignore too far entries */
4057 //if (distance(ty, tx, y, x) > 100) continue;
4059 /* Add the "children" */
4060 for (d = 0; d < 8; d++)
4062 /* Add that child if "legal" */
4063 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4067 /* Forget the flow info */
4068 flow_head = flow_tail = 0;
4072 * @brief トラベル処理のメインルーチン
4075 void do_cmd_travel(void)
4080 feature_type *f_ptr;
4082 if (travel.x != 0 && travel.y != 0 &&
4083 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4088 else if (!tgt_pt(&x, &y)) return;
4090 if ((x == p_ptr->x) && (y == p_ptr->y))
4092 msg_print(_("すでにそこにいます!", "You are already there!!"));
4096 f_ptr = &f_info[cave[y][x].feat];
4098 if ((cave[y][x].info & CAVE_MARK) &&
4099 (have_flag(f_ptr->flags, FF_WALL) ||
4100 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4101 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4103 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4107 forget_travel_flow();
4113 /* Travel till 255 steps */
4119 /* Decides first direction */
4120 dx = abs(p_ptr->x - x);
4121 dy = abs(p_ptr->y - y);
4122 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4123 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4125 for (i = 1; i <= 9; i++)
4127 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;