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 "spells-summon.h"
20 #include "spells-status.h"
21 #include "monster-status.h"
25 #include "player-status.h"
26 #include "realm-hex.h"
31 #include "player-move.h"
32 #include "player-effects.h"
33 #include "object-broken.h"
34 #include "object-flavor.h"
37 #include "cmd-basic.h"
38 #include "floor-save.h"
39 #include "dungeon-file.h"
42 #include "view-mainwindow.h"
45 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
46 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
47 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
49 static bool confirm_leave_level(bool down_stair)
51 quest_type *q_ptr = &quest[p_ptr->inside_quest];
53 /* Confirm leaving from once only quest */
54 if (confirm_quest && p_ptr->inside_quest &&
55 (q_ptr->type == QUEST_TYPE_RANDOM ||
56 (q_ptr->flags & QUEST_FLAG_ONCE &&
57 q_ptr->status != QUEST_STATUS_COMPLETED) ||
58 (q_ptr->flags & QUEST_FLAG_TOWER &&
59 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
60 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
62 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
63 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
73 * @brief 魔法系コマンドが制限されているかを返す。
74 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
76 bool cmd_limit_cast(player_type *creature_ptr)
78 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
80 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
84 else if (creature_ptr->anti_magic)
86 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
89 else if (creature_ptr->shero)
91 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
98 bool cmd_limit_confused(player_type *creature_ptr)
100 if (creature_ptr->confused)
102 msg_print(_("混乱していてできない!", "You are too confused!"));
108 bool cmd_limit_image(player_type *creature_ptr)
110 if (creature_ptr->image)
112 msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
118 bool cmd_limit_stun(player_type *creature_ptr)
120 if (creature_ptr->stun)
122 msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
128 bool cmd_limit_arena(player_type *creature_ptr)
130 if (creature_ptr->inside_arena)
132 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
139 bool cmd_limit_blind(player_type *creature_ptr)
141 if (creature_ptr->blind)
143 msg_print(_("目が見えない。", "You can't see anything."));
148 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
154 bool cmd_limit_time_walk(player_type *creature_ptr)
156 if (creature_ptr->timewalk)
158 if (flush_failure) flush();
159 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
167 * @brief 階段を使って階層を昇る処理 / Go up one level
170 void do_cmd_go_up(void)
175 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
176 feature_type *f_ptr = &f_info[g_ptr->feat];
180 if (p_ptr->special_defense & KATA_MUSOU)
182 set_action(ACTION_NONE);
186 if (!have_flag(f_ptr->flags, FF_LESS))
188 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
192 /* Quest up stairs */
193 if (have_flag(f_ptr->flags, FF_QUEST))
195 /* Cancel the command */
196 if (!confirm_leave_level(FALSE)) return;
200 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
201 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
203 msg_print(_("上の階に登った。", "You enter the up staircase."));
207 p_ptr->inside_quest = g_ptr->special;
209 /* Activate the quest */
210 if (!quest[p_ptr->inside_quest].status)
212 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
214 init_flags = INIT_ASSIGN;
215 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
217 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
220 /* Leaving a quest */
221 if (!p_ptr->inside_quest)
223 current_floor_ptr->dun_level = 0;
225 p_ptr->leaving = TRUE;
230 take_turn(p_ptr, 100);
232 /* End the command */
236 if (!current_floor_ptr->dun_level)
242 go_up = confirm_leave_level(FALSE);
245 /* Cancel the command */
248 take_turn(p_ptr, 100);
250 if (autosave_l) do_cmd_save_game(TRUE);
252 /* For a random quest */
253 if (p_ptr->inside_quest &&
254 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
258 p_ptr->inside_quest = 0;
261 /* For a fixed quest */
262 if (p_ptr->inside_quest &&
263 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
267 p_ptr->inside_quest = g_ptr->special;
268 current_floor_ptr->dun_level = 0;
272 /* For normal dungeon and random quest */
276 if (have_flag(f_ptr->flags, FF_SHAFT))
278 /* Create a way back */
279 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
285 /* Create a way back */
286 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
291 /* Get out from current dungeon */
292 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
293 up_num = current_floor_ptr->dun_level;
295 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
298 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
299 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
300 else if (up_num == current_floor_ptr->dun_level)
301 msg_print(_("地上に戻った。", "You go back to the surface."));
303 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
304 p_ptr->leaving = TRUE;
309 * @brief 階段を使って階層を降りる処理 / Go down one level
312 void do_cmd_go_down(void)
315 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
316 feature_type *f_ptr = &f_info[g_ptr->feat];
318 bool fall_trap = FALSE;
321 if (p_ptr->special_defense & KATA_MUSOU)
323 set_action(ACTION_NONE);
327 if (!have_flag(f_ptr->flags, FF_MORE))
329 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
333 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
336 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
341 /* Quest down stairs */
342 else if (have_flag(f_ptr->flags, FF_QUEST))
344 /* Confirm Leaving */
345 if(!confirm_leave_level(TRUE)) return;
347 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
348 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
350 msg_print(_("下の階に降りた。", "You enter the down staircase."));
355 p_ptr->inside_quest = g_ptr->special;
357 /* Activate the quest */
358 if (!quest[p_ptr->inside_quest].status)
360 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
362 init_flags = INIT_ASSIGN;
363 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
365 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
368 /* Leaving a quest */
369 if (!p_ptr->inside_quest)
371 current_floor_ptr->dun_level = 0;
373 p_ptr->leaving = TRUE;
377 take_turn(p_ptr, 100);
382 DUNGEON_IDX target_dungeon = 0;
384 if (!current_floor_ptr->dun_level)
386 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
388 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
390 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
393 if (!max_dlv[target_dungeon])
395 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
396 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
397 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
400 /* Save old player position */
401 p_ptr->oldpx = p_ptr->x;
402 p_ptr->oldpy = p_ptr->y;
403 p_ptr->dungeon_idx = target_dungeon;
406 * Clear all saved floors
407 * and create a first saved floor
409 prepare_change_floor_mode(CFM_FIRST_FLOOR);
412 take_turn(p_ptr, 100);
414 if (autosave_l) do_cmd_save_game(TRUE);
417 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
420 if (!current_floor_ptr->dun_level)
422 /* Enter the dungeon just now */
423 p_ptr->enter_dungeon = TRUE;
424 down_num = d_info[p_ptr->dungeon_idx].mindepth;
429 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
430 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
435 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
442 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
446 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
447 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
449 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
453 p_ptr->leaving = TRUE;
457 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
461 if (have_flag(f_ptr->flags, FF_SHAFT))
463 /* Create a way back */
464 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
468 /* Create a way back */
469 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
477 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn
480 void do_cmd_search(void)
482 /* Allow repeated command */
485 /* Set repeat count */
486 command_rep = command_arg - 1;
487 p_ptr->redraw |= (PR_STATE);
492 take_turn(p_ptr, 100);
500 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
501 * @param y 走査対象にしたいマスのY座標
502 * @param x 走査対象にしたいマスのX座標
503 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
504 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
506 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
508 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
509 OBJECT_IDX this_o_idx, next_o_idx = 0;
511 /* Scan all objects in the grid */
512 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
516 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
517 next_o_idx = o_ptr->next_o_idx;
519 /* Skip unknown chests XXX XXX */
520 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
522 /* Check for non empty chest */
523 if ((o_ptr->tval == TV_CHEST) &&
524 (((!trapped) && (o_ptr->pval)) || /* non empty */
525 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
534 * @brief 箱を開けるコマンドのメインルーチン /
535 * Attempt to open the given chest at the given location
536 * @param y 箱の存在するマスのY座標
537 * @param x 箱の存在するマスのX座標
538 * @param o_idx 箱のオブジェクトID
539 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
541 * Assume there is no monster blocking the destination
543 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
548 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
550 take_turn(p_ptr, 100);
552 /* Attempt to unlock it */
555 /* Assume locked, and thus not open */
558 /* Get the "disarm" factor */
559 i = p_ptr->skill_dis;
561 /* Penalize some conditions */
562 if (p_ptr->blind || no_lite()) i = i / 10;
563 if (p_ptr->confused || p_ptr->image) i = i / 10;
565 /* Extract the difficulty */
568 /* Always have a small chance of success */
571 /* Success -- May still have traps */
572 if (randint0(100) < j)
574 msg_print(_("鍵をはずした。", "You have picked the lock."));
579 /* Failure -- Keep trying */
582 /* We may continue repeating */
584 if (flush_failure) flush();
585 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
590 /* Allowed to open */
593 /* Apply chest traps, if any */
594 chest_trap(y, x, o_idx);
596 /* Let the Chest drop items */
597 chest_death(FALSE, y, x, o_idx);
603 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
604 * Attempt to open the given chest at the given location
605 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
606 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
607 * @param test 地形条件を判定するための関数ポインタ
608 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
610 * @details Return the number of features around (or under) the character.
611 * Usually look for doors and floor traps.
613 static int count_dt(POSITION *y, POSITION *x, bool (*test)(FEAT_IDX feat), bool under)
619 /* Count how many matches */
622 /* Check around (and under) the character */
623 for (d = 0; d < 9; d++)
628 /* if not searching under player continue */
629 if ((d == 8) && !under) continue;
631 /* Extract adjacent (legal) location */
632 yy = p_ptr->y + ddy_ddd[d];
633 xx = p_ptr->x + ddx_ddd[d];
635 /* Get the current_floor_ptr->grid_array */
636 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
638 /* Must have knowledge */
639 if (!(g_ptr->info & (CAVE_MARK))) continue;
641 /* Feature code (applying "mimic" field) */
642 feat = get_feat_mimic(g_ptr);
644 /* Not looking for this feature */
645 if (!((*test)(feat))) continue;
650 /* Remember the location. Only useful if only one match */
661 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
662 * Return the number of chests around (or under) the character.
663 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
664 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
665 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
668 * If requested, count only trapped chests.
670 static int count_chests(POSITION *y, POSITION *x, bool trapped)
677 /* Count how many matches */
680 /* Check around (and under) the character */
681 for (d = 0; d < 9; d++)
683 /* Extract adjacent (legal) location */
684 POSITION yy = p_ptr->y + ddy_ddd[d];
685 POSITION xx = p_ptr->x + ddx_ddd[d];
687 /* No (visible) chest is there */
688 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
690 /* Grab the object */
691 o_ptr = ¤t_floor_ptr->o_list[o_idx];
694 if (o_ptr->pval == 0) continue;
696 /* No (known) traps here */
697 if (trapped && (!object_is_known(o_ptr) ||
698 !chest_traps[o_ptr->pval])) continue;
703 /* Remember the location. Only useful if only one match */
715 * @brief 「開ける」動作コマンドのサブルーチン /
716 * Perform the basic "open" command on doors
717 * @param y 対象を行うマスのY座標
718 * @param x 対象を行うマスのX座標
719 * @return 実際に処理が行われた場合TRUEを返す。
721 * Assume destination is a closed/locked/jammed door
722 * Assume there is no monster blocking the destination
723 * Returns TRUE if repeated commands may continue
725 static bool do_cmd_open_aux(POSITION y, POSITION x)
729 /* Get requested grid */
730 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
731 feature_type *f_ptr = &f_info[g_ptr->feat];
734 take_turn(p_ptr, 100);
736 /* Seeing true feature code (ignore mimic) */
739 if (!have_flag(f_ptr->flags, FF_OPEN))
742 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
746 else if (f_ptr->power)
749 i = p_ptr->skill_dis;
751 /* Penalize some conditions */
752 if (p_ptr->blind || no_lite()) i = i / 10;
753 if (p_ptr->confused || p_ptr->image) i = i / 10;
755 /* Extract the lock power */
758 /* Extract the difficulty */
761 /* Always have a small chance of success */
765 if (randint0(100) < j)
767 msg_print(_("鍵をはずした。", "You have picked the lock."));
770 cave_alter_feat(y, x, FF_OPEN);
772 sound(SOUND_OPENDOOR);
782 if (flush_failure) flush();
784 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
786 /* We may keep trying */
795 cave_alter_feat(y, x, FF_OPEN);
797 sound(SOUND_OPENDOOR);
803 * @brief 「開ける」コマンドのメインルーチン /
804 * Open a closed/locked/jammed door or a closed/locked chest.
807 * Unlocking a locked door/chest is worth one experience point.
809 void do_cmd_open(void)
817 if (p_ptr->wild_mode) return;
819 if (p_ptr->special_defense & KATA_MUSOU)
821 set_action(ACTION_NONE);
824 /* Option: Pick a direction */
827 int num_doors, num_chests;
829 /* Count closed doors (locked or jammed) */
830 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
832 /* Count chests (locked) */
833 num_chests = count_chests(&y, &x, FALSE);
835 /* See if only one target */
836 if (num_doors || num_chests)
838 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
840 if (!too_many) command_dir = coords_to_dir(y, x);
844 /* Allow repeated command */
847 /* Set repeat count */
848 command_rep = command_arg - 1;
849 p_ptr->redraw |= (PR_STATE);
855 /* Get a "repeated" direction */
856 if (get_rep_dir(&dir, TRUE))
861 /* Get requested location */
862 y = p_ptr->y + ddy[dir];
863 x = p_ptr->x + ddx[dir];
865 /* Get requested grid */
866 g_ptr = ¤t_floor_ptr->grid_array[y][x];
868 /* Feature code (applying "mimic" field) */
869 feat = get_feat_mimic(g_ptr);
871 /* Check for chest */
872 o_idx = chest_check(y, x, FALSE);
875 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
877 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
880 /* Monster in the way */
881 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
883 take_turn(p_ptr, 100);
884 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
892 more = do_cmd_open_chest(y, x, o_idx);
899 more = do_cmd_open_aux(y, x);
903 /* Cancel repeat unless we may continue */
904 if (!more) disturb(FALSE, FALSE);
910 * @brief 「閉じる」動作コマンドのサブルーチン /
911 * Perform the basic "close" command
912 * @param y 対象を行うマスのY座標
913 * @param x 対象を行うマスのX座標
914 * @return 実際に処理が行われた場合TRUEを返す。
916 * Assume destination is an open/broken door
917 * Assume there is no monster blocking the destination
918 * Returns TRUE if repeated commands may continue
920 static bool do_cmd_close_aux(POSITION y, POSITION x)
922 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
923 FEAT_IDX old_feat = g_ptr->feat;
926 take_turn(p_ptr, 100);
928 /* Seeing true feature code (ignore mimic) */
931 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
933 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
935 /* Hack -- object in the way */
936 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
937 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
939 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
944 cave_alter_feat(y, x, FF_CLOSE);
947 if (old_feat == g_ptr->feat)
949 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
953 sound(SOUND_SHUTDOOR);
962 * @brief 「閉じる」コマンドのメインルーチン /
963 * Close an open door.
966 * Unlocking a locked door/chest is worth one experience point.
968 void do_cmd_close(void)
975 if (p_ptr->wild_mode) return;
977 if (p_ptr->special_defense & KATA_MUSOU)
979 set_action(ACTION_NONE);
982 /* Option: Pick a direction */
985 /* Count open doors */
986 if (count_dt(&y, &x, is_open, FALSE) == 1)
988 command_dir = coords_to_dir(y, x);
992 /* Allow repeated command */
995 /* Set repeat count */
996 command_rep = command_arg - 1;
997 p_ptr->redraw |= (PR_STATE);
1003 /* Get a "repeated" direction */
1004 if (get_rep_dir(&dir, FALSE))
1009 y = p_ptr->y + ddy[dir];
1010 x = p_ptr->x + ddx[dir];
1011 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1013 /* Feature code (applying "mimic" field) */
1014 feat = get_feat_mimic(g_ptr);
1016 /* Require open/broken door */
1017 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1019 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1022 /* Monster in the way */
1023 else if (g_ptr->m_idx)
1025 take_turn(p_ptr, 100);
1027 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1033 /* Close the door */
1036 /* Close the door */
1037 more = do_cmd_close_aux(y, x);
1041 /* Cancel repeat unless we may continue */
1042 if (!more) disturb(FALSE, FALSE);
1047 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1048 * Determine if a given grid may be "tunneled"
1049 * @param y 対象を行うマスのY座標
1050 * @param x 対象を行うマスのX座標
1053 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1055 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1057 /* Must have knowledge */
1058 if (!(g_ptr->info & CAVE_MARK))
1060 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1065 /* Must be a wall/door/etc */
1066 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1068 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1078 * @brief 「掘る」動作コマンドのサブルーチン /
1079 * Perform the basic "tunnel" command
1080 * @param y 対象を行うマスのY座標
1081 * @param x 対象を行うマスのX座標
1082 * @return 実際に処理が行われた場合TRUEを返す。
1084 * Assumes that no monster is blocking the destination
1085 * Do not use twall anymore
1086 * Returns TRUE if repeated commands may continue
1088 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1091 feature_type *f_ptr, *mimic_f_ptr;
1096 /* Verify legality */
1097 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1099 take_turn(p_ptr, 100);
1101 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1102 f_ptr = &f_info[g_ptr->feat];
1103 power = f_ptr->power;
1105 /* Feature code (applying "mimic" field) */
1106 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1108 name = f_name + mimic_f_ptr->name;
1112 if (have_flag(f_ptr->flags, FF_PERMANENT))
1115 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1117 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1120 /* Map border (mimiccing Permanent wall) */
1123 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1128 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1131 if (p_ptr->skill_dig > randint0(20 * power))
1133 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1135 /* Remove the feature */
1136 cave_alter_feat(y, x, FF_TUNNEL);
1137 p_ptr->update |= (PU_FLOW);
1141 /* Message, keep digging */
1142 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1150 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1153 if (p_ptr->skill_dig > power + randint0(40 * power))
1155 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1158 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1159 p_ptr->update |= (PU_FLOW);
1162 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1164 /* Remove the feature */
1165 cave_alter_feat(y, x, FF_TUNNEL);
1167 chg_virtue(V_DILIGENCE, 1);
1168 chg_virtue(V_NATURE, -1);
1176 /* We may continue chopping */
1177 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1178 /* Occasional Search XXX XXX */
1179 if (randint0(100) < 25) search();
1183 /* We may continue tunelling */
1184 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1191 if (is_hidden_door(g_ptr))
1193 /* Occasional Search XXX XXX */
1194 if (randint0(100) < 25) search();
1201 * @brief 「掘る」動作コマンドのメインルーチン /
1202 * Tunnels through "walls" (including rubble and closed doors)
1206 * Note that you must tunnel in order to hit invisible monsters
1207 * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
1209 * Digging is very difficult without a "digger" weapon, but can be
1210 * accomplished by strong players using heavy weapons.
1213 void do_cmd_tunnel(void)
1222 if (p_ptr->special_defense & KATA_MUSOU)
1224 set_action(ACTION_NONE);
1227 /* Allow repeated command */
1230 /* Set repeat count */
1231 command_rep = command_arg - 1;
1232 p_ptr->redraw |= (PR_STATE);
1234 /* Cancel the arg */
1238 /* Get a direction to tunnel, or Abort */
1239 if (get_rep_dir(&dir,FALSE))
1242 y = p_ptr->y + ddy[dir];
1243 x = p_ptr->x + ddx[dir];
1245 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1247 /* Feature code (applying "mimic" field) */
1248 feat = get_feat_mimic(g_ptr);
1250 /* No tunnelling through doors */
1251 if (have_flag(f_info[feat].flags, FF_DOOR))
1253 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1256 /* No tunnelling through most features */
1257 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1259 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1262 /* A monster is in the way */
1263 else if (g_ptr->m_idx)
1265 take_turn(p_ptr, 100);
1267 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1276 /* Tunnel through walls */
1277 more = do_cmd_tunnel_aux(y, x);
1281 /* Cancel repetition unless we can continue */
1282 if (!more) disturb(FALSE, FALSE);
1286 * @brief 移動処理による簡易な「開く」処理 /
1288 * @return 開く処理が実際に試みられた場合TRUEを返す
1291 * If there is a jammed/closed/locked door at the given location,
1292 * then attempt to unlock/open it. Return TRUE if an attempt was
1293 * made (successful or not), otherwise return FALSE.
1295 * The code here should be nearly identical to that in
1296 * do_cmd_open_test() and do_cmd_open_aux().
1299 bool easy_open_door(POSITION y, POSITION x)
1303 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1304 feature_type *f_ptr = &f_info[g_ptr->feat];
1306 /* Must be a closed door */
1307 if (!is_closed_door(g_ptr->feat))
1313 if (!have_flag(f_ptr->flags, FF_OPEN))
1316 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1321 else if (f_ptr->power)
1324 i = p_ptr->skill_dis;
1326 /* Penalize some conditions */
1327 if (p_ptr->blind || no_lite()) i = i / 10;
1328 if (p_ptr->confused || p_ptr->image) i = i / 10;
1330 /* Extract the lock power */
1333 /* Extract the difficulty */
1336 /* Always have a small chance of success */
1340 if (randint0(100) < j)
1342 msg_print(_("鍵をはずした。", "You have picked the lock."));
1345 cave_alter_feat(y, x, FF_OPEN);
1347 sound(SOUND_OPENDOOR);
1357 if (flush_failure) flush();
1359 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1368 cave_alter_feat(y, x, FF_OPEN);
1370 sound(SOUND_OPENDOOR);
1376 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1377 * Perform the basic "disarm" command
1378 * @param y 解除を行うマスのY座標
1379 * @param x 解除を行うマスのX座標
1380 * @param o_idx 箱のオブジェクトID
1381 * @return ターンを消費する処理が行われた場合TRUEを返す
1384 * Assume destination is a visible trap
1385 * Assume there is no monster blocking the destination
1386 * Returns TRUE if repeated commands may continue
1389 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1393 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1395 take_turn(p_ptr, 100);
1397 /* Get the "disarm" factor */
1398 i = p_ptr->skill_dis;
1400 /* Penalize some conditions */
1401 if (p_ptr->blind || no_lite()) i = i / 10;
1402 if (p_ptr->confused || p_ptr->image) i = i / 10;
1404 /* Extract the difficulty */
1405 j = i - o_ptr->pval;
1407 /* Always have a small chance of success */
1410 /* Must find the trap first. */
1411 if (!object_is_known(o_ptr))
1413 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1417 /* Already disarmed/unlocked */
1418 else if (o_ptr->pval <= 0)
1420 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1423 /* No traps to find. */
1424 else if (!chest_traps[o_ptr->pval])
1426 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1429 /* Success (get a lot of experience) */
1430 else if (randint0(100) < j)
1432 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1433 gain_exp(o_ptr->pval);
1434 o_ptr->pval = (0 - o_ptr->pval);
1437 /* Failure -- Keep trying */
1438 else if ((i > 5) && (randint1(i) > 5))
1440 /* We may keep trying */
1442 if (flush_failure) flush();
1443 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1446 /* Failure -- Set off the trap */
1449 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1451 chest_trap(y, x, o_idx);
1458 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1459 * Perform the basic "disarm" command
1460 * @param y 解除を行うマスのY座標
1461 * @param x 解除を行うマスのX座標
1462 * @param dir プレイヤーからみた方向ID
1463 * @return ターンを消費する処理が行われた場合TRUEを返す
1466 * Assume destination is a visible trap
1467 * Assume there is no monster blocking the destination
1468 * Returns TRUE if repeated commands may continue
1472 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1474 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1477 feature_type *f_ptr = &f_info[g_ptr->feat];
1479 /* Access trap name */
1480 concptr name = (f_name + f_ptr->name);
1482 /* Extract trap "power" */
1483 int power = f_ptr->power;
1486 /* Get the "disarm" factor */
1487 int i = p_ptr->skill_dis;
1490 take_turn(p_ptr, 100);
1492 /* Penalize some conditions */
1493 if (p_ptr->blind || no_lite()) i = i / 10;
1494 if (p_ptr->confused || p_ptr->image) i = i / 10;
1496 /* Extract the difficulty */
1499 /* Always have a small chance of success */
1503 if (randint0(100) < j)
1505 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1510 /* Remove the trap */
1511 cave_alter_feat(y, x, FF_DISARM);
1513 /* Move the player onto the trap */
1514 move_player(dir, easy_disarm, FALSE);
1517 /* Failure -- Keep trying */
1518 else if ((i > 5) && (randint1(i) > 5))
1521 if (flush_failure) flush();
1523 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1525 /* We may keep trying */
1529 /* Failure -- Set off the trap */
1532 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1533 /* Move the player onto the trap */
1534 move_player(dir, easy_disarm, FALSE);
1541 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1542 * Disarms a trap, or chest
1545 void do_cmd_disarm(void)
1553 if (p_ptr->wild_mode) return;
1555 if (p_ptr->special_defense & KATA_MUSOU)
1557 set_action(ACTION_NONE);
1560 /* Option: Pick a direction */
1563 int num_traps, num_chests;
1565 /* Count visible traps */
1566 num_traps = count_dt(&y, &x, is_trap, TRUE);
1568 /* Count chests (trapped) */
1569 num_chests = count_chests(&y, &x, TRUE);
1571 /* See if only one target */
1572 if (num_traps || num_chests)
1574 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1575 if (!too_many) command_dir = coords_to_dir(y, x);
1580 /* Allow repeated command */
1583 /* Set repeat count */
1584 command_rep = command_arg - 1;
1585 p_ptr->redraw |= (PR_STATE);
1587 /* Cancel the arg */
1591 /* Get a direction (or abort) */
1592 if (get_rep_dir(&dir,TRUE))
1597 y = p_ptr->y + ddy[dir];
1598 x = p_ptr->x + ddx[dir];
1599 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1601 /* Feature code (applying "mimic" field) */
1602 feat = get_feat_mimic(g_ptr);
1604 /* Check for chests */
1605 o_idx = chest_check(y, x, TRUE);
1608 if (!is_trap(feat) && !o_idx)
1610 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1613 /* Monster in the way */
1614 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1616 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1625 more = do_cmd_disarm_chest(y, x, o_idx);
1631 more = do_cmd_disarm_aux(y, x, dir);
1635 /* Cancel repeat unless told not to */
1636 if (!more) disturb(FALSE, FALSE);
1641 * @brief 「打ち破る」動作コマンドのサブルーチン /
1642 * Perform the basic "bash" command
1643 * @param y 対象を行うマスのY座標
1644 * @param x 対象を行うマスのX座標
1645 * @param dir プレイヤーから見たターゲットの方角ID
1646 * @return 実際に処理が行われた場合TRUEを返す。
1649 * Assume destination is a closed/locked/jammed door
1650 * Assume there is no monster blocking the destination
1651 * Returns TRUE if repeated commands may continue
1654 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1656 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1659 feature_type *f_ptr = &f_info[g_ptr->feat];
1661 /* Hack -- Bash power based on strength */
1662 /* (Ranges from 3 to 20 to 100 to 200) */
1663 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1665 /* Extract door power */
1666 int temp = f_ptr->power;
1670 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1672 take_turn(p_ptr, 100);
1674 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1676 /* Compare bash power to door power */
1677 temp = (bash - (temp * 10));
1679 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1681 /* Hack -- always have a chance */
1682 if (temp < 1) temp = 1;
1684 /* Hack -- attempt to bash down the door */
1685 if (randint0(100) < temp)
1687 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1689 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1691 /* Break down the door */
1692 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1694 cave_alter_feat(y, x, FF_BASH);
1700 cave_alter_feat(y, x, FF_OPEN);
1703 /* Hack -- Fall through the door */
1704 move_player(dir, FALSE, FALSE);
1707 /* Saving throw against stun */
1708 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1711 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1713 /* Allow repeated bashing */
1717 /* High dexterity yields coolness */
1720 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1722 /* Hack -- Lose balance ala paralysis */
1723 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1730 * @brief 「打ち破る」動作コマンドのメインルーチン /
1731 * Bash open a door, success based on character strength
1735 * For a closed door, pval is positive if locked; negative if stuck.
1737 * For an open door, pval is positive for a broken door.
1739 * A closed door can be opened - harder if locked. Any door might be
1740 * bashed open (and thereby broken). Bashing a door is (potentially)
1741 * faster! You move into the door way. To open a stuck door, it must
1742 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1744 * Creatures can also open or bash doors, see elsewhere.
1747 void do_cmd_bash(void)
1753 if (p_ptr->wild_mode) return;
1755 if (p_ptr->special_defense & KATA_MUSOU)
1757 set_action(ACTION_NONE);
1760 /* Allow repeated command */
1763 /* Set repeat count */
1764 command_rep = command_arg - 1;
1765 p_ptr->redraw |= (PR_STATE);
1767 /* Cancel the arg */
1771 /* Get a "repeated" direction */
1772 if (get_rep_dir(&dir,FALSE))
1777 y = p_ptr->y + ddy[dir];
1778 x = p_ptr->x + ddx[dir];
1780 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1782 /* Feature code (applying "mimic" field) */
1783 feat = get_feat_mimic(g_ptr);
1785 /* Nothing useful */
1786 if (!have_flag(f_info[feat].flags, FF_BASH))
1788 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1791 /* Monster in the way */
1792 else if (g_ptr->m_idx)
1794 take_turn(p_ptr, 100);
1796 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1802 /* Bash a closed door */
1806 more = do_cmd_bash_aux(y, x, dir);
1810 /* Unless valid action taken, cancel bash */
1811 if (!more) disturb(FALSE, FALSE);
1816 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1820 * Manipulate an adjacent grid in some way
1822 * Attack monsters, tunnel through walls, disarm traps, open doors.
1824 * Consider confusion
1826 * This command must always take a current_world_ptr->game_turn, to prevent free detection
1827 * of invisible monsters.
1830 void do_cmd_alter(void)
1837 if (p_ptr->special_defense & KATA_MUSOU)
1839 set_action(ACTION_NONE);
1842 /* Allow repeated command */
1845 /* Set repeat count */
1846 command_rep = command_arg - 1;
1847 p_ptr->redraw |= (PR_STATE);
1849 /* Cancel the arg */
1853 /* Get a direction */
1854 if (get_rep_dir(&dir,TRUE))
1857 feature_type *f_ptr;
1859 y = p_ptr->y + ddy[dir];
1860 x = p_ptr->x + ddx[dir];
1862 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1864 /* Feature code (applying "mimic" field) */
1865 feat = get_feat_mimic(g_ptr);
1866 f_ptr = &f_info[feat];
1868 take_turn(p_ptr, 100);
1876 else if (have_flag(f_ptr->flags, FF_OPEN))
1878 more = do_cmd_open_aux(y, x);
1881 /* Bash jammed doors */
1882 else if (have_flag(f_ptr->flags, FF_BASH))
1884 more = do_cmd_bash_aux(y, x, dir);
1887 /* Tunnel through walls */
1888 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1890 more = do_cmd_tunnel_aux(y, x);
1893 /* Close open doors */
1894 else if (have_flag(f_ptr->flags, FF_CLOSE))
1896 more = do_cmd_close_aux(y, x);
1900 else if (have_flag(f_ptr->flags, FF_DISARM))
1902 more = do_cmd_disarm_aux(y, x, dir);
1907 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1911 /* Cancel repetition unless we can continue */
1912 if (!more) disturb(FALSE, FALSE);
1918 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1919 * Find the index of some "spikes", if possible.
1920 * @param ip くさびとして打てるオブジェクトのID
1921 * @return オブジェクトがある場合TRUEを返す
1924 * Let user choose a pile of spikes, perhaps?
1927 static bool get_spike(INVENTORY_IDX *ip)
1931 /* Check every item in the pack */
1932 for (i = 0; i < INVEN_PACK; i++)
1934 object_type *o_ptr = &inventory[i];
1936 /* Skip non-objects */
1937 if (!o_ptr->k_idx) continue;
1939 /* Check the "tval" code */
1940 if (o_ptr->tval == TV_SPIKE)
1942 /* Save the spike index */
1955 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1956 * Jam a closed door with a spike
1960 * This command may NOT be repeated
1963 void do_cmd_spike(void)
1967 if (p_ptr->wild_mode) return;
1969 if (p_ptr->special_defense & KATA_MUSOU)
1971 set_action(ACTION_NONE);
1974 /* Get a "repeated" direction */
1975 if (get_rep_dir(&dir, FALSE))
1982 y = p_ptr->y + ddy[dir];
1983 x = p_ptr->x + ddx[dir];
1984 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1986 /* Feature code (applying "mimic" field) */
1987 feat = get_feat_mimic(g_ptr);
1989 /* Require closed door */
1990 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1992 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1996 else if (!get_spike(&item))
1998 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2001 /* Is a monster in the way? */
2002 else if (g_ptr->m_idx)
2004 take_turn(p_ptr, 100);
2006 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2015 take_turn(p_ptr, 100);
2017 /* Successful jamming */
2018 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2019 cave_alter_feat(y, x, FF_SPIKE);
2021 /* Use up, and describe, a single spike, from the bottom */
2022 inven_item_increase(item, -1);
2023 inven_item_describe(item);
2024 inven_item_optimize(item);
2032 * @brief 「歩く」動作コマンドのメインルーチン /
2033 * Support code for the "Walk" and "Jump" commands
2034 * @param pickup アイテムの自動拾いを行うならTRUE
2037 void do_cmd_walk(bool pickup)
2044 /* Allow repeated command */
2047 /* Set repeat count */
2048 command_rep = command_arg - 1;
2049 p_ptr->redraw |= (PR_STATE);
2051 /* Cancel the arg */
2055 /* Get a "repeated" direction */
2056 if (get_rep_dir(&dir, FALSE))
2058 take_turn(p_ptr, 100);
2060 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2062 set_action(ACTION_NONE);
2065 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2066 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2067 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2069 /* Actually move the character */
2070 move_player(dir, pickup, FALSE);
2072 /* Allow more walking */
2076 /* Hack again -- Is there a special encounter ??? */
2077 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2079 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2082 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2084 /* Inform the player of his horrible fate :=) */
2085 msg_print(_("襲撃だ!", "You are ambushed !"));
2087 /* Go into large wilderness view */
2088 p_ptr->oldpy = randint1(MAX_HGT-2);
2089 p_ptr->oldpx = randint1(MAX_WID-2);
2092 /* Give first move to monsters */
2093 take_turn(p_ptr, 100);
2095 /* HACk -- set the encouter flag for the wilderness generation */
2096 generate_encounter = TRUE;
2100 /* Cancel repeat unless we may continue */
2101 if (!more) disturb(FALSE, FALSE);
2106 * @brief 「走る」動作コマンドのメインルーチン /
2110 void do_cmd_run(void)
2113 if (cmd_limit_confused(p_ptr)) return;
2115 if (p_ptr->special_defense & KATA_MUSOU)
2117 set_action(ACTION_NONE);
2120 /* Get a "repeated" direction */
2121 if (get_rep_dir(&dir,FALSE))
2123 /* Hack -- Set the run counter */
2124 running = (command_arg ? command_arg : 1000);
2133 * @brief 「留まる」動作コマンドのメインルーチン /
2134 * Stay still. Search. Enter stores.
2135 * Pick up treasure if "pickup" is true.
2136 * @param pickup アイテムの自動拾いを行うならTRUE
2139 void do_cmd_stay(bool pickup)
2141 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2143 /* Allow repeated command */
2146 /* Set repeat count */
2147 command_rep = command_arg - 1;
2148 p_ptr->redraw |= (PR_STATE);
2150 /* Cancel the arg */
2154 take_turn(p_ptr, 100);
2156 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2157 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2162 * @brief 「休む」動作コマンドのメインルーチン /
2163 * Resting allows a player to safely restore his hp -RAK-
2166 void do_cmd_rest(void)
2169 set_action(ACTION_NONE);
2171 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2173 stop_singing(p_ptr);
2177 if (hex_spelling_any()) stop_hex_spell_all();
2179 /* Prompt for time if needed */
2180 if (command_arg <= 0)
2182 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2183 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2189 strcpy(out_val, "&");
2191 /* Ask for duration */
2192 if (!get_string(p, out_val, 4)) return;
2194 /* Rest until done */
2195 if (out_val[0] == '&')
2197 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2201 else if (out_val[0] == '*')
2203 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2209 command_arg = (COMMAND_ARG)atoi(out_val);
2210 if (command_arg <= 0) return;
2214 if (command_arg > 9999) command_arg = 9999;
2216 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2218 /* Take a current_world_ptr->game_turn (?) */
2219 take_turn(p_ptr, 100);
2221 /* The sin of sloth */
2222 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2224 /* Why are you sleeping when there's no need? WAKE UP!*/
2225 if ((p_ptr->chp == p_ptr->mhp) &&
2226 (p_ptr->csp == p_ptr->msp) &&
2227 !p_ptr->blind && !p_ptr->confused &&
2228 !p_ptr->poisoned && !p_ptr->afraid &&
2229 !p_ptr->stun && !p_ptr->cut &&
2230 !p_ptr->slow && !p_ptr->paralyzed &&
2231 !p_ptr->image && !p_ptr->word_recall &&
2232 !p_ptr->alter_reality)
2233 chg_virtue(V_DILIGENCE, -1);
2235 /* Save the rest code */
2236 p_ptr->resting = command_arg;
2237 p_ptr->action = ACTION_REST;
2238 p_ptr->update |= (PU_BONUS);
2239 update_creature(p_ptr);
2241 p_ptr->redraw |= (PR_STATE);
2250 * @brief 射撃処理のメインルーチン
2253 void do_cmd_fire(SPELL_IDX snipe_type)
2256 object_type *j_ptr, *ammo_ptr;
2259 if(p_ptr->wild_mode) return;
2261 is_fired = FALSE; /* not fired yet */
2263 /* Get the "bow" (if any) */
2264 j_ptr = &inventory[INVEN_BOW];
2266 /* Require a launcher */
2269 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2274 if (j_ptr->sval == SV_CRIMSON)
2276 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2281 if (j_ptr->sval == SV_HARP)
2283 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2289 if (p_ptr->special_defense & KATA_MUSOU)
2291 set_action(ACTION_NONE);
2294 /* Require proper missile */
2295 item_tester_tval = p_ptr->tval_ammo;
2297 q = _("どれを撃ちますか? ", "Fire which item? ");
2298 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2301 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2309 exe_fire(item, j_ptr, snipe_type);
2311 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2313 /* Sniper actions after some shootings */
2314 if (snipe_type == SP_AWAY)
2316 teleport_player(10 + (p_ptr->concent * 2), 0L);
2318 if (snipe_type == SP_FINAL)
2320 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2321 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2322 (void)set_stun(p_ptr->stun + randint1(25));
2328 * @brief 投射処理メインルーチン /
2329 * Throw an object from the pack or floor.
2331 * @param boomerang ブーメラン処理ならばTRUE
2332 * @param shuriken 忍者の手裏剣処理ならばTRUE
2333 * @return ターンを消費した場合TRUEを返す
2336 * Note: "unseen" monsters are very hard to hit.
2338 * Should throwing a weapon do full damage? Should it allow the magic
2339 * to hit bonus of the weapon to have an effect? Should it ever cause
2340 * the item to be destroyed? Should it do any damage at all?
2343 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2348 POSITION y, x, ty, tx, prev_y, prev_x;
2349 POSITION ny[19], nx[19];
2350 int chance, tdam, tdis;
2351 int mul, div, dd, ds;
2352 int cur_dis, visible;
2359 bool hit_body = FALSE;
2360 bool hit_wall = FALSE;
2361 bool equiped_item = FALSE;
2362 bool return_when_thrown = FALSE;
2364 GAME_TEXT o_name[MAX_NLEN];
2366 int msec = delay_factor * delay_factor * delay_factor;
2368 BIT_FLAGS flgs[TR_FLAG_SIZE];
2370 bool come_back = FALSE;
2371 bool do_drop = TRUE;
2373 if (p_ptr->wild_mode) return FALSE;
2375 if (p_ptr->special_defense & KATA_MUSOU)
2377 set_action(ACTION_NONE);
2383 o_ptr = &inventory[item];
2387 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2389 item_tester_hook = item_tester_hook_boomerang;
2390 q = _("どの武器を投げますか? ", "Throw which item? ");
2391 s = _("投げる武器がない。", "You have nothing to throw.");
2392 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2399 else if (has_melee_weapon(INVEN_LARM))
2402 o_ptr = &inventory[item];
2407 o_ptr = &inventory[item];
2412 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2413 s = _("投げるアイテムがない。", "You have nothing to throw.");
2414 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2422 /* Item is cursed */
2423 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2425 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2429 if (p_ptr->inside_arena && !boomerang)
2431 if (o_ptr->tval != TV_SPIKE)
2433 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2442 /* Obtain a local object */
2443 object_copy(q_ptr, o_ptr);
2445 /* Extract the thrown object's flags. */
2446 object_flags(q_ptr, flgs);
2447 torch_flags(q_ptr, flgs);
2449 /* Distribute the charges of rods/wands between the stacks */
2450 distribute_charges(o_ptr, q_ptr, 1);
2455 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2457 if (p_ptr->mighty_throw) mult += 3;
2459 /* Extract a "distance multiplier" */
2460 /* Changed for 'launcher' mutation */
2461 mul = 10 + 2 * (mult - 1);
2463 /* Enforce a minimum "weight" of one pound */
2464 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2465 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2467 /* Hack -- Distance -- Reward strength, penalize weight */
2468 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2470 /* Max distance of 10-18 */
2471 if (tdis > mul) tdis = mul;
2475 ty = randint0(101) - 50 + p_ptr->y;
2476 tx = randint0(101) - 50 + p_ptr->x;
2480 project_length = tdis + 1;
2482 /* Get a direction (or cancel) */
2483 if (!get_aim_dir(&dir)) return FALSE;
2485 /* Predict the "target" location */
2486 tx = p_ptr->x + 99 * ddx[dir];
2487 ty = p_ptr->y + 99 * ddy[dir];
2489 /* Check for "target request" */
2490 if ((dir == 5) && target_okay())
2496 project_length = 0; /* reset to default */
2499 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2500 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2501 return_when_thrown = TRUE;
2503 /* Reduce and describe inventory */
2506 inven_item_increase(item, -1);
2507 if (!return_when_thrown)
2508 inven_item_describe(item);
2509 inven_item_optimize(item);
2512 /* Reduce and describe floor item */
2515 floor_item_increase(0 - item, -1);
2516 floor_item_optimize(0 - item);
2518 if (item >= INVEN_RARM)
2520 equiped_item = TRUE;
2521 p_ptr->redraw |= (PR_EQUIPPY);
2524 take_turn(p_ptr, 100);
2526 /* Rogue and Ninja gets bonus */
2527 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2528 p_ptr->energy_use -= p_ptr->lev;
2530 /* Start at the player */
2536 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2537 else shuriken = FALSE;
2539 /* Chance of hitting */
2540 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2541 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2542 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2544 if (shuriken) chance *= 2;
2549 /* Travel until stopped */
2550 for (cur_dis = 0; cur_dis <= tdis; )
2552 /* Hack -- Stop at the target */
2553 if ((y == ty) && (x == tx)) break;
2555 /* Calculate the new location (see "project()") */
2558 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2560 /* Stopped by walls/doors */
2561 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2564 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;
2567 /* The player can see the (on screen) missile */
2568 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2570 SYMBOL_CODE c = object_char(q_ptr);
2571 TERM_COLOR a = object_attr(q_ptr);
2573 /* Draw, Hilite, Fresh, Pause, Erase */
2574 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2575 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2577 Term_xtra(TERM_XTRA_DELAY, msec);
2578 lite_spot(ny[cur_dis], nx[cur_dis]);
2582 /* The player cannot see the missile */
2585 /* Pause anyway, for consistancy */
2586 Term_xtra(TERM_XTRA_DELAY, msec);
2592 /* Save the new location */
2596 /* Advance the distance */
2599 /* Monster here, Try to hit it */
2600 if (current_floor_ptr->grid_array[y][x].m_idx)
2602 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2603 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2604 GAME_TEXT m_name[MAX_NLEN];
2605 monster_name(g_ptr->m_idx, m_name);
2607 /* Check the visibility */
2608 visible = m_ptr->ml;
2610 /* Note the collision */
2613 /* Did we hit it (penalize range) */
2614 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2618 /* Handle unseen monster */
2621 /* Invisible monster */
2622 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2625 /* Handle visible monster */
2628 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2632 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2633 health_track(g_ptr->m_idx);
2637 /* Hack -- Base damage from thrown object */
2640 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2641 tdam = damroll(dd, ds);
2642 /* Apply special damage */
2643 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2644 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2645 if (q_ptr->to_d > 0)
2646 tdam += q_ptr->to_d;
2648 tdam += -q_ptr->to_d;
2652 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2653 tdam += p_ptr->to_d_m;
2655 else if (have_flag(flgs, TR_THROW))
2658 tdam += p_ptr->to_d_m;
2666 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2669 /* No negative damage */
2670 if (tdam < 0) tdam = 0;
2672 /* Modify the damage */
2673 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2675 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2676 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2678 /* Hit the monster, check for death */
2679 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2687 message_pain(g_ptr->m_idx, tdam);
2689 /* Anger the monster */
2690 if ((tdam > 0) && !object_is_potion(q_ptr))
2691 anger_monster(m_ptr);
2693 if (fear && m_ptr->ml)
2696 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2706 /* decrease toach's fuel */
2707 if (hit_body) torch_lost_fuel(q_ptr);
2709 /* Chance of breakage (during attacks) */
2710 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2712 /* Figurines transform */
2713 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2717 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2718 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2719 else if (object_is_cursed(q_ptr))
2720 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2724 /* Potions smash open */
2725 if (object_is_potion(q_ptr))
2727 if (hit_body || hit_wall || (randint1(100) < j))
2729 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2731 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2733 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2734 if (current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2736 GAME_TEXT m_name[MAX_NLEN];
2737 monster_desc(m_name, m_ptr, 0);
2738 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2739 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2750 if (return_when_thrown)
2752 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2753 char o2_name[MAX_NLEN];
2754 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2757 if (boomerang) back_chance += 4+randint1(5);
2758 if (super_boomerang) back_chance += 100;
2759 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2761 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2763 for (i = cur_dis - 1; i > 0; i--)
2765 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2767 char c = object_char(q_ptr);
2768 byte a = object_attr(q_ptr);
2770 /* Draw, Hilite, Fresh, Pause, Erase */
2771 print_rel(c, a, ny[i], nx[i]);
2772 move_cursor_relative(ny[i], nx[i]);
2774 Term_xtra(TERM_XTRA_DELAY, msec);
2775 lite_spot(ny[i], nx[i]);
2780 /* Pause anyway, for consistancy */
2781 Term_xtra(TERM_XTRA_DELAY, msec);
2784 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2786 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2793 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2797 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2805 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2811 if (item == INVEN_RARM || item == INVEN_LARM)
2813 /* Access the wield slot */
2814 o_ptr = &inventory[item];
2816 /* Wear the new stuff */
2817 object_copy(o_ptr, q_ptr);
2819 p_ptr->total_weight += q_ptr->weight;
2821 /* Increment the equip counter by hand */
2824 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2825 p_ptr->window |= (PW_EQUIP);
2833 else if (equiped_item)
2841 if (cave_have_flag_bold(y, x, FF_PROJECT))
2843 (void)drop_near(q_ptr, j, y, x);
2847 (void)drop_near(q_ptr, j, prev_y, prev_x);
2855 * @brief 自殺するコマンドのメインルーチン
2856 * Hack -- commit suicide
2860 void do_cmd_suicide(void)
2867 /* Verify Retirement */
2868 if (p_ptr->total_winner)
2871 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2874 /* Verify Suicide */
2878 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2882 if (!p_ptr->noscore)
2884 /* Special Verification for suicide */
2885 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2890 if (i != '@') return;
2892 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2895 /* Initialize "last message" buffer */
2896 if (p_ptr->last_message) string_free(p_ptr->last_message);
2897 p_ptr->last_message = NULL;
2899 /* Hack -- Note *winning* message */
2900 if (p_ptr->total_winner && last_words)
2902 char buf[1024] = "";
2903 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2906 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2907 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2911 p_ptr->last_message = string_make(buf);
2912 msg_print(p_ptr->last_message);
2917 p_ptr->playing = FALSE;
2919 /* Kill the player */
2920 p_ptr->is_dead = TRUE;
2921 p_ptr->leaving = TRUE;
2923 if (!p_ptr->total_winner)
2925 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
2926 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2927 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
2930 /* Cause of death */
2931 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));