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"
19 #include "io/write-diary.h"
20 #include "cmd/cmd-dump.h"
21 #include "cmd/cmd-save.h"
26 #include "object-hook.h"
27 #include "monster-status.h"
31 #include "player-status.h"
32 #include "realm/realm-hex.h"
36 #include "player-move.h"
37 #include "player-effects.h"
38 #include "player-personality.h"
39 #include "player-inventory.h"
40 #include "object/object-kind.h"
41 #include "object-broken.h"
42 #include "object-flavor.h"
46 #include "cmd-basic.h"
47 #include "dungeon-file.h"
50 #include "view/display-main-window.h"
51 #include "targeting.h"
53 #include "effect/spells-effect-util.h"
56 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
57 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
58 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
60 static bool confirm_leave_level(player_type *creature_ptr, bool down_stair)
62 quest_type *q_ptr = &quest[creature_ptr->current_floor_ptr->inside_quest];
64 /* Confirm leaving from once only quest */
65 if (confirm_quest && creature_ptr->current_floor_ptr->inside_quest &&
66 (q_ptr->type == QUEST_TYPE_RANDOM ||
67 (q_ptr->flags & QUEST_FLAG_ONCE &&
68 q_ptr->status != QUEST_STATUS_COMPLETED) ||
69 (q_ptr->flags & QUEST_FLAG_TOWER &&
70 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
71 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
73 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
74 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
84 * @brief 魔法系コマンドが制限されているかを返す。
85 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
87 bool cmd_limit_cast(player_type *creature_ptr)
89 if (creature_ptr->current_floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
91 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
95 else if (creature_ptr->anti_magic)
97 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
100 else if (creature_ptr->shero)
102 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
109 bool cmd_limit_confused(player_type *creature_ptr)
111 if (creature_ptr->confused)
113 msg_print(_("混乱していてできない!", "You are too confused!"));
119 bool cmd_limit_image(player_type *creature_ptr)
121 if (creature_ptr->image)
123 msg_print(_("幻覚が見えて集中できない!", "Your hallucinations prevent you from concentrating!"));
129 bool cmd_limit_stun(player_type *creature_ptr)
131 if (creature_ptr->stun)
133 msg_print(_("頭が朦朧としていて集中できない!", "You are too stunned!"));
139 bool cmd_limit_arena(player_type *creature_ptr)
141 if (creature_ptr->current_floor_ptr->inside_arena)
143 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
150 bool cmd_limit_blind(player_type *creature_ptr)
152 if (creature_ptr->blind)
154 msg_print(_("目が見えない。", "You can't see anything."));
157 if (no_lite(creature_ptr))
159 msg_print(_("明かりがないので見えない。", "You have no light."));
165 bool cmd_limit_time_walk(player_type *creature_ptr)
167 if (creature_ptr->timewalk)
169 if (flush_failure) flush();
170 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
178 * @brief 階段を使って階層を昇る処理 / Go up one level
181 void do_cmd_go_up(player_type *creature_ptr)
186 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
187 feature_type *f_ptr = &f_info[g_ptr->feat];
191 if (creature_ptr->special_defense & KATA_MUSOU)
193 set_action(creature_ptr, ACTION_NONE);
197 if (!have_flag(f_ptr->flags, FF_LESS))
199 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
203 /* Quest up stairs */
204 if (have_flag(f_ptr->flags, FF_QUEST))
206 if (!confirm_leave_level(creature_ptr, FALSE)) return;
209 if (IS_ECHIZEN(creature_ptr))
210 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
212 msg_print(_("上の階に登った。", "You enter the up staircase."));
214 leave_quest_check(creature_ptr);
216 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
218 /* Activate the quest */
219 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
221 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
223 init_flags = INIT_ASSIGN;
224 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
226 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
229 /* Leaving a quest */
230 if (!creature_ptr->current_floor_ptr->inside_quest)
232 creature_ptr->current_floor_ptr->dun_level = 0;
234 creature_ptr->leaving = TRUE;
236 creature_ptr->oldpx = 0;
237 creature_ptr->oldpy = 0;
239 take_turn(creature_ptr, 100);
241 /* End the command */
245 if (!creature_ptr->current_floor_ptr->dun_level)
251 go_up = confirm_leave_level(creature_ptr, FALSE);
256 take_turn(creature_ptr, 100);
258 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
260 /* For a random quest */
261 if (creature_ptr->current_floor_ptr->inside_quest &&
262 quest[creature_ptr->current_floor_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
264 leave_quest_check(creature_ptr);
266 creature_ptr->current_floor_ptr->inside_quest = 0;
269 /* For a fixed quest */
270 if (creature_ptr->current_floor_ptr->inside_quest &&
271 quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
273 leave_quest_check(creature_ptr);
275 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
276 creature_ptr->current_floor_ptr->dun_level = 0;
280 /* For normal dungeon and random quest */
284 if (have_flag(f_ptr->flags, FF_SHAFT))
286 /* Create a way back */
287 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
293 /* Create a way back */
294 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP);
299 /* Get out from current dungeon */
300 if (creature_ptr->current_floor_ptr->dun_level - up_num < d_info[creature_ptr->dungeon_idx].mindepth)
301 up_num = creature_ptr->current_floor_ptr->dun_level;
303 if (record_stair) exe_write_diary(creature_ptr, DIARY_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
306 if (IS_ECHIZEN(creature_ptr))
307 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
308 else if (up_num == creature_ptr->current_floor_ptr->dun_level)
309 msg_print(_("地上に戻った。", "You go back to the surface."));
311 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
312 creature_ptr->leaving = TRUE;
317 * @brief 階段を使って階層を降りる処理 / Go down one level
318 * @param creature_ptr プレーヤーへの参照ポインタ
321 void do_cmd_go_down(player_type *creature_ptr)
323 bool fall_trap = FALSE;
326 if (creature_ptr->special_defense & KATA_MUSOU)
328 set_action(creature_ptr, ACTION_NONE);
332 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
333 feature_type *f_ptr = &f_info[g_ptr->feat];
334 if (!have_flag(f_ptr->flags, FF_MORE))
336 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
340 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
343 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
345 do_cmd_quest(creature_ptr);
349 /* Quest down stairs */
350 if (have_flag(f_ptr->flags, FF_QUEST))
352 /* Confirm Leaving */
353 if(!confirm_leave_level(creature_ptr, TRUE)) return;
355 if (IS_ECHIZEN(creature_ptr))
356 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
358 msg_print(_("下の階に降りた。", "You enter the down staircase."));
360 leave_quest_check(creature_ptr);
361 leave_tower_check(creature_ptr);
363 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
365 /* Activate the quest */
366 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
368 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
370 init_flags = INIT_ASSIGN;
371 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
373 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
376 /* Leaving a quest */
377 if (!creature_ptr->current_floor_ptr->inside_quest)
379 creature_ptr->current_floor_ptr->dun_level = 0;
381 creature_ptr->leaving = TRUE;
382 creature_ptr->oldpx = 0;
383 creature_ptr->oldpy = 0;
385 take_turn(creature_ptr, 100);
389 DUNGEON_IDX target_dungeon = 0;
391 if (!creature_ptr->current_floor_ptr->dun_level)
393 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
395 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
397 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
400 if (!max_dlv[target_dungeon])
402 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
403 d_name + d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
404 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
407 /* Save old player position */
408 creature_ptr->oldpx = creature_ptr->x;
409 creature_ptr->oldpy = creature_ptr->y;
410 creature_ptr->dungeon_idx = target_dungeon;
413 * Clear all saved floors
414 * and create a first saved floor
416 prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
419 take_turn(creature_ptr, 100);
421 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
424 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
427 if (!creature_ptr->current_floor_ptr->dun_level)
429 /* Enter the dungeon just now */
430 creature_ptr->enter_dungeon = TRUE;
431 down_num = d_info[creature_ptr->dungeon_idx].mindepth;
436 if (fall_trap) exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
437 else exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
442 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
449 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[creature_ptr->dungeon_idx].text);
453 if (IS_ECHIZEN(creature_ptr))
454 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
456 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
460 creature_ptr->leaving = TRUE;
464 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
468 /* Create a way back */
469 if (have_flag(f_ptr->flags, FF_SHAFT))
471 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
475 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN);
481 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
484 void do_cmd_search(player_type * creature_ptr)
486 /* Allow repeated command */
489 /* Set repeat count */
490 command_rep = command_arg - 1;
491 creature_ptr->redraw |= (PR_STATE);
497 take_turn(creature_ptr, 100);
498 search(creature_ptr);
503 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
504 * @param y 走査対象にしたいマスのY座標
505 * @param x 走査対象にしたいマスのX座標
506 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
507 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
509 static OBJECT_IDX chest_check(floor_type *floor_ptr, POSITION y, POSITION x, bool trapped)
511 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
512 OBJECT_IDX this_o_idx, next_o_idx = 0;
514 /* Scan all objects in the grid */
515 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
519 o_ptr = &floor_ptr->o_list[this_o_idx];
520 next_o_idx = o_ptr->next_o_idx;
522 /* Skip unknown chests XXX XXX */
523 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
525 /* Check for non empty chest */
526 if ((o_ptr->tval == TV_CHEST) &&
527 (((!trapped) && (o_ptr->pval)) || /* non empty */
528 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
539 * Attempt to open the given chest at the given location
540 * @param y 箱の存在するマスのY座標
541 * @param x 箱の存在するマスのX座標
542 * @param o_idx 箱のオブジェクトID
543 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
545 * Assume there is no monster blocking the destination
547 static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
551 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
553 take_turn(creature_ptr, 100);
555 /* Attempt to unlock it */
558 /* Assume locked, and thus not open */
561 /* Get the "disarm" factor */
562 int i = creature_ptr->skill_dis;
564 /* Penalize some conditions */
565 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
566 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
568 /* Extract the difficulty */
569 int j = i - o_ptr->pval;
571 /* Always have a small chance of success */
574 /* Success -- May still have traps */
575 if (randint0(100) < j)
577 msg_print(_("鍵をはずした。", "You have picked the lock."));
578 gain_exp(creature_ptr, 1);
582 /* Failure -- Keep trying */
585 /* We may continue repeating */
587 if (flush_failure) flush();
588 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
593 /* Allowed to open */
596 /* Apply chest traps, if any */
597 chest_trap(creature_ptr, y, x, o_idx);
599 /* Let the Chest drop items */
600 chest_death(creature_ptr, FALSE, y, x, o_idx);
607 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
608 * Attempt to open the given chest at the given location
609 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
610 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
611 * @param test 地形条件を判定するための関数ポインタ
612 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
614 * @details Return the number of features around (or under) the character.
615 * Usually look for doors and floor traps.
617 static int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(player_type*, FEAT_IDX feat), bool under)
619 /* Check around (and under) the character */
621 for (DIRECTION d = 0; d < 9; d++)
626 /* if not searching under player continue */
627 if ((d == 8) && !under) continue;
629 /* Extract adjacent (legal) location */
630 POSITION yy = creature_ptr->y + ddy_ddd[d];
631 POSITION xx = creature_ptr->x + ddx_ddd[d];
633 /* Get the creature_ptr->current_floor_ptr->grid_array */
634 g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
636 /* Must have knowledge */
637 if (!(g_ptr->info & (CAVE_MARK))) continue;
639 /* Feature code (applying "mimic" field) */
640 feat = get_feat_mimic(g_ptr);
642 /* Not looking for this feature */
643 if (!((*test)(creature_ptr, feat))) continue;
648 /* Remember the location. Only useful if only one match */
659 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
660 * Return the number of chests around (or under) the character.
661 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
662 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
663 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
666 * If requested, count only trapped chests.
668 static int count_chests(player_type *creature_ptr, POSITION *y, POSITION *x, bool trapped)
670 /* Check around (and under) the character */
672 for (DIRECTION d = 0; d < 9; d++)
674 /* Extract adjacent (legal) location */
675 POSITION yy = creature_ptr->y + ddy_ddd[d];
676 POSITION xx = creature_ptr->x + ddx_ddd[d];
678 /* No (visible) chest is there */
679 OBJECT_IDX o_idx = chest_check(creature_ptr->current_floor_ptr, yy, xx, FALSE);
680 if (!o_idx) continue;
682 /* Grab the object */
684 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
687 if (o_ptr->pval == 0) continue;
689 /* No (known) traps here */
690 if (trapped && (!object_is_known(o_ptr) ||
691 !chest_traps[o_ptr->pval])) continue;
696 /* Remember the location. Only useful if only one match */
708 * @brief 「開ける」動作コマンドのサブルーチン /
709 * Perform the basic "open" command on doors
710 * @param y 対象を行うマスのY座標
711 * @param x 対象を行うマスのX座標
712 * @return 実際に処理が行われた場合TRUEを返す。
714 * Assume destination is a closed/locked/jammed door
715 * Assume there is no monster blocking the destination
716 * Returns TRUE if repeated commands may continue
718 static bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
720 /* Get requested grid */
721 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
722 feature_type *f_ptr = &f_info[g_ptr->feat];
725 take_turn(creature_ptr, 100);
727 /* Seeing true feature code (ignore mimic) */
730 if (!have_flag(f_ptr->flags, FF_OPEN))
733 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
739 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
740 sound(SOUND_OPENDOOR);
745 int i = creature_ptr->skill_dis;
747 /* Penalize some conditions */
748 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
749 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
751 /* Extract the difficulty */
752 int j = f_ptr->power;
755 /* Always have a small chance of success */
758 if (randint0(100) >= j)
760 if (flush_failure) flush();
761 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
765 msg_print(_("鍵をはずした。", "You have picked the lock."));
768 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
770 sound(SOUND_OPENDOOR);
773 gain_exp(creature_ptr, 1);
778 * @brief 「開ける」コマンドのメインルーチン /
779 * Open a closed/locked/jammed door or a closed/locked chest.
782 * Unlocking a locked door/chest is worth one experience point.
784 void do_cmd_open(player_type *creature_ptr)
792 if (creature_ptr->wild_mode) return;
794 if (creature_ptr->special_defense & KATA_MUSOU)
796 set_action(creature_ptr, ACTION_NONE);
799 /* Option: Pick a direction */
802 int num_doors, num_chests;
804 num_doors = count_dt(creature_ptr, &y, &x, is_closed_door, FALSE);
805 num_chests = count_chests(creature_ptr, &y, &x, FALSE);
806 if (num_doors || num_chests)
808 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
810 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
814 /* Allow repeated command */
817 /* Set repeat count */
818 command_rep = command_arg - 1;
819 creature_ptr->redraw |= (PR_STATE);
825 /* Get a "repeated" direction */
826 if (get_rep_dir(creature_ptr, &dir, TRUE))
831 /* Get requested location */
832 y = creature_ptr->y + ddy[dir];
833 x = creature_ptr->x + ddx[dir];
835 /* Get requested grid */
836 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
838 /* Feature code (applying "mimic" field) */
839 feat = get_feat_mimic(g_ptr);
841 /* Check for chest */
842 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, FALSE);
844 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
846 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
848 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
850 take_turn(creature_ptr, 100);
851 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
852 py_attack(creature_ptr, y, x, 0);
856 more = exe_open_chest(creature_ptr, y, x, o_idx);
860 more = exe_open(creature_ptr, y, x);
864 /* Cancel repeat unless we may continue */
865 if (!more) disturb(creature_ptr, FALSE, FALSE);
872 * @brief 「閉じる」動作コマンドのサブルーチン /
873 * Perform the basic "close" command
874 * @param y 対象を行うマスのY座標
875 * @param x 対象を行うマスのX座標
876 * @return 実際に処理が行われた場合TRUEを返す。
878 * Assume destination is an open/broken door
879 * Assume there is no monster blocking the destination
880 * Returns TRUE if repeated commands may continue
882 static bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
884 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
885 FEAT_IDX old_feat = g_ptr->feat;
888 take_turn(creature_ptr, 100);
890 /* Seeing true feature code (ignore mimic) */
893 if (!have_flag(f_info[old_feat].flags, FF_CLOSE))
898 s16b closed_feat = feat_state(creature_ptr, old_feat, FF_CLOSE);
900 /* Hack -- object in the way */
901 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
902 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
904 msg_print(_("何かがつっかえて閉まらない。", "Something prevents it from closing."));
909 cave_alter_feat(creature_ptr, y, x, FF_CLOSE);
912 if (old_feat == g_ptr->feat)
914 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
918 sound(SOUND_SHUTDOOR);
927 * @brief 「閉じる」コマンドのメインルーチン /
928 * Close an open door.
931 * Unlocking a locked door/chest is worth one experience point.
933 void do_cmd_close(player_type *creature_ptr)
940 if (creature_ptr->wild_mode) return;
942 if (creature_ptr->special_defense & KATA_MUSOU)
944 set_action(creature_ptr, ACTION_NONE);
947 /* Option: Pick a direction */
950 /* Count open doors */
951 if (count_dt(creature_ptr, &y, &x, is_open, FALSE) == 1)
953 command_dir = coords_to_dir(creature_ptr, y, x);
957 /* Allow repeated command */
960 /* Set repeat count */
961 command_rep = command_arg - 1;
962 creature_ptr->redraw |= (PR_STATE);
968 /* Get a "repeated" direction */
969 if (get_rep_dir(creature_ptr, &dir, FALSE))
974 y = creature_ptr->y + ddy[dir];
975 x = creature_ptr->x + ddx[dir];
976 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
978 /* Feature code (applying "mimic" field) */
979 feat = get_feat_mimic(g_ptr);
981 /* Require open/broken door */
982 if (!have_flag(f_info[feat].flags, FF_CLOSE))
984 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
987 /* Monster in the way */
988 else if (g_ptr->m_idx)
990 take_turn(creature_ptr, 100);
992 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
995 py_attack(creature_ptr, y, x, 0);
1001 /* Close the door */
1002 more = exe_close(creature_ptr, y, x);
1006 /* Cancel repeat unless we may continue */
1007 if (!more) disturb(creature_ptr, FALSE, FALSE);
1012 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1013 * Determine if a given grid may be "tunneled"
1014 * @param y 対象を行うマスのY座標
1015 * @param x 対象を行うマスのX座標
1018 static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
1020 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1022 /* Must have knowledge */
1023 if (!(g_ptr->info & CAVE_MARK))
1025 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1030 /* Must be a wall/door/etc */
1031 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1033 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1043 * @brief 「掘る」動作コマンドのサブルーチン /
1044 * Perform the basic "tunnel" command
1045 * @param y 対象を行うマスのY座標
1046 * @param x 対象を行うマスのX座標
1047 * @return 実際に処理が行われた場合TRUEを返す。
1049 * Assumes that no monster is blocking the destination
1050 * Do not use twall anymore
1051 * Returns TRUE if repeated commands may continue
1053 static bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
1056 feature_type *f_ptr, *mimic_f_ptr;
1061 /* Verify legality */
1062 if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x)) return FALSE;
1064 take_turn(creature_ptr, 100);
1066 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1067 f_ptr = &f_info[g_ptr->feat];
1068 power = f_ptr->power;
1070 /* Feature code (applying "mimic" field) */
1071 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1073 name = f_name + mimic_f_ptr->name;
1077 if (have_flag(f_ptr->flags, FF_PERMANENT))
1080 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1082 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1085 /* Map border (mimiccing Permanent wall) */
1088 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1093 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1096 if (creature_ptr->skill_dig > randint0(20 * power))
1098 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1100 /* Remove the feature */
1101 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1102 creature_ptr->update |= (PU_FLOW);
1106 /* Message, keep digging */
1107 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1115 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1118 if (creature_ptr->skill_dig > power + randint0(40 * power))
1120 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1123 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1124 creature_ptr->update |= (PU_FLOW);
1127 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1129 /* Remove the feature */
1130 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1132 chg_virtue(creature_ptr, V_DILIGENCE, 1);
1133 chg_virtue(creature_ptr, V_NATURE, -1);
1141 /* We may continue chopping */
1142 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1143 /* Occasional Search XXX XXX */
1144 if (randint0(100) < 25) search(creature_ptr);
1148 /* We may continue tunelling */
1149 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1156 if (is_hidden_door(creature_ptr, g_ptr))
1158 /* Occasional Search XXX XXX */
1159 if (randint0(100) < 25) search(creature_ptr);
1167 * @brief 「掘る」動作コマンドのメインルーチン /
1168 * Tunnels through "walls" (including rubble and closed doors)
1172 * Note that you must tunnel in order to hit invisible monsters
1173 * in walls, though moving into walls still takes a turn anyway.
1175 * Digging is very difficult without a "digger" weapon, but can be
1176 * accomplished by strong players using heavy weapons.
1179 void do_cmd_tunnel(player_type *creature_ptr)
1188 if (creature_ptr->special_defense & KATA_MUSOU)
1190 set_action(creature_ptr, ACTION_NONE);
1193 /* Allow repeated command */
1196 /* Set repeat count */
1197 command_rep = command_arg - 1;
1198 creature_ptr->redraw |= (PR_STATE);
1200 /* Cancel the arg */
1204 /* Get a direction to tunnel, or Abort */
1205 if (get_rep_dir(creature_ptr, &dir,FALSE))
1208 y = creature_ptr->y + ddy[dir];
1209 x = creature_ptr->x + ddx[dir];
1211 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1213 /* Feature code (applying "mimic" field) */
1214 feat = get_feat_mimic(g_ptr);
1216 /* No tunnelling through doors */
1217 if (have_flag(f_info[feat].flags, FF_DOOR))
1219 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1222 /* No tunnelling through most features */
1223 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1225 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1228 /* A monster is in the way */
1229 else if (g_ptr->m_idx)
1231 take_turn(creature_ptr, 100);
1232 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1235 py_attack(creature_ptr, y, x, 0);
1241 /* Tunnel through walls */
1242 more = exe_tunnel(creature_ptr, y, x);
1246 /* Cancel repetition unless we can continue */
1247 if (!more) disturb(creature_ptr, FALSE, FALSE);
1251 * @brief 移動処理による簡易な「開く」処理 /
1253 * @return 開く処理が実際に試みられた場合TRUEを返す
1256 * If there is a jammed/closed/locked door at the given location,
1257 * then attempt to unlock/open it. Return TRUE if an attempt was
1258 * made (successful or not), otherwise return FALSE.
1260 * The code here should be nearly identical to that in
1261 * do_cmd_open_test() and exe_open().
1264 bool easy_open_door(player_type *creature_ptr, POSITION y, POSITION x)
1268 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1269 feature_type *f_ptr = &f_info[g_ptr->feat];
1271 /* Must be a closed door */
1272 if (!is_closed_door(creature_ptr, g_ptr->feat))
1278 if (!have_flag(f_ptr->flags, FF_OPEN))
1281 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1286 else if (f_ptr->power)
1289 i = creature_ptr->skill_dis;
1291 /* Penalize some conditions */
1292 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1293 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1295 /* Extract the lock power */
1298 /* Extract the difficulty */
1301 /* Always have a small chance of success */
1305 if (randint0(100) < j)
1307 msg_print(_("鍵をはずした。", "You have picked the lock."));
1310 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1312 sound(SOUND_OPENDOOR);
1315 gain_exp(creature_ptr, 1);
1322 if (flush_failure) flush();
1324 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1333 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1335 sound(SOUND_OPENDOOR);
1342 * @brief 箱のトラップを解除する実行処理 /
1343 * Perform the basic "disarm" command
1344 * @param y 解除を行うマスのY座標
1345 * @param x 解除を行うマスのX座標
1346 * @param o_idx 箱のオブジェクトID
1347 * @return ターンを消費する処理が行われた場合TRUEを返す
1350 * Assume destination is a visible trap
1351 * Assume there is no monster blocking the destination
1352 * Returns TRUE if repeated commands may continue
1355 static bool exe_disarm_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
1359 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
1361 take_turn(creature_ptr, 100);
1363 /* Get the "disarm" factor */
1364 i = creature_ptr->skill_dis;
1366 /* Penalize some conditions */
1367 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1368 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1370 /* Extract the difficulty */
1371 j = i - o_ptr->pval;
1373 /* Always have a small chance of success */
1376 /* Must find the trap first. */
1377 if (!object_is_known(o_ptr))
1379 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1383 /* Already disarmed/unlocked */
1384 else if (o_ptr->pval <= 0)
1386 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1389 /* No traps to find. */
1390 else if (!chest_traps[o_ptr->pval])
1392 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1395 /* Success (get a lot of experience) */
1396 else if (randint0(100) < j)
1398 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1399 gain_exp(creature_ptr, o_ptr->pval);
1400 o_ptr->pval = (0 - o_ptr->pval);
1403 /* Failure -- Keep trying */
1404 else if ((i > 5) && (randint1(i) > 5))
1406 /* We may keep trying */
1408 if (flush_failure) flush();
1409 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1412 /* Failure -- Set off the trap */
1415 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1417 chest_trap(creature_ptr, y, x, o_idx);
1425 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1426 * Perform the basic "disarm" command
1427 * @param y 解除を行うマスのY座標
1428 * @param x 解除を行うマスのX座標
1429 * @param dir プレイヤーからみた方向ID
1430 * @return ターンを消費する処理が行われた場合TRUEを返す
1433 * Assume destination is a visible trap
1434 * Assume there is no monster blocking the destination
1435 * Returns TRUE if repeated commands may continue
1439 bool exe_disarm(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1441 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1444 feature_type *f_ptr = &f_info[g_ptr->feat];
1446 /* Access trap name */
1447 concptr name = (f_name + f_ptr->name);
1449 /* Extract trap "power" */
1450 int power = f_ptr->power;
1453 /* Get the "disarm" factor */
1454 int i = creature_ptr->skill_dis;
1457 take_turn(creature_ptr, 100);
1459 /* Penalize some conditions */
1460 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1461 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1463 /* Extract the difficulty */
1466 /* Always have a small chance of success */
1470 if (randint0(100) < j)
1472 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1475 gain_exp(creature_ptr, power);
1477 /* Remove the trap */
1478 cave_alter_feat(creature_ptr, y, x, FF_DISARM);
1480 /* Move the player onto the trap */
1481 move_player(creature_ptr, dir, easy_disarm, FALSE);
1484 /* Failure -- Keep trying */
1485 else if ((i > 5) && (randint1(i) > 5))
1488 if (flush_failure) flush();
1490 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1492 /* We may keep trying */
1496 /* Failure -- Set off the trap */
1499 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1500 /* Move the player onto the trap */
1501 move_player(creature_ptr, dir, easy_disarm, FALSE);
1509 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1510 * Disarms a trap, or chest
1513 void do_cmd_disarm(player_type *creature_ptr)
1521 if (creature_ptr->wild_mode) return;
1523 if (creature_ptr->special_defense & KATA_MUSOU)
1525 set_action(creature_ptr, ACTION_NONE);
1528 /* Option: Pick a direction */
1531 int num_traps, num_chests;
1533 /* Count visible traps */
1534 num_traps = count_dt(creature_ptr, &y, &x, is_trap, TRUE);
1536 /* Count chests (trapped) */
1537 num_chests = count_chests(creature_ptr, &y, &x, TRUE);
1539 /* See if only one target */
1540 if (num_traps || num_chests)
1542 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1543 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
1547 /* Allow repeated command */
1550 /* Set repeat count */
1551 command_rep = command_arg - 1;
1552 creature_ptr->redraw |= (PR_STATE);
1554 /* Cancel the arg */
1558 /* Get a direction (or abort) */
1559 if (get_rep_dir(creature_ptr, &dir,TRUE))
1564 y = creature_ptr->y + ddy[dir];
1565 x = creature_ptr->x + ddx[dir];
1566 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1568 /* Feature code (applying "mimic" field) */
1569 feat = get_feat_mimic(g_ptr);
1571 /* Check for chests */
1572 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, TRUE);
1575 if (!is_trap(creature_ptr, feat) && !o_idx)
1577 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1580 /* Monster in the way */
1581 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
1583 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1586 py_attack(creature_ptr, y, x, 0);
1592 more = exe_disarm_chest(creature_ptr, y, x, o_idx);
1598 more = exe_disarm(creature_ptr, y, x, dir);
1602 /* Cancel repeat unless told not to */
1603 if (!more) disturb(creature_ptr, FALSE, FALSE);
1608 * @brief 「打ち破る」動作コマンドのサブルーチン /
1609 * Perform the basic "bash" command
1610 * @param y 対象を行うマスのY座標
1611 * @param x 対象を行うマスのX座標
1612 * @param dir プレイヤーから見たターゲットの方角ID
1613 * @return 実際に処理が行われた場合TRUEを返す。
1616 * Assume destination is a closed/locked/jammed door
1617 * Assume there is no monster blocking the destination
1618 * Returns TRUE if repeated commands may continue
1621 static bool do_cmd_bash_aux(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1623 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1626 feature_type *f_ptr = &f_info[g_ptr->feat];
1628 /* Hack -- Bash power based on strength */
1629 /* (Ranges from 3 to 20 to 100 to 200) */
1630 int bash = adj_str_blow[creature_ptr->stat_ind[A_STR]];
1632 /* Extract door power */
1633 int temp = f_ptr->power;
1637 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1639 take_turn(creature_ptr, 100);
1641 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1643 /* Compare bash power to door power */
1644 temp = (bash - (temp * 10));
1646 if (creature_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1648 /* Hack -- always have a chance */
1649 if (temp < 1) temp = 1;
1651 /* Hack -- attempt to bash down the door */
1652 if (randint0(100) < temp)
1654 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1656 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1658 /* Break down the door */
1659 if ((randint0(100) < 50) || (feat_state(creature_ptr, g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1661 cave_alter_feat(creature_ptr, y, x, FF_BASH);
1667 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1670 /* Hack -- Fall through the door */
1671 move_player(creature_ptr, dir, FALSE, FALSE);
1674 /* Saving throw against stun */
1675 else if (randint0(100) < adj_dex_safe[creature_ptr->stat_ind[A_DEX]] +
1678 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1680 /* Allow repeated bashing */
1684 /* High dexterity yields coolness */
1687 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1689 /* Hack -- Lose balance ala paralysis */
1690 (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 2 + randint0(2));
1698 * @brief 「打ち破る」動作コマンドのメインルーチン /
1699 * Bash open a door, success based on character strength
1703 * For a closed door, pval is positive if locked; negative if stuck.
1705 * For an open door, pval is positive for a broken door.
1707 * A closed door can be opened - harder if locked. Any door might be
1708 * bashed open (and thereby broken). Bashing a door is (potentially)
1709 * faster! You move into the door way. To open a stuck door, it must
1710 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1712 * Creatures can also open or bash doors, see elsewhere.
1715 void do_cmd_bash(player_type *creature_ptr)
1722 if (creature_ptr->wild_mode) return;
1724 if (creature_ptr->special_defense & KATA_MUSOU)
1726 set_action(creature_ptr, ACTION_NONE);
1729 /* Allow repeated command */
1732 /* Set repeat count */
1733 command_rep = command_arg - 1;
1734 creature_ptr->redraw |= (PR_STATE);
1736 /* Cancel the arg */
1740 /* Get a "repeated" direction */
1741 if (get_rep_dir(creature_ptr, &dir,FALSE))
1746 y = creature_ptr->y + ddy[dir];
1747 x = creature_ptr->x + ddx[dir];
1749 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1751 /* Feature code (applying "mimic" field) */
1752 feat = get_feat_mimic(g_ptr);
1754 /* Nothing useful */
1755 if (!have_flag(f_info[feat].flags, FF_BASH))
1757 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1760 /* Monster in the way */
1761 else if (g_ptr->m_idx)
1763 take_turn(creature_ptr, 100);
1765 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1768 py_attack(creature_ptr, y, x, 0);
1771 /* Bash a closed door */
1775 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1779 /* Unless valid action taken, cancel bash */
1780 if (!more) disturb(creature_ptr, FALSE, FALSE);
1785 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1789 * Manipulate an adjacent grid in some way
1791 * Attack monsters, tunnel through walls, disarm traps, open doors.
1793 * Consider confusion
1795 * This command must always take a turn, to prevent free detection
1796 * of invisible monsters.
1799 void do_cmd_alter(player_type *creature_ptr)
1806 if (creature_ptr->special_defense & KATA_MUSOU)
1808 set_action(creature_ptr, ACTION_NONE);
1811 /* Allow repeated command */
1814 /* Set repeat count */
1815 command_rep = command_arg - 1;
1816 creature_ptr->redraw |= (PR_STATE);
1818 /* Cancel the arg */
1822 /* Get a direction */
1823 if (get_rep_dir(creature_ptr, &dir,TRUE))
1826 feature_type *f_ptr;
1828 y = creature_ptr->y + ddy[dir];
1829 x = creature_ptr->x + ddx[dir];
1831 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1833 /* Feature code (applying "mimic" field) */
1834 feat = get_feat_mimic(g_ptr);
1835 f_ptr = &f_info[feat];
1837 take_turn(creature_ptr, 100);
1841 py_attack(creature_ptr, y, x, 0);
1845 else if (have_flag(f_ptr->flags, FF_OPEN))
1847 more = exe_open(creature_ptr, y, x);
1850 /* Bash jammed doors */
1851 else if (have_flag(f_ptr->flags, FF_BASH))
1853 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1856 /* Tunnel through walls */
1857 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1859 more = exe_tunnel(creature_ptr, y, x);
1862 /* Close open doors */
1863 else if (have_flag(f_ptr->flags, FF_CLOSE))
1865 more = exe_close(creature_ptr, y, x);
1869 else if (have_flag(f_ptr->flags, FF_DISARM))
1871 more = exe_disarm(creature_ptr, y, x, dir);
1876 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1880 /* Cancel repetition unless we can continue */
1881 if (!more) disturb(creature_ptr, FALSE, FALSE);
1887 * @brief 「くさびを打つ」ために必要なオブジェクトを所持しているかどうかの判定を返す /
1888 * Find the index of some "spikes", if possible.
1889 * @param ip くさびとして打てるオブジェクトのID
1890 * @return オブジェクトがある場合TRUEを返す
1893 * Let user choose a pile of spikes, perhaps?
1896 static bool get_spike(player_type *creature_ptr, INVENTORY_IDX *ip)
1900 /* Check every item in the pack */
1901 for (i = 0; i < INVEN_PACK; i++)
1903 object_type *o_ptr = &creature_ptr->inventory_list[i];
1904 if (!o_ptr->k_idx) continue;
1906 /* Check the "tval" code */
1907 if (o_ptr->tval == TV_SPIKE)
1909 /* Save the spike index */
1922 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1923 * Jam a closed door with a spike
1924 * @param creature_ptr プレーヤーへの参照ポインタ
1928 * This command may NOT be repeated
1931 void do_cmd_spike(player_type *creature_ptr)
1935 if (creature_ptr->wild_mode) return;
1936 if (creature_ptr->special_defense & KATA_MUSOU)
1938 set_action(creature_ptr, ACTION_NONE);
1941 /* Get a "repeated" direction */
1942 if (!get_rep_dir(creature_ptr, &dir, FALSE)) return;
1944 POSITION y = creature_ptr->y + ddy[dir];
1945 POSITION x = creature_ptr->x + ddx[dir];
1947 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1949 /* Feature code (applying "mimic" field) */
1950 FEAT_IDX feat = get_feat_mimic(g_ptr);
1952 /* Require closed door */
1954 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1956 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1960 else if (!get_spike(creature_ptr, &item))
1962 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1965 /* Is a monster in the way? */
1966 else if (g_ptr->m_idx)
1968 take_turn(creature_ptr, 100);
1970 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1973 py_attack(creature_ptr, y, x, 0);
1979 take_turn(creature_ptr, 100);
1981 /* Successful jamming */
1982 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1983 cave_alter_feat(creature_ptr, y, x, FF_SPIKE);
1985 vary_item(creature_ptr, item, -1);
1991 * @brief 「歩く」動作コマンドのメインルーチン /
1992 * Support code for the "Walk" and "Jump" commands
1993 * @param creature_ptr プレーヤーへの参照ポインタ
1994 * @param pickup アイテムの自動拾いを行うならTRUE
1997 void do_cmd_walk(player_type *creature_ptr, bool pickup)
1999 /* Allow repeated command */
2002 /* Set repeat count */
2003 command_rep = command_arg - 1;
2004 creature_ptr->redraw |= (PR_STATE);
2006 /* Cancel the arg */
2010 /* Get a "repeated" direction */
2013 if (get_rep_dir(creature_ptr, &dir, FALSE))
2015 take_turn(creature_ptr, 100);
2017 if ((dir != 5) && (creature_ptr->special_defense & KATA_MUSOU))
2019 set_action(creature_ptr, ACTION_NONE);
2022 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2023 if (creature_ptr->wild_mode) creature_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2024 if (creature_ptr->action == ACTION_HAYAGAKE) creature_ptr->energy_use = creature_ptr->energy_use * (45-(creature_ptr->lev/2)) / 100;
2026 /* Actually move the character */
2027 move_player(creature_ptr, dir, pickup, FALSE);
2029 /* Allow more walking */
2033 /* Hack again -- Is there a special encounter ??? */
2034 if (creature_ptr->wild_mode && !cave_have_flag_bold(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, FF_TOWN))
2036 int tmp = 120 + creature_ptr->lev*10 - wilderness[creature_ptr->y][creature_ptr->x].level + 5;
2039 if (((wilderness[creature_ptr->y][creature_ptr->x].level + 5) > (creature_ptr->lev / 2)) && randint0(tmp) < (21-creature_ptr->skill_stl))
2041 /* Inform the player of his horrible fate :=) */
2042 msg_print(_("襲撃だ!", "You are ambushed !"));
2044 /* Go into large wilderness view */
2045 creature_ptr->oldpy = randint1(MAX_HGT-2);
2046 creature_ptr->oldpx = randint1(MAX_WID-2);
2047 change_wild_mode(creature_ptr, TRUE);
2049 /* Give first move to monsters */
2050 take_turn(creature_ptr, 100);
2055 /* Cancel repeat unless we may continue */
2056 if (!more) disturb(creature_ptr, FALSE, FALSE);
2061 * @brief 「走る」動作コマンドのメインルーチン /
2063 * @param creature_ptr プレーヤーへの参照ポインタ
2066 void do_cmd_run(player_type *creature_ptr)
2069 if (cmd_limit_confused(creature_ptr)) return;
2071 if (creature_ptr->special_defense & KATA_MUSOU)
2073 set_action(creature_ptr, ACTION_NONE);
2076 /* Get a "repeated" direction */
2077 if (get_rep_dir(creature_ptr, &dir,FALSE))
2079 /* Hack -- Set the run counter */
2080 creature_ptr->running = (command_arg ? command_arg : 1000);
2083 run_step(creature_ptr, dir);
2089 * @brief 「留まる」動作コマンドのメインルーチン /
2090 * Stay still. Search. Enter stores.
2091 * Pick up treasure if "pickup" is true.
2092 * @param creature_ptr プレーヤーへの参照ポインタ
2093 * @param pickup アイテムの自動拾いを行うならTRUE
2096 void do_cmd_stay(player_type *creature_ptr, bool pickup)
2098 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2100 /* Allow repeated command */
2103 /* Set repeat count */
2104 command_rep = command_arg - 1;
2105 creature_ptr->redraw |= (PR_STATE);
2107 /* Cancel the arg */
2111 take_turn(creature_ptr, 100);
2113 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2114 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, mpe_mode);
2119 * @brief 「休む」動作コマンドのメインルーチン /
2120 * Resting allows a player to safely restore his hp -RAK-
2121 * @param creature_ptr プレーヤーへの参照ポインタ
2124 void do_cmd_rest(player_type *creature_ptr)
2126 set_action(creature_ptr, ACTION_NONE);
2128 if ((creature_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(creature_ptr) || INTERUPTING_SONG_EFFECT(creature_ptr)))
2130 stop_singing(creature_ptr);
2133 if (hex_spelling_any(creature_ptr)) stop_hex_spell_all(creature_ptr);
2135 /* Prompt for time if needed */
2136 if (command_arg <= 0)
2138 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2139 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2144 strcpy(out_val, "&");
2146 /* Ask for duration */
2147 if (!get_string(p, out_val, 4)) return;
2149 /* Rest until done */
2150 if (out_val[0] == '&')
2152 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2156 else if (out_val[0] == '*')
2158 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2164 command_arg = (COMMAND_ARG)atoi(out_val);
2165 if (command_arg <= 0) return;
2169 if (command_arg > 9999) command_arg = 9999;
2171 if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE);
2173 /* Take a turn (?) */
2174 take_turn(creature_ptr, 100);
2176 /* The sin of sloth */
2177 if (command_arg > 100) chg_virtue(creature_ptr, V_DILIGENCE, -1);
2179 /* Why are you sleeping when there's no need? WAKE UP!*/
2180 if ((creature_ptr->chp == creature_ptr->mhp) &&
2181 (creature_ptr->csp == creature_ptr->msp) &&
2182 !creature_ptr->blind && !creature_ptr->confused &&
2183 !creature_ptr->poisoned && !creature_ptr->afraid &&
2184 !creature_ptr->stun && !creature_ptr->cut &&
2185 !creature_ptr->slow && !creature_ptr->paralyzed &&
2186 !creature_ptr->image && !creature_ptr->word_recall &&
2187 !creature_ptr->alter_reality)
2188 chg_virtue(creature_ptr, V_DILIGENCE, -1);
2190 /* Save the rest code */
2191 creature_ptr->resting = command_arg;
2192 creature_ptr->action = ACTION_REST;
2193 creature_ptr->update |= (PU_BONUS);
2194 update_creature(creature_ptr);
2196 creature_ptr->redraw |= (PR_STATE);
2197 update_output(creature_ptr);
2206 * @brief 射撃処理のメインルーチン
2207 * @param creature_ptr プレーヤーへの参照ポインタ
2208 * @param snipe_type ???
2211 void do_cmd_fire(player_type *creature_ptr, SPELL_IDX snipe_type)
2214 object_type *j_ptr, *ammo_ptr;
2217 if(creature_ptr->wild_mode) return;
2219 creature_ptr->is_fired = FALSE; /* not fired yet */
2221 /* Get the "bow" (if any) */
2222 j_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2224 /* Require a launcher */
2227 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2232 if (j_ptr->sval == SV_CRIMSON)
2234 msg_print(_("この武器は発動して使うもののようだ。", "It's already activated."));
2239 if (j_ptr->sval == SV_HARP)
2241 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2247 if (creature_ptr->special_defense & KATA_MUSOU)
2249 set_action(creature_ptr, ACTION_NONE);
2252 q = _("どれを撃ちますか? ", "Fire which item? ");
2253 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2255 ammo_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), creature_ptr->tval_ammo);
2263 exe_fire(creature_ptr, item, j_ptr, snipe_type);
2265 if (!creature_ptr->is_fired || creature_ptr->pclass != CLASS_SNIPER) return;
2267 /* Sniper actions after some shootings */
2268 if (snipe_type == SP_AWAY)
2270 teleport_player(creature_ptr, 10 + (creature_ptr->concent * 2), 0L);
2273 if (snipe_type == SP_FINAL)
2275 msg_print(_("射撃の反動が体を襲った。", "The weapon's recoil stuns you. "));
2276 (void)set_slow(creature_ptr, creature_ptr->slow + randint0(7) + 7, FALSE);
2277 (void)set_stun(creature_ptr, creature_ptr->stun + randint1(25));
2283 * @brief 投射処理メインルーチン /
2284 * Throw an object from the pack or floor.
2286 * @param creature_ptr プレーヤーへの参照ポインタ
2287 * @param boomerang ブーメラン処理ならばTRUE
2288 * @param shuriken 忍者の手裏剣処理ならばTRUE
2289 * @return ターンを消費した場合TRUEを返す
2292 * Note: "unseen" monsters are very hard to hit.
2294 * Should throwing a weapon do full damage? Should it allow the magic
2295 * to hit bonus of the weapon to have an effect? Should it ever cause
2296 * the item to be destroyed? Should it do any damage at all?
2299 bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_IDX shuriken)
2304 POSITION y, x, ty, tx, prev_y, prev_x;
2305 POSITION ny[19], nx[19];
2306 int chance, tdam, tdis;
2307 int mul, div, dd, ds;
2308 int cur_dis, visible;
2315 bool hit_body = FALSE;
2316 bool hit_wall = FALSE;
2317 bool equiped_item = FALSE;
2318 bool return_when_thrown = FALSE;
2320 GAME_TEXT o_name[MAX_NLEN];
2322 int msec = delay_factor * delay_factor * delay_factor;
2324 BIT_FLAGS flgs[TR_FLAG_SIZE];
2326 bool come_back = FALSE;
2327 bool do_drop = TRUE;
2329 if (creature_ptr->wild_mode) return FALSE;
2331 if (creature_ptr->special_defense & KATA_MUSOU)
2333 set_action(creature_ptr, ACTION_NONE);
2339 o_ptr = &creature_ptr->inventory_list[item];
2343 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2345 item_tester_hook = item_tester_hook_boomerang;
2346 q = _("どの武器を投げますか? ", "Throw which item? ");
2347 s = _("投げる武器がない。", "You have nothing to throw.");
2348 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP), 0);
2355 else if (has_melee_weapon(creature_ptr, INVEN_LARM))
2358 o_ptr = &creature_ptr->inventory_list[item];
2363 o_ptr = &creature_ptr->inventory_list[item];
2368 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2369 s = _("投げるアイテムがない。", "You have nothing to throw.");
2370 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP), 0);
2378 /* Item is cursed */
2379 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2381 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2385 if (creature_ptr->current_floor_ptr->inside_arena && !boomerang)
2387 if (o_ptr->tval != TV_SPIKE)
2389 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2397 object_copy(q_ptr, o_ptr);
2399 /* Extract the thrown object's flags. */
2400 object_flags(q_ptr, flgs);
2401 torch_flags(q_ptr, flgs);
2403 /* Distribute the charges of rods/wands between the stacks */
2404 distribute_charges(o_ptr, q_ptr, 1);
2409 object_desc(creature_ptr, o_name, q_ptr, OD_OMIT_PREFIX);
2411 if (creature_ptr->mighty_throw) mult += 3;
2413 /* Extract a "distance multiplier" */
2414 /* Changed for 'launcher' mutation */
2415 mul = 10 + 2 * (mult - 1);
2417 /* Enforce a minimum "weight" of one pound */
2418 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2419 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2421 /* Hack -- Distance -- Reward strength, penalize weight */
2422 tdis = (adj_str_blow[creature_ptr->stat_ind[A_STR]] + 20) * mul / div;
2424 /* Max distance of 10-18 */
2425 if (tdis > mul) tdis = mul;
2429 ty = randint0(101) - 50 + creature_ptr->y;
2430 tx = randint0(101) - 50 + creature_ptr->x;
2434 project_length = tdis + 1;
2436 /* Get a direction (or cancel) */
2437 if (!get_aim_dir(creature_ptr, &dir)) return FALSE;
2439 /* Predict the "target" location */
2440 tx = creature_ptr->x + 99 * ddx[dir];
2441 ty = creature_ptr->y + 99 * ddy[dir];
2443 /* Check for "target request" */
2444 if ((dir == 5) && target_okay(creature_ptr))
2450 project_length = 0; /* reset to default */
2453 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2454 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2455 return_when_thrown = TRUE;
2459 inven_item_increase(creature_ptr, item, -1);
2460 if (!return_when_thrown)
2461 inven_item_describe(creature_ptr, item);
2462 inven_item_optimize(creature_ptr, item);
2466 floor_item_increase(creature_ptr->current_floor_ptr, 0 - item, -1);
2467 floor_item_optimize(creature_ptr, 0 - item);
2470 if (item >= INVEN_RARM)
2472 equiped_item = TRUE;
2473 creature_ptr->redraw |= (PR_EQUIPPY);
2476 take_turn(creature_ptr, 100);
2478 /* Rogue and Ninja gets bonus */
2479 if ((creature_ptr->pclass == CLASS_ROGUE) || (creature_ptr->pclass == CLASS_NINJA))
2480 creature_ptr->energy_use -= creature_ptr->lev;
2482 /* Start at the player */
2483 y = creature_ptr->y;
2484 x = creature_ptr->x;
2486 handle_stuff(creature_ptr);
2488 if ((creature_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2489 else shuriken = FALSE;
2491 /* Chance of hitting */
2492 if (have_flag(flgs, TR_THROW)) chance = ((creature_ptr->skill_tht) +
2493 ((creature_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2494 else chance = (creature_ptr->skill_tht + (creature_ptr->to_h_b * BTH_PLUS_ADJ));
2496 if (shuriken) chance *= 2;
2501 /* Travel until stopped */
2502 for (cur_dis = 0; cur_dis <= tdis; )
2504 /* Hack -- Stop at the target */
2505 if ((y == ty) && (x == tx)) break;
2507 /* Calculate the new location (see "project()") */
2510 mmove2(&ny[cur_dis], &nx[cur_dis], creature_ptr->y, creature_ptr->x, ty, tx);
2512 /* Stopped by walls/doors */
2513 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, ny[cur_dis], nx[cur_dis], FF_PROJECT))
2516 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;
2519 /* The player can see the (on screen) missile */
2520 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(creature_ptr, ny[cur_dis], nx[cur_dis]))
2522 SYMBOL_CODE c = object_char(q_ptr);
2523 TERM_COLOR a = object_attr(q_ptr);
2525 /* Draw, Hilite, Fresh, Pause, Erase */
2526 print_rel(creature_ptr, c, a, ny[cur_dis], nx[cur_dis]);
2527 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2529 Term_xtra(TERM_XTRA_DELAY, msec);
2530 lite_spot(creature_ptr, ny[cur_dis], nx[cur_dis]);
2534 /* The player cannot see the missile */
2537 /* Pause anyway, for consistancy */
2538 Term_xtra(TERM_XTRA_DELAY, msec);
2544 /* Save the new location */
2548 /* Advance the distance */
2551 /* Monster here, Try to hit it */
2552 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
2554 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
2555 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2556 GAME_TEXT m_name[MAX_NLEN];
2557 monster_name(creature_ptr, g_ptr->m_idx, m_name);
2559 /* Check the visibility */
2560 visible = m_ptr->ml;
2562 /* Note the collision */
2565 /* Did we hit it (penalize range) */
2566 if (test_hit_fire(creature_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2570 /* Handle unseen monster */
2573 /* Invisible monster */
2574 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2577 /* Handle visible monster */
2580 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2584 if (!creature_ptr->image) monster_race_track(creature_ptr, m_ptr->ap_r_idx);
2585 health_track(creature_ptr, g_ptr->m_idx);
2589 /* Hack -- Base damage from thrown object */
2592 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2593 tdam = damroll(dd, ds);
2594 /* Apply special damage */
2595 tdam = tot_dam_aux(creature_ptr, q_ptr, tdam, m_ptr, 0, TRUE);
2596 tdam = critical_shot(creature_ptr, q_ptr->weight, q_ptr->to_h, 0, tdam);
2597 if (q_ptr->to_d > 0)
2598 tdam += q_ptr->to_d;
2600 tdam += -q_ptr->to_d;
2604 tdam *= (mult+creature_ptr->num_blow[item - INVEN_RARM]);
2605 tdam += creature_ptr->to_d_m;
2607 else if (have_flag(flgs, TR_THROW))
2610 tdam += creature_ptr->to_d_m;
2618 tdam += ((creature_ptr->lev+30)*(creature_ptr->lev+30)-900)/55;
2621 /* No negative damage */
2622 if (tdam < 0) tdam = 0;
2624 /* Modify the damage */
2625 tdam = mon_damage_mod(creature_ptr, m_ptr, tdam, FALSE);
2627 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2628 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2630 /* Hit the monster, check for death */
2631 if (mon_take_hit(creature_ptr, g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2639 message_pain(creature_ptr, g_ptr->m_idx, tdam);
2641 /* Anger the monster */
2642 if ((tdam > 0) && !object_is_potion(q_ptr))
2643 anger_monster(creature_ptr, m_ptr);
2645 if (fear && m_ptr->ml)
2648 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2658 /* decrease toach's fuel */
2659 if (hit_body) torch_lost_fuel(q_ptr);
2661 /* Chance of breakage (during attacks) */
2662 j = (hit_body ? breakage_chance(creature_ptr, q_ptr, creature_ptr->pclass == CLASS_ARCHER, 0) : 0);
2664 /* Figurines transform */
2665 if ((q_ptr->tval == TV_FIGURINE) && !(creature_ptr->current_floor_ptr->inside_arena))
2669 if (!(summon_named_creature(creature_ptr, 0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2670 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2671 else if (object_is_cursed(q_ptr))
2672 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2676 /* Potions smash open */
2677 if (object_is_potion(q_ptr))
2679 if (hit_body || hit_wall || (randint1(100) < j))
2681 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2683 if (potion_smash_effect(creature_ptr, 0, y, x, q_ptr->k_idx))
2685 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx];
2686 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2688 GAME_TEXT m_name[MAX_NLEN];
2689 monster_desc(creature_ptr, m_name, m_ptr, 0);
2690 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2691 set_hostile(creature_ptr, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx]);
2702 if (return_when_thrown)
2704 int back_chance = randint1(30)+20+((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2705 char o2_name[MAX_NLEN];
2706 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2709 if (boomerang) back_chance += 4+randint1(5);
2710 if (super_boomerang) back_chance += 100;
2711 object_desc(creature_ptr, o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2713 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2715 for (i = cur_dis - 1; i > 0; i--)
2717 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(creature_ptr, ny[i], nx[i]))
2719 char c = object_char(q_ptr);
2720 byte a = object_attr(q_ptr);
2722 /* Draw, Hilite, Fresh, Pause, Erase */
2723 print_rel(creature_ptr, c, a, ny[i], nx[i]);
2724 move_cursor_relative(ny[i], nx[i]);
2726 Term_xtra(TERM_XTRA_DELAY, msec);
2727 lite_spot(creature_ptr, ny[i], nx[i]);
2732 /* Pause anyway, for consistancy */
2733 Term_xtra(TERM_XTRA_DELAY, msec);
2736 if((back_chance > 37) && !creature_ptr->blind && (item >= 0))
2738 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2745 msg_format(_("%sを受け損ねた!", "%s comes back, but you can't catch!"), o2_name);
2749 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2751 y = creature_ptr->y;
2752 x = creature_ptr->x;
2757 msg_format(_("%sが返ってこなかった!", "%s doesn't come back!"), o2_name);
2763 if (item == INVEN_RARM || item == INVEN_LARM)
2765 /* Access the wield slot */
2766 o_ptr = &creature_ptr->inventory_list[item];
2768 /* Wear the new stuff */
2769 object_copy(o_ptr, q_ptr);
2771 creature_ptr->total_weight += q_ptr->weight;
2773 /* Increment the equip counter by hand */
2774 creature_ptr->equip_cnt++;
2776 creature_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2777 creature_ptr->window |= (PW_EQUIP);
2781 inven_carry(creature_ptr, q_ptr);
2785 else if (equiped_item)
2787 verify_equip_slot(creature_ptr, item);
2788 calc_android_exp(creature_ptr);
2793 if (cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_PROJECT))
2795 (void)drop_near(creature_ptr, q_ptr, j, y, x);
2799 (void)drop_near(creature_ptr, q_ptr, j, prev_y, prev_x);
2807 * @brief 自殺するコマンドのメインルーチン
2808 * Hack -- commit suicide
2812 void do_cmd_suicide(player_type *creature_ptr)
2819 /* Verify Retirement */
2820 if (current_world_ptr->total_winner)
2823 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2826 /* Verify Suicide */
2830 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2833 if (!current_world_ptr->noscore)
2835 /* Special Verification for suicide */
2836 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2841 if (i != '@') return;
2843 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2846 /* Initialize "last message" buffer */
2847 if (creature_ptr->last_message) string_free(creature_ptr->last_message);
2848 creature_ptr->last_message = NULL;
2850 /* Hack -- Note *winning* message */
2851 if (current_world_ptr->total_winner && last_words)
2853 char buf[1024] = "";
2854 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2857 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2858 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2862 creature_ptr->last_message = string_make(buf);
2863 msg_print(creature_ptr->last_message);
2868 creature_ptr->playing = FALSE;
2870 /* Kill the player */
2871 creature_ptr->is_dead = TRUE;
2872 creature_ptr->leaving = TRUE;
2874 if (!current_world_ptr->total_winner)
2876 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("ダンジョンの探索に絶望して自殺した。", "gave up all hope to commit suicide."));
2877 exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2878 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
2881 /* Cause of death */
2882 (void)strcpy(creature_ptr->died_from, _("途中終了", "Quitting"));