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.
25 #include "object-hook.h"
27 #include "spells-summon.h"
28 #include "spells-status.h"
30 #include "monster-status.h"
34 #include "player-status.h"
35 #include "realm-hex.h"
40 #include "player-move.h"
41 #include "player-effects.h"
42 #include "objectkind.h"
43 #include "object-broken.h"
44 #include "object-flavor.h"
47 #include "cmd-basic.h"
49 #include "floor-save.h"
50 #include "dungeon-file.h"
53 #include "view-mainwindow.h"
54 #include "targeting.h"
57 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
58 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
59 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
61 static bool confirm_leave_level(bool down_stair)
63 quest_type *q_ptr = &quest[p_ptr->inside_quest];
65 /* Confirm leaving from once only quest */
66 if (confirm_quest && p_ptr->inside_quest &&
67 (q_ptr->type == QUEST_TYPE_RANDOM ||
68 (q_ptr->flags & QUEST_FLAG_ONCE &&
69 q_ptr->status != QUEST_STATUS_COMPLETED) ||
70 (q_ptr->flags & QUEST_FLAG_TOWER &&
71 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
72 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
74 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
75 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
85 * @brief 魔法系コマンドが制限されているかを返す。
86 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
88 bool cmd_limit_cast(player_type *creature_ptr)
90 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
92 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
96 else if (creature_ptr->anti_magic)
98 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
101 else if (creature_ptr->shero)
103 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
110 bool cmd_limit_confused(player_type *creature_ptr)
112 if (creature_ptr->confused)
114 msg_print(_("混乱していてできない!", "You are too confused!"));
120 bool cmd_limit_image(player_type *creature_ptr)
122 if (creature_ptr->image)
124 msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
130 bool cmd_limit_stun(player_type *creature_ptr)
132 if (creature_ptr->stun)
134 msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
140 bool cmd_limit_arena(player_type *creature_ptr)
142 if (creature_ptr->inside_arena)
144 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
151 bool cmd_limit_blind(player_type *creature_ptr)
153 if (creature_ptr->blind)
155 msg_print(_("目が見えない。", "You can't see anything."));
160 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
166 bool cmd_limit_time_walk(player_type *creature_ptr)
168 if (creature_ptr->timewalk)
170 if (flush_failure) flush();
171 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
179 * @brief 階段を使って階層を昇る処理 / Go up one level
182 void do_cmd_go_up(void)
187 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
188 feature_type *f_ptr = &f_info[g_ptr->feat];
192 if (p_ptr->special_defense & KATA_MUSOU)
194 set_action(ACTION_NONE);
198 if (!have_flag(f_ptr->flags, FF_LESS))
200 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
204 /* Quest up stairs */
205 if (have_flag(f_ptr->flags, FF_QUEST))
207 /* Cancel the command */
208 if (!confirm_leave_level(FALSE)) return;
212 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
213 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
215 msg_print(_("上の階に登った。", "You enter the up staircase."));
219 p_ptr->inside_quest = g_ptr->special;
221 /* Activate the quest */
222 if (!quest[p_ptr->inside_quest].status)
224 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
226 init_flags = INIT_ASSIGN;
227 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
229 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
232 /* Leaving a quest */
233 if (!p_ptr->inside_quest)
235 current_floor_ptr->dun_level = 0;
237 p_ptr->leaving = TRUE;
242 take_turn(p_ptr, 100);
244 /* End the command */
248 if (!current_floor_ptr->dun_level)
254 go_up = confirm_leave_level(FALSE);
257 /* Cancel the command */
260 take_turn(p_ptr, 100);
262 if (autosave_l) do_cmd_save_game(TRUE);
264 /* For a random quest */
265 if (p_ptr->inside_quest &&
266 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
270 p_ptr->inside_quest = 0;
273 /* For a fixed quest */
274 if (p_ptr->inside_quest &&
275 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
279 p_ptr->inside_quest = g_ptr->special;
280 current_floor_ptr->dun_level = 0;
284 /* For normal dungeon and random quest */
288 if (have_flag(f_ptr->flags, FF_SHAFT))
290 /* Create a way back */
291 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
297 /* Create a way back */
298 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
303 /* Get out from current dungeon */
304 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
305 up_num = current_floor_ptr->dun_level;
307 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
310 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
311 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
312 else if (up_num == current_floor_ptr->dun_level)
313 msg_print(_("地上に戻った。", "You go back to the surface."));
315 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
316 p_ptr->leaving = TRUE;
321 * @brief 階段を使って階層を降りる処理 / Go down one level
324 void do_cmd_go_down(void)
327 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
328 feature_type *f_ptr = &f_info[g_ptr->feat];
330 bool fall_trap = FALSE;
333 if (p_ptr->special_defense & KATA_MUSOU)
335 set_action(ACTION_NONE);
339 if (!have_flag(f_ptr->flags, FF_MORE))
341 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
345 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
348 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
353 /* Quest down stairs */
354 else if (have_flag(f_ptr->flags, FF_QUEST))
356 /* Confirm Leaving */
357 if(!confirm_leave_level(TRUE)) return;
359 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
360 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
362 msg_print(_("下の階に降りた。", "You enter the down staircase."));
367 p_ptr->inside_quest = g_ptr->special;
369 /* Activate the quest */
370 if (!quest[p_ptr->inside_quest].status)
372 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
374 init_flags = INIT_ASSIGN;
375 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
377 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
380 /* Leaving a quest */
381 if (!p_ptr->inside_quest)
383 current_floor_ptr->dun_level = 0;
385 p_ptr->leaving = TRUE;
389 take_turn(p_ptr, 100);
394 DUNGEON_IDX target_dungeon = 0;
396 if (!current_floor_ptr->dun_level)
398 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
400 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
402 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
405 if (!max_dlv[target_dungeon])
407 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
408 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
409 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
412 /* Save old player position */
413 p_ptr->oldpx = p_ptr->x;
414 p_ptr->oldpy = p_ptr->y;
415 p_ptr->dungeon_idx = target_dungeon;
418 * Clear all saved floors
419 * and create a first saved floor
421 prepare_change_floor_mode(CFM_FIRST_FLOOR);
424 take_turn(p_ptr, 100);
426 if (autosave_l) do_cmd_save_game(TRUE);
429 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
432 if (!current_floor_ptr->dun_level)
434 /* Enter the dungeon just now */
435 p_ptr->enter_dungeon = TRUE;
436 down_num = d_info[p_ptr->dungeon_idx].mindepth;
441 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
442 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
447 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
454 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
458 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
459 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
461 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
465 p_ptr->leaving = TRUE;
469 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
473 if (have_flag(f_ptr->flags, FF_SHAFT))
475 /* Create a way back */
476 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
480 /* Create a way back */
481 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
489 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn
492 void do_cmd_search(void)
494 /* Allow repeated command */
497 /* Set repeat count */
498 command_rep = command_arg - 1;
499 p_ptr->redraw |= (PR_STATE);
504 take_turn(p_ptr, 100);
512 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
513 * @param y 走査対象にしたいマスのY座標
514 * @param x 走査対象にしたいマスのX座標
515 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
516 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
518 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
520 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
521 OBJECT_IDX this_o_idx, next_o_idx = 0;
523 /* Scan all objects in the grid */
524 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
528 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
529 next_o_idx = o_ptr->next_o_idx;
531 /* Skip unknown chests XXX XXX */
532 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
534 /* Check for non empty chest */
535 if ((o_ptr->tval == TV_CHEST) &&
536 (((!trapped) && (o_ptr->pval)) || /* non empty */
537 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
546 * @brief 箱を開けるコマンドのメインルーチン /
547 * Attempt to open the given chest at the given location
548 * @param y 箱の存在するマスのY座標
549 * @param x 箱の存在するマスのX座標
550 * @param o_idx 箱のオブジェクトID
551 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
553 * Assume there is no monster blocking the destination
555 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
560 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
562 take_turn(p_ptr, 100);
564 /* Attempt to unlock it */
567 /* Assume locked, and thus not open */
570 /* Get the "disarm" factor */
571 i = p_ptr->skill_dis;
573 /* Penalize some conditions */
574 if (p_ptr->blind || no_lite()) i = i / 10;
575 if (p_ptr->confused || p_ptr->image) i = i / 10;
577 /* Extract the difficulty */
580 /* Always have a small chance of success */
583 /* Success -- May still have traps */
584 if (randint0(100) < j)
586 msg_print(_("鍵をはずした。", "You have picked the lock."));
591 /* Failure -- Keep trying */
594 /* We may continue repeating */
596 if (flush_failure) flush();
597 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
602 /* Allowed to open */
605 /* Apply chest traps, if any */
606 chest_trap(y, x, o_idx);
608 /* Let the Chest drop items */
609 chest_death(FALSE, y, x, o_idx);
615 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
616 * Attempt to open the given chest at the given location
617 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
618 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
619 * @param test 地形条件を判定するための関数ポインタ
620 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
622 * @details Return the number of features around (or under) the character.
623 * Usually look for doors and floor traps.
625 static int count_dt(POSITION *y, POSITION *x, bool (*test)(FEAT_IDX feat), bool under)
631 /* Count how many matches */
634 /* Check around (and under) the character */
635 for (d = 0; d < 9; d++)
640 /* if not searching under player continue */
641 if ((d == 8) && !under) continue;
643 /* Extract adjacent (legal) location */
644 yy = p_ptr->y + ddy_ddd[d];
645 xx = p_ptr->x + ddx_ddd[d];
647 /* Get the current_floor_ptr->grid_array */
648 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
650 /* Must have knowledge */
651 if (!(g_ptr->info & (CAVE_MARK))) continue;
653 /* Feature code (applying "mimic" field) */
654 feat = get_feat_mimic(g_ptr);
656 /* Not looking for this feature */
657 if (!((*test)(feat))) continue;
662 /* Remember the location. Only useful if only one match */
673 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
674 * Return the number of chests around (or under) the character.
675 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
676 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
677 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
680 * If requested, count only trapped chests.
682 static int count_chests(POSITION *y, POSITION *x, bool trapped)
689 /* Count how many matches */
692 /* Check around (and under) the character */
693 for (d = 0; d < 9; d++)
695 /* Extract adjacent (legal) location */
696 POSITION yy = p_ptr->y + ddy_ddd[d];
697 POSITION xx = p_ptr->x + ddx_ddd[d];
699 /* No (visible) chest is there */
700 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
702 /* Grab the object */
703 o_ptr = ¤t_floor_ptr->o_list[o_idx];
706 if (o_ptr->pval == 0) continue;
708 /* No (known) traps here */
709 if (trapped && (!object_is_known(o_ptr) ||
710 !chest_traps[o_ptr->pval])) continue;
715 /* Remember the location. Only useful if only one match */
727 * @brief 「開ける」動作コマンドのサブルーチン /
728 * Perform the basic "open" command on doors
729 * @param y 対象を行うマスのY座標
730 * @param x 対象を行うマスのX座標
731 * @return 実際に処理が行われた場合TRUEを返す。
733 * Assume destination is a closed/locked/jammed door
734 * Assume there is no monster blocking the destination
735 * Returns TRUE if repeated commands may continue
737 static bool do_cmd_open_aux(POSITION y, POSITION x)
741 /* Get requested grid */
742 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
743 feature_type *f_ptr = &f_info[g_ptr->feat];
746 take_turn(p_ptr, 100);
748 /* Seeing true feature code (ignore mimic) */
751 if (!have_flag(f_ptr->flags, FF_OPEN))
754 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
758 else if (f_ptr->power)
761 i = p_ptr->skill_dis;
763 /* Penalize some conditions */
764 if (p_ptr->blind || no_lite()) i = i / 10;
765 if (p_ptr->confused || p_ptr->image) i = i / 10;
767 /* Extract the lock power */
770 /* Extract the difficulty */
773 /* Always have a small chance of success */
777 if (randint0(100) < j)
779 msg_print(_("鍵をはずした。", "You have picked the lock."));
782 cave_alter_feat(y, x, FF_OPEN);
784 sound(SOUND_OPENDOOR);
794 if (flush_failure) flush();
796 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
798 /* We may keep trying */
807 cave_alter_feat(y, x, FF_OPEN);
809 sound(SOUND_OPENDOOR);
815 * @brief 「開ける」コマンドのメインルーチン /
816 * Open a closed/locked/jammed door or a closed/locked chest.
819 * Unlocking a locked door/chest is worth one experience point.
821 void do_cmd_open(void)
829 if (p_ptr->wild_mode) return;
831 if (p_ptr->special_defense & KATA_MUSOU)
833 set_action(ACTION_NONE);
836 /* Option: Pick a direction */
839 int num_doors, num_chests;
841 /* Count closed doors (locked or jammed) */
842 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
844 /* Count chests (locked) */
845 num_chests = count_chests(&y, &x, FALSE);
847 /* See if only one target */
848 if (num_doors || num_chests)
850 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
852 if (!too_many) command_dir = coords_to_dir(y, x);
856 /* Allow repeated command */
859 /* Set repeat count */
860 command_rep = command_arg - 1;
861 p_ptr->redraw |= (PR_STATE);
867 /* Get a "repeated" direction */
868 if (get_rep_dir(&dir, TRUE))
873 /* Get requested location */
874 y = p_ptr->y + ddy[dir];
875 x = p_ptr->x + ddx[dir];
877 /* Get requested grid */
878 g_ptr = ¤t_floor_ptr->grid_array[y][x];
880 /* Feature code (applying "mimic" field) */
881 feat = get_feat_mimic(g_ptr);
883 /* Check for chest */
884 o_idx = chest_check(y, x, FALSE);
887 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
889 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
892 /* Monster in the way */
893 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
895 take_turn(p_ptr, 100);
896 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
904 more = do_cmd_open_chest(y, x, o_idx);
911 more = do_cmd_open_aux(y, x);
915 /* Cancel repeat unless we may continue */
916 if (!more) disturb(FALSE, FALSE);
922 * @brief 「閉じる」動作コマンドのサブルーチン /
923 * Perform the basic "close" command
924 * @param y 対象を行うマスのY座標
925 * @param x 対象を行うマスのX座標
926 * @return 実際に処理が行われた場合TRUEを返す。
928 * Assume destination is an open/broken door
929 * Assume there is no monster blocking the destination
930 * Returns TRUE if repeated commands may continue
932 static bool do_cmd_close_aux(POSITION y, POSITION x)
934 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
935 FEAT_IDX old_feat = g_ptr->feat;
938 take_turn(p_ptr, 100);
940 /* Seeing true feature code (ignore mimic) */
943 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
945 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
947 /* Hack -- object in the way */
948 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
949 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
951 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
956 cave_alter_feat(y, x, FF_CLOSE);
959 if (old_feat == g_ptr->feat)
961 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
965 sound(SOUND_SHUTDOOR);
974 * @brief 「閉じる」コマンドのメインルーチン /
975 * Close an open door.
978 * Unlocking a locked door/chest is worth one experience point.
980 void do_cmd_close(void)
987 if (p_ptr->wild_mode) return;
989 if (p_ptr->special_defense & KATA_MUSOU)
991 set_action(ACTION_NONE);
994 /* Option: Pick a direction */
997 /* Count open doors */
998 if (count_dt(&y, &x, is_open, FALSE) == 1)
1000 command_dir = coords_to_dir(y, x);
1004 /* Allow repeated command */
1007 /* Set repeat count */
1008 command_rep = command_arg - 1;
1009 p_ptr->redraw |= (PR_STATE);
1011 /* Cancel the arg */
1015 /* Get a "repeated" direction */
1016 if (get_rep_dir(&dir, FALSE))
1021 y = p_ptr->y + ddy[dir];
1022 x = p_ptr->x + ddx[dir];
1023 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1025 /* Feature code (applying "mimic" field) */
1026 feat = get_feat_mimic(g_ptr);
1028 /* Require open/broken door */
1029 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1031 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1034 /* Monster in the way */
1035 else if (g_ptr->m_idx)
1037 take_turn(p_ptr, 100);
1039 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1045 /* Close the door */
1048 /* Close the door */
1049 more = do_cmd_close_aux(y, x);
1053 /* Cancel repeat unless we may continue */
1054 if (!more) disturb(FALSE, FALSE);
1059 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1060 * Determine if a given grid may be "tunneled"
1061 * @param y 対象を行うマスのY座標
1062 * @param x 対象を行うマスのX座標
1065 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1067 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1069 /* Must have knowledge */
1070 if (!(g_ptr->info & CAVE_MARK))
1072 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1077 /* Must be a wall/door/etc */
1078 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1080 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1090 * @brief 「掘る」動作コマンドのサブルーチン /
1091 * Perform the basic "tunnel" command
1092 * @param y 対象を行うマスのY座標
1093 * @param x 対象を行うマスのX座標
1094 * @return 実際に処理が行われた場合TRUEを返す。
1096 * Assumes that no monster is blocking the destination
1097 * Do not use twall anymore
1098 * Returns TRUE if repeated commands may continue
1100 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1103 feature_type *f_ptr, *mimic_f_ptr;
1108 /* Verify legality */
1109 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1111 take_turn(p_ptr, 100);
1113 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1114 f_ptr = &f_info[g_ptr->feat];
1115 power = f_ptr->power;
1117 /* Feature code (applying "mimic" field) */
1118 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1120 name = f_name + mimic_f_ptr->name;
1124 if (have_flag(f_ptr->flags, FF_PERMANENT))
1127 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1129 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1132 /* Map border (mimiccing Permanent wall) */
1135 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1140 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1143 if (p_ptr->skill_dig > randint0(20 * power))
1145 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1147 /* Remove the feature */
1148 cave_alter_feat(y, x, FF_TUNNEL);
1149 p_ptr->update |= (PU_FLOW);
1153 /* Message, keep digging */
1154 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1162 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1165 if (p_ptr->skill_dig > power + randint0(40 * power))
1167 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1170 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1171 p_ptr->update |= (PU_FLOW);
1174 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1176 /* Remove the feature */
1177 cave_alter_feat(y, x, FF_TUNNEL);
1179 chg_virtue(V_DILIGENCE, 1);
1180 chg_virtue(V_NATURE, -1);
1188 /* We may continue chopping */
1189 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1190 /* Occasional Search XXX XXX */
1191 if (randint0(100) < 25) search();
1195 /* We may continue tunelling */
1196 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1203 if (is_hidden_door(g_ptr))
1205 /* Occasional Search XXX XXX */
1206 if (randint0(100) < 25) search();
1213 * @brief 「掘る」動作コマンドのメインルーチン /
1214 * Tunnels through "walls" (including rubble and closed doors)
1218 * Note that you must tunnel in order to hit invisible monsters
1219 * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
1221 * Digging is very difficult without a "digger" weapon, but can be
1222 * accomplished by strong players using heavy weapons.
1225 void do_cmd_tunnel(void)
1234 if (p_ptr->special_defense & KATA_MUSOU)
1236 set_action(ACTION_NONE);
1239 /* Allow repeated command */
1242 /* Set repeat count */
1243 command_rep = command_arg - 1;
1244 p_ptr->redraw |= (PR_STATE);
1246 /* Cancel the arg */
1250 /* Get a direction to tunnel, or Abort */
1251 if (get_rep_dir(&dir,FALSE))
1254 y = p_ptr->y + ddy[dir];
1255 x = p_ptr->x + ddx[dir];
1257 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1259 /* Feature code (applying "mimic" field) */
1260 feat = get_feat_mimic(g_ptr);
1262 /* No tunnelling through doors */
1263 if (have_flag(f_info[feat].flags, FF_DOOR))
1265 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1268 /* No tunnelling through most features */
1269 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1271 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1274 /* A monster is in the way */
1275 else if (g_ptr->m_idx)
1277 take_turn(p_ptr, 100);
1279 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1288 /* Tunnel through walls */
1289 more = do_cmd_tunnel_aux(y, x);
1293 /* Cancel repetition unless we can continue */
1294 if (!more) disturb(FALSE, FALSE);
1298 * @brief 移動処理による簡易な「開く」処理 /
1300 * @return 開く処理が実際に試みられた場合TRUEを返す
1303 * If there is a jammed/closed/locked door at the given location,
1304 * then attempt to unlock/open it. Return TRUE if an attempt was
1305 * made (successful or not), otherwise return FALSE.
1307 * The code here should be nearly identical to that in
1308 * do_cmd_open_test() and do_cmd_open_aux().
1311 bool easy_open_door(POSITION y, POSITION x)
1315 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1316 feature_type *f_ptr = &f_info[g_ptr->feat];
1318 /* Must be a closed door */
1319 if (!is_closed_door(g_ptr->feat))
1325 if (!have_flag(f_ptr->flags, FF_OPEN))
1328 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1333 else if (f_ptr->power)
1336 i = p_ptr->skill_dis;
1338 /* Penalize some conditions */
1339 if (p_ptr->blind || no_lite()) i = i / 10;
1340 if (p_ptr->confused || p_ptr->image) i = i / 10;
1342 /* Extract the lock power */
1345 /* Extract the difficulty */
1348 /* Always have a small chance of success */
1352 if (randint0(100) < j)
1354 msg_print(_("鍵をはずした。", "You have picked the lock."));
1357 cave_alter_feat(y, x, FF_OPEN);
1359 sound(SOUND_OPENDOOR);
1369 if (flush_failure) flush();
1371 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1380 cave_alter_feat(y, x, FF_OPEN);
1382 sound(SOUND_OPENDOOR);
1388 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1389 * Perform the basic "disarm" command
1390 * @param y 解除を行うマスのY座標
1391 * @param x 解除を行うマスのX座標
1392 * @param o_idx 箱のオブジェクトID
1393 * @return ターンを消費する処理が行われた場合TRUEを返す
1396 * Assume destination is a visible trap
1397 * Assume there is no monster blocking the destination
1398 * Returns TRUE if repeated commands may continue
1401 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1405 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1407 take_turn(p_ptr, 100);
1409 /* Get the "disarm" factor */
1410 i = p_ptr->skill_dis;
1412 /* Penalize some conditions */
1413 if (p_ptr->blind || no_lite()) i = i / 10;
1414 if (p_ptr->confused || p_ptr->image) i = i / 10;
1416 /* Extract the difficulty */
1417 j = i - o_ptr->pval;
1419 /* Always have a small chance of success */
1422 /* Must find the trap first. */
1423 if (!object_is_known(o_ptr))
1425 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1429 /* Already disarmed/unlocked */
1430 else if (o_ptr->pval <= 0)
1432 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1435 /* No traps to find. */
1436 else if (!chest_traps[o_ptr->pval])
1438 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1441 /* Success (get a lot of experience) */
1442 else if (randint0(100) < j)
1444 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1445 gain_exp(o_ptr->pval);
1446 o_ptr->pval = (0 - o_ptr->pval);
1449 /* Failure -- Keep trying */
1450 else if ((i > 5) && (randint1(i) > 5))
1452 /* We may keep trying */
1454 if (flush_failure) flush();
1455 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1458 /* Failure -- Set off the trap */
1461 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1463 chest_trap(y, x, o_idx);
1470 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1471 * Perform the basic "disarm" command
1472 * @param y 解除を行うマスのY座標
1473 * @param x 解除を行うマスのX座標
1474 * @param dir プレイヤーからみた方向ID
1475 * @return ターンを消費する処理が行われた場合TRUEを返す
1478 * Assume destination is a visible trap
1479 * Assume there is no monster blocking the destination
1480 * Returns TRUE if repeated commands may continue
1484 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1486 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1489 feature_type *f_ptr = &f_info[g_ptr->feat];
1491 /* Access trap name */
1492 concptr name = (f_name + f_ptr->name);
1494 /* Extract trap "power" */
1495 int power = f_ptr->power;
1498 /* Get the "disarm" factor */
1499 int i = p_ptr->skill_dis;
1502 take_turn(p_ptr, 100);
1504 /* Penalize some conditions */
1505 if (p_ptr->blind || no_lite()) i = i / 10;
1506 if (p_ptr->confused || p_ptr->image) i = i / 10;
1508 /* Extract the difficulty */
1511 /* Always have a small chance of success */
1515 if (randint0(100) < j)
1517 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1522 /* Remove the trap */
1523 cave_alter_feat(y, x, FF_DISARM);
1525 /* Move the player onto the trap */
1526 move_player(dir, easy_disarm, FALSE);
1529 /* Failure -- Keep trying */
1530 else if ((i > 5) && (randint1(i) > 5))
1533 if (flush_failure) flush();
1535 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1537 /* We may keep trying */
1541 /* Failure -- Set off the trap */
1544 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1545 /* Move the player onto the trap */
1546 move_player(dir, easy_disarm, FALSE);
1553 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1554 * Disarms a trap, or chest
1557 void do_cmd_disarm(void)
1565 if (p_ptr->wild_mode) return;
1567 if (p_ptr->special_defense & KATA_MUSOU)
1569 set_action(ACTION_NONE);
1572 /* Option: Pick a direction */
1575 int num_traps, num_chests;
1577 /* Count visible traps */
1578 num_traps = count_dt(&y, &x, is_trap, TRUE);
1580 /* Count chests (trapped) */
1581 num_chests = count_chests(&y, &x, TRUE);
1583 /* See if only one target */
1584 if (num_traps || num_chests)
1586 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1587 if (!too_many) command_dir = coords_to_dir(y, x);
1592 /* Allow repeated command */
1595 /* Set repeat count */
1596 command_rep = command_arg - 1;
1597 p_ptr->redraw |= (PR_STATE);
1599 /* Cancel the arg */
1603 /* Get a direction (or abort) */
1604 if (get_rep_dir(&dir,TRUE))
1609 y = p_ptr->y + ddy[dir];
1610 x = p_ptr->x + ddx[dir];
1611 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1613 /* Feature code (applying "mimic" field) */
1614 feat = get_feat_mimic(g_ptr);
1616 /* Check for chests */
1617 o_idx = chest_check(y, x, TRUE);
1620 if (!is_trap(feat) && !o_idx)
1622 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1625 /* Monster in the way */
1626 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1628 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1637 more = do_cmd_disarm_chest(y, x, o_idx);
1643 more = do_cmd_disarm_aux(y, x, dir);
1647 /* Cancel repeat unless told not to */
1648 if (!more) disturb(FALSE, FALSE);
1653 * @brief 「打ち破る」動作コマンドのサブルーチン /
1654 * Perform the basic "bash" command
1655 * @param y 対象を行うマスのY座標
1656 * @param x 対象を行うマスのX座標
1657 * @param dir プレイヤーから見たターゲットの方角ID
1658 * @return 実際に処理が行われた場合TRUEを返す。
1661 * Assume destination is a closed/locked/jammed door
1662 * Assume there is no monster blocking the destination
1663 * Returns TRUE if repeated commands may continue
1666 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1668 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1671 feature_type *f_ptr = &f_info[g_ptr->feat];
1673 /* Hack -- Bash power based on strength */
1674 /* (Ranges from 3 to 20 to 100 to 200) */
1675 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1677 /* Extract door power */
1678 int temp = f_ptr->power;
1682 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1684 take_turn(p_ptr, 100);
1686 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1688 /* Compare bash power to door power */
1689 temp = (bash - (temp * 10));
1691 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1693 /* Hack -- always have a chance */
1694 if (temp < 1) temp = 1;
1696 /* Hack -- attempt to bash down the door */
1697 if (randint0(100) < temp)
1699 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1701 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1703 /* Break down the door */
1704 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1706 cave_alter_feat(y, x, FF_BASH);
1712 cave_alter_feat(y, x, FF_OPEN);
1715 /* Hack -- Fall through the door */
1716 move_player(dir, FALSE, FALSE);
1719 /* Saving throw against stun */
1720 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1723 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1725 /* Allow repeated bashing */
1729 /* High dexterity yields coolness */
1732 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1734 /* Hack -- Lose balance ala paralysis */
1735 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1742 * @brief 「打ち破る」動作コマンドのメインルーチン /
1743 * Bash open a door, success based on character strength
1747 * For a closed door, pval is positive if locked; negative if stuck.
1749 * For an open door, pval is positive for a broken door.
1751 * A closed door can be opened - harder if locked. Any door might be
1752 * bashed open (and thereby broken). Bashing a door is (potentially)
1753 * faster! You move into the door way. To open a stuck door, it must
1754 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1756 * Creatures can also open or bash doors, see elsewhere.
1759 void do_cmd_bash(void)
1765 if (p_ptr->wild_mode) return;
1767 if (p_ptr->special_defense & KATA_MUSOU)
1769 set_action(ACTION_NONE);
1772 /* Allow repeated command */
1775 /* Set repeat count */
1776 command_rep = command_arg - 1;
1777 p_ptr->redraw |= (PR_STATE);
1779 /* Cancel the arg */
1783 /* Get a "repeated" direction */
1784 if (get_rep_dir(&dir,FALSE))
1789 y = p_ptr->y + ddy[dir];
1790 x = p_ptr->x + ddx[dir];
1792 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1794 /* Feature code (applying "mimic" field) */
1795 feat = get_feat_mimic(g_ptr);
1797 /* Nothing useful */
1798 if (!have_flag(f_info[feat].flags, FF_BASH))
1800 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1803 /* Monster in the way */
1804 else if (g_ptr->m_idx)
1806 take_turn(p_ptr, 100);
1808 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1814 /* Bash a closed door */
1818 more = do_cmd_bash_aux(y, x, dir);
1822 /* Unless valid action taken, cancel bash */
1823 if (!more) disturb(FALSE, FALSE);
1828 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1832 * Manipulate an adjacent grid in some way
1834 * Attack monsters, tunnel through walls, disarm traps, open doors.
1836 * Consider confusion
1838 * This command must always take a current_world_ptr->game_turn, to prevent free detection
1839 * of invisible monsters.
1842 void do_cmd_alter(void)
1849 if (p_ptr->special_defense & KATA_MUSOU)
1851 set_action(ACTION_NONE);
1854 /* Allow repeated command */
1857 /* Set repeat count */
1858 command_rep = command_arg - 1;
1859 p_ptr->redraw |= (PR_STATE);
1861 /* Cancel the arg */
1865 /* Get a direction */
1866 if (get_rep_dir(&dir,TRUE))
1869 feature_type *f_ptr;
1871 y = p_ptr->y + ddy[dir];
1872 x = p_ptr->x + ddx[dir];
1874 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1876 /* Feature code (applying "mimic" field) */
1877 feat = get_feat_mimic(g_ptr);
1878 f_ptr = &f_info[feat];
1880 take_turn(p_ptr, 100);
1888 else if (have_flag(f_ptr->flags, FF_OPEN))
1890 more = do_cmd_open_aux(y, x);
1893 /* Bash jammed doors */
1894 else if (have_flag(f_ptr->flags, FF_BASH))
1896 more = do_cmd_bash_aux(y, x, dir);
1899 /* Tunnel through walls */
1900 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1902 more = do_cmd_tunnel_aux(y, x);
1905 /* Close open doors */
1906 else if (have_flag(f_ptr->flags, FF_CLOSE))
1908 more = do_cmd_close_aux(y, x);
1912 else if (have_flag(f_ptr->flags, FF_DISARM))
1914 more = do_cmd_disarm_aux(y, x, dir);
1919 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1923 /* Cancel repetition unless we can continue */
1924 if (!more) disturb(FALSE, FALSE);
1930 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1931 * Find the index of some "spikes", if possible.
1932 * @param ip くさびとして打てるオブジェクトのID
1933 * @return オブジェクトがある場合TRUEを返す
1936 * Let user choose a pile of spikes, perhaps?
1939 static bool get_spike(INVENTORY_IDX *ip)
1943 /* Check every item in the pack */
1944 for (i = 0; i < INVEN_PACK; i++)
1946 object_type *o_ptr = &p_ptr->inventory_list[i];
1947 if (!o_ptr->k_idx) continue;
1949 /* Check the "tval" code */
1950 if (o_ptr->tval == TV_SPIKE)
1952 /* Save the spike index */
1965 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1966 * Jam a closed door with a spike
1970 * This command may NOT be repeated
1973 void do_cmd_spike(void)
1977 if (p_ptr->wild_mode) return;
1979 if (p_ptr->special_defense & KATA_MUSOU)
1981 set_action(ACTION_NONE);
1984 /* Get a "repeated" direction */
1985 if (get_rep_dir(&dir, FALSE))
1992 y = p_ptr->y + ddy[dir];
1993 x = p_ptr->x + ddx[dir];
1994 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1996 /* Feature code (applying "mimic" field) */
1997 feat = get_feat_mimic(g_ptr);
1999 /* Require closed door */
2000 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2002 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2006 else if (!get_spike(&item))
2008 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2011 /* Is a monster in the way? */
2012 else if (g_ptr->m_idx)
2014 take_turn(p_ptr, 100);
2016 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2025 take_turn(p_ptr, 100);
2027 /* Successful jamming */
2028 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2029 cave_alter_feat(y, x, FF_SPIKE);
2031 /* Use up, and describe, a single spike, from the bottom */
2032 inven_item_increase(item, -1);
2033 inven_item_describe(item);
2034 inven_item_optimize(item);
2042 * @brief 「歩く」動作コマンドのメインルーチン /
2043 * Support code for the "Walk" and "Jump" commands
2044 * @param pickup アイテムの自動拾いを行うならTRUE
2047 void do_cmd_walk(bool pickup)
2054 /* Allow repeated command */
2057 /* Set repeat count */
2058 command_rep = command_arg - 1;
2059 p_ptr->redraw |= (PR_STATE);
2061 /* Cancel the arg */
2065 /* Get a "repeated" direction */
2066 if (get_rep_dir(&dir, FALSE))
2068 take_turn(p_ptr, 100);
2070 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2072 set_action(ACTION_NONE);
2075 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2076 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2077 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2079 /* Actually move the character */
2080 move_player(dir, pickup, FALSE);
2082 /* Allow more walking */
2086 /* Hack again -- Is there a special encounter ??? */
2087 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2089 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2092 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2094 /* Inform the player of his horrible fate :=) */
2095 msg_print(_("襲撃だ!", "You are ambushed !"));
2097 /* Go into large wilderness view */
2098 p_ptr->oldpy = randint1(MAX_HGT-2);
2099 p_ptr->oldpx = randint1(MAX_WID-2);
2100 change_wild_mode(TRUE);
2102 /* Give first move to monsters */
2103 take_turn(p_ptr, 100);
2108 /* Cancel repeat unless we may continue */
2109 if (!more) disturb(FALSE, FALSE);
2114 * @brief 「走る」動作コマンドのメインルーチン /
2118 void do_cmd_run(void)
2121 if (cmd_limit_confused(p_ptr)) return;
2123 if (p_ptr->special_defense & KATA_MUSOU)
2125 set_action(ACTION_NONE);
2128 /* Get a "repeated" direction */
2129 if (get_rep_dir(&dir,FALSE))
2131 /* Hack -- Set the run counter */
2132 p_ptr->running = (command_arg ? command_arg : 1000);
2141 * @brief 「留まる」動作コマンドのメインルーチン /
2142 * Stay still. Search. Enter stores.
2143 * Pick up treasure if "pickup" is true.
2144 * @param pickup アイテムの自動拾いを行うならTRUE
2147 void do_cmd_stay(bool pickup)
2149 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2151 /* Allow repeated command */
2154 /* Set repeat count */
2155 command_rep = command_arg - 1;
2156 p_ptr->redraw |= (PR_STATE);
2158 /* Cancel the arg */
2162 take_turn(p_ptr, 100);
2164 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2165 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2170 * @brief 「休む」動作コマンドのメインルーチン /
2171 * Resting allows a player to safely restore his hp -RAK-
2174 void do_cmd_rest(void)
2177 set_action(ACTION_NONE);
2179 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2181 stop_singing(p_ptr);
2185 if (hex_spelling_any()) stop_hex_spell_all();
2187 /* Prompt for time if needed */
2188 if (command_arg <= 0)
2190 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2191 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2197 strcpy(out_val, "&");
2199 /* Ask for duration */
2200 if (!get_string(p, out_val, 4)) return;
2202 /* Rest until done */
2203 if (out_val[0] == '&')
2205 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2209 else if (out_val[0] == '*')
2211 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2217 command_arg = (COMMAND_ARG)atoi(out_val);
2218 if (command_arg <= 0) return;
2222 if (command_arg > 9999) command_arg = 9999;
2224 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2226 /* Take a current_world_ptr->game_turn (?) */
2227 take_turn(p_ptr, 100);
2229 /* The sin of sloth */
2230 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2232 /* Why are you sleeping when there's no need? WAKE UP!*/
2233 if ((p_ptr->chp == p_ptr->mhp) &&
2234 (p_ptr->csp == p_ptr->msp) &&
2235 !p_ptr->blind && !p_ptr->confused &&
2236 !p_ptr->poisoned && !p_ptr->afraid &&
2237 !p_ptr->stun && !p_ptr->cut &&
2238 !p_ptr->slow && !p_ptr->paralyzed &&
2239 !p_ptr->image && !p_ptr->word_recall &&
2240 !p_ptr->alter_reality)
2241 chg_virtue(V_DILIGENCE, -1);
2243 /* Save the rest code */
2244 p_ptr->resting = command_arg;
2245 p_ptr->action = ACTION_REST;
2246 p_ptr->update |= (PU_BONUS);
2247 update_creature(p_ptr);
2249 p_ptr->redraw |= (PR_STATE);
2258 * @brief 射撃処理のメインルーチン
2261 void do_cmd_fire(SPELL_IDX snipe_type)
2264 object_type *j_ptr, *ammo_ptr;
2267 if(p_ptr->wild_mode) return;
2269 p_ptr->is_fired = FALSE; /* not fired yet */
2271 /* Get the "bow" (if any) */
2272 j_ptr = &p_ptr->inventory_list[INVEN_BOW];
2274 /* Require a launcher */
2277 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2282 if (j_ptr->sval == SV_CRIMSON)
2284 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2289 if (j_ptr->sval == SV_HARP)
2291 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2297 if (p_ptr->special_defense & KATA_MUSOU)
2299 set_action(ACTION_NONE);
2302 /* Require proper missile */
2303 item_tester_tval = p_ptr->tval_ammo;
2305 q = _("どれを撃ちますか? ", "Fire which item? ");
2306 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2309 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2317 exe_fire(item, j_ptr, snipe_type);
2319 if (!p_ptr->is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2321 /* Sniper actions after some shootings */
2322 if (snipe_type == SP_AWAY)
2324 teleport_player(10 + (p_ptr->concent * 2), 0L);
2326 if (snipe_type == SP_FINAL)
2328 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2329 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2330 (void)set_stun(p_ptr->stun + randint1(25));
2336 * @brief 投射処理メインルーチン /
2337 * Throw an object from the pack or floor.
2339 * @param boomerang ブーメラン処理ならばTRUE
2340 * @param shuriken 忍者の手裏剣処理ならばTRUE
2341 * @return ターンを消費した場合TRUEを返す
2344 * Note: "unseen" monsters are very hard to hit.
2346 * Should throwing a weapon do full damage? Should it allow the magic
2347 * to hit bonus of the weapon to have an effect? Should it ever cause
2348 * the item to be destroyed? Should it do any damage at all?
2351 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2356 POSITION y, x, ty, tx, prev_y, prev_x;
2357 POSITION ny[19], nx[19];
2358 int chance, tdam, tdis;
2359 int mul, div, dd, ds;
2360 int cur_dis, visible;
2367 bool hit_body = FALSE;
2368 bool hit_wall = FALSE;
2369 bool equiped_item = FALSE;
2370 bool return_when_thrown = FALSE;
2372 GAME_TEXT o_name[MAX_NLEN];
2374 int msec = delay_factor * delay_factor * delay_factor;
2376 BIT_FLAGS flgs[TR_FLAG_SIZE];
2378 bool come_back = FALSE;
2379 bool do_drop = TRUE;
2381 if (p_ptr->wild_mode) return FALSE;
2383 if (p_ptr->special_defense & KATA_MUSOU)
2385 set_action(ACTION_NONE);
2391 o_ptr = &p_ptr->inventory_list[item];
2395 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2397 item_tester_hook = item_tester_hook_boomerang;
2398 q = _("どの武器を投げますか? ", "Throw which item? ");
2399 s = _("投げる武器がない。", "You have nothing to throw.");
2400 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2407 else if (has_melee_weapon(INVEN_LARM))
2410 o_ptr = &p_ptr->inventory_list[item];
2415 o_ptr = &p_ptr->inventory_list[item];
2420 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2421 s = _("投げるアイテムがない。", "You have nothing to throw.");
2422 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2430 /* Item is cursed */
2431 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2433 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2437 if (p_ptr->inside_arena && !boomerang)
2439 if (o_ptr->tval != TV_SPIKE)
2441 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2450 /* Obtain a local object */
2451 object_copy(q_ptr, o_ptr);
2453 /* Extract the thrown object's flags. */
2454 object_flags(q_ptr, flgs);
2455 torch_flags(q_ptr, flgs);
2457 /* Distribute the charges of rods/wands between the stacks */
2458 distribute_charges(o_ptr, q_ptr, 1);
2463 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2465 if (p_ptr->mighty_throw) mult += 3;
2467 /* Extract a "distance multiplier" */
2468 /* Changed for 'launcher' mutation */
2469 mul = 10 + 2 * (mult - 1);
2471 /* Enforce a minimum "weight" of one pound */
2472 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2473 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2475 /* Hack -- Distance -- Reward strength, penalize weight */
2476 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2478 /* Max distance of 10-18 */
2479 if (tdis > mul) tdis = mul;
2483 ty = randint0(101) - 50 + p_ptr->y;
2484 tx = randint0(101) - 50 + p_ptr->x;
2488 project_length = tdis + 1;
2490 /* Get a direction (or cancel) */
2491 if (!get_aim_dir(&dir)) return FALSE;
2493 /* Predict the "target" location */
2494 tx = p_ptr->x + 99 * ddx[dir];
2495 ty = p_ptr->y + 99 * ddy[dir];
2497 /* Check for "target request" */
2498 if ((dir == 5) && target_okay())
2504 project_length = 0; /* reset to default */
2507 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2508 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2509 return_when_thrown = TRUE;
2511 /* Reduce and describe p_ptr->inventory_list */
2514 inven_item_increase(item, -1);
2515 if (!return_when_thrown)
2516 inven_item_describe(item);
2517 inven_item_optimize(item);
2520 /* Reduce and describe floor item */
2523 floor_item_increase(0 - item, -1);
2524 floor_item_optimize(0 - item);
2526 if (item >= INVEN_RARM)
2528 equiped_item = TRUE;
2529 p_ptr->redraw |= (PR_EQUIPPY);
2532 take_turn(p_ptr, 100);
2534 /* Rogue and Ninja gets bonus */
2535 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2536 p_ptr->energy_use -= p_ptr->lev;
2538 /* Start at the player */
2544 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2545 else shuriken = FALSE;
2547 /* Chance of hitting */
2548 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2549 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2550 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2552 if (shuriken) chance *= 2;
2557 /* Travel until stopped */
2558 for (cur_dis = 0; cur_dis <= tdis; )
2560 /* Hack -- Stop at the target */
2561 if ((y == ty) && (x == tx)) break;
2563 /* Calculate the new location (see "project()") */
2566 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2568 /* Stopped by walls/doors */
2569 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2572 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;
2575 /* The player can see the (on screen) missile */
2576 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2578 SYMBOL_CODE c = object_char(q_ptr);
2579 TERM_COLOR a = object_attr(q_ptr);
2581 /* Draw, Hilite, Fresh, Pause, Erase */
2582 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2583 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2585 Term_xtra(TERM_XTRA_DELAY, msec);
2586 lite_spot(ny[cur_dis], nx[cur_dis]);
2590 /* The player cannot see the missile */
2593 /* Pause anyway, for consistancy */
2594 Term_xtra(TERM_XTRA_DELAY, msec);
2600 /* Save the new location */
2604 /* Advance the distance */
2607 /* Monster here, Try to hit it */
2608 if (current_floor_ptr->grid_array[y][x].m_idx)
2610 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2611 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2612 GAME_TEXT m_name[MAX_NLEN];
2613 monster_name(g_ptr->m_idx, m_name);
2615 /* Check the visibility */
2616 visible = m_ptr->ml;
2618 /* Note the collision */
2621 /* Did we hit it (penalize range) */
2622 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2626 /* Handle unseen monster */
2629 /* Invisible monster */
2630 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2633 /* Handle visible monster */
2636 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2640 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2641 health_track(g_ptr->m_idx);
2645 /* Hack -- Base damage from thrown object */
2648 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2649 tdam = damroll(dd, ds);
2650 /* Apply special damage */
2651 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2652 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2653 if (q_ptr->to_d > 0)
2654 tdam += q_ptr->to_d;
2656 tdam += -q_ptr->to_d;
2660 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2661 tdam += p_ptr->to_d_m;
2663 else if (have_flag(flgs, TR_THROW))
2666 tdam += p_ptr->to_d_m;
2674 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2677 /* No negative damage */
2678 if (tdam < 0) tdam = 0;
2680 /* Modify the damage */
2681 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2683 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2684 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2686 /* Hit the monster, check for death */
2687 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2695 message_pain(g_ptr->m_idx, tdam);
2697 /* Anger the monster */
2698 if ((tdam > 0) && !object_is_potion(q_ptr))
2699 anger_monster(m_ptr);
2701 if (fear && m_ptr->ml)
2704 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2714 /* decrease toach's fuel */
2715 if (hit_body) torch_lost_fuel(q_ptr);
2717 /* Chance of breakage (during attacks) */
2718 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2720 /* Figurines transform */
2721 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2725 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2726 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2727 else if (object_is_cursed(q_ptr))
2728 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2732 /* Potions smash open */
2733 if (object_is_potion(q_ptr))
2735 if (hit_body || hit_wall || (randint1(100) < j))
2737 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2739 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2741 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2742 if (current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2744 GAME_TEXT m_name[MAX_NLEN];
2745 monster_desc(m_name, m_ptr, 0);
2746 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2747 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2758 if (return_when_thrown)
2760 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2761 char o2_name[MAX_NLEN];
2762 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2765 if (boomerang) back_chance += 4+randint1(5);
2766 if (super_boomerang) back_chance += 100;
2767 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2769 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2771 for (i = cur_dis - 1; i > 0; i--)
2773 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2775 char c = object_char(q_ptr);
2776 byte a = object_attr(q_ptr);
2778 /* Draw, Hilite, Fresh, Pause, Erase */
2779 print_rel(c, a, ny[i], nx[i]);
2780 move_cursor_relative(ny[i], nx[i]);
2782 Term_xtra(TERM_XTRA_DELAY, msec);
2783 lite_spot(ny[i], nx[i]);
2788 /* Pause anyway, for consistancy */
2789 Term_xtra(TERM_XTRA_DELAY, msec);
2792 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2794 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2801 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2805 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2813 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2819 if (item == INVEN_RARM || item == INVEN_LARM)
2821 /* Access the wield slot */
2822 o_ptr = &p_ptr->inventory_list[item];
2824 /* Wear the new stuff */
2825 object_copy(o_ptr, q_ptr);
2827 p_ptr->total_weight += q_ptr->weight;
2829 /* Increment the equip counter by hand */
2832 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2833 p_ptr->window |= (PW_EQUIP);
2841 else if (equiped_item)
2849 if (cave_have_flag_bold(y, x, FF_PROJECT))
2851 (void)drop_near(q_ptr, j, y, x);
2855 (void)drop_near(q_ptr, j, prev_y, prev_x);
2863 * @brief 自殺するコマンドのメインルーチン
2864 * Hack -- commit suicide
2868 void do_cmd_suicide(void)
2875 /* Verify Retirement */
2876 if (p_ptr->total_winner)
2879 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2882 /* Verify Suicide */
2886 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2890 if (!p_ptr->noscore)
2892 /* Special Verification for suicide */
2893 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2898 if (i != '@') return;
2900 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2903 /* Initialize "last message" buffer */
2904 if (p_ptr->last_message) string_free(p_ptr->last_message);
2905 p_ptr->last_message = NULL;
2907 /* Hack -- Note *winning* message */
2908 if (p_ptr->total_winner && last_words)
2910 char buf[1024] = "";
2911 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2914 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2915 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2919 p_ptr->last_message = string_make(buf);
2920 msg_print(p_ptr->last_message);
2925 p_ptr->playing = FALSE;
2927 /* Kill the player */
2928 p_ptr->is_dead = TRUE;
2929 p_ptr->leaving = TRUE;
2931 if (!p_ptr->total_winner)
2933 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
2934 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2935 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
2938 /* Cause of death */
2939 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));