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;
83 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
84 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
86 msg_print(_("上の階に登った。", "You enter the up staircase."));
90 p_ptr->inside_quest = c_ptr->special;
92 /* Activate the quest */
93 if (!quest[p_ptr->inside_quest].status)
95 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
97 init_flags = INIT_ASSIGN;
98 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
100 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
103 /* Leaving a quest */
104 if (!p_ptr->inside_quest)
110 p_ptr->leaving = TRUE;
115 /* Hack -- take a turn */
116 p_ptr->energy_use = 100;
118 /* End the command */
128 go_up = confirm_leave_level(FALSE);
131 /* Cancel the command */
134 /* Hack -- take a turn */
135 p_ptr->energy_use = 100;
137 if (autosave_l) do_cmd_save_game(TRUE);
139 /* For a random quest */
140 if (p_ptr->inside_quest &&
141 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
145 p_ptr->inside_quest = 0;
148 /* For a fixed quest */
149 if (p_ptr->inside_quest &&
150 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
154 p_ptr->inside_quest = c_ptr->special;
159 /* For normal dungeon and random quest */
163 if (have_flag(f_ptr->flags, FF_SHAFT))
165 /* Create a way back */
166 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
172 /* Create a way back */
173 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
178 /* Get out from current dungeon */
179 if (dun_level - up_num < d_info[dungeon_type].mindepth)
182 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to"));
185 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
186 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
187 else if (up_num == dun_level)
188 msg_print(_("地上に戻った。", "You go back to the surface."));
190 msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases."));
193 p_ptr->leaving = TRUE;
198 * @brief 階段を使って階層を降りる処理 / Go down one level
201 void do_cmd_go_down(void)
204 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
205 feature_type *f_ptr = &f_info[c_ptr->feat];
207 bool fall_trap = FALSE;
210 if (p_ptr->special_defense & KATA_MUSOU)
212 set_action(ACTION_NONE);
216 if (!have_flag(f_ptr->flags, FF_MORE))
218 msg_print(_("ここには下り階段が見当たらない。", "I see no down staircase here."));
222 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
225 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
230 /* Quest down stairs */
231 else if (have_flag(f_ptr->flags, FF_QUEST))
233 /* Confirm Leaving */
234 if(!confirm_leave_level(TRUE)) return;
236 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
237 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
239 msg_print(_("下の階に降りた。", "You enter the down staircase."));
244 p_ptr->inside_quest = c_ptr->special;
246 /* Activate the quest */
247 if (!quest[p_ptr->inside_quest].status)
249 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
251 init_flags = INIT_ASSIGN;
252 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
254 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
257 /* Leaving a quest */
258 if (!p_ptr->inside_quest)
264 p_ptr->leaving = TRUE;
270 /* Hack -- take a turn */
271 p_ptr->energy_use = 100;
276 int target_dungeon = 0;
280 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
282 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
284 msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
287 if (!max_dlv[target_dungeon])
289 msg_format(_("ここには%sの入り口(%d階相当)があります", "There is the entrance of %s (Danger level: %d)"),
290 d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
291 if (!get_check(_("本当にこのダンジョンに入りますか?", "Do you really get in this dungeon? "))) return;
294 /* Save old player position */
295 p_ptr->oldpx = p_ptr->x;
296 p_ptr->oldpy = p_ptr->y;
297 dungeon_type = (byte)target_dungeon;
300 * Clear all saved floors
301 * and create a first saved floor
303 prepare_change_floor_mode(CFM_FIRST_FLOOR);
306 /* Hack -- take a turn */
307 p_ptr->energy_use = 100;
309 if (autosave_l) do_cmd_save_game(TRUE);
312 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
317 /* Enter the dungeon just now */
318 p_ptr->enter_dungeon = TRUE;
319 down_num = d_info[dungeon_type].mindepth;
324 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, _("落とし戸に落ちた", "fell through a trap door"));
325 else do_cmd_write_nikki(NIKKI_STAIR, down_num, _("階段を下りた", "climbed down the stairs to"));
330 msg_print(_("わざと落とし戸に落ちた。", "You deliberately jump through the trap door."));
337 msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[dungeon_type].text);
341 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
342 msg_print(_("なんだこの階段は!", "What's this STAIRWAY!"));
344 msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases."));
350 p_ptr->leaving = TRUE;
354 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
358 if (have_flag(f_ptr->flags, FF_SHAFT))
360 /* Create a way back */
361 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
365 /* Create a way back */
366 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
374 * @brief 探索コマンドのメインルーチン / Simple command to "search" for one turn
377 void do_cmd_search(void)
379 /* Allow repeated command */
382 /* Set repeat count */
383 command_rep = command_arg - 1;
385 /* Redraw the state */
386 p_ptr->redraw |= (PR_STATE);
393 p_ptr->energy_use = 100;
401 * @brief 該当のマスに存在している箱のオブジェクトIDを返す。
402 * @param y 走査対象にしたいマスのY座標
403 * @param x 走査対象にしたいマスのX座標
404 * @param trapped TRUEならばトラップが存在する箱のみ、FALSEならば空でない箱全てを対象にする
405 * @return 箱が存在する場合そのオブジェクトID、存在しない場合0を返す。
407 static s16b chest_check(int y, int x, bool trapped)
409 cave_type *c_ptr = &cave[y][x];
411 s16b this_o_idx, next_o_idx = 0;
414 /* Scan all objects in the grid */
415 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
420 o_ptr = &o_list[this_o_idx];
422 /* Acquire next object */
423 next_o_idx = o_ptr->next_o_idx;
425 /* Skip unknown chests XXX XXX */
426 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
428 /* Check for non empty chest */
429 if ((o_ptr->tval == TV_CHEST) &&
430 (((!trapped) && (o_ptr->pval)) || /* non empty */
431 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
443 * @brief 箱からアイテムを引き出す /
444 * Allocates objects upon opening a chest -BEN-
445 * @param scatter TRUEならばトラップによるアイテムの拡散処理
446 * @param y 箱の存在するマスのY座標
447 * @param x 箱の存在するマスのX座標
448 * @param o_idx 箱のオブジェクトID
452 * Disperse treasures from the given chest, centered at (x,y).
454 * Small chests often contain "gold", while Large chests always contain
455 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
456 * and Steel chests contain 6 items. The "value" of the items in a
457 * chest is based on the "power" of the chest, which is in turn based
458 * on the level on which the chest is generated.
461 static void chest_death(bool scatter, int y, int x, s16b o_idx)
466 BIT_FLAGS mode = AM_GOOD;
471 object_type *o_ptr = &o_list[o_idx];
474 /* Small chests often hold "gold" */
475 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
477 /* Determine how much to drop (see above) */
478 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
480 if (o_ptr->sval == SV_CHEST_KANDUME)
485 object_level = o_ptr->xtra3;
489 /* Determine the "value" of the items */
490 object_level = ABS(o_ptr->pval) + 10;
493 /* Zero pval means empty chest */
494 if (!o_ptr->pval) number = 0;
496 /* Opening a chest */
497 opening_chest = TRUE;
499 /* Drop some objects (non-chests) */
500 for (; number > 0; --number)
502 /* Get local object */
505 /* Wipe the object */
508 /* Small chests often drop gold */
509 if (small && (randint0(100) < 25))
512 if (!make_gold(q_ptr)) continue;
515 /* Otherwise drop an item */
518 /* Make a good object */
519 if (!make_object(q_ptr, mode)) continue;
522 /* If chest scatters its contents, pick any floor square. */
526 for (i = 0; i < 200; i++)
528 /* Pick a totally random spot. */
529 y = randint0(MAX_HGT);
530 x = randint0(MAX_WID);
532 /* Must be an empty floor. */
533 if (!cave_empty_bold(y, x)) continue;
535 /* Place the object there. */
536 drop_near(q_ptr, -1, y, x);
542 /* Normally, drop object near the chest. */
543 else drop_near(q_ptr, -1, y, x);
546 /* Reset the object level */
547 object_level = base_level;
549 /* No longer opening a chest */
550 opening_chest = FALSE;
562 * Chests have traps too.
563 * @param y 箱の存在するマスのY座標
564 * @param x 箱の存在するマスのX座標
565 * @param o_idx 箱のオブジェクトID
569 * Exploding chest destroys contents (and traps).
570 * Note that the chest itself is never destroyed.
573 static void chest_trap(POSITION y, POSITION x, KIND_OBJECT_IDX o_idx)
577 object_type *o_ptr = &o_list[o_idx];
579 int mon_level = o_ptr->xtra3;
581 /* Ignore disarmed chests */
582 if (o_ptr->pval <= 0) return;
584 /* Obtain the traps */
585 trap = chest_traps[o_ptr->pval];
588 if (trap & (CHEST_LOSE_STR))
591 msg_print("仕掛けられていた小さな針に刺されてしまった!");
592 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "毒針", -1);
594 msg_print("A small needle has pricked you!");
595 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
598 (void)do_dec_stat(A_STR);
601 /* Lose constitution */
602 if (trap & (CHEST_LOSE_CON))
605 msg_print("仕掛けられていた小さな針に刺されてしまった!");
606 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "毒針", -1);
608 msg_print("A small needle has pricked you!");
609 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
612 (void)do_dec_stat(A_CON);
616 if (trap & (CHEST_POISON))
618 msg_print(_("突如吹き出した緑色のガスに包み込まれた!", "A puff of green gas surrounds you!"));
619 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
621 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
626 if (trap & (CHEST_PARALYZE))
628 msg_print(_("突如吹き出した黄色いガスに包み込まれた!", "A puff of yellow gas surrounds you!"));
629 if (!p_ptr->free_act)
631 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
635 /* Summon monsters */
636 if (trap & (CHEST_SUMMON))
638 int num = 2 + randint1(3);
639 msg_print(_("突如吹き出した煙に包み込まれた!", "You are enveloped in a cloud of smoke!"));
640 for (i = 0; i < num; i++)
642 if (randint1(100)<dun_level)
643 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
645 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
649 /* Elemental summon. */
650 if (trap & (CHEST_E_SUMMON))
652 msg_print(_("宝を守るためにエレメンタルが現れた!", "Elemental beings appear to protect their treasures!"));
653 for (i = 0; i < randint1(3) + 5; i++)
655 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
659 /* Force clouds, then summon birds. */
660 if (trap & (CHEST_BIRD_STORM))
662 msg_print(_("鳥の群れがあなたを取り巻いた!", "A storm of birds swirls around you!"));
664 for (i = 0; i < randint1(3) + 3; i++)
665 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
667 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
669 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
673 /* Various colorful summonings. */
674 if (trap & (CHEST_H_SUMMON))
679 msg_print(_("炎と硫黄の雲の中に悪魔が姿を現した!", "Demons materialize in clouds of fire and brimstone!"));
680 for (i = 0; i < randint1(3) + 2; i++)
682 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
683 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
687 /* Summon dragons. */
690 msg_print(_("暗闇にドラゴンの影がぼんやりと現れた!", "Draconic forms loom out of the darkness!"));
691 for (i = 0; i < randint1(3) + 2; i++)
693 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
697 /* Summon hybrids. */
700 msg_print(_("奇妙な姿の怪物が襲って来た!", "Creatures strange and twisted assault you!"));
701 for (i = 0; i < randint1(5) + 3; i++)
703 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
707 /* Summon vortices (scattered) */
710 msg_print(_("渦巻が合体し、破裂した!", "Vortices coalesce and wreak destruction!"));
711 for (i = 0; i < randint1(3) + 2; i++)
713 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
719 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
721 /* Determine how many nasty tricks can be played. */
722 int nasty_tricks_count = 4 + randint0(3);
725 msg_print(_("恐ろしい声が響いた: 「暗闇が汝をつつまん!」", "Hideous voices bid: 'Let the darkness have thee!'"));
726 /* This is gonna hurt... */
727 for (; nasty_tricks_count > 0; nasty_tricks_count--)
729 /* ...but a high saving throw does help a little. */
730 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
732 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), _("破滅のトラップの宝箱", "a chest dispel-player trap"), -1);
733 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
736 if (!p_ptr->free_act)
737 (void)set_paralyzed(p_ptr->paralyzed + 2 +
740 (void)set_stun(p_ptr->stun + 10 +
743 else if (one_in_(3)) apply_disenchant(0);
746 (void)do_dec_stat(A_STR);
747 (void)do_dec_stat(A_DEX);
748 (void)do_dec_stat(A_CON);
749 (void)do_dec_stat(A_INT);
750 (void)do_dec_stat(A_WIS);
751 (void)do_dec_stat(A_CHR);
753 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
758 /* Aggravate monsters. */
759 if (trap & (CHEST_ALARM))
761 msg_print(_("けたたましい音が鳴り響いた!", "An alarm sounds!"));
762 aggravate_monsters(0);
766 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
768 msg_print(_("突然、箱が爆発した!", "There is a sudden explosion!"));
769 msg_print(_("箱の中の物はすべて粉々に砕け散った!", "Everything inside the chest is destroyed!"));
771 sound(SOUND_EXPLODE);
772 take_hit(DAMAGE_ATTACK, damroll(5, 8), _("爆発する箱", "an exploding chest"), -1);
774 /* Scatter contents. */
775 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
777 msg_print(_("宝箱の中身はダンジョンじゅうに散乱した!", "The contents of the chest scatter all over the dungeon!"));
778 chest_death(TRUE, y, x, o_idx);
785 * @brief 箱を開けるコマンドのメインルーチン /
786 * Attempt to open the given chest at the given location
787 * @param y 箱の存在するマスのY座標
788 * @param x 箱の存在するマスのX座標
789 * @param o_idx 箱のオブジェクトID
790 * @return 箱が開かなかった場合TRUE / Returns TRUE if repeated commands may continue
792 * Assume there is no monster blocking the destination
794 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
802 object_type *o_ptr = &o_list[o_idx];
806 p_ptr->energy_use = 100;
808 /* Attempt to unlock it */
811 /* Assume locked, and thus not open */
814 /* Get the "disarm" factor */
815 i = p_ptr->skill_dis;
817 /* Penalize some conditions */
818 if (p_ptr->blind || no_lite()) i = i / 10;
819 if (p_ptr->confused || p_ptr->image) i = i / 10;
821 /* Extract the difficulty */
824 /* Always have a small chance of success */
827 /* Success -- May still have traps */
828 if (randint0(100) < j)
830 msg_print(_("鍵をはずした。", "You have picked the lock."));
835 /* Failure -- Keep trying */
838 /* We may continue repeating */
840 if (flush_failure) flush();
841 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
846 /* Allowed to open */
849 /* Apply chest traps, if any */
850 chest_trap(y, x, o_idx);
852 /* Let the Chest drop items */
853 chest_death(FALSE, y, x, o_idx);
861 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
864 * @brief 地形は開くものであって、かつ開かれているかを返す /
865 * Attempt to open the given chest at the given location
867 * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
869 static bool is_open(IDX feat)
871 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
876 * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
877 * Attempt to open the given chest at the given location
878 * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
879 * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
880 * @param test 地形条件を判定するための関数ポインタ
881 * @param under TRUEならばプレイヤーの直下の座標も走査対象にする
883 * @details Return the number of features around (or under) the character.
884 * Usually look for doors and floor traps.
886 static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under)
888 int d, count, xx, yy;
890 /* Count how many matches */
893 /* Check around (and under) the character */
894 for (d = 0; d < 9; d++)
899 /* if not searching under player continue */
900 if ((d == 8) && !under) continue;
902 /* Extract adjacent (legal) location */
903 yy = p_ptr->y + ddy_ddd[d];
904 xx = p_ptr->x + ddx_ddd[d];
907 c_ptr = &cave[yy][xx];
909 /* Must have knowledge */
910 if (!(c_ptr->info & (CAVE_MARK))) continue;
912 /* Feature code (applying "mimic" field) */
913 feat = get_feat_mimic(c_ptr);
915 /* Not looking for this feature */
916 if (!((*test)(feat))) continue;
921 /* Remember the location. Only useful if only one match */
932 * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す /
933 * Return the number of chests around (or under) the character.
934 * @param y 該当するマスの中から1つのY座標を返す参照ポインタ
935 * @param x 該当するマスの中から1つのX座標を返す参照ポインタ
936 * @param trapped TRUEならばトラップの存在が判明している箱のみ対象にする
939 * If requested, count only trapped chests.
941 static int count_chests(POSITION *y, POSITION *x, bool trapped)
948 /* Count how many matches */
951 /* Check around (and under) the character */
952 for (d = 0; d < 9; d++)
954 /* Extract adjacent (legal) location */
955 int yy = p_ptr->y + ddy_ddd[d];
956 int xx = p_ptr->x + ddx_ddd[d];
958 /* No (visible) chest is there */
959 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
961 /* Grab the object */
962 o_ptr = &o_list[o_idx];
965 if (o_ptr->pval == 0) continue;
967 /* No (known) traps here */
968 if (trapped && (!object_is_known(o_ptr) ||
969 !chest_traps[o_ptr->pval])) continue;
974 /* Remember the location. Only useful if only one match */
985 * @brief プレイヤーから指定の座標がどの方角にあるかを返す /
986 * Convert an adjacent location to a direction.
987 * @param y 方角を確認したY座標
988 * @param x 方角を確認したX座標
991 static DIRECTION coords_to_dir(POSITION y, POSITION x)
993 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1000 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1002 return d[dx + 1][dy + 1];
1005 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1009 * @brief 「開ける」動作コマンドのサブルーチン /
1010 * Perform the basic "open" command on doors
1011 * @param y 対象を行うマスのY座標
1012 * @param x 対象を行うマスのX座標
1013 * @return 実際に処理が行われた場合TRUEを返す。
1015 * Assume destination is a closed/locked/jammed door
1016 * Assume there is no monster blocking the destination
1017 * Returns TRUE if repeated commands may continue
1019 static bool do_cmd_open_aux(int y, int x)
1023 /* Get requested grid */
1024 cave_type *c_ptr = &cave[y][x];
1026 feature_type *f_ptr = &f_info[c_ptr->feat];
1032 p_ptr->energy_use = 100;
1034 /* Seeing true feature code (ignore mimic) */
1037 if (!have_flag(f_ptr->flags, FF_OPEN))
1040 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1044 else if (f_ptr->power)
1047 i = p_ptr->skill_dis;
1049 /* Penalize some conditions */
1050 if (p_ptr->blind || no_lite()) i = i / 10;
1051 if (p_ptr->confused || p_ptr->image) i = i / 10;
1053 /* Extract the lock power */
1056 /* Extract the difficulty XXX XXX XXX */
1059 /* Always have a small chance of success */
1063 if (randint0(100) < j)
1066 msg_print(_("鍵をはずした。", "You have picked the lock."));
1069 cave_alter_feat(y, x, FF_OPEN);
1072 sound(SOUND_OPENDOOR);
1082 if (flush_failure) flush();
1085 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1087 /* We may keep trying */
1096 cave_alter_feat(y, x, FF_OPEN);
1099 sound(SOUND_OPENDOOR);
1107 * @brief 「開ける」コマンドのメインルーチン /
1108 * Open a closed/locked/jammed door or a closed/locked chest.
1111 * Unlocking a locked door/chest is worth one experience point.
1113 void do_cmd_open(void)
1121 if (p_ptr->special_defense & KATA_MUSOU)
1123 set_action(ACTION_NONE);
1126 #ifdef ALLOW_EASY_OPEN /* TNB */
1128 /* Option: Pick a direction */
1131 int num_doors, num_chests;
1133 /* Count closed doors (locked or jammed) */
1134 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1136 /* Count chests (locked) */
1137 num_chests = count_chests(&y, &x, FALSE);
1139 /* See if only one target */
1140 if (num_doors || num_chests)
1142 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1144 if (!too_many) command_dir = coords_to_dir(y, x);
1148 #endif /* ALLOW_EASY_OPEN -- TNB */
1150 /* Allow repeated command */
1153 /* Set repeat count */
1154 command_rep = command_arg - 1;
1156 /* Redraw the state */
1157 p_ptr->redraw |= (PR_STATE);
1159 /* Cancel the arg */
1163 /* Get a "repeated" direction */
1164 if (get_rep_dir(&dir, TRUE))
1169 /* Get requested location */
1170 y = p_ptr->y + ddy[dir];
1171 x = p_ptr->x + ddx[dir];
1173 /* Get requested grid */
1174 c_ptr = &cave[y][x];
1176 /* Feature code (applying "mimic" field) */
1177 feat = get_feat_mimic(c_ptr);
1179 /* Check for chest */
1180 o_idx = chest_check(y, x, FALSE);
1182 /* Nothing useful */
1183 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
1186 msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
1189 /* Monster in the way */
1190 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1193 p_ptr->energy_use = 100;
1196 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1205 /* Open the chest */
1206 more = do_cmd_open_chest(y, x, o_idx);
1213 more = do_cmd_open_aux(y, x);
1217 /* Cancel repeat unless we may continue */
1218 if (!more) disturb(0, 0);
1224 * @brief 「閉じる」動作コマンドのサブルーチン /
1225 * Perform the basic "close" command
1226 * @param y 対象を行うマスのY座標
1227 * @param x 対象を行うマスのX座標
1228 * @return 実際に処理が行われた場合TRUEを返す。
1230 * Assume destination is an open/broken door
1231 * Assume there is no monster blocking the destination
1232 * Returns TRUE if repeated commands may continue
1234 static bool do_cmd_close_aux(int y, int x)
1236 /* Get grid and contents */
1237 cave_type *c_ptr = &cave[y][x];
1238 s16b old_feat = c_ptr->feat;
1242 p_ptr->energy_use = 100;
1244 /* Seeing true feature code (ignore mimic) */
1247 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1249 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
1251 /* Hack -- object in the way */
1252 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
1253 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
1256 msg_print(_("何かがつっかえて閉まらない。", "There seems stuck."));
1260 /* Close the door */
1261 cave_alter_feat(y, x, FF_CLOSE);
1264 if (old_feat == c_ptr->feat)
1267 msg_print(_("ドアは壊れてしまっている。", "The door appears to be broken."));
1272 sound(SOUND_SHUTDOOR);
1283 * @brief 「閉じる」コマンドのメインルーチン /
1284 * Close an open door.
1287 * Unlocking a locked door/chest is worth one experience point.
1289 void do_cmd_close(void)
1296 if (p_ptr->special_defense & KATA_MUSOU)
1298 set_action(ACTION_NONE);
1301 #ifdef ALLOW_EASY_OPEN /* TNB */
1303 /* Option: Pick a direction */
1306 /* Count open doors */
1307 if (count_dt(&y, &x, is_open, FALSE) == 1)
1309 command_dir = coords_to_dir(y, x);
1313 #endif /* ALLOW_EASY_OPEN -- TNB */
1315 /* Allow repeated command */
1318 /* Set repeat count */
1319 command_rep = command_arg - 1;
1321 /* Redraw the state */
1322 p_ptr->redraw |= (PR_STATE);
1324 /* Cancel the arg */
1328 /* Get a "repeated" direction */
1329 if (get_rep_dir(&dir,FALSE))
1334 /* Get requested location */
1335 y = p_ptr->y + ddy[dir];
1336 x = p_ptr->x + ddx[dir];
1338 /* Get grid and contents */
1339 c_ptr = &cave[y][x];
1341 /* Feature code (applying "mimic" field) */
1342 feat = get_feat_mimic(c_ptr);
1344 /* Require open/broken door */
1345 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1348 msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
1351 /* Monster in the way */
1352 else if (c_ptr->m_idx)
1355 p_ptr->energy_use = 100;
1358 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1364 /* Close the door */
1367 /* Close the door */
1368 more = do_cmd_close_aux(y, x);
1372 /* Cancel repeat unless we may continue */
1373 if (!more) disturb(0, 0);
1378 * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
1379 * Determine if a given grid may be "tunneled"
1380 * @param y 対象を行うマスのY座標
1381 * @param x 対象を行うマスのX座標
1384 static bool do_cmd_tunnel_test(int y, int x)
1386 cave_type *c_ptr = &cave[y][x];
1388 /* Must have knowledge */
1389 if (!(c_ptr->info & CAVE_MARK))
1392 msg_print(_("そこには何も見当たらない。", "You see nothing there."));
1398 /* Must be a wall/door/etc */
1399 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1402 msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
1414 * @brief 「掘る」動作コマンドのサブルーチン /
1415 * Perform the basic "tunnel" command
1416 * @param y 対象を行うマスのY座標
1417 * @param x 対象を行うマスのX座標
1418 * @return 実際に処理が行われた場合TRUEを返す。
1420 * Assumes that no monster is blocking the destination
1421 * Do not use twall anymore
1422 * Returns TRUE if repeated commands may continue
1424 static bool do_cmd_tunnel_aux(int y, int x)
1427 feature_type *f_ptr, *mimic_f_ptr;
1432 /* Verify legality */
1433 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1436 p_ptr->energy_use = 100;
1439 c_ptr = &cave[y][x];
1440 f_ptr = &f_info[c_ptr->feat];
1441 power = f_ptr->power;
1443 /* Feature code (applying "mimic" field) */
1444 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1446 name = f_name + mimic_f_ptr->name;
1451 if (have_flag(f_ptr->flags, FF_PERMANENT))
1454 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1456 msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
1459 /* Map border (mimiccing Permanent wall) */
1462 msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
1467 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1470 if (p_ptr->skill_dig > randint0(20 * power))
1473 msg_format(_("%sをくずした。", "You have removed the %s."), name);
1475 /* Remove the feature */
1476 cave_alter_feat(y, x, FF_TUNNEL);
1478 /* Update some things */
1479 p_ptr->update |= (PU_FLOW);
1483 /* Message, keep digging */
1484 msg_format(_("%sをくずしている。", "You dig into the %s."), name);
1492 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1495 if (p_ptr->skill_dig > power + randint0(40 * power))
1497 if (tree) msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
1500 msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
1501 p_ptr->update |= (PU_FLOW);
1505 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1507 /* Remove the feature */
1508 cave_alter_feat(y, x, FF_TUNNEL);
1510 chg_virtue(V_DILIGENCE, 1);
1511 chg_virtue(V_NATURE, -1);
1519 /* We may continue chopping */
1520 msg_format(_("%sを切っている。", "You chop away at the %s."), name);
1521 /* Occasional Search XXX XXX */
1522 if (randint0(100) < 25) search();
1526 /* We may continue tunelling */
1527 msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
1534 if (is_hidden_door(c_ptr))
1536 /* Occasional Search XXX XXX */
1537 if (randint0(100) < 25) search();
1546 * @brief 「掘る」動作コマンドのメインルーチン /
1547 * Tunnels through "walls" (including rubble and closed doors)
1551 * Note that you must tunnel in order to hit invisible monsters
1552 * in walls, though moving into walls still takes a turn anyway.
1554 * Digging is very difficult without a "digger" weapon, but can be
1555 * accomplished by strong players using heavy weapons.
1558 void do_cmd_tunnel(void)
1568 if (p_ptr->special_defense & KATA_MUSOU)
1570 set_action(ACTION_NONE);
1573 /* Allow repeated command */
1576 /* Set repeat count */
1577 command_rep = command_arg - 1;
1579 /* Redraw the state */
1580 p_ptr->redraw |= (PR_STATE);
1582 /* Cancel the arg */
1586 /* Get a direction to tunnel, or Abort */
1587 if (get_rep_dir(&dir,FALSE))
1590 y = p_ptr->y + ddy[dir];
1591 x = p_ptr->x + ddx[dir];
1594 c_ptr = &cave[y][x];
1596 /* Feature code (applying "mimic" field) */
1597 feat = get_feat_mimic(c_ptr);
1599 /* No tunnelling through doors */
1600 if (have_flag(f_info[feat].flags, FF_DOOR))
1603 msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
1606 /* No tunnelling through most features */
1607 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1609 msg_print(_("そこは掘れない。", "You can't tunnel through that."));
1612 /* A monster is in the way */
1613 else if (c_ptr->m_idx)
1616 p_ptr->energy_use = 100;
1619 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
1628 /* Tunnel through walls */
1629 more = do_cmd_tunnel_aux(y, x);
1633 /* Cancel repetition unless we can continue */
1634 if (!more) disturb(0, 0);
1638 #ifdef ALLOW_EASY_OPEN /* TNB */
1641 * @brief 移動処理による簡易な「開く」処理 /
1643 * @return 開く処理が実際に試みられた場合TRUEを返す
1646 * If there is a jammed/closed/locked door at the given location,
1647 * then attempt to unlock/open it. Return TRUE if an attempt was
1648 * made (successful or not), otherwise return FALSE.
1650 * The code here should be nearly identical to that in
1651 * do_cmd_open_test() and do_cmd_open_aux().
1654 bool easy_open_door(int y, int x)
1658 cave_type *c_ptr = &cave[y][x];
1659 feature_type *f_ptr = &f_info[c_ptr->feat];
1661 /* Must be a closed door */
1662 if (!is_closed_door(c_ptr->feat))
1669 if (!have_flag(f_ptr->flags, FF_OPEN))
1672 msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(c_ptr)].name);
1677 else if (f_ptr->power)
1680 i = p_ptr->skill_dis;
1682 /* Penalize some conditions */
1683 if (p_ptr->blind || no_lite()) i = i / 10;
1684 if (p_ptr->confused || p_ptr->image) i = i / 10;
1686 /* Extract the lock power */
1689 /* Extract the difficulty XXX XXX XXX */
1692 /* Always have a small chance of success */
1696 if (randint0(100) < j)
1699 msg_print(_("鍵をはずした。", "You have picked the lock."));
1702 cave_alter_feat(y, x, FF_OPEN);
1705 sound(SOUND_OPENDOOR);
1715 if (flush_failure) flush();
1718 msg_print(_("鍵をはずせなかった。", "You failed to pick the lock."));
1727 cave_alter_feat(y, x, FF_OPEN);
1730 sound(SOUND_OPENDOOR);
1737 #endif /* ALLOW_EASY_OPEN -- TNB */
1741 * @brief 箱のトラップを解除するコマンドのメインルーチン /
1742 * Perform the basic "disarm" command
1743 * @param y 解除を行うマスのY座標
1744 * @param x 解除を行うマスのX座標
1745 * @param o_idx 箱のオブジェクトID
1746 * @return ターンを消費する処理が行われた場合TRUEを返す
1749 * Assume destination is a visible trap
1750 * Assume there is no monster blocking the destination
1751 * Returns TRUE if repeated commands may continue
1754 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1760 object_type *o_ptr = &o_list[o_idx];
1764 p_ptr->energy_use = 100;
1766 /* Get the "disarm" factor */
1767 i = p_ptr->skill_dis;
1769 /* Penalize some conditions */
1770 if (p_ptr->blind || no_lite()) i = i / 10;
1771 if (p_ptr->confused || p_ptr->image) i = i / 10;
1773 /* Extract the difficulty */
1774 j = i - o_ptr->pval;
1776 /* Always have a small chance of success */
1779 /* Must find the trap first. */
1780 if (!object_is_known(o_ptr))
1782 msg_print(_("トラップが見あたらない。", "I don't see any traps."));
1786 /* Already disarmed/unlocked */
1787 else if (o_ptr->pval <= 0)
1789 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1792 /* No traps to find. */
1793 else if (!chest_traps[o_ptr->pval])
1795 msg_print(_("箱にはトラップが仕掛けられていない。", "The chest is not trapped."));
1798 /* Success (get a lot of experience) */
1799 else if (randint0(100) < j)
1801 msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest."));
1802 gain_exp(o_ptr->pval);
1803 o_ptr->pval = (0 - o_ptr->pval);
1806 /* Failure -- Keep trying */
1807 else if ((i > 5) && (randint1(i) > 5))
1809 /* We may keep trying */
1811 if (flush_failure) flush();
1812 msg_print(_("箱のトラップ解除に失敗した。", "You failed to disarm the chest."));
1815 /* Failure -- Set off the trap */
1818 msg_print(_("トラップを作動させてしまった!", "You set off a trap!"));
1820 chest_trap(y, x, o_idx);
1829 * @brief 箱のトラップを解除するコマンドのサブルーチン /
1830 * Perform the basic "disarm" command
1831 * @param y 解除を行うマスのY座標
1832 * @param x 解除を行うマスのX座標
1833 * @param dir プレイヤーからみた方向ID
1834 * @return ターンを消費する処理が行われた場合TRUEを返す
1837 * Assume destination is a visible trap
1838 * Assume there is no monster blocking the destination
1839 * Returns TRUE if repeated commands may continue
1842 #ifdef ALLOW_EASY_DISARM /* TNB */
1844 bool do_cmd_disarm_aux(int y, int x, int dir)
1846 #else /* ALLOW_EASY_DISARM -- TNB */
1848 static bool do_cmd_disarm_aux(int y, int x, int dir)
1850 #endif /* ALLOW_EASY_DISARM -- TNB */
1852 /* Get grid and contents */
1853 cave_type *c_ptr = &cave[y][x];
1856 feature_type *f_ptr = &f_info[c_ptr->feat];
1858 /* Access trap name */
1859 cptr name = (f_name + f_ptr->name);
1861 /* Extract trap "power" */
1862 int power = f_ptr->power;
1866 /* Get the "disarm" factor */
1867 int i = p_ptr->skill_dis;
1872 p_ptr->energy_use = 100;
1874 /* Penalize some conditions */
1875 if (p_ptr->blind || no_lite()) i = i / 10;
1876 if (p_ptr->confused || p_ptr->image) i = i / 10;
1878 /* Extract the difficulty */
1881 /* Always have a small chance of success */
1885 if (randint0(100) < j)
1888 msg_format(_("%sを解除した。", "You have disarmed the %s."), name);
1893 /* Remove the trap */
1894 cave_alter_feat(y, x, FF_DISARM);
1896 #ifdef ALLOW_EASY_DISARM /* TNB */
1898 /* Move the player onto the trap */
1899 move_player(dir, easy_disarm, FALSE);
1901 #else /* ALLOW_EASY_DISARM -- TNB */
1903 /* move the player onto the trap grid */
1904 move_player(dir, FALSE, FALSE);
1906 #endif /* ALLOW_EASY_DISARM -- TNB */
1909 /* Failure -- Keep trying */
1910 else if ((i > 5) && (randint1(i) > 5))
1913 if (flush_failure) flush();
1916 msg_format(_("%sの解除に失敗した。", "You failed to disarm the %s."), name);
1918 /* We may keep trying */
1922 /* Failure -- Set off the trap */
1926 msg_format(_("%sを作動させてしまった!", "You set off the %s!"), name);
1928 #ifdef ALLOW_EASY_DISARM /* TNB */
1930 /* Move the player onto the trap */
1931 move_player(dir, easy_disarm, FALSE);
1933 #else /* ALLOW_EASY_DISARM -- TNB */
1935 /* Move the player onto the trap */
1936 move_player(dir, FALSE, FALSE);
1938 #endif /* ALLOW_EASY_DISARM -- TNB */
1947 * @brief 箱、床のトラップ解除処理双方の統合メインルーチン /
1948 * Disarms a trap, or chest
1951 void do_cmd_disarm(void)
1959 if (p_ptr->special_defense & KATA_MUSOU)
1961 set_action(ACTION_NONE);
1964 #ifdef ALLOW_EASY_DISARM /* TNB */
1966 /* Option: Pick a direction */
1969 int num_traps, num_chests;
1971 /* Count visible traps */
1972 num_traps = count_dt(&y, &x, is_trap, TRUE);
1974 /* Count chests (trapped) */
1975 num_chests = count_chests(&y, &x, TRUE);
1977 /* See if only one target */
1978 if (num_traps || num_chests)
1980 bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1);
1981 if (!too_many) command_dir = coords_to_dir(y, x);
1985 #endif /* ALLOW_EASY_DISARM -- TNB */
1987 /* Allow repeated command */
1990 /* Set repeat count */
1991 command_rep = command_arg - 1;
1993 /* Redraw the state */
1994 p_ptr->redraw |= (PR_STATE);
1996 /* Cancel the arg */
2000 /* Get a direction (or abort) */
2001 if (get_rep_dir(&dir,TRUE))
2007 y = p_ptr->y + ddy[dir];
2008 x = p_ptr->x + ddx[dir];
2010 /* Get grid and contents */
2011 c_ptr = &cave[y][x];
2013 /* Feature code (applying "mimic" field) */
2014 feat = get_feat_mimic(c_ptr);
2016 /* Check for chests */
2017 o_idx = chest_check(y, x, TRUE);
2020 if (!is_trap(feat) && !o_idx)
2023 msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
2026 /* Monster in the way */
2027 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2030 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2039 /* Disarm the chest */
2040 more = do_cmd_disarm_chest(y, x, o_idx);
2046 /* Disarm the trap */
2047 more = do_cmd_disarm_aux(y, x, dir);
2051 /* Cancel repeat unless told not to */
2052 if (!more) disturb(0, 0);
2057 * @brief 「打ち破る」動作コマンドのサブルーチン /
2058 * Perform the basic "bash" command
2059 * @param y 対象を行うマスのY座標
2060 * @param x 対象を行うマスのX座標
2061 * @param dir プレイヤーから見たターゲットの方角ID
2062 * @return 実際に処理が行われた場合TRUEを返す。
2065 * Assume destination is a closed/locked/jammed door
2066 * Assume there is no monster blocking the destination
2067 * Returns TRUE if repeated commands may continue
2070 static bool do_cmd_bash_aux(int y, int x, int dir)
2073 cave_type *c_ptr = &cave[y][x];
2076 feature_type *f_ptr = &f_info[c_ptr->feat];
2078 /* Hack -- Bash power based on strength */
2079 /* (Ranges from 3 to 20 to 100 to 200) */
2080 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2082 /* Extract door power */
2083 int temp = f_ptr->power;
2087 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2090 p_ptr->energy_use = 100;
2093 msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
2095 /* Compare bash power to door power XXX XXX XXX */
2096 temp = (bash - (temp * 10));
2098 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2100 /* Hack -- always have a chance */
2101 if (temp < 1) temp = 1;
2103 /* Hack -- attempt to bash down the door */
2104 if (randint0(100) < temp)
2107 msg_format(_("%sを壊した!", "The %s crashes open!"), name);
2110 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
2112 /* Break down the door */
2113 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
2115 cave_alter_feat(y, x, FF_BASH);
2121 cave_alter_feat(y, x, FF_OPEN);
2124 /* Hack -- Fall through the door */
2125 move_player(dir, FALSE, FALSE);
2128 /* Saving throw against stun */
2129 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2133 msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
2135 /* Allow repeated bashing */
2139 /* High dexterity yields coolness */
2143 msg_print(_("体のバランスをくずしてしまった。", "You are off-balance."));
2145 /* Hack -- Lose balance ala paralysis */
2146 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2155 * @brief 「打ち破る」動作コマンドのメインルーチン /
2156 * Bash open a door, success based on character strength
2160 * For a closed door, pval is positive if locked; negative if stuck.
2162 * For an open door, pval is positive for a broken door.
2164 * A closed door can be opened - harder if locked. Any door might be
2165 * bashed open (and thereby broken). Bashing a door is (potentially)
2166 * faster! You move into the door way. To open a stuck door, it must
2167 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2169 * Creatures can also open or bash doors, see elsewhere.
2172 void do_cmd_bash(void)
2181 if (p_ptr->special_defense & KATA_MUSOU)
2183 set_action(ACTION_NONE);
2186 /* Allow repeated command */
2189 /* Set repeat count */
2190 command_rep = command_arg - 1;
2192 /* Redraw the state */
2193 p_ptr->redraw |= (PR_STATE);
2195 /* Cancel the arg */
2199 /* Get a "repeated" direction */
2200 if (get_rep_dir(&dir,FALSE))
2205 y = p_ptr->y + ddy[dir];
2206 x = p_ptr->x + ddx[dir];
2209 c_ptr = &cave[y][x];
2211 /* Feature code (applying "mimic" field) */
2212 feat = get_feat_mimic(c_ptr);
2214 /* Nothing useful */
2215 if (!have_flag(f_info[feat].flags, FF_BASH))
2218 msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
2221 /* Monster in the way */
2222 else if (c_ptr->m_idx)
2225 p_ptr->energy_use = 100;
2228 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2234 /* Bash a closed door */
2238 more = do_cmd_bash_aux(y, x, dir);
2242 /* Unless valid action taken, cancel bash */
2243 if (!more) disturb(0, 0);
2248 * @brief 特定のマスに影響を及ぼすための汎用的コマンド
2252 * Manipulate an adjacent grid in some way
2254 * Attack monsters, tunnel through walls, disarm traps, open doors.
2256 * Consider confusion XXX XXX XXX
2258 * This command must always take a turn, to prevent free detection
2259 * of invisible monsters.
2262 void do_cmd_alter(void)
2271 if (p_ptr->special_defense & KATA_MUSOU)
2273 set_action(ACTION_NONE);
2276 /* Allow repeated command */
2279 /* Set repeat count */
2280 command_rep = command_arg - 1;
2282 /* Redraw the state */
2283 p_ptr->redraw |= (PR_STATE);
2285 /* Cancel the arg */
2289 /* Get a direction */
2290 if (get_rep_dir(&dir,TRUE))
2293 feature_type *f_ptr;
2296 y = p_ptr->y + ddy[dir];
2297 x = p_ptr->x + ddx[dir];
2300 c_ptr = &cave[y][x];
2302 /* Feature code (applying "mimic" field) */
2303 feat = get_feat_mimic(c_ptr);
2304 f_ptr = &f_info[feat];
2307 p_ptr->energy_use = 100;
2309 /* Attack monsters */
2317 else if (have_flag(f_ptr->flags, FF_OPEN))
2319 more = do_cmd_open_aux(y, x);
2322 /* Bash jammed doors */
2323 else if (have_flag(f_ptr->flags, FF_BASH))
2325 more = do_cmd_bash_aux(y, x, dir);
2328 /* Tunnel through walls */
2329 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2331 more = do_cmd_tunnel_aux(y, x);
2334 /* Close open doors */
2335 else if (have_flag(f_ptr->flags, FF_CLOSE))
2337 more = do_cmd_close_aux(y, x);
2341 else if (have_flag(f_ptr->flags, FF_DISARM))
2343 more = do_cmd_disarm_aux(y, x, dir);
2350 msg_print(_("何もない空中を攻撃した。", "You attack the empty air."));
2354 /* Cancel repetition unless we can continue */
2355 if (!more) disturb(0, 0);
2361 * @brief 「くさびを打つ」ために必要なオブジェクトがあるかどうかの判定を返す /
2362 * Find the index of some "spikes", if possible.
2363 * @param ip くさびとして打てるオブジェクトのID
2364 * @return オブジェクトがある場合TRUEを返す
2367 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2370 static bool get_spike(int *ip)
2374 /* Check every item in the pack */
2375 for (i = 0; i < INVEN_PACK; i++)
2377 object_type *o_ptr = &inventory[i];
2379 /* Skip non-objects */
2380 if (!o_ptr->k_idx) continue;
2382 /* Check the "tval" code */
2383 if (o_ptr->tval == TV_SPIKE)
2385 /* Save the spike index */
2399 * @brief 「くさびを打つ」動作コマンドのメインルーチン /
2400 * Jam a closed door with a spike
2404 * This command may NOT be repeated
2407 void do_cmd_spike(void)
2411 if (p_ptr->special_defense & KATA_MUSOU)
2413 set_action(ACTION_NONE);
2416 /* Get a "repeated" direction */
2417 if (get_rep_dir(&dir,FALSE))
2424 y = p_ptr->y + ddy[dir];
2425 x = p_ptr->x + ddx[dir];
2427 /* Get grid and contents */
2428 c_ptr = &cave[y][x];
2430 /* Feature code (applying "mimic" field) */
2431 feat = get_feat_mimic(c_ptr);
2433 /* Require closed door */
2434 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2437 msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
2441 else if (!get_spike(&item))
2444 msg_print(_("くさびを持っていない!", "You have no spikes!"));
2447 /* Is a monster in the way? */
2448 else if (c_ptr->m_idx)
2451 p_ptr->energy_use = 100;
2454 msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
2464 p_ptr->energy_use = 100;
2466 /* Successful jamming */
2467 msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
2468 cave_alter_feat(y, x, FF_SPIKE);
2470 /* Use up, and describe, a single spike, from the bottom */
2471 inven_item_increase(item, -1);
2472 inven_item_describe(item);
2473 inven_item_optimize(item);
2481 * @brief 「歩く」動作コマンドのメインルーチン /
2482 * Support code for the "Walk" and "Jump" commands
2483 * @param pickup アイテムの自動拾いを行うならTRUE
2486 void do_cmd_walk(bool pickup)
2493 /* Allow repeated command */
2496 /* Set repeat count */
2497 command_rep = command_arg - 1;
2499 /* Redraw the state */
2500 p_ptr->redraw |= (PR_STATE);
2502 /* Cancel the arg */
2506 /* Get a "repeated" direction */
2507 if (get_rep_dir(&dir, FALSE))
2510 p_ptr->energy_use = 100;
2512 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2514 set_action(ACTION_NONE);
2517 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2518 if (p_ptr->wild_mode) p_ptr->energy_use *= ((MAX_HGT + MAX_WID) / 2);
2519 if (p_ptr->action == ACTION_HAYAGAKE) p_ptr->energy_use = p_ptr->energy_use * (45-(p_ptr->lev/2)) / 100;
2521 /* Actually move the character */
2522 move_player(dir, pickup, FALSE);
2524 /* Allow more walking */
2528 /* Hack again -- Is there a special encounter ??? */
2529 if (p_ptr->wild_mode && !cave_have_flag_bold(p_ptr->y, p_ptr->x, FF_TOWN))
2531 int tmp = 120 + p_ptr->lev*10 - wilderness[p_ptr->y][p_ptr->x].level + 5;
2534 if (((wilderness[p_ptr->y][p_ptr->x].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2536 /* Inform the player of his horrible fate :=) */
2537 msg_print(_("襲撃だ!", "You are ambushed !"));
2539 /* Go into large wilderness view */
2540 p_ptr->oldpy = randint1(MAX_HGT-2);
2541 p_ptr->oldpx = randint1(MAX_WID-2);
2544 /* Give first move to monsters */
2545 p_ptr->energy_use = 100;
2547 /* HACk -- set the encouter flag for the wilderness generation */
2548 generate_encounter = TRUE;
2552 /* Cancel repeat unless we may continue */
2553 if (!more) disturb(0, 0);
2558 * @brief 「走る」動作コマンドのメインルーチン /
2562 void do_cmd_run(void)
2566 /* Hack -- no running when confused */
2567 if (p_ptr->confused)
2569 msg_print(_("混乱していて走れない!", "You are too confused!"));
2573 if (p_ptr->special_defense & KATA_MUSOU)
2575 set_action(ACTION_NONE);
2578 /* Get a "repeated" direction */
2579 if (get_rep_dir(&dir,FALSE))
2581 /* Hack -- Set the run counter */
2582 running = (command_arg ? command_arg : 1000);
2591 * @brief 「留まる」動作コマンドのメインルーチン /
2592 * Stay still. Search. Enter stores.
2593 * Pick up treasure if "pickup" is true.
2594 * @param pickup アイテムの自動拾いを行うならTRUE
2597 void do_cmd_stay(bool pickup)
2599 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2601 /* Allow repeated command */
2604 /* Set repeat count */
2605 command_rep = command_arg - 1;
2607 /* Redraw the state */
2608 p_ptr->redraw |= (PR_STATE);
2610 /* Cancel the arg */
2615 p_ptr->energy_use = 100;
2617 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2618 (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
2623 * @brief 「休む」動作コマンドのメインルーチン /
2624 * Resting allows a player to safely restore his hp -RAK-
2627 void do_cmd_rest(void)
2630 set_action(ACTION_NONE);
2632 if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr)))
2638 if (hex_spelling_any()) stop_hex_spell_all();
2640 /* Prompt for time if needed */
2641 if (command_arg <= 0)
2643 cptr p = _("休憩 (0-9999, '*' で HP/MP全快, '&' で必要なだけ): ",
2644 "Rest (0-9999, '*' for HP/SP, '&' as needed): ");
2650 strcpy(out_val, "&");
2652 /* Ask for duration */
2653 if (!get_string(p, out_val, 4)) return;
2655 /* Rest until done */
2656 if (out_val[0] == '&')
2658 command_arg = COMMAND_ARG_REST_UNTIL_DONE;
2662 else if (out_val[0] == '*')
2664 command_arg = COMMAND_ARG_REST_FULL_HEALING;
2670 command_arg = (COMMAND_ARG)atoi(out_val);
2671 if (command_arg <= 0) return;
2677 if (command_arg > 9999) command_arg = 9999;
2679 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2681 /* Take a turn XXX XXX XXX (?) */
2682 p_ptr->energy_use = 100;
2684 /* The sin of sloth */
2685 if (command_arg > 100)
2686 chg_virtue(V_DILIGENCE, -1);
2688 /* Why are you sleeping when there's no need? WAKE UP!*/
2689 if ((p_ptr->chp == p_ptr->mhp) &&
2690 (p_ptr->csp == p_ptr->msp) &&
2691 !p_ptr->blind && !p_ptr->confused &&
2692 !p_ptr->poisoned && !p_ptr->afraid &&
2693 !p_ptr->stun && !p_ptr->cut &&
2694 !p_ptr->slow && !p_ptr->paralyzed &&
2695 !p_ptr->image && !p_ptr->word_recall &&
2696 !p_ptr->alter_reality)
2697 chg_virtue(V_DILIGENCE, -1);
2699 /* Save the rest code */
2700 resting = command_arg;
2701 p_ptr->action = ACTION_REST;
2703 /* Recalculate bonuses */
2704 p_ptr->update |= (PU_BONUS);
2706 /* Redraw the state */
2707 p_ptr->redraw |= (PR_STATE);
2718 * @brief 矢弾を射撃した場合の破損確率を返す /
2719 * Determines the odds of an object breaking when thrown at a monster
2720 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2723 * Note that artifacts never break, see the "drop_near()" function.
2725 static int breakage_chance(object_type *o_ptr)
2727 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2729 /* Examine the snipe type */
2732 if (snipe_type == SP_KILL_WALL) return (100);
2733 if (snipe_type == SP_EXPLODE) return (100);
2734 if (snipe_type == SP_PIERCE) return (100);
2735 if (snipe_type == SP_FINAL) return (100);
2736 if (snipe_type == SP_NEEDLE) return (100);
2737 if (snipe_type == SP_EVILNESS) return (40);
2738 if (snipe_type == SP_HOLYNESS) return (40);
2741 /* Examine the item type */
2742 switch (o_ptr->tval)
2758 /* Sometimes break */
2763 return (20 - archer_bonus * 2);
2768 return (10 - archer_bonus);
2776 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
2777 * Determines the odds of an object breaking when thrown at a monster
2778 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
2779 * @param tdam 計算途中のダメージ量
2780 * @param m_ptr 目標モンスターの構造体参照ポインタ
2781 * @return スレイ倍率をかけたダメージ量
2783 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2787 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2789 u32b flgs[TR_FLAG_SIZE];
2791 /* Extract the flags */
2792 object_flags(o_ptr, flgs);
2794 /* Some "weapons" and "ammo" do extra damage */
2795 switch (o_ptr->tval)
2802 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2803 (r_ptr->flags3 & RF3_ANIMAL))
2805 if (is_original_ap_and_seen(m_ptr))
2807 r_ptr->r_flags3 |= RF3_ANIMAL;
2810 if (mult < 17) mult = 17;
2814 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2815 (r_ptr->flags3 & RF3_ANIMAL))
2817 if (is_original_ap_and_seen(m_ptr))
2819 r_ptr->r_flags3 |= RF3_ANIMAL;
2822 if (mult < 27) mult = 27;
2826 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
2827 (r_ptr->flags3 & RF3_EVIL))
2829 if (is_original_ap_and_seen(m_ptr))
2831 r_ptr->r_flags3 |= RF3_EVIL;
2834 if (mult < 15) mult = 15;
2838 if ((have_flag(flgs, TR_KILL_EVIL)) &&
2839 (r_ptr->flags3 & RF3_EVIL))
2841 if (is_original_ap_and_seen(m_ptr))
2843 r_ptr->r_flags3 |= RF3_EVIL;
2846 if (mult < 25) mult = 25;
2850 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
2851 (r_ptr->flags2 & RF2_HUMAN))
2853 if (is_original_ap_and_seen(m_ptr))
2855 r_ptr->r_flags2 |= RF2_HUMAN;
2858 if (mult < 17) mult = 17;
2862 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
2863 (r_ptr->flags2 & RF2_HUMAN))
2865 if (is_original_ap_and_seen(m_ptr))
2867 r_ptr->r_flags2 |= RF2_HUMAN;
2870 if (mult < 27) mult = 27;
2874 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
2875 (r_ptr->flags3 & RF3_UNDEAD))
2877 if (is_original_ap_and_seen(m_ptr))
2879 r_ptr->r_flags3 |= RF3_UNDEAD;
2882 if (mult < 20) mult = 20;
2886 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
2887 (r_ptr->flags3 & RF3_UNDEAD))
2889 if (is_original_ap_and_seen(m_ptr))
2891 r_ptr->r_flags3 |= RF3_UNDEAD;
2894 if (mult < 30) mult = 30;
2898 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
2899 (r_ptr->flags3 & RF3_DEMON))
2901 if (is_original_ap_and_seen(m_ptr))
2903 r_ptr->r_flags3 |= RF3_DEMON;
2906 if (mult < 20) mult = 20;
2910 if ((have_flag(flgs, TR_KILL_DEMON)) &&
2911 (r_ptr->flags3 & RF3_DEMON))
2913 if (is_original_ap_and_seen(m_ptr))
2915 r_ptr->r_flags3 |= RF3_DEMON;
2918 if (mult < 30) mult = 30;
2922 if ((have_flag(flgs, TR_SLAY_ORC)) &&
2923 (r_ptr->flags3 & RF3_ORC))
2925 if (is_original_ap_and_seen(m_ptr))
2927 r_ptr->r_flags3 |= RF3_ORC;
2930 if (mult < 20) mult = 20;
2934 if ((have_flag(flgs, TR_KILL_ORC)) &&
2935 (r_ptr->flags3 & RF3_ORC))
2937 if (is_original_ap_and_seen(m_ptr))
2939 r_ptr->r_flags3 |= RF3_ORC;
2942 if (mult < 30) mult = 30;
2946 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
2947 (r_ptr->flags3 & RF3_TROLL))
2949 if (is_original_ap_and_seen(m_ptr))
2951 r_ptr->r_flags3 |= RF3_TROLL;
2954 if (mult < 20) mult = 20;
2958 if ((have_flag(flgs, TR_KILL_TROLL)) &&
2959 (r_ptr->flags3 & RF3_TROLL))
2961 if (is_original_ap_and_seen(m_ptr))
2963 r_ptr->r_flags3 |= RF3_TROLL;
2966 if (mult < 30) mult = 30;
2970 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
2971 (r_ptr->flags3 & RF3_GIANT))
2973 if (is_original_ap_and_seen(m_ptr))
2975 r_ptr->r_flags3 |= RF3_GIANT;
2978 if (mult < 20) mult = 20;
2982 if ((have_flag(flgs, TR_KILL_GIANT)) &&
2983 (r_ptr->flags3 & RF3_GIANT))
2985 if (is_original_ap_and_seen(m_ptr))
2987 r_ptr->r_flags3 |= RF3_GIANT;
2990 if (mult < 30) mult = 30;
2994 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
2995 (r_ptr->flags3 & RF3_DRAGON))
2997 if (is_original_ap_and_seen(m_ptr))
2999 r_ptr->r_flags3 |= RF3_DRAGON;
3002 if (mult < 20) mult = 20;
3005 /* Execute Dragon */
3006 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3007 (r_ptr->flags3 & RF3_DRAGON))
3009 if (is_original_ap_and_seen(m_ptr))
3011 r_ptr->r_flags3 |= RF3_DRAGON;
3014 if (mult < 30) mult = 30;
3016 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3017 (m_ptr->r_idx == MON_SMAUG) &&
3018 (inventory[INVEN_BOW].name1 == ART_BARD))
3023 if (have_flag(flgs, TR_BRAND_ACID))
3025 /* Notice immunity */
3026 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3028 if (is_original_ap_and_seen(m_ptr))
3030 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3034 /* Otherwise, take the damage */
3037 if (mult < 17) mult = 17;
3042 if (have_flag(flgs, TR_BRAND_ELEC))
3044 /* Notice immunity */
3045 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3047 if (is_original_ap_and_seen(m_ptr))
3049 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3053 /* Otherwise, take the damage */
3056 if (mult < 17) mult = 17;
3061 if (have_flag(flgs, TR_BRAND_FIRE))
3063 /* Notice immunity */
3064 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3066 if (is_original_ap_and_seen(m_ptr))
3068 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3072 /* Otherwise, take the damage */
3075 if (r_ptr->flags3 & RF3_HURT_FIRE)
3077 if (mult < 25) mult = 25;
3078 if (is_original_ap_and_seen(m_ptr))
3080 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3083 else if (mult < 17) mult = 17;
3088 if (have_flag(flgs, TR_BRAND_COLD))
3090 /* Notice immunity */
3091 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3093 if (is_original_ap_and_seen(m_ptr))
3095 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3098 /* Otherwise, take the damage */
3101 if (r_ptr->flags3 & RF3_HURT_COLD)
3103 if (mult < 25) mult = 25;
3104 if (is_original_ap_and_seen(m_ptr))
3106 r_ptr->r_flags3 |= RF3_HURT_COLD;
3109 else if (mult < 17) mult = 17;
3113 /* Brand (Poison) */
3114 if (have_flag(flgs, TR_BRAND_POIS))
3116 /* Notice immunity */
3117 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3119 if (is_original_ap_and_seen(m_ptr))
3121 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3125 /* Otherwise, take the damage */
3128 if (mult < 17) mult = 17;
3132 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3134 p_ptr->csp -= (1+(p_ptr->msp / 30));
3135 p_ptr->redraw |= (PR_MANA);
3136 mult = mult * 5 / 2;
3143 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
3145 /* Return the total damage */
3146 return (tdam * mult / 10);
3151 * @brief 射撃処理のサブルーチン /
3152 * Fire an object from the pack or floor.
3153 * @param item 射撃するオブジェクトの所持ID
3154 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
3158 * You may only fire items that "match" your missile launcher.
3160 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3162 * See "calc_bonuses()" for more calculations and such.
3164 * Note that "firing" a missile is MUCH better than "throwing" it.
3166 * Note: "unseen" monsters are very hard to hit.
3168 * Objects are more likely to break if they "attempt" to hit a monster.
3170 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3172 * The "extra shot" code works by decreasing the amount of energy
3173 * required to make each shot, spreading the shots out over time.
3175 * Note that when firing missiles, the launcher multiplier is applied
3176 * after all the bonuses are added in, making multipliers very useful.
3178 * Note that Bows of "Extra Might" get extra range and an extra bonus
3179 * for the damage multiplier.
3181 * Note that Bows of "Extra Shots" give an extra shot.
3184 void do_cmd_fire_aux(int item, object_type *j_ptr)
3187 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
3188 int tdam_base, tdis, thits, tmul;
3190 int cur_dis, visible;
3197 bool hit_body = FALSE;
3199 char o_name[MAX_NLEN];
3201 u16b path_g[512]; /* For calcuration of path length */
3203 int msec = delay_factor * delay_factor * delay_factor;
3206 bool stick_to = FALSE;
3208 /* Access the item (if in the pack) */
3211 o_ptr = &inventory[item];
3215 o_ptr = &o_list[0 - item];
3218 /* Sniper - Cannot shot a single arrow twice */
3219 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
3221 /* Describe the object */
3222 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3224 /* Use the proper number of shots */
3225 thits = p_ptr->num_fire;
3227 /* Use a base distance */
3230 /* Base damage from thrown object plus launcher bonus */
3231 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3233 /* Actually "fire" the object */
3234 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3235 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3236 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3238 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3240 p_ptr->energy_use = bow_energy(j_ptr->sval);
3241 tmul = bow_tmul(j_ptr->sval);
3243 /* Get extra "power" from "extra might" */
3244 if (p_ptr->xtra_might) tmul++;
3246 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3248 /* Boost the damage */
3253 tdis = 13 + tmul/80;
3254 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3257 tdis -= (5 - (p_ptr->concent + 1) / 2);
3262 project_length = tdis + 1;
3264 /* Get a direction (or cancel) */
3265 if (!get_aim_dir(&dir))
3267 p_ptr->energy_use = 0;
3269 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
3271 /* need not to reset project_length (already did)*/
3276 /* Predict the "target" location */
3277 tx = p_ptr->x + 99 * ddx[dir];
3278 ty = p_ptr->y + 99 * ddy[dir];
3280 /* Check for "target request" */
3281 if ((dir == 5) && target_okay())
3287 /* Get projection path length */
3288 tdis = project_path(path_g, project_length, p_ptr->y, p_ptr->x, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
3290 project_length = 0; /* reset to default */
3292 /* Don't shoot at my feet */
3293 if (tx == p_ptr->x && ty == p_ptr->y)
3295 p_ptr->energy_use = 0;
3297 /* project_length is already reset to 0 */
3303 /* Take a (partial) turn */
3304 p_ptr->energy_use = (p_ptr->energy_use / thits);
3307 /* Sniper - Difficult to shot twice at 1 turn */
3308 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
3310 /* Sniper - Repeat shooting when double shots */
3311 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
3314 /* Start at the player */
3318 /* Get local object */
3321 /* Obtain a local object */
3322 object_copy(q_ptr, o_ptr);
3327 /* Reduce and describe inventory */
3330 inven_item_increase(item, -1);
3331 inven_item_describe(item);
3332 inven_item_optimize(item);
3335 /* Reduce and describe floor item */
3338 floor_item_increase(0 - item, -1);
3339 floor_item_optimize(0 - item);
3345 /* Hack -- Handle stuff */
3348 /* Save the old location */
3352 /* The shot does not hit yet */
3355 /* Travel until stopped */
3356 for (cur_dis = 0; cur_dis <= tdis; )
3360 /* Hack -- Stop at the target */
3361 if ((y == ty) && (x == tx)) break;
3363 /* Calculate the new location (see "project()") */
3366 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3369 if (snipe_type == SP_KILL_WALL)
3371 c_ptr = &cave[ny][nx];
3373 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3375 if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
3376 /* Forget the wall */
3377 c_ptr->info &= ~(CAVE_MARK);
3379 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3381 /* Destroy the wall */
3382 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3389 /* Stopped by walls/doors */
3390 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3392 /* Advance the distance */
3396 if (snipe_type == SP_LITE)
3398 cave[ny][nx].info |= (CAVE_GLOW);
3407 /* The player can see the (on screen) missile */
3408 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3410 char c = object_char(q_ptr);
3411 byte a = object_attr(q_ptr);
3413 /* Draw, Hilite, Fresh, Pause, Erase */
3414 print_rel(c, a, ny, nx);
3415 move_cursor_relative(ny, nx);
3417 Term_xtra(TERM_XTRA_DELAY, msec);
3422 /* The player cannot see the missile */
3425 /* Pause anyway, for consistancy */
3426 Term_xtra(TERM_XTRA_DELAY, msec);
3430 if (snipe_type == SP_KILL_TRAP)
3432 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3433 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3437 if (snipe_type == SP_EVILNESS)
3439 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3448 /* Save the old location */
3452 /* Save the new location */
3457 /* Monster here, Try to hit it */
3458 if (cave[y][x].m_idx)
3460 cave_type *c_mon_ptr = &cave[y][x];
3462 monster_type *m_ptr = &m_list[c_mon_ptr->m_idx];
3463 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3465 /* Check the visibility */
3466 visible = m_ptr->ml;
3468 /* Note the collision */
3471 if (MON_CSLEEP(m_ptr))
3473 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3474 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3477 if ((r_ptr->level + 10) > p_ptr->lev)
3479 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3480 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3483 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3484 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3485 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3486 else if (p_ptr->lev > 34) amount = 2;
3487 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3488 p_ptr->update |= (PU_BONUS);
3494 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3495 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3498 p_ptr->skill_exp[GINOU_RIDING] += 1;
3499 p_ptr->update |= (PU_BONUS);
3503 /* Did we hit it (penalize range) */
3504 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3507 int tdam = tdam_base;
3509 /* Get extra damage from concentration */
3510 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3512 /* Handle unseen monster */
3515 /* Invisible monster */
3516 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
3519 /* Handle visible monster */
3524 /* Get "the monster" or "it" */
3525 monster_desc(m_name, m_ptr, 0);
3528 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
3532 /* Hack -- Track this monster race */
3533 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3535 /* Hack -- Track this monster */
3536 health_track(c_mon_ptr->m_idx);
3540 if (snipe_type == SP_NEEDLE)
3542 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3543 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3547 /* Get "the monster" or "it" */
3548 monster_desc(m_name, m_ptr, 0);
3550 tdam = m_ptr->hp + 1;
3551 msg_format(_("%sの急所に突き刺さった!", "Your shot sticked on a fatal spot of %s!"), m_name);
3557 /* Apply special damage XXX XXX XXX */
3558 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3559 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3561 /* No negative damage */
3562 if (tdam < 0) tdam = 0;
3564 /* Modify the damage */
3565 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3568 msg_format_wizard(CHEAT_MONSTER,
3569 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
3570 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
3573 if (snipe_type == SP_EXPLODE)
3575 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3577 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3578 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3583 if (snipe_type == SP_HOLYNESS)
3585 cave[ny][nx].info |= (CAVE_GLOW);
3594 /* Hit the monster, check for death */
3595 if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3604 if (object_is_fixed_artifact(q_ptr) &&
3605 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
3609 monster_desc(m_name, m_ptr, 0);
3612 msg_format(_("%sは%sに突き刺さった!", "%^s have stuck into %s!"),o_name, m_name);
3616 message_pain(c_mon_ptr->m_idx, tdam);
3618 /* Anger the monster */
3619 if (tdam > 0) anger_monster(m_ptr);
3622 if (fear && m_ptr->ml)
3629 /* Get the monster name (or "it") */
3630 monster_desc(m_name, m_ptr, 0);
3633 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
3636 set_target(m_ptr, p_ptr->y, p_ptr->x);
3639 if (snipe_type == SP_RUSH)
3641 int n = randint1(5) + 3;
3642 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
3644 for ( ; cur_dis <= tdis; )
3651 /* Calculate the new location (see "project()") */
3652 mmove2(&ny, &nx, p_ptr->y, p_ptr->x, ty, tx);
3654 /* Stopped by wilderness boundary */
3655 if (!in_bounds2(ny, nx)) break;
3657 /* Stopped by walls/doors */
3658 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3660 /* Stopped by monsters */
3661 if (!cave_empty_bold(ny, nx)) break;
3663 cave[ny][nx].m_idx = m_idx;
3664 cave[oy][ox].m_idx = 0;
3669 /* Update the monster (new location) */
3670 update_mon(c_mon_ptr->m_idx, TRUE);
3676 Term_xtra(TERM_XTRA_DELAY, msec);
3688 if (snipe_type == SP_PIERCE)
3690 if(p_ptr->concent < 1) break;
3700 /* Chance of breakage (during attacks) */
3701 j = (hit_body ? breakage_chance(q_ptr) : 0);
3705 MONSTER_IDX m_idx = cave[y][x].m_idx;
3706 monster_type *m_ptr = &m_list[m_idx];
3707 IDX o_idx = o_pop();
3711 msg_format(_("%sはどこかへ行った。", "The %s have gone to somewhere."), o_name);
3712 if (object_is_fixed_artifact(q_ptr))
3714 a_info[j_ptr->name1].cur_num = 0;
3719 o_ptr = &o_list[o_idx];
3720 object_copy(o_ptr, q_ptr);
3723 o_ptr->marked &= OM_TOUCHED;
3725 /* Forget location */
3726 o_ptr->iy = o_ptr->ix = 0;
3728 /* Memorize monster */
3729 o_ptr->held_m_idx = m_idx;
3732 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3735 m_ptr->hold_o_idx = o_idx;
3737 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3739 /* Drop (or break) near that location */
3740 (void)drop_near(q_ptr, j, y, x);
3744 /* Drop (or break) near that location */
3745 (void)drop_near(q_ptr, j, prev_y, prev_x);
3748 /* Sniper - Repeat shooting when double shots */
3751 /* Sniper - Loose his/her concentration after any shot */
3752 if (p_ptr->concent) reset_concentration(FALSE);
3756 * @brief 射撃処理のメインルーチン
3759 void do_cmd_fire(void)
3765 is_fired = FALSE; /* not fired yet */
3767 /* Get the "bow" (if any) */
3768 j_ptr = &inventory[INVEN_BOW];
3770 /* Require a launcher */
3773 msg_print(_("射撃用の武器を持っていない。", "You have nothing to fire with."));
3778 if (j_ptr->sval == SV_CRIMSON)
3780 msg_print(_("この武器は発動して使うもののようだ。", "Do activate."));
3785 if (j_ptr->sval == SV_HARP)
3787 msg_print(_("この武器で射撃はできない。", "It's not for firing."));
3793 if (p_ptr->special_defense & KATA_MUSOU)
3795 set_action(ACTION_NONE);
3798 /* Require proper missile */
3799 item_tester_tval = p_ptr->tval_ammo;
3802 q = _("どれを撃ちますか? ", "Fire which item? ");
3803 s = _("発射されるアイテムがありません。", "You have nothing to fire.");
3804 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3811 do_cmd_fire_aux(item, j_ptr);
3813 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
3815 /* Sniper actions after some shootings */
3816 if (snipe_type == SP_AWAY)
3818 teleport_player(10 + (p_ptr->concent * 2), 0L);
3820 if (snipe_type == SP_FINAL)
3822 msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. "));
3823 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
3824 (void)set_stun(p_ptr->stun + randint1(25));
3829 * @brief オブジェクトが投射可能な武器かどうかを返す。
3830 * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
3831 * @return 投射可能な武器ならばTRUE
3833 static bool item_tester_hook_boomerang(object_type *o_ptr)
3835 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
3843 * @brief 投射処理のサブルーチン /
3844 * Throw an object from the pack or floor.
3846 * @param boomerang ブーメラン処理ならばTRUE
3847 * @param shuriken 忍者の手裏剣処理ならばTRUE
3848 * @return ターンを消費した場合TRUEを返す
3851 * Note: "unseen" monsters are very hard to hit.
3853 * Should throwing a weapon do full damage? Should it allow the magic
3854 * to hit bonus of the weapon to have an effect? Should it ever cause
3855 * the item to be destroyed? Should it do any damage at all?
3858 bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken)
3862 int i, j, y, x, ty, tx, prev_y, prev_x;
3864 int chance, tdam, tdis;
3865 int mul, div, dd, ds;
3866 int cur_dis, visible;
3873 bool hit_body = FALSE;
3874 bool hit_wall = FALSE;
3875 bool equiped_item = FALSE;
3876 bool return_when_thrown = FALSE;
3878 char o_name[MAX_NLEN];
3880 int msec = delay_factor * delay_factor * delay_factor;
3882 u32b flgs[TR_FLAG_SIZE];
3884 bool come_back = FALSE;
3885 bool do_drop = TRUE;
3888 if (p_ptr->special_defense & KATA_MUSOU)
3890 set_action(ACTION_NONE);
3899 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
3901 item_tester_hook = item_tester_hook_boomerang;
3902 q = _("どの武器を投げますか? ", "Throw which item? ");
3903 s = _("投げる武器がない。", "You have nothing to throw.");
3904 if (!get_item(&item, q, s, (USE_EQUIP)))
3910 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
3911 else item = INVEN_RARM;
3916 q = _("どのアイテムを投げますか? ", "Throw which item? ");
3917 s = _("投げるアイテムがない。", "You have nothing to throw.");
3918 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3925 /* Access the item (if in the pack) */
3928 o_ptr = &inventory[item];
3932 o_ptr = &o_list[0 - item];
3936 /* Item is cursed */
3937 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3940 msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
3946 if (p_ptr->inside_arena && !boomerang)
3948 if (o_ptr->tval != TV_SPIKE)
3950 msg_print(_("アリーナではアイテムを使えない!", "You're in the arena now. This is hand-to-hand!"));
3958 /* Get local object */
3961 /* Obtain a local object */
3962 object_copy(q_ptr, o_ptr);
3964 /* Extract the thrown object's flags. */
3965 object_flags(q_ptr, flgs);
3966 torch_flags(q_ptr, flgs);
3968 /* Distribute the charges of rods/wands between the stacks */
3969 distribute_charges(o_ptr, q_ptr, 1);
3975 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3977 if (p_ptr->mighty_throw) mult += 3;
3979 /* Extract a "distance multiplier" */
3980 /* Changed for 'launcher' mutation */
3981 mul = 10 + 2 * (mult - 1);
3983 /* Enforce a minimum "weight" of one pound */
3984 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3985 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3987 /* Hack -- Distance -- Reward strength, penalize weight */
3988 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3990 /* Max distance of 10-18 */
3991 if (tdis > mul) tdis = mul;
3995 ty = randint0(101)-50+p_ptr->y;
3996 tx = randint0(101)-50+p_ptr->x;
4000 project_length = tdis + 1;
4002 /* Get a direction (or cancel) */
4003 if (!get_aim_dir(&dir)) return FALSE;
4005 /* Predict the "target" location */
4006 tx = p_ptr->x + 99 * ddx[dir];
4007 ty = p_ptr->y + 99 * ddy[dir];
4009 /* Check for "target request" */
4010 if ((dir == 5) && target_okay())
4016 project_length = 0; /* reset to default */
4019 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4020 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4021 return_when_thrown = TRUE;
4023 /* Reduce and describe inventory */
4026 inven_item_increase(item, -1);
4027 if (!return_when_thrown)
4028 inven_item_describe(item);
4029 inven_item_optimize(item);
4032 /* Reduce and describe floor item */
4035 floor_item_increase(0 - item, -1);
4036 floor_item_optimize(0 - item);
4038 if (item >= INVEN_RARM)
4040 equiped_item = TRUE;
4041 p_ptr->redraw |= (PR_EQUIPPY);
4045 p_ptr->energy_use = 100;
4047 /* Rogue and Ninja gets bonus */
4048 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4049 p_ptr->energy_use -= p_ptr->lev;
4051 /* Start at the player */
4056 /* Hack -- Handle stuff */
4059 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4060 else shuriken = FALSE;
4062 /* Chance of hitting */
4063 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4064 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4065 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4067 if (shuriken) chance *= 2;
4069 /* Save the old location */
4073 /* Travel until stopped */
4074 for (cur_dis = 0; cur_dis <= tdis; )
4076 /* Hack -- Stop at the target */
4077 if ((y == ty) && (x == tx)) break;
4079 /* Calculate the new location (see "project()") */
4082 mmove2(&ny[cur_dis], &nx[cur_dis], p_ptr->y, p_ptr->x, ty, tx);
4084 /* Stopped by walls/doors */
4085 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
4088 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
4091 /* The player can see the (on screen) missile */
4092 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
4094 char c = object_char(q_ptr);
4095 byte a = object_attr(q_ptr);
4097 /* Draw, Hilite, Fresh, Pause, Erase */
4098 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
4099 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
4101 Term_xtra(TERM_XTRA_DELAY, msec);
4102 lite_spot(ny[cur_dis], nx[cur_dis]);
4106 /* The player cannot see the missile */
4109 /* Pause anyway, for consistancy */
4110 Term_xtra(TERM_XTRA_DELAY, msec);
4113 /* Save the old location */
4117 /* Save the new location */
4121 /* Advance the distance */
4124 /* Monster here, Try to hit it */
4125 if (cave[y][x].m_idx)
4127 cave_type *c_ptr = &cave[y][x];
4129 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4131 /* Check the visibility */
4132 visible = m_ptr->ml;
4134 /* Note the collision */
4137 /* Did we hit it (penalize range) */
4138 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
4142 /* Handle unseen monster */
4145 /* Invisible monster */
4146 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
4149 /* Handle visible monster */
4154 /* Get "the monster" or "it" */
4155 monster_desc(m_name, m_ptr, 0);
4158 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
4162 /* Hack -- Track this monster race */
4163 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
4165 /* Hack -- Track this monster */
4166 health_track(c_ptr->m_idx);
4170 /* Hack -- Base damage from thrown object */
4173 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
4174 tdam = damroll(dd, ds);
4175 /* Apply special damage XXX XXX XXX */
4176 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4177 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
4178 if (q_ptr->to_d > 0)
4179 tdam += q_ptr->to_d;
4181 tdam += -q_ptr->to_d;
4185 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4186 tdam += p_ptr->to_d_m;
4188 else if (have_flag(flgs, TR_THROW))
4191 tdam += p_ptr->to_d_m;
4199 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4202 /* No negative damage */
4203 if (tdam < 0) tdam = 0;
4205 /* Modify the damage */
4206 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4208 msg_format_wizard(CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
4209 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
4211 /* Hit the monster, check for death */
4212 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4221 message_pain(c_ptr->m_idx, tdam);
4223 /* Anger the monster */
4224 if ((tdam > 0) && !object_is_potion(q_ptr))
4225 anger_monster(m_ptr);
4228 if (fear && m_ptr->ml)
4235 /* Get the monster name (or "it") */
4236 monster_desc(m_name, m_ptr, 0);
4239 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
4249 /* decrease toach's fuel */
4250 if (hit_body) torch_lost_fuel(q_ptr);
4252 /* Chance of breakage (during attacks) */
4253 j = (hit_body ? breakage_chance(q_ptr) : 0);
4255 /* Figurines transform */
4256 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4260 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4261 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
4262 msg_print(_("人形は捻じ曲がり砕け散ってしまった!", "The Figurine writhes and then shatters."));
4263 else if (object_is_cursed(q_ptr))
4264 msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this."));
4269 /* Potions smash open */
4270 if (object_is_potion(q_ptr))
4272 if (hit_body || hit_wall || (randint1(100) < j))
4275 msg_format(_("%sは砕け散った!", "The %s shatters!"), o_name);
4277 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4279 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4281 /* ToDo (Robert): fix the invulnerability */
4282 if (cave[y][x].m_idx &&
4283 is_friendly(&m_list[cave[y][x].m_idx]) &&
4284 !MON_INVULNER(m_ptr))
4287 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4288 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
4289 set_hostile(&m_list[cave[y][x].m_idx]);
4300 if (return_when_thrown)
4302 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4303 char o2_name[MAX_NLEN];
4304 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4307 if (boomerang) back_chance += 4+randint1(5);
4308 if (super_boomerang) back_chance += 100;
4309 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4311 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4313 for (i = cur_dis - 1; i > 0; i--)
4315 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4317 char c = object_char(q_ptr);
4318 byte a = object_attr(q_ptr);
4320 /* Draw, Hilite, Fresh, Pause, Erase */
4321 print_rel(c, a, ny[i], nx[i]);
4322 move_cursor_relative(ny[i], nx[i]);
4324 Term_xtra(TERM_XTRA_DELAY, msec);
4325 lite_spot(ny[i], nx[i]);
4330 /* Pause anyway, for consistancy */
4331 Term_xtra(TERM_XTRA_DELAY, msec);
4334 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4336 msg_format(_("%sが手元に返ってきた。", "%s comes back to you."), o2_name);
4343 msg_format(_("%sを受け損ねた!", "%s backs, but you can't catch!"), o2_name);
4347 msg_format(_("%sが返ってきた。", "%s comes back."), o2_name);
4355 msg_format(_("%sが返ってこなかった!", "%s doesn't back!"), o2_name);
4361 if (item == INVEN_RARM || item == INVEN_LARM)
4363 /* Access the wield slot */
4364 o_ptr = &inventory[item];
4366 /* Wear the new stuff */
4367 object_copy(o_ptr, q_ptr);
4369 /* Increase the weight */
4370 p_ptr->total_weight += q_ptr->weight;
4372 /* Increment the equip counter by hand */
4375 /* Recalculate bonuses */
4376 p_ptr->update |= (PU_BONUS);
4378 /* Recalculate torch */
4379 p_ptr->update |= (PU_TORCH);
4381 /* Recalculate mana XXX */
4382 p_ptr->update |= (PU_MANA);
4385 p_ptr->window |= (PW_EQUIP);
4393 else if (equiped_item)
4399 /* Drop (or break) near that location */
4402 if (cave_have_flag_bold(y, x, FF_PROJECT))
4404 /* Drop (or break) near that location */
4405 (void)drop_near(q_ptr, j, y, x);
4409 /* Drop (or break) near that location */
4410 (void)drop_near(q_ptr, j, prev_y, prev_x);
4419 * @brief 投射処理のメインルーチン /
4420 * Throw an object from the pack or floor.
4423 void do_cmd_throw(void)
4425 do_cmd_throw_aux(1, FALSE, -1);
4431 * Hack: travel command
4433 #define TRAVEL_UNABLE 9999
4435 static int flow_head = 0;
4436 static int flow_tail = 0;
4437 static POSITION temp2_x[MAX_SHORT];
4438 static POSITION temp2_y[MAX_SHORT];
4441 * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information
4444 void forget_travel_flow(void)
4448 /* Check the entire dungeon */
4449 for (y = 0; y < cur_hgt; y++)
4451 for (x = 0; x < cur_wid; x++)
4453 /* Forget the old data */
4454 travel.cost[y][x] = MAX_SHORT;
4458 travel.y = travel.x = 0;
4462 * @brief トラベル処理中に地形に応じた移動コスト基準を返す
4467 static int travel_flow_cost(int y, int x)
4469 feature_type *f_ptr = &f_info[cave[y][x].feat];
4472 /* Avoid obstacles (ex. trees) */
4473 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4476 if (have_flag(f_ptr->flags, FF_WATER))
4478 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4482 if (have_flag(f_ptr->flags, FF_LAVA))
4485 if (!p_ptr->resist_fire) lava *= 2;
4486 if (!p_ptr->levitation) lava *= 2;
4487 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4492 /* Detected traps and doors */
4493 if (cave[y][x].info & (CAVE_MARK))
4495 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4496 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4503 * @brief トラベル処理の到達地点までの行程を得る処理のサブルーチン
4507 * @param wall プレイヤーが壁の中にいるならばTRUE
4510 static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall)
4512 cave_type *c_ptr = &cave[y][x];
4513 feature_type *f_ptr = &f_info[c_ptr->feat];
4514 int old_head = flow_head;
4516 int base_cost = (n % TRAVEL_UNABLE);
4517 int from_wall = (n / TRAVEL_UNABLE);
4520 /* Ignore out of bounds */
4521 if (!in_bounds(y, x)) return;
4523 /* Ignore unknown grid except in wilderness */
4524 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
4526 /* Ignore "walls" and "rubble" (include "secret doors") */
4527 if (have_flag(f_ptr->flags, FF_WALL) ||
4528 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4529 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4530 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4532 if (!wall || !from_wall) return;
4533 add_cost += TRAVEL_UNABLE;
4537 add_cost = travel_flow_cost(y, x);
4540 cost = base_cost + add_cost;
4542 /* Ignore lower cost entries */
4543 if (travel.cost[y][x] <= cost) return;
4545 /* Save the flow cost */
4546 travel.cost[y][x] = cost;
4548 /* Enqueue that entry */
4549 temp2_y[flow_head] = y;
4550 temp2_x[flow_head] = x;
4552 /* Advance the queue */
4553 if (++flow_head == MAX_SHORT) flow_head = 0;
4555 /* Hack -- notice overflow by forgetting new entry */
4556 if (flow_head == flow_tail) flow_head = old_head;
4562 * @brief トラベル処理の到達地点までの行程を得る処理のメインルーチン
4563 * @param ty 目標地点のY座標
4564 * @param tx 目標地点のX座標
4567 static void travel_flow(int ty, int tx)
4571 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
4573 /* Reset the "queue" */
4574 flow_head = flow_tail = 0;
4576 /* is player in the wall? */
4577 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4579 /* Start at the target grid */
4580 travel_flow_aux(ty, tx, 0, wall);
4582 /* Now process the queue */
4583 while (flow_head != flow_tail)
4585 /* Extract the next entry */
4586 y = temp2_y[flow_tail];
4587 x = temp2_x[flow_tail];
4589 /* Forget that entry */
4590 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4592 /* Ignore too far entries */
4593 //if (distance(ty, tx, y, x) > 100) continue;
4595 /* Add the "children" */
4596 for (d = 0; d < 8; d++)
4598 /* Add that child if "legal" */
4599 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4603 /* Forget the flow info */
4604 flow_head = flow_tail = 0;
4608 * @brief トラベル処理のメインルーチン
4611 void do_cmd_travel(void)
4616 feature_type *f_ptr;
4618 if (travel.x != 0 && travel.y != 0 &&
4619 get_check(_("トラベルを継続しますか?", "Do you continue to travel?")))
4624 else if (!tgt_pt(&x, &y)) return;
4626 if ((x == p_ptr->x) && (y == p_ptr->y))
4628 msg_print(_("すでにそこにいます!", "You are already there!!"));
4632 f_ptr = &f_info[cave[y][x].feat];
4634 if ((cave[y][x].info & CAVE_MARK) &&
4635 (have_flag(f_ptr->flags, FF_WALL) ||
4636 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4637 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4639 msg_print(_("そこには行くことができません!", "You cannot travel there!"));
4643 forget_travel_flow();
4649 /* Travel till 255 steps */
4655 /* Decides first direction */
4656 dx = abs(p_ptr->x - x);
4657 dy = abs(p_ptr->y - y);
4658 sx = ((x == p_ptr->x) || (dx < dy)) ? 0 : ((x > p_ptr->x) ? 1 : -1);
4659 sy = ((y == p_ptr->y) || (dy < dx)) ? 0 : ((y > p_ptr->y) ? 1 : -1);
4661 for (i = 1; i <= 9; i++)
4663 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;