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.
13 #include "system/angband.h"
14 #include "main/music-definitions-table.h"
15 #include "main/sound-definitions-table.h"
16 #include "system/system-variables.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"
23 #include "object/chest.h"
25 #include "dungeon/dungeon.h"
27 #include "object/object-hook.h"
28 #include "monster/monster-status.h"
30 #include "object/artifact.h"
32 #include "player/player-status.h"
33 #include "realm/realm-hex.h"
37 #include "player/player-move.h"
38 #include "player/player-effects.h"
39 #include "player/player-personality.h"
40 #include "player-inventory.h"
41 #include "object/object-kind.h"
42 #include "object/object-broken.h"
43 #include "object/object-flavor.h"
47 #include "cmd-basic.h"
48 #include "dungeon/dungeon-file.h"
51 #include "view/display-main-window.h"
52 #include "targeting.h"
53 #include "world/world.h"
54 #include "effect/spells-effect-util.h"
55 #include "spell/spells3.h"
56 #include "core/output-updater.h"
59 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
60 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
61 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
63 static bool confirm_leave_level(player_type *creature_ptr, bool down_stair)
65 quest_type *q_ptr = &quest[creature_ptr->current_floor_ptr->inside_quest];
67 /* Confirm leaving from once only quest */
68 if (confirm_quest && creature_ptr->current_floor_ptr->inside_quest &&
69 (q_ptr->type == QUEST_TYPE_RANDOM ||
70 (q_ptr->flags & QUEST_FLAG_ONCE &&
71 q_ptr->status != QUEST_STATUS_COMPLETED) ||
72 (q_ptr->flags & QUEST_FLAG_TOWER &&
73 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
74 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
76 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
77 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
87 * @brief 魔法系コマンドが制限されているかを返す。
88 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
90 bool cmd_limit_cast(player_type *creature_ptr)
92 if (creature_ptr->current_floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
94 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
98 else if (creature_ptr->anti_magic)
100 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
103 else if (creature_ptr->shero)
105 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
112 bool cmd_limit_confused(player_type *creature_ptr)
114 if (creature_ptr->confused)
116 msg_print(_("混乱していてできない!", "You are too confused!"));
122 bool cmd_limit_image(player_type *creature_ptr)
124 if (creature_ptr->image)
126 msg_print(_("幻覚が見えて集中できない!", "Your hallucinations prevent you from concentrating!"));
132 bool cmd_limit_stun(player_type *creature_ptr)
134 if (creature_ptr->stun)
136 msg_print(_("頭が朦朧としていて集中できない!", "You are too stunned!"));
142 bool cmd_limit_arena(player_type *creature_ptr)
144 if (creature_ptr->current_floor_ptr->inside_arena)
146 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
153 bool cmd_limit_blind(player_type *creature_ptr)
155 if (creature_ptr->blind)
157 msg_print(_("目が見えない。", "You can't see anything."));
160 if (no_lite(creature_ptr))
162 msg_print(_("明かりがないので見えない。", "You have no light."));
168 bool cmd_limit_time_walk(player_type *creature_ptr)
170 if (creature_ptr->timewalk)
172 if (flush_failure) flush();
173 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
181 * @brief 階段を使って階層を昇る処理 / Go up one level
184 void do_cmd_go_up(player_type *creature_ptr)
189 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
190 feature_type *f_ptr = &f_info[g_ptr->feat];
194 if (creature_ptr->special_defense & KATA_MUSOU)
196 set_action(creature_ptr, ACTION_NONE);
200 if (!have_flag(f_ptr->flags, FF_LESS))
202 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
206 /* Quest up stairs */
207 if (have_flag(f_ptr->flags, FF_QUEST))
209 if (!confirm_leave_level(creature_ptr, FALSE)) return;
212 if (IS_ECHIZEN(creature_ptr))
213 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
215 msg_print(_("上の階に登った。", "You enter the up staircase."));
217 leave_quest_check(creature_ptr);
219 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
221 /* Activate the quest */
222 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
224 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
226 init_flags = INIT_ASSIGN;
227 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
229 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
232 /* Leaving a quest */
233 if (!creature_ptr->current_floor_ptr->inside_quest)
235 creature_ptr->current_floor_ptr->dun_level = 0;
237 creature_ptr->leaving = TRUE;
239 creature_ptr->oldpx = 0;
240 creature_ptr->oldpy = 0;
242 take_turn(creature_ptr, 100);
244 /* End the command */
248 if (!creature_ptr->current_floor_ptr->dun_level)
254 go_up = confirm_leave_level(creature_ptr, FALSE);
259 take_turn(creature_ptr, 100);
261 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
263 /* For a random quest */
264 if (creature_ptr->current_floor_ptr->inside_quest &&
265 quest[creature_ptr->current_floor_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
267 leave_quest_check(creature_ptr);
269 creature_ptr->current_floor_ptr->inside_quest = 0;
272 /* For a fixed quest */
273 if (creature_ptr->current_floor_ptr->inside_quest &&
274 quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
276 leave_quest_check(creature_ptr);
278 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
279 creature_ptr->current_floor_ptr->dun_level = 0;
283 /* For normal dungeon and random quest */
287 if (have_flag(f_ptr->flags, FF_SHAFT))
289 /* Create a way back */
290 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
296 /* Create a way back */
297 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP);
302 /* Get out from current dungeon */
303 if (creature_ptr->current_floor_ptr->dun_level - up_num < d_info[creature_ptr->dungeon_idx].mindepth)
304 up_num = creature_ptr->current_floor_ptr->dun_level;
306 if (record_stair) exe_write_diary(creature_ptr, DIARY_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
309 if (IS_ECHIZEN(creature_ptr))
310 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
311 else if (up_num == creature_ptr->current_floor_ptr->dun_level)
312 msg_print(_("地上に戻った。", "You go back to the surface."));
314 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
315 creature_ptr->leaving = TRUE;
320 * @brief 階段を使って階層を降りる処理 / Go down one level
321 * @param creature_ptr プレーヤーへの参照ポインタ
324 void do_cmd_go_down(player_type *creature_ptr)
326 bool fall_trap = FALSE;
329 if (creature_ptr->special_defense & KATA_MUSOU)
331 set_action(creature_ptr, ACTION_NONE);
335 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
336 feature_type *f_ptr = &f_info[g_ptr->feat];
337 if (!have_flag(f_ptr->flags, FF_MORE))
339 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
343 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
346 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
348 do_cmd_quest(creature_ptr);
352 /* Quest down stairs */
353 if (have_flag(f_ptr->flags, FF_QUEST))
355 /* Confirm Leaving */
356 if(!confirm_leave_level(creature_ptr, TRUE)) return;
358 if (IS_ECHIZEN(creature_ptr))
359 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
361 msg_print(_("下の階に降りた。", "You enter the down staircase."));
363 leave_quest_check(creature_ptr);
364 leave_tower_check(creature_ptr);
366 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
368 /* Activate the quest */
369 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
371 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
373 init_flags = INIT_ASSIGN;
374 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
376 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
379 /* Leaving a quest */
380 if (!creature_ptr->current_floor_ptr->inside_quest)
382 creature_ptr->current_floor_ptr->dun_level = 0;
384 creature_ptr->leaving = TRUE;
385 creature_ptr->oldpx = 0;
386 creature_ptr->oldpy = 0;
388 take_turn(creature_ptr, 100);
392 DUNGEON_IDX target_dungeon = 0;
394 if (!creature_ptr->current_floor_ptr->dun_level)
396 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
398 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
400 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
403 if (!max_dlv[target_dungeon])
405 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
406 d_name + d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
407 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
410 /* Save old player position */
411 creature_ptr->oldpx = creature_ptr->x;
412 creature_ptr->oldpy = creature_ptr->y;
413 creature_ptr->dungeon_idx = target_dungeon;
416 * Clear all saved floors
417 * and create a first saved floor
419 prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
422 take_turn(creature_ptr, 100);
424 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
427 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
430 if (!creature_ptr->current_floor_ptr->dun_level)
432 /* Enter the dungeon just now */
433 creature_ptr->enter_dungeon = TRUE;
434 down_num = d_info[creature_ptr->dungeon_idx].mindepth;
439 if (fall_trap) exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
440 else exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
445 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
452 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[creature_ptr->dungeon_idx].text);
456 if (IS_ECHIZEN(creature_ptr))
457 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
459 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
463 creature_ptr->leaving = TRUE;
467 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
471 /* Create a way back */
472 if (have_flag(f_ptr->flags, FF_SHAFT))
474 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
478 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN);
484 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
487 void do_cmd_search(player_type * creature_ptr)
489 /* Allow repeated command */
492 /* Set repeat count */
493 command_rep = command_arg - 1;
494 creature_ptr->redraw |= (PR_STATE);
500 take_turn(creature_ptr, 100);
501 search(creature_ptr);
506 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
507 * @param y 走査対象にしたいマスのY座標
508 * @param x 走査対象にしたいマスのX座標
509 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
510 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
512 static OBJECT_IDX chest_check(floor_type *floor_ptr, POSITION y, POSITION x, bool trapped)
514 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
515 OBJECT_IDX this_o_idx, next_o_idx = 0;
517 /* Scan all objects in the grid */
518 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
522 o_ptr = &floor_ptr->o_list[this_o_idx];
523 next_o_idx = o_ptr->next_o_idx;
525 /* Skip unknown chests XXX XXX */
526 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
528 /* Check for non empty chest */
529 if ((o_ptr->tval == TV_CHEST) &&
530 (((!trapped) && (o_ptr->pval)) || /* non empty */
531 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
542 * Attempt to open the given chest at the given location
543 * @param y 箱の存在するマスのY座標
544 * @param x 箱の存在するマスのX座標
545 * @param o_idx 箱のオブジェクトID
546 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
548 * Assume there is no monster blocking the destination
550 static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
554 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
556 take_turn(creature_ptr, 100);
558 /* Attempt to unlock it */
561 /* Assume locked, and thus not open */
564 /* Get the "disarm" factor */
565 int i = creature_ptr->skill_dis;
567 /* Penalize some conditions */
568 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
569 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
571 /* Extract the difficulty */
572 int j = i - o_ptr->pval;
574 /* Always have a small chance of success */
577 /* Success -- May still have traps */
578 if (randint0(100) < j)
580 msg_print(_("鍵をはずした。", "You have picked the lock."));
581 gain_exp(creature_ptr, 1);
585 /* Failure -- Keep trying */
588 /* We may continue repeating */
590 if (flush_failure) flush();
591 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
596 /* Allowed to open */
599 /* Apply chest traps, if any */
600 chest_trap(creature_ptr, y, x, o_idx);
602 /* Let the Chest drop items */
603 chest_death(creature_ptr, FALSE, y, x, o_idx);
610 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
611 * Attempt to open the given chest at the given location
612 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
613 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
614 * @param test 地形条件を判定するための関数ポインタ
615 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
617 * @details Return the number of features around (or under) the character.
618 * Usually look for doors and floor traps.
620 static int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(player_type*, FEAT_IDX feat), bool under)
622 /* Check around (and under) the character */
624 for (DIRECTION d = 0; d < 9; d++)
629 /* if not searching under player continue */
630 if ((d == 8) && !under) continue;
632 /* Extract adjacent (legal) location */
633 POSITION yy = creature_ptr->y + ddy_ddd[d];
634 POSITION xx = creature_ptr->x + ddx_ddd[d];
636 /* Get the creature_ptr->current_floor_ptr->grid_array */
637 g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
639 /* Must have knowledge */
640 if (!(g_ptr->info & (CAVE_MARK))) continue;
642 /* Feature code (applying "mimic" field) */
643 feat = get_feat_mimic(g_ptr);
645 /* Not looking for this feature */
646 if (!((*test)(creature_ptr, feat))) continue;
651 /* Remember the location. Only useful if only one match */
662 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
663 * Return the number of chests around (or under) the character.
664 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
665 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
666 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
669 * If requested, count only trapped chests.
671 static int count_chests(player_type *creature_ptr, POSITION *y, POSITION *x, bool trapped)
673 /* Check around (and under) the character */
675 for (DIRECTION d = 0; d < 9; d++)
677 /* Extract adjacent (legal) location */
678 POSITION yy = creature_ptr->y + ddy_ddd[d];
679 POSITION xx = creature_ptr->x + ddx_ddd[d];
681 /* No (visible) chest is there */
682 OBJECT_IDX o_idx = chest_check(creature_ptr->current_floor_ptr, yy, xx, FALSE);
683 if (!o_idx) continue;
685 /* Grab the object */
687 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
690 if (o_ptr->pval == 0) continue;
692 /* No (known) traps here */
693 if (trapped && (!object_is_known(o_ptr) ||
694 !chest_traps[o_ptr->pval])) continue;
699 /* Remember the location. Only useful if only one match */
711 * @brief 「開ける」動作コマンドのサブルーチン /
712 * Perform the basic "open" command on doors
713 * @param y 対象を行うマスのY座標
714 * @param x 対象を行うマスのX座標
715 * @return 実際に処理が行われた場合TRUEを返す。
717 * Assume destination is a closed/locked/jammed door
718 * Assume there is no monster blocking the destination
719 * Returns TRUE if repeated commands may continue
721 static bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
723 /* Get requested grid */
724 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
725 feature_type *f_ptr = &f_info[g_ptr->feat];
728 take_turn(creature_ptr, 100);
730 /* Seeing true feature code (ignore mimic) */
733 if (!have_flag(f_ptr->flags, FF_OPEN))
736 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
742 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
743 sound(SOUND_OPENDOOR);
748 int i = creature_ptr->skill_dis;
750 /* Penalize some conditions */
751 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
752 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
754 /* Extract the difficulty */
755 int j = f_ptr->power;
758 /* Always have a small chance of success */
761 if (randint0(100) >= j)
763 if (flush_failure) flush();
764 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
768 msg_print(_("鍵をはずした。", "You have picked the lock."));
771 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
773 sound(SOUND_OPENDOOR);
776 gain_exp(creature_ptr, 1);
781 * @brief 「開ける」コマンドのメインルーチン /
782 * Open a closed/locked/jammed door or a closed/locked chest.
785 * Unlocking a locked door/chest is worth one experience point.
787 void do_cmd_open(player_type *creature_ptr)
795 if (creature_ptr->wild_mode) return;
797 if (creature_ptr->special_defense & KATA_MUSOU)
799 set_action(creature_ptr, ACTION_NONE);
802 /* Option: Pick a direction */
805 int num_doors, num_chests;
807 num_doors = count_dt(creature_ptr, &y, &x, is_closed_door, FALSE);
808 num_chests = count_chests(creature_ptr, &y, &x, FALSE);
809 if (num_doors || num_chests)
811 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
813 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
817 /* Allow repeated command */
820 /* Set repeat count */
821 command_rep = command_arg - 1;
822 creature_ptr->redraw |= (PR_STATE);
828 /* Get a "repeated" direction */
829 if (get_rep_dir(creature_ptr, &dir, TRUE))
834 /* Get requested location */
835 y = creature_ptr->y + ddy[dir];
836 x = creature_ptr->x + ddx[dir];
838 /* Get requested grid */
839 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
841 /* Feature code (applying "mimic" field) */
842 feat = get_feat_mimic(g_ptr);
844 /* Check for chest */
845 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, FALSE);
847 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
849 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
851 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
853 take_turn(creature_ptr, 100);
854 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
855 py_attack(creature_ptr, y, x, 0);
859 more = exe_open_chest(creature_ptr, y, x, o_idx);
863 more = exe_open(creature_ptr, y, x);
867 /* Cancel repeat unless we may continue */
868 if (!more) disturb(creature_ptr, FALSE, FALSE);
875 * @brief 「閉じる」動作コマンドのサブルーチン /
876 * Perform the basic "close" command
877 * @param y 対象を行うマスのY座標
878 * @param x 対象を行うマスのX座標
879 * @return 実際に処理が行われた場合TRUEを返す。
881 * Assume destination is an open/broken door
882 * Assume there is no monster blocking the destination
883 * Returns TRUE if repeated commands may continue
885 static bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
887 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
888 FEAT_IDX old_feat = g_ptr->feat;
891 take_turn(creature_ptr, 100);
893 /* Seeing true feature code (ignore mimic) */
896 if (!have_flag(f_info[old_feat].flags, FF_CLOSE))
901 s16b closed_feat = feat_state(creature_ptr, old_feat, FF_CLOSE);
903 /* Hack -- object in the way */
904 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
905 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
907 msg_print(_("何かがつっかえて閉まらない。", "Something prevents it from closing."));
912 cave_alter_feat(creature_ptr, y, x, FF_CLOSE);
915 if (old_feat == g_ptr->feat)
917 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
921 sound(SOUND_SHUTDOOR);
930 * @brief 「閉じる」コマンドのメインルーチン /
931 * Close an open door.
934 * Unlocking a locked door/chest is worth one experience point.
936 void do_cmd_close(player_type *creature_ptr)
943 if (creature_ptr->wild_mode) return;
945 if (creature_ptr->special_defense & KATA_MUSOU)
947 set_action(creature_ptr, ACTION_NONE);
950 /* Option: Pick a direction */
953 /* Count open doors */
954 if (count_dt(creature_ptr, &y, &x, is_open, FALSE) == 1)
956 command_dir = coords_to_dir(creature_ptr, y, x);
960 /* Allow repeated command */
963 /* Set repeat count */
964 command_rep = command_arg - 1;
965 creature_ptr->redraw |= (PR_STATE);
971 /* Get a "repeated" direction */
972 if (get_rep_dir(creature_ptr, &dir, FALSE))
977 y = creature_ptr->y + ddy[dir];
978 x = creature_ptr->x + ddx[dir];
979 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
981 /* Feature code (applying "mimic" field) */
982 feat = get_feat_mimic(g_ptr);
984 /* Require open/broken door */
985 if (!have_flag(f_info[feat].flags, FF_CLOSE))
987 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
990 /* Monster in the way */
991 else if (g_ptr->m_idx)
993 take_turn(creature_ptr, 100);
995 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
998 py_attack(creature_ptr, y, x, 0);
1001 /* Close the door */
1004 /* Close the door */
1005 more = exe_close(creature_ptr, y, x);
1009 /* Cancel repeat unless we may continue */
1010 if (!more) disturb(creature_ptr, FALSE, FALSE);
1015 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1016 * Determine if a given grid may be "tunneled"
1017 * @param y 対象を行うマスのY座標
1018 * @param x 対象を行うマスのX座標
1021 static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
1023 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1025 /* Must have knowledge */
1026 if (!(g_ptr->info & CAVE_MARK))
1028 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1033 /* Must be a wall/door/etc */
1034 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1036 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1046 * @brief 「掘る」動作コマンドのサブルーチン /
1047 * Perform the basic "tunnel" command
1048 * @param y 対象を行うマスのY座標
1049 * @param x 対象を行うマスのX座標
1050 * @return 実際に処理が行われた場合TRUEを返す。
1052 * Assumes that no monster is blocking the destination
1053 * Do not use twall anymore
1054 * Returns TRUE if repeated commands may continue
1056 static bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
1059 feature_type *f_ptr, *mimic_f_ptr;
1064 /* Verify legality */
1065 if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x)) return FALSE;
1067 take_turn(creature_ptr, 100);
1069 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1070 f_ptr = &f_info[g_ptr->feat];
1071 power = f_ptr->power;
1073 /* Feature code (applying "mimic" field) */
1074 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1076 name = f_name + mimic_f_ptr->name;
1080 if (have_flag(f_ptr->flags, FF_PERMANENT))
1083 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1085 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1088 /* Map border (mimiccing Permanent wall) */
1091 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1096 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1099 if (creature_ptr->skill_dig > randint0(20 * power))
1101 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1103 /* Remove the feature */
1104 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1105 creature_ptr->update |= (PU_FLOW);
1109 /* Message, keep digging */
1110 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1118 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1121 if (creature_ptr->skill_dig > power + randint0(40 * power))
1123 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1126 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1127 creature_ptr->update |= (PU_FLOW);
1130 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1132 /* Remove the feature */
1133 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1135 chg_virtue(creature_ptr, V_DILIGENCE, 1);
1136 chg_virtue(creature_ptr, V_NATURE, -1);
1144 /* We may continue chopping */
1145 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1146 /* Occasional Search XXX XXX */
1147 if (randint0(100) < 25) search(creature_ptr);
1151 /* We may continue tunelling */
1152 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1159 if (is_hidden_door(creature_ptr, g_ptr))
1161 /* Occasional Search XXX XXX */
1162 if (randint0(100) < 25) search(creature_ptr);
1170 * @brief 「掘る」動作コマンドのメインルーチン /
1171 * Tunnels through "walls" (including rubble and closed doors)
1175 * Note that you must tunnel in order to hit invisible monsters
1176 * in walls, though moving into walls still takes a turn anyway.
1178 * Digging is very difficult without a "digger" weapon, but can be
1179 * accomplished by strong players using heavy weapons.
1182 void do_cmd_tunnel(player_type *creature_ptr)
1191 if (creature_ptr->special_defense & KATA_MUSOU)
1193 set_action(creature_ptr, ACTION_NONE);
1196 /* Allow repeated command */
1199 /* Set repeat count */
1200 command_rep = command_arg - 1;
1201 creature_ptr->redraw |= (PR_STATE);
1203 /* Cancel the arg */
1207 /* Get a direction to tunnel, or Abort */
1208 if (get_rep_dir(creature_ptr, &dir,FALSE))
1211 y = creature_ptr->y + ddy[dir];
1212 x = creature_ptr->x + ddx[dir];
1214 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1216 /* Feature code (applying "mimic" field) */
1217 feat = get_feat_mimic(g_ptr);
1219 /* No tunnelling through doors */
1220 if (have_flag(f_info[feat].flags, FF_DOOR))
1222 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1225 /* No tunnelling through most features */
1226 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1228 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1231 /* A monster is in the way */
1232 else if (g_ptr->m_idx)
1234 take_turn(creature_ptr, 100);
1235 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1238 py_attack(creature_ptr, y, x, 0);
1244 /* Tunnel through walls */
1245 more = exe_tunnel(creature_ptr, y, x);
1249 /* Cancel repetition unless we can continue */
1250 if (!more) disturb(creature_ptr, FALSE, FALSE);
1254 * @brief 移動処理による簡易な「開く」処理 /
1256 * @return 開く処理が実際に試みられた場合TRUEを返す
1259 * If there is a jammed/closed/locked door at the given location,
1260 * then attempt to unlock/open it. Return TRUE if an attempt was
1261 * made (successful or not), otherwise return FALSE.
1263 * The code here should be nearly identical to that in
1264 * do_cmd_open_test() and exe_open().
1267 bool easy_open_door(player_type *creature_ptr, POSITION y, POSITION x)
1271 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1272 feature_type *f_ptr = &f_info[g_ptr->feat];
1274 /* Must be a closed door */
1275 if (!is_closed_door(creature_ptr, g_ptr->feat))
1281 if (!have_flag(f_ptr->flags, FF_OPEN))
1284 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1289 else if (f_ptr->power)
1292 i = creature_ptr->skill_dis;
1294 /* Penalize some conditions */
1295 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1296 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1298 /* Extract the lock power */
1301 /* Extract the difficulty */
1304 /* Always have a small chance of success */
1308 if (randint0(100) < j)
1310 msg_print(_("鍵をはずした。", "You have picked the lock."));
1313 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1315 sound(SOUND_OPENDOOR);
1318 gain_exp(creature_ptr, 1);
1325 if (flush_failure) flush();
1327 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1336 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1338 sound(SOUND_OPENDOOR);
1345 * @brief 箱のトラップを解除する実行処理 /
1346 * Perform the basic "disarm" command
1347 * @param y 解除を行うマスのY座標
1348 * @param x 解除を行うマスのX座標
1349 * @param o_idx 箱のオブジェクトID
1350 * @return ターンを消費する処理が行われた場合TRUEを返す
1353 * Assume destination is a visible trap
1354 * Assume there is no monster blocking the destination
1355 * Returns TRUE if repeated commands may continue
1358 static bool exe_disarm_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
1362 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
1364 take_turn(creature_ptr, 100);
1366 /* Get the "disarm" factor */
1367 i = creature_ptr->skill_dis;
1369 /* Penalize some conditions */
1370 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1371 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1373 /* Extract the difficulty */
1374 j = i - o_ptr->pval;
1376 /* Always have a small chance of success */
1379 /* Must find the trap first. */
1380 if (!object_is_known(o_ptr))
1382 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1386 /* Already disarmed/unlocked */
1387 else if (o_ptr->pval <= 0)
1389 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1392 /* No traps to find. */
1393 else if (!chest_traps[o_ptr->pval])
1395 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1398 /* Success (get a lot of experience) */
1399 else if (randint0(100) < j)
1401 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1402 gain_exp(creature_ptr, o_ptr->pval);
1403 o_ptr->pval = (0 - o_ptr->pval);
1406 /* Failure -- Keep trying */
1407 else if ((i > 5) && (randint1(i) > 5))
1409 /* We may keep trying */
1411 if (flush_failure) flush();
1412 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1415 /* Failure -- Set off the trap */
1418 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1420 chest_trap(creature_ptr, y, x, o_idx);
1428 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1429 * Perform the basic "disarm" command
1430 * @param y 解除を行うマスのY座標
1431 * @param x 解除を行うマスのX座標
1432 * @param dir プレイヤーからみた方向ID
1433 * @return ターンを消費する処理が行われた場合TRUEを返す
1436 * Assume destination is a visible trap
1437 * Assume there is no monster blocking the destination
1438 * Returns TRUE if repeated commands may continue
1442 bool exe_disarm(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1444 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1447 feature_type *f_ptr = &f_info[g_ptr->feat];
1449 /* Access trap name */
1450 concptr name = (f_name + f_ptr->name);
1452 /* Extract trap "power" */
1453 int power = f_ptr->power;
1456 /* Get the "disarm" factor */
1457 int i = creature_ptr->skill_dis;
1460 take_turn(creature_ptr, 100);
1462 /* Penalize some conditions */
1463 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1464 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1466 /* Extract the difficulty */
1469 /* Always have a small chance of success */
1473 if (randint0(100) < j)
1475 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1478 gain_exp(creature_ptr, power);
1480 /* Remove the trap */
1481 cave_alter_feat(creature_ptr, y, x, FF_DISARM);
1483 /* Move the player onto the trap */
1484 move_player(creature_ptr, dir, easy_disarm, FALSE);
1487 /* Failure -- Keep trying */
1488 else if ((i > 5) && (randint1(i) > 5))
1491 if (flush_failure) flush();
1493 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1495 /* We may keep trying */
1499 /* Failure -- Set off the trap */
1502 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1503 /* Move the player onto the trap */
1504 move_player(creature_ptr, dir, easy_disarm, FALSE);
1512 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1513 * Disarms a trap, or chest
1516 void do_cmd_disarm(player_type *creature_ptr)
1524 if (creature_ptr->wild_mode) return;
1526 if (creature_ptr->special_defense & KATA_MUSOU)
1528 set_action(creature_ptr, ACTION_NONE);
1531 /* Option: Pick a direction */
1534 int num_traps, num_chests;
1536 /* Count visible traps */
1537 num_traps = count_dt(creature_ptr, &y, &x, is_trap, TRUE);
1539 /* Count chests (trapped) */
1540 num_chests = count_chests(creature_ptr, &y, &x, TRUE);
1542 /* See if only one target */
1543 if (num_traps || num_chests)
1545 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1546 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
1550 /* Allow repeated command */
1553 /* Set repeat count */
1554 command_rep = command_arg - 1;
1555 creature_ptr->redraw |= (PR_STATE);
1557 /* Cancel the arg */
1561 /* Get a direction (or abort) */
1562 if (get_rep_dir(creature_ptr, &dir,TRUE))
1567 y = creature_ptr->y + ddy[dir];
1568 x = creature_ptr->x + ddx[dir];
1569 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1571 /* Feature code (applying "mimic" field) */
1572 feat = get_feat_mimic(g_ptr);
1574 /* Check for chests */
1575 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, TRUE);
1578 if (!is_trap(creature_ptr, feat) && !o_idx)
1580 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1583 /* Monster in the way */
1584 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
1586 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1589 py_attack(creature_ptr, y, x, 0);
1595 more = exe_disarm_chest(creature_ptr, y, x, o_idx);
1601 more = exe_disarm(creature_ptr, y, x, dir);
1605 /* Cancel repeat unless told not to */
1606 if (!more) disturb(creature_ptr, FALSE, FALSE);
1611 * @brief 「打ち破る」動作コマンドのサブルーチン /
1612 * Perform the basic "bash" command
1613 * @param y 対象を行うマスのY座標
1614 * @param x 対象を行うマスのX座標
1615 * @param dir プレイヤーから見たターゲットの方角ID
1616 * @return 実際に処理が行われた場合TRUEを返す。
1619 * Assume destination is a closed/locked/jammed door
1620 * Assume there is no monster blocking the destination
1621 * Returns TRUE if repeated commands may continue
1624 static bool do_cmd_bash_aux(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1626 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1629 feature_type *f_ptr = &f_info[g_ptr->feat];
1631 /* Hack -- Bash power based on strength */
1632 /* (Ranges from 3 to 20 to 100 to 200) */
1633 int bash = adj_str_blow[creature_ptr->stat_ind[A_STR]];
1635 /* Extract door power */
1636 int temp = f_ptr->power;
1640 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1642 take_turn(creature_ptr, 100);
1644 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1646 /* Compare bash power to door power */
1647 temp = (bash - (temp * 10));
1649 if (creature_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1651 /* Hack -- always have a chance */
1652 if (temp < 1) temp = 1;
1654 /* Hack -- attempt to bash down the door */
1655 if (randint0(100) < temp)
1657 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1659 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1661 /* Break down the door */
1662 if ((randint0(100) < 50) || (feat_state(creature_ptr, g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1664 cave_alter_feat(creature_ptr, y, x, FF_BASH);
1670 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1673 /* Hack -- Fall through the door */
1674 move_player(creature_ptr, dir, FALSE, FALSE);
1677 /* Saving throw against stun */
1678 else if (randint0(100) < adj_dex_safe[creature_ptr->stat_ind[A_DEX]] +
1681 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1683 /* Allow repeated bashing */
1687 /* High dexterity yields coolness */
1690 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1692 /* Hack -- Lose balance ala paralysis */
1693 (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 2 + randint0(2));
1701 * @brief 「打ち破る」動作コマンドのメインルーチン /
1702 * Bash open a door, success based on character strength
1706 * For a closed door, pval is positive if locked; negative if stuck.
1708 * For an open door, pval is positive for a broken door.
1710 * A closed door can be opened - harder if locked. Any door might be
1711 * bashed open (and thereby broken). Bashing a door is (potentially)
1712 * faster! You move into the door way. To open a stuck door, it must
1713 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1715 * Creatures can also open or bash doors, see elsewhere.
1718 void do_cmd_bash(player_type *creature_ptr)
1725 if (creature_ptr->wild_mode) return;
1727 if (creature_ptr->special_defense & KATA_MUSOU)
1729 set_action(creature_ptr, ACTION_NONE);
1732 /* Allow repeated command */
1735 /* Set repeat count */
1736 command_rep = command_arg - 1;
1737 creature_ptr->redraw |= (PR_STATE);
1739 /* Cancel the arg */
1743 /* Get a "repeated" direction */
1744 if (get_rep_dir(creature_ptr, &dir,FALSE))
1749 y = creature_ptr->y + ddy[dir];
1750 x = creature_ptr->x + ddx[dir];
1752 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1754 /* Feature code (applying "mimic" field) */
1755 feat = get_feat_mimic(g_ptr);
1757 /* Nothing useful */
1758 if (!have_flag(f_info[feat].flags, FF_BASH))
1760 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1763 /* Monster in the way */
1764 else if (g_ptr->m_idx)
1766 take_turn(creature_ptr, 100);
1768 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1771 py_attack(creature_ptr, y, x, 0);
1774 /* Bash a closed door */
1778 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1782 /* Unless valid action taken, cancel bash */
1783 if (!more) disturb(creature_ptr, FALSE, FALSE);
1788 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1792 * Manipulate an adjacent grid in some way
1794 * Attack monsters, tunnel through walls, disarm traps, open doors.
1796 * Consider confusion
1798 * This command must always take a turn, to prevent free detection
1799 * of invisible monsters.
1802 void do_cmd_alter(player_type *creature_ptr)
1809 if (creature_ptr->special_defense & KATA_MUSOU)
1811 set_action(creature_ptr, ACTION_NONE);
1814 /* Allow repeated command */
1817 /* Set repeat count */
1818 command_rep = command_arg - 1;
1819 creature_ptr->redraw |= (PR_STATE);
1821 /* Cancel the arg */
1825 /* Get a direction */
1826 if (get_rep_dir(creature_ptr, &dir,TRUE))
1829 feature_type *f_ptr;
1831 y = creature_ptr->y + ddy[dir];
1832 x = creature_ptr->x + ddx[dir];
1834 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1836 /* Feature code (applying "mimic" field) */
1837 feat = get_feat_mimic(g_ptr);
1838 f_ptr = &f_info[feat];
1840 take_turn(creature_ptr, 100);
1844 py_attack(creature_ptr, y, x, 0);
1848 else if (have_flag(f_ptr->flags, FF_OPEN))
1850 more = exe_open(creature_ptr, y, x);
1853 /* Bash jammed doors */
1854 else if (have_flag(f_ptr->flags, FF_BASH))
1856 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1859 /* Tunnel through walls */
1860 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1862 more = exe_tunnel(creature_ptr, y, x);
1865 /* Close open doors */
1866 else if (have_flag(f_ptr->flags, FF_CLOSE))
1868 more = exe_close(creature_ptr, y, x);
1872 else if (have_flag(f_ptr->flags, FF_DISARM))
1874 more = exe_disarm(creature_ptr, y, x, dir);
1879 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1883 /* Cancel repetition unless we can continue */
1884 if (!more) disturb(creature_ptr, FALSE, FALSE);
1890 * @brief 「くさびを打つ」ために必要なオブジェクトを所持しているかどうかの判定を返す /
1891 * Find the index of some "spikes", if possible.
1892 * @param ip くさびとして打てるオブジェクトのID
1893 * @return オブジェクトがある場合TRUEを返す
1896 * Let user choose a pile of spikes, perhaps?
1899 static bool get_spike(player_type *creature_ptr, INVENTORY_IDX *ip)
1903 /* Check every item in the pack */
1904 for (i = 0; i < INVEN_PACK; i++)
1906 object_type *o_ptr = &creature_ptr->inventory_list[i];
1907 if (!o_ptr->k_idx) continue;
1909 /* Check the "tval" code */
1910 if (o_ptr->tval == TV_SPIKE)
1912 /* Save the spike index */
1925 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1926 * Jam a closed door with a spike
1927 * @param creature_ptr プレーヤーへの参照ポインタ
1931 * This command may NOT be repeated
1934 void do_cmd_spike(player_type *creature_ptr)
1938 if (creature_ptr->wild_mode) return;
1939 if (creature_ptr->special_defense & KATA_MUSOU)
1941 set_action(creature_ptr, ACTION_NONE);
1944 /* Get a "repeated" direction */
1945 if (!get_rep_dir(creature_ptr, &dir, FALSE)) return;
1947 POSITION y = creature_ptr->y + ddy[dir];
1948 POSITION x = creature_ptr->x + ddx[dir];
1950 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1952 /* Feature code (applying "mimic" field) */
1953 FEAT_IDX feat = get_feat_mimic(g_ptr);
1955 /* Require closed door */
1957 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1959 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1963 else if (!get_spike(creature_ptr, &item))
1965 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1968 /* Is a monster in the way? */
1969 else if (g_ptr->m_idx)
1971 take_turn(creature_ptr, 100);
1973 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1976 py_attack(creature_ptr, y, x, 0);
1982 take_turn(creature_ptr, 100);
1984 /* Successful jamming */
1985 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1986 cave_alter_feat(creature_ptr, y, x, FF_SPIKE);
1988 vary_item(creature_ptr, item, -1);
1994 * @brief 「歩く」動作コマンドのメインルーチン /
1995 * Support code for the "Walk" and "Jump" commands
1996 * @param creature_ptr プレーヤーへの参照ポインタ
1997 * @param pickup アイテムの自動拾いを行うならTRUE
2000 void do_cmd_walk(player_type *creature_ptr, bool pickup)
2002 /* Allow repeated command */
2005 /* Set repeat count */
2006 command_rep = command_arg - 1;
2007 creature_ptr->redraw |= (PR_STATE);
2009 /* Cancel the arg */
2013 /* Get a "repeated" direction */
2016 if (get_rep_dir(creature_ptr, &dir, FALSE))
2018 take_turn(creature_ptr, 100);
2020 if ((dir != 5) && (creature_ptr->special_defense & KATA_MUSOU))
2022 set_action(creature_ptr, ACTION_NONE);
2025 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2026 if (creature_ptr->wild_mode) creature_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2027 if (creature_ptr->action == ACTION_HAYAGAKE) creature_ptr->energy_use = creature_ptr->energy_use * (45-(creature_ptr->lev/2)) / 100;
2029 /* Actually move the character */
2030 move_player(creature_ptr, dir, pickup, FALSE);
2032 /* Allow more walking */
2036 /* Hack again -- Is there a special encounter ??? */
2037 if (creature_ptr->wild_mode && !cave_have_flag_bold(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, FF_TOWN))
2039 int tmp = 120 + creature_ptr->lev*10 - wilderness[creature_ptr->y][creature_ptr->x].level + 5;
2042 if (((wilderness[creature_ptr->y][creature_ptr->x].level + 5) > (creature_ptr->lev / 2)) && randint0(tmp) < (21-creature_ptr->skill_stl))
2044 /* Inform the player of his horrible fate :=) */
2045 msg_print(_("襲撃だ!", "You are ambushed !"));
2047 /* Go into large wilderness view */
2048 creature_ptr->oldpy = randint1(MAX_HGT-2);
2049 creature_ptr->oldpx = randint1(MAX_WID-2);
2050 change_wild_mode(creature_ptr, TRUE);
2052 /* Give first move to monsters */
2053 take_turn(creature_ptr, 100);
2058 /* Cancel repeat unless we may continue */
2059 if (!more) disturb(creature_ptr, FALSE, FALSE);
2064 * @brief 「走る」動作コマンドのメインルーチン /
2066 * @param creature_ptr プレーヤーへの参照ポインタ
2069 void do_cmd_run(player_type *creature_ptr)
2072 if (cmd_limit_confused(creature_ptr)) return;
2074 if (creature_ptr->special_defense & KATA_MUSOU)
2076 set_action(creature_ptr, ACTION_NONE);
2079 /* Get a "repeated" direction */
2080 if (get_rep_dir(creature_ptr, &dir,FALSE))
2082 /* Hack -- Set the run counter */
2083 creature_ptr->running = (command_arg ? command_arg : 1000);
2086 run_step(creature_ptr, dir);
2092 * @brief 「留まる」動作コマンドのメインルーチン /
2093 * Stay still. Search. Enter stores.
2094 * Pick up treasure if "pickup" is true.
2095 * @param creature_ptr プレーヤーへの参照ポインタ
2096 * @param pickup アイテムの自動拾いを行うならTRUE
2099 void do_cmd_stay(player_type *creature_ptr, bool pickup)
2101 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2103 /* Allow repeated command */
2106 /* Set repeat count */
2107 command_rep = command_arg - 1;
2108 creature_ptr->redraw |= (PR_STATE);
2110 /* Cancel the arg */
2114 take_turn(creature_ptr, 100);
2116 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2117 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, mpe_mode);
2122 * @brief 「休む」動作コマンドのメインルーチン /
2123 * Resting allows a player to safely restore his hp -RAK-
2124 * @param creature_ptr プレーヤーへの参照ポインタ
2127 void do_cmd_rest(player_type *creature_ptr)
2129 set_action(creature_ptr, ACTION_NONE);
2131 if ((creature_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(creature_ptr) || INTERUPTING_SONG_EFFECT(creature_ptr)))
2133 stop_singing(creature_ptr);
2136 if (hex_spelling_any(creature_ptr)) stop_hex_spell_all(creature_ptr);
2138 /* Prompt for time if needed */
2139 if (command_arg <= 0)
2141 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2142 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2147 strcpy(out_val, "&");
2149 /* Ask for duration */
2150 if (!get_string(p, out_val, 4)) return;
2152 /* Rest until done */
2153 if (out_val[0] == '&')
2155 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2159 else if (out_val[0] == '*')
2161 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2167 command_arg = (COMMAND_ARG)atoi(out_val);
2168 if (command_arg <= 0) return;
2172 if (command_arg > 9999) command_arg = 9999;
2174 if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE);
2176 /* Take a turn (?) */
2177 take_turn(creature_ptr, 100);
2179 /* The sin of sloth */
2180 if (command_arg > 100) chg_virtue(creature_ptr, V_DILIGENCE, -1);
2182 /* Why are you sleeping when there's no need? WAKE UP!*/
2183 if ((creature_ptr->chp == creature_ptr->mhp) &&
2184 (creature_ptr->csp == creature_ptr->msp) &&
2185 !creature_ptr->blind && !creature_ptr->confused &&
2186 !creature_ptr->poisoned && !creature_ptr->afraid &&
2187 !creature_ptr->stun && !creature_ptr->cut &&
2188 !creature_ptr->slow && !creature_ptr->paralyzed &&
2189 !creature_ptr->image && !creature_ptr->word_recall &&
2190 !creature_ptr->alter_reality)
2191 chg_virtue(creature_ptr, V_DILIGENCE, -1);
2193 /* Save the rest code */
2194 creature_ptr->resting = command_arg;
2195 creature_ptr->action = ACTION_REST;
2196 creature_ptr->update |= (PU_BONUS);
2197 update_creature(creature_ptr);
2199 creature_ptr->redraw |= (PR_STATE);
2200 update_output(creature_ptr);
2209 * @brief 射撃処理のメインルーチン
2210 * @param creature_ptr プレーヤーへの参照ポインタ
2211 * @param snipe_type ???
2214 void do_cmd_fire(player_type *creature_ptr, SPELL_IDX snipe_type)
2217 object_type *j_ptr, *ammo_ptr;
2220 if(creature_ptr->wild_mode) return;
2222 creature_ptr->is_fired = FALSE; /* not fired yet */
2224 /* Get the "bow" (if any) */
2225 j_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2227 /* Require a launcher */
2230 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2235 if (j_ptr->sval == SV_CRIMSON)
2237 msg_print(_("この武器は発動して使うもののようだ。", "It's already activated."));
2242 if (j_ptr->sval == SV_HARP)
2244 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2250 if (creature_ptr->special_defense & KATA_MUSOU)
2252 set_action(creature_ptr, ACTION_NONE);
2255 q = _("どれを撃ちますか? ", "Fire which item? ");
2256 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2258 ammo_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), creature_ptr->tval_ammo);
2266 exe_fire(creature_ptr, item, j_ptr, snipe_type);
2268 if (!creature_ptr->is_fired || creature_ptr->pclass != CLASS_SNIPER) return;
2270 /* Sniper actions after some shootings */
2271 if (snipe_type == SP_AWAY)
2273 teleport_player(creature_ptr, 10 + (creature_ptr->concent * 2), TELEPORT_SPONTANEOUS);
2276 if (snipe_type == SP_FINAL)
2278 msg_print(_("射撃の反動が体を襲った。", "The weapon's recoil stuns you. "));
2279 (void)set_slow(creature_ptr, creature_ptr->slow + randint0(7) + 7, FALSE);
2280 (void)set_stun(creature_ptr, creature_ptr->stun + randint1(25));
2286 * @brief 投射処理メインルーチン /
2287 * Throw an object from the pack or floor.
2289 * @param creature_ptr プレーヤーへの参照ポインタ
2290 * @param boomerang ブーメラン処理ならばTRUE
2291 * @param shuriken 忍者の手裏剣処理ならばTRUE
2292 * @return ターンを消費した場合TRUEを返す
2295 * Note: "unseen" monsters are very hard to hit.
2297 * Should throwing a weapon do full damage? Should it allow the magic
2298 * to hit bonus of the weapon to have an effect? Should it ever cause
2299 * the item to be destroyed? Should it do any damage at all?
2302 bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_IDX shuriken)
2307 POSITION y, x, ty, tx, prev_y, prev_x;
2308 POSITION ny[19], nx[19];
2309 int chance, tdam, tdis;
2310 int mul, div, dd, ds;
2311 int cur_dis, visible;
2318 bool hit_body = FALSE;
2319 bool hit_wall = FALSE;
2320 bool equiped_item = FALSE;
2321 bool return_when_thrown = FALSE;
2323 GAME_TEXT o_name[MAX_NLEN];
2325 int msec = delay_factor * delay_factor * delay_factor;
2327 BIT_FLAGS flgs[TR_FLAG_SIZE];
2329 bool come_back = FALSE;
2330 bool do_drop = TRUE;
2332 if (creature_ptr->wild_mode) return FALSE;
2334 if (creature_ptr->special_defense & KATA_MUSOU)
2336 set_action(creature_ptr, ACTION_NONE);
2342 o_ptr = &creature_ptr->inventory_list[item];
2346 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2348 item_tester_hook = item_tester_hook_boomerang;
2349 q = _("どの武器を投げますか? ", "Throw which item? ");
2350 s = _("投げる武器がない。", "You have nothing to throw.");
2351 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP), 0);
2358 else if (has_melee_weapon(creature_ptr, INVEN_LARM))
2361 o_ptr = &creature_ptr->inventory_list[item];
2366 o_ptr = &creature_ptr->inventory_list[item];
2371 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2372 s = _("投げるアイテムがない。", "You have nothing to throw.");
2373 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP), 0);
2381 /* Item is cursed */
2382 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2384 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2388 if (creature_ptr->current_floor_ptr->inside_arena && !boomerang)
2390 if (o_ptr->tval != TV_SPIKE)
2392 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2400 object_copy(q_ptr, o_ptr);
2402 /* Extract the thrown object's flags. */
2403 object_flags(q_ptr, flgs);
2404 torch_flags(q_ptr, flgs);
2406 /* Distribute the charges of rods/wands between the stacks */
2407 distribute_charges(o_ptr, q_ptr, 1);
2412 object_desc(creature_ptr, o_name, q_ptr, OD_OMIT_PREFIX);
2414 if (creature_ptr->mighty_throw) mult += 3;
2416 /* Extract a "distance multiplier" */
2417 /* Changed for 'launcher' mutation */
2418 mul = 10 + 2 * (mult - 1);
2420 /* Enforce a minimum "weight" of one pound */
2421 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2422 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2424 /* Hack -- Distance -- Reward strength, penalize weight */
2425 tdis = (adj_str_blow[creature_ptr->stat_ind[A_STR]] + 20) * mul / div;
2427 /* Max distance of 10-18 */
2428 if (tdis > mul) tdis = mul;
2432 ty = randint0(101) - 50 + creature_ptr->y;
2433 tx = randint0(101) - 50 + creature_ptr->x;
2437 project_length = tdis + 1;
2439 /* Get a direction (or cancel) */
2440 if (!get_aim_dir(creature_ptr, &dir)) return FALSE;
2442 /* Predict the "target" location */
2443 tx = creature_ptr->x + 99 * ddx[dir];
2444 ty = creature_ptr->y + 99 * ddy[dir];
2446 /* Check for "target request" */
2447 if ((dir == 5) && target_okay(creature_ptr))
2453 project_length = 0; /* reset to default */
2456 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2457 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2458 return_when_thrown = TRUE;
2462 inven_item_increase(creature_ptr, item, -1);
2463 if (!return_when_thrown)
2464 inven_item_describe(creature_ptr, item);
2465 inven_item_optimize(creature_ptr, item);
2469 floor_item_increase(creature_ptr->current_floor_ptr, 0 - item, -1);
2470 floor_item_optimize(creature_ptr, 0 - item);
2473 if (item >= INVEN_RARM)
2475 equiped_item = TRUE;
2476 creature_ptr->redraw |= (PR_EQUIPPY);
2479 take_turn(creature_ptr, 100);
2481 /* Rogue and Ninja gets bonus */
2482 if ((creature_ptr->pclass == CLASS_ROGUE) || (creature_ptr->pclass == CLASS_NINJA))
2483 creature_ptr->energy_use -= creature_ptr->lev;
2485 /* Start at the player */
2486 y = creature_ptr->y;
2487 x = creature_ptr->x;
2489 handle_stuff(creature_ptr);
2491 if ((creature_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2492 else shuriken = FALSE;
2494 /* Chance of hitting */
2495 if (have_flag(flgs, TR_THROW)) chance = ((creature_ptr->skill_tht) +
2496 ((creature_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2497 else chance = (creature_ptr->skill_tht + (creature_ptr->to_h_b * BTH_PLUS_ADJ));
2499 if (shuriken) chance *= 2;
2504 /* Travel until stopped */
2505 for (cur_dis = 0; cur_dis <= tdis; )
2507 /* Hack -- Stop at the target */
2508 if ((y == ty) && (x == tx)) break;
2510 /* Calculate the new location (see "project()") */
2513 mmove2(&ny[cur_dis], &nx[cur_dis], creature_ptr->y, creature_ptr->x, ty, tx);
2515 /* Stopped by walls/doors */
2516 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, ny[cur_dis], nx[cur_dis], FF_PROJECT))
2519 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;
2522 /* The player can see the (on screen) missile */
2523 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(creature_ptr, ny[cur_dis], nx[cur_dis]))
2525 SYMBOL_CODE c = object_char(q_ptr);
2526 TERM_COLOR a = object_attr(q_ptr);
2528 /* Draw, Hilite, Fresh, Pause, Erase */
2529 print_rel(creature_ptr, c, a, ny[cur_dis], nx[cur_dis]);
2530 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2532 Term_xtra(TERM_XTRA_DELAY, msec);
2533 lite_spot(creature_ptr, ny[cur_dis], nx[cur_dis]);
2537 /* The player cannot see the missile */
2540 /* Pause anyway, for consistancy */
2541 Term_xtra(TERM_XTRA_DELAY, msec);
2547 /* Save the new location */
2551 /* Advance the distance */
2554 /* Monster here, Try to hit it */
2555 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
2557 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
2558 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2559 GAME_TEXT m_name[MAX_NLEN];
2560 monster_name(creature_ptr, g_ptr->m_idx, m_name);
2562 /* Check the visibility */
2563 visible = m_ptr->ml;
2565 /* Note the collision */
2568 /* Did we hit it (penalize range) */
2569 if (test_hit_fire(creature_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2573 /* Handle unseen monster */
2576 /* Invisible monster */
2577 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2580 /* Handle visible monster */
2583 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2587 if (!creature_ptr->image) monster_race_track(creature_ptr, m_ptr->ap_r_idx);
2588 health_track(creature_ptr, g_ptr->m_idx);
2592 /* Hack -- Base damage from thrown object */
2595 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2596 tdam = damroll(dd, ds);
2597 /* Apply special damage */
2598 tdam = tot_dam_aux(creature_ptr, q_ptr, tdam, m_ptr, 0, TRUE);
2599 tdam = critical_shot(creature_ptr, q_ptr->weight, q_ptr->to_h, 0, tdam);
2600 if (q_ptr->to_d > 0)
2601 tdam += q_ptr->to_d;
2603 tdam += -q_ptr->to_d;
2607 tdam *= (mult+creature_ptr->num_blow[item - INVEN_RARM]);
2608 tdam += creature_ptr->to_d_m;
2610 else if (have_flag(flgs, TR_THROW))
2613 tdam += creature_ptr->to_d_m;
2621 tdam += ((creature_ptr->lev+30)*(creature_ptr->lev+30)-900)/55;
2624 /* No negative damage */
2625 if (tdam < 0) tdam = 0;
2627 /* Modify the damage */
2628 tdam = mon_damage_mod(creature_ptr, m_ptr, tdam, FALSE);
2630 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2631 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2633 /* Hit the monster, check for death */
2634 if (mon_take_hit(creature_ptr, g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2642 message_pain(creature_ptr, g_ptr->m_idx, tdam);
2644 /* Anger the monster */
2645 if ((tdam > 0) && !object_is_potion(q_ptr))
2646 anger_monster(creature_ptr, m_ptr);
2648 if (fear && m_ptr->ml)
2651 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2661 /* decrease toach's fuel */
2662 if (hit_body) torch_lost_fuel(q_ptr);
2664 /* Chance of breakage (during attacks) */
2665 j = (hit_body ? breakage_chance(creature_ptr, q_ptr, creature_ptr->pclass == CLASS_ARCHER, 0) : 0);
2667 /* Figurines transform */
2668 if ((q_ptr->tval == TV_FIGURINE) && !(creature_ptr->current_floor_ptr->inside_arena))
2672 if (!(summon_named_creature(creature_ptr, 0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2673 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2674 else if (object_is_cursed(q_ptr))
2675 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2679 /* Potions smash open */
2680 if (object_is_potion(q_ptr))
2682 if (hit_body || hit_wall || (randint1(100) < j))
2684 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2686 if (potion_smash_effect(creature_ptr, 0, y, x, q_ptr->k_idx))
2688 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx];
2689 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2691 GAME_TEXT m_name[MAX_NLEN];
2692 monster_desc(creature_ptr, m_name, m_ptr, 0);
2693 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2694 set_hostile(creature_ptr, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx]);
2705 if (return_when_thrown)
2707 int back_chance = randint1(30)+20+((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2708 char o2_name[MAX_NLEN];
2709 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2712 if (boomerang) back_chance += 4+randint1(5);
2713 if (super_boomerang) back_chance += 100;
2714 object_desc(creature_ptr, o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2716 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2718 for (i = cur_dis - 1; i > 0; i--)
2720 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(creature_ptr, ny[i], nx[i]))
2722 char c = object_char(q_ptr);
2723 byte a = object_attr(q_ptr);
2725 /* Draw, Hilite, Fresh, Pause, Erase */
2726 print_rel(creature_ptr, c, a, ny[i], nx[i]);
2727 move_cursor_relative(ny[i], nx[i]);
2729 Term_xtra(TERM_XTRA_DELAY, msec);
2730 lite_spot(creature_ptr, ny[i], nx[i]);
2735 /* Pause anyway, for consistancy */
2736 Term_xtra(TERM_XTRA_DELAY, msec);
2739 if((back_chance > 37) && !creature_ptr->blind && (item >= 0))
2741 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2748 msg_format(_("%sを受け損ねた!", "%s comes back, but you can't catch!"), o2_name);
2752 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2754 y = creature_ptr->y;
2755 x = creature_ptr->x;
2760 msg_format(_("%sが返ってこなかった!", "%s doesn't come back!"), o2_name);
2766 if (item == INVEN_RARM || item == INVEN_LARM)
2768 /* Access the wield slot */
2769 o_ptr = &creature_ptr->inventory_list[item];
2771 /* Wear the new stuff */
2772 object_copy(o_ptr, q_ptr);
2774 creature_ptr->total_weight += q_ptr->weight;
2776 /* Increment the equip counter by hand */
2777 creature_ptr->equip_cnt++;
2779 creature_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2780 creature_ptr->window |= (PW_EQUIP);
2784 inven_carry(creature_ptr, q_ptr);
2788 else if (equiped_item)
2790 verify_equip_slot(creature_ptr, item);
2791 calc_android_exp(creature_ptr);
2796 if (cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_PROJECT))
2798 (void)drop_near(creature_ptr, q_ptr, j, y, x);
2802 (void)drop_near(creature_ptr, q_ptr, j, prev_y, prev_x);
2810 * @brief 自殺するコマンドのメインルーチン
2811 * Hack -- commit suicide
2815 void do_cmd_suicide(player_type *creature_ptr)
2822 /* Verify Retirement */
2823 if (current_world_ptr->total_winner)
2826 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2829 /* Verify Suicide */
2833 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2836 if (!current_world_ptr->noscore)
2838 /* Special Verification for suicide */
2839 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2844 if (i != '@') return;
2846 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2849 /* Initialize "last message" buffer */
2850 if (creature_ptr->last_message) string_free(creature_ptr->last_message);
2851 creature_ptr->last_message = NULL;
2853 /* Hack -- Note *winning* message */
2854 if (current_world_ptr->total_winner && last_words)
2856 char buf[1024] = "";
2857 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2860 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2861 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2865 creature_ptr->last_message = string_make(buf);
2866 msg_print(creature_ptr->last_message);
2871 creature_ptr->playing = FALSE;
2873 /* Kill the player */
2874 creature_ptr->is_dead = TRUE;
2875 creature_ptr->leaving = TRUE;
2877 if (!current_world_ptr->total_winner)
2879 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("ダンジョンの探索に絶望して自殺した。", "gave up all hope to commit suicide."));
2880 exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2881 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
2884 /* Cause of death */
2885 (void)strcpy(creature_ptr->died_from, _("途中終了", "Quitting"));