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.
17 #include "object-hook.h"
18 #include "projection.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 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
32 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
33 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
35 static bool confirm_leave_level(bool down_stair)
37 quest_type *q_ptr = &quest[p_ptr->inside_quest];
39 /* Confirm leaving from once only quest */
40 if (confirm_quest && p_ptr->inside_quest &&
41 (q_ptr->type == QUEST_TYPE_RANDOM ||
42 (q_ptr->flags & QUEST_FLAG_ONCE &&
43 q_ptr->status != QUEST_STATUS_COMPLETED) ||
44 (q_ptr->flags & QUEST_FLAG_TOWER &&
45 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
46 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
48 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
49 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
59 * @brief 魔法系コマンドが制限されているかを返す。
60 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
62 bool cmd_limit_cast(player_type *creature_ptr)
64 if (dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
66 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
70 else if (creature_ptr->anti_magic)
72 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
75 else if (creature_ptr->shero)
77 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
84 bool cmd_limit_confused(player_type *creature_ptr)
86 if (creature_ptr->confused)
88 msg_print(_("混乱していてできない!", "You are too confused!"));
94 bool cmd_limit_arena(player_type *creature_ptr)
96 if (creature_ptr->inside_arena)
98 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
105 bool cmd_limit_blind(player_type *creature_ptr)
107 if (creature_ptr->blind)
109 msg_print(_("目が見えない。", "You can't see anything."));
114 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
120 bool cmd_limit_time_walk(player_type *creature_ptr)
122 if (creature_ptr->timewalk)
124 if (flush_failure) flush();
125 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
133 * @brief 階段を使って階層を昇る処理 / Go up one level
136 void do_cmd_go_up(void)
141 grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
142 feature_type *f_ptr = &f_info[g_ptr->feat];
146 if (p_ptr->special_defense & KATA_MUSOU)
148 set_action(ACTION_NONE);
152 if (!have_flag(f_ptr->flags, FF_LESS))
154 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
158 /* Quest up stairs */
159 if (have_flag(f_ptr->flags, FF_QUEST))
161 /* Cancel the command */
162 if (!confirm_leave_level(FALSE)) return;
166 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
167 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
169 msg_print(_("上の階に登った。", "You enter the up staircase."));
173 p_ptr->inside_quest = g_ptr->special;
175 /* Activate the quest */
176 if (!quest[p_ptr->inside_quest].status)
178 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
180 init_flags = INIT_ASSIGN;
181 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
183 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
186 /* Leaving a quest */
187 if (!p_ptr->inside_quest)
193 p_ptr->leaving = TRUE;
198 take_turn(p_ptr, 100);
200 /* End the command */
210 go_up = confirm_leave_level(FALSE);
213 /* Cancel the command */
216 take_turn(p_ptr, 100);
218 if (autosave_l) do_cmd_save_game(TRUE);
220 /* For a random quest */
221 if (p_ptr->inside_quest &&
222 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
226 p_ptr->inside_quest = 0;
229 /* For a fixed quest */
230 if (p_ptr->inside_quest &&
231 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
235 p_ptr->inside_quest = g_ptr->special;
240 /* For normal dungeon and random quest */
244 if (have_flag(f_ptr->flags, FF_SHAFT))
246 /* Create a way back */
247 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
253 /* Create a way back */
254 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
259 /* Get out from current dungeon */
260 if (dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
263 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
266 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
267 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
268 else if (up_num == dun_level)
269 msg_print(_("地上に戻った。", "You go back to the surface."));
271 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
274 p_ptr->leaving = TRUE;
279 * @brief 階段を使って階層を降りる処理 / Go down one level
282 void do_cmd_go_down(void)
285 grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
286 feature_type *f_ptr = &f_info[g_ptr->feat];
288 bool fall_trap = FALSE;
291 if (p_ptr->special_defense & KATA_MUSOU)
293 set_action(ACTION_NONE);
297 if (!have_flag(f_ptr->flags, FF_MORE))
299 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
303 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
306 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
311 /* Quest down stairs */
312 else if (have_flag(f_ptr->flags, FF_QUEST))
314 /* Confirm Leaving */
315 if(!confirm_leave_level(TRUE)) return;
317 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
318 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
320 msg_print(_("下の階に降りた。", "You enter the down staircase."));
325 p_ptr->inside_quest = g_ptr->special;
327 /* Activate the quest */
328 if (!quest[p_ptr->inside_quest].status)
330 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
332 init_flags = INIT_ASSIGN;
333 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
335 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
338 /* Leaving a quest */
339 if (!p_ptr->inside_quest)
345 p_ptr->leaving = TRUE;
349 take_turn(p_ptr, 100);
354 DUNGEON_IDX target_dungeon = 0;
358 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
360 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
362 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
365 if (!max_dlv[target_dungeon])
367 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
368 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
369 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
372 /* Save old player position */
373 p_ptr->oldpx = p_ptr->x;
374 p_ptr->oldpy = p_ptr->y;
375 p_ptr->dungeon_idx = target_dungeon;
378 * Clear all saved floors
379 * and create a first saved floor
381 prepare_change_floor_mode(CFM_FIRST_FLOOR);
384 take_turn(p_ptr, 100);
386 if (autosave_l) do_cmd_save_game(TRUE);
389 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
394 /* Enter the dungeon just now */
395 p_ptr->enter_dungeon = TRUE;
396 down_num = d_info[p_ptr->dungeon_idx].mindepth;
401 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
402 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
407 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
414 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
418 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
419 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
421 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
427 p_ptr->leaving = TRUE;
431 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
435 if (have_flag(f_ptr->flags, FF_SHAFT))
437 /* Create a way back */
438 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
442 /* Create a way back */
443 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
451 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
454 void do_cmd_search(void)
456 /* Allow repeated command */
459 /* Set repeat count */
460 command_rep = command_arg - 1;
461 p_ptr->redraw |= (PR_STATE);
466 take_turn(p_ptr, 100);
474 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
475 * @param y 走査対象にしたいマスのY座標
476 * @param x 走査対象にしたいマスのX座標
477 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
478 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
480 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
482 grid_type *g_ptr = &grid_array[y][x];
483 OBJECT_IDX this_o_idx, next_o_idx = 0;
485 /* Scan all objects in the grid */
486 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
490 o_ptr = &o_list[this_o_idx];
491 next_o_idx = o_ptr->next_o_idx;
493 /* Skip unknown chests XXX XXX */
494 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
496 /* Check for non empty chest */
497 if ((o_ptr->tval == TV_CHEST) &&
498 (((!trapped) && (o_ptr->pval)) || /* non empty */
499 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
508 * @brief 箱を開けるコマンドのメインルーチン /
509 * Attempt to open the given chest at the given location
510 * @param y 箱の存在するマスのY座標
511 * @param x 箱の存在するマスのX座標
512 * @param o_idx 箱のオブジェクトID
513 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
515 * Assume there is no monster blocking the destination
517 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
522 object_type *o_ptr = &o_list[o_idx];
524 take_turn(p_ptr, 100);
526 /* Attempt to unlock it */
529 /* Assume locked, and thus not open */
532 /* Get the "disarm" factor */
533 i = p_ptr->skill_dis;
535 /* Penalize some conditions */
536 if (p_ptr->blind || no_lite()) i = i / 10;
537 if (p_ptr->confused || p_ptr->image) i = i / 10;
539 /* Extract the difficulty */
542 /* Always have a small chance of success */
545 /* Success -- May still have traps */
546 if (randint0(100) < j)
548 msg_print(_("鍵をはずした。", "You have picked the lock."));
553 /* Failure -- Keep trying */
556 /* We may continue repeating */
558 if (flush_failure) flush();
559 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
564 /* Allowed to open */
567 /* Apply chest traps, if any */
568 chest_trap(y, x, o_idx);
570 /* Let the Chest drop items */
571 chest_death(FALSE, y, x, o_idx);
577 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
578 * Attempt to open the given chest at the given location
579 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
580 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
581 * @param test 地形条件を判定するための関数ポインタ
582 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
584 * @details Return the number of features around (or under) the character.
585 * Usually look for doors and floor traps.
587 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
593 /* Count how many matches */
596 /* Check around (and under) the character */
597 for (d = 0; d < 9; d++)
602 /* if not searching under player continue */
603 if ((d == 8) && !under) continue;
605 /* Extract adjacent (legal) location */
606 yy = p_ptr->y + ddy_ddd[d];
607 xx = p_ptr->x + ddx_ddd[d];
609 /* Get the grid_array */
610 g_ptr = &grid_array[yy][xx];
612 /* Must have knowledge */
613 if (!(g_ptr->info & (CAVE_MARK))) continue;
615 /* Feature code (applying "mimic" field) */
616 feat = get_feat_mimic(g_ptr);
618 /* Not looking for this feature */
619 if (!((*test)(feat))) continue;
624 /* Remember the location. Only useful if only one match */
635 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
636 * Return the number of chests around (or under) the character.
637 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
638 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
639 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
642 * If requested, count only trapped chests.
644 static int count_chests(POSITION *y, POSITION *x, bool trapped)
651 /* Count how many matches */
654 /* Check around (and under) the character */
655 for (d = 0; d < 9; d++)
657 /* Extract adjacent (legal) location */
658 POSITION yy = p_ptr->y + ddy_ddd[d];
659 POSITION xx = p_ptr->x + ddx_ddd[d];
661 /* No (visible) chest is there */
662 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
664 /* Grab the object */
665 o_ptr = &o_list[o_idx];
668 if (o_ptr->pval == 0) continue;
670 /* No (known) traps here */
671 if (trapped && (!object_is_known(o_ptr) ||
672 !chest_traps[o_ptr->pval])) continue;
677 /* Remember the location. Only useful if only one match */
689 * @brief 「開ける」動作コマンドのサブルーチン /
690 * Perform the basic "open" command on doors
691 * @param y 対象を行うマスのY座標
692 * @param x 対象を行うマスのX座標
693 * @return 実際に処理が行われた場合TRUEを返す。
695 * Assume destination is a closed/locked/jammed door
696 * Assume there is no monster blocking the destination
697 * Returns TRUE if repeated commands may continue
699 static bool do_cmd_open_aux(POSITION y, POSITION x)
703 /* Get requested grid */
704 grid_type *g_ptr = &grid_array[y][x];
705 feature_type *f_ptr = &f_info[g_ptr->feat];
708 take_turn(p_ptr, 100);
710 /* Seeing true feature code (ignore mimic) */
713 if (!have_flag(f_ptr->flags, FF_OPEN))
716 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
720 else if (f_ptr->power)
723 i = p_ptr->skill_dis;
725 /* Penalize some conditions */
726 if (p_ptr->blind || no_lite()) i = i / 10;
727 if (p_ptr->confused || p_ptr->image) i = i / 10;
729 /* Extract the lock power */
732 /* Extract the difficulty */
735 /* Always have a small chance of success */
739 if (randint0(100) < j)
741 msg_print(_("鍵をはずした。", "You have picked the lock."));
744 cave_alter_feat(y, x, FF_OPEN);
746 sound(SOUND_OPENDOOR);
756 if (flush_failure) flush();
758 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
760 /* We may keep trying */
769 cave_alter_feat(y, x, FF_OPEN);
771 sound(SOUND_OPENDOOR);
777 * @brief 「開ける」コマンドのメインルーチン /
778 * Open a closed/locked/jammed door or a closed/locked chest.
781 * Unlocking a locked door/chest is worth one experience point.
783 void do_cmd_open(void)
791 if (p_ptr->wild_mode) return;
793 if (p_ptr->special_defense & KATA_MUSOU)
795 set_action(ACTION_NONE);
798 /* Option: Pick a direction */
801 int num_doors, num_chests;
803 /* Count closed doors (locked or jammed) */
804 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
806 /* Count chests (locked) */
807 num_chests = count_chests(&y, &x, FALSE);
809 /* See if only one target */
810 if (num_doors || num_chests)
812 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
814 if (!too_many) command_dir = coords_to_dir(y, x);
818 /* Allow repeated command */
821 /* Set repeat count */
822 command_rep = command_arg - 1;
823 p_ptr->redraw |= (PR_STATE);
829 /* Get a "repeated" direction */
830 if (get_rep_dir(&dir, TRUE))
835 /* Get requested location */
836 y = p_ptr->y + ddy[dir];
837 x = p_ptr->x + ddx[dir];
839 /* Get requested grid */
840 g_ptr = &grid_array[y][x];
842 /* Feature code (applying "mimic" field) */
843 feat = get_feat_mimic(g_ptr);
845 /* Check for chest */
846 o_idx = chest_check(y, x, FALSE);
849 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
851 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
854 /* Monster in the way */
855 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
857 take_turn(p_ptr, 100);
858 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
866 more = do_cmd_open_chest(y, x, o_idx);
873 more = do_cmd_open_aux(y, x);
877 /* Cancel repeat unless we may continue */
878 if (!more) disturb(FALSE, FALSE);
884 * @brief 「閉じる」動作コマンドのサブルーチン /
885 * Perform the basic "close" command
886 * @param y 対象を行うマスのY座標
887 * @param x 対象を行うマスのX座標
888 * @return 実際に処理が行われた場合TRUEを返す。
890 * Assume destination is an open/broken door
891 * Assume there is no monster blocking the destination
892 * Returns TRUE if repeated commands may continue
894 static bool do_cmd_close_aux(POSITION y, POSITION x)
896 grid_type *g_ptr = &grid_array[y][x];
897 FEAT_IDX old_feat = g_ptr->feat;
900 take_turn(p_ptr, 100);
902 /* Seeing true feature code (ignore mimic) */
905 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
907 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
909 /* Hack -- object in the way */
910 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
911 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
913 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
918 cave_alter_feat(y, x, FF_CLOSE);
921 if (old_feat == g_ptr->feat)
923 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
927 sound(SOUND_SHUTDOOR);
936 * @brief 「閉じる」コマンドのメインルーチン /
937 * Close an open door.
940 * Unlocking a locked door/chest is worth one experience point.
942 void do_cmd_close(void)
949 if (p_ptr->wild_mode) return;
951 if (p_ptr->special_defense & KATA_MUSOU)
953 set_action(ACTION_NONE);
956 /* Option: Pick a direction */
959 /* Count open doors */
960 if (count_dt(&y, &x, is_open, FALSE) == 1)
962 command_dir = coords_to_dir(y, x);
966 /* Allow repeated command */
969 /* Set repeat count */
970 command_rep = command_arg - 1;
971 p_ptr->redraw |= (PR_STATE);
977 /* Get a "repeated" direction */
978 if (get_rep_dir(&dir, FALSE))
983 y = p_ptr->y + ddy[dir];
984 x = p_ptr->x + ddx[dir];
985 g_ptr = &grid_array[y][x];
987 /* Feature code (applying "mimic" field) */
988 feat = get_feat_mimic(g_ptr);
990 /* Require open/broken door */
991 if (!have_flag(f_info[feat].flags, FF_CLOSE))
993 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
996 /* Monster in the way */
997 else if (g_ptr->m_idx)
999 take_turn(p_ptr, 100);
1001 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1007 /* Close the door */
1010 /* Close the door */
1011 more = do_cmd_close_aux(y, x);
1015 /* Cancel repeat unless we may continue */
1016 if (!more) disturb(FALSE, FALSE);
1021 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1022 * Determine if a given grid may be "tunneled"
1023 * @param y 対象を行うマスのY座標
1024 * @param x 対象を行うマスのX座標
1027 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1029 grid_type *g_ptr = &grid_array[y][x];
1031 /* Must have knowledge */
1032 if (!(g_ptr->info & CAVE_MARK))
1034 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1039 /* Must be a wall/door/etc */
1040 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1042 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1052 * @brief 「掘る」動作コマンドのサブルーチン /
1053 * Perform the basic "tunnel" command
1054 * @param y 対象を行うマスのY座標
1055 * @param x 対象を行うマスのX座標
1056 * @return 実際に処理が行われた場合TRUEを返す。
1058 * Assumes that no monster is blocking the destination
1059 * Do not use twall anymore
1060 * Returns TRUE if repeated commands may continue
1062 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1065 feature_type *f_ptr, *mimic_f_ptr;
1070 /* Verify legality */
1071 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1073 take_turn(p_ptr, 100);
1075 g_ptr = &grid_array[y][x];
1076 f_ptr = &f_info[g_ptr->feat];
1077 power = f_ptr->power;
1079 /* Feature code (applying "mimic" field) */
1080 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1082 name = f_name + mimic_f_ptr->name;
1086 if (have_flag(f_ptr->flags, FF_PERMANENT))
1089 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1091 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1094 /* Map border (mimiccing Permanent wall) */
1097 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1102 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1105 if (p_ptr->skill_dig > randint0(20 * power))
1107 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1109 /* Remove the feature */
1110 cave_alter_feat(y, x, FF_TUNNEL);
1112 /* Update some things */
1113 p_ptr->update |= (PU_FLOW);
1117 /* Message, keep digging */
1118 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1126 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1129 if (p_ptr->skill_dig > power + randint0(40 * power))
1131 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1134 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1135 p_ptr->update |= (PU_FLOW);
1138 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1140 /* Remove the feature */
1141 cave_alter_feat(y, x, FF_TUNNEL);
1143 chg_virtue(V_DILIGENCE, 1);
1144 chg_virtue(V_NATURE, -1);
1152 /* We may continue chopping */
1153 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1154 /* Occasional Search XXX XXX */
1155 if (randint0(100) < 25) search();
1159 /* We may continue tunelling */
1160 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1167 if (is_hidden_door(g_ptr))
1169 /* Occasional Search XXX XXX */
1170 if (randint0(100) < 25) search();
1177 * @brief 「掘る」動作コマンドのメインルーチン /
1178 * Tunnels through "walls" (including rubble and closed doors)
1182 * Note that you must tunnel in order to hit invisible monsters
1183 * in walls, though moving into walls still takes a turn anyway.
1185 * Digging is very difficult without a "digger" weapon, but can be
1186 * accomplished by strong players using heavy weapons.
1189 void do_cmd_tunnel(void)
1198 if (p_ptr->special_defense & KATA_MUSOU)
1200 set_action(ACTION_NONE);
1203 /* Allow repeated command */
1206 /* Set repeat count */
1207 command_rep = command_arg - 1;
1208 p_ptr->redraw |= (PR_STATE);
1210 /* Cancel the arg */
1214 /* Get a direction to tunnel, or Abort */
1215 if (get_rep_dir(&dir,FALSE))
1218 y = p_ptr->y + ddy[dir];
1219 x = p_ptr->x + ddx[dir];
1221 g_ptr = &grid_array[y][x];
1223 /* Feature code (applying "mimic" field) */
1224 feat = get_feat_mimic(g_ptr);
1226 /* No tunnelling through doors */
1227 if (have_flag(f_info[feat].flags, FF_DOOR))
1229 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1232 /* No tunnelling through most features */
1233 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1235 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1238 /* A monster is in the way */
1239 else if (g_ptr->m_idx)
1241 take_turn(p_ptr, 100);
1243 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1252 /* Tunnel through walls */
1253 more = do_cmd_tunnel_aux(y, x);
1257 /* Cancel repetition unless we can continue */
1258 if (!more) disturb(FALSE, FALSE);
1262 * @brief 移動処理による簡易な「開く」処理 /
1264 * @return 開く処理が実際に試みられた場合TRUEを返す
1267 * If there is a jammed/closed/locked door at the given location,
1268 * then attempt to unlock/open it. Return TRUE if an attempt was
1269 * made (successful or not), otherwise return FALSE.
1271 * The code here should be nearly identical to that in
1272 * do_cmd_open_test() and do_cmd_open_aux().
1275 bool easy_open_door(POSITION y, POSITION x)
1279 grid_type *g_ptr = &grid_array[y][x];
1280 feature_type *f_ptr = &f_info[g_ptr->feat];
1282 /* Must be a closed door */
1283 if (!is_closed_door(g_ptr->feat))
1289 if (!have_flag(f_ptr->flags, FF_OPEN))
1292 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1297 else if (f_ptr->power)
1300 i = p_ptr->skill_dis;
1302 /* Penalize some conditions */
1303 if (p_ptr->blind || no_lite()) i = i / 10;
1304 if (p_ptr->confused || p_ptr->image) i = i / 10;
1306 /* Extract the lock power */
1309 /* Extract the difficulty */
1312 /* Always have a small chance of success */
1316 if (randint0(100) < j)
1318 msg_print(_("鍵をはずした。", "You have picked the lock."));
1321 cave_alter_feat(y, x, FF_OPEN);
1323 sound(SOUND_OPENDOOR);
1333 if (flush_failure) flush();
1335 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1344 cave_alter_feat(y, x, FF_OPEN);
1346 sound(SOUND_OPENDOOR);
1352 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1353 * Perform the basic "disarm" command
1354 * @param y 解除を行うマスのY座標
1355 * @param x 解除を行うマスのX座標
1356 * @param o_idx 箱のオブジェクトID
1357 * @return ターンを消費する処理が行われた場合TRUEを返す
1360 * Assume destination is a visible trap
1361 * Assume there is no monster blocking the destination
1362 * Returns TRUE if repeated commands may continue
1365 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1369 object_type *o_ptr = &o_list[o_idx];
1371 take_turn(p_ptr, 100);
1373 /* Get the "disarm" factor */
1374 i = p_ptr->skill_dis;
1376 /* Penalize some conditions */
1377 if (p_ptr->blind || no_lite()) i = i / 10;
1378 if (p_ptr->confused || p_ptr->image) i = i / 10;
1380 /* Extract the difficulty */
1381 j = i - o_ptr->pval;
1383 /* Always have a small chance of success */
1386 /* Must find the trap first. */
1387 if (!object_is_known(o_ptr))
1389 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1393 /* Already disarmed/unlocked */
1394 else if (o_ptr->pval <= 0)
1396 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1399 /* No traps to find. */
1400 else if (!chest_traps[o_ptr->pval])
1402 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1405 /* Success (get a lot of experience) */
1406 else if (randint0(100) < j)
1408 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1409 gain_exp(o_ptr->pval);
1410 o_ptr->pval = (0 - o_ptr->pval);
1413 /* Failure -- Keep trying */
1414 else if ((i > 5) && (randint1(i) > 5))
1416 /* We may keep trying */
1418 if (flush_failure) flush();
1419 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1422 /* Failure -- Set off the trap */
1425 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1427 chest_trap(y, x, o_idx);
1434 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1435 * Perform the basic "disarm" command
1436 * @param y 解除を行うマスのY座標
1437 * @param x 解除を行うマスのX座標
1438 * @param dir プレイヤーからみた方向ID
1439 * @return ターンを消費する処理が行われた場合TRUEを返す
1442 * Assume destination is a visible trap
1443 * Assume there is no monster blocking the destination
1444 * Returns TRUE if repeated commands may continue
1448 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1450 grid_type *g_ptr = &grid_array[y][x];
1453 feature_type *f_ptr = &f_info[g_ptr->feat];
1455 /* Access trap name */
1456 concptr name = (f_name + f_ptr->name);
1458 /* Extract trap "power" */
1459 int power = f_ptr->power;
1462 /* Get the "disarm" factor */
1463 int i = p_ptr->skill_dis;
1466 take_turn(p_ptr, 100);
1468 /* Penalize some conditions */
1469 if (p_ptr->blind || no_lite()) i = i / 10;
1470 if (p_ptr->confused || p_ptr->image) i = i / 10;
1472 /* Extract the difficulty */
1475 /* Always have a small chance of success */
1479 if (randint0(100) < j)
1481 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1486 /* Remove the trap */
1487 cave_alter_feat(y, x, FF_DISARM);
1489 /* Move the player onto the trap */
1490 move_player(dir, easy_disarm, FALSE);
1493 /* Failure -- Keep trying */
1494 else if ((i > 5) && (randint1(i) > 5))
1497 if (flush_failure) flush();
1499 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1501 /* We may keep trying */
1505 /* Failure -- Set off the trap */
1508 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1509 /* Move the player onto the trap */
1510 move_player(dir, easy_disarm, FALSE);
1517 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1518 * Disarms a trap, or chest
1521 void do_cmd_disarm(void)
1529 if (p_ptr->wild_mode) return;
1531 if (p_ptr->special_defense & KATA_MUSOU)
1533 set_action(ACTION_NONE);
1536 /* Option: Pick a direction */
1539 int num_traps, num_chests;
1541 /* Count visible traps */
1542 num_traps = count_dt(&y, &x, is_trap, TRUE);
1544 /* Count chests (trapped) */
1545 num_chests = count_chests(&y, &x, TRUE);
1547 /* See if only one target */
1548 if (num_traps || num_chests)
1550 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1551 if (!too_many) command_dir = coords_to_dir(y, x);
1556 /* Allow repeated command */
1559 /* Set repeat count */
1560 command_rep = command_arg - 1;
1561 p_ptr->redraw |= (PR_STATE);
1563 /* Cancel the arg */
1567 /* Get a direction (or abort) */
1568 if (get_rep_dir(&dir,TRUE))
1573 y = p_ptr->y + ddy[dir];
1574 x = p_ptr->x + ddx[dir];
1575 g_ptr = &grid_array[y][x];
1577 /* Feature code (applying "mimic" field) */
1578 feat = get_feat_mimic(g_ptr);
1580 /* Check for chests */
1581 o_idx = chest_check(y, x, TRUE);
1584 if (!is_trap(feat) && !o_idx)
1586 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1589 /* Monster in the way */
1590 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1592 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1601 more = do_cmd_disarm_chest(y, x, o_idx);
1607 more = do_cmd_disarm_aux(y, x, dir);
1611 /* Cancel repeat unless told not to */
1612 if (!more) disturb(FALSE, FALSE);
1617 * @brief 「打ち破る」動作コマンドのサブルーチン /
1618 * Perform the basic "bash" command
1619 * @param y 対象を行うマスのY座標
1620 * @param x 対象を行うマスのX座標
1621 * @param dir プレイヤーから見たターゲットの方角ID
1622 * @return 実際に処理が行われた場合TRUEを返す。
1625 * Assume destination is a closed/locked/jammed door
1626 * Assume there is no monster blocking the destination
1627 * Returns TRUE if repeated commands may continue
1630 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1632 grid_type *g_ptr = &grid_array[y][x];
1635 feature_type *f_ptr = &f_info[g_ptr->feat];
1637 /* Hack -- Bash power based on strength */
1638 /* (Ranges from 3 to 20 to 100 to 200) */
1639 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1641 /* Extract door power */
1642 int temp = f_ptr->power;
1646 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1648 take_turn(p_ptr, 100);
1650 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1652 /* Compare bash power to door power */
1653 temp = (bash - (temp * 10));
1655 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1657 /* Hack -- always have a chance */
1658 if (temp < 1) temp = 1;
1660 /* Hack -- attempt to bash down the door */
1661 if (randint0(100) < temp)
1663 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1665 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1667 /* Break down the door */
1668 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1670 cave_alter_feat(y, x, FF_BASH);
1676 cave_alter_feat(y, x, FF_OPEN);
1679 /* Hack -- Fall through the door */
1680 move_player(dir, FALSE, FALSE);
1683 /* Saving throw against stun */
1684 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1687 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1689 /* Allow repeated bashing */
1693 /* High dexterity yields coolness */
1696 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1698 /* Hack -- Lose balance ala paralysis */
1699 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1706 * @brief 「打ち破る」動作コマンドのメインルーチン /
1707 * Bash open a door, success based on character strength
1711 * For a closed door, pval is positive if locked; negative if stuck.
1713 * For an open door, pval is positive for a broken door.
1715 * A closed door can be opened - harder if locked. Any door might be
1716 * bashed open (and thereby broken). Bashing a door is (potentially)
1717 * faster! You move into the door way. To open a stuck door, it must
1718 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1720 * Creatures can also open or bash doors, see elsewhere.
1723 void do_cmd_bash(void)
1729 if (p_ptr->wild_mode) return;
1731 if (p_ptr->special_defense & KATA_MUSOU)
1733 set_action(ACTION_NONE);
1736 /* Allow repeated command */
1739 /* Set repeat count */
1740 command_rep = command_arg - 1;
1741 p_ptr->redraw |= (PR_STATE);
1743 /* Cancel the arg */
1747 /* Get a "repeated" direction */
1748 if (get_rep_dir(&dir,FALSE))
1753 y = p_ptr->y + ddy[dir];
1754 x = p_ptr->x + ddx[dir];
1756 g_ptr = &grid_array[y][x];
1758 /* Feature code (applying "mimic" field) */
1759 feat = get_feat_mimic(g_ptr);
1761 /* Nothing useful */
1762 if (!have_flag(f_info[feat].flags, FF_BASH))
1764 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1767 /* Monster in the way */
1768 else if (g_ptr->m_idx)
1770 take_turn(p_ptr, 100);
1772 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1778 /* Bash a closed door */
1782 more = do_cmd_bash_aux(y, x, dir);
1786 /* Unless valid action taken, cancel bash */
1787 if (!more) disturb(FALSE, FALSE);
1792 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1796 * Manipulate an adjacent grid in some way
1798 * Attack monsters, tunnel through walls, disarm traps, open doors.
1800 * Consider confusion
1802 * This command must always take a turn, to prevent free detection
1803 * of invisible monsters.
1806 void do_cmd_alter(void)
1813 if (p_ptr->special_defense & KATA_MUSOU)
1815 set_action(ACTION_NONE);
1818 /* Allow repeated command */
1821 /* Set repeat count */
1822 command_rep = command_arg - 1;
1823 p_ptr->redraw |= (PR_STATE);
1825 /* Cancel the arg */
1829 /* Get a direction */
1830 if (get_rep_dir(&dir,TRUE))
1833 feature_type *f_ptr;
1835 y = p_ptr->y + ddy[dir];
1836 x = p_ptr->x + ddx[dir];
1838 g_ptr = &grid_array[y][x];
1840 /* Feature code (applying "mimic" field) */
1841 feat = get_feat_mimic(g_ptr);
1842 f_ptr = &f_info[feat];
1844 take_turn(p_ptr, 100);
1852 else if (have_flag(f_ptr->flags, FF_OPEN))
1854 more = do_cmd_open_aux(y, x);
1857 /* Bash jammed doors */
1858 else if (have_flag(f_ptr->flags, FF_BASH))
1860 more = do_cmd_bash_aux(y, x, dir);
1863 /* Tunnel through walls */
1864 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1866 more = do_cmd_tunnel_aux(y, x);
1869 /* Close open doors */
1870 else if (have_flag(f_ptr->flags, FF_CLOSE))
1872 more = do_cmd_close_aux(y, x);
1876 else if (have_flag(f_ptr->flags, FF_DISARM))
1878 more = do_cmd_disarm_aux(y, x, dir);
1883 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1887 /* Cancel repetition unless we can continue */
1888 if (!more) disturb(FALSE, FALSE);
1894 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1895 * Find the index of some "spikes", if possible.
1896 * @param ip くさびとして打てるオブジェクトのID
1897 * @return オブジェクトがある場合TRUEを返す
1900 * Let user choose a pile of spikes, perhaps?
1903 static bool get_spike(INVENTORY_IDX *ip)
1907 /* Check every item in the pack */
1908 for (i = 0; i < INVEN_PACK; i++)
1910 object_type *o_ptr = &inventory[i];
1912 /* Skip non-objects */
1913 if (!o_ptr->k_idx) continue;
1915 /* Check the "tval" code */
1916 if (o_ptr->tval == TV_SPIKE)
1918 /* Save the spike index */
1931 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1932 * Jam a closed door with a spike
1936 * This command may NOT be repeated
1939 void do_cmd_spike(void)
1943 if (p_ptr->wild_mode) return;
1945 if (p_ptr->special_defense & KATA_MUSOU)
1947 set_action(ACTION_NONE);
1950 /* Get a "repeated" direction */
1951 if (get_rep_dir(&dir, FALSE))
1958 y = p_ptr->y + ddy[dir];
1959 x = p_ptr->x + ddx[dir];
1960 g_ptr = &grid_array[y][x];
1962 /* Feature code (applying "mimic" field) */
1963 feat = get_feat_mimic(g_ptr);
1965 /* Require closed door */
1966 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1968 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1972 else if (!get_spike(&item))
1974 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1977 /* Is a monster in the way? */
1978 else if (g_ptr->m_idx)
1980 take_turn(p_ptr, 100);
1982 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1991 take_turn(p_ptr, 100);
1993 /* Successful jamming */
1994 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1995 cave_alter_feat(y, x, FF_SPIKE);
1997 /* Use up, and describe, a single spike, from the bottom */
1998 inven_item_increase(item, -1);
1999 inven_item_describe(item);
2000 inven_item_optimize(item);
2008 * @brief 「歩く」動作コマンドのメインルーチン /
2009 * Support code for the "Walk" and "Jump" commands
2010 * @param pickup アイテムの自動拾いを行うならTRUE
2013 void do_cmd_walk(bool pickup)
2020 /* Allow repeated command */
2023 /* Set repeat count */
2024 command_rep = command_arg - 1;
2025 p_ptr->redraw |= (PR_STATE);
2027 /* Cancel the arg */
2031 /* Get a "repeated" direction */
2032 if (get_rep_dir(&dir, FALSE))
2034 take_turn(p_ptr, 100);
2036 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2038 set_action(ACTION_NONE);
2041 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2042 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2043 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2045 /* Actually move the character */
2046 move_player(dir, pickup, FALSE);
2048 /* Allow more walking */
2052 /* Hack again -- Is there a special encounter ??? */
2053 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2055 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2058 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2060 /* Inform the player of his horrible fate :=) */
2061 msg_print(_("襲撃だ!", "You are ambushed !"));
2063 /* Go into large wilderness view */
2064 p_ptr->oldpy = randint1(MAX_HGT-2);
2065 p_ptr->oldpx = randint1(MAX_WID-2);
2068 /* Give first move to monsters */
2069 take_turn(p_ptr, 100);
2071 /* HACk -- set the encouter flag for the wilderness generation */
2072 generate_encounter = TRUE;
2076 /* Cancel repeat unless we may continue */
2077 if (!more) disturb(FALSE, FALSE);
2082 * @brief 「走る」動作コマンドのメインルーチン /
2086 void do_cmd_run(void)
2089 if (cmd_limit_confused(p_ptr)) return;
2091 if (p_ptr->special_defense & KATA_MUSOU)
2093 set_action(ACTION_NONE);
2096 /* Get a "repeated" direction */
2097 if (get_rep_dir(&dir,FALSE))
2099 /* Hack -- Set the run counter */
2100 running = (command_arg ? command_arg : 1000);
2109 * @brief 「留まる」動作コマンドのメインルーチン /
2110 * Stay still. Search. Enter stores.
2111 * Pick up treasure if "pickup" is true.
2112 * @param pickup アイテムの自動拾いを行うならTRUE
2115 void do_cmd_stay(bool pickup)
2117 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2119 /* Allow repeated command */
2122 /* Set repeat count */
2123 command_rep = command_arg - 1;
2124 p_ptr->redraw |= (PR_STATE);
2126 /* Cancel the arg */
2130 take_turn(p_ptr, 100);
2132 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2133 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2138 * @brief 「休む」動作コマンドのメインルーチン /
2139 * Resting allows a player to safely restore his hp -RAK-
2142 void do_cmd_rest(void)
2145 set_action(ACTION_NONE);
2147 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2149 stop_singing(p_ptr);
2153 if (hex_spelling_any()) stop_hex_spell_all();
2155 /* Prompt for time if needed */
2156 if (command_arg <= 0)
2158 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2159 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2165 strcpy(out_val, "&");
2167 /* Ask for duration */
2168 if (!get_string(p, out_val, 4)) return;
2170 /* Rest until done */
2171 if (out_val[0] == '&')
2173 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2177 else if (out_val[0] == '*')
2179 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2185 command_arg = (COMMAND_ARG)atoi(out_val);
2186 if (command_arg <= 0) return;
2192 if (command_arg > 9999) command_arg = 9999;
2194 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2196 /* Take a turn (?) */
2197 take_turn(p_ptr, 100);
2199 /* The sin of sloth */
2200 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2202 /* Why are you sleeping when there's no need? WAKE UP!*/
2203 if ((p_ptr->chp == p_ptr->mhp) &&
2204 (p_ptr->csp == p_ptr->msp) &&
2205 !p_ptr->blind && !p_ptr->confused &&
2206 !p_ptr->poisoned && !p_ptr->afraid &&
2207 !p_ptr->stun && !p_ptr->cut &&
2208 !p_ptr->slow && !p_ptr->paralyzed &&
2209 !p_ptr->image && !p_ptr->word_recall &&
2210 !p_ptr->alter_reality)
2211 chg_virtue(V_DILIGENCE, -1);
2213 /* Save the rest code */
2214 resting = command_arg;
2215 p_ptr->action = ACTION_REST;
2216 p_ptr->update |= (PU_BONUS);
2217 update_creature(p_ptr);
2219 p_ptr->redraw |= (PR_STATE);
2228 * @brief 射撃処理のメインルーチン
2231 void do_cmd_fire(void)
2234 object_type *j_ptr, *ammo_ptr;
2237 if(p_ptr->wild_mode) return;
2239 is_fired = FALSE; /* not fired yet */
2241 /* Get the "bow" (if any) */
2242 j_ptr = &inventory[INVEN_BOW];
2244 /* Require a launcher */
2247 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2252 if (j_ptr->sval == SV_CRIMSON)
2254 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2259 if (j_ptr->sval == SV_HARP)
2261 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2267 if (p_ptr->special_defense & KATA_MUSOU)
2269 set_action(ACTION_NONE);
2272 /* Require proper missile */
2273 item_tester_tval = p_ptr->tval_ammo;
2275 q = _("どれを撃ちますか? ", "Fire which item? ");
2276 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2279 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2287 exe_fire(item, j_ptr);
2289 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2291 /* Sniper actions after some shootings */
2292 if (snipe_type == SP_AWAY)
2294 teleport_player(10 + (p_ptr->concent * 2), 0L);
2296 if (snipe_type == SP_FINAL)
2298 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2299 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2300 (void)set_stun(p_ptr->stun + randint1(25));
2306 * @brief 投射処理メインルーチン /
2307 * Throw an object from the pack or floor.
2309 * @param boomerang ブーメラン処理ならばTRUE
2310 * @param shuriken 忍者の手裏剣処理ならばTRUE
2311 * @return ターンを消費した場合TRUEを返す
2314 * Note: "unseen" monsters are very hard to hit.
2316 * Should throwing a weapon do full damage? Should it allow the magic
2317 * to hit bonus of the weapon to have an effect? Should it ever cause
2318 * the item to be destroyed? Should it do any damage at all?
2321 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2326 POSITION y, x, ty, tx, prev_y, prev_x;
2327 POSITION ny[19], nx[19];
2328 int chance, tdam, tdis;
2329 int mul, div, dd, ds;
2330 int cur_dis, visible;
2337 bool hit_body = FALSE;
2338 bool hit_wall = FALSE;
2339 bool equiped_item = FALSE;
2340 bool return_when_thrown = FALSE;
2342 GAME_TEXT o_name[MAX_NLEN];
2344 int msec = delay_factor * delay_factor * delay_factor;
2346 BIT_FLAGS flgs[TR_FLAG_SIZE];
2348 bool come_back = FALSE;
2349 bool do_drop = TRUE;
2351 if (p_ptr->wild_mode) return FALSE;
2353 if (p_ptr->special_defense & KATA_MUSOU)
2355 set_action(ACTION_NONE);
2361 o_ptr = &inventory[item];
2365 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2367 item_tester_hook = item_tester_hook_boomerang;
2368 q = _("どの武器を投げますか? ", "Throw which item? ");
2369 s = _("投げる武器がない。", "You have nothing to throw.");
2370 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2377 else if (has_melee_weapon(INVEN_LARM))
2380 o_ptr = &inventory[item];
2385 o_ptr = &inventory[item];
2390 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2391 s = _("投げるアイテムがない。", "You have nothing to throw.");
2392 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2400 /* Item is cursed */
2401 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2403 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2407 if (p_ptr->inside_arena && !boomerang)
2409 if (o_ptr->tval != TV_SPIKE)
2411 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2420 /* Obtain a local object */
2421 object_copy(q_ptr, o_ptr);
2423 /* Extract the thrown object's flags. */
2424 object_flags(q_ptr, flgs);
2425 torch_flags(q_ptr, flgs);
2427 /* Distribute the charges of rods/wands between the stacks */
2428 distribute_charges(o_ptr, q_ptr, 1);
2433 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2435 if (p_ptr->mighty_throw) mult += 3;
2437 /* Extract a "distance multiplier" */
2438 /* Changed for 'launcher' mutation */
2439 mul = 10 + 2 * (mult - 1);
2441 /* Enforce a minimum "weight" of one pound */
2442 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2443 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2445 /* Hack -- Distance -- Reward strength, penalize weight */
2446 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2448 /* Max distance of 10-18 */
2449 if (tdis > mul) tdis = mul;
2453 ty = randint0(101) - 50 + p_ptr->y;
2454 tx = randint0(101) - 50 + p_ptr->x;
2458 project_length = tdis + 1;
2460 /* Get a direction (or cancel) */
2461 if (!get_aim_dir(&dir)) return FALSE;
2463 /* Predict the "target" location */
2464 tx = p_ptr->x + 99 * ddx[dir];
2465 ty = p_ptr->y + 99 * ddy[dir];
2467 /* Check for "target request" */
2468 if ((dir == 5) && target_okay())
2474 project_length = 0; /* reset to default */
2477 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2478 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2479 return_when_thrown = TRUE;
2481 /* Reduce and describe inventory */
2484 inven_item_increase(item, -1);
2485 if (!return_when_thrown)
2486 inven_item_describe(item);
2487 inven_item_optimize(item);
2490 /* Reduce and describe floor item */
2493 floor_item_increase(0 - item, -1);
2494 floor_item_optimize(0 - item);
2496 if (item >= INVEN_RARM)
2498 equiped_item = TRUE;
2499 p_ptr->redraw |= (PR_EQUIPPY);
2502 take_turn(p_ptr, 100);
2504 /* Rogue and Ninja gets bonus */
2505 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2506 p_ptr->energy_use -= p_ptr->lev;
2508 /* Start at the player */
2514 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2515 else shuriken = FALSE;
2517 /* Chance of hitting */
2518 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2519 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2520 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2522 if (shuriken) chance *= 2;
2527 /* Travel until stopped */
2528 for (cur_dis = 0; cur_dis <= tdis; )
2530 /* Hack -- Stop at the target */
2531 if ((y == ty) && (x == tx)) break;
2533 /* Calculate the new location (see "project()") */
2536 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2538 /* Stopped by walls/doors */
2539 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2542 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2545 /* The player can see the (on screen) missile */
2546 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2548 SYMBOL_CODE c = object_char(q_ptr);
2549 TERM_COLOR a = object_attr(q_ptr);
2551 /* Draw, Hilite, Fresh, Pause, Erase */
2552 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2553 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2555 Term_xtra(TERM_XTRA_DELAY, msec);
2556 lite_spot(ny[cur_dis], nx[cur_dis]);
2560 /* The player cannot see the missile */
2563 /* Pause anyway, for consistancy */
2564 Term_xtra(TERM_XTRA_DELAY, msec);
2570 /* Save the new location */
2574 /* Advance the distance */
2577 /* Monster here, Try to hit it */
2578 if (grid_array[y][x].m_idx)
2580 grid_type *g_ptr = &grid_array[y][x];
2581 monster_type *m_ptr = &m_list[g_ptr->m_idx];
2583 /* Check the visibility */
2584 visible = m_ptr->ml;
2586 /* Note the collision */
2589 /* Did we hit it (penalize range) */
2590 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2594 /* Handle unseen monster */
2597 /* Invisible monster */
2598 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2601 /* Handle visible monster */
2604 GAME_TEXT m_name[MAX_NLEN];
2605 monster_desc(m_name, m_ptr, 0);
2606 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2610 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2611 health_track(g_ptr->m_idx);
2615 /* Hack -- Base damage from thrown object */
2618 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2619 tdam = damroll(dd, ds);
2620 /* Apply special damage */
2621 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2622 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2623 if (q_ptr->to_d > 0)
2624 tdam += q_ptr->to_d;
2626 tdam += -q_ptr->to_d;
2630 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2631 tdam += p_ptr->to_d_m;
2633 else if (have_flag(flgs, TR_THROW))
2636 tdam += p_ptr->to_d_m;
2644 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2647 /* No negative damage */
2648 if (tdam < 0) tdam = 0;
2650 /* Modify the damage */
2651 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2653 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2654 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2656 /* Hit the monster, check for death */
2657 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2665 message_pain(g_ptr->m_idx, tdam);
2667 /* Anger the monster */
2668 if ((tdam > 0) && !object_is_potion(q_ptr))
2669 anger_monster(m_ptr);
2671 if (fear && m_ptr->ml)
2674 GAME_TEXT m_name[MAX_NLEN];
2675 monster_desc(m_name, m_ptr, 0);
2676 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2686 /* decrease toach's fuel */
2687 if (hit_body) torch_lost_fuel(q_ptr);
2689 /* Chance of breakage (during attacks) */
2690 j = (hit_body ? breakage_chance(q_ptr) : 0);
2692 /* Figurines transform */
2693 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2697 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2698 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2699 else if (object_is_cursed(q_ptr))
2700 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2705 /* Potions smash open */
2706 if (object_is_potion(q_ptr))
2708 if (hit_body || hit_wall || (randint1(100) < j))
2710 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2712 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2714 monster_type *m_ptr = &m_list[grid_array[y][x].m_idx];
2716 /* ToDo (Robert): fix the invulnerability */
2717 if (grid_array[y][x].m_idx &&
2718 is_friendly(&m_list[grid_array[y][x].m_idx]) &&
2719 !MON_INVULNER(m_ptr))
2721 GAME_TEXT m_name[MAX_NLEN];
2722 monster_desc(m_name, &m_list[grid_array[y][x].m_idx], 0);
2723 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2724 set_hostile(&m_list[grid_array[y][x].m_idx]);
2735 if (return_when_thrown)
2737 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2738 char o2_name[MAX_NLEN];
2739 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2742 if (boomerang) back_chance += 4+randint1(5);
2743 if (super_boomerang) back_chance += 100;
2744 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2746 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2748 for (i = cur_dis - 1; i > 0; i--)
2750 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2752 char c = object_char(q_ptr);
2753 byte a = object_attr(q_ptr);
2755 /* Draw, Hilite, Fresh, Pause, Erase */
2756 print_rel(c, a, ny[i], nx[i]);
2757 move_cursor_relative(ny[i], nx[i]);
2759 Term_xtra(TERM_XTRA_DELAY, msec);
2760 lite_spot(ny[i], nx[i]);
2765 /* Pause anyway, for consistancy */
2766 Term_xtra(TERM_XTRA_DELAY, msec);
2769 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2771 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2778 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2782 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2790 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2796 if (item == INVEN_RARM || item == INVEN_LARM)
2798 /* Access the wield slot */
2799 o_ptr = &inventory[item];
2801 /* Wear the new stuff */
2802 object_copy(o_ptr, q_ptr);
2804 p_ptr->total_weight += q_ptr->weight;
2806 /* Increment the equip counter by hand */
2809 /* Recalculate torch */
2810 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2811 p_ptr->window |= (PW_EQUIP);
2819 else if (equiped_item)
2827 if (cave_have_flag_bold(y, x, FF_PROJECT))
2829 (void)drop_near(q_ptr, j, y, x);
2833 (void)drop_near(q_ptr, j, prev_y, prev_x);