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"
33 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
34 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
35 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
37 static bool confirm_leave_level(bool down_stair)
39 quest_type *q_ptr = &quest[p_ptr->inside_quest];
41 /* Confirm leaving from once only quest */
42 if (confirm_quest && p_ptr->inside_quest &&
43 (q_ptr->type == QUEST_TYPE_RANDOM ||
44 (q_ptr->flags & QUEST_FLAG_ONCE &&
45 q_ptr->status != QUEST_STATUS_COMPLETED) ||
46 (q_ptr->flags & QUEST_FLAG_TOWER &&
47 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
48 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
50 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
51 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
61 * @brief 魔法系コマンドが制限されているかを返す。
62 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
64 bool cmd_limit_cast(player_type *creature_ptr)
66 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
68 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
72 else if (creature_ptr->anti_magic)
74 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
77 else if (creature_ptr->shero)
79 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
86 bool cmd_limit_confused(player_type *creature_ptr)
88 if (creature_ptr->confused)
90 msg_print(_("混乱していてできない!", "You are too confused!"));
96 bool cmd_limit_arena(player_type *creature_ptr)
98 if (creature_ptr->inside_arena)
100 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
107 bool cmd_limit_blind(player_type *creature_ptr)
109 if (creature_ptr->blind)
111 msg_print(_("目が見えない。", "You can't see anything."));
116 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
122 bool cmd_limit_time_walk(player_type *creature_ptr)
124 if (creature_ptr->timewalk)
126 if (flush_failure) flush();
127 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
135 * @brief 階段を使って階層を昇る処理 / Go up one level
138 void do_cmd_go_up(void)
143 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
144 feature_type *f_ptr = &f_info[g_ptr->feat];
148 if (p_ptr->special_defense & KATA_MUSOU)
150 set_action(ACTION_NONE);
154 if (!have_flag(f_ptr->flags, FF_LESS))
156 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
160 /* Quest up stairs */
161 if (have_flag(f_ptr->flags, FF_QUEST))
163 /* Cancel the command */
164 if (!confirm_leave_level(FALSE)) return;
168 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
169 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
171 msg_print(_("上の階に登った。", "You enter the up staircase."));
175 p_ptr->inside_quest = g_ptr->special;
177 /* Activate the quest */
178 if (!quest[p_ptr->inside_quest].status)
180 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
182 init_flags = INIT_ASSIGN;
183 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
185 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
188 /* Leaving a quest */
189 if (!p_ptr->inside_quest)
191 current_floor_ptr->dun_level = 0;
195 p_ptr->leaving = TRUE;
200 take_turn(p_ptr, 100);
202 /* End the command */
206 if (!current_floor_ptr->dun_level)
212 go_up = confirm_leave_level(FALSE);
215 /* Cancel the command */
218 take_turn(p_ptr, 100);
220 if (autosave_l) do_cmd_save_game(TRUE);
222 /* For a random quest */
223 if (p_ptr->inside_quest &&
224 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
228 p_ptr->inside_quest = 0;
231 /* For a fixed quest */
232 if (p_ptr->inside_quest &&
233 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
237 p_ptr->inside_quest = g_ptr->special;
238 current_floor_ptr->dun_level = 0;
242 /* For normal dungeon and random quest */
246 if (have_flag(f_ptr->flags, FF_SHAFT))
248 /* Create a way back */
249 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
255 /* Create a way back */
256 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
261 /* Get out from current dungeon */
262 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
263 up_num = current_floor_ptr->dun_level;
265 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
268 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
269 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
270 else if (up_num == current_floor_ptr->dun_level)
271 msg_print(_("地上に戻った。", "You go back to the surface."));
273 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
276 p_ptr->leaving = TRUE;
281 * @brief 階段を使って階層を降りる処理 / Go down one level
284 void do_cmd_go_down(void)
287 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
288 feature_type *f_ptr = &f_info[g_ptr->feat];
290 bool fall_trap = FALSE;
293 if (p_ptr->special_defense & KATA_MUSOU)
295 set_action(ACTION_NONE);
299 if (!have_flag(f_ptr->flags, FF_MORE))
301 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
305 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
308 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
313 /* Quest down stairs */
314 else if (have_flag(f_ptr->flags, FF_QUEST))
316 /* Confirm Leaving */
317 if(!confirm_leave_level(TRUE)) return;
319 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
320 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
322 msg_print(_("下の階に降りた。", "You enter the down staircase."));
327 p_ptr->inside_quest = g_ptr->special;
329 /* Activate the quest */
330 if (!quest[p_ptr->inside_quest].status)
332 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
334 init_flags = INIT_ASSIGN;
335 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
337 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
340 /* Leaving a quest */
341 if (!p_ptr->inside_quest)
343 current_floor_ptr->dun_level = 0;
347 p_ptr->leaving = TRUE;
351 take_turn(p_ptr, 100);
356 DUNGEON_IDX target_dungeon = 0;
358 if (!current_floor_ptr->dun_level)
360 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
362 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
364 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
367 if (!max_dlv[target_dungeon])
369 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
370 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
371 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
374 /* Save old player position */
375 p_ptr->oldpx = p_ptr->x;
376 p_ptr->oldpy = p_ptr->y;
377 p_ptr->dungeon_idx = target_dungeon;
380 * Clear all saved floors
381 * and create a first saved floor
383 prepare_change_floor_mode(CFM_FIRST_FLOOR);
386 take_turn(p_ptr, 100);
388 if (autosave_l) do_cmd_save_game(TRUE);
391 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
394 if (!current_floor_ptr->dun_level)
396 /* Enter the dungeon just now */
397 p_ptr->enter_dungeon = TRUE;
398 down_num = d_info[p_ptr->dungeon_idx].mindepth;
403 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
404 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
409 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
416 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
420 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
421 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
423 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
429 p_ptr->leaving = TRUE;
433 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
437 if (have_flag(f_ptr->flags, FF_SHAFT))
439 /* Create a way back */
440 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
444 /* Create a way back */
445 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
453 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
456 void do_cmd_search(void)
458 /* Allow repeated command */
461 /* Set repeat count */
462 command_rep = command_arg - 1;
463 p_ptr->redraw |= (PR_STATE);
468 take_turn(p_ptr, 100);
476 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
477 * @param y 走査対象にしたいマスのY座標
478 * @param x 走査対象にしたいマスのX座標
479 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
480 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
482 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
484 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
485 OBJECT_IDX this_o_idx, next_o_idx = 0;
487 /* Scan all objects in the grid */
488 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
492 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
493 next_o_idx = o_ptr->next_o_idx;
495 /* Skip unknown chests XXX XXX */
496 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
498 /* Check for non empty chest */
499 if ((o_ptr->tval == TV_CHEST) &&
500 (((!trapped) && (o_ptr->pval)) || /* non empty */
501 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
510 * @brief 箱を開けるコマンドのメインルーチン /
511 * Attempt to open the given chest at the given location
512 * @param y 箱の存在するマスのY座標
513 * @param x 箱の存在するマスのX座標
514 * @param o_idx 箱のオブジェクトID
515 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
517 * Assume there is no monster blocking the destination
519 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
524 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
526 take_turn(p_ptr, 100);
528 /* Attempt to unlock it */
531 /* Assume locked, and thus not open */
534 /* Get the "disarm" factor */
535 i = p_ptr->skill_dis;
537 /* Penalize some conditions */
538 if (p_ptr->blind || no_lite()) i = i / 10;
539 if (p_ptr->confused || p_ptr->image) i = i / 10;
541 /* Extract the difficulty */
544 /* Always have a small chance of success */
547 /* Success -- May still have traps */
548 if (randint0(100) < j)
550 msg_print(_("鍵をはずした。", "You have picked the lock."));
555 /* Failure -- Keep trying */
558 /* We may continue repeating */
560 if (flush_failure) flush();
561 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
566 /* Allowed to open */
569 /* Apply chest traps, if any */
570 chest_trap(y, x, o_idx);
572 /* Let the Chest drop items */
573 chest_death(FALSE, y, x, o_idx);
579 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
580 * Attempt to open the given chest at the given location
581 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
582 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
583 * @param test 地形条件を判定するための関数ポインタ
584 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
586 * @details Return the number of features around (or under) the character.
587 * Usually look for doors and floor traps.
589 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
595 /* Count how many matches */
598 /* Check around (and under) the character */
599 for (d = 0; d < 9; d++)
604 /* if not searching under player continue */
605 if ((d == 8) && !under) continue;
607 /* Extract adjacent (legal) location */
608 yy = p_ptr->y + ddy_ddd[d];
609 xx = p_ptr->x + ddx_ddd[d];
611 /* Get the current_floor_ptr->grid_array */
612 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
614 /* Must have knowledge */
615 if (!(g_ptr->info & (CAVE_MARK))) continue;
617 /* Feature code (applying "mimic" field) */
618 feat = get_feat_mimic(g_ptr);
620 /* Not looking for this feature */
621 if (!((*test)(feat))) continue;
626 /* Remember the location. Only useful if only one match */
637 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
638 * Return the number of chests around (or under) the character.
639 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
640 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
641 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
644 * If requested, count only trapped chests.
646 static int count_chests(POSITION *y, POSITION *x, bool trapped)
653 /* Count how many matches */
656 /* Check around (and under) the character */
657 for (d = 0; d < 9; d++)
659 /* Extract adjacent (legal) location */
660 POSITION yy = p_ptr->y + ddy_ddd[d];
661 POSITION xx = p_ptr->x + ddx_ddd[d];
663 /* No (visible) chest is there */
664 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
666 /* Grab the object */
667 o_ptr = ¤t_floor_ptr->o_list[o_idx];
670 if (o_ptr->pval == 0) continue;
672 /* No (known) traps here */
673 if (trapped && (!object_is_known(o_ptr) ||
674 !chest_traps[o_ptr->pval])) continue;
679 /* Remember the location. Only useful if only one match */
691 * @brief 「開ける」動作コマンドのサブルーチン /
692 * Perform the basic "open" command on doors
693 * @param y 対象を行うマスのY座標
694 * @param x 対象を行うマスのX座標
695 * @return 実際に処理が行われた場合TRUEを返す。
697 * Assume destination is a closed/locked/jammed door
698 * Assume there is no monster blocking the destination
699 * Returns TRUE if repeated commands may continue
701 static bool do_cmd_open_aux(POSITION y, POSITION x)
705 /* Get requested grid */
706 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
707 feature_type *f_ptr = &f_info[g_ptr->feat];
710 take_turn(p_ptr, 100);
712 /* Seeing true feature code (ignore mimic) */
715 if (!have_flag(f_ptr->flags, FF_OPEN))
718 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
722 else if (f_ptr->power)
725 i = p_ptr->skill_dis;
727 /* Penalize some conditions */
728 if (p_ptr->blind || no_lite()) i = i / 10;
729 if (p_ptr->confused || p_ptr->image) i = i / 10;
731 /* Extract the lock power */
734 /* Extract the difficulty */
737 /* Always have a small chance of success */
741 if (randint0(100) < j)
743 msg_print(_("鍵をはずした。", "You have picked the lock."));
746 cave_alter_feat(y, x, FF_OPEN);
748 sound(SOUND_OPENDOOR);
758 if (flush_failure) flush();
760 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
762 /* We may keep trying */
771 cave_alter_feat(y, x, FF_OPEN);
773 sound(SOUND_OPENDOOR);
779 * @brief 「開ける」コマンドのメインルーチン /
780 * Open a closed/locked/jammed door or a closed/locked chest.
783 * Unlocking a locked door/chest is worth one experience point.
785 void do_cmd_open(void)
793 if (p_ptr->wild_mode) return;
795 if (p_ptr->special_defense & KATA_MUSOU)
797 set_action(ACTION_NONE);
800 /* Option: Pick a direction */
803 int num_doors, num_chests;
805 /* Count closed doors (locked or jammed) */
806 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
808 /* Count chests (locked) */
809 num_chests = count_chests(&y, &x, FALSE);
811 /* See if only one target */
812 if (num_doors || num_chests)
814 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
816 if (!too_many) command_dir = coords_to_dir(y, x);
820 /* Allow repeated command */
823 /* Set repeat count */
824 command_rep = command_arg - 1;
825 p_ptr->redraw |= (PR_STATE);
831 /* Get a "repeated" direction */
832 if (get_rep_dir(&dir, TRUE))
837 /* Get requested location */
838 y = p_ptr->y + ddy[dir];
839 x = p_ptr->x + ddx[dir];
841 /* Get requested grid */
842 g_ptr = ¤t_floor_ptr->grid_array[y][x];
844 /* Feature code (applying "mimic" field) */
845 feat = get_feat_mimic(g_ptr);
847 /* Check for chest */
848 o_idx = chest_check(y, x, FALSE);
851 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
853 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
856 /* Monster in the way */
857 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
859 take_turn(p_ptr, 100);
860 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
868 more = do_cmd_open_chest(y, x, o_idx);
875 more = do_cmd_open_aux(y, x);
879 /* Cancel repeat unless we may continue */
880 if (!more) disturb(FALSE, FALSE);
886 * @brief 「閉じる」動作コマンドのサブルーチン /
887 * Perform the basic "close" command
888 * @param y 対象を行うマスのY座標
889 * @param x 対象を行うマスのX座標
890 * @return 実際に処理が行われた場合TRUEを返す。
892 * Assume destination is an open/broken door
893 * Assume there is no monster blocking the destination
894 * Returns TRUE if repeated commands may continue
896 static bool do_cmd_close_aux(POSITION y, POSITION x)
898 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
899 FEAT_IDX old_feat = g_ptr->feat;
902 take_turn(p_ptr, 100);
904 /* Seeing true feature code (ignore mimic) */
907 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
909 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
911 /* Hack -- object in the way */
912 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
913 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
915 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
920 cave_alter_feat(y, x, FF_CLOSE);
923 if (old_feat == g_ptr->feat)
925 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
929 sound(SOUND_SHUTDOOR);
938 * @brief 「閉じる」コマンドのメインルーチン /
939 * Close an open door.
942 * Unlocking a locked door/chest is worth one experience point.
944 void do_cmd_close(void)
951 if (p_ptr->wild_mode) return;
953 if (p_ptr->special_defense & KATA_MUSOU)
955 set_action(ACTION_NONE);
958 /* Option: Pick a direction */
961 /* Count open doors */
962 if (count_dt(&y, &x, is_open, FALSE) == 1)
964 command_dir = coords_to_dir(y, x);
968 /* Allow repeated command */
971 /* Set repeat count */
972 command_rep = command_arg - 1;
973 p_ptr->redraw |= (PR_STATE);
979 /* Get a "repeated" direction */
980 if (get_rep_dir(&dir, FALSE))
985 y = p_ptr->y + ddy[dir];
986 x = p_ptr->x + ddx[dir];
987 g_ptr = ¤t_floor_ptr->grid_array[y][x];
989 /* Feature code (applying "mimic" field) */
990 feat = get_feat_mimic(g_ptr);
992 /* Require open/broken door */
993 if (!have_flag(f_info[feat].flags, FF_CLOSE))
995 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
998 /* Monster in the way */
999 else if (g_ptr->m_idx)
1001 take_turn(p_ptr, 100);
1003 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1009 /* Close the door */
1012 /* Close the door */
1013 more = do_cmd_close_aux(y, x);
1017 /* Cancel repeat unless we may continue */
1018 if (!more) disturb(FALSE, FALSE);
1023 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1024 * Determine if a given grid may be "tunneled"
1025 * @param y 対象を行うマスのY座標
1026 * @param x 対象を行うマスのX座標
1029 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1031 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1033 /* Must have knowledge */
1034 if (!(g_ptr->info & CAVE_MARK))
1036 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1041 /* Must be a wall/door/etc */
1042 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1044 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1054 * @brief 「掘る」動作コマンドのサブルーチン /
1055 * Perform the basic "tunnel" command
1056 * @param y 対象を行うマスのY座標
1057 * @param x 対象を行うマスのX座標
1058 * @return 実際に処理が行われた場合TRUEを返す。
1060 * Assumes that no monster is blocking the destination
1061 * Do not use twall anymore
1062 * Returns TRUE if repeated commands may continue
1064 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1067 feature_type *f_ptr, *mimic_f_ptr;
1072 /* Verify legality */
1073 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1075 take_turn(p_ptr, 100);
1077 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1078 f_ptr = &f_info[g_ptr->feat];
1079 power = f_ptr->power;
1081 /* Feature code (applying "mimic" field) */
1082 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1084 name = f_name + mimic_f_ptr->name;
1088 if (have_flag(f_ptr->flags, FF_PERMANENT))
1091 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1093 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1096 /* Map border (mimiccing Permanent wall) */
1099 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1104 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1107 if (p_ptr->skill_dig > randint0(20 * power))
1109 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1111 /* Remove the feature */
1112 cave_alter_feat(y, x, FF_TUNNEL);
1114 /* Update some things */
1115 p_ptr->update |= (PU_FLOW);
1119 /* Message, keep digging */
1120 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1128 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1131 if (p_ptr->skill_dig > power + randint0(40 * power))
1133 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1136 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1137 p_ptr->update |= (PU_FLOW);
1140 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1142 /* Remove the feature */
1143 cave_alter_feat(y, x, FF_TUNNEL);
1145 chg_virtue(V_DILIGENCE, 1);
1146 chg_virtue(V_NATURE, -1);
1154 /* We may continue chopping */
1155 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1156 /* Occasional Search XXX XXX */
1157 if (randint0(100) < 25) search();
1161 /* We may continue tunelling */
1162 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1169 if (is_hidden_door(g_ptr))
1171 /* Occasional Search XXX XXX */
1172 if (randint0(100) < 25) search();
1179 * @brief 「掘る」動作コマンドのメインルーチン /
1180 * Tunnels through "walls" (including rubble and closed doors)
1184 * Note that you must tunnel in order to hit invisible monsters
1185 * in walls, though moving into walls still takes a turn anyway.
1187 * Digging is very difficult without a "digger" weapon, but can be
1188 * accomplished by strong players using heavy weapons.
1191 void do_cmd_tunnel(void)
1200 if (p_ptr->special_defense & KATA_MUSOU)
1202 set_action(ACTION_NONE);
1205 /* Allow repeated command */
1208 /* Set repeat count */
1209 command_rep = command_arg - 1;
1210 p_ptr->redraw |= (PR_STATE);
1212 /* Cancel the arg */
1216 /* Get a direction to tunnel, or Abort */
1217 if (get_rep_dir(&dir,FALSE))
1220 y = p_ptr->y + ddy[dir];
1221 x = p_ptr->x + ddx[dir];
1223 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1225 /* Feature code (applying "mimic" field) */
1226 feat = get_feat_mimic(g_ptr);
1228 /* No tunnelling through doors */
1229 if (have_flag(f_info[feat].flags, FF_DOOR))
1231 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1234 /* No tunnelling through most features */
1235 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1237 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1240 /* A monster is in the way */
1241 else if (g_ptr->m_idx)
1243 take_turn(p_ptr, 100);
1245 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1254 /* Tunnel through walls */
1255 more = do_cmd_tunnel_aux(y, x);
1259 /* Cancel repetition unless we can continue */
1260 if (!more) disturb(FALSE, FALSE);
1264 * @brief 移動処理による簡易な「開く」処理 /
1266 * @return 開く処理が実際に試みられた場合TRUEを返す
1269 * If there is a jammed/closed/locked door at the given location,
1270 * then attempt to unlock/open it. Return TRUE if an attempt was
1271 * made (successful or not), otherwise return FALSE.
1273 * The code here should be nearly identical to that in
1274 * do_cmd_open_test() and do_cmd_open_aux().
1277 bool easy_open_door(POSITION y, POSITION x)
1281 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1282 feature_type *f_ptr = &f_info[g_ptr->feat];
1284 /* Must be a closed door */
1285 if (!is_closed_door(g_ptr->feat))
1291 if (!have_flag(f_ptr->flags, FF_OPEN))
1294 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1299 else if (f_ptr->power)
1302 i = p_ptr->skill_dis;
1304 /* Penalize some conditions */
1305 if (p_ptr->blind || no_lite()) i = i / 10;
1306 if (p_ptr->confused || p_ptr->image) i = i / 10;
1308 /* Extract the lock power */
1311 /* Extract the difficulty */
1314 /* Always have a small chance of success */
1318 if (randint0(100) < j)
1320 msg_print(_("鍵をはずした。", "You have picked the lock."));
1323 cave_alter_feat(y, x, FF_OPEN);
1325 sound(SOUND_OPENDOOR);
1335 if (flush_failure) flush();
1337 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1346 cave_alter_feat(y, x, FF_OPEN);
1348 sound(SOUND_OPENDOOR);
1354 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1355 * Perform the basic "disarm" command
1356 * @param y 解除を行うマスのY座標
1357 * @param x 解除を行うマスのX座標
1358 * @param o_idx 箱のオブジェクトID
1359 * @return ターンを消費する処理が行われた場合TRUEを返す
1362 * Assume destination is a visible trap
1363 * Assume there is no monster blocking the destination
1364 * Returns TRUE if repeated commands may continue
1367 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1371 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1373 take_turn(p_ptr, 100);
1375 /* Get the "disarm" factor */
1376 i = p_ptr->skill_dis;
1378 /* Penalize some conditions */
1379 if (p_ptr->blind || no_lite()) i = i / 10;
1380 if (p_ptr->confused || p_ptr->image) i = i / 10;
1382 /* Extract the difficulty */
1383 j = i - o_ptr->pval;
1385 /* Always have a small chance of success */
1388 /* Must find the trap first. */
1389 if (!object_is_known(o_ptr))
1391 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1395 /* Already disarmed/unlocked */
1396 else if (o_ptr->pval <= 0)
1398 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1401 /* No traps to find. */
1402 else if (!chest_traps[o_ptr->pval])
1404 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1407 /* Success (get a lot of experience) */
1408 else if (randint0(100) < j)
1410 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1411 gain_exp(o_ptr->pval);
1412 o_ptr->pval = (0 - o_ptr->pval);
1415 /* Failure -- Keep trying */
1416 else if ((i > 5) && (randint1(i) > 5))
1418 /* We may keep trying */
1420 if (flush_failure) flush();
1421 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1424 /* Failure -- Set off the trap */
1427 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1429 chest_trap(y, x, o_idx);
1436 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1437 * Perform the basic "disarm" command
1438 * @param y 解除を行うマスのY座標
1439 * @param x 解除を行うマスのX座標
1440 * @param dir プレイヤーからみた方向ID
1441 * @return ターンを消費する処理が行われた場合TRUEを返す
1444 * Assume destination is a visible trap
1445 * Assume there is no monster blocking the destination
1446 * Returns TRUE if repeated commands may continue
1450 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1452 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1455 feature_type *f_ptr = &f_info[g_ptr->feat];
1457 /* Access trap name */
1458 concptr name = (f_name + f_ptr->name);
1460 /* Extract trap "power" */
1461 int power = f_ptr->power;
1464 /* Get the "disarm" factor */
1465 int i = p_ptr->skill_dis;
1468 take_turn(p_ptr, 100);
1470 /* Penalize some conditions */
1471 if (p_ptr->blind || no_lite()) i = i / 10;
1472 if (p_ptr->confused || p_ptr->image) i = i / 10;
1474 /* Extract the difficulty */
1477 /* Always have a small chance of success */
1481 if (randint0(100) < j)
1483 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1488 /* Remove the trap */
1489 cave_alter_feat(y, x, FF_DISARM);
1491 /* Move the player onto the trap */
1492 move_player(dir, easy_disarm, FALSE);
1495 /* Failure -- Keep trying */
1496 else if ((i > 5) && (randint1(i) > 5))
1499 if (flush_failure) flush();
1501 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1503 /* We may keep trying */
1507 /* Failure -- Set off the trap */
1510 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1511 /* Move the player onto the trap */
1512 move_player(dir, easy_disarm, FALSE);
1519 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1520 * Disarms a trap, or chest
1523 void do_cmd_disarm(void)
1531 if (p_ptr->wild_mode) return;
1533 if (p_ptr->special_defense & KATA_MUSOU)
1535 set_action(ACTION_NONE);
1538 /* Option: Pick a direction */
1541 int num_traps, num_chests;
1543 /* Count visible traps */
1544 num_traps = count_dt(&y, &x, is_trap, TRUE);
1546 /* Count chests (trapped) */
1547 num_chests = count_chests(&y, &x, TRUE);
1549 /* See if only one target */
1550 if (num_traps || num_chests)
1552 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1553 if (!too_many) command_dir = coords_to_dir(y, x);
1558 /* Allow repeated command */
1561 /* Set repeat count */
1562 command_rep = command_arg - 1;
1563 p_ptr->redraw |= (PR_STATE);
1565 /* Cancel the arg */
1569 /* Get a direction (or abort) */
1570 if (get_rep_dir(&dir,TRUE))
1575 y = p_ptr->y + ddy[dir];
1576 x = p_ptr->x + ddx[dir];
1577 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1579 /* Feature code (applying "mimic" field) */
1580 feat = get_feat_mimic(g_ptr);
1582 /* Check for chests */
1583 o_idx = chest_check(y, x, TRUE);
1586 if (!is_trap(feat) && !o_idx)
1588 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1591 /* Monster in the way */
1592 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1594 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1603 more = do_cmd_disarm_chest(y, x, o_idx);
1609 more = do_cmd_disarm_aux(y, x, dir);
1613 /* Cancel repeat unless told not to */
1614 if (!more) disturb(FALSE, FALSE);
1619 * @brief 「打ち破る」動作コマンドのサブルーチン /
1620 * Perform the basic "bash" command
1621 * @param y 対象を行うマスのY座標
1622 * @param x 対象を行うマスのX座標
1623 * @param dir プレイヤーから見たターゲットの方角ID
1624 * @return 実際に処理が行われた場合TRUEを返す。
1627 * Assume destination is a closed/locked/jammed door
1628 * Assume there is no monster blocking the destination
1629 * Returns TRUE if repeated commands may continue
1632 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1634 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1637 feature_type *f_ptr = &f_info[g_ptr->feat];
1639 /* Hack -- Bash power based on strength */
1640 /* (Ranges from 3 to 20 to 100 to 200) */
1641 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1643 /* Extract door power */
1644 int temp = f_ptr->power;
1648 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1650 take_turn(p_ptr, 100);
1652 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1654 /* Compare bash power to door power */
1655 temp = (bash - (temp * 10));
1657 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1659 /* Hack -- always have a chance */
1660 if (temp < 1) temp = 1;
1662 /* Hack -- attempt to bash down the door */
1663 if (randint0(100) < temp)
1665 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1667 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1669 /* Break down the door */
1670 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1672 cave_alter_feat(y, x, FF_BASH);
1678 cave_alter_feat(y, x, FF_OPEN);
1681 /* Hack -- Fall through the door */
1682 move_player(dir, FALSE, FALSE);
1685 /* Saving throw against stun */
1686 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1689 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1691 /* Allow repeated bashing */
1695 /* High dexterity yields coolness */
1698 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1700 /* Hack -- Lose balance ala paralysis */
1701 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1708 * @brief 「打ち破る」動作コマンドのメインルーチン /
1709 * Bash open a door, success based on character strength
1713 * For a closed door, pval is positive if locked; negative if stuck.
1715 * For an open door, pval is positive for a broken door.
1717 * A closed door can be opened - harder if locked. Any door might be
1718 * bashed open (and thereby broken). Bashing a door is (potentially)
1719 * faster! You move into the door way. To open a stuck door, it must
1720 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1722 * Creatures can also open or bash doors, see elsewhere.
1725 void do_cmd_bash(void)
1731 if (p_ptr->wild_mode) return;
1733 if (p_ptr->special_defense & KATA_MUSOU)
1735 set_action(ACTION_NONE);
1738 /* Allow repeated command */
1741 /* Set repeat count */
1742 command_rep = command_arg - 1;
1743 p_ptr->redraw |= (PR_STATE);
1745 /* Cancel the arg */
1749 /* Get a "repeated" direction */
1750 if (get_rep_dir(&dir,FALSE))
1755 y = p_ptr->y + ddy[dir];
1756 x = p_ptr->x + ddx[dir];
1758 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1760 /* Feature code (applying "mimic" field) */
1761 feat = get_feat_mimic(g_ptr);
1763 /* Nothing useful */
1764 if (!have_flag(f_info[feat].flags, FF_BASH))
1766 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1769 /* Monster in the way */
1770 else if (g_ptr->m_idx)
1772 take_turn(p_ptr, 100);
1774 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1780 /* Bash a closed door */
1784 more = do_cmd_bash_aux(y, x, dir);
1788 /* Unless valid action taken, cancel bash */
1789 if (!more) disturb(FALSE, FALSE);
1794 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1798 * Manipulate an adjacent grid in some way
1800 * Attack monsters, tunnel through walls, disarm traps, open doors.
1802 * Consider confusion
1804 * This command must always take a turn, to prevent free detection
1805 * of invisible monsters.
1808 void do_cmd_alter(void)
1815 if (p_ptr->special_defense & KATA_MUSOU)
1817 set_action(ACTION_NONE);
1820 /* Allow repeated command */
1823 /* Set repeat count */
1824 command_rep = command_arg - 1;
1825 p_ptr->redraw |= (PR_STATE);
1827 /* Cancel the arg */
1831 /* Get a direction */
1832 if (get_rep_dir(&dir,TRUE))
1835 feature_type *f_ptr;
1837 y = p_ptr->y + ddy[dir];
1838 x = p_ptr->x + ddx[dir];
1840 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1842 /* Feature code (applying "mimic" field) */
1843 feat = get_feat_mimic(g_ptr);
1844 f_ptr = &f_info[feat];
1846 take_turn(p_ptr, 100);
1854 else if (have_flag(f_ptr->flags, FF_OPEN))
1856 more = do_cmd_open_aux(y, x);
1859 /* Bash jammed doors */
1860 else if (have_flag(f_ptr->flags, FF_BASH))
1862 more = do_cmd_bash_aux(y, x, dir);
1865 /* Tunnel through walls */
1866 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1868 more = do_cmd_tunnel_aux(y, x);
1871 /* Close open doors */
1872 else if (have_flag(f_ptr->flags, FF_CLOSE))
1874 more = do_cmd_close_aux(y, x);
1878 else if (have_flag(f_ptr->flags, FF_DISARM))
1880 more = do_cmd_disarm_aux(y, x, dir);
1885 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1889 /* Cancel repetition unless we can continue */
1890 if (!more) disturb(FALSE, FALSE);
1896 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1897 * Find the index of some "spikes", if possible.
1898 * @param ip くさびとして打てるオブジェクトのID
1899 * @return オブジェクトがある場合TRUEを返す
1902 * Let user choose a pile of spikes, perhaps?
1905 static bool get_spike(INVENTORY_IDX *ip)
1909 /* Check every item in the pack */
1910 for (i = 0; i < INVEN_PACK; i++)
1912 object_type *o_ptr = &inventory[i];
1914 /* Skip non-objects */
1915 if (!o_ptr->k_idx) continue;
1917 /* Check the "tval" code */
1918 if (o_ptr->tval == TV_SPIKE)
1920 /* Save the spike index */
1933 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1934 * Jam a closed door with a spike
1938 * This command may NOT be repeated
1941 void do_cmd_spike(void)
1945 if (p_ptr->wild_mode) return;
1947 if (p_ptr->special_defense & KATA_MUSOU)
1949 set_action(ACTION_NONE);
1952 /* Get a "repeated" direction */
1953 if (get_rep_dir(&dir, FALSE))
1960 y = p_ptr->y + ddy[dir];
1961 x = p_ptr->x + ddx[dir];
1962 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1964 /* Feature code (applying "mimic" field) */
1965 feat = get_feat_mimic(g_ptr);
1967 /* Require closed door */
1968 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1970 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1974 else if (!get_spike(&item))
1976 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1979 /* Is a monster in the way? */
1980 else if (g_ptr->m_idx)
1982 take_turn(p_ptr, 100);
1984 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1993 take_turn(p_ptr, 100);
1995 /* Successful jamming */
1996 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1997 cave_alter_feat(y, x, FF_SPIKE);
1999 /* Use up, and describe, a single spike, from the bottom */
2000 inven_item_increase(item, -1);
2001 inven_item_describe(item);
2002 inven_item_optimize(item);
2010 * @brief 「歩く」動作コマンドのメインルーチン /
2011 * Support code for the "Walk" and "Jump" commands
2012 * @param pickup アイテムの自動拾いを行うならTRUE
2015 void do_cmd_walk(bool pickup)
2022 /* Allow repeated command */
2025 /* Set repeat count */
2026 command_rep = command_arg - 1;
2027 p_ptr->redraw |= (PR_STATE);
2029 /* Cancel the arg */
2033 /* Get a "repeated" direction */
2034 if (get_rep_dir(&dir, FALSE))
2036 take_turn(p_ptr, 100);
2038 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2040 set_action(ACTION_NONE);
2043 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2044 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2045 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2047 /* Actually move the character */
2048 move_player(dir, pickup, FALSE);
2050 /* Allow more walking */
2054 /* Hack again -- Is there a special encounter ??? */
2055 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2057 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2060 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2062 /* Inform the player of his horrible fate :=) */
2063 msg_print(_("襲撃だ!", "You are ambushed !"));
2065 /* Go into large wilderness view */
2066 p_ptr->oldpy = randint1(MAX_HGT-2);
2067 p_ptr->oldpx = randint1(MAX_WID-2);
2070 /* Give first move to monsters */
2071 take_turn(p_ptr, 100);
2073 /* HACk -- set the encouter flag for the wilderness generation */
2074 generate_encounter = TRUE;
2078 /* Cancel repeat unless we may continue */
2079 if (!more) disturb(FALSE, FALSE);
2084 * @brief 「走る」動作コマンドのメインルーチン /
2088 void do_cmd_run(void)
2091 if (cmd_limit_confused(p_ptr)) return;
2093 if (p_ptr->special_defense & KATA_MUSOU)
2095 set_action(ACTION_NONE);
2098 /* Get a "repeated" direction */
2099 if (get_rep_dir(&dir,FALSE))
2101 /* Hack -- Set the run counter */
2102 running = (command_arg ? command_arg : 1000);
2111 * @brief 「留まる」動作コマンドのメインルーチン /
2112 * Stay still. Search. Enter stores.
2113 * Pick up treasure if "pickup" is true.
2114 * @param pickup アイテムの自動拾いを行うならTRUE
2117 void do_cmd_stay(bool pickup)
2119 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2121 /* Allow repeated command */
2124 /* Set repeat count */
2125 command_rep = command_arg - 1;
2126 p_ptr->redraw |= (PR_STATE);
2128 /* Cancel the arg */
2132 take_turn(p_ptr, 100);
2134 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2135 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2140 * @brief 「休む」動作コマンドのメインルーチン /
2141 * Resting allows a player to safely restore his hp -RAK-
2144 void do_cmd_rest(void)
2147 set_action(ACTION_NONE);
2149 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2151 stop_singing(p_ptr);
2155 if (hex_spelling_any()) stop_hex_spell_all();
2157 /* Prompt for time if needed */
2158 if (command_arg <= 0)
2160 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2161 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2167 strcpy(out_val, "&");
2169 /* Ask for duration */
2170 if (!get_string(p, out_val, 4)) return;
2172 /* Rest until done */
2173 if (out_val[0] == '&')
2175 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2179 else if (out_val[0] == '*')
2181 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2187 command_arg = (COMMAND_ARG)atoi(out_val);
2188 if (command_arg <= 0) return;
2194 if (command_arg > 9999) command_arg = 9999;
2196 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2198 /* Take a turn (?) */
2199 take_turn(p_ptr, 100);
2201 /* The sin of sloth */
2202 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2204 /* Why are you sleeping when there's no need? WAKE UP!*/
2205 if ((p_ptr->chp == p_ptr->mhp) &&
2206 (p_ptr->csp == p_ptr->msp) &&
2207 !p_ptr->blind && !p_ptr->confused &&
2208 !p_ptr->poisoned && !p_ptr->afraid &&
2209 !p_ptr->stun && !p_ptr->cut &&
2210 !p_ptr->slow && !p_ptr->paralyzed &&
2211 !p_ptr->image && !p_ptr->word_recall &&
2212 !p_ptr->alter_reality)
2213 chg_virtue(V_DILIGENCE, -1);
2215 /* Save the rest code */
2216 resting = command_arg;
2217 p_ptr->action = ACTION_REST;
2218 p_ptr->update |= (PU_BONUS);
2219 update_creature(p_ptr);
2221 p_ptr->redraw |= (PR_STATE);
2230 * @brief 射撃処理のメインルーチン
2233 void do_cmd_fire(void)
2236 object_type *j_ptr, *ammo_ptr;
2239 if(p_ptr->wild_mode) return;
2241 is_fired = FALSE; /* not fired yet */
2243 /* Get the "bow" (if any) */
2244 j_ptr = &inventory[INVEN_BOW];
2246 /* Require a launcher */
2249 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2254 if (j_ptr->sval == SV_CRIMSON)
2256 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2261 if (j_ptr->sval == SV_HARP)
2263 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2269 if (p_ptr->special_defense & KATA_MUSOU)
2271 set_action(ACTION_NONE);
2274 /* Require proper missile */
2275 item_tester_tval = p_ptr->tval_ammo;
2277 q = _("どれを撃ちますか? ", "Fire which item? ");
2278 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2281 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2289 exe_fire(item, j_ptr);
2291 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2293 /* Sniper actions after some shootings */
2294 if (snipe_type == SP_AWAY)
2296 teleport_player(10 + (p_ptr->concent * 2), 0L);
2298 if (snipe_type == SP_FINAL)
2300 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2301 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2302 (void)set_stun(p_ptr->stun + randint1(25));
2308 * @brief 投射処理メインルーチン /
2309 * Throw an object from the pack or floor.
2311 * @param boomerang ブーメラン処理ならばTRUE
2312 * @param shuriken 忍者の手裏剣処理ならばTRUE
2313 * @return ターンを消費した場合TRUEを返す
2316 * Note: "unseen" monsters are very hard to hit.
2318 * Should throwing a weapon do full damage? Should it allow the magic
2319 * to hit bonus of the weapon to have an effect? Should it ever cause
2320 * the item to be destroyed? Should it do any damage at all?
2323 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2328 POSITION y, x, ty, tx, prev_y, prev_x;
2329 POSITION ny[19], nx[19];
2330 int chance, tdam, tdis;
2331 int mul, div, dd, ds;
2332 int cur_dis, visible;
2339 bool hit_body = FALSE;
2340 bool hit_wall = FALSE;
2341 bool equiped_item = FALSE;
2342 bool return_when_thrown = FALSE;
2344 GAME_TEXT o_name[MAX_NLEN];
2346 int msec = delay_factor * delay_factor * delay_factor;
2348 BIT_FLAGS flgs[TR_FLAG_SIZE];
2350 bool come_back = FALSE;
2351 bool do_drop = TRUE;
2353 if (p_ptr->wild_mode) return FALSE;
2355 if (p_ptr->special_defense & KATA_MUSOU)
2357 set_action(ACTION_NONE);
2363 o_ptr = &inventory[item];
2367 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2369 item_tester_hook = item_tester_hook_boomerang;
2370 q = _("どの武器を投げますか? ", "Throw which item? ");
2371 s = _("投げる武器がない。", "You have nothing to throw.");
2372 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2379 else if (has_melee_weapon(INVEN_LARM))
2382 o_ptr = &inventory[item];
2387 o_ptr = &inventory[item];
2392 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2393 s = _("投げるアイテムがない。", "You have nothing to throw.");
2394 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2402 /* Item is cursed */
2403 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2405 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2409 if (p_ptr->inside_arena && !boomerang)
2411 if (o_ptr->tval != TV_SPIKE)
2413 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2422 /* Obtain a local object */
2423 object_copy(q_ptr, o_ptr);
2425 /* Extract the thrown object's flags. */
2426 object_flags(q_ptr, flgs);
2427 torch_flags(q_ptr, flgs);
2429 /* Distribute the charges of rods/wands between the stacks */
2430 distribute_charges(o_ptr, q_ptr, 1);
2435 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2437 if (p_ptr->mighty_throw) mult += 3;
2439 /* Extract a "distance multiplier" */
2440 /* Changed for 'launcher' mutation */
2441 mul = 10 + 2 * (mult - 1);
2443 /* Enforce a minimum "weight" of one pound */
2444 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2445 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2447 /* Hack -- Distance -- Reward strength, penalize weight */
2448 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2450 /* Max distance of 10-18 */
2451 if (tdis > mul) tdis = mul;
2455 ty = randint0(101) - 50 + p_ptr->y;
2456 tx = randint0(101) - 50 + p_ptr->x;
2460 project_length = tdis + 1;
2462 /* Get a direction (or cancel) */
2463 if (!get_aim_dir(&dir)) return FALSE;
2465 /* Predict the "target" location */
2466 tx = p_ptr->x + 99 * ddx[dir];
2467 ty = p_ptr->y + 99 * ddy[dir];
2469 /* Check for "target request" */
2470 if ((dir == 5) && target_okay())
2476 project_length = 0; /* reset to default */
2479 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2480 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2481 return_when_thrown = TRUE;
2483 /* Reduce and describe inventory */
2486 inven_item_increase(item, -1);
2487 if (!return_when_thrown)
2488 inven_item_describe(item);
2489 inven_item_optimize(item);
2492 /* Reduce and describe floor item */
2495 floor_item_increase(0 - item, -1);
2496 floor_item_optimize(0 - item);
2498 if (item >= INVEN_RARM)
2500 equiped_item = TRUE;
2501 p_ptr->redraw |= (PR_EQUIPPY);
2504 take_turn(p_ptr, 100);
2506 /* Rogue and Ninja gets bonus */
2507 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2508 p_ptr->energy_use -= p_ptr->lev;
2510 /* Start at the player */
2516 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2517 else shuriken = FALSE;
2519 /* Chance of hitting */
2520 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2521 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2522 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2524 if (shuriken) chance *= 2;
2529 /* Travel until stopped */
2530 for (cur_dis = 0; cur_dis <= tdis; )
2532 /* Hack -- Stop at the target */
2533 if ((y == ty) && (x == tx)) break;
2535 /* Calculate the new location (see "project()") */
2538 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2540 /* Stopped by walls/doors */
2541 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2544 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;
2547 /* The player can see the (on screen) missile */
2548 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2550 SYMBOL_CODE c = object_char(q_ptr);
2551 TERM_COLOR a = object_attr(q_ptr);
2553 /* Draw, Hilite, Fresh, Pause, Erase */
2554 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2555 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2557 Term_xtra(TERM_XTRA_DELAY, msec);
2558 lite_spot(ny[cur_dis], nx[cur_dis]);
2562 /* The player cannot see the missile */
2565 /* Pause anyway, for consistancy */
2566 Term_xtra(TERM_XTRA_DELAY, msec);
2572 /* Save the new location */
2576 /* Advance the distance */
2579 /* Monster here, Try to hit it */
2580 if (current_floor_ptr->grid_array[y][x].m_idx)
2582 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2583 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2585 /* Check the visibility */
2586 visible = m_ptr->ml;
2588 /* Note the collision */
2591 /* Did we hit it (penalize range) */
2592 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2596 /* Handle unseen monster */
2599 /* Invisible monster */
2600 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2603 /* Handle visible monster */
2606 GAME_TEXT m_name[MAX_NLEN];
2607 monster_desc(m_name, m_ptr, 0);
2608 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2612 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2613 health_track(g_ptr->m_idx);
2617 /* Hack -- Base damage from thrown object */
2620 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2621 tdam = damroll(dd, ds);
2622 /* Apply special damage */
2623 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2624 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2625 if (q_ptr->to_d > 0)
2626 tdam += q_ptr->to_d;
2628 tdam += -q_ptr->to_d;
2632 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2633 tdam += p_ptr->to_d_m;
2635 else if (have_flag(flgs, TR_THROW))
2638 tdam += p_ptr->to_d_m;
2646 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2649 /* No negative damage */
2650 if (tdam < 0) tdam = 0;
2652 /* Modify the damage */
2653 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2655 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2656 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2658 /* Hit the monster, check for death */
2659 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2667 message_pain(g_ptr->m_idx, tdam);
2669 /* Anger the monster */
2670 if ((tdam > 0) && !object_is_potion(q_ptr))
2671 anger_monster(m_ptr);
2673 if (fear && m_ptr->ml)
2676 GAME_TEXT m_name[MAX_NLEN];
2677 monster_desc(m_name, m_ptr, 0);
2678 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2688 /* decrease toach's fuel */
2689 if (hit_body) torch_lost_fuel(q_ptr);
2691 /* Chance of breakage (during attacks) */
2692 j = (hit_body ? breakage_chance(q_ptr) : 0);
2694 /* Figurines transform */
2695 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2699 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2700 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2701 else if (object_is_cursed(q_ptr))
2702 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2707 /* Potions smash open */
2708 if (object_is_potion(q_ptr))
2710 if (hit_body || hit_wall || (randint1(100) < j))
2712 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2714 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2716 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2718 /* ToDo (Robert): fix the invulnerability */
2719 if (current_floor_ptr->grid_array[y][x].m_idx &&
2720 is_friendly(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]) &&
2721 !MON_INVULNER(m_ptr))
2723 GAME_TEXT m_name[MAX_NLEN];
2724 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
2725 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2726 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2737 if (return_when_thrown)
2739 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2740 char o2_name[MAX_NLEN];
2741 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2744 if (boomerang) back_chance += 4+randint1(5);
2745 if (super_boomerang) back_chance += 100;
2746 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2748 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2750 for (i = cur_dis - 1; i > 0; i--)
2752 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2754 char c = object_char(q_ptr);
2755 byte a = object_attr(q_ptr);
2757 /* Draw, Hilite, Fresh, Pause, Erase */
2758 print_rel(c, a, ny[i], nx[i]);
2759 move_cursor_relative(ny[i], nx[i]);
2761 Term_xtra(TERM_XTRA_DELAY, msec);
2762 lite_spot(ny[i], nx[i]);
2767 /* Pause anyway, for consistancy */
2768 Term_xtra(TERM_XTRA_DELAY, msec);
2771 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2773 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2780 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2784 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2792 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2798 if (item == INVEN_RARM || item == INVEN_LARM)
2800 /* Access the wield slot */
2801 o_ptr = &inventory[item];
2803 /* Wear the new stuff */
2804 object_copy(o_ptr, q_ptr);
2806 p_ptr->total_weight += q_ptr->weight;
2808 /* Increment the equip counter by hand */
2811 /* Recalculate torch */
2812 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2813 p_ptr->window |= (PW_EQUIP);
2821 else if (equiped_item)
2829 if (cave_have_flag_bold(y, x, FF_PROJECT))
2831 (void)drop_near(q_ptr, j, y, x);
2835 (void)drop_near(q_ptr, j, prev_y, prev_x);