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.
17 #include "object-hook.h"
18 #include "projection.h"
19 #include "spells-summon.h"
20 #include "spells-status.h"
21 #include "monster-status.h"
25 #include "player-status.h"
26 #include "realm-hex.h"
29 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
30 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
31 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
33 bool confirm_leave_level(bool down_stair)
35 quest_type *q_ptr = &quest[p_ptr->inside_quest];
37 /* Confirm leaving from once only quest */
38 if (confirm_quest && p_ptr->inside_quest &&
39 (q_ptr->type == QUEST_TYPE_RANDOM ||
40 (q_ptr->flags & QUEST_FLAG_ONCE &&
41 q_ptr->status != QUEST_STATUS_COMPLETED) ||
42 (q_ptr->flags & QUEST_FLAG_TOWER &&
43 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
44 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
46 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
47 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
57 * @brief 魔法系コマンドが制限されているかを返す。
58 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
60 bool cmd_limit_cast(player_type *creature_ptr)
62 if (dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
64 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
68 else if (creature_ptr->anti_magic)
70 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
73 else if (creature_ptr->shero)
75 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
82 bool cmd_limit_confused(player_type *creature_ptr)
84 if (creature_ptr->confused)
86 msg_print(_("混乱していてできない!", "You are too confused!"));
92 bool cmd_limit_arena(player_type *creature_ptr)
94 if (creature_ptr->inside_arena)
96 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
103 bool cmd_limit_blind(player_type *creature_ptr)
105 if (creature_ptr->blind)
107 msg_print(_("目が見えない。", "You can't see anything."));
112 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
118 bool cmd_limit_time_walk(player_type *creature_ptr)
120 if (creature_ptr->timewalk)
122 if (flush_failure) flush();
123 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
131 * @brief 階段を使って階層を昇る処理 / Go up one level
134 void do_cmd_go_up(void)
139 grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
140 feature_type *f_ptr = &f_info[g_ptr->feat];
144 if (p_ptr->special_defense & KATA_MUSOU)
146 set_action(ACTION_NONE);
150 if (!have_flag(f_ptr->flags, FF_LESS))
152 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
156 /* Quest up stairs */
157 if (have_flag(f_ptr->flags, FF_QUEST))
159 /* Cancel the command */
160 if (!confirm_leave_level(FALSE)) return;
164 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
165 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
167 msg_print(_("上の階に登った。", "You enter the up staircase."));
171 p_ptr->inside_quest = g_ptr->special;
173 /* Activate the quest */
174 if (!quest[p_ptr->inside_quest].status)
176 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
178 init_flags = INIT_ASSIGN;
179 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
181 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
184 /* Leaving a quest */
185 if (!p_ptr->inside_quest)
191 p_ptr->leaving = TRUE;
196 take_turn(p_ptr, 100);
198 /* End the command */
208 go_up = confirm_leave_level(FALSE);
211 /* Cancel the command */
214 take_turn(p_ptr, 100);
216 if (autosave_l) do_cmd_save_game(TRUE);
218 /* For a random quest */
219 if (p_ptr->inside_quest &&
220 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
224 p_ptr->inside_quest = 0;
227 /* For a fixed quest */
228 if (p_ptr->inside_quest &&
229 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
233 p_ptr->inside_quest = g_ptr->special;
238 /* For normal dungeon and random quest */
242 if (have_flag(f_ptr->flags, FF_SHAFT))
244 /* Create a way back */
245 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
251 /* Create a way back */
252 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
257 /* Get out from current dungeon */
258 if (dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
261 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
264 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
265 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
266 else if (up_num == dun_level)
267 msg_print(_("地上に戻った。", "You go back to the surface."));
269 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
272 p_ptr->leaving = TRUE;
277 * @brief 階段を使って階層を降りる処理 / Go down one level
280 void do_cmd_go_down(void)
283 grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
284 feature_type *f_ptr = &f_info[g_ptr->feat];
286 bool fall_trap = FALSE;
289 if (p_ptr->special_defense & KATA_MUSOU)
291 set_action(ACTION_NONE);
295 if (!have_flag(f_ptr->flags, FF_MORE))
297 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
301 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
304 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
309 /* Quest down stairs */
310 else if (have_flag(f_ptr->flags, FF_QUEST))
312 /* Confirm Leaving */
313 if(!confirm_leave_level(TRUE)) return;
315 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
316 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
318 msg_print(_("下の階に降りた。", "You enter the down staircase."));
323 p_ptr->inside_quest = g_ptr->special;
325 /* Activate the quest */
326 if (!quest[p_ptr->inside_quest].status)
328 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
330 init_flags = INIT_ASSIGN;
331 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
333 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
336 /* Leaving a quest */
337 if (!p_ptr->inside_quest)
343 p_ptr->leaving = TRUE;
347 take_turn(p_ptr, 100);
352 DUNGEON_IDX target_dungeon = 0;
356 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
358 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
360 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
363 if (!max_dlv[target_dungeon])
365 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
366 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
367 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
370 /* Save old player position */
371 p_ptr->oldpx = p_ptr->x;
372 p_ptr->oldpy = p_ptr->y;
373 p_ptr->dungeon_idx = target_dungeon;
376 * Clear all saved floors
377 * and create a first saved floor
379 prepare_change_floor_mode(CFM_FIRST_FLOOR);
382 take_turn(p_ptr, 100);
384 if (autosave_l) do_cmd_save_game(TRUE);
387 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
392 /* Enter the dungeon just now */
393 p_ptr->enter_dungeon = TRUE;
394 down_num = d_info[p_ptr->dungeon_idx].mindepth;
399 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
400 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
405 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
412 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
416 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
417 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
419 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
425 p_ptr->leaving = TRUE;
429 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
433 if (have_flag(f_ptr->flags, FF_SHAFT))
435 /* Create a way back */
436 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
440 /* Create a way back */
441 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
449 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
452 void do_cmd_search(void)
454 /* Allow repeated command */
457 /* Set repeat count */
458 command_rep = command_arg - 1;
459 p_ptr->redraw |= (PR_STATE);
464 take_turn(p_ptr, 100);;
472 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
473 * @param y 走査対象にしたいマスのY座標
474 * @param x 走査対象にしたいマスのX座標
475 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
476 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
478 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
480 grid_type *g_ptr = &grid_array[y][x];
481 OBJECT_IDX this_o_idx, next_o_idx = 0;
483 /* Scan all objects in the grid */
484 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
488 o_ptr = &o_list[this_o_idx];
489 next_o_idx = o_ptr->next_o_idx;
491 /* Skip unknown chests XXX XXX */
492 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
494 /* Check for non empty chest */
495 if ((o_ptr->tval == TV_CHEST) &&
496 (((!trapped) && (o_ptr->pval)) || /* non empty */
497 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
506 * @brief 箱を開けるコマンドのメインルーチン /
507 * Attempt to open the given chest at the given location
508 * @param y 箱の存在するマスのY座標
509 * @param x 箱の存在するマスのX座標
510 * @param o_idx 箱のオブジェクトID
511 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
513 * Assume there is no monster blocking the destination
515 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
520 object_type *o_ptr = &o_list[o_idx];
522 take_turn(p_ptr, 100);;
524 /* Attempt to unlock it */
527 /* Assume locked, and thus not open */
530 /* Get the "disarm" factor */
531 i = p_ptr->skill_dis;
533 /* Penalize some conditions */
534 if (p_ptr->blind || no_lite()) i = i / 10;
535 if (p_ptr->confused || p_ptr->image) i = i / 10;
537 /* Extract the difficulty */
540 /* Always have a small chance of success */
543 /* Success -- May still have traps */
544 if (randint0(100) < j)
546 msg_print(_("鍵をはずした。", "You have picked the lock."));
551 /* Failure -- Keep trying */
554 /* We may continue repeating */
556 if (flush_failure) flush();
557 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
562 /* Allowed to open */
565 /* Apply chest traps, if any */
566 chest_trap(y, x, o_idx);
568 /* Let the Chest drop items */
569 chest_death(FALSE, y, x, o_idx);
575 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
576 * Attempt to open the given chest at the given location
577 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
578 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
579 * @param test 地形条件を判定するための関数ポインタ
580 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
582 * @details Return the number of features around (or under) the character.
583 * Usually look for doors and floor traps.
585 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
591 /* Count how many matches */
594 /* Check around (and under) the character */
595 for (d = 0; d < 9; d++)
600 /* if not searching under player continue */
601 if ((d == 8) && !under) continue;
603 /* Extract adjacent (legal) location */
604 yy = p_ptr->y + ddy_ddd[d];
605 xx = p_ptr->x + ddx_ddd[d];
607 /* Get the grid_array */
608 g_ptr = &grid_array[yy][xx];
610 /* Must have knowledge */
611 if (!(g_ptr->info & (CAVE_MARK))) continue;
613 /* Feature code (applying "mimic" field) */
614 feat = get_feat_mimic(g_ptr);
616 /* Not looking for this feature */
617 if (!((*test)(feat))) continue;
622 /* Remember the location. Only useful if only one match */
633 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
634 * Return the number of chests around (or under) the character.
635 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
636 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
637 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
640 * If requested, count only trapped chests.
642 static int count_chests(POSITION *y, POSITION *x, bool trapped)
649 /* Count how many matches */
652 /* Check around (and under) the character */
653 for (d = 0; d < 9; d++)
655 /* Extract adjacent (legal) location */
656 POSITION yy = p_ptr->y + ddy_ddd[d];
657 POSITION xx = p_ptr->x + ddx_ddd[d];
659 /* No (visible) chest is there */
660 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
662 /* Grab the object */
663 o_ptr = &o_list[o_idx];
666 if (o_ptr->pval == 0) continue;
668 /* No (known) traps here */
669 if (trapped && (!object_is_known(o_ptr) ||
670 !chest_traps[o_ptr->pval])) continue;
675 /* Remember the location. Only useful if only one match */
686 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
687 * Convert an adjacent location to a direction.
688 * @param y 方角を確認したY座標
689 * @param x 方角を確認したX座標
692 static DIRECTION coords_to_dir(POSITION y, POSITION x)
694 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
701 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
703 return d[dx + 1][dy + 1];
707 * @brief 「開ける」動作コマンドのサブルーチン /
708 * Perform the basic "open" command on doors
709 * @param y 対象を行うマスのY座標
710 * @param x 対象を行うマスのX座標
711 * @return 実際に処理が行われた場合TRUEを返す。
713 * Assume destination is a closed/locked/jammed door
714 * Assume there is no monster blocking the destination
715 * Returns TRUE if repeated commands may continue
717 static bool do_cmd_open_aux(POSITION y, POSITION x)
721 /* Get requested grid */
722 grid_type *g_ptr = &grid_array[y][x];
723 feature_type *f_ptr = &f_info[g_ptr->feat];
726 take_turn(p_ptr, 100);;
728 /* Seeing true feature code (ignore mimic) */
731 if (!have_flag(f_ptr->flags, FF_OPEN))
734 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
738 else if (f_ptr->power)
741 i = p_ptr->skill_dis;
743 /* Penalize some conditions */
744 if (p_ptr->blind || no_lite()) i = i / 10;
745 if (p_ptr->confused || p_ptr->image) i = i / 10;
747 /* Extract the lock power */
750 /* Extract the difficulty */
753 /* Always have a small chance of success */
757 if (randint0(100) < j)
759 msg_print(_("鍵をはずした。", "You have picked the lock."));
762 cave_alter_feat(y, x, FF_OPEN);
764 sound(SOUND_OPENDOOR);
774 if (flush_failure) flush();
776 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
778 /* We may keep trying */
787 cave_alter_feat(y, x, FF_OPEN);
789 sound(SOUND_OPENDOOR);
795 * @brief 「開ける」コマンドのメインルーチン /
796 * Open a closed/locked/jammed door or a closed/locked chest.
799 * Unlocking a locked door/chest is worth one experience point.
801 void do_cmd_open(void)
809 if (p_ptr->wild_mode) return;
811 if (p_ptr->special_defense & KATA_MUSOU)
813 set_action(ACTION_NONE);
816 /* Option: Pick a direction */
819 int num_doors, num_chests;
821 /* Count closed doors (locked or jammed) */
822 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
824 /* Count chests (locked) */
825 num_chests = count_chests(&y, &x, FALSE);
827 /* See if only one target */
828 if (num_doors || num_chests)
830 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
832 if (!too_many) command_dir = coords_to_dir(y, x);
836 /* Allow repeated command */
839 /* Set repeat count */
840 command_rep = command_arg - 1;
841 p_ptr->redraw |= (PR_STATE);
847 /* Get a "repeated" direction */
848 if (get_rep_dir(&dir, TRUE))
853 /* Get requested location */
854 y = p_ptr->y + ddy[dir];
855 x = p_ptr->x + ddx[dir];
857 /* Get requested grid */
858 g_ptr = &grid_array[y][x];
860 /* Feature code (applying "mimic" field) */
861 feat = get_feat_mimic(g_ptr);
863 /* Check for chest */
864 o_idx = chest_check(y, x, FALSE);
867 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
869 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
872 /* Monster in the way */
873 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
875 take_turn(p_ptr, 100);;
876 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
884 more = do_cmd_open_chest(y, x, o_idx);
891 more = do_cmd_open_aux(y, x);
895 /* Cancel repeat unless we may continue */
896 if (!more) disturb(FALSE, FALSE);
902 * @brief 「閉じる」動作コマンドのサブルーチン /
903 * Perform the basic "close" command
904 * @param y 対象を行うマスのY座標
905 * @param x 対象を行うマスのX座標
906 * @return 実際に処理が行われた場合TRUEを返す。
908 * Assume destination is an open/broken door
909 * Assume there is no monster blocking the destination
910 * Returns TRUE if repeated commands may continue
912 static bool do_cmd_close_aux(POSITION y, POSITION x)
914 grid_type *g_ptr = &grid_array[y][x];
915 FEAT_IDX old_feat = g_ptr->feat;
918 take_turn(p_ptr, 100);;
920 /* Seeing true feature code (ignore mimic) */
923 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
925 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
927 /* Hack -- object in the way */
928 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
929 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
931 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
936 cave_alter_feat(y, x, FF_CLOSE);
939 if (old_feat == g_ptr->feat)
941 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
945 sound(SOUND_SHUTDOOR);
954 * @brief 「閉じる」コマンドのメインルーチン /
955 * Close an open door.
958 * Unlocking a locked door/chest is worth one experience point.
960 void do_cmd_close(void)
967 if (p_ptr->wild_mode) return;
969 if (p_ptr->special_defense & KATA_MUSOU)
971 set_action(ACTION_NONE);
974 /* Option: Pick a direction */
977 /* Count open doors */
978 if (count_dt(&y, &x, is_open, FALSE) == 1)
980 command_dir = coords_to_dir(y, x);
984 /* Allow repeated command */
987 /* Set repeat count */
988 command_rep = command_arg - 1;
989 p_ptr->redraw |= (PR_STATE);
995 /* Get a "repeated" direction */
996 if (get_rep_dir(&dir, FALSE))
1001 y = p_ptr->y + ddy[dir];
1002 x = p_ptr->x + ddx[dir];
1003 g_ptr = &grid_array[y][x];
1005 /* Feature code (applying "mimic" field) */
1006 feat = get_feat_mimic(g_ptr);
1008 /* Require open/broken door */
1009 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1011 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1014 /* Monster in the way */
1015 else if (g_ptr->m_idx)
1017 take_turn(p_ptr, 100);;
1019 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1025 /* Close the door */
1028 /* Close the door */
1029 more = do_cmd_close_aux(y, x);
1033 /* Cancel repeat unless we may continue */
1034 if (!more) disturb(FALSE, FALSE);
1039 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1040 * Determine if a given grid may be "tunneled"
1041 * @param y 対象を行うマスのY座標
1042 * @param x 対象を行うマスのX座標
1045 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1047 grid_type *g_ptr = &grid_array[y][x];
1049 /* Must have knowledge */
1050 if (!(g_ptr->info & CAVE_MARK))
1052 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1057 /* Must be a wall/door/etc */
1058 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1060 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1070 * @brief 「掘る」動作コマンドのサブルーチン /
1071 * Perform the basic "tunnel" command
1072 * @param y 対象を行うマスのY座標
1073 * @param x 対象を行うマスのX座標
1074 * @return 実際に処理が行われた場合TRUEを返す。
1076 * Assumes that no monster is blocking the destination
1077 * Do not use twall anymore
1078 * Returns TRUE if repeated commands may continue
1080 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1083 feature_type *f_ptr, *mimic_f_ptr;
1088 /* Verify legality */
1089 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1091 take_turn(p_ptr, 100);;
1093 g_ptr = &grid_array[y][x];
1094 f_ptr = &f_info[g_ptr->feat];
1095 power = f_ptr->power;
1097 /* Feature code (applying "mimic" field) */
1098 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1100 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))
1125 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1127 /* Remove the feature */
1128 cave_alter_feat(y, x, FF_TUNNEL);
1130 /* Update some things */
1131 p_ptr->update |= (PU_FLOW);
1135 /* Message, keep digging */
1136 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1144 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1147 if (p_ptr->skill_dig > power + randint0(40 * power))
1149 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1152 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1153 p_ptr->update |= (PU_FLOW);
1156 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1158 /* Remove the feature */
1159 cave_alter_feat(y, x, FF_TUNNEL);
1161 chg_virtue(V_DILIGENCE, 1);
1162 chg_virtue(V_NATURE, -1);
1170 /* We may continue chopping */
1171 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1172 /* Occasional Search XXX XXX */
1173 if (randint0(100) < 25) search();
1177 /* We may continue tunelling */
1178 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1185 if (is_hidden_door(g_ptr))
1187 /* Occasional Search XXX XXX */
1188 if (randint0(100) < 25) search();
1195 * @brief 「掘る」動作コマンドのメインルーチン /
1196 * Tunnels through "walls" (including rubble and closed doors)
1200 * Note that you must tunnel in order to hit invisible monsters
1201 * in walls, though moving into walls still takes a turn anyway.
1203 * Digging is very difficult without a "digger" weapon, but can be
1204 * accomplished by strong players using heavy weapons.
1207 void do_cmd_tunnel(void)
1216 if (p_ptr->special_defense & KATA_MUSOU)
1218 set_action(ACTION_NONE);
1221 /* Allow repeated command */
1224 /* Set repeat count */
1225 command_rep = command_arg - 1;
1226 p_ptr->redraw |= (PR_STATE);
1228 /* Cancel the arg */
1232 /* Get a direction to tunnel, or Abort */
1233 if (get_rep_dir(&dir,FALSE))
1236 y = p_ptr->y + ddy[dir];
1237 x = p_ptr->x + ddx[dir];
1239 g_ptr = &grid_array[y][x];
1241 /* Feature code (applying "mimic" field) */
1242 feat = get_feat_mimic(g_ptr);
1244 /* No tunnelling through doors */
1245 if (have_flag(f_info[feat].flags, FF_DOOR))
1247 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1250 /* No tunnelling through most features */
1251 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1253 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1256 /* A monster is in the way */
1257 else if (g_ptr->m_idx)
1259 take_turn(p_ptr, 100);;
1261 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1270 /* Tunnel through walls */
1271 more = do_cmd_tunnel_aux(y, x);
1275 /* Cancel repetition unless we can continue */
1276 if (!more) disturb(FALSE, FALSE);
1280 * @brief 移動処理による簡易な「開く」処理 /
1282 * @return 開く処理が実際に試みられた場合TRUEを返す
1285 * If there is a jammed/closed/locked door at the given location,
1286 * then attempt to unlock/open it. Return TRUE if an attempt was
1287 * made (successful or not), otherwise return FALSE.
1289 * The code here should be nearly identical to that in
1290 * do_cmd_open_test() and do_cmd_open_aux().
1293 bool easy_open_door(POSITION y, POSITION x)
1297 grid_type *g_ptr = &grid_array[y][x];
1298 feature_type *f_ptr = &f_info[g_ptr->feat];
1300 /* Must be a closed door */
1301 if (!is_closed_door(g_ptr->feat))
1307 if (!have_flag(f_ptr->flags, FF_OPEN))
1310 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1315 else if (f_ptr->power)
1318 i = p_ptr->skill_dis;
1320 /* Penalize some conditions */
1321 if (p_ptr->blind || no_lite()) i = i / 10;
1322 if (p_ptr->confused || p_ptr->image) i = i / 10;
1324 /* Extract the lock power */
1327 /* Extract the difficulty */
1330 /* Always have a small chance of success */
1334 if (randint0(100) < j)
1336 msg_print(_("鍵をはずした。", "You have picked the lock."));
1339 cave_alter_feat(y, x, FF_OPEN);
1341 sound(SOUND_OPENDOOR);
1351 if (flush_failure) flush();
1353 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1362 cave_alter_feat(y, x, FF_OPEN);
1364 sound(SOUND_OPENDOOR);
1370 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1371 * Perform the basic "disarm" command
1372 * @param y 解除を行うマスのY座標
1373 * @param x 解除を行うマスのX座標
1374 * @param o_idx 箱のオブジェクトID
1375 * @return ターンを消費する処理が行われた場合TRUEを返す
1378 * Assume destination is a visible trap
1379 * Assume there is no monster blocking the destination
1380 * Returns TRUE if repeated commands may continue
1383 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1387 object_type *o_ptr = &o_list[o_idx];
1389 take_turn(p_ptr, 100);;
1391 /* Get the "disarm" factor */
1392 i = p_ptr->skill_dis;
1394 /* Penalize some conditions */
1395 if (p_ptr->blind || no_lite()) i = i / 10;
1396 if (p_ptr->confused || p_ptr->image) i = i / 10;
1398 /* Extract the difficulty */
1399 j = i - o_ptr->pval;
1401 /* Always have a small chance of success */
1404 /* Must find the trap first. */
1405 if (!object_is_known(o_ptr))
1407 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1411 /* Already disarmed/unlocked */
1412 else if (o_ptr->pval <= 0)
1414 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1417 /* No traps to find. */
1418 else if (!chest_traps[o_ptr->pval])
1420 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1423 /* Success (get a lot of experience) */
1424 else if (randint0(100) < j)
1426 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1427 gain_exp(o_ptr->pval);
1428 o_ptr->pval = (0 - o_ptr->pval);
1431 /* Failure -- Keep trying */
1432 else if ((i > 5) && (randint1(i) > 5))
1434 /* We may keep trying */
1436 if (flush_failure) flush();
1437 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1440 /* Failure -- Set off the trap */
1443 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1445 chest_trap(y, x, o_idx);
1452 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1453 * Perform the basic "disarm" command
1454 * @param y 解除を行うマスのY座標
1455 * @param x 解除を行うマスのX座標
1456 * @param dir プレイヤーからみた方向ID
1457 * @return ターンを消費する処理が行われた場合TRUEを返す
1460 * Assume destination is a visible trap
1461 * Assume there is no monster blocking the destination
1462 * Returns TRUE if repeated commands may continue
1466 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1468 grid_type *g_ptr = &grid_array[y][x];
1471 feature_type *f_ptr = &f_info[g_ptr->feat];
1473 /* Access trap name */
1474 concptr name = (f_name + f_ptr->name);
1476 /* Extract trap "power" */
1477 int power = f_ptr->power;
1480 /* Get the "disarm" factor */
1481 int i = p_ptr->skill_dis;
1484 take_turn(p_ptr, 100);;
1486 /* Penalize some conditions */
1487 if (p_ptr->blind || no_lite()) i = i / 10;
1488 if (p_ptr->confused || p_ptr->image) i = i / 10;
1490 /* Extract the difficulty */
1493 /* Always have a small chance of success */
1497 if (randint0(100) < j)
1499 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1504 /* Remove the trap */
1505 cave_alter_feat(y, x, FF_DISARM);
1507 /* Move the player onto the trap */
1508 move_player(dir, easy_disarm, FALSE);
1511 /* Failure -- Keep trying */
1512 else if ((i > 5) && (randint1(i) > 5))
1515 if (flush_failure) flush();
1517 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1519 /* We may keep trying */
1523 /* Failure -- Set off the trap */
1526 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1527 /* Move the player onto the trap */
1528 move_player(dir, easy_disarm, FALSE);
1535 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1536 * Disarms a trap, or chest
1539 void do_cmd_disarm(void)
1547 if (p_ptr->wild_mode) return;
1549 if (p_ptr->special_defense & KATA_MUSOU)
1551 set_action(ACTION_NONE);
1554 /* Option: Pick a direction */
1557 int num_traps, num_chests;
1559 /* Count visible traps */
1560 num_traps = count_dt(&y, &x, is_trap, TRUE);
1562 /* Count chests (trapped) */
1563 num_chests = count_chests(&y, &x, TRUE);
1565 /* See if only one target */
1566 if (num_traps || num_chests)
1568 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1569 if (!too_many) command_dir = coords_to_dir(y, x);
1574 /* Allow repeated command */
1577 /* Set repeat count */
1578 command_rep = command_arg - 1;
1579 p_ptr->redraw |= (PR_STATE);
1581 /* Cancel the arg */
1585 /* Get a direction (or abort) */
1586 if (get_rep_dir(&dir,TRUE))
1591 y = p_ptr->y + ddy[dir];
1592 x = p_ptr->x + ddx[dir];
1593 g_ptr = &grid_array[y][x];
1595 /* Feature code (applying "mimic" field) */
1596 feat = get_feat_mimic(g_ptr);
1598 /* Check for chests */
1599 o_idx = chest_check(y, x, TRUE);
1602 if (!is_trap(feat) && !o_idx)
1604 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1607 /* Monster in the way */
1608 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1610 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1619 more = do_cmd_disarm_chest(y, x, o_idx);
1625 more = do_cmd_disarm_aux(y, x, dir);
1629 /* Cancel repeat unless told not to */
1630 if (!more) disturb(FALSE, FALSE);
1635 * @brief 「打ち破る」動作コマンドのサブルーチン /
1636 * Perform the basic "bash" command
1637 * @param y 対象を行うマスのY座標
1638 * @param x 対象を行うマスのX座標
1639 * @param dir プレイヤーから見たターゲットの方角ID
1640 * @return 実際に処理が行われた場合TRUEを返す。
1643 * Assume destination is a closed/locked/jammed door
1644 * Assume there is no monster blocking the destination
1645 * Returns TRUE if repeated commands may continue
1648 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1650 grid_type *g_ptr = &grid_array[y][x];
1653 feature_type *f_ptr = &f_info[g_ptr->feat];
1655 /* Hack -- Bash power based on strength */
1656 /* (Ranges from 3 to 20 to 100 to 200) */
1657 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1659 /* Extract door power */
1660 int temp = f_ptr->power;
1664 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1666 take_turn(p_ptr, 100);;
1668 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1670 /* Compare bash power to door power */
1671 temp = (bash - (temp * 10));
1673 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1675 /* Hack -- always have a chance */
1676 if (temp < 1) temp = 1;
1678 /* Hack -- attempt to bash down the door */
1679 if (randint0(100) < temp)
1681 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1683 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1685 /* Break down the door */
1686 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1688 cave_alter_feat(y, x, FF_BASH);
1694 cave_alter_feat(y, x, FF_OPEN);
1697 /* Hack -- Fall through the door */
1698 move_player(dir, FALSE, FALSE);
1701 /* Saving throw against stun */
1702 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1705 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1707 /* Allow repeated bashing */
1711 /* High dexterity yields coolness */
1714 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1716 /* Hack -- Lose balance ala paralysis */
1717 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1724 * @brief 「打ち破る」動作コマンドのメインルーチン /
1725 * Bash open a door, success based on character strength
1729 * For a closed door, pval is positive if locked; negative if stuck.
1731 * For an open door, pval is positive for a broken door.
1733 * A closed door can be opened - harder if locked. Any door might be
1734 * bashed open (and thereby broken). Bashing a door is (potentially)
1735 * faster! You move into the door way. To open a stuck door, it must
1736 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1738 * Creatures can also open or bash doors, see elsewhere.
1741 void do_cmd_bash(void)
1747 if (p_ptr->wild_mode) return;
1749 if (p_ptr->special_defense & KATA_MUSOU)
1751 set_action(ACTION_NONE);
1754 /* Allow repeated command */
1757 /* Set repeat count */
1758 command_rep = command_arg - 1;
1759 p_ptr->redraw |= (PR_STATE);
1761 /* Cancel the arg */
1765 /* Get a "repeated" direction */
1766 if (get_rep_dir(&dir,FALSE))
1771 y = p_ptr->y + ddy[dir];
1772 x = p_ptr->x + ddx[dir];
1774 g_ptr = &grid_array[y][x];
1776 /* Feature code (applying "mimic" field) */
1777 feat = get_feat_mimic(g_ptr);
1779 /* Nothing useful */
1780 if (!have_flag(f_info[feat].flags, FF_BASH))
1782 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1785 /* Monster in the way */
1786 else if (g_ptr->m_idx)
1788 take_turn(p_ptr, 100);;
1790 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1796 /* Bash a closed door */
1800 more = do_cmd_bash_aux(y, x, dir);
1804 /* Unless valid action taken, cancel bash */
1805 if (!more) disturb(FALSE, FALSE);
1810 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1814 * Manipulate an adjacent grid in some way
1816 * Attack monsters, tunnel through walls, disarm traps, open doors.
1818 * Consider confusion
1820 * This command must always take a turn, to prevent free detection
1821 * of invisible monsters.
1824 void do_cmd_alter(void)
1831 if (p_ptr->special_defense & KATA_MUSOU)
1833 set_action(ACTION_NONE);
1836 /* Allow repeated command */
1839 /* Set repeat count */
1840 command_rep = command_arg - 1;
1841 p_ptr->redraw |= (PR_STATE);
1843 /* Cancel the arg */
1847 /* Get a direction */
1848 if (get_rep_dir(&dir,TRUE))
1851 feature_type *f_ptr;
1853 y = p_ptr->y + ddy[dir];
1854 x = p_ptr->x + ddx[dir];
1856 g_ptr = &grid_array[y][x];
1858 /* Feature code (applying "mimic" field) */
1859 feat = get_feat_mimic(g_ptr);
1860 f_ptr = &f_info[feat];
1862 take_turn(p_ptr, 100);;
1870 else if (have_flag(f_ptr->flags, FF_OPEN))
1872 more = do_cmd_open_aux(y, x);
1875 /* Bash jammed doors */
1876 else if (have_flag(f_ptr->flags, FF_BASH))
1878 more = do_cmd_bash_aux(y, x, dir);
1881 /* Tunnel through walls */
1882 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1884 more = do_cmd_tunnel_aux(y, x);
1887 /* Close open doors */
1888 else if (have_flag(f_ptr->flags, FF_CLOSE))
1890 more = do_cmd_close_aux(y, x);
1894 else if (have_flag(f_ptr->flags, FF_DISARM))
1896 more = do_cmd_disarm_aux(y, x, dir);
1901 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1905 /* Cancel repetition unless we can continue */
1906 if (!more) disturb(FALSE, FALSE);
1912 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1913 * Find the index of some "spikes", if possible.
1914 * @param ip くさびとして打てるオブジェクトのID
1915 * @return オブジェクトがある場合TRUEを返す
1918 * Let user choose a pile of spikes, perhaps?
1921 static bool get_spike(INVENTORY_IDX *ip)
1925 /* Check every item in the pack */
1926 for (i = 0; i < INVEN_PACK; i++)
1928 object_type *o_ptr = &inventory[i];
1930 /* Skip non-objects */
1931 if (!o_ptr->k_idx) continue;
1933 /* Check the "tval" code */
1934 if (o_ptr->tval == TV_SPIKE)
1936 /* Save the spike index */
1949 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1950 * Jam a closed door with a spike
1954 * This command may NOT be repeated
1957 void do_cmd_spike(void)
1961 if (p_ptr->wild_mode) return;
1963 if (p_ptr->special_defense & KATA_MUSOU)
1965 set_action(ACTION_NONE);
1968 /* Get a "repeated" direction */
1969 if (get_rep_dir(&dir, FALSE))
1976 y = p_ptr->y + ddy[dir];
1977 x = p_ptr->x + ddx[dir];
1978 g_ptr = &grid_array[y][x];
1980 /* Feature code (applying "mimic" field) */
1981 feat = get_feat_mimic(g_ptr);
1983 /* Require closed door */
1984 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1986 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1990 else if (!get_spike(&item))
1992 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1995 /* Is a monster in the way? */
1996 else if (g_ptr->m_idx)
1998 take_turn(p_ptr, 100);;
2000 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2009 take_turn(p_ptr, 100);;
2011 /* Successful jamming */
2012 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2013 cave_alter_feat(y, x, FF_SPIKE);
2015 /* Use up, and describe, a single spike, from the bottom */
2016 inven_item_increase(item, -1);
2017 inven_item_describe(item);
2018 inven_item_optimize(item);
2026 * @brief 「歩く」動作コマンドのメインルーチン /
2027 * Support code for the "Walk" and "Jump" commands
2028 * @param pickup アイテムの自動拾いを行うならTRUE
2031 void do_cmd_walk(bool pickup)
2038 /* Allow repeated command */
2041 /* Set repeat count */
2042 command_rep = command_arg - 1;
2043 p_ptr->redraw |= (PR_STATE);
2045 /* Cancel the arg */
2049 /* Get a "repeated" direction */
2050 if (get_rep_dir(&dir, FALSE))
2052 take_turn(p_ptr, 100);;
2054 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2056 set_action(ACTION_NONE);
2059 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2060 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2061 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2063 /* Actually move the character */
2064 move_player(dir, pickup, FALSE);
2066 /* Allow more walking */
2070 /* Hack again -- Is there a special encounter ??? */
2071 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2073 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2076 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2078 /* Inform the player of his horrible fate :=) */
2079 msg_print(_("襲撃だ!", "You are ambushed !"));
2081 /* Go into large wilderness view */
2082 p_ptr->oldpy = randint1(MAX_HGT-2);
2083 p_ptr->oldpx = randint1(MAX_WID-2);
2086 /* Give first move to monsters */
2087 take_turn(p_ptr, 100);
2089 /* HACk -- set the encouter flag for the wilderness generation */
2090 generate_encounter = TRUE;
2094 /* Cancel repeat unless we may continue */
2095 if (!more) disturb(FALSE, FALSE);
2100 * @brief 「走る」動作コマンドのメインルーチン /
2104 void do_cmd_run(void)
2107 if (cmd_limit_confused(p_ptr)) return;
2109 if (p_ptr->special_defense & KATA_MUSOU)
2111 set_action(ACTION_NONE);
2114 /* Get a "repeated" direction */
2115 if (get_rep_dir(&dir,FALSE))
2117 /* Hack -- Set the run counter */
2118 running = (command_arg ? command_arg : 1000);
2127 * @brief 「留まる」動作コマンドのメインルーチン /
2128 * Stay still. Search. Enter stores.
2129 * Pick up treasure if "pickup" is true.
2130 * @param pickup アイテムの自動拾いを行うならTRUE
2133 void do_cmd_stay(bool pickup)
2135 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2137 /* Allow repeated command */
2140 /* Set repeat count */
2141 command_rep = command_arg - 1;
2142 p_ptr->redraw |= (PR_STATE);
2144 /* Cancel the arg */
2148 take_turn(p_ptr, 100);;
2150 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2151 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2156 * @brief 「休む」動作コマンドのメインルーチン /
2157 * Resting allows a player to safely restore his hp -RAK-
2160 void do_cmd_rest(void)
2163 set_action(ACTION_NONE);
2165 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2167 stop_singing(p_ptr);
2171 if (hex_spelling_any()) stop_hex_spell_all();
2173 /* Prompt for time if needed */
2174 if (command_arg <= 0)
2176 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2177 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2183 strcpy(out_val, "&");
2185 /* Ask for duration */
2186 if (!get_string(p, out_val, 4)) return;
2188 /* Rest until done */
2189 if (out_val[0] == '&')
2191 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2195 else if (out_val[0] == '*')
2197 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2203 command_arg = (COMMAND_ARG)atoi(out_val);
2204 if (command_arg <= 0) return;
2210 if (command_arg > 9999) command_arg = 9999;
2212 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2214 /* Take a turn (?) */
2215 take_turn(p_ptr, 100);;
2217 /* The sin of sloth */
2218 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2220 /* Why are you sleeping when there's no need? WAKE UP!*/
2221 if ((p_ptr->chp == p_ptr->mhp) &&
2222 (p_ptr->csp == p_ptr->msp) &&
2223 !p_ptr->blind && !p_ptr->confused &&
2224 !p_ptr->poisoned && !p_ptr->afraid &&
2225 !p_ptr->stun && !p_ptr->cut &&
2226 !p_ptr->slow && !p_ptr->paralyzed &&
2227 !p_ptr->image && !p_ptr->word_recall &&
2228 !p_ptr->alter_reality)
2229 chg_virtue(V_DILIGENCE, -1);
2231 /* Save the rest code */
2232 resting = command_arg;
2233 p_ptr->action = ACTION_REST;
2234 p_ptr->update |= (PU_BONUS);
2235 update_creature(p_ptr);
2237 p_ptr->redraw |= (PR_STATE);
2246 * @brief 射撃処理のメインルーチン
2249 void do_cmd_fire(void)
2252 object_type *j_ptr, *ammo_ptr;
2255 if(p_ptr->wild_mode) return;
2257 is_fired = FALSE; /* not fired yet */
2259 /* Get the "bow" (if any) */
2260 j_ptr = &inventory[INVEN_BOW];
2262 /* Require a launcher */
2265 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2270 if (j_ptr->sval == SV_CRIMSON)
2272 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2277 if (j_ptr->sval == SV_HARP)
2279 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2285 if (p_ptr->special_defense & KATA_MUSOU)
2287 set_action(ACTION_NONE);
2290 /* Require proper missile */
2291 item_tester_tval = p_ptr->tval_ammo;
2293 q = _("どれを撃ちますか? ", "Fire which item? ");
2294 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2297 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2305 exe_fire(item, j_ptr);
2307 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2309 /* Sniper actions after some shootings */
2310 if (snipe_type == SP_AWAY)
2312 teleport_player(10 + (p_ptr->concent * 2), 0L);
2314 if (snipe_type == SP_FINAL)
2316 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2317 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2318 (void)set_stun(p_ptr->stun + randint1(25));
2324 * @brief 投射処理メインルーチン /
2325 * Throw an object from the pack or floor.
2327 * @param boomerang ブーメラン処理ならばTRUE
2328 * @param shuriken 忍者の手裏剣処理ならばTRUE
2329 * @return ターンを消費した場合TRUEを返す
2332 * Note: "unseen" monsters are very hard to hit.
2334 * Should throwing a weapon do full damage? Should it allow the magic
2335 * to hit bonus of the weapon to have an effect? Should it ever cause
2336 * the item to be destroyed? Should it do any damage at all?
2339 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2344 POSITION y, x, ty, tx, prev_y, prev_x;
2345 POSITION ny[19], nx[19];
2346 int chance, tdam, tdis;
2347 int mul, div, dd, ds;
2348 int cur_dis, visible;
2355 bool hit_body = FALSE;
2356 bool hit_wall = FALSE;
2357 bool equiped_item = FALSE;
2358 bool return_when_thrown = FALSE;
2360 GAME_TEXT o_name[MAX_NLEN];
2362 int msec = delay_factor * delay_factor * delay_factor;
2364 BIT_FLAGS flgs[TR_FLAG_SIZE];
2366 bool come_back = FALSE;
2367 bool do_drop = TRUE;
2369 if (p_ptr->wild_mode) return FALSE;
2371 if (p_ptr->special_defense & KATA_MUSOU)
2373 set_action(ACTION_NONE);
2379 o_ptr = &inventory[item];
2383 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2385 item_tester_hook = item_tester_hook_boomerang;
2386 q = _("どの武器を投げますか? ", "Throw which item? ");
2387 s = _("投げる武器がない。", "You have nothing to throw.");
2388 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2395 else if (has_melee_weapon(INVEN_LARM))
2398 o_ptr = &inventory[item];
2403 o_ptr = &inventory[item];
2408 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2409 s = _("投げるアイテムがない。", "You have nothing to throw.");
2410 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2418 /* Item is cursed */
2419 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2421 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2425 if (p_ptr->inside_arena && !boomerang)
2427 if (o_ptr->tval != TV_SPIKE)
2429 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2438 /* Obtain a local object */
2439 object_copy(q_ptr, o_ptr);
2441 /* Extract the thrown object's flags. */
2442 object_flags(q_ptr, flgs);
2443 torch_flags(q_ptr, flgs);
2445 /* Distribute the charges of rods/wands between the stacks */
2446 distribute_charges(o_ptr, q_ptr, 1);
2451 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2453 if (p_ptr->mighty_throw) mult += 3;
2455 /* Extract a "distance multiplier" */
2456 /* Changed for 'launcher' mutation */
2457 mul = 10 + 2 * (mult - 1);
2459 /* Enforce a minimum "weight" of one pound */
2460 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2461 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2463 /* Hack -- Distance -- Reward strength, penalize weight */
2464 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2466 /* Max distance of 10-18 */
2467 if (tdis > mul) tdis = mul;
2471 ty = randint0(101) - 50 + p_ptr->y;
2472 tx = randint0(101) - 50 + p_ptr->x;
2476 project_length = tdis + 1;
2478 /* Get a direction (or cancel) */
2479 if (!get_aim_dir(&dir)) return FALSE;
2481 /* Predict the "target" location */
2482 tx = p_ptr->x + 99 * ddx[dir];
2483 ty = p_ptr->y + 99 * ddy[dir];
2485 /* Check for "target request" */
2486 if ((dir == 5) && target_okay())
2492 project_length = 0; /* reset to default */
2495 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2496 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2497 return_when_thrown = TRUE;
2499 /* Reduce and describe inventory */
2502 inven_item_increase(item, -1);
2503 if (!return_when_thrown)
2504 inven_item_describe(item);
2505 inven_item_optimize(item);
2508 /* Reduce and describe floor item */
2511 floor_item_increase(0 - item, -1);
2512 floor_item_optimize(0 - item);
2514 if (item >= INVEN_RARM)
2516 equiped_item = TRUE;
2517 p_ptr->redraw |= (PR_EQUIPPY);
2520 take_turn(p_ptr, 100);;
2522 /* Rogue and Ninja gets bonus */
2523 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2524 p_ptr->energy_use -= p_ptr->lev;
2526 /* Start at the player */
2532 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2533 else shuriken = FALSE;
2535 /* Chance of hitting */
2536 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2537 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2538 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2540 if (shuriken) chance *= 2;
2545 /* Travel until stopped */
2546 for (cur_dis = 0; cur_dis <= tdis; )
2548 /* Hack -- Stop at the target */
2549 if ((y == ty) && (x == tx)) break;
2551 /* Calculate the new location (see "project()") */
2554 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2556 /* Stopped by walls/doors */
2557 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2560 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2563 /* The player can see the (on screen) missile */
2564 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2566 SYMBOL_CODE c = object_char(q_ptr);
2567 TERM_COLOR a = object_attr(q_ptr);
2569 /* Draw, Hilite, Fresh, Pause, Erase */
2570 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2571 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2573 Term_xtra(TERM_XTRA_DELAY, msec);
2574 lite_spot(ny[cur_dis], nx[cur_dis]);
2578 /* The player cannot see the missile */
2581 /* Pause anyway, for consistancy */
2582 Term_xtra(TERM_XTRA_DELAY, msec);
2588 /* Save the new location */
2592 /* Advance the distance */
2595 /* Monster here, Try to hit it */
2596 if (grid_array[y][x].m_idx)
2598 grid_type *g_ptr = &grid_array[y][x];
2599 monster_type *m_ptr = &m_list[g_ptr->m_idx];
2601 /* Check the visibility */
2602 visible = m_ptr->ml;
2604 /* Note the collision */
2607 /* Did we hit it (penalize range) */
2608 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2612 /* Handle unseen monster */
2615 /* Invisible monster */
2616 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2619 /* Handle visible monster */
2622 GAME_TEXT m_name[MAX_NLEN];
2623 monster_desc(m_name, m_ptr, 0);
2624 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2628 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2629 health_track(g_ptr->m_idx);
2633 /* Hack -- Base damage from thrown object */
2636 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2637 tdam = damroll(dd, ds);
2638 /* Apply special damage */
2639 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2640 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2641 if (q_ptr->to_d > 0)
2642 tdam += q_ptr->to_d;
2644 tdam += -q_ptr->to_d;
2648 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2649 tdam += p_ptr->to_d_m;
2651 else if (have_flag(flgs, TR_THROW))
2654 tdam += p_ptr->to_d_m;
2662 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2665 /* No negative damage */
2666 if (tdam < 0) tdam = 0;
2668 /* Modify the damage */
2669 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2671 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2672 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2674 /* Hit the monster, check for death */
2675 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2683 message_pain(g_ptr->m_idx, tdam);
2685 /* Anger the monster */
2686 if ((tdam > 0) && !object_is_potion(q_ptr))
2687 anger_monster(m_ptr);
2689 if (fear && m_ptr->ml)
2692 GAME_TEXT m_name[MAX_NLEN];
2693 monster_desc(m_name, m_ptr, 0);
2694 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2704 /* decrease toach's fuel */
2705 if (hit_body) torch_lost_fuel(q_ptr);
2707 /* Chance of breakage (during attacks) */
2708 j = (hit_body ? breakage_chance(q_ptr) : 0);
2710 /* Figurines transform */
2711 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2715 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2716 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2717 else if (object_is_cursed(q_ptr))
2718 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2723 /* Potions smash open */
2724 if (object_is_potion(q_ptr))
2726 if (hit_body || hit_wall || (randint1(100) < j))
2728 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2730 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2732 monster_type *m_ptr = &m_list[grid_array[y][x].m_idx];
2734 /* ToDo (Robert): fix the invulnerability */
2735 if (grid_array[y][x].m_idx &&
2736 is_friendly(&m_list[grid_array[y][x].m_idx]) &&
2737 !MON_INVULNER(m_ptr))
2739 GAME_TEXT m_name[MAX_NLEN];
2740 monster_desc(m_name, &m_list[grid_array[y][x].m_idx], 0);
2741 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2742 set_hostile(&m_list[grid_array[y][x].m_idx]);
2753 if (return_when_thrown)
2755 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2756 char o2_name[MAX_NLEN];
2757 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2760 if (boomerang) back_chance += 4+randint1(5);
2761 if (super_boomerang) back_chance += 100;
2762 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2764 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2766 for (i = cur_dis - 1; i > 0; i--)
2768 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2770 char c = object_char(q_ptr);
2771 byte a = object_attr(q_ptr);
2773 /* Draw, Hilite, Fresh, Pause, Erase */
2774 print_rel(c, a, ny[i], nx[i]);
2775 move_cursor_relative(ny[i], nx[i]);
2777 Term_xtra(TERM_XTRA_DELAY, msec);
2778 lite_spot(ny[i], nx[i]);
2783 /* Pause anyway, for consistancy */
2784 Term_xtra(TERM_XTRA_DELAY, msec);
2787 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2789 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2796 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2800 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2808 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2814 if (item == INVEN_RARM || item == INVEN_LARM)
2816 /* Access the wield slot */
2817 o_ptr = &inventory[item];
2819 /* Wear the new stuff */
2820 object_copy(o_ptr, q_ptr);
2822 p_ptr->total_weight += q_ptr->weight;
2824 /* Increment the equip counter by hand */
2827 /* Recalculate torch */
2828 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2829 p_ptr->window |= (PW_EQUIP);
2837 else if (equiped_item)
2845 if (cave_have_flag_bold(y, x, FF_PROJECT))
2847 (void)drop_near(q_ptr, j, y, x);
2851 (void)drop_near(q_ptr, j, prev_y, prev_x);