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.
23 #include "object-hook.h"
25 #include "spells-summon.h"
26 #include "spells-status.h"
28 #include "monster-status.h"
32 #include "player-status.h"
33 #include "realm-hex.h"
38 #include "player-move.h"
39 #include "player-effects.h"
40 #include "objectkind.h"
41 #include "object-broken.h"
42 #include "object-flavor.h"
45 #include "cmd-basic.h"
46 #include "floor-save.h"
47 #include "dungeon-file.h"
50 #include "view-mainwindow.h"
51 #include "targeting.h"
54 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
55 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
56 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
58 static bool confirm_leave_level(bool down_stair)
60 quest_type *q_ptr = &quest[p_ptr->inside_quest];
62 /* Confirm leaving from once only quest */
63 if (confirm_quest && p_ptr->inside_quest &&
64 (q_ptr->type == QUEST_TYPE_RANDOM ||
65 (q_ptr->flags & QUEST_FLAG_ONCE &&
66 q_ptr->status != QUEST_STATUS_COMPLETED) ||
67 (q_ptr->flags & QUEST_FLAG_TOWER &&
68 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
69 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
71 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
72 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
82 * @brief 魔法系コマンドが制限されているかを返す。
83 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
85 bool cmd_limit_cast(player_type *creature_ptr)
87 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
89 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
93 else if (creature_ptr->anti_magic)
95 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
98 else if (creature_ptr->shero)
100 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
107 bool cmd_limit_confused(player_type *creature_ptr)
109 if (creature_ptr->confused)
111 msg_print(_("混乱していてできない!", "You are too confused!"));
117 bool cmd_limit_image(player_type *creature_ptr)
119 if (creature_ptr->image)
121 msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
127 bool cmd_limit_stun(player_type *creature_ptr)
129 if (creature_ptr->stun)
131 msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
137 bool cmd_limit_arena(player_type *creature_ptr)
139 if (creature_ptr->inside_arena)
141 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
148 bool cmd_limit_blind(player_type *creature_ptr)
150 if (creature_ptr->blind)
152 msg_print(_("目が見えない。", "You can't see anything."));
157 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
163 bool cmd_limit_time_walk(player_type *creature_ptr)
165 if (creature_ptr->timewalk)
167 if (flush_failure) flush();
168 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
176 * @brief 階段を使って階層を昇る処理 / Go up one level
179 void do_cmd_go_up(void)
184 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
185 feature_type *f_ptr = &f_info[g_ptr->feat];
189 if (p_ptr->special_defense & KATA_MUSOU)
191 set_action(ACTION_NONE);
195 if (!have_flag(f_ptr->flags, FF_LESS))
197 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
201 /* Quest up stairs */
202 if (have_flag(f_ptr->flags, FF_QUEST))
204 /* Cancel the command */
205 if (!confirm_leave_level(FALSE)) return;
209 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
210 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
212 msg_print(_("上の階に登った。", "You enter the up staircase."));
216 p_ptr->inside_quest = g_ptr->special;
218 /* Activate the quest */
219 if (!quest[p_ptr->inside_quest].status)
221 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
223 init_flags = INIT_ASSIGN;
224 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
226 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
229 /* Leaving a quest */
230 if (!p_ptr->inside_quest)
232 current_floor_ptr->dun_level = 0;
234 p_ptr->leaving = TRUE;
239 take_turn(p_ptr, 100);
241 /* End the command */
245 if (!current_floor_ptr->dun_level)
251 go_up = confirm_leave_level(FALSE);
254 /* Cancel the command */
257 take_turn(p_ptr, 100);
259 if (autosave_l) do_cmd_save_game(TRUE);
261 /* For a random quest */
262 if (p_ptr->inside_quest &&
263 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
267 p_ptr->inside_quest = 0;
270 /* For a fixed quest */
271 if (p_ptr->inside_quest &&
272 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
276 p_ptr->inside_quest = g_ptr->special;
277 current_floor_ptr->dun_level = 0;
281 /* For normal dungeon and random quest */
285 if (have_flag(f_ptr->flags, FF_SHAFT))
287 /* Create a way back */
288 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
294 /* Create a way back */
295 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
300 /* Get out from current dungeon */
301 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
302 up_num = current_floor_ptr->dun_level;
304 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
307 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
308 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
309 else if (up_num == current_floor_ptr->dun_level)
310 msg_print(_("地上に戻った。", "You go back to the surface."));
312 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
313 p_ptr->leaving = TRUE;
318 * @brief 階段を使って階層を降りる処理 / Go down one level
321 void do_cmd_go_down(void)
324 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
325 feature_type *f_ptr = &f_info[g_ptr->feat];
327 bool fall_trap = FALSE;
330 if (p_ptr->special_defense & KATA_MUSOU)
332 set_action(ACTION_NONE);
336 if (!have_flag(f_ptr->flags, FF_MORE))
338 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
342 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
345 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
350 /* Quest down stairs */
351 else if (have_flag(f_ptr->flags, FF_QUEST))
353 /* Confirm Leaving */
354 if(!confirm_leave_level(TRUE)) return;
356 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
357 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
359 msg_print(_("下の階に降りた。", "You enter the down staircase."));
364 p_ptr->inside_quest = g_ptr->special;
366 /* Activate the quest */
367 if (!quest[p_ptr->inside_quest].status)
369 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
371 init_flags = INIT_ASSIGN;
372 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
374 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
377 /* Leaving a quest */
378 if (!p_ptr->inside_quest)
380 current_floor_ptr->dun_level = 0;
382 p_ptr->leaving = TRUE;
386 take_turn(p_ptr, 100);
391 DUNGEON_IDX target_dungeon = 0;
393 if (!current_floor_ptr->dun_level)
395 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
397 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
399 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
402 if (!max_dlv[target_dungeon])
404 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
405 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
406 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
409 /* Save old player position */
410 p_ptr->oldpx = p_ptr->x;
411 p_ptr->oldpy = p_ptr->y;
412 p_ptr->dungeon_idx = target_dungeon;
415 * Clear all saved floors
416 * and create a first saved floor
418 prepare_change_floor_mode(CFM_FIRST_FLOOR);
421 take_turn(p_ptr, 100);
423 if (autosave_l) do_cmd_save_game(TRUE);
426 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
429 if (!current_floor_ptr->dun_level)
431 /* Enter the dungeon just now */
432 p_ptr->enter_dungeon = TRUE;
433 down_num = d_info[p_ptr->dungeon_idx].mindepth;
438 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
439 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
444 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
451 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
455 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
456 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
458 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
462 p_ptr->leaving = TRUE;
466 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
470 if (have_flag(f_ptr->flags, FF_SHAFT))
472 /* Create a way back */
473 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
477 /* Create a way back */
478 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
486 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn
489 void do_cmd_search(void)
491 /* Allow repeated command */
494 /* Set repeat count */
495 command_rep = command_arg - 1;
496 p_ptr->redraw |= (PR_STATE);
501 take_turn(p_ptr, 100);
509 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
510 * @param y 走査対象にしたいマスのY座標
511 * @param x 走査対象にしたいマスのX座標
512 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
513 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
515 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
517 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
518 OBJECT_IDX this_o_idx, next_o_idx = 0;
520 /* Scan all objects in the grid */
521 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
525 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
526 next_o_idx = o_ptr->next_o_idx;
528 /* Skip unknown chests XXX XXX */
529 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
531 /* Check for non empty chest */
532 if ((o_ptr->tval == TV_CHEST) &&
533 (((!trapped) && (o_ptr->pval)) || /* non empty */
534 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
543 * @brief 箱を開けるコマンドのメインルーチン /
544 * Attempt to open the given chest at the given location
545 * @param y 箱の存在するマスのY座標
546 * @param x 箱の存在するマスのX座標
547 * @param o_idx 箱のオブジェクトID
548 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
550 * Assume there is no monster blocking the destination
552 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
557 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
559 take_turn(p_ptr, 100);
561 /* Attempt to unlock it */
564 /* Assume locked, and thus not open */
567 /* Get the "disarm" factor */
568 i = p_ptr->skill_dis;
570 /* Penalize some conditions */
571 if (p_ptr->blind || no_lite()) i = i / 10;
572 if (p_ptr->confused || p_ptr->image) i = i / 10;
574 /* Extract the difficulty */
577 /* Always have a small chance of success */
580 /* Success -- May still have traps */
581 if (randint0(100) < j)
583 msg_print(_("鍵をはずした。", "You have picked the lock."));
588 /* Failure -- Keep trying */
591 /* We may continue repeating */
593 if (flush_failure) flush();
594 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
599 /* Allowed to open */
602 /* Apply chest traps, if any */
603 chest_trap(y, x, o_idx);
605 /* Let the Chest drop items */
606 chest_death(FALSE, y, x, o_idx);
612 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
613 * Attempt to open the given chest at the given location
614 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
615 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
616 * @param test 地形条件を判定するための関数ポインタ
617 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
619 * @details Return the number of features around (or under) the character.
620 * Usually look for doors and floor traps.
622 static int count_dt(POSITION *y, POSITION *x, bool (*test)(FEAT_IDX feat), bool under)
628 /* Count how many matches */
631 /* Check around (and under) the character */
632 for (d = 0; d < 9; d++)
637 /* if not searching under player continue */
638 if ((d == 8) && !under) continue;
640 /* Extract adjacent (legal) location */
641 yy = p_ptr->y + ddy_ddd[d];
642 xx = p_ptr->x + ddx_ddd[d];
644 /* Get the current_floor_ptr->grid_array */
645 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
647 /* Must have knowledge */
648 if (!(g_ptr->info & (CAVE_MARK))) continue;
650 /* Feature code (applying "mimic" field) */
651 feat = get_feat_mimic(g_ptr);
653 /* Not looking for this feature */
654 if (!((*test)(feat))) continue;
659 /* Remember the location. Only useful if only one match */
670 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
671 * Return the number of chests around (or under) the character.
672 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
673 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
674 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
677 * If requested, count only trapped chests.
679 static int count_chests(POSITION *y, POSITION *x, bool trapped)
686 /* Count how many matches */
689 /* Check around (and under) the character */
690 for (d = 0; d < 9; d++)
692 /* Extract adjacent (legal) location */
693 POSITION yy = p_ptr->y + ddy_ddd[d];
694 POSITION xx = p_ptr->x + ddx_ddd[d];
696 /* No (visible) chest is there */
697 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
699 /* Grab the object */
700 o_ptr = ¤t_floor_ptr->o_list[o_idx];
703 if (o_ptr->pval == 0) continue;
705 /* No (known) traps here */
706 if (trapped && (!object_is_known(o_ptr) ||
707 !chest_traps[o_ptr->pval])) continue;
712 /* Remember the location. Only useful if only one match */
724 * @brief 「開ける」動作コマンドのサブルーチン /
725 * Perform the basic "open" command on doors
726 * @param y 対象を行うマスのY座標
727 * @param x 対象を行うマスのX座標
728 * @return 実際に処理が行われた場合TRUEを返す。
730 * Assume destination is a closed/locked/jammed door
731 * Assume there is no monster blocking the destination
732 * Returns TRUE if repeated commands may continue
734 static bool do_cmd_open_aux(POSITION y, POSITION x)
738 /* Get requested grid */
739 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
740 feature_type *f_ptr = &f_info[g_ptr->feat];
743 take_turn(p_ptr, 100);
745 /* Seeing true feature code (ignore mimic) */
748 if (!have_flag(f_ptr->flags, FF_OPEN))
751 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
755 else if (f_ptr->power)
758 i = p_ptr->skill_dis;
760 /* Penalize some conditions */
761 if (p_ptr->blind || no_lite()) i = i / 10;
762 if (p_ptr->confused || p_ptr->image) i = i / 10;
764 /* Extract the lock power */
767 /* Extract the difficulty */
770 /* Always have a small chance of success */
774 if (randint0(100) < j)
776 msg_print(_("鍵をはずした。", "You have picked the lock."));
779 cave_alter_feat(y, x, FF_OPEN);
781 sound(SOUND_OPENDOOR);
791 if (flush_failure) flush();
793 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
795 /* We may keep trying */
804 cave_alter_feat(y, x, FF_OPEN);
806 sound(SOUND_OPENDOOR);
812 * @brief 「開ける」コマンドのメインルーチン /
813 * Open a closed/locked/jammed door or a closed/locked chest.
816 * Unlocking a locked door/chest is worth one experience point.
818 void do_cmd_open(void)
826 if (p_ptr->wild_mode) return;
828 if (p_ptr->special_defense & KATA_MUSOU)
830 set_action(ACTION_NONE);
833 /* Option: Pick a direction */
836 int num_doors, num_chests;
838 /* Count closed doors (locked or jammed) */
839 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
841 /* Count chests (locked) */
842 num_chests = count_chests(&y, &x, FALSE);
844 /* See if only one target */
845 if (num_doors || num_chests)
847 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
849 if (!too_many) command_dir = coords_to_dir(y, x);
853 /* Allow repeated command */
856 /* Set repeat count */
857 command_rep = command_arg - 1;
858 p_ptr->redraw |= (PR_STATE);
864 /* Get a "repeated" direction */
865 if (get_rep_dir(&dir, TRUE))
870 /* Get requested location */
871 y = p_ptr->y + ddy[dir];
872 x = p_ptr->x + ddx[dir];
874 /* Get requested grid */
875 g_ptr = ¤t_floor_ptr->grid_array[y][x];
877 /* Feature code (applying "mimic" field) */
878 feat = get_feat_mimic(g_ptr);
880 /* Check for chest */
881 o_idx = chest_check(y, x, FALSE);
884 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
886 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
889 /* Monster in the way */
890 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
892 take_turn(p_ptr, 100);
893 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
901 more = do_cmd_open_chest(y, x, o_idx);
908 more = do_cmd_open_aux(y, x);
912 /* Cancel repeat unless we may continue */
913 if (!more) disturb(FALSE, FALSE);
919 * @brief 「閉じる」動作コマンドのサブルーチン /
920 * Perform the basic "close" command
921 * @param y 対象を行うマスのY座標
922 * @param x 対象を行うマスのX座標
923 * @return 実際に処理が行われた場合TRUEを返す。
925 * Assume destination is an open/broken door
926 * Assume there is no monster blocking the destination
927 * Returns TRUE if repeated commands may continue
929 static bool do_cmd_close_aux(POSITION y, POSITION x)
931 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
932 FEAT_IDX old_feat = g_ptr->feat;
935 take_turn(p_ptr, 100);
937 /* Seeing true feature code (ignore mimic) */
940 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
942 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
944 /* Hack -- object in the way */
945 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
946 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
948 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
953 cave_alter_feat(y, x, FF_CLOSE);
956 if (old_feat == g_ptr->feat)
958 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
962 sound(SOUND_SHUTDOOR);
971 * @brief 「閉じる」コマンドのメインルーチン /
972 * Close an open door.
975 * Unlocking a locked door/chest is worth one experience point.
977 void do_cmd_close(void)
984 if (p_ptr->wild_mode) return;
986 if (p_ptr->special_defense & KATA_MUSOU)
988 set_action(ACTION_NONE);
991 /* Option: Pick a direction */
994 /* Count open doors */
995 if (count_dt(&y, &x, is_open, FALSE) == 1)
997 command_dir = coords_to_dir(y, x);
1001 /* Allow repeated command */
1004 /* Set repeat count */
1005 command_rep = command_arg - 1;
1006 p_ptr->redraw |= (PR_STATE);
1008 /* Cancel the arg */
1012 /* Get a "repeated" direction */
1013 if (get_rep_dir(&dir, FALSE))
1018 y = p_ptr->y + ddy[dir];
1019 x = p_ptr->x + ddx[dir];
1020 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1022 /* Feature code (applying "mimic" field) */
1023 feat = get_feat_mimic(g_ptr);
1025 /* Require open/broken door */
1026 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1028 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1031 /* Monster in the way */
1032 else if (g_ptr->m_idx)
1034 take_turn(p_ptr, 100);
1036 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1042 /* Close the door */
1045 /* Close the door */
1046 more = do_cmd_close_aux(y, x);
1050 /* Cancel repeat unless we may continue */
1051 if (!more) disturb(FALSE, FALSE);
1056 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1057 * Determine if a given grid may be "tunneled"
1058 * @param y 対象を行うマスのY座標
1059 * @param x 対象を行うマスのX座標
1062 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1064 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1066 /* Must have knowledge */
1067 if (!(g_ptr->info & CAVE_MARK))
1069 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1074 /* Must be a wall/door/etc */
1075 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1077 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1087 * @brief 「掘る」動作コマンドのサブルーチン /
1088 * Perform the basic "tunnel" command
1089 * @param y 対象を行うマスのY座標
1090 * @param x 対象を行うマスのX座標
1091 * @return 実際に処理が行われた場合TRUEを返す。
1093 * Assumes that no monster is blocking the destination
1094 * Do not use twall anymore
1095 * Returns TRUE if repeated commands may continue
1097 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1100 feature_type *f_ptr, *mimic_f_ptr;
1105 /* Verify legality */
1106 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1108 take_turn(p_ptr, 100);
1110 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1111 f_ptr = &f_info[g_ptr->feat];
1112 power = f_ptr->power;
1114 /* Feature code (applying "mimic" field) */
1115 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1117 name = f_name + mimic_f_ptr->name;
1121 if (have_flag(f_ptr->flags, FF_PERMANENT))
1124 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1126 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1129 /* Map border (mimiccing Permanent wall) */
1132 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1137 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1140 if (p_ptr->skill_dig > randint0(20 * power))
1142 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1144 /* Remove the feature */
1145 cave_alter_feat(y, x, FF_TUNNEL);
1146 p_ptr->update |= (PU_FLOW);
1150 /* Message, keep digging */
1151 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1159 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1162 if (p_ptr->skill_dig > power + randint0(40 * power))
1164 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1167 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1168 p_ptr->update |= (PU_FLOW);
1171 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1173 /* Remove the feature */
1174 cave_alter_feat(y, x, FF_TUNNEL);
1176 chg_virtue(V_DILIGENCE, 1);
1177 chg_virtue(V_NATURE, -1);
1185 /* We may continue chopping */
1186 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1187 /* Occasional Search XXX XXX */
1188 if (randint0(100) < 25) search();
1192 /* We may continue tunelling */
1193 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1200 if (is_hidden_door(g_ptr))
1202 /* Occasional Search XXX XXX */
1203 if (randint0(100) < 25) search();
1210 * @brief 「掘る」動作コマンドのメインルーチン /
1211 * Tunnels through "walls" (including rubble and closed doors)
1215 * Note that you must tunnel in order to hit invisible monsters
1216 * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
1218 * Digging is very difficult without a "digger" weapon, but can be
1219 * accomplished by strong players using heavy weapons.
1222 void do_cmd_tunnel(void)
1231 if (p_ptr->special_defense & KATA_MUSOU)
1233 set_action(ACTION_NONE);
1236 /* Allow repeated command */
1239 /* Set repeat count */
1240 command_rep = command_arg - 1;
1241 p_ptr->redraw |= (PR_STATE);
1243 /* Cancel the arg */
1247 /* Get a direction to tunnel, or Abort */
1248 if (get_rep_dir(&dir,FALSE))
1251 y = p_ptr->y + ddy[dir];
1252 x = p_ptr->x + ddx[dir];
1254 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1256 /* Feature code (applying "mimic" field) */
1257 feat = get_feat_mimic(g_ptr);
1259 /* No tunnelling through doors */
1260 if (have_flag(f_info[feat].flags, FF_DOOR))
1262 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1265 /* No tunnelling through most features */
1266 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1268 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1271 /* A monster is in the way */
1272 else if (g_ptr->m_idx)
1274 take_turn(p_ptr, 100);
1276 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1285 /* Tunnel through walls */
1286 more = do_cmd_tunnel_aux(y, x);
1290 /* Cancel repetition unless we can continue */
1291 if (!more) disturb(FALSE, FALSE);
1295 * @brief 移動処理による簡易な「開く」処理 /
1297 * @return 開く処理が実際に試みられた場合TRUEを返す
1300 * If there is a jammed/closed/locked door at the given location,
1301 * then attempt to unlock/open it. Return TRUE if an attempt was
1302 * made (successful or not), otherwise return FALSE.
1304 * The code here should be nearly identical to that in
1305 * do_cmd_open_test() and do_cmd_open_aux().
1308 bool easy_open_door(POSITION y, POSITION x)
1312 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1313 feature_type *f_ptr = &f_info[g_ptr->feat];
1315 /* Must be a closed door */
1316 if (!is_closed_door(g_ptr->feat))
1322 if (!have_flag(f_ptr->flags, FF_OPEN))
1325 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1330 else if (f_ptr->power)
1333 i = p_ptr->skill_dis;
1335 /* Penalize some conditions */
1336 if (p_ptr->blind || no_lite()) i = i / 10;
1337 if (p_ptr->confused || p_ptr->image) i = i / 10;
1339 /* Extract the lock power */
1342 /* Extract the difficulty */
1345 /* Always have a small chance of success */
1349 if (randint0(100) < j)
1351 msg_print(_("鍵をはずした。", "You have picked the lock."));
1354 cave_alter_feat(y, x, FF_OPEN);
1356 sound(SOUND_OPENDOOR);
1366 if (flush_failure) flush();
1368 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1377 cave_alter_feat(y, x, FF_OPEN);
1379 sound(SOUND_OPENDOOR);
1385 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1386 * Perform the basic "disarm" command
1387 * @param y 解除を行うマスのY座標
1388 * @param x 解除を行うマスのX座標
1389 * @param o_idx 箱のオブジェクトID
1390 * @return ターンを消費する処理が行われた場合TRUEを返す
1393 * Assume destination is a visible trap
1394 * Assume there is no monster blocking the destination
1395 * Returns TRUE if repeated commands may continue
1398 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1402 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1404 take_turn(p_ptr, 100);
1406 /* Get the "disarm" factor */
1407 i = p_ptr->skill_dis;
1409 /* Penalize some conditions */
1410 if (p_ptr->blind || no_lite()) i = i / 10;
1411 if (p_ptr->confused || p_ptr->image) i = i / 10;
1413 /* Extract the difficulty */
1414 j = i - o_ptr->pval;
1416 /* Always have a small chance of success */
1419 /* Must find the trap first. */
1420 if (!object_is_known(o_ptr))
1422 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1426 /* Already disarmed/unlocked */
1427 else if (o_ptr->pval <= 0)
1429 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1432 /* No traps to find. */
1433 else if (!chest_traps[o_ptr->pval])
1435 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1438 /* Success (get a lot of experience) */
1439 else if (randint0(100) < j)
1441 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1442 gain_exp(o_ptr->pval);
1443 o_ptr->pval = (0 - o_ptr->pval);
1446 /* Failure -- Keep trying */
1447 else if ((i > 5) && (randint1(i) > 5))
1449 /* We may keep trying */
1451 if (flush_failure) flush();
1452 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1455 /* Failure -- Set off the trap */
1458 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1460 chest_trap(y, x, o_idx);
1467 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1468 * Perform the basic "disarm" command
1469 * @param y 解除を行うマスのY座標
1470 * @param x 解除を行うマスのX座標
1471 * @param dir プレイヤーからみた方向ID
1472 * @return ターンを消費する処理が行われた場合TRUEを返す
1475 * Assume destination is a visible trap
1476 * Assume there is no monster blocking the destination
1477 * Returns TRUE if repeated commands may continue
1481 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1483 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1486 feature_type *f_ptr = &f_info[g_ptr->feat];
1488 /* Access trap name */
1489 concptr name = (f_name + f_ptr->name);
1491 /* Extract trap "power" */
1492 int power = f_ptr->power;
1495 /* Get the "disarm" factor */
1496 int i = p_ptr->skill_dis;
1499 take_turn(p_ptr, 100);
1501 /* Penalize some conditions */
1502 if (p_ptr->blind || no_lite()) i = i / 10;
1503 if (p_ptr->confused || p_ptr->image) i = i / 10;
1505 /* Extract the difficulty */
1508 /* Always have a small chance of success */
1512 if (randint0(100) < j)
1514 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1519 /* Remove the trap */
1520 cave_alter_feat(y, x, FF_DISARM);
1522 /* Move the player onto the trap */
1523 move_player(dir, easy_disarm, FALSE);
1526 /* Failure -- Keep trying */
1527 else if ((i > 5) && (randint1(i) > 5))
1530 if (flush_failure) flush();
1532 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1534 /* We may keep trying */
1538 /* Failure -- Set off the trap */
1541 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1542 /* Move the player onto the trap */
1543 move_player(dir, easy_disarm, FALSE);
1550 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1551 * Disarms a trap, or chest
1554 void do_cmd_disarm(void)
1562 if (p_ptr->wild_mode) return;
1564 if (p_ptr->special_defense & KATA_MUSOU)
1566 set_action(ACTION_NONE);
1569 /* Option: Pick a direction */
1572 int num_traps, num_chests;
1574 /* Count visible traps */
1575 num_traps = count_dt(&y, &x, is_trap, TRUE);
1577 /* Count chests (trapped) */
1578 num_chests = count_chests(&y, &x, TRUE);
1580 /* See if only one target */
1581 if (num_traps || num_chests)
1583 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1584 if (!too_many) command_dir = coords_to_dir(y, x);
1589 /* Allow repeated command */
1592 /* Set repeat count */
1593 command_rep = command_arg - 1;
1594 p_ptr->redraw |= (PR_STATE);
1596 /* Cancel the arg */
1600 /* Get a direction (or abort) */
1601 if (get_rep_dir(&dir,TRUE))
1606 y = p_ptr->y + ddy[dir];
1607 x = p_ptr->x + ddx[dir];
1608 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1610 /* Feature code (applying "mimic" field) */
1611 feat = get_feat_mimic(g_ptr);
1613 /* Check for chests */
1614 o_idx = chest_check(y, x, TRUE);
1617 if (!is_trap(feat) && !o_idx)
1619 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1622 /* Monster in the way */
1623 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1625 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1634 more = do_cmd_disarm_chest(y, x, o_idx);
1640 more = do_cmd_disarm_aux(y, x, dir);
1644 /* Cancel repeat unless told not to */
1645 if (!more) disturb(FALSE, FALSE);
1650 * @brief 「打ち破る」動作コマンドのサブルーチン /
1651 * Perform the basic "bash" command
1652 * @param y 対象を行うマスのY座標
1653 * @param x 対象を行うマスのX座標
1654 * @param dir プレイヤーから見たターゲットの方角ID
1655 * @return 実際に処理が行われた場合TRUEを返す。
1658 * Assume destination is a closed/locked/jammed door
1659 * Assume there is no monster blocking the destination
1660 * Returns TRUE if repeated commands may continue
1663 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1665 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1668 feature_type *f_ptr = &f_info[g_ptr->feat];
1670 /* Hack -- Bash power based on strength */
1671 /* (Ranges from 3 to 20 to 100 to 200) */
1672 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1674 /* Extract door power */
1675 int temp = f_ptr->power;
1679 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1681 take_turn(p_ptr, 100);
1683 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1685 /* Compare bash power to door power */
1686 temp = (bash - (temp * 10));
1688 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1690 /* Hack -- always have a chance */
1691 if (temp < 1) temp = 1;
1693 /* Hack -- attempt to bash down the door */
1694 if (randint0(100) < temp)
1696 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1698 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1700 /* Break down the door */
1701 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1703 cave_alter_feat(y, x, FF_BASH);
1709 cave_alter_feat(y, x, FF_OPEN);
1712 /* Hack -- Fall through the door */
1713 move_player(dir, FALSE, FALSE);
1716 /* Saving throw against stun */
1717 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1720 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1722 /* Allow repeated bashing */
1726 /* High dexterity yields coolness */
1729 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1731 /* Hack -- Lose balance ala paralysis */
1732 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1739 * @brief 「打ち破る」動作コマンドのメインルーチン /
1740 * Bash open a door, success based on character strength
1744 * For a closed door, pval is positive if locked; negative if stuck.
1746 * For an open door, pval is positive for a broken door.
1748 * A closed door can be opened - harder if locked. Any door might be
1749 * bashed open (and thereby broken). Bashing a door is (potentially)
1750 * faster! You move into the door way. To open a stuck door, it must
1751 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1753 * Creatures can also open or bash doors, see elsewhere.
1756 void do_cmd_bash(void)
1762 if (p_ptr->wild_mode) return;
1764 if (p_ptr->special_defense & KATA_MUSOU)
1766 set_action(ACTION_NONE);
1769 /* Allow repeated command */
1772 /* Set repeat count */
1773 command_rep = command_arg - 1;
1774 p_ptr->redraw |= (PR_STATE);
1776 /* Cancel the arg */
1780 /* Get a "repeated" direction */
1781 if (get_rep_dir(&dir,FALSE))
1786 y = p_ptr->y + ddy[dir];
1787 x = p_ptr->x + ddx[dir];
1789 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1791 /* Feature code (applying "mimic" field) */
1792 feat = get_feat_mimic(g_ptr);
1794 /* Nothing useful */
1795 if (!have_flag(f_info[feat].flags, FF_BASH))
1797 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1800 /* Monster in the way */
1801 else if (g_ptr->m_idx)
1803 take_turn(p_ptr, 100);
1805 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1811 /* Bash a closed door */
1815 more = do_cmd_bash_aux(y, x, dir);
1819 /* Unless valid action taken, cancel bash */
1820 if (!more) disturb(FALSE, FALSE);
1825 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1829 * Manipulate an adjacent grid in some way
1831 * Attack monsters, tunnel through walls, disarm traps, open doors.
1833 * Consider confusion
1835 * This command must always take a current_world_ptr->game_turn, to prevent free detection
1836 * of invisible monsters.
1839 void do_cmd_alter(void)
1846 if (p_ptr->special_defense & KATA_MUSOU)
1848 set_action(ACTION_NONE);
1851 /* Allow repeated command */
1854 /* Set repeat count */
1855 command_rep = command_arg - 1;
1856 p_ptr->redraw |= (PR_STATE);
1858 /* Cancel the arg */
1862 /* Get a direction */
1863 if (get_rep_dir(&dir,TRUE))
1866 feature_type *f_ptr;
1868 y = p_ptr->y + ddy[dir];
1869 x = p_ptr->x + ddx[dir];
1871 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1873 /* Feature code (applying "mimic" field) */
1874 feat = get_feat_mimic(g_ptr);
1875 f_ptr = &f_info[feat];
1877 take_turn(p_ptr, 100);
1885 else if (have_flag(f_ptr->flags, FF_OPEN))
1887 more = do_cmd_open_aux(y, x);
1890 /* Bash jammed doors */
1891 else if (have_flag(f_ptr->flags, FF_BASH))
1893 more = do_cmd_bash_aux(y, x, dir);
1896 /* Tunnel through walls */
1897 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1899 more = do_cmd_tunnel_aux(y, x);
1902 /* Close open doors */
1903 else if (have_flag(f_ptr->flags, FF_CLOSE))
1905 more = do_cmd_close_aux(y, x);
1909 else if (have_flag(f_ptr->flags, FF_DISARM))
1911 more = do_cmd_disarm_aux(y, x, dir);
1916 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1920 /* Cancel repetition unless we can continue */
1921 if (!more) disturb(FALSE, FALSE);
1927 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1928 * Find the index of some "spikes", if possible.
1929 * @param ip くさびとして打てるオブジェクトのID
1930 * @return オブジェクトがある場合TRUEを返す
1933 * Let user choose a pile of spikes, perhaps?
1936 static bool get_spike(INVENTORY_IDX *ip)
1940 /* Check every item in the pack */
1941 for (i = 0; i < INVEN_PACK; i++)
1943 object_type *o_ptr = &p_ptr->inventory_list[i];
1944 if (!o_ptr->k_idx) continue;
1946 /* Check the "tval" code */
1947 if (o_ptr->tval == TV_SPIKE)
1949 /* Save the spike index */
1962 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1963 * Jam a closed door with a spike
1967 * This command may NOT be repeated
1970 void do_cmd_spike(void)
1974 if (p_ptr->wild_mode) return;
1976 if (p_ptr->special_defense & KATA_MUSOU)
1978 set_action(ACTION_NONE);
1981 /* Get a "repeated" direction */
1982 if (get_rep_dir(&dir, FALSE))
1989 y = p_ptr->y + ddy[dir];
1990 x = p_ptr->x + ddx[dir];
1991 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1993 /* Feature code (applying "mimic" field) */
1994 feat = get_feat_mimic(g_ptr);
1996 /* Require closed door */
1997 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1999 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2003 else if (!get_spike(&item))
2005 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2008 /* Is a monster in the way? */
2009 else if (g_ptr->m_idx)
2011 take_turn(p_ptr, 100);
2013 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2022 take_turn(p_ptr, 100);
2024 /* Successful jamming */
2025 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2026 cave_alter_feat(y, x, FF_SPIKE);
2028 /* Use up, and describe, a single spike, from the bottom */
2029 inven_item_increase(item, -1);
2030 inven_item_describe(item);
2031 inven_item_optimize(item);
2039 * @brief 「歩く」動作コマンドのメインルーチン /
2040 * Support code for the "Walk" and "Jump" commands
2041 * @param pickup アイテムの自動拾いを行うならTRUE
2044 void do_cmd_walk(bool pickup)
2051 /* Allow repeated command */
2054 /* Set repeat count */
2055 command_rep = command_arg - 1;
2056 p_ptr->redraw |= (PR_STATE);
2058 /* Cancel the arg */
2062 /* Get a "repeated" direction */
2063 if (get_rep_dir(&dir, FALSE))
2065 take_turn(p_ptr, 100);
2067 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2069 set_action(ACTION_NONE);
2072 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2073 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2074 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2076 /* Actually move the character */
2077 move_player(dir, pickup, FALSE);
2079 /* Allow more walking */
2083 /* Hack again -- Is there a special encounter ??? */
2084 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2086 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2089 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2091 /* Inform the player of his horrible fate :=) */
2092 msg_print(_("襲撃だ!", "You are ambushed !"));
2094 /* Go into large wilderness view */
2095 p_ptr->oldpy = randint1(MAX_HGT-2);
2096 p_ptr->oldpx = randint1(MAX_WID-2);
2097 change_wild_mode(TRUE);
2099 /* Give first move to monsters */
2100 take_turn(p_ptr, 100);
2105 /* Cancel repeat unless we may continue */
2106 if (!more) disturb(FALSE, FALSE);
2111 * @brief 「走る」動作コマンドのメインルーチン /
2115 void do_cmd_run(void)
2118 if (cmd_limit_confused(p_ptr)) return;
2120 if (p_ptr->special_defense & KATA_MUSOU)
2122 set_action(ACTION_NONE);
2125 /* Get a "repeated" direction */
2126 if (get_rep_dir(&dir,FALSE))
2128 /* Hack -- Set the run counter */
2129 running = (command_arg ? command_arg : 1000);
2138 * @brief 「留まる」動作コマンドのメインルーチン /
2139 * Stay still. Search. Enter stores.
2140 * Pick up treasure if "pickup" is true.
2141 * @param pickup アイテムの自動拾いを行うならTRUE
2144 void do_cmd_stay(bool pickup)
2146 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2148 /* Allow repeated command */
2151 /* Set repeat count */
2152 command_rep = command_arg - 1;
2153 p_ptr->redraw |= (PR_STATE);
2155 /* Cancel the arg */
2159 take_turn(p_ptr, 100);
2161 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2162 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2167 * @brief 「休む」動作コマンドのメインルーチン /
2168 * Resting allows a player to safely restore his hp -RAK-
2171 void do_cmd_rest(void)
2174 set_action(ACTION_NONE);
2176 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2178 stop_singing(p_ptr);
2182 if (hex_spelling_any()) stop_hex_spell_all();
2184 /* Prompt for time if needed */
2185 if (command_arg <= 0)
2187 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2188 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2194 strcpy(out_val, "&");
2196 /* Ask for duration */
2197 if (!get_string(p, out_val, 4)) return;
2199 /* Rest until done */
2200 if (out_val[0] == '&')
2202 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2206 else if (out_val[0] == '*')
2208 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2214 command_arg = (COMMAND_ARG)atoi(out_val);
2215 if (command_arg <= 0) return;
2219 if (command_arg > 9999) command_arg = 9999;
2221 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2223 /* Take a current_world_ptr->game_turn (?) */
2224 take_turn(p_ptr, 100);
2226 /* The sin of sloth */
2227 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2229 /* Why are you sleeping when there's no need? WAKE UP!*/
2230 if ((p_ptr->chp == p_ptr->mhp) &&
2231 (p_ptr->csp == p_ptr->msp) &&
2232 !p_ptr->blind && !p_ptr->confused &&
2233 !p_ptr->poisoned && !p_ptr->afraid &&
2234 !p_ptr->stun && !p_ptr->cut &&
2235 !p_ptr->slow && !p_ptr->paralyzed &&
2236 !p_ptr->image && !p_ptr->word_recall &&
2237 !p_ptr->alter_reality)
2238 chg_virtue(V_DILIGENCE, -1);
2240 /* Save the rest code */
2241 p_ptr->resting = command_arg;
2242 p_ptr->action = ACTION_REST;
2243 p_ptr->update |= (PU_BONUS);
2244 update_creature(p_ptr);
2246 p_ptr->redraw |= (PR_STATE);
2255 * @brief 射撃処理のメインルーチン
2258 void do_cmd_fire(SPELL_IDX snipe_type)
2261 object_type *j_ptr, *ammo_ptr;
2264 if(p_ptr->wild_mode) return;
2266 p_ptr->is_fired = FALSE; /* not fired yet */
2268 /* Get the "bow" (if any) */
2269 j_ptr = &p_ptr->inventory_list[INVEN_BOW];
2271 /* Require a launcher */
2274 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2279 if (j_ptr->sval == SV_CRIMSON)
2281 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2286 if (j_ptr->sval == SV_HARP)
2288 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2294 if (p_ptr->special_defense & KATA_MUSOU)
2296 set_action(ACTION_NONE);
2299 /* Require proper missile */
2300 item_tester_tval = p_ptr->tval_ammo;
2302 q = _("どれを撃ちますか? ", "Fire which item? ");
2303 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2306 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2314 exe_fire(item, j_ptr, snipe_type);
2316 if (!p_ptr->is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2318 /* Sniper actions after some shootings */
2319 if (snipe_type == SP_AWAY)
2321 teleport_player(10 + (p_ptr->concent * 2), 0L);
2323 if (snipe_type == SP_FINAL)
2325 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2326 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2327 (void)set_stun(p_ptr->stun + randint1(25));
2333 * @brief 投射処理メインルーチン /
2334 * Throw an object from the pack or floor.
2336 * @param boomerang ブーメラン処理ならばTRUE
2337 * @param shuriken 忍者の手裏剣処理ならばTRUE
2338 * @return ターンを消費した場合TRUEを返す
2341 * Note: "unseen" monsters are very hard to hit.
2343 * Should throwing a weapon do full damage? Should it allow the magic
2344 * to hit bonus of the weapon to have an effect? Should it ever cause
2345 * the item to be destroyed? Should it do any damage at all?
2348 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2353 POSITION y, x, ty, tx, prev_y, prev_x;
2354 POSITION ny[19], nx[19];
2355 int chance, tdam, tdis;
2356 int mul, div, dd, ds;
2357 int cur_dis, visible;
2364 bool hit_body = FALSE;
2365 bool hit_wall = FALSE;
2366 bool equiped_item = FALSE;
2367 bool return_when_thrown = FALSE;
2369 GAME_TEXT o_name[MAX_NLEN];
2371 int msec = delay_factor * delay_factor * delay_factor;
2373 BIT_FLAGS flgs[TR_FLAG_SIZE];
2375 bool come_back = FALSE;
2376 bool do_drop = TRUE;
2378 if (p_ptr->wild_mode) return FALSE;
2380 if (p_ptr->special_defense & KATA_MUSOU)
2382 set_action(ACTION_NONE);
2388 o_ptr = &p_ptr->inventory_list[item];
2392 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2394 item_tester_hook = item_tester_hook_boomerang;
2395 q = _("どの武器を投げますか? ", "Throw which item? ");
2396 s = _("投げる武器がない。", "You have nothing to throw.");
2397 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2404 else if (has_melee_weapon(INVEN_LARM))
2407 o_ptr = &p_ptr->inventory_list[item];
2412 o_ptr = &p_ptr->inventory_list[item];
2417 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2418 s = _("投げるアイテムがない。", "You have nothing to throw.");
2419 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2427 /* Item is cursed */
2428 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2430 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2434 if (p_ptr->inside_arena && !boomerang)
2436 if (o_ptr->tval != TV_SPIKE)
2438 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2447 /* Obtain a local object */
2448 object_copy(q_ptr, o_ptr);
2450 /* Extract the thrown object's flags. */
2451 object_flags(q_ptr, flgs);
2452 torch_flags(q_ptr, flgs);
2454 /* Distribute the charges of rods/wands between the stacks */
2455 distribute_charges(o_ptr, q_ptr, 1);
2460 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2462 if (p_ptr->mighty_throw) mult += 3;
2464 /* Extract a "distance multiplier" */
2465 /* Changed for 'launcher' mutation */
2466 mul = 10 + 2 * (mult - 1);
2468 /* Enforce a minimum "weight" of one pound */
2469 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2470 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2472 /* Hack -- Distance -- Reward strength, penalize weight */
2473 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2475 /* Max distance of 10-18 */
2476 if (tdis > mul) tdis = mul;
2480 ty = randint0(101) - 50 + p_ptr->y;
2481 tx = randint0(101) - 50 + p_ptr->x;
2485 project_length = tdis + 1;
2487 /* Get a direction (or cancel) */
2488 if (!get_aim_dir(&dir)) return FALSE;
2490 /* Predict the "target" location */
2491 tx = p_ptr->x + 99 * ddx[dir];
2492 ty = p_ptr->y + 99 * ddy[dir];
2494 /* Check for "target request" */
2495 if ((dir == 5) && target_okay())
2501 project_length = 0; /* reset to default */
2504 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2505 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2506 return_when_thrown = TRUE;
2508 /* Reduce and describe p_ptr->inventory_list */
2511 inven_item_increase(item, -1);
2512 if (!return_when_thrown)
2513 inven_item_describe(item);
2514 inven_item_optimize(item);
2517 /* Reduce and describe floor item */
2520 floor_item_increase(0 - item, -1);
2521 floor_item_optimize(0 - item);
2523 if (item >= INVEN_RARM)
2525 equiped_item = TRUE;
2526 p_ptr->redraw |= (PR_EQUIPPY);
2529 take_turn(p_ptr, 100);
2531 /* Rogue and Ninja gets bonus */
2532 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2533 p_ptr->energy_use -= p_ptr->lev;
2535 /* Start at the player */
2541 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2542 else shuriken = FALSE;
2544 /* Chance of hitting */
2545 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2546 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2547 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2549 if (shuriken) chance *= 2;
2554 /* Travel until stopped */
2555 for (cur_dis = 0; cur_dis <= tdis; )
2557 /* Hack -- Stop at the target */
2558 if ((y == ty) && (x == tx)) break;
2560 /* Calculate the new location (see "project()") */
2563 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2565 /* Stopped by walls/doors */
2566 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2569 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;
2572 /* The player can see the (on screen) missile */
2573 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2575 SYMBOL_CODE c = object_char(q_ptr);
2576 TERM_COLOR a = object_attr(q_ptr);
2578 /* Draw, Hilite, Fresh, Pause, Erase */
2579 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2580 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2582 Term_xtra(TERM_XTRA_DELAY, msec);
2583 lite_spot(ny[cur_dis], nx[cur_dis]);
2587 /* The player cannot see the missile */
2590 /* Pause anyway, for consistancy */
2591 Term_xtra(TERM_XTRA_DELAY, msec);
2597 /* Save the new location */
2601 /* Advance the distance */
2604 /* Monster here, Try to hit it */
2605 if (current_floor_ptr->grid_array[y][x].m_idx)
2607 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2608 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2609 GAME_TEXT m_name[MAX_NLEN];
2610 monster_name(g_ptr->m_idx, m_name);
2612 /* Check the visibility */
2613 visible = m_ptr->ml;
2615 /* Note the collision */
2618 /* Did we hit it (penalize range) */
2619 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2623 /* Handle unseen monster */
2626 /* Invisible monster */
2627 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2630 /* Handle visible monster */
2633 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2637 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2638 health_track(g_ptr->m_idx);
2642 /* Hack -- Base damage from thrown object */
2645 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2646 tdam = damroll(dd, ds);
2647 /* Apply special damage */
2648 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2649 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2650 if (q_ptr->to_d > 0)
2651 tdam += q_ptr->to_d;
2653 tdam += -q_ptr->to_d;
2657 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2658 tdam += p_ptr->to_d_m;
2660 else if (have_flag(flgs, TR_THROW))
2663 tdam += p_ptr->to_d_m;
2671 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2674 /* No negative damage */
2675 if (tdam < 0) tdam = 0;
2677 /* Modify the damage */
2678 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2680 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2681 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2683 /* Hit the monster, check for death */
2684 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2692 message_pain(g_ptr->m_idx, tdam);
2694 /* Anger the monster */
2695 if ((tdam > 0) && !object_is_potion(q_ptr))
2696 anger_monster(m_ptr);
2698 if (fear && m_ptr->ml)
2701 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2711 /* decrease toach's fuel */
2712 if (hit_body) torch_lost_fuel(q_ptr);
2714 /* Chance of breakage (during attacks) */
2715 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2717 /* Figurines transform */
2718 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2722 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2723 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2724 else if (object_is_cursed(q_ptr))
2725 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2729 /* Potions smash open */
2730 if (object_is_potion(q_ptr))
2732 if (hit_body || hit_wall || (randint1(100) < j))
2734 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2736 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2738 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2739 if (current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2741 GAME_TEXT m_name[MAX_NLEN];
2742 monster_desc(m_name, m_ptr, 0);
2743 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2744 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2755 if (return_when_thrown)
2757 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2758 char o2_name[MAX_NLEN];
2759 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2762 if (boomerang) back_chance += 4+randint1(5);
2763 if (super_boomerang) back_chance += 100;
2764 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2766 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2768 for (i = cur_dis - 1; i > 0; i--)
2770 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2772 char c = object_char(q_ptr);
2773 byte a = object_attr(q_ptr);
2775 /* Draw, Hilite, Fresh, Pause, Erase */
2776 print_rel(c, a, ny[i], nx[i]);
2777 move_cursor_relative(ny[i], nx[i]);
2779 Term_xtra(TERM_XTRA_DELAY, msec);
2780 lite_spot(ny[i], nx[i]);
2785 /* Pause anyway, for consistancy */
2786 Term_xtra(TERM_XTRA_DELAY, msec);
2789 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2791 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2798 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2802 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2810 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2816 if (item == INVEN_RARM || item == INVEN_LARM)
2818 /* Access the wield slot */
2819 o_ptr = &p_ptr->inventory_list[item];
2821 /* Wear the new stuff */
2822 object_copy(o_ptr, q_ptr);
2824 p_ptr->total_weight += q_ptr->weight;
2826 /* Increment the equip counter by hand */
2829 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2830 p_ptr->window |= (PW_EQUIP);
2838 else if (equiped_item)
2846 if (cave_have_flag_bold(y, x, FF_PROJECT))
2848 (void)drop_near(q_ptr, j, y, x);
2852 (void)drop_near(q_ptr, j, prev_y, prev_x);
2860 * @brief 自殺するコマンドのメインルーチン
2861 * Hack -- commit suicide
2865 void do_cmd_suicide(void)
2872 /* Verify Retirement */
2873 if (p_ptr->total_winner)
2876 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2879 /* Verify Suicide */
2883 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2887 if (!p_ptr->noscore)
2889 /* Special Verification for suicide */
2890 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2895 if (i != '@') return;
2897 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2900 /* Initialize "last message" buffer */
2901 if (p_ptr->last_message) string_free(p_ptr->last_message);
2902 p_ptr->last_message = NULL;
2904 /* Hack -- Note *winning* message */
2905 if (p_ptr->total_winner && last_words)
2907 char buf[1024] = "";
2908 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2911 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2912 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2916 p_ptr->last_message = string_make(buf);
2917 msg_print(p_ptr->last_message);
2922 p_ptr->playing = FALSE;
2924 /* Kill the player */
2925 p_ptr->is_dead = TRUE;
2926 p_ptr->leaving = TRUE;
2928 if (!p_ptr->total_winner)
2930 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
2931 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2932 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
2935 /* Cause of death */
2936 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));