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[p_ptr->y][p_ptr->x];
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 */
120 p_ptr->energy_use = 100;
122 /* End the command */
132 go_up = confirm_leave_level(FALSE);
135 /* Cancel the command */
138 /* Hack -- take a turn */
139 p_ptr->energy_use = 100;
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[p_ptr->y][p_ptr->x];
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 */
279 p_ptr->energy_use = 100;
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 */
303 p_ptr->oldpx = p_ptr->x;
304 p_ptr->oldpy = p_ptr->y;
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 */
315 p_ptr->energy_use = 100;
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);
401 p_ptr->energy_use = 100;
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)
474 BIT_FLAGS mode = AM_GOOD;
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(POSITION y, POSITION x, KIND_OBJECT_IDX 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(p_ptr->y, p_ptr->x, 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];
814 p_ptr->energy_use = 100;
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(IDX 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(POSITION *y, POSITION *x, bool (*test)(IDX 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 = p_ptr->y + ddy_ddd[d];
912 xx = p_ptr->x + 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(POSITION *y, POSITION *x, bool trapped)
956 /* Count how many matches */
959 /* Check around (and under) the character */
960 for (d = 0; d < 9; d++)
962 /* Extract adjacent (legal) location */
963 int yy = p_ptr->y + ddy_ddd[d];
964 int xx = p_ptr->x + ddx_ddd[d];
966 /* No (visible) chest is there */
967 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
969 /* Grab the object */
970 o_ptr = &o_list[o_idx];
973 if (o_ptr->pval == 0) continue;
975 /* No (known) traps here */
976 if (trapped && (!object_is_known(o_ptr) ||
977 !chest_traps[o_ptr->pval])) continue;
982 /* Remember the location. Only useful if only one match */
993 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
994 * Convert an adjacent location to a direction.
995 * @param y 方角を確認したY座標
996 * @param x 方角を確認したX座標
999 static DIRECTION coords_to_dir(POSITION y, POSITION x)
1001 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1008 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1010 return d[dx + 1][dy + 1];
1013 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1017 * @brief 「開ける」動作コマンドのサブルーチン /
1018 * Perform the basic "open" command on doors
1019 * @param y 対象を行うマスのY座標
1020 * @param x 対象を行うマスのX座標
1021 * @return 実際に処理が行われた場合TRUEを返す。
1023 * Assume destination is a closed/locked/jammed door
1024 * Assume there is no monster blocking the destination
1025 * Returns TRUE if repeated commands may continue
1027 static bool do_cmd_open_aux(int y, int x)
1031 /* Get requested grid */
1032 cave_type *c_ptr = &cave[y][x];
1034 feature_type *f_ptr = &f_info[c_ptr->feat];
1040 p_ptr->energy_use = 100;
1042 /* Seeing true feature code (ignore mimic) */
1045 if (!have_flag(f_ptr->flags, FF_OPEN))
1048 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1052 else if (f_ptr->power)
1055 i = p_ptr->skill_dis;
1057 /* Penalize some conditions */
1058 if (p_ptr->blind || no_lite()) i = i / 10;
1059 if (p_ptr->confused || p_ptr->image) i = i / 10;
1061 /* Extract the lock power */
1064 /* Extract the difficulty XXX XXX XXX */
1067 /* Always have a small chance of success */
1071 if (randint0(100) < j)
1074 msg_print(_("鍵をはずした。", "You have picked the lock."));
1077 cave_alter_feat(y, x, FF_OPEN);
1080 sound(SOUND_OPENDOOR);
1090 if (flush_failure) flush();
1093 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1095 /* We may keep trying */
1104 cave_alter_feat(y, x, FF_OPEN);
1107 sound(SOUND_OPENDOOR);
1115 * @brief 「開ける」コマンドのメインルーチン /
1116 * Open a closed/locked/jammed door or a closed/locked chest.
1119 * Unlocking a locked door/chest is worth one experience point.
1121 void do_cmd_open(void)
1129 if (p_ptr->special_defense & KATA_MUSOU)
1131 set_action(ACTION_NONE);
1134 #ifdef ALLOW_EASY_OPEN /* TNB */
1136 /* Option: Pick a direction */
1139 int num_doors, num_chests;
1141 /* Count closed doors (locked or jammed) */
1142 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1144 /* Count chests (locked) */
1145 num_chests = count_chests(&y, &x, FALSE);
1147 /* See if only one target */
1148 if (num_doors || num_chests)
1150 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1152 if (!too_many) command_dir = coords_to_dir(y, x);
1156 #endif /* ALLOW_EASY_OPEN -- TNB */
1158 /* Allow repeated command */
1161 /* Set repeat count */
1162 command_rep = command_arg - 1;
1164 /* Redraw the state */
1165 p_ptr->redraw |= (PR_STATE);
1167 /* Cancel the arg */
1171 /* Get a "repeated" direction */
1172 if (get_rep_dir(&dir, TRUE))
1177 /* Get requested location */
1178 y = p_ptr->y + ddy[dir];
1179 x = p_ptr->x + ddx[dir];
1181 /* Get requested grid */
1182 c_ptr = &cave[y][x];
1184 /* Feature code (applying "mimic" field) */
1185 feat = get_feat_mimic(c_ptr);
1187 /* Check for chest */
1188 o_idx = chest_check(y, x, FALSE);
1190 /* Nothing useful */
1191 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
1194 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
1197 /* Monster in the way */
1198 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1201 p_ptr->energy_use = 100;
1204 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1213 /* Open the chest */
1214 more = do_cmd_open_chest(y, x, o_idx);
1221 more = do_cmd_open_aux(y, x);
1225 /* Cancel repeat unless we may continue */
1226 if (!more) disturb(0, 0);
1232 * @brief 「閉じる」動作コマンドのサブルーチン /
1233 * Perform the basic "close" command
1234 * @param y 対象を行うマスのY座標
1235 * @param x 対象を行うマスのX座標
1236 * @return 実際に処理が行われた場合TRUEを返す。
1238 * Assume destination is an open/broken door
1239 * Assume there is no monster blocking the destination
1240 * Returns TRUE if repeated commands may continue
1242 static bool do_cmd_close_aux(int y, int x)
1244 /* Get grid and contents */
1245 cave_type *c_ptr = &cave[y][x];
1246 s16b old_feat = c_ptr->feat;
1250 p_ptr->energy_use = 100;
1252 /* Seeing true feature code (ignore mimic) */
1255 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1257 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
1259 /* Hack -- object in the way */
1260 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
1261 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
1264 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
1268 /* Close the door */
1269 cave_alter_feat(y, x, FF_CLOSE);
1272 if (old_feat == c_ptr->feat)
1275 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
1280 sound(SOUND_SHUTDOOR);
1291 * @brief 「閉じる」コマンドのメインルーチン /
1292 * Close an open door.
1295 * Unlocking a locked door/chest is worth one experience point.
1297 void do_cmd_close(void)
1304 if (p_ptr->special_defense & KATA_MUSOU)
1306 set_action(ACTION_NONE);
1309 #ifdef ALLOW_EASY_OPEN /* TNB */
1311 /* Option: Pick a direction */
1314 /* Count open doors */
1315 if (count_dt(&y, &x, is_open, FALSE) == 1)
1317 command_dir = coords_to_dir(y, x);
1321 #endif /* ALLOW_EASY_OPEN -- TNB */
1323 /* Allow repeated command */
1326 /* Set repeat count */
1327 command_rep = command_arg - 1;
1329 /* Redraw the state */
1330 p_ptr->redraw |= (PR_STATE);
1332 /* Cancel the arg */
1336 /* Get a "repeated" direction */
1337 if (get_rep_dir(&dir,FALSE))
1342 /* Get requested location */
1343 y = p_ptr->y + ddy[dir];
1344 x = p_ptr->x + ddx[dir];
1346 /* Get grid and contents */
1347 c_ptr = &cave[y][x];
1349 /* Feature code (applying "mimic" field) */
1350 feat = get_feat_mimic(c_ptr);
1352 /* Require open/broken door */
1353 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1356 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1359 /* Monster in the way */
1360 else if (c_ptr->m_idx)
1363 p_ptr->energy_use = 100;
1366 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1372 /* Close the door */
1375 /* Close the door */
1376 more = do_cmd_close_aux(y, x);
1380 /* Cancel repeat unless we may continue */
1381 if (!more) disturb(0, 0);
1386 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1387 * Determine if a given grid may be "tunneled"
1388 * @param y 対象を行うマスのY座標
1389 * @param x 対象を行うマスのX座標
1392 static bool do_cmd_tunnel_test(int y, int x)
1394 cave_type *c_ptr = &cave[y][x];
1396 /* Must have knowledge */
1397 if (!(c_ptr->info & CAVE_MARK))
1400 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1406 /* Must be a wall/door/etc */
1407 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1410 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1422 * @brief 「掘る」動作コマンドのサブルーチン /
1423 * Perform the basic "tunnel" command
1424 * @param y 対象を行うマスのY座標
1425 * @param x 対象を行うマスのX座標
1426 * @return 実際に処理が行われた場合TRUEを返す。
1428 * Assumes that no monster is blocking the destination
1429 * Do not use twall anymore
1430 * Returns TRUE if repeated commands may continue
1432 static bool do_cmd_tunnel_aux(int y, int x)
1435 feature_type *f_ptr, *mimic_f_ptr;
1440 /* Verify legality */
1441 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1444 p_ptr->energy_use = 100;
1447 c_ptr = &cave[y][x];
1448 f_ptr = &f_info[c_ptr->feat];
1449 power = f_ptr->power;
1451 /* Feature code (applying "mimic" field) */
1452 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1454 name = f_name + mimic_f_ptr->name;
1459 if (have_flag(f_ptr->flags, FF_PERMANENT))
1462 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1464 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1467 /* Map border (mimiccing Permanent wall) */
1470 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1475 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1478 if (p_ptr->skill_dig > randint0(20 * power))
1481 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1483 /* Remove the feature */
1484 cave_alter_feat(y, x, FF_TUNNEL);
1486 /* Update some things */
1487 p_ptr->update |= (PU_FLOW);
1491 /* Message, keep digging */
1492 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1500 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1503 if (p_ptr->skill_dig > power + randint0(40 * power))
1505 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1508 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1509 p_ptr->update |= (PU_FLOW);
1513 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1515 /* Remove the feature */
1516 cave_alter_feat(y, x, FF_TUNNEL);
1518 chg_virtue(V_DILIGENCE, 1);
1519 chg_virtue(V_NATURE, -1);
1527 /* We may continue chopping */
1528 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1529 /* Occasional Search XXX XXX */
1530 if (randint0(100) < 25) search();
1534 /* We may continue tunelling */
1535 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1542 if (is_hidden_door(c_ptr))
1544 /* Occasional Search XXX XXX */
1545 if (randint0(100) < 25) search();
1554 * @brief 「掘る」動作コマンドのメインルーチン /
1555 * Tunnels through "walls" (including rubble and closed doors)
1559 * Note that you must tunnel in order to hit invisible monsters
1560 * in walls, though moving into walls still takes a turn anyway.
1562 * Digging is very difficult without a "digger" weapon, but can be
1563 * accomplished by strong players using heavy weapons.
1566 void do_cmd_tunnel(void)
1576 if (p_ptr->special_defense & KATA_MUSOU)
1578 set_action(ACTION_NONE);
1581 /* Allow repeated command */
1584 /* Set repeat count */
1585 command_rep = command_arg - 1;
1587 /* Redraw the state */
1588 p_ptr->redraw |= (PR_STATE);
1590 /* Cancel the arg */
1594 /* Get a direction to tunnel, or Abort */
1595 if (get_rep_dir(&dir,FALSE))
1598 y = p_ptr->y + ddy[dir];
1599 x = p_ptr->x + ddx[dir];
1602 c_ptr = &cave[y][x];
1604 /* Feature code (applying "mimic" field) */
1605 feat = get_feat_mimic(c_ptr);
1607 /* No tunnelling through doors */
1608 if (have_flag(f_info[feat].flags, FF_DOOR))
1611 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1614 /* No tunnelling through most features */
1615 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1617 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1620 /* A monster is in the way */
1621 else if (c_ptr->m_idx)
1624 p_ptr->energy_use = 100;
1627 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1636 /* Tunnel through walls */
1637 more = do_cmd_tunnel_aux(y, x);
1641 /* Cancel repetition unless we can continue */
1642 if (!more) disturb(0, 0);
1646 #ifdef ALLOW_EASY_OPEN /* TNB */
1649 * @brief 移動処理による簡易な「開く」処理 /
1651 * @return 開く処理が実際に試みられた場合TRUEを返す
1654 * If there is a jammed/closed/locked door at the given location,
1655 * then attempt to unlock/open it. Return TRUE if an attempt was
1656 * made (successful or not), otherwise return FALSE.
1658 * The code here should be nearly identical to that in
1659 * do_cmd_open_test() and do_cmd_open_aux().
1662 bool easy_open_door(int y, int x)
1666 cave_type *c_ptr = &cave[y][x];
1667 feature_type *f_ptr = &f_info[c_ptr->feat];
1669 /* Must be a closed door */
1670 if (!is_closed_door(c_ptr->feat))
1677 if (!have_flag(f_ptr->flags, FF_OPEN))
1680 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1685 else if (f_ptr->power)
1688 i = p_ptr->skill_dis;
1690 /* Penalize some conditions */
1691 if (p_ptr->blind || no_lite()) i = i / 10;
1692 if (p_ptr->confused || p_ptr->image) i = i / 10;
1694 /* Extract the lock power */
1697 /* Extract the difficulty XXX XXX XXX */
1700 /* Always have a small chance of success */
1704 if (randint0(100) < j)
1707 msg_print(_("鍵をはずした。", "You have picked the lock."));
1710 cave_alter_feat(y, x, FF_OPEN);
1713 sound(SOUND_OPENDOOR);
1723 if (flush_failure) flush();
1726 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1735 cave_alter_feat(y, x, FF_OPEN);
1738 sound(SOUND_OPENDOOR);
1745 #endif /* ALLOW_EASY_OPEN -- TNB */
1749 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1750 * Perform the basic "disarm" command
1751 * @param y 解除を行うマスのY座標
1752 * @param x 解除を行うマスのX座標
1753 * @param o_idx 箱のオブジェクトID
1754 * @return ターンを消費する処理が行われた場合TRUEを返す
1757 * Assume destination is a visible trap
1758 * Assume there is no monster blocking the destination
1759 * Returns TRUE if repeated commands may continue
1762 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1768 object_type *o_ptr = &o_list[o_idx];
1772 p_ptr->energy_use = 100;
1774 /* Get the "disarm" factor */
1775 i = p_ptr->skill_dis;
1777 /* Penalize some conditions */
1778 if (p_ptr->blind || no_lite()) i = i / 10;
1779 if (p_ptr->confused || p_ptr->image) i = i / 10;
1781 /* Extract the difficulty */
1782 j = i - o_ptr->pval;
1784 /* Always have a small chance of success */
1787 /* Must find the trap first. */
1788 if (!object_is_known(o_ptr))
1790 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1794 /* Already disarmed/unlocked */
1795 else if (o_ptr->pval <= 0)
1797 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1800 /* No traps to find. */
1801 else if (!chest_traps[o_ptr->pval])
1803 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1806 /* Success (get a lot of experience) */
1807 else if (randint0(100) < j)
1809 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1810 gain_exp(o_ptr->pval);
1811 o_ptr->pval = (0 - o_ptr->pval);
1814 /* Failure -- Keep trying */
1815 else if ((i > 5) && (randint1(i) > 5))
1817 /* We may keep trying */
1819 if (flush_failure) flush();
1820 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1823 /* Failure -- Set off the trap */
1826 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1828 chest_trap(y, x, o_idx);
1837 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1838 * Perform the basic "disarm" command
1839 * @param y 解除を行うマスのY座標
1840 * @param x 解除を行うマスのX座標
1841 * @param dir プレイヤーからみた方向ID
1842 * @return ターンを消費する処理が行われた場合TRUEを返す
1845 * Assume destination is a visible trap
1846 * Assume there is no monster blocking the destination
1847 * Returns TRUE if repeated commands may continue
1850 #ifdef ALLOW_EASY_DISARM /* TNB */
1852 bool do_cmd_disarm_aux(int y, int x, int dir)
1854 #else /* ALLOW_EASY_DISARM -- TNB */
1856 static bool do_cmd_disarm_aux(int y, int x, int dir)
1858 #endif /* ALLOW_EASY_DISARM -- TNB */
1860 /* Get grid and contents */
1861 cave_type *c_ptr = &cave[y][x];
1864 feature_type *f_ptr = &f_info[c_ptr->feat];
1866 /* Access trap name */
1867 cptr name = (f_name + f_ptr->name);
1869 /* Extract trap "power" */
1870 int power = f_ptr->power;
1874 /* Get the "disarm" factor */
1875 int i = p_ptr->skill_dis;
1880 p_ptr->energy_use = 100;
1882 /* Penalize some conditions */
1883 if (p_ptr->blind || no_lite()) i = i / 10;
1884 if (p_ptr->confused || p_ptr->image) i = i / 10;
1886 /* Extract the difficulty */
1889 /* Always have a small chance of success */
1893 if (randint0(100) < j)
1896 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1901 /* Remove the trap */
1902 cave_alter_feat(y, x, FF_DISARM);
1904 #ifdef ALLOW_EASY_DISARM /* TNB */
1906 /* Move the player onto the trap */
1907 move_player(dir, easy_disarm, FALSE);
1909 #else /* ALLOW_EASY_DISARM -- TNB */
1911 /* move the player onto the trap grid */
1912 move_player(dir, FALSE, FALSE);
1914 #endif /* ALLOW_EASY_DISARM -- TNB */
1917 /* Failure -- Keep trying */
1918 else if ((i > 5) && (randint1(i) > 5))
1921 if (flush_failure) flush();
1924 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1926 /* We may keep trying */
1930 /* Failure -- Set off the trap */
1934 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1936 #ifdef ALLOW_EASY_DISARM /* TNB */
1938 /* Move the player onto the trap */
1939 move_player(dir, easy_disarm, FALSE);
1941 #else /* ALLOW_EASY_DISARM -- TNB */
1943 /* Move the player onto the trap */
1944 move_player(dir, FALSE, FALSE);
1946 #endif /* ALLOW_EASY_DISARM -- TNB */
1955 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1956 * Disarms a trap, or chest
1959 void do_cmd_disarm(void)
1967 if (p_ptr->special_defense & KATA_MUSOU)
1969 set_action(ACTION_NONE);
1972 #ifdef ALLOW_EASY_DISARM /* TNB */
1974 /* Option: Pick a direction */
1977 int num_traps, num_chests;
1979 /* Count visible traps */
1980 num_traps = count_dt(&y, &x, is_trap, TRUE);
1982 /* Count chests (trapped) */
1983 num_chests = count_chests(&y, &x, TRUE);
1985 /* See if only one target */
1986 if (num_traps || num_chests)
1988 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1989 if (!too_many) command_dir = coords_to_dir(y, x);
1993 #endif /* ALLOW_EASY_DISARM -- TNB */
1995 /* Allow repeated command */
1998 /* Set repeat count */
1999 command_rep = command_arg - 1;
2001 /* Redraw the state */
2002 p_ptr->redraw |= (PR_STATE);
2004 /* Cancel the arg */
2008 /* Get a direction (or abort) */
2009 if (get_rep_dir(&dir,TRUE))
2015 y = p_ptr->y + ddy[dir];
2016 x = p_ptr->x + ddx[dir];
2018 /* Get grid and contents */
2019 c_ptr = &cave[y][x];
2021 /* Feature code (applying "mimic" field) */
2022 feat = get_feat_mimic(c_ptr);
2024 /* Check for chests */
2025 o_idx = chest_check(y, x, TRUE);
2028 if (!is_trap(feat) && !o_idx)
2031 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
2034 /* Monster in the way */
2035 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2038 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2047 /* Disarm the chest */
2048 more = do_cmd_disarm_chest(y, x, o_idx);
2054 /* Disarm the trap */
2055 more = do_cmd_disarm_aux(y, x, dir);
2059 /* Cancel repeat unless told not to */
2060 if (!more) disturb(0, 0);
2065 * @brief 「打ち破る」動作コマンドのサブルーチン /
2066 * Perform the basic "bash" command
2067 * @param y 対象を行うマスのY座標
2068 * @param x 対象を行うマスのX座標
2069 * @param dir プレイヤーから見たターゲットの方角ID
2070 * @return 実際に処理が行われた場合TRUEを返す。
2073 * Assume destination is a closed/locked/jammed door
2074 * Assume there is no monster blocking the destination
2075 * Returns TRUE if repeated commands may continue
2078 static bool do_cmd_bash_aux(int y, int x, int dir)
2081 cave_type *c_ptr = &cave[y][x];
2084 feature_type *f_ptr = &f_info[c_ptr->feat];
2086 /* Hack -- Bash power based on strength */
2087 /* (Ranges from 3 to 20 to 100 to 200) */
2088 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2090 /* Extract door power */
2091 int temp = f_ptr->power;
2095 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2098 p_ptr->energy_use = 100;
2101 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
2103 /* Compare bash power to door power XXX XXX XXX */
2104 temp = (bash - (temp * 10));
2106 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2108 /* Hack -- always have a chance */
2109 if (temp < 1) temp = 1;
2111 /* Hack -- attempt to bash down the door */
2112 if (randint0(100) < temp)
2115 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
2118 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
2120 /* Break down the door */
2121 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
2123 cave_alter_feat(y, x, FF_BASH);
2129 cave_alter_feat(y, x, FF_OPEN);
2132 /* Hack -- Fall through the door */
2133 move_player(dir, FALSE, FALSE);
2136 /* Saving throw against stun */
2137 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2141 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
2143 /* Allow repeated bashing */
2147 /* High dexterity yields coolness */
2151 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
2153 /* Hack -- Lose balance ala paralysis */
2154 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2163 * @brief 「打ち破る」動作コマンドのメインルーチン /
2164 * Bash open a door, success based on character strength
2168 * For a closed door, pval is positive if locked; negative if stuck.
2170 * For an open door, pval is positive for a broken door.
2172 * A closed door can be opened - harder if locked. Any door might be
2173 * bashed open (and thereby broken). Bashing a door is (potentially)
2174 * faster! You move into the door way. To open a stuck door, it must
2175 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2177 * Creatures can also open or bash doors, see elsewhere.
2180 void do_cmd_bash(void)
2189 if (p_ptr->special_defense & KATA_MUSOU)
2191 set_action(ACTION_NONE);
2194 /* Allow repeated command */
2197 /* Set repeat count */
2198 command_rep = command_arg - 1;
2200 /* Redraw the state */
2201 p_ptr->redraw |= (PR_STATE);
2203 /* Cancel the arg */
2207 /* Get a "repeated" direction */
2208 if (get_rep_dir(&dir,FALSE))
2213 y = p_ptr->y + ddy[dir];
2214 x = p_ptr->x + ddx[dir];
2217 c_ptr = &cave[y][x];
2219 /* Feature code (applying "mimic" field) */
2220 feat = get_feat_mimic(c_ptr);
2222 /* Nothing useful */
2223 if (!have_flag(f_info[feat].flags, FF_BASH))
2226 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
2229 /* Monster in the way */
2230 else if (c_ptr->m_idx)
2233 p_ptr->energy_use = 100;
2236 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2242 /* Bash a closed door */
2246 more = do_cmd_bash_aux(y, x, dir);
2250 /* Unless valid action taken, cancel bash */
2251 if (!more) disturb(0, 0);
2256 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
2260 * Manipulate an adjacent grid in some way
2262 * Attack monsters, tunnel through walls, disarm traps, open doors.
2264 * Consider confusion XXX XXX XXX
2266 * This command must always take a turn, to prevent free detection
2267 * of invisible monsters.
2270 void do_cmd_alter(void)
2279 if (p_ptr->special_defense & KATA_MUSOU)
2281 set_action(ACTION_NONE);
2284 /* Allow repeated command */
2287 /* Set repeat count */
2288 command_rep = command_arg - 1;
2290 /* Redraw the state */
2291 p_ptr->redraw |= (PR_STATE);
2293 /* Cancel the arg */
2297 /* Get a direction */
2298 if (get_rep_dir(&dir,TRUE))
2301 feature_type *f_ptr;
2304 y = p_ptr->y + ddy[dir];
2305 x = p_ptr->x + ddx[dir];
2308 c_ptr = &cave[y][x];
2310 /* Feature code (applying "mimic" field) */
2311 feat = get_feat_mimic(c_ptr);
2312 f_ptr = &f_info[feat];
2315 p_ptr->energy_use = 100;
2317 /* Attack monsters */
2325 else if (have_flag(f_ptr->flags, FF_OPEN))
2327 more = do_cmd_open_aux(y, x);
2330 /* Bash jammed doors */
2331 else if (have_flag(f_ptr->flags, FF_BASH))
2333 more = do_cmd_bash_aux(y, x, dir);
2336 /* Tunnel through walls */
2337 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2339 more = do_cmd_tunnel_aux(y, x);
2342 /* Close open doors */
2343 else if (have_flag(f_ptr->flags, FF_CLOSE))
2345 more = do_cmd_close_aux(y, x);
2349 else if (have_flag(f_ptr->flags, FF_DISARM))
2351 more = do_cmd_disarm_aux(y, x, dir);
2358 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
2362 /* Cancel repetition unless we can continue */
2363 if (!more) disturb(0, 0);
2369 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
2370 * Find the index of some "spikes", if possible.
2371 * @param ip くさびとして打てるオブジェクトのID
2372 * @return オブジェクトがある場合TRUEを返す
2375 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2378 static bool get_spike(int *ip)
2382 /* Check every item in the pack */
2383 for (i = 0; i < INVEN_PACK; i++)
2385 object_type *o_ptr = &inventory[i];
2387 /* Skip non-objects */
2388 if (!o_ptr->k_idx) continue;
2390 /* Check the "tval" code */
2391 if (o_ptr->tval == TV_SPIKE)
2393 /* Save the spike index */
2407 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
2408 * Jam a closed door with a spike
2412 * This command may NOT be repeated
2415 void do_cmd_spike(void)
2419 if (p_ptr->special_defense & KATA_MUSOU)
2421 set_action(ACTION_NONE);
2424 /* Get a "repeated" direction */
2425 if (get_rep_dir(&dir,FALSE))
2432 y = p_ptr->y + ddy[dir];
2433 x = p_ptr->x + ddx[dir];
2435 /* Get grid and contents */
2436 c_ptr = &cave[y][x];
2438 /* Feature code (applying "mimic" field) */
2439 feat = get_feat_mimic(c_ptr);
2441 /* Require closed door */
2442 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2445 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2449 else if (!get_spike(&item))
2452 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2455 /* Is a monster in the way? */
2456 else if (c_ptr->m_idx)
2459 p_ptr->energy_use = 100;
2462 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2472 p_ptr->energy_use = 100;
2474 /* Successful jamming */
2475 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2476 cave_alter_feat(y, x, FF_SPIKE);
2478 /* Use up, and describe, a single spike, from the bottom */
2479 inven_item_increase(item, -1);
2480 inven_item_describe(item);
2481 inven_item_optimize(item);
2489 * @brief 「歩く」動作コマンドのメインルーチン /
2490 * Support code for the "Walk" and "Jump" commands
2491 * @param pickup アイテムの自動拾いを行うならTRUE
2494 void do_cmd_walk(bool pickup)
2501 /* Allow repeated command */
2504 /* Set repeat count */
2505 command_rep = command_arg - 1;
2507 /* Redraw the state */
2508 p_ptr->redraw |= (PR_STATE);
2510 /* Cancel the arg */
2514 /* Get a "repeated" direction */
2515 if (get_rep_dir(&dir, FALSE))
2518 p_ptr->energy_use = 100;
2520 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2522 set_action(ACTION_NONE);
2525 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2526 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2527 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2529 /* Actually move the character */
2530 move_player(dir, pickup, FALSE);
2532 /* Allow more walking */
2536 /* Hack again -- Is there a special encounter ??? */
2537 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2539 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2542 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2544 /* Inform the player of his horrible fate :=) */
2545 msg_print(_("襲撃だ!", "You are ambushed !"));
2547 /* Go into large wilderness view */
2548 p_ptr->oldpy = randint1(MAX_HGT-2);
2549 p_ptr->oldpx = randint1(MAX_WID-2);
2552 /* Give first move to monsters */
2553 p_ptr->energy_use = 100;
2555 /* HACk -- set the encouter flag for the wilderness generation */
2556 generate_encounter = TRUE;
2560 /* Cancel repeat unless we may continue */
2561 if (!more) disturb(0, 0);
2566 * @brief 「走る」動作コマンドのメインルーチン /
2570 void do_cmd_run(void)
2574 /* Hack -- no running when confused */
2575 if (p_ptr->confused)
2577 msg_print(_("混乱していて走れない!", "You are too confused!"));
2581 if (p_ptr->special_defense & KATA_MUSOU)
2583 set_action(ACTION_NONE);
2586 /* Get a "repeated" direction */
2587 if (get_rep_dir(&dir,FALSE))
2589 /* Hack -- Set the run counter */
2590 running = (command_arg ? command_arg : 1000);
2599 * @brief 「留まる」動作コマンドのメインルーチン /
2600 * Stay still. Search. Enter stores.
2601 * Pick up treasure if "pickup" is true.
2602 * @param pickup アイテムの自動拾いを行うならTRUE
2605 void do_cmd_stay(bool pickup)
2607 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2609 /* Allow repeated command */
2612 /* Set repeat count */
2613 command_rep = command_arg - 1;
2615 /* Redraw the state */
2616 p_ptr->redraw |= (PR_STATE);
2618 /* Cancel the arg */
2623 p_ptr->energy_use = 100;
2625 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2626 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2631 * @brief 「休む」動作コマンドのメインルーチン /
2632 * Resting allows a player to safely restore his hp -RAK-
2635 void do_cmd_rest(void)
2638 set_action(ACTION_NONE);
2640 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2646 if (hex_spelling_any()) stop_hex_spell_all();
2648 /* Prompt for time if needed */
2649 if (command_arg <= 0)
2651 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2652 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2658 strcpy(out_val, "&");
2660 /* Ask for duration */
2661 if (!get_string(p, out_val, 4)) return;
2663 /* Rest until done */
2664 if (out_val[0] == '&')
2666 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2670 else if (out_val[0] == '*')
2672 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2678 command_arg = (COMMAND_ARG)atoi(out_val);
2679 if (command_arg <= 0) return;
2685 if (command_arg > 9999) command_arg = 9999;
2687 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2689 /* Take a turn XXX XXX XXX (?) */
2690 p_ptr->energy_use = 100;
2692 /* The sin of sloth */
2693 if (command_arg > 100)
2694 chg_virtue(V_DILIGENCE, -1);
2696 /* Why are you sleeping when there's no need? WAKE UP!*/
2697 if ((p_ptr->chp == p_ptr->mhp) &&
2698 (p_ptr->csp == p_ptr->msp) &&
2699 !p_ptr->blind && !p_ptr->confused &&
2700 !p_ptr->poisoned && !p_ptr->afraid &&
2701 !p_ptr->stun && !p_ptr->cut &&
2702 !p_ptr->slow && !p_ptr->paralyzed &&
2703 !p_ptr->image && !p_ptr->word_recall &&
2704 !p_ptr->alter_reality)
2705 chg_virtue(V_DILIGENCE, -1);
2707 /* Save the rest code */
2708 resting = command_arg;
2709 p_ptr->action = ACTION_REST;
2711 /* Recalculate bonuses */
2712 p_ptr->update |= (PU_BONUS);
2714 /* Redraw the state */
2715 p_ptr->redraw |= (PR_STATE);
2726 * @brief 矢弾を射撃した場合の破損確率を返す /
2727 * Determines the odds of an object breaking when thrown at a monster
2728 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2731 * Note that artifacts never break, see the "drop_near()" function.
2733 static int breakage_chance(object_type *o_ptr)
2735 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2737 /* Examine the snipe type */
2740 if (snipe_type == SP_KILL_WALL) return (100);
2741 if (snipe_type == SP_EXPLODE) return (100);
2742 if (snipe_type == SP_PIERCE) return (100);
2743 if (snipe_type == SP_FINAL) return (100);
2744 if (snipe_type == SP_NEEDLE) return (100);
2745 if (snipe_type == SP_EVILNESS) return (40);
2746 if (snipe_type == SP_HOLYNESS) return (40);
2749 /* Examine the item type */
2750 switch (o_ptr->tval)
2766 /* Sometimes break */
2771 return (20 - archer_bonus * 2);
2776 return (10 - archer_bonus);
2784 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2785 * Determines the odds of an object breaking when thrown at a monster
2786 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2787 * @param tdam 計算途中のダメージ量
2788 * @param m_ptr 目標モンスターの構造体参照ポインタ
2789 * @return スレイ倍率をかけたダメージ量
2791 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2795 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2797 u32b flgs[TR_FLAG_SIZE];
2799 /* Extract the flags */
2800 object_flags(o_ptr, flgs);
2802 /* Some "weapons" and "ammo" do extra damage */
2803 switch (o_ptr->tval)
2810 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2811 (r_ptr->flags3 & RF3_ANIMAL))
2813 if (is_original_ap_and_seen(m_ptr))
2815 r_ptr->r_flags3 |= RF3_ANIMAL;
2818 if (mult < 17) mult = 17;
2822 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2823 (r_ptr->flags3 & RF3_ANIMAL))
2825 if (is_original_ap_and_seen(m_ptr))
2827 r_ptr->r_flags3 |= RF3_ANIMAL;
2830 if (mult < 27) mult = 27;
2834 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2835 (r_ptr->flags3 & RF3_EVIL))
2837 if (is_original_ap_and_seen(m_ptr))
2839 r_ptr->r_flags3 |= RF3_EVIL;
2842 if (mult < 15) mult = 15;
2846 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2847 (r_ptr->flags3 & RF3_EVIL))
2849 if (is_original_ap_and_seen(m_ptr))
2851 r_ptr->r_flags3 |= RF3_EVIL;
2854 if (mult < 25) mult = 25;
2858 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2859 (r_ptr->flags2 & RF2_HUMAN))
2861 if (is_original_ap_and_seen(m_ptr))
2863 r_ptr->r_flags2 |= RF2_HUMAN;
2866 if (mult < 17) mult = 17;
2870 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2871 (r_ptr->flags2 & RF2_HUMAN))
2873 if (is_original_ap_and_seen(m_ptr))
2875 r_ptr->r_flags2 |= RF2_HUMAN;
2878 if (mult < 27) mult = 27;
2882 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2883 (r_ptr->flags3 & RF3_UNDEAD))
2885 if (is_original_ap_and_seen(m_ptr))
2887 r_ptr->r_flags3 |= RF3_UNDEAD;
2890 if (mult < 20) mult = 20;
2894 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2895 (r_ptr->flags3 & RF3_UNDEAD))
2897 if (is_original_ap_and_seen(m_ptr))
2899 r_ptr->r_flags3 |= RF3_UNDEAD;
2902 if (mult < 30) mult = 30;
2906 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2907 (r_ptr->flags3 & RF3_DEMON))
2909 if (is_original_ap_and_seen(m_ptr))
2911 r_ptr->r_flags3 |= RF3_DEMON;
2914 if (mult < 20) mult = 20;
2918 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2919 (r_ptr->flags3 & RF3_DEMON))
2921 if (is_original_ap_and_seen(m_ptr))
2923 r_ptr->r_flags3 |= RF3_DEMON;
2926 if (mult < 30) mult = 30;
2930 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2931 (r_ptr->flags3 & RF3_ORC))
2933 if (is_original_ap_and_seen(m_ptr))
2935 r_ptr->r_flags3 |= RF3_ORC;
2938 if (mult < 20) mult = 20;
2942 if ((have_flag(flgs, TR_KILL_ORC)) &&
2943 (r_ptr->flags3 & RF3_ORC))
2945 if (is_original_ap_and_seen(m_ptr))
2947 r_ptr->r_flags3 |= RF3_ORC;
2950 if (mult < 30) mult = 30;
2954 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2955 (r_ptr->flags3 & RF3_TROLL))
2957 if (is_original_ap_and_seen(m_ptr))
2959 r_ptr->r_flags3 |= RF3_TROLL;
2962 if (mult < 20) mult = 20;
2966 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2967 (r_ptr->flags3 & RF3_TROLL))
2969 if (is_original_ap_and_seen(m_ptr))
2971 r_ptr->r_flags3 |= RF3_TROLL;
2974 if (mult < 30) mult = 30;
2978 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2979 (r_ptr->flags3 & RF3_GIANT))
2981 if (is_original_ap_and_seen(m_ptr))
2983 r_ptr->r_flags3 |= RF3_GIANT;
2986 if (mult < 20) mult = 20;
2990 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2991 (r_ptr->flags3 & RF3_GIANT))
2993 if (is_original_ap_and_seen(m_ptr))
2995 r_ptr->r_flags3 |= RF3_GIANT;
2998 if (mult < 30) mult = 30;
3002 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3003 (r_ptr->flags3 & RF3_DRAGON))
3005 if (is_original_ap_and_seen(m_ptr))
3007 r_ptr->r_flags3 |= RF3_DRAGON;
3010 if (mult < 20) mult = 20;
3013 /* Execute Dragon */
3014 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3015 (r_ptr->flags3 & RF3_DRAGON))
3017 if (is_original_ap_and_seen(m_ptr))
3019 r_ptr->r_flags3 |= RF3_DRAGON;
3022 if (mult < 30) mult = 30;
3024 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3025 (m_ptr->r_idx == MON_SMAUG) &&
3026 (inventory[INVEN_BOW].name1 == ART_BARD))
3031 if (have_flag(flgs, TR_BRAND_ACID))
3033 /* Notice immunity */
3034 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3036 if (is_original_ap_and_seen(m_ptr))
3038 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3042 /* Otherwise, take the damage */
3045 if (mult < 17) mult = 17;
3050 if (have_flag(flgs, TR_BRAND_ELEC))
3052 /* Notice immunity */
3053 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3055 if (is_original_ap_and_seen(m_ptr))
3057 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3061 /* Otherwise, take the damage */
3064 if (mult < 17) mult = 17;
3069 if (have_flag(flgs, TR_BRAND_FIRE))
3071 /* Notice immunity */
3072 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3074 if (is_original_ap_and_seen(m_ptr))
3076 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3080 /* Otherwise, take the damage */
3083 if (r_ptr->flags3 & RF3_HURT_FIRE)
3085 if (mult < 25) mult = 25;
3086 if (is_original_ap_and_seen(m_ptr))
3088 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3091 else if (mult < 17) mult = 17;
3096 if (have_flag(flgs, TR_BRAND_COLD))
3098 /* Notice immunity */
3099 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3101 if (is_original_ap_and_seen(m_ptr))
3103 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3106 /* Otherwise, take the damage */
3109 if (r_ptr->flags3 & RF3_HURT_COLD)
3111 if (mult < 25) mult = 25;
3112 if (is_original_ap_and_seen(m_ptr))
3114 r_ptr->r_flags3 |= RF3_HURT_COLD;
3117 else if (mult < 17) mult = 17;
3121 /* Brand (Poison) */
3122 if (have_flag(flgs, TR_BRAND_POIS))
3124 /* Notice immunity */
3125 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3127 if (is_original_ap_and_seen(m_ptr))
3129 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3133 /* Otherwise, take the damage */
3136 if (mult < 17) mult = 17;
3140 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3142 p_ptr->csp -= (1+(p_ptr->msp / 30));
3143 p_ptr->redraw |= (PR_MANA);
3144 mult = mult * 5 / 2;
3151 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
3153 /* Return the total damage */
3154 return (tdam * mult / 10);
3159 * @brief 射撃処理のサブルーチン /
3160 * Fire an object from the pack or floor.
3161 * @param item 射撃するオブジェクトの所持ID
3162 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
3166 * You may only fire items that "match" your missile launcher.
3168 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3170 * See "calc_bonuses()" for more calculations and such.
3172 * Note that "firing" a missile is MUCH better than "throwing" it.
3174 * Note: "unseen" monsters are very hard to hit.
3176 * Objects are more likely to break if they "attempt" to hit a monster.
3178 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3180 * The "extra shot" code works by decreasing the amount of energy
3181 * required to make each shot, spreading the shots out over time.
3183 * Note that when firing missiles, the launcher multiplier is applied
3184 * after all the bonuses are added in, making multipliers very useful.
3186 * Note that Bows of "Extra Might" get extra range and an extra bonus
3187 * for the damage multiplier.
3189 * Note that Bows of "Extra Shots" give an extra shot.
3192 void do_cmd_fire_aux(int item, object_type *j_ptr)
3195 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
3196 int tdam_base, tdis, thits, tmul;
3198 int cur_dis, visible;
3205 bool hit_body = FALSE;
3207 char o_name[MAX_NLEN];
3209 u16b path_g[512]; /* For calcuration of path length */
3211 int msec = delay_factor * delay_factor * delay_factor;
3214 bool stick_to = FALSE;
3216 /* Access the item (if in the pack) */
3219 o_ptr = &inventory[item];
3223 o_ptr = &o_list[0 - item];
3226 /* Sniper - Cannot shot a single arrow twice */
3227 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
3229 /* Describe the object */
3230 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3232 /* Use the proper number of shots */
3233 thits = p_ptr->num_fire;
3235 /* Use a base distance */
3238 /* Base damage from thrown object plus launcher bonus */
3239 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3241 /* Actually "fire" the object */
3242 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3243 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3244 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3246 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3248 p_ptr->energy_use = bow_energy(j_ptr->sval);
3249 tmul = bow_tmul(j_ptr->sval);
3251 /* Get extra "power" from "extra might" */
3252 if (p_ptr->xtra_might) tmul++;
3254 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3256 /* Boost the damage */
3261 tdis = 13 + tmul/80;
3262 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3265 tdis -= (5 - (p_ptr->concent + 1) / 2);
3270 project_length = tdis + 1;
3272 /* Get a direction (or cancel) */
3273 if (!get_aim_dir(&dir))
3275 p_ptr->energy_use = 0;
3277 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
3279 /* need not to reset project_length (already did)*/
3284 /* Predict the "target" location */
3285 tx = p_ptr->x + 99 * ddx[dir];
3286 ty = p_ptr->y + 99 * ddy[dir];
3288 /* Check for "target request" */
3289 if ((dir == 5) && target_okay())
3295 /* Get projection path length */
3296 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
3298 project_length = 0; /* reset to default */
3300 /* Don't shoot at my feet */
3301 if (tx == p_ptr->x && ty == p_ptr->y)
3303 p_ptr->energy_use = 0;
3305 /* project_length is already reset to 0 */
3311 /* Take a (partial) turn */
3312 p_ptr->energy_use = (p_ptr->energy_use / thits);
3315 /* Sniper - Difficult to shot twice at 1 turn */
3316 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
3318 /* Sniper - Repeat shooting when double shots */
3319 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
3322 /* Start at the player */
3326 /* Get local object */
3329 /* Obtain a local object */
3330 object_copy(q_ptr, o_ptr);
3335 /* Reduce and describe inventory */
3338 inven_item_increase(item, -1);
3339 inven_item_describe(item);
3340 inven_item_optimize(item);
3343 /* Reduce and describe floor item */
3346 floor_item_increase(0 - item, -1);
3347 floor_item_optimize(0 - item);
3353 /* Hack -- Handle stuff */
3356 /* Save the old location */
3360 /* The shot does not hit yet */
3363 /* Travel until stopped */
3364 for (cur_dis = 0; cur_dis <= tdis; )
3368 /* Hack -- Stop at the target */
3369 if ((y == ty) && (x == tx)) break;
3371 /* Calculate the new location (see "project()") */
3374 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3377 if (snipe_type == SP_KILL_WALL)
3379 c_ptr = &cave[ny][nx];
3381 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3383 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
3384 /* Forget the wall */
3385 c_ptr->info &= ~(CAVE_MARK);
3387 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3389 /* Destroy the wall */
3390 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3397 /* Stopped by walls/doors */
3398 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3400 /* Advance the distance */
3404 if (snipe_type == SP_LITE)
3406 cave[ny][nx].info |= (CAVE_GLOW);
3415 /* The player can see the (on screen) missile */
3416 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3418 char c = object_char(q_ptr);
3419 byte a = object_attr(q_ptr);
3421 /* Draw, Hilite, Fresh, Pause, Erase */
3422 print_rel(c, a, ny, nx);
3423 move_cursor_relative(ny, nx);
3425 Term_xtra(TERM_XTRA_DELAY, msec);
3430 /* The player cannot see the missile */
3433 /* Pause anyway, for consistancy */
3434 Term_xtra(TERM_XTRA_DELAY, msec);
3438 if (snipe_type == SP_KILL_TRAP)
3440 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3441 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3445 if (snipe_type == SP_EVILNESS)
3447 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3456 /* Save the old location */
3460 /* Save the new location */
3465 /* Monster here, Try to hit it */
3466 if (cave[y][x].m_idx)
3468 cave_type *c_mon_ptr = &cave[y][x];
3470 monster_type *m_ptr = &m_list[c_mon_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 /* Did we hit it (penalize range) */
3512 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3515 int tdam = tdam_base;
3517 /* Get extra damage from concentration */
3518 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3520 /* Handle unseen monster */
3523 /* Invisible monster */
3524 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3527 /* Handle visible monster */
3532 /* Get "the monster" or "it" */
3533 monster_desc(m_name, m_ptr, 0);
3536 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3540 /* Hack -- Track this monster race */
3541 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3543 /* Hack -- Track this monster */
3544 health_track(c_mon_ptr->m_idx);
3548 if (snipe_type == SP_NEEDLE)
3550 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3551 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3555 /* Get "the monster" or "it" */
3556 monster_desc(m_name, m_ptr, 0);
3558 tdam = m_ptr->hp + 1;
3559 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3565 /* Apply special damage XXX XXX XXX */
3566 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3567 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3569 /* No negative damage */
3570 if (tdam < 0) tdam = 0;
3572 /* Modify the damage */
3573 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3576 msg_format_wizard(CHEAT_MONSTER,
3577 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3578 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3581 if (snipe_type == SP_EXPLODE)
3583 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3585 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3586 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3591 if (snipe_type == SP_HOLYNESS)
3593 cave[ny][nx].info |= (CAVE_GLOW);
3602 /* Hit the monster, check for death */
3603 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3612 if (object_is_fixed_artifact(q_ptr) &&
3613 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3617 monster_desc(m_name, m_ptr, 0);
3620 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3624 message_pain(c_mon_ptr->m_idx, tdam);
3626 /* Anger the monster */
3627 if (tdam > 0) anger_monster(m_ptr);
3630 if (fear && m_ptr->ml)
3637 /* Get the monster name (or "it") */
3638 monster_desc(m_name, m_ptr, 0);
3641 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3644 set_target(m_ptr, p_ptr->y, p_ptr->x);
3647 if (snipe_type == SP_RUSH)
3649 int n = randint1(5) + 3;
3650 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3652 for ( ; cur_dis <= tdis; )
3659 /* Calculate the new location (see "project()") */
3660 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3662 /* Stopped by wilderness boundary */
3663 if (!in_bounds2(ny, nx)) break;
3665 /* Stopped by walls/doors */
3666 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3668 /* Stopped by monsters */
3669 if (!cave_empty_bold(ny, nx)) break;
3671 cave[ny][nx].m_idx = m_idx;
3672 cave[oy][ox].m_idx = 0;
3677 /* Update the monster (new location) */
3678 update_mon(c_mon_ptr->m_idx, TRUE);
3684 Term_xtra(TERM_XTRA_DELAY, msec);
3696 if (snipe_type == SP_PIERCE)
3698 if(p_ptr->concent < 1) break;
3708 /* Chance of breakage (during attacks) */
3709 j = (hit_body ? breakage_chance(q_ptr) : 0);
3713 MONSTER_IDX m_idx = cave[y][x].m_idx;
3714 monster_type *m_ptr = &m_list[m_idx];
3715 IDX o_idx = o_pop();
3719 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3720 if (object_is_fixed_artifact(q_ptr))
3722 a_info[j_ptr->name1].cur_num = 0;
3727 o_ptr = &o_list[o_idx];
3728 object_copy(o_ptr, q_ptr);
3731 o_ptr->marked &= OM_TOUCHED;
3733 /* Forget location */
3734 o_ptr->iy = o_ptr->ix = 0;
3736 /* Memorize monster */
3737 o_ptr->held_m_idx = m_idx;
3740 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3743 m_ptr->hold_o_idx = o_idx;
3745 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3747 /* Drop (or break) near that location */
3748 (void)drop_near(q_ptr, j, y, x);
3752 /* Drop (or break) near that location */
3753 (void)drop_near(q_ptr, j, prev_y, prev_x);
3756 /* Sniper - Repeat shooting when double shots */
3759 /* Sniper - Loose his/her concentration after any shot */
3760 if (p_ptr->concent) reset_concentration(FALSE);
3764 * @brief 射撃処理のメインルーチン
3767 void do_cmd_fire(void)
3773 is_fired = FALSE; /* not fired yet */
3775 /* Get the "bow" (if any) */
3776 j_ptr = &inventory[INVEN_BOW];
3778 /* Require a launcher */
3781 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3786 if (j_ptr->sval == SV_CRIMSON)
3788 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3793 if (j_ptr->sval == SV_HARP)
3795 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3801 if (p_ptr->special_defense & KATA_MUSOU)
3803 set_action(ACTION_NONE);
3806 /* Require proper missile */
3807 item_tester_tval = p_ptr->tval_ammo;
3810 q = _("どれを撃ちますか? ", "Fire which item? ");
3811 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3812 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3819 do_cmd_fire_aux(item, j_ptr);
3821 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3823 /* Sniper actions after some shootings */
3824 if (snipe_type == SP_AWAY)
3826 teleport_player(10 + (p_ptr->concent * 2), 0L);
3828 if (snipe_type == SP_FINAL)
3830 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3831 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3832 (void)set_stun(p_ptr->stun + randint1(25));
3837 * @brief オブジェクトが投射可能な武器かどうかを返す。
3838 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
3839 * @return 投射可能な武器ならばTRUE
3841 static bool item_tester_hook_boomerang(object_type *o_ptr)
3843 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
3851 * @brief 投射処理のサブルーチン /
3852 * Throw an object from the pack or floor.
3854 * @param boomerang ブーメラン処理ならばTRUE
3855 * @param shuriken 忍者の手裏剣処理ならばTRUE
3856 * @return ターンを消費した場合TRUEを返す
3859 * Note: "unseen" monsters are very hard to hit.
3861 * Should throwing a weapon do full damage? Should it allow the magic
3862 * to hit bonus of the weapon to have an effect? Should it ever cause
3863 * the item to be destroyed? Should it do any damage at all?
3866 bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken)
3870 int i, j, y, x, ty, tx, prev_y, prev_x;
3872 int chance, tdam, tdis;
3873 int mul, div, dd, ds;
3874 int cur_dis, visible;
3881 bool hit_body = FALSE;
3882 bool hit_wall = FALSE;
3883 bool equiped_item = FALSE;
3884 bool return_when_thrown = FALSE;
3886 char o_name[MAX_NLEN];
3888 int msec = delay_factor * delay_factor * delay_factor;
3890 u32b flgs[TR_FLAG_SIZE];
3892 bool come_back = FALSE;
3893 bool do_drop = TRUE;
3896 if (p_ptr->special_defense & KATA_MUSOU)
3898 set_action(ACTION_NONE);
3907 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3909 item_tester_hook = item_tester_hook_boomerang;
3910 q = _("どの武器を投げますか? ", "Throw which item? ");
3911 s = _("投げる武器がない。", "You have nothing to throw.");
3912 if (!get_item(&item, q, s, (USE_EQUIP)))
3918 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3919 else item = INVEN_RARM;
3924 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3925 s = _("投げるアイテムがない。", "You have nothing to throw.");
3926 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3933 /* Access the item (if in the pack) */
3936 o_ptr = &inventory[item];
3940 o_ptr = &o_list[0 - item];
3944 /* Item is cursed */
3945 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3948 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3954 if (p_ptr->inside_arena && !boomerang)
3956 if (o_ptr->tval != TV_SPIKE)
3958 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3966 /* Get local object */
3969 /* Obtain a local object */
3970 object_copy(q_ptr, o_ptr);
3972 /* Extract the thrown object's flags. */
3973 object_flags(q_ptr, flgs);
3974 torch_flags(q_ptr, flgs);
3976 /* Distribute the charges of rods/wands between the stacks */
3977 distribute_charges(o_ptr, q_ptr, 1);
3983 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3985 if (p_ptr->mighty_throw) mult += 3;
3987 /* Extract a "distance multiplier" */
3988 /* Changed for 'launcher' mutation */
3989 mul = 10 + 2 * (mult - 1);
3991 /* Enforce a minimum "weight" of one pound */
3992 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3993 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3995 /* Hack -- Distance -- Reward strength, penalize weight */
3996 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3998 /* Max distance of 10-18 */
3999 if (tdis > mul) tdis = mul;
4003 ty = randint0(101)-50+p_ptr->y;
4004 tx = randint0(101)-50+p_ptr->x;
4008 project_length = tdis + 1;
4010 /* Get a direction (or cancel) */
4011 if (!get_aim_dir(&dir)) return FALSE;
4013 /* Predict the "target" location */
4014 tx = p_ptr->x + 99 * ddx[dir];
4015 ty = p_ptr->y + 99 * ddy[dir];
4017 /* Check for "target request" */
4018 if ((dir == 5) && target_okay())
4024 project_length = 0; /* reset to default */
4027 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4028 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4029 return_when_thrown = TRUE;
4031 /* Reduce and describe inventory */
4034 inven_item_increase(item, -1);
4035 if (!return_when_thrown)
4036 inven_item_describe(item);
4037 inven_item_optimize(item);
4040 /* Reduce and describe floor item */
4043 floor_item_increase(0 - item, -1);
4044 floor_item_optimize(0 - item);
4046 if (item >= INVEN_RARM)
4048 equiped_item = TRUE;
4049 p_ptr->redraw |= (PR_EQUIPPY);
4053 p_ptr->energy_use = 100;
4055 /* Rogue and Ninja gets bonus */
4056 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4057 p_ptr->energy_use -= p_ptr->lev;
4059 /* Start at the player */
4064 /* Hack -- Handle stuff */
4067 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4068 else shuriken = FALSE;
4070 /* Chance of hitting */
4071 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4072 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4073 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4075 if (shuriken) chance *= 2;
4077 /* Save the old location */
4081 /* Travel until stopped */
4082 for (cur_dis = 0; cur_dis <= tdis; )
4084 /* Hack -- Stop at the target */
4085 if ((y == ty) && (x == tx)) break;
4087 /* Calculate the new location (see "project()") */
4090 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
4092 /* Stopped by walls/doors */
4093 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
4096 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
4099 /* The player can see the (on screen) missile */
4100 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
4102 char c = object_char(q_ptr);
4103 byte a = object_attr(q_ptr);
4105 /* Draw, Hilite, Fresh, Pause, Erase */
4106 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
4107 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
4109 Term_xtra(TERM_XTRA_DELAY, msec);
4110 lite_spot(ny[cur_dis], nx[cur_dis]);
4114 /* The player cannot see the missile */
4117 /* Pause anyway, for consistancy */
4118 Term_xtra(TERM_XTRA_DELAY, msec);
4121 /* Save the old location */
4125 /* Save the new location */
4129 /* Advance the distance */
4132 /* Monster here, Try to hit it */
4133 if (cave[y][x].m_idx)
4135 cave_type *c_ptr = &cave[y][x];
4137 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4139 /* Check the visibility */
4140 visible = m_ptr->ml;
4142 /* Note the collision */
4145 /* Did we hit it (penalize range) */
4146 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
4150 /* Handle unseen monster */
4153 /* Invisible monster */
4154 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
4157 /* Handle visible monster */
4162 /* Get "the monster" or "it" */
4163 monster_desc(m_name, m_ptr, 0);
4166 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
4170 /* Hack -- Track this monster race */
4171 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
4173 /* Hack -- Track this monster */
4174 health_track(c_ptr->m_idx);
4178 /* Hack -- Base damage from thrown object */
4181 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
4182 tdam = damroll(dd, ds);
4183 /* Apply special damage XXX XXX XXX */
4184 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4185 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
4186 if (q_ptr->to_d > 0)
4187 tdam += q_ptr->to_d;
4189 tdam += -q_ptr->to_d;
4193 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4194 tdam += p_ptr->to_d_m;
4196 else if (have_flag(flgs, TR_THROW))
4199 tdam += p_ptr->to_d_m;
4207 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4210 /* No negative damage */
4211 if (tdam < 0) tdam = 0;
4213 /* Modify the damage */
4214 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4216 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
4217 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
4219 /* Hit the monster, check for death */
4220 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4229 message_pain(c_ptr->m_idx, tdam);
4231 /* Anger the monster */
4232 if ((tdam > 0) && !object_is_potion(q_ptr))
4233 anger_monster(m_ptr);
4236 if (fear && m_ptr->ml)
4243 /* Get the monster name (or "it") */
4244 monster_desc(m_name, m_ptr, 0);
4247 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
4257 /* decrease toach's fuel */
4258 if (hit_body) torch_lost_fuel(q_ptr);
4260 /* Chance of breakage (during attacks) */
4261 j = (hit_body ? breakage_chance(q_ptr) : 0);
4263 /* Figurines transform */
4264 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4268 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4269 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
4270 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
4271 else if (object_is_cursed(q_ptr))
4272 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
4277 /* Potions smash open */
4278 if (object_is_potion(q_ptr))
4280 if (hit_body || hit_wall || (randint1(100) < j))
4283 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
4285 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4287 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4289 /* ToDo (Robert): fix the invulnerability */
4290 if (cave[y][x].m_idx &&
4291 is_friendly(&m_list[cave[y][x].m_idx]) &&
4292 !MON_INVULNER(m_ptr))
4295 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4296 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
4297 set_hostile(&m_list[cave[y][x].m_idx]);
4308 if (return_when_thrown)
4310 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4311 char o2_name[MAX_NLEN];
4312 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4315 if (boomerang) back_chance += 4+randint1(5);
4316 if (super_boomerang) back_chance += 100;
4317 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4319 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4321 for (i = cur_dis - 1; i > 0; i--)
4323 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4325 char c = object_char(q_ptr);
4326 byte a = object_attr(q_ptr);
4328 /* Draw, Hilite, Fresh, Pause, Erase */
4329 print_rel(c, a, ny[i], nx[i]);
4330 move_cursor_relative(ny[i], nx[i]);
4332 Term_xtra(TERM_XTRA_DELAY, msec);
4333 lite_spot(ny[i], nx[i]);
4338 /* Pause anyway, for consistancy */
4339 Term_xtra(TERM_XTRA_DELAY, msec);
4342 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4344 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
4351 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
4355 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
4363 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
4369 if (item == INVEN_RARM || item == INVEN_LARM)
4371 /* Access the wield slot */
4372 o_ptr = &inventory[item];
4374 /* Wear the new stuff */
4375 object_copy(o_ptr, q_ptr);
4377 /* Increase the weight */
4378 p_ptr->total_weight += q_ptr->weight;
4380 /* Increment the equip counter by hand */
4383 /* Recalculate bonuses */
4384 p_ptr->update |= (PU_BONUS);
4386 /* Recalculate torch */
4387 p_ptr->update |= (PU_TORCH);
4389 /* Recalculate mana XXX */
4390 p_ptr->update |= (PU_MANA);
4393 p_ptr->window |= (PW_EQUIP);
4401 else if (equiped_item)
4407 /* Drop (or break) near that location */
4410 if (cave_have_flag_bold(y, x, FF_PROJECT))
4412 /* Drop (or break) near that location */
4413 (void)drop_near(q_ptr, j, y, x);
4417 /* Drop (or break) near that location */
4418 (void)drop_near(q_ptr, j, prev_y, prev_x);
4427 * @brief 投射処理のメインルーチン /
4428 * Throw an object from the pack or floor.
4431 void do_cmd_throw(void)
4433 do_cmd_throw_aux(1, FALSE, -1);
4439 * Hack: travel command
4441 #define TRAVEL_UNABLE 9999
4443 static int flow_head = 0;
4444 static int flow_tail = 0;
4445 static POSITION temp2_x[MAX_SHORT];
4446 static POSITION temp2_y[MAX_SHORT];
4449 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
4452 void forget_travel_flow(void)
4456 /* Check the entire dungeon */
4457 for (y = 0; y < cur_hgt; y++)
4459 for (x = 0; x < cur_wid; x++)
4461 /* Forget the old data */
4462 travel.cost[y][x] = MAX_SHORT;
4466 travel.y = travel.x = 0;
4470 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
4475 static int travel_flow_cost(int y, int x)
4477 feature_type *f_ptr = &f_info[cave[y][x].feat];
4480 /* Avoid obstacles (ex. trees) */
4481 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4484 if (have_flag(f_ptr->flags, FF_WATER))
4486 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4490 if (have_flag(f_ptr->flags, FF_LAVA))
4493 if (!p_ptr->resist_fire) lava *= 2;
4494 if (!p_ptr->levitation) lava *= 2;
4495 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4500 /* Detected traps and doors */
4501 if (cave[y][x].info & (CAVE_MARK))
4503 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4504 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4511 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
4515 * @param wall プレイヤーが壁の中にいるならばTRUE
4518 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
4520 cave_type *c_ptr = &cave[y][x];
4521 feature_type *f_ptr = &f_info[c_ptr->feat];
4522 int old_head = flow_head;
4524 int base_cost = (n % TRAVEL_UNABLE);
4525 int from_wall = (n / TRAVEL_UNABLE);
4528 /* Ignore out of bounds */
4529 if (!in_bounds(y, x)) return;
4531 /* Ignore unknown grid except in wilderness */
4532 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
4534 /* Ignore "walls" and "rubble" (include "secret doors") */
4535 if (have_flag(f_ptr->flags, FF_WALL) ||
4536 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4537 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4538 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4540 if (!wall || !from_wall) return;
4541 add_cost += TRAVEL_UNABLE;
4545 add_cost = travel_flow_cost(y, x);
4548 cost = base_cost + add_cost;
4550 /* Ignore lower cost entries */
4551 if (travel.cost[y][x] <= cost) return;
4553 /* Save the flow cost */
4554 travel.cost[y][x] = cost;
4556 /* Enqueue that entry */
4557 temp2_y[flow_head] = y;
4558 temp2_x[flow_head] = x;
4560 /* Advance the queue */
4561 if (++flow_head == MAX_SHORT) flow_head = 0;
4563 /* Hack -- notice overflow by forgetting new entry */
4564 if (flow_head == flow_tail) flow_head = old_head;
4570 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
4571 * @param ty 目標地点のY座標
4572 * @param tx 目標地点のX座標
4575 static void travel_flow(int ty, int tx)
4579 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
4581 /* Reset the "queue" */
4582 flow_head = flow_tail = 0;
4584 /* is player in the wall? */
4585 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4587 /* Start at the target grid */
4588 travel_flow_aux(ty, tx, 0, wall);
4590 /* Now process the queue */
4591 while (flow_head != flow_tail)
4593 /* Extract the next entry */
4594 y = temp2_y[flow_tail];
4595 x = temp2_x[flow_tail];
4597 /* Forget that entry */
4598 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4600 /* Ignore too far entries */
4601 //if (distance(ty, tx, y, x) > 100) continue;
4603 /* Add the "children" */
4604 for (d = 0; d < 8; d++)
4606 /* Add that child if "legal" */
4607 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4611 /* Forget the flow info */
4612 flow_head = flow_tail = 0;
4616 * @brief トラベル処理のメインルーチン
4619 void do_cmd_travel(void)
4624 feature_type *f_ptr;
4626 if (travel.x != 0 && travel.y != 0 &&
4627 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4632 else if (!tgt_pt(&x, &y)) return;
4634 if ((x == p_ptr->x) && (y == p_ptr->y))
4636 msg_print(_("すでにそこにいます!", "You are already there!!"));
4640 f_ptr = &f_info[cave[y][x].feat];
4642 if ((cave[y][x].info & CAVE_MARK) &&
4643 (have_flag(f_ptr->flags, FF_WALL) ||
4644 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4645 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4647 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4651 forget_travel_flow();
4657 /* Travel till 255 steps */
4663 /* Decides first direction */
4664 dx = abs(p_ptr->x - x);
4665 dy = abs(p_ptr->y - y);
4666 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4667 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4669 for (i = 1; i <= 9; i++)
4671 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;