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 "art-definition/art-bow-types.h"
14 #include "art-definition/art-weapon-types.h"
15 #include "cmd-action/cmd-attack.h"
16 #include "cmd-io/cmd-dump.h"
17 #include "cmd-io/cmd-save.h"
18 #include "combat/attack-power-table.h"
19 #include "combat/shoot.h"
20 #include "combat/slaying.h"
21 #include "combat/snipe.h"
22 #include "core/output-updater.h"
23 #include "core/stuff-handler.h"
24 #include "dungeon/dungeon.h"
25 #include "dungeon/quest.h"
26 #include "effect/spells-effect-util.h"
27 #include "floor/floor-object.h"
28 #include "floor/geometry.h"
29 #include "floor/wild.h"
30 #include "grid/grid.h"
31 #include "grid/trap.h"
32 #include "info-reader/fixed-map-parser.h"
33 #include "inventory/inventory-object.h"
34 #include "inventory/player-inventory.h"
35 #include "io/files-util.h"
36 #include "io/targeting.h"
37 #include "io/write-diary.h"
38 #include "main/music-definitions-table.h"
39 #include "main/sound-definitions-table.h"
40 #include "monster/monster-status.h"
41 #include "object-enchant/special-object-flags.h"
42 #include "object-enchant/tr-types.h"
43 #include "object/item-use-flags.h"
44 #include "object/object-broken.h"
45 #include "object/object-flags.h"
46 #include "object/object-flavor.h"
47 #include "object/object-generator.h"
48 #include "object/object-hook.h"
49 #include "object/object-kind.h"
50 #include "object/object-stack.h"
51 #include "object/object-info.h"
52 #include "perception/object-perception.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 "specific-object/chest.h"
59 #include "specific-object/torch.h"
60 #include "spell-kind/spells-teleport.h"
61 #include "spell-realm/spells-hex.h"
62 #include "sv-definition/sv-bow-types.h"
63 #include "system/system-variables.h"
64 #include "view/display-main-window.h"
65 #include "view/object-describer.h"
66 #include "world/world.h"
69 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
70 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
71 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
73 static bool confirm_leave_level(player_type *creature_ptr, bool down_stair)
75 quest_type *q_ptr = &quest[creature_ptr->current_floor_ptr->inside_quest];
77 /* Confirm leaving from once only quest */
78 if (confirm_quest && creature_ptr->current_floor_ptr->inside_quest &&
79 (q_ptr->type == QUEST_TYPE_RANDOM ||
80 (q_ptr->flags & QUEST_FLAG_ONCE &&
81 q_ptr->status != QUEST_STATUS_COMPLETED) ||
82 (q_ptr->flags & QUEST_FLAG_TOWER &&
83 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
84 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
86 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
87 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
97 * @brief 魔法系コマンドが制限されているかを返す。
98 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
100 bool cmd_limit_cast(player_type *creature_ptr)
102 if (creature_ptr->current_floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
104 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
108 else if (creature_ptr->anti_magic)
110 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
113 else if (creature_ptr->shero)
115 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
122 bool cmd_limit_confused(player_type *creature_ptr)
124 if (creature_ptr->confused)
126 msg_print(_("混乱していてできない!", "You are too confused!"));
132 bool cmd_limit_image(player_type *creature_ptr)
134 if (creature_ptr->image)
136 msg_print(_("幻覚が見えて集中できない!", "Your hallucinations prevent you from concentrating!"));
142 bool cmd_limit_stun(player_type *creature_ptr)
144 if (creature_ptr->stun)
146 msg_print(_("頭が朦朧としていて集中できない!", "You are too stunned!"));
152 bool cmd_limit_arena(player_type *creature_ptr)
154 if (creature_ptr->current_floor_ptr->inside_arena)
156 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
163 bool cmd_limit_blind(player_type *creature_ptr)
165 if (creature_ptr->blind)
167 msg_print(_("目が見えない。", "You can't see anything."));
170 if (no_lite(creature_ptr))
172 msg_print(_("明かりがないので見えない。", "You have no light."));
178 bool cmd_limit_time_walk(player_type *creature_ptr)
180 if (creature_ptr->timewalk)
182 if (flush_failure) flush();
183 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
191 * @brief 階段を使って階層を昇る処理 / Go up one level
194 void do_cmd_go_up(player_type *creature_ptr)
199 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
200 feature_type *f_ptr = &f_info[g_ptr->feat];
204 if (creature_ptr->special_defense & KATA_MUSOU)
206 set_action(creature_ptr, ACTION_NONE);
210 if (!have_flag(f_ptr->flags, FF_LESS))
212 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
216 /* Quest up stairs */
217 if (have_flag(f_ptr->flags, FF_QUEST))
219 if (!confirm_leave_level(creature_ptr, FALSE)) return;
222 if (IS_ECHIZEN(creature_ptr))
223 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
225 msg_print(_("上の階に登った。", "You enter the up staircase."));
227 leave_quest_check(creature_ptr);
229 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
231 /* Activate the quest */
232 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
234 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
236 init_flags = INIT_ASSIGN;
237 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
239 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
242 /* Leaving a quest */
243 if (!creature_ptr->current_floor_ptr->inside_quest)
245 creature_ptr->current_floor_ptr->dun_level = 0;
247 creature_ptr->leaving = TRUE;
249 creature_ptr->oldpx = 0;
250 creature_ptr->oldpy = 0;
252 take_turn(creature_ptr, 100);
254 /* End the command */
258 if (!creature_ptr->current_floor_ptr->dun_level)
264 go_up = confirm_leave_level(creature_ptr, FALSE);
269 take_turn(creature_ptr, 100);
271 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
273 /* For a random quest */
274 if (creature_ptr->current_floor_ptr->inside_quest &&
275 quest[creature_ptr->current_floor_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
277 leave_quest_check(creature_ptr);
279 creature_ptr->current_floor_ptr->inside_quest = 0;
282 /* For a fixed quest */
283 if (creature_ptr->current_floor_ptr->inside_quest &&
284 quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
286 leave_quest_check(creature_ptr);
288 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
289 creature_ptr->current_floor_ptr->dun_level = 0;
293 /* For normal dungeon and random quest */
297 if (have_flag(f_ptr->flags, FF_SHAFT))
299 /* Create a way back */
300 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
306 /* Create a way back */
307 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP);
312 /* Get out from current dungeon */
313 if (creature_ptr->current_floor_ptr->dun_level - up_num < d_info[creature_ptr->dungeon_idx].mindepth)
314 up_num = creature_ptr->current_floor_ptr->dun_level;
316 if (record_stair) exe_write_diary(creature_ptr, DIARY_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
319 if (IS_ECHIZEN(creature_ptr))
320 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
321 else if (up_num == creature_ptr->current_floor_ptr->dun_level)
322 msg_print(_("地上に戻った。", "You go back to the surface."));
324 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
325 creature_ptr->leaving = TRUE;
330 * @brief 階段を使って階層を降りる処理 / Go down one level
331 * @param creature_ptr プレーヤーへの参照ポインタ
334 void do_cmd_go_down(player_type *creature_ptr)
336 bool fall_trap = FALSE;
339 if (creature_ptr->special_defense & KATA_MUSOU)
341 set_action(creature_ptr, ACTION_NONE);
345 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
346 feature_type *f_ptr = &f_info[g_ptr->feat];
347 if (!have_flag(f_ptr->flags, FF_MORE))
349 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
353 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
356 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
358 do_cmd_quest(creature_ptr);
362 /* Quest down stairs */
363 if (have_flag(f_ptr->flags, FF_QUEST))
365 /* Confirm Leaving */
366 if(!confirm_leave_level(creature_ptr, TRUE)) return;
368 if (IS_ECHIZEN(creature_ptr))
369 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
371 msg_print(_("下の階に降りた。", "You enter the down staircase."));
373 leave_quest_check(creature_ptr);
374 leave_tower_check(creature_ptr);
376 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
378 /* Activate the quest */
379 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
381 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
383 init_flags = INIT_ASSIGN;
384 parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
386 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
389 /* Leaving a quest */
390 if (!creature_ptr->current_floor_ptr->inside_quest)
392 creature_ptr->current_floor_ptr->dun_level = 0;
394 creature_ptr->leaving = TRUE;
395 creature_ptr->oldpx = 0;
396 creature_ptr->oldpy = 0;
398 take_turn(creature_ptr, 100);
402 DUNGEON_IDX target_dungeon = 0;
404 if (!creature_ptr->current_floor_ptr->dun_level)
406 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
408 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
410 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
413 if (!max_dlv[target_dungeon])
415 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
416 d_name + d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
417 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
420 /* Save old player position */
421 creature_ptr->oldpx = creature_ptr->x;
422 creature_ptr->oldpy = creature_ptr->y;
423 creature_ptr->dungeon_idx = target_dungeon;
426 * Clear all saved floors
427 * and create a first saved floor
429 prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
432 take_turn(creature_ptr, 100);
434 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
437 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
440 if (!creature_ptr->current_floor_ptr->dun_level)
442 /* Enter the dungeon just now */
443 creature_ptr->enter_dungeon = TRUE;
444 down_num = d_info[creature_ptr->dungeon_idx].mindepth;
449 if (fall_trap) exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
450 else exe_write_diary(creature_ptr, DIARY_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
455 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
462 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[creature_ptr->dungeon_idx].text);
466 if (IS_ECHIZEN(creature_ptr))
467 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
469 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
473 creature_ptr->leaving = TRUE;
477 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
481 /* Create a way back */
482 if (have_flag(f_ptr->flags, FF_SHAFT))
484 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
488 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN);
494 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
497 void do_cmd_search(player_type * creature_ptr)
499 /* Allow repeated command */
502 /* Set repeat count */
503 command_rep = command_arg - 1;
504 creature_ptr->redraw |= (PR_STATE);
510 take_turn(creature_ptr, 100);
511 search(creature_ptr);
516 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
517 * @param y 走査対象にしたいマスのY座標
518 * @param x 走査対象にしたいマスのX座標
519 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
520 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
522 static OBJECT_IDX chest_check(floor_type *floor_ptr, POSITION y, POSITION x, bool trapped)
524 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
525 OBJECT_IDX this_o_idx, next_o_idx = 0;
527 /* Scan all objects in the grid */
528 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
532 o_ptr = &floor_ptr->o_list[this_o_idx];
533 next_o_idx = o_ptr->next_o_idx;
535 /* Skip unknown chests XXX XXX */
536 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
538 /* Check for non empty chest */
539 if ((o_ptr->tval == TV_CHEST) &&
540 (((!trapped) && (o_ptr->pval)) || /* non empty */
541 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
552 * Attempt to open the given chest at the given location
553 * @param y 箱の存在するマスのY座標
554 * @param x 箱の存在するマスのX座標
555 * @param o_idx 箱のオブジェクトID
556 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
558 * Assume there is no monster blocking the destination
560 static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
564 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
566 take_turn(creature_ptr, 100);
568 /* Attempt to unlock it */
571 /* Assume locked, and thus not open */
574 /* Get the "disarm" factor */
575 int i = creature_ptr->skill_dis;
577 /* Penalize some conditions */
578 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
579 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
581 /* Extract the difficulty */
582 int j = i - o_ptr->pval;
584 /* Always have a small chance of success */
587 /* Success -- May still have traps */
588 if (randint0(100) < j)
590 msg_print(_("鍵をはずした。", "You have picked the lock."));
591 gain_exp(creature_ptr, 1);
595 /* Failure -- Keep trying */
598 /* We may continue repeating */
600 if (flush_failure) flush();
601 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
606 /* Allowed to open */
609 /* Apply chest traps, if any */
610 chest_trap(creature_ptr, y, x, o_idx);
612 /* Let the Chest drop items */
613 chest_death(creature_ptr, FALSE, y, x, o_idx);
620 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
621 * Attempt to open the given chest at the given location
622 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
623 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
624 * @param test 地形条件を判定するための関数ポインタ
625 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
627 * @details Return the number of features around (or under) the character.
628 * Usually look for doors and floor traps.
630 static int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(player_type*, FEAT_IDX feat), bool under)
632 /* Check around (and under) the character */
634 for (DIRECTION d = 0; d < 9; d++)
639 /* if not searching under player continue */
640 if ((d == 8) && !under) continue;
642 /* Extract adjacent (legal) location */
643 POSITION yy = creature_ptr->y + ddy_ddd[d];
644 POSITION xx = creature_ptr->x + ddx_ddd[d];
646 /* Get the creature_ptr->current_floor_ptr->grid_array */
647 g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
649 /* Must have knowledge */
650 if (!(g_ptr->info & (CAVE_MARK))) continue;
652 /* Feature code (applying "mimic" field) */
653 feat = get_feat_mimic(g_ptr);
655 /* Not looking for this feature */
656 if (!((*test)(creature_ptr, feat))) continue;
661 /* Remember the location. Only useful if only one match */
672 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
673 * Return the number of chests around (or under) the character.
674 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
675 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
676 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
679 * If requested, count only trapped chests.
681 static int count_chests(player_type *creature_ptr, POSITION *y, POSITION *x, bool trapped)
683 /* Check around (and under) the character */
685 for (DIRECTION d = 0; d < 9; d++)
687 /* Extract adjacent (legal) location */
688 POSITION yy = creature_ptr->y + ddy_ddd[d];
689 POSITION xx = creature_ptr->x + ddx_ddd[d];
691 /* No (visible) chest is there */
692 OBJECT_IDX o_idx = chest_check(creature_ptr->current_floor_ptr, yy, xx, FALSE);
693 if (!o_idx) continue;
695 /* Grab the object */
697 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
700 if (o_ptr->pval == 0) continue;
702 /* No (known) traps here */
703 if (trapped && (!object_is_known(o_ptr) ||
704 !chest_traps[o_ptr->pval])) continue;
709 /* Remember the location. Only useful if only one match */
721 * @brief 「開ける」動作コマンドのサブルーチン /
722 * Perform the basic "open" command on doors
723 * @param y 対象を行うマスのY座標
724 * @param x 対象を行うマスのX座標
725 * @return 実際に処理が行われた場合TRUEを返す。
727 * Assume destination is a closed/locked/jammed door
728 * Assume there is no monster blocking the destination
729 * Returns TRUE if repeated commands may continue
731 static bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
733 /* Get requested grid */
734 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
735 feature_type *f_ptr = &f_info[g_ptr->feat];
738 take_turn(creature_ptr, 100);
740 /* Seeing true feature code (ignore mimic) */
743 if (!have_flag(f_ptr->flags, FF_OPEN))
746 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
752 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
753 sound(SOUND_OPENDOOR);
758 int i = creature_ptr->skill_dis;
760 /* Penalize some conditions */
761 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
762 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
764 /* Extract the difficulty */
765 int j = f_ptr->power;
768 /* Always have a small chance of success */
771 if (randint0(100) >= j)
773 if (flush_failure) flush();
774 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
778 msg_print(_("鍵をはずした。", "You have picked the lock."));
781 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
783 sound(SOUND_OPENDOOR);
786 gain_exp(creature_ptr, 1);
791 * @brief 「開ける」コマンドのメインルーチン /
792 * Open a closed/locked/jammed door or a closed/locked chest.
795 * Unlocking a locked door/chest is worth one experience point.
797 void do_cmd_open(player_type *creature_ptr)
805 if (creature_ptr->wild_mode) return;
807 if (creature_ptr->special_defense & KATA_MUSOU)
809 set_action(creature_ptr, ACTION_NONE);
812 /* Option: Pick a direction */
815 int num_doors, num_chests;
817 num_doors = count_dt(creature_ptr, &y, &x, is_closed_door, FALSE);
818 num_chests = count_chests(creature_ptr, &y, &x, FALSE);
819 if (num_doors || num_chests)
821 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
823 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
827 /* Allow repeated command */
830 /* Set repeat count */
831 command_rep = command_arg - 1;
832 creature_ptr->redraw |= (PR_STATE);
838 /* Get a "repeated" direction */
839 if (get_rep_dir(creature_ptr, &dir, TRUE))
844 /* Get requested location */
845 y = creature_ptr->y + ddy[dir];
846 x = creature_ptr->x + ddx[dir];
848 /* Get requested grid */
849 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
851 /* Feature code (applying "mimic" field) */
852 feat = get_feat_mimic(g_ptr);
854 /* Check for chest */
855 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, FALSE);
857 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
859 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
861 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
863 take_turn(creature_ptr, 100);
864 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
865 do_cmd_attack(creature_ptr, y, x, 0);
869 more = exe_open_chest(creature_ptr, y, x, o_idx);
873 more = exe_open(creature_ptr, y, x);
877 /* Cancel repeat unless we may continue */
878 if (!more) disturb(creature_ptr, FALSE, FALSE);
885 * @brief 「閉じる」動作コマンドのサブルーチン /
886 * Perform the basic "close" command
887 * @param y 対象を行うマスのY座標
888 * @param x 対象を行うマスのX座標
889 * @return 実際に処理が行われた場合TRUEを返す。
891 * Assume destination is an open/broken door
892 * Assume there is no monster blocking the destination
893 * Returns TRUE if repeated commands may continue
895 static bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
897 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
898 FEAT_IDX old_feat = g_ptr->feat;
901 take_turn(creature_ptr, 100);
903 /* Seeing true feature code (ignore mimic) */
906 if (!have_flag(f_info[old_feat].flags, FF_CLOSE))
911 s16b closed_feat = feat_state(creature_ptr, old_feat, FF_CLOSE);
913 /* Hack -- object in the way */
914 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
915 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
917 msg_print(_("何かがつっかえて閉まらない。", "Something prevents it from closing."));
922 cave_alter_feat(creature_ptr, y, x, FF_CLOSE);
925 if (old_feat == g_ptr->feat)
927 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
931 sound(SOUND_SHUTDOOR);
940 * @brief 「閉じる」コマンドのメインルーチン /
941 * Close an open door.
944 * Unlocking a locked door/chest is worth one experience point.
946 void do_cmd_close(player_type *creature_ptr)
953 if (creature_ptr->wild_mode) return;
955 if (creature_ptr->special_defense & KATA_MUSOU)
957 set_action(creature_ptr, ACTION_NONE);
960 /* Option: Pick a direction */
963 /* Count open doors */
964 if (count_dt(creature_ptr, &y, &x, is_open, FALSE) == 1)
966 command_dir = coords_to_dir(creature_ptr, y, x);
970 /* Allow repeated command */
973 /* Set repeat count */
974 command_rep = command_arg - 1;
975 creature_ptr->redraw |= (PR_STATE);
981 /* Get a "repeated" direction */
982 if (get_rep_dir(creature_ptr, &dir, FALSE))
987 y = creature_ptr->y + ddy[dir];
988 x = creature_ptr->x + ddx[dir];
989 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
991 /* Feature code (applying "mimic" field) */
992 feat = get_feat_mimic(g_ptr);
994 /* Require open/broken door */
995 if (!have_flag(f_info[feat].flags, FF_CLOSE))
997 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1000 /* Monster in the way */
1001 else if (g_ptr->m_idx)
1003 take_turn(creature_ptr, 100);
1005 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1008 do_cmd_attack(creature_ptr, y, x, 0);
1011 /* Close the door */
1014 /* Close the door */
1015 more = exe_close(creature_ptr, y, x);
1019 /* Cancel repeat unless we may continue */
1020 if (!more) disturb(creature_ptr, FALSE, FALSE);
1025 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1026 * Determine if a given grid may be "tunneled"
1027 * @param y 対象を行うマスのY座標
1028 * @param x 対象を行うマスのX座標
1031 static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
1033 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1035 /* Must have knowledge */
1036 if (!(g_ptr->info & CAVE_MARK))
1038 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1043 /* Must be a wall/door/etc */
1044 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1046 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1056 * @brief 「掘る」動作コマンドのサブルーチン /
1057 * Perform the basic "tunnel" command
1058 * @param y 対象を行うマスのY座標
1059 * @param x 対象を行うマスのX座標
1060 * @return 実際に処理が行われた場合TRUEを返す。
1062 * Assumes that no monster is blocking the destination
1063 * Do not use twall anymore
1064 * Returns TRUE if repeated commands may continue
1066 static bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
1069 feature_type *f_ptr, *mimic_f_ptr;
1074 /* Verify legality */
1075 if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x)) return FALSE;
1077 take_turn(creature_ptr, 100);
1079 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1080 f_ptr = &f_info[g_ptr->feat];
1081 power = f_ptr->power;
1083 /* Feature code (applying "mimic" field) */
1084 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1086 name = f_name + mimic_f_ptr->name;
1090 if (have_flag(f_ptr->flags, FF_PERMANENT))
1093 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1095 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1098 /* Map border (mimiccing Permanent wall) */
1101 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1106 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1109 if (creature_ptr->skill_dig > randint0(20 * power))
1111 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1113 /* Remove the feature */
1114 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1115 creature_ptr->update |= (PU_FLOW);
1119 /* Message, keep digging */
1120 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1128 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1131 if (creature_ptr->skill_dig > power + randint0(40 * power))
1133 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1136 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1137 creature_ptr->update |= (PU_FLOW);
1140 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1142 /* Remove the feature */
1143 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1145 chg_virtue(creature_ptr, V_DILIGENCE, 1);
1146 chg_virtue(creature_ptr, V_NATURE, -1);
1154 /* We may continue chopping */
1155 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1156 /* Occasional Search XXX XXX */
1157 if (randint0(100) < 25) search(creature_ptr);
1161 /* We may continue tunelling */
1162 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1169 if (is_hidden_door(creature_ptr, g_ptr))
1171 /* Occasional Search XXX XXX */
1172 if (randint0(100) < 25) search(creature_ptr);
1180 * @brief 「掘る」動作コマンドのメインルーチン /
1181 * Tunnels through "walls" (including rubble and closed doors)
1185 * Note that you must tunnel in order to hit invisible monsters
1186 * in walls, though moving into walls still takes a turn anyway.
1188 * Digging is very difficult without a "digger" weapon, but can be
1189 * accomplished by strong players using heavy weapons.
1192 void do_cmd_tunnel(player_type *creature_ptr)
1201 if (creature_ptr->special_defense & KATA_MUSOU)
1203 set_action(creature_ptr, ACTION_NONE);
1206 /* Allow repeated command */
1209 /* Set repeat count */
1210 command_rep = command_arg - 1;
1211 creature_ptr->redraw |= (PR_STATE);
1213 /* Cancel the arg */
1217 /* Get a direction to tunnel, or Abort */
1218 if (get_rep_dir(creature_ptr, &dir,FALSE))
1221 y = creature_ptr->y + ddy[dir];
1222 x = creature_ptr->x + ddx[dir];
1224 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1226 /* Feature code (applying "mimic" field) */
1227 feat = get_feat_mimic(g_ptr);
1229 /* No tunnelling through doors */
1230 if (have_flag(f_info[feat].flags, FF_DOOR))
1232 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1235 /* No tunnelling through most features */
1236 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1238 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1241 /* A monster is in the way */
1242 else if (g_ptr->m_idx)
1244 take_turn(creature_ptr, 100);
1245 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1248 do_cmd_attack(creature_ptr, y, x, 0);
1254 /* Tunnel through walls */
1255 more = exe_tunnel(creature_ptr, y, x);
1259 /* Cancel repetition unless we can continue */
1260 if (!more) disturb(creature_ptr, FALSE, FALSE);
1264 * @brief 移動処理による簡易な「開く」処理 /
1266 * @return 開く処理が実際に試みられた場合TRUEを返す
1269 * If there is a jammed/closed/locked door at the given location,
1270 * then attempt to unlock/open it. Return TRUE if an attempt was
1271 * made (successful or not), otherwise return FALSE.
1273 * The code here should be nearly identical to that in
1274 * do_cmd_open_test() and exe_open().
1277 bool easy_open_door(player_type *creature_ptr, POSITION y, POSITION x)
1281 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1282 feature_type *f_ptr = &f_info[g_ptr->feat];
1284 /* Must be a closed door */
1285 if (!is_closed_door(creature_ptr, g_ptr->feat))
1291 if (!have_flag(f_ptr->flags, FF_OPEN))
1294 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1299 else if (f_ptr->power)
1302 i = creature_ptr->skill_dis;
1304 /* Penalize some conditions */
1305 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1306 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1308 /* Extract the lock power */
1311 /* Extract the difficulty */
1314 /* Always have a small chance of success */
1318 if (randint0(100) < j)
1320 msg_print(_("鍵をはずした。", "You have picked the lock."));
1323 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1325 sound(SOUND_OPENDOOR);
1328 gain_exp(creature_ptr, 1);
1335 if (flush_failure) flush();
1337 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1346 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1348 sound(SOUND_OPENDOOR);
1355 * @brief 箱のトラップを解除する実行処理 /
1356 * Perform the basic "disarm" command
1357 * @param y 解除を行うマスのY座標
1358 * @param x 解除を行うマスのX座標
1359 * @param o_idx 箱のオブジェクトID
1360 * @return ターンを消費する処理が行われた場合TRUEを返す
1363 * Assume destination is a visible trap
1364 * Assume there is no monster blocking the destination
1365 * Returns TRUE if repeated commands may continue
1368 static bool exe_disarm_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
1372 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
1374 take_turn(creature_ptr, 100);
1376 /* Get the "disarm" factor */
1377 i = creature_ptr->skill_dis;
1379 /* Penalize some conditions */
1380 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1381 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1383 /* Extract the difficulty */
1384 j = i - o_ptr->pval;
1386 /* Always have a small chance of success */
1389 /* Must find the trap first. */
1390 if (!object_is_known(o_ptr))
1392 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1396 /* Already disarmed/unlocked */
1397 else if (o_ptr->pval <= 0)
1399 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1402 /* No traps to find. */
1403 else if (!chest_traps[o_ptr->pval])
1405 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1408 /* Success (get a lot of experience) */
1409 else if (randint0(100) < j)
1411 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1412 gain_exp(creature_ptr, o_ptr->pval);
1413 o_ptr->pval = (0 - o_ptr->pval);
1416 /* Failure -- Keep trying */
1417 else if ((i > 5) && (randint1(i) > 5))
1419 /* We may keep trying */
1421 if (flush_failure) flush();
1422 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1425 /* Failure -- Set off the trap */
1428 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1430 chest_trap(creature_ptr, y, x, o_idx);
1438 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1439 * Perform the basic "disarm" command
1440 * @param y 解除を行うマスのY座標
1441 * @param x 解除を行うマスのX座標
1442 * @param dir プレイヤーからみた方向ID
1443 * @return ターンを消費する処理が行われた場合TRUEを返す
1446 * Assume destination is a visible trap
1447 * Assume there is no monster blocking the destination
1448 * Returns TRUE if repeated commands may continue
1452 bool exe_disarm(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1454 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1457 feature_type *f_ptr = &f_info[g_ptr->feat];
1459 /* Access trap name */
1460 concptr name = (f_name + f_ptr->name);
1462 /* Extract trap "power" */
1463 int power = f_ptr->power;
1466 /* Get the "disarm" factor */
1467 int i = creature_ptr->skill_dis;
1470 take_turn(creature_ptr, 100);
1472 /* Penalize some conditions */
1473 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1474 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1476 /* Extract the difficulty */
1479 /* Always have a small chance of success */
1483 if (randint0(100) < j)
1485 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1488 gain_exp(creature_ptr, power);
1490 /* Remove the trap */
1491 cave_alter_feat(creature_ptr, y, x, FF_DISARM);
1493 /* Move the player onto the trap */
1494 move_player(creature_ptr, dir, easy_disarm, FALSE);
1497 /* Failure -- Keep trying */
1498 else if ((i > 5) && (randint1(i) > 5))
1501 if (flush_failure) flush();
1503 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1505 /* We may keep trying */
1509 /* Failure -- Set off the trap */
1512 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1513 /* Move the player onto the trap */
1514 move_player(creature_ptr, dir, easy_disarm, FALSE);
1522 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1523 * Disarms a trap, or chest
1526 void do_cmd_disarm(player_type *creature_ptr)
1534 if (creature_ptr->wild_mode) return;
1536 if (creature_ptr->special_defense & KATA_MUSOU)
1538 set_action(creature_ptr, ACTION_NONE);
1541 /* Option: Pick a direction */
1544 int num_traps, num_chests;
1546 /* Count visible traps */
1547 num_traps = count_dt(creature_ptr, &y, &x, is_trap, TRUE);
1549 /* Count chests (trapped) */
1550 num_chests = count_chests(creature_ptr, &y, &x, TRUE);
1552 /* See if only one target */
1553 if (num_traps || num_chests)
1555 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1556 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
1560 /* Allow repeated command */
1563 /* Set repeat count */
1564 command_rep = command_arg - 1;
1565 creature_ptr->redraw |= (PR_STATE);
1567 /* Cancel the arg */
1571 /* Get a direction (or abort) */
1572 if (get_rep_dir(creature_ptr, &dir,TRUE))
1577 y = creature_ptr->y + ddy[dir];
1578 x = creature_ptr->x + ddx[dir];
1579 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1581 /* Feature code (applying "mimic" field) */
1582 feat = get_feat_mimic(g_ptr);
1584 /* Check for chests */
1585 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, TRUE);
1588 if (!is_trap(creature_ptr, feat) && !o_idx)
1590 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1593 /* Monster in the way */
1594 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
1596 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1599 do_cmd_attack(creature_ptr, y, x, 0);
1605 more = exe_disarm_chest(creature_ptr, y, x, o_idx);
1611 more = exe_disarm(creature_ptr, y, x, dir);
1615 /* Cancel repeat unless told not to */
1616 if (!more) disturb(creature_ptr, FALSE, FALSE);
1621 * @brief 「打ち破る」動作コマンドのサブルーチン /
1622 * Perform the basic "bash" command
1623 * @param y 対象を行うマスのY座標
1624 * @param x 対象を行うマスのX座標
1625 * @param dir プレイヤーから見たターゲットの方角ID
1626 * @return 実際に処理が行われた場合TRUEを返す。
1629 * Assume destination is a closed/locked/jammed door
1630 * Assume there is no monster blocking the destination
1631 * Returns TRUE if repeated commands may continue
1634 static bool do_cmd_bash_aux(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1636 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1639 feature_type *f_ptr = &f_info[g_ptr->feat];
1641 /* Hack -- Bash power based on strength */
1642 /* (Ranges from 3 to 20 to 100 to 200) */
1643 int bash = adj_str_blow[creature_ptr->stat_ind[A_STR]];
1645 /* Extract door power */
1646 int temp = f_ptr->power;
1650 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1652 take_turn(creature_ptr, 100);
1654 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1656 /* Compare bash power to door power */
1657 temp = (bash - (temp * 10));
1659 if (creature_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1661 /* Hack -- always have a chance */
1662 if (temp < 1) temp = 1;
1664 /* Hack -- attempt to bash down the door */
1665 if (randint0(100) < temp)
1667 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1669 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1671 /* Break down the door */
1672 if ((randint0(100) < 50) || (feat_state(creature_ptr, g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1674 cave_alter_feat(creature_ptr, y, x, FF_BASH);
1680 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1683 /* Hack -- Fall through the door */
1684 move_player(creature_ptr, dir, FALSE, FALSE);
1687 /* Saving throw against stun */
1688 else if (randint0(100) < adj_dex_safe[creature_ptr->stat_ind[A_DEX]] +
1691 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1693 /* Allow repeated bashing */
1697 /* High dexterity yields coolness */
1700 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1702 /* Hack -- Lose balance ala paralysis */
1703 (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 2 + randint0(2));
1711 * @brief 「打ち破る」動作コマンドのメインルーチン /
1712 * Bash open a door, success based on character strength
1716 * For a closed door, pval is positive if locked; negative if stuck.
1718 * For an open door, pval is positive for a broken door.
1720 * A closed door can be opened - harder if locked. Any door might be
1721 * bashed open (and thereby broken). Bashing a door is (potentially)
1722 * faster! You move into the door way. To open a stuck door, it must
1723 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1725 * Creatures can also open or bash doors, see elsewhere.
1728 void do_cmd_bash(player_type *creature_ptr)
1735 if (creature_ptr->wild_mode) return;
1737 if (creature_ptr->special_defense & KATA_MUSOU)
1739 set_action(creature_ptr, ACTION_NONE);
1742 /* Allow repeated command */
1745 /* Set repeat count */
1746 command_rep = command_arg - 1;
1747 creature_ptr->redraw |= (PR_STATE);
1749 /* Cancel the arg */
1753 /* Get a "repeated" direction */
1754 if (get_rep_dir(creature_ptr, &dir,FALSE))
1759 y = creature_ptr->y + ddy[dir];
1760 x = creature_ptr->x + ddx[dir];
1762 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1764 /* Feature code (applying "mimic" field) */
1765 feat = get_feat_mimic(g_ptr);
1767 /* Nothing useful */
1768 if (!have_flag(f_info[feat].flags, FF_BASH))
1770 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1773 /* Monster in the way */
1774 else if (g_ptr->m_idx)
1776 take_turn(creature_ptr, 100);
1778 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1781 do_cmd_attack(creature_ptr, y, x, 0);
1784 /* Bash a closed door */
1788 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1792 /* Unless valid action taken, cancel bash */
1793 if (!more) disturb(creature_ptr, FALSE, FALSE);
1798 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1802 * Manipulate an adjacent grid in some way
1804 * Attack monsters, tunnel through walls, disarm traps, open doors.
1806 * Consider confusion
1808 * This command must always take a turn, to prevent free detection
1809 * of invisible monsters.
1812 void do_cmd_alter(player_type *creature_ptr)
1819 if (creature_ptr->special_defense & KATA_MUSOU)
1821 set_action(creature_ptr, ACTION_NONE);
1824 /* Allow repeated command */
1827 /* Set repeat count */
1828 command_rep = command_arg - 1;
1829 creature_ptr->redraw |= (PR_STATE);
1831 /* Cancel the arg */
1835 /* Get a direction */
1836 if (get_rep_dir(creature_ptr, &dir,TRUE))
1839 feature_type *f_ptr;
1841 y = creature_ptr->y + ddy[dir];
1842 x = creature_ptr->x + ddx[dir];
1844 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1846 /* Feature code (applying "mimic" field) */
1847 feat = get_feat_mimic(g_ptr);
1848 f_ptr = &f_info[feat];
1850 take_turn(creature_ptr, 100);
1854 do_cmd_attack(creature_ptr, y, x, 0);
1858 else if (have_flag(f_ptr->flags, FF_OPEN))
1860 more = exe_open(creature_ptr, y, x);
1863 /* Bash jammed doors */
1864 else if (have_flag(f_ptr->flags, FF_BASH))
1866 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1869 /* Tunnel through walls */
1870 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1872 more = exe_tunnel(creature_ptr, y, x);
1875 /* Close open doors */
1876 else if (have_flag(f_ptr->flags, FF_CLOSE))
1878 more = exe_close(creature_ptr, y, x);
1882 else if (have_flag(f_ptr->flags, FF_DISARM))
1884 more = exe_disarm(creature_ptr, y, x, dir);
1889 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1893 /* Cancel repetition unless we can continue */
1894 if (!more) disturb(creature_ptr, FALSE, FALSE);
1900 * @brief 「くさびを打つ」ために必要なオブジェクトを所持しているかどうかの判定を返す /
1901 * Find the index of some "spikes", if possible.
1902 * @param ip くさびとして打てるオブジェクトのID
1903 * @return オブジェクトがある場合TRUEを返す
1906 * Let user choose a pile of spikes, perhaps?
1909 static bool get_spike(player_type *creature_ptr, INVENTORY_IDX *ip)
1913 /* Check every item in the pack */
1914 for (i = 0; i < INVEN_PACK; i++)
1916 object_type *o_ptr = &creature_ptr->inventory_list[i];
1917 if (!o_ptr->k_idx) continue;
1919 /* Check the "tval" code */
1920 if (o_ptr->tval == TV_SPIKE)
1922 /* Save the spike index */
1935 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1936 * Jam a closed door with a spike
1937 * @param creature_ptr プレーヤーへの参照ポインタ
1941 * This command may NOT be repeated
1944 void do_cmd_spike(player_type *creature_ptr)
1948 if (creature_ptr->wild_mode) return;
1949 if (creature_ptr->special_defense & KATA_MUSOU)
1951 set_action(creature_ptr, ACTION_NONE);
1954 /* Get a "repeated" direction */
1955 if (!get_rep_dir(creature_ptr, &dir, FALSE)) return;
1957 POSITION y = creature_ptr->y + ddy[dir];
1958 POSITION x = creature_ptr->x + ddx[dir];
1960 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1962 /* Feature code (applying "mimic" field) */
1963 FEAT_IDX feat = get_feat_mimic(g_ptr);
1965 /* Require closed door */
1967 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1969 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1973 else if (!get_spike(creature_ptr, &item))
1975 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1978 /* Is a monster in the way? */
1979 else if (g_ptr->m_idx)
1981 take_turn(creature_ptr, 100);
1983 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1986 do_cmd_attack(creature_ptr, y, x, 0);
1992 take_turn(creature_ptr, 100);
1994 /* Successful jamming */
1995 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1996 cave_alter_feat(creature_ptr, y, x, FF_SPIKE);
1998 vary_item(creature_ptr, item, -1);
2004 * @brief 「歩く」動作コマンドのメインルーチン /
2005 * Support code for the "Walk" and "Jump" commands
2006 * @param creature_ptr プレーヤーへの参照ポインタ
2007 * @param pickup アイテムの自動拾いを行うならTRUE
2010 void do_cmd_walk(player_type *creature_ptr, bool pickup)
2012 /* Allow repeated command */
2015 /* Set repeat count */
2016 command_rep = command_arg - 1;
2017 creature_ptr->redraw |= (PR_STATE);
2019 /* Cancel the arg */
2023 /* Get a "repeated" direction */
2026 if (get_rep_dir(creature_ptr, &dir, FALSE))
2028 take_turn(creature_ptr, 100);
2030 if ((dir != 5) && (creature_ptr->special_defense & KATA_MUSOU))
2032 set_action(creature_ptr, ACTION_NONE);
2035 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2036 if (creature_ptr->wild_mode) creature_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2037 if (creature_ptr->action == ACTION_HAYAGAKE) creature_ptr->energy_use = creature_ptr->energy_use * (45-(creature_ptr->lev/2)) / 100;
2039 /* Actually move the character */
2040 move_player(creature_ptr, dir, pickup, FALSE);
2042 /* Allow more walking */
2046 /* Hack again -- Is there a special encounter ??? */
2047 if (creature_ptr->wild_mode && !cave_have_flag_bold(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, FF_TOWN))
2049 int tmp = 120 + creature_ptr->lev*10 - wilderness[creature_ptr->y][creature_ptr->x].level + 5;
2052 if (((wilderness[creature_ptr->y][creature_ptr->x].level + 5) > (creature_ptr->lev / 2)) && randint0(tmp) < (21-creature_ptr->skill_stl))
2054 /* Inform the player of his horrible fate :=) */
2055 msg_print(_("襲撃だ!", "You are ambushed !"));
2057 /* Go into large wilderness view */
2058 creature_ptr->oldpy = randint1(MAX_HGT-2);
2059 creature_ptr->oldpx = randint1(MAX_WID-2);
2060 change_wild_mode(creature_ptr, TRUE);
2062 /* Give first move to monsters */
2063 take_turn(creature_ptr, 100);
2068 /* Cancel repeat unless we may continue */
2069 if (!more) disturb(creature_ptr, FALSE, FALSE);
2074 * @brief 「走る」動作コマンドのメインルーチン /
2076 * @param creature_ptr プレーヤーへの参照ポインタ
2079 void do_cmd_run(player_type *creature_ptr)
2082 if (cmd_limit_confused(creature_ptr)) return;
2084 if (creature_ptr->special_defense & KATA_MUSOU)
2086 set_action(creature_ptr, ACTION_NONE);
2089 /* Get a "repeated" direction */
2090 if (get_rep_dir(creature_ptr, &dir,FALSE))
2092 /* Hack -- Set the run counter */
2093 creature_ptr->running = (command_arg ? command_arg : 1000);
2096 run_step(creature_ptr, dir);
2102 * @brief 「留まる」動作コマンドのメインルーチン /
2103 * Stay still. Search. Enter stores.
2104 * Pick up treasure if "pickup" is true.
2105 * @param creature_ptr プレーヤーへの参照ポインタ
2106 * @param pickup アイテムの自動拾いを行うならTRUE
2109 void do_cmd_stay(player_type *creature_ptr, bool pickup)
2111 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2113 /* Allow repeated command */
2116 /* Set repeat count */
2117 command_rep = command_arg - 1;
2118 creature_ptr->redraw |= (PR_STATE);
2120 /* Cancel the arg */
2124 take_turn(creature_ptr, 100);
2126 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2127 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, mpe_mode);
2132 * @brief 「休む」動作コマンドのメインルーチン /
2133 * Resting allows a player to safely restore his hp -RAK-
2134 * @param creature_ptr プレーヤーへの参照ポインタ
2137 void do_cmd_rest(player_type *creature_ptr)
2139 set_action(creature_ptr, ACTION_NONE);
2141 if ((creature_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(creature_ptr) || INTERUPTING_SONG_EFFECT(creature_ptr)))
2143 stop_singing(creature_ptr);
2146 if (hex_spelling_any(creature_ptr)) stop_hex_spell_all(creature_ptr);
2148 /* Prompt for time if needed */
2149 if (command_arg <= 0)
2151 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2152 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2157 strcpy(out_val, "&");
2159 /* Ask for duration */
2160 if (!get_string(p, out_val, 4)) return;
2162 /* Rest until done */
2163 if (out_val[0] == '&')
2165 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2169 else if (out_val[0] == '*')
2171 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2177 command_arg = (COMMAND_ARG)atoi(out_val);
2178 if (command_arg <= 0) return;
2182 if (command_arg > 9999) command_arg = 9999;
2184 if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE);
2186 /* Take a turn (?) */
2187 take_turn(creature_ptr, 100);
2189 /* The sin of sloth */
2190 if (command_arg > 100) chg_virtue(creature_ptr, V_DILIGENCE, -1);
2192 /* Why are you sleeping when there's no need? WAKE UP!*/
2193 if ((creature_ptr->chp == creature_ptr->mhp) &&
2194 (creature_ptr->csp == creature_ptr->msp) &&
2195 !creature_ptr->blind && !creature_ptr->confused &&
2196 !creature_ptr->poisoned && !creature_ptr->afraid &&
2197 !creature_ptr->stun && !creature_ptr->cut &&
2198 !creature_ptr->slow && !creature_ptr->paralyzed &&
2199 !creature_ptr->image && !creature_ptr->word_recall &&
2200 !creature_ptr->alter_reality)
2201 chg_virtue(creature_ptr, V_DILIGENCE, -1);
2203 /* Save the rest code */
2204 creature_ptr->resting = command_arg;
2205 creature_ptr->action = ACTION_REST;
2206 creature_ptr->update |= (PU_BONUS);
2207 update_creature(creature_ptr);
2209 creature_ptr->redraw |= (PR_STATE);
2210 update_output(creature_ptr);
2219 * @brief 射撃処理のメインルーチン
2220 * @param creature_ptr プレーヤーへの参照ポインタ
2221 * @param snipe_type ???
2224 void do_cmd_fire(player_type *creature_ptr, SPELL_IDX snipe_type)
2227 object_type *j_ptr, *ammo_ptr;
2230 if(creature_ptr->wild_mode) return;
2232 creature_ptr->is_fired = FALSE; /* not fired yet */
2234 /* Get the "bow" (if any) */
2235 j_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2237 /* Require a launcher */
2240 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2245 if (j_ptr->sval == SV_CRIMSON)
2247 msg_print(_("この武器は発動して使うもののようだ。", "It's already activated."));
2252 if (j_ptr->sval == SV_HARP)
2254 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2260 if (creature_ptr->special_defense & KATA_MUSOU)
2262 set_action(creature_ptr, ACTION_NONE);
2265 q = _("どれを撃ちますか? ", "Fire which item? ");
2266 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2268 ammo_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), creature_ptr->tval_ammo);
2276 exe_fire(creature_ptr, item, j_ptr, snipe_type);
2278 if (!creature_ptr->is_fired || creature_ptr->pclass != CLASS_SNIPER) return;
2280 /* Sniper actions after some shootings */
2281 if (snipe_type == SP_AWAY)
2283 teleport_player(creature_ptr, 10 + (creature_ptr->concent * 2), TELEPORT_SPONTANEOUS);
2286 if (snipe_type == SP_FINAL)
2288 msg_print(_("射撃の反動が体を襲った。", "The weapon's recoil stuns you. "));
2289 (void)set_slow(creature_ptr, creature_ptr->slow + randint0(7) + 7, FALSE);
2290 (void)set_stun(creature_ptr, creature_ptr->stun + randint1(25));
2296 * @brief 投射処理メインルーチン /
2297 * Throw an object from the pack or floor.
2299 * @param creature_ptr プレーヤーへの参照ポインタ
2300 * @param boomerang ブーメラン処理ならばTRUE
2301 * @param shuriken 忍者の手裏剣処理ならばTRUE
2302 * @return ターンを消費した場合TRUEを返す
2305 * Note: "unseen" monsters are very hard to hit.
2307 * Should throwing a weapon do full damage? Should it allow the magic
2308 * to hit bonus of the weapon to have an effect? Should it ever cause
2309 * the item to be destroyed? Should it do any damage at all?
2312 bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_IDX shuriken)
2317 POSITION y, x, ty, tx, prev_y, prev_x;
2318 POSITION ny[19], nx[19];
2319 int chance, tdam, tdis;
2320 int mul, div, dd, ds;
2321 int cur_dis, visible;
2328 bool hit_body = FALSE;
2329 bool hit_wall = FALSE;
2330 bool equiped_item = FALSE;
2331 bool return_when_thrown = FALSE;
2333 GAME_TEXT o_name[MAX_NLEN];
2335 int msec = delay_factor * delay_factor * delay_factor;
2337 BIT_FLAGS flgs[TR_FLAG_SIZE];
2339 bool come_back = FALSE;
2340 bool do_drop = TRUE;
2342 if (creature_ptr->wild_mode) return FALSE;
2344 if (creature_ptr->special_defense & KATA_MUSOU)
2346 set_action(creature_ptr, ACTION_NONE);
2352 o_ptr = &creature_ptr->inventory_list[item];
2356 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2358 item_tester_hook = item_tester_hook_boomerang;
2359 q = _("どの武器を投げますか? ", "Throw which item? ");
2360 s = _("投げる武器がない。", "You have nothing to throw.");
2361 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP), 0);
2368 else if (has_melee_weapon(creature_ptr, INVEN_LARM))
2371 o_ptr = &creature_ptr->inventory_list[item];
2376 o_ptr = &creature_ptr->inventory_list[item];
2381 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2382 s = _("投げるアイテムがない。", "You have nothing to throw.");
2383 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP), 0);
2391 /* Item is cursed */
2392 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2394 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2398 if (creature_ptr->current_floor_ptr->inside_arena && !boomerang)
2400 if (o_ptr->tval != TV_SPIKE)
2402 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2410 object_copy(q_ptr, o_ptr);
2412 /* Extract the thrown object's flags. */
2413 object_flags(q_ptr, flgs);
2414 torch_flags(q_ptr, flgs);
2416 /* Distribute the charges of rods/wands between the stacks */
2417 distribute_charges(o_ptr, q_ptr, 1);
2422 object_desc(creature_ptr, o_name, q_ptr, OD_OMIT_PREFIX);
2424 if (creature_ptr->mighty_throw) mult += 3;
2426 /* Extract a "distance multiplier" */
2427 /* Changed for 'launcher' mutation */
2428 mul = 10 + 2 * (mult - 1);
2430 /* Enforce a minimum "weight" of one pound */
2431 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2432 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2434 /* Hack -- Distance -- Reward strength, penalize weight */
2435 tdis = (adj_str_blow[creature_ptr->stat_ind[A_STR]] + 20) * mul / div;
2437 /* Max distance of 10-18 */
2438 if (tdis > mul) tdis = mul;
2442 ty = randint0(101) - 50 + creature_ptr->y;
2443 tx = randint0(101) - 50 + creature_ptr->x;
2447 project_length = tdis + 1;
2449 /* Get a direction (or cancel) */
2450 if (!get_aim_dir(creature_ptr, &dir)) return FALSE;
2452 /* Predict the "target" location */
2453 tx = creature_ptr->x + 99 * ddx[dir];
2454 ty = creature_ptr->y + 99 * ddy[dir];
2456 /* Check for "target request" */
2457 if ((dir == 5) && target_okay(creature_ptr))
2463 project_length = 0; /* reset to default */
2466 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2467 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2468 return_when_thrown = TRUE;
2472 inven_item_increase(creature_ptr, item, -1);
2473 if (!return_when_thrown)
2474 inven_item_describe(creature_ptr, item);
2475 inven_item_optimize(creature_ptr, item);
2479 floor_item_increase(creature_ptr->current_floor_ptr, 0 - item, -1);
2480 floor_item_optimize(creature_ptr, 0 - item);
2483 if (item >= INVEN_RARM)
2485 equiped_item = TRUE;
2486 creature_ptr->redraw |= (PR_EQUIPPY);
2489 take_turn(creature_ptr, 100);
2491 /* Rogue and Ninja gets bonus */
2492 if ((creature_ptr->pclass == CLASS_ROGUE) || (creature_ptr->pclass == CLASS_NINJA))
2493 creature_ptr->energy_use -= creature_ptr->lev;
2495 /* Start at the player */
2496 y = creature_ptr->y;
2497 x = creature_ptr->x;
2499 handle_stuff(creature_ptr);
2501 if ((creature_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2502 else shuriken = FALSE;
2504 /* Chance of hitting */
2505 if (have_flag(flgs, TR_THROW)) chance = ((creature_ptr->skill_tht) +
2506 ((creature_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2507 else chance = (creature_ptr->skill_tht + (creature_ptr->to_h_b * BTH_PLUS_ADJ));
2509 if (shuriken) chance *= 2;
2514 /* Travel until stopped */
2515 for (cur_dis = 0; cur_dis <= tdis; )
2517 /* Hack -- Stop at the target */
2518 if ((y == ty) && (x == tx)) break;
2520 /* Calculate the new location (see "project()") */
2523 mmove2(&ny[cur_dis], &nx[cur_dis], creature_ptr->y, creature_ptr->x, ty, tx);
2525 /* Stopped by walls/doors */
2526 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, ny[cur_dis], nx[cur_dis], FF_PROJECT))
2529 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;
2532 /* The player can see the (on screen) missile */
2533 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(creature_ptr, ny[cur_dis], nx[cur_dis]))
2535 SYMBOL_CODE c = object_char(q_ptr);
2536 TERM_COLOR a = object_attr(q_ptr);
2538 /* Draw, Hilite, Fresh, Pause, Erase */
2539 print_rel(creature_ptr, c, a, ny[cur_dis], nx[cur_dis]);
2540 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2542 Term_xtra(TERM_XTRA_DELAY, msec);
2543 lite_spot(creature_ptr, ny[cur_dis], nx[cur_dis]);
2547 /* The player cannot see the missile */
2550 /* Pause anyway, for consistancy */
2551 Term_xtra(TERM_XTRA_DELAY, msec);
2557 /* Save the new location */
2561 /* Advance the distance */
2564 /* Monster here, Try to hit it */
2565 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
2567 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
2568 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2569 GAME_TEXT m_name[MAX_NLEN];
2570 monster_name(creature_ptr, g_ptr->m_idx, m_name);
2572 /* Check the visibility */
2573 visible = m_ptr->ml;
2575 /* Note the collision */
2578 /* Did we hit it (penalize range) */
2579 if (test_hit_fire(creature_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2583 /* Handle unseen monster */
2586 /* Invisible monster */
2587 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2590 /* Handle visible monster */
2593 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2597 if (!creature_ptr->image) monster_race_track(creature_ptr, m_ptr->ap_r_idx);
2598 health_track(creature_ptr, g_ptr->m_idx);
2602 /* Hack -- Base damage from thrown object */
2605 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2606 tdam = damroll(dd, ds);
2607 /* Apply special damage */
2608 tdam = calc_attack_damage_with_slay(creature_ptr, q_ptr, tdam, m_ptr, 0, TRUE);
2609 tdam = critical_shot(creature_ptr, q_ptr->weight, q_ptr->to_h, 0, tdam);
2610 if (q_ptr->to_d > 0)
2611 tdam += q_ptr->to_d;
2613 tdam += -q_ptr->to_d;
2617 tdam *= (mult+creature_ptr->num_blow[item - INVEN_RARM]);
2618 tdam += creature_ptr->to_d_m;
2620 else if (have_flag(flgs, TR_THROW))
2623 tdam += creature_ptr->to_d_m;
2631 tdam += ((creature_ptr->lev+30)*(creature_ptr->lev+30)-900)/55;
2634 /* No negative damage */
2635 if (tdam < 0) tdam = 0;
2637 /* Modify the damage */
2638 tdam = mon_damage_mod(creature_ptr, m_ptr, tdam, FALSE);
2640 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2641 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2643 /* Hit the monster, check for death */
2644 if (mon_take_hit(creature_ptr, g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2652 message_pain(creature_ptr, g_ptr->m_idx, tdam);
2654 /* Anger the monster */
2655 if ((tdam > 0) && !object_is_potion(q_ptr))
2656 anger_monster(creature_ptr, m_ptr);
2658 if (fear && m_ptr->ml)
2661 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2671 /* decrease toach's fuel */
2672 if (hit_body) torch_lost_fuel(q_ptr);
2674 /* Chance of breakage (during attacks) */
2675 j = (hit_body ? breakage_chance(creature_ptr, q_ptr, creature_ptr->pclass == CLASS_ARCHER, 0) : 0);
2677 /* Figurines transform */
2678 if ((q_ptr->tval == TV_FIGURINE) && !(creature_ptr->current_floor_ptr->inside_arena))
2682 if (!(summon_named_creature(creature_ptr, 0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2683 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2684 else if (object_is_cursed(q_ptr))
2685 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2689 /* Potions smash open */
2690 if (object_is_potion(q_ptr))
2692 if (hit_body || hit_wall || (randint1(100) < j))
2694 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2696 if (potion_smash_effect(creature_ptr, 0, y, x, q_ptr->k_idx))
2698 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx];
2699 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2701 GAME_TEXT m_name[MAX_NLEN];
2702 monster_desc(creature_ptr, m_name, m_ptr, 0);
2703 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2704 set_hostile(creature_ptr, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx]);
2715 if (return_when_thrown)
2717 int back_chance = randint1(30)+20+((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2718 char o2_name[MAX_NLEN];
2719 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2722 if (boomerang) back_chance += 4+randint1(5);
2723 if (super_boomerang) back_chance += 100;
2724 object_desc(creature_ptr, o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2726 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2728 for (i = cur_dis - 1; i > 0; i--)
2730 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(creature_ptr, ny[i], nx[i]))
2732 char c = object_char(q_ptr);
2733 byte a = object_attr(q_ptr);
2735 /* Draw, Hilite, Fresh, Pause, Erase */
2736 print_rel(creature_ptr, c, a, ny[i], nx[i]);
2737 move_cursor_relative(ny[i], nx[i]);
2739 Term_xtra(TERM_XTRA_DELAY, msec);
2740 lite_spot(creature_ptr, ny[i], nx[i]);
2745 /* Pause anyway, for consistancy */
2746 Term_xtra(TERM_XTRA_DELAY, msec);
2749 if((back_chance > 37) && !creature_ptr->blind && (item >= 0))
2751 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2758 msg_format(_("%sを受け損ねた!", "%s comes back, but you can't catch!"), o2_name);
2762 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2764 y = creature_ptr->y;
2765 x = creature_ptr->x;
2770 msg_format(_("%sが返ってこなかった!", "%s doesn't come back!"), o2_name);
2776 if (item == INVEN_RARM || item == INVEN_LARM)
2778 /* Access the wield slot */
2779 o_ptr = &creature_ptr->inventory_list[item];
2781 /* Wear the new stuff */
2782 object_copy(o_ptr, q_ptr);
2784 creature_ptr->total_weight += q_ptr->weight;
2786 /* Increment the equip counter by hand */
2787 creature_ptr->equip_cnt++;
2789 creature_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2790 creature_ptr->window |= (PW_EQUIP);
2794 store_item_to_inventory(creature_ptr, q_ptr);
2798 else if (equiped_item)
2800 verify_equip_slot(creature_ptr, item);
2801 calc_android_exp(creature_ptr);
2806 if (cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_PROJECT))
2808 (void)drop_near(creature_ptr, q_ptr, j, y, x);
2812 (void)drop_near(creature_ptr, q_ptr, j, prev_y, prev_x);
2820 * @brief 自殺するコマンドのメインルーチン
2821 * Hack -- commit suicide
2825 void do_cmd_suicide(player_type *creature_ptr)
2832 /* Verify Retirement */
2833 if (current_world_ptr->total_winner)
2836 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2839 /* Verify Suicide */
2843 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2846 if (!current_world_ptr->noscore)
2848 /* Special Verification for suicide */
2849 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2854 if (i != '@') return;
2856 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2859 /* Initialize "last message" buffer */
2860 if (creature_ptr->last_message) string_free(creature_ptr->last_message);
2861 creature_ptr->last_message = NULL;
2863 /* Hack -- Note *winning* message */
2864 if (current_world_ptr->total_winner && last_words)
2866 char buf[1024] = "";
2867 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2870 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2871 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2875 creature_ptr->last_message = string_make(buf);
2876 msg_print(creature_ptr->last_message);
2881 creature_ptr->playing = FALSE;
2883 /* Kill the player */
2884 creature_ptr->is_dead = TRUE;
2885 creature_ptr->leaving = TRUE;
2887 if (!current_world_ptr->total_winner)
2889 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("ダンジョンの探索に絶望して自殺した。", "gave up all hope to commit suicide."));
2890 exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2891 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
2894 /* Cause of death */
2895 (void)strcpy(creature_ptr->died_from, _("途中終了", "Quitting"));