3 * @brief プレイヤーのコマンド処理2 / Movement commands (part 2)
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
25 #include "object-hook.h"
27 #include "spells-summon.h"
28 #include "spells-status.h"
30 #include "monster-status.h"
34 #include "player-status.h"
35 #include "realm-hex.h"
36 #include "realm-song.h"
41 #include "player-move.h"
42 #include "player-effects.h"
43 #include "player-class.h"
44 #include "player-personality.h"
45 #include "player-inventory.h"
46 #include "objectkind.h"
47 #include "object-broken.h"
48 #include "object-flavor.h"
52 #include "cmd-basic.h"
54 #include "floor-save.h"
55 #include "dungeon-file.h"
58 #include "view-mainwindow.h"
59 #include "targeting.h"
63 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
64 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
65 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
67 static bool confirm_leave_level(player_type *creature_ptr, bool down_stair)
69 quest_type *q_ptr = &quest[creature_ptr->current_floor_ptr->inside_quest];
71 /* Confirm leaving from once only quest */
72 if (confirm_quest && creature_ptr->current_floor_ptr->inside_quest &&
73 (q_ptr->type == QUEST_TYPE_RANDOM ||
74 (q_ptr->flags & QUEST_FLAG_ONCE &&
75 q_ptr->status != QUEST_STATUS_COMPLETED) ||
76 (q_ptr->flags & QUEST_FLAG_TOWER &&
77 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
78 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
80 msg_print(_("この階を一度去ると二度と戻って来られません。", "You can't come back here once you leave this floor."));
81 if (get_check(_("本当にこの階を去りますか?", "Really leave this floor? "))) return TRUE;
91 * @brief 魔法系コマンドが制限されているかを返す。
92 * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
94 bool cmd_limit_cast(player_type *creature_ptr)
96 if (creature_ptr->current_floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC))
98 msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
102 else if (creature_ptr->anti_magic)
104 msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
107 else if (creature_ptr->shero)
109 msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
116 bool cmd_limit_confused(player_type *creature_ptr)
118 if (creature_ptr->confused)
120 msg_print(_("混乱していてできない!", "You are too confused!"));
126 bool cmd_limit_image(player_type *creature_ptr)
128 if (creature_ptr->image)
130 msg_print(_("幻覚が見えて集中できない!", "You are too hallucinated!"));
136 bool cmd_limit_stun(player_type *creature_ptr)
138 if (creature_ptr->stun)
140 msg_print(_("頭が朦朧としていて集中できない!", "You are too stuned!"));
146 bool cmd_limit_arena(player_type *creature_ptr)
148 if (creature_ptr->current_floor_ptr->inside_arena)
150 msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
157 bool cmd_limit_blind(player_type *creature_ptr)
159 if (creature_ptr->blind)
161 msg_print(_("目が見えない。", "You can't see anything."));
164 if (no_lite(creature_ptr))
166 msg_print(_("明かりがないので見えない。", "You have no light."));
172 bool cmd_limit_time_walk(player_type *creature_ptr)
174 if (creature_ptr->timewalk)
176 if (flush_failure) flush();
177 msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
185 * @brief 階段を使って階層を昇る処理 / Go up one level
188 void do_cmd_go_up(player_type *creature_ptr)
193 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
194 feature_type *f_ptr = &f_info[g_ptr->feat];
198 if (creature_ptr->special_defense & KATA_MUSOU)
200 set_action(creature_ptr, ACTION_NONE);
204 if (!have_flag(f_ptr->flags, FF_LESS))
206 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
210 /* Quest up stairs */
211 if (have_flag(f_ptr->flags, FF_QUEST))
213 if (!confirm_leave_level(creature_ptr, FALSE)) return;
216 if ((creature_ptr->pseikaku == SEIKAKU_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
217 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
219 msg_print(_("上の階に登った。", "You enter the up staircase."));
221 leave_quest_check(creature_ptr);
223 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
225 /* Activate the quest */
226 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
228 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
230 init_flags = INIT_ASSIGN;
231 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
233 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
236 /* Leaving a quest */
237 if (!creature_ptr->current_floor_ptr->inside_quest)
239 creature_ptr->current_floor_ptr->dun_level = 0;
241 creature_ptr->leaving = TRUE;
243 creature_ptr->oldpx = 0;
244 creature_ptr->oldpy = 0;
246 take_turn(creature_ptr, 100);
248 /* End the command */
252 if (!creature_ptr->current_floor_ptr->dun_level)
258 go_up = confirm_leave_level(creature_ptr, FALSE);
263 take_turn(creature_ptr, 100);
265 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
267 /* For a random quest */
268 if (creature_ptr->current_floor_ptr->inside_quest &&
269 quest[creature_ptr->current_floor_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
271 leave_quest_check(creature_ptr);
273 creature_ptr->current_floor_ptr->inside_quest = 0;
276 /* For a fixed quest */
277 if (creature_ptr->current_floor_ptr->inside_quest &&
278 quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
280 leave_quest_check(creature_ptr);
282 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
283 creature_ptr->current_floor_ptr->dun_level = 0;
287 /* For normal dungeon and random quest */
291 if (have_flag(f_ptr->flags, FF_SHAFT))
293 /* Create a way back */
294 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
300 /* Create a way back */
301 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_UP);
306 /* Get out from current dungeon */
307 if (creature_ptr->current_floor_ptr->dun_level - up_num < d_info[creature_ptr->dungeon_idx].mindepth)
308 up_num = creature_ptr->current_floor_ptr->dun_level;
310 if (record_stair) exe_write_diary(creature_ptr, NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
313 if ((creature_ptr->pseikaku == SEIKAKU_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
314 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
315 else if (up_num == creature_ptr->current_floor_ptr->dun_level)
316 msg_print(_("地上に戻った。", "You go back to the surface."));
318 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
319 creature_ptr->leaving = TRUE;
324 * @brief 階段を使って階層を降りる処理 / Go down one level
325 * @param creature_ptr プレーヤーへの参照ポインタ
328 void do_cmd_go_down(player_type *creature_ptr)
330 bool fall_trap = FALSE;
333 if (creature_ptr->special_defense & KATA_MUSOU)
335 set_action(creature_ptr, ACTION_NONE);
339 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x];
340 feature_type *f_ptr = &f_info[g_ptr->feat];
341 if (!have_flag(f_ptr->flags, FF_MORE))
343 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
347 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
350 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
352 do_cmd_quest(creature_ptr);
356 /* Quest down stairs */
357 if (have_flag(f_ptr->flags, FF_QUEST))
359 /* Confirm Leaving */
360 if(!confirm_leave_level(creature_ptr, TRUE)) return;
362 if ((creature_ptr->pseikaku == SEIKAKU_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
363 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
365 msg_print(_("下の階に降りた。", "You enter the down staircase."));
367 leave_quest_check(creature_ptr);
368 leave_tower_check(creature_ptr);
370 creature_ptr->current_floor_ptr->inside_quest = g_ptr->special;
372 /* Activate the quest */
373 if (!quest[creature_ptr->current_floor_ptr->inside_quest].status)
375 if (quest[creature_ptr->current_floor_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
377 init_flags = INIT_ASSIGN;
378 process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
380 quest[creature_ptr->current_floor_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
383 /* Leaving a quest */
384 if (!creature_ptr->current_floor_ptr->inside_quest)
386 creature_ptr->current_floor_ptr->dun_level = 0;
388 creature_ptr->leaving = TRUE;
389 creature_ptr->oldpx = 0;
390 creature_ptr->oldpy = 0;
392 take_turn(creature_ptr, 100);
396 DUNGEON_IDX target_dungeon = 0;
398 if (!creature_ptr->current_floor_ptr->dun_level)
400 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
402 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
404 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
407 if (!max_dlv[target_dungeon])
409 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
410 d_name + d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
411 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
414 /* Save old player position */
415 creature_ptr->oldpx = creature_ptr->x;
416 creature_ptr->oldpy = creature_ptr->y;
417 creature_ptr->dungeon_idx = target_dungeon;
420 * Clear all saved floors
421 * and create a first saved floor
423 prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
426 take_turn(creature_ptr, 100);
428 if (autosave_l) do_cmd_save_game(creature_ptr, TRUE);
431 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
434 if (!creature_ptr->current_floor_ptr->dun_level)
436 /* Enter the dungeon just now */
437 creature_ptr->enter_dungeon = TRUE;
438 down_num = d_info[creature_ptr->dungeon_idx].mindepth;
443 if (fall_trap) exe_write_diary(creature_ptr, NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
444 else exe_write_diary(creature_ptr, NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
449 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
456 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[creature_ptr->dungeon_idx].text);
460 if ((creature_ptr->pseikaku == SEIKAKU_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
461 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
463 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
467 creature_ptr->leaving = TRUE;
471 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
475 /* Create a way back */
476 if (have_flag(f_ptr->flags, FF_SHAFT))
478 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
482 prepare_change_floor_mode(creature_ptr, CFM_SAVE_FLOORS | CFM_DOWN);
488 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
491 void do_cmd_search(player_type * creature_ptr)
493 /* Allow repeated command */
496 /* Set repeat count */
497 command_rep = command_arg - 1;
498 creature_ptr->redraw |= (PR_STATE);
504 take_turn(creature_ptr, 100);
505 search(creature_ptr);
510 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
511 * @param y 走査対象にしたいマスのY座標
512 * @param x 走査対象にしたいマスのX座標
513 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
514 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
516 static OBJECT_IDX chest_check(floor_type *floor_ptr, POSITION y, POSITION x, bool trapped)
518 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
519 OBJECT_IDX this_o_idx, next_o_idx = 0;
521 /* Scan all objects in the grid */
522 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
526 o_ptr = &floor_ptr->o_list[this_o_idx];
527 next_o_idx = o_ptr->next_o_idx;
529 /* Skip unknown chests XXX XXX */
530 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
532 /* Check for non empty chest */
533 if ((o_ptr->tval == TV_CHEST) &&
534 (((!trapped) && (o_ptr->pval)) || /* non empty */
535 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
546 * Attempt to open the given chest at the given location
547 * @param y 箱の存在するマスのY座標
548 * @param x 箱の存在するマスのX座標
549 * @param o_idx 箱のオブジェクトID
550 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
552 * Assume there is no monster blocking the destination
554 static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
558 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
560 take_turn(creature_ptr, 100);
562 /* Attempt to unlock it */
565 /* Assume locked, and thus not open */
568 /* Get the "disarm" factor */
569 int i = creature_ptr->skill_dis;
571 /* Penalize some conditions */
572 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
573 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
575 /* Extract the difficulty */
576 int j = i - o_ptr->pval;
578 /* Always have a small chance of success */
581 /* Success -- May still have traps */
582 if (randint0(100) < j)
584 msg_print(_("鍵をはずした。", "You have picked the lock."));
585 gain_exp(creature_ptr, 1);
589 /* Failure -- Keep trying */
592 /* We may continue repeating */
594 if (flush_failure) flush();
595 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
600 /* Allowed to open */
603 /* Apply chest traps, if any */
604 chest_trap(creature_ptr, y, x, o_idx);
606 /* Let the Chest drop items */
607 chest_death(creature_ptr, FALSE, y, x, o_idx);
614 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
615 * Attempt to open the given chest at the given location
616 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
617 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
618 * @param test 地形条件を判定するための関数ポインタ
619 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
621 * @details Return the number of features around (or under) the character.
622 * Usually look for doors and floor traps.
624 static int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(FEAT_IDX feat), bool under)
626 /* Check around (and under) the character */
628 for (DIRECTION d = 0; d < 9; d++)
633 /* if not searching under player continue */
634 if ((d == 8) && !under) continue;
636 /* Extract adjacent (legal) location */
637 POSITION yy = creature_ptr->y + ddy_ddd[d];
638 POSITION xx = creature_ptr->x + ddx_ddd[d];
640 /* Get the creature_ptr->current_floor_ptr->grid_array */
641 g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
643 /* Must have knowledge */
644 if (!(g_ptr->info & (CAVE_MARK))) continue;
646 /* Feature code (applying "mimic" field) */
647 feat = get_feat_mimic(g_ptr);
649 /* Not looking for this feature */
650 if (!((*test)(feat))) continue;
655 /* Remember the location. Only useful if only one match */
666 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
667 * Return the number of chests around (or under) the character.
668 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
669 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
670 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
673 * If requested, count only trapped chests.
675 static int count_chests(player_type *creature_ptr, POSITION *y, POSITION *x, bool trapped)
677 /* Check around (and under) the character */
679 for (DIRECTION d = 0; d < 9; d++)
681 /* Extract adjacent (legal) location */
682 POSITION yy = creature_ptr->y + ddy_ddd[d];
683 POSITION xx = creature_ptr->x + ddx_ddd[d];
685 /* No (visible) chest is there */
686 OBJECT_IDX o_idx = chest_check(creature_ptr->current_floor_ptr, yy, xx, FALSE);
687 if (!o_idx) continue;
689 /* Grab the object */
691 o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
694 if (o_ptr->pval == 0) continue;
696 /* No (known) traps here */
697 if (trapped && (!object_is_known(o_ptr) ||
698 !chest_traps[o_ptr->pval])) continue;
703 /* Remember the location. Only useful if only one match */
715 * @brief 「開ける」動作コマンドのサブルーチン /
716 * Perform the basic "open" command on doors
717 * @param y 対象を行うマスのY座標
718 * @param x 対象を行うマスのX座標
719 * @return 実際に処理が行われた場合TRUEを返す。
721 * Assume destination is a closed/locked/jammed door
722 * Assume there is no monster blocking the destination
723 * Returns TRUE if repeated commands may continue
725 static bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
727 /* Get requested grid */
728 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
729 feature_type *f_ptr = &f_info[g_ptr->feat];
732 take_turn(creature_ptr, 100);
734 /* Seeing true feature code (ignore mimic) */
737 if (!have_flag(f_ptr->flags, FF_OPEN))
740 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
746 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
747 sound(SOUND_OPENDOOR);
752 int i = creature_ptr->skill_dis;
754 /* Penalize some conditions */
755 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
756 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
758 /* Extract the difficulty */
759 int j = f_ptr->power;
762 /* Always have a small chance of success */
765 if (randint0(100) >= j)
767 if (flush_failure) flush();
768 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
772 msg_print(_("鍵をはずした。", "You have picked the lock."));
775 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
777 sound(SOUND_OPENDOOR);
780 gain_exp(creature_ptr, 1);
785 * @brief 「開ける」コマンドのメインルーチン /
786 * Open a closed/locked/jammed door or a closed/locked chest.
789 * Unlocking a locked door/chest is worth one experience point.
791 void do_cmd_open(player_type *creature_ptr)
799 if (creature_ptr->wild_mode) return;
801 if (creature_ptr->special_defense & KATA_MUSOU)
803 set_action(creature_ptr, ACTION_NONE);
806 /* Option: Pick a direction */
809 int num_doors, num_chests;
811 num_doors = count_dt(creature_ptr, &y, &x, is_closed_door, FALSE);
812 num_chests = count_chests(creature_ptr, &y, &x, FALSE);
813 if (num_doors || num_chests)
815 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
817 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
821 /* Allow repeated command */
824 /* Set repeat count */
825 command_rep = command_arg - 1;
826 creature_ptr->redraw |= (PR_STATE);
832 /* Get a "repeated" direction */
833 if (get_rep_dir(&dir, TRUE))
838 /* Get requested location */
839 y = creature_ptr->y + ddy[dir];
840 x = creature_ptr->x + ddx[dir];
842 /* Get requested grid */
843 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
845 /* Feature code (applying "mimic" field) */
846 feat = get_feat_mimic(g_ptr);
848 /* Check for chest */
849 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, FALSE);
851 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
853 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
855 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
857 take_turn(creature_ptr, 100);
858 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
859 py_attack(creature_ptr, y, x, 0);
863 more = exe_open_chest(creature_ptr, y, x, o_idx);
867 more = exe_open(creature_ptr, y, x);
871 /* Cancel repeat unless we may continue */
872 if (!more) disturb(creature_ptr, FALSE, FALSE);
879 * @brief 「閉じる」動作コマンドのサブルーチン /
880 * Perform the basic "close" command
881 * @param y 対象を行うマスのY座標
882 * @param x 対象を行うマスのX座標
883 * @return 実際に処理が行われた場合TRUEを返す。
885 * Assume destination is an open/broken door
886 * Assume there is no monster blocking the destination
887 * Returns TRUE if repeated commands may continue
889 static bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
891 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
892 FEAT_IDX old_feat = g_ptr->feat;
895 take_turn(creature_ptr, 100);
897 /* Seeing true feature code (ignore mimic) */
900 if (!have_flag(f_info[old_feat].flags, FF_CLOSE))
905 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
907 /* Hack -- object in the way */
908 if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) &&
909 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
911 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
916 cave_alter_feat(creature_ptr, y, x, FF_CLOSE);
919 if (old_feat == g_ptr->feat)
921 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
925 sound(SOUND_SHUTDOOR);
934 * @brief 「閉じる」コマンドのメインルーチン /
935 * Close an open door.
938 * Unlocking a locked door/chest is worth one experience point.
940 void do_cmd_close(player_type *creature_ptr)
947 if (creature_ptr->wild_mode) return;
949 if (creature_ptr->special_defense & KATA_MUSOU)
951 set_action(creature_ptr, ACTION_NONE);
954 /* Option: Pick a direction */
957 /* Count open doors */
958 if (count_dt(creature_ptr, &y, &x, is_open, FALSE) == 1)
960 command_dir = coords_to_dir(creature_ptr, y, x);
964 /* Allow repeated command */
967 /* Set repeat count */
968 command_rep = command_arg - 1;
969 creature_ptr->redraw |= (PR_STATE);
975 /* Get a "repeated" direction */
976 if (get_rep_dir(&dir, FALSE))
981 y = creature_ptr->y + ddy[dir];
982 x = creature_ptr->x + ddx[dir];
983 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
985 /* Feature code (applying "mimic" field) */
986 feat = get_feat_mimic(g_ptr);
988 /* Require open/broken door */
989 if (!have_flag(f_info[feat].flags, FF_CLOSE))
991 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
994 /* Monster in the way */
995 else if (g_ptr->m_idx)
997 take_turn(creature_ptr, 100);
999 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1002 py_attack(creature_ptr, y, x, 0);
1005 /* Close the door */
1008 /* Close the door */
1009 more = exe_close(creature_ptr, y, x);
1013 /* Cancel repeat unless we may continue */
1014 if (!more) disturb(creature_ptr, FALSE, FALSE);
1019 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1020 * Determine if a given grid may be "tunneled"
1021 * @param y 対象を行うマスのY座標
1022 * @param x 対象を行うマスのX座標
1025 static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
1027 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
1029 /* Must have knowledge */
1030 if (!(g_ptr->info & CAVE_MARK))
1032 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1037 /* Must be a wall/door/etc */
1038 if (!cave_have_flag_grid(g_ptr, FF_TUNNEL))
1040 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1050 * @brief 「掘る」動作コマンドのサブルーチン /
1051 * Perform the basic "tunnel" command
1052 * @param y 対象を行うマスのY座標
1053 * @param x 対象を行うマスのX座標
1054 * @return 実際に処理が行われた場合TRUEを返す。
1056 * Assumes that no monster is blocking the destination
1057 * Do not use twall anymore
1058 * Returns TRUE if repeated commands may continue
1060 static bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
1063 feature_type *f_ptr, *mimic_f_ptr;
1068 /* Verify legality */
1069 if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x)) return FALSE;
1071 take_turn(creature_ptr, 100);
1073 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1074 f_ptr = &f_info[g_ptr->feat];
1075 power = f_ptr->power;
1077 /* Feature code (applying "mimic" field) */
1078 mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
1080 name = f_name + mimic_f_ptr->name;
1084 if (have_flag(f_ptr->flags, FF_PERMANENT))
1087 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1089 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1092 /* Map border (mimiccing Permanent wall) */
1095 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1100 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1103 if (creature_ptr->skill_dig > randint0(20 * power))
1105 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1107 /* Remove the feature */
1108 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1109 creature_ptr->update |= (PU_FLOW);
1113 /* Message, keep digging */
1114 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1122 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1125 if (creature_ptr->skill_dig > power + randint0(40 * power))
1127 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1130 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1131 creature_ptr->update |= (PU_FLOW);
1134 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1136 /* Remove the feature */
1137 cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
1139 chg_virtue(creature_ptr, V_DILIGENCE, 1);
1140 chg_virtue(creature_ptr, V_NATURE, -1);
1148 /* We may continue chopping */
1149 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1150 /* Occasional Search XXX XXX */
1151 if (randint0(100) < 25) search(creature_ptr);
1155 /* We may continue tunelling */
1156 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1163 if (is_hidden_door(g_ptr))
1165 /* Occasional Search XXX XXX */
1166 if (randint0(100) < 25) search(creature_ptr);
1174 * @brief 「掘る」動作コマンドのメインルーチン /
1175 * Tunnels through "walls" (including rubble and closed doors)
1179 * Note that you must tunnel in order to hit invisible monsters
1180 * in walls, though moving into walls still takes a turn anyway.
1182 * Digging is very difficult without a "digger" weapon, but can be
1183 * accomplished by strong players using heavy weapons.
1186 void do_cmd_tunnel(player_type *creature_ptr)
1195 if (creature_ptr->special_defense & KATA_MUSOU)
1197 set_action(creature_ptr, ACTION_NONE);
1200 /* Allow repeated command */
1203 /* Set repeat count */
1204 command_rep = command_arg - 1;
1205 creature_ptr->redraw |= (PR_STATE);
1207 /* Cancel the arg */
1211 /* Get a direction to tunnel, or Abort */
1212 if (get_rep_dir(&dir,FALSE))
1215 y = creature_ptr->y + ddy[dir];
1216 x = creature_ptr->x + ddx[dir];
1218 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1220 /* Feature code (applying "mimic" field) */
1221 feat = get_feat_mimic(g_ptr);
1223 /* No tunnelling through doors */
1224 if (have_flag(f_info[feat].flags, FF_DOOR))
1226 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1229 /* No tunnelling through most features */
1230 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1232 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1235 /* A monster is in the way */
1236 else if (g_ptr->m_idx)
1238 take_turn(creature_ptr, 100);
1239 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1242 py_attack(creature_ptr, y, x, 0);
1248 /* Tunnel through walls */
1249 more = exe_tunnel(creature_ptr, y, x);
1253 /* Cancel repetition unless we can continue */
1254 if (!more) disturb(creature_ptr, FALSE, FALSE);
1258 * @brief 移動処理による簡易な「開く」処理 /
1260 * @return 開く処理が実際に試みられた場合TRUEを返す
1263 * If there is a jammed/closed/locked door at the given location,
1264 * then attempt to unlock/open it. Return TRUE if an attempt was
1265 * made (successful or not), otherwise return FALSE.
1267 * The code here should be nearly identical to that in
1268 * do_cmd_open_test() and exe_open().
1271 bool easy_open_door(player_type *creature_ptr, POSITION y, POSITION x)
1275 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1276 feature_type *f_ptr = &f_info[g_ptr->feat];
1278 /* Must be a closed door */
1279 if (!is_closed_door(g_ptr->feat))
1285 if (!have_flag(f_ptr->flags, FF_OPEN))
1288 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
1293 else if (f_ptr->power)
1296 i = creature_ptr->skill_dis;
1298 /* Penalize some conditions */
1299 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1300 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1302 /* Extract the lock power */
1305 /* Extract the difficulty */
1308 /* Always have a small chance of success */
1312 if (randint0(100) < j)
1314 msg_print(_("鍵をはずした。", "You have picked the lock."));
1317 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1319 sound(SOUND_OPENDOOR);
1322 gain_exp(creature_ptr, 1);
1329 if (flush_failure) flush();
1331 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1340 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1342 sound(SOUND_OPENDOOR);
1349 * @brief 箱のトラップを解除する実行処理 /
1350 * Perform the basic "disarm" command
1351 * @param y 解除を行うマスのY座標
1352 * @param x 解除を行うマスのX座標
1353 * @param o_idx 箱のオブジェクトID
1354 * @return ターンを消費する処理が行われた場合TRUEを返す
1357 * Assume destination is a visible trap
1358 * Assume there is no monster blocking the destination
1359 * Returns TRUE if repeated commands may continue
1362 static bool exe_disarm_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx)
1366 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
1368 take_turn(creature_ptr, 100);
1370 /* Get the "disarm" factor */
1371 i = creature_ptr->skill_dis;
1373 /* Penalize some conditions */
1374 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1375 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1377 /* Extract the difficulty */
1378 j = i - o_ptr->pval;
1380 /* Always have a small chance of success */
1383 /* Must find the trap first. */
1384 if (!object_is_known(o_ptr))
1386 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1390 /* Already disarmed/unlocked */
1391 else if (o_ptr->pval <= 0)
1393 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1396 /* No traps to find. */
1397 else if (!chest_traps[o_ptr->pval])
1399 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1402 /* Success (get a lot of experience) */
1403 else if (randint0(100) < j)
1405 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1406 gain_exp(creature_ptr, o_ptr->pval);
1407 o_ptr->pval = (0 - o_ptr->pval);
1410 /* Failure -- Keep trying */
1411 else if ((i > 5) && (randint1(i) > 5))
1413 /* We may keep trying */
1415 if (flush_failure) flush();
1416 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1419 /* Failure -- Set off the trap */
1422 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1424 chest_trap(creature_ptr, y, x, o_idx);
1432 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1433 * Perform the basic "disarm" command
1434 * @param y 解除を行うマスのY座標
1435 * @param x 解除を行うマスのX座標
1436 * @param dir プレイヤーからみた方向ID
1437 * @return ターンを消費する処理が行われた場合TRUEを返す
1440 * Assume destination is a visible trap
1441 * Assume there is no monster blocking the destination
1442 * Returns TRUE if repeated commands may continue
1446 bool exe_disarm(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1448 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1451 feature_type *f_ptr = &f_info[g_ptr->feat];
1453 /* Access trap name */
1454 concptr name = (f_name + f_ptr->name);
1456 /* Extract trap "power" */
1457 int power = f_ptr->power;
1460 /* Get the "disarm" factor */
1461 int i = creature_ptr->skill_dis;
1464 take_turn(creature_ptr, 100);
1466 /* Penalize some conditions */
1467 if (creature_ptr->blind || no_lite(creature_ptr)) i = i / 10;
1468 if (creature_ptr->confused || creature_ptr->image) i = i / 10;
1470 /* Extract the difficulty */
1473 /* Always have a small chance of success */
1477 if (randint0(100) < j)
1479 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1482 gain_exp(creature_ptr, power);
1484 /* Remove the trap */
1485 cave_alter_feat(creature_ptr, y, x, FF_DISARM);
1487 /* Move the player onto the trap */
1488 move_player(creature_ptr, dir, easy_disarm, FALSE);
1491 /* Failure -- Keep trying */
1492 else if ((i > 5) && (randint1(i) > 5))
1495 if (flush_failure) flush();
1497 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1499 /* We may keep trying */
1503 /* Failure -- Set off the trap */
1506 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1507 /* Move the player onto the trap */
1508 move_player(creature_ptr, dir, easy_disarm, FALSE);
1516 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1517 * Disarms a trap, or chest
1520 void do_cmd_disarm(player_type *creature_ptr)
1528 if (creature_ptr->wild_mode) return;
1530 if (creature_ptr->special_defense & KATA_MUSOU)
1532 set_action(creature_ptr, ACTION_NONE);
1535 /* Option: Pick a direction */
1538 int num_traps, num_chests;
1540 /* Count visible traps */
1541 num_traps = count_dt(creature_ptr, &y, &x, is_trap, TRUE);
1543 /* Count chests (trapped) */
1544 num_chests = count_chests(creature_ptr, &y, &x, TRUE);
1546 /* See if only one target */
1547 if (num_traps || num_chests)
1549 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1550 if (!too_many) command_dir = coords_to_dir(creature_ptr, y, x);
1554 /* Allow repeated command */
1557 /* Set repeat count */
1558 command_rep = command_arg - 1;
1559 creature_ptr->redraw |= (PR_STATE);
1561 /* Cancel the arg */
1565 /* Get a direction (or abort) */
1566 if (get_rep_dir(&dir,TRUE))
1571 y = creature_ptr->y + ddy[dir];
1572 x = creature_ptr->x + ddx[dir];
1573 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1575 /* Feature code (applying "mimic" field) */
1576 feat = get_feat_mimic(g_ptr);
1578 /* Check for chests */
1579 o_idx = chest_check(creature_ptr->current_floor_ptr, y, x, TRUE);
1582 if (!is_trap(feat) && !o_idx)
1584 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
1587 /* Monster in the way */
1588 else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx)
1590 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1593 py_attack(creature_ptr, y, x, 0);
1599 more = exe_disarm_chest(creature_ptr, y, x, o_idx);
1605 more = exe_disarm(creature_ptr, y, x, dir);
1609 /* Cancel repeat unless told not to */
1610 if (!more) disturb(creature_ptr, FALSE, FALSE);
1615 * @brief 「打ち破る」動作コマンドのサブルーチン /
1616 * Perform the basic "bash" command
1617 * @param y 対象を行うマスのY座標
1618 * @param x 対象を行うマスのX座標
1619 * @param dir プレイヤーから見たターゲットの方角ID
1620 * @return 実際に処理が行われた場合TRUEを返す。
1623 * Assume destination is a closed/locked/jammed door
1624 * Assume there is no monster blocking the destination
1625 * Returns TRUE if repeated commands may continue
1628 static bool do_cmd_bash_aux(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
1630 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1633 feature_type *f_ptr = &f_info[g_ptr->feat];
1635 /* Hack -- Bash power based on strength */
1636 /* (Ranges from 3 to 20 to 100 to 200) */
1637 int bash = adj_str_blow[creature_ptr->stat_ind[A_STR]];
1639 /* Extract door power */
1640 int temp = f_ptr->power;
1644 concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
1646 take_turn(creature_ptr, 100);
1648 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
1650 /* Compare bash power to door power */
1651 temp = (bash - (temp * 10));
1653 if (creature_ptr->pclass == CLASS_BERSERKER) temp *= 2;
1655 /* Hack -- always have a chance */
1656 if (temp < 1) temp = 1;
1658 /* Hack -- attempt to bash down the door */
1659 if (randint0(100) < temp)
1661 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
1663 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
1665 /* Break down the door */
1666 if ((randint0(100) < 50) || (feat_state(g_ptr->feat, FF_OPEN) == g_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
1668 cave_alter_feat(creature_ptr, y, x, FF_BASH);
1674 cave_alter_feat(creature_ptr, y, x, FF_OPEN);
1677 /* Hack -- Fall through the door */
1678 move_player(creature_ptr, dir, FALSE, FALSE);
1681 /* Saving throw against stun */
1682 else if (randint0(100) < adj_dex_safe[creature_ptr->stat_ind[A_DEX]] +
1685 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
1687 /* Allow repeated bashing */
1691 /* High dexterity yields coolness */
1694 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
1696 /* Hack -- Lose balance ala paralysis */
1697 (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 2 + randint0(2));
1705 * @brief 「打ち破る」動作コマンドのメインルーチン /
1706 * Bash open a door, success based on character strength
1710 * For a closed door, pval is positive if locked; negative if stuck.
1712 * For an open door, pval is positive for a broken door.
1714 * A closed door can be opened - harder if locked. Any door might be
1715 * bashed open (and thereby broken). Bashing a door is (potentially)
1716 * faster! You move into the door way. To open a stuck door, it must
1717 * be bashed. A closed door can be jammed (see do_cmd_spike()).
1719 * Creatures can also open or bash doors, see elsewhere.
1722 void do_cmd_bash(player_type *creature_ptr)
1729 if (creature_ptr->wild_mode) return;
1731 if (creature_ptr->special_defense & KATA_MUSOU)
1733 set_action(creature_ptr, ACTION_NONE);
1736 /* Allow repeated command */
1739 /* Set repeat count */
1740 command_rep = command_arg - 1;
1741 creature_ptr->redraw |= (PR_STATE);
1743 /* Cancel the arg */
1747 /* Get a "repeated" direction */
1748 if (get_rep_dir(&dir,FALSE))
1753 y = creature_ptr->y + ddy[dir];
1754 x = creature_ptr->x + ddx[dir];
1756 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1758 /* Feature code (applying "mimic" field) */
1759 feat = get_feat_mimic(g_ptr);
1761 /* Nothing useful */
1762 if (!have_flag(f_info[feat].flags, FF_BASH))
1764 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
1767 /* Monster in the way */
1768 else if (g_ptr->m_idx)
1770 take_turn(creature_ptr, 100);
1772 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1775 py_attack(creature_ptr, y, x, 0);
1778 /* Bash a closed door */
1782 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1786 /* Unless valid action taken, cancel bash */
1787 if (!more) disturb(creature_ptr, FALSE, FALSE);
1792 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
1796 * Manipulate an adjacent grid in some way
1798 * Attack monsters, tunnel through walls, disarm traps, open doors.
1800 * Consider confusion
1802 * This command must always take a turn, to prevent free detection
1803 * of invisible monsters.
1806 void do_cmd_alter(player_type *creature_ptr)
1813 if (creature_ptr->special_defense & KATA_MUSOU)
1815 set_action(creature_ptr, ACTION_NONE);
1818 /* Allow repeated command */
1821 /* Set repeat count */
1822 command_rep = command_arg - 1;
1823 creature_ptr->redraw |= (PR_STATE);
1825 /* Cancel the arg */
1829 /* Get a direction */
1830 if (get_rep_dir(&dir,TRUE))
1833 feature_type *f_ptr;
1835 y = creature_ptr->y + ddy[dir];
1836 x = creature_ptr->x + ddx[dir];
1838 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1840 /* Feature code (applying "mimic" field) */
1841 feat = get_feat_mimic(g_ptr);
1842 f_ptr = &f_info[feat];
1844 take_turn(creature_ptr, 100);
1848 py_attack(creature_ptr, y, x, 0);
1852 else if (have_flag(f_ptr->flags, FF_OPEN))
1854 more = exe_open(creature_ptr, y, x);
1857 /* Bash jammed doors */
1858 else if (have_flag(f_ptr->flags, FF_BASH))
1860 more = do_cmd_bash_aux(creature_ptr, y, x, dir);
1863 /* Tunnel through walls */
1864 else if (have_flag(f_ptr->flags, FF_TUNNEL))
1866 more = exe_tunnel(creature_ptr, y, x);
1869 /* Close open doors */
1870 else if (have_flag(f_ptr->flags, FF_CLOSE))
1872 more = exe_close(creature_ptr, y, x);
1876 else if (have_flag(f_ptr->flags, FF_DISARM))
1878 more = exe_disarm(creature_ptr, y, x, dir);
1883 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
1887 /* Cancel repetition unless we can continue */
1888 if (!more) disturb(creature_ptr, FALSE, FALSE);
1894 * @brief 「くさびを打つ」ために必要なオブジェクトを所持しているかどうかの判定を返す /
1895 * Find the index of some "spikes", if possible.
1896 * @param ip くさびとして打てるオブジェクトのID
1897 * @return オブジェクトがある場合TRUEを返す
1900 * Let user choose a pile of spikes, perhaps?
1903 static bool get_spike(player_type *creature_ptr, INVENTORY_IDX *ip)
1907 /* Check every item in the pack */
1908 for (i = 0; i < INVEN_PACK; i++)
1910 object_type *o_ptr = &creature_ptr->inventory_list[i];
1911 if (!o_ptr->k_idx) continue;
1913 /* Check the "tval" code */
1914 if (o_ptr->tval == TV_SPIKE)
1916 /* Save the spike index */
1929 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
1930 * Jam a closed door with a spike
1931 * @param creature_ptr プレーヤーへの参照ポインタ
1935 * This command may NOT be repeated
1938 void do_cmd_spike(player_type *creature_ptr)
1942 if (creature_ptr->wild_mode) return;
1943 if (creature_ptr->special_defense & KATA_MUSOU)
1945 set_action(creature_ptr, ACTION_NONE);
1948 /* Get a "repeated" direction */
1949 if (!get_rep_dir(&dir, FALSE)) return;
1951 POSITION y = creature_ptr->y + ddy[dir];
1952 POSITION x = creature_ptr->x + ddx[dir];
1954 g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
1956 /* Feature code (applying "mimic" field) */
1957 FEAT_IDX feat = get_feat_mimic(g_ptr);
1959 /* Require closed door */
1961 if (!have_flag(f_info[feat].flags, FF_SPIKE))
1963 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
1967 else if (!get_spike(creature_ptr, &item))
1969 msg_print(_("くさびを持っていない!", "You have no spikes!"));
1972 /* Is a monster in the way? */
1973 else if (g_ptr->m_idx)
1975 take_turn(creature_ptr, 100);
1977 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1980 py_attack(creature_ptr, y, x, 0);
1986 take_turn(creature_ptr, 100);
1988 /* Successful jamming */
1989 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
1990 cave_alter_feat(creature_ptr, y, x, FF_SPIKE);
1992 vary_item(creature_ptr, item, -1);
1998 * @brief 「歩く」動作コマンドのメインルーチン /
1999 * Support code for the "Walk" and "Jump" commands
2000 * @param creature_ptr プレーヤーへの参照ポインタ
2001 * @param pickup アイテムの自動拾いを行うならTRUE
2004 void do_cmd_walk(player_type *creature_ptr, bool pickup)
2006 /* Allow repeated command */
2009 /* Set repeat count */
2010 command_rep = command_arg - 1;
2011 creature_ptr->redraw |= (PR_STATE);
2013 /* Cancel the arg */
2017 /* Get a "repeated" direction */
2020 if (get_rep_dir(&dir, FALSE))
2022 take_turn(creature_ptr, 100);
2024 if ((dir != 5) && (creature_ptr->special_defense & KATA_MUSOU))
2026 set_action(creature_ptr, ACTION_NONE);
2029 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2030 if (creature_ptr->wild_mode) creature_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2031 if (creature_ptr->action == ACTION_HAYAGAKE) creature_ptr->energy_use = creature_ptr->energy_use * (45-(creature_ptr->lev/2)) / 100;
2033 /* Actually move the character */
2034 move_player(creature_ptr, dir, pickup, FALSE);
2036 /* Allow more walking */
2040 /* Hack again -- Is there a special encounter ??? */
2041 if (creature_ptr->wild_mode && !cave_have_flag_bold(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, FF_TOWN))
2043 int tmp = 120 + creature_ptr->lev*10 - wilderness[creature_ptr->y][creature_ptr->x].level + 5;
2046 if (((wilderness[creature_ptr->y][creature_ptr->x].level + 5) > (creature_ptr->lev / 2)) && randint0(tmp) < (21-creature_ptr->skill_stl))
2048 /* Inform the player of his horrible fate :=) */
2049 msg_print(_("襲撃だ!", "You are ambushed !"));
2051 /* Go into large wilderness view */
2052 creature_ptr->oldpy = randint1(MAX_HGT-2);
2053 creature_ptr->oldpx = randint1(MAX_WID-2);
2054 change_wild_mode(creature_ptr, TRUE);
2056 /* Give first move to monsters */
2057 take_turn(creature_ptr, 100);
2062 /* Cancel repeat unless we may continue */
2063 if (!more) disturb(creature_ptr, FALSE, FALSE);
2068 * @brief 「走る」動作コマンドのメインルーチン /
2070 * @param creature_ptr プレーヤーへの参照ポインタ
2073 void do_cmd_run(player_type *creature_ptr)
2076 if (cmd_limit_confused(creature_ptr)) return;
2078 if (creature_ptr->special_defense & KATA_MUSOU)
2080 set_action(creature_ptr, ACTION_NONE);
2083 /* Get a "repeated" direction */
2084 if (get_rep_dir(&dir,FALSE))
2086 /* Hack -- Set the run counter */
2087 creature_ptr->running = (command_arg ? command_arg : 1000);
2096 * @brief 「留まる」動作コマンドのメインルーチン /
2097 * Stay still. Search. Enter stores.
2098 * Pick up treasure if "pickup" is true.
2099 * @param creature_ptr プレーヤーへの参照ポインタ
2100 * @param pickup アイテムの自動拾いを行うならTRUE
2103 void do_cmd_stay(player_type *creature_ptr, bool pickup)
2105 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2107 /* Allow repeated command */
2110 /* Set repeat count */
2111 command_rep = command_arg - 1;
2112 creature_ptr->redraw |= (PR_STATE);
2114 /* Cancel the arg */
2118 take_turn(creature_ptr, 100);
2120 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2121 (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, mpe_mode);
2126 * @brief 「休む」動作コマンドのメインルーチン /
2127 * Resting allows a player to safely restore his hp -RAK-
2128 * @param creature_ptr プレーヤーへの参照ポインタ
2131 void do_cmd_rest(player_type *creature_ptr)
2133 set_action(creature_ptr, ACTION_NONE);
2135 if ((creature_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(creature_ptr) || INTERUPTING_SONG_EFFECT(creature_ptr)))
2137 stop_singing(creature_ptr);
2140 if (hex_spelling_any(creature_ptr)) stop_hex_spell_all(creature_ptr);
2142 /* Prompt for time if needed */
2143 if (command_arg <= 0)
2145 concptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2146 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2151 strcpy(out_val, "&");
2153 /* Ask for duration */
2154 if (!get_string(p, out_val, 4)) return;
2156 /* Rest until done */
2157 if (out_val[0] == '&')
2159 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2163 else if (out_val[0] == '*')
2165 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2171 command_arg = (COMMAND_ARG)atoi(out_val);
2172 if (command_arg <= 0) return;
2176 if (command_arg > 9999) command_arg = 9999;
2178 if (creature_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(creature_ptr, FALSE);
2180 /* Take a turn (?) */
2181 take_turn(creature_ptr, 100);
2183 /* The sin of sloth */
2184 if (command_arg > 100) chg_virtue(creature_ptr, V_DILIGENCE, -1);
2186 /* Why are you sleeping when there's no need? WAKE UP!*/
2187 if ((creature_ptr->chp == creature_ptr->mhp) &&
2188 (creature_ptr->csp == creature_ptr->msp) &&
2189 !creature_ptr->blind && !creature_ptr->confused &&
2190 !creature_ptr->poisoned && !creature_ptr->afraid &&
2191 !creature_ptr->stun && !creature_ptr->cut &&
2192 !creature_ptr->slow && !creature_ptr->paralyzed &&
2193 !creature_ptr->image && !creature_ptr->word_recall &&
2194 !creature_ptr->alter_reality)
2195 chg_virtue(creature_ptr, V_DILIGENCE, -1);
2197 /* Save the rest code */
2198 creature_ptr->resting = command_arg;
2199 creature_ptr->action = ACTION_REST;
2200 creature_ptr->update |= (PU_BONUS);
2201 update_creature(creature_ptr);
2203 creature_ptr->redraw |= (PR_STATE);
2204 update_output(creature_ptr);
2213 * @brief 射撃処理のメインルーチン
2214 * @param creature_ptr プレーヤーへの参照ポインタ
2215 * @param snipe_type ???
2218 void do_cmd_fire(player_type *creature_ptr, SPELL_IDX snipe_type)
2221 object_type *j_ptr, *ammo_ptr;
2224 if(creature_ptr->wild_mode) return;
2226 creature_ptr->is_fired = FALSE; /* not fired yet */
2228 /* Get the "bow" (if any) */
2229 j_ptr = &creature_ptr->inventory_list[INVEN_BOW];
2231 /* Require a launcher */
2234 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
2239 if (j_ptr->sval == SV_CRIMSON)
2241 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
2246 if (j_ptr->sval == SV_HARP)
2248 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
2254 if (creature_ptr->special_defense & KATA_MUSOU)
2256 set_action(creature_ptr, ACTION_NONE);
2259 q = _("どれを撃ちますか? ", "Fire which item? ");
2260 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
2262 ammo_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), creature_ptr->tval_ammo);
2270 exe_fire(creature_ptr, item, j_ptr, snipe_type);
2272 if (!creature_ptr->is_fired || creature_ptr->pclass != CLASS_SNIPER) return;
2274 /* Sniper actions after some shootings */
2275 if (snipe_type == SP_AWAY)
2277 teleport_player(creature_ptr, 10 + (creature_ptr->concent * 2), 0L);
2280 if (snipe_type == SP_FINAL)
2282 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
2283 (void)set_slow(creature_ptr, creature_ptr->slow + randint0(7) + 7, FALSE);
2284 (void)set_stun(creature_ptr, creature_ptr->stun + randint1(25));
2290 * @brief 投射処理メインルーチン /
2291 * Throw an object from the pack or floor.
2293 * @param creature_ptr プレーヤーへの参照ポインタ
2294 * @param boomerang ブーメラン処理ならばTRUE
2295 * @param shuriken 忍者の手裏剣処理ならばTRUE
2296 * @return ターンを消費した場合TRUEを返す
2299 * Note: "unseen" monsters are very hard to hit.
2301 * Should throwing a weapon do full damage? Should it allow the magic
2302 * to hit bonus of the weapon to have an effect? Should it ever cause
2303 * the item to be destroyed? Should it do any damage at all?
2306 bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_IDX shuriken)
2311 POSITION y, x, ty, tx, prev_y, prev_x;
2312 POSITION ny[19], nx[19];
2313 int chance, tdam, tdis;
2314 int mul, div, dd, ds;
2315 int cur_dis, visible;
2322 bool hit_body = FALSE;
2323 bool hit_wall = FALSE;
2324 bool equiped_item = FALSE;
2325 bool return_when_thrown = FALSE;
2327 GAME_TEXT o_name[MAX_NLEN];
2329 int msec = delay_factor * delay_factor * delay_factor;
2331 BIT_FLAGS flgs[TR_FLAG_SIZE];
2333 bool come_back = FALSE;
2334 bool do_drop = TRUE;
2336 if (creature_ptr->wild_mode) return FALSE;
2338 if (creature_ptr->special_defense & KATA_MUSOU)
2340 set_action(creature_ptr, ACTION_NONE);
2346 o_ptr = &creature_ptr->inventory_list[item];
2350 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM))
2352 item_tester_hook = item_tester_hook_boomerang;
2353 q = _("どの武器を投げますか? ", "Throw which item? ");
2354 s = _("投げる武器がない。", "You have nothing to throw.");
2355 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP), 0);
2362 else if (has_melee_weapon(creature_ptr, INVEN_LARM))
2365 o_ptr = &creature_ptr->inventory_list[item];
2370 o_ptr = &creature_ptr->inventory_list[item];
2375 q = _("どのアイテムを投げますか? ", "Throw which item? ");
2376 s = _("投げるアイテムがない。", "You have nothing to throw.");
2377 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP), 0);
2385 /* Item is cursed */
2386 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
2388 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
2392 if (creature_ptr->current_floor_ptr->inside_arena && !boomerang)
2394 if (o_ptr->tval != TV_SPIKE)
2396 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
2404 object_copy(q_ptr, o_ptr);
2406 /* Extract the thrown object's flags. */
2407 object_flags(q_ptr, flgs);
2408 torch_flags(q_ptr, flgs);
2410 /* Distribute the charges of rods/wands between the stacks */
2411 distribute_charges(o_ptr, q_ptr, 1);
2416 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
2418 if (creature_ptr->mighty_throw) mult += 3;
2420 /* Extract a "distance multiplier" */
2421 /* Changed for 'launcher' mutation */
2422 mul = 10 + 2 * (mult - 1);
2424 /* Enforce a minimum "weight" of one pound */
2425 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
2426 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
2428 /* Hack -- Distance -- Reward strength, penalize weight */
2429 tdis = (adj_str_blow[creature_ptr->stat_ind[A_STR]] + 20) * mul / div;
2431 /* Max distance of 10-18 */
2432 if (tdis > mul) tdis = mul;
2436 ty = randint0(101) - 50 + creature_ptr->y;
2437 tx = randint0(101) - 50 + creature_ptr->x;
2441 project_length = tdis + 1;
2443 /* Get a direction (or cancel) */
2444 if (!get_aim_dir(&dir)) return FALSE;
2446 /* Predict the "target" location */
2447 tx = creature_ptr->x + 99 * ddx[dir];
2448 ty = creature_ptr->y + 99 * ddy[dir];
2450 /* Check for "target request" */
2451 if ((dir == 5) && target_okay())
2457 project_length = 0; /* reset to default */
2460 if ((q_ptr->name1 == ART_MJOLLNIR) ||
2461 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
2462 return_when_thrown = TRUE;
2466 inven_item_increase(creature_ptr, item, -1);
2467 if (!return_when_thrown)
2468 inven_item_describe(creature_ptr, item);
2469 inven_item_optimize(creature_ptr, item);
2473 floor_item_increase(creature_ptr->current_floor_ptr, 0 - item, -1);
2474 floor_item_optimize(creature_ptr->current_floor_ptr, 0 - item);
2477 if (item >= INVEN_RARM)
2479 equiped_item = TRUE;
2480 creature_ptr->redraw |= (PR_EQUIPPY);
2483 take_turn(creature_ptr, 100);
2485 /* Rogue and Ninja gets bonus */
2486 if ((creature_ptr->pclass == CLASS_ROGUE) || (creature_ptr->pclass == CLASS_NINJA))
2487 creature_ptr->energy_use -= creature_ptr->lev;
2489 /* Start at the player */
2490 y = creature_ptr->y;
2491 x = creature_ptr->x;
2493 handle_stuff(creature_ptr);
2495 if ((creature_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
2496 else shuriken = FALSE;
2498 /* Chance of hitting */
2499 if (have_flag(flgs, TR_THROW)) chance = ((creature_ptr->skill_tht) +
2500 ((creature_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
2501 else chance = (creature_ptr->skill_tht + (creature_ptr->to_h_b * BTH_PLUS_ADJ));
2503 if (shuriken) chance *= 2;
2508 /* Travel until stopped */
2509 for (cur_dis = 0; cur_dis <= tdis; )
2511 /* Hack -- Stop at the target */
2512 if ((y == ty) && (x == tx)) break;
2514 /* Calculate the new location (see "project()") */
2517 mmove2(&ny[cur_dis], &nx[cur_dis], creature_ptr->y, creature_ptr->x, ty, tx);
2519 /* Stopped by walls/doors */
2520 if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, ny[cur_dis], nx[cur_dis], FF_PROJECT))
2523 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;
2526 /* The player can see the (on screen) missile */
2527 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(creature_ptr, ny[cur_dis], nx[cur_dis]))
2529 SYMBOL_CODE c = object_char(q_ptr);
2530 TERM_COLOR a = object_attr(q_ptr);
2532 /* Draw, Hilite, Fresh, Pause, Erase */
2533 print_rel(creature_ptr, c, a, ny[cur_dis], nx[cur_dis]);
2534 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
2536 Term_xtra(TERM_XTRA_DELAY, msec);
2537 lite_spot(ny[cur_dis], nx[cur_dis]);
2541 /* The player cannot see the missile */
2544 /* Pause anyway, for consistancy */
2545 Term_xtra(TERM_XTRA_DELAY, msec);
2551 /* Save the new location */
2555 /* Advance the distance */
2558 /* Monster here, Try to hit it */
2559 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
2561 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
2562 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
2563 GAME_TEXT m_name[MAX_NLEN];
2564 monster_name(g_ptr->m_idx, m_name);
2566 /* Check the visibility */
2567 visible = m_ptr->ml;
2569 /* Note the collision */
2572 /* Did we hit it (penalize range) */
2573 if (test_hit_fire(creature_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
2577 /* Handle unseen monster */
2580 /* Invisible monster */
2581 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
2584 /* Handle visible monster */
2587 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
2591 if (!creature_ptr->image) monster_race_track(m_ptr->ap_r_idx);
2592 health_track(g_ptr->m_idx);
2596 /* Hack -- Base damage from thrown object */
2599 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
2600 tdam = damroll(dd, ds);
2601 /* Apply special damage */
2602 tdam = tot_dam_aux(creature_ptr, q_ptr, tdam, m_ptr, 0, TRUE);
2603 tdam = critical_shot(creature_ptr, q_ptr->weight, q_ptr->to_h, 0, tdam);
2604 if (q_ptr->to_d > 0)
2605 tdam += q_ptr->to_d;
2607 tdam += -q_ptr->to_d;
2611 tdam *= (mult+creature_ptr->num_blow[item - INVEN_RARM]);
2612 tdam += creature_ptr->to_d_m;
2614 else if (have_flag(flgs, TR_THROW))
2617 tdam += creature_ptr->to_d_m;
2625 tdam += ((creature_ptr->lev+30)*(creature_ptr->lev+30)-900)/55;
2628 /* No negative damage */
2629 if (tdam < 0) tdam = 0;
2631 /* Modify the damage */
2632 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
2634 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
2635 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
2637 /* Hit the monster, check for death */
2638 if (mon_take_hit(g_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
2646 message_pain(g_ptr->m_idx, tdam);
2648 /* Anger the monster */
2649 if ((tdam > 0) && !object_is_potion(q_ptr))
2650 anger_monster(m_ptr);
2652 if (fear && m_ptr->ml)
2655 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
2665 /* decrease toach's fuel */
2666 if (hit_body) torch_lost_fuel(q_ptr);
2668 /* Chance of breakage (during attacks) */
2669 j = (hit_body ? breakage_chance(q_ptr, creature_ptr->pclass == CLASS_ARCHER, 0) : 0);
2671 /* Figurines transform */
2672 if ((q_ptr->tval == TV_FIGURINE) && !(creature_ptr->current_floor_ptr->inside_arena))
2676 if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
2677 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
2678 else if (object_is_cursed(q_ptr))
2679 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
2683 /* Potions smash open */
2684 if (object_is_potion(q_ptr))
2686 if (hit_body || hit_wall || (randint1(100) < j))
2688 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
2690 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
2692 monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx];
2693 if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx && is_friendly(m_ptr) && !MON_INVULNER(m_ptr))
2695 GAME_TEXT m_name[MAX_NLEN];
2696 monster_desc(m_name, m_ptr, 0);
2697 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
2698 set_hostile(&creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx]);
2709 if (return_when_thrown)
2711 int back_chance = randint1(30)+20+((int)(adj_dex_th[creature_ptr->stat_ind[A_DEX]]) - 128);
2712 char o2_name[MAX_NLEN];
2713 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
2716 if (boomerang) back_chance += 4+randint1(5);
2717 if (super_boomerang) back_chance += 100;
2718 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2720 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
2722 for (i = cur_dis - 1; i > 0; i--)
2724 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(creature_ptr, ny[i], nx[i]))
2726 char c = object_char(q_ptr);
2727 byte a = object_attr(q_ptr);
2729 /* Draw, Hilite, Fresh, Pause, Erase */
2730 print_rel(creature_ptr, c, a, ny[i], nx[i]);
2731 move_cursor_relative(ny[i], nx[i]);
2733 Term_xtra(TERM_XTRA_DELAY, msec);
2734 lite_spot(ny[i], nx[i]);
2739 /* Pause anyway, for consistancy */
2740 Term_xtra(TERM_XTRA_DELAY, msec);
2743 if((back_chance > 37) && !creature_ptr->blind && (item >= 0))
2745 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
2752 msg_format(_("%sを受け損ねた!", "%s comes backs, but you can't catch!"), o2_name);
2756 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
2758 y = creature_ptr->y;
2759 x = creature_ptr->x;
2764 msg_format(_("%sが返ってこなかった!", "%s doesn't come back!"), o2_name);
2770 if (item == INVEN_RARM || item == INVEN_LARM)
2772 /* Access the wield slot */
2773 o_ptr = &creature_ptr->inventory_list[item];
2775 /* Wear the new stuff */
2776 object_copy(o_ptr, q_ptr);
2778 creature_ptr->total_weight += q_ptr->weight;
2780 /* Increment the equip counter by hand */
2781 creature_ptr->equip_cnt++;
2783 creature_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA);
2784 creature_ptr->window |= (PW_EQUIP);
2788 inven_carry(creature_ptr, q_ptr);
2792 else if (equiped_item)
2794 verify_equip_slot(creature_ptr, item);
2795 calc_android_exp(creature_ptr);
2800 if (cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_PROJECT))
2802 (void)drop_near(creature_ptr, q_ptr, j, y, x);
2806 (void)drop_near(creature_ptr, q_ptr, j, prev_y, prev_x);
2814 * @brief 自殺するコマンドのメインルーチン
2815 * Hack -- commit suicide
2819 void do_cmd_suicide(player_type *creature_ptr)
2826 /* Verify Retirement */
2827 if (current_world_ptr->total_winner)
2830 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
2833 /* Verify Suicide */
2837 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
2840 if (!current_world_ptr->noscore)
2842 /* Special Verification for suicide */
2843 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
2848 if (i != '@') return;
2850 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
2853 /* Initialize "last message" buffer */
2854 if (creature_ptr->last_message) string_free(creature_ptr->last_message);
2855 creature_ptr->last_message = NULL;
2857 /* Hack -- Note *winning* message */
2858 if (current_world_ptr->total_winner && last_words)
2860 char buf[1024] = "";
2861 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
2864 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf));
2865 } while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
2869 creature_ptr->last_message = string_make(buf);
2870 msg_print(creature_ptr->last_message);
2875 creature_ptr->playing = FALSE;
2877 /* Kill the player */
2878 creature_ptr->is_dead = TRUE;
2879 creature_ptr->leaving = TRUE;
2881 if (!current_world_ptr->total_winner)
2883 exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
2884 exe_write_diary(creature_ptr, NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
2885 exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 1, "\n\n\n\n");
2888 /* Cause of death */
2889 (void)strcpy(creature_ptr->died_from, _("途中終了", "Quitting"));