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"
36 #include "realm-song.h"
41 #include "player-move.h"
42 #include "player-effects.h"
43 #include "player-class.h"
44 #include "player-personality.h"
45 #include "objectkind.h"
46 #include "object-broken.h"
47 #include "object-flavor.h"
51 #include "cmd-basic.h"
53 #include "floor-save.h"
54 #include "dungeon-file.h"
57 #include "view-mainwindow.h"
58 #include "targeting.h"
61 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
62 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
63 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
65 static bool confirm_leave_level(bool down_stair)
67 quest_type *q_ptr = &quest[p_ptr->inside_quest];
69 /* Confirm leaving from once only quest */
70 if (confirm_quest && p_ptr->inside_quest &&
71 (q_ptr->type == QUEST_TYPE_RANDOM ||
72 (q_ptr->flags & QUEST_FLAG_ONCE &&
73 q_ptr->status != QUEST_STATUS_COMPLETED) ||
74 (q_ptr->flags & QUEST_FLAG_TOWER &&
75 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
76 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
78 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
79 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
89 * @brief 魔法系コマンドが制限されているかを返す。
90 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
92 bool cmd_limit_cast(player_type *creature_ptr)
94 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
96 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
100 else if (creature_ptr->anti_magic)
102 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
105 else if (creature_ptr->shero)
107 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
114 bool cmd_limit_confused(player_type *creature_ptr)
116 if (creature_ptr->confused)
118 msg_print(_("混乱していてできない!", "You are too confused!"));
124 bool cmd_limit_image(player_type *creature_ptr)
126 if (creature_ptr->image)
128 msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
134 bool cmd_limit_stun(player_type *creature_ptr)
136 if (creature_ptr->stun)
138 msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
144 bool cmd_limit_arena(player_type *creature_ptr)
146 if (creature_ptr->inside_arena)
148 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
155 bool cmd_limit_blind(player_type *creature_ptr)
157 if (creature_ptr->blind)
159 msg_print(_("目が見えない。", "You can't see anything."));
164 msg_print(_("明かりがないので見えない。", "You have no light."));
170 bool cmd_limit_time_walk(player_type *creature_ptr)
172 if (creature_ptr->timewalk)
174 if (flush_failure) flush();
175 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
183 * @brief 階段を使って階層を昇る処理 / Go up one level
186 void do_cmd_go_up(void)
191 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
192 feature_type *f_ptr = &f_info[g_ptr->feat];
196 if (p_ptr->special_defense & KATA_MUSOU)
198 set_action(ACTION_NONE);
202 if (!have_flag(f_ptr->flags, FF_LESS))
204 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
208 /* Quest up stairs */
209 if (have_flag(f_ptr->flags, FF_QUEST))
211 /* Cancel the command */
212 if (!confirm_leave_level(FALSE)) return;
216 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
217 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
219 msg_print(_("上の階に登った。", "You enter the up staircase."));
223 p_ptr->inside_quest = g_ptr->special;
225 /* Activate the quest */
226 if (!quest[p_ptr->inside_quest].status)
228 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
230 init_flags = INIT_ASSIGN;
231 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
233 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
236 /* Leaving a quest */
237 if (!p_ptr->inside_quest)
239 current_floor_ptr->dun_level = 0;
241 p_ptr->leaving = TRUE;
246 take_turn(p_ptr, 100);
248 /* End the command */
252 if (!current_floor_ptr->dun_level)
258 go_up = confirm_leave_level(FALSE);
261 /* Cancel the command */
264 take_turn(p_ptr, 100);
266 if (autosave_l) do_cmd_save_game(TRUE);
268 /* For a random quest */
269 if (p_ptr->inside_quest &&
270 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
274 p_ptr->inside_quest = 0;
277 /* For a fixed quest */
278 if (p_ptr->inside_quest &&
279 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
283 p_ptr->inside_quest = g_ptr->special;
284 current_floor_ptr->dun_level = 0;
288 /* For normal dungeon and random quest */
292 if (have_flag(f_ptr->flags, FF_SHAFT))
294 /* Create a way back */
295 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
301 /* Create a way back */
302 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
307 /* Get out from current dungeon */
308 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
309 up_num = current_floor_ptr->dun_level;
311 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
314 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
315 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
316 else if (up_num == current_floor_ptr->dun_level)
317 msg_print(_("地上に戻った。", "You go back to the surface."));
319 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
320 p_ptr->leaving = TRUE;
325 * @brief 階段を使って階層を降りる処理 / Go down one level
328 void do_cmd_go_down(void)
331 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
332 feature_type *f_ptr = &f_info[g_ptr->feat];
334 bool fall_trap = FALSE;
337 if (p_ptr->special_defense & KATA_MUSOU)
339 set_action(ACTION_NONE);
343 if (!have_flag(f_ptr->flags, FF_MORE))
345 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
349 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
352 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
357 /* Quest down stairs */
358 else if (have_flag(f_ptr->flags, FF_QUEST))
360 /* Confirm Leaving */
361 if(!confirm_leave_level(TRUE)) return;
363 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
364 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
366 msg_print(_("下の階に降りた。", "You enter the down staircase."));
371 p_ptr->inside_quest = g_ptr->special;
373 /* Activate the quest */
374 if (!quest[p_ptr->inside_quest].status)
376 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
378 init_flags = INIT_ASSIGN;
379 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
381 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
384 /* Leaving a quest */
385 if (!p_ptr->inside_quest)
387 current_floor_ptr->dun_level = 0;
389 p_ptr->leaving = TRUE;
393 take_turn(p_ptr, 100);
398 DUNGEON_IDX target_dungeon = 0;
400 if (!current_floor_ptr->dun_level)
402 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
404 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
406 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
409 if (!max_dlv[target_dungeon])
411 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
412 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
413 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
416 /* Save old player position */
417 p_ptr->oldpx = p_ptr->x;
418 p_ptr->oldpy = p_ptr->y;
419 p_ptr->dungeon_idx = target_dungeon;
422 * Clear all saved floors
423 * and create a first saved floor
425 prepare_change_floor_mode(CFM_FIRST_FLOOR);
428 take_turn(p_ptr, 100);
430 if (autosave_l) do_cmd_save_game(TRUE);
433 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
436 if (!current_floor_ptr->dun_level)
438 /* Enter the dungeon just now */
439 p_ptr->enter_dungeon = TRUE;
440 down_num = d_info[p_ptr->dungeon_idx].mindepth;
445 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
446 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
451 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
458 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
462 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
463 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
465 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
469 p_ptr->leaving = TRUE;
473 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
477 if (have_flag(f_ptr->flags, FF_SHAFT))
479 /* Create a way back */
480 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
484 /* Create a way back */
485 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
493 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn
496 void do_cmd_search(void)
498 /* Allow repeated command */
501 /* Set repeat count */
502 command_rep = command_arg - 1;
503 p_ptr->redraw |= (PR_STATE);
508 take_turn(p_ptr, 100);
516 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
517 * @param y 走査対象にしたいマスのY座標
518 * @param x 走査対象にしたいマスのX座標
519 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
520 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
522 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
524 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
525 OBJECT_IDX this_o_idx, next_o_idx = 0;
527 /* Scan all objects in the grid */
528 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
532 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
533 next_o_idx = o_ptr->next_o_idx;
535 /* Skip unknown chests XXX XXX */
536 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
538 /* Check for non empty chest */
539 if ((o_ptr->tval == TV_CHEST) &&
540 (((!trapped) && (o_ptr->pval)) || /* non empty */
541 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
550 * @brief 箱を開けるコマンドのメインルーチン /
551 * Attempt to open the given chest at the given location
552 * @param y 箱の存在するマスのY座標
553 * @param x 箱の存在するマスのX座標
554 * @param o_idx 箱のオブジェクトID
555 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
557 * Assume there is no monster blocking the destination
559 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
564 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
566 take_turn(p_ptr, 100);
568 /* Attempt to unlock it */
571 /* Assume locked, and thus not open */
574 /* Get the "disarm" factor */
575 i = p_ptr->skill_dis;
577 /* Penalize some conditions */
578 if (p_ptr->blind || no_lite()) i = i / 10;
579 if (p_ptr->confused || p_ptr->image) i = i / 10;
581 /* Extract the difficulty */
584 /* Always have a small chance of success */
587 /* Success -- May still have traps */
588 if (randint0(100) < j)
590 msg_print(_("鍵をはずした。", "You have picked the lock."));
595 /* Failure -- Keep trying */
598 /* We may continue repeating */
600 if (flush_failure) flush();
601 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
606 /* Allowed to open */
609 /* Apply chest traps, if any */
610 chest_trap(y, x, o_idx);
612 /* Let the Chest drop items */
613 chest_death(FALSE, y, x, o_idx);
619 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
620 * Attempt to open the given chest at the given location
621 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
622 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
623 * @param test 地形条件を判定するための関数ポインタ
624 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
626 * @details Return the number of features around (or under) the character.
627 * Usually look for doors and floor traps.
629 static int count_dt(POSITION *y, POSITION *x, bool (*test)(FEAT_IDX feat), bool under)
635 /* Count how many matches */
638 /* Check around (and under) the character */
639 for (d = 0; d < 9; d++)
644 /* if not searching under player continue */
645 if ((d == 8) && !under) continue;
647 /* Extract adjacent (legal) location */
648 yy = p_ptr->y + ddy_ddd[d];
649 xx = p_ptr->x + ddx_ddd[d];
651 /* Get the current_floor_ptr->grid_array */
652 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
654 /* Must have knowledge */
655 if (!(g_ptr->info & (CAVE_MARK))) continue;
657 /* Feature code (applying "mimic" field) */
658 feat = get_feat_mimic(g_ptr);
660 /* Not looking for this feature */
661 if (!((*test)(feat))) continue;
666 /* Remember the location. Only useful if only one match */
677 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
678 * Return the number of chests around (or under) the character.
679 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
680 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
681 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
684 * If requested, count only trapped chests.
686 static int count_chests(POSITION *y, POSITION *x, bool trapped)
693 /* Count how many matches */
696 /* Check around (and under) the character */
697 for (d = 0; d < 9; d++)
699 /* Extract adjacent (legal) location */
700 POSITION yy = p_ptr->y + ddy_ddd[d];
701 POSITION xx = p_ptr->x + ddx_ddd[d];
703 /* No (visible) chest is there */
704 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
706 /* Grab the object */
707 o_ptr = ¤t_floor_ptr->o_list[o_idx];
710 if (o_ptr->pval == 0) continue;
712 /* No (known) traps here */
713 if (trapped && (!object_is_known(o_ptr) ||
714 !chest_traps[o_ptr->pval])) continue;
719 /* Remember the location. Only useful if only one match */
731 * @brief 「開ける」動作コマンドのサブルーチン /
732 * Perform the basic "open" command on doors
733 * @param y 対象を行うマスのY座標
734 * @param x 対象を行うマスのX座標
735 * @return 実際に処理が行われた場合TRUEを返す。
737 * Assume destination is a closed/locked/jammed door
738 * Assume there is no monster blocking the destination
739 * Returns TRUE if repeated commands may continue
741 static bool do_cmd_open_aux(POSITION y, POSITION x)
745 /* Get requested grid */
746 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
747 feature_type *f_ptr = &f_info[g_ptr->feat];
750 take_turn(p_ptr, 100);
752 /* Seeing true feature code (ignore mimic) */
755 if (!have_flag(f_ptr->flags, FF_OPEN))
758 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
762 else if (f_ptr->power)
765 i = p_ptr->skill_dis;
767 /* Penalize some conditions */
768 if (p_ptr->blind || no_lite()) i = i / 10;
769 if (p_ptr->confused || p_ptr->image) i = i / 10;
771 /* Extract the lock power */
774 /* Extract the difficulty */
777 /* Always have a small chance of success */
781 if (randint0(100) < j)
783 msg_print(_("鍵をはずした。", "You have picked the lock."));
786 cave_alter_feat(y, x, FF_OPEN);
788 sound(SOUND_OPENDOOR);
798 if (flush_failure) flush();
800 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
802 /* We may keep trying */
811 cave_alter_feat(y, x, FF_OPEN);
813 sound(SOUND_OPENDOOR);
819 * @brief 「開ける」コマンドのメインルーチン /
820 * Open a closed/locked/jammed door or a closed/locked chest.
823 * Unlocking a locked door/chest is worth one experience point.
825 void do_cmd_open(void)
833 if (p_ptr->wild_mode) return;
835 if (p_ptr->special_defense & KATA_MUSOU)
837 set_action(ACTION_NONE);
840 /* Option: Pick a direction */
843 int num_doors, num_chests;
845 /* Count closed doors (locked or jammed) */
846 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
848 /* Count chests (locked) */
849 num_chests = count_chests(&y, &x, FALSE);
851 /* See if only one target */
852 if (num_doors || num_chests)
854 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
856 if (!too_many) command_dir = coords_to_dir(y, x);
860 /* Allow repeated command */
863 /* Set repeat count */
864 command_rep = command_arg - 1;
865 p_ptr->redraw |= (PR_STATE);
871 /* Get a "repeated" direction */
872 if (get_rep_dir(&dir, TRUE))
877 /* Get requested location */
878 y = p_ptr->y + ddy[dir];
879 x = p_ptr->x + ddx[dir];
881 /* Get requested grid */
882 g_ptr = ¤t_floor_ptr->grid_array[y][x];
884 /* Feature code (applying "mimic" field) */
885 feat = get_feat_mimic(g_ptr);
887 /* Check for chest */
888 o_idx = chest_check(y, x, FALSE);
891 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
893 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
896 /* Monster in the way */
897 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
899 take_turn(p_ptr, 100);
900 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
908 more = do_cmd_open_chest(y, x, o_idx);
915 more = do_cmd_open_aux(y, x);
919 /* Cancel repeat unless we may continue */
920 if (!more) disturb(FALSE, FALSE);
926 * @brief 「閉じる」動作コマンドのサブルーチン /
927 * Perform the basic "close" command
928 * @param y 対象を行うマスのY座標
929 * @param x 対象を行うマスのX座標
930 * @return 実際に処理が行われた場合TRUEを返す。
932 * Assume destination is an open/broken door
933 * Assume there is no monster blocking the destination
934 * Returns TRUE if repeated commands may continue
936 static bool do_cmd_close_aux(POSITION y, POSITION x)
938 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
939 FEAT_IDX old_feat = g_ptr->feat;
942 take_turn(p_ptr, 100);
944 /* Seeing true feature code (ignore mimic) */
947 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
949 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
951 /* Hack -- object in the way */
952 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
953 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
955 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
960 cave_alter_feat(y, x, FF_CLOSE);
963 if (old_feat == g_ptr->feat)
965 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
969 sound(SOUND_SHUTDOOR);
978 * @brief 「閉じる」コマンドのメインルーチン /
979 * Close an open door.
982 * Unlocking a locked door/chest is worth one experience point.
984 void do_cmd_close(void)
991 if (p_ptr->wild_mode) return;
993 if (p_ptr->special_defense & KATA_MUSOU)
995 set_action(ACTION_NONE);
998 /* Option: Pick a direction */
1001 /* Count open doors */
1002 if (count_dt(&y, &x, is_open, FALSE) == 1)
1004 command_dir = coords_to_dir(y, x);
1008 /* Allow repeated command */
1011 /* Set repeat count */
1012 command_rep = command_arg - 1;
1013 p_ptr->redraw |= (PR_STATE);
1015 /* Cancel the arg */
1019 /* Get a "repeated" direction */
1020 if (get_rep_dir(&dir, FALSE))
1025 y = p_ptr->y + ddy[dir];
1026 x = p_ptr->x + ddx[dir];
1027 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1029 /* Feature code (applying "mimic" field) */
1030 feat = get_feat_mimic(g_ptr);
1032 /* Require open/broken door */
1033 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1035 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1038 /* Monster in the way */
1039 else if (g_ptr->m_idx)
1041 take_turn(p_ptr, 100);
1043 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1049 /* Close the door */
1052 /* Close the door */
1053 more = do_cmd_close_aux(y, x);
1057 /* Cancel repeat unless we may continue */
1058 if (!more) disturb(FALSE, FALSE);
1063 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1064 * Determine if a given grid may be "tunneled"
1065 * @param y 対象を行うマスのY座標
1066 * @param x 対象を行うマスのX座標
1069 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1071 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1073 /* Must have knowledge */
1074 if (!(g_ptr->info & CAVE_MARK))
1076 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1081 /* Must be a wall/door/etc */
1082 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1084 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1094 * @brief 「掘る」動作コマンドのサブルーチン /
1095 * Perform the basic "tunnel" command
1096 * @param y 対象を行うマスのY座標
1097 * @param x 対象を行うマスのX座標
1098 * @return 実際に処理が行われた場合TRUEを返す。
1100 * Assumes that no monster is blocking the destination
1101 * Do not use twall anymore
1102 * Returns TRUE if repeated commands may continue
1104 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1107 feature_type *f_ptr, *mimic_f_ptr;
1112 /* Verify legality */
1113 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1115 take_turn(p_ptr, 100);
1117 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1118 f_ptr = &f_info[g_ptr->feat];
1119 power = f_ptr->power;
1121 /* Feature code (applying "mimic" field) */
1122 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1124 name = f_name + mimic_f_ptr->name;
1128 if (have_flag(f_ptr->flags, FF_PERMANENT))
1131 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1133 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1136 /* Map border (mimiccing Permanent wall) */
1139 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1144 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1147 if (p_ptr->skill_dig > randint0(20 * power))
1149 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1151 /* Remove the feature */
1152 cave_alter_feat(y, x, FF_TUNNEL);
1153 p_ptr->update |= (PU_FLOW);
1157 /* Message, keep digging */
1158 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1166 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1169 if (p_ptr->skill_dig > power + randint0(40 * power))
1171 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1174 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1175 p_ptr->update |= (PU_FLOW);
1178 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1180 /* Remove the feature */
1181 cave_alter_feat(y, x, FF_TUNNEL);
1183 chg_virtue(V_DILIGENCE, 1);
1184 chg_virtue(V_NATURE, -1);
1192 /* We may continue chopping */
1193 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1194 /* Occasional Search XXX XXX */
1195 if (randint0(100) < 25) search();
1199 /* We may continue tunelling */
1200 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1207 if (is_hidden_door(g_ptr))
1209 /* Occasional Search XXX XXX */
1210 if (randint0(100) < 25) search();
1217 * @brief 「掘る」動作コマンドのメインルーチン /
1218 * Tunnels through "walls" (including rubble and closed doors)
1222 * Note that you must tunnel in order to hit invisible monsters
1223 * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
1225 * Digging is very difficult without a "digger" weapon, but can be
1226 * accomplished by strong players using heavy weapons.
1229 void do_cmd_tunnel(void)
1238 if (p_ptr->special_defense & KATA_MUSOU)
1240 set_action(ACTION_NONE);
1243 /* Allow repeated command */
1246 /* Set repeat count */
1247 command_rep = command_arg - 1;
1248 p_ptr->redraw |= (PR_STATE);
1250 /* Cancel the arg */
1254 /* Get a direction to tunnel, or Abort */
1255 if (get_rep_dir(&dir,FALSE))
1258 y = p_ptr->y + ddy[dir];
1259 x = p_ptr->x + ddx[dir];
1261 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1263 /* Feature code (applying "mimic" field) */
1264 feat = get_feat_mimic(g_ptr);
1266 /* No tunnelling through doors */
1267 if (have_flag(f_info[feat].flags, FF_DOOR))
1269 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1272 /* No tunnelling through most features */
1273 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1275 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1278 /* A monster is in the way */
1279 else if (g_ptr->m_idx)
1281 take_turn(p_ptr, 100);
1283 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1292 /* Tunnel through walls */
1293 more = do_cmd_tunnel_aux(y, x);
1297 /* Cancel repetition unless we can continue */
1298 if (!more) disturb(FALSE, FALSE);
1302 * @brief 移動処理による簡易な「開く」処理 /
1304 * @return 開く処理が実際に試みられた場合TRUEを返す
1307 * If there is a jammed/closed/locked door at the given location,
1308 * then attempt to unlock/open it. Return TRUE if an attempt was
1309 * made (successful or not), otherwise return FALSE.
1311 * The code here should be nearly identical to that in
1312 * do_cmd_open_test() and do_cmd_open_aux().
1315 bool easy_open_door(POSITION y, POSITION x)
1319 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1320 feature_type *f_ptr = &f_info[g_ptr->feat];
1322 /* Must be a closed door */
1323 if (!is_closed_door(g_ptr->feat))
1329 if (!have_flag(f_ptr->flags, FF_OPEN))
1332 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1337 else if (f_ptr->power)
1340 i = p_ptr->skill_dis;
1342 /* Penalize some conditions */
1343 if (p_ptr->blind || no_lite()) i = i / 10;
1344 if (p_ptr->confused || p_ptr->image) i = i / 10;
1346 /* Extract the lock power */
1349 /* Extract the difficulty */
1352 /* Always have a small chance of success */
1356 if (randint0(100) < j)
1358 msg_print(_("鍵をはずした。", "You have picked the lock."));
1361 cave_alter_feat(y, x, FF_OPEN);
1363 sound(SOUND_OPENDOOR);
1373 if (flush_failure) flush();
1375 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1384 cave_alter_feat(y, x, FF_OPEN);
1386 sound(SOUND_OPENDOOR);
1392 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1393 * Perform the basic "disarm" command
1394 * @param y 解除を行うマスのY座標
1395 * @param x 解除を行うマスのX座標
1396 * @param o_idx 箱のオブジェクトID
1397 * @return ターンを消費する処理が行われた場合TRUEを返す
1400 * Assume destination is a visible trap
1401 * Assume there is no monster blocking the destination
1402 * Returns TRUE if repeated commands may continue
1405 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1409 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1411 take_turn(p_ptr, 100);
1413 /* Get the "disarm" factor */
1414 i = p_ptr->skill_dis;
1416 /* Penalize some conditions */
1417 if (p_ptr->blind || no_lite()) i = i / 10;
1418 if (p_ptr->confused || p_ptr->image) i = i / 10;
1420 /* Extract the difficulty */
1421 j = i - o_ptr->pval;
1423 /* Always have a small chance of success */
1426 /* Must find the trap first. */
1427 if (!object_is_known(o_ptr))
1429 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1433 /* Already disarmed/unlocked */
1434 else if (o_ptr->pval <= 0)
1436 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1439 /* No traps to find. */
1440 else if (!chest_traps[o_ptr->pval])
1442 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1445 /* Success (get a lot of experience) */
1446 else if (randint0(100) < j)
1448 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1449 gain_exp(o_ptr->pval);
1450 o_ptr->pval = (0 - o_ptr->pval);
1453 /* Failure -- Keep trying */
1454 else if ((i > 5) && (randint1(i) > 5))
1456 /* We may keep trying */
1458 if (flush_failure) flush();
1459 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1462 /* Failure -- Set off the trap */
1465 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1467 chest_trap(y, x, o_idx);
1474 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1475 * Perform the basic "disarm" command
1476 * @param y 解除を行うマスのY座標
1477 * @param x 解除を行うマスのX座標
1478 * @param dir プレイヤーからみた方向ID
1479 * @return ターンを消費する処理が行われた場合TRUEを返す
1482 * Assume destination is a visible trap
1483 * Assume there is no monster blocking the destination
1484 * Returns TRUE if repeated commands may continue
1488 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1490 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1493 feature_type *f_ptr = &f_info[g_ptr->feat];
1495 /* Access trap name */
1496 concptr name = (f_name + f_ptr->name);
1498 /* Extract trap "power" */
1499 int power = f_ptr->power;
1502 /* Get the "disarm" factor */
1503 int i = p_ptr->skill_dis;
1506 take_turn(p_ptr, 100);
1508 /* Penalize some conditions */
1509 if (p_ptr->blind || no_lite()) i = i / 10;
1510 if (p_ptr->confused || p_ptr->image) i = i / 10;
1512 /* Extract the difficulty */
1515 /* Always have a small chance of success */
1519 if (randint0(100) < j)
1521 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1526 /* Remove the trap */
1527 cave_alter_feat(y, x, FF_DISARM);
1529 /* Move the player onto the trap */
1530 move_player(dir, easy_disarm, FALSE);
1533 /* Failure -- Keep trying */
1534 else if ((i > 5) && (randint1(i) > 5))
1537 if (flush_failure) flush();
1539 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1541 /* We may keep trying */
1545 /* Failure -- Set off the trap */
1548 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1549 /* Move the player onto the trap */
1550 move_player(dir, easy_disarm, FALSE);
1557 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1558 * Disarms a trap, or chest
1561 void do_cmd_disarm(void)
1569 if (p_ptr->wild_mode) return;
1571 if (p_ptr->special_defense & KATA_MUSOU)
1573 set_action(ACTION_NONE);
1576 /* Option: Pick a direction */
1579 int num_traps, num_chests;
1581 /* Count visible traps */
1582 num_traps = count_dt(&y, &x, is_trap, TRUE);
1584 /* Count chests (trapped) */
1585 num_chests = count_chests(&y, &x, TRUE);
1587 /* See if only one target */
1588 if (num_traps || num_chests)
1590 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1591 if (!too_many) command_dir = coords_to_dir(y, x);
1596 /* Allow repeated command */
1599 /* Set repeat count */
1600 command_rep = command_arg - 1;
1601 p_ptr->redraw |= (PR_STATE);
1603 /* Cancel the arg */
1607 /* Get a direction (or abort) */
1608 if (get_rep_dir(&dir,TRUE))
1613 y = p_ptr->y + ddy[dir];
1614 x = p_ptr->x + ddx[dir];
1615 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1617 /* Feature code (applying "mimic" field) */
1618 feat = get_feat_mimic(g_ptr);
1620 /* Check for chests */
1621 o_idx = chest_check(y, x, TRUE);
1624 if (!is_trap(feat) && !o_idx)
1626 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1629 /* Monster in the way */
1630 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1632 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1641 more = do_cmd_disarm_chest(y, x, o_idx);
1647 more = do_cmd_disarm_aux(y, x, dir);
1651 /* Cancel repeat unless told not to */
1652 if (!more) disturb(FALSE, FALSE);
1657 * @brief 「打ち破る」動作コマンドのサブルーチン /
1658 * Perform the basic "bash" command
1659 * @param y 対象を行うマスのY座標
1660 * @param x 対象を行うマスのX座標
1661 * @param dir プレイヤーから見たターゲットの方角ID
1662 * @return 実際に処理が行われた場合TRUEを返す。
1665 * Assume destination is a closed/locked/jammed door
1666 * Assume there is no monster blocking the destination
1667 * Returns TRUE if repeated commands may continue
1670 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1672 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1675 feature_type *f_ptr = &f_info[g_ptr->feat];
1677 /* Hack -- Bash power based on strength */
1678 /* (Ranges from 3 to 20 to 100 to 200) */
1679 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1681 /* Extract door power */
1682 int temp = f_ptr->power;
1686 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1688 take_turn(p_ptr, 100);
1690 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1692 /* Compare bash power to door power */
1693 temp = (bash - (temp * 10));
1695 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1697 /* Hack -- always have a chance */
1698 if (temp < 1) temp = 1;
1700 /* Hack -- attempt to bash down the door */
1701 if (randint0(100) < temp)
1703 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1705 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1707 /* Break down the door */
1708 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1710 cave_alter_feat(y, x, FF_BASH);
1716 cave_alter_feat(y, x, FF_OPEN);
1719 /* Hack -- Fall through the door */
1720 move_player(dir, FALSE, FALSE);
1723 /* Saving throw against stun */
1724 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1727 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1729 /* Allow repeated bashing */
1733 /* High dexterity yields coolness */
1736 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1738 /* Hack -- Lose balance ala paralysis */
1739 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1746 * @brief 「打ち破る」動作コマンドのメインルーチン /
1747 * Bash open a door, success based on character strength
1751 * For a closed door, pval is positive if locked; negative if stuck.
1753 * For an open door, pval is positive for a broken door.
1755 * A closed door can be opened - harder if locked. Any door might be
1756 * bashed open (and thereby broken). Bashing a door is (potentially)
1757 * faster! You move into the door way. To open a stuck door, it must
1758 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1760 * Creatures can also open or bash doors, see elsewhere.
1763 void do_cmd_bash(void)
1769 if (p_ptr->wild_mode) return;
1771 if (p_ptr->special_defense & KATA_MUSOU)
1773 set_action(ACTION_NONE);
1776 /* Allow repeated command */
1779 /* Set repeat count */
1780 command_rep = command_arg - 1;
1781 p_ptr->redraw |= (PR_STATE);
1783 /* Cancel the arg */
1787 /* Get a "repeated" direction */
1788 if (get_rep_dir(&dir,FALSE))
1793 y = p_ptr->y + ddy[dir];
1794 x = p_ptr->x + ddx[dir];
1796 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1798 /* Feature code (applying "mimic" field) */
1799 feat = get_feat_mimic(g_ptr);
1801 /* Nothing useful */
1802 if (!have_flag(f_info[feat].flags, FF_BASH))
1804 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1807 /* Monster in the way */
1808 else if (g_ptr->m_idx)
1810 take_turn(p_ptr, 100);
1812 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1818 /* Bash a closed door */
1822 more = do_cmd_bash_aux(y, x, dir);
1826 /* Unless valid action taken, cancel bash */
1827 if (!more) disturb(FALSE, FALSE);
1832 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1836 * Manipulate an adjacent grid in some way
1838 * Attack monsters, tunnel through walls, disarm traps, open doors.
1840 * Consider confusion
1842 * This command must always take a current_world_ptr->game_turn, to prevent free detection
1843 * of invisible monsters.
1846 void do_cmd_alter(void)
1853 if (p_ptr->special_defense & KATA_MUSOU)
1855 set_action(ACTION_NONE);
1858 /* Allow repeated command */
1861 /* Set repeat count */
1862 command_rep = command_arg - 1;
1863 p_ptr->redraw |= (PR_STATE);
1865 /* Cancel the arg */
1869 /* Get a direction */
1870 if (get_rep_dir(&dir,TRUE))
1873 feature_type *f_ptr;
1875 y = p_ptr->y + ddy[dir];
1876 x = p_ptr->x + ddx[dir];
1878 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1880 /* Feature code (applying "mimic" field) */
1881 feat = get_feat_mimic(g_ptr);
1882 f_ptr = &f_info[feat];
1884 take_turn(p_ptr, 100);
1892 else if (have_flag(f_ptr->flags, FF_OPEN))
1894 more = do_cmd_open_aux(y, x);
1897 /* Bash jammed doors */
1898 else if (have_flag(f_ptr->flags, FF_BASH))
1900 more = do_cmd_bash_aux(y, x, dir);
1903 /* Tunnel through walls */
1904 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1906 more = do_cmd_tunnel_aux(y, x);
1909 /* Close open doors */
1910 else if (have_flag(f_ptr->flags, FF_CLOSE))
1912 more = do_cmd_close_aux(y, x);
1916 else if (have_flag(f_ptr->flags, FF_DISARM))
1918 more = do_cmd_disarm_aux(y, x, dir);
1923 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1927 /* Cancel repetition unless we can continue */
1928 if (!more) disturb(FALSE, FALSE);
1934 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1935 * Find the index of some "spikes", if possible.
1936 * @param ip くさびとして打てるオブジェクトのID
1937 * @return オブジェクトがある場合TRUEを返す
1940 * Let user choose a pile of spikes, perhaps?
1943 static bool get_spike(INVENTORY_IDX *ip)
1947 /* Check every item in the pack */
1948 for (i = 0; i < INVEN_PACK; i++)
1950 object_type *o_ptr = &p_ptr->inventory_list[i];
1951 if (!o_ptr->k_idx) continue;
1953 /* Check the "tval" code */
1954 if (o_ptr->tval == TV_SPIKE)
1956 /* Save the spike index */
1969 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1970 * Jam a closed door with a spike
1974 * This command may NOT be repeated
1977 void do_cmd_spike(void)
1981 if (p_ptr->wild_mode) return;
1983 if (p_ptr->special_defense & KATA_MUSOU)
1985 set_action(ACTION_NONE);
1988 /* Get a "repeated" direction */
1989 if (get_rep_dir(&dir, FALSE))
1996 y = p_ptr->y + ddy[dir];
1997 x = p_ptr->x + ddx[dir];
1998 g_ptr = ¤t_floor_ptr->grid_array[y][x];
2000 /* Feature code (applying "mimic" field) */
2001 feat = get_feat_mimic(g_ptr);
2003 /* Require closed door */
2004 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2006 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2010 else if (!get_spike(&item))
2012 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2015 /* Is a monster in the way? */
2016 else if (g_ptr->m_idx)
2018 take_turn(p_ptr, 100);
2020 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2029 take_turn(p_ptr, 100);
2031 /* Successful jamming */
2032 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2033 cave_alter_feat(y, x, FF_SPIKE);
2035 /* Use up, and describe, a single spike, from the bottom */
2036 inven_item_increase(item, -1);
2037 inven_item_describe(item);
2038 inven_item_optimize(item);
2046 * @brief 「歩く」動作コマンドのメインルーチン /
2047 * Support code for the "Walk" and "Jump" commands
2048 * @param pickup アイテムの自動拾いを行うならTRUE
2051 void do_cmd_walk(bool pickup)
2058 /* Allow repeated command */
2061 /* Set repeat count */
2062 command_rep = command_arg - 1;
2063 p_ptr->redraw |= (PR_STATE);
2065 /* Cancel the arg */
2069 /* Get a "repeated" direction */
2070 if (get_rep_dir(&dir, FALSE))
2072 take_turn(p_ptr, 100);
2074 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2076 set_action(ACTION_NONE);
2079 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2080 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2081 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2083 /* Actually move the character */
2084 move_player(dir, pickup, FALSE);
2086 /* Allow more walking */
2090 /* Hack again -- Is there a special encounter ??? */
2091 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2093 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2096 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2098 /* Inform the player of his horrible fate :=) */
2099 msg_print(_("襲撃だ!", "You are ambushed !"));
2101 /* Go into large wilderness view */
2102 p_ptr->oldpy = randint1(MAX_HGT-2);
2103 p_ptr->oldpx = randint1(MAX_WID-2);
2104 change_wild_mode(TRUE);
2106 /* Give first move to monsters */
2107 take_turn(p_ptr, 100);
2112 /* Cancel repeat unless we may continue */
2113 if (!more) disturb(FALSE, FALSE);
2118 * @brief 「走る」動作コマンドのメインルーチン /
2122 void do_cmd_run(void)
2125 if (cmd_limit_confused(p_ptr)) return;
2127 if (p_ptr->special_defense & KATA_MUSOU)
2129 set_action(ACTION_NONE);
2132 /* Get a "repeated" direction */
2133 if (get_rep_dir(&dir,FALSE))
2135 /* Hack -- Set the run counter */
2136 p_ptr->running = (command_arg ? command_arg : 1000);
2145 * @brief 「留まる」動作コマンドのメインルーチン /
2146 * Stay still. Search. Enter stores.
2147 * Pick up treasure if "pickup" is true.
2148 * @param pickup アイテムの自動拾いを行うならTRUE
2151 void do_cmd_stay(bool pickup)
2153 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2155 /* Allow repeated command */
2158 /* Set repeat count */
2159 command_rep = command_arg - 1;
2160 p_ptr->redraw |= (PR_STATE);
2162 /* Cancel the arg */
2166 take_turn(p_ptr, 100);
2168 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2169 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2174 * @brief 「休む」動作コマンドのメインルーチン /
2175 * Resting allows a player to safely restore his hp -RAK-
2178 void do_cmd_rest(void)
2181 set_action(ACTION_NONE);
2183 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2185 stop_singing(p_ptr);
2189 if (hex_spelling_any()) stop_hex_spell_all();
2191 /* Prompt for time if needed */
2192 if (command_arg <= 0)
2194 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2195 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2201 strcpy(out_val, "&");
2203 /* Ask for duration */
2204 if (!get_string(p, out_val, 4)) return;
2206 /* Rest until done */
2207 if (out_val[0] == '&')
2209 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2213 else if (out_val[0] == '*')
2215 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2221 command_arg = (COMMAND_ARG)atoi(out_val);
2222 if (command_arg <= 0) return;
2226 if (command_arg > 9999) command_arg = 9999;
2228 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2230 /* Take a current_world_ptr->game_turn (?) */
2231 take_turn(p_ptr, 100);
2233 /* The sin of sloth */
2234 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2236 /* Why are you sleeping when there's no need? WAKE UP!*/
2237 if ((p_ptr->chp == p_ptr->mhp) &&
2238 (p_ptr->csp == p_ptr->msp) &&
2239 !p_ptr->blind && !p_ptr->confused &&
2240 !p_ptr->poisoned && !p_ptr->afraid &&
2241 !p_ptr->stun && !p_ptr->cut &&
2242 !p_ptr->slow && !p_ptr->paralyzed &&
2243 !p_ptr->image && !p_ptr->word_recall &&
2244 !p_ptr->alter_reality)
2245 chg_virtue(V_DILIGENCE, -1);
2247 /* Save the rest code */
2248 p_ptr->resting = command_arg;
2249 p_ptr->action = ACTION_REST;
2250 p_ptr->update |= (PU_BONUS);
2251 update_creature(p_ptr);
2253 p_ptr->redraw |= (PR_STATE);
2262 * @brief 射撃処理のメインルーチン
2265 void do_cmd_fire(SPELL_IDX snipe_type)
2268 object_type *j_ptr, *ammo_ptr;
2271 if(p_ptr->wild_mode) return;
2273 p_ptr->is_fired = FALSE; /* not fired yet */
2275 /* Get the "bow" (if any) */
2276 j_ptr = &p_ptr->inventory_list[INVEN_BOW];
2278 /* Require a launcher */
2281 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2286 if (j_ptr->sval == SV_CRIMSON)
2288 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2293 if (j_ptr->sval == SV_HARP)
2295 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2301 if (p_ptr->special_defense & KATA_MUSOU)
2303 set_action(ACTION_NONE);
2306 q = _("どれを撃ちますか? ", "Fire which item? ");
2307 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2309 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), p_ptr->tval_ammo);
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), 0);
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), 0);
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!"));
2449 object_copy(q_ptr, o_ptr);
2451 /* Extract the thrown object's flags. */
2452 object_flags(q_ptr, flgs);
2453 torch_flags(q_ptr, flgs);
2455 /* Distribute the charges of rods/wands between the stacks */
2456 distribute_charges(o_ptr, q_ptr, 1);
2461 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2463 if (p_ptr->mighty_throw) mult += 3;
2465 /* Extract a "distance multiplier" */
2466 /* Changed for 'launcher' mutation */
2467 mul = 10 + 2 * (mult - 1);
2469 /* Enforce a minimum "weight" of one pound */
2470 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2471 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2473 /* Hack -- Distance -- Reward strength, penalize weight */
2474 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2476 /* Max distance of 10-18 */
2477 if (tdis > mul) tdis = mul;
2481 ty = randint0(101) - 50 + p_ptr->y;
2482 tx = randint0(101) - 50 + p_ptr->x;
2486 project_length = tdis + 1;
2488 /* Get a direction (or cancel) */
2489 if (!get_aim_dir(&dir)) return FALSE;
2491 /* Predict the "target" location */
2492 tx = p_ptr->x + 99 * ddx[dir];
2493 ty = p_ptr->y + 99 * ddy[dir];
2495 /* Check for "target request" */
2496 if ((dir == 5) && target_okay())
2502 project_length = 0; /* reset to default */
2505 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2506 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2507 return_when_thrown = TRUE;
2509 /* Reduce and describe p_ptr->inventory_list */
2512 inven_item_increase(item, -1);
2513 if (!return_when_thrown)
2514 inven_item_describe(item);
2515 inven_item_optimize(item);
2518 /* Reduce and describe floor item */
2521 floor_item_increase(0 - item, -1);
2522 floor_item_optimize(0 - item);
2524 if (item >= INVEN_RARM)
2526 equiped_item = TRUE;
2527 p_ptr->redraw |= (PR_EQUIPPY);
2530 take_turn(p_ptr, 100);
2532 /* Rogue and Ninja gets bonus */
2533 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2534 p_ptr->energy_use -= p_ptr->lev;
2536 /* Start at the player */
2542 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2543 else shuriken = FALSE;
2545 /* Chance of hitting */
2546 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2547 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2548 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2550 if (shuriken) chance *= 2;
2555 /* Travel until stopped */
2556 for (cur_dis = 0; cur_dis <= tdis; )
2558 /* Hack -- Stop at the target */
2559 if ((y == ty) && (x == tx)) break;
2561 /* Calculate the new location (see "project()") */
2564 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2566 /* Stopped by walls/doors */
2567 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2570 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;
2573 /* The player can see the (on screen) missile */
2574 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2576 SYMBOL_CODE c = object_char(q_ptr);
2577 TERM_COLOR a = object_attr(q_ptr);
2579 /* Draw, Hilite, Fresh, Pause, Erase */
2580 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2581 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2583 Term_xtra(TERM_XTRA_DELAY, msec);
2584 lite_spot(ny[cur_dis], nx[cur_dis]);
2588 /* The player cannot see the missile */
2591 /* Pause anyway, for consistancy */
2592 Term_xtra(TERM_XTRA_DELAY, msec);
2598 /* Save the new location */
2602 /* Advance the distance */
2605 /* Monster here, Try to hit it */
2606 if (current_floor_ptr->grid_array[y][x].m_idx)
2608 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2609 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2610 GAME_TEXT m_name[MAX_NLEN];
2611 monster_name(g_ptr->m_idx, m_name);
2613 /* Check the visibility */
2614 visible = m_ptr->ml;
2616 /* Note the collision */
2619 /* Did we hit it (penalize range) */
2620 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2624 /* Handle unseen monster */
2627 /* Invisible monster */
2628 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2631 /* Handle visible monster */
2634 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2638 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2639 health_track(g_ptr->m_idx);
2643 /* Hack -- Base damage from thrown object */
2646 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2647 tdam = damroll(dd, ds);
2648 /* Apply special damage */
2649 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2650 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2651 if (q_ptr->to_d > 0)
2652 tdam += q_ptr->to_d;
2654 tdam += -q_ptr->to_d;
2658 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2659 tdam += p_ptr->to_d_m;
2661 else if (have_flag(flgs, TR_THROW))
2664 tdam += p_ptr->to_d_m;
2672 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2675 /* No negative damage */
2676 if (tdam < 0) tdam = 0;
2678 /* Modify the damage */
2679 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2681 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2682 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2684 /* Hit the monster, check for death */
2685 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2693 message_pain(g_ptr->m_idx, tdam);
2695 /* Anger the monster */
2696 if ((tdam > 0) && !object_is_potion(q_ptr))
2697 anger_monster(m_ptr);
2699 if (fear && m_ptr->ml)
2702 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2712 /* decrease toach's fuel */
2713 if (hit_body) torch_lost_fuel(q_ptr);
2715 /* Chance of breakage (during attacks) */
2716 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2718 /* Figurines transform */
2719 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2723 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2724 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2725 else if (object_is_cursed(q_ptr))
2726 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2730 /* Potions smash open */
2731 if (object_is_potion(q_ptr))
2733 if (hit_body || hit_wall || (randint1(100) < j))
2735 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2737 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2739 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2740 if (current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2742 GAME_TEXT m_name[MAX_NLEN];
2743 monster_desc(m_name, m_ptr, 0);
2744 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2745 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2756 if (return_when_thrown)
2758 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2759 char o2_name[MAX_NLEN];
2760 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2763 if (boomerang) back_chance += 4+randint1(5);
2764 if (super_boomerang) back_chance += 100;
2765 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2767 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2769 for (i = cur_dis - 1; i > 0; i--)
2771 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2773 char c = object_char(q_ptr);
2774 byte a = object_attr(q_ptr);
2776 /* Draw, Hilite, Fresh, Pause, Erase */
2777 print_rel(c, a, ny[i], nx[i]);
2778 move_cursor_relative(ny[i], nx[i]);
2780 Term_xtra(TERM_XTRA_DELAY, msec);
2781 lite_spot(ny[i], nx[i]);
2786 /* Pause anyway, for consistancy */
2787 Term_xtra(TERM_XTRA_DELAY, msec);
2790 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2792 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2799 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2803 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2811 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2817 if (item == INVEN_RARM || item == INVEN_LARM)
2819 /* Access the wield slot */
2820 o_ptr = &p_ptr->inventory_list[item];
2822 /* Wear the new stuff */
2823 object_copy(o_ptr, q_ptr);
2825 p_ptr->total_weight += q_ptr->weight;
2827 /* Increment the equip counter by hand */
2830 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2831 p_ptr->window |= (PW_EQUIP);
2839 else if (equiped_item)
2847 if (cave_have_flag_bold(y, x, FF_PROJECT))
2849 (void)drop_near(q_ptr, j, y, x);
2853 (void)drop_near(q_ptr, j, prev_y, prev_x);
2861 * @brief 自殺するコマンドのメインルーチン
2862 * Hack -- commit suicide
2866 void do_cmd_suicide(void)
2873 /* Verify Retirement */
2874 if (p_ptr->total_winner)
2877 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2880 /* Verify Suicide */
2884 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2888 if (!p_ptr->noscore)
2890 /* Special Verification for suicide */
2891 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2896 if (i != '@') return;
2898 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2901 /* Initialize "last message" buffer */
2902 if (p_ptr->last_message) string_free(p_ptr->last_message);
2903 p_ptr->last_message = NULL;
2905 /* Hack -- Note *winning* message */
2906 if (p_ptr->total_winner && last_words)
2908 char buf[1024] = "";
2909 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2912 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2913 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2917 p_ptr->last_message = string_make(buf);
2918 msg_print(p_ptr->last_message);
2923 p_ptr->playing = FALSE;
2925 /* Kill the player */
2926 p_ptr->is_dead = TRUE;
2927 p_ptr->leaving = TRUE;
2929 if (!p_ptr->total_winner)
2931 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
2932 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2933 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
2936 /* Cause of death */
2937 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));