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 #include "player-move.h"
32 #include "object-broken.h"
35 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
36 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
37 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
39 static bool confirm_leave_level(bool down_stair)
41 quest_type *q_ptr = &quest[p_ptr->inside_quest];
43 /* Confirm leaving from once only quest */
44 if (confirm_quest && p_ptr->inside_quest &&
45 (q_ptr->type == QUEST_TYPE_RANDOM ||
46 (q_ptr->flags & QUEST_FLAG_ONCE &&
47 q_ptr->status != QUEST_STATUS_COMPLETED) ||
48 (q_ptr->flags & QUEST_FLAG_TOWER &&
49 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
50 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
52 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
53 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
63 * @brief 魔法系コマンドが制限されているかを返す。
64 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
66 bool cmd_limit_cast(player_type *creature_ptr)
68 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
70 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
74 else if (creature_ptr->anti_magic)
76 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
79 else if (creature_ptr->shero)
81 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
88 bool cmd_limit_confused(player_type *creature_ptr)
90 if (creature_ptr->confused)
92 msg_print(_("混乱していてできない!", "You are too confused!"));
98 bool cmd_limit_arena(player_type *creature_ptr)
100 if (creature_ptr->inside_arena)
102 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
109 bool cmd_limit_blind(player_type *creature_ptr)
111 if (creature_ptr->blind)
113 msg_print(_("目が見えない。", "You can't see anything."));
118 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
124 bool cmd_limit_time_walk(player_type *creature_ptr)
126 if (creature_ptr->timewalk)
128 if (flush_failure) flush();
129 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
137 * @brief 階段を使って階層を昇る処理 / Go up one level
140 void do_cmd_go_up(void)
145 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
146 feature_type *f_ptr = &f_info[g_ptr->feat];
150 if (p_ptr->special_defense & KATA_MUSOU)
152 set_action(ACTION_NONE);
156 if (!have_flag(f_ptr->flags, FF_LESS))
158 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
162 /* Quest up stairs */
163 if (have_flag(f_ptr->flags, FF_QUEST))
165 /* Cancel the command */
166 if (!confirm_leave_level(FALSE)) return;
170 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
171 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
173 msg_print(_("上の階に登った。", "You enter the up staircase."));
177 p_ptr->inside_quest = g_ptr->special;
179 /* Activate the quest */
180 if (!quest[p_ptr->inside_quest].status)
182 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
184 init_flags = INIT_ASSIGN;
185 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
187 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
190 /* Leaving a quest */
191 if (!p_ptr->inside_quest)
193 current_floor_ptr->dun_level = 0;
197 p_ptr->leaving = TRUE;
202 take_turn(p_ptr, 100);
204 /* End the command */
208 if (!current_floor_ptr->dun_level)
214 go_up = confirm_leave_level(FALSE);
217 /* Cancel the command */
220 take_turn(p_ptr, 100);
222 if (autosave_l) do_cmd_save_game(TRUE);
224 /* For a random quest */
225 if (p_ptr->inside_quest &&
226 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
230 p_ptr->inside_quest = 0;
233 /* For a fixed quest */
234 if (p_ptr->inside_quest &&
235 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
239 p_ptr->inside_quest = g_ptr->special;
240 current_floor_ptr->dun_level = 0;
244 /* For normal dungeon and random quest */
248 if (have_flag(f_ptr->flags, FF_SHAFT))
250 /* Create a way back */
251 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
257 /* Create a way back */
258 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
263 /* Get out from current dungeon */
264 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
265 up_num = current_floor_ptr->dun_level;
267 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
270 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
271 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
272 else if (up_num == current_floor_ptr->dun_level)
273 msg_print(_("地上に戻った。", "You go back to the surface."));
275 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
278 p_ptr->leaving = TRUE;
283 * @brief 階段を使って階層を降りる処理 / Go down one level
286 void do_cmd_go_down(void)
289 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
290 feature_type *f_ptr = &f_info[g_ptr->feat];
292 bool fall_trap = FALSE;
295 if (p_ptr->special_defense & KATA_MUSOU)
297 set_action(ACTION_NONE);
301 if (!have_flag(f_ptr->flags, FF_MORE))
303 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
307 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
310 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
315 /* Quest down stairs */
316 else if (have_flag(f_ptr->flags, FF_QUEST))
318 /* Confirm Leaving */
319 if(!confirm_leave_level(TRUE)) return;
321 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
322 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
324 msg_print(_("下の階に降りた。", "You enter the down staircase."));
329 p_ptr->inside_quest = g_ptr->special;
331 /* Activate the quest */
332 if (!quest[p_ptr->inside_quest].status)
334 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
336 init_flags = INIT_ASSIGN;
337 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
339 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
342 /* Leaving a quest */
343 if (!p_ptr->inside_quest)
345 current_floor_ptr->dun_level = 0;
349 p_ptr->leaving = TRUE;
353 take_turn(p_ptr, 100);
358 DUNGEON_IDX target_dungeon = 0;
360 if (!current_floor_ptr->dun_level)
362 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
364 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
366 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
369 if (!max_dlv[target_dungeon])
371 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
372 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
373 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
376 /* Save old player position */
377 p_ptr->oldpx = p_ptr->x;
378 p_ptr->oldpy = p_ptr->y;
379 p_ptr->dungeon_idx = target_dungeon;
382 * Clear all saved floors
383 * and create a first saved floor
385 prepare_change_floor_mode(CFM_FIRST_FLOOR);
388 take_turn(p_ptr, 100);
390 if (autosave_l) do_cmd_save_game(TRUE);
393 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
396 if (!current_floor_ptr->dun_level)
398 /* Enter the dungeon just now */
399 p_ptr->enter_dungeon = TRUE;
400 down_num = d_info[p_ptr->dungeon_idx].mindepth;
405 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
406 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
411 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
418 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
422 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
423 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
425 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
431 p_ptr->leaving = TRUE;
435 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
439 if (have_flag(f_ptr->flags, FF_SHAFT))
441 /* Create a way back */
442 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
446 /* Create a way back */
447 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
455 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn
458 void do_cmd_search(void)
460 /* Allow repeated command */
463 /* Set repeat count */
464 command_rep = command_arg - 1;
465 p_ptr->redraw |= (PR_STATE);
470 take_turn(p_ptr, 100);
478 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
479 * @param y 走査対象にしたいマスのY座標
480 * @param x 走査対象にしたいマスのX座標
481 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
482 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
484 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
486 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
487 OBJECT_IDX this_o_idx, next_o_idx = 0;
489 /* Scan all objects in the grid */
490 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
494 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
495 next_o_idx = o_ptr->next_o_idx;
497 /* Skip unknown chests XXX XXX */
498 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
500 /* Check for non empty chest */
501 if ((o_ptr->tval == TV_CHEST) &&
502 (((!trapped) && (o_ptr->pval)) || /* non empty */
503 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
512 * @brief 箱を開けるコマンドのメインルーチン /
513 * Attempt to open the given chest at the given location
514 * @param y 箱の存在するマスのY座標
515 * @param x 箱の存在するマスのX座標
516 * @param o_idx 箱のオブジェクトID
517 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
519 * Assume there is no monster blocking the destination
521 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
526 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
528 take_turn(p_ptr, 100);
530 /* Attempt to unlock it */
533 /* Assume locked, and thus not open */
536 /* Get the "disarm" factor */
537 i = p_ptr->skill_dis;
539 /* Penalize some conditions */
540 if (p_ptr->blind || no_lite()) i = i / 10;
541 if (p_ptr->confused || p_ptr->image) i = i / 10;
543 /* Extract the difficulty */
546 /* Always have a small chance of success */
549 /* Success -- May still have traps */
550 if (randint0(100) < j)
552 msg_print(_("鍵をはずした。", "You have picked the lock."));
557 /* Failure -- Keep trying */
560 /* We may continue repeating */
562 if (flush_failure) flush();
563 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
568 /* Allowed to open */
571 /* Apply chest traps, if any */
572 chest_trap(y, x, o_idx);
574 /* Let the Chest drop items */
575 chest_death(FALSE, y, x, o_idx);
581 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
582 * Attempt to open the given chest at the given location
583 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
584 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
585 * @param test 地形条件を判定するための関数ポインタ
586 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
588 * @details Return the number of features around (or under) the character.
589 * Usually look for doors and floor traps.
591 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
597 /* Count how many matches */
600 /* Check around (and under) the character */
601 for (d = 0; d < 9; d++)
606 /* if not searching under player continue */
607 if ((d == 8) && !under) continue;
609 /* Extract adjacent (legal) location */
610 yy = p_ptr->y + ddy_ddd[d];
611 xx = p_ptr->x + ddx_ddd[d];
613 /* Get the current_floor_ptr->grid_array */
614 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
616 /* Must have knowledge */
617 if (!(g_ptr->info & (CAVE_MARK))) continue;
619 /* Feature code (applying "mimic" field) */
620 feat = get_feat_mimic(g_ptr);
622 /* Not looking for this feature */
623 if (!((*test)(feat))) continue;
628 /* Remember the location. Only useful if only one match */
639 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
640 * Return the number of chests around (or under) the character.
641 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
642 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
643 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
646 * If requested, count only trapped chests.
648 static int count_chests(POSITION *y, POSITION *x, bool trapped)
655 /* Count how many matches */
658 /* Check around (and under) the character */
659 for (d = 0; d < 9; d++)
661 /* Extract adjacent (legal) location */
662 POSITION yy = p_ptr->y + ddy_ddd[d];
663 POSITION xx = p_ptr->x + ddx_ddd[d];
665 /* No (visible) chest is there */
666 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
668 /* Grab the object */
669 o_ptr = ¤t_floor_ptr->o_list[o_idx];
672 if (o_ptr->pval == 0) continue;
674 /* No (known) traps here */
675 if (trapped && (!object_is_known(o_ptr) ||
676 !chest_traps[o_ptr->pval])) continue;
681 /* Remember the location. Only useful if only one match */
693 * @brief 「開ける」動作コマンドのサブルーチン /
694 * Perform the basic "open" command on doors
695 * @param y 対象を行うマスのY座標
696 * @param x 対象を行うマスのX座標
697 * @return 実際に処理が行われた場合TRUEを返す。
699 * Assume destination is a closed/locked/jammed door
700 * Assume there is no monster blocking the destination
701 * Returns TRUE if repeated commands may continue
703 static bool do_cmd_open_aux(POSITION y, POSITION x)
707 /* Get requested grid */
708 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
709 feature_type *f_ptr = &f_info[g_ptr->feat];
712 take_turn(p_ptr, 100);
714 /* Seeing true feature code (ignore mimic) */
717 if (!have_flag(f_ptr->flags, FF_OPEN))
720 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
724 else if (f_ptr->power)
727 i = p_ptr->skill_dis;
729 /* Penalize some conditions */
730 if (p_ptr->blind || no_lite()) i = i / 10;
731 if (p_ptr->confused || p_ptr->image) i = i / 10;
733 /* Extract the lock power */
736 /* Extract the difficulty */
739 /* Always have a small chance of success */
743 if (randint0(100) < j)
745 msg_print(_("鍵をはずした。", "You have picked the lock."));
748 cave_alter_feat(y, x, FF_OPEN);
750 sound(SOUND_OPENDOOR);
760 if (flush_failure) flush();
762 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
764 /* We may keep trying */
773 cave_alter_feat(y, x, FF_OPEN);
775 sound(SOUND_OPENDOOR);
781 * @brief 「開ける」コマンドのメインルーチン /
782 * Open a closed/locked/jammed door or a closed/locked chest.
785 * Unlocking a locked door/chest is worth one experience point.
787 void do_cmd_open(void)
795 if (p_ptr->wild_mode) return;
797 if (p_ptr->special_defense & KATA_MUSOU)
799 set_action(ACTION_NONE);
802 /* Option: Pick a direction */
805 int num_doors, num_chests;
807 /* Count closed doors (locked or jammed) */
808 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
810 /* Count chests (locked) */
811 num_chests = count_chests(&y, &x, FALSE);
813 /* See if only one target */
814 if (num_doors || num_chests)
816 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
818 if (!too_many) command_dir = coords_to_dir(y, x);
822 /* Allow repeated command */
825 /* Set repeat count */
826 command_rep = command_arg - 1;
827 p_ptr->redraw |= (PR_STATE);
833 /* Get a "repeated" direction */
834 if (get_rep_dir(&dir, TRUE))
839 /* Get requested location */
840 y = p_ptr->y + ddy[dir];
841 x = p_ptr->x + ddx[dir];
843 /* Get requested grid */
844 g_ptr = ¤t_floor_ptr->grid_array[y][x];
846 /* Feature code (applying "mimic" field) */
847 feat = get_feat_mimic(g_ptr);
849 /* Check for chest */
850 o_idx = chest_check(y, x, FALSE);
853 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
855 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
858 /* Monster in the way */
859 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
861 take_turn(p_ptr, 100);
862 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
870 more = do_cmd_open_chest(y, x, o_idx);
877 more = do_cmd_open_aux(y, x);
881 /* Cancel repeat unless we may continue */
882 if (!more) disturb(FALSE, FALSE);
888 * @brief 「閉じる」動作コマンドのサブルーチン /
889 * Perform the basic "close" command
890 * @param y 対象を行うマスのY座標
891 * @param x 対象を行うマスのX座標
892 * @return 実際に処理が行われた場合TRUEを返す。
894 * Assume destination is an open/broken door
895 * Assume there is no monster blocking the destination
896 * Returns TRUE if repeated commands may continue
898 static bool do_cmd_close_aux(POSITION y, POSITION x)
900 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
901 FEAT_IDX old_feat = g_ptr->feat;
904 take_turn(p_ptr, 100);
906 /* Seeing true feature code (ignore mimic) */
909 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
911 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
913 /* Hack -- object in the way */
914 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
915 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
917 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
922 cave_alter_feat(y, x, FF_CLOSE);
925 if (old_feat == g_ptr->feat)
927 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
931 sound(SOUND_SHUTDOOR);
940 * @brief 「閉じる」コマンドのメインルーチン /
941 * Close an open door.
944 * Unlocking a locked door/chest is worth one experience point.
946 void do_cmd_close(void)
953 if (p_ptr->wild_mode) return;
955 if (p_ptr->special_defense & KATA_MUSOU)
957 set_action(ACTION_NONE);
960 /* Option: Pick a direction */
963 /* Count open doors */
964 if (count_dt(&y, &x, is_open, FALSE) == 1)
966 command_dir = coords_to_dir(y, x);
970 /* Allow repeated command */
973 /* Set repeat count */
974 command_rep = command_arg - 1;
975 p_ptr->redraw |= (PR_STATE);
981 /* Get a "repeated" direction */
982 if (get_rep_dir(&dir, FALSE))
987 y = p_ptr->y + ddy[dir];
988 x = p_ptr->x + ddx[dir];
989 g_ptr = ¤t_floor_ptr->grid_array[y][x];
991 /* Feature code (applying "mimic" field) */
992 feat = get_feat_mimic(g_ptr);
994 /* Require open/broken door */
995 if (!have_flag(f_info[feat].flags, FF_CLOSE))
997 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1000 /* Monster in the way */
1001 else if (g_ptr->m_idx)
1003 take_turn(p_ptr, 100);
1005 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1011 /* Close the door */
1014 /* Close the door */
1015 more = do_cmd_close_aux(y, x);
1019 /* Cancel repeat unless we may continue */
1020 if (!more) disturb(FALSE, FALSE);
1025 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1026 * Determine if a given grid may be "tunneled"
1027 * @param y 対象を行うマスのY座標
1028 * @param x 対象を行うマスのX座標
1031 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1033 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1035 /* Must have knowledge */
1036 if (!(g_ptr->info & CAVE_MARK))
1038 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1043 /* Must be a wall/door/etc */
1044 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1046 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1056 * @brief 「掘る」動作コマンドのサブルーチン /
1057 * Perform the basic "tunnel" command
1058 * @param y 対象を行うマスのY座標
1059 * @param x 対象を行うマスのX座標
1060 * @return 実際に処理が行われた場合TRUEを返す。
1062 * Assumes that no monster is blocking the destination
1063 * Do not use twall anymore
1064 * Returns TRUE if repeated commands may continue
1066 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1069 feature_type *f_ptr, *mimic_f_ptr;
1074 /* Verify legality */
1075 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1077 take_turn(p_ptr, 100);
1079 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1080 f_ptr = &f_info[g_ptr->feat];
1081 power = f_ptr->power;
1083 /* Feature code (applying "mimic" field) */
1084 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1086 name = f_name + mimic_f_ptr->name;
1090 if (have_flag(f_ptr->flags, FF_PERMANENT))
1093 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1095 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1098 /* Map border (mimiccing Permanent wall) */
1101 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1106 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1109 if (p_ptr->skill_dig > randint0(20 * power))
1111 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1113 /* Remove the feature */
1114 cave_alter_feat(y, x, FF_TUNNEL);
1116 /* Update some things */
1117 p_ptr->update |= (PU_FLOW);
1121 /* Message, keep digging */
1122 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1130 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1133 if (p_ptr->skill_dig > power + randint0(40 * power))
1135 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1138 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1139 p_ptr->update |= (PU_FLOW);
1142 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1144 /* Remove the feature */
1145 cave_alter_feat(y, x, FF_TUNNEL);
1147 chg_virtue(V_DILIGENCE, 1);
1148 chg_virtue(V_NATURE, -1);
1156 /* We may continue chopping */
1157 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1158 /* Occasional Search XXX XXX */
1159 if (randint0(100) < 25) search();
1163 /* We may continue tunelling */
1164 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1171 if (is_hidden_door(g_ptr))
1173 /* Occasional Search XXX XXX */
1174 if (randint0(100) < 25) search();
1181 * @brief 「掘る」動作コマンドのメインルーチン /
1182 * Tunnels through "walls" (including rubble and closed doors)
1186 * Note that you must tunnel in order to hit invisible monsters
1187 * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
1189 * Digging is very difficult without a "digger" weapon, but can be
1190 * accomplished by strong players using heavy weapons.
1193 void do_cmd_tunnel(void)
1202 if (p_ptr->special_defense & KATA_MUSOU)
1204 set_action(ACTION_NONE);
1207 /* Allow repeated command */
1210 /* Set repeat count */
1211 command_rep = command_arg - 1;
1212 p_ptr->redraw |= (PR_STATE);
1214 /* Cancel the arg */
1218 /* Get a direction to tunnel, or Abort */
1219 if (get_rep_dir(&dir,FALSE))
1222 y = p_ptr->y + ddy[dir];
1223 x = p_ptr->x + ddx[dir];
1225 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1227 /* Feature code (applying "mimic" field) */
1228 feat = get_feat_mimic(g_ptr);
1230 /* No tunnelling through doors */
1231 if (have_flag(f_info[feat].flags, FF_DOOR))
1233 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1236 /* No tunnelling through most features */
1237 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1239 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1242 /* A monster is in the way */
1243 else if (g_ptr->m_idx)
1245 take_turn(p_ptr, 100);
1247 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1256 /* Tunnel through walls */
1257 more = do_cmd_tunnel_aux(y, x);
1261 /* Cancel repetition unless we can continue */
1262 if (!more) disturb(FALSE, FALSE);
1266 * @brief 移動処理による簡易な「開く」処理 /
1268 * @return 開く処理が実際に試みられた場合TRUEを返す
1271 * If there is a jammed/closed/locked door at the given location,
1272 * then attempt to unlock/open it. Return TRUE if an attempt was
1273 * made (successful or not), otherwise return FALSE.
1275 * The code here should be nearly identical to that in
1276 * do_cmd_open_test() and do_cmd_open_aux().
1279 bool easy_open_door(POSITION y, POSITION x)
1283 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1284 feature_type *f_ptr = &f_info[g_ptr->feat];
1286 /* Must be a closed door */
1287 if (!is_closed_door(g_ptr->feat))
1293 if (!have_flag(f_ptr->flags, FF_OPEN))
1296 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1301 else if (f_ptr->power)
1304 i = p_ptr->skill_dis;
1306 /* Penalize some conditions */
1307 if (p_ptr->blind || no_lite()) i = i / 10;
1308 if (p_ptr->confused || p_ptr->image) i = i / 10;
1310 /* Extract the lock power */
1313 /* Extract the difficulty */
1316 /* Always have a small chance of success */
1320 if (randint0(100) < j)
1322 msg_print(_("鍵をはずした。", "You have picked the lock."));
1325 cave_alter_feat(y, x, FF_OPEN);
1327 sound(SOUND_OPENDOOR);
1337 if (flush_failure) flush();
1339 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1348 cave_alter_feat(y, x, FF_OPEN);
1350 sound(SOUND_OPENDOOR);
1356 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1357 * Perform the basic "disarm" command
1358 * @param y 解除を行うマスのY座標
1359 * @param x 解除を行うマスのX座標
1360 * @param o_idx 箱のオブジェクトID
1361 * @return ターンを消費する処理が行われた場合TRUEを返す
1364 * Assume destination is a visible trap
1365 * Assume there is no monster blocking the destination
1366 * Returns TRUE if repeated commands may continue
1369 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1373 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1375 take_turn(p_ptr, 100);
1377 /* Get the "disarm" factor */
1378 i = p_ptr->skill_dis;
1380 /* Penalize some conditions */
1381 if (p_ptr->blind || no_lite()) i = i / 10;
1382 if (p_ptr->confused || p_ptr->image) i = i / 10;
1384 /* Extract the difficulty */
1385 j = i - o_ptr->pval;
1387 /* Always have a small chance of success */
1390 /* Must find the trap first. */
1391 if (!object_is_known(o_ptr))
1393 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1397 /* Already disarmed/unlocked */
1398 else if (o_ptr->pval <= 0)
1400 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1403 /* No traps to find. */
1404 else if (!chest_traps[o_ptr->pval])
1406 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1409 /* Success (get a lot of experience) */
1410 else if (randint0(100) < j)
1412 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1413 gain_exp(o_ptr->pval);
1414 o_ptr->pval = (0 - o_ptr->pval);
1417 /* Failure -- Keep trying */
1418 else if ((i > 5) && (randint1(i) > 5))
1420 /* We may keep trying */
1422 if (flush_failure) flush();
1423 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1426 /* Failure -- Set off the trap */
1429 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1431 chest_trap(y, x, o_idx);
1438 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1439 * Perform the basic "disarm" command
1440 * @param y 解除を行うマスのY座標
1441 * @param x 解除を行うマスのX座標
1442 * @param dir プレイヤーからみた方向ID
1443 * @return ターンを消費する処理が行われた場合TRUEを返す
1446 * Assume destination is a visible trap
1447 * Assume there is no monster blocking the destination
1448 * Returns TRUE if repeated commands may continue
1452 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1454 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1457 feature_type *f_ptr = &f_info[g_ptr->feat];
1459 /* Access trap name */
1460 concptr name = (f_name + f_ptr->name);
1462 /* Extract trap "power" */
1463 int power = f_ptr->power;
1466 /* Get the "disarm" factor */
1467 int i = p_ptr->skill_dis;
1470 take_turn(p_ptr, 100);
1472 /* Penalize some conditions */
1473 if (p_ptr->blind || no_lite()) i = i / 10;
1474 if (p_ptr->confused || p_ptr->image) i = i / 10;
1476 /* Extract the difficulty */
1479 /* Always have a small chance of success */
1483 if (randint0(100) < j)
1485 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1490 /* Remove the trap */
1491 cave_alter_feat(y, x, FF_DISARM);
1493 /* Move the player onto the trap */
1494 move_player(dir, easy_disarm, FALSE);
1497 /* Failure -- Keep trying */
1498 else if ((i > 5) && (randint1(i) > 5))
1501 if (flush_failure) flush();
1503 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1505 /* We may keep trying */
1509 /* Failure -- Set off the trap */
1512 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1513 /* Move the player onto the trap */
1514 move_player(dir, easy_disarm, FALSE);
1521 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1522 * Disarms a trap, or chest
1525 void do_cmd_disarm(void)
1533 if (p_ptr->wild_mode) return;
1535 if (p_ptr->special_defense & KATA_MUSOU)
1537 set_action(ACTION_NONE);
1540 /* Option: Pick a direction */
1543 int num_traps, num_chests;
1545 /* Count visible traps */
1546 num_traps = count_dt(&y, &x, is_trap, TRUE);
1548 /* Count chests (trapped) */
1549 num_chests = count_chests(&y, &x, TRUE);
1551 /* See if only one target */
1552 if (num_traps || num_chests)
1554 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1555 if (!too_many) command_dir = coords_to_dir(y, x);
1560 /* Allow repeated command */
1563 /* Set repeat count */
1564 command_rep = command_arg - 1;
1565 p_ptr->redraw |= (PR_STATE);
1567 /* Cancel the arg */
1571 /* Get a direction (or abort) */
1572 if (get_rep_dir(&dir,TRUE))
1577 y = p_ptr->y + ddy[dir];
1578 x = p_ptr->x + ddx[dir];
1579 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1581 /* Feature code (applying "mimic" field) */
1582 feat = get_feat_mimic(g_ptr);
1584 /* Check for chests */
1585 o_idx = chest_check(y, x, TRUE);
1588 if (!is_trap(feat) && !o_idx)
1590 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1593 /* Monster in the way */
1594 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1596 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1605 more = do_cmd_disarm_chest(y, x, o_idx);
1611 more = do_cmd_disarm_aux(y, x, dir);
1615 /* Cancel repeat unless told not to */
1616 if (!more) disturb(FALSE, FALSE);
1621 * @brief 「打ち破る」動作コマンドのサブルーチン /
1622 * Perform the basic "bash" command
1623 * @param y 対象を行うマスのY座標
1624 * @param x 対象を行うマスのX座標
1625 * @param dir プレイヤーから見たターゲットの方角ID
1626 * @return 実際に処理が行われた場合TRUEを返す。
1629 * Assume destination is a closed/locked/jammed door
1630 * Assume there is no monster blocking the destination
1631 * Returns TRUE if repeated commands may continue
1634 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1636 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1639 feature_type *f_ptr = &f_info[g_ptr->feat];
1641 /* Hack -- Bash power based on strength */
1642 /* (Ranges from 3 to 20 to 100 to 200) */
1643 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1645 /* Extract door power */
1646 int temp = f_ptr->power;
1650 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1652 take_turn(p_ptr, 100);
1654 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1656 /* Compare bash power to door power */
1657 temp = (bash - (temp * 10));
1659 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1661 /* Hack -- always have a chance */
1662 if (temp < 1) temp = 1;
1664 /* Hack -- attempt to bash down the door */
1665 if (randint0(100) < temp)
1667 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1669 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1671 /* Break down the door */
1672 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1674 cave_alter_feat(y, x, FF_BASH);
1680 cave_alter_feat(y, x, FF_OPEN);
1683 /* Hack -- Fall through the door */
1684 move_player(dir, FALSE, FALSE);
1687 /* Saving throw against stun */
1688 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1691 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1693 /* Allow repeated bashing */
1697 /* High dexterity yields coolness */
1700 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1702 /* Hack -- Lose balance ala paralysis */
1703 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1710 * @brief 「打ち破る」動作コマンドのメインルーチン /
1711 * Bash open a door, success based on character strength
1715 * For a closed door, pval is positive if locked; negative if stuck.
1717 * For an open door, pval is positive for a broken door.
1719 * A closed door can be opened - harder if locked. Any door might be
1720 * bashed open (and thereby broken). Bashing a door is (potentially)
1721 * faster! You move into the door way. To open a stuck door, it must
1722 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1724 * Creatures can also open or bash doors, see elsewhere.
1727 void do_cmd_bash(void)
1733 if (p_ptr->wild_mode) return;
1735 if (p_ptr->special_defense & KATA_MUSOU)
1737 set_action(ACTION_NONE);
1740 /* Allow repeated command */
1743 /* Set repeat count */
1744 command_rep = command_arg - 1;
1745 p_ptr->redraw |= (PR_STATE);
1747 /* Cancel the arg */
1751 /* Get a "repeated" direction */
1752 if (get_rep_dir(&dir,FALSE))
1757 y = p_ptr->y + ddy[dir];
1758 x = p_ptr->x + ddx[dir];
1760 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1762 /* Feature code (applying "mimic" field) */
1763 feat = get_feat_mimic(g_ptr);
1765 /* Nothing useful */
1766 if (!have_flag(f_info[feat].flags, FF_BASH))
1768 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1771 /* Monster in the way */
1772 else if (g_ptr->m_idx)
1774 take_turn(p_ptr, 100);
1776 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1782 /* Bash a closed door */
1786 more = do_cmd_bash_aux(y, x, dir);
1790 /* Unless valid action taken, cancel bash */
1791 if (!more) disturb(FALSE, FALSE);
1796 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1800 * Manipulate an adjacent grid in some way
1802 * Attack monsters, tunnel through walls, disarm traps, open doors.
1804 * Consider confusion
1806 * This command must always take a current_world_ptr->game_turn, to prevent free detection
1807 * of invisible monsters.
1810 void do_cmd_alter(void)
1817 if (p_ptr->special_defense & KATA_MUSOU)
1819 set_action(ACTION_NONE);
1822 /* Allow repeated command */
1825 /* Set repeat count */
1826 command_rep = command_arg - 1;
1827 p_ptr->redraw |= (PR_STATE);
1829 /* Cancel the arg */
1833 /* Get a direction */
1834 if (get_rep_dir(&dir,TRUE))
1837 feature_type *f_ptr;
1839 y = p_ptr->y + ddy[dir];
1840 x = p_ptr->x + ddx[dir];
1842 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1844 /* Feature code (applying "mimic" field) */
1845 feat = get_feat_mimic(g_ptr);
1846 f_ptr = &f_info[feat];
1848 take_turn(p_ptr, 100);
1856 else if (have_flag(f_ptr->flags, FF_OPEN))
1858 more = do_cmd_open_aux(y, x);
1861 /* Bash jammed doors */
1862 else if (have_flag(f_ptr->flags, FF_BASH))
1864 more = do_cmd_bash_aux(y, x, dir);
1867 /* Tunnel through walls */
1868 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1870 more = do_cmd_tunnel_aux(y, x);
1873 /* Close open doors */
1874 else if (have_flag(f_ptr->flags, FF_CLOSE))
1876 more = do_cmd_close_aux(y, x);
1880 else if (have_flag(f_ptr->flags, FF_DISARM))
1882 more = do_cmd_disarm_aux(y, x, dir);
1887 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1891 /* Cancel repetition unless we can continue */
1892 if (!more) disturb(FALSE, FALSE);
1898 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1899 * Find the index of some "spikes", if possible.
1900 * @param ip くさびとして打てるオブジェクトのID
1901 * @return オブジェクトがある場合TRUEを返す
1904 * Let user choose a pile of spikes, perhaps?
1907 static bool get_spike(INVENTORY_IDX *ip)
1911 /* Check every item in the pack */
1912 for (i = 0; i < INVEN_PACK; i++)
1914 object_type *o_ptr = &inventory[i];
1916 /* Skip non-objects */
1917 if (!o_ptr->k_idx) continue;
1919 /* Check the "tval" code */
1920 if (o_ptr->tval == TV_SPIKE)
1922 /* Save the spike index */
1935 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1936 * Jam a closed door with a spike
1940 * This command may NOT be repeated
1943 void do_cmd_spike(void)
1947 if (p_ptr->wild_mode) return;
1949 if (p_ptr->special_defense & KATA_MUSOU)
1951 set_action(ACTION_NONE);
1954 /* Get a "repeated" direction */
1955 if (get_rep_dir(&dir, FALSE))
1962 y = p_ptr->y + ddy[dir];
1963 x = p_ptr->x + ddx[dir];
1964 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1966 /* Feature code (applying "mimic" field) */
1967 feat = get_feat_mimic(g_ptr);
1969 /* Require closed door */
1970 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1972 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1976 else if (!get_spike(&item))
1978 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1981 /* Is a monster in the way? */
1982 else if (g_ptr->m_idx)
1984 take_turn(p_ptr, 100);
1986 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1995 take_turn(p_ptr, 100);
1997 /* Successful jamming */
1998 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1999 cave_alter_feat(y, x, FF_SPIKE);
2001 /* Use up, and describe, a single spike, from the bottom */
2002 inven_item_increase(item, -1);
2003 inven_item_describe(item);
2004 inven_item_optimize(item);
2012 * @brief 「歩く」動作コマンドのメインルーチン /
2013 * Support code for the "Walk" and "Jump" commands
2014 * @param pickup アイテムの自動拾いを行うならTRUE
2017 void do_cmd_walk(bool pickup)
2024 /* Allow repeated command */
2027 /* Set repeat count */
2028 command_rep = command_arg - 1;
2029 p_ptr->redraw |= (PR_STATE);
2031 /* Cancel the arg */
2035 /* Get a "repeated" direction */
2036 if (get_rep_dir(&dir, FALSE))
2038 take_turn(p_ptr, 100);
2040 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2042 set_action(ACTION_NONE);
2045 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2046 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2047 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2049 /* Actually move the character */
2050 move_player(dir, pickup, FALSE);
2052 /* Allow more walking */
2056 /* Hack again -- Is there a special encounter ??? */
2057 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2059 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2062 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2064 /* Inform the player of his horrible fate :=) */
2065 msg_print(_("襲撃だ!", "You are ambushed !"));
2067 /* Go into large wilderness view */
2068 p_ptr->oldpy = randint1(MAX_HGT-2);
2069 p_ptr->oldpx = randint1(MAX_WID-2);
2072 /* Give first move to monsters */
2073 take_turn(p_ptr, 100);
2075 /* HACk -- set the encouter flag for the wilderness generation */
2076 generate_encounter = TRUE;
2080 /* Cancel repeat unless we may continue */
2081 if (!more) disturb(FALSE, FALSE);
2086 * @brief 「走る」動作コマンドのメインルーチン /
2090 void do_cmd_run(void)
2093 if (cmd_limit_confused(p_ptr)) return;
2095 if (p_ptr->special_defense & KATA_MUSOU)
2097 set_action(ACTION_NONE);
2100 /* Get a "repeated" direction */
2101 if (get_rep_dir(&dir,FALSE))
2103 /* Hack -- Set the run counter */
2104 running = (command_arg ? command_arg : 1000);
2113 * @brief 「留まる」動作コマンドのメインルーチン /
2114 * Stay still. Search. Enter stores.
2115 * Pick up treasure if "pickup" is true.
2116 * @param pickup アイテムの自動拾いを行うならTRUE
2119 void do_cmd_stay(bool pickup)
2121 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2123 /* Allow repeated command */
2126 /* Set repeat count */
2127 command_rep = command_arg - 1;
2128 p_ptr->redraw |= (PR_STATE);
2130 /* Cancel the arg */
2134 take_turn(p_ptr, 100);
2136 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2137 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2142 * @brief 「休む」動作コマンドのメインルーチン /
2143 * Resting allows a player to safely restore his hp -RAK-
2146 void do_cmd_rest(void)
2149 set_action(ACTION_NONE);
2151 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2153 stop_singing(p_ptr);
2157 if (hex_spelling_any()) stop_hex_spell_all();
2159 /* Prompt for time if needed */
2160 if (command_arg <= 0)
2162 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2163 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2169 strcpy(out_val, "&");
2171 /* Ask for duration */
2172 if (!get_string(p, out_val, 4)) return;
2174 /* Rest until done */
2175 if (out_val[0] == '&')
2177 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2181 else if (out_val[0] == '*')
2183 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2189 command_arg = (COMMAND_ARG)atoi(out_val);
2190 if (command_arg <= 0) return;
2196 if (command_arg > 9999) command_arg = 9999;
2198 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2200 /* Take a current_world_ptr->game_turn (?) */
2201 take_turn(p_ptr, 100);
2203 /* The sin of sloth */
2204 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2206 /* Why are you sleeping when there's no need? WAKE UP!*/
2207 if ((p_ptr->chp == p_ptr->mhp) &&
2208 (p_ptr->csp == p_ptr->msp) &&
2209 !p_ptr->blind && !p_ptr->confused &&
2210 !p_ptr->poisoned && !p_ptr->afraid &&
2211 !p_ptr->stun && !p_ptr->cut &&
2212 !p_ptr->slow && !p_ptr->paralyzed &&
2213 !p_ptr->image && !p_ptr->word_recall &&
2214 !p_ptr->alter_reality)
2215 chg_virtue(V_DILIGENCE, -1);
2217 /* Save the rest code */
2218 p_ptr->resting = command_arg;
2219 p_ptr->action = ACTION_REST;
2220 p_ptr->update |= (PU_BONUS);
2221 update_creature(p_ptr);
2223 p_ptr->redraw |= (PR_STATE);
2232 * @brief 射撃処理のメインルーチン
2235 void do_cmd_fire(SPELL_IDX snipe_type)
2238 object_type *j_ptr, *ammo_ptr;
2241 if(p_ptr->wild_mode) return;
2243 is_fired = FALSE; /* not fired yet */
2245 /* Get the "bow" (if any) */
2246 j_ptr = &inventory[INVEN_BOW];
2248 /* Require a launcher */
2251 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2256 if (j_ptr->sval == SV_CRIMSON)
2258 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2263 if (j_ptr->sval == SV_HARP)
2265 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2271 if (p_ptr->special_defense & KATA_MUSOU)
2273 set_action(ACTION_NONE);
2276 /* Require proper missile */
2277 item_tester_tval = p_ptr->tval_ammo;
2279 q = _("どれを撃ちますか? ", "Fire which item? ");
2280 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2283 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2291 exe_fire(item, j_ptr, snipe_type);
2293 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2295 /* Sniper actions after some shootings */
2296 if (snipe_type == SP_AWAY)
2298 teleport_player(10 + (p_ptr->concent * 2), 0L);
2300 if (snipe_type == SP_FINAL)
2302 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2303 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2304 (void)set_stun(p_ptr->stun + randint1(25));
2310 * @brief 投射処理メインルーチン /
2311 * Throw an object from the pack or floor.
2313 * @param boomerang ブーメラン処理ならばTRUE
2314 * @param shuriken 忍者の手裏剣処理ならばTRUE
2315 * @return ターンを消費した場合TRUEを返す
2318 * Note: "unseen" monsters are very hard to hit.
2320 * Should throwing a weapon do full damage? Should it allow the magic
2321 * to hit bonus of the weapon to have an effect? Should it ever cause
2322 * the item to be destroyed? Should it do any damage at all?
2325 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2330 POSITION y, x, ty, tx, prev_y, prev_x;
2331 POSITION ny[19], nx[19];
2332 int chance, tdam, tdis;
2333 int mul, div, dd, ds;
2334 int cur_dis, visible;
2341 bool hit_body = FALSE;
2342 bool hit_wall = FALSE;
2343 bool equiped_item = FALSE;
2344 bool return_when_thrown = FALSE;
2346 GAME_TEXT o_name[MAX_NLEN];
2348 int msec = delay_factor * delay_factor * delay_factor;
2350 BIT_FLAGS flgs[TR_FLAG_SIZE];
2352 bool come_back = FALSE;
2353 bool do_drop = TRUE;
2355 if (p_ptr->wild_mode) return FALSE;
2357 if (p_ptr->special_defense & KATA_MUSOU)
2359 set_action(ACTION_NONE);
2365 o_ptr = &inventory[item];
2369 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2371 item_tester_hook = item_tester_hook_boomerang;
2372 q = _("どの武器を投げますか? ", "Throw which item? ");
2373 s = _("投げる武器がない。", "You have nothing to throw.");
2374 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2381 else if (has_melee_weapon(INVEN_LARM))
2384 o_ptr = &inventory[item];
2389 o_ptr = &inventory[item];
2394 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2395 s = _("投げるアイテムがない。", "You have nothing to throw.");
2396 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2404 /* Item is cursed */
2405 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2407 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2411 if (p_ptr->inside_arena && !boomerang)
2413 if (o_ptr->tval != TV_SPIKE)
2415 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2424 /* Obtain a local object */
2425 object_copy(q_ptr, o_ptr);
2427 /* Extract the thrown object's flags. */
2428 object_flags(q_ptr, flgs);
2429 torch_flags(q_ptr, flgs);
2431 /* Distribute the charges of rods/wands between the stacks */
2432 distribute_charges(o_ptr, q_ptr, 1);
2437 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2439 if (p_ptr->mighty_throw) mult += 3;
2441 /* Extract a "distance multiplier" */
2442 /* Changed for 'launcher' mutation */
2443 mul = 10 + 2 * (mult - 1);
2445 /* Enforce a minimum "weight" of one pound */
2446 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2447 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2449 /* Hack -- Distance -- Reward strength, penalize weight */
2450 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2452 /* Max distance of 10-18 */
2453 if (tdis > mul) tdis = mul;
2457 ty = randint0(101) - 50 + p_ptr->y;
2458 tx = randint0(101) - 50 + p_ptr->x;
2462 project_length = tdis + 1;
2464 /* Get a direction (or cancel) */
2465 if (!get_aim_dir(&dir)) return FALSE;
2467 /* Predict the "target" location */
2468 tx = p_ptr->x + 99 * ddx[dir];
2469 ty = p_ptr->y + 99 * ddy[dir];
2471 /* Check for "target request" */
2472 if ((dir == 5) && target_okay())
2478 project_length = 0; /* reset to default */
2481 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2482 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2483 return_when_thrown = TRUE;
2485 /* Reduce and describe inventory */
2488 inven_item_increase(item, -1);
2489 if (!return_when_thrown)
2490 inven_item_describe(item);
2491 inven_item_optimize(item);
2494 /* Reduce and describe floor item */
2497 floor_item_increase(0 - item, -1);
2498 floor_item_optimize(0 - item);
2500 if (item >= INVEN_RARM)
2502 equiped_item = TRUE;
2503 p_ptr->redraw |= (PR_EQUIPPY);
2506 take_turn(p_ptr, 100);
2508 /* Rogue and Ninja gets bonus */
2509 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2510 p_ptr->energy_use -= p_ptr->lev;
2512 /* Start at the player */
2518 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2519 else shuriken = FALSE;
2521 /* Chance of hitting */
2522 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2523 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2524 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2526 if (shuriken) chance *= 2;
2531 /* Travel until stopped */
2532 for (cur_dis = 0; cur_dis <= tdis; )
2534 /* Hack -- Stop at the target */
2535 if ((y == ty) && (x == tx)) break;
2537 /* Calculate the new location (see "project()") */
2540 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2542 /* Stopped by walls/doors */
2543 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2546 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;
2549 /* The player can see the (on screen) missile */
2550 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2552 SYMBOL_CODE c = object_char(q_ptr);
2553 TERM_COLOR a = object_attr(q_ptr);
2555 /* Draw, Hilite, Fresh, Pause, Erase */
2556 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2557 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2559 Term_xtra(TERM_XTRA_DELAY, msec);
2560 lite_spot(ny[cur_dis], nx[cur_dis]);
2564 /* The player cannot see the missile */
2567 /* Pause anyway, for consistancy */
2568 Term_xtra(TERM_XTRA_DELAY, msec);
2574 /* Save the new location */
2578 /* Advance the distance */
2581 /* Monster here, Try to hit it */
2582 if (current_floor_ptr->grid_array[y][x].m_idx)
2584 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2585 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2587 /* Check the visibility */
2588 visible = m_ptr->ml;
2590 /* Note the collision */
2593 /* Did we hit it (penalize range) */
2594 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2598 /* Handle unseen monster */
2601 /* Invisible monster */
2602 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2605 /* Handle visible monster */
2608 GAME_TEXT m_name[MAX_NLEN];
2609 monster_desc(m_name, m_ptr, 0);
2610 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2614 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2615 health_track(g_ptr->m_idx);
2619 /* Hack -- Base damage from thrown object */
2622 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2623 tdam = damroll(dd, ds);
2624 /* Apply special damage */
2625 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2626 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2627 if (q_ptr->to_d > 0)
2628 tdam += q_ptr->to_d;
2630 tdam += -q_ptr->to_d;
2634 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2635 tdam += p_ptr->to_d_m;
2637 else if (have_flag(flgs, TR_THROW))
2640 tdam += p_ptr->to_d_m;
2648 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2651 /* No negative damage */
2652 if (tdam < 0) tdam = 0;
2654 /* Modify the damage */
2655 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2657 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2658 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2660 /* Hit the monster, check for death */
2661 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2669 message_pain(g_ptr->m_idx, tdam);
2671 /* Anger the monster */
2672 if ((tdam > 0) && !object_is_potion(q_ptr))
2673 anger_monster(m_ptr);
2675 if (fear && m_ptr->ml)
2678 GAME_TEXT m_name[MAX_NLEN];
2679 monster_desc(m_name, m_ptr, 0);
2680 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2690 /* decrease toach's fuel */
2691 if (hit_body) torch_lost_fuel(q_ptr);
2693 /* Chance of breakage (during attacks) */
2694 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2696 /* Figurines transform */
2697 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2701 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2702 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2703 else if (object_is_cursed(q_ptr))
2704 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2709 /* Potions smash open */
2710 if (object_is_potion(q_ptr))
2712 if (hit_body || hit_wall || (randint1(100) < j))
2714 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2716 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2718 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2720 /* ToDo (Robert): fix the invulnerability */
2721 if (current_floor_ptr->grid_array[y][x].m_idx &&
2722 is_friendly(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]) &&
2723 !MON_INVULNER(m_ptr))
2725 GAME_TEXT m_name[MAX_NLEN];
2726 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
2727 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2728 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2739 if (return_when_thrown)
2741 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2742 char o2_name[MAX_NLEN];
2743 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2746 if (boomerang) back_chance += 4+randint1(5);
2747 if (super_boomerang) back_chance += 100;
2748 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2750 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2752 for (i = cur_dis - 1; i > 0; i--)
2754 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2756 char c = object_char(q_ptr);
2757 byte a = object_attr(q_ptr);
2759 /* Draw, Hilite, Fresh, Pause, Erase */
2760 print_rel(c, a, ny[i], nx[i]);
2761 move_cursor_relative(ny[i], nx[i]);
2763 Term_xtra(TERM_XTRA_DELAY, msec);
2764 lite_spot(ny[i], nx[i]);
2769 /* Pause anyway, for consistancy */
2770 Term_xtra(TERM_XTRA_DELAY, msec);
2773 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2775 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2782 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2786 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2794 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2800 if (item == INVEN_RARM || item == INVEN_LARM)
2802 /* Access the wield slot */
2803 o_ptr = &inventory[item];
2805 /* Wear the new stuff */
2806 object_copy(o_ptr, q_ptr);
2808 p_ptr->total_weight += q_ptr->weight;
2810 /* Increment the equip counter by hand */
2813 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2814 p_ptr->window |= (PW_EQUIP);
2822 else if (equiped_item)
2830 if (cave_have_flag_bold(y, x, FF_PROJECT))
2832 (void)drop_near(q_ptr, j, y, x);
2836 (void)drop_near(q_ptr, j, prev_y, prev_x);