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.
21 #include "object-hook.h"
23 #include "spells-summon.h"
24 #include "spells-status.h"
26 #include "monster-status.h"
30 #include "player-status.h"
31 #include "realm-hex.h"
36 #include "player-move.h"
37 #include "player-effects.h"
38 #include "objectkind.h"
39 #include "object-broken.h"
40 #include "object-flavor.h"
43 #include "cmd-basic.h"
44 #include "floor-save.h"
45 #include "dungeon-file.h"
48 #include "view-mainwindow.h"
51 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
52 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
53 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
55 static bool confirm_leave_level(bool down_stair)
57 quest_type *q_ptr = &quest[p_ptr->inside_quest];
59 /* Confirm leaving from once only quest */
60 if (confirm_quest && p_ptr->inside_quest &&
61 (q_ptr->type == QUEST_TYPE_RANDOM ||
62 (q_ptr->flags & QUEST_FLAG_ONCE &&
63 q_ptr->status != QUEST_STATUS_COMPLETED) ||
64 (q_ptr->flags & QUEST_FLAG_TOWER &&
65 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
66 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
68 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
69 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
79 * @brief 魔法系コマンドが制限されているかを返す。
80 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
82 bool cmd_limit_cast(player_type *creature_ptr)
84 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
86 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
90 else if (creature_ptr->anti_magic)
92 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
95 else if (creature_ptr->shero)
97 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
104 bool cmd_limit_confused(player_type *creature_ptr)
106 if (creature_ptr->confused)
108 msg_print(_("混乱していてできない!", "You are too confused!"));
114 bool cmd_limit_image(player_type *creature_ptr)
116 if (creature_ptr->image)
118 msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
124 bool cmd_limit_stun(player_type *creature_ptr)
126 if (creature_ptr->stun)
128 msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
134 bool cmd_limit_arena(player_type *creature_ptr)
136 if (creature_ptr->inside_arena)
138 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
145 bool cmd_limit_blind(player_type *creature_ptr)
147 if (creature_ptr->blind)
149 msg_print(_("目が見えない。", "You can't see anything."));
154 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
160 bool cmd_limit_time_walk(player_type *creature_ptr)
162 if (creature_ptr->timewalk)
164 if (flush_failure) flush();
165 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
173 * @brief 階段を使って階層を昇る処理 / Go up one level
176 void do_cmd_go_up(void)
181 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
182 feature_type *f_ptr = &f_info[g_ptr->feat];
186 if (p_ptr->special_defense & KATA_MUSOU)
188 set_action(ACTION_NONE);
192 if (!have_flag(f_ptr->flags, FF_LESS))
194 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
198 /* Quest up stairs */
199 if (have_flag(f_ptr->flags, FF_QUEST))
201 /* Cancel the command */
202 if (!confirm_leave_level(FALSE)) return;
206 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
207 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
209 msg_print(_("上の階に登った。", "You enter the up staircase."));
213 p_ptr->inside_quest = g_ptr->special;
215 /* Activate the quest */
216 if (!quest[p_ptr->inside_quest].status)
218 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
220 init_flags = INIT_ASSIGN;
221 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
223 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
226 /* Leaving a quest */
227 if (!p_ptr->inside_quest)
229 current_floor_ptr->dun_level = 0;
231 p_ptr->leaving = TRUE;
236 take_turn(p_ptr, 100);
238 /* End the command */
242 if (!current_floor_ptr->dun_level)
248 go_up = confirm_leave_level(FALSE);
251 /* Cancel the command */
254 take_turn(p_ptr, 100);
256 if (autosave_l) do_cmd_save_game(TRUE);
258 /* For a random quest */
259 if (p_ptr->inside_quest &&
260 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
264 p_ptr->inside_quest = 0;
267 /* For a fixed quest */
268 if (p_ptr->inside_quest &&
269 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
273 p_ptr->inside_quest = g_ptr->special;
274 current_floor_ptr->dun_level = 0;
278 /* For normal dungeon and random quest */
282 if (have_flag(f_ptr->flags, FF_SHAFT))
284 /* Create a way back */
285 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
291 /* Create a way back */
292 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
297 /* Get out from current dungeon */
298 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
299 up_num = current_floor_ptr->dun_level;
301 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
304 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
305 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
306 else if (up_num == current_floor_ptr->dun_level)
307 msg_print(_("地上に戻った。", "You go back to the surface."));
309 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
310 p_ptr->leaving = TRUE;
315 * @brief 階段を使って階層を降りる処理 / Go down one level
318 void do_cmd_go_down(void)
321 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
322 feature_type *f_ptr = &f_info[g_ptr->feat];
324 bool fall_trap = FALSE;
327 if (p_ptr->special_defense & KATA_MUSOU)
329 set_action(ACTION_NONE);
333 if (!have_flag(f_ptr->flags, FF_MORE))
335 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
339 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
342 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
347 /* Quest down stairs */
348 else if (have_flag(f_ptr->flags, FF_QUEST))
350 /* Confirm Leaving */
351 if(!confirm_leave_level(TRUE)) return;
353 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
354 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
356 msg_print(_("下の階に降りた。", "You enter the down staircase."));
361 p_ptr->inside_quest = g_ptr->special;
363 /* Activate the quest */
364 if (!quest[p_ptr->inside_quest].status)
366 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
368 init_flags = INIT_ASSIGN;
369 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
371 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
374 /* Leaving a quest */
375 if (!p_ptr->inside_quest)
377 current_floor_ptr->dun_level = 0;
379 p_ptr->leaving = TRUE;
383 take_turn(p_ptr, 100);
388 DUNGEON_IDX target_dungeon = 0;
390 if (!current_floor_ptr->dun_level)
392 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
394 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
396 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
399 if (!max_dlv[target_dungeon])
401 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
402 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
403 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
406 /* Save old player position */
407 p_ptr->oldpx = p_ptr->x;
408 p_ptr->oldpy = p_ptr->y;
409 p_ptr->dungeon_idx = target_dungeon;
412 * Clear all saved floors
413 * and create a first saved floor
415 prepare_change_floor_mode(CFM_FIRST_FLOOR);
418 take_turn(p_ptr, 100);
420 if (autosave_l) do_cmd_save_game(TRUE);
423 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
426 if (!current_floor_ptr->dun_level)
428 /* Enter the dungeon just now */
429 p_ptr->enter_dungeon = TRUE;
430 down_num = d_info[p_ptr->dungeon_idx].mindepth;
435 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
436 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
441 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
448 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
452 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
453 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
455 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
459 p_ptr->leaving = TRUE;
463 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
467 if (have_flag(f_ptr->flags, FF_SHAFT))
469 /* Create a way back */
470 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
474 /* Create a way back */
475 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
483 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn
486 void do_cmd_search(void)
488 /* Allow repeated command */
491 /* Set repeat count */
492 command_rep = command_arg - 1;
493 p_ptr->redraw |= (PR_STATE);
498 take_turn(p_ptr, 100);
506 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
507 * @param y 走査対象にしたいマスのY座標
508 * @param x 走査対象にしたいマスのX座標
509 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
510 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
512 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
514 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
515 OBJECT_IDX this_o_idx, next_o_idx = 0;
517 /* Scan all objects in the grid */
518 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
522 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
523 next_o_idx = o_ptr->next_o_idx;
525 /* Skip unknown chests XXX XXX */
526 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
528 /* Check for non empty chest */
529 if ((o_ptr->tval == TV_CHEST) &&
530 (((!trapped) && (o_ptr->pval)) || /* non empty */
531 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
540 * @brief 箱を開けるコマンドのメインルーチン /
541 * Attempt to open the given chest at the given location
542 * @param y 箱の存在するマスのY座標
543 * @param x 箱の存在するマスのX座標
544 * @param o_idx 箱のオブジェクトID
545 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
547 * Assume there is no monster blocking the destination
549 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
554 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
556 take_turn(p_ptr, 100);
558 /* Attempt to unlock it */
561 /* Assume locked, and thus not open */
564 /* Get the "disarm" factor */
565 i = p_ptr->skill_dis;
567 /* Penalize some conditions */
568 if (p_ptr->blind || no_lite()) i = i / 10;
569 if (p_ptr->confused || p_ptr->image) i = i / 10;
571 /* Extract the difficulty */
574 /* Always have a small chance of success */
577 /* Success -- May still have traps */
578 if (randint0(100) < j)
580 msg_print(_("鍵をはずした。", "You have picked the lock."));
585 /* Failure -- Keep trying */
588 /* We may continue repeating */
590 if (flush_failure) flush();
591 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
596 /* Allowed to open */
599 /* Apply chest traps, if any */
600 chest_trap(y, x, o_idx);
602 /* Let the Chest drop items */
603 chest_death(FALSE, y, x, o_idx);
609 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
610 * Attempt to open the given chest at the given location
611 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
612 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
613 * @param test 地形条件を判定するための関数ポインタ
614 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
616 * @details Return the number of features around (or under) the character.
617 * Usually look for doors and floor traps.
619 static int count_dt(POSITION *y, POSITION *x, bool (*test)(FEAT_IDX feat), bool under)
625 /* Count how many matches */
628 /* Check around (and under) the character */
629 for (d = 0; d < 9; d++)
634 /* if not searching under player continue */
635 if ((d == 8) && !under) continue;
637 /* Extract adjacent (legal) location */
638 yy = p_ptr->y + ddy_ddd[d];
639 xx = p_ptr->x + ddx_ddd[d];
641 /* Get the current_floor_ptr->grid_array */
642 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
644 /* Must have knowledge */
645 if (!(g_ptr->info & (CAVE_MARK))) continue;
647 /* Feature code (applying "mimic" field) */
648 feat = get_feat_mimic(g_ptr);
650 /* Not looking for this feature */
651 if (!((*test)(feat))) continue;
656 /* Remember the location. Only useful if only one match */
667 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
668 * Return the number of chests around (or under) the character.
669 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
670 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
671 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
674 * If requested, count only trapped chests.
676 static int count_chests(POSITION *y, POSITION *x, bool trapped)
683 /* Count how many matches */
686 /* Check around (and under) the character */
687 for (d = 0; d < 9; d++)
689 /* Extract adjacent (legal) location */
690 POSITION yy = p_ptr->y + ddy_ddd[d];
691 POSITION xx = p_ptr->x + ddx_ddd[d];
693 /* No (visible) chest is there */
694 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
696 /* Grab the object */
697 o_ptr = ¤t_floor_ptr->o_list[o_idx];
700 if (o_ptr->pval == 0) continue;
702 /* No (known) traps here */
703 if (trapped && (!object_is_known(o_ptr) ||
704 !chest_traps[o_ptr->pval])) continue;
709 /* Remember the location. Only useful if only one match */
721 * @brief 「開ける」動作コマンドのサブルーチン /
722 * Perform the basic "open" command on doors
723 * @param y 対象を行うマスのY座標
724 * @param x 対象を行うマスのX座標
725 * @return 実際に処理が行われた場合TRUEを返す。
727 * Assume destination is a closed/locked/jammed door
728 * Assume there is no monster blocking the destination
729 * Returns TRUE if repeated commands may continue
731 static bool do_cmd_open_aux(POSITION y, POSITION x)
735 /* Get requested grid */
736 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
737 feature_type *f_ptr = &f_info[g_ptr->feat];
740 take_turn(p_ptr, 100);
742 /* Seeing true feature code (ignore mimic) */
745 if (!have_flag(f_ptr->flags, FF_OPEN))
748 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
752 else if (f_ptr->power)
755 i = p_ptr->skill_dis;
757 /* Penalize some conditions */
758 if (p_ptr->blind || no_lite()) i = i / 10;
759 if (p_ptr->confused || p_ptr->image) i = i / 10;
761 /* Extract the lock power */
764 /* Extract the difficulty */
767 /* Always have a small chance of success */
771 if (randint0(100) < j)
773 msg_print(_("鍵をはずした。", "You have picked the lock."));
776 cave_alter_feat(y, x, FF_OPEN);
778 sound(SOUND_OPENDOOR);
788 if (flush_failure) flush();
790 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
792 /* We may keep trying */
801 cave_alter_feat(y, x, FF_OPEN);
803 sound(SOUND_OPENDOOR);
809 * @brief 「開ける」コマンドのメインルーチン /
810 * Open a closed/locked/jammed door or a closed/locked chest.
813 * Unlocking a locked door/chest is worth one experience point.
815 void do_cmd_open(void)
823 if (p_ptr->wild_mode) return;
825 if (p_ptr->special_defense & KATA_MUSOU)
827 set_action(ACTION_NONE);
830 /* Option: Pick a direction */
833 int num_doors, num_chests;
835 /* Count closed doors (locked or jammed) */
836 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
838 /* Count chests (locked) */
839 num_chests = count_chests(&y, &x, FALSE);
841 /* See if only one target */
842 if (num_doors || num_chests)
844 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
846 if (!too_many) command_dir = coords_to_dir(y, x);
850 /* Allow repeated command */
853 /* Set repeat count */
854 command_rep = command_arg - 1;
855 p_ptr->redraw |= (PR_STATE);
861 /* Get a "repeated" direction */
862 if (get_rep_dir(&dir, TRUE))
867 /* Get requested location */
868 y = p_ptr->y + ddy[dir];
869 x = p_ptr->x + ddx[dir];
871 /* Get requested grid */
872 g_ptr = ¤t_floor_ptr->grid_array[y][x];
874 /* Feature code (applying "mimic" field) */
875 feat = get_feat_mimic(g_ptr);
877 /* Check for chest */
878 o_idx = chest_check(y, x, FALSE);
881 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
883 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
886 /* Monster in the way */
887 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
889 take_turn(p_ptr, 100);
890 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
898 more = do_cmd_open_chest(y, x, o_idx);
905 more = do_cmd_open_aux(y, x);
909 /* Cancel repeat unless we may continue */
910 if (!more) disturb(FALSE, FALSE);
916 * @brief 「閉じる」動作コマンドのサブルーチン /
917 * Perform the basic "close" command
918 * @param y 対象を行うマスのY座標
919 * @param x 対象を行うマスのX座標
920 * @return 実際に処理が行われた場合TRUEを返す。
922 * Assume destination is an open/broken door
923 * Assume there is no monster blocking the destination
924 * Returns TRUE if repeated commands may continue
926 static bool do_cmd_close_aux(POSITION y, POSITION x)
928 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
929 FEAT_IDX old_feat = g_ptr->feat;
932 take_turn(p_ptr, 100);
934 /* Seeing true feature code (ignore mimic) */
937 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
939 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
941 /* Hack -- object in the way */
942 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
943 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
945 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
950 cave_alter_feat(y, x, FF_CLOSE);
953 if (old_feat == g_ptr->feat)
955 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
959 sound(SOUND_SHUTDOOR);
968 * @brief 「閉じる」コマンドのメインルーチン /
969 * Close an open door.
972 * Unlocking a locked door/chest is worth one experience point.
974 void do_cmd_close(void)
981 if (p_ptr->wild_mode) return;
983 if (p_ptr->special_defense & KATA_MUSOU)
985 set_action(ACTION_NONE);
988 /* Option: Pick a direction */
991 /* Count open doors */
992 if (count_dt(&y, &x, is_open, FALSE) == 1)
994 command_dir = coords_to_dir(y, x);
998 /* Allow repeated command */
1001 /* Set repeat count */
1002 command_rep = command_arg - 1;
1003 p_ptr->redraw |= (PR_STATE);
1005 /* Cancel the arg */
1009 /* Get a "repeated" direction */
1010 if (get_rep_dir(&dir, FALSE))
1015 y = p_ptr->y + ddy[dir];
1016 x = p_ptr->x + ddx[dir];
1017 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1019 /* Feature code (applying "mimic" field) */
1020 feat = get_feat_mimic(g_ptr);
1022 /* Require open/broken door */
1023 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1025 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1028 /* Monster in the way */
1029 else if (g_ptr->m_idx)
1031 take_turn(p_ptr, 100);
1033 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1039 /* Close the door */
1042 /* Close the door */
1043 more = do_cmd_close_aux(y, x);
1047 /* Cancel repeat unless we may continue */
1048 if (!more) disturb(FALSE, FALSE);
1053 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1054 * Determine if a given grid may be "tunneled"
1055 * @param y 対象を行うマスのY座標
1056 * @param x 対象を行うマスのX座標
1059 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1061 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1063 /* Must have knowledge */
1064 if (!(g_ptr->info & CAVE_MARK))
1066 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1071 /* Must be a wall/door/etc */
1072 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1074 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1084 * @brief 「掘る」動作コマンドのサブルーチン /
1085 * Perform the basic "tunnel" command
1086 * @param y 対象を行うマスのY座標
1087 * @param x 対象を行うマスのX座標
1088 * @return 実際に処理が行われた場合TRUEを返す。
1090 * Assumes that no monster is blocking the destination
1091 * Do not use twall anymore
1092 * Returns TRUE if repeated commands may continue
1094 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1097 feature_type *f_ptr, *mimic_f_ptr;
1102 /* Verify legality */
1103 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1105 take_turn(p_ptr, 100);
1107 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1108 f_ptr = &f_info[g_ptr->feat];
1109 power = f_ptr->power;
1111 /* Feature code (applying "mimic" field) */
1112 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1114 name = f_name + mimic_f_ptr->name;
1118 if (have_flag(f_ptr->flags, FF_PERMANENT))
1121 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1123 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1126 /* Map border (mimiccing Permanent wall) */
1129 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1134 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1137 if (p_ptr->skill_dig > randint0(20 * power))
1139 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1141 /* Remove the feature */
1142 cave_alter_feat(y, x, FF_TUNNEL);
1143 p_ptr->update |= (PU_FLOW);
1147 /* Message, keep digging */
1148 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1156 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1159 if (p_ptr->skill_dig > power + randint0(40 * power))
1161 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1164 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1165 p_ptr->update |= (PU_FLOW);
1168 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1170 /* Remove the feature */
1171 cave_alter_feat(y, x, FF_TUNNEL);
1173 chg_virtue(V_DILIGENCE, 1);
1174 chg_virtue(V_NATURE, -1);
1182 /* We may continue chopping */
1183 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1184 /* Occasional Search XXX XXX */
1185 if (randint0(100) < 25) search();
1189 /* We may continue tunelling */
1190 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1197 if (is_hidden_door(g_ptr))
1199 /* Occasional Search XXX XXX */
1200 if (randint0(100) < 25) search();
1207 * @brief 「掘る」動作コマンドのメインルーチン /
1208 * Tunnels through "walls" (including rubble and closed doors)
1212 * Note that you must tunnel in order to hit invisible monsters
1213 * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
1215 * Digging is very difficult without a "digger" weapon, but can be
1216 * accomplished by strong players using heavy weapons.
1219 void do_cmd_tunnel(void)
1228 if (p_ptr->special_defense & KATA_MUSOU)
1230 set_action(ACTION_NONE);
1233 /* Allow repeated command */
1236 /* Set repeat count */
1237 command_rep = command_arg - 1;
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];
1251 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1253 /* Feature code (applying "mimic" field) */
1254 feat = get_feat_mimic(g_ptr);
1256 /* No tunnelling through doors */
1257 if (have_flag(f_info[feat].flags, FF_DOOR))
1259 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1262 /* No tunnelling through most features */
1263 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1265 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1268 /* A monster is in the way */
1269 else if (g_ptr->m_idx)
1271 take_turn(p_ptr, 100);
1273 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1282 /* Tunnel through walls */
1283 more = do_cmd_tunnel_aux(y, x);
1287 /* Cancel repetition unless we can continue */
1288 if (!more) disturb(FALSE, FALSE);
1292 * @brief 移動処理による簡易な「開く」処理 /
1294 * @return 開く処理が実際に試みられた場合TRUEを返す
1297 * If there is a jammed/closed/locked door at the given location,
1298 * then attempt to unlock/open it. Return TRUE if an attempt was
1299 * made (successful or not), otherwise return FALSE.
1301 * The code here should be nearly identical to that in
1302 * do_cmd_open_test() and do_cmd_open_aux().
1305 bool easy_open_door(POSITION y, POSITION x)
1309 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1310 feature_type *f_ptr = &f_info[g_ptr->feat];
1312 /* Must be a closed door */
1313 if (!is_closed_door(g_ptr->feat))
1319 if (!have_flag(f_ptr->flags, FF_OPEN))
1322 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1327 else if (f_ptr->power)
1330 i = p_ptr->skill_dis;
1332 /* Penalize some conditions */
1333 if (p_ptr->blind || no_lite()) i = i / 10;
1334 if (p_ptr->confused || p_ptr->image) i = i / 10;
1336 /* Extract the lock power */
1339 /* Extract the difficulty */
1342 /* Always have a small chance of success */
1346 if (randint0(100) < j)
1348 msg_print(_("鍵をはずした。", "You have picked the lock."));
1351 cave_alter_feat(y, x, FF_OPEN);
1353 sound(SOUND_OPENDOOR);
1363 if (flush_failure) flush();
1365 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1374 cave_alter_feat(y, x, FF_OPEN);
1376 sound(SOUND_OPENDOOR);
1382 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1383 * Perform the basic "disarm" command
1384 * @param y 解除を行うマスのY座標
1385 * @param x 解除を行うマスのX座標
1386 * @param o_idx 箱のオブジェクトID
1387 * @return ターンを消費する処理が行われた場合TRUEを返す
1390 * Assume destination is a visible trap
1391 * Assume there is no monster blocking the destination
1392 * Returns TRUE if repeated commands may continue
1395 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1399 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1401 take_turn(p_ptr, 100);
1403 /* Get the "disarm" factor */
1404 i = p_ptr->skill_dis;
1406 /* Penalize some conditions */
1407 if (p_ptr->blind || no_lite()) i = i / 10;
1408 if (p_ptr->confused || p_ptr->image) i = i / 10;
1410 /* Extract the difficulty */
1411 j = i - o_ptr->pval;
1413 /* Always have a small chance of success */
1416 /* Must find the trap first. */
1417 if (!object_is_known(o_ptr))
1419 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1423 /* Already disarmed/unlocked */
1424 else if (o_ptr->pval <= 0)
1426 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1429 /* No traps to find. */
1430 else if (!chest_traps[o_ptr->pval])
1432 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1435 /* Success (get a lot of experience) */
1436 else if (randint0(100) < j)
1438 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1439 gain_exp(o_ptr->pval);
1440 o_ptr->pval = (0 - o_ptr->pval);
1443 /* Failure -- Keep trying */
1444 else if ((i > 5) && (randint1(i) > 5))
1446 /* We may keep trying */
1448 if (flush_failure) flush();
1449 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1452 /* Failure -- Set off the trap */
1455 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1457 chest_trap(y, x, o_idx);
1464 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1465 * Perform the basic "disarm" command
1466 * @param y 解除を行うマスのY座標
1467 * @param x 解除を行うマスのX座標
1468 * @param dir プレイヤーからみた方向ID
1469 * @return ターンを消費する処理が行われた場合TRUEを返す
1472 * Assume destination is a visible trap
1473 * Assume there is no monster blocking the destination
1474 * Returns TRUE if repeated commands may continue
1478 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1480 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1483 feature_type *f_ptr = &f_info[g_ptr->feat];
1485 /* Access trap name */
1486 concptr name = (f_name + f_ptr->name);
1488 /* Extract trap "power" */
1489 int power = f_ptr->power;
1492 /* Get the "disarm" factor */
1493 int i = p_ptr->skill_dis;
1496 take_turn(p_ptr, 100);
1498 /* Penalize some conditions */
1499 if (p_ptr->blind || no_lite()) i = i / 10;
1500 if (p_ptr->confused || p_ptr->image) i = i / 10;
1502 /* Extract the difficulty */
1505 /* Always have a small chance of success */
1509 if (randint0(100) < j)
1511 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1516 /* Remove the trap */
1517 cave_alter_feat(y, x, FF_DISARM);
1519 /* Move the player onto the trap */
1520 move_player(dir, easy_disarm, FALSE);
1523 /* Failure -- Keep trying */
1524 else if ((i > 5) && (randint1(i) > 5))
1527 if (flush_failure) flush();
1529 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1531 /* We may keep trying */
1535 /* Failure -- Set off the trap */
1538 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1539 /* Move the player onto the trap */
1540 move_player(dir, easy_disarm, FALSE);
1547 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1548 * Disarms a trap, or chest
1551 void do_cmd_disarm(void)
1559 if (p_ptr->wild_mode) return;
1561 if (p_ptr->special_defense & KATA_MUSOU)
1563 set_action(ACTION_NONE);
1566 /* Option: Pick a direction */
1569 int num_traps, num_chests;
1571 /* Count visible traps */
1572 num_traps = count_dt(&y, &x, is_trap, TRUE);
1574 /* Count chests (trapped) */
1575 num_chests = count_chests(&y, &x, TRUE);
1577 /* See if only one target */
1578 if (num_traps || num_chests)
1580 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1581 if (!too_many) command_dir = coords_to_dir(y, x);
1586 /* Allow repeated command */
1589 /* Set repeat count */
1590 command_rep = command_arg - 1;
1591 p_ptr->redraw |= (PR_STATE);
1593 /* Cancel the arg */
1597 /* Get a direction (or abort) */
1598 if (get_rep_dir(&dir,TRUE))
1603 y = p_ptr->y + ddy[dir];
1604 x = p_ptr->x + ddx[dir];
1605 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1607 /* Feature code (applying "mimic" field) */
1608 feat = get_feat_mimic(g_ptr);
1610 /* Check for chests */
1611 o_idx = chest_check(y, x, TRUE);
1614 if (!is_trap(feat) && !o_idx)
1616 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1619 /* Monster in the way */
1620 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1622 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1631 more = do_cmd_disarm_chest(y, x, o_idx);
1637 more = do_cmd_disarm_aux(y, x, dir);
1641 /* Cancel repeat unless told not to */
1642 if (!more) disturb(FALSE, FALSE);
1647 * @brief 「打ち破る」動作コマンドのサブルーチン /
1648 * Perform the basic "bash" command
1649 * @param y 対象を行うマスのY座標
1650 * @param x 対象を行うマスのX座標
1651 * @param dir プレイヤーから見たターゲットの方角ID
1652 * @return 実際に処理が行われた場合TRUEを返す。
1655 * Assume destination is a closed/locked/jammed door
1656 * Assume there is no monster blocking the destination
1657 * Returns TRUE if repeated commands may continue
1660 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1662 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1665 feature_type *f_ptr = &f_info[g_ptr->feat];
1667 /* Hack -- Bash power based on strength */
1668 /* (Ranges from 3 to 20 to 100 to 200) */
1669 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1671 /* Extract door power */
1672 int temp = f_ptr->power;
1676 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1678 take_turn(p_ptr, 100);
1680 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1682 /* Compare bash power to door power */
1683 temp = (bash - (temp * 10));
1685 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1687 /* Hack -- always have a chance */
1688 if (temp < 1) temp = 1;
1690 /* Hack -- attempt to bash down the door */
1691 if (randint0(100) < temp)
1693 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1695 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1697 /* Break down the door */
1698 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1700 cave_alter_feat(y, x, FF_BASH);
1706 cave_alter_feat(y, x, FF_OPEN);
1709 /* Hack -- Fall through the door */
1710 move_player(dir, FALSE, FALSE);
1713 /* Saving throw against stun */
1714 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1717 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1719 /* Allow repeated bashing */
1723 /* High dexterity yields coolness */
1726 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1728 /* Hack -- Lose balance ala paralysis */
1729 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1736 * @brief 「打ち破る」動作コマンドのメインルーチン /
1737 * Bash open a door, success based on character strength
1741 * For a closed door, pval is positive if locked; negative if stuck.
1743 * For an open door, pval is positive for a broken door.
1745 * A closed door can be opened - harder if locked. Any door might be
1746 * bashed open (and thereby broken). Bashing a door is (potentially)
1747 * faster! You move into the door way. To open a stuck door, it must
1748 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1750 * Creatures can also open or bash doors, see elsewhere.
1753 void do_cmd_bash(void)
1759 if (p_ptr->wild_mode) return;
1761 if (p_ptr->special_defense & KATA_MUSOU)
1763 set_action(ACTION_NONE);
1766 /* Allow repeated command */
1769 /* Set repeat count */
1770 command_rep = command_arg - 1;
1771 p_ptr->redraw |= (PR_STATE);
1773 /* Cancel the arg */
1777 /* Get a "repeated" direction */
1778 if (get_rep_dir(&dir,FALSE))
1783 y = p_ptr->y + ddy[dir];
1784 x = p_ptr->x + ddx[dir];
1786 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1788 /* Feature code (applying "mimic" field) */
1789 feat = get_feat_mimic(g_ptr);
1791 /* Nothing useful */
1792 if (!have_flag(f_info[feat].flags, FF_BASH))
1794 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1797 /* Monster in the way */
1798 else if (g_ptr->m_idx)
1800 take_turn(p_ptr, 100);
1802 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1808 /* Bash a closed door */
1812 more = do_cmd_bash_aux(y, x, dir);
1816 /* Unless valid action taken, cancel bash */
1817 if (!more) disturb(FALSE, FALSE);
1822 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1826 * Manipulate an adjacent grid in some way
1828 * Attack monsters, tunnel through walls, disarm traps, open doors.
1830 * Consider confusion
1832 * This command must always take a current_world_ptr->game_turn, to prevent free detection
1833 * of invisible monsters.
1836 void do_cmd_alter(void)
1843 if (p_ptr->special_defense & KATA_MUSOU)
1845 set_action(ACTION_NONE);
1848 /* Allow repeated command */
1851 /* Set repeat count */
1852 command_rep = command_arg - 1;
1853 p_ptr->redraw |= (PR_STATE);
1855 /* Cancel the arg */
1859 /* Get a direction */
1860 if (get_rep_dir(&dir,TRUE))
1863 feature_type *f_ptr;
1865 y = p_ptr->y + ddy[dir];
1866 x = p_ptr->x + ddx[dir];
1868 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1870 /* Feature code (applying "mimic" field) */
1871 feat = get_feat_mimic(g_ptr);
1872 f_ptr = &f_info[feat];
1874 take_turn(p_ptr, 100);
1882 else if (have_flag(f_ptr->flags, FF_OPEN))
1884 more = do_cmd_open_aux(y, x);
1887 /* Bash jammed doors */
1888 else if (have_flag(f_ptr->flags, FF_BASH))
1890 more = do_cmd_bash_aux(y, x, dir);
1893 /* Tunnel through walls */
1894 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1896 more = do_cmd_tunnel_aux(y, x);
1899 /* Close open doors */
1900 else if (have_flag(f_ptr->flags, FF_CLOSE))
1902 more = do_cmd_close_aux(y, x);
1906 else if (have_flag(f_ptr->flags, FF_DISARM))
1908 more = do_cmd_disarm_aux(y, x, dir);
1913 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1917 /* Cancel repetition unless we can continue */
1918 if (!more) disturb(FALSE, FALSE);
1924 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1925 * Find the index of some "spikes", if possible.
1926 * @param ip くさびとして打てるオブジェクトのID
1927 * @return オブジェクトがある場合TRUEを返す
1930 * Let user choose a pile of spikes, perhaps?
1933 static bool get_spike(INVENTORY_IDX *ip)
1937 /* Check every item in the pack */
1938 for (i = 0; i < INVEN_PACK; i++)
1940 object_type *o_ptr = &p_ptr->inventory_list[i];
1941 if (!o_ptr->k_idx) continue;
1943 /* Check the "tval" code */
1944 if (o_ptr->tval == TV_SPIKE)
1946 /* Save the spike index */
1959 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1960 * Jam a closed door with a spike
1964 * This command may NOT be repeated
1967 void do_cmd_spike(void)
1971 if (p_ptr->wild_mode) return;
1973 if (p_ptr->special_defense & KATA_MUSOU)
1975 set_action(ACTION_NONE);
1978 /* Get a "repeated" direction */
1979 if (get_rep_dir(&dir, FALSE))
1986 y = p_ptr->y + ddy[dir];
1987 x = p_ptr->x + ddx[dir];
1988 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1990 /* Feature code (applying "mimic" field) */
1991 feat = get_feat_mimic(g_ptr);
1993 /* Require closed door */
1994 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1996 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2000 else if (!get_spike(&item))
2002 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2005 /* Is a monster in the way? */
2006 else if (g_ptr->m_idx)
2008 take_turn(p_ptr, 100);
2010 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2019 take_turn(p_ptr, 100);
2021 /* Successful jamming */
2022 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2023 cave_alter_feat(y, x, FF_SPIKE);
2025 /* Use up, and describe, a single spike, from the bottom */
2026 inven_item_increase(item, -1);
2027 inven_item_describe(item);
2028 inven_item_optimize(item);
2036 * @brief 「歩く」動作コマンドのメインルーチン /
2037 * Support code for the "Walk" and "Jump" commands
2038 * @param pickup アイテムの自動拾いを行うならTRUE
2041 void do_cmd_walk(bool pickup)
2048 /* Allow repeated command */
2051 /* Set repeat count */
2052 command_rep = command_arg - 1;
2053 p_ptr->redraw |= (PR_STATE);
2055 /* Cancel the arg */
2059 /* Get a "repeated" direction */
2060 if (get_rep_dir(&dir, FALSE))
2062 take_turn(p_ptr, 100);
2064 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2066 set_action(ACTION_NONE);
2069 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2070 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2071 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2073 /* Actually move the character */
2074 move_player(dir, pickup, FALSE);
2076 /* Allow more walking */
2080 /* Hack again -- Is there a special encounter ??? */
2081 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2083 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2086 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2088 /* Inform the player of his horrible fate :=) */
2089 msg_print(_("襲撃だ!", "You are ambushed !"));
2091 /* Go into large wilderness view */
2092 p_ptr->oldpy = randint1(MAX_HGT-2);
2093 p_ptr->oldpx = randint1(MAX_WID-2);
2096 /* Give first move to monsters */
2097 take_turn(p_ptr, 100);
2099 /* HACk -- set the encouter flag for the wilderness generation */
2100 generate_encounter = TRUE;
2104 /* Cancel repeat unless we may continue */
2105 if (!more) disturb(FALSE, FALSE);
2110 * @brief 「走る」動作コマンドのメインルーチン /
2114 void do_cmd_run(void)
2117 if (cmd_limit_confused(p_ptr)) return;
2119 if (p_ptr->special_defense & KATA_MUSOU)
2121 set_action(ACTION_NONE);
2124 /* Get a "repeated" direction */
2125 if (get_rep_dir(&dir,FALSE))
2127 /* Hack -- Set the run counter */
2128 running = (command_arg ? command_arg : 1000);
2137 * @brief 「留まる」動作コマンドのメインルーチン /
2138 * Stay still. Search. Enter stores.
2139 * Pick up treasure if "pickup" is true.
2140 * @param pickup アイテムの自動拾いを行うならTRUE
2143 void do_cmd_stay(bool pickup)
2145 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2147 /* Allow repeated command */
2150 /* Set repeat count */
2151 command_rep = command_arg - 1;
2152 p_ptr->redraw |= (PR_STATE);
2154 /* Cancel the arg */
2158 take_turn(p_ptr, 100);
2160 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2161 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2166 * @brief 「休む」動作コマンドのメインルーチン /
2167 * Resting allows a player to safely restore his hp -RAK-
2170 void do_cmd_rest(void)
2173 set_action(ACTION_NONE);
2175 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2177 stop_singing(p_ptr);
2181 if (hex_spelling_any()) stop_hex_spell_all();
2183 /* Prompt for time if needed */
2184 if (command_arg <= 0)
2186 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2187 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2193 strcpy(out_val, "&");
2195 /* Ask for duration */
2196 if (!get_string(p, out_val, 4)) return;
2198 /* Rest until done */
2199 if (out_val[0] == '&')
2201 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2205 else if (out_val[0] == '*')
2207 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2213 command_arg = (COMMAND_ARG)atoi(out_val);
2214 if (command_arg <= 0) return;
2218 if (command_arg > 9999) command_arg = 9999;
2220 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2222 /* Take a current_world_ptr->game_turn (?) */
2223 take_turn(p_ptr, 100);
2225 /* The sin of sloth */
2226 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2228 /* Why are you sleeping when there's no need? WAKE UP!*/
2229 if ((p_ptr->chp == p_ptr->mhp) &&
2230 (p_ptr->csp == p_ptr->msp) &&
2231 !p_ptr->blind && !p_ptr->confused &&
2232 !p_ptr->poisoned && !p_ptr->afraid &&
2233 !p_ptr->stun && !p_ptr->cut &&
2234 !p_ptr->slow && !p_ptr->paralyzed &&
2235 !p_ptr->image && !p_ptr->word_recall &&
2236 !p_ptr->alter_reality)
2237 chg_virtue(V_DILIGENCE, -1);
2239 /* Save the rest code */
2240 p_ptr->resting = command_arg;
2241 p_ptr->action = ACTION_REST;
2242 p_ptr->update |= (PU_BONUS);
2243 update_creature(p_ptr);
2245 p_ptr->redraw |= (PR_STATE);
2254 * @brief 射撃処理のメインルーチン
2257 void do_cmd_fire(SPELL_IDX snipe_type)
2260 object_type *j_ptr, *ammo_ptr;
2263 if(p_ptr->wild_mode) return;
2265 is_fired = FALSE; /* not fired yet */
2267 /* Get the "bow" (if any) */
2268 j_ptr = &p_ptr->inventory_list[INVEN_BOW];
2270 /* Require a launcher */
2273 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2278 if (j_ptr->sval == SV_CRIMSON)
2280 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2285 if (j_ptr->sval == SV_HARP)
2287 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2293 if (p_ptr->special_defense & KATA_MUSOU)
2295 set_action(ACTION_NONE);
2298 /* Require proper missile */
2299 item_tester_tval = p_ptr->tval_ammo;
2301 q = _("どれを撃ちますか? ", "Fire which item? ");
2302 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2305 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2313 exe_fire(item, j_ptr, snipe_type);
2315 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2317 /* Sniper actions after some shootings */
2318 if (snipe_type == SP_AWAY)
2320 teleport_player(10 + (p_ptr->concent * 2), 0L);
2322 if (snipe_type == SP_FINAL)
2324 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2325 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2326 (void)set_stun(p_ptr->stun + randint1(25));
2332 * @brief 投射処理メインルーチン /
2333 * Throw an object from the pack or floor.
2335 * @param boomerang ブーメラン処理ならばTRUE
2336 * @param shuriken 忍者の手裏剣処理ならばTRUE
2337 * @return ターンを消費した場合TRUEを返す
2340 * Note: "unseen" monsters are very hard to hit.
2342 * Should throwing a weapon do full damage? Should it allow the magic
2343 * to hit bonus of the weapon to have an effect? Should it ever cause
2344 * the item to be destroyed? Should it do any damage at all?
2347 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2352 POSITION y, x, ty, tx, prev_y, prev_x;
2353 POSITION ny[19], nx[19];
2354 int chance, tdam, tdis;
2355 int mul, div, dd, ds;
2356 int cur_dis, visible;
2363 bool hit_body = FALSE;
2364 bool hit_wall = FALSE;
2365 bool equiped_item = FALSE;
2366 bool return_when_thrown = FALSE;
2368 GAME_TEXT o_name[MAX_NLEN];
2370 int msec = delay_factor * delay_factor * delay_factor;
2372 BIT_FLAGS flgs[TR_FLAG_SIZE];
2374 bool come_back = FALSE;
2375 bool do_drop = TRUE;
2377 if (p_ptr->wild_mode) return FALSE;
2379 if (p_ptr->special_defense & KATA_MUSOU)
2381 set_action(ACTION_NONE);
2387 o_ptr = &p_ptr->inventory_list[item];
2391 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2393 item_tester_hook = item_tester_hook_boomerang;
2394 q = _("どの武器を投げますか? ", "Throw which item? ");
2395 s = _("投げる武器がない。", "You have nothing to throw.");
2396 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2403 else if (has_melee_weapon(INVEN_LARM))
2406 o_ptr = &p_ptr->inventory_list[item];
2411 o_ptr = &p_ptr->inventory_list[item];
2416 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2417 s = _("投げるアイテムがない。", "You have nothing to throw.");
2418 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2426 /* Item is cursed */
2427 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2429 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2433 if (p_ptr->inside_arena && !boomerang)
2435 if (o_ptr->tval != TV_SPIKE)
2437 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2446 /* Obtain a local object */
2447 object_copy(q_ptr, o_ptr);
2449 /* Extract the thrown object's flags. */
2450 object_flags(q_ptr, flgs);
2451 torch_flags(q_ptr, flgs);
2453 /* Distribute the charges of rods/wands between the stacks */
2454 distribute_charges(o_ptr, q_ptr, 1);
2459 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2461 if (p_ptr->mighty_throw) mult += 3;
2463 /* Extract a "distance multiplier" */
2464 /* Changed for 'launcher' mutation */
2465 mul = 10 + 2 * (mult - 1);
2467 /* Enforce a minimum "weight" of one pound */
2468 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2469 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2471 /* Hack -- Distance -- Reward strength, penalize weight */
2472 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2474 /* Max distance of 10-18 */
2475 if (tdis > mul) tdis = mul;
2479 ty = randint0(101) - 50 + p_ptr->y;
2480 tx = randint0(101) - 50 + p_ptr->x;
2484 project_length = tdis + 1;
2486 /* Get a direction (or cancel) */
2487 if (!get_aim_dir(&dir)) return FALSE;
2489 /* Predict the "target" location */
2490 tx = p_ptr->x + 99 * ddx[dir];
2491 ty = p_ptr->y + 99 * ddy[dir];
2493 /* Check for "target request" */
2494 if ((dir == 5) && target_okay())
2500 project_length = 0; /* reset to default */
2503 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2504 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2505 return_when_thrown = TRUE;
2507 /* Reduce and describe p_ptr->inventory_list */
2510 inven_item_increase(item, -1);
2511 if (!return_when_thrown)
2512 inven_item_describe(item);
2513 inven_item_optimize(item);
2516 /* Reduce and describe floor item */
2519 floor_item_increase(0 - item, -1);
2520 floor_item_optimize(0 - item);
2522 if (item >= INVEN_RARM)
2524 equiped_item = TRUE;
2525 p_ptr->redraw |= (PR_EQUIPPY);
2528 take_turn(p_ptr, 100);
2530 /* Rogue and Ninja gets bonus */
2531 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2532 p_ptr->energy_use -= p_ptr->lev;
2534 /* Start at the player */
2540 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2541 else shuriken = FALSE;
2543 /* Chance of hitting */
2544 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2545 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2546 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2548 if (shuriken) chance *= 2;
2553 /* Travel until stopped */
2554 for (cur_dis = 0; cur_dis <= tdis; )
2556 /* Hack -- Stop at the target */
2557 if ((y == ty) && (x == tx)) break;
2559 /* Calculate the new location (see "project()") */
2562 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2564 /* Stopped by walls/doors */
2565 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2568 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !current_floor_ptr->grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2571 /* The player can see the (on screen) missile */
2572 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2574 SYMBOL_CODE c = object_char(q_ptr);
2575 TERM_COLOR a = object_attr(q_ptr);
2577 /* Draw, Hilite, Fresh, Pause, Erase */
2578 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2579 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2581 Term_xtra(TERM_XTRA_DELAY, msec);
2582 lite_spot(ny[cur_dis], nx[cur_dis]);
2586 /* The player cannot see the missile */
2589 /* Pause anyway, for consistancy */
2590 Term_xtra(TERM_XTRA_DELAY, msec);
2596 /* Save the new location */
2600 /* Advance the distance */
2603 /* Monster here, Try to hit it */
2604 if (current_floor_ptr->grid_array[y][x].m_idx)
2606 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2607 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2608 GAME_TEXT m_name[MAX_NLEN];
2609 monster_name(g_ptr->m_idx, m_name);
2611 /* Check the visibility */
2612 visible = m_ptr->ml;
2614 /* Note the collision */
2617 /* Did we hit it (penalize range) */
2618 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2622 /* Handle unseen monster */
2625 /* Invisible monster */
2626 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2629 /* Handle visible monster */
2632 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2636 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2637 health_track(g_ptr->m_idx);
2641 /* Hack -- Base damage from thrown object */
2644 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2645 tdam = damroll(dd, ds);
2646 /* Apply special damage */
2647 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2648 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2649 if (q_ptr->to_d > 0)
2650 tdam += q_ptr->to_d;
2652 tdam += -q_ptr->to_d;
2656 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2657 tdam += p_ptr->to_d_m;
2659 else if (have_flag(flgs, TR_THROW))
2662 tdam += p_ptr->to_d_m;
2670 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2673 /* No negative damage */
2674 if (tdam < 0) tdam = 0;
2676 /* Modify the damage */
2677 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2679 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2680 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2682 /* Hit the monster, check for death */
2683 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2691 message_pain(g_ptr->m_idx, tdam);
2693 /* Anger the monster */
2694 if ((tdam > 0) && !object_is_potion(q_ptr))
2695 anger_monster(m_ptr);
2697 if (fear && m_ptr->ml)
2700 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2710 /* decrease toach's fuel */
2711 if (hit_body) torch_lost_fuel(q_ptr);
2713 /* Chance of breakage (during attacks) */
2714 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2716 /* Figurines transform */
2717 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2721 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2722 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2723 else if (object_is_cursed(q_ptr))
2724 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2728 /* Potions smash open */
2729 if (object_is_potion(q_ptr))
2731 if (hit_body || hit_wall || (randint1(100) < j))
2733 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2735 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2737 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2738 if (current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2740 GAME_TEXT m_name[MAX_NLEN];
2741 monster_desc(m_name, m_ptr, 0);
2742 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2743 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2754 if (return_when_thrown)
2756 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2757 char o2_name[MAX_NLEN];
2758 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2761 if (boomerang) back_chance += 4+randint1(5);
2762 if (super_boomerang) back_chance += 100;
2763 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2765 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2767 for (i = cur_dis - 1; i > 0; i--)
2769 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2771 char c = object_char(q_ptr);
2772 byte a = object_attr(q_ptr);
2774 /* Draw, Hilite, Fresh, Pause, Erase */
2775 print_rel(c, a, ny[i], nx[i]);
2776 move_cursor_relative(ny[i], nx[i]);
2778 Term_xtra(TERM_XTRA_DELAY, msec);
2779 lite_spot(ny[i], nx[i]);
2784 /* Pause anyway, for consistancy */
2785 Term_xtra(TERM_XTRA_DELAY, msec);
2788 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2790 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2797 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2801 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2809 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2815 if (item == INVEN_RARM || item == INVEN_LARM)
2817 /* Access the wield slot */
2818 o_ptr = &p_ptr->inventory_list[item];
2820 /* Wear the new stuff */
2821 object_copy(o_ptr, q_ptr);
2823 p_ptr->total_weight += q_ptr->weight;
2825 /* Increment the equip counter by hand */
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);
2859 * @brief 自殺するコマンドのメインルーチン
2860 * Hack -- commit suicide
2864 void do_cmd_suicide(void)
2871 /* Verify Retirement */
2872 if (p_ptr->total_winner)
2875 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2878 /* Verify Suicide */
2882 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2886 if (!p_ptr->noscore)
2888 /* Special Verification for suicide */
2889 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2894 if (i != '@') return;
2896 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2899 /* Initialize "last message" buffer */
2900 if (p_ptr->last_message) string_free(p_ptr->last_message);
2901 p_ptr->last_message = NULL;
2903 /* Hack -- Note *winning* message */
2904 if (p_ptr->total_winner && last_words)
2906 char buf[1024] = "";
2907 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2910 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2911 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2915 p_ptr->last_message = string_make(buf);
2916 msg_print(p_ptr->last_message);
2921 p_ptr->playing = FALSE;
2923 /* Kill the player */
2924 p_ptr->is_dead = TRUE;
2925 p_ptr->leaving = TRUE;
2927 if (!p_ptr->total_winner)
2929 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
2930 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2931 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
2934 /* Cause of death */
2935 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));