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.
17 * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
18 * @param down_stair TRUEならば階段を降りる処理、FALSEなら階段を昇る処理による内容
19 * @return フロア移動を実際に行うならTRUE、キャンセルする場合はFALSE
21 bool confirm_leave_level(bool down_stair)
23 quest_type *q_ptr = &quest[p_ptr->inside_quest];
25 /* Confirm leaving from once only quest */
26 if (confirm_quest && p_ptr->inside_quest &&
27 (q_ptr->type == QUEST_TYPE_RANDOM ||
28 (q_ptr->flags & QUEST_FLAG_ONCE &&
29 q_ptr->status != QUEST_STATUS_COMPLETED) ||
30 (q_ptr->flags & QUEST_FLAG_TOWER &&
31 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
32 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
35 msg_print("この階を一度去ると二度と戻って来られません。");
36 if (get_check("本当にこの階を去りますか?")) return TRUE;
38 msg_print("You can't come back here once you leave this floor.");
39 if (get_check("Really leave this floor? ")) return TRUE;
50 * @brief 階段を使って階層を昇る処理 / Go up one level
53 void do_cmd_go_up(void)
58 cave_type *c_ptr = &cave[py][px];
59 feature_type *f_ptr = &f_info[c_ptr->feat];
63 if (p_ptr->special_defense & KATA_MUSOU)
65 set_action(ACTION_NONE);
69 if (!have_flag(f_ptr->flags, FF_LESS))
71 msg_print(_("ここには上り階段が見当たらない。", "I see no up staircase here."));
76 if (have_flag(f_ptr->flags, FF_QUEST))
78 /* Cancel the command */
79 if (!confirm_leave_level(FALSE)) return;
84 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
85 msg_print("なんだこの階段は!");
87 msg_print("上の階に登った。");
89 msg_print("You enter the up staircase.");
94 p_ptr->inside_quest = c_ptr->special;
96 /* Activate the quest */
97 if (!quest[p_ptr->inside_quest].status)
99 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
101 init_flags = INIT_ASSIGN;
102 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
104 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
107 /* Leaving a quest */
108 if (!p_ptr->inside_quest)
114 p_ptr->leaving = TRUE;
119 /* Hack -- take a turn */
122 /* End the command */
132 go_up = confirm_leave_level(FALSE);
135 /* Cancel the command */
138 /* Hack -- take a turn */
141 if (autosave_l) do_cmd_save_game(TRUE);
143 /* For a random quest */
144 if (p_ptr->inside_quest &&
145 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
149 p_ptr->inside_quest = 0;
152 /* For a fixed quest */
153 if (p_ptr->inside_quest &&
154 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
158 p_ptr->inside_quest = c_ptr->special;
163 /* For normal dungeon and random quest */
167 if (have_flag(f_ptr->flags, FF_SHAFT))
169 /* Create a way back */
170 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
176 /* Create a way back */
177 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
182 /* Get out from current dungeon */
183 if (dun_level - up_num < d_info[dungeon_type].mindepth)
186 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
189 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
190 msg_print(_("なんだこの階段は!", ""));
191 else if (up_num == dun_level)
192 msg_print(_("地上に戻った。", "You go back to the surface."));
194 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
197 p_ptr->leaving = TRUE;
202 * @brief 階段を使って階層を降りる処理 / Go down one level
205 void do_cmd_go_down(void)
208 cave_type *c_ptr = &cave[py][px];
209 feature_type *f_ptr = &f_info[c_ptr->feat];
211 bool fall_trap = FALSE;
214 if (p_ptr->special_defense & KATA_MUSOU)
216 set_action(ACTION_NONE);
220 if (!have_flag(f_ptr->flags, FF_MORE))
222 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
226 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
229 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
234 /* Quest down stairs */
235 else if (have_flag(f_ptr->flags, FF_QUEST))
237 /* Confirm Leaving */
238 if(!confirm_leave_level(TRUE)) return;
241 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
242 msg_print("なんだこの階段は!");
244 msg_print("下の階に降りた。");
246 msg_print("You enter the down staircase.");
252 p_ptr->inside_quest = c_ptr->special;
254 /* Activate the quest */
255 if (!quest[p_ptr->inside_quest].status)
257 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
259 init_flags = INIT_ASSIGN;
260 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
262 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
265 /* Leaving a quest */
266 if (!p_ptr->inside_quest)
272 p_ptr->leaving = TRUE;
278 /* Hack -- take a turn */
284 int target_dungeon = 0;
288 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
290 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
292 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
295 if (!max_dlv[target_dungeon])
297 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
298 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
299 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
302 /* Save old player position */
305 dungeon_type = (byte)target_dungeon;
308 * Clear all saved floors
309 * and create a first saved floor
311 prepare_change_floor_mode(CFM_FIRST_FLOOR);
314 /* Hack -- take a turn */
317 if (autosave_l) do_cmd_save_game(TRUE);
320 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
325 /* Enter the dungeon just now */
326 p_ptr->enter_dungeon = TRUE;
327 down_num = d_info[dungeon_type].mindepth;
332 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
333 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
338 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
345 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
349 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
350 msg_print(_("なんだこの階段は!", ""));
352 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
358 p_ptr->leaving = TRUE;
362 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
366 if (have_flag(f_ptr->flags, FF_SHAFT))
368 /* Create a way back */
369 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
373 /* Create a way back */
374 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
382 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
385 void do_cmd_search(void)
387 /* Allow repeated command */
390 /* Set repeat count */
391 command_rep = command_arg - 1;
393 /* Redraw the state */
394 p_ptr->redraw |= (PR_STATE);
409 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
410 * @param y 走査対象にしたいマスのY座標
411 * @param x 走査対象にしたいマスのX座標
412 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
413 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
415 static s16b chest_check(int y, int x, bool trapped)
417 cave_type *c_ptr = &cave[y][x];
419 s16b this_o_idx, next_o_idx = 0;
422 /* Scan all objects in the grid */
423 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
428 o_ptr = &o_list[this_o_idx];
430 /* Acquire next object */
431 next_o_idx = o_ptr->next_o_idx;
433 /* Skip unknown chests XXX XXX */
434 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
436 /* Check for non empty chest */
437 if ((o_ptr->tval == TV_CHEST) &&
438 (((!trapped) && (o_ptr->pval)) || /* non empty */
439 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
451 * @brief 箱からアイテムを引き出す /
452 * Allocates objects upon opening a chest -BEN-
453 * @param scatter TRUEならばトラップによるアイテムの拡散処理
454 * @param y 箱の存在するマスのY座標
455 * @param x 箱の存在するマスのX座標
456 * @param o_idx 箱のオブジェクトID
460 * Disperse treasures from the given chest, centered at (x,y).
462 * Small chests often contain "gold", while Large chests always contain
463 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
464 * and Steel chests contain 6 items. The "value" of the items in a
465 * chest is based on the "power" of the chest, which is in turn based
466 * on the level on which the chest is generated.
469 static void chest_death(bool scatter, int y, int x, s16b o_idx)
479 object_type *o_ptr = &o_list[o_idx];
482 /* Small chests often hold "gold" */
483 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
485 /* Determine how much to drop (see above) */
486 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
488 if (o_ptr->sval == SV_CHEST_KANDUME)
493 object_level = o_ptr->xtra3;
497 /* Determine the "value" of the items */
498 object_level = ABS(o_ptr->pval) + 10;
501 /* Zero pval means empty chest */
502 if (!o_ptr->pval) number = 0;
504 /* Opening a chest */
505 opening_chest = TRUE;
507 /* Drop some objects (non-chests) */
508 for (; number > 0; --number)
510 /* Get local object */
513 /* Wipe the object */
516 /* Small chests often drop gold */
517 if (small && (randint0(100) < 25))
520 if (!make_gold(q_ptr)) continue;
523 /* Otherwise drop an item */
526 /* Make a good object */
527 if (!make_object(q_ptr, mode)) continue;
530 /* If chest scatters its contents, pick any floor square. */
534 for (i = 0; i < 200; i++)
536 /* Pick a totally random spot. */
537 y = randint0(MAX_HGT);
538 x = randint0(MAX_WID);
540 /* Must be an empty floor. */
541 if (!cave_empty_bold(y, x)) continue;
543 /* Place the object there. */
544 drop_near(q_ptr, -1, y, x);
550 /* Normally, drop object near the chest. */
551 else drop_near(q_ptr, -1, y, x);
554 /* Reset the object level */
555 object_level = base_level;
557 /* No longer opening a chest */
558 opening_chest = FALSE;
570 * Chests have traps too.
571 * @param y 箱の存在するマスのY座標
572 * @param x 箱の存在するマスのX座標
573 * @param o_idx 箱のオブジェクトID
577 * Exploding chest destroys contents (and traps).
578 * Note that the chest itself is never destroyed.
581 static void chest_trap(int y, int x, s16b o_idx)
585 object_type *o_ptr = &o_list[o_idx];
587 int mon_level = o_ptr->xtra3;
589 /* Ignore disarmed chests */
590 if (o_ptr->pval <= 0) return;
592 /* Obtain the traps */
593 trap = chest_traps[o_ptr->pval];
596 if (trap & (CHEST_LOSE_STR))
599 msg_print("仕掛けられていた小さな針に刺されてしまった!");
600 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "毒針", -1);
602 msg_print("A small needle has pricked you!");
603 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
606 (void)do_dec_stat(A_STR);
609 /* Lose constitution */
610 if (trap & (CHEST_LOSE_CON))
613 msg_print("仕掛けられていた小さな針に刺されてしまった!");
614 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "毒針", -1);
616 msg_print("A small needle has pricked you!");
617 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
620 (void)do_dec_stat(A_CON);
624 if (trap & (CHEST_POISON))
626 msg_print(_("突如吹き出した緑色のガスに包み込まれた!", "A puff of green gas surrounds you!"));
627 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
629 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
634 if (trap & (CHEST_PARALYZE))
636 msg_print(_("突如吹き出した黄色いガスに包み込まれた!", "A puff of yellow gas surrounds you!"));
637 if (!p_ptr->free_act)
639 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
643 /* Summon monsters */
644 if (trap & (CHEST_SUMMON))
646 int num = 2 + randint1(3);
647 msg_print(_("突如吹き出した煙に包み込まれた!", "You are enveloped in a cloud of smoke!"));
648 for (i = 0; i < num; i++)
650 if (randint1(100)<dun_level)
651 activate_hi_summon(py, px, FALSE);
653 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
657 /* Elemental summon. */
658 if (trap & (CHEST_E_SUMMON))
660 msg_print(_("宝を守るためにエレメンタルが現れた!", "Elemental beings appear to protect their treasures!"));
661 for (i = 0; i < randint1(3) + 5; i++)
663 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
667 /* Force clouds, then summon birds. */
668 if (trap & (CHEST_BIRD_STORM))
670 msg_print(_("鳥の群れがあなたを取り巻いた!", "A storm of birds swirls around you!"));
672 for (i = 0; i < randint1(3) + 3; i++)
673 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
675 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
677 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
681 /* Various colorful summonings. */
682 if (trap & (CHEST_H_SUMMON))
687 msg_print(_("炎と硫黄の雲の中に悪魔が姿を現した!", "Demons materialize in clouds of fire and brimstone!"));
688 for (i = 0; i < randint1(3) + 2; i++)
690 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
691 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
695 /* Summon dragons. */
698 msg_print(_("暗闇にドラゴンの影がぼんやりと現れた!", "Draconic forms loom out of the darkness!"));
699 for (i = 0; i < randint1(3) + 2; i++)
701 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
705 /* Summon hybrids. */
708 msg_print(_("奇妙な姿の怪物が襲って来た!", "Creatures strange and twisted assault you!"));
709 for (i = 0; i < randint1(5) + 3; i++)
711 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
715 /* Summon vortices (scattered) */
718 msg_print(_("渦巻が合体し、破裂した!", "Vortices coalesce and wreak destruction!"));
719 for (i = 0; i < randint1(3) + 2; i++)
721 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
727 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
729 /* Determine how many nasty tricks can be played. */
730 int nasty_tricks_count = 4 + randint0(3);
733 msg_print(_("恐ろしい声が響いた: 「暗闇が汝をつつまん!」", "Hideous voices bid: 'Let the darkness have thee!'"));
734 /* This is gonna hurt... */
735 for (; nasty_tricks_count > 0; nasty_tricks_count--)
737 /* ...but a high saving throw does help a little. */
738 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
740 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), _("破滅のトラップの宝箱", "a chest dispel-player trap"), -1);
741 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
744 if (!p_ptr->free_act)
745 (void)set_paralyzed(p_ptr->paralyzed + 2 +
748 (void)set_stun(p_ptr->stun + 10 +
751 else if (one_in_(3)) apply_disenchant(0);
754 (void)do_dec_stat(A_STR);
755 (void)do_dec_stat(A_DEX);
756 (void)do_dec_stat(A_CON);
757 (void)do_dec_stat(A_INT);
758 (void)do_dec_stat(A_WIS);
759 (void)do_dec_stat(A_CHR);
761 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
766 /* Aggravate monsters. */
767 if (trap & (CHEST_ALARM))
769 msg_print(_("けたたましい音が鳴り響いた!", "An alarm sounds!"));
770 aggravate_monsters(0);
774 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
776 msg_print(_("突然、箱が爆発した!", "There is a sudden explosion!"));
777 msg_print(_("箱の中の物はすべて粉々に砕け散った!", "Everything inside the chest is destroyed!"));
779 sound(SOUND_EXPLODE);
780 take_hit(DAMAGE_ATTACK, damroll(5, 8), _("爆発する箱", "an exploding chest"), -1);
782 /* Scatter contents. */
783 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
785 msg_print(_("宝箱の中身はダンジョンじゅうに散乱した!", "The contents of the chest scatter all over the dungeon!"));
786 chest_death(TRUE, y, x, o_idx);
793 * @brief 箱を開けるコマンドのメインルーチン /
794 * Attempt to open the given chest at the given location
795 * @param y 箱の存在するマスのY座標
796 * @param x 箱の存在するマスのX座標
797 * @param o_idx 箱のオブジェクトID
798 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
800 * Assume there is no monster blocking the destination
802 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
810 object_type *o_ptr = &o_list[o_idx];
816 /* Attempt to unlock it */
819 /* Assume locked, and thus not open */
822 /* Get the "disarm" factor */
823 i = p_ptr->skill_dis;
825 /* Penalize some conditions */
826 if (p_ptr->blind || no_lite()) i = i / 10;
827 if (p_ptr->confused || p_ptr->image) i = i / 10;
829 /* Extract the difficulty */
832 /* Always have a small chance of success */
835 /* Success -- May still have traps */
836 if (randint0(100) < j)
838 msg_print(_("鍵をはずした。", "You have picked the lock."));
843 /* Failure -- Keep trying */
846 /* We may continue repeating */
848 if (flush_failure) flush();
849 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
854 /* Allowed to open */
857 /* Apply chest traps, if any */
858 chest_trap(y, x, o_idx);
860 /* Let the Chest drop items */
861 chest_death(FALSE, y, x, o_idx);
869 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
872 * @brief 地形は開くものであって、かつ開かれているかを返す /
873 * Attempt to open the given chest at the given location
875 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
877 static bool is_open(int feat)
879 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
884 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
885 * Attempt to open the given chest at the given location
886 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
887 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
888 * @param test 地形条件を判定するための関数ポインタ
889 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
891 * @details Return the number of features around (or under) the character.
892 * Usually look for doors and floor traps.
894 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
896 int d, count, xx, yy;
898 /* Count how many matches */
901 /* Check around (and under) the character */
902 for (d = 0; d < 9; d++)
907 /* if not searching under player continue */
908 if ((d == 8) && !under) continue;
910 /* Extract adjacent (legal) location */
911 yy = py + ddy_ddd[d];
912 xx = px + ddx_ddd[d];
915 c_ptr = &cave[yy][xx];
917 /* Must have knowledge */
918 if (!(c_ptr->info & (CAVE_MARK))) continue;
920 /* Feature code (applying "mimic" field) */
921 feat = get_feat_mimic(c_ptr);
923 /* Not looking for this feature */
924 if (!((*test)(feat))) continue;
929 /* Remember the location. Only useful if only one match */
940 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
941 * Return the number of chests around (or under) the character.
942 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
943 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
944 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
947 * If requested, count only trapped chests.
949 static int count_chests(int *y, int *x, bool trapped)
955 /* Count how many matches */
958 /* Check around (and under) the character */
959 for (d = 0; d < 9; d++)
961 /* Extract adjacent (legal) location */
962 int yy = py + ddy_ddd[d];
963 int xx = px + ddx_ddd[d];
965 /* No (visible) chest is there */
966 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
968 /* Grab the object */
969 o_ptr = &o_list[o_idx];
972 if (o_ptr->pval == 0) continue;
974 /* No (known) traps here */
975 if (trapped && (!object_is_known(o_ptr) ||
976 !chest_traps[o_ptr->pval])) continue;
981 /* Remember the location. Only useful if only one match */
992 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
993 * Convert an adjacent location to a direction.
994 * @param y 方角を確認したY座標
995 * @param x 方角を確認したX座標
998 static int coords_to_dir(int y, int x)
1000 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1007 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1009 return d[dx + 1][dy + 1];
1012 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1016 * @brief 「開ける」動作コマンドのサブルーチン /
1017 * Perform the basic "open" command on doors
1018 * @param y 対象を行うマスのY座標
1019 * @param x 対象を行うマスのX座標
1020 * @return 実際に処理が行われた場合TRUEを返す。
1022 * Assume destination is a closed/locked/jammed door
1023 * Assume there is no monster blocking the destination
1024 * Returns TRUE if repeated commands may continue
1026 static bool do_cmd_open_aux(int y, int x)
1030 /* Get requested grid */
1031 cave_type *c_ptr = &cave[y][x];
1033 feature_type *f_ptr = &f_info[c_ptr->feat];
1041 /* Seeing true feature code (ignore mimic) */
1044 if (!have_flag(f_ptr->flags, FF_OPEN))
1047 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1051 else if (f_ptr->power)
1054 i = p_ptr->skill_dis;
1056 /* Penalize some conditions */
1057 if (p_ptr->blind || no_lite()) i = i / 10;
1058 if (p_ptr->confused || p_ptr->image) i = i / 10;
1060 /* Extract the lock power */
1063 /* Extract the difficulty XXX XXX XXX */
1066 /* Always have a small chance of success */
1070 if (randint0(100) < j)
1073 msg_print(_("鍵をはずした。", "You have picked the lock."));
1076 cave_alter_feat(y, x, FF_OPEN);
1079 sound(SOUND_OPENDOOR);
1089 if (flush_failure) flush();
1092 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1094 /* We may keep trying */
1103 cave_alter_feat(y, x, FF_OPEN);
1106 sound(SOUND_OPENDOOR);
1114 * @brief 「開ける」コマンドのメインルーチン /
1115 * Open a closed/locked/jammed door or a closed/locked chest.
1118 * Unlocking a locked door/chest is worth one experience point.
1120 void do_cmd_open(void)
1128 if (p_ptr->special_defense & KATA_MUSOU)
1130 set_action(ACTION_NONE);
1133 #ifdef ALLOW_EASY_OPEN /* TNB */
1135 /* Option: Pick a direction */
1138 int num_doors, num_chests;
1140 /* Count closed doors (locked or jammed) */
1141 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1143 /* Count chests (locked) */
1144 num_chests = count_chests(&y, &x, FALSE);
1146 /* See if only one target */
1147 if (num_doors || num_chests)
1149 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1151 if (!too_many) command_dir = coords_to_dir(y, x);
1155 #endif /* ALLOW_EASY_OPEN -- TNB */
1157 /* Allow repeated command */
1160 /* Set repeat count */
1161 command_rep = command_arg - 1;
1163 /* Redraw the state */
1164 p_ptr->redraw |= (PR_STATE);
1166 /* Cancel the arg */
1170 /* Get a "repeated" direction */
1171 if (get_rep_dir(&dir, TRUE))
1176 /* Get requested location */
1180 /* Get requested grid */
1181 c_ptr = &cave[y][x];
1183 /* Feature code (applying "mimic" field) */
1184 feat = get_feat_mimic(c_ptr);
1186 /* Check for chest */
1187 o_idx = chest_check(y, x, FALSE);
1189 /* Nothing useful */
1190 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
1193 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
1196 /* Monster in the way */
1197 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1203 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1212 /* Open the chest */
1213 more = do_cmd_open_chest(y, x, o_idx);
1220 more = do_cmd_open_aux(y, x);
1224 /* Cancel repeat unless we may continue */
1225 if (!more) disturb(0, 0);
1231 * @brief 「閉じる」動作コマンドのサブルーチン /
1232 * Perform the basic "close" command
1233 * @param y 対象を行うマスのY座標
1234 * @param x 対象を行うマスのX座標
1235 * @return 実際に処理が行われた場合TRUEを返す。
1237 * Assume destination is an open/broken door
1238 * Assume there is no monster blocking the destination
1239 * Returns TRUE if repeated commands may continue
1241 static bool do_cmd_close_aux(int y, int x)
1243 /* Get grid and contents */
1244 cave_type *c_ptr = &cave[y][x];
1245 s16b old_feat = c_ptr->feat;
1251 /* Seeing true feature code (ignore mimic) */
1254 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1256 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
1258 /* Hack -- object in the way */
1259 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
1260 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
1263 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
1267 /* Close the door */
1268 cave_alter_feat(y, x, FF_CLOSE);
1271 if (old_feat == c_ptr->feat)
1274 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
1279 sound(SOUND_SHUTDOOR);
1290 * @brief 「閉じる」コマンドのメインルーチン /
1291 * Close an open door.
1294 * Unlocking a locked door/chest is worth one experience point.
1296 void do_cmd_close(void)
1302 if (p_ptr->special_defense & KATA_MUSOU)
1304 set_action(ACTION_NONE);
1307 #ifdef ALLOW_EASY_OPEN /* TNB */
1309 /* Option: Pick a direction */
1312 /* Count open doors */
1313 if (count_dt(&y, &x, is_open, FALSE) == 1)
1315 command_dir = coords_to_dir(y, x);
1319 #endif /* ALLOW_EASY_OPEN -- TNB */
1321 /* Allow repeated command */
1324 /* Set repeat count */
1325 command_rep = command_arg - 1;
1327 /* Redraw the state */
1328 p_ptr->redraw |= (PR_STATE);
1330 /* Cancel the arg */
1334 /* Get a "repeated" direction */
1335 if (get_rep_dir(&dir,FALSE))
1340 /* Get requested location */
1344 /* Get grid and contents */
1345 c_ptr = &cave[y][x];
1347 /* Feature code (applying "mimic" field) */
1348 feat = get_feat_mimic(c_ptr);
1350 /* Require open/broken door */
1351 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1354 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1357 /* Monster in the way */
1358 else if (c_ptr->m_idx)
1364 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1370 /* Close the door */
1373 /* Close the door */
1374 more = do_cmd_close_aux(y, x);
1378 /* Cancel repeat unless we may continue */
1379 if (!more) disturb(0, 0);
1384 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1385 * Determine if a given grid may be "tunneled"
1386 * @param y 対象を行うマスのY座標
1387 * @param x 対象を行うマスのX座標
1390 static bool do_cmd_tunnel_test(int y, int x)
1392 cave_type *c_ptr = &cave[y][x];
1394 /* Must have knowledge */
1395 if (!(c_ptr->info & CAVE_MARK))
1398 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1404 /* Must be a wall/door/etc */
1405 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1408 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1420 * @brief 「掘る」動作コマンドのサブルーチン /
1421 * Perform the basic "tunnel" command
1422 * @param y 対象を行うマスのY座標
1423 * @param x 対象を行うマスのX座標
1424 * @return 実際に処理が行われた場合TRUEを返す。
1426 * Assumes that no monster is blocking the destination
1427 * Do not use twall anymore
1428 * Returns TRUE if repeated commands may continue
1430 static bool do_cmd_tunnel_aux(int y, int x)
1433 feature_type *f_ptr, *mimic_f_ptr;
1438 /* Verify legality */
1439 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1445 c_ptr = &cave[y][x];
1446 f_ptr = &f_info[c_ptr->feat];
1447 power = f_ptr->power;
1449 /* Feature code (applying "mimic" field) */
1450 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1452 name = f_name + mimic_f_ptr->name;
1457 if (have_flag(f_ptr->flags, FF_PERMANENT))
1460 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1462 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1465 /* Map border (mimiccing Permanent wall) */
1468 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1473 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1476 if (p_ptr->skill_dig > randint0(20 * power))
1479 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1481 /* Remove the feature */
1482 cave_alter_feat(y, x, FF_TUNNEL);
1484 /* Update some things */
1485 p_ptr->update |= (PU_FLOW);
1489 /* Message, keep digging */
1490 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1498 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1501 if (p_ptr->skill_dig > power + randint0(40 * power))
1503 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1506 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1507 p_ptr->update |= (PU_FLOW);
1511 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1513 /* Remove the feature */
1514 cave_alter_feat(y, x, FF_TUNNEL);
1516 chg_virtue(V_DILIGENCE, 1);
1517 chg_virtue(V_NATURE, -1);
1525 /* We may continue chopping */
1526 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1527 /* Occasional Search XXX XXX */
1528 if (randint0(100) < 25) search();
1532 /* We may continue tunelling */
1533 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1540 if (is_hidden_door(c_ptr))
1542 /* Occasional Search XXX XXX */
1543 if (randint0(100) < 25) search();
1552 * @brief 「掘る」動作コマンドのメインルーチン /
1553 * Tunnels through "walls" (including rubble and closed doors)
1557 * Note that you must tunnel in order to hit invisible monsters
1558 * in walls, though moving into walls still takes a turn anyway.
1560 * Digging is very difficult without a "digger" weapon, but can be
1561 * accomplished by strong players using heavy weapons.
1564 void do_cmd_tunnel(void)
1574 if (p_ptr->special_defense & KATA_MUSOU)
1576 set_action(ACTION_NONE);
1579 /* Allow repeated command */
1582 /* Set repeat count */
1583 command_rep = command_arg - 1;
1585 /* Redraw the state */
1586 p_ptr->redraw |= (PR_STATE);
1588 /* Cancel the arg */
1592 /* Get a direction to tunnel, or Abort */
1593 if (get_rep_dir(&dir,FALSE))
1600 c_ptr = &cave[y][x];
1602 /* Feature code (applying "mimic" field) */
1603 feat = get_feat_mimic(c_ptr);
1605 /* No tunnelling through doors */
1606 if (have_flag(f_info[feat].flags, FF_DOOR))
1609 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1612 /* No tunnelling through most features */
1613 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1615 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1618 /* A monster is in the way */
1619 else if (c_ptr->m_idx)
1625 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1634 /* Tunnel through walls */
1635 more = do_cmd_tunnel_aux(y, x);
1639 /* Cancel repetition unless we can continue */
1640 if (!more) disturb(0, 0);
1644 #ifdef ALLOW_EASY_OPEN /* TNB */
1647 * @brief 移動処理による簡易な「開く」処理 /
1649 * @return 開く処理が実際に試みられた場合TRUEを返す
1652 * If there is a jammed/closed/locked door at the given location,
1653 * then attempt to unlock/open it. Return TRUE if an attempt was
1654 * made (successful or not), otherwise return FALSE.
1656 * The code here should be nearly identical to that in
1657 * do_cmd_open_test() and do_cmd_open_aux().
1660 bool easy_open_door(int y, int x)
1664 cave_type *c_ptr = &cave[y][x];
1665 feature_type *f_ptr = &f_info[c_ptr->feat];
1667 /* Must be a closed door */
1668 if (!is_closed_door(c_ptr->feat))
1675 if (!have_flag(f_ptr->flags, FF_OPEN))
1678 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1683 else if (f_ptr->power)
1686 i = p_ptr->skill_dis;
1688 /* Penalize some conditions */
1689 if (p_ptr->blind || no_lite()) i = i / 10;
1690 if (p_ptr->confused || p_ptr->image) i = i / 10;
1692 /* Extract the lock power */
1695 /* Extract the difficulty XXX XXX XXX */
1698 /* Always have a small chance of success */
1702 if (randint0(100) < j)
1705 msg_print(_("鍵をはずした。", "You have picked the lock."));
1708 cave_alter_feat(y, x, FF_OPEN);
1711 sound(SOUND_OPENDOOR);
1721 if (flush_failure) flush();
1724 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1733 cave_alter_feat(y, x, FF_OPEN);
1736 sound(SOUND_OPENDOOR);
1743 #endif /* ALLOW_EASY_OPEN -- TNB */
1747 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1748 * Perform the basic "disarm" command
1749 * @param y 解除を行うマスのY座標
1750 * @param x 解除を行うマスのX座標
1751 * @param o_idx 箱のオブジェクトID
1752 * @return ターンを消費する処理が行われた場合TRUEを返す
1755 * Assume destination is a visible trap
1756 * Assume there is no monster blocking the destination
1757 * Returns TRUE if repeated commands may continue
1760 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1766 object_type *o_ptr = &o_list[o_idx];
1772 /* Get the "disarm" factor */
1773 i = p_ptr->skill_dis;
1775 /* Penalize some conditions */
1776 if (p_ptr->blind || no_lite()) i = i / 10;
1777 if (p_ptr->confused || p_ptr->image) i = i / 10;
1779 /* Extract the difficulty */
1780 j = i - o_ptr->pval;
1782 /* Always have a small chance of success */
1785 /* Must find the trap first. */
1786 if (!object_is_known(o_ptr))
1788 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1792 /* Already disarmed/unlocked */
1793 else if (o_ptr->pval <= 0)
1795 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1798 /* No traps to find. */
1799 else if (!chest_traps[o_ptr->pval])
1801 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1804 /* Success (get a lot of experience) */
1805 else if (randint0(100) < j)
1807 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1808 gain_exp(o_ptr->pval);
1809 o_ptr->pval = (0 - o_ptr->pval);
1812 /* Failure -- Keep trying */
1813 else if ((i > 5) && (randint1(i) > 5))
1815 /* We may keep trying */
1817 if (flush_failure) flush();
1818 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1821 /* Failure -- Set off the trap */
1824 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1826 chest_trap(y, x, o_idx);
1835 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1836 * Perform the basic "disarm" command
1837 * @param y 解除を行うマスのY座標
1838 * @param x 解除を行うマスのX座標
1839 * @param dir プレイヤーからみた方向ID
1840 * @return ターンを消費する処理が行われた場合TRUEを返す
1843 * Assume destination is a visible trap
1844 * Assume there is no monster blocking the destination
1845 * Returns TRUE if repeated commands may continue
1848 #ifdef ALLOW_EASY_DISARM /* TNB */
1850 bool do_cmd_disarm_aux(int y, int x, int dir)
1852 #else /* ALLOW_EASY_DISARM -- TNB */
1854 static bool do_cmd_disarm_aux(int y, int x, int dir)
1856 #endif /* ALLOW_EASY_DISARM -- TNB */
1858 /* Get grid and contents */
1859 cave_type *c_ptr = &cave[y][x];
1862 feature_type *f_ptr = &f_info[c_ptr->feat];
1864 /* Access trap name */
1865 cptr name = (f_name + f_ptr->name);
1867 /* Extract trap "power" */
1868 int power = f_ptr->power;
1872 /* Get the "disarm" factor */
1873 int i = p_ptr->skill_dis;
1880 /* Penalize some conditions */
1881 if (p_ptr->blind || no_lite()) i = i / 10;
1882 if (p_ptr->confused || p_ptr->image) i = i / 10;
1884 /* Extract the difficulty */
1887 /* Always have a small chance of success */
1891 if (randint0(100) < j)
1894 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1899 /* Remove the trap */
1900 cave_alter_feat(y, x, FF_DISARM);
1902 #ifdef ALLOW_EASY_DISARM /* TNB */
1904 /* Move the player onto the trap */
1905 move_player(dir, easy_disarm, FALSE);
1907 #else /* ALLOW_EASY_DISARM -- TNB */
1909 /* move the player onto the trap grid */
1910 move_player(dir, FALSE, FALSE);
1912 #endif /* ALLOW_EASY_DISARM -- TNB */
1915 /* Failure -- Keep trying */
1916 else if ((i > 5) && (randint1(i) > 5))
1919 if (flush_failure) flush();
1922 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1924 /* We may keep trying */
1928 /* Failure -- Set off the trap */
1932 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1934 #ifdef ALLOW_EASY_DISARM /* TNB */
1936 /* Move the player onto the trap */
1937 move_player(dir, easy_disarm, FALSE);
1939 #else /* ALLOW_EASY_DISARM -- TNB */
1941 /* Move the player onto the trap */
1942 move_player(dir, FALSE, FALSE);
1944 #endif /* ALLOW_EASY_DISARM -- TNB */
1953 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1954 * Disarms a trap, or chest
1957 void do_cmd_disarm(void)
1965 if (p_ptr->special_defense & KATA_MUSOU)
1967 set_action(ACTION_NONE);
1970 #ifdef ALLOW_EASY_DISARM /* TNB */
1972 /* Option: Pick a direction */
1975 int num_traps, num_chests;
1977 /* Count visible traps */
1978 num_traps = count_dt(&y, &x, is_trap, TRUE);
1980 /* Count chests (trapped) */
1981 num_chests = count_chests(&y, &x, TRUE);
1983 /* See if only one target */
1984 if (num_traps || num_chests)
1986 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
1988 if (!too_many) command_dir = coords_to_dir(y, x);
1992 #endif /* ALLOW_EASY_DISARM -- TNB */
1994 /* Allow repeated command */
1997 /* Set repeat count */
1998 command_rep = command_arg - 1;
2000 /* Redraw the state */
2001 p_ptr->redraw |= (PR_STATE);
2003 /* Cancel the arg */
2007 /* Get a direction (or abort) */
2008 if (get_rep_dir(&dir,TRUE))
2017 /* Get grid and contents */
2018 c_ptr = &cave[y][x];
2020 /* Feature code (applying "mimic" field) */
2021 feat = get_feat_mimic(c_ptr);
2023 /* Check for chests */
2024 o_idx = chest_check(y, x, TRUE);
2027 if (!is_trap(feat) && !o_idx)
2030 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
2033 /* Monster in the way */
2034 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2037 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2046 /* Disarm the chest */
2047 more = do_cmd_disarm_chest(y, x, o_idx);
2053 /* Disarm the trap */
2054 more = do_cmd_disarm_aux(y, x, dir);
2058 /* Cancel repeat unless told not to */
2059 if (!more) disturb(0, 0);
2064 * @brief 「打ち破る」動作コマンドのサブルーチン /
2065 * Perform the basic "bash" command
2066 * @param y 対象を行うマスのY座標
2067 * @param x 対象を行うマスのX座標
2068 * @param dir プレイヤーから見たターゲットの方角ID
2069 * @return 実際に処理が行われた場合TRUEを返す。
2072 * Assume destination is a closed/locked/jammed door
2073 * Assume there is no monster blocking the destination
2074 * Returns TRUE if repeated commands may continue
2077 static bool do_cmd_bash_aux(int y, int x, int dir)
2080 cave_type *c_ptr = &cave[y][x];
2083 feature_type *f_ptr = &f_info[c_ptr->feat];
2085 /* Hack -- Bash power based on strength */
2086 /* (Ranges from 3 to 20 to 100 to 200) */
2087 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2089 /* Extract door power */
2090 int temp = f_ptr->power;
2094 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2100 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
2102 /* Compare bash power to door power XXX XXX XXX */
2103 temp = (bash - (temp * 10));
2105 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2107 /* Hack -- always have a chance */
2108 if (temp < 1) temp = 1;
2110 /* Hack -- attempt to bash down the door */
2111 if (randint0(100) < temp)
2114 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
2117 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
2119 /* Break down the door */
2120 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
2122 cave_alter_feat(y, x, FF_BASH);
2128 cave_alter_feat(y, x, FF_OPEN);
2131 /* Hack -- Fall through the door */
2132 move_player(dir, FALSE, FALSE);
2135 /* Saving throw against stun */
2136 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2140 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
2142 /* Allow repeated bashing */
2146 /* High dexterity yields coolness */
2150 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
2152 /* Hack -- Lose balance ala paralysis */
2153 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2162 * @brief 「打ち破る」動作コマンドのメインルーチン /
2163 * Bash open a door, success based on character strength
2167 * For a closed door, pval is positive if locked; negative if stuck.
2169 * For an open door, pval is positive for a broken door.
2171 * A closed door can be opened - harder if locked. Any door might be
2172 * bashed open (and thereby broken). Bashing a door is (potentially)
2173 * faster! You move into the door way. To open a stuck door, it must
2174 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2176 * Creatures can also open or bash doors, see elsewhere.
2179 void do_cmd_bash(void)
2188 if (p_ptr->special_defense & KATA_MUSOU)
2190 set_action(ACTION_NONE);
2193 /* Allow repeated command */
2196 /* Set repeat count */
2197 command_rep = command_arg - 1;
2199 /* Redraw the state */
2200 p_ptr->redraw |= (PR_STATE);
2202 /* Cancel the arg */
2206 /* Get a "repeated" direction */
2207 if (get_rep_dir(&dir,FALSE))
2216 c_ptr = &cave[y][x];
2218 /* Feature code (applying "mimic" field) */
2219 feat = get_feat_mimic(c_ptr);
2221 /* Nothing useful */
2222 if (!have_flag(f_info[feat].flags, FF_BASH))
2225 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
2228 /* Monster in the way */
2229 else if (c_ptr->m_idx)
2235 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2241 /* Bash a closed door */
2245 more = do_cmd_bash_aux(y, x, dir);
2249 /* Unless valid action taken, cancel bash */
2250 if (!more) disturb(0, 0);
2255 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
2259 * Manipulate an adjacent grid in some way
2261 * Attack monsters, tunnel through walls, disarm traps, open doors.
2263 * Consider confusion XXX XXX XXX
2265 * This command must always take a turn, to prevent free detection
2266 * of invisible monsters.
2269 void do_cmd_alter(void)
2278 if (p_ptr->special_defense & KATA_MUSOU)
2280 set_action(ACTION_NONE);
2283 /* Allow repeated command */
2286 /* Set repeat count */
2287 command_rep = command_arg - 1;
2289 /* Redraw the state */
2290 p_ptr->redraw |= (PR_STATE);
2292 /* Cancel the arg */
2296 /* Get a direction */
2297 if (get_rep_dir(&dir,TRUE))
2300 feature_type *f_ptr;
2307 c_ptr = &cave[y][x];
2309 /* Feature code (applying "mimic" field) */
2310 feat = get_feat_mimic(c_ptr);
2311 f_ptr = &f_info[feat];
2316 /* Attack monsters */
2324 else if (have_flag(f_ptr->flags, FF_OPEN))
2326 more = do_cmd_open_aux(y, x);
2329 /* Bash jammed doors */
2330 else if (have_flag(f_ptr->flags, FF_BASH))
2332 more = do_cmd_bash_aux(y, x, dir);
2335 /* Tunnel through walls */
2336 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2338 more = do_cmd_tunnel_aux(y, x);
2341 /* Close open doors */
2342 else if (have_flag(f_ptr->flags, FF_CLOSE))
2344 more = do_cmd_close_aux(y, x);
2348 else if (have_flag(f_ptr->flags, FF_DISARM))
2350 more = do_cmd_disarm_aux(y, x, dir);
2357 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
2361 /* Cancel repetition unless we can continue */
2362 if (!more) disturb(0, 0);
2368 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
2369 * Find the index of some "spikes", if possible.
2370 * @param ip くさびとして打てるオブジェクトのID
2371 * @return オブジェクトがある場合TRUEを返す
2374 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2377 static bool get_spike(int *ip)
2381 /* Check every item in the pack */
2382 for (i = 0; i < INVEN_PACK; i++)
2384 object_type *o_ptr = &inventory[i];
2386 /* Skip non-objects */
2387 if (!o_ptr->k_idx) continue;
2389 /* Check the "tval" code */
2390 if (o_ptr->tval == TV_SPIKE)
2392 /* Save the spike index */
2406 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
2407 * Jam a closed door with a spike
2411 * This command may NOT be repeated
2414 void do_cmd_spike(void)
2418 if (p_ptr->special_defense & KATA_MUSOU)
2420 set_action(ACTION_NONE);
2423 /* Get a "repeated" direction */
2424 if (get_rep_dir(&dir,FALSE))
2434 /* Get grid and contents */
2435 c_ptr = &cave[y][x];
2437 /* Feature code (applying "mimic" field) */
2438 feat = get_feat_mimic(c_ptr);
2440 /* Require closed door */
2441 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2444 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2448 else if (!get_spike(&item))
2451 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2454 /* Is a monster in the way? */
2455 else if (c_ptr->m_idx)
2461 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2473 /* Successful jamming */
2474 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2475 cave_alter_feat(y, x, FF_SPIKE);
2477 /* Use up, and describe, a single spike, from the bottom */
2478 inven_item_increase(item, -1);
2479 inven_item_describe(item);
2480 inven_item_optimize(item);
2488 * @brief 「歩く」動作コマンドのメインルーチン /
2489 * Support code for the "Walk" and "Jump" commands
2490 * @param pickup アイテムの自動拾いを行うならTRUE
2493 void do_cmd_walk(bool pickup)
2500 /* Allow repeated command */
2503 /* Set repeat count */
2504 command_rep = command_arg - 1;
2506 /* Redraw the state */
2507 p_ptr->redraw |= (PR_STATE);
2509 /* Cancel the arg */
2513 /* Get a "repeated" direction */
2514 if (get_rep_dir(&dir,FALSE))
2519 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2521 set_action(ACTION_NONE);
2524 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2525 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2526 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2528 /* Actually move the character */
2529 move_player(dir, pickup, FALSE);
2531 /* Allow more walking */
2535 /* Hack again -- Is there a special encounter ??? */
2536 if (p_ptr->wild_mode && !cave_have_flag_bold(py, px, FF_TOWN))
2538 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2541 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2543 /* Inform the player of his horrible fate :=) */
2544 msg_print(_("襲撃だ!", "You are ambushed !"));
2546 /* Go into large wilderness view */
2547 p_ptr->oldpy = randint1(MAX_HGT-2);
2548 p_ptr->oldpx = randint1(MAX_WID-2);
2551 /* Give first move to monsters */
2554 /* HACk -- set the encouter flag for the wilderness generation */
2555 generate_encounter = TRUE;
2559 /* Cancel repeat unless we may continue */
2560 if (!more) disturb(0, 0);
2565 * @brief 「走る」動作コマンドのメインルーチン /
2569 void do_cmd_run(void)
2573 /* Hack -- no running when confused */
2574 if (p_ptr->confused)
2576 msg_print(_("混乱していて走れない!", "You are too confused!"));
2580 if (p_ptr->special_defense & KATA_MUSOU)
2582 set_action(ACTION_NONE);
2585 /* Get a "repeated" direction */
2586 if (get_rep_dir(&dir,FALSE))
2588 /* Hack -- Set the run counter */
2589 running = (command_arg ? command_arg : 1000);
2598 * @brief 「留まる」動作コマンドのメインルーチン /
2599 * Stay still. Search. Enter stores.
2600 * Pick up treasure if "pickup" is true.
2601 * @param pickup アイテムの自動拾いを行うならTRUE
2604 void do_cmd_stay(bool pickup)
2606 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2608 /* Allow repeated command */
2611 /* Set repeat count */
2612 command_rep = command_arg - 1;
2614 /* Redraw the state */
2615 p_ptr->redraw |= (PR_STATE);
2617 /* Cancel the arg */
2624 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2625 (void)move_player_effect(py, px, mpe_mode);
2630 * @brief 「休む」動作コマンドのメインルーチン /
2631 * Resting allows a player to safely restore his hp -RAK-
2634 void do_cmd_rest(void)
2637 set_action(ACTION_NONE);
2639 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
2645 if (hex_spelling_any()) stop_hex_spell_all();
2647 /* Prompt for time if needed */
2648 if (command_arg <= 0)
2650 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2651 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2657 strcpy(out_val, "&");
2659 /* Ask for duration */
2660 if (!get_string(p, out_val, 4)) return;
2662 /* Rest until done */
2663 if (out_val[0] == '&')
2669 else if (out_val[0] == '*')
2677 command_arg = atoi(out_val);
2678 if (command_arg <= 0) return;
2684 if (command_arg > 9999) command_arg = 9999;
2686 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2688 /* Take a turn XXX XXX XXX (?) */
2691 /* The sin of sloth */
2692 if (command_arg > 100)
2693 chg_virtue(V_DILIGENCE, -1);
2695 /* Why are you sleeping when there's no need? WAKE UP!*/
2696 if ((p_ptr->chp == p_ptr->mhp) &&
2697 (p_ptr->csp == p_ptr->msp) &&
2698 !p_ptr->blind && !p_ptr->confused &&
2699 !p_ptr->poisoned && !p_ptr->afraid &&
2700 !p_ptr->stun && !p_ptr->cut &&
2701 !p_ptr->slow && !p_ptr->paralyzed &&
2702 !p_ptr->image && !p_ptr->word_recall &&
2703 !p_ptr->alter_reality)
2704 chg_virtue(V_DILIGENCE, -1);
2706 /* Save the rest code */
2707 resting = command_arg;
2708 p_ptr->action = ACTION_REST;
2710 /* Recalculate bonuses */
2711 p_ptr->update |= (PU_BONUS);
2713 /* Redraw the state */
2714 p_ptr->redraw |= (PR_STATE);
2725 * @brief 矢弾を射撃した場合の破損確率を返す /
2726 * Determines the odds of an object breaking when thrown at a monster
2727 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2730 * Note that artifacts never break, see the "drop_near()" function.
2732 static int breakage_chance(object_type *o_ptr)
2734 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2736 /* Examine the snipe type */
2739 if (snipe_type == SP_KILL_WALL) return (100);
2740 if (snipe_type == SP_EXPLODE) return (100);
2741 if (snipe_type == SP_PIERCE) return (100);
2742 if (snipe_type == SP_FINAL) return (100);
2743 if (snipe_type == SP_NEEDLE) return (100);
2744 if (snipe_type == SP_EVILNESS) return (40);
2745 if (snipe_type == SP_HOLYNESS) return (40);
2748 /* Examine the item type */
2749 switch (o_ptr->tval)
2765 /* Sometimes break */
2770 return (20 - archer_bonus * 2);
2775 return (10 - archer_bonus);
2783 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2784 * Determines the odds of an object breaking when thrown at a monster
2785 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2786 * @param tdam 計算途中のダメージ量
2787 * @param m_ptr 目標モンスターの構造体参照ポインタ
2788 * @return スレイ倍率をかけたダメージ量
2790 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2794 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2796 u32b flgs[TR_FLAG_SIZE];
2798 /* Extract the flags */
2799 object_flags(o_ptr, flgs);
2801 /* Some "weapons" and "ammo" do extra damage */
2802 switch (o_ptr->tval)
2809 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2810 (r_ptr->flags3 & RF3_ANIMAL))
2812 if (is_original_ap_and_seen(m_ptr))
2814 r_ptr->r_flags3 |= RF3_ANIMAL;
2817 if (mult < 17) mult = 17;
2821 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2822 (r_ptr->flags3 & RF3_ANIMAL))
2824 if (is_original_ap_and_seen(m_ptr))
2826 r_ptr->r_flags3 |= RF3_ANIMAL;
2829 if (mult < 27) mult = 27;
2833 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2834 (r_ptr->flags3 & RF3_EVIL))
2836 if (is_original_ap_and_seen(m_ptr))
2838 r_ptr->r_flags3 |= RF3_EVIL;
2841 if (mult < 15) mult = 15;
2845 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2846 (r_ptr->flags3 & RF3_EVIL))
2848 if (is_original_ap_and_seen(m_ptr))
2850 r_ptr->r_flags3 |= RF3_EVIL;
2853 if (mult < 25) mult = 25;
2857 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2858 (r_ptr->flags2 & RF2_HUMAN))
2860 if (is_original_ap_and_seen(m_ptr))
2862 r_ptr->r_flags2 |= RF2_HUMAN;
2865 if (mult < 17) mult = 17;
2869 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2870 (r_ptr->flags2 & RF2_HUMAN))
2872 if (is_original_ap_and_seen(m_ptr))
2874 r_ptr->r_flags2 |= RF2_HUMAN;
2877 if (mult < 27) mult = 27;
2881 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2882 (r_ptr->flags3 & RF3_UNDEAD))
2884 if (is_original_ap_and_seen(m_ptr))
2886 r_ptr->r_flags3 |= RF3_UNDEAD;
2889 if (mult < 20) mult = 20;
2893 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2894 (r_ptr->flags3 & RF3_UNDEAD))
2896 if (is_original_ap_and_seen(m_ptr))
2898 r_ptr->r_flags3 |= RF3_UNDEAD;
2901 if (mult < 30) mult = 30;
2905 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2906 (r_ptr->flags3 & RF3_DEMON))
2908 if (is_original_ap_and_seen(m_ptr))
2910 r_ptr->r_flags3 |= RF3_DEMON;
2913 if (mult < 20) mult = 20;
2917 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2918 (r_ptr->flags3 & RF3_DEMON))
2920 if (is_original_ap_and_seen(m_ptr))
2922 r_ptr->r_flags3 |= RF3_DEMON;
2925 if (mult < 30) mult = 30;
2929 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2930 (r_ptr->flags3 & RF3_ORC))
2932 if (is_original_ap_and_seen(m_ptr))
2934 r_ptr->r_flags3 |= RF3_ORC;
2937 if (mult < 20) mult = 20;
2941 if ((have_flag(flgs, TR_KILL_ORC)) &&
2942 (r_ptr->flags3 & RF3_ORC))
2944 if (is_original_ap_and_seen(m_ptr))
2946 r_ptr->r_flags3 |= RF3_ORC;
2949 if (mult < 30) mult = 30;
2953 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2954 (r_ptr->flags3 & RF3_TROLL))
2956 if (is_original_ap_and_seen(m_ptr))
2958 r_ptr->r_flags3 |= RF3_TROLL;
2961 if (mult < 20) mult = 20;
2965 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2966 (r_ptr->flags3 & RF3_TROLL))
2968 if (is_original_ap_and_seen(m_ptr))
2970 r_ptr->r_flags3 |= RF3_TROLL;
2973 if (mult < 30) mult = 30;
2977 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2978 (r_ptr->flags3 & RF3_GIANT))
2980 if (is_original_ap_and_seen(m_ptr))
2982 r_ptr->r_flags3 |= RF3_GIANT;
2985 if (mult < 20) mult = 20;
2989 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2990 (r_ptr->flags3 & RF3_GIANT))
2992 if (is_original_ap_and_seen(m_ptr))
2994 r_ptr->r_flags3 |= RF3_GIANT;
2997 if (mult < 30) mult = 30;
3001 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3002 (r_ptr->flags3 & RF3_DRAGON))
3004 if (is_original_ap_and_seen(m_ptr))
3006 r_ptr->r_flags3 |= RF3_DRAGON;
3009 if (mult < 20) mult = 20;
3012 /* Execute Dragon */
3013 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3014 (r_ptr->flags3 & RF3_DRAGON))
3016 if (is_original_ap_and_seen(m_ptr))
3018 r_ptr->r_flags3 |= RF3_DRAGON;
3021 if (mult < 30) mult = 30;
3023 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3024 (m_ptr->r_idx == MON_SMAUG) &&
3025 (inventory[INVEN_BOW].name1 == ART_BARD))
3030 if (have_flag(flgs, TR_BRAND_ACID))
3032 /* Notice immunity */
3033 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3035 if (is_original_ap_and_seen(m_ptr))
3037 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3041 /* Otherwise, take the damage */
3044 if (mult < 17) mult = 17;
3049 if (have_flag(flgs, TR_BRAND_ELEC))
3051 /* Notice immunity */
3052 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3054 if (is_original_ap_and_seen(m_ptr))
3056 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3060 /* Otherwise, take the damage */
3063 if (mult < 17) mult = 17;
3068 if (have_flag(flgs, TR_BRAND_FIRE))
3070 /* Notice immunity */
3071 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3073 if (is_original_ap_and_seen(m_ptr))
3075 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3079 /* Otherwise, take the damage */
3082 if (r_ptr->flags3 & RF3_HURT_FIRE)
3084 if (mult < 25) mult = 25;
3085 if (is_original_ap_and_seen(m_ptr))
3087 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3090 else if (mult < 17) mult = 17;
3095 if (have_flag(flgs, TR_BRAND_COLD))
3097 /* Notice immunity */
3098 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3100 if (is_original_ap_and_seen(m_ptr))
3102 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3105 /* Otherwise, take the damage */
3108 if (r_ptr->flags3 & RF3_HURT_COLD)
3110 if (mult < 25) mult = 25;
3111 if (is_original_ap_and_seen(m_ptr))
3113 r_ptr->r_flags3 |= RF3_HURT_COLD;
3116 else if (mult < 17) mult = 17;
3120 /* Brand (Poison) */
3121 if (have_flag(flgs, TR_BRAND_POIS))
3123 /* Notice immunity */
3124 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3126 if (is_original_ap_and_seen(m_ptr))
3128 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3132 /* Otherwise, take the damage */
3135 if (mult < 17) mult = 17;
3139 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3141 p_ptr->csp -= (1+(p_ptr->msp / 30));
3142 p_ptr->redraw |= (PR_MANA);
3143 mult = mult * 5 / 2;
3150 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
3152 /* Return the total damage */
3153 return (tdam * mult / 10);
3158 * @brief 射撃処理のサブルーチン /
3159 * Fire an object from the pack or floor.
3160 * @param item 射撃するオブジェクトの所持ID
3161 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
3165 * You may only fire items that "match" your missile launcher.
3167 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3169 * See "calc_bonuses()" for more calculations and such.
3171 * Note that "firing" a missile is MUCH better than "throwing" it.
3173 * Note: "unseen" monsters are very hard to hit.
3175 * Objects are more likely to break if they "attempt" to hit a monster.
3177 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3179 * The "extra shot" code works by decreasing the amount of energy
3180 * required to make each shot, spreading the shots out over time.
3182 * Note that when firing missiles, the launcher multiplier is applied
3183 * after all the bonuses are added in, making multipliers very useful.
3185 * Note that Bows of "Extra Might" get extra range and an extra bonus
3186 * for the damage multiplier.
3188 * Note that Bows of "Extra Shots" give an extra shot.
3191 void do_cmd_fire_aux(int item, object_type *j_ptr)
3194 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
3195 int tdam_base, tdis, thits, tmul;
3197 int cur_dis, visible;
3204 bool hit_body = FALSE;
3206 char o_name[MAX_NLEN];
3208 u16b path_g[512]; /* For calcuration of path length */
3210 int msec = delay_factor * delay_factor * delay_factor;
3213 bool stick_to = FALSE;
3215 /* Access the item (if in the pack) */
3218 o_ptr = &inventory[item];
3222 o_ptr = &o_list[0 - item];
3225 /* Sniper - Cannot shot a single arrow twice */
3226 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
3228 /* Describe the object */
3229 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3231 /* Use the proper number of shots */
3232 thits = p_ptr->num_fire;
3234 /* Use a base distance */
3237 /* Base damage from thrown object plus launcher bonus */
3238 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3240 /* Actually "fire" the object */
3241 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3242 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3243 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3245 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3247 energy_use = bow_energy(j_ptr->sval);
3248 tmul = bow_tmul(j_ptr->sval);
3250 /* Get extra "power" from "extra might" */
3251 if (p_ptr->xtra_might) tmul++;
3253 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3255 /* Boost the damage */
3260 tdis = 13 + tmul/80;
3261 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3264 tdis -= (5 - (p_ptr->concent + 1) / 2);
3269 project_length = tdis + 1;
3271 /* Get a direction (or cancel) */
3272 if (!get_aim_dir(&dir))
3276 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
3278 /* need not to reset project_length (already did)*/
3283 /* Predict the "target" location */
3284 tx = px + 99 * ddx[dir];
3285 ty = py + 99 * ddy[dir];
3287 /* Check for "target request" */
3288 if ((dir == 5) && target_okay())
3294 /* Get projection path length */
3295 tdis = project_path(path_g, project_length, py, px, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
3297 project_length = 0; /* reset to default */
3299 /* Don't shoot at my feet */
3300 if (tx == px && ty == py)
3304 /* project_length is already reset to 0 */
3310 /* Take a (partial) turn */
3311 energy_use = (energy_use / thits);
3314 /* Sniper - Difficult to shot twice at 1 turn */
3315 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
3317 /* Sniper - Repeat shooting when double shots */
3318 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
3321 /* Start at the player */
3325 /* Get local object */
3328 /* Obtain a local object */
3329 object_copy(q_ptr, o_ptr);
3334 /* Reduce and describe inventory */
3337 inven_item_increase(item, -1);
3338 inven_item_describe(item);
3339 inven_item_optimize(item);
3342 /* Reduce and describe floor item */
3345 floor_item_increase(0 - item, -1);
3346 floor_item_optimize(0 - item);
3352 /* Hack -- Handle stuff */
3355 /* Save the old location */
3359 /* The shot does not hit yet */
3362 /* Travel until stopped */
3363 for (cur_dis = 0; cur_dis <= tdis; )
3367 /* Hack -- Stop at the target */
3368 if ((y == ty) && (x == tx)) break;
3370 /* Calculate the new location (see "project()") */
3373 mmove2(&ny, &nx, py, px, ty, tx);
3376 if (snipe_type == SP_KILL_WALL)
3378 c_ptr = &cave[ny][nx];
3380 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3382 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
3383 /* Forget the wall */
3384 c_ptr->info &= ~(CAVE_MARK);
3386 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3388 /* Destroy the wall */
3389 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3396 /* Stopped by walls/doors */
3397 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3399 /* Advance the distance */
3403 if (snipe_type == SP_LITE)
3405 cave[ny][nx].info |= (CAVE_GLOW);
3414 /* The player can see the (on screen) missile */
3415 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3417 char c = object_char(q_ptr);
3418 byte a = object_attr(q_ptr);
3420 /* Draw, Hilite, Fresh, Pause, Erase */
3421 print_rel(c, a, ny, nx);
3422 move_cursor_relative(ny, nx);
3424 Term_xtra(TERM_XTRA_DELAY, msec);
3429 /* The player cannot see the missile */
3432 /* Pause anyway, for consistancy */
3433 Term_xtra(TERM_XTRA_DELAY, msec);
3437 if (snipe_type == SP_KILL_TRAP)
3439 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3440 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3444 if (snipe_type == SP_EVILNESS)
3446 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3455 /* Save the old location */
3459 /* Save the new location */
3464 /* Monster here, Try to hit it */
3465 if (cave[y][x].m_idx)
3468 cave_type *c_ptr = &cave[y][x];
3470 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3471 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3473 /* Check the visibility */
3474 visible = m_ptr->ml;
3476 /* Note the collision */
3479 if (MON_CSLEEP(m_ptr))
3481 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3482 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3485 if ((r_ptr->level + 10) > p_ptr->lev)
3487 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3488 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3491 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3492 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3493 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3494 else if (p_ptr->lev > 34) amount = 2;
3495 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3496 p_ptr->update |= (PU_BONUS);
3502 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3503 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3506 p_ptr->skill_exp[GINOU_RIDING] += 1;
3507 p_ptr->update |= (PU_BONUS);
3511 /* Some shots have hit bonus */
3515 armour *= (8 - p_ptr->concent);
3519 /* Did we hit it (penalize range) */
3520 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3523 int tdam = tdam_base;
3525 /* Get extra damage from concentration */
3526 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3528 /* Handle unseen monster */
3531 /* Invisible monster */
3532 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3535 /* Handle visible monster */
3540 /* Get "the monster" or "it" */
3541 monster_desc(m_name, m_ptr, 0);
3544 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3548 /* Hack -- Track this monster race */
3549 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3551 /* Hack -- Track this monster */
3552 health_track(c_ptr->m_idx);
3556 if (snipe_type == SP_NEEDLE)
3558 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3559 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3563 /* Get "the monster" or "it" */
3564 monster_desc(m_name, m_ptr, 0);
3566 tdam = m_ptr->hp + 1;
3567 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3573 /* Apply special damage XXX XXX XXX */
3574 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3575 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3577 /* No negative damage */
3578 if (tdam < 0) tdam = 0;
3580 /* Modify the damage */
3581 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3584 /* Complex message */
3585 if (p_ptr->wizard || cheat_xtra)
3587 msg_format(_("%d/%d のダメージを与えた。", "You do %d (out of %d) damage."), tdam, m_ptr->hp);
3591 if (snipe_type == SP_EXPLODE)
3593 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3595 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3596 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3601 if (snipe_type == SP_HOLYNESS)
3603 cave[ny][nx].info |= (CAVE_GLOW);
3612 /* Hit the monster, check for death */
3613 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3622 if (object_is_fixed_artifact(q_ptr) &&
3623 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3627 monster_desc(m_name, m_ptr, 0);
3630 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3634 message_pain(c_ptr->m_idx, tdam);
3636 /* Anger the monster */
3637 if (tdam > 0) anger_monster(m_ptr);
3640 if (fear && m_ptr->ml)
3647 /* Get the monster name (or "it") */
3648 monster_desc(m_name, m_ptr, 0);
3651 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3654 set_target(m_ptr, py, px);
3657 if (snipe_type == SP_RUSH)
3659 int n = randint1(5) + 3;
3660 int m_idx = c_ptr->m_idx;
3662 for ( ; cur_dis <= tdis; )
3669 /* Calculate the new location (see "project()") */
3670 mmove2(&ny, &nx, py, px, ty, tx);
3672 /* Stopped by wilderness boundary */
3673 if (!in_bounds2(ny, nx)) break;
3675 /* Stopped by walls/doors */
3676 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3678 /* Stopped by monsters */
3679 if (!cave_empty_bold(ny, nx)) break;
3681 cave[ny][nx].m_idx = m_idx;
3682 cave[oy][ox].m_idx = 0;
3687 /* Update the monster (new location) */
3688 update_mon(c_ptr->m_idx, TRUE);
3694 Term_xtra(TERM_XTRA_DELAY, msec);
3706 if (snipe_type == SP_PIERCE)
3708 if(p_ptr->concent < 1) break;
3718 /* Chance of breakage (during attacks) */
3719 j = (hit_body ? breakage_chance(q_ptr) : 0);
3723 int m_idx = cave[y][x].m_idx;
3724 monster_type *m_ptr = &m_list[m_idx];
3725 int o_idx = o_pop();
3729 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3730 if (object_is_fixed_artifact(q_ptr))
3732 a_info[j_ptr->name1].cur_num = 0;
3737 o_ptr = &o_list[o_idx];
3738 object_copy(o_ptr, q_ptr);
3741 o_ptr->marked &= OM_TOUCHED;
3743 /* Forget location */
3744 o_ptr->iy = o_ptr->ix = 0;
3746 /* Memorize monster */
3747 o_ptr->held_m_idx = m_idx;
3750 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3753 m_ptr->hold_o_idx = o_idx;
3755 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3757 /* Drop (or break) near that location */
3758 (void)drop_near(q_ptr, j, y, x);
3762 /* Drop (or break) near that location */
3763 (void)drop_near(q_ptr, j, prev_y, prev_x);
3766 /* Sniper - Repeat shooting when double shots */
3769 /* Sniper - Loose his/her concentration after any shot */
3770 if (p_ptr->concent) reset_concentration(FALSE);
3774 * @brief 射撃処理のメインルーチン
3777 void do_cmd_fire(void)
3783 is_fired = FALSE; /* not fired yet */
3785 /* Get the "bow" (if any) */
3786 j_ptr = &inventory[INVEN_BOW];
3788 /* Require a launcher */
3791 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3796 if (j_ptr->sval == SV_CRIMSON)
3798 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3804 if (p_ptr->special_defense & KATA_MUSOU)
3806 set_action(ACTION_NONE);
3809 /* Require proper missile */
3810 item_tester_tval = p_ptr->tval_ammo;
3813 q = _("どれを撃ちますか? ", "Fire which item? ");
3814 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3815 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3822 do_cmd_fire_aux(item, j_ptr);
3824 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3826 /* Sniper actions after some shootings */
3827 if (snipe_type == SP_AWAY)
3829 teleport_player(10 + (p_ptr->concent * 2), 0L);
3831 if (snipe_type == SP_FINAL)
3833 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3834 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3835 (void)set_stun(p_ptr->stun + randint1(25));
3840 * @brief オブジェクトが投射可能な武器かどうかを返す。
3841 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
3842 * @return 投射可能な武器ならばTRUE
3844 static bool item_tester_hook_boomerang(object_type *o_ptr)
3846 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
3854 * @brief 投射処理のサブルーチン /
3855 * Throw an object from the pack or floor.
3857 * @param boomerang ブーメラン処理ならばTRUE
3858 * @param shuriken 忍者の手裏剣処理ならばTRUE
3859 * @return ターンを消費した場合TRUEを返す
3862 * Note: "unseen" monsters are very hard to hit.
3864 * Should throwing a weapon do full damage? Should it allow the magic
3865 * to hit bonus of the weapon to have an effect? Should it ever cause
3866 * the item to be destroyed? Should it do any damage at all?
3869 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
3872 int i, j, y, x, ty, tx, prev_y, prev_x;
3874 int chance, tdam, tdis;
3875 int mul, div, dd, ds;
3876 int cur_dis, visible;
3883 bool hit_body = FALSE;
3884 bool hit_wall = FALSE;
3885 bool equiped_item = FALSE;
3886 bool return_when_thrown = FALSE;
3888 char o_name[MAX_NLEN];
3890 int msec = delay_factor * delay_factor * delay_factor;
3892 u32b flgs[TR_FLAG_SIZE];
3894 bool come_back = FALSE;
3895 bool do_drop = TRUE;
3898 if (p_ptr->special_defense & KATA_MUSOU)
3900 set_action(ACTION_NONE);
3909 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3911 item_tester_hook = item_tester_hook_boomerang;
3912 q = _("どの武器を投げますか? ", "Throw which item? ");
3913 s = _("投げる武器がない。", "You have nothing to throw.");
3914 if (!get_item(&item, q, s, (USE_EQUIP)))
3920 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3921 else item = INVEN_RARM;
3926 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3927 s = _("投げるアイテムがない。", "You have nothing to throw.");
3928 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3935 /* Access the item (if in the pack) */
3938 o_ptr = &inventory[item];
3942 o_ptr = &o_list[0 - item];
3946 /* Item is cursed */
3947 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3950 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3956 if (p_ptr->inside_arena && !boomerang)
3958 if (o_ptr->tval != TV_SPIKE)
3960 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3968 /* Get local object */
3971 /* Obtain a local object */
3972 object_copy(q_ptr, o_ptr);
3974 /* Extract the thrown object's flags. */
3975 object_flags(q_ptr, flgs);
3976 torch_flags(q_ptr, flgs);
3978 /* Distribute the charges of rods/wands between the stacks */
3979 distribute_charges(o_ptr, q_ptr, 1);
3985 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3987 if (p_ptr->mighty_throw) mult += 3;
3989 /* Extract a "distance multiplier" */
3990 /* Changed for 'launcher' mutation */
3991 mul = 10 + 2 * (mult - 1);
3993 /* Enforce a minimum "weight" of one pound */
3994 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3995 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3997 /* Hack -- Distance -- Reward strength, penalize weight */
3998 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4000 /* Max distance of 10-18 */
4001 if (tdis > mul) tdis = mul;
4005 ty = randint0(101)-50+py;
4006 tx = randint0(101)-50+px;
4010 project_length = tdis + 1;
4012 /* Get a direction (or cancel) */
4013 if (!get_aim_dir(&dir)) return FALSE;
4015 /* Predict the "target" location */
4016 tx = px + 99 * ddx[dir];
4017 ty = py + 99 * ddy[dir];
4019 /* Check for "target request" */
4020 if ((dir == 5) && target_okay())
4026 project_length = 0; /* reset to default */
4029 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4030 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4031 return_when_thrown = TRUE;
4033 /* Reduce and describe inventory */
4036 inven_item_increase(item, -1);
4037 if (!return_when_thrown)
4038 inven_item_describe(item);
4039 inven_item_optimize(item);
4042 /* Reduce and describe floor item */
4045 floor_item_increase(0 - item, -1);
4046 floor_item_optimize(0 - item);
4048 if (item >= INVEN_RARM)
4050 equiped_item = TRUE;
4051 p_ptr->redraw |= (PR_EQUIPPY);
4057 /* Rogue and Ninja gets bonus */
4058 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4059 energy_use -= p_ptr->lev;
4061 /* Start at the player */
4066 /* Hack -- Handle stuff */
4069 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4070 else shuriken = FALSE;
4072 /* Chance of hitting */
4073 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4074 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4075 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4077 if (shuriken) chance *= 2;
4079 /* Save the old location */
4083 /* Travel until stopped */
4084 for (cur_dis = 0; cur_dis <= tdis; )
4086 /* Hack -- Stop at the target */
4087 if ((y == ty) && (x == tx)) break;
4089 /* Calculate the new location (see "project()") */
4092 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4094 /* Stopped by walls/doors */
4095 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
4098 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
4101 /* The player can see the (on screen) missile */
4102 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
4104 char c = object_char(q_ptr);
4105 byte a = object_attr(q_ptr);
4107 /* Draw, Hilite, Fresh, Pause, Erase */
4108 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
4109 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
4111 Term_xtra(TERM_XTRA_DELAY, msec);
4112 lite_spot(ny[cur_dis], nx[cur_dis]);
4116 /* The player cannot see the missile */
4119 /* Pause anyway, for consistancy */
4120 Term_xtra(TERM_XTRA_DELAY, msec);
4123 /* Save the old location */
4127 /* Save the new location */
4131 /* Advance the distance */
4134 /* Monster here, Try to hit it */
4135 if (cave[y][x].m_idx)
4137 cave_type *c_ptr = &cave[y][x];
4139 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4141 /* Check the visibility */
4142 visible = m_ptr->ml;
4144 /* Note the collision */
4147 /* Did we hit it (penalize range) */
4148 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
4152 /* Handle unseen monster */
4155 /* Invisible monster */
4156 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
4159 /* Handle visible monster */
4164 /* Get "the monster" or "it" */
4165 monster_desc(m_name, m_ptr, 0);
4168 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
4172 /* Hack -- Track this monster race */
4173 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
4175 /* Hack -- Track this monster */
4176 health_track(c_ptr->m_idx);
4180 /* Hack -- Base damage from thrown object */
4183 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
4184 tdam = damroll(dd, ds);
4185 /* Apply special damage XXX XXX XXX */
4186 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4187 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
4188 if (q_ptr->to_d > 0)
4189 tdam += q_ptr->to_d;
4191 tdam += -q_ptr->to_d;
4195 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4196 tdam += p_ptr->to_d_m;
4198 else if (have_flag(flgs, TR_THROW))
4201 tdam += p_ptr->to_d_m;
4209 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4212 /* No negative damage */
4213 if (tdam < 0) tdam = 0;
4215 /* Modify the damage */
4216 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4218 /* Complex message */
4221 msg_format(_("%d/%dのダメージを与えた。", "You do %d (out of %d) damage."), tdam, m_ptr->hp);
4224 /* Hit the monster, check for death */
4225 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4234 message_pain(c_ptr->m_idx, tdam);
4236 /* Anger the monster */
4237 if ((tdam > 0) && !object_is_potion(q_ptr))
4238 anger_monster(m_ptr);
4241 if (fear && m_ptr->ml)
4248 /* Get the monster name (or "it") */
4249 monster_desc(m_name, m_ptr, 0);
4252 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
4262 /* decrease toach's fuel */
4263 if (hit_body) torch_lost_fuel(q_ptr);
4265 /* Chance of breakage (during attacks) */
4266 j = (hit_body ? breakage_chance(q_ptr) : 0);
4268 /* Figurines transform */
4269 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4273 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4274 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
4275 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
4276 else if (object_is_cursed(q_ptr))
4277 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
4282 /* Potions smash open */
4283 if (object_is_potion(q_ptr))
4285 if (hit_body || hit_wall || (randint1(100) < j))
4288 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
4290 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4292 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4294 /* ToDo (Robert): fix the invulnerability */
4295 if (cave[y][x].m_idx &&
4296 is_friendly(&m_list[cave[y][x].m_idx]) &&
4297 !MON_INVULNER(m_ptr))
4300 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4301 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
4302 set_hostile(&m_list[cave[y][x].m_idx]);
4313 if (return_when_thrown)
4315 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4316 char o2_name[MAX_NLEN];
4317 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4320 if (boomerang) back_chance += 4+randint1(5);
4321 if (super_boomerang) back_chance += 100;
4322 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4324 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4326 for (i = cur_dis - 1; i > 0; i--)
4328 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4330 char c = object_char(q_ptr);
4331 byte a = object_attr(q_ptr);
4333 /* Draw, Hilite, Fresh, Pause, Erase */
4334 print_rel(c, a, ny[i], nx[i]);
4335 move_cursor_relative(ny[i], nx[i]);
4337 Term_xtra(TERM_XTRA_DELAY, msec);
4338 lite_spot(ny[i], nx[i]);
4343 /* Pause anyway, for consistancy */
4344 Term_xtra(TERM_XTRA_DELAY, msec);
4347 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4349 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
4356 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
4360 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
4368 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
4374 if (item == INVEN_RARM || item == INVEN_LARM)
4376 /* Access the wield slot */
4377 o_ptr = &inventory[item];
4379 /* Wear the new stuff */
4380 object_copy(o_ptr, q_ptr);
4382 /* Increase the weight */
4383 p_ptr->total_weight += q_ptr->weight;
4385 /* Increment the equip counter by hand */
4388 /* Recalculate bonuses */
4389 p_ptr->update |= (PU_BONUS);
4391 /* Recalculate torch */
4392 p_ptr->update |= (PU_TORCH);
4394 /* Recalculate mana XXX */
4395 p_ptr->update |= (PU_MANA);
4398 p_ptr->window |= (PW_EQUIP);
4406 else if (equiped_item)
4412 /* Drop (or break) near that location */
4415 if (cave_have_flag_bold(y, x, FF_PROJECT))
4417 /* Drop (or break) near that location */
4418 (void)drop_near(q_ptr, j, y, x);
4422 /* Drop (or break) near that location */
4423 (void)drop_near(q_ptr, j, prev_y, prev_x);
4432 * @brief 投射処理のメインルーチン /
4433 * Throw an object from the pack or floor.
4436 void do_cmd_throw(void)
4438 do_cmd_throw_aux(1, FALSE, -1);
4444 * Hack: travel command
4446 #define TRAVEL_UNABLE 9999
4448 static int flow_head = 0;
4449 static int flow_tail = 0;
4450 static s16b temp2_x[MAX_SHORT];
4451 static s16b temp2_y[MAX_SHORT];
4454 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
4457 void forget_travel_flow(void)
4461 /* Check the entire dungeon */
4462 for (y = 0; y < cur_hgt; y++)
4464 for (x = 0; x < cur_wid; x++)
4466 /* Forget the old data */
4467 travel.cost[y][x] = MAX_SHORT;
4471 travel.y = travel.x = 0;
4475 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
4480 static int travel_flow_cost(int y, int x)
4482 feature_type *f_ptr = &f_info[cave[y][x].feat];
4485 /* Avoid obstacles (ex. trees) */
4486 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4489 if (have_flag(f_ptr->flags, FF_WATER))
4491 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4495 if (have_flag(f_ptr->flags, FF_LAVA))
4498 if (!p_ptr->resist_fire) lava *= 2;
4499 if (!p_ptr->levitation) lava *= 2;
4500 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4505 /* Detected traps and doors */
4506 if (cave[y][x].info & (CAVE_MARK))
4508 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4509 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4516 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
4520 * @param wall プレイヤーが壁の中にいるならばTRUE
4523 static void travel_flow_aux(int y, int x, int n, bool wall)
4525 cave_type *c_ptr = &cave[y][x];
4526 feature_type *f_ptr = &f_info[c_ptr->feat];
4527 int old_head = flow_head;
4529 int base_cost = (n % TRAVEL_UNABLE);
4530 int from_wall = (n / TRAVEL_UNABLE);
4533 /* Ignore out of bounds */
4534 if (!in_bounds(y, x)) return;
4536 /* Ignore unknown grid except in wilderness */
4537 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
4539 /* Ignore "walls" and "rubble" (include "secret doors") */
4540 if (have_flag(f_ptr->flags, FF_WALL) ||
4541 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4542 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4543 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4545 if (!wall || !from_wall) return;
4546 add_cost += TRAVEL_UNABLE;
4550 add_cost = travel_flow_cost(y, x);
4553 cost = base_cost + add_cost;
4555 /* Ignore lower cost entries */
4556 if (travel.cost[y][x] <= cost) return;
4558 /* Save the flow cost */
4559 travel.cost[y][x] = cost;
4561 /* Enqueue that entry */
4562 temp2_y[flow_head] = y;
4563 temp2_x[flow_head] = x;
4565 /* Advance the queue */
4566 if (++flow_head == MAX_SHORT) flow_head = 0;
4568 /* Hack -- notice overflow by forgetting new entry */
4569 if (flow_head == flow_tail) flow_head = old_head;
4575 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
4576 * @param ty 目標地点のY座標
4577 * @param tx 目標地点のX座標
4580 static void travel_flow(int ty, int tx)
4584 feature_type *f_ptr = &f_info[cave[py][px].feat];
4586 /* Reset the "queue" */
4587 flow_head = flow_tail = 0;
4589 /* is player in the wall? */
4590 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4592 /* Start at the target grid */
4593 travel_flow_aux(ty, tx, 0, wall);
4595 /* Now process the queue */
4596 while (flow_head != flow_tail)
4598 /* Extract the next entry */
4599 y = temp2_y[flow_tail];
4600 x = temp2_x[flow_tail];
4602 /* Forget that entry */
4603 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4605 /* Ignore too far entries */
4606 //if (distance(ty, tx, y, x) > 100) continue;
4608 /* Add the "children" */
4609 for (d = 0; d < 8; d++)
4611 /* Add that child if "legal" */
4612 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4616 /* Forget the flow info */
4617 flow_head = flow_tail = 0;
4621 * @brief トラベル処理のメインルーチン
4624 void do_cmd_travel(void)
4628 feature_type *f_ptr;
4630 if (travel.x != 0 && travel.y != 0 &&
4631 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4636 else if (!tgt_pt(&x, &y)) return;
4638 if ((x == px) && (y == py))
4640 msg_print(_("すでにそこにいます!", "You are already there!!"));
4644 f_ptr = &f_info[cave[y][x].feat];
4646 if ((cave[y][x].info & CAVE_MARK) &&
4647 (have_flag(f_ptr->flags, FF_WALL) ||
4648 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4649 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4651 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4655 forget_travel_flow();
4661 /* Travel till 255 steps */
4667 /* Decides first direction */
4670 sx = ((x == px) || (dx < dy)) ? 0 : ((x > px) ? 1 : -1);
4671 sy = ((y == py) || (dy < dx)) ? 0 : ((y > py) ? 1 : -1);
4673 for (i = 1; i <= 9; i++)
4675 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;