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.
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 s16b chest_check(int y, int x, bool trapped)
405 cave_type *c_ptr = &cave[y][x];
407 s16b 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(int y, int x, s16b 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 int yy = p_ptr->y + ddy_ddd[d];
609 int 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(int y, int 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);
725 sound(SOUND_OPENDOOR);
735 if (flush_failure) flush();
738 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
740 /* We may keep trying */
749 cave_alter_feat(y, x, FF_OPEN);
752 sound(SOUND_OPENDOOR);
760 * @brief 「開ける」コマンドのメインルーチン /
761 * Open a closed/locked/jammed door or a closed/locked chest.
764 * Unlocking a locked door/chest is worth one experience point.
766 void do_cmd_open(void)
774 if (p_ptr->special_defense & KATA_MUSOU)
776 set_action(ACTION_NONE);
779 #ifdef ALLOW_EASY_OPEN /* TNB */
781 /* Option: Pick a direction */
784 int num_doors, num_chests;
786 /* Count closed doors (locked or jammed) */
787 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
789 /* Count chests (locked) */
790 num_chests = count_chests(&y, &x, FALSE);
792 /* See if only one target */
793 if (num_doors || num_chests)
795 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
797 if (!too_many) command_dir = coords_to_dir(y, x);
801 #endif /* ALLOW_EASY_OPEN -- TNB */
803 /* Allow repeated command */
806 /* Set repeat count */
807 command_rep = command_arg - 1;
809 /* Redraw the state */
810 p_ptr->redraw |= (PR_STATE);
816 /* Get a "repeated" direction */
817 if (get_rep_dir(&dir, TRUE))
822 /* Get requested location */
823 y = p_ptr->y + ddy[dir];
824 x = p_ptr->x + ddx[dir];
826 /* Get requested grid */
829 /* Feature code (applying "mimic" field) */
830 feat = get_feat_mimic(c_ptr);
832 /* Check for chest */
833 o_idx = chest_check(y, x, FALSE);
836 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
839 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
842 /* Monster in the way */
843 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
846 p_ptr->energy_use = 100;
849 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
859 more = do_cmd_open_chest(y, x, o_idx);
866 more = do_cmd_open_aux(y, x);
870 /* Cancel repeat unless we may continue */
871 if (!more) disturb(0, 0);
877 * @brief 「閉じる」動作コマンドのサブルーチン /
878 * Perform the basic "close" command
879 * @param y 対象を行うマスのY座標
880 * @param x 対象を行うマスのX座標
881 * @return 実際に処理が行われた場合TRUEを返す。
883 * Assume destination is an open/broken door
884 * Assume there is no monster blocking the destination
885 * Returns TRUE if repeated commands may continue
887 static bool do_cmd_close_aux(int y, int x)
889 /* Get grid and contents */
890 cave_type *c_ptr = &cave[y][x];
891 s16b old_feat = c_ptr->feat;
895 p_ptr->energy_use = 100;
897 /* Seeing true feature code (ignore mimic) */
900 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
902 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
904 /* Hack -- object in the way */
905 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
906 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
909 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
914 cave_alter_feat(y, x, FF_CLOSE);
917 if (old_feat == c_ptr->feat)
920 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
925 sound(SOUND_SHUTDOOR);
936 * @brief 「閉じる」コマンドのメインルーチン /
937 * Close an open door.
940 * Unlocking a locked door/chest is worth one experience point.
942 void do_cmd_close(void)
949 if (p_ptr->special_defense & KATA_MUSOU)
951 set_action(ACTION_NONE);
954 #ifdef ALLOW_EASY_OPEN /* TNB */
956 /* Option: Pick a direction */
959 /* Count open doors */
960 if (count_dt(&y, &x, is_open, FALSE) == 1)
962 command_dir = coords_to_dir(y, x);
966 #endif /* ALLOW_EASY_OPEN -- TNB */
968 /* Allow repeated command */
971 /* Set repeat count */
972 command_rep = command_arg - 1;
974 /* Redraw the state */
975 p_ptr->redraw |= (PR_STATE);
981 /* Get a "repeated" direction */
982 if (get_rep_dir(&dir,FALSE))
987 /* Get requested location */
988 y = p_ptr->y + ddy[dir];
989 x = p_ptr->x + ddx[dir];
991 /* Get grid and contents */
994 /* Feature code (applying "mimic" field) */
995 feat = get_feat_mimic(c_ptr);
997 /* Require open/broken door */
998 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1001 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1004 /* Monster in the way */
1005 else if (c_ptr->m_idx)
1008 p_ptr->energy_use = 100;
1011 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1017 /* Close the door */
1020 /* Close the door */
1021 more = do_cmd_close_aux(y, x);
1025 /* Cancel repeat unless we may continue */
1026 if (!more) disturb(0, 0);
1031 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1032 * Determine if a given grid may be "tunneled"
1033 * @param y 対象を行うマスのY座標
1034 * @param x 対象を行うマスのX座標
1037 static bool do_cmd_tunnel_test(int y, int x)
1039 cave_type *c_ptr = &cave[y][x];
1041 /* Must have knowledge */
1042 if (!(c_ptr->info & CAVE_MARK))
1045 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1051 /* Must be a wall/door/etc */
1052 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1055 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1067 * @brief 「掘る」動作コマンドのサブルーチン /
1068 * Perform the basic "tunnel" command
1069 * @param y 対象を行うマスのY座標
1070 * @param x 対象を行うマスのX座標
1071 * @return 実際に処理が行われた場合TRUEを返す。
1073 * Assumes that no monster is blocking the destination
1074 * Do not use twall anymore
1075 * Returns TRUE if repeated commands may continue
1077 static bool do_cmd_tunnel_aux(int y, int x)
1080 feature_type *f_ptr, *mimic_f_ptr;
1085 /* Verify legality */
1086 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1089 p_ptr->energy_use = 100;
1092 c_ptr = &cave[y][x];
1093 f_ptr = &f_info[c_ptr->feat];
1094 power = f_ptr->power;
1096 /* Feature code (applying "mimic" field) */
1097 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1099 name = f_name + mimic_f_ptr->name;
1104 if (have_flag(f_ptr->flags, FF_PERMANENT))
1107 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1109 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1112 /* Map border (mimiccing Permanent wall) */
1115 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1120 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1123 if (p_ptr->skill_dig > randint0(20 * power))
1126 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1128 /* Remove the feature */
1129 cave_alter_feat(y, x, FF_TUNNEL);
1131 /* Update some things */
1132 p_ptr->update |= (PU_FLOW);
1136 /* Message, keep digging */
1137 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1145 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1148 if (p_ptr->skill_dig > power + randint0(40 * power))
1150 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1153 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1154 p_ptr->update |= (PU_FLOW);
1158 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1160 /* Remove the feature */
1161 cave_alter_feat(y, x, FF_TUNNEL);
1163 chg_virtue(V_DILIGENCE, 1);
1164 chg_virtue(V_NATURE, -1);
1172 /* We may continue chopping */
1173 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1174 /* Occasional Search XXX XXX */
1175 if (randint0(100) < 25) search();
1179 /* We may continue tunelling */
1180 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1187 if (is_hidden_door(c_ptr))
1189 /* Occasional Search XXX XXX */
1190 if (randint0(100) < 25) search();
1199 * @brief 「掘る」動作コマンドのメインルーチン /
1200 * Tunnels through "walls" (including rubble and closed doors)
1204 * Note that you must tunnel in order to hit invisible monsters
1205 * in walls, though moving into walls still takes a turn anyway.
1207 * Digging is very difficult without a "digger" weapon, but can be
1208 * accomplished by strong players using heavy weapons.
1211 void do_cmd_tunnel(void)
1221 if (p_ptr->special_defense & KATA_MUSOU)
1223 set_action(ACTION_NONE);
1226 /* Allow repeated command */
1229 /* Set repeat count */
1230 command_rep = command_arg - 1;
1232 /* Redraw the state */
1233 p_ptr->redraw |= (PR_STATE);
1235 /* Cancel the arg */
1239 /* Get a direction to tunnel, or Abort */
1240 if (get_rep_dir(&dir,FALSE))
1243 y = p_ptr->y + ddy[dir];
1244 x = p_ptr->x + ddx[dir];
1247 c_ptr = &cave[y][x];
1249 /* Feature code (applying "mimic" field) */
1250 feat = get_feat_mimic(c_ptr);
1252 /* No tunnelling through doors */
1253 if (have_flag(f_info[feat].flags, FF_DOOR))
1256 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1259 /* No tunnelling through most features */
1260 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1262 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1265 /* A monster is in the way */
1266 else if (c_ptr->m_idx)
1269 p_ptr->energy_use = 100;
1272 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1281 /* Tunnel through walls */
1282 more = do_cmd_tunnel_aux(y, x);
1286 /* Cancel repetition unless we can continue */
1287 if (!more) disturb(0, 0);
1291 #ifdef ALLOW_EASY_OPEN /* TNB */
1294 * @brief 移動処理による簡易な「開く」処理 /
1296 * @return 開く処理が実際に試みられた場合TRUEを返す
1299 * If there is a jammed/closed/locked door at the given location,
1300 * then attempt to unlock/open it. Return TRUE if an attempt was
1301 * made (successful or not), otherwise return FALSE.
1303 * The code here should be nearly identical to that in
1304 * do_cmd_open_test() and do_cmd_open_aux().
1307 bool easy_open_door(int y, int x)
1311 cave_type *c_ptr = &cave[y][x];
1312 feature_type *f_ptr = &f_info[c_ptr->feat];
1314 /* Must be a closed door */
1315 if (!is_closed_door(c_ptr->feat))
1322 if (!have_flag(f_ptr->flags, FF_OPEN))
1325 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1330 else if (f_ptr->power)
1333 i = p_ptr->skill_dis;
1335 /* Penalize some conditions */
1336 if (p_ptr->blind || no_lite()) i = i / 10;
1337 if (p_ptr->confused || p_ptr->image) i = i / 10;
1339 /* Extract the lock power */
1342 /* Extract the difficulty XXX XXX XXX */
1345 /* Always have a small chance of success */
1349 if (randint0(100) < j)
1352 msg_print(_("鍵をはずした。", "You have picked the lock."));
1355 cave_alter_feat(y, x, FF_OPEN);
1358 sound(SOUND_OPENDOOR);
1368 if (flush_failure) flush();
1371 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1380 cave_alter_feat(y, x, FF_OPEN);
1383 sound(SOUND_OPENDOOR);
1390 #endif /* ALLOW_EASY_OPEN -- TNB */
1394 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1395 * Perform the basic "disarm" command
1396 * @param y 解除を行うマスのY座標
1397 * @param x 解除を行うマスのX座標
1398 * @param o_idx 箱のオブジェクトID
1399 * @return ターンを消費する処理が行われた場合TRUEを返す
1402 * Assume destination is a visible trap
1403 * Assume there is no monster blocking the destination
1404 * Returns TRUE if repeated commands may continue
1407 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1413 object_type *o_ptr = &o_list[o_idx];
1417 p_ptr->energy_use = 100;
1419 /* Get the "disarm" factor */
1420 i = p_ptr->skill_dis;
1422 /* Penalize some conditions */
1423 if (p_ptr->blind || no_lite()) i = i / 10;
1424 if (p_ptr->confused || p_ptr->image) i = i / 10;
1426 /* Extract the difficulty */
1427 j = i - o_ptr->pval;
1429 /* Always have a small chance of success */
1432 /* Must find the trap first. */
1433 if (!object_is_known(o_ptr))
1435 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1439 /* Already disarmed/unlocked */
1440 else if (o_ptr->pval <= 0)
1442 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1445 /* No traps to find. */
1446 else if (!chest_traps[o_ptr->pval])
1448 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1451 /* Success (get a lot of experience) */
1452 else if (randint0(100) < j)
1454 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1455 gain_exp(o_ptr->pval);
1456 o_ptr->pval = (0 - o_ptr->pval);
1459 /* Failure -- Keep trying */
1460 else if ((i > 5) && (randint1(i) > 5))
1462 /* We may keep trying */
1464 if (flush_failure) flush();
1465 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1468 /* Failure -- Set off the trap */
1471 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1473 chest_trap(y, x, o_idx);
1482 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1483 * Perform the basic "disarm" command
1484 * @param y 解除を行うマスのY座標
1485 * @param x 解除を行うマスのX座標
1486 * @param dir プレイヤーからみた方向ID
1487 * @return ターンを消費する処理が行われた場合TRUEを返す
1490 * Assume destination is a visible trap
1491 * Assume there is no monster blocking the destination
1492 * Returns TRUE if repeated commands may continue
1495 #ifdef ALLOW_EASY_DISARM /* TNB */
1497 bool do_cmd_disarm_aux(int y, int x, int dir)
1499 #else /* ALLOW_EASY_DISARM -- TNB */
1501 static bool do_cmd_disarm_aux(int y, int x, int dir)
1503 #endif /* ALLOW_EASY_DISARM -- TNB */
1505 /* Get grid and contents */
1506 cave_type *c_ptr = &cave[y][x];
1509 feature_type *f_ptr = &f_info[c_ptr->feat];
1511 /* Access trap name */
1512 cptr name = (f_name + f_ptr->name);
1514 /* Extract trap "power" */
1515 int power = f_ptr->power;
1519 /* Get the "disarm" factor */
1520 int i = p_ptr->skill_dis;
1525 p_ptr->energy_use = 100;
1527 /* Penalize some conditions */
1528 if (p_ptr->blind || no_lite()) i = i / 10;
1529 if (p_ptr->confused || p_ptr->image) i = i / 10;
1531 /* Extract the difficulty */
1534 /* Always have a small chance of success */
1538 if (randint0(100) < j)
1541 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1546 /* Remove the trap */
1547 cave_alter_feat(y, x, FF_DISARM);
1549 #ifdef ALLOW_EASY_DISARM /* TNB */
1551 /* Move the player onto the trap */
1552 move_player(dir, easy_disarm, FALSE);
1554 #else /* ALLOW_EASY_DISARM -- TNB */
1556 /* move the player onto the trap grid */
1557 move_player(dir, FALSE, FALSE);
1559 #endif /* ALLOW_EASY_DISARM -- TNB */
1562 /* Failure -- Keep trying */
1563 else if ((i > 5) && (randint1(i) > 5))
1566 if (flush_failure) flush();
1569 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1571 /* We may keep trying */
1575 /* Failure -- Set off the trap */
1579 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1581 #ifdef ALLOW_EASY_DISARM /* TNB */
1583 /* Move the player onto the trap */
1584 move_player(dir, easy_disarm, FALSE);
1586 #else /* ALLOW_EASY_DISARM -- TNB */
1588 /* Move the player onto the trap */
1589 move_player(dir, FALSE, FALSE);
1591 #endif /* ALLOW_EASY_DISARM -- TNB */
1600 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1601 * Disarms a trap, or chest
1604 void do_cmd_disarm(void)
1612 if (p_ptr->special_defense & KATA_MUSOU)
1614 set_action(ACTION_NONE);
1617 #ifdef ALLOW_EASY_DISARM /* TNB */
1619 /* Option: Pick a direction */
1622 int num_traps, num_chests;
1624 /* Count visible traps */
1625 num_traps = count_dt(&y, &x, is_trap, TRUE);
1627 /* Count chests (trapped) */
1628 num_chests = count_chests(&y, &x, TRUE);
1630 /* See if only one target */
1631 if (num_traps || num_chests)
1633 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1634 if (!too_many) command_dir = coords_to_dir(y, x);
1638 #endif /* ALLOW_EASY_DISARM -- TNB */
1640 /* Allow repeated command */
1643 /* Set repeat count */
1644 command_rep = command_arg - 1;
1646 /* Redraw the state */
1647 p_ptr->redraw |= (PR_STATE);
1649 /* Cancel the arg */
1653 /* Get a direction (or abort) */
1654 if (get_rep_dir(&dir,TRUE))
1660 y = p_ptr->y + ddy[dir];
1661 x = p_ptr->x + ddx[dir];
1663 /* Get grid and contents */
1664 c_ptr = &cave[y][x];
1666 /* Feature code (applying "mimic" field) */
1667 feat = get_feat_mimic(c_ptr);
1669 /* Check for chests */
1670 o_idx = chest_check(y, x, TRUE);
1673 if (!is_trap(feat) && !o_idx)
1676 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1679 /* Monster in the way */
1680 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1683 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1692 /* Disarm the chest */
1693 more = do_cmd_disarm_chest(y, x, o_idx);
1699 /* Disarm the trap */
1700 more = do_cmd_disarm_aux(y, x, dir);
1704 /* Cancel repeat unless told not to */
1705 if (!more) disturb(0, 0);
1710 * @brief 「打ち破る」動作コマンドのサブルーチン /
1711 * Perform the basic "bash" command
1712 * @param y 対象を行うマスのY座標
1713 * @param x 対象を行うマスのX座標
1714 * @param dir プレイヤーから見たターゲットの方角ID
1715 * @return 実際に処理が行われた場合TRUEを返す。
1718 * Assume destination is a closed/locked/jammed door
1719 * Assume there is no monster blocking the destination
1720 * Returns TRUE if repeated commands may continue
1723 static bool do_cmd_bash_aux(int y, int x, int dir)
1726 cave_type *c_ptr = &cave[y][x];
1729 feature_type *f_ptr = &f_info[c_ptr->feat];
1731 /* Hack -- Bash power based on strength */
1732 /* (Ranges from 3 to 20 to 100 to 200) */
1733 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1735 /* Extract door power */
1736 int temp = f_ptr->power;
1740 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1743 p_ptr->energy_use = 100;
1746 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1748 /* Compare bash power to door power XXX XXX XXX */
1749 temp = (bash - (temp * 10));
1751 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1753 /* Hack -- always have a chance */
1754 if (temp < 1) temp = 1;
1756 /* Hack -- attempt to bash down the door */
1757 if (randint0(100) < temp)
1760 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1763 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1765 /* Break down the door */
1766 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1768 cave_alter_feat(y, x, FF_BASH);
1774 cave_alter_feat(y, x, FF_OPEN);
1777 /* Hack -- Fall through the door */
1778 move_player(dir, FALSE, FALSE);
1781 /* Saving throw against stun */
1782 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1786 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1788 /* Allow repeated bashing */
1792 /* High dexterity yields coolness */
1796 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1798 /* Hack -- Lose balance ala paralysis */
1799 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1808 * @brief 「打ち破る」動作コマンドのメインルーチン /
1809 * Bash open a door, success based on character strength
1813 * For a closed door, pval is positive if locked; negative if stuck.
1815 * For an open door, pval is positive for a broken door.
1817 * A closed door can be opened - harder if locked. Any door might be
1818 * bashed open (and thereby broken). Bashing a door is (potentially)
1819 * faster! You move into the door way. To open a stuck door, it must
1820 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1822 * Creatures can also open or bash doors, see elsewhere.
1825 void do_cmd_bash(void)
1834 if (p_ptr->special_defense & KATA_MUSOU)
1836 set_action(ACTION_NONE);
1839 /* Allow repeated command */
1842 /* Set repeat count */
1843 command_rep = command_arg - 1;
1845 /* Redraw the state */
1846 p_ptr->redraw |= (PR_STATE);
1848 /* Cancel the arg */
1852 /* Get a "repeated" direction */
1853 if (get_rep_dir(&dir,FALSE))
1858 y = p_ptr->y + ddy[dir];
1859 x = p_ptr->x + ddx[dir];
1862 c_ptr = &cave[y][x];
1864 /* Feature code (applying "mimic" field) */
1865 feat = get_feat_mimic(c_ptr);
1867 /* Nothing useful */
1868 if (!have_flag(f_info[feat].flags, FF_BASH))
1871 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1874 /* Monster in the way */
1875 else if (c_ptr->m_idx)
1878 p_ptr->energy_use = 100;
1881 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1887 /* Bash a closed door */
1891 more = do_cmd_bash_aux(y, x, dir);
1895 /* Unless valid action taken, cancel bash */
1896 if (!more) disturb(0, 0);
1901 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1905 * Manipulate an adjacent grid in some way
1907 * Attack monsters, tunnel through walls, disarm traps, open doors.
1909 * Consider confusion XXX XXX XXX
1911 * This command must always take a turn, to prevent free detection
1912 * of invisible monsters.
1915 void do_cmd_alter(void)
1924 if (p_ptr->special_defense & KATA_MUSOU)
1926 set_action(ACTION_NONE);
1929 /* Allow repeated command */
1932 /* Set repeat count */
1933 command_rep = command_arg - 1;
1935 /* Redraw the state */
1936 p_ptr->redraw |= (PR_STATE);
1938 /* Cancel the arg */
1942 /* Get a direction */
1943 if (get_rep_dir(&dir,TRUE))
1946 feature_type *f_ptr;
1949 y = p_ptr->y + ddy[dir];
1950 x = p_ptr->x + ddx[dir];
1953 c_ptr = &cave[y][x];
1955 /* Feature code (applying "mimic" field) */
1956 feat = get_feat_mimic(c_ptr);
1957 f_ptr = &f_info[feat];
1960 p_ptr->energy_use = 100;
1962 /* Attack monsters */
1970 else if (have_flag(f_ptr->flags, FF_OPEN))
1972 more = do_cmd_open_aux(y, x);
1975 /* Bash jammed doors */
1976 else if (have_flag(f_ptr->flags, FF_BASH))
1978 more = do_cmd_bash_aux(y, x, dir);
1981 /* Tunnel through walls */
1982 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1984 more = do_cmd_tunnel_aux(y, x);
1987 /* Close open doors */
1988 else if (have_flag(f_ptr->flags, FF_CLOSE))
1990 more = do_cmd_close_aux(y, x);
1994 else if (have_flag(f_ptr->flags, FF_DISARM))
1996 more = do_cmd_disarm_aux(y, x, dir);
2003 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
2007 /* Cancel repetition unless we can continue */
2008 if (!more) disturb(0, 0);
2014 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
2015 * Find the index of some "spikes", if possible.
2016 * @param ip くさびとして打てるオブジェクトのID
2017 * @return オブジェクトがある場合TRUEを返す
2020 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2023 static bool get_spike(int *ip)
2027 /* Check every item in the pack */
2028 for (i = 0; i < INVEN_PACK; i++)
2030 object_type *o_ptr = &inventory[i];
2032 /* Skip non-objects */
2033 if (!o_ptr->k_idx) continue;
2035 /* Check the "tval" code */
2036 if (o_ptr->tval == TV_SPIKE)
2038 /* Save the spike index */
2052 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
2053 * Jam a closed door with a spike
2057 * This command may NOT be repeated
2060 void do_cmd_spike(void)
2064 if (p_ptr->special_defense & KATA_MUSOU)
2066 set_action(ACTION_NONE);
2069 /* Get a "repeated" direction */
2070 if (get_rep_dir(&dir,FALSE))
2077 y = p_ptr->y + ddy[dir];
2078 x = p_ptr->x + ddx[dir];
2080 /* Get grid and contents */
2081 c_ptr = &cave[y][x];
2083 /* Feature code (applying "mimic" field) */
2084 feat = get_feat_mimic(c_ptr);
2086 /* Require closed door */
2087 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2090 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2094 else if (!get_spike(&item))
2097 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2100 /* Is a monster in the way? */
2101 else if (c_ptr->m_idx)
2104 p_ptr->energy_use = 100;
2107 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2117 p_ptr->energy_use = 100;
2119 /* Successful jamming */
2120 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2121 cave_alter_feat(y, x, FF_SPIKE);
2123 /* Use up, and describe, a single spike, from the bottom */
2124 inven_item_increase(item, -1);
2125 inven_item_describe(item);
2126 inven_item_optimize(item);
2134 * @brief 「歩く」動作コマンドのメインルーチン /
2135 * Support code for the "Walk" and "Jump" commands
2136 * @param pickup アイテムの自動拾いを行うならTRUE
2139 void do_cmd_walk(bool pickup)
2146 /* Allow repeated command */
2149 /* Set repeat count */
2150 command_rep = command_arg - 1;
2152 /* Redraw the state */
2153 p_ptr->redraw |= (PR_STATE);
2155 /* Cancel the arg */
2159 /* Get a "repeated" direction */
2160 if (get_rep_dir(&dir, FALSE))
2163 p_ptr->energy_use = 100;
2165 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2167 set_action(ACTION_NONE);
2170 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2171 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2172 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2174 /* Actually move the character */
2175 move_player(dir, pickup, FALSE);
2177 /* Allow more walking */
2181 /* Hack again -- Is there a special encounter ??? */
2182 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2184 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2187 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2189 /* Inform the player of his horrible fate :=) */
2190 msg_print(_("襲撃だ!", "You are ambushed !"));
2192 /* Go into large wilderness view */
2193 p_ptr->oldpy = randint1(MAX_HGT-2);
2194 p_ptr->oldpx = randint1(MAX_WID-2);
2197 /* Give first move to monsters */
2198 p_ptr->energy_use = 100;
2200 /* HACk -- set the encouter flag for the wilderness generation */
2201 generate_encounter = TRUE;
2205 /* Cancel repeat unless we may continue */
2206 if (!more) disturb(0, 0);
2211 * @brief 「走る」動作コマンドのメインルーチン /
2215 void do_cmd_run(void)
2219 /* Hack -- no running when confused */
2220 if (p_ptr->confused)
2222 msg_print(_("混乱していて走れない!", "You are too confused!"));
2226 if (p_ptr->special_defense & KATA_MUSOU)
2228 set_action(ACTION_NONE);
2231 /* Get a "repeated" direction */
2232 if (get_rep_dir(&dir,FALSE))
2234 /* Hack -- Set the run counter */
2235 running = (command_arg ? command_arg : 1000);
2244 * @brief 「留まる」動作コマンドのメインルーチン /
2245 * Stay still. Search. Enter stores.
2246 * Pick up treasure if "pickup" is true.
2247 * @param pickup アイテムの自動拾いを行うならTRUE
2250 void do_cmd_stay(bool pickup)
2252 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2254 /* Allow repeated command */
2257 /* Set repeat count */
2258 command_rep = command_arg - 1;
2260 /* Redraw the state */
2261 p_ptr->redraw |= (PR_STATE);
2263 /* Cancel the arg */
2268 p_ptr->energy_use = 100;
2270 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2271 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2276 * @brief 「休む」動作コマンドのメインルーチン /
2277 * Resting allows a player to safely restore his hp -RAK-
2280 void do_cmd_rest(void)
2283 set_action(ACTION_NONE);
2285 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2291 if (hex_spelling_any()) stop_hex_spell_all();
2293 /* Prompt for time if needed */
2294 if (command_arg <= 0)
2296 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2297 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2303 strcpy(out_val, "&");
2305 /* Ask for duration */
2306 if (!get_string(p, out_val, 4)) return;
2308 /* Rest until done */
2309 if (out_val[0] == '&')
2311 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2315 else if (out_val[0] == '*')
2317 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2323 command_arg = (COMMAND_ARG)atoi(out_val);
2324 if (command_arg <= 0) return;
2330 if (command_arg > 9999) command_arg = 9999;
2332 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2334 /* Take a turn XXX XXX XXX (?) */
2335 p_ptr->energy_use = 100;
2337 /* The sin of sloth */
2338 if (command_arg > 100)
2339 chg_virtue(V_DILIGENCE, -1);
2341 /* Why are you sleeping when there's no need? WAKE UP!*/
2342 if ((p_ptr->chp == p_ptr->mhp) &&
2343 (p_ptr->csp == p_ptr->msp) &&
2344 !p_ptr->blind && !p_ptr->confused &&
2345 !p_ptr->poisoned && !p_ptr->afraid &&
2346 !p_ptr->stun && !p_ptr->cut &&
2347 !p_ptr->slow && !p_ptr->paralyzed &&
2348 !p_ptr->image && !p_ptr->word_recall &&
2349 !p_ptr->alter_reality)
2350 chg_virtue(V_DILIGENCE, -1);
2352 /* Save the rest code */
2353 resting = command_arg;
2354 p_ptr->action = ACTION_REST;
2356 /* Recalculate bonuses */
2357 p_ptr->update |= (PU_BONUS);
2359 /* Redraw the state */
2360 p_ptr->redraw |= (PR_STATE);
2371 * @brief 矢弾を射撃した場合の破損確率を返す /
2372 * Determines the odds of an object breaking when thrown at a monster
2373 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2376 * Note that artifacts never break, see the "drop_near()" function.
2378 static int breakage_chance(object_type *o_ptr)
2380 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2382 /* Examine the snipe type */
2385 if (snipe_type == SP_KILL_WALL) return (100);
2386 if (snipe_type == SP_EXPLODE) return (100);
2387 if (snipe_type == SP_PIERCE) return (100);
2388 if (snipe_type == SP_FINAL) return (100);
2389 if (snipe_type == SP_NEEDLE) return (100);
2390 if (snipe_type == SP_EVILNESS) return (40);
2391 if (snipe_type == SP_HOLYNESS) return (40);
2394 /* Examine the item type */
2395 switch (o_ptr->tval)
2411 /* Sometimes break */
2416 return (20 - archer_bonus * 2);
2421 return (10 - archer_bonus);
2429 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2430 * Determines the odds of an object breaking when thrown at a monster
2431 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2432 * @param tdam 計算途中のダメージ量
2433 * @param m_ptr 目標モンスターの構造体参照ポインタ
2434 * @return スレイ倍率をかけたダメージ量
2436 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2440 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2442 u32b flgs[TR_FLAG_SIZE];
2444 /* Extract the flags */
2445 object_flags(o_ptr, flgs);
2447 /* Some "weapons" and "ammo" do extra damage */
2448 switch (o_ptr->tval)
2455 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2456 (r_ptr->flags3 & RF3_ANIMAL))
2458 if (is_original_ap_and_seen(m_ptr))
2460 r_ptr->r_flags3 |= RF3_ANIMAL;
2463 if (mult < 17) mult = 17;
2467 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2468 (r_ptr->flags3 & RF3_ANIMAL))
2470 if (is_original_ap_and_seen(m_ptr))
2472 r_ptr->r_flags3 |= RF3_ANIMAL;
2475 if (mult < 27) mult = 27;
2479 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2480 (r_ptr->flags3 & RF3_EVIL))
2482 if (is_original_ap_and_seen(m_ptr))
2484 r_ptr->r_flags3 |= RF3_EVIL;
2487 if (mult < 15) mult = 15;
2491 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2492 (r_ptr->flags3 & RF3_EVIL))
2494 if (is_original_ap_and_seen(m_ptr))
2496 r_ptr->r_flags3 |= RF3_EVIL;
2499 if (mult < 25) mult = 25;
2503 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2504 (r_ptr->flags2 & RF2_HUMAN))
2506 if (is_original_ap_and_seen(m_ptr))
2508 r_ptr->r_flags2 |= RF2_HUMAN;
2511 if (mult < 17) mult = 17;
2515 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2516 (r_ptr->flags2 & RF2_HUMAN))
2518 if (is_original_ap_and_seen(m_ptr))
2520 r_ptr->r_flags2 |= RF2_HUMAN;
2523 if (mult < 27) mult = 27;
2527 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2528 (r_ptr->flags3 & RF3_UNDEAD))
2530 if (is_original_ap_and_seen(m_ptr))
2532 r_ptr->r_flags3 |= RF3_UNDEAD;
2535 if (mult < 20) mult = 20;
2539 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2540 (r_ptr->flags3 & RF3_UNDEAD))
2542 if (is_original_ap_and_seen(m_ptr))
2544 r_ptr->r_flags3 |= RF3_UNDEAD;
2547 if (mult < 30) mult = 30;
2551 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2552 (r_ptr->flags3 & RF3_DEMON))
2554 if (is_original_ap_and_seen(m_ptr))
2556 r_ptr->r_flags3 |= RF3_DEMON;
2559 if (mult < 20) mult = 20;
2563 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2564 (r_ptr->flags3 & RF3_DEMON))
2566 if (is_original_ap_and_seen(m_ptr))
2568 r_ptr->r_flags3 |= RF3_DEMON;
2571 if (mult < 30) mult = 30;
2575 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2576 (r_ptr->flags3 & RF3_ORC))
2578 if (is_original_ap_and_seen(m_ptr))
2580 r_ptr->r_flags3 |= RF3_ORC;
2583 if (mult < 20) mult = 20;
2587 if ((have_flag(flgs, TR_KILL_ORC)) &&
2588 (r_ptr->flags3 & RF3_ORC))
2590 if (is_original_ap_and_seen(m_ptr))
2592 r_ptr->r_flags3 |= RF3_ORC;
2595 if (mult < 30) mult = 30;
2599 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2600 (r_ptr->flags3 & RF3_TROLL))
2602 if (is_original_ap_and_seen(m_ptr))
2604 r_ptr->r_flags3 |= RF3_TROLL;
2607 if (mult < 20) mult = 20;
2611 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2612 (r_ptr->flags3 & RF3_TROLL))
2614 if (is_original_ap_and_seen(m_ptr))
2616 r_ptr->r_flags3 |= RF3_TROLL;
2619 if (mult < 30) mult = 30;
2623 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2624 (r_ptr->flags3 & RF3_GIANT))
2626 if (is_original_ap_and_seen(m_ptr))
2628 r_ptr->r_flags3 |= RF3_GIANT;
2631 if (mult < 20) mult = 20;
2635 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2636 (r_ptr->flags3 & RF3_GIANT))
2638 if (is_original_ap_and_seen(m_ptr))
2640 r_ptr->r_flags3 |= RF3_GIANT;
2643 if (mult < 30) mult = 30;
2647 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
2648 (r_ptr->flags3 & RF3_DRAGON))
2650 if (is_original_ap_and_seen(m_ptr))
2652 r_ptr->r_flags3 |= RF3_DRAGON;
2655 if (mult < 20) mult = 20;
2658 /* Execute Dragon */
2659 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
2660 (r_ptr->flags3 & RF3_DRAGON))
2662 if (is_original_ap_and_seen(m_ptr))
2664 r_ptr->r_flags3 |= RF3_DRAGON;
2667 if (mult < 30) mult = 30;
2669 if ((o_ptr->name1 == ART_BARD_ARROW) &&
2670 (m_ptr->r_idx == MON_SMAUG) &&
2671 (inventory[INVEN_BOW].name1 == ART_BARD))
2676 if (have_flag(flgs, TR_BRAND_ACID))
2678 /* Notice immunity */
2679 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2681 if (is_original_ap_and_seen(m_ptr))
2683 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2687 /* Otherwise, take the damage */
2690 if (mult < 17) mult = 17;
2695 if (have_flag(flgs, TR_BRAND_ELEC))
2697 /* Notice immunity */
2698 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2700 if (is_original_ap_and_seen(m_ptr))
2702 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2706 /* Otherwise, take the damage */
2709 if (mult < 17) mult = 17;
2714 if (have_flag(flgs, TR_BRAND_FIRE))
2716 /* Notice immunity */
2717 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2719 if (is_original_ap_and_seen(m_ptr))
2721 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2725 /* Otherwise, take the damage */
2728 if (r_ptr->flags3 & RF3_HURT_FIRE)
2730 if (mult < 25) mult = 25;
2731 if (is_original_ap_and_seen(m_ptr))
2733 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2736 else if (mult < 17) mult = 17;
2741 if (have_flag(flgs, TR_BRAND_COLD))
2743 /* Notice immunity */
2744 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2746 if (is_original_ap_and_seen(m_ptr))
2748 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2751 /* Otherwise, take the damage */
2754 if (r_ptr->flags3 & RF3_HURT_COLD)
2756 if (mult < 25) mult = 25;
2757 if (is_original_ap_and_seen(m_ptr))
2759 r_ptr->r_flags3 |= RF3_HURT_COLD;
2762 else if (mult < 17) mult = 17;
2766 /* Brand (Poison) */
2767 if (have_flag(flgs, TR_BRAND_POIS))
2769 /* Notice immunity */
2770 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2772 if (is_original_ap_and_seen(m_ptr))
2774 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2778 /* Otherwise, take the damage */
2781 if (mult < 17) mult = 17;
2785 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2787 p_ptr->csp -= (1+(p_ptr->msp / 30));
2788 p_ptr->redraw |= (PR_MANA);
2789 mult = mult * 5 / 2;
2796 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2798 /* Return the total damage */
2799 return (tdam * mult / 10);
2804 * @brief 射撃処理のサブルーチン /
2805 * Fire an object from the pack or floor.
2806 * @param item 射撃するオブジェクトの所持ID
2807 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2811 * You may only fire items that "match" your missile launcher.
2813 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2815 * See "calc_bonuses()" for more calculations and such.
2817 * Note that "firing" a missile is MUCH better than "throwing" it.
2819 * Note: "unseen" monsters are very hard to hit.
2821 * Objects are more likely to break if they "attempt" to hit a monster.
2823 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2825 * The "extra shot" code works by decreasing the amount of energy
2826 * required to make each shot, spreading the shots out over time.
2828 * Note that when firing missiles, the launcher multiplier is applied
2829 * after all the bonuses are added in, making multipliers very useful.
2831 * Note that Bows of "Extra Might" get extra range and an extra bonus
2832 * for the damage multiplier.
2834 * Note that Bows of "Extra Shots" give an extra shot.
2837 void do_cmd_fire_aux(int item, object_type *j_ptr)
2840 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
2841 int tdam_base, tdis, thits, tmul;
2843 int cur_dis, visible;
2850 bool hit_body = FALSE;
2852 char o_name[MAX_NLEN];
2854 u16b path_g[512]; /* For calcuration of path length */
2856 int msec = delay_factor * delay_factor * delay_factor;
2859 bool stick_to = FALSE;
2861 /* Access the item (if in the pack) */
2864 o_ptr = &inventory[item];
2868 o_ptr = &o_list[0 - item];
2871 /* Sniper - Cannot shot a single arrow twice */
2872 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2874 /* Describe the object */
2875 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2877 /* Use the proper number of shots */
2878 thits = p_ptr->num_fire;
2880 /* Use a base distance */
2883 /* Base damage from thrown object plus launcher bonus */
2884 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2886 /* Actually "fire" the object */
2887 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2888 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2889 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2891 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2893 p_ptr->energy_use = bow_energy(j_ptr->sval);
2894 tmul = bow_tmul(j_ptr->sval);
2896 /* Get extra "power" from "extra might" */
2897 if (p_ptr->xtra_might) tmul++;
2899 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2901 /* Boost the damage */
2906 tdis = 13 + tmul/80;
2907 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2910 tdis -= (5 - (p_ptr->concent + 1) / 2);
2915 project_length = tdis + 1;
2917 /* Get a direction (or cancel) */
2918 if (!get_aim_dir(&dir))
2920 p_ptr->energy_use = 0;
2922 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2924 /* need not to reset project_length (already did)*/
2929 /* Predict the "target" location */
2930 tx = p_ptr->x + 99 * ddx[dir];
2931 ty = p_ptr->y + 99 * ddy[dir];
2933 /* Check for "target request" */
2934 if ((dir == 5) && target_okay())
2940 /* Get projection path length */
2941 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2943 project_length = 0; /* reset to default */
2945 /* Don't shoot at my feet */
2946 if (tx == p_ptr->x && ty == p_ptr->y)
2948 p_ptr->energy_use = 0;
2950 /* project_length is already reset to 0 */
2956 /* Take a (partial) turn */
2957 p_ptr->energy_use = (p_ptr->energy_use / thits);
2960 /* Sniper - Difficult to shot twice at 1 turn */
2961 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2963 /* Sniper - Repeat shooting when double shots */
2964 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2967 /* Start at the player */
2971 /* Get local object */
2974 /* Obtain a local object */
2975 object_copy(q_ptr, o_ptr);
2980 /* Reduce and describe inventory */
2983 inven_item_increase(item, -1);
2984 inven_item_describe(item);
2985 inven_item_optimize(item);
2988 /* Reduce and describe floor item */
2991 floor_item_increase(0 - item, -1);
2992 floor_item_optimize(0 - item);
2998 /* Hack -- Handle stuff */
3001 /* Save the old location */
3005 /* The shot does not hit yet */
3008 /* Travel until stopped */
3009 for (cur_dis = 0; cur_dis <= tdis; )
3013 /* Hack -- Stop at the target */
3014 if ((y == ty) && (x == tx)) break;
3016 /* Calculate the new location (see "project()") */
3019 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3022 if (snipe_type == SP_KILL_WALL)
3024 c_ptr = &cave[ny][nx];
3026 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3028 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
3029 /* Forget the wall */
3030 c_ptr->info &= ~(CAVE_MARK);
3032 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3034 /* Destroy the wall */
3035 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3042 /* Stopped by walls/doors */
3043 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3045 /* Advance the distance */
3049 if (snipe_type == SP_LITE)
3051 cave[ny][nx].info |= (CAVE_GLOW);
3060 /* The player can see the (on screen) missile */
3061 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3063 char c = object_char(q_ptr);
3064 byte a = object_attr(q_ptr);
3066 /* Draw, Hilite, Fresh, Pause, Erase */
3067 print_rel(c, a, ny, nx);
3068 move_cursor_relative(ny, nx);
3070 Term_xtra(TERM_XTRA_DELAY, msec);
3075 /* The player cannot see the missile */
3078 /* Pause anyway, for consistancy */
3079 Term_xtra(TERM_XTRA_DELAY, msec);
3083 if (snipe_type == SP_KILL_TRAP)
3085 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3086 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3090 if (snipe_type == SP_EVILNESS)
3092 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3101 /* Save the old location */
3105 /* Save the new location */
3110 /* Monster here, Try to hit it */
3111 if (cave[y][x].m_idx)
3113 cave_type *c_mon_ptr = &cave[y][x];
3115 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
3116 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3118 /* Check the visibility */
3119 visible = m_ptr->ml;
3121 /* Note the collision */
3124 if (MON_CSLEEP(m_ptr))
3126 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3127 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3130 if ((r_ptr->level + 10) > p_ptr->lev)
3132 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3133 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3136 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3137 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3138 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3139 else if (p_ptr->lev > 34) amount = 2;
3140 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3141 p_ptr->update |= (PU_BONUS);
3147 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3148 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3151 p_ptr->skill_exp[GINOU_RIDING] += 1;
3152 p_ptr->update |= (PU_BONUS);
3156 /* Did we hit it (penalize range) */
3157 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3160 int tdam = tdam_base;
3162 /* Get extra damage from concentration */
3163 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3165 /* Handle unseen monster */
3168 /* Invisible monster */
3169 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3172 /* Handle visible monster */
3177 /* Get "the monster" or "it" */
3178 monster_desc(m_name, m_ptr, 0);
3181 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3185 /* Hack -- Track this monster race */
3186 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3188 /* Hack -- Track this monster */
3189 health_track(c_mon_ptr->m_idx);
3193 if (snipe_type == SP_NEEDLE)
3195 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3196 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3200 /* Get "the monster" or "it" */
3201 monster_desc(m_name, m_ptr, 0);
3203 tdam = m_ptr->hp + 1;
3204 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3210 /* Apply special damage XXX XXX XXX */
3211 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3212 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3214 /* No negative damage */
3215 if (tdam < 0) tdam = 0;
3217 /* Modify the damage */
3218 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3221 msg_format_wizard(CHEAT_MONSTER,
3222 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3223 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3226 if (snipe_type == SP_EXPLODE)
3228 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3230 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3231 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3236 if (snipe_type == SP_HOLYNESS)
3238 cave[ny][nx].info |= (CAVE_GLOW);
3247 /* Hit the monster, check for death */
3248 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3257 if (object_is_fixed_artifact(q_ptr) &&
3258 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3262 monster_desc(m_name, m_ptr, 0);
3265 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3269 message_pain(c_mon_ptr->m_idx, tdam);
3271 /* Anger the monster */
3272 if (tdam > 0) anger_monster(m_ptr);
3275 if (fear && m_ptr->ml)
3282 /* Get the monster name (or "it") */
3283 monster_desc(m_name, m_ptr, 0);
3286 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3289 set_target(m_ptr, p_ptr->y, p_ptr->x);
3292 if (snipe_type == SP_RUSH)
3294 int n = randint1(5) + 3;
3295 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3297 for ( ; cur_dis <= tdis; )
3304 /* Calculate the new location (see "project()") */
3305 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3307 /* Stopped by wilderness boundary */
3308 if (!in_bounds2(ny, nx)) break;
3310 /* Stopped by walls/doors */
3311 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3313 /* Stopped by monsters */
3314 if (!cave_empty_bold(ny, nx)) break;
3316 cave[ny][nx].m_idx = m_idx;
3317 cave[oy][ox].m_idx = 0;
3322 /* Update the monster (new location) */
3323 update_mon(c_mon_ptr->m_idx, TRUE);
3329 Term_xtra(TERM_XTRA_DELAY, msec);
3341 if (snipe_type == SP_PIERCE)
3343 if(p_ptr->concent < 1) break;
3353 /* Chance of breakage (during attacks) */
3354 j = (hit_body ? breakage_chance(q_ptr) : 0);
3358 MONSTER_IDX m_idx = cave[y][x].m_idx;
3359 monster_type *m_ptr = &m_list[m_idx];
3360 IDX o_idx = o_pop();
3364 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3365 if (object_is_fixed_artifact(q_ptr))
3367 a_info[j_ptr->name1].cur_num = 0;
3372 o_ptr = &o_list[o_idx];
3373 object_copy(o_ptr, q_ptr);
3376 o_ptr->marked &= OM_TOUCHED;
3378 /* Forget location */
3379 o_ptr->iy = o_ptr->ix = 0;
3381 /* Memorize monster */
3382 o_ptr->held_m_idx = m_idx;
3385 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3388 m_ptr->hold_o_idx = o_idx;
3390 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3392 /* Drop (or break) near that location */
3393 (void)drop_near(q_ptr, j, y, x);
3397 /* Drop (or break) near that location */
3398 (void)drop_near(q_ptr, j, prev_y, prev_x);
3401 /* Sniper - Repeat shooting when double shots */
3404 /* Sniper - Loose his/her concentration after any shot */
3405 if (p_ptr->concent) reset_concentration(FALSE);
3409 * @brief 射撃処理のメインルーチン
3412 void do_cmd_fire(void)
3418 is_fired = FALSE; /* not fired yet */
3420 /* Get the "bow" (if any) */
3421 j_ptr = &inventory[INVEN_BOW];
3423 /* Require a launcher */
3426 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3431 if (j_ptr->sval == SV_CRIMSON)
3433 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3438 if (j_ptr->sval == SV_HARP)
3440 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3446 if (p_ptr->special_defense & KATA_MUSOU)
3448 set_action(ACTION_NONE);
3451 /* Require proper missile */
3452 item_tester_tval = p_ptr->tval_ammo;
3455 q = _("どれを撃ちますか? ", "Fire which item? ");
3456 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3457 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3464 do_cmd_fire_aux(item, j_ptr);
3466 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3468 /* Sniper actions after some shootings */
3469 if (snipe_type == SP_AWAY)
3471 teleport_player(10 + (p_ptr->concent * 2), 0L);
3473 if (snipe_type == SP_FINAL)
3475 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3476 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3477 (void)set_stun(p_ptr->stun + randint1(25));
3482 * @brief オブジェクトが投射可能な武器かどうかを返す。
3483 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
3484 * @return 投射可能な武器ならばTRUE
3486 static bool item_tester_hook_boomerang(object_type *o_ptr)
3488 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
3496 * @brief 投射処理メインルーチン /
3497 * Throw an object from the pack or floor.
3499 * @param boomerang ブーメラン処理ならばTRUE
3500 * @param shuriken 忍者の手裏剣処理ならばTRUE
3501 * @return ターンを消費した場合TRUEを返す
3504 * Note: "unseen" monsters are very hard to hit.
3506 * Should throwing a weapon do full damage? Should it allow the magic
3507 * to hit bonus of the weapon to have an effect? Should it ever cause
3508 * the item to be destroyed? Should it do any damage at all?
3511 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
3515 int i, j, y, x, ty, tx, prev_y, prev_x;
3517 int chance, tdam, tdis;
3518 int mul, div, dd, ds;
3519 int cur_dis, visible;
3526 bool hit_body = FALSE;
3527 bool hit_wall = FALSE;
3528 bool equiped_item = FALSE;
3529 bool return_when_thrown = FALSE;
3531 char o_name[MAX_NLEN];
3533 int msec = delay_factor * delay_factor * delay_factor;
3535 u32b flgs[TR_FLAG_SIZE];
3537 bool come_back = FALSE;
3538 bool do_drop = TRUE;
3541 if (p_ptr->special_defense & KATA_MUSOU)
3543 set_action(ACTION_NONE);
3552 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3554 item_tester_hook = item_tester_hook_boomerang;
3555 q = _("どの武器を投げますか? ", "Throw which item? ");
3556 s = _("投げる武器がない。", "You have nothing to throw.");
3557 if (!get_item(&item, q, s, (USE_EQUIP)))
3563 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3564 else item = INVEN_RARM;
3569 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3570 s = _("投げるアイテムがない。", "You have nothing to throw.");
3571 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3578 /* Access the item (if in the pack) */
3581 o_ptr = &inventory[item];
3585 o_ptr = &o_list[0 - item];
3589 /* Item is cursed */
3590 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3593 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3599 if (p_ptr->inside_arena && !boomerang)
3601 if (o_ptr->tval != TV_SPIKE)
3603 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3611 /* Get local object */
3614 /* Obtain a local object */
3615 object_copy(q_ptr, o_ptr);
3617 /* Extract the thrown object's flags. */
3618 object_flags(q_ptr, flgs);
3619 torch_flags(q_ptr, flgs);
3621 /* Distribute the charges of rods/wands between the stacks */
3622 distribute_charges(o_ptr, q_ptr, 1);
3628 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3630 if (p_ptr->mighty_throw) mult += 3;
3632 /* Extract a "distance multiplier" */
3633 /* Changed for 'launcher' mutation */
3634 mul = 10 + 2 * (mult - 1);
3636 /* Enforce a minimum "weight" of one pound */
3637 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3638 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3640 /* Hack -- Distance -- Reward strength, penalize weight */
3641 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3643 /* Max distance of 10-18 */
3644 if (tdis > mul) tdis = mul;
3648 ty = randint0(101)-50+p_ptr->y;
3649 tx = randint0(101)-50+p_ptr->x;
3653 project_length = tdis + 1;
3655 /* Get a direction (or cancel) */
3656 if (!get_aim_dir(&dir)) return FALSE;
3658 /* Predict the "target" location */
3659 tx = p_ptr->x + 99 * ddx[dir];
3660 ty = p_ptr->y + 99 * ddy[dir];
3662 /* Check for "target request" */
3663 if ((dir == 5) && target_okay())
3669 project_length = 0; /* reset to default */
3672 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3673 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3674 return_when_thrown = TRUE;
3676 /* Reduce and describe inventory */
3679 inven_item_increase(item, -1);
3680 if (!return_when_thrown)
3681 inven_item_describe(item);
3682 inven_item_optimize(item);
3685 /* Reduce and describe floor item */
3688 floor_item_increase(0 - item, -1);
3689 floor_item_optimize(0 - item);
3691 if (item >= INVEN_RARM)
3693 equiped_item = TRUE;
3694 p_ptr->redraw |= (PR_EQUIPPY);
3698 p_ptr->energy_use = 100;
3700 /* Rogue and Ninja gets bonus */
3701 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3702 p_ptr->energy_use -= p_ptr->lev;
3704 /* Start at the player */
3709 /* Hack -- Handle stuff */
3712 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3713 else shuriken = FALSE;
3715 /* Chance of hitting */
3716 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3717 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3718 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3720 if (shuriken) chance *= 2;
3722 /* Save the old location */
3726 /* Travel until stopped */
3727 for (cur_dis = 0; cur_dis <= tdis; )
3729 /* Hack -- Stop at the target */
3730 if ((y == ty) && (x == tx)) break;
3732 /* Calculate the new location (see "project()") */
3735 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3737 /* Stopped by walls/doors */
3738 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3741 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3744 /* The player can see the (on screen) missile */
3745 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3747 char c = object_char(q_ptr);
3748 byte a = object_attr(q_ptr);
3750 /* Draw, Hilite, Fresh, Pause, Erase */
3751 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3752 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3754 Term_xtra(TERM_XTRA_DELAY, msec);
3755 lite_spot(ny[cur_dis], nx[cur_dis]);
3759 /* The player cannot see the missile */
3762 /* Pause anyway, for consistancy */
3763 Term_xtra(TERM_XTRA_DELAY, msec);
3766 /* Save the old location */
3770 /* Save the new location */
3774 /* Advance the distance */
3777 /* Monster here, Try to hit it */
3778 if (cave[y][x].m_idx)
3780 cave_type *c_ptr = &cave[y][x];
3782 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3784 /* Check the visibility */
3785 visible = m_ptr->ml;
3787 /* Note the collision */
3790 /* Did we hit it (penalize range) */
3791 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3795 /* Handle unseen monster */
3798 /* Invisible monster */
3799 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3802 /* Handle visible monster */
3807 /* Get "the monster" or "it" */
3808 monster_desc(m_name, m_ptr, 0);
3811 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3815 /* Hack -- Track this monster race */
3816 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3818 /* Hack -- Track this monster */
3819 health_track(c_ptr->m_idx);
3823 /* Hack -- Base damage from thrown object */
3826 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3827 tdam = damroll(dd, ds);
3828 /* Apply special damage XXX XXX XXX */
3829 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3830 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3831 if (q_ptr->to_d > 0)
3832 tdam += q_ptr->to_d;
3834 tdam += -q_ptr->to_d;
3838 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3839 tdam += p_ptr->to_d_m;
3841 else if (have_flag(flgs, TR_THROW))
3844 tdam += p_ptr->to_d_m;
3852 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3855 /* No negative damage */
3856 if (tdam < 0) tdam = 0;
3858 /* Modify the damage */
3859 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3861 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3862 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3864 /* Hit the monster, check for death */
3865 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3874 message_pain(c_ptr->m_idx, tdam);
3876 /* Anger the monster */
3877 if ((tdam > 0) && !object_is_potion(q_ptr))
3878 anger_monster(m_ptr);
3881 if (fear && m_ptr->ml)
3888 /* Get the monster name (or "it") */
3889 monster_desc(m_name, m_ptr, 0);
3892 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3902 /* decrease toach's fuel */
3903 if (hit_body) torch_lost_fuel(q_ptr);
3905 /* Chance of breakage (during attacks) */
3906 j = (hit_body ? breakage_chance(q_ptr) : 0);
3908 /* Figurines transform */
3909 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3913 if (!(summon_named_creature(0, y, x, q_ptr->pval,
3914 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3915 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3916 else if (object_is_cursed(q_ptr))
3917 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3922 /* Potions smash open */
3923 if (object_is_potion(q_ptr))
3925 if (hit_body || hit_wall || (randint1(100) < j))
3928 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3930 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3932 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3934 /* ToDo (Robert): fix the invulnerability */
3935 if (cave[y][x].m_idx &&
3936 is_friendly(&m_list[cave[y][x].m_idx]) &&
3937 !MON_INVULNER(m_ptr))
3940 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3941 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3942 set_hostile(&m_list[cave[y][x].m_idx]);
3953 if (return_when_thrown)
3955 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3956 char o2_name[MAX_NLEN];
3957 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3960 if (boomerang) back_chance += 4+randint1(5);
3961 if (super_boomerang) back_chance += 100;
3962 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3964 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3966 for (i = cur_dis - 1; i > 0; i--)
3968 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3970 char c = object_char(q_ptr);
3971 byte a = object_attr(q_ptr);
3973 /* Draw, Hilite, Fresh, Pause, Erase */
3974 print_rel(c, a, ny[i], nx[i]);
3975 move_cursor_relative(ny[i], nx[i]);
3977 Term_xtra(TERM_XTRA_DELAY, msec);
3978 lite_spot(ny[i], nx[i]);
3983 /* Pause anyway, for consistancy */
3984 Term_xtra(TERM_XTRA_DELAY, msec);
3987 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3989 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
3996 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
4000 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
4008 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
4014 if (item == INVEN_RARM || item == INVEN_LARM)
4016 /* Access the wield slot */
4017 o_ptr = &inventory[item];
4019 /* Wear the new stuff */
4020 object_copy(o_ptr, q_ptr);
4022 /* Increase the weight */
4023 p_ptr->total_weight += q_ptr->weight;
4025 /* Increment the equip counter by hand */
4028 /* Recalculate bonuses */
4029 p_ptr->update |= (PU_BONUS);
4031 /* Recalculate torch */
4032 p_ptr->update |= (PU_TORCH);
4034 /* Recalculate mana XXX */
4035 p_ptr->update |= (PU_MANA);
4038 p_ptr->window |= (PW_EQUIP);
4046 else if (equiped_item)
4052 /* Drop (or break) near that location */
4055 if (cave_have_flag_bold(y, x, FF_PROJECT))
4057 /* Drop (or break) near that location */
4058 (void)drop_near(q_ptr, j, y, x);
4062 /* Drop (or break) near that location */
4063 (void)drop_near(q_ptr, j, prev_y, prev_x);
4073 * Hack: travel command
4075 #define TRAVEL_UNABLE 9999
4077 static int flow_head = 0;
4078 static int flow_tail = 0;
4079 static POSITION temp2_x[MAX_SHORT];
4080 static POSITION temp2_y[MAX_SHORT];
4083 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
4086 void forget_travel_flow(void)
4090 /* Check the entire dungeon */
4091 for (y = 0; y < cur_hgt; y++)
4093 for (x = 0; x < cur_wid; x++)
4095 /* Forget the old data */
4096 travel.cost[y][x] = MAX_SHORT;
4100 travel.y = travel.x = 0;
4104 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
4109 static int travel_flow_cost(int y, int x)
4111 feature_type *f_ptr = &f_info[cave[y][x].feat];
4114 /* Avoid obstacles (ex. trees) */
4115 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4118 if (have_flag(f_ptr->flags, FF_WATER))
4120 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4124 if (have_flag(f_ptr->flags, FF_LAVA))
4127 if (!p_ptr->resist_fire) lava *= 2;
4128 if (!p_ptr->levitation) lava *= 2;
4129 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4134 /* Detected traps and doors */
4135 if (cave[y][x].info & (CAVE_MARK))
4137 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4138 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4145 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
4149 * @param wall プレイヤーが壁の中にいるならばTRUE
4152 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
4154 cave_type *c_ptr = &cave[y][x];
4155 feature_type *f_ptr = &f_info[c_ptr->feat];
4156 int old_head = flow_head;
4158 int base_cost = (n % TRAVEL_UNABLE);
4159 int from_wall = (n / TRAVEL_UNABLE);
4162 /* Ignore out of bounds */
4163 if (!in_bounds(y, x)) return;
4165 /* Ignore unknown grid except in wilderness */
4166 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
4168 /* Ignore "walls" and "rubble" (include "secret doors") */
4169 if (have_flag(f_ptr->flags, FF_WALL) ||
4170 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4171 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4172 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4174 if (!wall || !from_wall) return;
4175 add_cost += TRAVEL_UNABLE;
4179 add_cost = travel_flow_cost(y, x);
4182 cost = base_cost + add_cost;
4184 /* Ignore lower cost entries */
4185 if (travel.cost[y][x] <= cost) return;
4187 /* Save the flow cost */
4188 travel.cost[y][x] = cost;
4190 /* Enqueue that entry */
4191 temp2_y[flow_head] = y;
4192 temp2_x[flow_head] = x;
4194 /* Advance the queue */
4195 if (++flow_head == MAX_SHORT) flow_head = 0;
4197 /* Hack -- notice overflow by forgetting new entry */
4198 if (flow_head == flow_tail) flow_head = old_head;
4204 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
4205 * @param ty 目標地点のY座標
4206 * @param tx 目標地点のX座標
4209 static void travel_flow(int ty, int tx)
4213 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
4215 /* Reset the "queue" */
4216 flow_head = flow_tail = 0;
4218 /* is player in the wall? */
4219 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4221 /* Start at the target grid */
4222 travel_flow_aux(ty, tx, 0, wall);
4224 /* Now process the queue */
4225 while (flow_head != flow_tail)
4227 /* Extract the next entry */
4228 y = temp2_y[flow_tail];
4229 x = temp2_x[flow_tail];
4231 /* Forget that entry */
4232 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4234 /* Ignore too far entries */
4235 //if (distance(ty, tx, y, x) > 100) continue;
4237 /* Add the "children" */
4238 for (d = 0; d < 8; d++)
4240 /* Add that child if "legal" */
4241 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4245 /* Forget the flow info */
4246 flow_head = flow_tail = 0;
4250 * @brief トラベル処理のメインルーチン
4253 void do_cmd_travel(void)
4258 feature_type *f_ptr;
4260 if (travel.x != 0 && travel.y != 0 &&
4261 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4266 else if (!tgt_pt(&x, &y)) return;
4268 if ((x == p_ptr->x) && (y == p_ptr->y))
4270 msg_print(_("すでにそこにいます!", "You are already there!!"));
4274 f_ptr = &f_info[cave[y][x].feat];
4276 if ((cave[y][x].info & CAVE_MARK) &&
4277 (have_flag(f_ptr->flags, FF_WALL) ||
4278 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4279 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4281 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4285 forget_travel_flow();
4291 /* Travel till 255 steps */
4297 /* Decides first direction */
4298 dx = abs(p_ptr->x - x);
4299 dy = abs(p_ptr->y - y);
4300 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4301 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4303 for (i = 1; i <= 9; i++)
4305 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;