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))))))
36 msg_print("この階を一度去ると二度と戻って来られません。");
37 if (get_check("本当にこの階を去りますか?")) return TRUE;
39 msg_print("You can't come back here once you leave this floor.");
40 if (get_check("Really leave this floor? ")) return TRUE;
51 * @brief 階段を使って階層を昇る処理 / Go up one level
54 void do_cmd_go_up(void)
59 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
60 feature_type *f_ptr = &f_info[c_ptr->feat];
64 if (p_ptr->special_defense & KATA_MUSOU)
66 set_action(ACTION_NONE);
70 if (!have_flag(f_ptr->flags, FF_LESS))
72 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
77 if (have_flag(f_ptr->flags, FF_QUEST))
79 /* Cancel the command */
80 if (!confirm_leave_level(FALSE)) return;
84 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
85 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
87 msg_print(_("上の階に登った。", "You enter the up staircase."));
91 p_ptr->inside_quest = c_ptr->special;
93 /* Activate the quest */
94 if (!quest[p_ptr->inside_quest].status)
96 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
98 init_flags = INIT_ASSIGN;
99 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
101 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
104 /* Leaving a quest */
105 if (!p_ptr->inside_quest)
111 p_ptr->leaving = TRUE;
116 /* Hack -- take a turn */
117 p_ptr->energy_use = 100;
119 /* End the command */
129 go_up = confirm_leave_level(FALSE);
132 /* Cancel the command */
135 /* Hack -- take a turn */
136 p_ptr->energy_use = 100;
138 if (autosave_l) do_cmd_save_game(TRUE);
140 /* For a random quest */
141 if (p_ptr->inside_quest &&
142 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
146 p_ptr->inside_quest = 0;
149 /* For a fixed quest */
150 if (p_ptr->inside_quest &&
151 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
155 p_ptr->inside_quest = c_ptr->special;
160 /* For normal dungeon and random quest */
164 if (have_flag(f_ptr->flags, FF_SHAFT))
166 /* Create a way back */
167 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
173 /* Create a way back */
174 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
179 /* Get out from current dungeon */
180 if (dun_level - up_num < d_info[dungeon_type].mindepth)
183 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
186 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
187 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
188 else if (up_num == dun_level)
189 msg_print(_("地上に戻った。", "You go back to the surface."));
191 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
194 p_ptr->leaving = TRUE;
199 * @brief 階段を使って階層を降りる処理 / Go down one level
202 void do_cmd_go_down(void)
205 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
206 feature_type *f_ptr = &f_info[c_ptr->feat];
208 bool fall_trap = FALSE;
211 if (p_ptr->special_defense & KATA_MUSOU)
213 set_action(ACTION_NONE);
217 if (!have_flag(f_ptr->flags, FF_MORE))
219 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
223 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
226 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
231 /* Quest down stairs */
232 else if (have_flag(f_ptr->flags, FF_QUEST))
234 /* Confirm Leaving */
235 if(!confirm_leave_level(TRUE)) return;
237 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
238 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
240 msg_print(_("下の階に降りた。", "You enter the down staircase."));
245 p_ptr->inside_quest = c_ptr->special;
247 /* Activate the quest */
248 if (!quest[p_ptr->inside_quest].status)
250 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
252 init_flags = INIT_ASSIGN;
253 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
255 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
258 /* Leaving a quest */
259 if (!p_ptr->inside_quest)
265 p_ptr->leaving = TRUE;
271 /* Hack -- take a turn */
272 p_ptr->energy_use = 100;
277 int target_dungeon = 0;
281 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
283 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
285 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
288 if (!max_dlv[target_dungeon])
290 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
291 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
292 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
295 /* Save old player position */
296 p_ptr->oldpx = p_ptr->x;
297 p_ptr->oldpy = p_ptr->y;
298 dungeon_type = (byte)target_dungeon;
301 * Clear all saved floors
302 * and create a first saved floor
304 prepare_change_floor_mode(CFM_FIRST_FLOOR);
307 /* Hack -- take a turn */
308 p_ptr->energy_use = 100;
310 if (autosave_l) do_cmd_save_game(TRUE);
313 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
318 /* Enter the dungeon just now */
319 p_ptr->enter_dungeon = TRUE;
320 down_num = d_info[dungeon_type].mindepth;
325 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
326 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
331 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
338 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
342 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
343 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
345 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
351 p_ptr->leaving = TRUE;
355 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
359 if (have_flag(f_ptr->flags, FF_SHAFT))
361 /* Create a way back */
362 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
366 /* Create a way back */
367 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
375 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
378 void do_cmd_search(void)
380 /* Allow repeated command */
383 /* Set repeat count */
384 command_rep = command_arg - 1;
386 /* Redraw the state */
387 p_ptr->redraw |= (PR_STATE);
394 p_ptr->energy_use = 100;
402 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
403 * @param y 走査対象にしたいマスのY座標
404 * @param x 走査対象にしたいマスのX座標
405 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
406 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
408 static s16b chest_check(int y, int x, bool trapped)
410 cave_type *c_ptr = &cave[y][x];
412 s16b this_o_idx, next_o_idx = 0;
415 /* Scan all objects in the grid */
416 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
421 o_ptr = &o_list[this_o_idx];
423 /* Acquire next object */
424 next_o_idx = o_ptr->next_o_idx;
426 /* Skip unknown chests XXX XXX */
427 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
429 /* Check for non empty chest */
430 if ((o_ptr->tval == TV_CHEST) &&
431 (((!trapped) && (o_ptr->pval)) || /* non empty */
432 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
443 * @brief 箱を開けるコマンドのメインルーチン /
444 * Attempt to open the given chest at the given location
445 * @param y 箱の存在するマスのY座標
446 * @param x 箱の存在するマスのX座標
447 * @param o_idx 箱のオブジェクトID
448 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
450 * Assume there is no monster blocking the destination
452 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
460 object_type *o_ptr = &o_list[o_idx];
464 p_ptr->energy_use = 100;
466 /* Attempt to unlock it */
469 /* Assume locked, and thus not open */
472 /* Get the "disarm" factor */
473 i = p_ptr->skill_dis;
475 /* Penalize some conditions */
476 if (p_ptr->blind || no_lite()) i = i / 10;
477 if (p_ptr->confused || p_ptr->image) i = i / 10;
479 /* Extract the difficulty */
482 /* Always have a small chance of success */
485 /* Success -- May still have traps */
486 if (randint0(100) < j)
488 msg_print(_("鍵をはずした。", "You have picked the lock."));
493 /* Failure -- Keep trying */
496 /* We may continue repeating */
498 if (flush_failure) flush();
499 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
504 /* Allowed to open */
507 /* Apply chest traps, if any */
508 chest_trap(y, x, o_idx);
510 /* Let the Chest drop items */
511 chest_death(FALSE, y, x, o_idx);
519 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
522 * @brief 地形は開くものであって、かつ開かれているかを返す /
523 * Attempt to open the given chest at the given location
525 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
527 static bool is_open(IDX feat)
529 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
534 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
535 * Attempt to open the given chest at the given location
536 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
537 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
538 * @param test 地形条件を判定するための関数ポインタ
539 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
541 * @details Return the number of features around (or under) the character.
542 * Usually look for doors and floor traps.
544 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
546 int d, count, xx, yy;
548 /* Count how many matches */
551 /* Check around (and under) the character */
552 for (d = 0; d < 9; d++)
557 /* if not searching under player continue */
558 if ((d == 8) && !under) continue;
560 /* Extract adjacent (legal) location */
561 yy = p_ptr->y + ddy_ddd[d];
562 xx = p_ptr->x + ddx_ddd[d];
565 c_ptr = &cave[yy][xx];
567 /* Must have knowledge */
568 if (!(c_ptr->info & (CAVE_MARK))) continue;
570 /* Feature code (applying "mimic" field) */
571 feat = get_feat_mimic(c_ptr);
573 /* Not looking for this feature */
574 if (!((*test)(feat))) continue;
579 /* Remember the location. Only useful if only one match */
590 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
591 * Return the number of chests around (or under) the character.
592 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
593 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
594 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
597 * If requested, count only trapped chests.
599 static int count_chests(POSITION *y, POSITION *x, bool trapped)
606 /* Count how many matches */
609 /* Check around (and under) the character */
610 for (d = 0; d < 9; d++)
612 /* Extract adjacent (legal) location */
613 int yy = p_ptr->y + ddy_ddd[d];
614 int xx = p_ptr->x + ddx_ddd[d];
616 /* No (visible) chest is there */
617 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
619 /* Grab the object */
620 o_ptr = &o_list[o_idx];
623 if (o_ptr->pval == 0) continue;
625 /* No (known) traps here */
626 if (trapped && (!object_is_known(o_ptr) ||
627 !chest_traps[o_ptr->pval])) continue;
632 /* Remember the location. Only useful if only one match */
643 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
644 * Convert an adjacent location to a direction.
645 * @param y 方角を確認したY座標
646 * @param x 方角を確認したX座標
649 static DIRECTION coords_to_dir(POSITION y, POSITION x)
651 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
658 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
660 return d[dx + 1][dy + 1];
663 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
667 * @brief 「開ける」動作コマンドのサブルーチン /
668 * Perform the basic "open" command on doors
669 * @param y 対象を行うマスのY座標
670 * @param x 対象を行うマスのX座標
671 * @return 実際に処理が行われた場合TRUEを返す。
673 * Assume destination is a closed/locked/jammed door
674 * Assume there is no monster blocking the destination
675 * Returns TRUE if repeated commands may continue
677 static bool do_cmd_open_aux(int y, int x)
681 /* Get requested grid */
682 cave_type *c_ptr = &cave[y][x];
684 feature_type *f_ptr = &f_info[c_ptr->feat];
690 p_ptr->energy_use = 100;
692 /* Seeing true feature code (ignore mimic) */
695 if (!have_flag(f_ptr->flags, FF_OPEN))
698 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
702 else if (f_ptr->power)
705 i = p_ptr->skill_dis;
707 /* Penalize some conditions */
708 if (p_ptr->blind || no_lite()) i = i / 10;
709 if (p_ptr->confused || p_ptr->image) i = i / 10;
711 /* Extract the lock power */
714 /* Extract the difficulty XXX XXX XXX */
717 /* Always have a small chance of success */
721 if (randint0(100) < j)
724 msg_print(_("鍵をはずした。", "You have picked the lock."));
727 cave_alter_feat(y, x, FF_OPEN);
730 sound(SOUND_OPENDOOR);
740 if (flush_failure) flush();
743 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
745 /* We may keep trying */
754 cave_alter_feat(y, x, FF_OPEN);
757 sound(SOUND_OPENDOOR);
765 * @brief 「開ける」コマンドのメインルーチン /
766 * Open a closed/locked/jammed door or a closed/locked chest.
769 * Unlocking a locked door/chest is worth one experience point.
771 void do_cmd_open(void)
779 if (p_ptr->special_defense & KATA_MUSOU)
781 set_action(ACTION_NONE);
784 #ifdef ALLOW_EASY_OPEN /* TNB */
786 /* Option: Pick a direction */
789 int num_doors, num_chests;
791 /* Count closed doors (locked or jammed) */
792 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
794 /* Count chests (locked) */
795 num_chests = count_chests(&y, &x, FALSE);
797 /* See if only one target */
798 if (num_doors || num_chests)
800 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
802 if (!too_many) command_dir = coords_to_dir(y, x);
806 #endif /* ALLOW_EASY_OPEN -- TNB */
808 /* Allow repeated command */
811 /* Set repeat count */
812 command_rep = command_arg - 1;
814 /* Redraw the state */
815 p_ptr->redraw |= (PR_STATE);
821 /* Get a "repeated" direction */
822 if (get_rep_dir(&dir, TRUE))
827 /* Get requested location */
828 y = p_ptr->y + ddy[dir];
829 x = p_ptr->x + ddx[dir];
831 /* Get requested grid */
834 /* Feature code (applying "mimic" field) */
835 feat = get_feat_mimic(c_ptr);
837 /* Check for chest */
838 o_idx = chest_check(y, x, FALSE);
841 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
844 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
847 /* Monster in the way */
848 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
851 p_ptr->energy_use = 100;
854 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
864 more = do_cmd_open_chest(y, x, o_idx);
871 more = do_cmd_open_aux(y, x);
875 /* Cancel repeat unless we may continue */
876 if (!more) disturb(0, 0);
882 * @brief 「閉じる」動作コマンドのサブルーチン /
883 * Perform the basic "close" command
884 * @param y 対象を行うマスのY座標
885 * @param x 対象を行うマスのX座標
886 * @return 実際に処理が行われた場合TRUEを返す。
888 * Assume destination is an open/broken door
889 * Assume there is no monster blocking the destination
890 * Returns TRUE if repeated commands may continue
892 static bool do_cmd_close_aux(int y, int x)
894 /* Get grid and contents */
895 cave_type *c_ptr = &cave[y][x];
896 s16b old_feat = c_ptr->feat;
900 p_ptr->energy_use = 100;
902 /* Seeing true feature code (ignore mimic) */
905 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
907 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
909 /* Hack -- object in the way */
910 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
911 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
914 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
919 cave_alter_feat(y, x, FF_CLOSE);
922 if (old_feat == c_ptr->feat)
925 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
930 sound(SOUND_SHUTDOOR);
941 * @brief 「閉じる」コマンドのメインルーチン /
942 * Close an open door.
945 * Unlocking a locked door/chest is worth one experience point.
947 void do_cmd_close(void)
954 if (p_ptr->special_defense & KATA_MUSOU)
956 set_action(ACTION_NONE);
959 #ifdef ALLOW_EASY_OPEN /* TNB */
961 /* Option: Pick a direction */
964 /* Count open doors */
965 if (count_dt(&y, &x, is_open, FALSE) == 1)
967 command_dir = coords_to_dir(y, x);
971 #endif /* ALLOW_EASY_OPEN -- TNB */
973 /* Allow repeated command */
976 /* Set repeat count */
977 command_rep = command_arg - 1;
979 /* Redraw the state */
980 p_ptr->redraw |= (PR_STATE);
986 /* Get a "repeated" direction */
987 if (get_rep_dir(&dir,FALSE))
992 /* Get requested location */
993 y = p_ptr->y + ddy[dir];
994 x = p_ptr->x + ddx[dir];
996 /* Get grid and contents */
999 /* Feature code (applying "mimic" field) */
1000 feat = get_feat_mimic(c_ptr);
1002 /* Require open/broken door */
1003 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1006 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1009 /* Monster in the way */
1010 else if (c_ptr->m_idx)
1013 p_ptr->energy_use = 100;
1016 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1022 /* Close the door */
1025 /* Close the door */
1026 more = do_cmd_close_aux(y, x);
1030 /* Cancel repeat unless we may continue */
1031 if (!more) disturb(0, 0);
1036 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1037 * Determine if a given grid may be "tunneled"
1038 * @param y 対象を行うマスのY座標
1039 * @param x 対象を行うマスのX座標
1042 static bool do_cmd_tunnel_test(int y, int x)
1044 cave_type *c_ptr = &cave[y][x];
1046 /* Must have knowledge */
1047 if (!(c_ptr->info & CAVE_MARK))
1050 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1056 /* Must be a wall/door/etc */
1057 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1060 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1072 * @brief 「掘る」動作コマンドのサブルーチン /
1073 * Perform the basic "tunnel" command
1074 * @param y 対象を行うマスのY座標
1075 * @param x 対象を行うマスのX座標
1076 * @return 実際に処理が行われた場合TRUEを返す。
1078 * Assumes that no monster is blocking the destination
1079 * Do not use twall anymore
1080 * Returns TRUE if repeated commands may continue
1082 static bool do_cmd_tunnel_aux(int y, int x)
1085 feature_type *f_ptr, *mimic_f_ptr;
1090 /* Verify legality */
1091 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1094 p_ptr->energy_use = 100;
1097 c_ptr = &cave[y][x];
1098 f_ptr = &f_info[c_ptr->feat];
1099 power = f_ptr->power;
1101 /* Feature code (applying "mimic" field) */
1102 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1104 name = f_name + mimic_f_ptr->name;
1109 if (have_flag(f_ptr->flags, FF_PERMANENT))
1112 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1114 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1117 /* Map border (mimiccing Permanent wall) */
1120 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1125 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1128 if (p_ptr->skill_dig > randint0(20 * power))
1131 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1133 /* Remove the feature */
1134 cave_alter_feat(y, x, FF_TUNNEL);
1136 /* Update some things */
1137 p_ptr->update |= (PU_FLOW);
1141 /* Message, keep digging */
1142 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1150 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1153 if (p_ptr->skill_dig > power + randint0(40 * power))
1155 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1158 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1159 p_ptr->update |= (PU_FLOW);
1163 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1165 /* Remove the feature */
1166 cave_alter_feat(y, x, FF_TUNNEL);
1168 chg_virtue(V_DILIGENCE, 1);
1169 chg_virtue(V_NATURE, -1);
1177 /* We may continue chopping */
1178 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1179 /* Occasional Search XXX XXX */
1180 if (randint0(100) < 25) search();
1184 /* We may continue tunelling */
1185 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1192 if (is_hidden_door(c_ptr))
1194 /* Occasional Search XXX XXX */
1195 if (randint0(100) < 25) search();
1204 * @brief 「掘る」動作コマンドのメインルーチン /
1205 * Tunnels through "walls" (including rubble and closed doors)
1209 * Note that you must tunnel in order to hit invisible monsters
1210 * in walls, though moving into walls still takes a turn anyway.
1212 * Digging is very difficult without a "digger" weapon, but can be
1213 * accomplished by strong players using heavy weapons.
1216 void do_cmd_tunnel(void)
1226 if (p_ptr->special_defense & KATA_MUSOU)
1228 set_action(ACTION_NONE);
1231 /* Allow repeated command */
1234 /* Set repeat count */
1235 command_rep = command_arg - 1;
1237 /* Redraw the state */
1238 p_ptr->redraw |= (PR_STATE);
1240 /* Cancel the arg */
1244 /* Get a direction to tunnel, or Abort */
1245 if (get_rep_dir(&dir,FALSE))
1248 y = p_ptr->y + ddy[dir];
1249 x = p_ptr->x + ddx[dir];
1252 c_ptr = &cave[y][x];
1254 /* Feature code (applying "mimic" field) */
1255 feat = get_feat_mimic(c_ptr);
1257 /* No tunnelling through doors */
1258 if (have_flag(f_info[feat].flags, FF_DOOR))
1261 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1264 /* No tunnelling through most features */
1265 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1267 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1270 /* A monster is in the way */
1271 else if (c_ptr->m_idx)
1274 p_ptr->energy_use = 100;
1277 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1286 /* Tunnel through walls */
1287 more = do_cmd_tunnel_aux(y, x);
1291 /* Cancel repetition unless we can continue */
1292 if (!more) disturb(0, 0);
1296 #ifdef ALLOW_EASY_OPEN /* TNB */
1299 * @brief 移動処理による簡易な「開く」処理 /
1301 * @return 開く処理が実際に試みられた場合TRUEを返す
1304 * If there is a jammed/closed/locked door at the given location,
1305 * then attempt to unlock/open it. Return TRUE if an attempt was
1306 * made (successful or not), otherwise return FALSE.
1308 * The code here should be nearly identical to that in
1309 * do_cmd_open_test() and do_cmd_open_aux().
1312 bool easy_open_door(int y, int x)
1316 cave_type *c_ptr = &cave[y][x];
1317 feature_type *f_ptr = &f_info[c_ptr->feat];
1319 /* Must be a closed door */
1320 if (!is_closed_door(c_ptr->feat))
1327 if (!have_flag(f_ptr->flags, FF_OPEN))
1330 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1335 else if (f_ptr->power)
1338 i = p_ptr->skill_dis;
1340 /* Penalize some conditions */
1341 if (p_ptr->blind || no_lite()) i = i / 10;
1342 if (p_ptr->confused || p_ptr->image) i = i / 10;
1344 /* Extract the lock power */
1347 /* Extract the difficulty XXX XXX XXX */
1350 /* Always have a small chance of success */
1354 if (randint0(100) < j)
1357 msg_print(_("鍵をはずした。", "You have picked the lock."));
1360 cave_alter_feat(y, x, FF_OPEN);
1363 sound(SOUND_OPENDOOR);
1373 if (flush_failure) flush();
1376 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1385 cave_alter_feat(y, x, FF_OPEN);
1388 sound(SOUND_OPENDOOR);
1395 #endif /* ALLOW_EASY_OPEN -- TNB */
1399 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1400 * Perform the basic "disarm" command
1401 * @param y 解除を行うマスのY座標
1402 * @param x 解除を行うマスのX座標
1403 * @param o_idx 箱のオブジェクトID
1404 * @return ターンを消費する処理が行われた場合TRUEを返す
1407 * Assume destination is a visible trap
1408 * Assume there is no monster blocking the destination
1409 * Returns TRUE if repeated commands may continue
1412 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1418 object_type *o_ptr = &o_list[o_idx];
1422 p_ptr->energy_use = 100;
1424 /* Get the "disarm" factor */
1425 i = p_ptr->skill_dis;
1427 /* Penalize some conditions */
1428 if (p_ptr->blind || no_lite()) i = i / 10;
1429 if (p_ptr->confused || p_ptr->image) i = i / 10;
1431 /* Extract the difficulty */
1432 j = i - o_ptr->pval;
1434 /* Always have a small chance of success */
1437 /* Must find the trap first. */
1438 if (!object_is_known(o_ptr))
1440 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1444 /* Already disarmed/unlocked */
1445 else if (o_ptr->pval <= 0)
1447 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1450 /* No traps to find. */
1451 else if (!chest_traps[o_ptr->pval])
1453 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1456 /* Success (get a lot of experience) */
1457 else if (randint0(100) < j)
1459 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1460 gain_exp(o_ptr->pval);
1461 o_ptr->pval = (0 - o_ptr->pval);
1464 /* Failure -- Keep trying */
1465 else if ((i > 5) && (randint1(i) > 5))
1467 /* We may keep trying */
1469 if (flush_failure) flush();
1470 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1473 /* Failure -- Set off the trap */
1476 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1478 chest_trap(y, x, o_idx);
1487 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1488 * Perform the basic "disarm" command
1489 * @param y 解除を行うマスのY座標
1490 * @param x 解除を行うマスのX座標
1491 * @param dir プレイヤーからみた方向ID
1492 * @return ターンを消費する処理が行われた場合TRUEを返す
1495 * Assume destination is a visible trap
1496 * Assume there is no monster blocking the destination
1497 * Returns TRUE if repeated commands may continue
1500 #ifdef ALLOW_EASY_DISARM /* TNB */
1502 bool do_cmd_disarm_aux(int y, int x, int dir)
1504 #else /* ALLOW_EASY_DISARM -- TNB */
1506 static bool do_cmd_disarm_aux(int y, int x, int dir)
1508 #endif /* ALLOW_EASY_DISARM -- TNB */
1510 /* Get grid and contents */
1511 cave_type *c_ptr = &cave[y][x];
1514 feature_type *f_ptr = &f_info[c_ptr->feat];
1516 /* Access trap name */
1517 cptr name = (f_name + f_ptr->name);
1519 /* Extract trap "power" */
1520 int power = f_ptr->power;
1524 /* Get the "disarm" factor */
1525 int i = p_ptr->skill_dis;
1530 p_ptr->energy_use = 100;
1532 /* Penalize some conditions */
1533 if (p_ptr->blind || no_lite()) i = i / 10;
1534 if (p_ptr->confused || p_ptr->image) i = i / 10;
1536 /* Extract the difficulty */
1539 /* Always have a small chance of success */
1543 if (randint0(100) < j)
1546 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1551 /* Remove the trap */
1552 cave_alter_feat(y, x, FF_DISARM);
1554 #ifdef ALLOW_EASY_DISARM /* TNB */
1556 /* Move the player onto the trap */
1557 move_player(dir, easy_disarm, FALSE);
1559 #else /* ALLOW_EASY_DISARM -- TNB */
1561 /* move the player onto the trap grid */
1562 move_player(dir, FALSE, FALSE);
1564 #endif /* ALLOW_EASY_DISARM -- TNB */
1567 /* Failure -- Keep trying */
1568 else if ((i > 5) && (randint1(i) > 5))
1571 if (flush_failure) flush();
1574 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1576 /* We may keep trying */
1580 /* Failure -- Set off the trap */
1584 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1586 #ifdef ALLOW_EASY_DISARM /* TNB */
1588 /* Move the player onto the trap */
1589 move_player(dir, easy_disarm, FALSE);
1591 #else /* ALLOW_EASY_DISARM -- TNB */
1593 /* Move the player onto the trap */
1594 move_player(dir, FALSE, FALSE);
1596 #endif /* ALLOW_EASY_DISARM -- TNB */
1605 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1606 * Disarms a trap, or chest
1609 void do_cmd_disarm(void)
1617 if (p_ptr->special_defense & KATA_MUSOU)
1619 set_action(ACTION_NONE);
1622 #ifdef ALLOW_EASY_DISARM /* TNB */
1624 /* Option: Pick a direction */
1627 int num_traps, num_chests;
1629 /* Count visible traps */
1630 num_traps = count_dt(&y, &x, is_trap, TRUE);
1632 /* Count chests (trapped) */
1633 num_chests = count_chests(&y, &x, TRUE);
1635 /* See if only one target */
1636 if (num_traps || num_chests)
1638 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1639 if (!too_many) command_dir = coords_to_dir(y, x);
1643 #endif /* ALLOW_EASY_DISARM -- TNB */
1645 /* Allow repeated command */
1648 /* Set repeat count */
1649 command_rep = command_arg - 1;
1651 /* Redraw the state */
1652 p_ptr->redraw |= (PR_STATE);
1654 /* Cancel the arg */
1658 /* Get a direction (or abort) */
1659 if (get_rep_dir(&dir,TRUE))
1665 y = p_ptr->y + ddy[dir];
1666 x = p_ptr->x + ddx[dir];
1668 /* Get grid and contents */
1669 c_ptr = &cave[y][x];
1671 /* Feature code (applying "mimic" field) */
1672 feat = get_feat_mimic(c_ptr);
1674 /* Check for chests */
1675 o_idx = chest_check(y, x, TRUE);
1678 if (!is_trap(feat) && !o_idx)
1681 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1684 /* Monster in the way */
1685 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1688 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1697 /* Disarm the chest */
1698 more = do_cmd_disarm_chest(y, x, o_idx);
1704 /* Disarm the trap */
1705 more = do_cmd_disarm_aux(y, x, dir);
1709 /* Cancel repeat unless told not to */
1710 if (!more) disturb(0, 0);
1715 * @brief 「打ち破る」動作コマンドのサブルーチン /
1716 * Perform the basic "bash" command
1717 * @param y 対象を行うマスのY座標
1718 * @param x 対象を行うマスのX座標
1719 * @param dir プレイヤーから見たターゲットの方角ID
1720 * @return 実際に処理が行われた場合TRUEを返す。
1723 * Assume destination is a closed/locked/jammed door
1724 * Assume there is no monster blocking the destination
1725 * Returns TRUE if repeated commands may continue
1728 static bool do_cmd_bash_aux(int y, int x, int dir)
1731 cave_type *c_ptr = &cave[y][x];
1734 feature_type *f_ptr = &f_info[c_ptr->feat];
1736 /* Hack -- Bash power based on strength */
1737 /* (Ranges from 3 to 20 to 100 to 200) */
1738 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1740 /* Extract door power */
1741 int temp = f_ptr->power;
1745 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
1748 p_ptr->energy_use = 100;
1751 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1753 /* Compare bash power to door power XXX XXX XXX */
1754 temp = (bash - (temp * 10));
1756 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1758 /* Hack -- always have a chance */
1759 if (temp < 1) temp = 1;
1761 /* Hack -- attempt to bash down the door */
1762 if (randint0(100) < temp)
1765 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1768 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1770 /* Break down the door */
1771 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1773 cave_alter_feat(y, x, FF_BASH);
1779 cave_alter_feat(y, x, FF_OPEN);
1782 /* Hack -- Fall through the door */
1783 move_player(dir, FALSE, FALSE);
1786 /* Saving throw against stun */
1787 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1791 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1793 /* Allow repeated bashing */
1797 /* High dexterity yields coolness */
1801 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1803 /* Hack -- Lose balance ala paralysis */
1804 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1813 * @brief 「打ち破る」動作コマンドのメインルーチン /
1814 * Bash open a door, success based on character strength
1818 * For a closed door, pval is positive if locked; negative if stuck.
1820 * For an open door, pval is positive for a broken door.
1822 * A closed door can be opened - harder if locked. Any door might be
1823 * bashed open (and thereby broken). Bashing a door is (potentially)
1824 * faster! You move into the door way. To open a stuck door, it must
1825 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1827 * Creatures can also open or bash doors, see elsewhere.
1830 void do_cmd_bash(void)
1839 if (p_ptr->special_defense & KATA_MUSOU)
1841 set_action(ACTION_NONE);
1844 /* Allow repeated command */
1847 /* Set repeat count */
1848 command_rep = command_arg - 1;
1850 /* Redraw the state */
1851 p_ptr->redraw |= (PR_STATE);
1853 /* Cancel the arg */
1857 /* Get a "repeated" direction */
1858 if (get_rep_dir(&dir,FALSE))
1863 y = p_ptr->y + ddy[dir];
1864 x = p_ptr->x + ddx[dir];
1867 c_ptr = &cave[y][x];
1869 /* Feature code (applying "mimic" field) */
1870 feat = get_feat_mimic(c_ptr);
1872 /* Nothing useful */
1873 if (!have_flag(f_info[feat].flags, FF_BASH))
1876 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1879 /* Monster in the way */
1880 else if (c_ptr->m_idx)
1883 p_ptr->energy_use = 100;
1886 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1892 /* Bash a closed door */
1896 more = do_cmd_bash_aux(y, x, dir);
1900 /* Unless valid action taken, cancel bash */
1901 if (!more) disturb(0, 0);
1906 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1910 * Manipulate an adjacent grid in some way
1912 * Attack monsters, tunnel through walls, disarm traps, open doors.
1914 * Consider confusion XXX XXX XXX
1916 * This command must always take a turn, to prevent free detection
1917 * of invisible monsters.
1920 void do_cmd_alter(void)
1929 if (p_ptr->special_defense & KATA_MUSOU)
1931 set_action(ACTION_NONE);
1934 /* Allow repeated command */
1937 /* Set repeat count */
1938 command_rep = command_arg - 1;
1940 /* Redraw the state */
1941 p_ptr->redraw |= (PR_STATE);
1943 /* Cancel the arg */
1947 /* Get a direction */
1948 if (get_rep_dir(&dir,TRUE))
1951 feature_type *f_ptr;
1954 y = p_ptr->y + ddy[dir];
1955 x = p_ptr->x + ddx[dir];
1958 c_ptr = &cave[y][x];
1960 /* Feature code (applying "mimic" field) */
1961 feat = get_feat_mimic(c_ptr);
1962 f_ptr = &f_info[feat];
1965 p_ptr->energy_use = 100;
1967 /* Attack monsters */
1975 else if (have_flag(f_ptr->flags, FF_OPEN))
1977 more = do_cmd_open_aux(y, x);
1980 /* Bash jammed doors */
1981 else if (have_flag(f_ptr->flags, FF_BASH))
1983 more = do_cmd_bash_aux(y, x, dir);
1986 /* Tunnel through walls */
1987 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1989 more = do_cmd_tunnel_aux(y, x);
1992 /* Close open doors */
1993 else if (have_flag(f_ptr->flags, FF_CLOSE))
1995 more = do_cmd_close_aux(y, x);
1999 else if (have_flag(f_ptr->flags, FF_DISARM))
2001 more = do_cmd_disarm_aux(y, x, dir);
2008 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
2012 /* Cancel repetition unless we can continue */
2013 if (!more) disturb(0, 0);
2019 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
2020 * Find the index of some "spikes", if possible.
2021 * @param ip くさびとして打てるオブジェクトのID
2022 * @return オブジェクトがある場合TRUEを返す
2025 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2028 static bool get_spike(int *ip)
2032 /* Check every item in the pack */
2033 for (i = 0; i < INVEN_PACK; i++)
2035 object_type *o_ptr = &inventory[i];
2037 /* Skip non-objects */
2038 if (!o_ptr->k_idx) continue;
2040 /* Check the "tval" code */
2041 if (o_ptr->tval == TV_SPIKE)
2043 /* Save the spike index */
2057 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
2058 * Jam a closed door with a spike
2062 * This command may NOT be repeated
2065 void do_cmd_spike(void)
2069 if (p_ptr->special_defense & KATA_MUSOU)
2071 set_action(ACTION_NONE);
2074 /* Get a "repeated" direction */
2075 if (get_rep_dir(&dir,FALSE))
2082 y = p_ptr->y + ddy[dir];
2083 x = p_ptr->x + ddx[dir];
2085 /* Get grid and contents */
2086 c_ptr = &cave[y][x];
2088 /* Feature code (applying "mimic" field) */
2089 feat = get_feat_mimic(c_ptr);
2091 /* Require closed door */
2092 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2095 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2099 else if (!get_spike(&item))
2102 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2105 /* Is a monster in the way? */
2106 else if (c_ptr->m_idx)
2109 p_ptr->energy_use = 100;
2112 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2122 p_ptr->energy_use = 100;
2124 /* Successful jamming */
2125 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2126 cave_alter_feat(y, x, FF_SPIKE);
2128 /* Use up, and describe, a single spike, from the bottom */
2129 inven_item_increase(item, -1);
2130 inven_item_describe(item);
2131 inven_item_optimize(item);
2139 * @brief 「歩く」動作コマンドのメインルーチン /
2140 * Support code for the "Walk" and "Jump" commands
2141 * @param pickup アイテムの自動拾いを行うならTRUE
2144 void do_cmd_walk(bool pickup)
2151 /* Allow repeated command */
2154 /* Set repeat count */
2155 command_rep = command_arg - 1;
2157 /* Redraw the state */
2158 p_ptr->redraw |= (PR_STATE);
2160 /* Cancel the arg */
2164 /* Get a "repeated" direction */
2165 if (get_rep_dir(&dir, FALSE))
2168 p_ptr->energy_use = 100;
2170 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2172 set_action(ACTION_NONE);
2175 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2176 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2177 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2179 /* Actually move the character */
2180 move_player(dir, pickup, FALSE);
2182 /* Allow more walking */
2186 /* Hack again -- Is there a special encounter ??? */
2187 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2189 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2192 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2194 /* Inform the player of his horrible fate :=) */
2195 msg_print(_("襲撃だ!", "You are ambushed !"));
2197 /* Go into large wilderness view */
2198 p_ptr->oldpy = randint1(MAX_HGT-2);
2199 p_ptr->oldpx = randint1(MAX_WID-2);
2202 /* Give first move to monsters */
2203 p_ptr->energy_use = 100;
2205 /* HACk -- set the encouter flag for the wilderness generation */
2206 generate_encounter = TRUE;
2210 /* Cancel repeat unless we may continue */
2211 if (!more) disturb(0, 0);
2216 * @brief 「走る」動作コマンドのメインルーチン /
2220 void do_cmd_run(void)
2224 /* Hack -- no running when confused */
2225 if (p_ptr->confused)
2227 msg_print(_("混乱していて走れない!", "You are too confused!"));
2231 if (p_ptr->special_defense & KATA_MUSOU)
2233 set_action(ACTION_NONE);
2236 /* Get a "repeated" direction */
2237 if (get_rep_dir(&dir,FALSE))
2239 /* Hack -- Set the run counter */
2240 running = (command_arg ? command_arg : 1000);
2249 * @brief 「留まる」動作コマンドのメインルーチン /
2250 * Stay still. Search. Enter stores.
2251 * Pick up treasure if "pickup" is true.
2252 * @param pickup アイテムの自動拾いを行うならTRUE
2255 void do_cmd_stay(bool pickup)
2257 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2259 /* Allow repeated command */
2262 /* Set repeat count */
2263 command_rep = command_arg - 1;
2265 /* Redraw the state */
2266 p_ptr->redraw |= (PR_STATE);
2268 /* Cancel the arg */
2273 p_ptr->energy_use = 100;
2275 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2276 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2281 * @brief 「休む」動作コマンドのメインルーチン /
2282 * Resting allows a player to safely restore his hp -RAK-
2285 void do_cmd_rest(void)
2288 set_action(ACTION_NONE);
2290 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2296 if (hex_spelling_any()) stop_hex_spell_all();
2298 /* Prompt for time if needed */
2299 if (command_arg <= 0)
2301 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2302 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2308 strcpy(out_val, "&");
2310 /* Ask for duration */
2311 if (!get_string(p, out_val, 4)) return;
2313 /* Rest until done */
2314 if (out_val[0] == '&')
2316 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2320 else if (out_val[0] == '*')
2322 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2328 command_arg = (COMMAND_ARG)atoi(out_val);
2329 if (command_arg <= 0) return;
2335 if (command_arg > 9999) command_arg = 9999;
2337 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2339 /* Take a turn XXX XXX XXX (?) */
2340 p_ptr->energy_use = 100;
2342 /* The sin of sloth */
2343 if (command_arg > 100)
2344 chg_virtue(V_DILIGENCE, -1);
2346 /* Why are you sleeping when there's no need? WAKE UP!*/
2347 if ((p_ptr->chp == p_ptr->mhp) &&
2348 (p_ptr->csp == p_ptr->msp) &&
2349 !p_ptr->blind && !p_ptr->confused &&
2350 !p_ptr->poisoned && !p_ptr->afraid &&
2351 !p_ptr->stun && !p_ptr->cut &&
2352 !p_ptr->slow && !p_ptr->paralyzed &&
2353 !p_ptr->image && !p_ptr->word_recall &&
2354 !p_ptr->alter_reality)
2355 chg_virtue(V_DILIGENCE, -1);
2357 /* Save the rest code */
2358 resting = command_arg;
2359 p_ptr->action = ACTION_REST;
2361 /* Recalculate bonuses */
2362 p_ptr->update |= (PU_BONUS);
2364 /* Redraw the state */
2365 p_ptr->redraw |= (PR_STATE);
2376 * @brief 矢弾を射撃した場合の破損確率を返す /
2377 * Determines the odds of an object breaking when thrown at a monster
2378 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2381 * Note that artifacts never break, see the "drop_near()" function.
2383 static int breakage_chance(object_type *o_ptr)
2385 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2387 /* Examine the snipe type */
2390 if (snipe_type == SP_KILL_WALL) return (100);
2391 if (snipe_type == SP_EXPLODE) return (100);
2392 if (snipe_type == SP_PIERCE) return (100);
2393 if (snipe_type == SP_FINAL) return (100);
2394 if (snipe_type == SP_NEEDLE) return (100);
2395 if (snipe_type == SP_EVILNESS) return (40);
2396 if (snipe_type == SP_HOLYNESS) return (40);
2399 /* Examine the item type */
2400 switch (o_ptr->tval)
2416 /* Sometimes break */
2421 return (20 - archer_bonus * 2);
2426 return (10 - archer_bonus);
2434 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2435 * Determines the odds of an object breaking when thrown at a monster
2436 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2437 * @param tdam 計算途中のダメージ量
2438 * @param m_ptr 目標モンスターの構造体参照ポインタ
2439 * @return スレイ倍率をかけたダメージ量
2441 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2445 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2447 u32b flgs[TR_FLAG_SIZE];
2449 /* Extract the flags */
2450 object_flags(o_ptr, flgs);
2452 /* Some "weapons" and "ammo" do extra damage */
2453 switch (o_ptr->tval)
2460 if ((have_flag(flgs, TR_SLAY_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 < 17) mult = 17;
2472 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2473 (r_ptr->flags3 & RF3_ANIMAL))
2475 if (is_original_ap_and_seen(m_ptr))
2477 r_ptr->r_flags3 |= RF3_ANIMAL;
2480 if (mult < 27) mult = 27;
2484 if ((have_flag(flgs, TR_SLAY_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 < 15) mult = 15;
2496 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2497 (r_ptr->flags3 & RF3_EVIL))
2499 if (is_original_ap_and_seen(m_ptr))
2501 r_ptr->r_flags3 |= RF3_EVIL;
2504 if (mult < 25) mult = 25;
2508 if ((have_flag(flgs, TR_SLAY_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 < 17) mult = 17;
2520 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2521 (r_ptr->flags2 & RF2_HUMAN))
2523 if (is_original_ap_and_seen(m_ptr))
2525 r_ptr->r_flags2 |= RF2_HUMAN;
2528 if (mult < 27) mult = 27;
2532 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
2544 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2545 (r_ptr->flags3 & RF3_UNDEAD))
2547 if (is_original_ap_and_seen(m_ptr))
2549 r_ptr->r_flags3 |= RF3_UNDEAD;
2552 if (mult < 30) mult = 30;
2556 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
2568 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2569 (r_ptr->flags3 & RF3_DEMON))
2571 if (is_original_ap_and_seen(m_ptr))
2573 r_ptr->r_flags3 |= RF3_DEMON;
2576 if (mult < 30) mult = 30;
2580 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
2592 if ((have_flag(flgs, TR_KILL_ORC)) &&
2593 (r_ptr->flags3 & RF3_ORC))
2595 if (is_original_ap_and_seen(m_ptr))
2597 r_ptr->r_flags3 |= RF3_ORC;
2600 if (mult < 30) mult = 30;
2604 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
2616 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2617 (r_ptr->flags3 & RF3_TROLL))
2619 if (is_original_ap_and_seen(m_ptr))
2621 r_ptr->r_flags3 |= RF3_TROLL;
2624 if (mult < 30) mult = 30;
2628 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
2640 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2641 (r_ptr->flags3 & RF3_GIANT))
2643 if (is_original_ap_and_seen(m_ptr))
2645 r_ptr->r_flags3 |= RF3_GIANT;
2648 if (mult < 30) mult = 30;
2652 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
2663 /* Execute Dragon */
2664 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
2665 (r_ptr->flags3 & RF3_DRAGON))
2667 if (is_original_ap_and_seen(m_ptr))
2669 r_ptr->r_flags3 |= RF3_DRAGON;
2672 if (mult < 30) mult = 30;
2674 if ((o_ptr->name1 == ART_BARD_ARROW) &&
2675 (m_ptr->r_idx == MON_SMAUG) &&
2676 (inventory[INVEN_BOW].name1 == ART_BARD))
2681 if (have_flag(flgs, TR_BRAND_ACID))
2683 /* Notice immunity */
2684 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
2686 if (is_original_ap_and_seen(m_ptr))
2688 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
2692 /* Otherwise, take the damage */
2695 if (mult < 17) mult = 17;
2700 if (have_flag(flgs, TR_BRAND_ELEC))
2702 /* Notice immunity */
2703 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
2705 if (is_original_ap_and_seen(m_ptr))
2707 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
2711 /* Otherwise, take the damage */
2714 if (mult < 17) mult = 17;
2719 if (have_flag(flgs, TR_BRAND_FIRE))
2721 /* Notice immunity */
2722 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
2724 if (is_original_ap_and_seen(m_ptr))
2726 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
2730 /* Otherwise, take the damage */
2733 if (r_ptr->flags3 & RF3_HURT_FIRE)
2735 if (mult < 25) mult = 25;
2736 if (is_original_ap_and_seen(m_ptr))
2738 r_ptr->r_flags3 |= RF3_HURT_FIRE;
2741 else if (mult < 17) mult = 17;
2746 if (have_flag(flgs, TR_BRAND_COLD))
2748 /* Notice immunity */
2749 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
2751 if (is_original_ap_and_seen(m_ptr))
2753 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
2756 /* Otherwise, take the damage */
2759 if (r_ptr->flags3 & RF3_HURT_COLD)
2761 if (mult < 25) mult = 25;
2762 if (is_original_ap_and_seen(m_ptr))
2764 r_ptr->r_flags3 |= RF3_HURT_COLD;
2767 else if (mult < 17) mult = 17;
2771 /* Brand (Poison) */
2772 if (have_flag(flgs, TR_BRAND_POIS))
2774 /* Notice immunity */
2775 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
2777 if (is_original_ap_and_seen(m_ptr))
2779 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
2783 /* Otherwise, take the damage */
2786 if (mult < 17) mult = 17;
2790 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
2792 p_ptr->csp -= (1+(p_ptr->msp / 30));
2793 p_ptr->redraw |= (PR_MANA);
2794 mult = mult * 5 / 2;
2801 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
2803 /* Return the total damage */
2804 return (tdam * mult / 10);
2809 * @brief 射撃処理のサブルーチン /
2810 * Fire an object from the pack or floor.
2811 * @param item 射撃するオブジェクトの所持ID
2812 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
2816 * You may only fire items that "match" your missile launcher.
2818 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
2820 * See "calc_bonuses()" for more calculations and such.
2822 * Note that "firing" a missile is MUCH better than "throwing" it.
2824 * Note: "unseen" monsters are very hard to hit.
2826 * Objects are more likely to break if they "attempt" to hit a monster.
2828 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
2830 * The "extra shot" code works by decreasing the amount of energy
2831 * required to make each shot, spreading the shots out over time.
2833 * Note that when firing missiles, the launcher multiplier is applied
2834 * after all the bonuses are added in, making multipliers very useful.
2836 * Note that Bows of "Extra Might" get extra range and an extra bonus
2837 * for the damage multiplier.
2839 * Note that Bows of "Extra Shots" give an extra shot.
2842 void do_cmd_fire_aux(int item, object_type *j_ptr)
2845 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
2846 int tdam_base, tdis, thits, tmul;
2848 int cur_dis, visible;
2855 bool hit_body = FALSE;
2857 char o_name[MAX_NLEN];
2859 u16b path_g[512]; /* For calcuration of path length */
2861 int msec = delay_factor * delay_factor * delay_factor;
2864 bool stick_to = FALSE;
2866 /* Access the item (if in the pack) */
2869 o_ptr = &inventory[item];
2873 o_ptr = &o_list[0 - item];
2876 /* Sniper - Cannot shot a single arrow twice */
2877 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
2879 /* Describe the object */
2880 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
2882 /* Use the proper number of shots */
2883 thits = p_ptr->num_fire;
2885 /* Use a base distance */
2888 /* Base damage from thrown object plus launcher bonus */
2889 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
2891 /* Actually "fire" the object */
2892 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
2893 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2894 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
2896 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
2898 p_ptr->energy_use = bow_energy(j_ptr->sval);
2899 tmul = bow_tmul(j_ptr->sval);
2901 /* Get extra "power" from "extra might" */
2902 if (p_ptr->xtra_might) tmul++;
2904 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
2906 /* Boost the damage */
2911 tdis = 13 + tmul/80;
2912 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
2915 tdis -= (5 - (p_ptr->concent + 1) / 2);
2920 project_length = tdis + 1;
2922 /* Get a direction (or cancel) */
2923 if (!get_aim_dir(&dir))
2925 p_ptr->energy_use = 0;
2927 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
2929 /* need not to reset project_length (already did)*/
2934 /* Predict the "target" location */
2935 tx = p_ptr->x + 99 * ddx[dir];
2936 ty = p_ptr->y + 99 * ddy[dir];
2938 /* Check for "target request" */
2939 if ((dir == 5) && target_okay())
2945 /* Get projection path length */
2946 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
2948 project_length = 0; /* reset to default */
2950 /* Don't shoot at my feet */
2951 if (tx == p_ptr->x && ty == p_ptr->y)
2953 p_ptr->energy_use = 0;
2955 /* project_length is already reset to 0 */
2961 /* Take a (partial) turn */
2962 p_ptr->energy_use = (p_ptr->energy_use / thits);
2965 /* Sniper - Difficult to shot twice at 1 turn */
2966 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
2968 /* Sniper - Repeat shooting when double shots */
2969 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
2972 /* Start at the player */
2976 /* Get local object */
2979 /* Obtain a local object */
2980 object_copy(q_ptr, o_ptr);
2985 /* Reduce and describe inventory */
2988 inven_item_increase(item, -1);
2989 inven_item_describe(item);
2990 inven_item_optimize(item);
2993 /* Reduce and describe floor item */
2996 floor_item_increase(0 - item, -1);
2997 floor_item_optimize(0 - item);
3003 /* Hack -- Handle stuff */
3006 /* Save the old location */
3010 /* The shot does not hit yet */
3013 /* Travel until stopped */
3014 for (cur_dis = 0; cur_dis <= tdis; )
3018 /* Hack -- Stop at the target */
3019 if ((y == ty) && (x == tx)) break;
3021 /* Calculate the new location (see "project()") */
3024 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3027 if (snipe_type == SP_KILL_WALL)
3029 c_ptr = &cave[ny][nx];
3031 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3033 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
3034 /* Forget the wall */
3035 c_ptr->info &= ~(CAVE_MARK);
3037 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3039 /* Destroy the wall */
3040 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3047 /* Stopped by walls/doors */
3048 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3050 /* Advance the distance */
3054 if (snipe_type == SP_LITE)
3056 cave[ny][nx].info |= (CAVE_GLOW);
3065 /* The player can see the (on screen) missile */
3066 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3068 char c = object_char(q_ptr);
3069 byte a = object_attr(q_ptr);
3071 /* Draw, Hilite, Fresh, Pause, Erase */
3072 print_rel(c, a, ny, nx);
3073 move_cursor_relative(ny, nx);
3075 Term_xtra(TERM_XTRA_DELAY, msec);
3080 /* The player cannot see the missile */
3083 /* Pause anyway, for consistancy */
3084 Term_xtra(TERM_XTRA_DELAY, msec);
3088 if (snipe_type == SP_KILL_TRAP)
3090 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3091 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3095 if (snipe_type == SP_EVILNESS)
3097 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3106 /* Save the old location */
3110 /* Save the new location */
3115 /* Monster here, Try to hit it */
3116 if (cave[y][x].m_idx)
3118 cave_type *c_mon_ptr = &cave[y][x];
3120 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
3121 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3123 /* Check the visibility */
3124 visible = m_ptr->ml;
3126 /* Note the collision */
3129 if (MON_CSLEEP(m_ptr))
3131 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3132 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3135 if ((r_ptr->level + 10) > p_ptr->lev)
3137 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3138 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3141 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3142 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3143 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3144 else if (p_ptr->lev > 34) amount = 2;
3145 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3146 p_ptr->update |= (PU_BONUS);
3152 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3153 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3156 p_ptr->skill_exp[GINOU_RIDING] += 1;
3157 p_ptr->update |= (PU_BONUS);
3161 /* Did we hit it (penalize range) */
3162 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3165 int tdam = tdam_base;
3167 /* Get extra damage from concentration */
3168 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3170 /* Handle unseen monster */
3173 /* Invisible monster */
3174 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3177 /* Handle visible monster */
3182 /* Get "the monster" or "it" */
3183 monster_desc(m_name, m_ptr, 0);
3186 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3190 /* Hack -- Track this monster race */
3191 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3193 /* Hack -- Track this monster */
3194 health_track(c_mon_ptr->m_idx);
3198 if (snipe_type == SP_NEEDLE)
3200 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3201 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3205 /* Get "the monster" or "it" */
3206 monster_desc(m_name, m_ptr, 0);
3208 tdam = m_ptr->hp + 1;
3209 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3215 /* Apply special damage XXX XXX XXX */
3216 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3217 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3219 /* No negative damage */
3220 if (tdam < 0) tdam = 0;
3222 /* Modify the damage */
3223 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3226 msg_format_wizard(CHEAT_MONSTER,
3227 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3228 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3231 if (snipe_type == SP_EXPLODE)
3233 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3235 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3236 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3241 if (snipe_type == SP_HOLYNESS)
3243 cave[ny][nx].info |= (CAVE_GLOW);
3252 /* Hit the monster, check for death */
3253 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3262 if (object_is_fixed_artifact(q_ptr) &&
3263 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3267 monster_desc(m_name, m_ptr, 0);
3270 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3274 message_pain(c_mon_ptr->m_idx, tdam);
3276 /* Anger the monster */
3277 if (tdam > 0) anger_monster(m_ptr);
3280 if (fear && m_ptr->ml)
3287 /* Get the monster name (or "it") */
3288 monster_desc(m_name, m_ptr, 0);
3291 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3294 set_target(m_ptr, p_ptr->y, p_ptr->x);
3297 if (snipe_type == SP_RUSH)
3299 int n = randint1(5) + 3;
3300 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3302 for ( ; cur_dis <= tdis; )
3309 /* Calculate the new location (see "project()") */
3310 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3312 /* Stopped by wilderness boundary */
3313 if (!in_bounds2(ny, nx)) break;
3315 /* Stopped by walls/doors */
3316 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3318 /* Stopped by monsters */
3319 if (!cave_empty_bold(ny, nx)) break;
3321 cave[ny][nx].m_idx = m_idx;
3322 cave[oy][ox].m_idx = 0;
3327 /* Update the monster (new location) */
3328 update_mon(c_mon_ptr->m_idx, TRUE);
3334 Term_xtra(TERM_XTRA_DELAY, msec);
3346 if (snipe_type == SP_PIERCE)
3348 if(p_ptr->concent < 1) break;
3358 /* Chance of breakage (during attacks) */
3359 j = (hit_body ? breakage_chance(q_ptr) : 0);
3363 MONSTER_IDX m_idx = cave[y][x].m_idx;
3364 monster_type *m_ptr = &m_list[m_idx];
3365 IDX o_idx = o_pop();
3369 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3370 if (object_is_fixed_artifact(q_ptr))
3372 a_info[j_ptr->name1].cur_num = 0;
3377 o_ptr = &o_list[o_idx];
3378 object_copy(o_ptr, q_ptr);
3381 o_ptr->marked &= OM_TOUCHED;
3383 /* Forget location */
3384 o_ptr->iy = o_ptr->ix = 0;
3386 /* Memorize monster */
3387 o_ptr->held_m_idx = m_idx;
3390 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3393 m_ptr->hold_o_idx = o_idx;
3395 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3397 /* Drop (or break) near that location */
3398 (void)drop_near(q_ptr, j, y, x);
3402 /* Drop (or break) near that location */
3403 (void)drop_near(q_ptr, j, prev_y, prev_x);
3406 /* Sniper - Repeat shooting when double shots */
3409 /* Sniper - Loose his/her concentration after any shot */
3410 if (p_ptr->concent) reset_concentration(FALSE);
3414 * @brief 射撃処理のメインルーチン
3417 void do_cmd_fire(void)
3423 is_fired = FALSE; /* not fired yet */
3425 /* Get the "bow" (if any) */
3426 j_ptr = &inventory[INVEN_BOW];
3428 /* Require a launcher */
3431 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3436 if (j_ptr->sval == SV_CRIMSON)
3438 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3443 if (j_ptr->sval == SV_HARP)
3445 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3451 if (p_ptr->special_defense & KATA_MUSOU)
3453 set_action(ACTION_NONE);
3456 /* Require proper missile */
3457 item_tester_tval = p_ptr->tval_ammo;
3460 q = _("どれを撃ちますか? ", "Fire which item? ");
3461 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3462 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3469 do_cmd_fire_aux(item, j_ptr);
3471 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3473 /* Sniper actions after some shootings */
3474 if (snipe_type == SP_AWAY)
3476 teleport_player(10 + (p_ptr->concent * 2), 0L);
3478 if (snipe_type == SP_FINAL)
3480 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3481 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3482 (void)set_stun(p_ptr->stun + randint1(25));
3487 * @brief オブジェクトが投射可能な武器かどうかを返す。
3488 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
3489 * @return 投射可能な武器ならばTRUE
3491 static bool item_tester_hook_boomerang(object_type *o_ptr)
3493 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
3501 * @brief 投射処理のサブルーチン /
3502 * Throw an object from the pack or floor.
3504 * @param boomerang ブーメラン処理ならばTRUE
3505 * @param shuriken 忍者の手裏剣処理ならばTRUE
3506 * @return ターンを消費した場合TRUEを返す
3509 * Note: "unseen" monsters are very hard to hit.
3511 * Should throwing a weapon do full damage? Should it allow the magic
3512 * to hit bonus of the weapon to have an effect? Should it ever cause
3513 * the item to be destroyed? Should it do any damage at all?
3516 bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken)
3520 int i, j, y, x, ty, tx, prev_y, prev_x;
3522 int chance, tdam, tdis;
3523 int mul, div, dd, ds;
3524 int cur_dis, visible;
3531 bool hit_body = FALSE;
3532 bool hit_wall = FALSE;
3533 bool equiped_item = FALSE;
3534 bool return_when_thrown = FALSE;
3536 char o_name[MAX_NLEN];
3538 int msec = delay_factor * delay_factor * delay_factor;
3540 u32b flgs[TR_FLAG_SIZE];
3542 bool come_back = FALSE;
3543 bool do_drop = TRUE;
3546 if (p_ptr->special_defense & KATA_MUSOU)
3548 set_action(ACTION_NONE);
3557 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3559 item_tester_hook = item_tester_hook_boomerang;
3560 q = _("どの武器を投げますか? ", "Throw which item? ");
3561 s = _("投げる武器がない。", "You have nothing to throw.");
3562 if (!get_item(&item, q, s, (USE_EQUIP)))
3568 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3569 else item = INVEN_RARM;
3574 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3575 s = _("投げるアイテムがない。", "You have nothing to throw.");
3576 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3583 /* Access the item (if in the pack) */
3586 o_ptr = &inventory[item];
3590 o_ptr = &o_list[0 - item];
3594 /* Item is cursed */
3595 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3598 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3604 if (p_ptr->inside_arena && !boomerang)
3606 if (o_ptr->tval != TV_SPIKE)
3608 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3616 /* Get local object */
3619 /* Obtain a local object */
3620 object_copy(q_ptr, o_ptr);
3622 /* Extract the thrown object's flags. */
3623 object_flags(q_ptr, flgs);
3624 torch_flags(q_ptr, flgs);
3626 /* Distribute the charges of rods/wands between the stacks */
3627 distribute_charges(o_ptr, q_ptr, 1);
3633 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3635 if (p_ptr->mighty_throw) mult += 3;
3637 /* Extract a "distance multiplier" */
3638 /* Changed for 'launcher' mutation */
3639 mul = 10 + 2 * (mult - 1);
3641 /* Enforce a minimum "weight" of one pound */
3642 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3643 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3645 /* Hack -- Distance -- Reward strength, penalize weight */
3646 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3648 /* Max distance of 10-18 */
3649 if (tdis > mul) tdis = mul;
3653 ty = randint0(101)-50+p_ptr->y;
3654 tx = randint0(101)-50+p_ptr->x;
3658 project_length = tdis + 1;
3660 /* Get a direction (or cancel) */
3661 if (!get_aim_dir(&dir)) return FALSE;
3663 /* Predict the "target" location */
3664 tx = p_ptr->x + 99 * ddx[dir];
3665 ty = p_ptr->y + 99 * ddy[dir];
3667 /* Check for "target request" */
3668 if ((dir == 5) && target_okay())
3674 project_length = 0; /* reset to default */
3677 if ((q_ptr->name1 == ART_MJOLLNIR) ||
3678 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
3679 return_when_thrown = TRUE;
3681 /* Reduce and describe inventory */
3684 inven_item_increase(item, -1);
3685 if (!return_when_thrown)
3686 inven_item_describe(item);
3687 inven_item_optimize(item);
3690 /* Reduce and describe floor item */
3693 floor_item_increase(0 - item, -1);
3694 floor_item_optimize(0 - item);
3696 if (item >= INVEN_RARM)
3698 equiped_item = TRUE;
3699 p_ptr->redraw |= (PR_EQUIPPY);
3703 p_ptr->energy_use = 100;
3705 /* Rogue and Ninja gets bonus */
3706 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
3707 p_ptr->energy_use -= p_ptr->lev;
3709 /* Start at the player */
3714 /* Hack -- Handle stuff */
3717 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
3718 else shuriken = FALSE;
3720 /* Chance of hitting */
3721 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
3722 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
3723 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
3725 if (shuriken) chance *= 2;
3727 /* Save the old location */
3731 /* Travel until stopped */
3732 for (cur_dis = 0; cur_dis <= tdis; )
3734 /* Hack -- Stop at the target */
3735 if ((y == ty) && (x == tx)) break;
3737 /* Calculate the new location (see "project()") */
3740 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
3742 /* Stopped by walls/doors */
3743 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
3746 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
3749 /* The player can see the (on screen) missile */
3750 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
3752 char c = object_char(q_ptr);
3753 byte a = object_attr(q_ptr);
3755 /* Draw, Hilite, Fresh, Pause, Erase */
3756 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
3757 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
3759 Term_xtra(TERM_XTRA_DELAY, msec);
3760 lite_spot(ny[cur_dis], nx[cur_dis]);
3764 /* The player cannot see the missile */
3767 /* Pause anyway, for consistancy */
3768 Term_xtra(TERM_XTRA_DELAY, msec);
3771 /* Save the old location */
3775 /* Save the new location */
3779 /* Advance the distance */
3782 /* Monster here, Try to hit it */
3783 if (cave[y][x].m_idx)
3785 cave_type *c_ptr = &cave[y][x];
3787 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3789 /* Check the visibility */
3790 visible = m_ptr->ml;
3792 /* Note the collision */
3795 /* Did we hit it (penalize range) */
3796 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3800 /* Handle unseen monster */
3803 /* Invisible monster */
3804 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3807 /* Handle visible monster */
3812 /* Get "the monster" or "it" */
3813 monster_desc(m_name, m_ptr, 0);
3816 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3820 /* Hack -- Track this monster race */
3821 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3823 /* Hack -- Track this monster */
3824 health_track(c_ptr->m_idx);
3828 /* Hack -- Base damage from thrown object */
3831 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
3832 tdam = damroll(dd, ds);
3833 /* Apply special damage XXX XXX XXX */
3834 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
3835 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
3836 if (q_ptr->to_d > 0)
3837 tdam += q_ptr->to_d;
3839 tdam += -q_ptr->to_d;
3843 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
3844 tdam += p_ptr->to_d_m;
3846 else if (have_flag(flgs, TR_THROW))
3849 tdam += p_ptr->to_d_m;
3857 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
3860 /* No negative damage */
3861 if (tdam < 0) tdam = 0;
3863 /* Modify the damage */
3864 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3866 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3867 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3869 /* Hit the monster, check for death */
3870 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3879 message_pain(c_ptr->m_idx, tdam);
3881 /* Anger the monster */
3882 if ((tdam > 0) && !object_is_potion(q_ptr))
3883 anger_monster(m_ptr);
3886 if (fear && m_ptr->ml)
3893 /* Get the monster name (or "it") */
3894 monster_desc(m_name, m_ptr, 0);
3897 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3907 /* decrease toach's fuel */
3908 if (hit_body) torch_lost_fuel(q_ptr);
3910 /* Chance of breakage (during attacks) */
3911 j = (hit_body ? breakage_chance(q_ptr) : 0);
3913 /* Figurines transform */
3914 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
3918 if (!(summon_named_creature(0, y, x, q_ptr->pval,
3919 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
3920 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
3921 else if (object_is_cursed(q_ptr))
3922 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
3927 /* Potions smash open */
3928 if (object_is_potion(q_ptr))
3930 if (hit_body || hit_wall || (randint1(100) < j))
3933 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
3935 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
3937 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
3939 /* ToDo (Robert): fix the invulnerability */
3940 if (cave[y][x].m_idx &&
3941 is_friendly(&m_list[cave[y][x].m_idx]) &&
3942 !MON_INVULNER(m_ptr))
3945 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
3946 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
3947 set_hostile(&m_list[cave[y][x].m_idx]);
3958 if (return_when_thrown)
3960 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
3961 char o2_name[MAX_NLEN];
3962 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
3965 if (boomerang) back_chance += 4+randint1(5);
3966 if (super_boomerang) back_chance += 100;
3967 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3969 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
3971 for (i = cur_dis - 1; i > 0; i--)
3973 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
3975 char c = object_char(q_ptr);
3976 byte a = object_attr(q_ptr);
3978 /* Draw, Hilite, Fresh, Pause, Erase */
3979 print_rel(c, a, ny[i], nx[i]);
3980 move_cursor_relative(ny[i], nx[i]);
3982 Term_xtra(TERM_XTRA_DELAY, msec);
3983 lite_spot(ny[i], nx[i]);
3988 /* Pause anyway, for consistancy */
3989 Term_xtra(TERM_XTRA_DELAY, msec);
3992 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
3994 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
4001 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
4005 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
4013 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
4019 if (item == INVEN_RARM || item == INVEN_LARM)
4021 /* Access the wield slot */
4022 o_ptr = &inventory[item];
4024 /* Wear the new stuff */
4025 object_copy(o_ptr, q_ptr);
4027 /* Increase the weight */
4028 p_ptr->total_weight += q_ptr->weight;
4030 /* Increment the equip counter by hand */
4033 /* Recalculate bonuses */
4034 p_ptr->update |= (PU_BONUS);
4036 /* Recalculate torch */
4037 p_ptr->update |= (PU_TORCH);
4039 /* Recalculate mana XXX */
4040 p_ptr->update |= (PU_MANA);
4043 p_ptr->window |= (PW_EQUIP);
4051 else if (equiped_item)
4057 /* Drop (or break) near that location */
4060 if (cave_have_flag_bold(y, x, FF_PROJECT))
4062 /* Drop (or break) near that location */
4063 (void)drop_near(q_ptr, j, y, x);
4067 /* Drop (or break) near that location */
4068 (void)drop_near(q_ptr, j, prev_y, prev_x);
4077 * @brief 投射処理のメインルーチン /
4078 * Throw an object from the pack or floor.
4081 void do_cmd_throw(void)
4083 do_cmd_throw_aux(1, FALSE, -1);
4089 * Hack: travel command
4091 #define TRAVEL_UNABLE 9999
4093 static int flow_head = 0;
4094 static int flow_tail = 0;
4095 static POSITION temp2_x[MAX_SHORT];
4096 static POSITION temp2_y[MAX_SHORT];
4099 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
4102 void forget_travel_flow(void)
4106 /* Check the entire dungeon */
4107 for (y = 0; y < cur_hgt; y++)
4109 for (x = 0; x < cur_wid; x++)
4111 /* Forget the old data */
4112 travel.cost[y][x] = MAX_SHORT;
4116 travel.y = travel.x = 0;
4120 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
4125 static int travel_flow_cost(int y, int x)
4127 feature_type *f_ptr = &f_info[cave[y][x].feat];
4130 /* Avoid obstacles (ex. trees) */
4131 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4134 if (have_flag(f_ptr->flags, FF_WATER))
4136 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4140 if (have_flag(f_ptr->flags, FF_LAVA))
4143 if (!p_ptr->resist_fire) lava *= 2;
4144 if (!p_ptr->levitation) lava *= 2;
4145 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4150 /* Detected traps and doors */
4151 if (cave[y][x].info & (CAVE_MARK))
4153 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4154 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4161 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
4165 * @param wall プレイヤーが壁の中にいるならばTRUE
4168 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
4170 cave_type *c_ptr = &cave[y][x];
4171 feature_type *f_ptr = &f_info[c_ptr->feat];
4172 int old_head = flow_head;
4174 int base_cost = (n % TRAVEL_UNABLE);
4175 int from_wall = (n / TRAVEL_UNABLE);
4178 /* Ignore out of bounds */
4179 if (!in_bounds(y, x)) return;
4181 /* Ignore unknown grid except in wilderness */
4182 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
4184 /* Ignore "walls" and "rubble" (include "secret doors") */
4185 if (have_flag(f_ptr->flags, FF_WALL) ||
4186 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4187 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4188 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4190 if (!wall || !from_wall) return;
4191 add_cost += TRAVEL_UNABLE;
4195 add_cost = travel_flow_cost(y, x);
4198 cost = base_cost + add_cost;
4200 /* Ignore lower cost entries */
4201 if (travel.cost[y][x] <= cost) return;
4203 /* Save the flow cost */
4204 travel.cost[y][x] = cost;
4206 /* Enqueue that entry */
4207 temp2_y[flow_head] = y;
4208 temp2_x[flow_head] = x;
4210 /* Advance the queue */
4211 if (++flow_head == MAX_SHORT) flow_head = 0;
4213 /* Hack -- notice overflow by forgetting new entry */
4214 if (flow_head == flow_tail) flow_head = old_head;
4220 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
4221 * @param ty 目標地点のY座標
4222 * @param tx 目標地点のX座標
4225 static void travel_flow(int ty, int tx)
4229 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
4231 /* Reset the "queue" */
4232 flow_head = flow_tail = 0;
4234 /* is player in the wall? */
4235 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4237 /* Start at the target grid */
4238 travel_flow_aux(ty, tx, 0, wall);
4240 /* Now process the queue */
4241 while (flow_head != flow_tail)
4243 /* Extract the next entry */
4244 y = temp2_y[flow_tail];
4245 x = temp2_x[flow_tail];
4247 /* Forget that entry */
4248 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4250 /* Ignore too far entries */
4251 //if (distance(ty, tx, y, x) > 100) continue;
4253 /* Add the "children" */
4254 for (d = 0; d < 8; d++)
4256 /* Add that child if "legal" */
4257 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4261 /* Forget the flow info */
4262 flow_head = flow_tail = 0;
4266 * @brief トラベル処理のメインルーチン
4269 void do_cmd_travel(void)
4274 feature_type *f_ptr;
4276 if (travel.x != 0 && travel.y != 0 &&
4277 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4282 else if (!tgt_pt(&x, &y)) return;
4284 if ((x == p_ptr->x) && (y == p_ptr->y))
4286 msg_print(_("すでにそこにいます!", "You are already there!!"));
4290 f_ptr = &f_info[cave[y][x].feat];
4292 if ((cave[y][x].info & CAVE_MARK) &&
4293 (have_flag(f_ptr->flags, FF_WALL) ||
4294 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4295 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4297 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4301 forget_travel_flow();
4307 /* Travel till 255 steps */
4313 /* Decides first direction */
4314 dx = abs(p_ptr->x - x);
4315 dy = abs(p_ptr->y - y);
4316 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4317 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4319 for (i = 1; i <= 9; i++)
4321 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;