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.
22 #include "object-hook.h"
24 #include "spells-summon.h"
25 #include "spells-status.h"
27 #include "monster-status.h"
31 #include "player-status.h"
32 #include "realm-hex.h"
37 #include "player-move.h"
38 #include "player-effects.h"
39 #include "objectkind.h"
40 #include "object-broken.h"
41 #include "object-flavor.h"
44 #include "cmd-basic.h"
45 #include "floor-save.h"
46 #include "dungeon-file.h"
49 #include "view-mainwindow.h"
52 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
53 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
54 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
56 static bool confirm_leave_level(bool down_stair)
58 quest_type *q_ptr = &quest[p_ptr->inside_quest];
60 /* Confirm leaving from once only quest */
61 if (confirm_quest && p_ptr->inside_quest &&
62 (q_ptr->type == QUEST_TYPE_RANDOM ||
63 (q_ptr->flags & QUEST_FLAG_ONCE &&
64 q_ptr->status != QUEST_STATUS_COMPLETED) ||
65 (q_ptr->flags & QUEST_FLAG_TOWER &&
66 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
67 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
69 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
70 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
80 * @brief 魔法系コマンドが制限されているかを返す。
81 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
83 bool cmd_limit_cast(player_type *creature_ptr)
85 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
87 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
91 else if (creature_ptr->anti_magic)
93 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
96 else if (creature_ptr->shero)
98 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
105 bool cmd_limit_confused(player_type *creature_ptr)
107 if (creature_ptr->confused)
109 msg_print(_("混乱していてできない!", "You are too confused!"));
115 bool cmd_limit_image(player_type *creature_ptr)
117 if (creature_ptr->image)
119 msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
125 bool cmd_limit_stun(player_type *creature_ptr)
127 if (creature_ptr->stun)
129 msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
135 bool cmd_limit_arena(player_type *creature_ptr)
137 if (creature_ptr->inside_arena)
139 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
146 bool cmd_limit_blind(player_type *creature_ptr)
148 if (creature_ptr->blind)
150 msg_print(_("目が見えない。", "You can't see anything."));
155 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
161 bool cmd_limit_time_walk(player_type *creature_ptr)
163 if (creature_ptr->timewalk)
165 if (flush_failure) flush();
166 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
174 * @brief 階段を使って階層を昇る処理 / Go up one level
177 void do_cmd_go_up(void)
182 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
183 feature_type *f_ptr = &f_info[g_ptr->feat];
187 if (p_ptr->special_defense & KATA_MUSOU)
189 set_action(ACTION_NONE);
193 if (!have_flag(f_ptr->flags, FF_LESS))
195 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
199 /* Quest up stairs */
200 if (have_flag(f_ptr->flags, FF_QUEST))
202 /* Cancel the command */
203 if (!confirm_leave_level(FALSE)) return;
207 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
208 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
210 msg_print(_("上の階に登った。", "You enter the up staircase."));
214 p_ptr->inside_quest = g_ptr->special;
216 /* Activate the quest */
217 if (!quest[p_ptr->inside_quest].status)
219 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
221 init_flags = INIT_ASSIGN;
222 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
224 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
227 /* Leaving a quest */
228 if (!p_ptr->inside_quest)
230 current_floor_ptr->dun_level = 0;
232 p_ptr->leaving = TRUE;
237 take_turn(p_ptr, 100);
239 /* End the command */
243 if (!current_floor_ptr->dun_level)
249 go_up = confirm_leave_level(FALSE);
252 /* Cancel the command */
255 take_turn(p_ptr, 100);
257 if (autosave_l) do_cmd_save_game(TRUE);
259 /* For a random quest */
260 if (p_ptr->inside_quest &&
261 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
265 p_ptr->inside_quest = 0;
268 /* For a fixed quest */
269 if (p_ptr->inside_quest &&
270 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
274 p_ptr->inside_quest = g_ptr->special;
275 current_floor_ptr->dun_level = 0;
279 /* For normal dungeon and random quest */
283 if (have_flag(f_ptr->flags, FF_SHAFT))
285 /* Create a way back */
286 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
292 /* Create a way back */
293 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
298 /* Get out from current dungeon */
299 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
300 up_num = current_floor_ptr->dun_level;
302 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
305 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
306 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
307 else if (up_num == current_floor_ptr->dun_level)
308 msg_print(_("地上に戻った。", "You go back to the surface."));
310 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
311 p_ptr->leaving = TRUE;
316 * @brief 階段を使って階層を降りる処理 / Go down one level
319 void do_cmd_go_down(void)
322 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
323 feature_type *f_ptr = &f_info[g_ptr->feat];
325 bool fall_trap = FALSE;
328 if (p_ptr->special_defense & KATA_MUSOU)
330 set_action(ACTION_NONE);
334 if (!have_flag(f_ptr->flags, FF_MORE))
336 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
340 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
343 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
348 /* Quest down stairs */
349 else if (have_flag(f_ptr->flags, FF_QUEST))
351 /* Confirm Leaving */
352 if(!confirm_leave_level(TRUE)) return;
354 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
355 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
357 msg_print(_("下の階に降りた。", "You enter the down staircase."));
362 p_ptr->inside_quest = g_ptr->special;
364 /* Activate the quest */
365 if (!quest[p_ptr->inside_quest].status)
367 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
369 init_flags = INIT_ASSIGN;
370 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
372 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
375 /* Leaving a quest */
376 if (!p_ptr->inside_quest)
378 current_floor_ptr->dun_level = 0;
380 p_ptr->leaving = TRUE;
384 take_turn(p_ptr, 100);
389 DUNGEON_IDX target_dungeon = 0;
391 if (!current_floor_ptr->dun_level)
393 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
395 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
397 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
400 if (!max_dlv[target_dungeon])
402 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
403 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
404 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
407 /* Save old player position */
408 p_ptr->oldpx = p_ptr->x;
409 p_ptr->oldpy = p_ptr->y;
410 p_ptr->dungeon_idx = target_dungeon;
413 * Clear all saved floors
414 * and create a first saved floor
416 prepare_change_floor_mode(CFM_FIRST_FLOOR);
419 take_turn(p_ptr, 100);
421 if (autosave_l) do_cmd_save_game(TRUE);
424 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
427 if (!current_floor_ptr->dun_level)
429 /* Enter the dungeon just now */
430 p_ptr->enter_dungeon = TRUE;
431 down_num = d_info[p_ptr->dungeon_idx].mindepth;
436 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
437 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
442 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
449 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
453 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
454 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
456 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
460 p_ptr->leaving = TRUE;
464 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
468 if (have_flag(f_ptr->flags, FF_SHAFT))
470 /* Create a way back */
471 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
475 /* Create a way back */
476 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
484 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn
487 void do_cmd_search(void)
489 /* Allow repeated command */
492 /* Set repeat count */
493 command_rep = command_arg - 1;
494 p_ptr->redraw |= (PR_STATE);
499 take_turn(p_ptr, 100);
507 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
508 * @param y 走査対象にしたいマスのY座標
509 * @param x 走査対象にしたいマスのX座標
510 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
511 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
513 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
515 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
516 OBJECT_IDX this_o_idx, next_o_idx = 0;
518 /* Scan all objects in the grid */
519 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
523 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
524 next_o_idx = o_ptr->next_o_idx;
526 /* Skip unknown chests XXX XXX */
527 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
529 /* Check for non empty chest */
530 if ((o_ptr->tval == TV_CHEST) &&
531 (((!trapped) && (o_ptr->pval)) || /* non empty */
532 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
541 * @brief 箱を開けるコマンドのメインルーチン /
542 * Attempt to open the given chest at the given location
543 * @param y 箱の存在するマスのY座標
544 * @param x 箱の存在するマスのX座標
545 * @param o_idx 箱のオブジェクトID
546 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
548 * Assume there is no monster blocking the destination
550 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
555 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
557 take_turn(p_ptr, 100);
559 /* Attempt to unlock it */
562 /* Assume locked, and thus not open */
565 /* Get the "disarm" factor */
566 i = p_ptr->skill_dis;
568 /* Penalize some conditions */
569 if (p_ptr->blind || no_lite()) i = i / 10;
570 if (p_ptr->confused || p_ptr->image) i = i / 10;
572 /* Extract the difficulty */
575 /* Always have a small chance of success */
578 /* Success -- May still have traps */
579 if (randint0(100) < j)
581 msg_print(_("鍵をはずした。", "You have picked the lock."));
586 /* Failure -- Keep trying */
589 /* We may continue repeating */
591 if (flush_failure) flush();
592 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
597 /* Allowed to open */
600 /* Apply chest traps, if any */
601 chest_trap(y, x, o_idx);
603 /* Let the Chest drop items */
604 chest_death(FALSE, y, x, o_idx);
610 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
611 * Attempt to open the given chest at the given location
612 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
613 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
614 * @param test 地形条件を判定するための関数ポインタ
615 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
617 * @details Return the number of features around (or under) the character.
618 * Usually look for doors and floor traps.
620 static int count_dt(POSITION *y, POSITION *x, bool (*test)(FEAT_IDX feat), bool under)
626 /* Count how many matches */
629 /* Check around (and under) the character */
630 for (d = 0; d < 9; d++)
635 /* if not searching under player continue */
636 if ((d == 8) && !under) continue;
638 /* Extract adjacent (legal) location */
639 yy = p_ptr->y + ddy_ddd[d];
640 xx = p_ptr->x + ddx_ddd[d];
642 /* Get the current_floor_ptr->grid_array */
643 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
645 /* Must have knowledge */
646 if (!(g_ptr->info & (CAVE_MARK))) continue;
648 /* Feature code (applying "mimic" field) */
649 feat = get_feat_mimic(g_ptr);
651 /* Not looking for this feature */
652 if (!((*test)(feat))) continue;
657 /* Remember the location. Only useful if only one match */
668 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
669 * Return the number of chests around (or under) the character.
670 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
671 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
672 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
675 * If requested, count only trapped chests.
677 static int count_chests(POSITION *y, POSITION *x, bool trapped)
684 /* Count how many matches */
687 /* Check around (and under) the character */
688 for (d = 0; d < 9; d++)
690 /* Extract adjacent (legal) location */
691 POSITION yy = p_ptr->y + ddy_ddd[d];
692 POSITION xx = p_ptr->x + ddx_ddd[d];
694 /* No (visible) chest is there */
695 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
697 /* Grab the object */
698 o_ptr = ¤t_floor_ptr->o_list[o_idx];
701 if (o_ptr->pval == 0) continue;
703 /* No (known) traps here */
704 if (trapped && (!object_is_known(o_ptr) ||
705 !chest_traps[o_ptr->pval])) continue;
710 /* Remember the location. Only useful if only one match */
722 * @brief 「開ける」動作コマンドのサブルーチン /
723 * Perform the basic "open" command on doors
724 * @param y 対象を行うマスのY座標
725 * @param x 対象を行うマスのX座標
726 * @return 実際に処理が行われた場合TRUEを返す。
728 * Assume destination is a closed/locked/jammed door
729 * Assume there is no monster blocking the destination
730 * Returns TRUE if repeated commands may continue
732 static bool do_cmd_open_aux(POSITION y, POSITION x)
736 /* Get requested grid */
737 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
738 feature_type *f_ptr = &f_info[g_ptr->feat];
741 take_turn(p_ptr, 100);
743 /* Seeing true feature code (ignore mimic) */
746 if (!have_flag(f_ptr->flags, FF_OPEN))
749 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
753 else if (f_ptr->power)
756 i = p_ptr->skill_dis;
758 /* Penalize some conditions */
759 if (p_ptr->blind || no_lite()) i = i / 10;
760 if (p_ptr->confused || p_ptr->image) i = i / 10;
762 /* Extract the lock power */
765 /* Extract the difficulty */
768 /* Always have a small chance of success */
772 if (randint0(100) < j)
774 msg_print(_("鍵をはずした。", "You have picked the lock."));
777 cave_alter_feat(y, x, FF_OPEN);
779 sound(SOUND_OPENDOOR);
789 if (flush_failure) flush();
791 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
793 /* We may keep trying */
802 cave_alter_feat(y, x, FF_OPEN);
804 sound(SOUND_OPENDOOR);
810 * @brief 「開ける」コマンドのメインルーチン /
811 * Open a closed/locked/jammed door or a closed/locked chest.
814 * Unlocking a locked door/chest is worth one experience point.
816 void do_cmd_open(void)
824 if (p_ptr->wild_mode) return;
826 if (p_ptr->special_defense & KATA_MUSOU)
828 set_action(ACTION_NONE);
831 /* Option: Pick a direction */
834 int num_doors, num_chests;
836 /* Count closed doors (locked or jammed) */
837 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
839 /* Count chests (locked) */
840 num_chests = count_chests(&y, &x, FALSE);
842 /* See if only one target */
843 if (num_doors || num_chests)
845 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
847 if (!too_many) command_dir = coords_to_dir(y, x);
851 /* Allow repeated command */
854 /* Set repeat count */
855 command_rep = command_arg - 1;
856 p_ptr->redraw |= (PR_STATE);
862 /* Get a "repeated" direction */
863 if (get_rep_dir(&dir, TRUE))
868 /* Get requested location */
869 y = p_ptr->y + ddy[dir];
870 x = p_ptr->x + ddx[dir];
872 /* Get requested grid */
873 g_ptr = ¤t_floor_ptr->grid_array[y][x];
875 /* Feature code (applying "mimic" field) */
876 feat = get_feat_mimic(g_ptr);
878 /* Check for chest */
879 o_idx = chest_check(y, x, FALSE);
882 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
884 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
887 /* Monster in the way */
888 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
890 take_turn(p_ptr, 100);
891 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
899 more = do_cmd_open_chest(y, x, o_idx);
906 more = do_cmd_open_aux(y, x);
910 /* Cancel repeat unless we may continue */
911 if (!more) disturb(FALSE, FALSE);
917 * @brief 「閉じる」動作コマンドのサブルーチン /
918 * Perform the basic "close" command
919 * @param y 対象を行うマスのY座標
920 * @param x 対象を行うマスのX座標
921 * @return 実際に処理が行われた場合TRUEを返す。
923 * Assume destination is an open/broken door
924 * Assume there is no monster blocking the destination
925 * Returns TRUE if repeated commands may continue
927 static bool do_cmd_close_aux(POSITION y, POSITION x)
929 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
930 FEAT_IDX old_feat = g_ptr->feat;
933 take_turn(p_ptr, 100);
935 /* Seeing true feature code (ignore mimic) */
938 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
940 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
942 /* Hack -- object in the way */
943 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
944 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
946 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
951 cave_alter_feat(y, x, FF_CLOSE);
954 if (old_feat == g_ptr->feat)
956 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
960 sound(SOUND_SHUTDOOR);
969 * @brief 「閉じる」コマンドのメインルーチン /
970 * Close an open door.
973 * Unlocking a locked door/chest is worth one experience point.
975 void do_cmd_close(void)
982 if (p_ptr->wild_mode) return;
984 if (p_ptr->special_defense & KATA_MUSOU)
986 set_action(ACTION_NONE);
989 /* Option: Pick a direction */
992 /* Count open doors */
993 if (count_dt(&y, &x, is_open, FALSE) == 1)
995 command_dir = coords_to_dir(y, x);
999 /* Allow repeated command */
1002 /* Set repeat count */
1003 command_rep = command_arg - 1;
1004 p_ptr->redraw |= (PR_STATE);
1006 /* Cancel the arg */
1010 /* Get a "repeated" direction */
1011 if (get_rep_dir(&dir, FALSE))
1016 y = p_ptr->y + ddy[dir];
1017 x = p_ptr->x + ddx[dir];
1018 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1020 /* Feature code (applying "mimic" field) */
1021 feat = get_feat_mimic(g_ptr);
1023 /* Require open/broken door */
1024 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1026 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1029 /* Monster in the way */
1030 else if (g_ptr->m_idx)
1032 take_turn(p_ptr, 100);
1034 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1040 /* Close the door */
1043 /* Close the door */
1044 more = do_cmd_close_aux(y, x);
1048 /* Cancel repeat unless we may continue */
1049 if (!more) disturb(FALSE, FALSE);
1054 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1055 * Determine if a given grid may be "tunneled"
1056 * @param y 対象を行うマスのY座標
1057 * @param x 対象を行うマスのX座標
1060 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1062 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1064 /* Must have knowledge */
1065 if (!(g_ptr->info & CAVE_MARK))
1067 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1072 /* Must be a wall/door/etc */
1073 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1075 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1085 * @brief 「掘る」動作コマンドのサブルーチン /
1086 * Perform the basic "tunnel" command
1087 * @param y 対象を行うマスのY座標
1088 * @param x 対象を行うマスのX座標
1089 * @return 実際に処理が行われた場合TRUEを返す。
1091 * Assumes that no monster is blocking the destination
1092 * Do not use twall anymore
1093 * Returns TRUE if repeated commands may continue
1095 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1098 feature_type *f_ptr, *mimic_f_ptr;
1103 /* Verify legality */
1104 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1106 take_turn(p_ptr, 100);
1108 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1109 f_ptr = &f_info[g_ptr->feat];
1110 power = f_ptr->power;
1112 /* Feature code (applying "mimic" field) */
1113 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1115 name = f_name + mimic_f_ptr->name;
1119 if (have_flag(f_ptr->flags, FF_PERMANENT))
1122 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1124 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1127 /* Map border (mimiccing Permanent wall) */
1130 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1135 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1138 if (p_ptr->skill_dig > randint0(20 * power))
1140 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1142 /* Remove the feature */
1143 cave_alter_feat(y, x, FF_TUNNEL);
1144 p_ptr->update |= (PU_FLOW);
1148 /* Message, keep digging */
1149 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1157 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1160 if (p_ptr->skill_dig > power + randint0(40 * power))
1162 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1165 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1166 p_ptr->update |= (PU_FLOW);
1169 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1171 /* Remove the feature */
1172 cave_alter_feat(y, x, FF_TUNNEL);
1174 chg_virtue(V_DILIGENCE, 1);
1175 chg_virtue(V_NATURE, -1);
1183 /* We may continue chopping */
1184 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1185 /* Occasional Search XXX XXX */
1186 if (randint0(100) < 25) search();
1190 /* We may continue tunelling */
1191 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1198 if (is_hidden_door(g_ptr))
1200 /* Occasional Search XXX XXX */
1201 if (randint0(100) < 25) search();
1208 * @brief 「掘る」動作コマンドのメインルーチン /
1209 * Tunnels through "walls" (including rubble and closed doors)
1213 * Note that you must tunnel in order to hit invisible monsters
1214 * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
1216 * Digging is very difficult without a "digger" weapon, but can be
1217 * accomplished by strong players using heavy weapons.
1220 void do_cmd_tunnel(void)
1229 if (p_ptr->special_defense & KATA_MUSOU)
1231 set_action(ACTION_NONE);
1234 /* Allow repeated command */
1237 /* Set repeat count */
1238 command_rep = command_arg - 1;
1239 p_ptr->redraw |= (PR_STATE);
1241 /* Cancel the arg */
1245 /* Get a direction to tunnel, or Abort */
1246 if (get_rep_dir(&dir,FALSE))
1249 y = p_ptr->y + ddy[dir];
1250 x = p_ptr->x + ddx[dir];
1252 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1254 /* Feature code (applying "mimic" field) */
1255 feat = get_feat_mimic(g_ptr);
1257 /* No tunnelling through doors */
1258 if (have_flag(f_info[feat].flags, FF_DOOR))
1260 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1263 /* No tunnelling through most features */
1264 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1266 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1269 /* A monster is in the way */
1270 else if (g_ptr->m_idx)
1272 take_turn(p_ptr, 100);
1274 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1283 /* Tunnel through walls */
1284 more = do_cmd_tunnel_aux(y, x);
1288 /* Cancel repetition unless we can continue */
1289 if (!more) disturb(FALSE, FALSE);
1293 * @brief 移動処理による簡易な「開く」処理 /
1295 * @return 開く処理が実際に試みられた場合TRUEを返す
1298 * If there is a jammed/closed/locked door at the given location,
1299 * then attempt to unlock/open it. Return TRUE if an attempt was
1300 * made (successful or not), otherwise return FALSE.
1302 * The code here should be nearly identical to that in
1303 * do_cmd_open_test() and do_cmd_open_aux().
1306 bool easy_open_door(POSITION y, POSITION x)
1310 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1311 feature_type *f_ptr = &f_info[g_ptr->feat];
1313 /* Must be a closed door */
1314 if (!is_closed_door(g_ptr->feat))
1320 if (!have_flag(f_ptr->flags, FF_OPEN))
1323 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1328 else if (f_ptr->power)
1331 i = p_ptr->skill_dis;
1333 /* Penalize some conditions */
1334 if (p_ptr->blind || no_lite()) i = i / 10;
1335 if (p_ptr->confused || p_ptr->image) i = i / 10;
1337 /* Extract the lock power */
1340 /* Extract the difficulty */
1343 /* Always have a small chance of success */
1347 if (randint0(100) < j)
1349 msg_print(_("鍵をはずした。", "You have picked the lock."));
1352 cave_alter_feat(y, x, FF_OPEN);
1354 sound(SOUND_OPENDOOR);
1364 if (flush_failure) flush();
1366 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1375 cave_alter_feat(y, x, FF_OPEN);
1377 sound(SOUND_OPENDOOR);
1383 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1384 * Perform the basic "disarm" command
1385 * @param y 解除を行うマスのY座標
1386 * @param x 解除を行うマスのX座標
1387 * @param o_idx 箱のオブジェクトID
1388 * @return ターンを消費する処理が行われた場合TRUEを返す
1391 * Assume destination is a visible trap
1392 * Assume there is no monster blocking the destination
1393 * Returns TRUE if repeated commands may continue
1396 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1400 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1402 take_turn(p_ptr, 100);
1404 /* Get the "disarm" factor */
1405 i = p_ptr->skill_dis;
1407 /* Penalize some conditions */
1408 if (p_ptr->blind || no_lite()) i = i / 10;
1409 if (p_ptr->confused || p_ptr->image) i = i / 10;
1411 /* Extract the difficulty */
1412 j = i - o_ptr->pval;
1414 /* Always have a small chance of success */
1417 /* Must find the trap first. */
1418 if (!object_is_known(o_ptr))
1420 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1424 /* Already disarmed/unlocked */
1425 else if (o_ptr->pval <= 0)
1427 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1430 /* No traps to find. */
1431 else if (!chest_traps[o_ptr->pval])
1433 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1436 /* Success (get a lot of experience) */
1437 else if (randint0(100) < j)
1439 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1440 gain_exp(o_ptr->pval);
1441 o_ptr->pval = (0 - o_ptr->pval);
1444 /* Failure -- Keep trying */
1445 else if ((i > 5) && (randint1(i) > 5))
1447 /* We may keep trying */
1449 if (flush_failure) flush();
1450 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1453 /* Failure -- Set off the trap */
1456 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1458 chest_trap(y, x, o_idx);
1465 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1466 * Perform the basic "disarm" command
1467 * @param y 解除を行うマスのY座標
1468 * @param x 解除を行うマスのX座標
1469 * @param dir プレイヤーからみた方向ID
1470 * @return ターンを消費する処理が行われた場合TRUEを返す
1473 * Assume destination is a visible trap
1474 * Assume there is no monster blocking the destination
1475 * Returns TRUE if repeated commands may continue
1479 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1481 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1484 feature_type *f_ptr = &f_info[g_ptr->feat];
1486 /* Access trap name */
1487 concptr name = (f_name + f_ptr->name);
1489 /* Extract trap "power" */
1490 int power = f_ptr->power;
1493 /* Get the "disarm" factor */
1494 int i = p_ptr->skill_dis;
1497 take_turn(p_ptr, 100);
1499 /* Penalize some conditions */
1500 if (p_ptr->blind || no_lite()) i = i / 10;
1501 if (p_ptr->confused || p_ptr->image) i = i / 10;
1503 /* Extract the difficulty */
1506 /* Always have a small chance of success */
1510 if (randint0(100) < j)
1512 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1517 /* Remove the trap */
1518 cave_alter_feat(y, x, FF_DISARM);
1520 /* Move the player onto the trap */
1521 move_player(dir, easy_disarm, FALSE);
1524 /* Failure -- Keep trying */
1525 else if ((i > 5) && (randint1(i) > 5))
1528 if (flush_failure) flush();
1530 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1532 /* We may keep trying */
1536 /* Failure -- Set off the trap */
1539 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1540 /* Move the player onto the trap */
1541 move_player(dir, easy_disarm, FALSE);
1548 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1549 * Disarms a trap, or chest
1552 void do_cmd_disarm(void)
1560 if (p_ptr->wild_mode) return;
1562 if (p_ptr->special_defense & KATA_MUSOU)
1564 set_action(ACTION_NONE);
1567 /* Option: Pick a direction */
1570 int num_traps, num_chests;
1572 /* Count visible traps */
1573 num_traps = count_dt(&y, &x, is_trap, TRUE);
1575 /* Count chests (trapped) */
1576 num_chests = count_chests(&y, &x, TRUE);
1578 /* See if only one target */
1579 if (num_traps || num_chests)
1581 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1582 if (!too_many) command_dir = coords_to_dir(y, x);
1587 /* Allow repeated command */
1590 /* Set repeat count */
1591 command_rep = command_arg - 1;
1592 p_ptr->redraw |= (PR_STATE);
1594 /* Cancel the arg */
1598 /* Get a direction (or abort) */
1599 if (get_rep_dir(&dir,TRUE))
1604 y = p_ptr->y + ddy[dir];
1605 x = p_ptr->x + ddx[dir];
1606 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1608 /* Feature code (applying "mimic" field) */
1609 feat = get_feat_mimic(g_ptr);
1611 /* Check for chests */
1612 o_idx = chest_check(y, x, TRUE);
1615 if (!is_trap(feat) && !o_idx)
1617 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1620 /* Monster in the way */
1621 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1623 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1632 more = do_cmd_disarm_chest(y, x, o_idx);
1638 more = do_cmd_disarm_aux(y, x, dir);
1642 /* Cancel repeat unless told not to */
1643 if (!more) disturb(FALSE, FALSE);
1648 * @brief 「打ち破る」動作コマンドのサブルーチン /
1649 * Perform the basic "bash" command
1650 * @param y 対象を行うマスのY座標
1651 * @param x 対象を行うマスのX座標
1652 * @param dir プレイヤーから見たターゲットの方角ID
1653 * @return 実際に処理が行われた場合TRUEを返す。
1656 * Assume destination is a closed/locked/jammed door
1657 * Assume there is no monster blocking the destination
1658 * Returns TRUE if repeated commands may continue
1661 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1663 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1666 feature_type *f_ptr = &f_info[g_ptr->feat];
1668 /* Hack -- Bash power based on strength */
1669 /* (Ranges from 3 to 20 to 100 to 200) */
1670 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1672 /* Extract door power */
1673 int temp = f_ptr->power;
1677 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1679 take_turn(p_ptr, 100);
1681 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1683 /* Compare bash power to door power */
1684 temp = (bash - (temp * 10));
1686 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1688 /* Hack -- always have a chance */
1689 if (temp < 1) temp = 1;
1691 /* Hack -- attempt to bash down the door */
1692 if (randint0(100) < temp)
1694 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1696 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1698 /* Break down the door */
1699 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1701 cave_alter_feat(y, x, FF_BASH);
1707 cave_alter_feat(y, x, FF_OPEN);
1710 /* Hack -- Fall through the door */
1711 move_player(dir, FALSE, FALSE);
1714 /* Saving throw against stun */
1715 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1718 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1720 /* Allow repeated bashing */
1724 /* High dexterity yields coolness */
1727 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1729 /* Hack -- Lose balance ala paralysis */
1730 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1737 * @brief 「打ち破る」動作コマンドのメインルーチン /
1738 * Bash open a door, success based on character strength
1742 * For a closed door, pval is positive if locked; negative if stuck.
1744 * For an open door, pval is positive for a broken door.
1746 * A closed door can be opened - harder if locked. Any door might be
1747 * bashed open (and thereby broken). Bashing a door is (potentially)
1748 * faster! You move into the door way. To open a stuck door, it must
1749 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1751 * Creatures can also open or bash doors, see elsewhere.
1754 void do_cmd_bash(void)
1760 if (p_ptr->wild_mode) return;
1762 if (p_ptr->special_defense & KATA_MUSOU)
1764 set_action(ACTION_NONE);
1767 /* Allow repeated command */
1770 /* Set repeat count */
1771 command_rep = command_arg - 1;
1772 p_ptr->redraw |= (PR_STATE);
1774 /* Cancel the arg */
1778 /* Get a "repeated" direction */
1779 if (get_rep_dir(&dir,FALSE))
1784 y = p_ptr->y + ddy[dir];
1785 x = p_ptr->x + ddx[dir];
1787 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1789 /* Feature code (applying "mimic" field) */
1790 feat = get_feat_mimic(g_ptr);
1792 /* Nothing useful */
1793 if (!have_flag(f_info[feat].flags, FF_BASH))
1795 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1798 /* Monster in the way */
1799 else if (g_ptr->m_idx)
1801 take_turn(p_ptr, 100);
1803 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1809 /* Bash a closed door */
1813 more = do_cmd_bash_aux(y, x, dir);
1817 /* Unless valid action taken, cancel bash */
1818 if (!more) disturb(FALSE, FALSE);
1823 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1827 * Manipulate an adjacent grid in some way
1829 * Attack monsters, tunnel through walls, disarm traps, open doors.
1831 * Consider confusion
1833 * This command must always take a current_world_ptr->game_turn, to prevent free detection
1834 * of invisible monsters.
1837 void do_cmd_alter(void)
1844 if (p_ptr->special_defense & KATA_MUSOU)
1846 set_action(ACTION_NONE);
1849 /* Allow repeated command */
1852 /* Set repeat count */
1853 command_rep = command_arg - 1;
1854 p_ptr->redraw |= (PR_STATE);
1856 /* Cancel the arg */
1860 /* Get a direction */
1861 if (get_rep_dir(&dir,TRUE))
1864 feature_type *f_ptr;
1866 y = p_ptr->y + ddy[dir];
1867 x = p_ptr->x + ddx[dir];
1869 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1871 /* Feature code (applying "mimic" field) */
1872 feat = get_feat_mimic(g_ptr);
1873 f_ptr = &f_info[feat];
1875 take_turn(p_ptr, 100);
1883 else if (have_flag(f_ptr->flags, FF_OPEN))
1885 more = do_cmd_open_aux(y, x);
1888 /* Bash jammed doors */
1889 else if (have_flag(f_ptr->flags, FF_BASH))
1891 more = do_cmd_bash_aux(y, x, dir);
1894 /* Tunnel through walls */
1895 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1897 more = do_cmd_tunnel_aux(y, x);
1900 /* Close open doors */
1901 else if (have_flag(f_ptr->flags, FF_CLOSE))
1903 more = do_cmd_close_aux(y, x);
1907 else if (have_flag(f_ptr->flags, FF_DISARM))
1909 more = do_cmd_disarm_aux(y, x, dir);
1914 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1918 /* Cancel repetition unless we can continue */
1919 if (!more) disturb(FALSE, FALSE);
1925 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1926 * Find the index of some "spikes", if possible.
1927 * @param ip くさびとして打てるオブジェクトのID
1928 * @return オブジェクトがある場合TRUEを返す
1931 * Let user choose a pile of spikes, perhaps?
1934 static bool get_spike(INVENTORY_IDX *ip)
1938 /* Check every item in the pack */
1939 for (i = 0; i < INVEN_PACK; i++)
1941 object_type *o_ptr = &p_ptr->inventory_list[i];
1942 if (!o_ptr->k_idx) continue;
1944 /* Check the "tval" code */
1945 if (o_ptr->tval == TV_SPIKE)
1947 /* Save the spike index */
1960 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1961 * Jam a closed door with a spike
1965 * This command may NOT be repeated
1968 void do_cmd_spike(void)
1972 if (p_ptr->wild_mode) return;
1974 if (p_ptr->special_defense & KATA_MUSOU)
1976 set_action(ACTION_NONE);
1979 /* Get a "repeated" direction */
1980 if (get_rep_dir(&dir, FALSE))
1987 y = p_ptr->y + ddy[dir];
1988 x = p_ptr->x + ddx[dir];
1989 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1991 /* Feature code (applying "mimic" field) */
1992 feat = get_feat_mimic(g_ptr);
1994 /* Require closed door */
1995 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1997 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2001 else if (!get_spike(&item))
2003 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2006 /* Is a monster in the way? */
2007 else if (g_ptr->m_idx)
2009 take_turn(p_ptr, 100);
2011 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2020 take_turn(p_ptr, 100);
2022 /* Successful jamming */
2023 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2024 cave_alter_feat(y, x, FF_SPIKE);
2026 /* Use up, and describe, a single spike, from the bottom */
2027 inven_item_increase(item, -1);
2028 inven_item_describe(item);
2029 inven_item_optimize(item);
2037 * @brief 「歩く」動作コマンドのメインルーチン /
2038 * Support code for the "Walk" and "Jump" commands
2039 * @param pickup アイテムの自動拾いを行うならTRUE
2042 void do_cmd_walk(bool pickup)
2049 /* Allow repeated command */
2052 /* Set repeat count */
2053 command_rep = command_arg - 1;
2054 p_ptr->redraw |= (PR_STATE);
2056 /* Cancel the arg */
2060 /* Get a "repeated" direction */
2061 if (get_rep_dir(&dir, FALSE))
2063 take_turn(p_ptr, 100);
2065 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2067 set_action(ACTION_NONE);
2070 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2071 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2072 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2074 /* Actually move the character */
2075 move_player(dir, pickup, FALSE);
2077 /* Allow more walking */
2081 /* Hack again -- Is there a special encounter ??? */
2082 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2084 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2087 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2089 /* Inform the player of his horrible fate :=) */
2090 msg_print(_("襲撃だ!", "You are ambushed !"));
2092 /* Go into large wilderness view */
2093 p_ptr->oldpy = randint1(MAX_HGT-2);
2094 p_ptr->oldpx = randint1(MAX_WID-2);
2097 /* Give first move to monsters */
2098 take_turn(p_ptr, 100);
2100 /* HACk -- set the encouter flag for the wilderness generation */
2101 generate_encounter = TRUE;
2105 /* Cancel repeat unless we may continue */
2106 if (!more) disturb(FALSE, FALSE);
2111 * @brief 「走る」動作コマンドのメインルーチン /
2115 void do_cmd_run(void)
2118 if (cmd_limit_confused(p_ptr)) return;
2120 if (p_ptr->special_defense & KATA_MUSOU)
2122 set_action(ACTION_NONE);
2125 /* Get a "repeated" direction */
2126 if (get_rep_dir(&dir,FALSE))
2128 /* Hack -- Set the run counter */
2129 running = (command_arg ? command_arg : 1000);
2138 * @brief 「留まる」動作コマンドのメインルーチン /
2139 * Stay still. Search. Enter stores.
2140 * Pick up treasure if "pickup" is true.
2141 * @param pickup アイテムの自動拾いを行うならTRUE
2144 void do_cmd_stay(bool pickup)
2146 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2148 /* Allow repeated command */
2151 /* Set repeat count */
2152 command_rep = command_arg - 1;
2153 p_ptr->redraw |= (PR_STATE);
2155 /* Cancel the arg */
2159 take_turn(p_ptr, 100);
2161 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2162 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2167 * @brief 「休む」動作コマンドのメインルーチン /
2168 * Resting allows a player to safely restore his hp -RAK-
2171 void do_cmd_rest(void)
2174 set_action(ACTION_NONE);
2176 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2178 stop_singing(p_ptr);
2182 if (hex_spelling_any()) stop_hex_spell_all();
2184 /* Prompt for time if needed */
2185 if (command_arg <= 0)
2187 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2188 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2194 strcpy(out_val, "&");
2196 /* Ask for duration */
2197 if (!get_string(p, out_val, 4)) return;
2199 /* Rest until done */
2200 if (out_val[0] == '&')
2202 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2206 else if (out_val[0] == '*')
2208 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2214 command_arg = (COMMAND_ARG)atoi(out_val);
2215 if (command_arg <= 0) return;
2219 if (command_arg > 9999) command_arg = 9999;
2221 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2223 /* Take a current_world_ptr->game_turn (?) */
2224 take_turn(p_ptr, 100);
2226 /* The sin of sloth */
2227 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2229 /* Why are you sleeping when there's no need? WAKE UP!*/
2230 if ((p_ptr->chp == p_ptr->mhp) &&
2231 (p_ptr->csp == p_ptr->msp) &&
2232 !p_ptr->blind && !p_ptr->confused &&
2233 !p_ptr->poisoned && !p_ptr->afraid &&
2234 !p_ptr->stun && !p_ptr->cut &&
2235 !p_ptr->slow && !p_ptr->paralyzed &&
2236 !p_ptr->image && !p_ptr->word_recall &&
2237 !p_ptr->alter_reality)
2238 chg_virtue(V_DILIGENCE, -1);
2240 /* Save the rest code */
2241 p_ptr->resting = command_arg;
2242 p_ptr->action = ACTION_REST;
2243 p_ptr->update |= (PU_BONUS);
2244 update_creature(p_ptr);
2246 p_ptr->redraw |= (PR_STATE);
2255 * @brief 射撃処理のメインルーチン
2258 void do_cmd_fire(SPELL_IDX snipe_type)
2261 object_type *j_ptr, *ammo_ptr;
2264 if(p_ptr->wild_mode) return;
2266 is_fired = FALSE; /* not fired yet */
2268 /* Get the "bow" (if any) */
2269 j_ptr = &p_ptr->inventory_list[INVEN_BOW];
2271 /* Require a launcher */
2274 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2279 if (j_ptr->sval == SV_CRIMSON)
2281 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2286 if (j_ptr->sval == SV_HARP)
2288 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2294 if (p_ptr->special_defense & KATA_MUSOU)
2296 set_action(ACTION_NONE);
2299 /* Require proper missile */
2300 item_tester_tval = p_ptr->tval_ammo;
2302 q = _("どれを撃ちますか? ", "Fire which item? ");
2303 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2306 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2314 exe_fire(item, j_ptr, snipe_type);
2316 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2318 /* Sniper actions after some shootings */
2319 if (snipe_type == SP_AWAY)
2321 teleport_player(10 + (p_ptr->concent * 2), 0L);
2323 if (snipe_type == SP_FINAL)
2325 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2326 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2327 (void)set_stun(p_ptr->stun + randint1(25));
2333 * @brief 投射処理メインルーチン /
2334 * Throw an object from the pack or floor.
2336 * @param boomerang ブーメラン処理ならばTRUE
2337 * @param shuriken 忍者の手裏剣処理ならばTRUE
2338 * @return ターンを消費した場合TRUEを返す
2341 * Note: "unseen" monsters are very hard to hit.
2343 * Should throwing a weapon do full damage? Should it allow the magic
2344 * to hit bonus of the weapon to have an effect? Should it ever cause
2345 * the item to be destroyed? Should it do any damage at all?
2348 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2353 POSITION y, x, ty, tx, prev_y, prev_x;
2354 POSITION ny[19], nx[19];
2355 int chance, tdam, tdis;
2356 int mul, div, dd, ds;
2357 int cur_dis, visible;
2364 bool hit_body = FALSE;
2365 bool hit_wall = FALSE;
2366 bool equiped_item = FALSE;
2367 bool return_when_thrown = FALSE;
2369 GAME_TEXT o_name[MAX_NLEN];
2371 int msec = delay_factor * delay_factor * delay_factor;
2373 BIT_FLAGS flgs[TR_FLAG_SIZE];
2375 bool come_back = FALSE;
2376 bool do_drop = TRUE;
2378 if (p_ptr->wild_mode) return FALSE;
2380 if (p_ptr->special_defense & KATA_MUSOU)
2382 set_action(ACTION_NONE);
2388 o_ptr = &p_ptr->inventory_list[item];
2392 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2394 item_tester_hook = item_tester_hook_boomerang;
2395 q = _("どの武器を投げますか? ", "Throw which item? ");
2396 s = _("投げる武器がない。", "You have nothing to throw.");
2397 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2404 else if (has_melee_weapon(INVEN_LARM))
2407 o_ptr = &p_ptr->inventory_list[item];
2412 o_ptr = &p_ptr->inventory_list[item];
2417 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2418 s = _("投げるアイテムがない。", "You have nothing to throw.");
2419 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2427 /* Item is cursed */
2428 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2430 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2434 if (p_ptr->inside_arena && !boomerang)
2436 if (o_ptr->tval != TV_SPIKE)
2438 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2447 /* Obtain a local object */
2448 object_copy(q_ptr, o_ptr);
2450 /* Extract the thrown object's flags. */
2451 object_flags(q_ptr, flgs);
2452 torch_flags(q_ptr, flgs);
2454 /* Distribute the charges of rods/wands between the stacks */
2455 distribute_charges(o_ptr, q_ptr, 1);
2460 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2462 if (p_ptr->mighty_throw) mult += 3;
2464 /* Extract a "distance multiplier" */
2465 /* Changed for 'launcher' mutation */
2466 mul = 10 + 2 * (mult - 1);
2468 /* Enforce a minimum "weight" of one pound */
2469 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2470 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2472 /* Hack -- Distance -- Reward strength, penalize weight */
2473 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2475 /* Max distance of 10-18 */
2476 if (tdis > mul) tdis = mul;
2480 ty = randint0(101) - 50 + p_ptr->y;
2481 tx = randint0(101) - 50 + p_ptr->x;
2485 project_length = tdis + 1;
2487 /* Get a direction (or cancel) */
2488 if (!get_aim_dir(&dir)) return FALSE;
2490 /* Predict the "target" location */
2491 tx = p_ptr->x + 99 * ddx[dir];
2492 ty = p_ptr->y + 99 * ddy[dir];
2494 /* Check for "target request" */
2495 if ((dir == 5) && target_okay())
2501 project_length = 0; /* reset to default */
2504 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2505 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2506 return_when_thrown = TRUE;
2508 /* Reduce and describe p_ptr->inventory_list */
2511 inven_item_increase(item, -1);
2512 if (!return_when_thrown)
2513 inven_item_describe(item);
2514 inven_item_optimize(item);
2517 /* Reduce and describe floor item */
2520 floor_item_increase(0 - item, -1);
2521 floor_item_optimize(0 - item);
2523 if (item >= INVEN_RARM)
2525 equiped_item = TRUE;
2526 p_ptr->redraw |= (PR_EQUIPPY);
2529 take_turn(p_ptr, 100);
2531 /* Rogue and Ninja gets bonus */
2532 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2533 p_ptr->energy_use -= p_ptr->lev;
2535 /* Start at the player */
2541 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2542 else shuriken = FALSE;
2544 /* Chance of hitting */
2545 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2546 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2547 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2549 if (shuriken) chance *= 2;
2554 /* Travel until stopped */
2555 for (cur_dis = 0; cur_dis <= tdis; )
2557 /* Hack -- Stop at the target */
2558 if ((y == ty) && (x == tx)) break;
2560 /* Calculate the new location (see "project()") */
2563 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2565 /* Stopped by walls/doors */
2566 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2569 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;
2572 /* The player can see the (on screen) missile */
2573 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2575 SYMBOL_CODE c = object_char(q_ptr);
2576 TERM_COLOR a = object_attr(q_ptr);
2578 /* Draw, Hilite, Fresh, Pause, Erase */
2579 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2580 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2582 Term_xtra(TERM_XTRA_DELAY, msec);
2583 lite_spot(ny[cur_dis], nx[cur_dis]);
2587 /* The player cannot see the missile */
2590 /* Pause anyway, for consistancy */
2591 Term_xtra(TERM_XTRA_DELAY, msec);
2597 /* Save the new location */
2601 /* Advance the distance */
2604 /* Monster here, Try to hit it */
2605 if (current_floor_ptr->grid_array[y][x].m_idx)
2607 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2608 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2609 GAME_TEXT m_name[MAX_NLEN];
2610 monster_name(g_ptr->m_idx, m_name);
2612 /* Check the visibility */
2613 visible = m_ptr->ml;
2615 /* Note the collision */
2618 /* Did we hit it (penalize range) */
2619 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2623 /* Handle unseen monster */
2626 /* Invisible monster */
2627 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2630 /* Handle visible monster */
2633 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2637 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2638 health_track(g_ptr->m_idx);
2642 /* Hack -- Base damage from thrown object */
2645 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2646 tdam = damroll(dd, ds);
2647 /* Apply special damage */
2648 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2649 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2650 if (q_ptr->to_d > 0)
2651 tdam += q_ptr->to_d;
2653 tdam += -q_ptr->to_d;
2657 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2658 tdam += p_ptr->to_d_m;
2660 else if (have_flag(flgs, TR_THROW))
2663 tdam += p_ptr->to_d_m;
2671 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2674 /* No negative damage */
2675 if (tdam < 0) tdam = 0;
2677 /* Modify the damage */
2678 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2680 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2681 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2683 /* Hit the monster, check for death */
2684 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2692 message_pain(g_ptr->m_idx, tdam);
2694 /* Anger the monster */
2695 if ((tdam > 0) && !object_is_potion(q_ptr))
2696 anger_monster(m_ptr);
2698 if (fear && m_ptr->ml)
2701 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2711 /* decrease toach's fuel */
2712 if (hit_body) torch_lost_fuel(q_ptr);
2714 /* Chance of breakage (during attacks) */
2715 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2717 /* Figurines transform */
2718 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2722 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2723 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2724 else if (object_is_cursed(q_ptr))
2725 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2729 /* Potions smash open */
2730 if (object_is_potion(q_ptr))
2732 if (hit_body || hit_wall || (randint1(100) < j))
2734 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2736 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2738 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2739 if (current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2741 GAME_TEXT m_name[MAX_NLEN];
2742 monster_desc(m_name, m_ptr, 0);
2743 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2744 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2755 if (return_when_thrown)
2757 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2758 char o2_name[MAX_NLEN];
2759 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2762 if (boomerang) back_chance += 4+randint1(5);
2763 if (super_boomerang) back_chance += 100;
2764 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2766 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2768 for (i = cur_dis - 1; i > 0; i--)
2770 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2772 char c = object_char(q_ptr);
2773 byte a = object_attr(q_ptr);
2775 /* Draw, Hilite, Fresh, Pause, Erase */
2776 print_rel(c, a, ny[i], nx[i]);
2777 move_cursor_relative(ny[i], nx[i]);
2779 Term_xtra(TERM_XTRA_DELAY, msec);
2780 lite_spot(ny[i], nx[i]);
2785 /* Pause anyway, for consistancy */
2786 Term_xtra(TERM_XTRA_DELAY, msec);
2789 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2791 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2798 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2802 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2810 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2816 if (item == INVEN_RARM || item == INVEN_LARM)
2818 /* Access the wield slot */
2819 o_ptr = &p_ptr->inventory_list[item];
2821 /* Wear the new stuff */
2822 object_copy(o_ptr, q_ptr);
2824 p_ptr->total_weight += q_ptr->weight;
2826 /* Increment the equip counter by hand */
2829 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2830 p_ptr->window |= (PW_EQUIP);
2838 else if (equiped_item)
2846 if (cave_have_flag_bold(y, x, FF_PROJECT))
2848 (void)drop_near(q_ptr, j, y, x);
2852 (void)drop_near(q_ptr, j, prev_y, prev_x);
2860 * @brief 自殺するコマンドのメインルーチン
2861 * Hack -- commit suicide
2865 void do_cmd_suicide(void)
2872 /* Verify Retirement */
2873 if (p_ptr->total_winner)
2876 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2879 /* Verify Suicide */
2883 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2887 if (!p_ptr->noscore)
2889 /* Special Verification for suicide */
2890 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2895 if (i != '@') return;
2897 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2900 /* Initialize "last message" buffer */
2901 if (p_ptr->last_message) string_free(p_ptr->last_message);
2902 p_ptr->last_message = NULL;
2904 /* Hack -- Note *winning* message */
2905 if (p_ptr->total_winner && last_words)
2907 char buf[1024] = "";
2908 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2911 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2912 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2916 p_ptr->last_message = string_make(buf);
2917 msg_print(p_ptr->last_message);
2922 p_ptr->playing = FALSE;
2924 /* Kill the player */
2925 p_ptr->is_dead = TRUE;
2926 p_ptr->leaving = TRUE;
2928 if (!p_ptr->total_winner)
2930 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
2931 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2932 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
2935 /* Cause of death */
2936 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));