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);
1128 /* Update some things */
1129 p_ptr->update |= (PU_FLOW);
1133 /* Message, keep digging */
1134 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1142 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1145 if (p_ptr->skill_dig > power + randint0(40 * power))
1147 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1150 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1151 p_ptr->update |= (PU_FLOW);
1154 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1156 /* Remove the feature */
1157 cave_alter_feat(y, x, FF_TUNNEL);
1159 chg_virtue(V_DILIGENCE, 1);
1160 chg_virtue(V_NATURE, -1);
1168 /* We may continue chopping */
1169 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1170 /* Occasional Search XXX XXX */
1171 if (randint0(100) < 25) search();
1175 /* We may continue tunelling */
1176 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1183 if (is_hidden_door(g_ptr))
1185 /* Occasional Search XXX XXX */
1186 if (randint0(100) < 25) search();
1193 * @brief 「掘る」動作コマンドのメインルーチン /
1194 * Tunnels through "walls" (including rubble and closed doors)
1198 * Note that you must tunnel in order to hit invisible monsters
1199 * in walls, though moving into walls still takes a current_world_ptr->game_turn anyway.
1201 * Digging is very difficult without a "digger" weapon, but can be
1202 * accomplished by strong players using heavy weapons.
1205 void do_cmd_tunnel(void)
1214 if (p_ptr->special_defense & KATA_MUSOU)
1216 set_action(ACTION_NONE);
1219 /* Allow repeated command */
1222 /* Set repeat count */
1223 command_rep = command_arg - 1;
1224 p_ptr->redraw |= (PR_STATE);
1226 /* Cancel the arg */
1230 /* Get a direction to tunnel, or Abort */
1231 if (get_rep_dir(&dir,FALSE))
1234 y = p_ptr->y + ddy[dir];
1235 x = p_ptr->x + ddx[dir];
1237 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1239 /* Feature code (applying "mimic" field) */
1240 feat = get_feat_mimic(g_ptr);
1242 /* No tunnelling through doors */
1243 if (have_flag(f_info[feat].flags, FF_DOOR))
1245 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1248 /* No tunnelling through most features */
1249 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1251 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1254 /* A monster is in the way */
1255 else if (g_ptr->m_idx)
1257 take_turn(p_ptr, 100);
1259 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1268 /* Tunnel through walls */
1269 more = do_cmd_tunnel_aux(y, x);
1273 /* Cancel repetition unless we can continue */
1274 if (!more) disturb(FALSE, FALSE);
1278 * @brief 移動処理による簡易な「開く」処理 /
1280 * @return 開く処理が実際に試みられた場合TRUEを返す
1283 * If there is a jammed/closed/locked door at the given location,
1284 * then attempt to unlock/open it. Return TRUE if an attempt was
1285 * made (successful or not), otherwise return FALSE.
1287 * The code here should be nearly identical to that in
1288 * do_cmd_open_test() and do_cmd_open_aux().
1291 bool easy_open_door(POSITION y, POSITION x)
1295 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1296 feature_type *f_ptr = &f_info[g_ptr->feat];
1298 /* Must be a closed door */
1299 if (!is_closed_door(g_ptr->feat))
1305 if (!have_flag(f_ptr->flags, FF_OPEN))
1308 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1313 else if (f_ptr->power)
1316 i = p_ptr->skill_dis;
1318 /* Penalize some conditions */
1319 if (p_ptr->blind || no_lite()) i = i / 10;
1320 if (p_ptr->confused || p_ptr->image) i = i / 10;
1322 /* Extract the lock power */
1325 /* Extract the difficulty */
1328 /* Always have a small chance of success */
1332 if (randint0(100) < j)
1334 msg_print(_("鍵をはずした。", "You have picked the lock."));
1337 cave_alter_feat(y, x, FF_OPEN);
1339 sound(SOUND_OPENDOOR);
1349 if (flush_failure) flush();
1351 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1360 cave_alter_feat(y, x, FF_OPEN);
1362 sound(SOUND_OPENDOOR);
1368 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1369 * Perform the basic "disarm" command
1370 * @param y 解除を行うマスのY座標
1371 * @param x 解除を行うマスのX座標
1372 * @param o_idx 箱のオブジェクトID
1373 * @return ターンを消費する処理が行われた場合TRUEを返す
1376 * Assume destination is a visible trap
1377 * Assume there is no monster blocking the destination
1378 * Returns TRUE if repeated commands may continue
1381 static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
1385 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
1387 take_turn(p_ptr, 100);
1389 /* Get the "disarm" factor */
1390 i = p_ptr->skill_dis;
1392 /* Penalize some conditions */
1393 if (p_ptr->blind || no_lite()) i = i / 10;
1394 if (p_ptr->confused || p_ptr->image) i = i / 10;
1396 /* Extract the difficulty */
1397 j = i - o_ptr->pval;
1399 /* Always have a small chance of success */
1402 /* Must find the trap first. */
1403 if (!object_is_known(o_ptr))
1405 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1409 /* Already disarmed/unlocked */
1410 else if (o_ptr->pval <= 0)
1412 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1415 /* No traps to find. */
1416 else if (!chest_traps[o_ptr->pval])
1418 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1421 /* Success (get a lot of experience) */
1422 else if (randint0(100) < j)
1424 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1425 gain_exp(o_ptr->pval);
1426 o_ptr->pval = (0 - o_ptr->pval);
1429 /* Failure -- Keep trying */
1430 else if ((i > 5) && (randint1(i) > 5))
1432 /* We may keep trying */
1434 if (flush_failure) flush();
1435 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1438 /* Failure -- Set off the trap */
1441 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1443 chest_trap(y, x, o_idx);
1450 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1451 * Perform the basic "disarm" command
1452 * @param y 解除を行うマスのY座標
1453 * @param x 解除を行うマスのX座標
1454 * @param dir プレイヤーからみた方向ID
1455 * @return ターンを消費する処理が行われた場合TRUEを返す
1458 * Assume destination is a visible trap
1459 * Assume there is no monster blocking the destination
1460 * Returns TRUE if repeated commands may continue
1464 bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
1466 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1469 feature_type *f_ptr = &f_info[g_ptr->feat];
1471 /* Access trap name */
1472 concptr name = (f_name + f_ptr->name);
1474 /* Extract trap "power" */
1475 int power = f_ptr->power;
1478 /* Get the "disarm" factor */
1479 int i = p_ptr->skill_dis;
1482 take_turn(p_ptr, 100);
1484 /* Penalize some conditions */
1485 if (p_ptr->blind || no_lite()) i = i / 10;
1486 if (p_ptr->confused || p_ptr->image) i = i / 10;
1488 /* Extract the difficulty */
1491 /* Always have a small chance of success */
1495 if (randint0(100) < j)
1497 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1502 /* Remove the trap */
1503 cave_alter_feat(y, x, FF_DISARM);
1505 /* Move the player onto the trap */
1506 move_player(dir, easy_disarm, FALSE);
1509 /* Failure -- Keep trying */
1510 else if ((i > 5) && (randint1(i) > 5))
1513 if (flush_failure) flush();
1515 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1517 /* We may keep trying */
1521 /* Failure -- Set off the trap */
1524 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1525 /* Move the player onto the trap */
1526 move_player(dir, easy_disarm, FALSE);
1533 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1534 * Disarms a trap, or chest
1537 void do_cmd_disarm(void)
1545 if (p_ptr->wild_mode) return;
1547 if (p_ptr->special_defense & KATA_MUSOU)
1549 set_action(ACTION_NONE);
1552 /* Option: Pick a direction */
1555 int num_traps, num_chests;
1557 /* Count visible traps */
1558 num_traps = count_dt(&y, &x, is_trap, TRUE);
1560 /* Count chests (trapped) */
1561 num_chests = count_chests(&y, &x, TRUE);
1563 /* See if only one target */
1564 if (num_traps || num_chests)
1566 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1567 if (!too_many) command_dir = coords_to_dir(y, x);
1572 /* Allow repeated command */
1575 /* Set repeat count */
1576 command_rep = command_arg - 1;
1577 p_ptr->redraw |= (PR_STATE);
1579 /* Cancel the arg */
1583 /* Get a direction (or abort) */
1584 if (get_rep_dir(&dir,TRUE))
1589 y = p_ptr->y + ddy[dir];
1590 x = p_ptr->x + ddx[dir];
1591 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1593 /* Feature code (applying "mimic" field) */
1594 feat = get_feat_mimic(g_ptr);
1596 /* Check for chests */
1597 o_idx = chest_check(y, x, TRUE);
1600 if (!is_trap(feat) && !o_idx)
1602 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1605 /* Monster in the way */
1606 else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx)
1608 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1617 more = do_cmd_disarm_chest(y, x, o_idx);
1623 more = do_cmd_disarm_aux(y, x, dir);
1627 /* Cancel repeat unless told not to */
1628 if (!more) disturb(FALSE, FALSE);
1633 * @brief 「打ち破る」動作コマンドのサブルーチン /
1634 * Perform the basic "bash" command
1635 * @param y 対象を行うマスのY座標
1636 * @param x 対象を行うマスのX座標
1637 * @param dir プレイヤーから見たターゲットの方角ID
1638 * @return 実際に処理が行われた場合TRUEを返す。
1641 * Assume destination is a closed/locked/jammed door
1642 * Assume there is no monster blocking the destination
1643 * Returns TRUE if repeated commands may continue
1646 static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
1648 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
1651 feature_type *f_ptr = &f_info[g_ptr->feat];
1653 /* Hack -- Bash power based on strength */
1654 /* (Ranges from 3 to 20 to 100 to 200) */
1655 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
1657 /* Extract door power */
1658 int temp = f_ptr->power;
1662 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1664 take_turn(p_ptr, 100);
1666 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1668 /* Compare bash power to door power */
1669 temp = (bash - (temp * 10));
1671 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1673 /* Hack -- always have a chance */
1674 if (temp < 1) temp = 1;
1676 /* Hack -- attempt to bash down the door */
1677 if (randint0(100) < temp)
1679 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1681 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1683 /* Break down the door */
1684 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1686 cave_alter_feat(y, x, FF_BASH);
1692 cave_alter_feat(y, x, FF_OPEN);
1695 /* Hack -- Fall through the door */
1696 move_player(dir, FALSE, FALSE);
1699 /* Saving throw against stun */
1700 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
1703 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1705 /* Allow repeated bashing */
1709 /* High dexterity yields coolness */
1712 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1714 /* Hack -- Lose balance ala paralysis */
1715 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
1722 * @brief 「打ち破る」動作コマンドのメインルーチン /
1723 * Bash open a door, success based on character strength
1727 * For a closed door, pval is positive if locked; negative if stuck.
1729 * For an open door, pval is positive for a broken door.
1731 * A closed door can be opened - harder if locked. Any door might be
1732 * bashed open (and thereby broken). Bashing a door is (potentially)
1733 * faster! You move into the door way. To open a stuck door, it must
1734 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1736 * Creatures can also open or bash doors, see elsewhere.
1739 void do_cmd_bash(void)
1745 if (p_ptr->wild_mode) return;
1747 if (p_ptr->special_defense & KATA_MUSOU)
1749 set_action(ACTION_NONE);
1752 /* Allow repeated command */
1755 /* Set repeat count */
1756 command_rep = command_arg - 1;
1757 p_ptr->redraw |= (PR_STATE);
1759 /* Cancel the arg */
1763 /* Get a "repeated" direction */
1764 if (get_rep_dir(&dir,FALSE))
1769 y = p_ptr->y + ddy[dir];
1770 x = p_ptr->x + ddx[dir];
1772 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1774 /* Feature code (applying "mimic" field) */
1775 feat = get_feat_mimic(g_ptr);
1777 /* Nothing useful */
1778 if (!have_flag(f_info[feat].flags, FF_BASH))
1780 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1783 /* Monster in the way */
1784 else if (g_ptr->m_idx)
1786 take_turn(p_ptr, 100);
1788 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1794 /* Bash a closed door */
1798 more = do_cmd_bash_aux(y, x, dir);
1802 /* Unless valid action taken, cancel bash */
1803 if (!more) disturb(FALSE, FALSE);
1808 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1812 * Manipulate an adjacent grid in some way
1814 * Attack monsters, tunnel through walls, disarm traps, open doors.
1816 * Consider confusion
1818 * This command must always take a current_world_ptr->game_turn, to prevent free detection
1819 * of invisible monsters.
1822 void do_cmd_alter(void)
1829 if (p_ptr->special_defense & KATA_MUSOU)
1831 set_action(ACTION_NONE);
1834 /* Allow repeated command */
1837 /* Set repeat count */
1838 command_rep = command_arg - 1;
1839 p_ptr->redraw |= (PR_STATE);
1841 /* Cancel the arg */
1845 /* Get a direction */
1846 if (get_rep_dir(&dir,TRUE))
1849 feature_type *f_ptr;
1851 y = p_ptr->y + ddy[dir];
1852 x = p_ptr->x + ddx[dir];
1854 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1856 /* Feature code (applying "mimic" field) */
1857 feat = get_feat_mimic(g_ptr);
1858 f_ptr = &f_info[feat];
1860 take_turn(p_ptr, 100);
1868 else if (have_flag(f_ptr->flags, FF_OPEN))
1870 more = do_cmd_open_aux(y, x);
1873 /* Bash jammed doors */
1874 else if (have_flag(f_ptr->flags, FF_BASH))
1876 more = do_cmd_bash_aux(y, x, dir);
1879 /* Tunnel through walls */
1880 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1882 more = do_cmd_tunnel_aux(y, x);
1885 /* Close open doors */
1886 else if (have_flag(f_ptr->flags, FF_CLOSE))
1888 more = do_cmd_close_aux(y, x);
1892 else if (have_flag(f_ptr->flags, FF_DISARM))
1894 more = do_cmd_disarm_aux(y, x, dir);
1899 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1903 /* Cancel repetition unless we can continue */
1904 if (!more) disturb(FALSE, FALSE);
1910 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
1911 * Find the index of some "spikes", if possible.
1912 * @param ip くさびとして打てるオブジェクトのID
1913 * @return オブジェクトがある場合TRUEを返す
1916 * Let user choose a pile of spikes, perhaps?
1919 static bool get_spike(INVENTORY_IDX *ip)
1923 /* Check every item in the pack */
1924 for (i = 0; i < INVEN_PACK; i++)
1926 object_type *o_ptr = &inventory[i];
1928 /* Skip non-objects */
1929 if (!o_ptr->k_idx) continue;
1931 /* Check the "tval" code */
1932 if (o_ptr->tval == TV_SPIKE)
1934 /* Save the spike index */
1947 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1948 * Jam a closed door with a spike
1952 * This command may NOT be repeated
1955 void do_cmd_spike(void)
1959 if (p_ptr->wild_mode) return;
1961 if (p_ptr->special_defense & KATA_MUSOU)
1963 set_action(ACTION_NONE);
1966 /* Get a "repeated" direction */
1967 if (get_rep_dir(&dir, FALSE))
1974 y = p_ptr->y + ddy[dir];
1975 x = p_ptr->x + ddx[dir];
1976 g_ptr = ¤t_floor_ptr->grid_array[y][x];
1978 /* Feature code (applying "mimic" field) */
1979 feat = get_feat_mimic(g_ptr);
1981 /* Require closed door */
1982 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1984 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1988 else if (!get_spike(&item))
1990 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1993 /* Is a monster in the way? */
1994 else if (g_ptr->m_idx)
1996 take_turn(p_ptr, 100);
1998 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2007 take_turn(p_ptr, 100);
2009 /* Successful jamming */
2010 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2011 cave_alter_feat(y, x, FF_SPIKE);
2013 /* Use up, and describe, a single spike, from the bottom */
2014 inven_item_increase(item, -1);
2015 inven_item_describe(item);
2016 inven_item_optimize(item);
2024 * @brief 「歩く」動作コマンドのメインルーチン /
2025 * Support code for the "Walk" and "Jump" commands
2026 * @param pickup アイテムの自動拾いを行うならTRUE
2029 void do_cmd_walk(bool pickup)
2036 /* Allow repeated command */
2039 /* Set repeat count */
2040 command_rep = command_arg - 1;
2041 p_ptr->redraw |= (PR_STATE);
2043 /* Cancel the arg */
2047 /* Get a "repeated" direction */
2048 if (get_rep_dir(&dir, FALSE))
2050 take_turn(p_ptr, 100);
2052 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2054 set_action(ACTION_NONE);
2057 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2058 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2059 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2061 /* Actually move the character */
2062 move_player(dir, pickup, FALSE);
2064 /* Allow more walking */
2068 /* Hack again -- Is there a special encounter ??? */
2069 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2071 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2074 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2076 /* Inform the player of his horrible fate :=) */
2077 msg_print(_("襲撃だ!", "You are ambushed !"));
2079 /* Go into large wilderness view */
2080 p_ptr->oldpy = randint1(MAX_HGT-2);
2081 p_ptr->oldpx = randint1(MAX_WID-2);
2084 /* Give first move to monsters */
2085 take_turn(p_ptr, 100);
2087 /* HACk -- set the encouter flag for the wilderness generation */
2088 generate_encounter = TRUE;
2092 /* Cancel repeat unless we may continue */
2093 if (!more) disturb(FALSE, FALSE);
2098 * @brief 「走る」動作コマンドのメインルーチン /
2102 void do_cmd_run(void)
2105 if (cmd_limit_confused(p_ptr)) return;
2107 if (p_ptr->special_defense & KATA_MUSOU)
2109 set_action(ACTION_NONE);
2112 /* Get a "repeated" direction */
2113 if (get_rep_dir(&dir,FALSE))
2115 /* Hack -- Set the run counter */
2116 running = (command_arg ? command_arg : 1000);
2125 * @brief 「留まる」動作コマンドのメインルーチン /
2126 * Stay still. Search. Enter stores.
2127 * Pick up treasure if "pickup" is true.
2128 * @param pickup アイテムの自動拾いを行うならTRUE
2131 void do_cmd_stay(bool pickup)
2133 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2135 /* Allow repeated command */
2138 /* Set repeat count */
2139 command_rep = command_arg - 1;
2140 p_ptr->redraw |= (PR_STATE);
2142 /* Cancel the arg */
2146 take_turn(p_ptr, 100);
2148 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2149 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2154 * @brief 「休む」動作コマンドのメインルーチン /
2155 * Resting allows a player to safely restore his hp -RAK-
2158 void do_cmd_rest(void)
2161 set_action(ACTION_NONE);
2163 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2165 stop_singing(p_ptr);
2169 if (hex_spelling_any()) stop_hex_spell_all();
2171 /* Prompt for time if needed */
2172 if (command_arg <= 0)
2174 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2175 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2181 strcpy(out_val, "&");
2183 /* Ask for duration */
2184 if (!get_string(p, out_val, 4)) return;
2186 /* Rest until done */
2187 if (out_val[0] == '&')
2189 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2193 else if (out_val[0] == '*')
2195 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2201 command_arg = (COMMAND_ARG)atoi(out_val);
2202 if (command_arg <= 0) return;
2208 if (command_arg > 9999) command_arg = 9999;
2210 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2212 /* Take a current_world_ptr->game_turn (?) */
2213 take_turn(p_ptr, 100);
2215 /* The sin of sloth */
2216 if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
2218 /* Why are you sleeping when there's no need? WAKE UP!*/
2219 if ((p_ptr->chp == p_ptr->mhp) &&
2220 (p_ptr->csp == p_ptr->msp) &&
2221 !p_ptr->blind && !p_ptr->confused &&
2222 !p_ptr->poisoned && !p_ptr->afraid &&
2223 !p_ptr->stun && !p_ptr->cut &&
2224 !p_ptr->slow && !p_ptr->paralyzed &&
2225 !p_ptr->image && !p_ptr->word_recall &&
2226 !p_ptr->alter_reality)
2227 chg_virtue(V_DILIGENCE, -1);
2229 /* Save the rest code */
2230 p_ptr->resting = command_arg;
2231 p_ptr->action = ACTION_REST;
2232 p_ptr->update |= (PU_BONUS);
2233 update_creature(p_ptr);
2235 p_ptr->redraw |= (PR_STATE);
2244 * @brief 射撃処理のメインルーチン
2247 void do_cmd_fire(SPELL_IDX snipe_type)
2250 object_type *j_ptr, *ammo_ptr;
2253 if(p_ptr->wild_mode) return;
2255 is_fired = FALSE; /* not fired yet */
2257 /* Get the "bow" (if any) */
2258 j_ptr = &inventory[INVEN_BOW];
2260 /* Require a launcher */
2263 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2268 if (j_ptr->sval == SV_CRIMSON)
2270 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2275 if (j_ptr->sval == SV_HARP)
2277 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2283 if (p_ptr->special_defense & KATA_MUSOU)
2285 set_action(ACTION_NONE);
2288 /* Require proper missile */
2289 item_tester_tval = p_ptr->tval_ammo;
2291 q = _("どれを撃ちますか? ", "Fire which item? ");
2292 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2295 ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
2303 exe_fire(item, j_ptr, snipe_type);
2305 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
2307 /* Sniper actions after some shootings */
2308 if (snipe_type == SP_AWAY)
2310 teleport_player(10 + (p_ptr->concent * 2), 0L);
2312 if (snipe_type == SP_FINAL)
2314 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2315 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
2316 (void)set_stun(p_ptr->stun + randint1(25));
2322 * @brief 投射処理メインルーチン /
2323 * Throw an object from the pack or floor.
2325 * @param boomerang ブーメラン処理ならばTRUE
2326 * @param shuriken 忍者の手裏剣処理ならばTRUE
2327 * @return ターンを消費した場合TRUEを返す
2330 * Note: "unseen" monsters are very hard to hit.
2332 * Should throwing a weapon do full damage? Should it allow the magic
2333 * to hit bonus of the weapon to have an effect? Should it ever cause
2334 * the item to be destroyed? Should it do any damage at all?
2337 bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
2342 POSITION y, x, ty, tx, prev_y, prev_x;
2343 POSITION ny[19], nx[19];
2344 int chance, tdam, tdis;
2345 int mul, div, dd, ds;
2346 int cur_dis, visible;
2353 bool hit_body = FALSE;
2354 bool hit_wall = FALSE;
2355 bool equiped_item = FALSE;
2356 bool return_when_thrown = FALSE;
2358 GAME_TEXT o_name[MAX_NLEN];
2360 int msec = delay_factor * delay_factor * delay_factor;
2362 BIT_FLAGS flgs[TR_FLAG_SIZE];
2364 bool come_back = FALSE;
2365 bool do_drop = TRUE;
2367 if (p_ptr->wild_mode) return FALSE;
2369 if (p_ptr->special_defense & KATA_MUSOU)
2371 set_action(ACTION_NONE);
2377 o_ptr = &inventory[item];
2381 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
2383 item_tester_hook = item_tester_hook_boomerang;
2384 q = _("どの武器を投げますか? ", "Throw which item? ");
2385 s = _("投げる武器がない。", "You have nothing to throw.");
2386 o_ptr = choose_object(&item, q, s, (USE_EQUIP));
2393 else if (has_melee_weapon(INVEN_LARM))
2396 o_ptr = &inventory[item];
2401 o_ptr = &inventory[item];
2406 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2407 s = _("投げるアイテムがない。", "You have nothing to throw.");
2408 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
2416 /* Item is cursed */
2417 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2419 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2423 if (p_ptr->inside_arena && !boomerang)
2425 if (o_ptr->tval != TV_SPIKE)
2427 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2436 /* Obtain a local object */
2437 object_copy(q_ptr, o_ptr);
2439 /* Extract the thrown object's flags. */
2440 object_flags(q_ptr, flgs);
2441 torch_flags(q_ptr, flgs);
2443 /* Distribute the charges of rods/wands between the stacks */
2444 distribute_charges(o_ptr, q_ptr, 1);
2449 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2451 if (p_ptr->mighty_throw) mult += 3;
2453 /* Extract a "distance multiplier" */
2454 /* Changed for 'launcher' mutation */
2455 mul = 10 + 2 * (mult - 1);
2457 /* Enforce a minimum "weight" of one pound */
2458 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2459 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2461 /* Hack -- Distance -- Reward strength, penalize weight */
2462 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
2464 /* Max distance of 10-18 */
2465 if (tdis > mul) tdis = mul;
2469 ty = randint0(101) - 50 + p_ptr->y;
2470 tx = randint0(101) - 50 + p_ptr->x;
2474 project_length = tdis + 1;
2476 /* Get a direction (or cancel) */
2477 if (!get_aim_dir(&dir)) return FALSE;
2479 /* Predict the "target" location */
2480 tx = p_ptr->x + 99 * ddx[dir];
2481 ty = p_ptr->y + 99 * ddy[dir];
2483 /* Check for "target request" */
2484 if ((dir == 5) && target_okay())
2490 project_length = 0; /* reset to default */
2493 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2494 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2495 return_when_thrown = TRUE;
2497 /* Reduce and describe inventory */
2500 inven_item_increase(item, -1);
2501 if (!return_when_thrown)
2502 inven_item_describe(item);
2503 inven_item_optimize(item);
2506 /* Reduce and describe floor item */
2509 floor_item_increase(0 - item, -1);
2510 floor_item_optimize(0 - item);
2512 if (item >= INVEN_RARM)
2514 equiped_item = TRUE;
2515 p_ptr->redraw |= (PR_EQUIPPY);
2518 take_turn(p_ptr, 100);
2520 /* Rogue and Ninja gets bonus */
2521 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
2522 p_ptr->energy_use -= p_ptr->lev;
2524 /* Start at the player */
2530 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2531 else shuriken = FALSE;
2533 /* Chance of hitting */
2534 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
2535 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2536 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
2538 if (shuriken) chance *= 2;
2543 /* Travel until stopped */
2544 for (cur_dis = 0; cur_dis <= tdis; )
2546 /* Hack -- Stop at the target */
2547 if ((y == ty) && (x == tx)) break;
2549 /* Calculate the new location (see "project()") */
2552 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
2554 /* Stopped by walls/doors */
2555 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
2558 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;
2561 /* The player can see the (on screen) missile */
2562 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
2564 SYMBOL_CODE c = object_char(q_ptr);
2565 TERM_COLOR a = object_attr(q_ptr);
2567 /* Draw, Hilite, Fresh, Pause, Erase */
2568 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
2569 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2571 Term_xtra(TERM_XTRA_DELAY, msec);
2572 lite_spot(ny[cur_dis], nx[cur_dis]);
2576 /* The player cannot see the missile */
2579 /* Pause anyway, for consistancy */
2580 Term_xtra(TERM_XTRA_DELAY, msec);
2586 /* Save the new location */
2590 /* Advance the distance */
2593 /* Monster here, Try to hit it */
2594 if (current_floor_ptr->grid_array[y][x].m_idx)
2596 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2597 monster_type *m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2599 /* Check the visibility */
2600 visible = m_ptr->ml;
2602 /* Note the collision */
2605 /* Did we hit it (penalize range) */
2606 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2610 /* Handle unseen monster */
2613 /* Invisible monster */
2614 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2617 /* Handle visible monster */
2620 GAME_TEXT m_name[MAX_NLEN];
2621 monster_desc(m_name, m_ptr, 0);
2622 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2626 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2627 health_track(g_ptr->m_idx);
2631 /* Hack -- Base damage from thrown object */
2634 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2635 tdam = damroll(dd, ds);
2636 /* Apply special damage */
2637 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
2638 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
2639 if (q_ptr->to_d > 0)
2640 tdam += q_ptr->to_d;
2642 tdam += -q_ptr->to_d;
2646 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
2647 tdam += p_ptr->to_d_m;
2649 else if (have_flag(flgs, TR_THROW))
2652 tdam += p_ptr->to_d_m;
2660 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
2663 /* No negative damage */
2664 if (tdam < 0) tdam = 0;
2666 /* Modify the damage */
2667 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2669 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2670 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2672 /* Hit the monster, check for death */
2673 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2681 message_pain(g_ptr->m_idx, tdam);
2683 /* Anger the monster */
2684 if ((tdam > 0) && !object_is_potion(q_ptr))
2685 anger_monster(m_ptr);
2687 if (fear && m_ptr->ml)
2690 GAME_TEXT m_name[MAX_NLEN];
2691 monster_desc(m_name, m_ptr, 0);
2692 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2702 /* decrease toach's fuel */
2703 if (hit_body) torch_lost_fuel(q_ptr);
2705 /* Chance of breakage (during attacks) */
2706 j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
2708 /* Figurines transform */
2709 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
2713 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2714 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2715 else if (object_is_cursed(q_ptr))
2716 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2721 /* Potions smash open */
2722 if (object_is_potion(q_ptr))
2724 if (hit_body || hit_wall || (randint1(100) < j))
2726 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2728 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2730 monster_type *m_ptr = ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx];
2732 /* ToDo (Robert): fix the invulnerability */
2733 if (current_floor_ptr->grid_array[y][x].m_idx &&
2734 is_friendly(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]) &&
2735 !MON_INVULNER(m_ptr))
2737 GAME_TEXT m_name[MAX_NLEN];
2738 monster_desc(m_name, ¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx], 0);
2739 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2740 set_hostile(¤t_floor_ptr->m_list[current_floor_ptr->grid_array[y][x].m_idx]);
2751 if (return_when_thrown)
2753 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
2754 char o2_name[MAX_NLEN];
2755 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2758 if (boomerang) back_chance += 4+randint1(5);
2759 if (super_boomerang) back_chance += 100;
2760 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2762 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2764 for (i = cur_dis - 1; i > 0; i--)
2766 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
2768 char c = object_char(q_ptr);
2769 byte a = object_attr(q_ptr);
2771 /* Draw, Hilite, Fresh, Pause, Erase */
2772 print_rel(c, a, ny[i], nx[i]);
2773 move_cursor_relative(ny[i], nx[i]);
2775 Term_xtra(TERM_XTRA_DELAY, msec);
2776 lite_spot(ny[i], nx[i]);
2781 /* Pause anyway, for consistancy */
2782 Term_xtra(TERM_XTRA_DELAY, msec);
2785 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
2787 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2794 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
2798 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2806 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
2812 if (item == INVEN_RARM || item == INVEN_LARM)
2814 /* Access the wield slot */
2815 o_ptr = &inventory[item];
2817 /* Wear the new stuff */
2818 object_copy(o_ptr, q_ptr);
2820 p_ptr->total_weight += q_ptr->weight;
2822 /* Increment the equip counter by hand */
2825 p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2826 p_ptr->window |= (PW_EQUIP);
2834 else if (equiped_item)
2842 if (cave_have_flag_bold(y, x, FF_PROJECT))
2844 (void)drop_near(q_ptr, j, y, x);
2848 (void)drop_near(q_ptr, j, prev_y, prev_x);