3 * @brief プレイヤーのコマンド処理2 / Movement commands (part 2)
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
17 #include "object-hook.h"
18 #include "projection.h"
19 #include "spells-summon.h"
20 #include "spells-status.h"
21 #include "monster-status.h"
25 #include "player-status.h"
26 #include "realm-hex.h"
31 #include "player-move.h"
32 #include "object-broken.h"
35 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
36 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
37 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
39 static bool confirm_leave_level(bool down_stair)
41 quest_type *q_ptr = &quest[p_ptr->inside_quest];
43 /* Confirm leaving from once only quest */
44 if (confirm_quest && p_ptr->inside_quest &&
45 (q_ptr->type == QUEST_TYPE_RANDOM ||
46 (q_ptr->flags & QUEST_FLAG_ONCE &&
47 q_ptr->status != QUEST_STATUS_COMPLETED) ||
48 (q_ptr->flags & QUEST_FLAG_TOWER &&
49 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
50 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
52 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
53 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
63 * @brief 魔法系コマンドが制限されているかを返す。
64 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
66 bool cmd_limit_cast(player_type *creature_ptr)
68 if (current_floor_ptr->dun_level && (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
70 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
74 else if (creature_ptr->anti_magic)
76 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
79 else if (creature_ptr->shero)
81 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
88 bool cmd_limit_confused(player_type *creature_ptr)
90 if (creature_ptr->confused)
92 msg_print(_("混乱していてできない!", "You are too confused!"));
98 bool cmd_limit_image(player_type *creature_ptr)
100 if (creature_ptr->image)
102 msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
108 bool cmd_limit_stun(player_type *creature_ptr)
110 if (creature_ptr->stun)
112 msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
118 bool cmd_limit_arena(player_type *creature_ptr)
120 if (creature_ptr->inside_arena)
122 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
129 bool cmd_limit_blind(player_type *creature_ptr)
131 if (creature_ptr->blind)
133 msg_print(_("目が見えない。", "You can't see anything."));
138 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
144 bool cmd_limit_time_walk(player_type *creature_ptr)
146 if (creature_ptr->timewalk)
148 if (flush_failure) flush();
149 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
157 * @brief 階段を使って階層を昇る処理 / Go up one level
160 void do_cmd_go_up(void)
165 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
166 feature_type *f_ptr = &f_info[g_ptr->feat];
170 if (p_ptr->special_defense & KATA_MUSOU)
172 set_action(ACTION_NONE);
176 if (!have_flag(f_ptr->flags, FF_LESS))
178 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
182 /* Quest up stairs */
183 if (have_flag(f_ptr->flags, FF_QUEST))
185 /* Cancel the command */
186 if (!confirm_leave_level(FALSE)) return;
190 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
191 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
193 msg_print(_("上の階に登った。", "You enter the up staircase."));
197 p_ptr->inside_quest = g_ptr->special;
199 /* Activate the quest */
200 if (!quest[p_ptr->inside_quest].status)
202 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
204 init_flags = INIT_ASSIGN;
205 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
207 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
210 /* Leaving a quest */
211 if (!p_ptr->inside_quest)
213 current_floor_ptr->dun_level = 0;
215 p_ptr->leaving = TRUE;
220 take_turn(p_ptr, 100);
222 /* End the command */
226 if (!current_floor_ptr->dun_level)
232 go_up = confirm_leave_level(FALSE);
235 /* Cancel the command */
238 take_turn(p_ptr, 100);
240 if (autosave_l) do_cmd_save_game(TRUE);
242 /* For a random quest */
243 if (p_ptr->inside_quest &&
244 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
248 p_ptr->inside_quest = 0;
251 /* For a fixed quest */
252 if (p_ptr->inside_quest &&
253 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
257 p_ptr->inside_quest = g_ptr->special;
258 current_floor_ptr->dun_level = 0;
262 /* For normal dungeon and random quest */
266 if (have_flag(f_ptr->flags, FF_SHAFT))
268 /* Create a way back */
269 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
275 /* Create a way back */
276 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
281 /* Get out from current dungeon */
282 if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth)
283 up_num = current_floor_ptr->dun_level;
285 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
288 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
289 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
290 else if (up_num == current_floor_ptr->dun_level)
291 msg_print(_("地上に戻った。", "You go back to the surface."));
293 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
294 p_ptr->leaving = TRUE;
299 * @brief 階段を使って階層を降りる処理 / Go down one level
302 void do_cmd_go_down(void)
305 grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
306 feature_type *f_ptr = &f_info[g_ptr->feat];
308 bool fall_trap = FALSE;
311 if (p_ptr->special_defense & KATA_MUSOU)
313 set_action(ACTION_NONE);
317 if (!have_flag(f_ptr->flags, FF_MORE))
319 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
323 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
326 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
331 /* Quest down stairs */
332 else if (have_flag(f_ptr->flags, FF_QUEST))
334 /* Confirm Leaving */
335 if(!confirm_leave_level(TRUE)) return;
337 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
338 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
340 msg_print(_("下の階に降りた。", "You enter the down staircase."));
345 p_ptr->inside_quest = g_ptr->special;
347 /* Activate the quest */
348 if (!quest[p_ptr->inside_quest].status)
350 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
352 init_flags = INIT_ASSIGN;
353 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
355 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
358 /* Leaving a quest */
359 if (!p_ptr->inside_quest)
361 current_floor_ptr->dun_level = 0;
363 p_ptr->leaving = TRUE;
367 take_turn(p_ptr, 100);
372 DUNGEON_IDX target_dungeon = 0;
374 if (!current_floor_ptr->dun_level)
376 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
378 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
380 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
383 if (!max_dlv[target_dungeon])
385 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
386 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
387 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
390 /* Save old player position */
391 p_ptr->oldpx = p_ptr->x;
392 p_ptr->oldpy = p_ptr->y;
393 p_ptr->dungeon_idx = target_dungeon;
396 * Clear all saved floors
397 * and create a first saved floor
399 prepare_change_floor_mode(CFM_FIRST_FLOOR);
402 take_turn(p_ptr, 100);
404 if (autosave_l) do_cmd_save_game(TRUE);
407 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
410 if (!current_floor_ptr->dun_level)
412 /* Enter the dungeon just now */
413 p_ptr->enter_dungeon = TRUE;
414 down_num = d_info[p_ptr->dungeon_idx].mindepth;
419 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
420 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
425 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
432 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text);
436 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
437 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
439 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
443 p_ptr->leaving = TRUE;
447 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
451 if (have_flag(f_ptr->flags, FF_SHAFT))
453 /* Create a way back */
454 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
458 /* Create a way back */
459 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
467 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn
470 void do_cmd_search(void)
472 /* Allow repeated command */
475 /* Set repeat count */
476 command_rep = command_arg - 1;
477 p_ptr->redraw |= (PR_STATE);
482 take_turn(p_ptr, 100);
490 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
491 * @param y 走査対象にしたいマスのY座標
492 * @param x 走査対象にしたいマスのX座標
493 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
494 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
496 static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped)
498 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
499 OBJECT_IDX this_o_idx, next_o_idx = 0;
501 /* Scan all objects in the grid */
502 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
506 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
507 next_o_idx = o_ptr->next_o_idx;
509 /* Skip unknown chests XXX XXX */
510 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
512 /* Check for non empty chest */
513 if ((o_ptr->tval == TV_CHEST) &&
514 (((!trapped) && (o_ptr->pval)) || /* non empty */
515 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
524 * @brief 箱を開けるコマンドのメインルーチン /
525 * Attempt to open the given chest at the given location
526 * @param y 箱の存在するマスのY座標
527 * @param x 箱の存在するマスのX座標
528 * @param o_idx 箱のオブジェクトID
529 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
531 * Assume there is no monster blocking the destination
533 static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
538 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
540 take_turn(p_ptr, 100);
542 /* Attempt to unlock it */
545 /* Assume locked, and thus not open */
548 /* Get the "disarm" factor */
549 i = p_ptr->skill_dis;
551 /* Penalize some conditions */
552 if (p_ptr->blind || no_lite()) i = i / 10;
553 if (p_ptr->confused || p_ptr->image) i = i / 10;
555 /* Extract the difficulty */
558 /* Always have a small chance of success */
561 /* Success -- May still have traps */
562 if (randint0(100) < j)
564 msg_print(_("鍵をはずした。", "You have picked the lock."));
569 /* Failure -- Keep trying */
572 /* We may continue repeating */
574 if (flush_failure) flush();
575 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
580 /* Allowed to open */
583 /* Apply chest traps, if any */
584 chest_trap(y, x, o_idx);
586 /* Let the Chest drop items */
587 chest_death(FALSE, y, x, o_idx);
593 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
594 * Attempt to open the given chest at the given location
595 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
596 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
597 * @param test 地形条件を判定するための関数ポインタ
598 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
600 * @details Return the number of features around (or under) the character.
601 * Usually look for doors and floor traps.
603 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
609 /* Count how many matches */
612 /* Check around (and under) the character */
613 for (d = 0; d < 9; d++)
618 /* if not searching under player continue */
619 if ((d == 8) && !under) continue;
621 /* Extract adjacent (legal) location */
622 yy = p_ptr->y + ddy_ddd[d];
623 xx = p_ptr->x + ddx_ddd[d];
625 /* Get the current_floor_ptr->grid_array */
626 g_ptr = ¤t_floor_ptr->grid_array[yy][xx];
628 /* Must have knowledge */
629 if (!(g_ptr->info & (CAVE_MARK))) continue;
631 /* Feature code (applying "mimic" field) */
632 feat = get_feat_mimic(g_ptr);
634 /* Not looking for this feature */
635 if (!((*test)(feat))) continue;
640 /* Remember the location. Only useful if only one match */
651 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
652 * Return the number of chests around (or under) the character.
653 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
654 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
655 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
658 * If requested, count only trapped chests.
660 static int count_chests(POSITION *y, POSITION *x, bool trapped)
667 /* Count how many matches */
670 /* Check around (and under) the character */
671 for (d = 0; d < 9; d++)
673 /* Extract adjacent (legal) location */
674 POSITION yy = p_ptr->y + ddy_ddd[d];
675 POSITION xx = p_ptr->x + ddx_ddd[d];
677 /* No (visible) chest is there */
678 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
680 /* Grab the object */
681 o_ptr = ¤t_floor_ptr->o_list[o_idx];
684 if (o_ptr->pval == 0) continue;
686 /* No (known) traps here */
687 if (trapped && (!object_is_known(o_ptr) ||
688 !chest_traps[o_ptr->pval])) continue;
693 /* Remember the location. Only useful if only one match */
705 * @brief 「開ける」動作コマンドのサブルーチン /
706 * Perform the basic "open" command on doors
707 * @param y 対象を行うマスのY座標
708 * @param x 対象を行うマスのX座標
709 * @return 実際に処理が行われた場合TRUEを返す。
711 * Assume destination is a closed/locked/jammed door
712 * Assume there is no monster blocking the destination
713 * Returns TRUE if repeated commands may continue
715 static bool do_cmd_open_aux(POSITION y, POSITION x)
719 /* Get requested grid */
720 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
721 feature_type *f_ptr = &f_info[g_ptr->feat];
724 take_turn(p_ptr, 100);
726 /* Seeing true feature code (ignore mimic) */
729 if (!have_flag(f_ptr->flags, FF_OPEN))
732 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
736 else if (f_ptr->power)
739 i = p_ptr->skill_dis;
741 /* Penalize some conditions */
742 if (p_ptr->blind || no_lite()) i = i / 10;
743 if (p_ptr->confused || p_ptr->image) i = i / 10;
745 /* Extract the lock power */
748 /* Extract the difficulty */
751 /* Always have a small chance of success */
755 if (randint0(100) < j)
757 msg_print(_("鍵をはずした。", "You have picked the lock."));
760 cave_alter_feat(y, x, FF_OPEN);
762 sound(SOUND_OPENDOOR);
772 if (flush_failure) flush();
774 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
776 /* We may keep trying */
785 cave_alter_feat(y, x, FF_OPEN);
787 sound(SOUND_OPENDOOR);
793 * @brief 「開ける」コマンドのメインルーチン /
794 * Open a closed/locked/jammed door or a closed/locked chest.
797 * Unlocking a locked door/chest is worth one experience point.
799 void do_cmd_open(void)
807 if (p_ptr->wild_mode) return;
809 if (p_ptr->special_defense & KATA_MUSOU)
811 set_action(ACTION_NONE);
814 /* Option: Pick a direction */
817 int num_doors, num_chests;
819 /* Count closed doors (locked or jammed) */
820 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
822 /* Count chests (locked) */
823 num_chests = count_chests(&y, &x, FALSE);
825 /* See if only one target */
826 if (num_doors || num_chests)
828 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
830 if (!too_many) command_dir = coords_to_dir(y, x);
834 /* Allow repeated command */
837 /* Set repeat count */
838 command_rep = command_arg - 1;
839 p_ptr->redraw |= (PR_STATE);
845 /* Get a "repeated" direction */
846 if (get_rep_dir(&dir, TRUE))
851 /* Get requested location */
852 y = p_ptr->y + ddy[dir];
853 x = p_ptr->x + ddx[dir];
855 /* Get requested grid */
856 g_ptr = ¤t_floor_ptr->grid_array[y][x];
858 /* Feature code (applying "mimic" field) */
859 feat = get_feat_mimic(g_ptr);
861 /* Check for chest */
862 o_idx = chest_check(y, x, FALSE);
865 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
867 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
870 /* Monster in the way */
871 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
873 take_turn(p_ptr, 100);
874 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
882 more = do_cmd_open_chest(y, x, o_idx);
889 more = do_cmd_open_aux(y, x);
893 /* Cancel repeat unless we may continue */
894 if (!more) disturb(FALSE, FALSE);
900 * @brief 「閉じる」動作コマンドのサブルーチン /
901 * Perform the basic "close" command
902 * @param y 対象を行うマスのY座標
903 * @param x 対象を行うマスのX座標
904 * @return 実際に処理が行われた場合TRUEを返す。
906 * Assume destination is an open/broken door
907 * Assume there is no monster blocking the destination
908 * Returns TRUE if repeated commands may continue
910 static bool do_cmd_close_aux(POSITION y, POSITION x)
912 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
913 FEAT_IDX old_feat = g_ptr->feat;
916 take_turn(p_ptr, 100);
918 /* Seeing true feature code (ignore mimic) */
921 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
923 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
925 /* Hack -- object in the way */
926 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
927 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
929 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
934 cave_alter_feat(y, x, FF_CLOSE);
937 if (old_feat == g_ptr->feat)
939 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
943 sound(SOUND_SHUTDOOR);
952 * @brief 「閉じる」コマンドのメインルーチン /
953 * Close an open door.
956 * Unlocking a locked door/chest is worth one experience point.
958 void do_cmd_close(void)
965 if (p_ptr->wild_mode) return;
967 if (p_ptr->special_defense & KATA_MUSOU)
969 set_action(ACTION_NONE);
972 /* Option: Pick a direction */
975 /* Count open doors */
976 if (count_dt(&y, &x, is_open, FALSE) == 1)
978 command_dir = coords_to_dir(y, x);
982 /* Allow repeated command */
985 /* Set repeat count */
986 command_rep = command_arg - 1;
987 p_ptr->redraw |= (PR_STATE);
993 /* Get a "repeated" direction */
994 if (get_rep_dir(&dir, FALSE))
999 y = p_ptr->y + ddy[dir];
1000 x = p_ptr->x + ddx[dir];
1001 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1003 /* Feature code (applying "mimic" field) */
1004 feat = get_feat_mimic(g_ptr);
1006 /* Require open/broken door */
1007 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1009 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1012 /* Monster in the way */
1013 else if (g_ptr->m_idx)
1015 take_turn(p_ptr, 100);
1017 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1023 /* Close the door */
1026 /* Close the door */
1027 more = do_cmd_close_aux(y, x);
1031 /* Cancel repeat unless we may continue */
1032 if (!more) disturb(FALSE, FALSE);
1037 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1038 * Determine if a given grid may be "tunneled"
1039 * @param y 対象を行うマスのY座標
1040 * @param x 対象を行うマスのX座標
1043 static bool do_cmd_tunnel_test(POSITION y, POSITION x)
1045 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1047 /* Must have knowledge */
1048 if (!(g_ptr->info & CAVE_MARK))
1050 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1055 /* Must be a wall/door/etc */
1056 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1058 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1068 * @brief 「掘る」動作コマンドのサブルーチン /
1069 * Perform the basic "tunnel" command
1070 * @param y 対象を行うマスのY座標
1071 * @param x 対象を行うマスのX座標
1072 * @return 実際に処理が行われた場合TRUEを返す。
1074 * Assumes that no monster is blocking the destination
1075 * Do not use twall anymore
1076 * Returns TRUE if repeated commands may continue
1078 static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
1081 feature_type *f_ptr, *mimic_f_ptr;
1086 /* Verify legality */
1087 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1089 take_turn(p_ptr, 100);
1091 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1092 f_ptr = &f_info[g_ptr->feat];
1093 power = f_ptr->power;
1095 /* Feature code (applying "mimic" field) */
1096 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1098 name = f_name + mimic_f_ptr->name;
1102 if (have_flag(f_ptr->flags, FF_PERMANENT))
1105 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1107 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1110 /* Map border (mimiccing Permanent wall) */
1113 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1118 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1121 if (p_ptr->skill_dig > randint0(20 * power))
1123 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1125 /* Remove the feature */
1126 cave_alter_feat(y, x, FF_TUNNEL);
1127 p_ptr->update |= (PU_FLOW);
1131 /* Message, keep digging */
1132 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1140 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1143 if (p_ptr->skill_dig > power + randint0(40 * power))
1145 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1148 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1149 p_ptr->update |= (PU_FLOW);
1152 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1154 /* Remove the feature */
1155 cave_alter_feat(y, x, FF_TUNNEL);
1157 chg_virtue(V_DILIGENCE, 1);
1158 chg_virtue(V_NATURE, -1);
1166 /* We may continue chopping */
1167 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1168 /* Occasional Search XXX XXX */
1169 if (randint0(100) < 25) search();
1173 /* We may continue tunelling */
1174 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1181 if (is_hidden_door(g_ptr))
1183 /* Occasional Search XXX XXX */
1184 if (randint0(100) < 25) search();
1191 * @brief 「掘る」動作コマンドのメインルーチン /
1192 * Tunnels through "walls" (including rubble and closed doors)
1196 * Note that you must tunnel in order to hit invisible monsters
1197 * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
1199 * Digging is very difficult without a "digger" weapon, but can be
1200 * accomplished by strong players using heavy weapons.
1203 void do_cmd_tunnel(void)
1212 if (p_ptr->special_defense & KATA_MUSOU)
1214 set_action(ACTION_NONE);
1217 /* Allow repeated command */
1220 /* Set repeat count */
1221 command_rep = command_arg - 1;
1222 p_ptr->redraw |= (PR_STATE);
1224 /* Cancel the arg */
1228 /* Get a direction to tunnel, or Abort */
1229 if (get_rep_dir(&dir,FALSE))
1232 y = p_ptr->y + ddy[dir];
1233 x = p_ptr->x + ddx[dir];
1235 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1237 /* Feature code (applying "mimic" field) */
1238 feat = get_feat_mimic(g_ptr);
1240 /* No tunnelling through doors */
1241 if (have_flag(f_info[feat].flags, FF_DOOR))
1243 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1246 /* No tunnelling through most features */
1247 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1249 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1252 /* A monster is in the way */
1253 else if (g_ptr->m_idx)
1255 take_turn(p_ptr, 100);
1257 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1266 /* Tunnel through walls */
1267 more = do_cmd_tunnel_aux(y, x);
1271 /* Cancel repetition unless we can continue */
1272 if (!more) disturb(FALSE, FALSE);
1276 * @brief 移動処理による簡易な「開く」処理 /
1278 * @return 開く処理が実際に試みられた場合TRUEを返す
1281 * If there is a jammed/closed/locked door at the given location,
1282 * then attempt to unlock/open it. Return TRUE if an attempt was
1283 * made (successful or not), otherwise return FALSE.
1285 * The code here should be nearly identical to that in
1286 * do_cmd_open_test() and do_cmd_open_aux().
1289 bool easy_open_door(POSITION y, POSITION x)
1293 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1294 feature_type *f_ptr = &f_info[g_ptr->feat];
1296 /* Must be a closed door */
1297 if (!is_closed_door(g_ptr->feat))
1303 if (!have_flag(f_ptr->flags, FF_OPEN))
1306 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1311 else if (f_ptr->power)
1314 i = p_ptr->skill_dis;
1316 /* Penalize some conditions */
1317 if (p_ptr->blind || no_lite()) i = i / 10;
1318 if (p_ptr->confused || p_ptr->image) i = i / 10;
1320 /* Extract the lock power */
1323 /* Extract the difficulty */
1326 /* Always have a small chance of success */
1330 if (randint0(100) < j)
1332 msg_print(_("鍵をはずした。", "You have picked the lock."));
1335 cave_alter_feat(y, x, FF_OPEN);
1337 sound(SOUND_OPENDOOR);
1347 if (flush_failure) flush();
1349 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1358 cave_alter_feat(y, x, FF_OPEN);
1360 sound(SOUND_OPENDOOR);
1366 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1367 * Perform the basic "disarm" command
1368 * @param y 解除を行うマスのY座標
1369 * @param x 解除を行うマスのX座標
1370 * @param o_idx 箱のオブジェクトID
1371 * @return ターンを消費する処理が行われた場合TRUEを返す
1374 * Assume destination is a visible trap
1375 * Assume there is no monster blocking the destination
1376 * Returns TRUE if repeated commands may continue
1379 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1383 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1385 take_turn(p_ptr, 100);
1387 /* Get the "disarm" factor */
1388 i = p_ptr->skill_dis;
1390 /* Penalize some conditions */
1391 if (p_ptr->blind || no_lite()) i = i / 10;
1392 if (p_ptr->confused || p_ptr->image) i = i / 10;
1394 /* Extract the difficulty */
1395 j = i - o_ptr->pval;
1397 /* Always have a small chance of success */
1400 /* Must find the trap first. */
1401 if (!object_is_known(o_ptr))
1403 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1407 /* Already disarmed/unlocked */
1408 else if (o_ptr->pval <= 0)
1410 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1413 /* No traps to find. */
1414 else if (!chest_traps[o_ptr->pval])
1416 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1419 /* Success (get a lot of experience) */
1420 else if (randint0(100) < j)
1422 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1423 gain_exp(o_ptr->pval);
1424 o_ptr->pval = (0 - o_ptr->pval);
1427 /* Failure -- Keep trying */
1428 else if ((i > 5) && (randint1(i) > 5))
1430 /* We may keep trying */
1432 if (flush_failure) flush();
1433 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1436 /* Failure -- Set off the trap */
1439 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1441 chest_trap(y, x, o_idx);
1448 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1449 * Perform the basic "disarm" command
1450 * @param y 解除を行うマスのY座標
1451 * @param x 解除を行うマスのX座標
1452 * @param dir プレイヤーからみた方向ID
1453 * @return ターンを消費する処理が行われた場合TRUEを返す
1456 * Assume destination is a visible trap
1457 * Assume there is no monster blocking the destination
1458 * Returns TRUE if repeated commands may continue
1462 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1464 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1467 feature_type *f_ptr = &f_info[g_ptr->feat];
1469 /* Access trap name */
1470 concptr name = (f_name + f_ptr->name);
1472 /* Extract trap "power" */
1473 int power = f_ptr->power;
1476 /* Get the "disarm" factor */
1477 int i = p_ptr->skill_dis;
1480 take_turn(p_ptr, 100);
1482 /* Penalize some conditions */
1483 if (p_ptr->blind || no_lite()) i = i / 10;
1484 if (p_ptr->confused || p_ptr->image) i = i / 10;
1486 /* Extract the difficulty */
1489 /* Always have a small chance of success */
1493 if (randint0(100) < j)
1495 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1500 /* Remove the trap */
1501 cave_alter_feat(y, x, FF_DISARM);
1503 /* Move the player onto the trap */
1504 move_player(dir, easy_disarm, FALSE);
1507 /* Failure -- Keep trying */
1508 else if ((i > 5) && (randint1(i) > 5))
1511 if (flush_failure) flush();
1513 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1515 /* We may keep trying */
1519 /* Failure -- Set off the trap */
1522 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1523 /* Move the player onto the trap */
1524 move_player(dir, easy_disarm, FALSE);
1531 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1532 * Disarms a trap, or chest
1535 void do_cmd_disarm(void)
1543 if (p_ptr->wild_mode) return;
1545 if (p_ptr->special_defense & KATA_MUSOU)
1547 set_action(ACTION_NONE);
1550 /* Option: Pick a direction */
1553 int num_traps, num_chests;
1555 /* Count visible traps */
1556 num_traps = count_dt(&y, &x, is_trap, TRUE);
1558 /* Count chests (trapped) */
1559 num_chests = count_chests(&y, &x, TRUE);
1561 /* See if only one target */
1562 if (num_traps || num_chests)
1564 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1565 if (!too_many) command_dir = coords_to_dir(y, x);
1570 /* Allow repeated command */
1573 /* Set repeat count */
1574 command_rep = command_arg - 1;
1575 p_ptr->redraw |= (PR_STATE);
1577 /* Cancel the arg */
1581 /* Get a direction (or abort) */
1582 if (get_rep_dir(&dir,TRUE))
1587 y = p_ptr->y + ddy[dir];
1588 x = p_ptr->x + ddx[dir];
1589 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1591 /* Feature code (applying "mimic" field) */
1592 feat = get_feat_mimic(g_ptr);
1594 /* Check for chests */
1595 o_idx = chest_check(y, x, TRUE);
1598 if (!is_trap(feat) && !o_idx)
1600 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1603 /* Monster in the way */
1604 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1606 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1615 more = do_cmd_disarm_chest(y, x, o_idx);
1621 more = do_cmd_disarm_aux(y, x, dir);
1625 /* Cancel repeat unless told not to */
1626 if (!more) disturb(FALSE, FALSE);
1631 * @brief 「打ち破る」動作コマンドのサブルーチン /
1632 * Perform the basic "bash" command
1633 * @param y 対象を行うマスのY座標
1634 * @param x 対象を行うマスのX座標
1635 * @param dir プレイヤーから見たターゲットの方角ID
1636 * @return 実際に処理が行われた場合TRUEを返す。
1639 * Assume destination is a closed/locked/jammed door
1640 * Assume there is no monster blocking the destination
1641 * Returns TRUE if repeated commands may continue
1644 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1646 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1649 feature_type *f_ptr = &f_info[g_ptr->feat];
1651 /* Hack -- Bash power based on strength */
1652 /* (Ranges from 3 to 20 to 100 to 200) */
1653 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1655 /* Extract door power */
1656 int temp = f_ptr->power;
1660 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1662 take_turn(p_ptr, 100);
1664 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1666 /* Compare bash power to door power */
1667 temp = (bash - (temp * 10));
1669 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1671 /* Hack -- always have a chance */
1672 if (temp < 1) temp = 1;
1674 /* Hack -- attempt to bash down the door */
1675 if (randint0(100) < temp)
1677 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1679 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1681 /* Break down the door */
1682 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1684 cave_alter_feat(y, x, FF_BASH);
1690 cave_alter_feat(y, x, FF_OPEN);
1693 /* Hack -- Fall through the door */
1694 move_player(dir, FALSE, FALSE);
1697 /* Saving throw against stun */
1698 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1701 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1703 /* Allow repeated bashing */
1707 /* High dexterity yields coolness */
1710 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1712 /* Hack -- Lose balance ala paralysis */
1713 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1720 * @brief 「打ち破る」動作コマンドのメインルーチン /
1721 * Bash open a door, success based on character strength
1725 * For a closed door, pval is positive if locked; negative if stuck.
1727 * For an open door, pval is positive for a broken door.
1729 * A closed door can be opened - harder if locked. Any door might be
1730 * bashed open (and thereby broken). Bashing a door is (potentially)
1731 * faster! You move into the door way. To open a stuck door, it must
1732 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1734 * Creatures can also open or bash doors, see elsewhere.
1737 void do_cmd_bash(void)
1743 if (p_ptr->wild_mode) return;
1745 if (p_ptr->special_defense & KATA_MUSOU)
1747 set_action(ACTION_NONE);
1750 /* Allow repeated command */
1753 /* Set repeat count */
1754 command_rep = command_arg - 1;
1755 p_ptr->redraw |= (PR_STATE);
1757 /* Cancel the arg */
1761 /* Get a "repeated" direction */
1762 if (get_rep_dir(&dir,FALSE))
1767 y = p_ptr->y + ddy[dir];
1768 x = p_ptr->x + ddx[dir];
1770 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1772 /* Feature code (applying "mimic" field) */
1773 feat = get_feat_mimic(g_ptr);
1775 /* Nothing useful */
1776 if (!have_flag(f_info[feat].flags, FF_BASH))
1778 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1781 /* Monster in the way */
1782 else if (g_ptr->m_idx)
1784 take_turn(p_ptr, 100);
1786 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1792 /* Bash a closed door */
1796 more = do_cmd_bash_aux(y, x, dir);
1800 /* Unless valid action taken, cancel bash */
1801 if (!more) disturb(FALSE, FALSE);
1806 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1810 * Manipulate an adjacent grid in some way
1812 * Attack monsters, tunnel through walls, disarm traps, open doors.
1814 * Consider confusion
1816 * This command must always take a current_world_ptr->game_turn, to prevent free detection
1817 * of invisible monsters.
1820 void do_cmd_alter(void)
1827 if (p_ptr->special_defense & KATA_MUSOU)
1829 set_action(ACTION_NONE);
1832 /* Allow repeated command */
1835 /* Set repeat count */
1836 command_rep = command_arg - 1;
1837 p_ptr->redraw |= (PR_STATE);
1839 /* Cancel the arg */
1843 /* Get a direction */
1844 if (get_rep_dir(&dir,TRUE))
1847 feature_type *f_ptr;
1849 y = p_ptr->y + ddy[dir];
1850 x = p_ptr->x + ddx[dir];
1852 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1854 /* Feature code (applying "mimic" field) */
1855 feat = get_feat_mimic(g_ptr);
1856 f_ptr = &f_info[feat];
1858 take_turn(p_ptr, 100);
1866 else if (have_flag(f_ptr->flags, FF_OPEN))
1868 more = do_cmd_open_aux(y, x);
1871 /* Bash jammed doors */
1872 else if (have_flag(f_ptr->flags, FF_BASH))
1874 more = do_cmd_bash_aux(y, x, dir);
1877 /* Tunnel through walls */
1878 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1880 more = do_cmd_tunnel_aux(y, x);
1883 /* Close open doors */
1884 else if (have_flag(f_ptr->flags, FF_CLOSE))
1886 more = do_cmd_close_aux(y, x);
1890 else if (have_flag(f_ptr->flags, FF_DISARM))
1892 more = do_cmd_disarm_aux(y, x, dir);
1897 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1901 /* Cancel repetition unless we can continue */
1902 if (!more) disturb(FALSE, FALSE);
1908 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1909 * Find the index of some "spikes", if possible.
1910 * @param ip くさびとして打てるオブジェクトのID
1911 * @return オブジェクトがある場合TRUEを返す
1914 * Let user choose a pile of spikes, perhaps?
1917 static bool get_spike(INVENTORY_IDX *ip)
1921 /* Check every item in the pack */
1922 for (i = 0; i < INVEN_PACK; i++)
1924 object_type *o_ptr = &inventory[i];
1926 /* Skip non-objects */
1927 if (!o_ptr->k_idx) continue;
1929 /* Check the "tval" code */
1930 if (o_ptr->tval == TV_SPIKE)
1932 /* Save the spike index */
1945 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1946 * Jam a closed door with a spike
1950 * This command may NOT be repeated
1953 void do_cmd_spike(void)
1957 if (p_ptr->wild_mode) return;
1959 if (p_ptr->special_defense & KATA_MUSOU)
1961 set_action(ACTION_NONE);
1964 /* Get a "repeated" direction */
1965 if (get_rep_dir(&dir, FALSE))
1972 y = p_ptr->y + ddy[dir];
1973 x = p_ptr->x + ddx[dir];
1974 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1976 /* Feature code (applying "mimic" field) */
1977 feat = get_feat_mimic(g_ptr);
1979 /* Require closed door */
1980 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1982 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1986 else if (!get_spike(&item))
1988 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1991 /* Is a monster in the way? */
1992 else if (g_ptr->m_idx)
1994 take_turn(p_ptr, 100);
1996 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2005 take_turn(p_ptr, 100);
2007 /* Successful jamming */
2008 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2009 cave_alter_feat(y, x, FF_SPIKE);
2011 /* Use up, and describe, a single spike, from the bottom */
2012 inven_item_increase(item, -1);
2013 inven_item_describe(item);
2014 inven_item_optimize(item);
2022 * @brief 「歩く」動作コマンドのメインルーチン /
2023 * Support code for the "Walk" and "Jump" commands
2024 * @param pickup アイテムの自動拾いを行うならTRUE
2027 void do_cmd_walk(bool pickup)
2034 /* Allow repeated command */
2037 /* Set repeat count */
2038 command_rep = command_arg - 1;
2039 p_ptr->redraw |= (PR_STATE);
2041 /* Cancel the arg */
2045 /* Get a "repeated" direction */
2046 if (get_rep_dir(&dir, FALSE))
2048 take_turn(p_ptr, 100);
2050 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2052 set_action(ACTION_NONE);
2055 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2056 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2057 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2059 /* Actually move the character */
2060 move_player(dir, pickup, FALSE);
2062 /* Allow more walking */
2066 /* Hack again -- Is there a special encounter ??? */
2067 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2069 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2072 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2074 /* Inform the player of his horrible fate :=) */
2075 msg_print(_("襲撃だ!", "You are ambushed !"));
2077 /* Go into large wilderness view */
2078 p_ptr->oldpy = randint1(MAX_HGT-2);
2079 p_ptr->oldpx = randint1(MAX_WID-2);
2082 /* Give first move to monsters */
2083 take_turn(p_ptr, 100);
2085 /* HACk -- set the encouter flag for the wilderness generation */
2086 generate_encounter = TRUE;
2090 /* Cancel repeat unless we may continue */
2091 if (!more) disturb(FALSE, FALSE);
2096 * @brief 「走る」動作コマンドのメインルーチン /
2100 void do_cmd_run(void)
2103 if (cmd_limit_confused(p_ptr)) return;
2105 if (p_ptr->special_defense & KATA_MUSOU)
2107 set_action(ACTION_NONE);
2110 /* Get a "repeated" direction */
2111 if (get_rep_dir(&dir,FALSE))
2113 /* Hack -- Set the run counter */
2114 running = (command_arg ? command_arg : 1000);
2123 * @brief 「留まる」動作コマンドのメインルーチン /
2124 * Stay still. Search. Enter stores.
2125 * Pick up treasure if "pickup" is true.
2126 * @param pickup アイテムの自動拾いを行うならTRUE
2129 void do_cmd_stay(bool pickup)
2131 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2133 /* Allow repeated command */
2136 /* Set repeat count */
2137 command_rep = command_arg - 1;
2138 p_ptr->redraw |= (PR_STATE);
2140 /* Cancel the arg */
2144 take_turn(p_ptr, 100);
2146 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2147 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2152 * @brief 「休む」動作コマンドのメインルーチン /
2153 * Resting allows a player to safely restore his hp -RAK-
2156 void do_cmd_rest(void)
2159 set_action(ACTION_NONE);
2161 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2163 stop_singing(p_ptr);
2167 if (hex_spelling_any()) stop_hex_spell_all();
2169 /* Prompt for time if needed */
2170 if (command_arg <= 0)
2172 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2173 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2179 strcpy(out_val, "&");
2181 /* Ask for duration */
2182 if (!get_string(p, out_val, 4)) return;
2184 /* Rest until done */
2185 if (out_val[0] == '&')
2187 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2191 else if (out_val[0] == '*')
2193 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2199 command_arg = (COMMAND_ARG)atoi(out_val);
2200 if (command_arg <= 0) return;
2204 if (command_arg > 9999) command_arg = 9999;
2206 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2208 /* Take a current_world_ptr->game_turn (?) */
2209 take_turn(p_ptr, 100);
2211 /* The sin of sloth */
2212 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2214 /* Why are you sleeping when there's no need? WAKE UP!*/
2215 if ((p_ptr->chp == p_ptr->mhp) &&
2216 (p_ptr->csp == p_ptr->msp) &&
2217 !p_ptr->blind && !p_ptr->confused &&
2218 !p_ptr->poisoned && !p_ptr->afraid &&
2219 !p_ptr->stun && !p_ptr->cut &&
2220 !p_ptr->slow && !p_ptr->paralyzed &&
2221 !p_ptr->image && !p_ptr->word_recall &&
2222 !p_ptr->alter_reality)
2223 chg_virtue(V_DILIGENCE, -1);
2225 /* Save the rest code */
2226 p_ptr->resting = command_arg;
2227 p_ptr->action = ACTION_REST;
2228 p_ptr->update |= (PU_BONUS);
2229 update_creature(p_ptr);
2231 p_ptr->redraw |= (PR_STATE);
2240 * @brief 射撃処理のメインルーチン
2243 void do_cmd_fire(SPELL_IDX snipe_type)
2246 object_type *j_ptr, *ammo_ptr;
2249 if(p_ptr->wild_mode) return;
2251 is_fired = FALSE; /* not fired yet */
2253 /* Get the "bow" (if any) */
2254 j_ptr = &inventory[INVEN_BOW];
2256 /* Require a launcher */
2259 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2264 if (j_ptr->sval == SV_CRIMSON)
2266 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2271 if (j_ptr->sval == SV_HARP)
2273 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2279 if (p_ptr->special_defense & KATA_MUSOU)
2281 set_action(ACTION_NONE);
2284 /* Require proper missile */
2285 item_tester_tval = p_ptr->tval_ammo;
2287 q = _("どれを撃ちますか? ", "Fire which item? ");
2288 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2291 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2299 exe_fire(item, j_ptr, snipe_type);
2301 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2303 /* Sniper actions after some shootings */
2304 if (snipe_type == SP_AWAY)
2306 teleport_player(10 + (p_ptr->concent * 2), 0L);
2308 if (snipe_type == SP_FINAL)
2310 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2311 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2312 (void)set_stun(p_ptr->stun + randint1(25));
2318 * @brief 投射処理メインルーチン /
2319 * Throw an object from the pack or floor.
2321 * @param boomerang ブーメラン処理ならばTRUE
2322 * @param shuriken 忍者の手裏剣処理ならばTRUE
2323 * @return ターンを消費した場合TRUEを返す
2326 * Note: "unseen" monsters are very hard to hit.
2328 * Should throwing a weapon do full damage? Should it allow the magic
2329 * to hit bonus of the weapon to have an effect? Should it ever cause
2330 * the item to be destroyed? Should it do any damage at all?
2333 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2338 POSITION y, x, ty, tx, prev_y, prev_x;
2339 POSITION ny[19], nx[19];
2340 int chance, tdam, tdis;
2341 int mul, div, dd, ds;
2342 int cur_dis, visible;
2349 bool hit_body = FALSE;
2350 bool hit_wall = FALSE;
2351 bool equiped_item = FALSE;
2352 bool return_when_thrown = FALSE;
2354 GAME_TEXT o_name[MAX_NLEN];
2356 int msec = delay_factor * delay_factor * delay_factor;
2358 BIT_FLAGS flgs[TR_FLAG_SIZE];
2360 bool come_back = FALSE;
2361 bool do_drop = TRUE;
2363 if (p_ptr->wild_mode) return FALSE;
2365 if (p_ptr->special_defense & KATA_MUSOU)
2367 set_action(ACTION_NONE);
2373 o_ptr = &inventory[item];
2377 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2379 item_tester_hook = item_tester_hook_boomerang;
2380 q = _("どの武器を投げますか? ", "Throw which item? ");
2381 s = _("投げる武器がない。", "You have nothing to throw.");
2382 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2389 else if (has_melee_weapon(INVEN_LARM))
2392 o_ptr = &inventory[item];
2397 o_ptr = &inventory[item];
2402 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2403 s = _("投げるアイテムがない。", "You have nothing to throw.");
2404 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2412 /* Item is cursed */
2413 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2415 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2419 if (p_ptr->inside_arena && !boomerang)
2421 if (o_ptr->tval != TV_SPIKE)
2423 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2432 /* Obtain a local object */
2433 object_copy(q_ptr, o_ptr);
2435 /* Extract the thrown object's flags. */
2436 object_flags(q_ptr, flgs);
2437 torch_flags(q_ptr, flgs);
2439 /* Distribute the charges of rods/wands between the stacks */
2440 distribute_charges(o_ptr, q_ptr, 1);
2445 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2447 if (p_ptr->mighty_throw) mult += 3;
2449 /* Extract a "distance multiplier" */
2450 /* Changed for 'launcher' mutation */
2451 mul = 10 + 2 * (mult - 1);
2453 /* Enforce a minimum "weight" of one pound */
2454 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2455 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2457 /* Hack -- Distance -- Reward strength, penalize weight */
2458 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2460 /* Max distance of 10-18 */
2461 if (tdis > mul) tdis = mul;
2465 ty = randint0(101) - 50 + p_ptr->y;
2466 tx = randint0(101) - 50 + p_ptr->x;
2470 project_length = tdis + 1;
2472 /* Get a direction (or cancel) */
2473 if (!get_aim_dir(&dir)) return FALSE;
2475 /* Predict the "target" location */
2476 tx = p_ptr->x + 99 * ddx[dir];
2477 ty = p_ptr->y + 99 * ddy[dir];
2479 /* Check for "target request" */
2480 if ((dir == 5) && target_okay())
2486 project_length = 0; /* reset to default */
2489 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2490 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2491 return_when_thrown = TRUE;
2493 /* Reduce and describe inventory */
2496 inven_item_increase(item, -1);
2497 if (!return_when_thrown)
2498 inven_item_describe(item);
2499 inven_item_optimize(item);
2502 /* Reduce and describe floor item */
2505 floor_item_increase(0 - item, -1);
2506 floor_item_optimize(0 - item);
2508 if (item >= INVEN_RARM)
2510 equiped_item = TRUE;
2511 p_ptr->redraw |= (PR_EQUIPPY);
2514 take_turn(p_ptr, 100);
2516 /* Rogue and Ninja gets bonus */
2517 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2518 p_ptr->energy_use -= p_ptr->lev;
2520 /* Start at the player */
2526 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2527 else shuriken = FALSE;
2529 /* Chance of hitting */
2530 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2531 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2532 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2534 if (shuriken) chance *= 2;
2539 /* Travel until stopped */
2540 for (cur_dis = 0; cur_dis <= tdis; )
2542 /* Hack -- Stop at the target */
2543 if ((y == ty) && (x == tx)) break;
2545 /* Calculate the new location (see "project()") */
2548 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2550 /* Stopped by walls/doors */
2551 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2554 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;
2557 /* The player can see the (on screen) missile */
2558 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2560 SYMBOL_CODE c = object_char(q_ptr);
2561 TERM_COLOR a = object_attr(q_ptr);
2563 /* Draw, Hilite, Fresh, Pause, Erase */
2564 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2565 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2567 Term_xtra(TERM_XTRA_DELAY, msec);
2568 lite_spot(ny[cur_dis], nx[cur_dis]);
2572 /* The player cannot see the missile */
2575 /* Pause anyway, for consistancy */
2576 Term_xtra(TERM_XTRA_DELAY, msec);
2582 /* Save the new location */
2586 /* Advance the distance */
2589 /* Monster here, Try to hit it */
2590 if (current_floor_ptr->grid_array[y][x].m_idx)
2592 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2593 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2595 /* Check the visibility */
2596 visible = m_ptr->ml;
2598 /* Note the collision */
2601 /* Did we hit it (penalize range) */
2602 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2606 /* Handle unseen monster */
2609 /* Invisible monster */
2610 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2613 /* Handle visible monster */
2616 GAME_TEXT m_name[MAX_NLEN];
2617 monster_desc(m_name, m_ptr, 0);
2618 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2622 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2623 health_track(g_ptr->m_idx);
2627 /* Hack -- Base damage from thrown object */
2630 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2631 tdam = damroll(dd, ds);
2632 /* Apply special damage */
2633 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2634 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2635 if (q_ptr->to_d > 0)
2636 tdam += q_ptr->to_d;
2638 tdam += -q_ptr->to_d;
2642 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2643 tdam += p_ptr->to_d_m;
2645 else if (have_flag(flgs, TR_THROW))
2648 tdam += p_ptr->to_d_m;
2656 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2659 /* No negative damage */
2660 if (tdam < 0) tdam = 0;
2662 /* Modify the damage */
2663 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2665 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2666 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2668 /* Hit the monster, check for death */
2669 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2677 message_pain(g_ptr->m_idx, tdam);
2679 /* Anger the monster */
2680 if ((tdam > 0) && !object_is_potion(q_ptr))
2681 anger_monster(m_ptr);
2683 if (fear && m_ptr->ml)
2686 GAME_TEXT m_name[MAX_NLEN];
2687 monster_desc(m_name, m_ptr, 0);
2688 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2698 /* decrease toach's fuel */
2699 if (hit_body) torch_lost_fuel(q_ptr);
2701 /* Chance of breakage (during attacks) */
2702 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2704 /* Figurines transform */
2705 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2709 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2710 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2711 else if (object_is_cursed(q_ptr))
2712 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2717 /* Potions smash open */
2718 if (object_is_potion(q_ptr))
2720 if (hit_body || hit_wall || (randint1(100) < j))
2722 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2724 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2726 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2728 /* ToDo (Robert): fix the invulnerability */
2729 if (current_floor_ptr->grid_array[y][x].m_idx &&
2730 is_friendly(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]) &&
2731 !MON_INVULNER(m_ptr))
2733 GAME_TEXT m_name[MAX_NLEN];
2734 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
2735 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2736 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2747 if (return_when_thrown)
2749 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2750 char o2_name[MAX_NLEN];
2751 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2754 if (boomerang) back_chance += 4+randint1(5);
2755 if (super_boomerang) back_chance += 100;
2756 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2758 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2760 for (i = cur_dis - 1; i > 0; i--)
2762 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2764 char c = object_char(q_ptr);
2765 byte a = object_attr(q_ptr);
2767 /* Draw, Hilite, Fresh, Pause, Erase */
2768 print_rel(c, a, ny[i], nx[i]);
2769 move_cursor_relative(ny[i], nx[i]);
2771 Term_xtra(TERM_XTRA_DELAY, msec);
2772 lite_spot(ny[i], nx[i]);
2777 /* Pause anyway, for consistancy */
2778 Term_xtra(TERM_XTRA_DELAY, msec);
2781 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2783 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2790 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2794 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2802 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2808 if (item == INVEN_RARM || item == INVEN_LARM)
2810 /* Access the wield slot */
2811 o_ptr = &inventory[item];
2813 /* Wear the new stuff */
2814 object_copy(o_ptr, q_ptr);
2816 p_ptr->total_weight += q_ptr->weight;
2818 /* Increment the equip counter by hand */
2821 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2822 p_ptr->window |= (PW_EQUIP);
2830 else if (equiped_item)
2838 if (cave_have_flag_bold(y, x, FF_PROJECT))
2840 (void)drop_near(q_ptr, j, y, x);
2844 (void)drop_near(q_ptr, j, prev_y, prev_x);
2852 * @brief 自殺するコマンドのメインルーチン
2853 * Hack -- commit suicide
2857 void do_cmd_suicide(void)
2864 /* Verify Retirement */
2865 if (p_ptr->total_winner)
2868 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2871 /* Verify Suicide */
2875 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2879 if (!p_ptr->noscore)
2881 /* Special Verification for suicide */
2882 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2887 if (i != '@') return;
2889 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2892 /* Initialize "last message" buffer */
2893 if (p_ptr->last_message) string_free(p_ptr->last_message);
2894 p_ptr->last_message = NULL;
2896 /* Hack -- Note *winning* message */
2897 if (p_ptr->total_winner && last_words)
2899 char buf[1024] = "";
2900 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2903 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2904 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2908 p_ptr->last_message = string_make(buf);
2909 msg_print(p_ptr->last_message);
2914 p_ptr->playing = FALSE;
2916 /* Kill the player */
2917 p_ptr->is_dead = TRUE;
2918 p_ptr->leaving = TRUE;
2920 if (!p_ptr->total_winner)
2922 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
2923 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2924 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
2927 /* Cause of death */
2928 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));