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"
30 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
31 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
32 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
34 bool confirm_leave_level(bool down_stair)
36 quest_type *q_ptr = &quest[p_ptr->inside_quest];
38 /* Confirm leaving from once only quest */
39 if (confirm_quest && p_ptr->inside_quest &&
40 (q_ptr->type == QUEST_TYPE_RANDOM ||
41 (q_ptr->flags & QUEST_FLAG_ONCE &&
42 q_ptr->status != QUEST_STATUS_COMPLETED) ||
43 (q_ptr->flags & QUEST_FLAG_TOWER &&
44 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
45 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
47 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
48 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
58 * @brief 魔法系コマンドが制限されているかを返す。
59 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
61 bool cmd_limit_cast(player_type *creature_ptr)
63 if (dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
65 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
69 else if (creature_ptr->anti_magic)
71 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
74 else if (creature_ptr->shero)
76 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
83 bool cmd_limit_confused(player_type *creature_ptr)
85 if (creature_ptr->confused)
87 msg_print(_("混乱していてできない!", "You are too confused!"));
93 bool cmd_limit_arena(player_type *creature_ptr)
95 if (creature_ptr->inside_arena)
97 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
104 bool cmd_limit_blind(player_type *creature_ptr)
106 if (creature_ptr->blind)
108 msg_print(_("目が見えない。", "You can't see anything."));
113 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
119 bool cmd_limit_time_walk(player_type *creature_ptr)
121 if (creature_ptr->timewalk)
123 if (flush_failure) flush();
124 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
132 * @brief 階段を使って階層を昇る処理 / Go up one level
135 void do_cmd_go_up(void)
140 grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
141 feature_type *f_ptr = &f_info[g_ptr->feat];
145 if (p_ptr->special_defense & KATA_MUSOU)
147 set_action(ACTION_NONE);
151 if (!have_flag(f_ptr->flags, FF_LESS))
153 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
157 /* Quest up stairs */
158 if (have_flag(f_ptr->flags, FF_QUEST))
160 /* Cancel the command */
161 if (!confirm_leave_level(FALSE)) return;
165 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
166 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
168 msg_print(_("上の階に登った。", "You enter the up staircase."));
172 p_ptr->inside_quest = g_ptr->special;
174 /* Activate the quest */
175 if (!quest[p_ptr->inside_quest].status)
177 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
179 init_flags = INIT_ASSIGN;
180 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
182 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
185 /* Leaving a quest */
186 if (!p_ptr->inside_quest)
192 p_ptr->leaving = TRUE;
197 take_turn(p_ptr, 100);
199 /* End the command */
209 go_up = confirm_leave_level(FALSE);
212 /* Cancel the command */
215 take_turn(p_ptr, 100);
217 if (autosave_l) do_cmd_save_game(TRUE);
219 /* For a random quest */
220 if (p_ptr->inside_quest &&
221 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
225 p_ptr->inside_quest = 0;
228 /* For a fixed quest */
229 if (p_ptr->inside_quest &&
230 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
234 p_ptr->inside_quest = g_ptr->special;
239 /* For normal dungeon and random quest */
243 if (have_flag(f_ptr->flags, FF_SHAFT))
245 /* Create a way back */
246 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
252 /* Create a way back */
253 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
258 /* Get out from current dungeon */
259 if (dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
262 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
265 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
266 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
267 else if (up_num == dun_level)
268 msg_print(_("地上に戻った。", "You go back to the surface."));
270 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
273 p_ptr->leaving = TRUE;
278 * @brief 階段を使って階層を降りる処理 / Go down one level
281 void do_cmd_go_down(void)
284 grid_type *g_ptr = &grid_array[p_ptr->y][p_ptr->x];
285 feature_type *f_ptr = &f_info[g_ptr->feat];
287 bool fall_trap = FALSE;
290 if (p_ptr->special_defense & KATA_MUSOU)
292 set_action(ACTION_NONE);
296 if (!have_flag(f_ptr->flags, FF_MORE))
298 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
302 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
305 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
310 /* Quest down stairs */
311 else if (have_flag(f_ptr->flags, FF_QUEST))
313 /* Confirm Leaving */
314 if(!confirm_leave_level(TRUE)) return;
316 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
317 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
319 msg_print(_("下の階に降りた。", "You enter the down staircase."));
324 p_ptr->inside_quest = g_ptr->special;
326 /* Activate the quest */
327 if (!quest[p_ptr->inside_quest].status)
329 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
331 init_flags = INIT_ASSIGN;
332 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
334 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
337 /* Leaving a quest */
338 if (!p_ptr->inside_quest)
344 p_ptr->leaving = TRUE;
348 take_turn(p_ptr, 100);
353 DUNGEON_IDX target_dungeon = 0;
357 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
359 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
361 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
364 if (!max_dlv[target_dungeon])
366 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
367 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
368 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
371 /* Save old player position */
372 p_ptr->oldpx = p_ptr->x;
373 p_ptr->oldpy = p_ptr->y;
374 p_ptr->dungeon_idx = target_dungeon;
377 * Clear all saved floors
378 * and create a first saved floor
380 prepare_change_floor_mode(CFM_FIRST_FLOOR);
383 take_turn(p_ptr, 100);
385 if (autosave_l) do_cmd_save_game(TRUE);
388 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
393 /* Enter the dungeon just now */
394 p_ptr->enter_dungeon = TRUE;
395 down_num = d_info[p_ptr->dungeon_idx].mindepth;
400 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
401 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
406 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
413 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
417 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
418 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
420 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
426 p_ptr->leaving = TRUE;
430 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
434 if (have_flag(f_ptr->flags, FF_SHAFT))
436 /* Create a way back */
437 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
441 /* Create a way back */
442 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
450 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
453 void do_cmd_search(void)
455 /* Allow repeated command */
458 /* Set repeat count */
459 command_rep = command_arg - 1;
460 p_ptr->redraw |= (PR_STATE);
465 take_turn(p_ptr, 100);;
473 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
474 * @param y 走査対象にしたいマスのY座標
475 * @param x 走査対象にしたいマスのX座標
476 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
477 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
479 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
481 grid_type *g_ptr = &grid_array[y][x];
482 OBJECT_IDX this_o_idx, next_o_idx = 0;
484 /* Scan all objects in the grid */
485 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
489 o_ptr = &o_list[this_o_idx];
490 next_o_idx = o_ptr->next_o_idx;
492 /* Skip unknown chests XXX XXX */
493 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
495 /* Check for non empty chest */
496 if ((o_ptr->tval == TV_CHEST) &&
497 (((!trapped) && (o_ptr->pval)) || /* non empty */
498 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
507 * @brief 箱を開けるコマンドのメインルーチン /
508 * Attempt to open the given chest at the given location
509 * @param y 箱の存在するマスのY座標
510 * @param x 箱の存在するマスのX座標
511 * @param o_idx 箱のオブジェクトID
512 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
514 * Assume there is no monster blocking the destination
516 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
521 object_type *o_ptr = &o_list[o_idx];
523 take_turn(p_ptr, 100);;
525 /* Attempt to unlock it */
528 /* Assume locked, and thus not open */
531 /* Get the "disarm" factor */
532 i = p_ptr->skill_dis;
534 /* Penalize some conditions */
535 if (p_ptr->blind || no_lite()) i = i / 10;
536 if (p_ptr->confused || p_ptr->image) i = i / 10;
538 /* Extract the difficulty */
541 /* Always have a small chance of success */
544 /* Success -- May still have traps */
545 if (randint0(100) < j)
547 msg_print(_("鍵をはずした。", "You have picked the lock."));
552 /* Failure -- Keep trying */
555 /* We may continue repeating */
557 if (flush_failure) flush();
558 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
563 /* Allowed to open */
566 /* Apply chest traps, if any */
567 chest_trap(y, x, o_idx);
569 /* Let the Chest drop items */
570 chest_death(FALSE, y, x, o_idx);
576 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
577 * Attempt to open the given chest at the given location
578 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
579 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
580 * @param test 地形条件を判定するための関数ポインタ
581 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
583 * @details Return the number of features around (or under) the character.
584 * Usually look for doors and floor traps.
586 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
592 /* Count how many matches */
595 /* Check around (and under) the character */
596 for (d = 0; d < 9; d++)
601 /* if not searching under player continue */
602 if ((d == 8) && !under) continue;
604 /* Extract adjacent (legal) location */
605 yy = p_ptr->y + ddy_ddd[d];
606 xx = p_ptr->x + ddx_ddd[d];
608 /* Get the grid_array */
609 g_ptr = &grid_array[yy][xx];
611 /* Must have knowledge */
612 if (!(g_ptr->info & (CAVE_MARK))) continue;
614 /* Feature code (applying "mimic" field) */
615 feat = get_feat_mimic(g_ptr);
617 /* Not looking for this feature */
618 if (!((*test)(feat))) continue;
623 /* Remember the location. Only useful if only one match */
634 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
635 * Return the number of chests around (or under) the character.
636 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
637 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
638 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
641 * If requested, count only trapped chests.
643 static int count_chests(POSITION *y, POSITION *x, bool trapped)
650 /* Count how many matches */
653 /* Check around (and under) the character */
654 for (d = 0; d < 9; d++)
656 /* Extract adjacent (legal) location */
657 POSITION yy = p_ptr->y + ddy_ddd[d];
658 POSITION xx = p_ptr->x + ddx_ddd[d];
660 /* No (visible) chest is there */
661 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
663 /* Grab the object */
664 o_ptr = &o_list[o_idx];
667 if (o_ptr->pval == 0) continue;
669 /* No (known) traps here */
670 if (trapped && (!object_is_known(o_ptr) ||
671 !chest_traps[o_ptr->pval])) continue;
676 /* Remember the location. Only useful if only one match */
688 * @brief 「開ける」動作コマンドのサブルーチン /
689 * Perform the basic "open" command on doors
690 * @param y 対象を行うマスのY座標
691 * @param x 対象を行うマスのX座標
692 * @return 実際に処理が行われた場合TRUEを返す。
694 * Assume destination is a closed/locked/jammed door
695 * Assume there is no monster blocking the destination
696 * Returns TRUE if repeated commands may continue
698 static bool do_cmd_open_aux(POSITION y, POSITION x)
702 /* Get requested grid */
703 grid_type *g_ptr = &grid_array[y][x];
704 feature_type *f_ptr = &f_info[g_ptr->feat];
707 take_turn(p_ptr, 100);;
709 /* Seeing true feature code (ignore mimic) */
712 if (!have_flag(f_ptr->flags, FF_OPEN))
715 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
719 else if (f_ptr->power)
722 i = p_ptr->skill_dis;
724 /* Penalize some conditions */
725 if (p_ptr->blind || no_lite()) i = i / 10;
726 if (p_ptr->confused || p_ptr->image) i = i / 10;
728 /* Extract the lock power */
731 /* Extract the difficulty */
734 /* Always have a small chance of success */
738 if (randint0(100) < j)
740 msg_print(_("鍵をはずした。", "You have picked the lock."));
743 cave_alter_feat(y, x, FF_OPEN);
745 sound(SOUND_OPENDOOR);
755 if (flush_failure) flush();
757 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
759 /* We may keep trying */
768 cave_alter_feat(y, x, FF_OPEN);
770 sound(SOUND_OPENDOOR);
776 * @brief 「開ける」コマンドのメインルーチン /
777 * Open a closed/locked/jammed door or a closed/locked chest.
780 * Unlocking a locked door/chest is worth one experience point.
782 void do_cmd_open(void)
790 if (p_ptr->wild_mode) return;
792 if (p_ptr->special_defense & KATA_MUSOU)
794 set_action(ACTION_NONE);
797 /* Option: Pick a direction */
800 int num_doors, num_chests;
802 /* Count closed doors (locked or jammed) */
803 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
805 /* Count chests (locked) */
806 num_chests = count_chests(&y, &x, FALSE);
808 /* See if only one target */
809 if (num_doors || num_chests)
811 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
813 if (!too_many) command_dir = coords_to_dir(y, x);
817 /* Allow repeated command */
820 /* Set repeat count */
821 command_rep = command_arg - 1;
822 p_ptr->redraw |= (PR_STATE);
828 /* Get a "repeated" direction */
829 if (get_rep_dir(&dir, TRUE))
834 /* Get requested location */
835 y = p_ptr->y + ddy[dir];
836 x = p_ptr->x + ddx[dir];
838 /* Get requested grid */
839 g_ptr = &grid_array[y][x];
841 /* Feature code (applying "mimic" field) */
842 feat = get_feat_mimic(g_ptr);
844 /* Check for chest */
845 o_idx = chest_check(y, x, FALSE);
848 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
850 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
853 /* Monster in the way */
854 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
856 take_turn(p_ptr, 100);;
857 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
865 more = do_cmd_open_chest(y, x, o_idx);
872 more = do_cmd_open_aux(y, x);
876 /* Cancel repeat unless we may continue */
877 if (!more) disturb(FALSE, FALSE);
883 * @brief 「閉じる」動作コマンドのサブルーチン /
884 * Perform the basic "close" command
885 * @param y 対象を行うマスのY座標
886 * @param x 対象を行うマスのX座標
887 * @return 実際に処理が行われた場合TRUEを返す。
889 * Assume destination is an open/broken door
890 * Assume there is no monster blocking the destination
891 * Returns TRUE if repeated commands may continue
893 static bool do_cmd_close_aux(POSITION y, POSITION x)
895 grid_type *g_ptr = &grid_array[y][x];
896 FEAT_IDX old_feat = g_ptr->feat;
899 take_turn(p_ptr, 100);;
901 /* Seeing true feature code (ignore mimic) */
904 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
906 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
908 /* Hack -- object in the way */
909 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
910 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
912 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
917 cave_alter_feat(y, x, FF_CLOSE);
920 if (old_feat == g_ptr->feat)
922 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
926 sound(SOUND_SHUTDOOR);
935 * @brief 「閉じる」コマンドのメインルーチン /
936 * Close an open door.
939 * Unlocking a locked door/chest is worth one experience point.
941 void do_cmd_close(void)
948 if (p_ptr->wild_mode) return;
950 if (p_ptr->special_defense & KATA_MUSOU)
952 set_action(ACTION_NONE);
955 /* Option: Pick a direction */
958 /* Count open doors */
959 if (count_dt(&y, &x, is_open, FALSE) == 1)
961 command_dir = coords_to_dir(y, x);
965 /* Allow repeated command */
968 /* Set repeat count */
969 command_rep = command_arg - 1;
970 p_ptr->redraw |= (PR_STATE);
976 /* Get a "repeated" direction */
977 if (get_rep_dir(&dir, FALSE))
982 y = p_ptr->y + ddy[dir];
983 x = p_ptr->x + ddx[dir];
984 g_ptr = &grid_array[y][x];
986 /* Feature code (applying "mimic" field) */
987 feat = get_feat_mimic(g_ptr);
989 /* Require open/broken door */
990 if (!have_flag(f_info[feat].flags, FF_CLOSE))
992 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
995 /* Monster in the way */
996 else if (g_ptr->m_idx)
998 take_turn(p_ptr, 100);;
1000 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1006 /* Close the door */
1009 /* Close the door */
1010 more = do_cmd_close_aux(y, x);
1014 /* Cancel repeat unless we may continue */
1015 if (!more) disturb(FALSE, FALSE);
1020 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1021 * Determine if a given grid may be "tunneled"
1022 * @param y 対象を行うマスのY座標
1023 * @param x 対象を行うマスのX座標
1026 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1028 grid_type *g_ptr = &grid_array[y][x];
1030 /* Must have knowledge */
1031 if (!(g_ptr->info & CAVE_MARK))
1033 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1038 /* Must be a wall/door/etc */
1039 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1041 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1051 * @brief 「掘る」動作コマンドのサブルーチン /
1052 * Perform the basic "tunnel" command
1053 * @param y 対象を行うマスのY座標
1054 * @param x 対象を行うマスのX座標
1055 * @return 実際に処理が行われた場合TRUEを返す。
1057 * Assumes that no monster is blocking the destination
1058 * Do not use twall anymore
1059 * Returns TRUE if repeated commands may continue
1061 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1064 feature_type *f_ptr, *mimic_f_ptr;
1069 /* Verify legality */
1070 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1072 take_turn(p_ptr, 100);;
1074 g_ptr = &grid_array[y][x];
1075 f_ptr = &f_info[g_ptr->feat];
1076 power = f_ptr->power;
1078 /* Feature code (applying "mimic" field) */
1079 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1081 name = f_name + mimic_f_ptr->name;
1085 if (have_flag(f_ptr->flags, FF_PERMANENT))
1088 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1090 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1093 /* Map border (mimiccing Permanent wall) */
1096 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1101 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1104 if (p_ptr->skill_dig > randint0(20 * power))
1106 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1108 /* Remove the feature */
1109 cave_alter_feat(y, x, FF_TUNNEL);
1111 /* Update some things */
1112 p_ptr->update |= (PU_FLOW);
1116 /* Message, keep digging */
1117 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1125 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1128 if (p_ptr->skill_dig > power + randint0(40 * power))
1130 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1133 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1134 p_ptr->update |= (PU_FLOW);
1137 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1139 /* Remove the feature */
1140 cave_alter_feat(y, x, FF_TUNNEL);
1142 chg_virtue(V_DILIGENCE, 1);
1143 chg_virtue(V_NATURE, -1);
1151 /* We may continue chopping */
1152 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1153 /* Occasional Search XXX XXX */
1154 if (randint0(100) < 25) search();
1158 /* We may continue tunelling */
1159 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1166 if (is_hidden_door(g_ptr))
1168 /* Occasional Search XXX XXX */
1169 if (randint0(100) < 25) search();
1176 * @brief 「掘る」動作コマンドのメインルーチン /
1177 * Tunnels through "walls" (including rubble and closed doors)
1181 * Note that you must tunnel in order to hit invisible monsters
1182 * in walls, though moving into walls still takes a turn anyway.
1184 * Digging is very difficult without a "digger" weapon, but can be
1185 * accomplished by strong players using heavy weapons.
1188 void do_cmd_tunnel(void)
1197 if (p_ptr->special_defense & KATA_MUSOU)
1199 set_action(ACTION_NONE);
1202 /* Allow repeated command */
1205 /* Set repeat count */
1206 command_rep = command_arg - 1;
1207 p_ptr->redraw |= (PR_STATE);
1209 /* Cancel the arg */
1213 /* Get a direction to tunnel, or Abort */
1214 if (get_rep_dir(&dir,FALSE))
1217 y = p_ptr->y + ddy[dir];
1218 x = p_ptr->x + ddx[dir];
1220 g_ptr = &grid_array[y][x];
1222 /* Feature code (applying "mimic" field) */
1223 feat = get_feat_mimic(g_ptr);
1225 /* No tunnelling through doors */
1226 if (have_flag(f_info[feat].flags, FF_DOOR))
1228 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1231 /* No tunnelling through most features */
1232 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1234 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1237 /* A monster is in the way */
1238 else if (g_ptr->m_idx)
1240 take_turn(p_ptr, 100);;
1242 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1251 /* Tunnel through walls */
1252 more = do_cmd_tunnel_aux(y, x);
1256 /* Cancel repetition unless we can continue */
1257 if (!more) disturb(FALSE, FALSE);
1261 * @brief 移動処理による簡易な「開く」処理 /
1263 * @return 開く処理が実際に試みられた場合TRUEを返す
1266 * If there is a jammed/closed/locked door at the given location,
1267 * then attempt to unlock/open it. Return TRUE if an attempt was
1268 * made (successful or not), otherwise return FALSE.
1270 * The code here should be nearly identical to that in
1271 * do_cmd_open_test() and do_cmd_open_aux().
1274 bool easy_open_door(POSITION y, POSITION x)
1278 grid_type *g_ptr = &grid_array[y][x];
1279 feature_type *f_ptr = &f_info[g_ptr->feat];
1281 /* Must be a closed door */
1282 if (!is_closed_door(g_ptr->feat))
1288 if (!have_flag(f_ptr->flags, FF_OPEN))
1291 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1296 else if (f_ptr->power)
1299 i = p_ptr->skill_dis;
1301 /* Penalize some conditions */
1302 if (p_ptr->blind || no_lite()) i = i / 10;
1303 if (p_ptr->confused || p_ptr->image) i = i / 10;
1305 /* Extract the lock power */
1308 /* Extract the difficulty */
1311 /* Always have a small chance of success */
1315 if (randint0(100) < j)
1317 msg_print(_("鍵をはずした。", "You have picked the lock."));
1320 cave_alter_feat(y, x, FF_OPEN);
1322 sound(SOUND_OPENDOOR);
1332 if (flush_failure) flush();
1334 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1343 cave_alter_feat(y, x, FF_OPEN);
1345 sound(SOUND_OPENDOOR);
1351 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1352 * Perform the basic "disarm" command
1353 * @param y 解除を行うマスのY座標
1354 * @param x 解除を行うマスのX座標
1355 * @param o_idx 箱のオブジェクトID
1356 * @return ターンを消費する処理が行われた場合TRUEを返す
1359 * Assume destination is a visible trap
1360 * Assume there is no monster blocking the destination
1361 * Returns TRUE if repeated commands may continue
1364 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1368 object_type *o_ptr = &o_list[o_idx];
1370 take_turn(p_ptr, 100);;
1372 /* Get the "disarm" factor */
1373 i = p_ptr->skill_dis;
1375 /* Penalize some conditions */
1376 if (p_ptr->blind || no_lite()) i = i / 10;
1377 if (p_ptr->confused || p_ptr->image) i = i / 10;
1379 /* Extract the difficulty */
1380 j = i - o_ptr->pval;
1382 /* Always have a small chance of success */
1385 /* Must find the trap first. */
1386 if (!object_is_known(o_ptr))
1388 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1392 /* Already disarmed/unlocked */
1393 else if (o_ptr->pval <= 0)
1395 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1398 /* No traps to find. */
1399 else if (!chest_traps[o_ptr->pval])
1401 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1404 /* Success (get a lot of experience) */
1405 else if (randint0(100) < j)
1407 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1408 gain_exp(o_ptr->pval);
1409 o_ptr->pval = (0 - o_ptr->pval);
1412 /* Failure -- Keep trying */
1413 else if ((i > 5) && (randint1(i) > 5))
1415 /* We may keep trying */
1417 if (flush_failure) flush();
1418 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1421 /* Failure -- Set off the trap */
1424 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1426 chest_trap(y, x, o_idx);
1433 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1434 * Perform the basic "disarm" command
1435 * @param y 解除を行うマスのY座標
1436 * @param x 解除を行うマスのX座標
1437 * @param dir プレイヤーからみた方向ID
1438 * @return ターンを消費する処理が行われた場合TRUEを返す
1441 * Assume destination is a visible trap
1442 * Assume there is no monster blocking the destination
1443 * Returns TRUE if repeated commands may continue
1447 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1449 grid_type *g_ptr = &grid_array[y][x];
1452 feature_type *f_ptr = &f_info[g_ptr->feat];
1454 /* Access trap name */
1455 concptr name = (f_name + f_ptr->name);
1457 /* Extract trap "power" */
1458 int power = f_ptr->power;
1461 /* Get the "disarm" factor */
1462 int i = p_ptr->skill_dis;
1465 take_turn(p_ptr, 100);;
1467 /* Penalize some conditions */
1468 if (p_ptr->blind || no_lite()) i = i / 10;
1469 if (p_ptr->confused || p_ptr->image) i = i / 10;
1471 /* Extract the difficulty */
1474 /* Always have a small chance of success */
1478 if (randint0(100) < j)
1480 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1485 /* Remove the trap */
1486 cave_alter_feat(y, x, FF_DISARM);
1488 /* Move the player onto the trap */
1489 move_player(dir, easy_disarm, FALSE);
1492 /* Failure -- Keep trying */
1493 else if ((i > 5) && (randint1(i) > 5))
1496 if (flush_failure) flush();
1498 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1500 /* We may keep trying */
1504 /* Failure -- Set off the trap */
1507 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1508 /* Move the player onto the trap */
1509 move_player(dir, easy_disarm, FALSE);
1516 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1517 * Disarms a trap, or chest
1520 void do_cmd_disarm(void)
1528 if (p_ptr->wild_mode) return;
1530 if (p_ptr->special_defense & KATA_MUSOU)
1532 set_action(ACTION_NONE);
1535 /* Option: Pick a direction */
1538 int num_traps, num_chests;
1540 /* Count visible traps */
1541 num_traps = count_dt(&y, &x, is_trap, TRUE);
1543 /* Count chests (trapped) */
1544 num_chests = count_chests(&y, &x, TRUE);
1546 /* See if only one target */
1547 if (num_traps || num_chests)
1549 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1550 if (!too_many) command_dir = coords_to_dir(y, x);
1555 /* Allow repeated command */
1558 /* Set repeat count */
1559 command_rep = command_arg - 1;
1560 p_ptr->redraw |= (PR_STATE);
1562 /* Cancel the arg */
1566 /* Get a direction (or abort) */
1567 if (get_rep_dir(&dir,TRUE))
1572 y = p_ptr->y + ddy[dir];
1573 x = p_ptr->x + ddx[dir];
1574 g_ptr = &grid_array[y][x];
1576 /* Feature code (applying "mimic" field) */
1577 feat = get_feat_mimic(g_ptr);
1579 /* Check for chests */
1580 o_idx = chest_check(y, x, TRUE);
1583 if (!is_trap(feat) && !o_idx)
1585 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1588 /* Monster in the way */
1589 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1591 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1600 more = do_cmd_disarm_chest(y, x, o_idx);
1606 more = do_cmd_disarm_aux(y, x, dir);
1610 /* Cancel repeat unless told not to */
1611 if (!more) disturb(FALSE, FALSE);
1616 * @brief 「打ち破る」動作コマンドのサブルーチン /
1617 * Perform the basic "bash" command
1618 * @param y 対象を行うマスのY座標
1619 * @param x 対象を行うマスのX座標
1620 * @param dir プレイヤーから見たターゲットの方角ID
1621 * @return 実際に処理が行われた場合TRUEを返す。
1624 * Assume destination is a closed/locked/jammed door
1625 * Assume there is no monster blocking the destination
1626 * Returns TRUE if repeated commands may continue
1629 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1631 grid_type *g_ptr = &grid_array[y][x];
1634 feature_type *f_ptr = &f_info[g_ptr->feat];
1636 /* Hack -- Bash power based on strength */
1637 /* (Ranges from 3 to 20 to 100 to 200) */
1638 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1640 /* Extract door power */
1641 int temp = f_ptr->power;
1645 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1647 take_turn(p_ptr, 100);;
1649 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1651 /* Compare bash power to door power */
1652 temp = (bash - (temp * 10));
1654 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1656 /* Hack -- always have a chance */
1657 if (temp < 1) temp = 1;
1659 /* Hack -- attempt to bash down the door */
1660 if (randint0(100) < temp)
1662 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1664 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1666 /* Break down the door */
1667 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1669 cave_alter_feat(y, x, FF_BASH);
1675 cave_alter_feat(y, x, FF_OPEN);
1678 /* Hack -- Fall through the door */
1679 move_player(dir, FALSE, FALSE);
1682 /* Saving throw against stun */
1683 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1686 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1688 /* Allow repeated bashing */
1692 /* High dexterity yields coolness */
1695 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1697 /* Hack -- Lose balance ala paralysis */
1698 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1705 * @brief 「打ち破る」動作コマンドのメインルーチン /
1706 * Bash open a door, success based on character strength
1710 * For a closed door, pval is positive if locked; negative if stuck.
1712 * For an open door, pval is positive for a broken door.
1714 * A closed door can be opened - harder if locked. Any door might be
1715 * bashed open (and thereby broken). Bashing a door is (potentially)
1716 * faster! You move into the door way. To open a stuck door, it must
1717 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1719 * Creatures can also open or bash doors, see elsewhere.
1722 void do_cmd_bash(void)
1728 if (p_ptr->wild_mode) return;
1730 if (p_ptr->special_defense & KATA_MUSOU)
1732 set_action(ACTION_NONE);
1735 /* Allow repeated command */
1738 /* Set repeat count */
1739 command_rep = command_arg - 1;
1740 p_ptr->redraw |= (PR_STATE);
1742 /* Cancel the arg */
1746 /* Get a "repeated" direction */
1747 if (get_rep_dir(&dir,FALSE))
1752 y = p_ptr->y + ddy[dir];
1753 x = p_ptr->x + ddx[dir];
1755 g_ptr = &grid_array[y][x];
1757 /* Feature code (applying "mimic" field) */
1758 feat = get_feat_mimic(g_ptr);
1760 /* Nothing useful */
1761 if (!have_flag(f_info[feat].flags, FF_BASH))
1763 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1766 /* Monster in the way */
1767 else if (g_ptr->m_idx)
1769 take_turn(p_ptr, 100);;
1771 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1777 /* Bash a closed door */
1781 more = do_cmd_bash_aux(y, x, dir);
1785 /* Unless valid action taken, cancel bash */
1786 if (!more) disturb(FALSE, FALSE);
1791 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1795 * Manipulate an adjacent grid in some way
1797 * Attack monsters, tunnel through walls, disarm traps, open doors.
1799 * Consider confusion
1801 * This command must always take a turn, to prevent free detection
1802 * of invisible monsters.
1805 void do_cmd_alter(void)
1812 if (p_ptr->special_defense & KATA_MUSOU)
1814 set_action(ACTION_NONE);
1817 /* Allow repeated command */
1820 /* Set repeat count */
1821 command_rep = command_arg - 1;
1822 p_ptr->redraw |= (PR_STATE);
1824 /* Cancel the arg */
1828 /* Get a direction */
1829 if (get_rep_dir(&dir,TRUE))
1832 feature_type *f_ptr;
1834 y = p_ptr->y + ddy[dir];
1835 x = p_ptr->x + ddx[dir];
1837 g_ptr = &grid_array[y][x];
1839 /* Feature code (applying "mimic" field) */
1840 feat = get_feat_mimic(g_ptr);
1841 f_ptr = &f_info[feat];
1843 take_turn(p_ptr, 100);;
1851 else if (have_flag(f_ptr->flags, FF_OPEN))
1853 more = do_cmd_open_aux(y, x);
1856 /* Bash jammed doors */
1857 else if (have_flag(f_ptr->flags, FF_BASH))
1859 more = do_cmd_bash_aux(y, x, dir);
1862 /* Tunnel through walls */
1863 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1865 more = do_cmd_tunnel_aux(y, x);
1868 /* Close open doors */
1869 else if (have_flag(f_ptr->flags, FF_CLOSE))
1871 more = do_cmd_close_aux(y, x);
1875 else if (have_flag(f_ptr->flags, FF_DISARM))
1877 more = do_cmd_disarm_aux(y, x, dir);
1882 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1886 /* Cancel repetition unless we can continue */
1887 if (!more) disturb(FALSE, FALSE);
1893 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1894 * Find the index of some "spikes", if possible.
1895 * @param ip くさびとして打てるオブジェクトのID
1896 * @return オブジェクトがある場合TRUEを返す
1899 * Let user choose a pile of spikes, perhaps?
1902 static bool get_spike(INVENTORY_IDX *ip)
1906 /* Check every item in the pack */
1907 for (i = 0; i < INVEN_PACK; i++)
1909 object_type *o_ptr = &inventory[i];
1911 /* Skip non-objects */
1912 if (!o_ptr->k_idx) continue;
1914 /* Check the "tval" code */
1915 if (o_ptr->tval == TV_SPIKE)
1917 /* Save the spike index */
1930 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1931 * Jam a closed door with a spike
1935 * This command may NOT be repeated
1938 void do_cmd_spike(void)
1942 if (p_ptr->wild_mode) return;
1944 if (p_ptr->special_defense & KATA_MUSOU)
1946 set_action(ACTION_NONE);
1949 /* Get a "repeated" direction */
1950 if (get_rep_dir(&dir, FALSE))
1957 y = p_ptr->y + ddy[dir];
1958 x = p_ptr->x + ddx[dir];
1959 g_ptr = &grid_array[y][x];
1961 /* Feature code (applying "mimic" field) */
1962 feat = get_feat_mimic(g_ptr);
1964 /* Require closed door */
1965 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1967 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1971 else if (!get_spike(&item))
1973 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1976 /* Is a monster in the way? */
1977 else if (g_ptr->m_idx)
1979 take_turn(p_ptr, 100);;
1981 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1990 take_turn(p_ptr, 100);;
1992 /* Successful jamming */
1993 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1994 cave_alter_feat(y, x, FF_SPIKE);
1996 /* Use up, and describe, a single spike, from the bottom */
1997 inven_item_increase(item, -1);
1998 inven_item_describe(item);
1999 inven_item_optimize(item);
2007 * @brief 「歩く」動作コマンドのメインルーチン /
2008 * Support code for the "Walk" and "Jump" commands
2009 * @param pickup アイテムの自動拾いを行うならTRUE
2012 void do_cmd_walk(bool pickup)
2019 /* Allow repeated command */
2022 /* Set repeat count */
2023 command_rep = command_arg - 1;
2024 p_ptr->redraw |= (PR_STATE);
2026 /* Cancel the arg */
2030 /* Get a "repeated" direction */
2031 if (get_rep_dir(&dir, FALSE))
2033 take_turn(p_ptr, 100);;
2035 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2037 set_action(ACTION_NONE);
2040 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2041 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2042 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2044 /* Actually move the character */
2045 move_player(dir, pickup, FALSE);
2047 /* Allow more walking */
2051 /* Hack again -- Is there a special encounter ??? */
2052 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2054 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2057 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2059 /* Inform the player of his horrible fate :=) */
2060 msg_print(_("襲撃だ!", "You are ambushed !"));
2062 /* Go into large wilderness view */
2063 p_ptr->oldpy = randint1(MAX_HGT-2);
2064 p_ptr->oldpx = randint1(MAX_WID-2);
2067 /* Give first move to monsters */
2068 take_turn(p_ptr, 100);
2070 /* HACk -- set the encouter flag for the wilderness generation */
2071 generate_encounter = TRUE;
2075 /* Cancel repeat unless we may continue */
2076 if (!more) disturb(FALSE, FALSE);
2081 * @brief 「走る」動作コマンドのメインルーチン /
2085 void do_cmd_run(void)
2088 if (cmd_limit_confused(p_ptr)) return;
2090 if (p_ptr->special_defense & KATA_MUSOU)
2092 set_action(ACTION_NONE);
2095 /* Get a "repeated" direction */
2096 if (get_rep_dir(&dir,FALSE))
2098 /* Hack -- Set the run counter */
2099 running = (command_arg ? command_arg : 1000);
2108 * @brief 「留まる」動作コマンドのメインルーチン /
2109 * Stay still. Search. Enter stores.
2110 * Pick up treasure if "pickup" is true.
2111 * @param pickup アイテムの自動拾いを行うならTRUE
2114 void do_cmd_stay(bool pickup)
2116 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2118 /* Allow repeated command */
2121 /* Set repeat count */
2122 command_rep = command_arg - 1;
2123 p_ptr->redraw |= (PR_STATE);
2125 /* Cancel the arg */
2129 take_turn(p_ptr, 100);;
2131 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2132 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2137 * @brief 「休む」動作コマンドのメインルーチン /
2138 * Resting allows a player to safely restore his hp -RAK-
2141 void do_cmd_rest(void)
2144 set_action(ACTION_NONE);
2146 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2148 stop_singing(p_ptr);
2152 if (hex_spelling_any()) stop_hex_spell_all();
2154 /* Prompt for time if needed */
2155 if (command_arg <= 0)
2157 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2158 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2164 strcpy(out_val, "&");
2166 /* Ask for duration */
2167 if (!get_string(p, out_val, 4)) return;
2169 /* Rest until done */
2170 if (out_val[0] == '&')
2172 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2176 else if (out_val[0] == '*')
2178 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2184 command_arg = (COMMAND_ARG)atoi(out_val);
2185 if (command_arg <= 0) return;
2191 if (command_arg > 9999) command_arg = 9999;
2193 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2195 /* Take a turn (?) */
2196 take_turn(p_ptr, 100);;
2198 /* The sin of sloth */
2199 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2201 /* Why are you sleeping when there's no need? WAKE UP!*/
2202 if ((p_ptr->chp == p_ptr->mhp) &&
2203 (p_ptr->csp == p_ptr->msp) &&
2204 !p_ptr->blind && !p_ptr->confused &&
2205 !p_ptr->poisoned && !p_ptr->afraid &&
2206 !p_ptr->stun && !p_ptr->cut &&
2207 !p_ptr->slow && !p_ptr->paralyzed &&
2208 !p_ptr->image && !p_ptr->word_recall &&
2209 !p_ptr->alter_reality)
2210 chg_virtue(V_DILIGENCE, -1);
2212 /* Save the rest code */
2213 resting = command_arg;
2214 p_ptr->action = ACTION_REST;
2215 p_ptr->update |= (PU_BONUS);
2216 update_creature(p_ptr);
2218 p_ptr->redraw |= (PR_STATE);
2227 * @brief 射撃処理のメインルーチン
2230 void do_cmd_fire(void)
2233 object_type *j_ptr, *ammo_ptr;
2236 if(p_ptr->wild_mode) return;
2238 is_fired = FALSE; /* not fired yet */
2240 /* Get the "bow" (if any) */
2241 j_ptr = &inventory[INVEN_BOW];
2243 /* Require a launcher */
2246 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2251 if (j_ptr->sval == SV_CRIMSON)
2253 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2258 if (j_ptr->sval == SV_HARP)
2260 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2266 if (p_ptr->special_defense & KATA_MUSOU)
2268 set_action(ACTION_NONE);
2271 /* Require proper missile */
2272 item_tester_tval = p_ptr->tval_ammo;
2274 q = _("どれを撃ちますか? ", "Fire which item? ");
2275 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2278 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2286 exe_fire(item, j_ptr);
2288 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2290 /* Sniper actions after some shootings */
2291 if (snipe_type == SP_AWAY)
2293 teleport_player(10 + (p_ptr->concent * 2), 0L);
2295 if (snipe_type == SP_FINAL)
2297 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2298 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2299 (void)set_stun(p_ptr->stun + randint1(25));
2305 * @brief 投射処理メインルーチン /
2306 * Throw an object from the pack or floor.
2308 * @param boomerang ブーメラン処理ならばTRUE
2309 * @param shuriken 忍者の手裏剣処理ならばTRUE
2310 * @return ターンを消費した場合TRUEを返す
2313 * Note: "unseen" monsters are very hard to hit.
2315 * Should throwing a weapon do full damage? Should it allow the magic
2316 * to hit bonus of the weapon to have an effect? Should it ever cause
2317 * the item to be destroyed? Should it do any damage at all?
2320 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2325 POSITION y, x, ty, tx, prev_y, prev_x;
2326 POSITION ny[19], nx[19];
2327 int chance, tdam, tdis;
2328 int mul, div, dd, ds;
2329 int cur_dis, visible;
2336 bool hit_body = FALSE;
2337 bool hit_wall = FALSE;
2338 bool equiped_item = FALSE;
2339 bool return_when_thrown = FALSE;
2341 GAME_TEXT o_name[MAX_NLEN];
2343 int msec = delay_factor * delay_factor * delay_factor;
2345 BIT_FLAGS flgs[TR_FLAG_SIZE];
2347 bool come_back = FALSE;
2348 bool do_drop = TRUE;
2350 if (p_ptr->wild_mode) return FALSE;
2352 if (p_ptr->special_defense & KATA_MUSOU)
2354 set_action(ACTION_NONE);
2360 o_ptr = &inventory[item];
2364 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2366 item_tester_hook = item_tester_hook_boomerang;
2367 q = _("どの武器を投げますか? ", "Throw which item? ");
2368 s = _("投げる武器がない。", "You have nothing to throw.");
2369 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2376 else if (has_melee_weapon(INVEN_LARM))
2379 o_ptr = &inventory[item];
2384 o_ptr = &inventory[item];
2389 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2390 s = _("投げるアイテムがない。", "You have nothing to throw.");
2391 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2399 /* Item is cursed */
2400 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2402 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2406 if (p_ptr->inside_arena && !boomerang)
2408 if (o_ptr->tval != TV_SPIKE)
2410 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2419 /* Obtain a local object */
2420 object_copy(q_ptr, o_ptr);
2422 /* Extract the thrown object's flags. */
2423 object_flags(q_ptr, flgs);
2424 torch_flags(q_ptr, flgs);
2426 /* Distribute the charges of rods/wands between the stacks */
2427 distribute_charges(o_ptr, q_ptr, 1);
2432 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2434 if (p_ptr->mighty_throw) mult += 3;
2436 /* Extract a "distance multiplier" */
2437 /* Changed for 'launcher' mutation */
2438 mul = 10 + 2 * (mult - 1);
2440 /* Enforce a minimum "weight" of one pound */
2441 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2442 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2444 /* Hack -- Distance -- Reward strength, penalize weight */
2445 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2447 /* Max distance of 10-18 */
2448 if (tdis > mul) tdis = mul;
2452 ty = randint0(101) - 50 + p_ptr->y;
2453 tx = randint0(101) - 50 + p_ptr->x;
2457 project_length = tdis + 1;
2459 /* Get a direction (or cancel) */
2460 if (!get_aim_dir(&dir)) return FALSE;
2462 /* Predict the "target" location */
2463 tx = p_ptr->x + 99 * ddx[dir];
2464 ty = p_ptr->y + 99 * ddy[dir];
2466 /* Check for "target request" */
2467 if ((dir == 5) && target_okay())
2473 project_length = 0; /* reset to default */
2476 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2477 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2478 return_when_thrown = TRUE;
2480 /* Reduce and describe inventory */
2483 inven_item_increase(item, -1);
2484 if (!return_when_thrown)
2485 inven_item_describe(item);
2486 inven_item_optimize(item);
2489 /* Reduce and describe floor item */
2492 floor_item_increase(0 - item, -1);
2493 floor_item_optimize(0 - item);
2495 if (item >= INVEN_RARM)
2497 equiped_item = TRUE;
2498 p_ptr->redraw |= (PR_EQUIPPY);
2501 take_turn(p_ptr, 100);;
2503 /* Rogue and Ninja gets bonus */
2504 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2505 p_ptr->energy_use -= p_ptr->lev;
2507 /* Start at the player */
2513 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2514 else shuriken = FALSE;
2516 /* Chance of hitting */
2517 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2518 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2519 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2521 if (shuriken) chance *= 2;
2526 /* Travel until stopped */
2527 for (cur_dis = 0; cur_dis <= tdis; )
2529 /* Hack -- Stop at the target */
2530 if ((y == ty) && (x == tx)) break;
2532 /* Calculate the new location (see "project()") */
2535 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2537 /* Stopped by walls/doors */
2538 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2541 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2544 /* The player can see the (on screen) missile */
2545 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2547 SYMBOL_CODE c = object_char(q_ptr);
2548 TERM_COLOR a = object_attr(q_ptr);
2550 /* Draw, Hilite, Fresh, Pause, Erase */
2551 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2552 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2554 Term_xtra(TERM_XTRA_DELAY, msec);
2555 lite_spot(ny[cur_dis], nx[cur_dis]);
2559 /* The player cannot see the missile */
2562 /* Pause anyway, for consistancy */
2563 Term_xtra(TERM_XTRA_DELAY, msec);
2569 /* Save the new location */
2573 /* Advance the distance */
2576 /* Monster here, Try to hit it */
2577 if (grid_array[y][x].m_idx)
2579 grid_type *g_ptr = &grid_array[y][x];
2580 monster_type *m_ptr = &m_list[g_ptr->m_idx];
2582 /* Check the visibility */
2583 visible = m_ptr->ml;
2585 /* Note the collision */
2588 /* Did we hit it (penalize range) */
2589 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2593 /* Handle unseen monster */
2596 /* Invisible monster */
2597 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2600 /* Handle visible monster */
2603 GAME_TEXT m_name[MAX_NLEN];
2604 monster_desc(m_name, m_ptr, 0);
2605 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2609 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2610 health_track(g_ptr->m_idx);
2614 /* Hack -- Base damage from thrown object */
2617 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2618 tdam = damroll(dd, ds);
2619 /* Apply special damage */
2620 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2621 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2622 if (q_ptr->to_d > 0)
2623 tdam += q_ptr->to_d;
2625 tdam += -q_ptr->to_d;
2629 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2630 tdam += p_ptr->to_d_m;
2632 else if (have_flag(flgs, TR_THROW))
2635 tdam += p_ptr->to_d_m;
2643 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2646 /* No negative damage */
2647 if (tdam < 0) tdam = 0;
2649 /* Modify the damage */
2650 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2652 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2653 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2655 /* Hit the monster, check for death */
2656 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2664 message_pain(g_ptr->m_idx, tdam);
2666 /* Anger the monster */
2667 if ((tdam > 0) && !object_is_potion(q_ptr))
2668 anger_monster(m_ptr);
2670 if (fear && m_ptr->ml)
2673 GAME_TEXT m_name[MAX_NLEN];
2674 monster_desc(m_name, m_ptr, 0);
2675 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2685 /* decrease toach's fuel */
2686 if (hit_body) torch_lost_fuel(q_ptr);
2688 /* Chance of breakage (during attacks) */
2689 j = (hit_body ? breakage_chance(q_ptr) : 0);
2691 /* Figurines transform */
2692 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2696 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2697 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2698 else if (object_is_cursed(q_ptr))
2699 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2704 /* Potions smash open */
2705 if (object_is_potion(q_ptr))
2707 if (hit_body || hit_wall || (randint1(100) < j))
2709 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2711 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2713 monster_type *m_ptr = &m_list[grid_array[y][x].m_idx];
2715 /* ToDo (Robert): fix the invulnerability */
2716 if (grid_array[y][x].m_idx &&
2717 is_friendly(&m_list[grid_array[y][x].m_idx]) &&
2718 !MON_INVULNER(m_ptr))
2720 GAME_TEXT m_name[MAX_NLEN];
2721 monster_desc(m_name, &m_list[grid_array[y][x].m_idx], 0);
2722 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2723 set_hostile(&m_list[grid_array[y][x].m_idx]);
2734 if (return_when_thrown)
2736 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2737 char o2_name[MAX_NLEN];
2738 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2741 if (boomerang) back_chance += 4+randint1(5);
2742 if (super_boomerang) back_chance += 100;
2743 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2745 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2747 for (i = cur_dis - 1; i > 0; i--)
2749 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2751 char c = object_char(q_ptr);
2752 byte a = object_attr(q_ptr);
2754 /* Draw, Hilite, Fresh, Pause, Erase */
2755 print_rel(c, a, ny[i], nx[i]);
2756 move_cursor_relative(ny[i], nx[i]);
2758 Term_xtra(TERM_XTRA_DELAY, msec);
2759 lite_spot(ny[i], nx[i]);
2764 /* Pause anyway, for consistancy */
2765 Term_xtra(TERM_XTRA_DELAY, msec);
2768 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2770 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2777 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2781 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2789 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2795 if (item == INVEN_RARM || item == INVEN_LARM)
2797 /* Access the wield slot */
2798 o_ptr = &inventory[item];
2800 /* Wear the new stuff */
2801 object_copy(o_ptr, q_ptr);
2803 p_ptr->total_weight += q_ptr->weight;
2805 /* Increment the equip counter by hand */
2808 /* Recalculate torch */
2809 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2810 p_ptr->window |= (PW_EQUIP);
2818 else if (equiped_item)
2826 if (cave_have_flag_bold(y, x, FF_PROJECT))
2828 (void)drop_near(q_ptr, j, y, x);
2832 (void)drop_near(q_ptr, j, prev_y, prev_x);