3 * @brief ¥×¥ì¥¤¥ä¡¼¤Î¥³¥Þ¥ó¥É½èÍý2 / Movement commands (part 2)
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
17 * @brief ¥Õ¥í¥¢Ã¦½Ð»þ¤Ë½ÐÌá¤ê¤¬ÉÔ²Äǽ¤À¤Ã¤¿¾ì¹ç¤Ë·Ù¹ð¤ò²Ã¤¨¤ë½èÍý
18 * @param down_stair TRUE¤Ê¤é¤Ð³¬Ãʤò¹ß¤ê¤ë½èÍý¡¢FALSE¤Ê¤é³¬Ãʤò¾º¤ë½èÍý¤Ë¤è¤ëÆâÍÆ
19 * @return ¥Õ¥í¥¢°ÜÆ°¤ò¼ÂºÝ¤Ë¹Ô¤¦¤Ê¤éTRUE¡¢¥¥ã¥ó¥»¥ë¤¹¤ë¾ì¹ç¤ÏFALSE
21 bool confirm_leave_level(bool down_stair)
23 quest_type *q_ptr = &quest[p_ptr->inside_quest];
25 /* Confirm leaving from once only quest */
26 if (confirm_quest && p_ptr->inside_quest &&
27 (q_ptr->type == QUEST_TYPE_RANDOM ||
28 (q_ptr->flags & QUEST_FLAG_ONCE &&
29 q_ptr->status != QUEST_STATUS_COMPLETED) ||
30 (q_ptr->flags & QUEST_FLAG_TOWER &&
31 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
32 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
35 msg_print("¤³¤Î³¬¤ò°ìÅÙµî¤ë¤ÈÆóÅÙ¤ÈÌá¤Ã¤ÆÍè¤é¤ì¤Þ¤»¤ó¡£");
36 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©")) return TRUE;
38 msg_print("You can't come back here once you leave this floor.");
39 if (get_check("Really leave this floor? ")) return TRUE;
50 * @brief ³¬Ãʤò»È¤Ã¤Æ³¬Áؤò¾º¤ë½èÍý / Go up one level
53 void do_cmd_go_up(void)
58 cave_type *c_ptr = &cave[py][px];
59 feature_type *f_ptr = &f_info[c_ptr->feat];
63 if (p_ptr->special_defense & KATA_MUSOU)
65 set_action(ACTION_NONE);
69 if (!have_flag(f_ptr->flags, FF_LESS))
72 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
74 msg_print("I see no up staircase here.");
81 if (have_flag(f_ptr->flags, FF_QUEST))
83 /* Cancel the command */
84 if (!confirm_leave_level(FALSE)) return;
89 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
90 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
92 msg_print("¾å¤Î³¬¤ËÅФä¿¡£");
94 msg_print("You enter the up staircase.");
99 p_ptr->inside_quest = c_ptr->special;
101 /* Activate the quest */
102 if (!quest[p_ptr->inside_quest].status)
104 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
106 init_flags = INIT_ASSIGN;
107 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
109 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
112 /* Leaving a quest */
113 if (!p_ptr->inside_quest)
119 p_ptr->leaving = TRUE;
124 /* Hack -- take a turn */
127 /* End the command */
137 go_up = confirm_leave_level(FALSE);
140 /* Cancel the command */
143 /* Hack -- take a turn */
146 if (autosave_l) do_cmd_save_game(TRUE);
148 /* For a random quest */
149 if (p_ptr->inside_quest &&
150 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
154 p_ptr->inside_quest = 0;
157 /* For a fixed quest */
158 if (p_ptr->inside_quest &&
159 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
163 p_ptr->inside_quest = c_ptr->special;
168 /* For normal dungeon and random quest */
172 if (have_flag(f_ptr->flags, FF_SHAFT))
174 /* Create a way back */
175 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
181 /* Create a way back */
182 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
187 /* Get out from current dungeon */
188 if (dun_level - up_num < d_info[dungeon_type].mindepth)
193 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
195 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "climbed up the stairs to");
200 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
201 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
202 else if (up_num == dun_level)
203 msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
205 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
207 if (up_num == dun_level)
208 msg_print("You go back to the surface.");
210 msg_print("You enter a maze of up staircases.");
214 p_ptr->leaving = TRUE;
219 * @brief ³¬Ãʤò»È¤Ã¤Æ³¬Áؤò¹ß¤ê¤ë½èÍý / Go down one level
222 void do_cmd_go_down(void)
225 cave_type *c_ptr = &cave[py][px];
226 feature_type *f_ptr = &f_info[c_ptr->feat];
228 bool fall_trap = FALSE;
231 if (p_ptr->special_defense & KATA_MUSOU)
233 set_action(ACTION_NONE);
237 if (!have_flag(f_ptr->flags, FF_MORE))
240 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
242 msg_print("I see no down staircase here.");
248 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
251 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
256 /* Quest down stairs */
257 else if (have_flag(f_ptr->flags, FF_QUEST))
259 /* Confirm Leaving */
260 if(!confirm_leave_level(TRUE)) return;
263 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
264 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
266 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
268 msg_print("You enter the down staircase.");
274 p_ptr->inside_quest = c_ptr->special;
276 /* Activate the quest */
277 if (!quest[p_ptr->inside_quest].status)
279 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
281 init_flags = INIT_ASSIGN;
282 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
284 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
287 /* Leaving a quest */
288 if (!p_ptr->inside_quest)
294 p_ptr->leaving = TRUE;
300 /* Hack -- take a turn */
306 int target_dungeon = 0;
310 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
312 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
315 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
317 msg_print("The entrance of this dungeon is closed!");
321 if (!max_dlv[target_dungeon])
324 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
325 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
327 msg_format("There is the entrance of %s (Danger level: %d)", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
328 if (!get_check("Do you really get in this dungeon? ")) return;
332 /* Save old player position */
335 dungeon_type = (byte)target_dungeon;
338 * Clear all saved floors
339 * and create a first saved floor
341 prepare_change_floor_mode(CFM_FIRST_FLOOR);
344 /* Hack -- take a turn */
347 if (autosave_l) do_cmd_save_game(TRUE);
350 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
355 /* Enter the dungeon just now */
356 p_ptr->enter_dungeon = TRUE;
357 down_num = d_info[dungeon_type].mindepth;
363 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Íî¤È¤·¸Í¤ËÍî¤Á¤¿");
364 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
366 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fell through a trap door");
367 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed down the stairs to");
374 msg_print("¤ï¤¶¤ÈÍî¤È¤·¸Í¤ËÍî¤Á¤¿¡£");
376 msg_print("You deliberately jump through the trap door.");
385 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
387 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
393 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
394 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
396 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
398 msg_print("You enter a maze of down staircases.");
405 p_ptr->leaving = TRUE;
409 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
413 if (have_flag(f_ptr->flags, FF_SHAFT))
415 /* Create a way back */
416 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
420 /* Create a way back */
421 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
429 * @brief õº÷¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó / Simple command to "search" for one turn
432 void do_cmd_search(void)
434 /* Allow repeated command */
437 /* Set repeat count */
438 command_rep = command_arg - 1;
440 /* Redraw the state */
441 p_ptr->redraw |= (PR_STATE);
456 * @brief ³ºÅö¤Î¥Þ¥¹¤Ë¸ºß¤·¤Æ¤¤¤ëÈ¢¤Î¥ª¥Ö¥¸¥§¥¯¥ÈID¤òÊÖ¤¹¡£
457 * @param y ÁöººÂоݤˤ·¤¿¤¤¥Þ¥¹¤ÎYºÂɸ
458 * @param x ÁöººÂоݤˤ·¤¿¤¤¥Þ¥¹¤ÎXºÂɸ
459 * @param trapped TRUE¤Ê¤é¤Ð¥È¥é¥Ã¥×¤¬Â¸ºß¤¹¤ëÈ¢¤Î¤ß¡¢FALSE¤Ê¤é¤Ð¶õ¤Ç¤Ê¤¤È¢Á´¤Æ¤òÂоݤˤ¹¤ë
460 * @return È¢¤¬Â¸ºß¤¹¤ë¾ì¹ç¤½¤Î¥ª¥Ö¥¸¥§¥¯¥ÈID¡¢Â¸ºß¤·¤Ê¤¤¾ì¹ç0¤òÊÖ¤¹¡£
462 static s16b chest_check(int y, int x, bool trapped)
464 cave_type *c_ptr = &cave[y][x];
466 s16b this_o_idx, next_o_idx = 0;
469 /* Scan all objects in the grid */
470 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
475 o_ptr = &o_list[this_o_idx];
477 /* Acquire next object */
478 next_o_idx = o_ptr->next_o_idx;
480 /* Skip unknown chests XXX XXX */
481 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
483 /* Check for non empty chest */
484 if ((o_ptr->tval == TV_CHEST) &&
485 (((!trapped) && (o_ptr->pval)) || /* non empty */
486 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
498 * @brief È¢¤«¤é¥¢¥¤¥Æ¥à¤ò°ú¤½Ð¤¹ /
499 * Allocates objects upon opening a chest -BEN-
500 * @param scatter TRUE¤Ê¤é¤Ð¥È¥é¥Ã¥×¤Ë¤è¤ë¥¢¥¤¥Æ¥à¤Î³È»¶½èÍý
501 * @param y È¢¤Î¸ºß¤¹¤ë¥Þ¥¹¤ÎYºÂɸ
502 * @param x È¢¤Î¸ºß¤¹¤ë¥Þ¥¹¤ÎXºÂɸ
503 * @param o_idx È¢¤Î¥ª¥Ö¥¸¥§¥¯¥ÈID
507 * Disperse treasures from the given chest, centered at (x,y).
509 * Small chests often contain "gold", while Large chests always contain
510 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
511 * and Steel chests contain 6 items. The "value" of the items in a
512 * chest is based on the "power" of the chest, which is in turn based
513 * on the level on which the chest is generated.
516 static void chest_death(bool scatter, int y, int x, s16b o_idx)
526 object_type *o_ptr = &o_list[o_idx];
529 /* Small chests often hold "gold" */
530 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
532 /* Determine how much to drop (see above) */
533 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
535 if (o_ptr->sval == SV_CHEST_KANDUME)
540 object_level = o_ptr->xtra3;
544 /* Determine the "value" of the items */
545 object_level = ABS(o_ptr->pval) + 10;
548 /* Zero pval means empty chest */
549 if (!o_ptr->pval) number = 0;
551 /* Opening a chest */
552 opening_chest = TRUE;
554 /* Drop some objects (non-chests) */
555 for (; number > 0; --number)
557 /* Get local object */
560 /* Wipe the object */
563 /* Small chests often drop gold */
564 if (small && (randint0(100) < 25))
567 if (!make_gold(q_ptr)) continue;
570 /* Otherwise drop an item */
573 /* Make a good object */
574 if (!make_object(q_ptr, mode)) continue;
577 /* If chest scatters its contents, pick any floor square. */
581 for (i = 0; i < 200; i++)
583 /* Pick a totally random spot. */
584 y = randint0(MAX_HGT);
585 x = randint0(MAX_WID);
587 /* Must be an empty floor. */
588 if (!cave_empty_bold(y, x)) continue;
590 /* Place the object there. */
591 drop_near(q_ptr, -1, y, x);
597 /* Normally, drop object near the chest. */
598 else drop_near(q_ptr, -1, y, x);
601 /* Reset the object level */
602 object_level = base_level;
604 /* No longer opening a chest */
605 opening_chest = FALSE;
616 * @brief È¢¤Î¥È¥é¥Ã¥×½èÍý /
617 * Chests have traps too.
618 * @param y È¢¤Î¸ºß¤¹¤ë¥Þ¥¹¤ÎYºÂɸ
619 * @param x È¢¤Î¸ºß¤¹¤ë¥Þ¥¹¤ÎXºÂɸ
620 * @param o_idx È¢¤Î¥ª¥Ö¥¸¥§¥¯¥ÈID
624 * Exploding chest destroys contents (and traps).
625 * Note that the chest itself is never destroyed.
628 static void chest_trap(int y, int x, s16b o_idx)
632 object_type *o_ptr = &o_list[o_idx];
634 int mon_level = o_ptr->xtra3;
636 /* Ignore disarmed chests */
637 if (o_ptr->pval <= 0) return;
639 /* Obtain the traps */
640 trap = chest_traps[o_ptr->pval];
643 if (trap & (CHEST_LOSE_STR))
646 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
647 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
649 msg_print("A small needle has pricked you!");
650 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
653 (void)do_dec_stat(A_STR);
656 /* Lose constitution */
657 if (trap & (CHEST_LOSE_CON))
660 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
661 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
663 msg_print("A small needle has pricked you!");
664 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
667 (void)do_dec_stat(A_CON);
671 if (trap & (CHEST_POISON))
674 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
676 msg_print("A puff of green gas surrounds you!");
679 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
681 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
686 if (trap & (CHEST_PARALYZE))
689 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
691 msg_print("A puff of yellow gas surrounds you!");
695 if (!p_ptr->free_act)
697 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
701 /* Summon monsters */
702 if (trap & (CHEST_SUMMON))
704 int num = 2 + randint1(3);
706 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
708 msg_print("You are enveloped in a cloud of smoke!");
712 for (i = 0; i < num; i++)
714 if (randint1(100)<dun_level)
715 activate_hi_summon(py, px, FALSE);
717 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
721 /* Elemental summon. */
722 if (trap & (CHEST_E_SUMMON))
725 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
727 msg_print("Elemental beings appear to protect their treasures!");
729 for (i = 0; i < randint1(3) + 5; i++)
731 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
735 /* Force clouds, then summon birds. */
736 if (trap & (CHEST_BIRD_STORM))
739 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
741 msg_print("A storm of birds swirls around you!");
744 for (i = 0; i < randint1(3) + 3; i++)
745 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
747 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
749 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
753 /* Various colorful summonings. */
754 if (trap & (CHEST_H_SUMMON))
760 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
762 msg_print("Demons materialize in clouds of fire and brimstone!");
765 for (i = 0; i < randint1(3) + 2; i++)
767 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
768 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
772 /* Summon dragons. */
776 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
778 msg_print("Draconic forms loom out of the darkness!");
781 for (i = 0; i < randint1(3) + 2; i++)
783 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
787 /* Summon hybrids. */
791 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
793 msg_print("Creatures strange and twisted assault you!");
796 for (i = 0; i < randint1(5) + 3; i++)
798 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
802 /* Summon vortices (scattered) */
806 msg_print("±²´¬¤¬¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
808 msg_print("Vortices coalesce and wreak destruction!");
811 for (i = 0; i < randint1(3) + 2; i++)
813 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
819 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
821 /* Determine how many nasty tricks can be played. */
822 int nasty_tricks_count = 4 + randint0(3);
826 msg_print("¶²¤í¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
828 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
831 /* This is gonna hurt... */
832 for (; nasty_tricks_count > 0; nasty_tricks_count--)
834 /* ...but a high saving throw does help a little. */
835 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
838 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
840 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
842 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
845 if (!p_ptr->free_act)
846 (void)set_paralyzed(p_ptr->paralyzed + 2 +
849 (void)set_stun(p_ptr->stun + 10 +
852 else if (one_in_(3)) apply_disenchant(0);
855 (void)do_dec_stat(A_STR);
856 (void)do_dec_stat(A_DEX);
857 (void)do_dec_stat(A_CON);
858 (void)do_dec_stat(A_INT);
859 (void)do_dec_stat(A_WIS);
860 (void)do_dec_stat(A_CHR);
862 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
867 /* Aggravate monsters. */
868 if (trap & (CHEST_ALARM))
871 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
873 msg_print("An alarm sounds!");
875 aggravate_monsters(0);
879 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
882 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
883 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
885 msg_print("There is a sudden explosion!");
886 msg_print("Everything inside the chest is destroyed!");
890 sound(SOUND_EXPLODE);
892 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
894 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
898 /* Scatter contents. */
899 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
902 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
904 msg_print("The contents of the chest scatter all over the dungeon!");
906 chest_death(TRUE, y, x, o_idx);
913 * @brief È¢¤ò³«¤±¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
914 * Attempt to open the given chest at the given location
915 * @param y È¢¤Î¸ºß¤¹¤ë¥Þ¥¹¤ÎYºÂɸ
916 * @param x È¢¤Î¸ºß¤¹¤ë¥Þ¥¹¤ÎXºÂɸ
917 * @param o_idx È¢¤Î¥ª¥Ö¥¸¥§¥¯¥ÈID
918 * @return È¢¤¬³«¤«¤Ê¤«¤Ã¤¿¾ì¹çTRUE / Returns TRUE if repeated commands may continue
920 * Assume there is no monster blocking the destination
922 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
930 object_type *o_ptr = &o_list[o_idx];
936 /* Attempt to unlock it */
939 /* Assume locked, and thus not open */
942 /* Get the "disarm" factor */
943 i = p_ptr->skill_dis;
945 /* Penalize some conditions */
946 if (p_ptr->blind || no_lite()) i = i / 10;
947 if (p_ptr->confused || p_ptr->image) i = i / 10;
949 /* Extract the difficulty */
952 /* Always have a small chance of success */
955 /* Success -- May still have traps */
956 if (randint0(100) < j)
959 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
961 msg_print("You have picked the lock.");
968 /* Failure -- Keep trying */
971 /* We may continue repeating */
973 if (flush_failure) flush();
975 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
977 msg_print("You failed to pick the lock.");
983 /* Allowed to open */
986 /* Apply chest traps, if any */
987 chest_trap(y, x, o_idx);
989 /* Let the Chest drop items */
990 chest_death(FALSE, y, x, o_idx);
998 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
1001 * @brief ÃÏ·Á¤Ï³«¤¯¤â¤Î¤Ç¤¢¤Ã¤Æ¡¢¤«¤Ä³«¤«¤ì¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
1002 * Attempt to open the given chest at the given location
1003 * @param feat ÃÏ·ÁID
1004 * @return ³«¤¤¤¿ÃÏ·Á¤Ç¤¢¤ë¾ì¹çTRUE¤òÊÖ¤¹ / Return TRUE if the given feature is an open door
1006 static bool is_open(int feat)
1008 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
1013 * @brief ¥×¥ì¥¤¥ä¡¼¤Î¼þÊÕ9¥Þ¥¹¤Ë³ºÅö¤¹¤ëÃÏ·Á¤¬¤¤¤¯¤Ä¤¢¤ë¤«¤òÊÖ¤¹ /
1014 * Attempt to open the given chest at the given location
1015 * @param y ³ºÅö¤¹¤ëÃÏ·Á¤ÎÃ椫¤é1¤Ä¤ÎYºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
1016 * @param x ³ºÅö¤¹¤ëÃÏ·Á¤ÎÃ椫¤é1¤Ä¤ÎXºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
1017 * @param test ÃÏ·Á¾ò·ï¤òȽÄꤹ¤ë¤¿¤á¤Î´Ø¿ô¥Ý¥¤¥ó¥¿
1018 * @param under TRUE¤Ê¤é¤Ð¥×¥ì¥¤¥ä¡¼¤Îľ²¼¤ÎºÂɸ¤âÁöººÂоݤˤ¹¤ë
1019 * @return ³ºÅö¤¹¤ëÃÏ·Á¤Î¿ô
1020 * @details Return the number of features around (or under) the character.
1021 * Usually look for doors and floor traps.
1023 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
1025 int d, count, xx, yy;
1027 /* Count how many matches */
1030 /* Check around (and under) the character */
1031 for (d = 0; d < 9; d++)
1036 /* if not searching under player continue */
1037 if ((d == 8) && !under) continue;
1039 /* Extract adjacent (legal) location */
1040 yy = py + ddy_ddd[d];
1041 xx = px + ddx_ddd[d];
1044 c_ptr = &cave[yy][xx];
1046 /* Must have knowledge */
1047 if (!(c_ptr->info & (CAVE_MARK))) continue;
1049 /* Feature code (applying "mimic" field) */
1050 feat = get_feat_mimic(c_ptr);
1052 /* Not looking for this feature */
1053 if (!((*test)(feat))) continue;
1058 /* Remember the location. Only useful if only one match */
1069 * @brief ¥×¥ì¥¤¥ä¡¼¤Î¼þÊÕ9¥Þ¥¹¤ËÈ¢¤Î¤¢¤ë¥Þ¥¹¤¬¤¤¤¯¤Ä¤¢¤ë¤«¤òÊÖ¤¹ /
1070 * Return the number of chests around (or under) the character.
1071 * @param y ³ºÅö¤¹¤ë¥Þ¥¹¤ÎÃ椫¤é1¤Ä¤ÎYºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
1072 * @param x ³ºÅö¤¹¤ë¥Þ¥¹¤ÎÃ椫¤é1¤Ä¤ÎXºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
1073 * @param test TRUE¤Ê¤é¤Ð¥È¥é¥Ã¥×¤Î¸ºß¤¬È½ÌÀ¤·¤Æ¤¤¤ëÈ¢¤Î¤ßÂоݤˤ¹¤ë
1074 * @return ³ºÅö¤¹¤ëÃÏ·Á¤Î¿ô
1076 * If requested, count only trapped chests.
1078 static int count_chests(int *y, int *x, bool trapped)
1080 int d, count, o_idx;
1084 /* Count how many matches */
1087 /* Check around (and under) the character */
1088 for (d = 0; d < 9; d++)
1090 /* Extract adjacent (legal) location */
1091 int yy = py + ddy_ddd[d];
1092 int xx = px + ddx_ddd[d];
1094 /* No (visible) chest is there */
1095 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
1097 /* Grab the object */
1098 o_ptr = &o_list[o_idx];
1101 if (o_ptr->pval == 0) continue;
1103 /* No (known) traps here */
1104 if (trapped && (!object_is_known(o_ptr) ||
1105 !chest_traps[o_ptr->pval])) continue;
1110 /* Remember the location. Only useful if only one match */
1121 * @brief ¥×¥ì¥¤¥ä¡¼¤«¤é»ØÄê¤ÎºÂɸ¤¬¤É¤ÎÊý³Ñ¤Ë¤¢¤ë¤«¤òÊÖ¤¹ /
1122 * Convert an adjacent location to a direction.
1123 * @param y Êý³Ñ¤ò³Îǧ¤·¤¿YºÂɸ
1124 * @param x Êý³Ñ¤ò³Îǧ¤·¤¿XºÂɸ
1127 static int coords_to_dir(int y, int x)
1129 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1136 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1138 return d[dx + 1][dy + 1];
1141 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1145 * @brief ¡Ö³«¤±¤ë¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
1146 * Perform the basic "open" command on doors
1147 * @param y Âоݤò¹Ô¤¦¥Þ¥¹¤ÎYºÂɸ
1148 * @param x Âоݤò¹Ô¤¦¥Þ¥¹¤ÎXºÂɸ
1149 * @return ¼ÂºÝ¤Ë½èÍý¤¬¹Ô¤ï¤ì¤¿¾ì¹çTRUE¤òÊÖ¤¹¡£
1151 * Assume destination is a closed/locked/jammed door
1152 * Assume there is no monster blocking the destination
1153 * Returns TRUE if repeated commands may continue
1155 static bool do_cmd_open_aux(int y, int x)
1159 /* Get requested grid */
1160 cave_type *c_ptr = &cave[y][x];
1162 feature_type *f_ptr = &f_info[c_ptr->feat];
1170 /* Seeing true feature code (ignore mimic) */
1173 if (!have_flag(f_ptr->flags, FF_OPEN))
1177 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1179 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1185 else if (f_ptr->power)
1188 i = p_ptr->skill_dis;
1190 /* Penalize some conditions */
1191 if (p_ptr->blind || no_lite()) i = i / 10;
1192 if (p_ptr->confused || p_ptr->image) i = i / 10;
1194 /* Extract the lock power */
1197 /* Extract the difficulty XXX XXX XXX */
1200 /* Always have a small chance of success */
1204 if (randint0(100) < j)
1208 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1210 msg_print("You have picked the lock.");
1214 cave_alter_feat(y, x, FF_OPEN);
1217 sound(SOUND_OPENDOOR);
1227 if (flush_failure) flush();
1231 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1233 msg_print("You failed to pick the lock.");
1237 /* We may keep trying */
1246 cave_alter_feat(y, x, FF_OPEN);
1249 sound(SOUND_OPENDOOR);
1257 * @brief ¡Ö³«¤±¤ë¡×¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
1258 * Open a closed/locked/jammed door or a closed/locked chest.
1261 * Unlocking a locked door/chest is worth one experience point.
1263 void do_cmd_open(void)
1271 if (p_ptr->special_defense & KATA_MUSOU)
1273 set_action(ACTION_NONE);
1276 #ifdef ALLOW_EASY_OPEN /* TNB */
1278 /* Option: Pick a direction */
1281 int num_doors, num_chests;
1283 /* Count closed doors (locked or jammed) */
1284 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1286 /* Count chests (locked) */
1287 num_chests = count_chests(&y, &x, FALSE);
1289 /* See if only one target */
1290 if (num_doors || num_chests)
1292 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1294 if (!too_many) command_dir = coords_to_dir(y, x);
1298 #endif /* ALLOW_EASY_OPEN -- TNB */
1300 /* Allow repeated command */
1303 /* Set repeat count */
1304 command_rep = command_arg - 1;
1306 /* Redraw the state */
1307 p_ptr->redraw |= (PR_STATE);
1309 /* Cancel the arg */
1313 /* Get a "repeated" direction */
1314 if (get_rep_dir(&dir, TRUE))
1319 /* Get requested location */
1323 /* Get requested grid */
1324 c_ptr = &cave[y][x];
1326 /* Feature code (applying "mimic" field) */
1327 feat = get_feat_mimic(c_ptr);
1329 /* Check for chest */
1330 o_idx = chest_check(y, x, FALSE);
1332 /* Nothing useful */
1333 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
1337 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1339 msg_print("You see nothing there to open.");
1344 /* Monster in the way */
1345 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1352 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1354 msg_print("There is a monster in the way!");
1365 /* Open the chest */
1366 more = do_cmd_open_chest(y, x, o_idx);
1373 more = do_cmd_open_aux(y, x);
1377 /* Cancel repeat unless we may continue */
1378 if (!more) disturb(0, 0);
1384 * @brief ¡ÖÊĤ¸¤ë¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
1385 * Perform the basic "close" command
1386 * @param y Âоݤò¹Ô¤¦¥Þ¥¹¤ÎYºÂɸ
1387 * @param x Âоݤò¹Ô¤¦¥Þ¥¹¤ÎXºÂɸ
1388 * @return ¼ÂºÝ¤Ë½èÍý¤¬¹Ô¤ï¤ì¤¿¾ì¹çTRUE¤òÊÖ¤¹¡£
1390 * Assume destination is an open/broken door
1391 * Assume there is no monster blocking the destination
1392 * Returns TRUE if repeated commands may continue
1394 static bool do_cmd_close_aux(int y, int x)
1396 /* Get grid and contents */
1397 cave_type *c_ptr = &cave[y][x];
1398 s16b old_feat = c_ptr->feat;
1404 /* Seeing true feature code (ignore mimic) */
1407 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1409 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
1411 /* Hack -- object in the way */
1412 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
1413 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
1417 msg_print("²¿¤«¤¬¤Ä¤Ã¤«¤¨¤ÆÊĤޤé¤Ê¤¤¡£");
1419 msg_print("There seems stuck.");
1424 /* Close the door */
1425 cave_alter_feat(y, x, FF_CLOSE);
1428 if (old_feat == c_ptr->feat)
1432 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1434 msg_print("The door appears to be broken.");
1440 sound(SOUND_SHUTDOOR);
1451 * @brief ¡ÖÊĤ¸¤ë¡×¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
1452 * Close an open door.
1453 * @param y Âоݤò¹Ô¤¦¥Þ¥¹¤ÎYºÂɸ
1454 * @param x Âоݤò¹Ô¤¦¥Þ¥¹¤ÎXºÂɸ
1457 * Unlocking a locked door/chest is worth one experience point.
1459 void do_cmd_close(void)
1465 if (p_ptr->special_defense & KATA_MUSOU)
1467 set_action(ACTION_NONE);
1470 #ifdef ALLOW_EASY_OPEN /* TNB */
1472 /* Option: Pick a direction */
1475 /* Count open doors */
1476 if (count_dt(&y, &x, is_open, FALSE) == 1)
1478 command_dir = coords_to_dir(y, x);
1482 #endif /* ALLOW_EASY_OPEN -- TNB */
1484 /* Allow repeated command */
1487 /* Set repeat count */
1488 command_rep = command_arg - 1;
1490 /* Redraw the state */
1491 p_ptr->redraw |= (PR_STATE);
1493 /* Cancel the arg */
1497 /* Get a "repeated" direction */
1498 if (get_rep_dir(&dir,FALSE))
1503 /* Get requested location */
1507 /* Get grid and contents */
1508 c_ptr = &cave[y][x];
1510 /* Feature code (applying "mimic" field) */
1511 feat = get_feat_mimic(c_ptr);
1513 /* Require open/broken door */
1514 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1518 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1520 msg_print("You see nothing there to close.");
1524 /* Monster in the way */
1525 else if (c_ptr->m_idx)
1532 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1534 msg_print("There is a monster in the way!");
1541 /* Close the door */
1544 /* Close the door */
1545 more = do_cmd_close_aux(y, x);
1549 /* Cancel repeat unless we may continue */
1550 if (!more) disturb(0, 0);
1555 * @brief ¡Ö·¡¤ë¡×¥³¥Þ¥ó¥É¤ò³ºÅö¤Î¥Þ¥¹¤Ë¹Ô¤¨¤ë¤«¤ÎȽÄê¤È·ë²Ì¥á¥Ã¥»¡¼¥¸¤Îɽ¼¨ /
1556 * Determine if a given grid may be "tunneled"
1557 * @param y Âоݤò¹Ô¤¦¥Þ¥¹¤ÎYºÂɸ
1558 * @param x Âоݤò¹Ô¤¦¥Þ¥¹¤ÎXºÂɸ
1561 static bool do_cmd_tunnel_test(int y, int x)
1563 cave_type *c_ptr = &cave[y][x];
1565 /* Must have knowledge */
1566 if (!(c_ptr->info & CAVE_MARK))
1570 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1572 msg_print("You see nothing there.");
1579 /* Must be a wall/door/etc */
1580 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1584 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1586 msg_print("You see nothing there to tunnel.");
1599 * @brief ¡Ö·¡¤ë¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
1600 * Perform the basic "tunnel" command
1601 * @param y Âоݤò¹Ô¤¦¥Þ¥¹¤ÎYºÂɸ
1602 * @param x Âоݤò¹Ô¤¦¥Þ¥¹¤ÎXºÂɸ
1603 * @return ¼ÂºÝ¤Ë½èÍý¤¬¹Ô¤ï¤ì¤¿¾ì¹çTRUE¤òÊÖ¤¹¡£
1605 * Assumes that no monster is blocking the destination
1606 * Do not use twall anymore
1607 * Returns TRUE if repeated commands may continue
1609 static bool do_cmd_tunnel_aux(int y, int x)
1612 feature_type *f_ptr, *mimic_f_ptr;
1617 /* Verify legality */
1618 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1624 c_ptr = &cave[y][x];
1625 f_ptr = &f_info[c_ptr->feat];
1626 power = f_ptr->power;
1628 /* Feature code (applying "mimic" field) */
1629 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1631 name = f_name + mimic_f_ptr->name;
1636 if (have_flag(f_ptr->flags, FF_PERMANENT))
1639 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1642 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1644 msg_print("This seems to be permanent rock.");
1648 /* Map border (mimiccing Permanent wall) */
1652 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1654 msg_print("You can't tunnel through that!");
1660 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1663 if (p_ptr->skill_dig > randint0(20 * power))
1667 msg_format("%s¤ò¤¯¤º¤·¤¿¡£", name);
1669 msg_format("You have removed the %s.", name);
1672 /* Remove the feature */
1673 cave_alter_feat(y, x, FF_TUNNEL);
1675 /* Update some things */
1676 p_ptr->update |= (PU_FLOW);
1680 /* Message, keep digging */
1682 msg_format("%s¤ò¤¯¤º¤·¤Æ¤¤¤ë¡£", name);
1684 msg_format("You dig into the %s.", name);
1693 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1696 if (p_ptr->skill_dig > power + randint0(40 * power))
1699 if (tree) msg_format("%s¤òÀÚ¤êʧ¤Ã¤¿¡£", name);
1702 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1703 p_ptr->update |= (PU_FLOW);
1706 if (tree) msg_format("You have cleared away the %s.", name);
1709 msg_print("You have finished the tunnel.");
1710 p_ptr->update |= (PU_FLOW);
1715 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1717 /* Remove the feature */
1718 cave_alter_feat(y, x, FF_TUNNEL);
1720 chg_virtue(V_DILIGENCE, 1);
1721 chg_virtue(V_NATURE, -1);
1729 /* We may continue chopping */
1731 msg_format("%s¤òÀڤäƤ¤¤ë¡£", name);
1733 msg_format("You chop away at the %s.", name);
1735 /* Occasional Search XXX XXX */
1736 if (randint0(100) < 25) search();
1740 /* We may continue tunelling */
1742 msg_format("%s¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£", name);
1744 msg_format("You tunnel into the %s.", name);
1752 if (is_hidden_door(c_ptr))
1754 /* Occasional Search XXX XXX */
1755 if (randint0(100) < 25) search();
1764 * @brief ¡Ö·¡¤ë¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
1765 * Tunnels through "walls" (including rubble and closed doors)
1769 * Note that you must tunnel in order to hit invisible monsters
1770 * in walls, though moving into walls still takes a turn anyway.
1772 * Digging is very difficult without a "digger" weapon, but can be
1773 * accomplished by strong players using heavy weapons.
1776 void do_cmd_tunnel(void)
1786 if (p_ptr->special_defense & KATA_MUSOU)
1788 set_action(ACTION_NONE);
1791 /* Allow repeated command */
1794 /* Set repeat count */
1795 command_rep = command_arg - 1;
1797 /* Redraw the state */
1798 p_ptr->redraw |= (PR_STATE);
1800 /* Cancel the arg */
1804 /* Get a direction to tunnel, or Abort */
1805 if (get_rep_dir(&dir,FALSE))
1812 c_ptr = &cave[y][x];
1814 /* Feature code (applying "mimic" field) */
1815 feat = get_feat_mimic(c_ptr);
1817 /* No tunnelling through doors */
1818 if (have_flag(f_info[feat].flags, FF_DOOR))
1822 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1824 msg_print("You cannot tunnel through doors.");
1828 /* No tunnelling through most features */
1829 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1832 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1834 msg_print("You can't tunnel through that.");
1838 /* A monster is in the way */
1839 else if (c_ptr->m_idx)
1846 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1848 msg_print("There is a monster in the way!");
1858 /* Tunnel through walls */
1859 more = do_cmd_tunnel_aux(y, x);
1863 /* Cancel repetition unless we can continue */
1864 if (!more) disturb(0, 0);
1868 #ifdef ALLOW_EASY_OPEN /* TNB */
1871 * @brief °ÜÆ°½èÍý¤Ë¤è¤ë´Ê°×¤Ê¡Ö³«¤¯¡×½èÍý /
1873 * @return ³«¤¯½èÍý¤¬¼ÂºÝ¤Ë»î¤ß¤é¤ì¤¿¾ì¹çTRUE¤òÊÖ¤¹
1876 * If there is a jammed/closed/locked door at the given location,
1877 * then attempt to unlock/open it. Return TRUE if an attempt was
1878 * made (successful or not), otherwise return FALSE.
1880 * The code here should be nearly identical to that in
1881 * do_cmd_open_test() and do_cmd_open_aux().
1884 bool easy_open_door(int y, int x)
1888 cave_type *c_ptr = &cave[y][x];
1889 feature_type *f_ptr = &f_info[c_ptr->feat];
1891 /* Must be a closed door */
1892 if (!is_closed_door(c_ptr->feat))
1899 if (!have_flag(f_ptr->flags, FF_OPEN))
1903 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1905 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1911 else if (f_ptr->power)
1914 i = p_ptr->skill_dis;
1916 /* Penalize some conditions */
1917 if (p_ptr->blind || no_lite()) i = i / 10;
1918 if (p_ptr->confused || p_ptr->image) i = i / 10;
1920 /* Extract the lock power */
1923 /* Extract the difficulty XXX XXX XXX */
1926 /* Always have a small chance of success */
1930 if (randint0(100) < j)
1934 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1936 msg_print("You have picked the lock.");
1940 cave_alter_feat(y, x, FF_OPEN);
1943 sound(SOUND_OPENDOOR);
1953 if (flush_failure) flush();
1957 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1959 msg_print("You failed to pick the lock.");
1969 cave_alter_feat(y, x, FF_OPEN);
1972 sound(SOUND_OPENDOOR);
1979 #endif /* ALLOW_EASY_OPEN -- TNB */
1983 * @brief È¢¤Î¥È¥é¥Ã¥×¤ò²ò½ü¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
1984 * Perform the basic "disarm" command
1985 * @param y ²ò½ü¤ò¹Ô¤¦¥Þ¥¹¤ÎYºÂɸ
1986 * @param x ²ò½ü¤ò¹Ô¤¦¥Þ¥¹¤ÎXºÂɸ
1987 * @param o_idx È¢¤Î¥ª¥Ö¥¸¥§¥¯¥ÈID
1988 * @return ¥¿¡¼¥ó¤ò¾ÃÈñ¤¹¤ë½èÍý¤¬¹Ô¤ï¤ì¤¿¾ì¹çTRUE¤òÊÖ¤¹
1991 * Assume destination is a visible trap
1992 * Assume there is no monster blocking the destination
1993 * Returns TRUE if repeated commands may continue
1996 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2002 object_type *o_ptr = &o_list[o_idx];
2008 /* Get the "disarm" factor */
2009 i = p_ptr->skill_dis;
2011 /* Penalize some conditions */
2012 if (p_ptr->blind || no_lite()) i = i / 10;
2013 if (p_ptr->confused || p_ptr->image) i = i / 10;
2015 /* Extract the difficulty */
2016 j = i - o_ptr->pval;
2018 /* Always have a small chance of success */
2021 /* Must find the trap first. */
2022 if (!object_is_known(o_ptr))
2025 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2027 msg_print("I don't see any traps.");
2032 /* Already disarmed/unlocked */
2033 else if (o_ptr->pval <= 0)
2036 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2038 msg_print("The chest is not trapped.");
2043 /* No traps to find. */
2044 else if (!chest_traps[o_ptr->pval])
2047 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2049 msg_print("The chest is not trapped.");
2054 /* Success (get a lot of experience) */
2055 else if (randint0(100) < j)
2058 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2060 msg_print("You have disarmed the chest.");
2063 gain_exp(o_ptr->pval);
2064 o_ptr->pval = (0 - o_ptr->pval);
2067 /* Failure -- Keep trying */
2068 else if ((i > 5) && (randint1(i) > 5))
2070 /* We may keep trying */
2072 if (flush_failure) flush();
2074 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2076 msg_print("You failed to disarm the chest.");
2081 /* Failure -- Set off the trap */
2085 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2087 msg_print("You set off a trap!");
2091 chest_trap(y, x, o_idx);
2100 * @brief È¢¤Î¥È¥é¥Ã¥×¤ò²ò½ü¤¹¤ë¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
2101 * Perform the basic "disarm" command
2102 * @param y ²ò½ü¤ò¹Ô¤¦¥Þ¥¹¤ÎYºÂɸ
2103 * @param x ²ò½ü¤ò¹Ô¤¦¥Þ¥¹¤ÎXºÂɸ
2104 * @param dir ¥×¥ì¥¤¥ä¡¼¤«¤é¤ß¤¿Êý¸þID
2105 * @return ¥¿¡¼¥ó¤ò¾ÃÈñ¤¹¤ë½èÍý¤¬¹Ô¤ï¤ì¤¿¾ì¹çTRUE¤òÊÖ¤¹
2108 * Assume destination is a visible trap
2109 * Assume there is no monster blocking the destination
2110 * Returns TRUE if repeated commands may continue
2113 #ifdef ALLOW_EASY_DISARM /* TNB */
2115 bool do_cmd_disarm_aux(int y, int x, int dir)
2117 #else /* ALLOW_EASY_DISARM -- TNB */
2119 static bool do_cmd_disarm_aux(int y, int x, int dir)
2121 #endif /* ALLOW_EASY_DISARM -- TNB */
2123 /* Get grid and contents */
2124 cave_type *c_ptr = &cave[y][x];
2127 feature_type *f_ptr = &f_info[c_ptr->feat];
2129 /* Access trap name */
2130 cptr name = (f_name + f_ptr->name);
2132 /* Extract trap "power" */
2133 int power = f_ptr->power;
2137 /* Get the "disarm" factor */
2138 int i = p_ptr->skill_dis;
2145 /* Penalize some conditions */
2146 if (p_ptr->blind || no_lite()) i = i / 10;
2147 if (p_ptr->confused || p_ptr->image) i = i / 10;
2149 /* Extract the difficulty */
2152 /* Always have a small chance of success */
2156 if (randint0(100) < j)
2160 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2162 msg_format("You have disarmed the %s.", name);
2168 /* Remove the trap */
2169 cave_alter_feat(y, x, FF_DISARM);
2171 #ifdef ALLOW_EASY_DISARM /* TNB */
2173 /* Move the player onto the trap */
2174 move_player(dir, easy_disarm, FALSE);
2176 #else /* ALLOW_EASY_DISARM -- TNB */
2178 /* move the player onto the trap grid */
2179 move_player(dir, FALSE, FALSE);
2181 #endif /* ALLOW_EASY_DISARM -- TNB */
2184 /* Failure -- Keep trying */
2185 else if ((i > 5) && (randint1(i) > 5))
2188 if (flush_failure) flush();
2192 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2194 msg_format("You failed to disarm the %s.", name);
2197 /* We may keep trying */
2201 /* Failure -- Set off the trap */
2206 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2208 msg_format("You set off the %s!", name);
2211 #ifdef ALLOW_EASY_DISARM /* TNB */
2213 /* Move the player onto the trap */
2214 move_player(dir, easy_disarm, FALSE);
2216 #else /* ALLOW_EASY_DISARM -- TNB */
2218 /* Move the player onto the trap */
2219 move_player(dir, FALSE, FALSE);
2221 #endif /* ALLOW_EASY_DISARM -- TNB */
2230 * @brief È¢¡¢¾²¤Î¥È¥é¥Ã¥×²ò½ü½èÍýÁÐÊý¤ÎÅý¹ç¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2231 * Disarms a trap, or chest
2234 void do_cmd_disarm(void)
2242 if (p_ptr->special_defense & KATA_MUSOU)
2244 set_action(ACTION_NONE);
2247 #ifdef ALLOW_EASY_DISARM /* TNB */
2249 /* Option: Pick a direction */
2252 int num_traps, num_chests;
2254 /* Count visible traps */
2255 num_traps = count_dt(&y, &x, is_trap, TRUE);
2257 /* Count chests (trapped) */
2258 num_chests = count_chests(&y, &x, TRUE);
2260 /* See if only one target */
2261 if (num_traps || num_chests)
2263 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2265 if (!too_many) command_dir = coords_to_dir(y, x);
2269 #endif /* ALLOW_EASY_DISARM -- TNB */
2271 /* Allow repeated command */
2274 /* Set repeat count */
2275 command_rep = command_arg - 1;
2277 /* Redraw the state */
2278 p_ptr->redraw |= (PR_STATE);
2280 /* Cancel the arg */
2284 /* Get a direction (or abort) */
2285 if (get_rep_dir(&dir,TRUE))
2294 /* Get grid and contents */
2295 c_ptr = &cave[y][x];
2297 /* Feature code (applying "mimic" field) */
2298 feat = get_feat_mimic(c_ptr);
2300 /* Check for chests */
2301 o_idx = chest_check(y, x, TRUE);
2304 if (!is_trap(feat) && !o_idx)
2308 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2310 msg_print("You see nothing there to disarm.");
2315 /* Monster in the way */
2316 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2320 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2322 msg_print("There is a monster in the way!");
2333 /* Disarm the chest */
2334 more = do_cmd_disarm_chest(y, x, o_idx);
2340 /* Disarm the trap */
2341 more = do_cmd_disarm_aux(y, x, dir);
2345 /* Cancel repeat unless told not to */
2346 if (!more) disturb(0, 0);
2351 * @brief ¡ÖÂǤÁÇˤë¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
2352 * Perform the basic "bash" command
2353 * @param y Âоݤò¹Ô¤¦¥Þ¥¹¤ÎYºÂɸ
2354 * @param x Âоݤò¹Ô¤¦¥Þ¥¹¤ÎXºÂɸ
2355 * @param dir ¥×¥ì¥¤¥ä¡¼¤«¤é¸«¤¿¥¿¡¼¥²¥Ã¥È¤ÎÊý³ÑID
2356 * @return ¼ÂºÝ¤Ë½èÍý¤¬¹Ô¤ï¤ì¤¿¾ì¹çTRUE¤òÊÖ¤¹¡£
2359 * Assume destination is a closed/locked/jammed door
2360 * Assume there is no monster blocking the destination
2361 * Returns TRUE if repeated commands may continue
2364 static bool do_cmd_bash_aux(int y, int x, int dir)
2367 cave_type *c_ptr = &cave[y][x];
2370 feature_type *f_ptr = &f_info[c_ptr->feat];
2372 /* Hack -- Bash power based on strength */
2373 /* (Ranges from 3 to 20 to 100 to 200) */
2374 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2376 /* Extract door power */
2377 int temp = f_ptr->power;
2381 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2388 msg_format("%s¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª", name);
2390 msg_format("You smash into the %s!", name);
2393 /* Compare bash power to door power XXX XXX XXX */
2394 temp = (bash - (temp * 10));
2396 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2398 /* Hack -- always have a chance */
2399 if (temp < 1) temp = 1;
2401 /* Hack -- attempt to bash down the door */
2402 if (randint0(100) < temp)
2406 msg_format("%s¤ò²õ¤·¤¿¡ª", name);
2408 msg_format("The %s crashes open!", name);
2412 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
2414 /* Break down the door */
2415 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
2417 cave_alter_feat(y, x, FF_BASH);
2423 cave_alter_feat(y, x, FF_OPEN);
2426 /* Hack -- Fall through the door */
2427 move_player(dir, FALSE, FALSE);
2430 /* Saving throw against stun */
2431 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2436 msg_format("¤³¤Î%s¤Ï´è¾æ¤À¡£", name);
2438 msg_format("The %s holds firm.", name);
2442 /* Allow repeated bashing */
2446 /* High dexterity yields coolness */
2451 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2453 msg_print("You are off-balance.");
2457 /* Hack -- Lose balance ala paralysis */
2458 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2467 * @brief ¡ÖÂǤÁÇˤë¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2468 * Bash open a door, success based on character strength
2472 * For a closed door, pval is positive if locked; negative if stuck.
2474 * For an open door, pval is positive for a broken door.
2476 * A closed door can be opened - harder if locked. Any door might be
2477 * bashed open (and thereby broken). Bashing a door is (potentially)
2478 * faster! You move into the door way. To open a stuck door, it must
2479 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2481 * Creatures can also open or bash doors, see elsewhere.
2484 void do_cmd_bash(void)
2493 if (p_ptr->special_defense & KATA_MUSOU)
2495 set_action(ACTION_NONE);
2498 /* Allow repeated command */
2501 /* Set repeat count */
2502 command_rep = command_arg - 1;
2504 /* Redraw the state */
2505 p_ptr->redraw |= (PR_STATE);
2507 /* Cancel the arg */
2511 /* Get a "repeated" direction */
2512 if (get_rep_dir(&dir,FALSE))
2521 c_ptr = &cave[y][x];
2523 /* Feature code (applying "mimic" field) */
2524 feat = get_feat_mimic(c_ptr);
2526 /* Nothing useful */
2527 if (!have_flag(f_info[feat].flags, FF_BASH))
2531 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2533 msg_print("You see nothing there to bash.");
2538 /* Monster in the way */
2539 else if (c_ptr->m_idx)
2546 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2548 msg_print("There is a monster in the way!");
2556 /* Bash a closed door */
2560 more = do_cmd_bash_aux(y, x, dir);
2564 /* Unless valid action taken, cancel bash */
2565 if (!more) disturb(0, 0);
2570 * @brief ÆÃÄê¤Î¥Þ¥¹¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¤¿¤á¤ÎÈÆÍÑŪ¥³¥Þ¥ó¥É
2574 * Manipulate an adjacent grid in some way
2576 * Attack monsters, tunnel through walls, disarm traps, open doors.
2578 * Consider confusion XXX XXX XXX
2580 * This command must always take a turn, to prevent free detection
2581 * of invisible monsters.
2584 void do_cmd_alter(void)
2593 if (p_ptr->special_defense & KATA_MUSOU)
2595 set_action(ACTION_NONE);
2598 /* Allow repeated command */
2601 /* Set repeat count */
2602 command_rep = command_arg - 1;
2604 /* Redraw the state */
2605 p_ptr->redraw |= (PR_STATE);
2607 /* Cancel the arg */
2611 /* Get a direction */
2612 if (get_rep_dir(&dir,TRUE))
2615 feature_type *f_ptr;
2622 c_ptr = &cave[y][x];
2624 /* Feature code (applying "mimic" field) */
2625 feat = get_feat_mimic(c_ptr);
2626 f_ptr = &f_info[feat];
2631 /* Attack monsters */
2639 else if (have_flag(f_ptr->flags, FF_OPEN))
2641 more = do_cmd_open_aux(y, x);
2644 /* Bash jammed doors */
2645 else if (have_flag(f_ptr->flags, FF_BASH))
2647 more = do_cmd_bash_aux(y, x, dir);
2650 /* Tunnel through walls */
2651 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2653 more = do_cmd_tunnel_aux(y, x);
2656 /* Close open doors */
2657 else if (have_flag(f_ptr->flags, FF_CLOSE))
2659 more = do_cmd_close_aux(y, x);
2663 else if (have_flag(f_ptr->flags, FF_DISARM))
2665 more = do_cmd_disarm_aux(y, x, dir);
2673 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2675 msg_print("You attack the empty air.");
2681 /* Cancel repetition unless we can continue */
2682 if (!more) disturb(0, 0);
2688 * @brief ¡Ö¤¯¤µ¤Ó¤òÂǤġפ¿¤á¤ËɬÍפʥª¥Ö¥¸¥§¥¯¥È¤¬¤¢¤ë¤«¤É¤¦¤«¤ÎȽÄê¤òÊÖ¤¹ /
2689 * Find the index of some "spikes", if possible.
2690 * @param ip ¤¯¤µ¤Ó¤È¤·¤ÆÂǤƤ륪¥Ö¥¸¥§¥¯¥È¤ÎID
2691 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤¬¤¢¤ë¾ì¹çTRUE¤òÊÖ¤¹
2694 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2697 static bool get_spike(int *ip)
2701 /* Check every item in the pack */
2702 for (i = 0; i < INVEN_PACK; i++)
2704 object_type *o_ptr = &inventory[i];
2706 /* Skip non-objects */
2707 if (!o_ptr->k_idx) continue;
2709 /* Check the "tval" code */
2710 if (o_ptr->tval == TV_SPIKE)
2712 /* Save the spike index */
2726 * @brief ¡Ö¤¯¤µ¤Ó¤òÂǤġ×Æ°ºî¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2727 * Jam a closed door with a spike
2731 * This command may NOT be repeated
2734 void do_cmd_spike(void)
2738 if (p_ptr->special_defense & KATA_MUSOU)
2740 set_action(ACTION_NONE);
2743 /* Get a "repeated" direction */
2744 if (get_rep_dir(&dir,FALSE))
2754 /* Get grid and contents */
2755 c_ptr = &cave[y][x];
2757 /* Feature code (applying "mimic" field) */
2758 feat = get_feat_mimic(c_ptr);
2760 /* Require closed door */
2761 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2765 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2767 msg_print("You see nothing there to spike.");
2773 else if (!get_spike(&item))
2777 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2779 msg_print("You have no spikes!");
2783 /* Is a monster in the way? */
2784 else if (c_ptr->m_idx)
2791 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2793 msg_print("There is a monster in the way!");
2806 /* Successful jamming */
2808 msg_format("%s¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£", f_name + f_info[feat].name);
2810 msg_format("You jam the %s with a spike.", f_name + f_info[feat].name);
2813 cave_alter_feat(y, x, FF_SPIKE);
2815 /* Use up, and describe, a single spike, from the bottom */
2816 inven_item_increase(item, -1);
2817 inven_item_describe(item);
2818 inven_item_optimize(item);
2826 * @brief ¡ÖÊ⤯¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2827 * Support code for the "Walk" and "Jump" commands
2828 * @param pickup ¥¢¥¤¥Æ¥à¤Î¼«Æ°½¦¤¤¤ò¹Ô¤¦¤Ê¤éTRUE
2831 void do_cmd_walk(bool pickup)
2838 /* Allow repeated command */
2841 /* Set repeat count */
2842 command_rep = command_arg - 1;
2844 /* Redraw the state */
2845 p_ptr->redraw |= (PR_STATE);
2847 /* Cancel the arg */
2851 /* Get a "repeated" direction */
2852 if (get_rep_dir(&dir,FALSE))
2857 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2859 set_action(ACTION_NONE);
2862 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2863 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2864 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2866 /* Actually move the character */
2867 move_player(dir, pickup, FALSE);
2869 /* Allow more walking */
2873 /* Hack again -- Is there a special encounter ??? */
2874 if (p_ptr->wild_mode && !cave_have_flag_bold(py, px, FF_TOWN))
2876 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2879 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2881 /* Inform the player of his horrible fate :=) */
2883 msg_print("½±·â¤À¡ª");
2885 msg_print("You are ambushed !");
2888 /* Go into large wilderness view */
2889 p_ptr->oldpy = randint1(MAX_HGT-2);
2890 p_ptr->oldpx = randint1(MAX_WID-2);
2893 /* Give first move to monsters */
2896 /* HACk -- set the encouter flag for the wilderness generation */
2897 generate_encounter = TRUE;
2901 /* Cancel repeat unless we may continue */
2902 if (!more) disturb(0, 0);
2907 * @brief ¡ÖÁö¤ë¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2911 void do_cmd_run(void)
2915 /* Hack -- no running when confused */
2916 if (p_ptr->confused)
2919 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2921 msg_print("You are too confused!");
2927 if (p_ptr->special_defense & KATA_MUSOU)
2929 set_action(ACTION_NONE);
2932 /* Get a "repeated" direction */
2933 if (get_rep_dir(&dir,FALSE))
2935 /* Hack -- Set the run counter */
2936 running = (command_arg ? command_arg : 1000);
2945 * @brief ¡Öα¤Þ¤ë¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2946 * Stay still. Search. Enter stores.
2947 * Pick up treasure if "pickup" is true.
2948 * @param pickup ¥¢¥¤¥Æ¥à¤Î¼«Æ°½¦¤¤¤ò¹Ô¤¦¤Ê¤éTRUE
2951 void do_cmd_stay(bool pickup)
2953 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2955 /* Allow repeated command */
2958 /* Set repeat count */
2959 command_rep = command_arg - 1;
2961 /* Redraw the state */
2962 p_ptr->redraw |= (PR_STATE);
2964 /* Cancel the arg */
2971 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2972 (void)move_player_effect(py, px, mpe_mode);
2977 * @brief ¡ÖµÙ¤à¡×Æ°ºî¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2978 * Resting allows a player to safely restore his hp -RAK-
2981 void do_cmd_rest(void)
2984 set_action(ACTION_NONE);
2986 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
2992 if (hex_spelling_any()) stop_hex_spell_all();
2994 /* Prompt for time if needed */
2995 if (command_arg <= 0)
2998 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3000 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3007 strcpy(out_val, "&");
3009 /* Ask for duration */
3010 if (!get_string(p, out_val, 4)) return;
3012 /* Rest until done */
3013 if (out_val[0] == '&')
3019 else if (out_val[0] == '*')
3027 command_arg = atoi(out_val);
3028 if (command_arg <= 0) return;
3034 if (command_arg > 9999) command_arg = 9999;
3036 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3038 /* Take a turn XXX XXX XXX (?) */
3041 /* The sin of sloth */
3042 if (command_arg > 100)
3043 chg_virtue(V_DILIGENCE, -1);
3045 /* Why are you sleeping when there's no need? WAKE UP!*/
3046 if ((p_ptr->chp == p_ptr->mhp) &&
3047 (p_ptr->csp == p_ptr->msp) &&
3048 !p_ptr->blind && !p_ptr->confused &&
3049 !p_ptr->poisoned && !p_ptr->afraid &&
3050 !p_ptr->stun && !p_ptr->cut &&
3051 !p_ptr->slow && !p_ptr->paralyzed &&
3052 !p_ptr->image && !p_ptr->word_recall &&
3053 !p_ptr->alter_reality)
3054 chg_virtue(V_DILIGENCE, -1);
3056 /* Save the rest code */
3057 resting = command_arg;
3058 p_ptr->action = ACTION_REST;
3060 /* Recalculate bonuses */
3061 p_ptr->update |= (PU_BONUS);
3063 /* Redraw the state */
3064 p_ptr->redraw |= (PR_STATE);
3075 * @brief ÌðÃƤò¼Í·â¤·¤¿¾ì¹ç¤ÎÇË»³ÎΨ¤òÊÖ¤¹ /
3076 * Determines the odds of an object breaking when thrown at a monster
3077 * @param o_ptr ÌðÃƤΥª¥Ö¥¸¥§¥¯¥È¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
3078 * @return ÇË»³ÎΨ(%)
3080 * Note that artifacts never break, see the "drop_near()" function.
3082 static int breakage_chance(object_type *o_ptr)
3084 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3086 /* Examine the snipe type */
3089 if (snipe_type == SP_KILL_WALL) return (100);
3090 if (snipe_type == SP_EXPLODE) return (100);
3091 if (snipe_type == SP_PIERCE) return (100);
3092 if (snipe_type == SP_FINAL) return (100);
3093 if (snipe_type == SP_NEEDLE) return (100);
3094 if (snipe_type == SP_EVILNESS) return (40);
3095 if (snipe_type == SP_HOLYNESS) return (40);
3098 /* Examine the item type */
3099 switch (o_ptr->tval)
3115 /* Sometimes break */
3120 return (20 - archer_bonus * 2);
3125 return (10 - archer_bonus);
3133 * @brief ÌðÃƤò¼Í·â¤·¤¿ºÝ¤Î¥¹¥ì¥¤ÇÜΨ¤ò¤«¤±¤¿·ë²Ì¤òÊÖ¤¹ /
3134 * Determines the odds of an object breaking when thrown at a monster
3135 * @param o_ptr ÌðÃƤΥª¥Ö¥¸¥§¥¯¥È¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
3136 * @param tdam ·×»»ÅÓÃæ¤Î¥À¥á¡¼¥¸ÎÌ
3137 * @param m_ptr ÌÜɸ¥â¥ó¥¹¥¿¡¼¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
3138 * @return ¥¹¥ì¥¤ÇÜΨ¤ò¤«¤±¤¿¥À¥á¡¼¥¸ÎÌ
3140 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3144 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3146 u32b flgs[TR_FLAG_SIZE];
3148 /* Extract the flags */
3149 object_flags(o_ptr, flgs);
3151 /* Some "weapons" and "ammo" do extra damage */
3152 switch (o_ptr->tval)
3159 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3160 (r_ptr->flags3 & RF3_ANIMAL))
3162 if (is_original_ap_and_seen(m_ptr))
3164 r_ptr->r_flags3 |= RF3_ANIMAL;
3167 if (mult < 17) mult = 17;
3171 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3172 (r_ptr->flags3 & RF3_ANIMAL))
3174 if (is_original_ap_and_seen(m_ptr))
3176 r_ptr->r_flags3 |= RF3_ANIMAL;
3179 if (mult < 27) mult = 27;
3183 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3184 (r_ptr->flags3 & RF3_EVIL))
3186 if (is_original_ap_and_seen(m_ptr))
3188 r_ptr->r_flags3 |= RF3_EVIL;
3191 if (mult < 15) mult = 15;
3195 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3196 (r_ptr->flags3 & RF3_EVIL))
3198 if (is_original_ap_and_seen(m_ptr))
3200 r_ptr->r_flags3 |= RF3_EVIL;
3203 if (mult < 25) mult = 25;
3207 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3208 (r_ptr->flags2 & RF2_HUMAN))
3210 if (is_original_ap_and_seen(m_ptr))
3212 r_ptr->r_flags2 |= RF2_HUMAN;
3215 if (mult < 17) mult = 17;
3219 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3220 (r_ptr->flags2 & RF2_HUMAN))
3222 if (is_original_ap_and_seen(m_ptr))
3224 r_ptr->r_flags2 |= RF2_HUMAN;
3227 if (mult < 27) mult = 27;
3231 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3232 (r_ptr->flags3 & RF3_UNDEAD))
3234 if (is_original_ap_and_seen(m_ptr))
3236 r_ptr->r_flags3 |= RF3_UNDEAD;
3239 if (mult < 20) mult = 20;
3243 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3244 (r_ptr->flags3 & RF3_UNDEAD))
3246 if (is_original_ap_and_seen(m_ptr))
3248 r_ptr->r_flags3 |= RF3_UNDEAD;
3251 if (mult < 30) mult = 30;
3255 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3256 (r_ptr->flags3 & RF3_DEMON))
3258 if (is_original_ap_and_seen(m_ptr))
3260 r_ptr->r_flags3 |= RF3_DEMON;
3263 if (mult < 20) mult = 20;
3267 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3268 (r_ptr->flags3 & RF3_DEMON))
3270 if (is_original_ap_and_seen(m_ptr))
3272 r_ptr->r_flags3 |= RF3_DEMON;
3275 if (mult < 30) mult = 30;
3279 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3280 (r_ptr->flags3 & RF3_ORC))
3282 if (is_original_ap_and_seen(m_ptr))
3284 r_ptr->r_flags3 |= RF3_ORC;
3287 if (mult < 20) mult = 20;
3291 if ((have_flag(flgs, TR_KILL_ORC)) &&
3292 (r_ptr->flags3 & RF3_ORC))
3294 if (is_original_ap_and_seen(m_ptr))
3296 r_ptr->r_flags3 |= RF3_ORC;
3299 if (mult < 30) mult = 30;
3303 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3304 (r_ptr->flags3 & RF3_TROLL))
3306 if (is_original_ap_and_seen(m_ptr))
3308 r_ptr->r_flags3 |= RF3_TROLL;
3311 if (mult < 20) mult = 20;
3315 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3316 (r_ptr->flags3 & RF3_TROLL))
3318 if (is_original_ap_and_seen(m_ptr))
3320 r_ptr->r_flags3 |= RF3_TROLL;
3323 if (mult < 30) mult = 30;
3327 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3328 (r_ptr->flags3 & RF3_GIANT))
3330 if (is_original_ap_and_seen(m_ptr))
3332 r_ptr->r_flags3 |= RF3_GIANT;
3335 if (mult < 20) mult = 20;
3339 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3340 (r_ptr->flags3 & RF3_GIANT))
3342 if (is_original_ap_and_seen(m_ptr))
3344 r_ptr->r_flags3 |= RF3_GIANT;
3347 if (mult < 30) mult = 30;
3351 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3352 (r_ptr->flags3 & RF3_DRAGON))
3354 if (is_original_ap_and_seen(m_ptr))
3356 r_ptr->r_flags3 |= RF3_DRAGON;
3359 if (mult < 20) mult = 20;
3362 /* Execute Dragon */
3363 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3364 (r_ptr->flags3 & RF3_DRAGON))
3366 if (is_original_ap_and_seen(m_ptr))
3368 r_ptr->r_flags3 |= RF3_DRAGON;
3371 if (mult < 30) mult = 30;
3373 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3374 (m_ptr->r_idx == MON_SMAUG) &&
3375 (inventory[INVEN_BOW].name1 == ART_BARD))
3380 if (have_flag(flgs, TR_BRAND_ACID))
3382 /* Notice immunity */
3383 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3385 if (is_original_ap_and_seen(m_ptr))
3387 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3391 /* Otherwise, take the damage */
3394 if (mult < 17) mult = 17;
3399 if (have_flag(flgs, TR_BRAND_ELEC))
3401 /* Notice immunity */
3402 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3404 if (is_original_ap_and_seen(m_ptr))
3406 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3410 /* Otherwise, take the damage */
3413 if (mult < 17) mult = 17;
3418 if (have_flag(flgs, TR_BRAND_FIRE))
3420 /* Notice immunity */
3421 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3423 if (is_original_ap_and_seen(m_ptr))
3425 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3429 /* Otherwise, take the damage */
3432 if (r_ptr->flags3 & RF3_HURT_FIRE)
3434 if (mult < 25) mult = 25;
3435 if (is_original_ap_and_seen(m_ptr))
3437 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3440 else if (mult < 17) mult = 17;
3445 if (have_flag(flgs, TR_BRAND_COLD))
3447 /* Notice immunity */
3448 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3450 if (is_original_ap_and_seen(m_ptr))
3452 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3455 /* Otherwise, take the damage */
3458 if (r_ptr->flags3 & RF3_HURT_COLD)
3460 if (mult < 25) mult = 25;
3461 if (is_original_ap_and_seen(m_ptr))
3463 r_ptr->r_flags3 |= RF3_HURT_COLD;
3466 else if (mult < 17) mult = 17;
3470 /* Brand (Poison) */
3471 if (have_flag(flgs, TR_BRAND_POIS))
3473 /* Notice immunity */
3474 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3476 if (is_original_ap_and_seen(m_ptr))
3478 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3482 /* Otherwise, take the damage */
3485 if (mult < 17) mult = 17;
3489 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3491 p_ptr->csp -= (1+(p_ptr->msp / 30));
3492 p_ptr->redraw |= (PR_MANA);
3493 mult = mult * 5 / 2;
3500 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
3502 /* Return the total damage */
3503 return (tdam * mult / 10);
3508 * @brief ¼Í·â½èÍý¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
3509 * Fire an object from the pack or floor.
3510 * @param item ¼Í·â¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î½ê»ýID
3511 * @param j_ptr ¼Í·âÉð´ï¤Î¥ª¥Ö¥¸¥§¥¯¥È»²¾È¥Ý¥¤¥ó¥¿
3515 * You may only fire items that "match" your missile launcher.
3517 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3519 * See "calc_bonuses()" for more calculations and such.
3521 * Note that "firing" a missile is MUCH better than "throwing" it.
3523 * Note: "unseen" monsters are very hard to hit.
3525 * Objects are more likely to break if they "attempt" to hit a monster.
3527 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3529 * The "extra shot" code works by decreasing the amount of energy
3530 * required to make each shot, spreading the shots out over time.
3532 * Note that when firing missiles, the launcher multiplier is applied
3533 * after all the bonuses are added in, making multipliers very useful.
3535 * Note that Bows of "Extra Might" get extra range and an extra bonus
3536 * for the damage multiplier.
3538 * Note that Bows of "Extra Shots" give an extra shot.
3541 void do_cmd_fire_aux(int item, object_type *j_ptr)
3544 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
3545 int tdam_base, tdis, thits, tmul;
3547 int cur_dis, visible;
3554 bool hit_body = FALSE;
3556 char o_name[MAX_NLEN];
3558 u16b path_g[512]; /* For calcuration of path length */
3560 int msec = delay_factor * delay_factor * delay_factor;
3563 bool stick_to = FALSE;
3565 /* Access the item (if in the pack) */
3568 o_ptr = &inventory[item];
3572 o_ptr = &o_list[0 - item];
3575 /* Sniper - Cannot shot a single arrow twice */
3576 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
3578 /* Describe the object */
3579 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3581 /* Use the proper number of shots */
3582 thits = p_ptr->num_fire;
3584 /* Use a base distance */
3587 /* Base damage from thrown object plus launcher bonus */
3588 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3590 /* Actually "fire" the object */
3591 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3592 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3593 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3595 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3597 energy_use = bow_energy(j_ptr->sval);
3598 tmul = bow_tmul(j_ptr->sval);
3600 /* Get extra "power" from "extra might" */
3601 if (p_ptr->xtra_might) tmul++;
3603 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3605 /* Boost the damage */
3610 tdis = 13 + tmul/80;
3611 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3614 tdis -= (5 - (p_ptr->concent + 1) / 2);
3619 project_length = tdis + 1;
3621 /* Get a direction (or cancel) */
3622 if (!get_aim_dir(&dir))
3626 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
3628 /* need not to reset project_length (already did)*/
3633 /* Predict the "target" location */
3634 tx = px + 99 * ddx[dir];
3635 ty = py + 99 * ddy[dir];
3637 /* Check for "target request" */
3638 if ((dir == 5) && target_okay())
3644 /* Get projection path length */
3645 tdis = project_path(path_g, project_length, py, px, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
3647 project_length = 0; /* reset to default */
3649 /* Don't shoot at my feet */
3650 if (tx == px && ty == py)
3654 /* project_length is already reset to 0 */
3660 /* Take a (partial) turn */
3661 energy_use = (energy_use / thits);
3664 /* Sniper - Difficult to shot twice at 1 turn */
3665 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
3667 /* Sniper - Repeat shooting when double shots */
3668 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
3671 /* Start at the player */
3675 /* Get local object */
3678 /* Obtain a local object */
3679 object_copy(q_ptr, o_ptr);
3684 /* Reduce and describe inventory */
3687 inven_item_increase(item, -1);
3688 inven_item_describe(item);
3689 inven_item_optimize(item);
3692 /* Reduce and describe floor item */
3695 floor_item_increase(0 - item, -1);
3696 floor_item_optimize(0 - item);
3702 /* Hack -- Handle stuff */
3705 /* Save the old location */
3709 /* The shot does not hit yet */
3712 /* Travel until stopped */
3713 for (cur_dis = 0; cur_dis <= tdis; )
3717 /* Hack -- Stop at the target */
3718 if ((y == ty) && (x == tx)) break;
3720 /* Calculate the new location (see "project()") */
3723 mmove2(&ny, &nx, py, px, ty, tx);
3726 if (snipe_type == SP_KILL_WALL)
3728 c_ptr = &cave[ny][nx];
3730 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3733 if (c_ptr->info & (CAVE_MARK)) msg_print("´ä¤¬ºÕ¤±»¶¤Ã¤¿¡£");
3735 if (c_ptr->info & (CAVE_MARK)) msg_print("Wall rocks were shattered.");
3737 /* Forget the wall */
3738 c_ptr->info &= ~(CAVE_MARK);
3740 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3742 /* Destroy the wall */
3743 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3750 /* Stopped by walls/doors */
3751 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3753 /* Advance the distance */
3757 if (snipe_type == SP_LITE)
3759 cave[ny][nx].info |= (CAVE_GLOW);
3768 /* The player can see the (on screen) missile */
3769 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3771 char c = object_char(q_ptr);
3772 byte a = object_attr(q_ptr);
3774 /* Draw, Hilite, Fresh, Pause, Erase */
3775 print_rel(c, a, ny, nx);
3776 move_cursor_relative(ny, nx);
3778 Term_xtra(TERM_XTRA_DELAY, msec);
3783 /* The player cannot see the missile */
3786 /* Pause anyway, for consistancy */
3787 Term_xtra(TERM_XTRA_DELAY, msec);
3791 if (snipe_type == SP_KILL_TRAP)
3793 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3794 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3798 if (snipe_type == SP_EVILNESS)
3800 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3809 /* Save the old location */
3813 /* Save the new location */
3818 /* Monster here, Try to hit it */
3819 if (cave[y][x].m_idx)
3822 cave_type *c_ptr = &cave[y][x];
3824 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3825 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3827 /* Check the visibility */
3828 visible = m_ptr->ml;
3830 /* Note the collision */
3833 if (MON_CSLEEP(m_ptr))
3835 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3836 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3839 if ((r_ptr->level + 10) > p_ptr->lev)
3841 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3842 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3845 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3846 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3847 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3848 else if (p_ptr->lev > 34) amount = 2;
3849 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3850 p_ptr->update |= (PU_BONUS);
3856 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3857 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3860 p_ptr->skill_exp[GINOU_RIDING] += 1;
3861 p_ptr->update |= (PU_BONUS);
3865 /* Some shots have hit bonus */
3869 armour *= (8 - p_ptr->concent);
3873 /* Did we hit it (penalize range) */
3874 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
3877 int tdam = tdam_base;
3879 /* Get extra damage from concentration */
3880 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3882 /* Handle unseen monster */
3885 /* Invisible monster */
3887 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3889 msg_format("The %s finds a mark.", o_name);
3894 /* Handle visible monster */
3899 /* Get "the monster" or "it" */
3900 monster_desc(m_name, m_ptr, 0);
3904 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3906 msg_format("The %s hits %s.", o_name, m_name);
3911 /* Hack -- Track this monster race */
3912 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3914 /* Hack -- Track this monster */
3915 health_track(c_ptr->m_idx);
3919 if (snipe_type == SP_NEEDLE)
3921 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3922 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3926 /* Get "the monster" or "it" */
3927 monster_desc(m_name, m_ptr, 0);
3929 tdam = m_ptr->hp + 1;
3931 msg_format("%s¤ÎµÞ½ê¤ËÆͤ»É¤µ¤Ã¤¿¡ª", m_name);
3933 msg_format("Your shot sticked on a fatal spot of %s!", m_name);
3940 /* Apply special damage XXX XXX XXX */
3941 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3942 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
3944 /* No negative damage */
3945 if (tdam < 0) tdam = 0;
3947 /* Modify the damage */
3948 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3951 /* Complex message */
3952 if (p_ptr->wizard || cheat_xtra)
3955 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3958 msg_format("You do %d (out of %d) damage.",
3965 if (snipe_type == SP_EXPLODE)
3967 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3969 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3970 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3975 if (snipe_type == SP_HOLYNESS)
3977 cave[ny][nx].info |= (CAVE_GLOW);
3986 /* Hit the monster, check for death */
3987 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3996 if (object_is_fixed_artifact(q_ptr) &&
3997 (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0))
4001 monster_desc(m_name, m_ptr, 0);
4005 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
4007 msg_format("%^s have stuck into %s!",o_name, m_name);
4012 message_pain(c_ptr->m_idx, tdam);
4014 /* Anger the monster */
4015 if (tdam > 0) anger_monster(m_ptr);
4018 if (fear && m_ptr->ml)
4025 /* Get the monster name (or "it") */
4026 monster_desc(m_name, m_ptr, 0);
4030 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4032 msg_format("%^s flees in terror!", m_name);
4037 set_target(m_ptr, py, px);
4040 if (snipe_type == SP_RUSH)
4042 int n = randint1(5) + 3;
4043 int m_idx = c_ptr->m_idx;
4045 for ( ; cur_dis <= tdis; )
4052 /* Calculate the new location (see "project()") */
4053 mmove2(&ny, &nx, py, px, ty, tx);
4055 /* Stopped by wilderness boundary */
4056 if (!in_bounds2(ny, nx)) break;
4058 /* Stopped by walls/doors */
4059 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
4061 /* Stopped by monsters */
4062 if (!cave_empty_bold(ny, nx)) break;
4064 cave[ny][nx].m_idx = m_idx;
4065 cave[oy][ox].m_idx = 0;
4070 /* Update the monster (new location) */
4071 update_mon(c_ptr->m_idx, TRUE);
4077 Term_xtra(TERM_XTRA_DELAY, msec);
4089 if (snipe_type == SP_PIERCE)
4091 if(p_ptr->concent < 1) break;
4101 /* Chance of breakage (during attacks) */
4102 j = (hit_body ? breakage_chance(q_ptr) : 0);
4106 int m_idx = cave[y][x].m_idx;
4107 monster_type *m_ptr = &m_list[m_idx];
4108 int o_idx = o_pop();
4113 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
4115 msg_format("The %s have gone to somewhere.", o_name);
4117 if (object_is_fixed_artifact(q_ptr))
4119 a_info[j_ptr->name1].cur_num = 0;
4124 o_ptr = &o_list[o_idx];
4125 object_copy(o_ptr, q_ptr);
4128 o_ptr->marked &= OM_TOUCHED;
4130 /* Forget location */
4131 o_ptr->iy = o_ptr->ix = 0;
4133 /* Memorize monster */
4134 o_ptr->held_m_idx = m_idx;
4137 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4140 m_ptr->hold_o_idx = o_idx;
4142 else if (cave_have_flag_bold(y, x, FF_PROJECT))
4144 /* Drop (or break) near that location */
4145 (void)drop_near(q_ptr, j, y, x);
4149 /* Drop (or break) near that location */
4150 (void)drop_near(q_ptr, j, prev_y, prev_x);
4153 /* Sniper - Repeat shooting when double shots */
4156 /* Sniper - Loose his/her concentration after any shot */
4157 if (p_ptr->concent) reset_concentration(FALSE);
4161 * @brief ¼Í·â½èÍý¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
4164 void do_cmd_fire(void)
4170 is_fired = FALSE; /* not fired yet */
4172 /* Get the "bow" (if any) */
4173 j_ptr = &inventory[INVEN_BOW];
4175 /* Require a launcher */
4179 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4181 msg_print("You have nothing to fire with.");
4187 if (j_ptr->sval == SV_CRIMSON)
4190 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4192 msg_print("Do activate.");
4199 if (p_ptr->special_defense & KATA_MUSOU)
4201 set_action(ACTION_NONE);
4204 /* Require proper missile */
4205 item_tester_tval = p_ptr->tval_ammo;
4209 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4210 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4212 q = "Fire which item? ";
4213 s = "You have nothing to fire.";
4216 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4223 do_cmd_fire_aux(item, j_ptr);
4225 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
4227 /* Sniper actions after some shootings */
4228 if (snipe_type == SP_AWAY)
4230 teleport_player(10 + (p_ptr->concent * 2), 0L);
4232 if (snipe_type == SP_FINAL)
4235 msg_print("¼Í·â¤ÎÈ¿Æ°¤¬ÂΤò½±¤Ã¤¿¡£");
4237 msg_print("A reactionary of shooting attacked you. ");
4239 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
4240 (void)set_stun(p_ptr->stun + randint1(25));
4245 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬Åê¼Í²Äǽ¤ÊÉð´ï¤«¤É¤¦¤«¤òÊÖ¤¹¡£
4246 * @param o_ptr ȽÄꤹ¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
4247 * @return Åê¼Í²Äǽ¤ÊÉð´ï¤Ê¤é¤ÐTRUE
4249 static bool item_tester_hook_boomerang(object_type *o_ptr)
4251 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4259 * @brief Åê¼Í½èÍý¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
4260 * Throw an object from the pack or floor.
4261 * @param mult °ÒÎϤÎÇÜΨ
4262 * @param boomerang ¥Ö¡¼¥á¥é¥ó½èÍý¤Ê¤é¤ÐTRUE
4263 * @param shuriken Ǧ¼Ô¤Î¼ê΢·õ½èÍý¤Ê¤é¤ÐTRUE
4264 * @return ¥¿¡¼¥ó¤ò¾ÃÈñ¤·¤¿¾ì¹çTRUE¤òÊÖ¤¹
4267 * Note: "unseen" monsters are very hard to hit.
4269 * Should throwing a weapon do full damage? Should it allow the magic
4270 * to hit bonus of the weapon to have an effect? Should it ever cause
4271 * the item to be destroyed? Should it do any damage at all?
4274 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4277 int i, j, y, x, ty, tx, prev_y, prev_x;
4279 int chance, tdam, tdis;
4280 int mul, div, dd, ds;
4281 int cur_dis, visible;
4288 bool hit_body = FALSE;
4289 bool hit_wall = FALSE;
4290 bool equiped_item = FALSE;
4291 bool return_when_thrown = FALSE;
4293 char o_name[MAX_NLEN];
4295 int msec = delay_factor * delay_factor * delay_factor;
4297 u32b flgs[TR_FLAG_SIZE];
4299 bool come_back = FALSE;
4300 bool do_drop = TRUE;
4303 if (p_ptr->special_defense & KATA_MUSOU)
4305 set_action(ACTION_NONE);
4314 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
4316 item_tester_hook = item_tester_hook_boomerang;
4318 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4319 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4321 q = "Throw which item? ";
4322 s = "You have nothing to throw.";
4325 if (!get_item(&item, q, s, (USE_EQUIP)))
4331 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
4332 else item = INVEN_RARM;
4338 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4339 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4341 q = "Throw which item? ";
4342 s = "You have nothing to throw.";
4345 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4352 /* Access the item (if in the pack) */
4355 o_ptr = &inventory[item];
4359 o_ptr = &o_list[0 - item];
4363 /* Item is cursed */
4364 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
4368 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4370 msg_print("Hmmm, it seems to be cursed.");
4377 if (p_ptr->inside_arena && !boomerang)
4379 if (o_ptr->tval != TV_SPIKE)
4382 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4384 msg_print("You're in the arena now. This is hand-to-hand!");
4393 /* Get local object */
4396 /* Obtain a local object */
4397 object_copy(q_ptr, o_ptr);
4399 /* Extract the thrown object's flags. */
4400 object_flags(q_ptr, flgs);
4401 torch_flags(q_ptr, flgs);
4403 /* Distribute the charges of rods/wands between the stacks */
4404 distribute_charges(o_ptr, q_ptr, 1);
4410 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
4412 if (p_ptr->mighty_throw) mult += 3;
4414 /* Extract a "distance multiplier" */
4415 /* Changed for 'launcher' mutation */
4416 mul = 10 + 2 * (mult - 1);
4418 /* Enforce a minimum "weight" of one pound */
4419 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4420 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4422 /* Hack -- Distance -- Reward strength, penalize weight */
4423 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4425 /* Max distance of 10-18 */
4426 if (tdis > mul) tdis = mul;
4430 ty = randint0(101)-50+py;
4431 tx = randint0(101)-50+px;
4435 project_length = tdis + 1;
4437 /* Get a direction (or cancel) */
4438 if (!get_aim_dir(&dir)) return FALSE;
4440 /* Predict the "target" location */
4441 tx = px + 99 * ddx[dir];
4442 ty = py + 99 * ddy[dir];
4444 /* Check for "target request" */
4445 if ((dir == 5) && target_okay())
4451 project_length = 0; /* reset to default */
4454 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4455 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4456 return_when_thrown = TRUE;
4458 /* Reduce and describe inventory */
4461 inven_item_increase(item, -1);
4462 if (!return_when_thrown)
4463 inven_item_describe(item);
4464 inven_item_optimize(item);
4467 /* Reduce and describe floor item */
4470 floor_item_increase(0 - item, -1);
4471 floor_item_optimize(0 - item);
4473 if (item >= INVEN_RARM)
4475 equiped_item = TRUE;
4476 p_ptr->redraw |= (PR_EQUIPPY);
4482 /* Rogue and Ninja gets bonus */
4483 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4484 energy_use -= p_ptr->lev;
4486 /* Start at the player */
4491 /* Hack -- Handle stuff */
4494 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4495 else shuriken = FALSE;
4497 /* Chance of hitting */
4498 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4499 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4500 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4502 if (shuriken) chance *= 2;
4504 /* Save the old location */
4508 /* Travel until stopped */
4509 for (cur_dis = 0; cur_dis <= tdis; )
4511 /* Hack -- Stop at the target */
4512 if ((y == ty) && (x == tx)) break;
4514 /* Calculate the new location (see "project()") */
4517 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4519 /* Stopped by walls/doors */
4520 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
4523 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
4526 /* The player can see the (on screen) missile */
4527 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
4529 char c = object_char(q_ptr);
4530 byte a = object_attr(q_ptr);
4532 /* Draw, Hilite, Fresh, Pause, Erase */
4533 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
4534 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
4536 Term_xtra(TERM_XTRA_DELAY, msec);
4537 lite_spot(ny[cur_dis], nx[cur_dis]);
4541 /* The player cannot see the missile */
4544 /* Pause anyway, for consistancy */
4545 Term_xtra(TERM_XTRA_DELAY, msec);
4548 /* Save the old location */
4552 /* Save the new location */
4556 /* Advance the distance */
4559 /* Monster here, Try to hit it */
4560 if (cave[y][x].m_idx)
4562 cave_type *c_ptr = &cave[y][x];
4564 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4565 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4567 /* Check the visibility */
4568 visible = m_ptr->ml;
4570 /* Note the collision */
4573 /* Did we hit it (penalize range) */
4574 if (test_hit_fire(chance - cur_dis, m_ptr, m_ptr->ml, o_name))
4578 /* Handle unseen monster */
4581 /* Invisible monster */
4583 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4585 msg_format("The %s finds a mark.", o_name);
4590 /* Handle visible monster */
4595 /* Get "the monster" or "it" */
4596 monster_desc(m_name, m_ptr, 0);
4600 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4602 msg_format("The %s hits %s.", o_name, m_name);
4607 /* Hack -- Track this monster race */
4608 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
4610 /* Hack -- Track this monster */
4611 health_track(c_ptr->m_idx);
4615 /* Hack -- Base damage from thrown object */
4618 torch_dice(q_ptr, &dd, &ds); /* throwing a torch */
4619 tdam = damroll(dd, ds);
4620 /* Apply special damage XXX XXX XXX */
4621 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4622 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam);
4623 if (q_ptr->to_d > 0)
4624 tdam += q_ptr->to_d;
4626 tdam += -q_ptr->to_d;
4630 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4631 tdam += p_ptr->to_d_m;
4633 else if (have_flag(flgs, TR_THROW))
4636 tdam += p_ptr->to_d_m;
4644 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4647 /* No negative damage */
4648 if (tdam < 0) tdam = 0;
4650 /* Modify the damage */
4651 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4653 /* Complex message */
4657 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4660 msg_format("You do %d (out of %d) damage.",
4666 /* Hit the monster, check for death */
4667 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4676 message_pain(c_ptr->m_idx, tdam);
4678 /* Anger the monster */
4679 if ((tdam > 0) && !object_is_potion(q_ptr))
4680 anger_monster(m_ptr);
4683 if (fear && m_ptr->ml)
4690 /* Get the monster name (or "it") */
4691 monster_desc(m_name, m_ptr, 0);
4695 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4697 msg_format("%^s flees in terror!", m_name);
4709 /* decrease toach's fuel */
4710 if (hit_body) torch_lost_fuel(q_ptr);
4712 /* Chance of breakage (during attacks) */
4713 j = (hit_body ? breakage_chance(q_ptr) : 0);
4715 /* Figurines transform */
4716 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4720 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4721 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
4723 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4725 msg_print("The Figurine writhes and then shatters.");
4728 else if (object_is_cursed(q_ptr))
4730 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4732 msg_print("You have a bad feeling about this.");
4738 /* Potions smash open */
4739 if (object_is_potion(q_ptr))
4741 if (hit_body || hit_wall || (randint1(100) < j))
4745 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4747 msg_format("The %s shatters!", o_name);
4751 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4753 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4755 /* ToDo (Robert): fix the invulnerability */
4756 if (cave[y][x].m_idx &&
4757 is_friendly(&m_list[cave[y][x].m_idx]) &&
4758 !MON_INVULNER(m_ptr))
4761 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4763 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4765 msg_format("%^s gets angry!", m_name);
4768 set_hostile(&m_list[cave[y][x].m_idx]);
4779 if (return_when_thrown)
4781 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4782 char o2_name[MAX_NLEN];
4783 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4786 if (boomerang) back_chance += 4+randint1(5);
4787 if (super_boomerang) back_chance += 100;
4788 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4790 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4792 for (i = cur_dis - 1; i > 0; i--)
4794 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4796 char c = object_char(q_ptr);
4797 byte a = object_attr(q_ptr);
4799 /* Draw, Hilite, Fresh, Pause, Erase */
4800 print_rel(c, a, ny[i], nx[i]);
4801 move_cursor_relative(ny[i], nx[i]);
4803 Term_xtra(TERM_XTRA_DELAY, msec);
4804 lite_spot(ny[i], nx[i]);
4809 /* Pause anyway, for consistancy */
4810 Term_xtra(TERM_XTRA_DELAY, msec);
4813 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4816 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4818 msg_format("%s comes back to you.", o2_name);
4827 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4829 msg_format("%s backs, but you can't catch!", o2_name);
4835 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4837 msg_format("%s comes back.", o2_name);
4847 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4849 msg_format("%s doesn't back!", o2_name);
4856 if (item == INVEN_RARM || item == INVEN_LARM)
4858 /* Access the wield slot */
4859 o_ptr = &inventory[item];
4861 /* Wear the new stuff */
4862 object_copy(o_ptr, q_ptr);
4864 /* Increase the weight */
4865 p_ptr->total_weight += q_ptr->weight;
4867 /* Increment the equip counter by hand */
4870 /* Recalculate bonuses */
4871 p_ptr->update |= (PU_BONUS);
4873 /* Recalculate torch */
4874 p_ptr->update |= (PU_TORCH);
4876 /* Recalculate mana XXX */
4877 p_ptr->update |= (PU_MANA);
4880 p_ptr->window |= (PW_EQUIP);
4888 else if (equiped_item)
4894 /* Drop (or break) near that location */
4897 if (cave_have_flag_bold(y, x, FF_PROJECT))
4899 /* Drop (or break) near that location */
4900 (void)drop_near(q_ptr, j, y, x);
4904 /* Drop (or break) near that location */
4905 (void)drop_near(q_ptr, j, prev_y, prev_x);
4914 * @brief Åê¼Í½èÍý¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
4915 * Throw an object from the pack or floor.
4918 void do_cmd_throw(void)
4920 do_cmd_throw_aux(1, FALSE, -1);
4926 * Hack: travel command
4928 #define TRAVEL_UNABLE 9999
4930 static int flow_head = 0;
4931 static int flow_tail = 0;
4932 static s16b temp2_x[MAX_SHORT];
4933 static s16b temp2_y[MAX_SHORT];
4935 /* Hack: forget the "flow" information */
4936 void forget_travel_flow(void)
4940 /* Check the entire dungeon */
4941 for (y = 0; y < cur_hgt; y++)
4943 for (x = 0; x < cur_wid; x++)
4945 /* Forget the old data */
4946 travel.cost[y][x] = MAX_SHORT;
4950 travel.y = travel.x = 0;
4953 static int travel_flow_cost(int y, int x)
4955 feature_type *f_ptr = &f_info[cave[y][x].feat];
4958 /* Avoid obstacles (ex. trees) */
4959 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4962 if (have_flag(f_ptr->flags, FF_WATER))
4964 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4968 if (have_flag(f_ptr->flags, FF_LAVA))
4971 if (!p_ptr->resist_fire) lava *= 2;
4972 if (!p_ptr->levitation) lava *= 2;
4973 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4978 /* Detected traps and doors */
4979 if (cave[y][x].info & (CAVE_MARK))
4981 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4982 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4988 static void travel_flow_aux(int y, int x, int n, bool wall)
4990 cave_type *c_ptr = &cave[y][x];
4991 feature_type *f_ptr = &f_info[c_ptr->feat];
4992 int old_head = flow_head;
4994 int base_cost = (n % TRAVEL_UNABLE);
4995 int from_wall = (n / TRAVEL_UNABLE);
4998 /* Ignore out of bounds */
4999 if (!in_bounds(y, x)) return;
5001 /* Ignore unknown grid except in wilderness */
5002 if (dun_level > 0 && !(c_ptr->info & CAVE_KNOWN)) return;
5004 /* Ignore "walls" and "rubble" (include "secret doors") */
5005 if (have_flag(f_ptr->flags, FF_WALL) ||
5006 have_flag(f_ptr->flags, FF_CAN_DIG) ||
5007 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
5008 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
5010 if (!wall || !from_wall) return;
5011 add_cost += TRAVEL_UNABLE;
5015 add_cost = travel_flow_cost(y, x);
5018 cost = base_cost + add_cost;
5020 /* Ignore lower cost entries */
5021 if (travel.cost[y][x] <= cost) return;
5023 /* Save the flow cost */
5024 travel.cost[y][x] = cost;
5026 /* Enqueue that entry */
5027 temp2_y[flow_head] = y;
5028 temp2_x[flow_head] = x;
5030 /* Advance the queue */
5031 if (++flow_head == MAX_SHORT) flow_head = 0;
5033 /* Hack -- notice overflow by forgetting new entry */
5034 if (flow_head == flow_tail) flow_head = old_head;
5040 static void travel_flow(int ty, int tx)
5044 feature_type *f_ptr = &f_info[cave[py][px].feat];
5046 /* Reset the "queue" */
5047 flow_head = flow_tail = 0;
5049 /* is player in the wall? */
5050 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
5052 /* Start at the target grid */
5053 travel_flow_aux(ty, tx, 0, wall);
5055 /* Now process the queue */
5056 while (flow_head != flow_tail)
5058 /* Extract the next entry */
5059 y = temp2_y[flow_tail];
5060 x = temp2_x[flow_tail];
5062 /* Forget that entry */
5063 if (++flow_tail == MAX_SHORT) flow_tail = 0;
5065 /* Ignore too far entries */
5066 //if (distance(ty, tx, y, x) > 100) continue;
5068 /* Add the "children" */
5069 for (d = 0; d < 8; d++)
5071 /* Add that child if "legal" */
5072 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
5076 /* Forget the flow info */
5077 flow_head = flow_tail = 0;
5081 * @brief ¥È¥é¥Ù¥ë½èÍý¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
5084 void do_cmd_travel(void)
5088 feature_type *f_ptr;
5090 if (travel.x != 0 && travel.y != 0 &&
5091 get_check(_("¥È¥é¥Ù¥ë¤ò·Ñ³¤·¤Þ¤¹¤«¡©", "Do you continue to travel?")))
5096 else if (!tgt_pt(&x, &y)) return;
5098 if ((x == px) && (y == py))
5101 msg_print("¤¹¤Ç¤Ë¤½¤³¤Ë¤¤¤Þ¤¹¡ª");
5103 msg_print("You are already there!!");
5108 f_ptr = &f_info[cave[y][x].feat];
5110 if ((cave[y][x].info & CAVE_MARK) &&
5111 (have_flag(f_ptr->flags, FF_WALL) ||
5112 have_flag(f_ptr->flags, FF_CAN_DIG) ||
5113 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
5116 msg_print("¤½¤³¤Ë¤Ï¹Ô¤¯¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
5118 msg_print("You cannot travel there!");
5123 forget_travel_flow();
5129 /* Travel till 255 steps */
5135 /* Decides first direction */
5138 sx = ((x == px) || (dx < dy)) ? 0 : ((x > px) ? 1 : -1);
5139 sy = ((y == py) || (dy < dx)) ? 0 : ((y > py) ? 1 : -1);
5141 for (i = 1; i <= 9; i++)
5143 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;