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);
389 p_ptr->energy_use = 100;
397 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
398 * @param y 走査対象にしたいマスのY座標
399 * @param x 走査対象にしたいマスのX座標
400 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
401 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
403 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
405 cave_type *c_ptr = &cave[y][x];
407 OBJECT_IDX this_o_idx, next_o_idx = 0;
410 /* Scan all objects in the grid */
411 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
416 o_ptr = &o_list[this_o_idx];
418 /* Acquire next object */
419 next_o_idx = o_ptr->next_o_idx;
421 /* Skip unknown chests XXX XXX */
422 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
424 /* Check for non empty chest */
425 if ((o_ptr->tval == TV_CHEST) &&
426 (((!trapped) && (o_ptr->pval)) || /* non empty */
427 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
438 * @brief 箱を開けるコマンドのメインルーチン /
439 * Attempt to open the given chest at the given location
440 * @param y 箱の存在するマスのY座標
441 * @param x 箱の存在するマスのX座標
442 * @param o_idx 箱のオブジェクトID
443 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
445 * Assume there is no monster blocking the destination
447 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
455 object_type *o_ptr = &o_list[o_idx];
459 p_ptr->energy_use = 100;
461 /* Attempt to unlock it */
464 /* Assume locked, and thus not open */
467 /* Get the "disarm" factor */
468 i = p_ptr->skill_dis;
470 /* Penalize some conditions */
471 if (p_ptr->blind || no_lite()) i = i / 10;
472 if (p_ptr->confused || p_ptr->image) i = i / 10;
474 /* Extract the difficulty */
477 /* Always have a small chance of success */
480 /* Success -- May still have traps */
481 if (randint0(100) < j)
483 msg_print(_("鍵をはずした。", "You have picked the lock."));
488 /* Failure -- Keep trying */
491 /* We may continue repeating */
493 if (flush_failure) flush();
494 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
499 /* Allowed to open */
502 /* Apply chest traps, if any */
503 chest_trap(y, x, o_idx);
505 /* Let the Chest drop items */
506 chest_death(FALSE, y, x, o_idx);
514 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
517 * @brief 地形は開くものであって、かつ開かれているかを返す /
518 * Attempt to open the given chest at the given location
520 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
522 static bool is_open(IDX feat)
524 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
529 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
530 * Attempt to open the given chest at the given location
531 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
532 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
533 * @param test 地形条件を判定するための関数ポインタ
534 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
536 * @details Return the number of features around (or under) the character.
537 * Usually look for doors and floor traps.
539 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
541 int d, count, xx, yy;
543 /* Count how many matches */
546 /* Check around (and under) the character */
547 for (d = 0; d < 9; d++)
552 /* if not searching under player continue */
553 if ((d == 8) && !under) continue;
555 /* Extract adjacent (legal) location */
556 yy = p_ptr->y + ddy_ddd[d];
557 xx = p_ptr->x + ddx_ddd[d];
560 c_ptr = &cave[yy][xx];
562 /* Must have knowledge */
563 if (!(c_ptr->info & (CAVE_MARK))) continue;
565 /* Feature code (applying "mimic" field) */
566 feat = get_feat_mimic(c_ptr);
568 /* Not looking for this feature */
569 if (!((*test)(feat))) continue;
574 /* Remember the location. Only useful if only one match */
585 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
586 * Return the number of chests around (or under) the character.
587 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
588 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
589 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
592 * If requested, count only trapped chests.
594 static int count_chests(POSITION *y, POSITION *x, bool trapped)
601 /* Count how many matches */
604 /* Check around (and under) the character */
605 for (d = 0; d < 9; d++)
607 /* Extract adjacent (legal) location */
608 POSITION yy = p_ptr->y + ddy_ddd[d];
609 POSITION xx = p_ptr->x + ddx_ddd[d];
611 /* No (visible) chest is there */
612 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
614 /* Grab the object */
615 o_ptr = &o_list[o_idx];
618 if (o_ptr->pval == 0) continue;
620 /* No (known) traps here */
621 if (trapped && (!object_is_known(o_ptr) ||
622 !chest_traps[o_ptr->pval])) continue;
627 /* Remember the location. Only useful if only one match */
638 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
639 * Convert an adjacent location to a direction.
640 * @param y 方角を確認したY座標
641 * @param x 方角を確認したX座標
644 static DIRECTION coords_to_dir(POSITION y, POSITION x)
646 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
653 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
655 return d[dx + 1][dy + 1];
658 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
662 * @brief 「開ける」動作コマンドのサブルーチン /
663 * Perform the basic "open" command on doors
664 * @param y 対象を行うマスのY座標
665 * @param x 対象を行うマスのX座標
666 * @return 実際に処理が行われた場合TRUEを返す。
668 * Assume destination is a closed/locked/jammed door
669 * Assume there is no monster blocking the destination
670 * Returns TRUE if repeated commands may continue
672 static bool do_cmd_open_aux(POSITION y, POSITION x)
676 /* Get requested grid */
677 cave_type *c_ptr = &cave[y][x];
679 feature_type *f_ptr = &f_info[c_ptr->feat];
685 p_ptr->energy_use = 100;
687 /* Seeing true feature code (ignore mimic) */
690 if (!have_flag(f_ptr->flags, FF_OPEN))
693 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
697 else if (f_ptr->power)
700 i = p_ptr->skill_dis;
702 /* Penalize some conditions */
703 if (p_ptr->blind || no_lite()) i = i / 10;
704 if (p_ptr->confused || p_ptr->image) i = i / 10;
706 /* Extract the lock power */
709 /* Extract the difficulty XXX XXX XXX */
712 /* Always have a small chance of success */
716 if (randint0(100) < j)
719 msg_print(_("鍵をはずした。", "You have picked the lock."));
722 cave_alter_feat(y, x, FF_OPEN);
724 sound(SOUND_OPENDOOR);
734 if (flush_failure) flush();
737 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
739 /* We may keep trying */
748 cave_alter_feat(y, x, FF_OPEN);
750 sound(SOUND_OPENDOOR);
758 * @brief 「開ける」コマンドのメインルーチン /
759 * Open a closed/locked/jammed door or a closed/locked chest.
762 * Unlocking a locked door/chest is worth one experience point.
764 void do_cmd_open(void)
772 if (p_ptr->special_defense & KATA_MUSOU)
774 set_action(ACTION_NONE);
777 #ifdef ALLOW_EASY_OPEN /* TNB */
779 /* Option: Pick a direction */
782 int num_doors, num_chests;
784 /* Count closed doors (locked or jammed) */
785 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
787 /* Count chests (locked) */
788 num_chests = count_chests(&y, &x, FALSE);
790 /* See if only one target */
791 if (num_doors || num_chests)
793 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
795 if (!too_many) command_dir = coords_to_dir(y, x);
799 #endif /* ALLOW_EASY_OPEN -- TNB */
801 /* Allow repeated command */
804 /* Set repeat count */
805 command_rep = command_arg - 1;
807 /* Redraw the state */
808 p_ptr->redraw |= (PR_STATE);
814 /* Get a "repeated" direction */
815 if (get_rep_dir(&dir, TRUE))
820 /* Get requested location */
821 y = p_ptr->y + ddy[dir];
822 x = p_ptr->x + ddx[dir];
824 /* Get requested grid */
827 /* Feature code (applying "mimic" field) */
828 feat = get_feat_mimic(c_ptr);
830 /* Check for chest */
831 o_idx = chest_check(y, x, FALSE);
834 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
837 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
840 /* Monster in the way */
841 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
844 p_ptr->energy_use = 100;
847 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
857 more = do_cmd_open_chest(y, x, o_idx);
864 more = do_cmd_open_aux(y, x);
868 /* Cancel repeat unless we may continue */
869 if (!more) disturb(0, 0);
875 * @brief 「閉じる」動作コマンドのサブルーチン /
876 * Perform the basic "close" command
877 * @param y 対象を行うマスのY座標
878 * @param x 対象を行うマスのX座標
879 * @return 実際に処理が行われた場合TRUEを返す。
881 * Assume destination is an open/broken door
882 * Assume there is no monster blocking the destination
883 * Returns TRUE if repeated commands may continue
885 static bool do_cmd_close_aux(POSITION y, POSITION x)
887 /* Get grid and contents */
888 cave_type *c_ptr = &cave[y][x];
889 FEAT_IDX old_feat = c_ptr->feat;
893 p_ptr->energy_use = 100;
895 /* Seeing true feature code (ignore mimic) */
898 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
900 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
902 /* Hack -- object in the way */
903 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
904 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
907 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
912 cave_alter_feat(y, x, FF_CLOSE);
915 if (old_feat == c_ptr->feat)
918 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
922 sound(SOUND_SHUTDOOR);
933 * @brief 「閉じる」コマンドのメインルーチン /
934 * Close an open door.
937 * Unlocking a locked door/chest is worth one experience point.
939 void do_cmd_close(void)
946 if (p_ptr->special_defense & KATA_MUSOU)
948 set_action(ACTION_NONE);
951 #ifdef ALLOW_EASY_OPEN /* TNB */
953 /* Option: Pick a direction */
956 /* Count open doors */
957 if (count_dt(&y, &x, is_open, FALSE) == 1)
959 command_dir = coords_to_dir(y, x);
963 #endif /* ALLOW_EASY_OPEN -- TNB */
965 /* Allow repeated command */
968 /* Set repeat count */
969 command_rep = command_arg - 1;
971 /* Redraw the state */
972 p_ptr->redraw |= (PR_STATE);
978 /* Get a "repeated" direction */
979 if (get_rep_dir(&dir,FALSE))
984 /* Get requested location */
985 y = p_ptr->y + ddy[dir];
986 x = p_ptr->x + ddx[dir];
988 /* Get grid and contents */
991 /* Feature code (applying "mimic" field) */
992 feat = get_feat_mimic(c_ptr);
994 /* Require open/broken door */
995 if (!have_flag(f_info[feat].flags, FF_CLOSE))
998 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1001 /* Monster in the way */
1002 else if (c_ptr->m_idx)
1005 p_ptr->energy_use = 100;
1008 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1014 /* Close the door */
1017 /* Close the door */
1018 more = do_cmd_close_aux(y, x);
1022 /* Cancel repeat unless we may continue */
1023 if (!more) disturb(0, 0);
1028 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1029 * Determine if a given grid may be "tunneled"
1030 * @param y 対象を行うマスのY座標
1031 * @param x 対象を行うマスのX座標
1034 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1036 cave_type *c_ptr = &cave[y][x];
1038 /* Must have knowledge */
1039 if (!(c_ptr->info & CAVE_MARK))
1042 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1048 /* Must be a wall/door/etc */
1049 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1052 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1064 * @brief 「掘る」動作コマンドのサブルーチン /
1065 * Perform the basic "tunnel" command
1066 * @param y 対象を行うマスのY座標
1067 * @param x 対象を行うマスのX座標
1068 * @return 実際に処理が行われた場合TRUEを返す。
1070 * Assumes that no monster is blocking the destination
1071 * Do not use twall anymore
1072 * Returns TRUE if repeated commands may continue
1074 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1077 feature_type *f_ptr, *mimic_f_ptr;
1082 /* Verify legality */
1083 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1086 p_ptr->energy_use = 100;
1089 c_ptr = &cave[y][x];
1090 f_ptr = &f_info[c_ptr->feat];
1091 power = f_ptr->power;
1093 /* Feature code (applying "mimic" field) */
1094 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1096 name = f_name + mimic_f_ptr->name;
1100 if (have_flag(f_ptr->flags, FF_PERMANENT))
1103 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1105 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1108 /* Map border (mimiccing Permanent wall) */
1111 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1116 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1119 if (p_ptr->skill_dig > randint0(20 * power))
1122 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1124 /* Remove the feature */
1125 cave_alter_feat(y, x, FF_TUNNEL);
1127 /* Update some things */
1128 p_ptr->update |= (PU_FLOW);
1132 /* Message, keep digging */
1133 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1141 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1144 if (p_ptr->skill_dig > power + randint0(40 * power))
1146 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1149 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1150 p_ptr->update |= (PU_FLOW);
1153 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1155 /* Remove the feature */
1156 cave_alter_feat(y, x, FF_TUNNEL);
1158 chg_virtue(V_DILIGENCE, 1);
1159 chg_virtue(V_NATURE, -1);
1167 /* We may continue chopping */
1168 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1169 /* Occasional Search XXX XXX */
1170 if (randint0(100) < 25) search();
1174 /* We may continue tunelling */
1175 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1182 if (is_hidden_door(c_ptr))
1184 /* Occasional Search XXX XXX */
1185 if (randint0(100) < 25) search();
1194 * @brief 「掘る」動作コマンドのメインルーチン /
1195 * Tunnels through "walls" (including rubble and closed doors)
1199 * Note that you must tunnel in order to hit invisible monsters
1200 * in walls, though moving into walls still takes a turn anyway.
1202 * Digging is very difficult without a "digger" weapon, but can be
1203 * accomplished by strong players using heavy weapons.
1206 void do_cmd_tunnel(void)
1216 if (p_ptr->special_defense & KATA_MUSOU)
1218 set_action(ACTION_NONE);
1221 /* Allow repeated command */
1224 /* Set repeat count */
1225 command_rep = command_arg - 1;
1227 /* Redraw the state */
1228 p_ptr->redraw |= (PR_STATE);
1230 /* Cancel the arg */
1234 /* Get a direction to tunnel, or Abort */
1235 if (get_rep_dir(&dir,FALSE))
1238 y = p_ptr->y + ddy[dir];
1239 x = p_ptr->x + ddx[dir];
1242 c_ptr = &cave[y][x];
1244 /* Feature code (applying "mimic" field) */
1245 feat = get_feat_mimic(c_ptr);
1247 /* No tunnelling through doors */
1248 if (have_flag(f_info[feat].flags, FF_DOOR))
1251 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1254 /* No tunnelling through most features */
1255 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1257 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1260 /* A monster is in the way */
1261 else if (c_ptr->m_idx)
1264 p_ptr->energy_use = 100;
1267 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1276 /* Tunnel through walls */
1277 more = do_cmd_tunnel_aux(y, x);
1281 /* Cancel repetition unless we can continue */
1282 if (!more) disturb(0, 0);
1286 #ifdef ALLOW_EASY_OPEN /* TNB */
1289 * @brief 移動処理による簡易な「開く」処理 /
1291 * @return 開く処理が実際に試みられた場合TRUEを返す
1294 * If there is a jammed/closed/locked door at the given location,
1295 * then attempt to unlock/open it. Return TRUE if an attempt was
1296 * made (successful or not), otherwise return FALSE.
1298 * The code here should be nearly identical to that in
1299 * do_cmd_open_test() and do_cmd_open_aux().
1302 bool easy_open_door(POSITION y, POSITION x)
1306 cave_type *c_ptr = &cave[y][x];
1307 feature_type *f_ptr = &f_info[c_ptr->feat];
1309 /* Must be a closed door */
1310 if (!is_closed_door(c_ptr->feat))
1317 if (!have_flag(f_ptr->flags, FF_OPEN))
1320 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1325 else if (f_ptr->power)
1328 i = p_ptr->skill_dis;
1330 /* Penalize some conditions */
1331 if (p_ptr->blind || no_lite()) i = i / 10;
1332 if (p_ptr->confused || p_ptr->image) i = i / 10;
1334 /* Extract the lock power */
1337 /* Extract the difficulty XXX XXX XXX */
1340 /* Always have a small chance of success */
1344 if (randint0(100) < j)
1347 msg_print(_("鍵をはずした。", "You have picked the lock."));
1350 cave_alter_feat(y, x, FF_OPEN);
1352 sound(SOUND_OPENDOOR);
1362 if (flush_failure) flush();
1365 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1374 cave_alter_feat(y, x, FF_OPEN);
1376 sound(SOUND_OPENDOOR);
1383 #endif /* ALLOW_EASY_OPEN -- TNB */
1387 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1388 * Perform the basic "disarm" command
1389 * @param y 解除を行うマスのY座標
1390 * @param x 解除を行うマスのX座標
1391 * @param o_idx 箱のオブジェクトID
1392 * @return ターンを消費する処理が行われた場合TRUEを返す
1395 * Assume destination is a visible trap
1396 * Assume there is no monster blocking the destination
1397 * Returns TRUE if repeated commands may continue
1400 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1406 object_type *o_ptr = &o_list[o_idx];
1410 p_ptr->energy_use = 100;
1412 /* Get the "disarm" factor */
1413 i = p_ptr->skill_dis;
1415 /* Penalize some conditions */
1416 if (p_ptr->blind || no_lite()) i = i / 10;
1417 if (p_ptr->confused || p_ptr->image) i = i / 10;
1419 /* Extract the difficulty */
1420 j = i - o_ptr->pval;
1422 /* Always have a small chance of success */
1425 /* Must find the trap first. */
1426 if (!object_is_known(o_ptr))
1428 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1432 /* Already disarmed/unlocked */
1433 else if (o_ptr->pval <= 0)
1435 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1438 /* No traps to find. */
1439 else if (!chest_traps[o_ptr->pval])
1441 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1444 /* Success (get a lot of experience) */
1445 else if (randint0(100) < j)
1447 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1448 gain_exp(o_ptr->pval);
1449 o_ptr->pval = (0 - o_ptr->pval);
1452 /* Failure -- Keep trying */
1453 else if ((i > 5) && (randint1(i) > 5))
1455 /* We may keep trying */
1457 if (flush_failure) flush();
1458 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1461 /* Failure -- Set off the trap */
1464 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1466 chest_trap(y, x, o_idx);
1475 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1476 * Perform the basic "disarm" command
1477 * @param y 解除を行うマスのY座標
1478 * @param x 解除を行うマスのX座標
1479 * @param dir プレイヤーからみた方向ID
1480 * @return ターンを消費する処理が行われた場合TRUEを返す
1483 * Assume destination is a visible trap
1484 * Assume there is no monster blocking the destination
1485 * Returns TRUE if repeated commands may continue
1488 #ifdef ALLOW_EASY_DISARM /* TNB */
1490 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1492 #else /* ALLOW_EASY_DISARM -- TNB */
1494 static bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1496 #endif /* ALLOW_EASY_DISARM -- TNB */
1498 /* Get grid and contents */
1499 cave_type *c_ptr = &cave[y][x];
1502 feature_type *f_ptr = &f_info[c_ptr->feat];
1504 /* Access trap name */
1505 cptr name = (f_name + f_ptr->name);
1507 /* Extract trap "power" */
1508 int power = f_ptr->power;
1512 /* Get the "disarm" factor */
1513 int i = p_ptr->skill_dis;
1518 p_ptr->energy_use = 100;
1520 /* Penalize some conditions */
1521 if (p_ptr->blind || no_lite()) i = i / 10;
1522 if (p_ptr->confused || p_ptr->image) i = i / 10;
1524 /* Extract the difficulty */
1527 /* Always have a small chance of success */
1531 if (randint0(100) < j)
1534 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1539 /* Remove the trap */
1540 cave_alter_feat(y, x, FF_DISARM);
1542 #ifdef ALLOW_EASY_DISARM /* TNB */
1544 /* Move the player onto the trap */
1545 move_player(dir, easy_disarm, FALSE);
1547 #else /* ALLOW_EASY_DISARM -- TNB */
1549 /* move the player onto the trap grid */
1550 move_player(dir, FALSE, FALSE);
1552 #endif /* ALLOW_EASY_DISARM -- TNB */
1555 /* Failure -- Keep trying */
1556 else if ((i > 5) && (randint1(i) > 5))
1559 if (flush_failure) flush();
1562 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1564 /* We may keep trying */
1568 /* Failure -- Set off the trap */
1572 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1574 #ifdef ALLOW_EASY_DISARM /* TNB */
1576 /* Move the player onto the trap */
1577 move_player(dir, easy_disarm, FALSE);
1579 #else /* ALLOW_EASY_DISARM -- TNB */
1581 /* Move the player onto the trap */
1582 move_player(dir, FALSE, FALSE);
1584 #endif /* ALLOW_EASY_DISARM -- TNB */
1593 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1594 * Disarms a trap, or chest
1597 void do_cmd_disarm(void)
1605 if (p_ptr->special_defense & KATA_MUSOU)
1607 set_action(ACTION_NONE);
1610 #ifdef ALLOW_EASY_DISARM /* TNB */
1612 /* Option: Pick a direction */
1615 int num_traps, num_chests;
1617 /* Count visible traps */
1618 num_traps = count_dt(&y, &x, is_trap, TRUE);
1620 /* Count chests (trapped) */
1621 num_chests = count_chests(&y, &x, TRUE);
1623 /* See if only one target */
1624 if (num_traps || num_chests)
1626 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1627 if (!too_many) command_dir = coords_to_dir(y, x);
1631 #endif /* ALLOW_EASY_DISARM -- TNB */
1633 /* Allow repeated command */
1636 /* Set repeat count */
1637 command_rep = command_arg - 1;
1639 /* Redraw the state */
1640 p_ptr->redraw |= (PR_STATE);
1642 /* Cancel the arg */
1646 /* Get a direction (or abort) */
1647 if (get_rep_dir(&dir,TRUE))
1653 y = p_ptr->y + ddy[dir];
1654 x = p_ptr->x + ddx[dir];
1656 /* Get grid and contents */
1657 c_ptr = &cave[y][x];
1659 /* Feature code (applying "mimic" field) */
1660 feat = get_feat_mimic(c_ptr);
1662 /* Check for chests */
1663 o_idx = chest_check(y, x, TRUE);
1666 if (!is_trap(feat) && !o_idx)
1669 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1672 /* Monster in the way */
1673 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1676 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1685 /* Disarm the chest */
1686 more = do_cmd_disarm_chest(y, x, o_idx);
1692 /* Disarm the trap */
1693 more = do_cmd_disarm_aux(y, x, dir);
1697 /* Cancel repeat unless told not to */
1698 if (!more) disturb(0, 0);
1703 * @brief 「打ち破る」動作コマンドのサブルーチン /
1704 * Perform the basic "bash" command
1705 * @param y 対象を行うマスのY座標
1706 * @param x 対象を行うマスのX座標
1707 * @param dir プレイヤーから見たターゲットの方角ID
1708 * @return 実際に処理が行われた場合TRUEを返す。
1711 * Assume destination is a closed/locked/jammed door
1712 * Assume there is no monster blocking the destination
1713 * Returns TRUE if repeated commands may continue
1716 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1719 cave_type *c_ptr = &cave[y][x];
1722 feature_type *f_ptr = &f_info[c_ptr->feat];
1724 /* Hack -- Bash power based on strength */
1725 /* (Ranges from 3 to 20 to 100 to 200) */
1726 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1728 /* Extract door power */
1729 int temp = f_ptr->power;
1733 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1736 p_ptr->energy_use = 100;
1739 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1741 /* Compare bash power to door power XXX XXX XXX */
1742 temp = (bash - (temp * 10));
1744 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1746 /* Hack -- always have a chance */
1747 if (temp < 1) temp = 1;
1749 /* Hack -- attempt to bash down the door */
1750 if (randint0(100) < temp)
1753 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1755 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1757 /* Break down the door */
1758 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1760 cave_alter_feat(y, x, FF_BASH);
1766 cave_alter_feat(y, x, FF_OPEN);
1769 /* Hack -- Fall through the door */
1770 move_player(dir, FALSE, FALSE);
1773 /* Saving throw against stun */
1774 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1778 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1780 /* Allow repeated bashing */
1784 /* High dexterity yields coolness */
1788 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1790 /* Hack -- Lose balance ala paralysis */
1791 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1800 * @brief 「打ち破る」動作コマンドのメインルーチン /
1801 * Bash open a door, success based on character strength
1805 * For a closed door, pval is positive if locked; negative if stuck.
1807 * For an open door, pval is positive for a broken door.
1809 * A closed door can be opened - harder if locked. Any door might be
1810 * bashed open (and thereby broken). Bashing a door is (potentially)
1811 * faster! You move into the door way. To open a stuck door, it must
1812 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1814 * Creatures can also open or bash doors, see elsewhere.
1817 void do_cmd_bash(void)
1826 if (p_ptr->special_defense & KATA_MUSOU)
1828 set_action(ACTION_NONE);
1831 /* Allow repeated command */
1834 /* Set repeat count */
1835 command_rep = command_arg - 1;
1837 /* Redraw the state */
1838 p_ptr->redraw |= (PR_STATE);
1840 /* Cancel the arg */
1844 /* Get a "repeated" direction */
1845 if (get_rep_dir(&dir,FALSE))
1850 y = p_ptr->y + ddy[dir];
1851 x = p_ptr->x + ddx[dir];
1854 c_ptr = &cave[y][x];
1856 /* Feature code (applying "mimic" field) */
1857 feat = get_feat_mimic(c_ptr);
1859 /* Nothing useful */
1860 if (!have_flag(f_info[feat].flags, FF_BASH))
1863 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1866 /* Monster in the way */
1867 else if (c_ptr->m_idx)
1870 p_ptr->energy_use = 100;
1873 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1879 /* Bash a closed door */
1883 more = do_cmd_bash_aux(y, x, dir);
1887 /* Unless valid action taken, cancel bash */
1888 if (!more) disturb(0, 0);
1893 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1897 * Manipulate an adjacent grid in some way
1899 * Attack monsters, tunnel through walls, disarm traps, open doors.
1901 * Consider confusion XXX XXX XXX
1903 * This command must always take a turn, to prevent free detection
1904 * of invisible monsters.
1907 void do_cmd_alter(void)
1916 if (p_ptr->special_defense & KATA_MUSOU)
1918 set_action(ACTION_NONE);
1921 /* Allow repeated command */
1924 /* Set repeat count */
1925 command_rep = command_arg - 1;
1927 /* Redraw the state */
1928 p_ptr->redraw |= (PR_STATE);
1930 /* Cancel the arg */
1934 /* Get a direction */
1935 if (get_rep_dir(&dir,TRUE))
1938 feature_type *f_ptr;
1941 y = p_ptr->y + ddy[dir];
1942 x = p_ptr->x + ddx[dir];
1945 c_ptr = &cave[y][x];
1947 /* Feature code (applying "mimic" field) */
1948 feat = get_feat_mimic(c_ptr);
1949 f_ptr = &f_info[feat];
1952 p_ptr->energy_use = 100;
1954 /* Attack monsters */
1962 else if (have_flag(f_ptr->flags, FF_OPEN))
1964 more = do_cmd_open_aux(y, x);
1967 /* Bash jammed doors */
1968 else if (have_flag(f_ptr->flags, FF_BASH))
1970 more = do_cmd_bash_aux(y, x, dir);
1973 /* Tunnel through walls */
1974 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1976 more = do_cmd_tunnel_aux(y, x);
1979 /* Close open doors */
1980 else if (have_flag(f_ptr->flags, FF_CLOSE))
1982 more = do_cmd_close_aux(y, x);
1986 else if (have_flag(f_ptr->flags, FF_DISARM))
1988 more = do_cmd_disarm_aux(y, x, dir);
1995 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1999 /* Cancel repetition unless we can continue */
2000 if (!more) disturb(0, 0);
2006 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
2007 * Find the index of some "spikes", if possible.
2008 * @param ip くさびとして打てるオブジェクトのID
2009 * @return オブジェクトがある場合TRUEを返す
2012 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2015 static bool get_spike(INVENTORY_IDX *ip)
2019 /* Check every item in the pack */
2020 for (i = 0; i < INVEN_PACK; i++)
2022 object_type *o_ptr = &inventory[i];
2024 /* Skip non-objects */
2025 if (!o_ptr->k_idx) continue;
2027 /* Check the "tval" code */
2028 if (o_ptr->tval == TV_SPIKE)
2030 /* Save the spike index */
2044 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
2045 * Jam a closed door with a spike
2049 * This command may NOT be repeated
2052 void do_cmd_spike(void)
2056 if (p_ptr->special_defense & KATA_MUSOU)
2058 set_action(ACTION_NONE);
2061 /* Get a "repeated" direction */
2062 if (get_rep_dir(&dir,FALSE))
2070 y = p_ptr->y + ddy[dir];
2071 x = p_ptr->x + ddx[dir];
2073 /* Get grid and contents */
2074 c_ptr = &cave[y][x];
2076 /* Feature code (applying "mimic" field) */
2077 feat = get_feat_mimic(c_ptr);
2079 /* Require closed door */
2080 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2083 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2087 else if (!get_spike(&item))
2090 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2093 /* Is a monster in the way? */
2094 else if (c_ptr->m_idx)
2097 p_ptr->energy_use = 100;
2100 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2110 p_ptr->energy_use = 100;
2112 /* Successful jamming */
2113 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2114 cave_alter_feat(y, x, FF_SPIKE);
2116 /* Use up, and describe, a single spike, from the bottom */
2117 inven_item_increase(item, -1);
2118 inven_item_describe(item);
2119 inven_item_optimize(item);
2127 * @brief 「歩く」動作コマンドのメインルーチン /
2128 * Support code for the "Walk" and "Jump" commands
2129 * @param pickup アイテムの自動拾いを行うならTRUE
2132 void do_cmd_walk(bool pickup)
2139 /* Allow repeated command */
2142 /* Set repeat count */
2143 command_rep = command_arg - 1;
2145 /* Redraw the state */
2146 p_ptr->redraw |= (PR_STATE);
2148 /* Cancel the arg */
2152 /* Get a "repeated" direction */
2153 if (get_rep_dir(&dir, FALSE))
2156 p_ptr->energy_use = 100;
2158 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2160 set_action(ACTION_NONE);
2163 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2164 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2165 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2167 /* Actually move the character */
2168 move_player(dir, pickup, FALSE);
2170 /* Allow more walking */
2174 /* Hack again -- Is there a special encounter ??? */
2175 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2177 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2180 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2182 /* Inform the player of his horrible fate :=) */
2183 msg_print(_("襲撃だ!", "You are ambushed !"));
2185 /* Go into large wilderness view */
2186 p_ptr->oldpy = randint1(MAX_HGT-2);
2187 p_ptr->oldpx = randint1(MAX_WID-2);
2190 /* Give first move to monsters */
2191 p_ptr->energy_use = 100;
2193 /* HACk -- set the encouter flag for the wilderness generation */
2194 generate_encounter = TRUE;
2198 /* Cancel repeat unless we may continue */
2199 if (!more) disturb(0, 0);
2204 * @brief 「走る」動作コマンドのメインルーチン /
2208 void do_cmd_run(void)
2212 /* Hack -- no running when confused */
2213 if (p_ptr->confused)
2215 msg_print(_("混乱していて走れない!", "You are too confused!"));
2219 if (p_ptr->special_defense & KATA_MUSOU)
2221 set_action(ACTION_NONE);
2224 /* Get a "repeated" direction */
2225 if (get_rep_dir(&dir,FALSE))
2227 /* Hack -- Set the run counter */
2228 running = (command_arg ? command_arg : 1000);
2237 * @brief 「留まる」動作コマンドのメインルーチン /
2238 * Stay still. Search. Enter stores.
2239 * Pick up treasure if "pickup" is true.
2240 * @param pickup アイテムの自動拾いを行うならTRUE
2243 void do_cmd_stay(bool pickup)
2245 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2247 /* Allow repeated command */
2250 /* Set repeat count */
2251 command_rep = command_arg - 1;
2253 /* Redraw the state */
2254 p_ptr->redraw |= (PR_STATE);
2256 /* Cancel the arg */
2261 p_ptr->energy_use = 100;
2263 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2264 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2269 * @brief 「休む」動作コマンドのメインルーチン /
2270 * Resting allows a player to safely restore his hp -RAK-
2273 void do_cmd_rest(void)
2276 set_action(ACTION_NONE);
2278 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2284 if (hex_spelling_any()) stop_hex_spell_all();
2286 /* Prompt for time if needed */
2287 if (command_arg <= 0)
2289 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2290 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2296 strcpy(out_val, "&");
2298 /* Ask for duration */
2299 if (!get_string(p, out_val, 4)) return;
2301 /* Rest until done */
2302 if (out_val[0] == '&')
2304 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2308 else if (out_val[0] == '*')
2310 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2316 command_arg = (COMMAND_ARG)atoi(out_val);
2317 if (command_arg <= 0) return;
2323 if (command_arg > 9999) command_arg = 9999;
2325 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2327 /* Take a turn XXX XXX XXX (?) */
2328 p_ptr->energy_use = 100;
2330 /* The sin of sloth */
2331 if (command_arg > 100)
2332 chg_virtue(V_DILIGENCE, -1);
2334 /* Why are you sleeping when there's no need? WAKE UP!*/
2335 if ((p_ptr->chp == p_ptr->mhp) &&
2336 (p_ptr->csp == p_ptr->msp) &&
2337 !p_ptr->blind && !p_ptr->confused &&
2338 !p_ptr->poisoned && !p_ptr->afraid &&
2339 !p_ptr->stun && !p_ptr->cut &&
2340 !p_ptr->slow && !p_ptr->paralyzed &&
2341 !p_ptr->image && !p_ptr->word_recall &&
2342 !p_ptr->alter_reality)
2343 chg_virtue(V_DILIGENCE, -1);
2345 /* Save the rest code */
2346 resting = command_arg;
2347 p_ptr->action = ACTION_REST;
2349 /* Recalculate bonuses */
2350 p_ptr->update |= (PU_BONUS);
2352 /* Redraw the state */
2353 p_ptr->redraw |= (PR_STATE);
2364 * @brief 矢弾を射撃した場合の破損確率を返す /
2365 * Determines the odds of an object breaking when thrown at a monster
2366 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2369 * Note that artifacts never break, see the "drop_near()" function.
2371 static PERCENTAGE breakage_chance(object_type *o_ptr)
2373 PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0);
2375 /* Examine the snipe type */
2378 if (snipe_type == SP_KILL_WALL) return (100);
2379 if (snipe_type == SP_EXPLODE) return (100);
2380 if (snipe_type == SP_PIERCE) return (100);
2381 if (snipe_type == SP_FINAL) return (100);
2382 if (snipe_type == SP_NEEDLE) return (100);
2383 if (snipe_type == SP_EVILNESS) return (40);
2384 if (snipe_type == SP_HOLYNESS) return (40);
2387 /* Examine the item type */
2388 switch (o_ptr->tval)
2404 /* Sometimes break */
2409 return (20 - archer_bonus * 2);
2414 return (10 - archer_bonus);
2422 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2423 * Determines the odds of an object breaking when thrown at a monster
2424 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2425 * @param tdam 計算途中のダメージ量
2426 * @param m_ptr 目標モンスターの構造体参照ポインタ
2427 * @return スレイ倍率をかけたダメージ量
2429 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2433 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2435 BIT_FLAGS flgs[TR_FLAG_SIZE];
2437 /* Extract the flags */
2438 object_flags(o_ptr, flgs);
2440 /* Some "weapons" and "ammo" do extra damage */
2441 switch (o_ptr->tval)
2448 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2449 (r_ptr->flags3 & RF3_ANIMAL))
2451 if (is_original_ap_and_seen(m_ptr))
2453 r_ptr->r_flags3 |= RF3_ANIMAL;
2456 if (mult < 17) mult = 17;
2460 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2461 (r_ptr->flags3 & RF3_ANIMAL))
2463 if (is_original_ap_and_seen(m_ptr))
2465 r_ptr->r_flags3 |= RF3_ANIMAL;
2468 if (mult < 27) mult = 27;
2472 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2473 (r_ptr->flags3 & RF3_EVIL))
2475 if (is_original_ap_and_seen(m_ptr))
2477 r_ptr->r_flags3 |= RF3_EVIL;
2480 if (mult < 15) mult = 15;
2484 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2485 (r_ptr->flags3 & RF3_EVIL))
2487 if (is_original_ap_and_seen(m_ptr))
2489 r_ptr->r_flags3 |= RF3_EVIL;
2492 if (mult < 25) mult = 25;
2496 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2497 (r_ptr->flags2 & RF2_HUMAN))
2499 if (is_original_ap_and_seen(m_ptr))
2501 r_ptr->r_flags2 |= RF2_HUMAN;
2504 if (mult < 17) mult = 17;
2508 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2509 (r_ptr->flags2 & RF2_HUMAN))
2511 if (is_original_ap_and_seen(m_ptr))
2513 r_ptr->r_flags2 |= RF2_HUMAN;
2516 if (mult < 27) mult = 27;
2520 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2521 (r_ptr->flags3 & RF3_UNDEAD))
2523 if (is_original_ap_and_seen(m_ptr))
2525 r_ptr->r_flags3 |= RF3_UNDEAD;
2528 if (mult < 20) mult = 20;
2532 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2533 (r_ptr->flags3 & RF3_UNDEAD))
2535 if (is_original_ap_and_seen(m_ptr))
2537 r_ptr->r_flags3 |= RF3_UNDEAD;
2540 if (mult < 30) mult = 30;
2544 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2545 (r_ptr->flags3 & RF3_DEMON))
2547 if (is_original_ap_and_seen(m_ptr))
2549 r_ptr->r_flags3 |= RF3_DEMON;
2552 if (mult < 20) mult = 20;
2556 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2557 (r_ptr->flags3 & RF3_DEMON))
2559 if (is_original_ap_and_seen(m_ptr))
2561 r_ptr->r_flags3 |= RF3_DEMON;
2564 if (mult < 30) mult = 30;
2568 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2569 (r_ptr->flags3 & RF3_ORC))
2571 if (is_original_ap_and_seen(m_ptr))
2573 r_ptr->r_flags3 |= RF3_ORC;
2576 if (mult < 20) mult = 20;
2580 if ((have_flag(flgs, TR_KILL_ORC)) &&
2581 (r_ptr->flags3 & RF3_ORC))
2583 if (is_original_ap_and_seen(m_ptr))
2585 r_ptr->r_flags3 |= RF3_ORC;
2588 if (mult < 30) mult = 30;
2592 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2593 (r_ptr->flags3 & RF3_TROLL))
2595 if (is_original_ap_and_seen(m_ptr))
2597 r_ptr->r_flags3 |= RF3_TROLL;
2600 if (mult < 20) mult = 20;
2604 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2605 (r_ptr->flags3 & RF3_TROLL))
2607 if (is_original_ap_and_seen(m_ptr))
2609 r_ptr->r_flags3 |= RF3_TROLL;
2612 if (mult < 30) mult = 30;
2616 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2617 (r_ptr->flags3 & RF3_GIANT))
2619 if (is_original_ap_and_seen(m_ptr))
2621 r_ptr->r_flags3 |= RF3_GIANT;
2624 if (mult < 20) mult = 20;
2628 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2629 (r_ptr->flags3 & RF3_GIANT))
2631 if (is_original_ap_and_seen(m_ptr))
2633 r_ptr->r_flags3 |= RF3_GIANT;
2636 if (mult < 30) mult = 30;
2640 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
2641 (r_ptr->flags3 & RF3_DRAGON))
2643 if (is_original_ap_and_seen(m_ptr))
2645 r_ptr->r_flags3 |= RF3_DRAGON;
2648 if (mult < 20) mult = 20;
2651 /* Execute Dragon */
2652 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
2653 (r_ptr->flags3 & RF3_DRAGON))
2655 if (is_original_ap_and_seen(m_ptr))
2657 r_ptr->r_flags3 |= RF3_DRAGON;
2660 if (mult < 30) mult = 30;
2662 if ((o_ptr->name1 == ART_BARD_ARROW) &&
2663 (m_ptr->r_idx == MON_SMAUG) &&
2664 (inventory[INVEN_BOW].name1 == ART_BARD))
2669 if (have_flag(flgs, TR_BRAND_ACID))
2671 /* Notice immunity */
2672 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2674 if (is_original_ap_and_seen(m_ptr))
2676 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2680 /* Otherwise, take the damage */
2683 if (mult < 17) mult = 17;
2688 if (have_flag(flgs, TR_BRAND_ELEC))
2690 /* Notice immunity */
2691 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2693 if (is_original_ap_and_seen(m_ptr))
2695 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2699 /* Otherwise, take the damage */
2702 if (mult < 17) mult = 17;
2707 if (have_flag(flgs, TR_BRAND_FIRE))
2709 /* Notice immunity */
2710 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2712 if (is_original_ap_and_seen(m_ptr))
2714 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2718 /* Otherwise, take the damage */
2721 if (r_ptr->flags3 & RF3_HURT_FIRE)
2723 if (mult < 25) mult = 25;
2724 if (is_original_ap_and_seen(m_ptr))
2726 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2729 else if (mult < 17) mult = 17;
2734 if (have_flag(flgs, TR_BRAND_COLD))
2736 /* Notice immunity */
2737 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2739 if (is_original_ap_and_seen(m_ptr))
2741 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2744 /* Otherwise, take the damage */
2747 if (r_ptr->flags3 & RF3_HURT_COLD)
2749 if (mult < 25) mult = 25;
2750 if (is_original_ap_and_seen(m_ptr))
2752 r_ptr->r_flags3 |= RF3_HURT_COLD;
2755 else if (mult < 17) mult = 17;
2759 /* Brand (Poison) */
2760 if (have_flag(flgs, TR_BRAND_POIS))
2762 /* Notice immunity */
2763 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2765 if (is_original_ap_and_seen(m_ptr))
2767 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2771 /* Otherwise, take the damage */
2774 if (mult < 17) mult = 17;
2778 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2780 p_ptr->csp -= (1+(p_ptr->msp / 30));
2781 p_ptr->redraw |= (PR_MANA);
2782 mult = mult * 5 / 2;
2789 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2791 /* Return the total damage */
2792 return (tdam * mult / 10);
2797 * @brief 射撃処理のサブルーチン /
2798 * Fire an object from the pack or floor.
2799 * @param item 射撃するオブジェクトの所持ID
2800 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2804 * You may only fire items that "match" your missile launcher.
2806 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2808 * See "calc_bonuses()" for more calculations and such.
2810 * Note that "firing" a missile is MUCH better than "throwing" it.
2812 * Note: "unseen" monsters are very hard to hit.
2814 * Objects are more likely to break if they "attempt" to hit a monster.
2816 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2818 * The "extra shot" code works by decreasing the amount of energy
2819 * required to make each shot, spreading the shots out over time.
2821 * Note that when firing missiles, the launcher multiplier is applied
2822 * after all the bonuses are added in, making multipliers very useful.
2824 * Note that Bows of "Extra Might" get extra range and an extra bonus
2825 * for the damage multiplier.
2827 * Note that Bows of "Extra Shots" give an extra shot.
2830 void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
2834 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
2835 int tdam_base, tdis, thits, tmul;
2837 int cur_dis, visible;
2845 bool hit_body = FALSE;
2847 char o_name[MAX_NLEN];
2849 u16b path_g[512]; /* For calcuration of path length */
2851 int msec = delay_factor * delay_factor * delay_factor;
2854 bool stick_to = FALSE;
2856 /* Access the item (if in the pack) */
2859 o_ptr = &inventory[item];
2863 o_ptr = &o_list[0 - item];
2866 /* Sniper - Cannot shot a single arrow twice */
2867 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2869 /* Describe the object */
2870 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2872 /* Use the proper number of shots */
2873 thits = p_ptr->num_fire;
2875 /* Use a base distance */
2878 /* Base damage from thrown object plus launcher bonus */
2879 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2881 /* Actually "fire" the object */
2882 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2883 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2884 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2886 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2888 p_ptr->energy_use = bow_energy(j_ptr->sval);
2889 tmul = bow_tmul(j_ptr->sval);
2891 /* Get extra "power" from "extra might" */
2892 if (p_ptr->xtra_might) tmul++;
2894 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2896 /* Boost the damage */
2901 tdis = 13 + tmul/80;
2902 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2905 tdis -= (5 - (p_ptr->concent + 1) / 2);
2910 project_length = tdis + 1;
2912 /* Get a direction (or cancel) */
2913 if (!get_aim_dir(&dir))
2915 p_ptr->energy_use = 0;
2917 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2919 /* need not to reset project_length (already did)*/
2924 /* Predict the "target" location */
2925 tx = p_ptr->x + 99 * ddx[dir];
2926 ty = p_ptr->y + 99 * ddy[dir];
2928 /* Check for "target request" */
2929 if ((dir == 5) && target_okay())
2935 /* Get projection path length */
2936 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2938 project_length = 0; /* reset to default */
2940 /* Don't shoot at my feet */
2941 if (tx == p_ptr->x && ty == p_ptr->y)
2943 p_ptr->energy_use = 0;
2945 /* project_length is already reset to 0 */
2951 /* Take a (partial) turn */
2952 p_ptr->energy_use = (p_ptr->energy_use / thits);
2955 /* Sniper - Difficult to shot twice at 1 turn */
2956 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2958 /* Sniper - Repeat shooting when double shots */
2959 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2962 /* Start at the player */
2966 /* Get local object */
2969 /* Obtain a local object */
2970 object_copy(q_ptr, o_ptr);
2975 /* Reduce and describe inventory */
2978 inven_item_increase(item, -1);
2979 inven_item_describe(item);
2980 inven_item_optimize(item);
2983 /* Reduce and describe floor item */
2986 floor_item_increase(0 - item, -1);
2987 floor_item_optimize(0 - item);
2992 /* Hack -- Handle stuff */
2995 /* Save the old location */
2999 /* The shot does not hit yet */
3002 /* Travel until stopped */
3003 for (cur_dis = 0; cur_dis <= tdis; )
3007 /* Hack -- Stop at the target */
3008 if ((y == ty) && (x == tx)) break;
3010 /* Calculate the new location (see "project()") */
3013 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3016 if (snipe_type == SP_KILL_WALL)
3018 c_ptr = &cave[ny][nx];
3020 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3022 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
3023 /* Forget the wall */
3024 c_ptr->info &= ~(CAVE_MARK);
3026 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3028 /* Destroy the wall */
3029 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3036 /* Stopped by walls/doors */
3037 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3039 /* Advance the distance */
3043 if (snipe_type == SP_LITE)
3045 cave[ny][nx].info |= (CAVE_GLOW);
3054 /* The player can see the (on screen) missile */
3055 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3057 char c = object_char(q_ptr);
3058 byte a = object_attr(q_ptr);
3060 /* Draw, Hilite, Fresh, Pause, Erase */
3061 print_rel(c, a, ny, nx);
3062 move_cursor_relative(ny, nx);
3064 Term_xtra(TERM_XTRA_DELAY, msec);
3069 /* The player cannot see the missile */
3072 /* Pause anyway, for consistancy */
3073 Term_xtra(TERM_XTRA_DELAY, msec);
3077 if (snipe_type == SP_KILL_TRAP)
3079 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3080 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3084 if (snipe_type == SP_EVILNESS)
3086 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3095 /* Save the old location */
3099 /* Save the new location */
3104 /* Monster here, Try to hit it */
3105 if (cave[y][x].m_idx)
3107 cave_type *c_mon_ptr = &cave[y][x];
3109 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
3110 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3112 /* Check the visibility */
3113 visible = m_ptr->ml;
3115 /* Note the collision */
3118 if (MON_CSLEEP(m_ptr))
3120 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3121 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3124 if ((r_ptr->level + 10) > p_ptr->lev)
3126 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3127 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3130 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3131 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3132 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3133 else if (p_ptr->lev > 34) amount = 2;
3134 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3135 p_ptr->update |= (PU_BONUS);
3141 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3142 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3145 p_ptr->skill_exp[GINOU_RIDING] += 1;
3146 p_ptr->update |= (PU_BONUS);
3150 /* Did we hit it (penalize range) */
3151 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3154 int tdam = tdam_base;
3156 /* Get extra damage from concentration */
3157 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3159 /* Handle unseen monster */
3162 /* Invisible monster */
3163 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3166 /* Handle visible monster */
3171 /* Get "the monster" or "it" */
3172 monster_desc(m_name, m_ptr, 0);
3175 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3179 /* Hack -- Track this monster race */
3180 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3182 /* Hack -- Track this monster */
3183 health_track(c_mon_ptr->m_idx);
3187 if (snipe_type == SP_NEEDLE)
3189 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3190 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3194 /* Get "the monster" or "it" */
3195 monster_desc(m_name, m_ptr, 0);
3197 tdam = m_ptr->hp + 1;
3198 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3204 /* Apply special damage XXX XXX XXX */
3205 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3206 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3208 /* No negative damage */
3209 if (tdam < 0) tdam = 0;
3211 /* Modify the damage */
3212 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3215 msg_format_wizard(CHEAT_MONSTER,
3216 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3217 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3220 if (snipe_type == SP_EXPLODE)
3222 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3224 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3225 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3230 if (snipe_type == SP_HOLYNESS)
3232 cave[ny][nx].info |= (CAVE_GLOW);
3241 /* Hit the monster, check for death */
3242 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3251 if (object_is_fixed_artifact(q_ptr) &&
3252 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3256 monster_desc(m_name, m_ptr, 0);
3259 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3263 message_pain(c_mon_ptr->m_idx, tdam);
3265 /* Anger the monster */
3266 if (tdam > 0) anger_monster(m_ptr);
3269 if (fear && m_ptr->ml)
3275 /* Get the monster name (or "it") */
3276 monster_desc(m_name, m_ptr, 0);
3279 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3282 set_target(m_ptr, p_ptr->y, p_ptr->x);
3285 if (snipe_type == SP_RUSH)
3287 int n = randint1(5) + 3;
3288 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3290 for ( ; cur_dis <= tdis; )
3297 /* Calculate the new location (see "project()") */
3298 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3300 /* Stopped by wilderness boundary */
3301 if (!in_bounds2(ny, nx)) break;
3303 /* Stopped by walls/doors */
3304 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3306 /* Stopped by monsters */
3307 if (!cave_empty_bold(ny, nx)) break;
3309 cave[ny][nx].m_idx = m_idx;
3310 cave[oy][ox].m_idx = 0;
3315 /* Update the monster (new location) */
3316 update_mon(c_mon_ptr->m_idx, TRUE);
3322 Term_xtra(TERM_XTRA_DELAY, msec);
3334 if (snipe_type == SP_PIERCE)
3336 if(p_ptr->concent < 1) break;
3346 /* Chance of breakage (during attacks) */
3347 j = (hit_body ? breakage_chance(q_ptr) : 0);
3351 MONSTER_IDX m_idx = cave[y][x].m_idx;
3352 monster_type *m_ptr = &m_list[m_idx];
3353 OBJECT_IDX o_idx = o_pop();
3357 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3358 if (object_is_fixed_artifact(q_ptr))
3360 a_info[j_ptr->name1].cur_num = 0;
3365 o_ptr = &o_list[o_idx];
3366 object_copy(o_ptr, q_ptr);
3369 o_ptr->marked &= OM_TOUCHED;
3371 /* Forget location */
3372 o_ptr->iy = o_ptr->ix = 0;
3374 /* Memorize monster */
3375 o_ptr->held_m_idx = m_idx;
3378 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3381 m_ptr->hold_o_idx = o_idx;
3383 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3385 /* Drop (or break) near that location */
3386 (void)drop_near(q_ptr, j, y, x);
3390 /* Drop (or break) near that location */
3391 (void)drop_near(q_ptr, j, prev_y, prev_x);
3394 /* Sniper - Repeat shooting when double shots */
3397 /* Sniper - Loose his/her concentration after any shot */
3398 if (p_ptr->concent) reset_concentration(FALSE);
3402 * @brief 射撃処理のメインルーチン
3405 void do_cmd_fire(void)
3411 is_fired = FALSE; /* not fired yet */
3413 /* Get the "bow" (if any) */
3414 j_ptr = &inventory[INVEN_BOW];
3416 /* Require a launcher */
3419 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3424 if (j_ptr->sval == SV_CRIMSON)
3426 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3431 if (j_ptr->sval == SV_HARP)
3433 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3439 if (p_ptr->special_defense & KATA_MUSOU)
3441 set_action(ACTION_NONE);
3444 /* Require proper missile */
3445 item_tester_tval = p_ptr->tval_ammo;
3448 q = _("どれを撃ちますか? ", "Fire which item? ");
3449 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3450 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3457 do_cmd_fire_aux(item, j_ptr);
3459 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3461 /* Sniper actions after some shootings */
3462 if (snipe_type == SP_AWAY)
3464 teleport_player(10 + (p_ptr->concent * 2), 0L);
3466 if (snipe_type == SP_FINAL)
3468 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3469 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3470 (void)set_stun(p_ptr->stun + randint1(25));
3476 * @brief 投射処理メインルーチン /
3477 * Throw an object from the pack or floor.
3479 * @param boomerang ブーメラン処理ならばTRUE
3480 * @param shuriken 忍者の手裏剣処理ならばTRUE
3481 * @return ターンを消費した場合TRUEを返す
3484 * Note: "unseen" monsters are very hard to hit.
3486 * Should throwing a weapon do full damage? Should it allow the magic
3487 * to hit bonus of the weapon to have an effect? Should it ever cause
3488 * the item to be destroyed? Should it do any damage at all?
3491 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3496 POSITION y, x, ty, tx, prev_y, prev_x;
3497 POSITION ny[19], nx[19];
3498 int chance, tdam, tdis;
3499 int mul, div, dd, ds;
3500 int cur_dis, visible;
3508 bool hit_body = FALSE;
3509 bool hit_wall = FALSE;
3510 bool equiped_item = FALSE;
3511 bool return_when_thrown = FALSE;
3513 char o_name[MAX_NLEN];
3515 int msec = delay_factor * delay_factor * delay_factor;
3517 BIT_FLAGS flgs[TR_FLAG_SIZE];
3519 bool come_back = FALSE;
3520 bool do_drop = TRUE;
3523 if (p_ptr->special_defense & KATA_MUSOU)
3525 set_action(ACTION_NONE);
3534 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3536 item_tester_hook = item_tester_hook_boomerang;
3537 q = _("どの武器を投げますか? ", "Throw which item? ");
3538 s = _("投げる武器がない。", "You have nothing to throw.");
3539 if (!get_item(&item, q, s, (USE_EQUIP)))
3545 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3546 else item = INVEN_RARM;
3551 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3552 s = _("投げるアイテムがない。", "You have nothing to throw.");
3553 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3560 /* Access the item (if in the pack) */
3563 o_ptr = &inventory[item];
3567 o_ptr = &o_list[0 - item];
3571 /* Item is cursed */
3572 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3575 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3581 if (p_ptr->inside_arena && !boomerang)
3583 if (o_ptr->tval != TV_SPIKE)
3585 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3594 /* Get local object */
3597 /* Obtain a local object */
3598 object_copy(q_ptr, o_ptr);
3600 /* Extract the thrown object's flags. */
3601 object_flags(q_ptr, flgs);
3602 torch_flags(q_ptr, flgs);
3604 /* Distribute the charges of rods/wands between the stacks */
3605 distribute_charges(o_ptr, q_ptr, 1);
3611 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3613 if (p_ptr->mighty_throw) mult += 3;
3615 /* Extract a "distance multiplier" */
3616 /* Changed for 'launcher' mutation */
3617 mul = 10 + 2 * (mult - 1);
3619 /* Enforce a minimum "weight" of one pound */
3620 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3621 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3623 /* Hack -- Distance -- Reward strength, penalize weight */
3624 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3626 /* Max distance of 10-18 */
3627 if (tdis > mul) tdis = mul;
3631 ty = randint0(101) - 50 + p_ptr->y;
3632 tx = randint0(101) - 50 + p_ptr->x;
3636 project_length = tdis + 1;
3638 /* Get a direction (or cancel) */
3639 if (!get_aim_dir(&dir)) return FALSE;
3641 /* Predict the "target" location */
3642 tx = p_ptr->x + 99 * ddx[dir];
3643 ty = p_ptr->y + 99 * ddy[dir];
3645 /* Check for "target request" */
3646 if ((dir == 5) && target_okay())
3652 project_length = 0; /* reset to default */
3655 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3656 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3657 return_when_thrown = TRUE;
3659 /* Reduce and describe inventory */
3662 inven_item_increase(item, -1);
3663 if (!return_when_thrown)
3664 inven_item_describe(item);
3665 inven_item_optimize(item);
3668 /* Reduce and describe floor item */
3671 floor_item_increase(0 - item, -1);
3672 floor_item_optimize(0 - item);
3674 if (item >= INVEN_RARM)
3676 equiped_item = TRUE;
3677 p_ptr->redraw |= (PR_EQUIPPY);
3681 p_ptr->energy_use = 100;
3683 /* Rogue and Ninja gets bonus */
3684 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3685 p_ptr->energy_use -= p_ptr->lev;
3687 /* Start at the player */
3692 /* Hack -- Handle stuff */
3695 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3696 else shuriken = FALSE;
3698 /* Chance of hitting */
3699 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3700 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3701 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3703 if (shuriken) chance *= 2;
3705 /* Save the old location */
3709 /* Travel until stopped */
3710 for (cur_dis = 0; cur_dis <= tdis; )
3712 /* Hack -- Stop at the target */
3713 if ((y == ty) && (x == tx)) break;
3715 /* Calculate the new location (see "project()") */
3718 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3720 /* Stopped by walls/doors */
3721 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3724 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3727 /* The player can see the (on screen) missile */
3728 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3730 char c = object_char(q_ptr);
3731 byte a = object_attr(q_ptr);
3733 /* Draw, Hilite, Fresh, Pause, Erase */
3734 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3735 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3737 Term_xtra(TERM_XTRA_DELAY, msec);
3738 lite_spot(ny[cur_dis], nx[cur_dis]);
3742 /* The player cannot see the missile */
3745 /* Pause anyway, for consistancy */
3746 Term_xtra(TERM_XTRA_DELAY, msec);
3749 /* Save the old location */
3753 /* Save the new location */
3757 /* Advance the distance */
3760 /* Monster here, Try to hit it */
3761 if (cave[y][x].m_idx)
3763 cave_type *c_ptr = &cave[y][x];
3764 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3766 /* Check the visibility */
3767 visible = m_ptr->ml;
3769 /* Note the collision */
3772 /* Did we hit it (penalize range) */
3773 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3777 /* Handle unseen monster */
3780 /* Invisible monster */
3781 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3784 /* Handle visible monster */
3789 /* Get "the monster" or "it" */
3790 monster_desc(m_name, m_ptr, 0);
3793 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3797 /* Hack -- Track this monster race */
3798 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3800 /* Hack -- Track this monster */
3801 health_track(c_ptr->m_idx);
3805 /* Hack -- Base damage from thrown object */
3808 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3809 tdam = damroll(dd, ds);
3810 /* Apply special damage XXX XXX XXX */
3811 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3812 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3813 if (q_ptr->to_d > 0)
3814 tdam += q_ptr->to_d;
3816 tdam += -q_ptr->to_d;
3820 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3821 tdam += p_ptr->to_d_m;
3823 else if (have_flag(flgs, TR_THROW))
3826 tdam += p_ptr->to_d_m;
3834 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3837 /* No negative damage */
3838 if (tdam < 0) tdam = 0;
3840 /* Modify the damage */
3841 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3843 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3844 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3846 /* Hit the monster, check for death */
3847 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3856 message_pain(c_ptr->m_idx, tdam);
3858 /* Anger the monster */
3859 if ((tdam > 0) && !object_is_potion(q_ptr))
3860 anger_monster(m_ptr);
3863 if (fear && m_ptr->ml)
3869 /* Get the monster name (or "it") */
3870 monster_desc(m_name, m_ptr, 0);
3873 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3883 /* decrease toach's fuel */
3884 if (hit_body) torch_lost_fuel(q_ptr);
3886 /* Chance of breakage (during attacks) */
3887 j = (hit_body ? breakage_chance(q_ptr) : 0);
3889 /* Figurines transform */
3890 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3894 if (!(summon_named_creature(0, y, x, q_ptr->pval,
3895 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3896 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3897 else if (object_is_cursed(q_ptr))
3898 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3903 /* Potions smash open */
3904 if (object_is_potion(q_ptr))
3906 if (hit_body || hit_wall || (randint1(100) < j))
3909 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3911 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3913 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3915 /* ToDo (Robert): fix the invulnerability */
3916 if (cave[y][x].m_idx &&
3917 is_friendly(&m_list[cave[y][x].m_idx]) &&
3918 !MON_INVULNER(m_ptr))
3921 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3922 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3923 set_hostile(&m_list[cave[y][x].m_idx]);
3934 if (return_when_thrown)
3936 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3937 char o2_name[MAX_NLEN];
3938 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3941 if (boomerang) back_chance += 4+randint1(5);
3942 if (super_boomerang) back_chance += 100;
3943 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3945 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3947 for (i = cur_dis - 1; i > 0; i--)
3949 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3951 char c = object_char(q_ptr);
3952 byte a = object_attr(q_ptr);
3954 /* Draw, Hilite, Fresh, Pause, Erase */
3955 print_rel(c, a, ny[i], nx[i]);
3956 move_cursor_relative(ny[i], nx[i]);
3958 Term_xtra(TERM_XTRA_DELAY, msec);
3959 lite_spot(ny[i], nx[i]);
3964 /* Pause anyway, for consistancy */
3965 Term_xtra(TERM_XTRA_DELAY, msec);
3968 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3970 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3977 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
3981 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
3989 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
3995 if (item == INVEN_RARM || item == INVEN_LARM)
3997 /* Access the wield slot */
3998 o_ptr = &inventory[item];
4000 /* Wear the new stuff */
4001 object_copy(o_ptr, q_ptr);
4003 /* Increase the weight */
4004 p_ptr->total_weight += q_ptr->weight;
4006 /* Increment the equip counter by hand */
4009 /* Recalculate bonuses */
4010 p_ptr->update |= (PU_BONUS);
4012 /* Recalculate torch */
4013 p_ptr->update |= (PU_TORCH);
4015 /* Recalculate mana XXX */
4016 p_ptr->update |= (PU_MANA);
4019 p_ptr->window |= (PW_EQUIP);
4027 else if (equiped_item)
4033 /* Drop (or break) near that location */
4036 if (cave_have_flag_bold(y, x, FF_PROJECT))
4038 /* Drop (or break) near that location */
4039 (void)drop_near(q_ptr, j, y, x);
4043 /* Drop (or break) near that location */
4044 (void)drop_near(q_ptr, j, prev_y, prev_x);
4054 * Hack: travel command
4056 #define TRAVEL_UNABLE 9999
4058 static int flow_head = 0;
4059 static int flow_tail = 0;
4060 static POSITION temp2_x[MAX_SHORT];
4061 static POSITION temp2_y[MAX_SHORT];
4064 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
4067 void forget_travel_flow(void)
4071 /* Check the entire dungeon */
4072 for (y = 0; y < cur_hgt; y++)
4074 for (x = 0; x < cur_wid; x++)
4076 /* Forget the old data */
4077 travel.cost[y][x] = MAX_SHORT;
4081 travel.y = travel.x = 0;
4085 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
4090 static int travel_flow_cost(POSITION y, POSITION x)
4092 feature_type *f_ptr = &f_info[cave[y][x].feat];
4095 /* Avoid obstacles (ex. trees) */
4096 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4099 if (have_flag(f_ptr->flags, FF_WATER))
4101 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4105 if (have_flag(f_ptr->flags, FF_LAVA))
4108 if (!p_ptr->resist_fire) lava *= 2;
4109 if (!p_ptr->levitation) lava *= 2;
4110 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4115 /* Detected traps and doors */
4116 if (cave[y][x].info & (CAVE_MARK))
4118 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4119 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4126 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
4130 * @param wall プレイヤーが壁の中にいるならばTRUE
4133 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
4135 cave_type *c_ptr = &cave[y][x];
4136 feature_type *f_ptr = &f_info[c_ptr->feat];
4137 int old_head = flow_head;
4139 int base_cost = (n % TRAVEL_UNABLE);
4140 int from_wall = (n / TRAVEL_UNABLE);
4143 /* Ignore out of bounds */
4144 if (!in_bounds(y, x)) return;
4146 /* Ignore unknown grid except in wilderness */
4147 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
4149 /* Ignore "walls" and "rubble" (include "secret doors") */
4150 if (have_flag(f_ptr->flags, FF_WALL) ||
4151 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4152 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4153 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4155 if (!wall || !from_wall) return;
4156 add_cost += TRAVEL_UNABLE;
4160 add_cost = travel_flow_cost(y, x);
4163 cost = base_cost + add_cost;
4165 /* Ignore lower cost entries */
4166 if (travel.cost[y][x] <= cost) return;
4168 /* Save the flow cost */
4169 travel.cost[y][x] = cost;
4171 /* Enqueue that entry */
4172 temp2_y[flow_head] = y;
4173 temp2_x[flow_head] = x;
4175 /* Advance the queue */
4176 if (++flow_head == MAX_SHORT) flow_head = 0;
4178 /* Hack -- notice overflow by forgetting new entry */
4179 if (flow_head == flow_tail) flow_head = old_head;
4185 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
4186 * @param ty 目標地点のY座標
4187 * @param tx 目標地点のX座標
4190 static void travel_flow(POSITION ty, POSITION tx)
4194 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
4196 /* Reset the "queue" */
4197 flow_head = flow_tail = 0;
4199 /* is player in the wall? */
4200 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4202 /* Start at the target grid */
4203 travel_flow_aux(ty, tx, 0, wall);
4205 /* Now process the queue */
4206 while (flow_head != flow_tail)
4208 /* Extract the next entry */
4209 y = temp2_y[flow_tail];
4210 x = temp2_x[flow_tail];
4212 /* Forget that entry */
4213 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4215 /* Ignore too far entries */
4216 //if (distance(ty, tx, y, x) > 100) continue;
4218 /* Add the "children" */
4219 for (d = 0; d < 8; d++)
4221 /* Add that child if "legal" */
4222 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4226 /* Forget the flow info */
4227 flow_head = flow_tail = 0;
4231 * @brief トラベル処理のメインルーチン
4234 void do_cmd_travel(void)
4239 feature_type *f_ptr;
4241 if (travel.x != 0 && travel.y != 0 &&
4242 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4247 else if (!tgt_pt(&x, &y)) return;
4249 if ((x == p_ptr->x) && (y == p_ptr->y))
4251 msg_print(_("すでにそこにいます!", "You are already there!!"));
4255 f_ptr = &f_info[cave[y][x].feat];
4257 if ((cave[y][x].info & CAVE_MARK) &&
4258 (have_flag(f_ptr->flags, FF_WALL) ||
4259 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4260 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4262 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4266 forget_travel_flow();
4272 /* Travel till 255 steps */
4278 /* Decides first direction */
4279 dx = abs(p_ptr->x - x);
4280 dy = abs(p_ptr->y - y);
4281 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4282 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4284 for (i = 1; i <= 9; i++)
4286 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;