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 "io/write-diary.h"
18 #include "cmd/cmd-dump.h"
19 #include "cmd/cmd-save.h"
24 #include "object-hook.h"
25 #include "monster-status.h"
29 #include "player-status.h"
30 #include "realm-hex.h"
34 #include "player-move.h"
35 #include "player-effects.h"
36 #include "player-personality.h"
37 #include "player-inventory.h"
38 #include "objectkind.h"
39 #include "object-broken.h"
40 #include "object-flavor.h"
44 #include "cmd-basic.h"
45 #include "dungeon-file.h"
48 #include "view-mainwindow.h"
49 #include "targeting.h"
53 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
54 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
55 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
57 static bool confirm_leave_level(player_type *creature_ptr, bool down_stair)
59 quest_type *q_ptr = &quest[creature_ptr->current_floor_ptr->inside_quest];
61 /* Confirm leaving from once only quest */
62 if (confirm_quest && creature_ptr->current_floor_ptr->inside_quest &&
63 (q_ptr->type == QUEST_TYPE_RANDOM ||
64 (q_ptr->flags & QUEST_FLAG_ONCE &&
65 q_ptr->status != QUEST_STATUS_COMPLETED) ||
66 (q_ptr->flags & QUEST_FLAG_TOWER &&
67 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
68 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
70 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
71 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
81 * @brief 魔法系コマンドが制限されているかを返す。
82 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
84 bool cmd_limit_cast(player_type *creature_ptr)
86 if (creature_ptr->current_floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
88 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
92 else if (creature_ptr->anti_magic)
94 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
97 else if (creature_ptr->shero)
99 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
106 bool cmd_limit_confused(player_type *creature_ptr)
108 if (creature_ptr->confused)
110 msg_print(_("混乱していてできない!", "You are too confused!"));
116 bool cmd_limit_image(player_type *creature_ptr)
118 if (creature_ptr->image)
120 msg_print(_("幻覚が見えて集中できない!", "Your hallucinations prevent you from concentrating!"));
126 bool cmd_limit_stun(player_type *creature_ptr)
128 if (creature_ptr->stun)
130 msg_print(_("頭が朦朧としていて集中できない!", "You are too stunned!"));
136 bool cmd_limit_arena(player_type *creature_ptr)
138 if (creature_ptr->current_floor_ptr->inside_arena)
140 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
147 bool cmd_limit_blind(player_type *creature_ptr)
149 if (creature_ptr->blind)
151 msg_print(_("目が見えない。", "You can't see anything."));
154 if (no_lite(creature_ptr))
156 msg_print(_("明かりがないので見えない。", "You have no light."));
162 bool cmd_limit_time_walk(player_type *creature_ptr)
164 if (creature_ptr->timewalk)
166 if (flush_failure) flush();
167 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
175 * @brief 階段を使って階層を昇る処理 / Go up one level
178 void do_cmd_go_up(player_type *creature_ptr)
183 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
184 feature_type *f_ptr = &f_info[g_ptr->feat];
188 if (creature_ptr->special_defense & KATA_MUSOU)
190 set_action(creature_ptr, ACTION_NONE);
194 if (!have_flag(f_ptr->flags, FF_LESS))
196 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
200 /* Quest up stairs */
201 if (have_flag(f_ptr->flags, FF_QUEST))
203 if (!confirm_leave_level(creature_ptr, FALSE)) return;
206 if (IS_ECHIZEN(creature_ptr))
207 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
209 msg_print(_("上の階に登った。", "You enter the up staircase."));
211 leave_quest_check(creature_ptr);
213 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
215 /* Activate the quest */
216 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
218 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
220 init_flags = INIT_ASSIGN;
221 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
223 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
226 /* Leaving a quest */
227 if (!creature_ptr->current_floor_ptr->inside_quest)
229 creature_ptr->current_floor_ptr->dun_level = 0;
231 creature_ptr->leaving = TRUE;
233 creature_ptr->oldpx = 0;
234 creature_ptr->oldpy = 0;
236 take_turn(creature_ptr, 100);
238 /* End the command */
242 if (!creature_ptr->current_floor_ptr->dun_level)
248 go_up = confirm_leave_level(creature_ptr, FALSE);
253 take_turn(creature_ptr, 100);
255 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
257 /* For a random quest */
258 if (creature_ptr->current_floor_ptr->inside_quest &&
259 quest[creature_ptr->current_floor_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
261 leave_quest_check(creature_ptr);
263 creature_ptr->current_floor_ptr->inside_quest = 0;
266 /* For a fixed quest */
267 if (creature_ptr->current_floor_ptr->inside_quest &&
268 quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
270 leave_quest_check(creature_ptr);
272 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
273 creature_ptr->current_floor_ptr->dun_level = 0;
277 /* For normal dungeon and random quest */
281 if (have_flag(f_ptr->flags, FF_SHAFT))
283 /* Create a way back */
284 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
290 /* Create a way back */
291 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP);
296 /* Get out from current dungeon */
297 if (creature_ptr->current_floor_ptr->dun_level - up_num < d_info[creature_ptr->dungeon_idx].mindepth)
298 up_num = creature_ptr->current_floor_ptr->dun_level;
300 if (record_stair) exe_write_diary(creature_ptr, DIARY_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
303 if (IS_ECHIZEN(creature_ptr))
304 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
305 else if (up_num == creature_ptr->current_floor_ptr->dun_level)
306 msg_print(_("地上に戻った。", "You go back to the surface."));
308 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
309 creature_ptr->leaving = TRUE;
314 * @brief 階段を使って階層を降りる処理 / Go down one level
315 * @param creature_ptr プレーヤーへの参照ポインタ
318 void do_cmd_go_down(player_type *creature_ptr)
320 bool fall_trap = FALSE;
323 if (creature_ptr->special_defense & KATA_MUSOU)
325 set_action(creature_ptr, ACTION_NONE);
329 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
330 feature_type *f_ptr = &f_info[g_ptr->feat];
331 if (!have_flag(f_ptr->flags, FF_MORE))
333 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
337 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
340 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
342 do_cmd_quest(creature_ptr);
346 /* Quest down stairs */
347 if (have_flag(f_ptr->flags, FF_QUEST))
349 /* Confirm Leaving */
350 if(!confirm_leave_level(creature_ptr, TRUE)) return;
352 if (IS_ECHIZEN(creature_ptr))
353 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
355 msg_print(_("下の階に降りた。", "You enter the down staircase."));
357 leave_quest_check(creature_ptr);
358 leave_tower_check(creature_ptr);
360 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
362 /* Activate the quest */
363 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
365 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
367 init_flags = INIT_ASSIGN;
368 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
370 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
373 /* Leaving a quest */
374 if (!creature_ptr->current_floor_ptr->inside_quest)
376 creature_ptr->current_floor_ptr->dun_level = 0;
378 creature_ptr->leaving = TRUE;
379 creature_ptr->oldpx = 0;
380 creature_ptr->oldpy = 0;
382 take_turn(creature_ptr, 100);
386 DUNGEON_IDX target_dungeon = 0;
388 if (!creature_ptr->current_floor_ptr->dun_level)
390 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
392 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
394 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
397 if (!max_dlv[target_dungeon])
399 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
400 d_name + d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
401 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
404 /* Save old player position */
405 creature_ptr->oldpx = creature_ptr->x;
406 creature_ptr->oldpy = creature_ptr->y;
407 creature_ptr->dungeon_idx = target_dungeon;
410 * Clear all saved floors
411 * and create a first saved floor
413 prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
416 take_turn(creature_ptr, 100);
418 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
421 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
424 if (!creature_ptr->current_floor_ptr->dun_level)
426 /* Enter the dungeon just now */
427 creature_ptr->enter_dungeon = TRUE;
428 down_num = d_info[creature_ptr->dungeon_idx].mindepth;
433 if (fall_trap) exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
434 else exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
439 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
446 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[creature_ptr->dungeon_idx].text);
450 if (IS_ECHIZEN(creature_ptr))
451 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
453 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
457 creature_ptr->leaving = TRUE;
461 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
465 /* Create a way back */
466 if (have_flag(f_ptr->flags, FF_SHAFT))
468 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
472 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN);
478 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
481 void do_cmd_search(player_type * creature_ptr)
483 /* Allow repeated command */
486 /* Set repeat count */
487 command_rep = command_arg - 1;
488 creature_ptr->redraw |= (PR_STATE);
494 take_turn(creature_ptr, 100);
495 search(creature_ptr);
500 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
501 * @param y 走査対象にしたいマスのY座標
502 * @param x 走査対象にしたいマスのX座標
503 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
504 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
506 static OBJECT_IDX chest_check(floor_type *floor_ptr, POSITION y, POSITION x, bool trapped)
508 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
509 OBJECT_IDX this_o_idx, next_o_idx = 0;
511 /* Scan all objects in the grid */
512 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
516 o_ptr = &floor_ptr->o_list[this_o_idx];
517 next_o_idx = o_ptr->next_o_idx;
519 /* Skip unknown chests XXX XXX */
520 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
522 /* Check for non empty chest */
523 if ((o_ptr->tval == TV_CHEST) &&
524 (((!trapped) && (o_ptr->pval)) || /* non empty */
525 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
536 * Attempt to open the given chest at the given location
537 * @param y 箱の存在するマスのY座標
538 * @param x 箱の存在するマスのX座標
539 * @param o_idx 箱のオブジェクトID
540 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
542 * Assume there is no monster blocking the destination
544 static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
548 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
550 take_turn(creature_ptr, 100);
552 /* Attempt to unlock it */
555 /* Assume locked, and thus not open */
558 /* Get the "disarm" factor */
559 int i = creature_ptr->skill_dis;
561 /* Penalize some conditions */
562 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
563 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
565 /* Extract the difficulty */
566 int j = i - o_ptr->pval;
568 /* Always have a small chance of success */
571 /* Success -- May still have traps */
572 if (randint0(100) < j)
574 msg_print(_("鍵をはずした。", "You have picked the lock."));
575 gain_exp(creature_ptr, 1);
579 /* Failure -- Keep trying */
582 /* We may continue repeating */
584 if (flush_failure) flush();
585 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
590 /* Allowed to open */
593 /* Apply chest traps, if any */
594 chest_trap(creature_ptr, y, x, o_idx);
596 /* Let the Chest drop items */
597 chest_death(creature_ptr, FALSE, y, x, o_idx);
604 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
605 * Attempt to open the given chest at the given location
606 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
607 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
608 * @param test 地形条件を判定するための関数ポインタ
609 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
611 * @details Return the number of features around (or under) the character.
612 * Usually look for doors and floor traps.
614 static int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(player_type*, FEAT_IDX feat), bool under)
616 /* Check around (and under) the character */
618 for (DIRECTION d = 0; d < 9; d++)
623 /* if not searching under player continue */
624 if ((d == 8) && !under) continue;
626 /* Extract adjacent (legal) location */
627 POSITION yy = creature_ptr->y + ddy_ddd[d];
628 POSITION xx = creature_ptr->x + ddx_ddd[d];
630 /* Get the creature_ptr->current_floor_ptr->grid_array */
631 g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
633 /* Must have knowledge */
634 if (!(g_ptr->info & (CAVE_MARK))) continue;
636 /* Feature code (applying "mimic" field) */
637 feat = get_feat_mimic(g_ptr);
639 /* Not looking for this feature */
640 if (!((*test)(creature_ptr, feat))) continue;
645 /* Remember the location. Only useful if only one match */
656 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
657 * Return the number of chests around (or under) the character.
658 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
659 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
660 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
663 * If requested, count only trapped chests.
665 static int count_chests(player_type *creature_ptr, POSITION *y, POSITION *x, bool trapped)
667 /* Check around (and under) the character */
669 for (DIRECTION d = 0; d < 9; d++)
671 /* Extract adjacent (legal) location */
672 POSITION yy = creature_ptr->y + ddy_ddd[d];
673 POSITION xx = creature_ptr->x + ddx_ddd[d];
675 /* No (visible) chest is there */
676 OBJECT_IDX o_idx = chest_check(creature_ptr->current_floor_ptr, yy, xx, FALSE);
677 if (!o_idx) continue;
679 /* Grab the object */
681 o_ptr = &creature_ptr->current_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 exe_open(player_type *creature_ptr, POSITION y, POSITION x)
717 /* Get requested grid */
718 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
719 feature_type *f_ptr = &f_info[g_ptr->feat];
722 take_turn(creature_ptr, 100);
724 /* Seeing true feature code (ignore mimic) */
727 if (!have_flag(f_ptr->flags, FF_OPEN))
730 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
736 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
737 sound(SOUND_OPENDOOR);
742 int i = creature_ptr->skill_dis;
744 /* Penalize some conditions */
745 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
746 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
748 /* Extract the difficulty */
749 int j = f_ptr->power;
752 /* Always have a small chance of success */
755 if (randint0(100) >= j)
757 if (flush_failure) flush();
758 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
762 msg_print(_("鍵をはずした。", "You have picked the lock."));
765 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
767 sound(SOUND_OPENDOOR);
770 gain_exp(creature_ptr, 1);
775 * @brief 「開ける」コマンドのメインルーチン /
776 * Open a closed/locked/jammed door or a closed/locked chest.
779 * Unlocking a locked door/chest is worth one experience point.
781 void do_cmd_open(player_type *creature_ptr)
789 if (creature_ptr->wild_mode) return;
791 if (creature_ptr->special_defense & KATA_MUSOU)
793 set_action(creature_ptr, ACTION_NONE);
796 /* Option: Pick a direction */
799 int num_doors, num_chests;
801 num_doors = count_dt(creature_ptr, &y, &x, is_closed_door, FALSE);
802 num_chests = count_chests(creature_ptr, &y, &x, FALSE);
803 if (num_doors || num_chests)
805 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
807 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
811 /* Allow repeated command */
814 /* Set repeat count */
815 command_rep = command_arg - 1;
816 creature_ptr->redraw |= (PR_STATE);
822 /* Get a "repeated" direction */
823 if (get_rep_dir(creature_ptr, &dir, TRUE))
828 /* Get requested location */
829 y = creature_ptr->y + ddy[dir];
830 x = creature_ptr->x + ddx[dir];
832 /* Get requested grid */
833 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
835 /* Feature code (applying "mimic" field) */
836 feat = get_feat_mimic(g_ptr);
838 /* Check for chest */
839 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, FALSE);
841 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
843 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
845 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
847 take_turn(creature_ptr, 100);
848 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
849 py_attack(creature_ptr, y, x, 0);
853 more = exe_open_chest(creature_ptr, y, x, o_idx);
857 more = exe_open(creature_ptr, y, x);
861 /* Cancel repeat unless we may continue */
862 if (!more) disturb(creature_ptr, FALSE, FALSE);
869 * @brief 「閉じる」動作コマンドのサブルーチン /
870 * Perform the basic "close" command
871 * @param y 対象を行うマスのY座標
872 * @param x 対象を行うマスのX座標
873 * @return 実際に処理が行われた場合TRUEを返す。
875 * Assume destination is an open/broken door
876 * Assume there is no monster blocking the destination
877 * Returns TRUE if repeated commands may continue
879 static bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
881 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
882 FEAT_IDX old_feat = g_ptr->feat;
885 take_turn(creature_ptr, 100);
887 /* Seeing true feature code (ignore mimic) */
890 if (!have_flag(f_info[old_feat].flags, FF_CLOSE))
895 s16b closed_feat = feat_state(creature_ptr, old_feat, FF_CLOSE);
897 /* Hack -- object in the way */
898 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
899 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
901 msg_print(_("何かがつっかえて閉まらない。", "Something prevents it from closing."));
906 cave_alter_feat(creature_ptr, y, x, FF_CLOSE);
909 if (old_feat == g_ptr->feat)
911 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
915 sound(SOUND_SHUTDOOR);
924 * @brief 「閉じる」コマンドのメインルーチン /
925 * Close an open door.
928 * Unlocking a locked door/chest is worth one experience point.
930 void do_cmd_close(player_type *creature_ptr)
937 if (creature_ptr->wild_mode) return;
939 if (creature_ptr->special_defense & KATA_MUSOU)
941 set_action(creature_ptr, ACTION_NONE);
944 /* Option: Pick a direction */
947 /* Count open doors */
948 if (count_dt(creature_ptr, &y, &x, is_open, FALSE) == 1)
950 command_dir = coords_to_dir(creature_ptr, y, x);
954 /* Allow repeated command */
957 /* Set repeat count */
958 command_rep = command_arg - 1;
959 creature_ptr->redraw |= (PR_STATE);
965 /* Get a "repeated" direction */
966 if (get_rep_dir(creature_ptr, &dir, FALSE))
971 y = creature_ptr->y + ddy[dir];
972 x = creature_ptr->x + ddx[dir];
973 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
975 /* Feature code (applying "mimic" field) */
976 feat = get_feat_mimic(g_ptr);
978 /* Require open/broken door */
979 if (!have_flag(f_info[feat].flags, FF_CLOSE))
981 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
984 /* Monster in the way */
985 else if (g_ptr->m_idx)
987 take_turn(creature_ptr, 100);
989 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
992 py_attack(creature_ptr, y, x, 0);
999 more = exe_close(creature_ptr, y, x);
1003 /* Cancel repeat unless we may continue */
1004 if (!more) disturb(creature_ptr, FALSE, FALSE);
1009 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1010 * Determine if a given grid may be "tunneled"
1011 * @param y 対象を行うマスのY座標
1012 * @param x 対象を行うマスのX座標
1015 static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
1017 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1019 /* Must have knowledge */
1020 if (!(g_ptr->info & CAVE_MARK))
1022 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1027 /* Must be a wall/door/etc */
1028 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1030 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1040 * @brief 「掘る」動作コマンドのサブルーチン /
1041 * Perform the basic "tunnel" command
1042 * @param y 対象を行うマスのY座標
1043 * @param x 対象を行うマスのX座標
1044 * @return 実際に処理が行われた場合TRUEを返す。
1046 * Assumes that no monster is blocking the destination
1047 * Do not use twall anymore
1048 * Returns TRUE if repeated commands may continue
1050 static bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
1053 feature_type *f_ptr, *mimic_f_ptr;
1058 /* Verify legality */
1059 if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x)) return FALSE;
1061 take_turn(creature_ptr, 100);
1063 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1064 f_ptr = &f_info[g_ptr->feat];
1065 power = f_ptr->power;
1067 /* Feature code (applying "mimic" field) */
1068 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1070 name = f_name + mimic_f_ptr->name;
1074 if (have_flag(f_ptr->flags, FF_PERMANENT))
1077 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1079 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1082 /* Map border (mimiccing Permanent wall) */
1085 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1090 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1093 if (creature_ptr->skill_dig > randint0(20 * power))
1095 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1097 /* Remove the feature */
1098 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1099 creature_ptr->update |= (PU_FLOW);
1103 /* Message, keep digging */
1104 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1112 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1115 if (creature_ptr->skill_dig > power + randint0(40 * power))
1117 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1120 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1121 creature_ptr->update |= (PU_FLOW);
1124 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1126 /* Remove the feature */
1127 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1129 chg_virtue(creature_ptr, V_DILIGENCE, 1);
1130 chg_virtue(creature_ptr, V_NATURE, -1);
1138 /* We may continue chopping */
1139 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1140 /* Occasional Search XXX XXX */
1141 if (randint0(100) < 25) search(creature_ptr);
1145 /* We may continue tunelling */
1146 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1153 if (is_hidden_door(creature_ptr, g_ptr))
1155 /* Occasional Search XXX XXX */
1156 if (randint0(100) < 25) search(creature_ptr);
1164 * @brief 「掘る」動作コマンドのメインルーチン /
1165 * Tunnels through "walls" (including rubble and closed doors)
1169 * Note that you must tunnel in order to hit invisible monsters
1170 * in walls, though moving into walls still takes a turn anyway.
1172 * Digging is very difficult without a "digger" weapon, but can be
1173 * accomplished by strong players using heavy weapons.
1176 void do_cmd_tunnel(player_type *creature_ptr)
1185 if (creature_ptr->special_defense & KATA_MUSOU)
1187 set_action(creature_ptr, ACTION_NONE);
1190 /* Allow repeated command */
1193 /* Set repeat count */
1194 command_rep = command_arg - 1;
1195 creature_ptr->redraw |= (PR_STATE);
1197 /* Cancel the arg */
1201 /* Get a direction to tunnel, or Abort */
1202 if (get_rep_dir(creature_ptr, &dir,FALSE))
1205 y = creature_ptr->y + ddy[dir];
1206 x = creature_ptr->x + ddx[dir];
1208 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1210 /* Feature code (applying "mimic" field) */
1211 feat = get_feat_mimic(g_ptr);
1213 /* No tunnelling through doors */
1214 if (have_flag(f_info[feat].flags, FF_DOOR))
1216 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1219 /* No tunnelling through most features */
1220 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1222 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1225 /* A monster is in the way */
1226 else if (g_ptr->m_idx)
1228 take_turn(creature_ptr, 100);
1229 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1232 py_attack(creature_ptr, y, x, 0);
1238 /* Tunnel through walls */
1239 more = exe_tunnel(creature_ptr, y, x);
1243 /* Cancel repetition unless we can continue */
1244 if (!more) disturb(creature_ptr, FALSE, FALSE);
1248 * @brief 移動処理による簡易な「開く」処理 /
1250 * @return 開く処理が実際に試みられた場合TRUEを返す
1253 * If there is a jammed/closed/locked door at the given location,
1254 * then attempt to unlock/open it. Return TRUE if an attempt was
1255 * made (successful or not), otherwise return FALSE.
1257 * The code here should be nearly identical to that in
1258 * do_cmd_open_test() and exe_open().
1261 bool easy_open_door(player_type *creature_ptr, POSITION y, POSITION x)
1265 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1266 feature_type *f_ptr = &f_info[g_ptr->feat];
1268 /* Must be a closed door */
1269 if (!is_closed_door(creature_ptr, g_ptr->feat))
1275 if (!have_flag(f_ptr->flags, FF_OPEN))
1278 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1283 else if (f_ptr->power)
1286 i = creature_ptr->skill_dis;
1288 /* Penalize some conditions */
1289 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1290 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1292 /* Extract the lock power */
1295 /* Extract the difficulty */
1298 /* Always have a small chance of success */
1302 if (randint0(100) < j)
1304 msg_print(_("鍵をはずした。", "You have picked the lock."));
1307 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1309 sound(SOUND_OPENDOOR);
1312 gain_exp(creature_ptr, 1);
1319 if (flush_failure) flush();
1321 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1330 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1332 sound(SOUND_OPENDOOR);
1339 * @brief 箱のトラップを解除する実行処理 /
1340 * Perform the basic "disarm" command
1341 * @param y 解除を行うマスのY座標
1342 * @param x 解除を行うマスのX座標
1343 * @param o_idx 箱のオブジェクトID
1344 * @return ターンを消費する処理が行われた場合TRUEを返す
1347 * Assume destination is a visible trap
1348 * Assume there is no monster blocking the destination
1349 * Returns TRUE if repeated commands may continue
1352 static bool exe_disarm_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
1356 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
1358 take_turn(creature_ptr, 100);
1360 /* Get the "disarm" factor */
1361 i = creature_ptr->skill_dis;
1363 /* Penalize some conditions */
1364 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1365 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1367 /* Extract the difficulty */
1368 j = i - o_ptr->pval;
1370 /* Always have a small chance of success */
1373 /* Must find the trap first. */
1374 if (!object_is_known(o_ptr))
1376 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1380 /* Already disarmed/unlocked */
1381 else if (o_ptr->pval <= 0)
1383 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1386 /* No traps to find. */
1387 else if (!chest_traps[o_ptr->pval])
1389 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1392 /* Success (get a lot of experience) */
1393 else if (randint0(100) < j)
1395 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1396 gain_exp(creature_ptr, o_ptr->pval);
1397 o_ptr->pval = (0 - o_ptr->pval);
1400 /* Failure -- Keep trying */
1401 else if ((i > 5) && (randint1(i) > 5))
1403 /* We may keep trying */
1405 if (flush_failure) flush();
1406 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1409 /* Failure -- Set off the trap */
1412 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1414 chest_trap(creature_ptr, y, x, o_idx);
1422 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1423 * Perform the basic "disarm" command
1424 * @param y 解除を行うマスのY座標
1425 * @param x 解除を行うマスのX座標
1426 * @param dir プレイヤーからみた方向ID
1427 * @return ターンを消費する処理が行われた場合TRUEを返す
1430 * Assume destination is a visible trap
1431 * Assume there is no monster blocking the destination
1432 * Returns TRUE if repeated commands may continue
1436 bool exe_disarm(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1438 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1441 feature_type *f_ptr = &f_info[g_ptr->feat];
1443 /* Access trap name */
1444 concptr name = (f_name + f_ptr->name);
1446 /* Extract trap "power" */
1447 int power = f_ptr->power;
1450 /* Get the "disarm" factor */
1451 int i = creature_ptr->skill_dis;
1454 take_turn(creature_ptr, 100);
1456 /* Penalize some conditions */
1457 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1458 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1460 /* Extract the difficulty */
1463 /* Always have a small chance of success */
1467 if (randint0(100) < j)
1469 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1472 gain_exp(creature_ptr, power);
1474 /* Remove the trap */
1475 cave_alter_feat(creature_ptr, y, x, FF_DISARM);
1477 /* Move the player onto the trap */
1478 move_player(creature_ptr, dir, easy_disarm, FALSE);
1481 /* Failure -- Keep trying */
1482 else if ((i > 5) && (randint1(i) > 5))
1485 if (flush_failure) flush();
1487 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1489 /* We may keep trying */
1493 /* Failure -- Set off the trap */
1496 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1497 /* Move the player onto the trap */
1498 move_player(creature_ptr, dir, easy_disarm, FALSE);
1506 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1507 * Disarms a trap, or chest
1510 void do_cmd_disarm(player_type *creature_ptr)
1518 if (creature_ptr->wild_mode) return;
1520 if (creature_ptr->special_defense & KATA_MUSOU)
1522 set_action(creature_ptr, ACTION_NONE);
1525 /* Option: Pick a direction */
1528 int num_traps, num_chests;
1530 /* Count visible traps */
1531 num_traps = count_dt(creature_ptr, &y, &x, is_trap, TRUE);
1533 /* Count chests (trapped) */
1534 num_chests = count_chests(creature_ptr, &y, &x, TRUE);
1536 /* See if only one target */
1537 if (num_traps || num_chests)
1539 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1540 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
1544 /* Allow repeated command */
1547 /* Set repeat count */
1548 command_rep = command_arg - 1;
1549 creature_ptr->redraw |= (PR_STATE);
1551 /* Cancel the arg */
1555 /* Get a direction (or abort) */
1556 if (get_rep_dir(creature_ptr, &dir,TRUE))
1561 y = creature_ptr->y + ddy[dir];
1562 x = creature_ptr->x + ddx[dir];
1563 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1565 /* Feature code (applying "mimic" field) */
1566 feat = get_feat_mimic(g_ptr);
1568 /* Check for chests */
1569 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, TRUE);
1572 if (!is_trap(creature_ptr, feat) && !o_idx)
1574 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1577 /* Monster in the way */
1578 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
1580 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1583 py_attack(creature_ptr, y, x, 0);
1589 more = exe_disarm_chest(creature_ptr, y, x, o_idx);
1595 more = exe_disarm(creature_ptr, y, x, dir);
1599 /* Cancel repeat unless told not to */
1600 if (!more) disturb(creature_ptr, FALSE, FALSE);
1605 * @brief 「打ち破る」動作コマンドのサブルーチン /
1606 * Perform the basic "bash" command
1607 * @param y 対象を行うマスのY座標
1608 * @param x 対象を行うマスのX座標
1609 * @param dir プレイヤーから見たターゲットの方角ID
1610 * @return 実際に処理が行われた場合TRUEを返す。
1613 * Assume destination is a closed/locked/jammed door
1614 * Assume there is no monster blocking the destination
1615 * Returns TRUE if repeated commands may continue
1618 static bool do_cmd_bash_aux(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1620 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1623 feature_type *f_ptr = &f_info[g_ptr->feat];
1625 /* Hack -- Bash power based on strength */
1626 /* (Ranges from 3 to 20 to 100 to 200) */
1627 int bash = adj_str_blow[creature_ptr->stat_ind[A_STR]];
1629 /* Extract door power */
1630 int temp = f_ptr->power;
1634 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1636 take_turn(creature_ptr, 100);
1638 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1640 /* Compare bash power to door power */
1641 temp = (bash - (temp * 10));
1643 if (creature_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1645 /* Hack -- always have a chance */
1646 if (temp < 1) temp = 1;
1648 /* Hack -- attempt to bash down the door */
1649 if (randint0(100) < temp)
1651 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1653 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1655 /* Break down the door */
1656 if ((randint0(100) < 50) || (feat_state(creature_ptr, g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1658 cave_alter_feat(creature_ptr, y, x, FF_BASH);
1664 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1667 /* Hack -- Fall through the door */
1668 move_player(creature_ptr, dir, FALSE, FALSE);
1671 /* Saving throw against stun */
1672 else if (randint0(100) < adj_dex_safe[creature_ptr->stat_ind[A_DEX]] +
1675 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1677 /* Allow repeated bashing */
1681 /* High dexterity yields coolness */
1684 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1686 /* Hack -- Lose balance ala paralysis */
1687 (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 2 + randint0(2));
1695 * @brief 「打ち破る」動作コマンドのメインルーチン /
1696 * Bash open a door, success based on character strength
1700 * For a closed door, pval is positive if locked; negative if stuck.
1702 * For an open door, pval is positive for a broken door.
1704 * A closed door can be opened - harder if locked. Any door might be
1705 * bashed open (and thereby broken). Bashing a door is (potentially)
1706 * faster! You move into the door way. To open a stuck door, it must
1707 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1709 * Creatures can also open or bash doors, see elsewhere.
1712 void do_cmd_bash(player_type *creature_ptr)
1719 if (creature_ptr->wild_mode) return;
1721 if (creature_ptr->special_defense & KATA_MUSOU)
1723 set_action(creature_ptr, ACTION_NONE);
1726 /* Allow repeated command */
1729 /* Set repeat count */
1730 command_rep = command_arg - 1;
1731 creature_ptr->redraw |= (PR_STATE);
1733 /* Cancel the arg */
1737 /* Get a "repeated" direction */
1738 if (get_rep_dir(creature_ptr, &dir,FALSE))
1743 y = creature_ptr->y + ddy[dir];
1744 x = creature_ptr->x + ddx[dir];
1746 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1748 /* Feature code (applying "mimic" field) */
1749 feat = get_feat_mimic(g_ptr);
1751 /* Nothing useful */
1752 if (!have_flag(f_info[feat].flags, FF_BASH))
1754 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1757 /* Monster in the way */
1758 else if (g_ptr->m_idx)
1760 take_turn(creature_ptr, 100);
1762 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1765 py_attack(creature_ptr, y, x, 0);
1768 /* Bash a closed door */
1772 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1776 /* Unless valid action taken, cancel bash */
1777 if (!more) disturb(creature_ptr, FALSE, FALSE);
1782 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1786 * Manipulate an adjacent grid in some way
1788 * Attack monsters, tunnel through walls, disarm traps, open doors.
1790 * Consider confusion
1792 * This command must always take a turn, to prevent free detection
1793 * of invisible monsters.
1796 void do_cmd_alter(player_type *creature_ptr)
1803 if (creature_ptr->special_defense & KATA_MUSOU)
1805 set_action(creature_ptr, ACTION_NONE);
1808 /* Allow repeated command */
1811 /* Set repeat count */
1812 command_rep = command_arg - 1;
1813 creature_ptr->redraw |= (PR_STATE);
1815 /* Cancel the arg */
1819 /* Get a direction */
1820 if (get_rep_dir(creature_ptr, &dir,TRUE))
1823 feature_type *f_ptr;
1825 y = creature_ptr->y + ddy[dir];
1826 x = creature_ptr->x + ddx[dir];
1828 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1830 /* Feature code (applying "mimic" field) */
1831 feat = get_feat_mimic(g_ptr);
1832 f_ptr = &f_info[feat];
1834 take_turn(creature_ptr, 100);
1838 py_attack(creature_ptr, y, x, 0);
1842 else if (have_flag(f_ptr->flags, FF_OPEN))
1844 more = exe_open(creature_ptr, y, x);
1847 /* Bash jammed doors */
1848 else if (have_flag(f_ptr->flags, FF_BASH))
1850 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1853 /* Tunnel through walls */
1854 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1856 more = exe_tunnel(creature_ptr, y, x);
1859 /* Close open doors */
1860 else if (have_flag(f_ptr->flags, FF_CLOSE))
1862 more = exe_close(creature_ptr, y, x);
1866 else if (have_flag(f_ptr->flags, FF_DISARM))
1868 more = exe_disarm(creature_ptr, y, x, dir);
1873 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1877 /* Cancel repetition unless we can continue */
1878 if (!more) disturb(creature_ptr, FALSE, FALSE);
1884 * @brief 「くさびを打つ」ために必要なオブジェクトを所持しているかどうかの判定を返す /
1885 * Find the index of some "spikes", if possible.
1886 * @param ip くさびとして打てるオブジェクトのID
1887 * @return オブジェクトがある場合TRUEを返す
1890 * Let user choose a pile of spikes, perhaps?
1893 static bool get_spike(player_type *creature_ptr, INVENTORY_IDX *ip)
1897 /* Check every item in the pack */
1898 for (i = 0; i < INVEN_PACK; i++)
1900 object_type *o_ptr = &creature_ptr->inventory_list[i];
1901 if (!o_ptr->k_idx) continue;
1903 /* Check the "tval" code */
1904 if (o_ptr->tval == TV_SPIKE)
1906 /* Save the spike index */
1919 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1920 * Jam a closed door with a spike
1921 * @param creature_ptr プレーヤーへの参照ポインタ
1925 * This command may NOT be repeated
1928 void do_cmd_spike(player_type *creature_ptr)
1932 if (creature_ptr->wild_mode) return;
1933 if (creature_ptr->special_defense & KATA_MUSOU)
1935 set_action(creature_ptr, ACTION_NONE);
1938 /* Get a "repeated" direction */
1939 if (!get_rep_dir(creature_ptr, &dir, FALSE)) return;
1941 POSITION y = creature_ptr->y + ddy[dir];
1942 POSITION x = creature_ptr->x + ddx[dir];
1944 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1946 /* Feature code (applying "mimic" field) */
1947 FEAT_IDX feat = get_feat_mimic(g_ptr);
1949 /* Require closed door */
1951 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1953 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1957 else if (!get_spike(creature_ptr, &item))
1959 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1962 /* Is a monster in the way? */
1963 else if (g_ptr->m_idx)
1965 take_turn(creature_ptr, 100);
1967 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1970 py_attack(creature_ptr, y, x, 0);
1976 take_turn(creature_ptr, 100);
1978 /* Successful jamming */
1979 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1980 cave_alter_feat(creature_ptr, y, x, FF_SPIKE);
1982 vary_item(creature_ptr, item, -1);
1988 * @brief 「歩く」動作コマンドのメインルーチン /
1989 * Support code for the "Walk" and "Jump" commands
1990 * @param creature_ptr プレーヤーへの参照ポインタ
1991 * @param pickup アイテムの自動拾いを行うならTRUE
1994 void do_cmd_walk(player_type *creature_ptr, bool pickup)
1996 /* Allow repeated command */
1999 /* Set repeat count */
2000 command_rep = command_arg - 1;
2001 creature_ptr->redraw |= (PR_STATE);
2003 /* Cancel the arg */
2007 /* Get a "repeated" direction */
2010 if (get_rep_dir(creature_ptr, &dir, FALSE))
2012 take_turn(creature_ptr, 100);
2014 if ((dir != 5) && (creature_ptr->special_defense & KATA_MUSOU))
2016 set_action(creature_ptr, ACTION_NONE);
2019 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2020 if (creature_ptr->wild_mode) creature_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2021 if (creature_ptr->action == ACTION_HAYAGAKE) creature_ptr->energy_use = creature_ptr->energy_use * (45-(creature_ptr->lev/2)) / 100;
2023 /* Actually move the character */
2024 move_player(creature_ptr, dir, pickup, FALSE);
2026 /* Allow more walking */
2030 /* Hack again -- Is there a special encounter ??? */
2031 if (creature_ptr->wild_mode && !cave_have_flag_bold(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, FF_TOWN))
2033 int tmp = 120 + creature_ptr->lev*10 - wilderness[creature_ptr->y][creature_ptr->x].level + 5;
2036 if (((wilderness[creature_ptr->y][creature_ptr->x].level + 5) > (creature_ptr->lev / 2)) && randint0(tmp) < (21-creature_ptr->skill_stl))
2038 /* Inform the player of his horrible fate :=) */
2039 msg_print(_("襲撃だ!", "You are ambushed !"));
2041 /* Go into large wilderness view */
2042 creature_ptr->oldpy = randint1(MAX_HGT-2);
2043 creature_ptr->oldpx = randint1(MAX_WID-2);
2044 change_wild_mode(creature_ptr, TRUE);
2046 /* Give first move to monsters */
2047 take_turn(creature_ptr, 100);
2052 /* Cancel repeat unless we may continue */
2053 if (!more) disturb(creature_ptr, FALSE, FALSE);
2058 * @brief 「走る」動作コマンドのメインルーチン /
2060 * @param creature_ptr プレーヤーへの参照ポインタ
2063 void do_cmd_run(player_type *creature_ptr)
2066 if (cmd_limit_confused(creature_ptr)) return;
2068 if (creature_ptr->special_defense & KATA_MUSOU)
2070 set_action(creature_ptr, ACTION_NONE);
2073 /* Get a "repeated" direction */
2074 if (get_rep_dir(creature_ptr, &dir,FALSE))
2076 /* Hack -- Set the run counter */
2077 creature_ptr->running = (command_arg ? command_arg : 1000);
2080 run_step(creature_ptr, dir);
2086 * @brief 「留まる」動作コマンドのメインルーチン /
2087 * Stay still. Search. Enter stores.
2088 * Pick up treasure if "pickup" is true.
2089 * @param creature_ptr プレーヤーへの参照ポインタ
2090 * @param pickup アイテムの自動拾いを行うならTRUE
2093 void do_cmd_stay(player_type *creature_ptr, bool pickup)
2095 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2097 /* Allow repeated command */
2100 /* Set repeat count */
2101 command_rep = command_arg - 1;
2102 creature_ptr->redraw |= (PR_STATE);
2104 /* Cancel the arg */
2108 take_turn(creature_ptr, 100);
2110 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2111 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, mpe_mode);
2116 * @brief 「休む」動作コマンドのメインルーチン /
2117 * Resting allows a player to safely restore his hp -RAK-
2118 * @param creature_ptr プレーヤーへの参照ポインタ
2121 void do_cmd_rest(player_type *creature_ptr)
2123 set_action(creature_ptr, ACTION_NONE);
2125 if ((creature_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(creature_ptr) || INTERUPTING_SONG_EFFECT(creature_ptr)))
2127 stop_singing(creature_ptr);
2130 if (hex_spelling_any(creature_ptr)) stop_hex_spell_all(creature_ptr);
2132 /* Prompt for time if needed */
2133 if (command_arg <= 0)
2135 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2136 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2141 strcpy(out_val, "&");
2143 /* Ask for duration */
2144 if (!get_string(p, out_val, 4)) return;
2146 /* Rest until done */
2147 if (out_val[0] == '&')
2149 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2153 else if (out_val[0] == '*')
2155 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2161 command_arg = (COMMAND_ARG)atoi(out_val);
2162 if (command_arg <= 0) return;
2166 if (command_arg > 9999) command_arg = 9999;
2168 if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE);
2170 /* Take a turn (?) */
2171 take_turn(creature_ptr, 100);
2173 /* The sin of sloth */
2174 if (command_arg > 100) chg_virtue(creature_ptr, V_DILIGENCE, -1);
2176 /* Why are you sleeping when there's no need? WAKE UP!*/
2177 if ((creature_ptr->chp == creature_ptr->mhp) &&
2178 (creature_ptr->csp == creature_ptr->msp) &&
2179 !creature_ptr->blind && !creature_ptr->confused &&
2180 !creature_ptr->poisoned && !creature_ptr->afraid &&
2181 !creature_ptr->stun && !creature_ptr->cut &&
2182 !creature_ptr->slow && !creature_ptr->paralyzed &&
2183 !creature_ptr->image && !creature_ptr->word_recall &&
2184 !creature_ptr->alter_reality)
2185 chg_virtue(creature_ptr, V_DILIGENCE, -1);
2187 /* Save the rest code */
2188 creature_ptr->resting = command_arg;
2189 creature_ptr->action = ACTION_REST;
2190 creature_ptr->update |= (PU_BONUS);
2191 update_creature(creature_ptr);
2193 creature_ptr->redraw |= (PR_STATE);
2194 update_output(creature_ptr);
2203 * @brief 射撃処理のメインルーチン
2204 * @param creature_ptr プレーヤーへの参照ポインタ
2205 * @param snipe_type ???
2208 void do_cmd_fire(player_type *creature_ptr, SPELL_IDX snipe_type)
2211 object_type *j_ptr, *ammo_ptr;
2214 if(creature_ptr->wild_mode) return;
2216 creature_ptr->is_fired = FALSE; /* not fired yet */
2218 /* Get the "bow" (if any) */
2219 j_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2221 /* Require a launcher */
2224 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2229 if (j_ptr->sval == SV_CRIMSON)
2231 msg_print(_("この武器は発動して使うもののようだ。", "It's already activated."));
2236 if (j_ptr->sval == SV_HARP)
2238 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2244 if (creature_ptr->special_defense & KATA_MUSOU)
2246 set_action(creature_ptr, ACTION_NONE);
2249 q = _("どれを撃ちますか? ", "Fire which item? ");
2250 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2252 ammo_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), creature_ptr->tval_ammo);
2260 exe_fire(creature_ptr, item, j_ptr, snipe_type);
2262 if (!creature_ptr->is_fired || creature_ptr->pclass != CLASS_SNIPER) return;
2264 /* Sniper actions after some shootings */
2265 if (snipe_type == SP_AWAY)
2267 teleport_player(creature_ptr, 10 + (creature_ptr->concent * 2), 0L);
2270 if (snipe_type == SP_FINAL)
2272 msg_print(_("射撃の反動が体を襲った。", "The weapon's recoil stuns you. "));
2273 (void)set_slow(creature_ptr, creature_ptr->slow + randint0(7) + 7, FALSE);
2274 (void)set_stun(creature_ptr, creature_ptr->stun + randint1(25));
2280 * @brief 投射処理メインルーチン /
2281 * Throw an object from the pack or floor.
2283 * @param creature_ptr プレーヤーへの参照ポインタ
2284 * @param boomerang ブーメラン処理ならばTRUE
2285 * @param shuriken 忍者の手裏剣処理ならばTRUE
2286 * @return ターンを消費した場合TRUEを返す
2289 * Note: "unseen" monsters are very hard to hit.
2291 * Should throwing a weapon do full damage? Should it allow the magic
2292 * to hit bonus of the weapon to have an effect? Should it ever cause
2293 * the item to be destroyed? Should it do any damage at all?
2296 bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_IDX shuriken)
2301 POSITION y, x, ty, tx, prev_y, prev_x;
2302 POSITION ny[19], nx[19];
2303 int chance, tdam, tdis;
2304 int mul, div, dd, ds;
2305 int cur_dis, visible;
2312 bool hit_body = FALSE;
2313 bool hit_wall = FALSE;
2314 bool equiped_item = FALSE;
2315 bool return_when_thrown = FALSE;
2317 GAME_TEXT o_name[MAX_NLEN];
2319 int msec = delay_factor * delay_factor * delay_factor;
2321 BIT_FLAGS flgs[TR_FLAG_SIZE];
2323 bool come_back = FALSE;
2324 bool do_drop = TRUE;
2326 if (creature_ptr->wild_mode) return FALSE;
2328 if (creature_ptr->special_defense & KATA_MUSOU)
2330 set_action(creature_ptr, ACTION_NONE);
2336 o_ptr = &creature_ptr->inventory_list[item];
2340 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2342 item_tester_hook = item_tester_hook_boomerang;
2343 q = _("どの武器を投げますか? ", "Throw which item? ");
2344 s = _("投げる武器がない。", "You have nothing to throw.");
2345 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP), 0);
2352 else if (has_melee_weapon(creature_ptr, INVEN_LARM))
2355 o_ptr = &creature_ptr->inventory_list[item];
2360 o_ptr = &creature_ptr->inventory_list[item];
2365 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2366 s = _("投げるアイテムがない。", "You have nothing to throw.");
2367 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP), 0);
2375 /* Item is cursed */
2376 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2378 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2382 if (creature_ptr->current_floor_ptr->inside_arena && !boomerang)
2384 if (o_ptr->tval != TV_SPIKE)
2386 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2394 object_copy(q_ptr, o_ptr);
2396 /* Extract the thrown object's flags. */
2397 object_flags(q_ptr, flgs);
2398 torch_flags(q_ptr, flgs);
2400 /* Distribute the charges of rods/wands between the stacks */
2401 distribute_charges(o_ptr, q_ptr, 1);
2406 object_desc(creature_ptr, o_name, q_ptr, OD_OMIT_PREFIX);
2408 if (creature_ptr->mighty_throw) mult += 3;
2410 /* Extract a "distance multiplier" */
2411 /* Changed for 'launcher' mutation */
2412 mul = 10 + 2 * (mult - 1);
2414 /* Enforce a minimum "weight" of one pound */
2415 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2416 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2418 /* Hack -- Distance -- Reward strength, penalize weight */
2419 tdis = (adj_str_blow[creature_ptr->stat_ind[A_STR]] + 20) * mul / div;
2421 /* Max distance of 10-18 */
2422 if (tdis > mul) tdis = mul;
2426 ty = randint0(101) - 50 + creature_ptr->y;
2427 tx = randint0(101) - 50 + creature_ptr->x;
2431 project_length = tdis + 1;
2433 /* Get a direction (or cancel) */
2434 if (!get_aim_dir(creature_ptr, &dir)) return FALSE;
2436 /* Predict the "target" location */
2437 tx = creature_ptr->x + 99 * ddx[dir];
2438 ty = creature_ptr->y + 99 * ddy[dir];
2440 /* Check for "target request" */
2441 if ((dir == 5) && target_okay(creature_ptr))
2447 project_length = 0; /* reset to default */
2450 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2451 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2452 return_when_thrown = TRUE;
2456 inven_item_increase(creature_ptr, item, -1);
2457 if (!return_when_thrown)
2458 inven_item_describe(creature_ptr, item);
2459 inven_item_optimize(creature_ptr, item);
2463 floor_item_increase(creature_ptr->current_floor_ptr, 0 - item, -1);
2464 floor_item_optimize(creature_ptr, 0 - item);
2467 if (item >= INVEN_RARM)
2469 equiped_item = TRUE;
2470 creature_ptr->redraw |= (PR_EQUIPPY);
2473 take_turn(creature_ptr, 100);
2475 /* Rogue and Ninja gets bonus */
2476 if ((creature_ptr->pclass == CLASS_ROGUE) || (creature_ptr->pclass == CLASS_NINJA))
2477 creature_ptr->energy_use -= creature_ptr->lev;
2479 /* Start at the player */
2480 y = creature_ptr->y;
2481 x = creature_ptr->x;
2483 handle_stuff(creature_ptr);
2485 if ((creature_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2486 else shuriken = FALSE;
2488 /* Chance of hitting */
2489 if (have_flag(flgs, TR_THROW)) chance = ((creature_ptr->skill_tht) +
2490 ((creature_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2491 else chance = (creature_ptr->skill_tht + (creature_ptr->to_h_b * BTH_PLUS_ADJ));
2493 if (shuriken) chance *= 2;
2498 /* Travel until stopped */
2499 for (cur_dis = 0; cur_dis <= tdis; )
2501 /* Hack -- Stop at the target */
2502 if ((y == ty) && (x == tx)) break;
2504 /* Calculate the new location (see "project()") */
2507 mmove2(&ny[cur_dis], &nx[cur_dis], creature_ptr->y, creature_ptr->x, ty, tx);
2509 /* Stopped by walls/doors */
2510 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, ny[cur_dis], nx[cur_dis], FF_PROJECT))
2513 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !creature_ptr->current_floor_ptr->grid_array[ny[cur_dis]][nx[cur_dis]].m_idx) break;
2516 /* The player can see the (on screen) missile */
2517 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(creature_ptr, ny[cur_dis], nx[cur_dis]))
2519 SYMBOL_CODE c = object_char(q_ptr);
2520 TERM_COLOR a = object_attr(q_ptr);
2522 /* Draw, Hilite, Fresh, Pause, Erase */
2523 print_rel(creature_ptr, c, a, ny[cur_dis], nx[cur_dis]);
2524 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2526 Term_xtra(TERM_XTRA_DELAY, msec);
2527 lite_spot(creature_ptr, ny[cur_dis], nx[cur_dis]);
2531 /* The player cannot see the missile */
2534 /* Pause anyway, for consistancy */
2535 Term_xtra(TERM_XTRA_DELAY, msec);
2541 /* Save the new location */
2545 /* Advance the distance */
2548 /* Monster here, Try to hit it */
2549 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
2551 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
2552 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2553 GAME_TEXT m_name[MAX_NLEN];
2554 monster_name(creature_ptr, g_ptr->m_idx, m_name);
2556 /* Check the visibility */
2557 visible = m_ptr->ml;
2559 /* Note the collision */
2562 /* Did we hit it (penalize range) */
2563 if (test_hit_fire(creature_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2567 /* Handle unseen monster */
2570 /* Invisible monster */
2571 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2574 /* Handle visible monster */
2577 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2581 if (!creature_ptr->image) monster_race_track(creature_ptr, m_ptr->ap_r_idx);
2582 health_track(creature_ptr, g_ptr->m_idx);
2586 /* Hack -- Base damage from thrown object */
2589 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2590 tdam = damroll(dd, ds);
2591 /* Apply special damage */
2592 tdam = tot_dam_aux(creature_ptr, q_ptr, tdam, m_ptr, 0, TRUE);
2593 tdam = critical_shot(creature_ptr, q_ptr->weight, q_ptr->to_h, 0, tdam);
2594 if (q_ptr->to_d > 0)
2595 tdam += q_ptr->to_d;
2597 tdam += -q_ptr->to_d;
2601 tdam *= (mult+creature_ptr->num_blow[item - INVEN_RARM]);
2602 tdam += creature_ptr->to_d_m;
2604 else if (have_flag(flgs, TR_THROW))
2607 tdam += creature_ptr->to_d_m;
2615 tdam += ((creature_ptr->lev+30)*(creature_ptr->lev+30)-900)/55;
2618 /* No negative damage */
2619 if (tdam < 0) tdam = 0;
2621 /* Modify the damage */
2622 tdam = mon_damage_mod(creature_ptr, m_ptr, tdam, FALSE);
2624 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2625 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2627 /* Hit the monster, check for death */
2628 if (mon_take_hit(creature_ptr, g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2636 message_pain(creature_ptr, g_ptr->m_idx, tdam);
2638 /* Anger the monster */
2639 if ((tdam > 0) && !object_is_potion(q_ptr))
2640 anger_monster(creature_ptr, m_ptr);
2642 if (fear && m_ptr->ml)
2645 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2655 /* decrease toach's fuel */
2656 if (hit_body) torch_lost_fuel(q_ptr);
2658 /* Chance of breakage (during attacks) */
2659 j = (hit_body ? breakage_chance(creature_ptr, q_ptr, creature_ptr->pclass == CLASS_ARCHER, 0) : 0);
2661 /* Figurines transform */
2662 if ((q_ptr->tval == TV_FIGURINE) && !(creature_ptr->current_floor_ptr->inside_arena))
2666 if (!(summon_named_creature(creature_ptr, 0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2667 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2668 else if (object_is_cursed(q_ptr))
2669 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2673 /* Potions smash open */
2674 if (object_is_potion(q_ptr))
2676 if (hit_body || hit_wall || (randint1(100) < j))
2678 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2680 if (potion_smash_effect(creature_ptr, 0, y, x, q_ptr->k_idx))
2682 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx];
2683 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2685 GAME_TEXT m_name[MAX_NLEN];
2686 monster_desc(creature_ptr, m_name, m_ptr, 0);
2687 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2688 set_hostile(creature_ptr, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx]);
2699 if (return_when_thrown)
2701 int back_chance = randint1(30)+20+((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2702 char o2_name[MAX_NLEN];
2703 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2706 if (boomerang) back_chance += 4+randint1(5);
2707 if (super_boomerang) back_chance += 100;
2708 object_desc(creature_ptr, o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2710 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2712 for (i = cur_dis - 1; i > 0; i--)
2714 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(creature_ptr, ny[i], nx[i]))
2716 char c = object_char(q_ptr);
2717 byte a = object_attr(q_ptr);
2719 /* Draw, Hilite, Fresh, Pause, Erase */
2720 print_rel(creature_ptr, c, a, ny[i], nx[i]);
2721 move_cursor_relative(ny[i], nx[i]);
2723 Term_xtra(TERM_XTRA_DELAY, msec);
2724 lite_spot(creature_ptr, ny[i], nx[i]);
2729 /* Pause anyway, for consistancy */
2730 Term_xtra(TERM_XTRA_DELAY, msec);
2733 if((back_chance > 37) && !creature_ptr->blind && (item >= 0))
2735 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2742 msg_format(_("%sを受け損ねた!", "%s comes back, but you can't catch!"), o2_name);
2746 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2748 y = creature_ptr->y;
2749 x = creature_ptr->x;
2754 msg_format(_("%sが返ってこなかった!", "%s doesn't come back!"), o2_name);
2760 if (item == INVEN_RARM || item == INVEN_LARM)
2762 /* Access the wield slot */
2763 o_ptr = &creature_ptr->inventory_list[item];
2765 /* Wear the new stuff */
2766 object_copy(o_ptr, q_ptr);
2768 creature_ptr->total_weight += q_ptr->weight;
2770 /* Increment the equip counter by hand */
2771 creature_ptr->equip_cnt++;
2773 creature_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2774 creature_ptr->window |= (PW_EQUIP);
2778 inven_carry(creature_ptr, q_ptr);
2782 else if (equiped_item)
2784 verify_equip_slot(creature_ptr, item);
2785 calc_android_exp(creature_ptr);
2790 if (cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_PROJECT))
2792 (void)drop_near(creature_ptr, q_ptr, j, y, x);
2796 (void)drop_near(creature_ptr, q_ptr, j, prev_y, prev_x);
2804 * @brief 自殺するコマンドのメインルーチン
2805 * Hack -- commit suicide
2809 void do_cmd_suicide(player_type *creature_ptr)
2816 /* Verify Retirement */
2817 if (current_world_ptr->total_winner)
2820 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2823 /* Verify Suicide */
2827 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2830 if (!current_world_ptr->noscore)
2832 /* Special Verification for suicide */
2833 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2838 if (i != '@') return;
2840 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2843 /* Initialize "last message" buffer */
2844 if (creature_ptr->last_message) string_free(creature_ptr->last_message);
2845 creature_ptr->last_message = NULL;
2847 /* Hack -- Note *winning* message */
2848 if (current_world_ptr->total_winner && last_words)
2850 char buf[1024] = "";
2851 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2854 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2855 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2859 creature_ptr->last_message = string_make(buf);
2860 msg_print(creature_ptr->last_message);
2865 creature_ptr->playing = FALSE;
2867 /* Kill the player */
2868 creature_ptr->is_dead = TRUE;
2869 creature_ptr->leaving = TRUE;
2871 if (!current_world_ptr->total_winner)
2873 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("ダンジョンの探索に絶望して自殺した。", "gave up all hope to commit suicide."));
2874 exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2875 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
2878 /* Cause of death */
2879 (void)strcpy(creature_ptr->died_from, _("途中終了", "Quitting"));