2 * @brief プレイヤーのコマンド処理2 / Movement commands (part 2)
5 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
12 #include "cmd/cmd-basic.h"
13 #include "cmd-action/cmd-attack.h"
14 #include "cmd-io/cmd-dump.h"
15 #include "cmd-io/cmd-save.h"
16 #include "combat/attack-power-table.h"
17 #include "combat/shoot.h"
18 #include "combat/slaying.h"
19 #include "combat/snipe.h"
20 #include "core/output-updater.h"
21 #include "core/stuff-handler.h"
22 #include "info-reader/fixed-map-parser.h"
23 #include "dungeon/dungeon.h"
24 #include "dungeon/quest.h"
25 #include "effect/spells-effect-util.h"
26 #include "floor/floor-object.h"
27 #include "floor/geometry.h"
28 #include "floor/wild.h"
29 #include "grid/grid.h"
30 #include "grid/trap.h"
31 #include "inventory/inventory-object.h"
32 #include "inventory/player-inventory.h"
33 #include "io/files-util.h"
34 #include "io/targeting.h"
35 #include "io/write-diary.h"
36 #include "main/music-definitions-table.h"
37 #include "main/sound-definitions-table.h"
38 #include "monster/monster-status.h"
39 #include "object-enchant/artifact.h"
40 #include "specific-object/chest.h"
41 #include "object/item-use-flags.h"
42 #include "perception/object-perception.h"
43 #include "object/object-broken.h"
44 #include "object/object-flavor.h"
45 #include "object/object-generator.h"
46 #include "object/object-hook.h"
47 #include "object/object-kind.h"
48 #include "object/object-stack.h"
49 #include "object-enchant/special-object-flags.h"
50 #include "sv-definition/sv-bow-types.h"
51 #include "specific-object/torch.h"
52 #include "object-enchant/tr-types.h"
53 #include "player/avatar.h"
54 #include "player/player-effects.h"
55 #include "player/player-move.h"
56 #include "player/player-personalities-table.h"
57 #include "player/player-status.h"
58 #include "spell-realm/spells-hex.h"
59 #include "spell-kind/spells-teleport.h"
60 #include "system/system-variables.h"
61 #include "view/display-main-window.h"
62 #include "view/object-describer.h"
63 #include "world/world.h"
66 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
67 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
68 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
70 static bool confirm_leave_level(player_type *creature_ptr, bool down_stair)
72 quest_type *q_ptr = &quest[creature_ptr->current_floor_ptr->inside_quest];
74 /* Confirm leaving from once only quest */
75 if (confirm_quest && creature_ptr->current_floor_ptr->inside_quest &&
76 (q_ptr->type == QUEST_TYPE_RANDOM ||
77 (q_ptr->flags & QUEST_FLAG_ONCE &&
78 q_ptr->status != QUEST_STATUS_COMPLETED) ||
79 (q_ptr->flags & QUEST_FLAG_TOWER &&
80 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
81 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
83 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
84 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
94 * @brief 魔法系コマンドが制限されているかを返す。
95 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
97 bool cmd_limit_cast(player_type *creature_ptr)
99 if (creature_ptr->current_floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
101 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
105 else if (creature_ptr->anti_magic)
107 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
110 else if (creature_ptr->shero)
112 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
119 bool cmd_limit_confused(player_type *creature_ptr)
121 if (creature_ptr->confused)
123 msg_print(_("混乱していてできない!", "You are too confused!"));
129 bool cmd_limit_image(player_type *creature_ptr)
131 if (creature_ptr->image)
133 msg_print(_("幻覚が見えて集中できない!", "Your hallucinations prevent you from concentrating!"));
139 bool cmd_limit_stun(player_type *creature_ptr)
141 if (creature_ptr->stun)
143 msg_print(_("頭が朦朧としていて集中できない!", "You are too stunned!"));
149 bool cmd_limit_arena(player_type *creature_ptr)
151 if (creature_ptr->current_floor_ptr->inside_arena)
153 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
160 bool cmd_limit_blind(player_type *creature_ptr)
162 if (creature_ptr->blind)
164 msg_print(_("目が見えない。", "You can't see anything."));
167 if (no_lite(creature_ptr))
169 msg_print(_("明かりがないので見えない。", "You have no light."));
175 bool cmd_limit_time_walk(player_type *creature_ptr)
177 if (creature_ptr->timewalk)
179 if (flush_failure) flush();
180 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
188 * @brief 階段を使って階層を昇る処理 / Go up one level
191 void do_cmd_go_up(player_type *creature_ptr)
196 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
197 feature_type *f_ptr = &f_info[g_ptr->feat];
201 if (creature_ptr->special_defense & KATA_MUSOU)
203 set_action(creature_ptr, ACTION_NONE);
207 if (!have_flag(f_ptr->flags, FF_LESS))
209 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
213 /* Quest up stairs */
214 if (have_flag(f_ptr->flags, FF_QUEST))
216 if (!confirm_leave_level(creature_ptr, FALSE)) return;
219 if (IS_ECHIZEN(creature_ptr))
220 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
222 msg_print(_("上の階に登った。", "You enter the up staircase."));
224 leave_quest_check(creature_ptr);
226 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
228 /* Activate the quest */
229 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
231 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
233 init_flags = INIT_ASSIGN;
234 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
236 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
239 /* Leaving a quest */
240 if (!creature_ptr->current_floor_ptr->inside_quest)
242 creature_ptr->current_floor_ptr->dun_level = 0;
244 creature_ptr->leaving = TRUE;
246 creature_ptr->oldpx = 0;
247 creature_ptr->oldpy = 0;
249 take_turn(creature_ptr, 100);
251 /* End the command */
255 if (!creature_ptr->current_floor_ptr->dun_level)
261 go_up = confirm_leave_level(creature_ptr, FALSE);
266 take_turn(creature_ptr, 100);
268 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
270 /* For a random quest */
271 if (creature_ptr->current_floor_ptr->inside_quest &&
272 quest[creature_ptr->current_floor_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
274 leave_quest_check(creature_ptr);
276 creature_ptr->current_floor_ptr->inside_quest = 0;
279 /* For a fixed quest */
280 if (creature_ptr->current_floor_ptr->inside_quest &&
281 quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
283 leave_quest_check(creature_ptr);
285 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
286 creature_ptr->current_floor_ptr->dun_level = 0;
290 /* For normal dungeon and random quest */
294 if (have_flag(f_ptr->flags, FF_SHAFT))
296 /* Create a way back */
297 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
303 /* Create a way back */
304 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP);
309 /* Get out from current dungeon */
310 if (creature_ptr->current_floor_ptr->dun_level - up_num < d_info[creature_ptr->dungeon_idx].mindepth)
311 up_num = creature_ptr->current_floor_ptr->dun_level;
313 if (record_stair) exe_write_diary(creature_ptr, DIARY_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
316 if (IS_ECHIZEN(creature_ptr))
317 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
318 else if (up_num == creature_ptr->current_floor_ptr->dun_level)
319 msg_print(_("地上に戻った。", "You go back to the surface."));
321 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
322 creature_ptr->leaving = TRUE;
327 * @brief 階段を使って階層を降りる処理 / Go down one level
328 * @param creature_ptr プレーヤーへの参照ポインタ
331 void do_cmd_go_down(player_type *creature_ptr)
333 bool fall_trap = FALSE;
336 if (creature_ptr->special_defense & KATA_MUSOU)
338 set_action(creature_ptr, ACTION_NONE);
342 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
343 feature_type *f_ptr = &f_info[g_ptr->feat];
344 if (!have_flag(f_ptr->flags, FF_MORE))
346 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
350 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
353 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
355 do_cmd_quest(creature_ptr);
359 /* Quest down stairs */
360 if (have_flag(f_ptr->flags, FF_QUEST))
362 /* Confirm Leaving */
363 if(!confirm_leave_level(creature_ptr, TRUE)) return;
365 if (IS_ECHIZEN(creature_ptr))
366 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
368 msg_print(_("下の階に降りた。", "You enter the down staircase."));
370 leave_quest_check(creature_ptr);
371 leave_tower_check(creature_ptr);
373 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
375 /* Activate the quest */
376 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
378 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
380 init_flags = INIT_ASSIGN;
381 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
383 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
386 /* Leaving a quest */
387 if (!creature_ptr->current_floor_ptr->inside_quest)
389 creature_ptr->current_floor_ptr->dun_level = 0;
391 creature_ptr->leaving = TRUE;
392 creature_ptr->oldpx = 0;
393 creature_ptr->oldpy = 0;
395 take_turn(creature_ptr, 100);
399 DUNGEON_IDX target_dungeon = 0;
401 if (!creature_ptr->current_floor_ptr->dun_level)
403 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
405 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
407 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
410 if (!max_dlv[target_dungeon])
412 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
413 d_name + d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
414 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
417 /* Save old player position */
418 creature_ptr->oldpx = creature_ptr->x;
419 creature_ptr->oldpy = creature_ptr->y;
420 creature_ptr->dungeon_idx = target_dungeon;
423 * Clear all saved floors
424 * and create a first saved floor
426 prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
429 take_turn(creature_ptr, 100);
431 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
434 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
437 if (!creature_ptr->current_floor_ptr->dun_level)
439 /* Enter the dungeon just now */
440 creature_ptr->enter_dungeon = TRUE;
441 down_num = d_info[creature_ptr->dungeon_idx].mindepth;
446 if (fall_trap) exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
447 else exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
452 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
459 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[creature_ptr->dungeon_idx].text);
463 if (IS_ECHIZEN(creature_ptr))
464 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
466 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
470 creature_ptr->leaving = TRUE;
474 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
478 /* Create a way back */
479 if (have_flag(f_ptr->flags, FF_SHAFT))
481 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
485 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN);
491 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
494 void do_cmd_search(player_type * creature_ptr)
496 /* Allow repeated command */
499 /* Set repeat count */
500 command_rep = command_arg - 1;
501 creature_ptr->redraw |= (PR_STATE);
507 take_turn(creature_ptr, 100);
508 search(creature_ptr);
513 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
514 * @param y 走査対象にしたいマスのY座標
515 * @param x 走査対象にしたいマスのX座標
516 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
517 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
519 static OBJECT_IDX chest_check(floor_type *floor_ptr, POSITION y, POSITION x, bool trapped)
521 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
522 OBJECT_IDX this_o_idx, next_o_idx = 0;
524 /* Scan all objects in the grid */
525 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
529 o_ptr = &floor_ptr->o_list[this_o_idx];
530 next_o_idx = o_ptr->next_o_idx;
532 /* Skip unknown chests XXX XXX */
533 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
535 /* Check for non empty chest */
536 if ((o_ptr->tval == TV_CHEST) &&
537 (((!trapped) && (o_ptr->pval)) || /* non empty */
538 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
549 * Attempt to open the given chest at the given location
550 * @param y 箱の存在するマスのY座標
551 * @param x 箱の存在するマスのX座標
552 * @param o_idx 箱のオブジェクトID
553 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
555 * Assume there is no monster blocking the destination
557 static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
561 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
563 take_turn(creature_ptr, 100);
565 /* Attempt to unlock it */
568 /* Assume locked, and thus not open */
571 /* Get the "disarm" factor */
572 int i = creature_ptr->skill_dis;
574 /* Penalize some conditions */
575 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
576 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
578 /* Extract the difficulty */
579 int j = i - o_ptr->pval;
581 /* Always have a small chance of success */
584 /* Success -- May still have traps */
585 if (randint0(100) < j)
587 msg_print(_("鍵をはずした。", "You have picked the lock."));
588 gain_exp(creature_ptr, 1);
592 /* Failure -- Keep trying */
595 /* We may continue repeating */
597 if (flush_failure) flush();
598 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
603 /* Allowed to open */
606 /* Apply chest traps, if any */
607 chest_trap(creature_ptr, y, x, o_idx);
609 /* Let the Chest drop items */
610 chest_death(creature_ptr, FALSE, y, x, o_idx);
617 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
618 * Attempt to open the given chest at the given location
619 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
620 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
621 * @param test 地形条件を判定するための関数ポインタ
622 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
624 * @details Return the number of features around (or under) the character.
625 * Usually look for doors and floor traps.
627 static int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(player_type*, FEAT_IDX feat), bool under)
629 /* Check around (and under) the character */
631 for (DIRECTION d = 0; d < 9; d++)
636 /* if not searching under player continue */
637 if ((d == 8) && !under) continue;
639 /* Extract adjacent (legal) location */
640 POSITION yy = creature_ptr->y + ddy_ddd[d];
641 POSITION xx = creature_ptr->x + ddx_ddd[d];
643 /* Get the creature_ptr->current_floor_ptr->grid_array */
644 g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
646 /* Must have knowledge */
647 if (!(g_ptr->info & (CAVE_MARK))) continue;
649 /* Feature code (applying "mimic" field) */
650 feat = get_feat_mimic(g_ptr);
652 /* Not looking for this feature */
653 if (!((*test)(creature_ptr, feat))) continue;
658 /* Remember the location. Only useful if only one match */
669 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
670 * Return the number of chests around (or under) the character.
671 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
672 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
673 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
676 * If requested, count only trapped chests.
678 static int count_chests(player_type *creature_ptr, POSITION *y, POSITION *x, bool trapped)
680 /* Check around (and under) the character */
682 for (DIRECTION d = 0; d < 9; d++)
684 /* Extract adjacent (legal) location */
685 POSITION yy = creature_ptr->y + ddy_ddd[d];
686 POSITION xx = creature_ptr->x + ddx_ddd[d];
688 /* No (visible) chest is there */
689 OBJECT_IDX o_idx = chest_check(creature_ptr->current_floor_ptr, yy, xx, FALSE);
690 if (!o_idx) continue;
692 /* Grab the object */
694 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
697 if (o_ptr->pval == 0) continue;
699 /* No (known) traps here */
700 if (trapped && (!object_is_known(o_ptr) ||
701 !chest_traps[o_ptr->pval])) continue;
706 /* Remember the location. Only useful if only one match */
718 * @brief 「開ける」動作コマンドのサブルーチン /
719 * Perform the basic "open" command on doors
720 * @param y 対象を行うマスのY座標
721 * @param x 対象を行うマスのX座標
722 * @return 実際に処理が行われた場合TRUEを返す。
724 * Assume destination is a closed/locked/jammed door
725 * Assume there is no monster blocking the destination
726 * Returns TRUE if repeated commands may continue
728 static bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
730 /* Get requested grid */
731 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
732 feature_type *f_ptr = &f_info[g_ptr->feat];
735 take_turn(creature_ptr, 100);
737 /* Seeing true feature code (ignore mimic) */
740 if (!have_flag(f_ptr->flags, FF_OPEN))
743 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
749 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
750 sound(SOUND_OPENDOOR);
755 int i = creature_ptr->skill_dis;
757 /* Penalize some conditions */
758 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
759 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
761 /* Extract the difficulty */
762 int j = f_ptr->power;
765 /* Always have a small chance of success */
768 if (randint0(100) >= j)
770 if (flush_failure) flush();
771 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
775 msg_print(_("鍵をはずした。", "You have picked the lock."));
778 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
780 sound(SOUND_OPENDOOR);
783 gain_exp(creature_ptr, 1);
788 * @brief 「開ける」コマンドのメインルーチン /
789 * Open a closed/locked/jammed door or a closed/locked chest.
792 * Unlocking a locked door/chest is worth one experience point.
794 void do_cmd_open(player_type *creature_ptr)
802 if (creature_ptr->wild_mode) return;
804 if (creature_ptr->special_defense & KATA_MUSOU)
806 set_action(creature_ptr, ACTION_NONE);
809 /* Option: Pick a direction */
812 int num_doors, num_chests;
814 num_doors = count_dt(creature_ptr, &y, &x, is_closed_door, FALSE);
815 num_chests = count_chests(creature_ptr, &y, &x, FALSE);
816 if (num_doors || num_chests)
818 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
820 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
824 /* Allow repeated command */
827 /* Set repeat count */
828 command_rep = command_arg - 1;
829 creature_ptr->redraw |= (PR_STATE);
835 /* Get a "repeated" direction */
836 if (get_rep_dir(creature_ptr, &dir, TRUE))
841 /* Get requested location */
842 y = creature_ptr->y + ddy[dir];
843 x = creature_ptr->x + ddx[dir];
845 /* Get requested grid */
846 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
848 /* Feature code (applying "mimic" field) */
849 feat = get_feat_mimic(g_ptr);
851 /* Check for chest */
852 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, FALSE);
854 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
856 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
858 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
860 take_turn(creature_ptr, 100);
861 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
862 do_cmd_attack(creature_ptr, y, x, 0);
866 more = exe_open_chest(creature_ptr, y, x, o_idx);
870 more = exe_open(creature_ptr, y, x);
874 /* Cancel repeat unless we may continue */
875 if (!more) disturb(creature_ptr, FALSE, FALSE);
882 * @brief 「閉じる」動作コマンドのサブルーチン /
883 * Perform the basic "close" command
884 * @param y 対象を行うマスのY座標
885 * @param x 対象を行うマスのX座標
886 * @return 実際に処理が行われた場合TRUEを返す。
888 * Assume destination is an open/broken door
889 * Assume there is no monster blocking the destination
890 * Returns TRUE if repeated commands may continue
892 static bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
894 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
895 FEAT_IDX old_feat = g_ptr->feat;
898 take_turn(creature_ptr, 100);
900 /* Seeing true feature code (ignore mimic) */
903 if (!have_flag(f_info[old_feat].flags, FF_CLOSE))
908 s16b closed_feat = feat_state(creature_ptr, old_feat, FF_CLOSE);
910 /* Hack -- object in the way */
911 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
912 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
914 msg_print(_("何かがつっかえて閉まらない。", "Something prevents it from closing."));
919 cave_alter_feat(creature_ptr, y, x, FF_CLOSE);
922 if (old_feat == g_ptr->feat)
924 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
928 sound(SOUND_SHUTDOOR);
937 * @brief 「閉じる」コマンドのメインルーチン /
938 * Close an open door.
941 * Unlocking a locked door/chest is worth one experience point.
943 void do_cmd_close(player_type *creature_ptr)
950 if (creature_ptr->wild_mode) return;
952 if (creature_ptr->special_defense & KATA_MUSOU)
954 set_action(creature_ptr, ACTION_NONE);
957 /* Option: Pick a direction */
960 /* Count open doors */
961 if (count_dt(creature_ptr, &y, &x, is_open, FALSE) == 1)
963 command_dir = coords_to_dir(creature_ptr, y, x);
967 /* Allow repeated command */
970 /* Set repeat count */
971 command_rep = command_arg - 1;
972 creature_ptr->redraw |= (PR_STATE);
978 /* Get a "repeated" direction */
979 if (get_rep_dir(creature_ptr, &dir, FALSE))
984 y = creature_ptr->y + ddy[dir];
985 x = creature_ptr->x + ddx[dir];
986 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
988 /* Feature code (applying "mimic" field) */
989 feat = get_feat_mimic(g_ptr);
991 /* Require open/broken door */
992 if (!have_flag(f_info[feat].flags, FF_CLOSE))
994 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
997 /* Monster in the way */
998 else if (g_ptr->m_idx)
1000 take_turn(creature_ptr, 100);
1002 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1005 do_cmd_attack(creature_ptr, y, x, 0);
1008 /* Close the door */
1011 /* Close the door */
1012 more = exe_close(creature_ptr, y, x);
1016 /* Cancel repeat unless we may continue */
1017 if (!more) disturb(creature_ptr, FALSE, FALSE);
1022 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1023 * Determine if a given grid may be "tunneled"
1024 * @param y 対象を行うマスのY座標
1025 * @param x 対象を行うマスのX座標
1028 static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
1030 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1032 /* Must have knowledge */
1033 if (!(g_ptr->info & CAVE_MARK))
1035 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1040 /* Must be a wall/door/etc */
1041 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1043 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1053 * @brief 「掘る」動作コマンドのサブルーチン /
1054 * Perform the basic "tunnel" command
1055 * @param y 対象を行うマスのY座標
1056 * @param x 対象を行うマスのX座標
1057 * @return 実際に処理が行われた場合TRUEを返す。
1059 * Assumes that no monster is blocking the destination
1060 * Do not use twall anymore
1061 * Returns TRUE if repeated commands may continue
1063 static bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
1066 feature_type *f_ptr, *mimic_f_ptr;
1071 /* Verify legality */
1072 if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x)) return FALSE;
1074 take_turn(creature_ptr, 100);
1076 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1077 f_ptr = &f_info[g_ptr->feat];
1078 power = f_ptr->power;
1080 /* Feature code (applying "mimic" field) */
1081 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1083 name = f_name + mimic_f_ptr->name;
1087 if (have_flag(f_ptr->flags, FF_PERMANENT))
1090 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1092 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1095 /* Map border (mimiccing Permanent wall) */
1098 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1103 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1106 if (creature_ptr->skill_dig > randint0(20 * power))
1108 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1110 /* Remove the feature */
1111 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1112 creature_ptr->update |= (PU_FLOW);
1116 /* Message, keep digging */
1117 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1125 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1128 if (creature_ptr->skill_dig > power + randint0(40 * power))
1130 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1133 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1134 creature_ptr->update |= (PU_FLOW);
1137 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1139 /* Remove the feature */
1140 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1142 chg_virtue(creature_ptr, V_DILIGENCE, 1);
1143 chg_virtue(creature_ptr, V_NATURE, -1);
1151 /* We may continue chopping */
1152 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1153 /* Occasional Search XXX XXX */
1154 if (randint0(100) < 25) search(creature_ptr);
1158 /* We may continue tunelling */
1159 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1166 if (is_hidden_door(creature_ptr, g_ptr))
1168 /* Occasional Search XXX XXX */
1169 if (randint0(100) < 25) search(creature_ptr);
1177 * @brief 「掘る」動作コマンドのメインルーチン /
1178 * Tunnels through "walls" (including rubble and closed doors)
1182 * Note that you must tunnel in order to hit invisible monsters
1183 * in walls, though moving into walls still takes a turn anyway.
1185 * Digging is very difficult without a "digger" weapon, but can be
1186 * accomplished by strong players using heavy weapons.
1189 void do_cmd_tunnel(player_type *creature_ptr)
1198 if (creature_ptr->special_defense & KATA_MUSOU)
1200 set_action(creature_ptr, ACTION_NONE);
1203 /* Allow repeated command */
1206 /* Set repeat count */
1207 command_rep = command_arg - 1;
1208 creature_ptr->redraw |= (PR_STATE);
1210 /* Cancel the arg */
1214 /* Get a direction to tunnel, or Abort */
1215 if (get_rep_dir(creature_ptr, &dir,FALSE))
1218 y = creature_ptr->y + ddy[dir];
1219 x = creature_ptr->x + ddx[dir];
1221 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1223 /* Feature code (applying "mimic" field) */
1224 feat = get_feat_mimic(g_ptr);
1226 /* No tunnelling through doors */
1227 if (have_flag(f_info[feat].flags, FF_DOOR))
1229 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1232 /* No tunnelling through most features */
1233 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1235 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1238 /* A monster is in the way */
1239 else if (g_ptr->m_idx)
1241 take_turn(creature_ptr, 100);
1242 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1245 do_cmd_attack(creature_ptr, y, x, 0);
1251 /* Tunnel through walls */
1252 more = exe_tunnel(creature_ptr, y, x);
1256 /* Cancel repetition unless we can continue */
1257 if (!more) disturb(creature_ptr, FALSE, FALSE);
1261 * @brief 移動処理による簡易な「開く」処理 /
1263 * @return 開く処理が実際に試みられた場合TRUEを返す
1266 * If there is a jammed/closed/locked door at the given location,
1267 * then attempt to unlock/open it. Return TRUE if an attempt was
1268 * made (successful or not), otherwise return FALSE.
1270 * The code here should be nearly identical to that in
1271 * do_cmd_open_test() and exe_open().
1274 bool easy_open_door(player_type *creature_ptr, POSITION y, POSITION x)
1278 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1279 feature_type *f_ptr = &f_info[g_ptr->feat];
1281 /* Must be a closed door */
1282 if (!is_closed_door(creature_ptr, g_ptr->feat))
1288 if (!have_flag(f_ptr->flags, FF_OPEN))
1291 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1296 else if (f_ptr->power)
1299 i = creature_ptr->skill_dis;
1301 /* Penalize some conditions */
1302 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1303 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1305 /* Extract the lock power */
1308 /* Extract the difficulty */
1311 /* Always have a small chance of success */
1315 if (randint0(100) < j)
1317 msg_print(_("鍵をはずした。", "You have picked the lock."));
1320 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1322 sound(SOUND_OPENDOOR);
1325 gain_exp(creature_ptr, 1);
1332 if (flush_failure) flush();
1334 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1343 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1345 sound(SOUND_OPENDOOR);
1352 * @brief 箱のトラップを解除する実行処理 /
1353 * Perform the basic "disarm" command
1354 * @param y 解除を行うマスのY座標
1355 * @param x 解除を行うマスのX座標
1356 * @param o_idx 箱のオブジェクトID
1357 * @return ターンを消費する処理が行われた場合TRUEを返す
1360 * Assume destination is a visible trap
1361 * Assume there is no monster blocking the destination
1362 * Returns TRUE if repeated commands may continue
1365 static bool exe_disarm_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
1369 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
1371 take_turn(creature_ptr, 100);
1373 /* Get the "disarm" factor */
1374 i = creature_ptr->skill_dis;
1376 /* Penalize some conditions */
1377 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1378 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1380 /* Extract the difficulty */
1381 j = i - o_ptr->pval;
1383 /* Always have a small chance of success */
1386 /* Must find the trap first. */
1387 if (!object_is_known(o_ptr))
1389 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1393 /* Already disarmed/unlocked */
1394 else if (o_ptr->pval <= 0)
1396 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1399 /* No traps to find. */
1400 else if (!chest_traps[o_ptr->pval])
1402 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1405 /* Success (get a lot of experience) */
1406 else if (randint0(100) < j)
1408 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1409 gain_exp(creature_ptr, o_ptr->pval);
1410 o_ptr->pval = (0 - o_ptr->pval);
1413 /* Failure -- Keep trying */
1414 else if ((i > 5) && (randint1(i) > 5))
1416 /* We may keep trying */
1418 if (flush_failure) flush();
1419 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1422 /* Failure -- Set off the trap */
1425 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1427 chest_trap(creature_ptr, y, x, o_idx);
1435 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1436 * Perform the basic "disarm" command
1437 * @param y 解除を行うマスのY座標
1438 * @param x 解除を行うマスのX座標
1439 * @param dir プレイヤーからみた方向ID
1440 * @return ターンを消費する処理が行われた場合TRUEを返す
1443 * Assume destination is a visible trap
1444 * Assume there is no monster blocking the destination
1445 * Returns TRUE if repeated commands may continue
1449 bool exe_disarm(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1451 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1454 feature_type *f_ptr = &f_info[g_ptr->feat];
1456 /* Access trap name */
1457 concptr name = (f_name + f_ptr->name);
1459 /* Extract trap "power" */
1460 int power = f_ptr->power;
1463 /* Get the "disarm" factor */
1464 int i = creature_ptr->skill_dis;
1467 take_turn(creature_ptr, 100);
1469 /* Penalize some conditions */
1470 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1471 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1473 /* Extract the difficulty */
1476 /* Always have a small chance of success */
1480 if (randint0(100) < j)
1482 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1485 gain_exp(creature_ptr, power);
1487 /* Remove the trap */
1488 cave_alter_feat(creature_ptr, y, x, FF_DISARM);
1490 /* Move the player onto the trap */
1491 move_player(creature_ptr, dir, easy_disarm, FALSE);
1494 /* Failure -- Keep trying */
1495 else if ((i > 5) && (randint1(i) > 5))
1498 if (flush_failure) flush();
1500 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1502 /* We may keep trying */
1506 /* Failure -- Set off the trap */
1509 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1510 /* Move the player onto the trap */
1511 move_player(creature_ptr, dir, easy_disarm, FALSE);
1519 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1520 * Disarms a trap, or chest
1523 void do_cmd_disarm(player_type *creature_ptr)
1531 if (creature_ptr->wild_mode) return;
1533 if (creature_ptr->special_defense & KATA_MUSOU)
1535 set_action(creature_ptr, ACTION_NONE);
1538 /* Option: Pick a direction */
1541 int num_traps, num_chests;
1543 /* Count visible traps */
1544 num_traps = count_dt(creature_ptr, &y, &x, is_trap, TRUE);
1546 /* Count chests (trapped) */
1547 num_chests = count_chests(creature_ptr, &y, &x, TRUE);
1549 /* See if only one target */
1550 if (num_traps || num_chests)
1552 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1553 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
1557 /* Allow repeated command */
1560 /* Set repeat count */
1561 command_rep = command_arg - 1;
1562 creature_ptr->redraw |= (PR_STATE);
1564 /* Cancel the arg */
1568 /* Get a direction (or abort) */
1569 if (get_rep_dir(creature_ptr, &dir,TRUE))
1574 y = creature_ptr->y + ddy[dir];
1575 x = creature_ptr->x + ddx[dir];
1576 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1578 /* Feature code (applying "mimic" field) */
1579 feat = get_feat_mimic(g_ptr);
1581 /* Check for chests */
1582 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, TRUE);
1585 if (!is_trap(creature_ptr, feat) && !o_idx)
1587 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1590 /* Monster in the way */
1591 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
1593 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1596 do_cmd_attack(creature_ptr, y, x, 0);
1602 more = exe_disarm_chest(creature_ptr, y, x, o_idx);
1608 more = exe_disarm(creature_ptr, y, x, dir);
1612 /* Cancel repeat unless told not to */
1613 if (!more) disturb(creature_ptr, FALSE, FALSE);
1618 * @brief 「打ち破る」動作コマンドのサブルーチン /
1619 * Perform the basic "bash" command
1620 * @param y 対象を行うマスのY座標
1621 * @param x 対象を行うマスのX座標
1622 * @param dir プレイヤーから見たターゲットの方角ID
1623 * @return 実際に処理が行われた場合TRUEを返す。
1626 * Assume destination is a closed/locked/jammed door
1627 * Assume there is no monster blocking the destination
1628 * Returns TRUE if repeated commands may continue
1631 static bool do_cmd_bash_aux(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1633 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1636 feature_type *f_ptr = &f_info[g_ptr->feat];
1638 /* Hack -- Bash power based on strength */
1639 /* (Ranges from 3 to 20 to 100 to 200) */
1640 int bash = adj_str_blow[creature_ptr->stat_ind[A_STR]];
1642 /* Extract door power */
1643 int temp = f_ptr->power;
1647 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1649 take_turn(creature_ptr, 100);
1651 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1653 /* Compare bash power to door power */
1654 temp = (bash - (temp * 10));
1656 if (creature_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1658 /* Hack -- always have a chance */
1659 if (temp < 1) temp = 1;
1661 /* Hack -- attempt to bash down the door */
1662 if (randint0(100) < temp)
1664 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1666 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1668 /* Break down the door */
1669 if ((randint0(100) < 50) || (feat_state(creature_ptr, g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1671 cave_alter_feat(creature_ptr, y, x, FF_BASH);
1677 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1680 /* Hack -- Fall through the door */
1681 move_player(creature_ptr, dir, FALSE, FALSE);
1684 /* Saving throw against stun */
1685 else if (randint0(100) < adj_dex_safe[creature_ptr->stat_ind[A_DEX]] +
1688 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1690 /* Allow repeated bashing */
1694 /* High dexterity yields coolness */
1697 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1699 /* Hack -- Lose balance ala paralysis */
1700 (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 2 + randint0(2));
1708 * @brief 「打ち破る」動作コマンドのメインルーチン /
1709 * Bash open a door, success based on character strength
1713 * For a closed door, pval is positive if locked; negative if stuck.
1715 * For an open door, pval is positive for a broken door.
1717 * A closed door can be opened - harder if locked. Any door might be
1718 * bashed open (and thereby broken). Bashing a door is (potentially)
1719 * faster! You move into the door way. To open a stuck door, it must
1720 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1722 * Creatures can also open or bash doors, see elsewhere.
1725 void do_cmd_bash(player_type *creature_ptr)
1732 if (creature_ptr->wild_mode) return;
1734 if (creature_ptr->special_defense & KATA_MUSOU)
1736 set_action(creature_ptr, ACTION_NONE);
1739 /* Allow repeated command */
1742 /* Set repeat count */
1743 command_rep = command_arg - 1;
1744 creature_ptr->redraw |= (PR_STATE);
1746 /* Cancel the arg */
1750 /* Get a "repeated" direction */
1751 if (get_rep_dir(creature_ptr, &dir,FALSE))
1756 y = creature_ptr->y + ddy[dir];
1757 x = creature_ptr->x + ddx[dir];
1759 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1761 /* Feature code (applying "mimic" field) */
1762 feat = get_feat_mimic(g_ptr);
1764 /* Nothing useful */
1765 if (!have_flag(f_info[feat].flags, FF_BASH))
1767 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1770 /* Monster in the way */
1771 else if (g_ptr->m_idx)
1773 take_turn(creature_ptr, 100);
1775 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1778 do_cmd_attack(creature_ptr, y, x, 0);
1781 /* Bash a closed door */
1785 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1789 /* Unless valid action taken, cancel bash */
1790 if (!more) disturb(creature_ptr, FALSE, FALSE);
1795 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1799 * Manipulate an adjacent grid in some way
1801 * Attack monsters, tunnel through walls, disarm traps, open doors.
1803 * Consider confusion
1805 * This command must always take a turn, to prevent free detection
1806 * of invisible monsters.
1809 void do_cmd_alter(player_type *creature_ptr)
1816 if (creature_ptr->special_defense & KATA_MUSOU)
1818 set_action(creature_ptr, ACTION_NONE);
1821 /* Allow repeated command */
1824 /* Set repeat count */
1825 command_rep = command_arg - 1;
1826 creature_ptr->redraw |= (PR_STATE);
1828 /* Cancel the arg */
1832 /* Get a direction */
1833 if (get_rep_dir(creature_ptr, &dir,TRUE))
1836 feature_type *f_ptr;
1838 y = creature_ptr->y + ddy[dir];
1839 x = creature_ptr->x + ddx[dir];
1841 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1843 /* Feature code (applying "mimic" field) */
1844 feat = get_feat_mimic(g_ptr);
1845 f_ptr = &f_info[feat];
1847 take_turn(creature_ptr, 100);
1851 do_cmd_attack(creature_ptr, y, x, 0);
1855 else if (have_flag(f_ptr->flags, FF_OPEN))
1857 more = exe_open(creature_ptr, y, x);
1860 /* Bash jammed doors */
1861 else if (have_flag(f_ptr->flags, FF_BASH))
1863 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1866 /* Tunnel through walls */
1867 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1869 more = exe_tunnel(creature_ptr, y, x);
1872 /* Close open doors */
1873 else if (have_flag(f_ptr->flags, FF_CLOSE))
1875 more = exe_close(creature_ptr, y, x);
1879 else if (have_flag(f_ptr->flags, FF_DISARM))
1881 more = exe_disarm(creature_ptr, y, x, dir);
1886 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1890 /* Cancel repetition unless we can continue */
1891 if (!more) disturb(creature_ptr, FALSE, FALSE);
1897 * @brief 「くさびを打つ」ために必要なオブジェクトを所持しているかどうかの判定を返す /
1898 * Find the index of some "spikes", if possible.
1899 * @param ip くさびとして打てるオブジェクトのID
1900 * @return オブジェクトがある場合TRUEを返す
1903 * Let user choose a pile of spikes, perhaps?
1906 static bool get_spike(player_type *creature_ptr, INVENTORY_IDX *ip)
1910 /* Check every item in the pack */
1911 for (i = 0; i < INVEN_PACK; i++)
1913 object_type *o_ptr = &creature_ptr->inventory_list[i];
1914 if (!o_ptr->k_idx) continue;
1916 /* Check the "tval" code */
1917 if (o_ptr->tval == TV_SPIKE)
1919 /* Save the spike index */
1932 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1933 * Jam a closed door with a spike
1934 * @param creature_ptr プレーヤーへの参照ポインタ
1938 * This command may NOT be repeated
1941 void do_cmd_spike(player_type *creature_ptr)
1945 if (creature_ptr->wild_mode) return;
1946 if (creature_ptr->special_defense & KATA_MUSOU)
1948 set_action(creature_ptr, ACTION_NONE);
1951 /* Get a "repeated" direction */
1952 if (!get_rep_dir(creature_ptr, &dir, FALSE)) return;
1954 POSITION y = creature_ptr->y + ddy[dir];
1955 POSITION x = creature_ptr->x + ddx[dir];
1957 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1959 /* Feature code (applying "mimic" field) */
1960 FEAT_IDX feat = get_feat_mimic(g_ptr);
1962 /* Require closed door */
1964 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1966 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1970 else if (!get_spike(creature_ptr, &item))
1972 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1975 /* Is a monster in the way? */
1976 else if (g_ptr->m_idx)
1978 take_turn(creature_ptr, 100);
1980 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1983 do_cmd_attack(creature_ptr, y, x, 0);
1989 take_turn(creature_ptr, 100);
1991 /* Successful jamming */
1992 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1993 cave_alter_feat(creature_ptr, y, x, FF_SPIKE);
1995 vary_item(creature_ptr, item, -1);
2001 * @brief 「歩く」動作コマンドのメインルーチン /
2002 * Support code for the "Walk" and "Jump" commands
2003 * @param creature_ptr プレーヤーへの参照ポインタ
2004 * @param pickup アイテムの自動拾いを行うならTRUE
2007 void do_cmd_walk(player_type *creature_ptr, bool pickup)
2009 /* Allow repeated command */
2012 /* Set repeat count */
2013 command_rep = command_arg - 1;
2014 creature_ptr->redraw |= (PR_STATE);
2016 /* Cancel the arg */
2020 /* Get a "repeated" direction */
2023 if (get_rep_dir(creature_ptr, &dir, FALSE))
2025 take_turn(creature_ptr, 100);
2027 if ((dir != 5) && (creature_ptr->special_defense & KATA_MUSOU))
2029 set_action(creature_ptr, ACTION_NONE);
2032 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2033 if (creature_ptr->wild_mode) creature_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2034 if (creature_ptr->action == ACTION_HAYAGAKE) creature_ptr->energy_use = creature_ptr->energy_use * (45-(creature_ptr->lev/2)) / 100;
2036 /* Actually move the character */
2037 move_player(creature_ptr, dir, pickup, FALSE);
2039 /* Allow more walking */
2043 /* Hack again -- Is there a special encounter ??? */
2044 if (creature_ptr->wild_mode && !cave_have_flag_bold(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, FF_TOWN))
2046 int tmp = 120 + creature_ptr->lev*10 - wilderness[creature_ptr->y][creature_ptr->x].level + 5;
2049 if (((wilderness[creature_ptr->y][creature_ptr->x].level + 5) > (creature_ptr->lev / 2)) && randint0(tmp) < (21-creature_ptr->skill_stl))
2051 /* Inform the player of his horrible fate :=) */
2052 msg_print(_("襲撃だ!", "You are ambushed !"));
2054 /* Go into large wilderness view */
2055 creature_ptr->oldpy = randint1(MAX_HGT-2);
2056 creature_ptr->oldpx = randint1(MAX_WID-2);
2057 change_wild_mode(creature_ptr, TRUE);
2059 /* Give first move to monsters */
2060 take_turn(creature_ptr, 100);
2065 /* Cancel repeat unless we may continue */
2066 if (!more) disturb(creature_ptr, FALSE, FALSE);
2071 * @brief 「走る」動作コマンドのメインルーチン /
2073 * @param creature_ptr プレーヤーへの参照ポインタ
2076 void do_cmd_run(player_type *creature_ptr)
2079 if (cmd_limit_confused(creature_ptr)) return;
2081 if (creature_ptr->special_defense & KATA_MUSOU)
2083 set_action(creature_ptr, ACTION_NONE);
2086 /* Get a "repeated" direction */
2087 if (get_rep_dir(creature_ptr, &dir,FALSE))
2089 /* Hack -- Set the run counter */
2090 creature_ptr->running = (command_arg ? command_arg : 1000);
2093 run_step(creature_ptr, dir);
2099 * @brief 「留まる」動作コマンドのメインルーチン /
2100 * Stay still. Search. Enter stores.
2101 * Pick up treasure if "pickup" is true.
2102 * @param creature_ptr プレーヤーへの参照ポインタ
2103 * @param pickup アイテムの自動拾いを行うならTRUE
2106 void do_cmd_stay(player_type *creature_ptr, bool pickup)
2108 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2110 /* Allow repeated command */
2113 /* Set repeat count */
2114 command_rep = command_arg - 1;
2115 creature_ptr->redraw |= (PR_STATE);
2117 /* Cancel the arg */
2121 take_turn(creature_ptr, 100);
2123 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2124 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, mpe_mode);
2129 * @brief 「休む」動作コマンドのメインルーチン /
2130 * Resting allows a player to safely restore his hp -RAK-
2131 * @param creature_ptr プレーヤーへの参照ポインタ
2134 void do_cmd_rest(player_type *creature_ptr)
2136 set_action(creature_ptr, ACTION_NONE);
2138 if ((creature_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(creature_ptr) || INTERUPTING_SONG_EFFECT(creature_ptr)))
2140 stop_singing(creature_ptr);
2143 if (hex_spelling_any(creature_ptr)) stop_hex_spell_all(creature_ptr);
2145 /* Prompt for time if needed */
2146 if (command_arg <= 0)
2148 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2149 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2154 strcpy(out_val, "&");
2156 /* Ask for duration */
2157 if (!get_string(p, out_val, 4)) return;
2159 /* Rest until done */
2160 if (out_val[0] == '&')
2162 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2166 else if (out_val[0] == '*')
2168 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2174 command_arg = (COMMAND_ARG)atoi(out_val);
2175 if (command_arg <= 0) return;
2179 if (command_arg > 9999) command_arg = 9999;
2181 if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE);
2183 /* Take a turn (?) */
2184 take_turn(creature_ptr, 100);
2186 /* The sin of sloth */
2187 if (command_arg > 100) chg_virtue(creature_ptr, V_DILIGENCE, -1);
2189 /* Why are you sleeping when there's no need? WAKE UP!*/
2190 if ((creature_ptr->chp == creature_ptr->mhp) &&
2191 (creature_ptr->csp == creature_ptr->msp) &&
2192 !creature_ptr->blind && !creature_ptr->confused &&
2193 !creature_ptr->poisoned && !creature_ptr->afraid &&
2194 !creature_ptr->stun && !creature_ptr->cut &&
2195 !creature_ptr->slow && !creature_ptr->paralyzed &&
2196 !creature_ptr->image && !creature_ptr->word_recall &&
2197 !creature_ptr->alter_reality)
2198 chg_virtue(creature_ptr, V_DILIGENCE, -1);
2200 /* Save the rest code */
2201 creature_ptr->resting = command_arg;
2202 creature_ptr->action = ACTION_REST;
2203 creature_ptr->update |= (PU_BONUS);
2204 update_creature(creature_ptr);
2206 creature_ptr->redraw |= (PR_STATE);
2207 update_output(creature_ptr);
2216 * @brief 射撃処理のメインルーチン
2217 * @param creature_ptr プレーヤーへの参照ポインタ
2218 * @param snipe_type ???
2221 void do_cmd_fire(player_type *creature_ptr, SPELL_IDX snipe_type)
2224 object_type *j_ptr, *ammo_ptr;
2227 if(creature_ptr->wild_mode) return;
2229 creature_ptr->is_fired = FALSE; /* not fired yet */
2231 /* Get the "bow" (if any) */
2232 j_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2234 /* Require a launcher */
2237 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2242 if (j_ptr->sval == SV_CRIMSON)
2244 msg_print(_("この武器は発動して使うもののようだ。", "It's already activated."));
2249 if (j_ptr->sval == SV_HARP)
2251 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2257 if (creature_ptr->special_defense & KATA_MUSOU)
2259 set_action(creature_ptr, ACTION_NONE);
2262 q = _("どれを撃ちますか? ", "Fire which item? ");
2263 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2265 ammo_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), creature_ptr->tval_ammo);
2273 exe_fire(creature_ptr, item, j_ptr, snipe_type);
2275 if (!creature_ptr->is_fired || creature_ptr->pclass != CLASS_SNIPER) return;
2277 /* Sniper actions after some shootings */
2278 if (snipe_type == SP_AWAY)
2280 teleport_player(creature_ptr, 10 + (creature_ptr->concent * 2), TELEPORT_SPONTANEOUS);
2283 if (snipe_type == SP_FINAL)
2285 msg_print(_("射撃の反動が体を襲った。", "The weapon's recoil stuns you. "));
2286 (void)set_slow(creature_ptr, creature_ptr->slow + randint0(7) + 7, FALSE);
2287 (void)set_stun(creature_ptr, creature_ptr->stun + randint1(25));
2293 * @brief 投射処理メインルーチン /
2294 * Throw an object from the pack or floor.
2296 * @param creature_ptr プレーヤーへの参照ポインタ
2297 * @param boomerang ブーメラン処理ならばTRUE
2298 * @param shuriken 忍者の手裏剣処理ならばTRUE
2299 * @return ターンを消費した場合TRUEを返す
2302 * Note: "unseen" monsters are very hard to hit.
2304 * Should throwing a weapon do full damage? Should it allow the magic
2305 * to hit bonus of the weapon to have an effect? Should it ever cause
2306 * the item to be destroyed? Should it do any damage at all?
2309 bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_IDX shuriken)
2314 POSITION y, x, ty, tx, prev_y, prev_x;
2315 POSITION ny[19], nx[19];
2316 int chance, tdam, tdis;
2317 int mul, div, dd, ds;
2318 int cur_dis, visible;
2325 bool hit_body = FALSE;
2326 bool hit_wall = FALSE;
2327 bool equiped_item = FALSE;
2328 bool return_when_thrown = FALSE;
2330 GAME_TEXT o_name[MAX_NLEN];
2332 int msec = delay_factor * delay_factor * delay_factor;
2334 BIT_FLAGS flgs[TR_FLAG_SIZE];
2336 bool come_back = FALSE;
2337 bool do_drop = TRUE;
2339 if (creature_ptr->wild_mode) return FALSE;
2341 if (creature_ptr->special_defense & KATA_MUSOU)
2343 set_action(creature_ptr, ACTION_NONE);
2349 o_ptr = &creature_ptr->inventory_list[item];
2353 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2355 item_tester_hook = item_tester_hook_boomerang;
2356 q = _("どの武器を投げますか? ", "Throw which item? ");
2357 s = _("投げる武器がない。", "You have nothing to throw.");
2358 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP), 0);
2365 else if (has_melee_weapon(creature_ptr, INVEN_LARM))
2368 o_ptr = &creature_ptr->inventory_list[item];
2373 o_ptr = &creature_ptr->inventory_list[item];
2378 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2379 s = _("投げるアイテムがない。", "You have nothing to throw.");
2380 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP), 0);
2388 /* Item is cursed */
2389 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2391 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2395 if (creature_ptr->current_floor_ptr->inside_arena && !boomerang)
2397 if (o_ptr->tval != TV_SPIKE)
2399 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2407 object_copy(q_ptr, o_ptr);
2409 /* Extract the thrown object's flags. */
2410 object_flags(q_ptr, flgs);
2411 torch_flags(q_ptr, flgs);
2413 /* Distribute the charges of rods/wands between the stacks */
2414 distribute_charges(o_ptr, q_ptr, 1);
2419 object_desc(creature_ptr, o_name, q_ptr, OD_OMIT_PREFIX);
2421 if (creature_ptr->mighty_throw) mult += 3;
2423 /* Extract a "distance multiplier" */
2424 /* Changed for 'launcher' mutation */
2425 mul = 10 + 2 * (mult - 1);
2427 /* Enforce a minimum "weight" of one pound */
2428 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2429 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2431 /* Hack -- Distance -- Reward strength, penalize weight */
2432 tdis = (adj_str_blow[creature_ptr->stat_ind[A_STR]] + 20) * mul / div;
2434 /* Max distance of 10-18 */
2435 if (tdis > mul) tdis = mul;
2439 ty = randint0(101) - 50 + creature_ptr->y;
2440 tx = randint0(101) - 50 + creature_ptr->x;
2444 project_length = tdis + 1;
2446 /* Get a direction (or cancel) */
2447 if (!get_aim_dir(creature_ptr, &dir)) return FALSE;
2449 /* Predict the "target" location */
2450 tx = creature_ptr->x + 99 * ddx[dir];
2451 ty = creature_ptr->y + 99 * ddy[dir];
2453 /* Check for "target request" */
2454 if ((dir == 5) && target_okay(creature_ptr))
2460 project_length = 0; /* reset to default */
2463 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2464 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2465 return_when_thrown = TRUE;
2469 inven_item_increase(creature_ptr, item, -1);
2470 if (!return_when_thrown)
2471 inven_item_describe(creature_ptr, item);
2472 inven_item_optimize(creature_ptr, item);
2476 floor_item_increase(creature_ptr->current_floor_ptr, 0 - item, -1);
2477 floor_item_optimize(creature_ptr, 0 - item);
2480 if (item >= INVEN_RARM)
2482 equiped_item = TRUE;
2483 creature_ptr->redraw |= (PR_EQUIPPY);
2486 take_turn(creature_ptr, 100);
2488 /* Rogue and Ninja gets bonus */
2489 if ((creature_ptr->pclass == CLASS_ROGUE) || (creature_ptr->pclass == CLASS_NINJA))
2490 creature_ptr->energy_use -= creature_ptr->lev;
2492 /* Start at the player */
2493 y = creature_ptr->y;
2494 x = creature_ptr->x;
2496 handle_stuff(creature_ptr);
2498 if ((creature_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2499 else shuriken = FALSE;
2501 /* Chance of hitting */
2502 if (have_flag(flgs, TR_THROW)) chance = ((creature_ptr->skill_tht) +
2503 ((creature_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2504 else chance = (creature_ptr->skill_tht + (creature_ptr->to_h_b * BTH_PLUS_ADJ));
2506 if (shuriken) chance *= 2;
2511 /* Travel until stopped */
2512 for (cur_dis = 0; cur_dis <= tdis; )
2514 /* Hack -- Stop at the target */
2515 if ((y == ty) && (x == tx)) break;
2517 /* Calculate the new location (see "project()") */
2520 mmove2(&ny[cur_dis], &nx[cur_dis], creature_ptr->y, creature_ptr->x, ty, tx);
2522 /* Stopped by walls/doors */
2523 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, ny[cur_dis], nx[cur_dis], FF_PROJECT))
2526 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;
2529 /* The player can see the (on screen) missile */
2530 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(creature_ptr, ny[cur_dis], nx[cur_dis]))
2532 SYMBOL_CODE c = object_char(q_ptr);
2533 TERM_COLOR a = object_attr(q_ptr);
2535 /* Draw, Hilite, Fresh, Pause, Erase */
2536 print_rel(creature_ptr, c, a, ny[cur_dis], nx[cur_dis]);
2537 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2539 Term_xtra(TERM_XTRA_DELAY, msec);
2540 lite_spot(creature_ptr, ny[cur_dis], nx[cur_dis]);
2544 /* The player cannot see the missile */
2547 /* Pause anyway, for consistancy */
2548 Term_xtra(TERM_XTRA_DELAY, msec);
2554 /* Save the new location */
2558 /* Advance the distance */
2561 /* Monster here, Try to hit it */
2562 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
2564 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
2565 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2566 GAME_TEXT m_name[MAX_NLEN];
2567 monster_name(creature_ptr, g_ptr->m_idx, m_name);
2569 /* Check the visibility */
2570 visible = m_ptr->ml;
2572 /* Note the collision */
2575 /* Did we hit it (penalize range) */
2576 if (test_hit_fire(creature_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2580 /* Handle unseen monster */
2583 /* Invisible monster */
2584 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2587 /* Handle visible monster */
2590 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2594 if (!creature_ptr->image) monster_race_track(creature_ptr, m_ptr->ap_r_idx);
2595 health_track(creature_ptr, g_ptr->m_idx);
2599 /* Hack -- Base damage from thrown object */
2602 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2603 tdam = damroll(dd, ds);
2604 /* Apply special damage */
2605 tdam = calc_attack_damage_with_slay(creature_ptr, q_ptr, tdam, m_ptr, 0, TRUE);
2606 tdam = critical_shot(creature_ptr, q_ptr->weight, q_ptr->to_h, 0, tdam);
2607 if (q_ptr->to_d > 0)
2608 tdam += q_ptr->to_d;
2610 tdam += -q_ptr->to_d;
2614 tdam *= (mult+creature_ptr->num_blow[item - INVEN_RARM]);
2615 tdam += creature_ptr->to_d_m;
2617 else if (have_flag(flgs, TR_THROW))
2620 tdam += creature_ptr->to_d_m;
2628 tdam += ((creature_ptr->lev+30)*(creature_ptr->lev+30)-900)/55;
2631 /* No negative damage */
2632 if (tdam < 0) tdam = 0;
2634 /* Modify the damage */
2635 tdam = mon_damage_mod(creature_ptr, m_ptr, tdam, FALSE);
2637 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2638 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2640 /* Hit the monster, check for death */
2641 if (mon_take_hit(creature_ptr, g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2649 message_pain(creature_ptr, g_ptr->m_idx, tdam);
2651 /* Anger the monster */
2652 if ((tdam > 0) && !object_is_potion(q_ptr))
2653 anger_monster(creature_ptr, m_ptr);
2655 if (fear && m_ptr->ml)
2658 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2668 /* decrease toach's fuel */
2669 if (hit_body) torch_lost_fuel(q_ptr);
2671 /* Chance of breakage (during attacks) */
2672 j = (hit_body ? breakage_chance(creature_ptr, q_ptr, creature_ptr->pclass == CLASS_ARCHER, 0) : 0);
2674 /* Figurines transform */
2675 if ((q_ptr->tval == TV_FIGURINE) && !(creature_ptr->current_floor_ptr->inside_arena))
2679 if (!(summon_named_creature(creature_ptr, 0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2680 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2681 else if (object_is_cursed(q_ptr))
2682 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2686 /* Potions smash open */
2687 if (object_is_potion(q_ptr))
2689 if (hit_body || hit_wall || (randint1(100) < j))
2691 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2693 if (potion_smash_effect(creature_ptr, 0, y, x, q_ptr->k_idx))
2695 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx];
2696 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2698 GAME_TEXT m_name[MAX_NLEN];
2699 monster_desc(creature_ptr, m_name, m_ptr, 0);
2700 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2701 set_hostile(creature_ptr, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx]);
2712 if (return_when_thrown)
2714 int back_chance = randint1(30)+20+((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2715 char o2_name[MAX_NLEN];
2716 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2719 if (boomerang) back_chance += 4+randint1(5);
2720 if (super_boomerang) back_chance += 100;
2721 object_desc(creature_ptr, o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2723 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2725 for (i = cur_dis - 1; i > 0; i--)
2727 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(creature_ptr, ny[i], nx[i]))
2729 char c = object_char(q_ptr);
2730 byte a = object_attr(q_ptr);
2732 /* Draw, Hilite, Fresh, Pause, Erase */
2733 print_rel(creature_ptr, c, a, ny[i], nx[i]);
2734 move_cursor_relative(ny[i], nx[i]);
2736 Term_xtra(TERM_XTRA_DELAY, msec);
2737 lite_spot(creature_ptr, ny[i], nx[i]);
2742 /* Pause anyway, for consistancy */
2743 Term_xtra(TERM_XTRA_DELAY, msec);
2746 if((back_chance > 37) && !creature_ptr->blind && (item >= 0))
2748 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2755 msg_format(_("%sを受け損ねた!", "%s comes back, but you can't catch!"), o2_name);
2759 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2761 y = creature_ptr->y;
2762 x = creature_ptr->x;
2767 msg_format(_("%sが返ってこなかった!", "%s doesn't come back!"), o2_name);
2773 if (item == INVEN_RARM || item == INVEN_LARM)
2775 /* Access the wield slot */
2776 o_ptr = &creature_ptr->inventory_list[item];
2778 /* Wear the new stuff */
2779 object_copy(o_ptr, q_ptr);
2781 creature_ptr->total_weight += q_ptr->weight;
2783 /* Increment the equip counter by hand */
2784 creature_ptr->equip_cnt++;
2786 creature_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2787 creature_ptr->window |= (PW_EQUIP);
2791 store_item_to_inventory(creature_ptr, q_ptr);
2795 else if (equiped_item)
2797 verify_equip_slot(creature_ptr, item);
2798 calc_android_exp(creature_ptr);
2803 if (cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_PROJECT))
2805 (void)drop_near(creature_ptr, q_ptr, j, y, x);
2809 (void)drop_near(creature_ptr, q_ptr, j, prev_y, prev_x);
2817 * @brief 自殺するコマンドのメインルーチン
2818 * Hack -- commit suicide
2822 void do_cmd_suicide(player_type *creature_ptr)
2829 /* Verify Retirement */
2830 if (current_world_ptr->total_winner)
2833 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2836 /* Verify Suicide */
2840 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2843 if (!current_world_ptr->noscore)
2845 /* Special Verification for suicide */
2846 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2851 if (i != '@') return;
2853 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2856 /* Initialize "last message" buffer */
2857 if (creature_ptr->last_message) string_free(creature_ptr->last_message);
2858 creature_ptr->last_message = NULL;
2860 /* Hack -- Note *winning* message */
2861 if (current_world_ptr->total_winner && last_words)
2863 char buf[1024] = "";
2864 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2867 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2868 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2872 creature_ptr->last_message = string_make(buf);
2873 msg_print(creature_ptr->last_message);
2878 creature_ptr->playing = FALSE;
2880 /* Kill the player */
2881 creature_ptr->is_dead = TRUE;
2882 creature_ptr->leaving = TRUE;
2884 if (!current_world_ptr->total_winner)
2886 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("ダンジョンの探索に絶望して自殺した。", "gave up all hope to commit suicide."));
2887 exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2888 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
2891 /* Cause of death */
2892 (void)strcpy(creature_ptr->died_from, _("途中終了", "Quitting"));