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.
18 #include "object-hook.h"
19 #include "projection.h"
20 #include "spells-summon.h"
21 #include "spells-status.h"
22 #include "monster-status.h"
26 #include "player-status.h"
27 #include "realm-hex.h"
32 #include "player-move.h"
33 #include "object-broken.h"
36 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
37 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
38 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
40 static bool confirm_leave_level(bool down_stair)
42 quest_type *q_ptr = &quest[p_ptr->inside_quest];
44 /* Confirm leaving from once only quest */
45 if (confirm_quest && p_ptr->inside_quest &&
46 (q_ptr->type == QUEST_TYPE_RANDOM ||
47 (q_ptr->flags & QUEST_FLAG_ONCE &&
48 q_ptr->status != QUEST_STATUS_COMPLETED) ||
49 (q_ptr->flags & QUEST_FLAG_TOWER &&
50 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
51 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
53 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
54 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
64 * @brief 魔法系コマンドが制限されているかを返す。
65 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
67 bool cmd_limit_cast(player_type *creature_ptr)
69 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
71 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
75 else if (creature_ptr->anti_magic)
77 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
80 else if (creature_ptr->shero)
82 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
89 bool cmd_limit_confused(player_type *creature_ptr)
91 if (creature_ptr->confused)
93 msg_print(_("混乱していてできない!", "You are too confused!"));
99 bool cmd_limit_image(player_type *creature_ptr)
101 if (creature_ptr->image)
103 msg_print(_("幻覚が見えて集中できない!", "Your hallucinations prevent you from concentrating!"));
109 bool cmd_limit_stun(player_type *creature_ptr)
111 if (creature_ptr->stun)
113 msg_print(_("頭が朦朧としていて集中できない!", "You are too stunned!"));
119 bool cmd_limit_arena(player_type *creature_ptr)
121 if (creature_ptr->inside_arena)
123 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
130 bool cmd_limit_blind(player_type *creature_ptr)
132 if (creature_ptr->blind)
134 msg_print(_("目が見えない。", "You can't see anything."));
139 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
145 bool cmd_limit_time_walk(player_type *creature_ptr)
147 if (creature_ptr->timewalk)
149 if (flush_failure) flush();
150 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
158 * @brief 階段を使って階層を昇る処理 / Go up one level
161 void do_cmd_go_up(void)
166 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
167 feature_type *f_ptr = &f_info[g_ptr->feat];
171 if (p_ptr->special_defense & KATA_MUSOU)
173 set_action(ACTION_NONE);
177 if (!have_flag(f_ptr->flags, FF_LESS))
179 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
183 /* Quest up stairs */
184 if (have_flag(f_ptr->flags, FF_QUEST))
186 /* Cancel the command */
187 if (!confirm_leave_level(FALSE)) return;
191 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
192 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
194 msg_print(_("上の階に登った。", "You enter the up staircase."));
198 p_ptr->inside_quest = g_ptr->special;
200 /* Activate the quest */
201 if (!quest[p_ptr->inside_quest].status)
203 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
205 init_flags = INIT_ASSIGN;
206 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
208 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
211 /* Leaving a quest */
212 if (!p_ptr->inside_quest)
214 current_floor_ptr->dun_level = 0;
216 p_ptr->leaving = TRUE;
221 take_turn(p_ptr, 100);
223 /* End the command */
227 if (!current_floor_ptr->dun_level)
233 go_up = confirm_leave_level(FALSE);
236 /* Cancel the command */
239 take_turn(p_ptr, 100);
241 if (autosave_l) do_cmd_save_game(TRUE);
243 /* For a random quest */
244 if (p_ptr->inside_quest &&
245 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
249 p_ptr->inside_quest = 0;
252 /* For a fixed quest */
253 if (p_ptr->inside_quest &&
254 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
258 p_ptr->inside_quest = g_ptr->special;
259 current_floor_ptr->dun_level = 0;
263 /* For normal dungeon and random quest */
267 if (have_flag(f_ptr->flags, FF_SHAFT))
269 /* Create a way back */
270 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
276 /* Create a way back */
277 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
282 /* Get out from current dungeon */
283 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
284 up_num = current_floor_ptr->dun_level;
286 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
289 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
290 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
291 else if (up_num == current_floor_ptr->dun_level)
292 msg_print(_("地上に戻った。", "You go back to the surface."));
294 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
295 p_ptr->leaving = TRUE;
300 * @brief 階段を使って階層を降りる処理 / Go down one level
303 void do_cmd_go_down(void)
306 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
307 feature_type *f_ptr = &f_info[g_ptr->feat];
309 bool fall_trap = FALSE;
312 if (p_ptr->special_defense & KATA_MUSOU)
314 set_action(ACTION_NONE);
318 if (!have_flag(f_ptr->flags, FF_MORE))
320 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
324 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
327 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
332 /* Quest down stairs */
333 else if (have_flag(f_ptr->flags, FF_QUEST))
335 /* Confirm Leaving */
336 if(!confirm_leave_level(TRUE)) return;
338 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
339 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
341 msg_print(_("下の階に降りた。", "You enter the down staircase."));
346 p_ptr->inside_quest = g_ptr->special;
348 /* Activate the quest */
349 if (!quest[p_ptr->inside_quest].status)
351 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
353 init_flags = INIT_ASSIGN;
354 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
356 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
359 /* Leaving a quest */
360 if (!p_ptr->inside_quest)
362 current_floor_ptr->dun_level = 0;
364 p_ptr->leaving = TRUE;
368 take_turn(p_ptr, 100);
373 DUNGEON_IDX target_dungeon = 0;
375 if (!current_floor_ptr->dun_level)
377 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
379 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
381 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
384 if (!max_dlv[target_dungeon])
386 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
387 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
388 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
391 /* Save old player position */
392 p_ptr->oldpx = p_ptr->x;
393 p_ptr->oldpy = p_ptr->y;
394 p_ptr->dungeon_idx = target_dungeon;
397 * Clear all saved floors
398 * and create a first saved floor
400 prepare_change_floor_mode(CFM_FIRST_FLOOR);
403 take_turn(p_ptr, 100);
405 if (autosave_l) do_cmd_save_game(TRUE);
408 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
411 if (!current_floor_ptr->dun_level)
413 /* Enter the dungeon just now */
414 p_ptr->enter_dungeon = TRUE;
415 down_num = d_info[p_ptr->dungeon_idx].mindepth;
420 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
421 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
426 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
433 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
437 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
438 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
440 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
444 p_ptr->leaving = TRUE;
448 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
452 if (have_flag(f_ptr->flags, FF_SHAFT))
454 /* Create a way back */
455 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
459 /* Create a way back */
460 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
468 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
471 void do_cmd_search(void)
473 /* Allow repeated command */
476 /* Set repeat count */
477 command_rep = command_arg - 1;
478 p_ptr->redraw |= (PR_STATE);
483 take_turn(p_ptr, 100);
491 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
492 * @param y 走査対象にしたいマスのY座標
493 * @param x 走査対象にしたいマスのX座標
494 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
495 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
497 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
499 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
500 OBJECT_IDX this_o_idx, next_o_idx = 0;
502 /* Scan all objects in the grid */
503 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
507 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
508 next_o_idx = o_ptr->next_o_idx;
510 /* Skip unknown chests XXX XXX */
511 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
513 /* Check for non empty chest */
514 if ((o_ptr->tval == TV_CHEST) &&
515 (((!trapped) && (o_ptr->pval)) || /* non empty */
516 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
525 * @brief 箱を開けるコマンドのメインルーチン /
526 * Attempt to open the given chest at the given location
527 * @param y 箱の存在するマスのY座標
528 * @param x 箱の存在するマスのX座標
529 * @param o_idx 箱のオブジェクトID
530 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
532 * Assume there is no monster blocking the destination
534 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
539 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
541 take_turn(p_ptr, 100);
543 /* Attempt to unlock it */
546 /* Assume locked, and thus not open */
549 /* Get the "disarm" factor */
550 i = p_ptr->skill_dis;
552 /* Penalize some conditions */
553 if (p_ptr->blind || no_lite()) i = i / 10;
554 if (p_ptr->confused || p_ptr->image) i = i / 10;
556 /* Extract the difficulty */
559 /* Always have a small chance of success */
562 /* Success -- May still have traps */
563 if (randint0(100) < j)
565 msg_print(_("鍵をはずした。", "You have picked the lock."));
570 /* Failure -- Keep trying */
573 /* We may continue repeating */
575 if (flush_failure) flush();
576 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
581 /* Allowed to open */
584 /* Apply chest traps, if any */
585 chest_trap(y, x, o_idx);
587 /* Let the Chest drop items */
588 chest_death(FALSE, y, x, o_idx);
594 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
595 * Attempt to open the given chest at the given location
596 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
597 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
598 * @param test 地形条件を判定するための関数ポインタ
599 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
601 * @details Return the number of features around (or under) the character.
602 * Usually look for doors and floor traps.
604 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
610 /* Count how many matches */
613 /* Check around (and under) the character */
614 for (d = 0; d < 9; d++)
619 /* if not searching under player continue */
620 if ((d == 8) && !under) continue;
622 /* Extract adjacent (legal) location */
623 yy = p_ptr->y + ddy_ddd[d];
624 xx = p_ptr->x + ddx_ddd[d];
626 /* Get the current_floor_ptr->grid_array */
627 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
629 /* Must have knowledge */
630 if (!(g_ptr->info & (CAVE_MARK))) continue;
632 /* Feature code (applying "mimic" field) */
633 feat = get_feat_mimic(g_ptr);
635 /* Not looking for this feature */
636 if (!((*test)(feat))) continue;
641 /* Remember the location. Only useful if only one match */
652 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
653 * Return the number of chests around (or under) the character.
654 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
655 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
656 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
659 * If requested, count only trapped chests.
661 static int count_chests(POSITION *y, POSITION *x, bool trapped)
668 /* Count how many matches */
671 /* Check around (and under) the character */
672 for (d = 0; d < 9; d++)
674 /* Extract adjacent (legal) location */
675 POSITION yy = p_ptr->y + ddy_ddd[d];
676 POSITION xx = p_ptr->x + ddx_ddd[d];
678 /* No (visible) chest is there */
679 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
681 /* Grab the object */
682 o_ptr = ¤t_floor_ptr->o_list[o_idx];
685 if (o_ptr->pval == 0) continue;
687 /* No (known) traps here */
688 if (trapped && (!object_is_known(o_ptr) ||
689 !chest_traps[o_ptr->pval])) continue;
694 /* Remember the location. Only useful if only one match */
706 * @brief 「開ける」動作コマンドのサブルーチン /
707 * Perform the basic "open" command on doors
708 * @param y 対象を行うマスのY座標
709 * @param x 対象を行うマスのX座標
710 * @return 実際に処理が行われた場合TRUEを返す。
712 * Assume destination is a closed/locked/jammed door
713 * Assume there is no monster blocking the destination
714 * Returns TRUE if repeated commands may continue
716 static bool do_cmd_open_aux(POSITION y, POSITION x)
720 /* Get requested grid */
721 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
722 feature_type *f_ptr = &f_info[g_ptr->feat];
725 take_turn(p_ptr, 100);
727 /* Seeing true feature code (ignore mimic) */
730 if (!have_flag(f_ptr->flags, FF_OPEN))
733 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
737 else if (f_ptr->power)
740 i = p_ptr->skill_dis;
742 /* Penalize some conditions */
743 if (p_ptr->blind || no_lite()) i = i / 10;
744 if (p_ptr->confused || p_ptr->image) i = i / 10;
746 /* Extract the lock power */
749 /* Extract the difficulty */
752 /* Always have a small chance of success */
756 if (randint0(100) < j)
758 msg_print(_("鍵をはずした。", "You have picked the lock."));
761 cave_alter_feat(y, x, FF_OPEN);
763 sound(SOUND_OPENDOOR);
773 if (flush_failure) flush();
775 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
777 /* We may keep trying */
786 cave_alter_feat(y, x, FF_OPEN);
788 sound(SOUND_OPENDOOR);
794 * @brief 「開ける」コマンドのメインルーチン /
795 * Open a closed/locked/jammed door or a closed/locked chest.
798 * Unlocking a locked door/chest is worth one experience point.
800 void do_cmd_open(void)
808 if (p_ptr->wild_mode) return;
810 if (p_ptr->special_defense & KATA_MUSOU)
812 set_action(ACTION_NONE);
815 /* Option: Pick a direction */
818 int num_doors, num_chests;
820 /* Count closed doors (locked or jammed) */
821 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
823 /* Count chests (locked) */
824 num_chests = count_chests(&y, &x, FALSE);
826 /* See if only one target */
827 if (num_doors || num_chests)
829 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
831 if (!too_many) command_dir = coords_to_dir(y, x);
835 /* Allow repeated command */
838 /* Set repeat count */
839 command_rep = command_arg - 1;
840 p_ptr->redraw |= (PR_STATE);
846 /* Get a "repeated" direction */
847 if (get_rep_dir(&dir, TRUE))
852 /* Get requested location */
853 y = p_ptr->y + ddy[dir];
854 x = p_ptr->x + ddx[dir];
856 /* Get requested grid */
857 g_ptr = ¤t_floor_ptr->grid_array[y][x];
859 /* Feature code (applying "mimic" field) */
860 feat = get_feat_mimic(g_ptr);
862 /* Check for chest */
863 o_idx = chest_check(y, x, FALSE);
866 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
868 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
871 /* Monster in the way */
872 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
874 take_turn(p_ptr, 100);
875 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
883 more = do_cmd_open_chest(y, x, o_idx);
890 more = do_cmd_open_aux(y, x);
894 /* Cancel repeat unless we may continue */
895 if (!more) disturb(FALSE, FALSE);
901 * @brief 「閉じる」動作コマンドのサブルーチン /
902 * Perform the basic "close" command
903 * @param y 対象を行うマスのY座標
904 * @param x 対象を行うマスのX座標
905 * @return 実際に処理が行われた場合TRUEを返す。
907 * Assume destination is an open/broken door
908 * Assume there is no monster blocking the destination
909 * Returns TRUE if repeated commands may continue
911 static bool do_cmd_close_aux(POSITION y, POSITION x)
913 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
914 FEAT_IDX old_feat = g_ptr->feat;
917 take_turn(p_ptr, 100);
919 /* Seeing true feature code (ignore mimic) */
922 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
924 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
926 /* Hack -- object in the way */
927 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
928 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
930 msg_print(_("何かがつっかえて閉まらない。", "Something prevents it from closing."));
935 cave_alter_feat(y, x, FF_CLOSE);
938 if (old_feat == g_ptr->feat)
940 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
944 sound(SOUND_SHUTDOOR);
953 * @brief 「閉じる」コマンドのメインルーチン /
954 * Close an open door.
957 * Unlocking a locked door/chest is worth one experience point.
959 void do_cmd_close(void)
966 if (p_ptr->wild_mode) return;
968 if (p_ptr->special_defense & KATA_MUSOU)
970 set_action(ACTION_NONE);
973 /* Option: Pick a direction */
976 /* Count open doors */
977 if (count_dt(&y, &x, is_open, FALSE) == 1)
979 command_dir = coords_to_dir(y, x);
983 /* Allow repeated command */
986 /* Set repeat count */
987 command_rep = command_arg - 1;
988 p_ptr->redraw |= (PR_STATE);
994 /* Get a "repeated" direction */
995 if (get_rep_dir(&dir, FALSE))
1000 y = p_ptr->y + ddy[dir];
1001 x = p_ptr->x + ddx[dir];
1002 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1004 /* Feature code (applying "mimic" field) */
1005 feat = get_feat_mimic(g_ptr);
1007 /* Require open/broken door */
1008 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1010 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1013 /* Monster in the way */
1014 else if (g_ptr->m_idx)
1016 take_turn(p_ptr, 100);
1018 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1024 /* Close the door */
1027 /* Close the door */
1028 more = do_cmd_close_aux(y, x);
1032 /* Cancel repeat unless we may continue */
1033 if (!more) disturb(FALSE, FALSE);
1038 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1039 * Determine if a given grid may be "tunneled"
1040 * @param y 対象を行うマスのY座標
1041 * @param x 対象を行うマスのX座標
1044 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1046 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1048 /* Must have knowledge */
1049 if (!(g_ptr->info & CAVE_MARK))
1051 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1056 /* Must be a wall/door/etc */
1057 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1059 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1069 * @brief 「掘る」動作コマンドのサブルーチン /
1070 * Perform the basic "tunnel" command
1071 * @param y 対象を行うマスのY座標
1072 * @param x 対象を行うマスのX座標
1073 * @return 実際に処理が行われた場合TRUEを返す。
1075 * Assumes that no monster is blocking the destination
1076 * Do not use twall anymore
1077 * Returns TRUE if repeated commands may continue
1079 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1082 feature_type *f_ptr, *mimic_f_ptr;
1087 /* Verify legality */
1088 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1090 take_turn(p_ptr, 100);
1092 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1093 f_ptr = &f_info[g_ptr->feat];
1094 power = f_ptr->power;
1096 /* Feature code (applying "mimic" field) */
1097 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1099 name = f_name + mimic_f_ptr->name;
1103 if (have_flag(f_ptr->flags, FF_PERMANENT))
1106 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1108 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1111 /* Map border (mimiccing Permanent wall) */
1114 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1119 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1122 if (p_ptr->skill_dig > randint0(20 * power))
1124 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1126 /* Remove the feature */
1127 cave_alter_feat(y, x, FF_TUNNEL);
1128 p_ptr->update |= (PU_FLOW);
1132 /* Message, keep digging */
1133 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1141 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1144 if (p_ptr->skill_dig > power + randint0(40 * power))
1146 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1149 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1150 p_ptr->update |= (PU_FLOW);
1153 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1155 /* Remove the feature */
1156 cave_alter_feat(y, x, FF_TUNNEL);
1158 chg_virtue(V_DILIGENCE, 1);
1159 chg_virtue(V_NATURE, -1);
1167 /* We may continue chopping */
1168 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1169 /* Occasional Search XXX XXX */
1170 if (randint0(100) < 25) search();
1174 /* We may continue tunelling */
1175 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1182 if (is_hidden_door(g_ptr))
1184 /* Occasional Search XXX XXX */
1185 if (randint0(100) < 25) search();
1192 * @brief 「掘る」動作コマンドのメインルーチン /
1193 * Tunnels through "walls" (including rubble and closed doors)
1197 * Note that you must tunnel in order to hit invisible monsters
1198 * in walls, though moving into walls still takes a turn anyway.
1200 * Digging is very difficult without a "digger" weapon, but can be
1201 * accomplished by strong players using heavy weapons.
1204 void do_cmd_tunnel(void)
1213 if (p_ptr->special_defense & KATA_MUSOU)
1215 set_action(ACTION_NONE);
1218 /* Allow repeated command */
1221 /* Set repeat count */
1222 command_rep = command_arg - 1;
1223 p_ptr->redraw |= (PR_STATE);
1225 /* Cancel the arg */
1229 /* Get a direction to tunnel, or Abort */
1230 if (get_rep_dir(&dir,FALSE))
1233 y = p_ptr->y + ddy[dir];
1234 x = p_ptr->x + ddx[dir];
1236 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1238 /* Feature code (applying "mimic" field) */
1239 feat = get_feat_mimic(g_ptr);
1241 /* No tunnelling through doors */
1242 if (have_flag(f_info[feat].flags, FF_DOOR))
1244 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1247 /* No tunnelling through most features */
1248 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1250 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1253 /* A monster is in the way */
1254 else if (g_ptr->m_idx)
1256 take_turn(p_ptr, 100);
1258 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1267 /* Tunnel through walls */
1268 more = do_cmd_tunnel_aux(y, x);
1272 /* Cancel repetition unless we can continue */
1273 if (!more) disturb(FALSE, FALSE);
1277 * @brief 移動処理による簡易な「開く」処理 /
1279 * @return 開く処理が実際に試みられた場合TRUEを返す
1282 * If there is a jammed/closed/locked door at the given location,
1283 * then attempt to unlock/open it. Return TRUE if an attempt was
1284 * made (successful or not), otherwise return FALSE.
1286 * The code here should be nearly identical to that in
1287 * do_cmd_open_test() and do_cmd_open_aux().
1290 bool easy_open_door(POSITION y, POSITION x)
1294 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1295 feature_type *f_ptr = &f_info[g_ptr->feat];
1297 /* Must be a closed door */
1298 if (!is_closed_door(g_ptr->feat))
1304 if (!have_flag(f_ptr->flags, FF_OPEN))
1307 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1312 else if (f_ptr->power)
1315 i = p_ptr->skill_dis;
1317 /* Penalize some conditions */
1318 if (p_ptr->blind || no_lite()) i = i / 10;
1319 if (p_ptr->confused || p_ptr->image) i = i / 10;
1321 /* Extract the lock power */
1324 /* Extract the difficulty */
1327 /* Always have a small chance of success */
1331 if (randint0(100) < j)
1333 msg_print(_("鍵をはずした。", "You have picked the lock."));
1336 cave_alter_feat(y, x, FF_OPEN);
1338 sound(SOUND_OPENDOOR);
1348 if (flush_failure) flush();
1350 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1359 cave_alter_feat(y, x, FF_OPEN);
1361 sound(SOUND_OPENDOOR);
1367 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1368 * Perform the basic "disarm" command
1369 * @param y 解除を行うマスのY座標
1370 * @param x 解除を行うマスのX座標
1371 * @param o_idx 箱のオブジェクトID
1372 * @return ターンを消費する処理が行われた場合TRUEを返す
1375 * Assume destination is a visible trap
1376 * Assume there is no monster blocking the destination
1377 * Returns TRUE if repeated commands may continue
1380 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1384 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1386 take_turn(p_ptr, 100);
1388 /* Get the "disarm" factor */
1389 i = p_ptr->skill_dis;
1391 /* Penalize some conditions */
1392 if (p_ptr->blind || no_lite()) i = i / 10;
1393 if (p_ptr->confused || p_ptr->image) i = i / 10;
1395 /* Extract the difficulty */
1396 j = i - o_ptr->pval;
1398 /* Always have a small chance of success */
1401 /* Must find the trap first. */
1402 if (!object_is_known(o_ptr))
1404 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1408 /* Already disarmed/unlocked */
1409 else if (o_ptr->pval <= 0)
1411 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1414 /* No traps to find. */
1415 else if (!chest_traps[o_ptr->pval])
1417 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1420 /* Success (get a lot of experience) */
1421 else if (randint0(100) < j)
1423 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1424 gain_exp(o_ptr->pval);
1425 o_ptr->pval = (0 - o_ptr->pval);
1428 /* Failure -- Keep trying */
1429 else if ((i > 5) && (randint1(i) > 5))
1431 /* We may keep trying */
1433 if (flush_failure) flush();
1434 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1437 /* Failure -- Set off the trap */
1440 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1442 chest_trap(y, x, o_idx);
1449 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1450 * Perform the basic "disarm" command
1451 * @param y 解除を行うマスのY座標
1452 * @param x 解除を行うマスのX座標
1453 * @param dir プレイヤーからみた方向ID
1454 * @return ターンを消費する処理が行われた場合TRUEを返す
1457 * Assume destination is a visible trap
1458 * Assume there is no monster blocking the destination
1459 * Returns TRUE if repeated commands may continue
1463 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1465 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1468 feature_type *f_ptr = &f_info[g_ptr->feat];
1470 /* Access trap name */
1471 concptr name = (f_name + f_ptr->name);
1473 /* Extract trap "power" */
1474 int power = f_ptr->power;
1477 /* Get the "disarm" factor */
1478 int i = p_ptr->skill_dis;
1481 take_turn(p_ptr, 100);
1483 /* Penalize some conditions */
1484 if (p_ptr->blind || no_lite()) i = i / 10;
1485 if (p_ptr->confused || p_ptr->image) i = i / 10;
1487 /* Extract the difficulty */
1490 /* Always have a small chance of success */
1494 if (randint0(100) < j)
1496 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1501 /* Remove the trap */
1502 cave_alter_feat(y, x, FF_DISARM);
1504 /* Move the player onto the trap */
1505 move_player(dir, easy_disarm, FALSE);
1508 /* Failure -- Keep trying */
1509 else if ((i > 5) && (randint1(i) > 5))
1512 if (flush_failure) flush();
1514 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1516 /* We may keep trying */
1520 /* Failure -- Set off the trap */
1523 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1524 /* Move the player onto the trap */
1525 move_player(dir, easy_disarm, FALSE);
1532 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1533 * Disarms a trap, or chest
1536 void do_cmd_disarm(void)
1544 if (p_ptr->wild_mode) return;
1546 if (p_ptr->special_defense & KATA_MUSOU)
1548 set_action(ACTION_NONE);
1551 /* Option: Pick a direction */
1554 int num_traps, num_chests;
1556 /* Count visible traps */
1557 num_traps = count_dt(&y, &x, is_trap, TRUE);
1559 /* Count chests (trapped) */
1560 num_chests = count_chests(&y, &x, TRUE);
1562 /* See if only one target */
1563 if (num_traps || num_chests)
1565 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1566 if (!too_many) command_dir = coords_to_dir(y, x);
1571 /* Allow repeated command */
1574 /* Set repeat count */
1575 command_rep = command_arg - 1;
1576 p_ptr->redraw |= (PR_STATE);
1578 /* Cancel the arg */
1582 /* Get a direction (or abort) */
1583 if (get_rep_dir(&dir,TRUE))
1588 y = p_ptr->y + ddy[dir];
1589 x = p_ptr->x + ddx[dir];
1590 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1592 /* Feature code (applying "mimic" field) */
1593 feat = get_feat_mimic(g_ptr);
1595 /* Check for chests */
1596 o_idx = chest_check(y, x, TRUE);
1599 if (!is_trap(feat) && !o_idx)
1601 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1604 /* Monster in the way */
1605 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1607 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1616 more = do_cmd_disarm_chest(y, x, o_idx);
1622 more = do_cmd_disarm_aux(y, x, dir);
1626 /* Cancel repeat unless told not to */
1627 if (!more) disturb(FALSE, FALSE);
1632 * @brief 「打ち破る」動作コマンドのサブルーチン /
1633 * Perform the basic "bash" command
1634 * @param y 対象を行うマスのY座標
1635 * @param x 対象を行うマスのX座標
1636 * @param dir プレイヤーから見たターゲットの方角ID
1637 * @return 実際に処理が行われた場合TRUEを返す。
1640 * Assume destination is a closed/locked/jammed door
1641 * Assume there is no monster blocking the destination
1642 * Returns TRUE if repeated commands may continue
1645 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1647 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1650 feature_type *f_ptr = &f_info[g_ptr->feat];
1652 /* Hack -- Bash power based on strength */
1653 /* (Ranges from 3 to 20 to 100 to 200) */
1654 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1656 /* Extract door power */
1657 int temp = f_ptr->power;
1661 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1663 take_turn(p_ptr, 100);
1665 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1667 /* Compare bash power to door power */
1668 temp = (bash - (temp * 10));
1670 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1672 /* Hack -- always have a chance */
1673 if (temp < 1) temp = 1;
1675 /* Hack -- attempt to bash down the door */
1676 if (randint0(100) < temp)
1678 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1680 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1682 /* Break down the door */
1683 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1685 cave_alter_feat(y, x, FF_BASH);
1691 cave_alter_feat(y, x, FF_OPEN);
1694 /* Hack -- Fall through the door */
1695 move_player(dir, FALSE, FALSE);
1698 /* Saving throw against stun */
1699 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1702 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1704 /* Allow repeated bashing */
1708 /* High dexterity yields coolness */
1711 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1713 /* Hack -- Lose balance ala paralysis */
1714 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1721 * @brief 「打ち破る」動作コマンドのメインルーチン /
1722 * Bash open a door, success based on character strength
1726 * For a closed door, pval is positive if locked; negative if stuck.
1728 * For an open door, pval is positive for a broken door.
1730 * A closed door can be opened - harder if locked. Any door might be
1731 * bashed open (and thereby broken). Bashing a door is (potentially)
1732 * faster! You move into the door way. To open a stuck door, it must
1733 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1735 * Creatures can also open or bash doors, see elsewhere.
1738 void do_cmd_bash(void)
1744 if (p_ptr->wild_mode) return;
1746 if (p_ptr->special_defense & KATA_MUSOU)
1748 set_action(ACTION_NONE);
1751 /* Allow repeated command */
1754 /* Set repeat count */
1755 command_rep = command_arg - 1;
1756 p_ptr->redraw |= (PR_STATE);
1758 /* Cancel the arg */
1762 /* Get a "repeated" direction */
1763 if (get_rep_dir(&dir,FALSE))
1768 y = p_ptr->y + ddy[dir];
1769 x = p_ptr->x + ddx[dir];
1771 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1773 /* Feature code (applying "mimic" field) */
1774 feat = get_feat_mimic(g_ptr);
1776 /* Nothing useful */
1777 if (!have_flag(f_info[feat].flags, FF_BASH))
1779 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1782 /* Monster in the way */
1783 else if (g_ptr->m_idx)
1785 take_turn(p_ptr, 100);
1787 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1793 /* Bash a closed door */
1797 more = do_cmd_bash_aux(y, x, dir);
1801 /* Unless valid action taken, cancel bash */
1802 if (!more) disturb(FALSE, FALSE);
1807 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1811 * Manipulate an adjacent grid in some way
1813 * Attack monsters, tunnel through walls, disarm traps, open doors.
1815 * Consider confusion
1817 * This command must always take a turn, to prevent free detection
1818 * of invisible monsters.
1821 void do_cmd_alter(void)
1828 if (p_ptr->special_defense & KATA_MUSOU)
1830 set_action(ACTION_NONE);
1833 /* Allow repeated command */
1836 /* Set repeat count */
1837 command_rep = command_arg - 1;
1838 p_ptr->redraw |= (PR_STATE);
1840 /* Cancel the arg */
1844 /* Get a direction */
1845 if (get_rep_dir(&dir,TRUE))
1848 feature_type *f_ptr;
1850 y = p_ptr->y + ddy[dir];
1851 x = p_ptr->x + ddx[dir];
1853 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1855 /* Feature code (applying "mimic" field) */
1856 feat = get_feat_mimic(g_ptr);
1857 f_ptr = &f_info[feat];
1859 take_turn(p_ptr, 100);
1867 else if (have_flag(f_ptr->flags, FF_OPEN))
1869 more = do_cmd_open_aux(y, x);
1872 /* Bash jammed doors */
1873 else if (have_flag(f_ptr->flags, FF_BASH))
1875 more = do_cmd_bash_aux(y, x, dir);
1878 /* Tunnel through walls */
1879 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1881 more = do_cmd_tunnel_aux(y, x);
1884 /* Close open doors */
1885 else if (have_flag(f_ptr->flags, FF_CLOSE))
1887 more = do_cmd_close_aux(y, x);
1891 else if (have_flag(f_ptr->flags, FF_DISARM))
1893 more = do_cmd_disarm_aux(y, x, dir);
1898 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1902 /* Cancel repetition unless we can continue */
1903 if (!more) disturb(FALSE, FALSE);
1909 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1910 * Find the index of some "spikes", if possible.
1911 * @param ip くさびとして打てるオブジェクトのID
1912 * @return オブジェクトがある場合TRUEを返す
1915 * Let user choose a pile of spikes, perhaps?
1918 static bool get_spike(INVENTORY_IDX *ip)
1922 /* Check every item in the pack */
1923 for (i = 0; i < INVEN_PACK; i++)
1925 object_type *o_ptr = &inventory[i];
1927 /* Skip non-objects */
1928 if (!o_ptr->k_idx) continue;
1930 /* Check the "tval" code */
1931 if (o_ptr->tval == TV_SPIKE)
1933 /* Save the spike index */
1946 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1947 * Jam a closed door with a spike
1951 * This command may NOT be repeated
1954 void do_cmd_spike(void)
1958 if (p_ptr->wild_mode) return;
1960 if (p_ptr->special_defense & KATA_MUSOU)
1962 set_action(ACTION_NONE);
1965 /* Get a "repeated" direction */
1966 if (get_rep_dir(&dir, FALSE))
1973 y = p_ptr->y + ddy[dir];
1974 x = p_ptr->x + ddx[dir];
1975 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1977 /* Feature code (applying "mimic" field) */
1978 feat = get_feat_mimic(g_ptr);
1980 /* Require closed door */
1981 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1983 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1987 else if (!get_spike(&item))
1989 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1992 /* Is a monster in the way? */
1993 else if (g_ptr->m_idx)
1995 take_turn(p_ptr, 100);
1997 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2006 take_turn(p_ptr, 100);
2008 /* Successful jamming */
2009 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2010 cave_alter_feat(y, x, FF_SPIKE);
2012 /* Use up, and describe, a single spike, from the bottom */
2013 inven_item_increase(item, -1);
2014 inven_item_describe(item);
2015 inven_item_optimize(item);
2023 * @brief 「歩く」動作コマンドのメインルーチン /
2024 * Support code for the "Walk" and "Jump" commands
2025 * @param pickup アイテムの自動拾いを行うならTRUE
2028 void do_cmd_walk(bool pickup)
2035 /* Allow repeated command */
2038 /* Set repeat count */
2039 command_rep = command_arg - 1;
2040 p_ptr->redraw |= (PR_STATE);
2042 /* Cancel the arg */
2046 /* Get a "repeated" direction */
2047 if (get_rep_dir(&dir, FALSE))
2049 take_turn(p_ptr, 100);
2051 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2053 set_action(ACTION_NONE);
2056 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2057 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2058 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2060 /* Actually move the character */
2061 move_player(dir, pickup, FALSE);
2063 /* Allow more walking */
2067 /* Hack again -- Is there a special encounter ??? */
2068 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2070 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2073 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2075 /* Inform the player of his horrible fate :=) */
2076 msg_print(_("襲撃だ!", "You are ambushed !"));
2078 /* Go into large wilderness view */
2079 p_ptr->oldpy = randint1(MAX_HGT-2);
2080 p_ptr->oldpx = randint1(MAX_WID-2);
2083 /* Give first move to monsters */
2084 take_turn(p_ptr, 100);
2086 /* HACk -- set the encouter flag for the wilderness generation */
2087 generate_encounter = TRUE;
2091 /* Cancel repeat unless we may continue */
2092 if (!more) disturb(FALSE, FALSE);
2097 * @brief 「走る」動作コマンドのメインルーチン /
2101 void do_cmd_run(void)
2104 if (cmd_limit_confused(p_ptr)) return;
2106 if (p_ptr->special_defense & KATA_MUSOU)
2108 set_action(ACTION_NONE);
2111 /* Get a "repeated" direction */
2112 if (get_rep_dir(&dir,FALSE))
2114 /* Hack -- Set the run counter */
2115 running = (command_arg ? command_arg : 1000);
2124 * @brief 「留まる」動作コマンドのメインルーチン /
2125 * Stay still. Search. Enter stores.
2126 * Pick up treasure if "pickup" is true.
2127 * @param pickup アイテムの自動拾いを行うならTRUE
2130 void do_cmd_stay(bool pickup)
2132 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2134 /* Allow repeated command */
2137 /* Set repeat count */
2138 command_rep = command_arg - 1;
2139 p_ptr->redraw |= (PR_STATE);
2141 /* Cancel the arg */
2145 take_turn(p_ptr, 100);
2147 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2148 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2153 * @brief 「休む」動作コマンドのメインルーチン /
2154 * Resting allows a player to safely restore his hp -RAK-
2157 void do_cmd_rest(void)
2160 set_action(ACTION_NONE);
2162 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2164 stop_singing(p_ptr);
2168 if (hex_spelling_any()) stop_hex_spell_all();
2170 /* Prompt for time if needed */
2171 if (command_arg <= 0)
2173 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2174 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2180 strcpy(out_val, "&");
2182 /* Ask for duration */
2183 if (!get_string(p, out_val, 4)) return;
2185 /* Rest until done */
2186 if (out_val[0] == '&')
2188 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2192 else if (out_val[0] == '*')
2194 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2200 command_arg = (COMMAND_ARG)atoi(out_val);
2201 if (command_arg <= 0) return;
2205 if (command_arg > 9999) command_arg = 9999;
2207 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2209 /* Take a turn (?) */
2210 take_turn(p_ptr, 100);
2212 /* The sin of sloth */
2213 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2215 /* Why are you sleeping when there's no need? WAKE UP!*/
2216 if ((p_ptr->chp == p_ptr->mhp) &&
2217 (p_ptr->csp == p_ptr->msp) &&
2218 !p_ptr->blind && !p_ptr->confused &&
2219 !p_ptr->poisoned && !p_ptr->afraid &&
2220 !p_ptr->stun && !p_ptr->cut &&
2221 !p_ptr->slow && !p_ptr->paralyzed &&
2222 !p_ptr->image && !p_ptr->word_recall &&
2223 !p_ptr->alter_reality)
2224 chg_virtue(V_DILIGENCE, -1);
2226 /* Save the rest code */
2227 p_ptr->resting = command_arg;
2228 p_ptr->action = ACTION_REST;
2229 p_ptr->update |= (PU_BONUS);
2230 update_creature(p_ptr);
2232 p_ptr->redraw |= (PR_STATE);
2241 * @brief 射撃処理のメインルーチン
2244 void do_cmd_fire(SPELL_IDX snipe_type)
2247 object_type *j_ptr, *ammo_ptr;
2250 if(p_ptr->wild_mode) return;
2252 is_fired = FALSE; /* not fired yet */
2254 /* Get the "bow" (if any) */
2255 j_ptr = &inventory[INVEN_BOW];
2257 /* Require a launcher */
2260 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2265 if (j_ptr->sval == SV_CRIMSON)
2267 msg_print(_("この武器は発動して使うもののようだ。", "It's already activated."));
2272 if (j_ptr->sval == SV_HARP)
2274 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2280 if (p_ptr->special_defense & KATA_MUSOU)
2282 set_action(ACTION_NONE);
2285 /* Require proper missile */
2286 item_tester_tval = p_ptr->tval_ammo;
2288 q = _("どれを撃ちますか? ", "Fire which item? ");
2289 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2292 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2300 exe_fire(item, j_ptr, snipe_type);
2302 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2304 /* Sniper actions after some shootings */
2305 if (snipe_type == SP_AWAY)
2307 teleport_player(10 + (p_ptr->concent * 2), 0L);
2309 if (snipe_type == SP_FINAL)
2311 msg_print(_("射撃の反動が体を襲った。", "The weapon's recoil stuns you. "));
2312 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2313 (void)set_stun(p_ptr->stun + randint1(25));
2319 * @brief 投射処理メインルーチン /
2320 * Throw an object from the pack or floor.
2322 * @param boomerang ブーメラン処理ならばTRUE
2323 * @param shuriken 忍者の手裏剣処理ならばTRUE
2324 * @return ターンを消費した場合TRUEを返す
2327 * Note: "unseen" monsters are very hard to hit.
2329 * Should throwing a weapon do full damage? Should it allow the magic
2330 * to hit bonus of the weapon to have an effect? Should it ever cause
2331 * the item to be destroyed? Should it do any damage at all?
2334 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2339 POSITION y, x, ty, tx, prev_y, prev_x;
2340 POSITION ny[19], nx[19];
2341 int chance, tdam, tdis;
2342 int mul, div, dd, ds;
2343 int cur_dis, visible;
2350 bool hit_body = FALSE;
2351 bool hit_wall = FALSE;
2352 bool equiped_item = FALSE;
2353 bool return_when_thrown = FALSE;
2355 GAME_TEXT o_name[MAX_NLEN];
2357 int msec = delay_factor * delay_factor * delay_factor;
2359 BIT_FLAGS flgs[TR_FLAG_SIZE];
2361 bool come_back = FALSE;
2362 bool do_drop = TRUE;
2364 if (p_ptr->wild_mode) return FALSE;
2366 if (p_ptr->special_defense & KATA_MUSOU)
2368 set_action(ACTION_NONE);
2374 o_ptr = &inventory[item];
2378 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2380 item_tester_hook = item_tester_hook_boomerang;
2381 q = _("どの武器を投げますか? ", "Throw which item? ");
2382 s = _("投げる武器がない。", "You have nothing to throw.");
2383 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2390 else if (has_melee_weapon(INVEN_LARM))
2393 o_ptr = &inventory[item];
2398 o_ptr = &inventory[item];
2403 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2404 s = _("投げるアイテムがない。", "You have nothing to throw.");
2405 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2413 /* Item is cursed */
2414 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2416 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2420 if (p_ptr->inside_arena && !boomerang)
2422 if (o_ptr->tval != TV_SPIKE)
2424 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2433 /* Obtain a local object */
2434 object_copy(q_ptr, o_ptr);
2436 /* Extract the thrown object's flags. */
2437 object_flags(q_ptr, flgs);
2438 torch_flags(q_ptr, flgs);
2440 /* Distribute the charges of rods/wands between the stacks */
2441 distribute_charges(o_ptr, q_ptr, 1);
2446 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2448 if (p_ptr->mighty_throw) mult += 3;
2450 /* Extract a "distance multiplier" */
2451 /* Changed for 'launcher' mutation */
2452 mul = 10 + 2 * (mult - 1);
2454 /* Enforce a minimum "weight" of one pound */
2455 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2456 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2458 /* Hack -- Distance -- Reward strength, penalize weight */
2459 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2461 /* Max distance of 10-18 */
2462 if (tdis > mul) tdis = mul;
2466 ty = randint0(101) - 50 + p_ptr->y;
2467 tx = randint0(101) - 50 + p_ptr->x;
2471 project_length = tdis + 1;
2473 /* Get a direction (or cancel) */
2474 if (!get_aim_dir(&dir)) return FALSE;
2476 /* Predict the "target" location */
2477 tx = p_ptr->x + 99 * ddx[dir];
2478 ty = p_ptr->y + 99 * ddy[dir];
2480 /* Check for "target request" */
2481 if ((dir == 5) && target_okay())
2487 project_length = 0; /* reset to default */
2490 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2491 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2492 return_when_thrown = TRUE;
2494 /* Reduce and describe inventory */
2497 inven_item_increase(item, -1);
2498 if (!return_when_thrown)
2499 inven_item_describe(item);
2500 inven_item_optimize(item);
2503 /* Reduce and describe floor item */
2506 floor_item_increase(0 - item, -1);
2507 floor_item_optimize(0 - item);
2509 if (item >= INVEN_RARM)
2511 equiped_item = TRUE;
2512 p_ptr->redraw |= (PR_EQUIPPY);
2515 take_turn(p_ptr, 100);
2517 /* Rogue and Ninja gets bonus */
2518 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2519 p_ptr->energy_use -= p_ptr->lev;
2521 /* Start at the player */
2527 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2528 else shuriken = FALSE;
2530 /* Chance of hitting */
2531 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2532 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2533 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2535 if (shuriken) chance *= 2;
2540 /* Travel until stopped */
2541 for (cur_dis = 0; cur_dis <= tdis; )
2543 /* Hack -- Stop at the target */
2544 if ((y == ty) && (x == tx)) break;
2546 /* Calculate the new location (see "project()") */
2549 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2551 /* Stopped by walls/doors */
2552 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2555 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;
2558 /* The player can see the (on screen) missile */
2559 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2561 SYMBOL_CODE c = object_char(q_ptr);
2562 TERM_COLOR a = object_attr(q_ptr);
2564 /* Draw, Hilite, Fresh, Pause, Erase */
2565 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2566 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2568 Term_xtra(TERM_XTRA_DELAY, msec);
2569 lite_spot(ny[cur_dis], nx[cur_dis]);
2573 /* The player cannot see the missile */
2576 /* Pause anyway, for consistancy */
2577 Term_xtra(TERM_XTRA_DELAY, msec);
2583 /* Save the new location */
2587 /* Advance the distance */
2590 /* Monster here, Try to hit it */
2591 if (current_floor_ptr->grid_array[y][x].m_idx)
2593 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2594 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2595 GAME_TEXT m_name[MAX_NLEN];
2596 monster_name(g_ptr->m_idx, m_name);
2598 /* Check the visibility */
2599 visible = m_ptr->ml;
2601 /* Note the collision */
2604 /* Did we hit it (penalize range) */
2605 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2609 /* Handle unseen monster */
2612 /* Invisible monster */
2613 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2616 /* Handle visible monster */
2619 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2623 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2624 health_track(g_ptr->m_idx);
2628 /* Hack -- Base damage from thrown object */
2631 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2632 tdam = damroll(dd, ds);
2633 /* Apply special damage */
2634 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2635 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2636 if (q_ptr->to_d > 0)
2637 tdam += q_ptr->to_d;
2639 tdam += -q_ptr->to_d;
2643 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2644 tdam += p_ptr->to_d_m;
2646 else if (have_flag(flgs, TR_THROW))
2649 tdam += p_ptr->to_d_m;
2657 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2660 /* No negative damage */
2661 if (tdam < 0) tdam = 0;
2663 /* Modify the damage */
2664 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2666 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2667 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2669 /* Hit the monster, check for death */
2670 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2678 message_pain(g_ptr->m_idx, tdam);
2680 /* Anger the monster */
2681 if ((tdam > 0) && !object_is_potion(q_ptr))
2682 anger_monster(m_ptr);
2684 if (fear && m_ptr->ml)
2687 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2697 /* decrease toach's fuel */
2698 if (hit_body) torch_lost_fuel(q_ptr);
2700 /* Chance of breakage (during attacks) */
2701 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2703 /* Figurines transform */
2704 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2708 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2709 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2710 else if (object_is_cursed(q_ptr))
2711 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2715 /* Potions smash open */
2716 if (object_is_potion(q_ptr))
2718 if (hit_body || hit_wall || (randint1(100) < j))
2720 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2722 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2724 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2725 if (current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2727 GAME_TEXT m_name[MAX_NLEN];
2728 monster_desc(m_name, m_ptr, 0);
2729 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2730 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2741 if (return_when_thrown)
2743 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2744 char o2_name[MAX_NLEN];
2745 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2748 if (boomerang) back_chance += 4+randint1(5);
2749 if (super_boomerang) back_chance += 100;
2750 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2752 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2754 for (i = cur_dis - 1; i > 0; i--)
2756 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2758 char c = object_char(q_ptr);
2759 byte a = object_attr(q_ptr);
2761 /* Draw, Hilite, Fresh, Pause, Erase */
2762 print_rel(c, a, ny[i], nx[i]);
2763 move_cursor_relative(ny[i], nx[i]);
2765 Term_xtra(TERM_XTRA_DELAY, msec);
2766 lite_spot(ny[i], nx[i]);
2771 /* Pause anyway, for consistancy */
2772 Term_xtra(TERM_XTRA_DELAY, msec);
2775 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2777 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2784 msg_format(_("%sを受け損ねた!", "%s comes back, but you can't catch!"), o2_name);
2788 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2796 msg_format(_("%sが返ってこなかった!", "%s doesn't come back!"), o2_name);
2802 if (item == INVEN_RARM || item == INVEN_LARM)
2804 /* Access the wield slot */
2805 o_ptr = &inventory[item];
2807 /* Wear the new stuff */
2808 object_copy(o_ptr, q_ptr);
2810 p_ptr->total_weight += q_ptr->weight;
2812 /* Increment the equip counter by hand */
2815 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2816 p_ptr->window |= (PW_EQUIP);
2824 else if (equiped_item)
2832 if (cave_have_flag_bold(y, x, FF_PROJECT))
2834 (void)drop_near(q_ptr, j, y, x);
2838 (void)drop_near(q_ptr, j, prev_y, prev_x);
2846 * @brief 自殺するコマンドのメインルーチン
2847 * Hack -- commit suicide
2851 void do_cmd_suicide(void)
2858 /* Verify Retirement */
2859 if (p_ptr->total_winner)
2862 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2865 /* Verify Suicide */
2869 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2873 if (!p_ptr->noscore)
2875 /* Special Verification for suicide */
2876 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2881 if (i != '@') return;
2883 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2886 /* Initialize "last message" buffer */
2887 if (p_ptr->last_message) string_free(p_ptr->last_message);
2888 p_ptr->last_message = NULL;
2890 /* Hack -- Note *winning* message */
2891 if (p_ptr->total_winner && last_words)
2893 char buf[1024] = "";
2894 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2897 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2898 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2902 p_ptr->last_message = string_make(buf);
2903 msg_print(p_ptr->last_message);
2908 p_ptr->playing = FALSE;
2910 /* Kill the player */
2911 p_ptr->is_dead = TRUE;
2912 p_ptr->leaving = TRUE;
2914 if (!p_ptr->total_winner)
2916 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
2917 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2918 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
2921 /* Cause of death */
2922 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));