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.
14 #include "main/music-definitions-table.h"
15 #include "main/sound-definitions-table.h"
17 #include "core/stuff-handler.h"
20 #include "io/write-diary.h"
21 #include "cmd/cmd-dump.h"
22 #include "cmd/cmd-save.h"
27 #include "object-hook.h"
28 #include "monster-status.h"
32 #include "player-status.h"
33 #include "realm/realm-hex.h"
37 #include "player-move.h"
38 #include "player-effects.h"
39 #include "player-personality.h"
40 #include "player-inventory.h"
41 #include "object/object-kind.h"
42 #include "object-broken.h"
43 #include "object-flavor.h"
47 #include "cmd-basic.h"
48 #include "dungeon-file.h"
51 #include "view/display-main-window.h"
52 #include "targeting.h"
54 #include "effect/spells-effect-util.h"
55 #include "spell/spells3.h"
58 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
59 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
60 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
62 static bool confirm_leave_level(player_type *creature_ptr, bool down_stair)
64 quest_type *q_ptr = &quest[creature_ptr->current_floor_ptr->inside_quest];
66 /* Confirm leaving from once only quest */
67 if (confirm_quest && creature_ptr->current_floor_ptr->inside_quest &&
68 (q_ptr->type == QUEST_TYPE_RANDOM ||
69 (q_ptr->flags & QUEST_FLAG_ONCE &&
70 q_ptr->status != QUEST_STATUS_COMPLETED) ||
71 (q_ptr->flags & QUEST_FLAG_TOWER &&
72 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
73 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
75 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
76 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
86 * @brief 魔法系コマンドが制限されているかを返す。
87 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
89 bool cmd_limit_cast(player_type *creature_ptr)
91 if (creature_ptr->current_floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
93 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
97 else if (creature_ptr->anti_magic)
99 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
102 else if (creature_ptr->shero)
104 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
111 bool cmd_limit_confused(player_type *creature_ptr)
113 if (creature_ptr->confused)
115 msg_print(_("混乱していてできない!", "You are too confused!"));
121 bool cmd_limit_image(player_type *creature_ptr)
123 if (creature_ptr->image)
125 msg_print(_("幻覚が見えて集中できない!", "Your hallucinations prevent you from concentrating!"));
131 bool cmd_limit_stun(player_type *creature_ptr)
133 if (creature_ptr->stun)
135 msg_print(_("頭が朦朧としていて集中できない!", "You are too stunned!"));
141 bool cmd_limit_arena(player_type *creature_ptr)
143 if (creature_ptr->current_floor_ptr->inside_arena)
145 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
152 bool cmd_limit_blind(player_type *creature_ptr)
154 if (creature_ptr->blind)
156 msg_print(_("目が見えない。", "You can't see anything."));
159 if (no_lite(creature_ptr))
161 msg_print(_("明かりがないので見えない。", "You have no light."));
167 bool cmd_limit_time_walk(player_type *creature_ptr)
169 if (creature_ptr->timewalk)
171 if (flush_failure) flush();
172 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
180 * @brief 階段を使って階層を昇る処理 / Go up one level
183 void do_cmd_go_up(player_type *creature_ptr)
188 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
189 feature_type *f_ptr = &f_info[g_ptr->feat];
193 if (creature_ptr->special_defense & KATA_MUSOU)
195 set_action(creature_ptr, ACTION_NONE);
199 if (!have_flag(f_ptr->flags, FF_LESS))
201 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
205 /* Quest up stairs */
206 if (have_flag(f_ptr->flags, FF_QUEST))
208 if (!confirm_leave_level(creature_ptr, FALSE)) return;
211 if (IS_ECHIZEN(creature_ptr))
212 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
214 msg_print(_("上の階に登った。", "You enter the up staircase."));
216 leave_quest_check(creature_ptr);
218 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
220 /* Activate the quest */
221 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
223 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
225 init_flags = INIT_ASSIGN;
226 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
228 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
231 /* Leaving a quest */
232 if (!creature_ptr->current_floor_ptr->inside_quest)
234 creature_ptr->current_floor_ptr->dun_level = 0;
236 creature_ptr->leaving = TRUE;
238 creature_ptr->oldpx = 0;
239 creature_ptr->oldpy = 0;
241 take_turn(creature_ptr, 100);
243 /* End the command */
247 if (!creature_ptr->current_floor_ptr->dun_level)
253 go_up = confirm_leave_level(creature_ptr, FALSE);
258 take_turn(creature_ptr, 100);
260 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
262 /* For a random quest */
263 if (creature_ptr->current_floor_ptr->inside_quest &&
264 quest[creature_ptr->current_floor_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
266 leave_quest_check(creature_ptr);
268 creature_ptr->current_floor_ptr->inside_quest = 0;
271 /* For a fixed quest */
272 if (creature_ptr->current_floor_ptr->inside_quest &&
273 quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
275 leave_quest_check(creature_ptr);
277 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
278 creature_ptr->current_floor_ptr->dun_level = 0;
282 /* For normal dungeon and random quest */
286 if (have_flag(f_ptr->flags, FF_SHAFT))
288 /* Create a way back */
289 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
295 /* Create a way back */
296 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP);
301 /* Get out from current dungeon */
302 if (creature_ptr->current_floor_ptr->dun_level - up_num < d_info[creature_ptr->dungeon_idx].mindepth)
303 up_num = creature_ptr->current_floor_ptr->dun_level;
305 if (record_stair) exe_write_diary(creature_ptr, DIARY_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
308 if (IS_ECHIZEN(creature_ptr))
309 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
310 else if (up_num == creature_ptr->current_floor_ptr->dun_level)
311 msg_print(_("地上に戻った。", "You go back to the surface."));
313 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
314 creature_ptr->leaving = TRUE;
319 * @brief 階段を使って階層を降りる処理 / Go down one level
320 * @param creature_ptr プレーヤーへの参照ポインタ
323 void do_cmd_go_down(player_type *creature_ptr)
325 bool fall_trap = FALSE;
328 if (creature_ptr->special_defense & KATA_MUSOU)
330 set_action(creature_ptr, ACTION_NONE);
334 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
335 feature_type *f_ptr = &f_info[g_ptr->feat];
336 if (!have_flag(f_ptr->flags, FF_MORE))
338 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
342 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
345 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
347 do_cmd_quest(creature_ptr);
351 /* Quest down stairs */
352 if (have_flag(f_ptr->flags, FF_QUEST))
354 /* Confirm Leaving */
355 if(!confirm_leave_level(creature_ptr, TRUE)) return;
357 if (IS_ECHIZEN(creature_ptr))
358 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
360 msg_print(_("下の階に降りた。", "You enter the down staircase."));
362 leave_quest_check(creature_ptr);
363 leave_tower_check(creature_ptr);
365 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
367 /* Activate the quest */
368 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
370 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
372 init_flags = INIT_ASSIGN;
373 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
375 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
378 /* Leaving a quest */
379 if (!creature_ptr->current_floor_ptr->inside_quest)
381 creature_ptr->current_floor_ptr->dun_level = 0;
383 creature_ptr->leaving = TRUE;
384 creature_ptr->oldpx = 0;
385 creature_ptr->oldpy = 0;
387 take_turn(creature_ptr, 100);
391 DUNGEON_IDX target_dungeon = 0;
393 if (!creature_ptr->current_floor_ptr->dun_level)
395 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
397 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
399 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
402 if (!max_dlv[target_dungeon])
404 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
405 d_name + d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
406 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
409 /* Save old player position */
410 creature_ptr->oldpx = creature_ptr->x;
411 creature_ptr->oldpy = creature_ptr->y;
412 creature_ptr->dungeon_idx = target_dungeon;
415 * Clear all saved floors
416 * and create a first saved floor
418 prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
421 take_turn(creature_ptr, 100);
423 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
426 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
429 if (!creature_ptr->current_floor_ptr->dun_level)
431 /* Enter the dungeon just now */
432 creature_ptr->enter_dungeon = TRUE;
433 down_num = d_info[creature_ptr->dungeon_idx].mindepth;
438 if (fall_trap) exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
439 else exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
444 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
451 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[creature_ptr->dungeon_idx].text);
455 if (IS_ECHIZEN(creature_ptr))
456 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
458 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
462 creature_ptr->leaving = TRUE;
466 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
470 /* Create a way back */
471 if (have_flag(f_ptr->flags, FF_SHAFT))
473 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
477 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN);
483 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
486 void do_cmd_search(player_type * creature_ptr)
488 /* Allow repeated command */
491 /* Set repeat count */
492 command_rep = command_arg - 1;
493 creature_ptr->redraw |= (PR_STATE);
499 take_turn(creature_ptr, 100);
500 search(creature_ptr);
505 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
506 * @param y 走査対象にしたいマスのY座標
507 * @param x 走査対象にしたいマスのX座標
508 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
509 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
511 static OBJECT_IDX chest_check(floor_type *floor_ptr, POSITION y, POSITION x, bool trapped)
513 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
514 OBJECT_IDX this_o_idx, next_o_idx = 0;
516 /* Scan all objects in the grid */
517 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
521 o_ptr = &floor_ptr->o_list[this_o_idx];
522 next_o_idx = o_ptr->next_o_idx;
524 /* Skip unknown chests XXX XXX */
525 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
527 /* Check for non empty chest */
528 if ((o_ptr->tval == TV_CHEST) &&
529 (((!trapped) && (o_ptr->pval)) || /* non empty */
530 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
541 * Attempt to open the given chest at the given location
542 * @param y 箱の存在するマスのY座標
543 * @param x 箱の存在するマスのX座標
544 * @param o_idx 箱のオブジェクトID
545 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
547 * Assume there is no monster blocking the destination
549 static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
553 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
555 take_turn(creature_ptr, 100);
557 /* Attempt to unlock it */
560 /* Assume locked, and thus not open */
563 /* Get the "disarm" factor */
564 int i = creature_ptr->skill_dis;
566 /* Penalize some conditions */
567 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
568 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
570 /* Extract the difficulty */
571 int j = i - o_ptr->pval;
573 /* Always have a small chance of success */
576 /* Success -- May still have traps */
577 if (randint0(100) < j)
579 msg_print(_("鍵をはずした。", "You have picked the lock."));
580 gain_exp(creature_ptr, 1);
584 /* Failure -- Keep trying */
587 /* We may continue repeating */
589 if (flush_failure) flush();
590 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
595 /* Allowed to open */
598 /* Apply chest traps, if any */
599 chest_trap(creature_ptr, y, x, o_idx);
601 /* Let the Chest drop items */
602 chest_death(creature_ptr, FALSE, y, x, o_idx);
609 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
610 * Attempt to open the given chest at the given location
611 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
612 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
613 * @param test 地形条件を判定するための関数ポインタ
614 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
616 * @details Return the number of features around (or under) the character.
617 * Usually look for doors and floor traps.
619 static int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(player_type*, FEAT_IDX feat), bool under)
621 /* Check around (and under) the character */
623 for (DIRECTION d = 0; d < 9; d++)
628 /* if not searching under player continue */
629 if ((d == 8) && !under) continue;
631 /* Extract adjacent (legal) location */
632 POSITION yy = creature_ptr->y + ddy_ddd[d];
633 POSITION xx = creature_ptr->x + ddx_ddd[d];
635 /* Get the creature_ptr->current_floor_ptr->grid_array */
636 g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
638 /* Must have knowledge */
639 if (!(g_ptr->info & (CAVE_MARK))) continue;
641 /* Feature code (applying "mimic" field) */
642 feat = get_feat_mimic(g_ptr);
644 /* Not looking for this feature */
645 if (!((*test)(creature_ptr, feat))) continue;
650 /* Remember the location. Only useful if only one match */
661 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
662 * Return the number of chests around (or under) the character.
663 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
664 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
665 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
668 * If requested, count only trapped chests.
670 static int count_chests(player_type *creature_ptr, POSITION *y, POSITION *x, bool trapped)
672 /* Check around (and under) the character */
674 for (DIRECTION d = 0; d < 9; d++)
676 /* Extract adjacent (legal) location */
677 POSITION yy = creature_ptr->y + ddy_ddd[d];
678 POSITION xx = creature_ptr->x + ddx_ddd[d];
680 /* No (visible) chest is there */
681 OBJECT_IDX o_idx = chest_check(creature_ptr->current_floor_ptr, yy, xx, FALSE);
682 if (!o_idx) continue;
684 /* Grab the object */
686 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
689 if (o_ptr->pval == 0) continue;
691 /* No (known) traps here */
692 if (trapped && (!object_is_known(o_ptr) ||
693 !chest_traps[o_ptr->pval])) continue;
698 /* Remember the location. Only useful if only one match */
710 * @brief 「開ける」動作コマンドのサブルーチン /
711 * Perform the basic "open" command on doors
712 * @param y 対象を行うマスのY座標
713 * @param x 対象を行うマスのX座標
714 * @return 実際に処理が行われた場合TRUEを返す。
716 * Assume destination is a closed/locked/jammed door
717 * Assume there is no monster blocking the destination
718 * Returns TRUE if repeated commands may continue
720 static bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
722 /* Get requested grid */
723 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
724 feature_type *f_ptr = &f_info[g_ptr->feat];
727 take_turn(creature_ptr, 100);
729 /* Seeing true feature code (ignore mimic) */
732 if (!have_flag(f_ptr->flags, FF_OPEN))
735 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
741 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
742 sound(SOUND_OPENDOOR);
747 int i = creature_ptr->skill_dis;
749 /* Penalize some conditions */
750 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
751 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
753 /* Extract the difficulty */
754 int j = f_ptr->power;
757 /* Always have a small chance of success */
760 if (randint0(100) >= j)
762 if (flush_failure) flush();
763 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
767 msg_print(_("鍵をはずした。", "You have picked the lock."));
770 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
772 sound(SOUND_OPENDOOR);
775 gain_exp(creature_ptr, 1);
780 * @brief 「開ける」コマンドのメインルーチン /
781 * Open a closed/locked/jammed door or a closed/locked chest.
784 * Unlocking a locked door/chest is worth one experience point.
786 void do_cmd_open(player_type *creature_ptr)
794 if (creature_ptr->wild_mode) return;
796 if (creature_ptr->special_defense & KATA_MUSOU)
798 set_action(creature_ptr, ACTION_NONE);
801 /* Option: Pick a direction */
804 int num_doors, num_chests;
806 num_doors = count_dt(creature_ptr, &y, &x, is_closed_door, FALSE);
807 num_chests = count_chests(creature_ptr, &y, &x, FALSE);
808 if (num_doors || num_chests)
810 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
812 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
816 /* Allow repeated command */
819 /* Set repeat count */
820 command_rep = command_arg - 1;
821 creature_ptr->redraw |= (PR_STATE);
827 /* Get a "repeated" direction */
828 if (get_rep_dir(creature_ptr, &dir, TRUE))
833 /* Get requested location */
834 y = creature_ptr->y + ddy[dir];
835 x = creature_ptr->x + ddx[dir];
837 /* Get requested grid */
838 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
840 /* Feature code (applying "mimic" field) */
841 feat = get_feat_mimic(g_ptr);
843 /* Check for chest */
844 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, FALSE);
846 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
848 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
850 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
852 take_turn(creature_ptr, 100);
853 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
854 py_attack(creature_ptr, y, x, 0);
858 more = exe_open_chest(creature_ptr, y, x, o_idx);
862 more = exe_open(creature_ptr, y, x);
866 /* Cancel repeat unless we may continue */
867 if (!more) disturb(creature_ptr, FALSE, FALSE);
874 * @brief 「閉じる」動作コマンドのサブルーチン /
875 * Perform the basic "close" command
876 * @param y 対象を行うマスのY座標
877 * @param x 対象を行うマスのX座標
878 * @return 実際に処理が行われた場合TRUEを返す。
880 * Assume destination is an open/broken door
881 * Assume there is no monster blocking the destination
882 * Returns TRUE if repeated commands may continue
884 static bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
886 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
887 FEAT_IDX old_feat = g_ptr->feat;
890 take_turn(creature_ptr, 100);
892 /* Seeing true feature code (ignore mimic) */
895 if (!have_flag(f_info[old_feat].flags, FF_CLOSE))
900 s16b closed_feat = feat_state(creature_ptr, old_feat, FF_CLOSE);
902 /* Hack -- object in the way */
903 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
904 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
906 msg_print(_("何かがつっかえて閉まらない。", "Something prevents it from closing."));
911 cave_alter_feat(creature_ptr, y, x, FF_CLOSE);
914 if (old_feat == g_ptr->feat)
916 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
920 sound(SOUND_SHUTDOOR);
929 * @brief 「閉じる」コマンドのメインルーチン /
930 * Close an open door.
933 * Unlocking a locked door/chest is worth one experience point.
935 void do_cmd_close(player_type *creature_ptr)
942 if (creature_ptr->wild_mode) return;
944 if (creature_ptr->special_defense & KATA_MUSOU)
946 set_action(creature_ptr, ACTION_NONE);
949 /* Option: Pick a direction */
952 /* Count open doors */
953 if (count_dt(creature_ptr, &y, &x, is_open, FALSE) == 1)
955 command_dir = coords_to_dir(creature_ptr, y, x);
959 /* Allow repeated command */
962 /* Set repeat count */
963 command_rep = command_arg - 1;
964 creature_ptr->redraw |= (PR_STATE);
970 /* Get a "repeated" direction */
971 if (get_rep_dir(creature_ptr, &dir, FALSE))
976 y = creature_ptr->y + ddy[dir];
977 x = creature_ptr->x + ddx[dir];
978 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
980 /* Feature code (applying "mimic" field) */
981 feat = get_feat_mimic(g_ptr);
983 /* Require open/broken door */
984 if (!have_flag(f_info[feat].flags, FF_CLOSE))
986 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
989 /* Monster in the way */
990 else if (g_ptr->m_idx)
992 take_turn(creature_ptr, 100);
994 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
997 py_attack(creature_ptr, y, x, 0);
1000 /* Close the door */
1003 /* Close the door */
1004 more = exe_close(creature_ptr, y, x);
1008 /* Cancel repeat unless we may continue */
1009 if (!more) disturb(creature_ptr, FALSE, FALSE);
1014 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1015 * Determine if a given grid may be "tunneled"
1016 * @param y 対象を行うマスのY座標
1017 * @param x 対象を行うマスのX座標
1020 static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
1022 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1024 /* Must have knowledge */
1025 if (!(g_ptr->info & CAVE_MARK))
1027 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1032 /* Must be a wall/door/etc */
1033 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1035 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1045 * @brief 「掘る」動作コマンドのサブルーチン /
1046 * Perform the basic "tunnel" command
1047 * @param y 対象を行うマスのY座標
1048 * @param x 対象を行うマスのX座標
1049 * @return 実際に処理が行われた場合TRUEを返す。
1051 * Assumes that no monster is blocking the destination
1052 * Do not use twall anymore
1053 * Returns TRUE if repeated commands may continue
1055 static bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
1058 feature_type *f_ptr, *mimic_f_ptr;
1063 /* Verify legality */
1064 if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x)) return FALSE;
1066 take_turn(creature_ptr, 100);
1068 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1069 f_ptr = &f_info[g_ptr->feat];
1070 power = f_ptr->power;
1072 /* Feature code (applying "mimic" field) */
1073 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1075 name = f_name + mimic_f_ptr->name;
1079 if (have_flag(f_ptr->flags, FF_PERMANENT))
1082 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1084 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1087 /* Map border (mimiccing Permanent wall) */
1090 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1095 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1098 if (creature_ptr->skill_dig > randint0(20 * power))
1100 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1102 /* Remove the feature */
1103 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1104 creature_ptr->update |= (PU_FLOW);
1108 /* Message, keep digging */
1109 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1117 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1120 if (creature_ptr->skill_dig > power + randint0(40 * power))
1122 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1125 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1126 creature_ptr->update |= (PU_FLOW);
1129 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1131 /* Remove the feature */
1132 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1134 chg_virtue(creature_ptr, V_DILIGENCE, 1);
1135 chg_virtue(creature_ptr, V_NATURE, -1);
1143 /* We may continue chopping */
1144 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1145 /* Occasional Search XXX XXX */
1146 if (randint0(100) < 25) search(creature_ptr);
1150 /* We may continue tunelling */
1151 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1158 if (is_hidden_door(creature_ptr, g_ptr))
1160 /* Occasional Search XXX XXX */
1161 if (randint0(100) < 25) search(creature_ptr);
1169 * @brief 「掘る」動作コマンドのメインルーチン /
1170 * Tunnels through "walls" (including rubble and closed doors)
1174 * Note that you must tunnel in order to hit invisible monsters
1175 * in walls, though moving into walls still takes a turn anyway.
1177 * Digging is very difficult without a "digger" weapon, but can be
1178 * accomplished by strong players using heavy weapons.
1181 void do_cmd_tunnel(player_type *creature_ptr)
1190 if (creature_ptr->special_defense & KATA_MUSOU)
1192 set_action(creature_ptr, ACTION_NONE);
1195 /* Allow repeated command */
1198 /* Set repeat count */
1199 command_rep = command_arg - 1;
1200 creature_ptr->redraw |= (PR_STATE);
1202 /* Cancel the arg */
1206 /* Get a direction to tunnel, or Abort */
1207 if (get_rep_dir(creature_ptr, &dir,FALSE))
1210 y = creature_ptr->y + ddy[dir];
1211 x = creature_ptr->x + ddx[dir];
1213 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1215 /* Feature code (applying "mimic" field) */
1216 feat = get_feat_mimic(g_ptr);
1218 /* No tunnelling through doors */
1219 if (have_flag(f_info[feat].flags, FF_DOOR))
1221 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1224 /* No tunnelling through most features */
1225 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1227 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1230 /* A monster is in the way */
1231 else if (g_ptr->m_idx)
1233 take_turn(creature_ptr, 100);
1234 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1237 py_attack(creature_ptr, y, x, 0);
1243 /* Tunnel through walls */
1244 more = exe_tunnel(creature_ptr, y, x);
1248 /* Cancel repetition unless we can continue */
1249 if (!more) disturb(creature_ptr, FALSE, FALSE);
1253 * @brief 移動処理による簡易な「開く」処理 /
1255 * @return 開く処理が実際に試みられた場合TRUEを返す
1258 * If there is a jammed/closed/locked door at the given location,
1259 * then attempt to unlock/open it. Return TRUE if an attempt was
1260 * made (successful or not), otherwise return FALSE.
1262 * The code here should be nearly identical to that in
1263 * do_cmd_open_test() and exe_open().
1266 bool easy_open_door(player_type *creature_ptr, POSITION y, POSITION x)
1270 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1271 feature_type *f_ptr = &f_info[g_ptr->feat];
1273 /* Must be a closed door */
1274 if (!is_closed_door(creature_ptr, g_ptr->feat))
1280 if (!have_flag(f_ptr->flags, FF_OPEN))
1283 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1288 else if (f_ptr->power)
1291 i = creature_ptr->skill_dis;
1293 /* Penalize some conditions */
1294 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1295 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1297 /* Extract the lock power */
1300 /* Extract the difficulty */
1303 /* Always have a small chance of success */
1307 if (randint0(100) < j)
1309 msg_print(_("鍵をはずした。", "You have picked the lock."));
1312 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1314 sound(SOUND_OPENDOOR);
1317 gain_exp(creature_ptr, 1);
1324 if (flush_failure) flush();
1326 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1335 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1337 sound(SOUND_OPENDOOR);
1344 * @brief 箱のトラップを解除する実行処理 /
1345 * Perform the basic "disarm" command
1346 * @param y 解除を行うマスのY座標
1347 * @param x 解除を行うマスのX座標
1348 * @param o_idx 箱のオブジェクトID
1349 * @return ターンを消費する処理が行われた場合TRUEを返す
1352 * Assume destination is a visible trap
1353 * Assume there is no monster blocking the destination
1354 * Returns TRUE if repeated commands may continue
1357 static bool exe_disarm_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
1361 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
1363 take_turn(creature_ptr, 100);
1365 /* Get the "disarm" factor */
1366 i = creature_ptr->skill_dis;
1368 /* Penalize some conditions */
1369 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1370 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1372 /* Extract the difficulty */
1373 j = i - o_ptr->pval;
1375 /* Always have a small chance of success */
1378 /* Must find the trap first. */
1379 if (!object_is_known(o_ptr))
1381 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1385 /* Already disarmed/unlocked */
1386 else if (o_ptr->pval <= 0)
1388 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1391 /* No traps to find. */
1392 else if (!chest_traps[o_ptr->pval])
1394 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1397 /* Success (get a lot of experience) */
1398 else if (randint0(100) < j)
1400 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1401 gain_exp(creature_ptr, o_ptr->pval);
1402 o_ptr->pval = (0 - o_ptr->pval);
1405 /* Failure -- Keep trying */
1406 else if ((i > 5) && (randint1(i) > 5))
1408 /* We may keep trying */
1410 if (flush_failure) flush();
1411 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1414 /* Failure -- Set off the trap */
1417 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1419 chest_trap(creature_ptr, y, x, o_idx);
1427 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1428 * Perform the basic "disarm" command
1429 * @param y 解除を行うマスのY座標
1430 * @param x 解除を行うマスのX座標
1431 * @param dir プレイヤーからみた方向ID
1432 * @return ターンを消費する処理が行われた場合TRUEを返す
1435 * Assume destination is a visible trap
1436 * Assume there is no monster blocking the destination
1437 * Returns TRUE if repeated commands may continue
1441 bool exe_disarm(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1443 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1446 feature_type *f_ptr = &f_info[g_ptr->feat];
1448 /* Access trap name */
1449 concptr name = (f_name + f_ptr->name);
1451 /* Extract trap "power" */
1452 int power = f_ptr->power;
1455 /* Get the "disarm" factor */
1456 int i = creature_ptr->skill_dis;
1459 take_turn(creature_ptr, 100);
1461 /* Penalize some conditions */
1462 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1463 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1465 /* Extract the difficulty */
1468 /* Always have a small chance of success */
1472 if (randint0(100) < j)
1474 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1477 gain_exp(creature_ptr, power);
1479 /* Remove the trap */
1480 cave_alter_feat(creature_ptr, y, x, FF_DISARM);
1482 /* Move the player onto the trap */
1483 move_player(creature_ptr, dir, easy_disarm, FALSE);
1486 /* Failure -- Keep trying */
1487 else if ((i > 5) && (randint1(i) > 5))
1490 if (flush_failure) flush();
1492 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1494 /* We may keep trying */
1498 /* Failure -- Set off the trap */
1501 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1502 /* Move the player onto the trap */
1503 move_player(creature_ptr, dir, easy_disarm, FALSE);
1511 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1512 * Disarms a trap, or chest
1515 void do_cmd_disarm(player_type *creature_ptr)
1523 if (creature_ptr->wild_mode) return;
1525 if (creature_ptr->special_defense & KATA_MUSOU)
1527 set_action(creature_ptr, ACTION_NONE);
1530 /* Option: Pick a direction */
1533 int num_traps, num_chests;
1535 /* Count visible traps */
1536 num_traps = count_dt(creature_ptr, &y, &x, is_trap, TRUE);
1538 /* Count chests (trapped) */
1539 num_chests = count_chests(creature_ptr, &y, &x, TRUE);
1541 /* See if only one target */
1542 if (num_traps || num_chests)
1544 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1545 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
1549 /* Allow repeated command */
1552 /* Set repeat count */
1553 command_rep = command_arg - 1;
1554 creature_ptr->redraw |= (PR_STATE);
1556 /* Cancel the arg */
1560 /* Get a direction (or abort) */
1561 if (get_rep_dir(creature_ptr, &dir,TRUE))
1566 y = creature_ptr->y + ddy[dir];
1567 x = creature_ptr->x + ddx[dir];
1568 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1570 /* Feature code (applying "mimic" field) */
1571 feat = get_feat_mimic(g_ptr);
1573 /* Check for chests */
1574 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, TRUE);
1577 if (!is_trap(creature_ptr, feat) && !o_idx)
1579 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1582 /* Monster in the way */
1583 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
1585 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1588 py_attack(creature_ptr, y, x, 0);
1594 more = exe_disarm_chest(creature_ptr, y, x, o_idx);
1600 more = exe_disarm(creature_ptr, y, x, dir);
1604 /* Cancel repeat unless told not to */
1605 if (!more) disturb(creature_ptr, FALSE, FALSE);
1610 * @brief 「打ち破る」動作コマンドのサブルーチン /
1611 * Perform the basic "bash" command
1612 * @param y 対象を行うマスのY座標
1613 * @param x 対象を行うマスのX座標
1614 * @param dir プレイヤーから見たターゲットの方角ID
1615 * @return 実際に処理が行われた場合TRUEを返す。
1618 * Assume destination is a closed/locked/jammed door
1619 * Assume there is no monster blocking the destination
1620 * Returns TRUE if repeated commands may continue
1623 static bool do_cmd_bash_aux(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1625 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1628 feature_type *f_ptr = &f_info[g_ptr->feat];
1630 /* Hack -- Bash power based on strength */
1631 /* (Ranges from 3 to 20 to 100 to 200) */
1632 int bash = adj_str_blow[creature_ptr->stat_ind[A_STR]];
1634 /* Extract door power */
1635 int temp = f_ptr->power;
1639 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1641 take_turn(creature_ptr, 100);
1643 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1645 /* Compare bash power to door power */
1646 temp = (bash - (temp * 10));
1648 if (creature_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1650 /* Hack -- always have a chance */
1651 if (temp < 1) temp = 1;
1653 /* Hack -- attempt to bash down the door */
1654 if (randint0(100) < temp)
1656 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1658 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1660 /* Break down the door */
1661 if ((randint0(100) < 50) || (feat_state(creature_ptr, g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1663 cave_alter_feat(creature_ptr, y, x, FF_BASH);
1669 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1672 /* Hack -- Fall through the door */
1673 move_player(creature_ptr, dir, FALSE, FALSE);
1676 /* Saving throw against stun */
1677 else if (randint0(100) < adj_dex_safe[creature_ptr->stat_ind[A_DEX]] +
1680 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1682 /* Allow repeated bashing */
1686 /* High dexterity yields coolness */
1689 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1691 /* Hack -- Lose balance ala paralysis */
1692 (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 2 + randint0(2));
1700 * @brief 「打ち破る」動作コマンドのメインルーチン /
1701 * Bash open a door, success based on character strength
1705 * For a closed door, pval is positive if locked; negative if stuck.
1707 * For an open door, pval is positive for a broken door.
1709 * A closed door can be opened - harder if locked. Any door might be
1710 * bashed open (and thereby broken). Bashing a door is (potentially)
1711 * faster! You move into the door way. To open a stuck door, it must
1712 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1714 * Creatures can also open or bash doors, see elsewhere.
1717 void do_cmd_bash(player_type *creature_ptr)
1724 if (creature_ptr->wild_mode) return;
1726 if (creature_ptr->special_defense & KATA_MUSOU)
1728 set_action(creature_ptr, ACTION_NONE);
1731 /* Allow repeated command */
1734 /* Set repeat count */
1735 command_rep = command_arg - 1;
1736 creature_ptr->redraw |= (PR_STATE);
1738 /* Cancel the arg */
1742 /* Get a "repeated" direction */
1743 if (get_rep_dir(creature_ptr, &dir,FALSE))
1748 y = creature_ptr->y + ddy[dir];
1749 x = creature_ptr->x + ddx[dir];
1751 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1753 /* Feature code (applying "mimic" field) */
1754 feat = get_feat_mimic(g_ptr);
1756 /* Nothing useful */
1757 if (!have_flag(f_info[feat].flags, FF_BASH))
1759 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1762 /* Monster in the way */
1763 else if (g_ptr->m_idx)
1765 take_turn(creature_ptr, 100);
1767 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1770 py_attack(creature_ptr, y, x, 0);
1773 /* Bash a closed door */
1777 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1781 /* Unless valid action taken, cancel bash */
1782 if (!more) disturb(creature_ptr, FALSE, FALSE);
1787 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1791 * Manipulate an adjacent grid in some way
1793 * Attack monsters, tunnel through walls, disarm traps, open doors.
1795 * Consider confusion
1797 * This command must always take a turn, to prevent free detection
1798 * of invisible monsters.
1801 void do_cmd_alter(player_type *creature_ptr)
1808 if (creature_ptr->special_defense & KATA_MUSOU)
1810 set_action(creature_ptr, ACTION_NONE);
1813 /* Allow repeated command */
1816 /* Set repeat count */
1817 command_rep = command_arg - 1;
1818 creature_ptr->redraw |= (PR_STATE);
1820 /* Cancel the arg */
1824 /* Get a direction */
1825 if (get_rep_dir(creature_ptr, &dir,TRUE))
1828 feature_type *f_ptr;
1830 y = creature_ptr->y + ddy[dir];
1831 x = creature_ptr->x + ddx[dir];
1833 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1835 /* Feature code (applying "mimic" field) */
1836 feat = get_feat_mimic(g_ptr);
1837 f_ptr = &f_info[feat];
1839 take_turn(creature_ptr, 100);
1843 py_attack(creature_ptr, y, x, 0);
1847 else if (have_flag(f_ptr->flags, FF_OPEN))
1849 more = exe_open(creature_ptr, y, x);
1852 /* Bash jammed doors */
1853 else if (have_flag(f_ptr->flags, FF_BASH))
1855 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1858 /* Tunnel through walls */
1859 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1861 more = exe_tunnel(creature_ptr, y, x);
1864 /* Close open doors */
1865 else if (have_flag(f_ptr->flags, FF_CLOSE))
1867 more = exe_close(creature_ptr, y, x);
1871 else if (have_flag(f_ptr->flags, FF_DISARM))
1873 more = exe_disarm(creature_ptr, y, x, dir);
1878 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1882 /* Cancel repetition unless we can continue */
1883 if (!more) disturb(creature_ptr, FALSE, FALSE);
1889 * @brief 「くさびを打つ」ために必要なオブジェクトを所持しているかどうかの判定を返す /
1890 * Find the index of some "spikes", if possible.
1891 * @param ip くさびとして打てるオブジェクトのID
1892 * @return オブジェクトがある場合TRUEを返す
1895 * Let user choose a pile of spikes, perhaps?
1898 static bool get_spike(player_type *creature_ptr, INVENTORY_IDX *ip)
1902 /* Check every item in the pack */
1903 for (i = 0; i < INVEN_PACK; i++)
1905 object_type *o_ptr = &creature_ptr->inventory_list[i];
1906 if (!o_ptr->k_idx) continue;
1908 /* Check the "tval" code */
1909 if (o_ptr->tval == TV_SPIKE)
1911 /* Save the spike index */
1924 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1925 * Jam a closed door with a spike
1926 * @param creature_ptr プレーヤーへの参照ポインタ
1930 * This command may NOT be repeated
1933 void do_cmd_spike(player_type *creature_ptr)
1937 if (creature_ptr->wild_mode) return;
1938 if (creature_ptr->special_defense & KATA_MUSOU)
1940 set_action(creature_ptr, ACTION_NONE);
1943 /* Get a "repeated" direction */
1944 if (!get_rep_dir(creature_ptr, &dir, FALSE)) return;
1946 POSITION y = creature_ptr->y + ddy[dir];
1947 POSITION x = creature_ptr->x + ddx[dir];
1949 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1951 /* Feature code (applying "mimic" field) */
1952 FEAT_IDX feat = get_feat_mimic(g_ptr);
1954 /* Require closed door */
1956 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1958 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1962 else if (!get_spike(creature_ptr, &item))
1964 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1967 /* Is a monster in the way? */
1968 else if (g_ptr->m_idx)
1970 take_turn(creature_ptr, 100);
1972 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1975 py_attack(creature_ptr, y, x, 0);
1981 take_turn(creature_ptr, 100);
1983 /* Successful jamming */
1984 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1985 cave_alter_feat(creature_ptr, y, x, FF_SPIKE);
1987 vary_item(creature_ptr, item, -1);
1993 * @brief 「歩く」動作コマンドのメインルーチン /
1994 * Support code for the "Walk" and "Jump" commands
1995 * @param creature_ptr プレーヤーへの参照ポインタ
1996 * @param pickup アイテムの自動拾いを行うならTRUE
1999 void do_cmd_walk(player_type *creature_ptr, bool pickup)
2001 /* Allow repeated command */
2004 /* Set repeat count */
2005 command_rep = command_arg - 1;
2006 creature_ptr->redraw |= (PR_STATE);
2008 /* Cancel the arg */
2012 /* Get a "repeated" direction */
2015 if (get_rep_dir(creature_ptr, &dir, FALSE))
2017 take_turn(creature_ptr, 100);
2019 if ((dir != 5) && (creature_ptr->special_defense & KATA_MUSOU))
2021 set_action(creature_ptr, ACTION_NONE);
2024 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2025 if (creature_ptr->wild_mode) creature_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2026 if (creature_ptr->action == ACTION_HAYAGAKE) creature_ptr->energy_use = creature_ptr->energy_use * (45-(creature_ptr->lev/2)) / 100;
2028 /* Actually move the character */
2029 move_player(creature_ptr, dir, pickup, FALSE);
2031 /* Allow more walking */
2035 /* Hack again -- Is there a special encounter ??? */
2036 if (creature_ptr->wild_mode && !cave_have_flag_bold(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, FF_TOWN))
2038 int tmp = 120 + creature_ptr->lev*10 - wilderness[creature_ptr->y][creature_ptr->x].level + 5;
2041 if (((wilderness[creature_ptr->y][creature_ptr->x].level + 5) > (creature_ptr->lev / 2)) && randint0(tmp) < (21-creature_ptr->skill_stl))
2043 /* Inform the player of his horrible fate :=) */
2044 msg_print(_("襲撃だ!", "You are ambushed !"));
2046 /* Go into large wilderness view */
2047 creature_ptr->oldpy = randint1(MAX_HGT-2);
2048 creature_ptr->oldpx = randint1(MAX_WID-2);
2049 change_wild_mode(creature_ptr, TRUE);
2051 /* Give first move to monsters */
2052 take_turn(creature_ptr, 100);
2057 /* Cancel repeat unless we may continue */
2058 if (!more) disturb(creature_ptr, FALSE, FALSE);
2063 * @brief 「走る」動作コマンドのメインルーチン /
2065 * @param creature_ptr プレーヤーへの参照ポインタ
2068 void do_cmd_run(player_type *creature_ptr)
2071 if (cmd_limit_confused(creature_ptr)) return;
2073 if (creature_ptr->special_defense & KATA_MUSOU)
2075 set_action(creature_ptr, ACTION_NONE);
2078 /* Get a "repeated" direction */
2079 if (get_rep_dir(creature_ptr, &dir,FALSE))
2081 /* Hack -- Set the run counter */
2082 creature_ptr->running = (command_arg ? command_arg : 1000);
2085 run_step(creature_ptr, dir);
2091 * @brief 「留まる」動作コマンドのメインルーチン /
2092 * Stay still. Search. Enter stores.
2093 * Pick up treasure if "pickup" is true.
2094 * @param creature_ptr プレーヤーへの参照ポインタ
2095 * @param pickup アイテムの自動拾いを行うならTRUE
2098 void do_cmd_stay(player_type *creature_ptr, bool pickup)
2100 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2102 /* Allow repeated command */
2105 /* Set repeat count */
2106 command_rep = command_arg - 1;
2107 creature_ptr->redraw |= (PR_STATE);
2109 /* Cancel the arg */
2113 take_turn(creature_ptr, 100);
2115 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2116 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, mpe_mode);
2121 * @brief 「休む」動作コマンドのメインルーチン /
2122 * Resting allows a player to safely restore his hp -RAK-
2123 * @param creature_ptr プレーヤーへの参照ポインタ
2126 void do_cmd_rest(player_type *creature_ptr)
2128 set_action(creature_ptr, ACTION_NONE);
2130 if ((creature_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(creature_ptr) || INTERUPTING_SONG_EFFECT(creature_ptr)))
2132 stop_singing(creature_ptr);
2135 if (hex_spelling_any(creature_ptr)) stop_hex_spell_all(creature_ptr);
2137 /* Prompt for time if needed */
2138 if (command_arg <= 0)
2140 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2141 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2146 strcpy(out_val, "&");
2148 /* Ask for duration */
2149 if (!get_string(p, out_val, 4)) return;
2151 /* Rest until done */
2152 if (out_val[0] == '&')
2154 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2158 else if (out_val[0] == '*')
2160 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2166 command_arg = (COMMAND_ARG)atoi(out_val);
2167 if (command_arg <= 0) return;
2171 if (command_arg > 9999) command_arg = 9999;
2173 if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE);
2175 /* Take a turn (?) */
2176 take_turn(creature_ptr, 100);
2178 /* The sin of sloth */
2179 if (command_arg > 100) chg_virtue(creature_ptr, V_DILIGENCE, -1);
2181 /* Why are you sleeping when there's no need? WAKE UP!*/
2182 if ((creature_ptr->chp == creature_ptr->mhp) &&
2183 (creature_ptr->csp == creature_ptr->msp) &&
2184 !creature_ptr->blind && !creature_ptr->confused &&
2185 !creature_ptr->poisoned && !creature_ptr->afraid &&
2186 !creature_ptr->stun && !creature_ptr->cut &&
2187 !creature_ptr->slow && !creature_ptr->paralyzed &&
2188 !creature_ptr->image && !creature_ptr->word_recall &&
2189 !creature_ptr->alter_reality)
2190 chg_virtue(creature_ptr, V_DILIGENCE, -1);
2192 /* Save the rest code */
2193 creature_ptr->resting = command_arg;
2194 creature_ptr->action = ACTION_REST;
2195 creature_ptr->update |= (PU_BONUS);
2196 update_creature(creature_ptr);
2198 creature_ptr->redraw |= (PR_STATE);
2199 update_output(creature_ptr);
2208 * @brief 射撃処理のメインルーチン
2209 * @param creature_ptr プレーヤーへの参照ポインタ
2210 * @param snipe_type ???
2213 void do_cmd_fire(player_type *creature_ptr, SPELL_IDX snipe_type)
2216 object_type *j_ptr, *ammo_ptr;
2219 if(creature_ptr->wild_mode) return;
2221 creature_ptr->is_fired = FALSE; /* not fired yet */
2223 /* Get the "bow" (if any) */
2224 j_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2226 /* Require a launcher */
2229 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2234 if (j_ptr->sval == SV_CRIMSON)
2236 msg_print(_("この武器は発動して使うもののようだ。", "It's already activated."));
2241 if (j_ptr->sval == SV_HARP)
2243 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2249 if (creature_ptr->special_defense & KATA_MUSOU)
2251 set_action(creature_ptr, ACTION_NONE);
2254 q = _("どれを撃ちますか? ", "Fire which item? ");
2255 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2257 ammo_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), creature_ptr->tval_ammo);
2265 exe_fire(creature_ptr, item, j_ptr, snipe_type);
2267 if (!creature_ptr->is_fired || creature_ptr->pclass != CLASS_SNIPER) return;
2269 /* Sniper actions after some shootings */
2270 if (snipe_type == SP_AWAY)
2272 teleport_player(creature_ptr, 10 + (creature_ptr->concent * 2), TELEPORT_SPONTANEOUS);
2275 if (snipe_type == SP_FINAL)
2277 msg_print(_("射撃の反動が体を襲った。", "The weapon's recoil stuns you. "));
2278 (void)set_slow(creature_ptr, creature_ptr->slow + randint0(7) + 7, FALSE);
2279 (void)set_stun(creature_ptr, creature_ptr->stun + randint1(25));
2285 * @brief 投射処理メインルーチン /
2286 * Throw an object from the pack or floor.
2288 * @param creature_ptr プレーヤーへの参照ポインタ
2289 * @param boomerang ブーメラン処理ならばTRUE
2290 * @param shuriken 忍者の手裏剣処理ならばTRUE
2291 * @return ターンを消費した場合TRUEを返す
2294 * Note: "unseen" monsters are very hard to hit.
2296 * Should throwing a weapon do full damage? Should it allow the magic
2297 * to hit bonus of the weapon to have an effect? Should it ever cause
2298 * the item to be destroyed? Should it do any damage at all?
2301 bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_IDX shuriken)
2306 POSITION y, x, ty, tx, prev_y, prev_x;
2307 POSITION ny[19], nx[19];
2308 int chance, tdam, tdis;
2309 int mul, div, dd, ds;
2310 int cur_dis, visible;
2317 bool hit_body = FALSE;
2318 bool hit_wall = FALSE;
2319 bool equiped_item = FALSE;
2320 bool return_when_thrown = FALSE;
2322 GAME_TEXT o_name[MAX_NLEN];
2324 int msec = delay_factor * delay_factor * delay_factor;
2326 BIT_FLAGS flgs[TR_FLAG_SIZE];
2328 bool come_back = FALSE;
2329 bool do_drop = TRUE;
2331 if (creature_ptr->wild_mode) return FALSE;
2333 if (creature_ptr->special_defense & KATA_MUSOU)
2335 set_action(creature_ptr, ACTION_NONE);
2341 o_ptr = &creature_ptr->inventory_list[item];
2345 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2347 item_tester_hook = item_tester_hook_boomerang;
2348 q = _("どの武器を投げますか? ", "Throw which item? ");
2349 s = _("投げる武器がない。", "You have nothing to throw.");
2350 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP), 0);
2357 else if (has_melee_weapon(creature_ptr, INVEN_LARM))
2360 o_ptr = &creature_ptr->inventory_list[item];
2365 o_ptr = &creature_ptr->inventory_list[item];
2370 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2371 s = _("投げるアイテムがない。", "You have nothing to throw.");
2372 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP), 0);
2380 /* Item is cursed */
2381 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2383 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2387 if (creature_ptr->current_floor_ptr->inside_arena && !boomerang)
2389 if (o_ptr->tval != TV_SPIKE)
2391 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2399 object_copy(q_ptr, o_ptr);
2401 /* Extract the thrown object's flags. */
2402 object_flags(q_ptr, flgs);
2403 torch_flags(q_ptr, flgs);
2405 /* Distribute the charges of rods/wands between the stacks */
2406 distribute_charges(o_ptr, q_ptr, 1);
2411 object_desc(creature_ptr, o_name, q_ptr, OD_OMIT_PREFIX);
2413 if (creature_ptr->mighty_throw) mult += 3;
2415 /* Extract a "distance multiplier" */
2416 /* Changed for 'launcher' mutation */
2417 mul = 10 + 2 * (mult - 1);
2419 /* Enforce a minimum "weight" of one pound */
2420 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2421 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2423 /* Hack -- Distance -- Reward strength, penalize weight */
2424 tdis = (adj_str_blow[creature_ptr->stat_ind[A_STR]] + 20) * mul / div;
2426 /* Max distance of 10-18 */
2427 if (tdis > mul) tdis = mul;
2431 ty = randint0(101) - 50 + creature_ptr->y;
2432 tx = randint0(101) - 50 + creature_ptr->x;
2436 project_length = tdis + 1;
2438 /* Get a direction (or cancel) */
2439 if (!get_aim_dir(creature_ptr, &dir)) return FALSE;
2441 /* Predict the "target" location */
2442 tx = creature_ptr->x + 99 * ddx[dir];
2443 ty = creature_ptr->y + 99 * ddy[dir];
2445 /* Check for "target request" */
2446 if ((dir == 5) && target_okay(creature_ptr))
2452 project_length = 0; /* reset to default */
2455 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2456 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2457 return_when_thrown = TRUE;
2461 inven_item_increase(creature_ptr, item, -1);
2462 if (!return_when_thrown)
2463 inven_item_describe(creature_ptr, item);
2464 inven_item_optimize(creature_ptr, item);
2468 floor_item_increase(creature_ptr->current_floor_ptr, 0 - item, -1);
2469 floor_item_optimize(creature_ptr, 0 - item);
2472 if (item >= INVEN_RARM)
2474 equiped_item = TRUE;
2475 creature_ptr->redraw |= (PR_EQUIPPY);
2478 take_turn(creature_ptr, 100);
2480 /* Rogue and Ninja gets bonus */
2481 if ((creature_ptr->pclass == CLASS_ROGUE) || (creature_ptr->pclass == CLASS_NINJA))
2482 creature_ptr->energy_use -= creature_ptr->lev;
2484 /* Start at the player */
2485 y = creature_ptr->y;
2486 x = creature_ptr->x;
2488 handle_stuff(creature_ptr);
2490 if ((creature_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2491 else shuriken = FALSE;
2493 /* Chance of hitting */
2494 if (have_flag(flgs, TR_THROW)) chance = ((creature_ptr->skill_tht) +
2495 ((creature_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2496 else chance = (creature_ptr->skill_tht + (creature_ptr->to_h_b * BTH_PLUS_ADJ));
2498 if (shuriken) chance *= 2;
2503 /* Travel until stopped */
2504 for (cur_dis = 0; cur_dis <= tdis; )
2506 /* Hack -- Stop at the target */
2507 if ((y == ty) && (x == tx)) break;
2509 /* Calculate the new location (see "project()") */
2512 mmove2(&ny[cur_dis], &nx[cur_dis], creature_ptr->y, creature_ptr->x, ty, tx);
2514 /* Stopped by walls/doors */
2515 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, ny[cur_dis], nx[cur_dis], FF_PROJECT))
2518 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;
2521 /* The player can see the (on screen) missile */
2522 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(creature_ptr, ny[cur_dis], nx[cur_dis]))
2524 SYMBOL_CODE c = object_char(q_ptr);
2525 TERM_COLOR a = object_attr(q_ptr);
2527 /* Draw, Hilite, Fresh, Pause, Erase */
2528 print_rel(creature_ptr, c, a, ny[cur_dis], nx[cur_dis]);
2529 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2531 Term_xtra(TERM_XTRA_DELAY, msec);
2532 lite_spot(creature_ptr, ny[cur_dis], nx[cur_dis]);
2536 /* The player cannot see the missile */
2539 /* Pause anyway, for consistancy */
2540 Term_xtra(TERM_XTRA_DELAY, msec);
2546 /* Save the new location */
2550 /* Advance the distance */
2553 /* Monster here, Try to hit it */
2554 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
2556 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
2557 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2558 GAME_TEXT m_name[MAX_NLEN];
2559 monster_name(creature_ptr, g_ptr->m_idx, m_name);
2561 /* Check the visibility */
2562 visible = m_ptr->ml;
2564 /* Note the collision */
2567 /* Did we hit it (penalize range) */
2568 if (test_hit_fire(creature_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2572 /* Handle unseen monster */
2575 /* Invisible monster */
2576 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2579 /* Handle visible monster */
2582 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2586 if (!creature_ptr->image) monster_race_track(creature_ptr, m_ptr->ap_r_idx);
2587 health_track(creature_ptr, g_ptr->m_idx);
2591 /* Hack -- Base damage from thrown object */
2594 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2595 tdam = damroll(dd, ds);
2596 /* Apply special damage */
2597 tdam = tot_dam_aux(creature_ptr, q_ptr, tdam, m_ptr, 0, TRUE);
2598 tdam = critical_shot(creature_ptr, q_ptr->weight, q_ptr->to_h, 0, tdam);
2599 if (q_ptr->to_d > 0)
2600 tdam += q_ptr->to_d;
2602 tdam += -q_ptr->to_d;
2606 tdam *= (mult+creature_ptr->num_blow[item - INVEN_RARM]);
2607 tdam += creature_ptr->to_d_m;
2609 else if (have_flag(flgs, TR_THROW))
2612 tdam += creature_ptr->to_d_m;
2620 tdam += ((creature_ptr->lev+30)*(creature_ptr->lev+30)-900)/55;
2623 /* No negative damage */
2624 if (tdam < 0) tdam = 0;
2626 /* Modify the damage */
2627 tdam = mon_damage_mod(creature_ptr, m_ptr, tdam, FALSE);
2629 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2630 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2632 /* Hit the monster, check for death */
2633 if (mon_take_hit(creature_ptr, g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2641 message_pain(creature_ptr, g_ptr->m_idx, tdam);
2643 /* Anger the monster */
2644 if ((tdam > 0) && !object_is_potion(q_ptr))
2645 anger_monster(creature_ptr, m_ptr);
2647 if (fear && m_ptr->ml)
2650 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2660 /* decrease toach's fuel */
2661 if (hit_body) torch_lost_fuel(q_ptr);
2663 /* Chance of breakage (during attacks) */
2664 j = (hit_body ? breakage_chance(creature_ptr, q_ptr, creature_ptr->pclass == CLASS_ARCHER, 0) : 0);
2666 /* Figurines transform */
2667 if ((q_ptr->tval == TV_FIGURINE) && !(creature_ptr->current_floor_ptr->inside_arena))
2671 if (!(summon_named_creature(creature_ptr, 0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2672 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2673 else if (object_is_cursed(q_ptr))
2674 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2678 /* Potions smash open */
2679 if (object_is_potion(q_ptr))
2681 if (hit_body || hit_wall || (randint1(100) < j))
2683 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2685 if (potion_smash_effect(creature_ptr, 0, y, x, q_ptr->k_idx))
2687 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx];
2688 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2690 GAME_TEXT m_name[MAX_NLEN];
2691 monster_desc(creature_ptr, m_name, m_ptr, 0);
2692 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2693 set_hostile(creature_ptr, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx]);
2704 if (return_when_thrown)
2706 int back_chance = randint1(30)+20+((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2707 char o2_name[MAX_NLEN];
2708 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2711 if (boomerang) back_chance += 4+randint1(5);
2712 if (super_boomerang) back_chance += 100;
2713 object_desc(creature_ptr, o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2715 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2717 for (i = cur_dis - 1; i > 0; i--)
2719 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(creature_ptr, ny[i], nx[i]))
2721 char c = object_char(q_ptr);
2722 byte a = object_attr(q_ptr);
2724 /* Draw, Hilite, Fresh, Pause, Erase */
2725 print_rel(creature_ptr, c, a, ny[i], nx[i]);
2726 move_cursor_relative(ny[i], nx[i]);
2728 Term_xtra(TERM_XTRA_DELAY, msec);
2729 lite_spot(creature_ptr, ny[i], nx[i]);
2734 /* Pause anyway, for consistancy */
2735 Term_xtra(TERM_XTRA_DELAY, msec);
2738 if((back_chance > 37) && !creature_ptr->blind && (item >= 0))
2740 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2747 msg_format(_("%sを受け損ねた!", "%s comes back, but you can't catch!"), o2_name);
2751 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2753 y = creature_ptr->y;
2754 x = creature_ptr->x;
2759 msg_format(_("%sが返ってこなかった!", "%s doesn't come back!"), o2_name);
2765 if (item == INVEN_RARM || item == INVEN_LARM)
2767 /* Access the wield slot */
2768 o_ptr = &creature_ptr->inventory_list[item];
2770 /* Wear the new stuff */
2771 object_copy(o_ptr, q_ptr);
2773 creature_ptr->total_weight += q_ptr->weight;
2775 /* Increment the equip counter by hand */
2776 creature_ptr->equip_cnt++;
2778 creature_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2779 creature_ptr->window |= (PW_EQUIP);
2783 inven_carry(creature_ptr, q_ptr);
2787 else if (equiped_item)
2789 verify_equip_slot(creature_ptr, item);
2790 calc_android_exp(creature_ptr);
2795 if (cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_PROJECT))
2797 (void)drop_near(creature_ptr, q_ptr, j, y, x);
2801 (void)drop_near(creature_ptr, q_ptr, j, prev_y, prev_x);
2809 * @brief 自殺するコマンドのメインルーチン
2810 * Hack -- commit suicide
2814 void do_cmd_suicide(player_type *creature_ptr)
2821 /* Verify Retirement */
2822 if (current_world_ptr->total_winner)
2825 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2828 /* Verify Suicide */
2832 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2835 if (!current_world_ptr->noscore)
2837 /* Special Verification for suicide */
2838 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2843 if (i != '@') return;
2845 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2848 /* Initialize "last message" buffer */
2849 if (creature_ptr->last_message) string_free(creature_ptr->last_message);
2850 creature_ptr->last_message = NULL;
2852 /* Hack -- Note *winning* message */
2853 if (current_world_ptr->total_winner && last_words)
2855 char buf[1024] = "";
2856 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2859 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2860 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2864 creature_ptr->last_message = string_make(buf);
2865 msg_print(creature_ptr->last_message);
2870 creature_ptr->playing = FALSE;
2872 /* Kill the player */
2873 creature_ptr->is_dead = TRUE;
2874 creature_ptr->leaving = TRUE;
2876 if (!current_world_ptr->total_winner)
2878 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("ダンジョンの探索に絶望して自殺した。", "gave up all hope to commit suicide."));
2879 exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2880 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
2883 /* Cause of death */
2884 (void)strcpy(creature_ptr->died_from, _("途中終了", "Quitting"));