3 /* Purpose: Movement commands (part 2) */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
19 void do_cmd_go_up(void)
25 if (p_ptr->special_defense & KATA_MUSOU)
27 set_action(ACTION_NONE);
31 c_ptr = &cave[py][px];
34 if (c_ptr->feat == FEAT_QUEST_UP)
38 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
39 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
41 msg_print("¾å¤Î³¬¤ËÅФä¿¡£");
43 msg_print("You enter the up staircase.");
49 p_ptr->inside_quest = c_ptr->special;
51 /* Activate the quest */
52 if (!quest[p_ptr->inside_quest].status)
54 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
58 if (!p_ptr->inside_quest)
64 p_ptr->leaving = TRUE;
65 p_ptr->leftbldg = TRUE;
70 /* Normal up stairs */
71 else if ((c_ptr->feat == FEAT_LESS) || (c_ptr->feat == FEAT_LESS_LESS))
82 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
84 if (get_check("Really leave the level? "))
98 /* Hack -- take a turn */
101 if (autosave_l) do_cmd_save_game(TRUE);
103 if (p_ptr->inside_quest)
105 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
109 p_ptr->inside_quest = c_ptr->special;
113 if (c_ptr->feat == FEAT_LESS_LESS)
115 /* Create a way back */
116 create_down_stair = 2;
122 /* Create a way back */
123 create_down_stair = 1;
127 if (!c_ptr->special && dungeon_type && ((dun_level - up_num + 1) > d_info[dungeon_type].mindepth) && one_in_(13))
131 if (c_ptr->feat == FEAT_LESS_LESS) msg_print("Ť¤¹£Æ»¤ò¾å¤Ã¤¿¡£");
132 else msg_print("Ť¤³¬Ãʤò¾å¤Ã¤¿¡£");
134 msg_print("These were very long stairs.");
138 if (dun_level-up_num+1 == d_info[dungeon_type].mindepth) up_num = dun_level;
140 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
142 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "go up the stairs to");
148 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
149 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
150 else if (0 == dun_level)
151 msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
153 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
156 msg_print("You go back to the surface.");
158 msg_print("You enter a maze of up staircases.");
162 /* Leaving the dungeon to town */
163 if (!dun_level && dungeon_type)
165 p_ptr->leaving_dungeon = TRUE;
166 if (!vanilla_town && !lite_town)
168 p_ptr->wilderness_y = d_info[dungeon_type].dy;
169 p_ptr->wilderness_x = d_info[dungeon_type].dx;
171 p_ptr->recall_dungeon = dungeon_type;
174 if (!dun_level) dungeon_type = 0;
177 p_ptr->leaving = TRUE;
183 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
185 msg_print("I see no up staircase here.");
196 void do_cmd_go_down(void)
199 bool go_down = FALSE;
200 bool fall_trap = FALSE;
203 if (p_ptr->special_defense & KATA_MUSOU)
205 set_action(ACTION_NONE);
209 c_ptr = &cave[py][px];
211 if (c_ptr->feat == (FEAT_TRAP_TRAPDOOR)) fall_trap = TRUE;
213 /* Quest down stairs */
214 if (c_ptr->feat == FEAT_QUEST_DOWN)
217 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
218 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
220 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
222 msg_print("You enter the down staircase.");
228 p_ptr->inside_quest = c_ptr->special;
230 /* Activate the quest */
231 if (!quest[p_ptr->inside_quest].status)
233 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
236 /* Leaving a quest */
237 if (!p_ptr->inside_quest)
243 p_ptr->leaving = TRUE;
244 p_ptr->leftbldg = TRUE;
250 else if ((c_ptr->feat != FEAT_MORE) && (c_ptr->feat != FEAT_MORE_MORE) && (c_ptr->feat != FEAT_ENTRANCE) && !fall_trap)
253 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
255 msg_print("I see no down staircase here.");
264 if (ironman_downward && (c_ptr->special != DUNGEON_ANGBAND))
267 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
269 msg_print("The entrance of this dungeon is closed!");
273 if (!max_dlv[c_ptr->special])
276 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[c_ptr->special].name, d_info[c_ptr->special].mindepth);
277 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
279 msg_format("There is the entrance of %s (Danger level: %d)", d_name+d_info[c_ptr->special].name, d_info[c_ptr->special].mindepth);
280 if (!get_check("Do you really get in this dungeon? ")) return;
285 /* Save old player position */
288 dungeon_type = (byte)c_ptr->special;
295 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
297 if (get_check("Really leave the level? "))
311 /* Hack -- take a turn */
314 if (autosave_l) do_cmd_save_game(TRUE);
317 if (c_ptr->feat == FEAT_MORE_MORE) down_num += 2;
319 if (!quest_number(dun_level+down_num) && (dun_level < d_info[dungeon_type].maxdepth - 1 - down_num) && one_in_(13) && !fall_trap && dun_level && !ironman_downward)
323 if (c_ptr->feat == FEAT_MORE_MORE) msg_print("Ť¤¹£Æ»¤ò²¼¤ê¤¿¡£");
324 else msg_print("Ť¤³¬Ãʤò²¼¤ê¤¿¡£");
326 msg_print("These were very long stairs.");
330 else if (!dun_level) down_num = d_info[c_ptr->special].mindepth;
334 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
335 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
337 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fall from trap door");
338 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "go down the stairs to");
344 dun_level += down_num;
346 msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
348 msg_print("You deliberately jump through the trap door.");
354 if(c_ptr->feat == FEAT_ENTRANCE)
356 dun_level = d_info[c_ptr->special].mindepth;
358 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
360 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
365 dun_level += down_num;
367 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
368 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
370 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
372 msg_print("You enter a maze of down staircases.");
379 p_ptr->leaving = TRUE;
383 if (c_ptr->feat == FEAT_MORE_MORE)
385 /* Create a way back */
390 /* Create a way back */
401 * Simple command to "search" for one turn
403 void do_cmd_search(void)
405 /* Allow repeated command */
408 /* Set repeat count */
409 command_rep = command_arg - 1;
411 /* Redraw the state */
412 p_ptr->redraw |= (PR_STATE);
427 * Determine if a grid contains a chest
429 static s16b chest_check(int y, int x)
431 cave_type *c_ptr = &cave[y][x];
433 s16b this_o_idx, next_o_idx = 0;
436 /* Scan all objects in the grid */
437 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
442 o_ptr = &o_list[this_o_idx];
444 /* Acquire next object */
445 next_o_idx = o_ptr->next_o_idx;
447 /* Skip unknown chests XXX XXX */
448 /* if (!o_ptr->marked) continue; */
450 /* Check for chest */
451 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
460 * Allocates objects upon opening a chest -BEN-
462 * Disperse treasures from the given chest, centered at (x,y).
464 * Small chests often contain "gold", while Large chests always contain
465 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
466 * and Steel chests contain 6 items. The "value" of the items in a
467 * chest is based on the "power" of the chest, which is in turn based
468 * on the level on which the chest is generated.
470 static void chest_death(bool scatter, int y, int x, s16b o_idx)
480 object_type *o_ptr = &o_list[o_idx];
483 /* Small chests often hold "gold" */
484 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
486 /* Determine how much to drop (see above) */
487 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
489 if (o_ptr->sval == SV_CHEST_KANDUME)
494 object_level = o_ptr->xtra3;
498 /* Determine the "value" of the items */
499 object_level = ABS(o_ptr->pval) + 10;
502 /* Zero pval means empty chest */
503 if (!o_ptr->pval) number = 0;
505 /* Opening a chest */
506 opening_chest = TRUE;
508 /* Drop some objects (non-chests) */
509 for (; number > 0; --number)
511 /* Get local object */
514 /* Wipe the object */
517 /* Small chests often drop gold */
518 if (small && (randint0(100) < 25))
521 if (!make_gold(q_ptr)) continue;
524 /* Otherwise drop an item */
527 /* Make a good object */
528 if (!make_object(q_ptr, TRUE, great)) continue;
531 /* If chest scatters its contents, pick any floor square. */
535 for (i = 0; i < 200; i++)
537 /* Pick a totally random spot. */
538 y = randint0(MAX_HGT);
539 x = randint0(MAX_WID);
541 /* Must be an empty floor. */
542 if (!cave_empty_bold(y, x)) continue;
544 /* Place the object there. */
545 drop_near(q_ptr, -1, y, x);
551 /* Normally, drop object near the chest. */
552 else drop_near(q_ptr, -1, y, x);
555 /* Reset the object level */
556 object_level = base_level;
558 /* No longer opening a chest */
559 opening_chest = FALSE;
570 * Chests have traps too.
572 * Exploding chest destroys contents (and traps).
573 * Note that the chest itself is never destroyed.
575 static void chest_trap(int y, int x, s16b o_idx)
579 object_type *o_ptr = &o_list[o_idx];
581 int mon_level = o_ptr->xtra3;
583 /* Ignore disarmed chests */
584 if (o_ptr->pval <= 0) return;
586 /* Obtain the traps */
587 trap = chest_traps[o_ptr->pval];
590 if (trap & (CHEST_LOSE_STR))
593 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
594 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
596 msg_print("A small needle has pricked you!");
597 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
600 (void)do_dec_stat(A_STR);
603 /* Lose constitution */
604 if (trap & (CHEST_LOSE_CON))
607 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
608 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
610 msg_print("A small needle has pricked you!");
611 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
614 (void)do_dec_stat(A_CON);
618 if (trap & (CHEST_POISON))
621 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
623 msg_print("A puff of green gas surrounds you!");
626 if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
628 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
633 if (trap & (CHEST_PARALYZE))
636 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
638 msg_print("A puff of yellow gas surrounds you!");
642 if (!p_ptr->free_act)
644 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
648 /* Summon monsters */
649 if (trap & (CHEST_SUMMON))
651 int num = 2 + randint1(3);
653 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
655 msg_print("You are enveloped in a cloud of smoke!");
659 for (i = 0; i < num; i++)
661 if (randint1(100)<dun_level)
662 activate_hi_summon(py, px, FALSE);
664 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
668 /* Elemental summon. */
669 if (trap & (CHEST_E_SUMMON))
672 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
674 msg_print("Elemental beings appear to protect their treasures!");
676 for (i = 0; i < randint1(3) + 5; i++)
678 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
682 /* Force clouds, then summon birds. */
683 if (trap & (CHEST_BIRD_STORM))
686 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
688 msg_print("A storm of birds swirls around you!");
691 for (i = 0; i < randint1(3) + 3; i++)
692 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
694 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
696 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
700 /* Various colorful summonings. */
701 if (trap & (CHEST_H_SUMMON))
707 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
709 msg_print("Demons materialize in clouds of fire and brimstone!");
712 for (i = 0; i < randint1(3) + 2; i++)
714 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
715 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
719 /* Summon dragons. */
723 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
725 msg_print("Draconic forms loom out of the darkness!");
728 for (i = 0; i < randint1(3) + 2; i++)
730 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
734 /* Summon hybrids. */
738 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
740 msg_print("Creatures strange and twisted assault you!");
743 for (i = 0; i < randint1(5) + 3; i++)
745 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
749 /* Summon vortices (scattered) */
753 msg_print("±²´¬¤«¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
755 msg_print("Vortices coalesce and wreak destruction!");
758 for (i = 0; i < randint1(3) + 2; i++)
760 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
766 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
768 /* Determine how many nasty tricks can be played. */
769 int nasty_tricks_count = 4 + randint0(3);
773 msg_print("¶²¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
775 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
778 /* This is gonna hurt... */
779 for (; nasty_tricks_count > 0; nasty_tricks_count--)
781 /* ...but a high saving throw does help a little. */
782 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
785 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
787 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
789 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
792 if (!p_ptr->free_act)
793 (void)set_paralyzed(p_ptr->paralyzed + 2 +
796 (void)set_stun(p_ptr->stun + 10 +
799 else if (one_in_(3)) apply_disenchant(0);
802 (void)do_dec_stat(A_STR);
803 (void)do_dec_stat(A_DEX);
804 (void)do_dec_stat(A_CON);
805 (void)do_dec_stat(A_INT);
806 (void)do_dec_stat(A_WIS);
807 (void)do_dec_stat(A_CHR);
809 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
814 /* Aggravate monsters. */
815 if (trap & (CHEST_ALARM))
818 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
820 msg_print("An alarm sounds!");
822 aggravate_monsters(0);
826 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
829 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
830 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
832 msg_print("There is a sudden explosion!");
833 msg_print("Everything inside the chest is destroyed!");
837 sound(SOUND_EXPLODE);
839 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
841 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
845 /* Scatter contents. */
846 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
849 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
851 msg_print("The contents of the chest scatter all over the dungeon!");
853 chest_death(TRUE, y, x, o_idx);
860 * Attempt to open the given chest at the given location
862 * Assume there is no monster blocking the destination
864 * Returns TRUE if repeated commands may continue
866 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
874 object_type *o_ptr = &o_list[o_idx];
880 /* Attempt to unlock it */
883 /* Assume locked, and thus not open */
886 /* Get the "disarm" factor */
887 i = p_ptr->skill_dis;
889 /* Penalize some conditions */
890 if (p_ptr->blind || no_lite()) i = i / 10;
891 if (p_ptr->confused || p_ptr->image) i = i / 10;
893 /* Extract the difficulty */
896 /* Always have a small chance of success */
899 /* Success -- May still have traps */
900 if (randint0(100) < j)
903 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
905 msg_print("You have picked the lock.");
912 /* Failure -- Keep trying */
915 /* We may continue repeating */
917 if (flush_failure) flush();
919 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
921 msg_print("You failed to pick the lock.");
927 /* Allowed to open */
930 /* Apply chest traps, if any */
931 chest_trap(y, x, o_idx);
933 /* Let the Chest drop items */
934 chest_death(FALSE, y, x, o_idx);
942 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
945 * Return TRUE if the given feature is an open door
947 static bool is_open(int feat)
949 return (feat == FEAT_OPEN);
954 * Return the number of features around (or under) the character.
955 * Usually look for doors and floor traps.
957 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
959 int d, count, xx, yy;
961 /* Count how many matches */
964 /* Check around (and under) the character */
965 for (d = 0; d < 9; d++)
970 /* if not searching under player continue */
971 if ((d == 8) && !under) continue;
973 /* Extract adjacent (legal) location */
974 yy = py + ddy_ddd[d];
975 xx = px + ddx_ddd[d];
978 c_ptr = &cave[yy][xx];
980 /* Must have knowledge */
981 if (!(c_ptr->info & (CAVE_MARK))) continue;
983 /* Feature code (applying "mimic" field) */
984 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
986 /* Not looking for this feature */
987 if (!((*test)(feat))) continue;
992 /* Remember the location. Only useful if only one match */
1003 * Return the number of chests around (or under) the character.
1004 * If requested, count only trapped chests.
1006 static int count_chests(int *y, int *x, bool trapped)
1008 int d, count, o_idx;
1012 /* Count how many matches */
1015 /* Check around (and under) the character */
1016 for (d = 0; d < 9; d++)
1018 /* Extract adjacent (legal) location */
1019 int yy = py + ddy_ddd[d];
1020 int xx = px + ddx_ddd[d];
1022 /* No (visible) chest is there */
1023 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1025 /* Grab the object */
1026 o_ptr = &o_list[o_idx];
1029 if (o_ptr->pval == 0) continue;
1031 /* No (known) traps here */
1032 if (trapped && (!object_known_p(o_ptr) ||
1033 !chest_traps[o_ptr->pval])) continue;
1038 /* Remember the location. Only useful if only one match */
1049 * Convert an adjacent location to a direction.
1051 static int coords_to_dir(int y, int x)
1053 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1060 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1062 return d[dx + 1][dy + 1];
1065 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1069 * Perform the basic "open" command on doors
1071 * Assume destination is a closed/locked/jammed door
1073 * Assume there is no monster blocking the destination
1075 * Returns TRUE if repeated commands may continue
1077 static bool do_cmd_open_aux(int y, int x)
1090 /* Get requested grid */
1091 c_ptr = &cave[y][x];
1093 /* Feature code (applying "mimic" field) */
1094 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1097 if (feat >= FEAT_DOOR_HEAD + 0x08)
1101 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1103 msg_print("The door appears to be stuck.");
1109 else if (feat >= FEAT_DOOR_HEAD + 0x01)
1112 i = p_ptr->skill_dis;
1114 /* Penalize some conditions */
1115 if (p_ptr->blind || no_lite()) i = i / 10;
1116 if (p_ptr->confused || p_ptr->image) i = i / 10;
1118 /* Extract the lock power */
1119 j = c_ptr->feat - FEAT_DOOR_HEAD;
1121 /* Extract the difficulty XXX XXX XXX */
1124 /* Always have a small chance of success */
1128 if (randint0(100) < j)
1132 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1134 msg_print("You have picked the lock.");
1139 cave_set_feat(y, x, FEAT_OPEN);
1141 /* Update some things */
1142 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1145 sound(SOUND_OPENDOOR);
1155 if (flush_failure) flush();
1159 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1161 msg_print("You failed to pick the lock.");
1165 /* We may keep trying */
1174 cave_set_feat(y, x, FEAT_OPEN);
1176 /* Update some things */
1177 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1180 sound(SOUND_OPENDOOR);
1190 * Open a closed/locked/jammed door or a closed/locked chest.
1192 * Unlocking a locked door/chest is worth one experience point.
1194 void do_cmd_open(void)
1202 if (p_ptr->special_defense & KATA_MUSOU)
1204 set_action(ACTION_NONE);
1207 #ifdef ALLOW_EASY_OPEN /* TNB */
1209 /* Option: Pick a direction */
1212 int num_doors, num_chests;
1214 /* Count closed doors (locked or jammed) */
1215 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1217 /* Count chests (locked) */
1218 num_chests = count_chests(&y, &x, FALSE);
1220 /* See if only one target */
1221 if (num_doors || num_chests)
1223 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1225 if (!too_many) command_dir = coords_to_dir(y, x);
1229 #endif /* ALLOW_EASY_OPEN -- TNB */
1231 /* Allow repeated command */
1234 /* Set repeat count */
1235 command_rep = command_arg - 1;
1237 /* Redraw the state */
1238 p_ptr->redraw |= (PR_STATE);
1240 /* Cancel the arg */
1244 /* Get a "repeated" direction */
1245 if (get_rep_dir(&dir, TRUE))
1250 /* Get requested location */
1254 /* Get requested grid */
1255 c_ptr = &cave[y][x];
1257 /* Feature code (applying "mimic" field) */
1258 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1260 /* Check for chest */
1261 o_idx = chest_check(y, x);
1263 /* Nothing useful */
1264 if (!is_closed_door(feat) && !o_idx)
1268 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1270 msg_print("You see nothing there to open.");
1275 /* Monster in the way */
1276 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1283 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1285 msg_print("There is a monster in the way!");
1296 /* Open the chest */
1297 more = do_cmd_open_chest(y, x, o_idx);
1304 more = do_cmd_open_aux(y, x);
1308 /* Cancel repeat unless we may continue */
1309 if (!more) disturb(0, 0);
1315 * Perform the basic "close" command
1317 * Assume destination is an open/broken door
1319 * Assume there is no monster blocking the destination
1321 * Returns TRUE if repeated commands may continue
1323 static bool do_cmd_close_aux(int y, int x)
1334 /* Get grid and contents */
1335 c_ptr = &cave[y][x];
1337 /* Feature code (applying "mimic" field) */
1338 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1341 if (feat == FEAT_BROKEN)
1345 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1347 msg_print("The door appears to be broken.");
1355 /* Close the door */
1356 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1358 /* Update some things */
1359 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1362 sound(SOUND_SHUTDOOR);
1371 * Close an open door.
1373 void do_cmd_close(void)
1379 if (p_ptr->special_defense & KATA_MUSOU)
1381 set_action(ACTION_NONE);
1384 #ifdef ALLOW_EASY_OPEN /* TNB */
1386 /* Option: Pick a direction */
1389 /* Count open doors */
1390 if (count_dt(&y, &x, is_open, FALSE) == 1)
1392 command_dir = coords_to_dir(y, x);
1396 #endif /* ALLOW_EASY_OPEN -- TNB */
1398 /* Allow repeated command */
1401 /* Set repeat count */
1402 command_rep = command_arg - 1;
1404 /* Redraw the state */
1405 p_ptr->redraw |= (PR_STATE);
1407 /* Cancel the arg */
1411 /* Get a "repeated" direction */
1412 if (get_rep_dir(&dir,FALSE))
1417 /* Get requested location */
1421 /* Get grid and contents */
1422 c_ptr = &cave[y][x];
1424 /* Feature code (applying "mimic" field) */
1425 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1427 /* Require open/broken door */
1428 if ((feat != FEAT_OPEN) && (feat != FEAT_BROKEN))
1432 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1434 msg_print("You see nothing there to close.");
1439 /* Monster in the way */
1440 else if (c_ptr->m_idx)
1447 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1449 msg_print("There is a monster in the way!");
1457 /* Close the door */
1460 /* Close the door */
1461 more = do_cmd_close_aux(y, x);
1465 /* Cancel repeat unless we may continue */
1466 if (!more) disturb(0, 0);
1471 * Determine if a given grid may be "tunneled"
1473 static bool do_cmd_tunnel_test(int y, int x)
1475 /* Must have knowledge */
1476 if (!(cave[y][x].info & (CAVE_MARK)))
1480 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1482 msg_print("You see nothing there.");
1490 /* Must be a wall/door/etc */
1491 if (cave_floor_bold(y, x))
1495 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1497 msg_print("You see nothing there to tunnel.");
1512 * Tunnel through wall. Assumes valid location.
1514 * Note that it is impossible to "extend" rooms past their
1515 * outer walls (which are actually part of the room).
1517 * This will, however, produce grids which are NOT illuminated
1518 * (or darkened) along with the rest of the room.
1520 static bool twall(int y, int x, byte feat)
1522 cave_type *c_ptr = &cave[y][x];
1524 /* Paranoia -- Require a wall or door or some such */
1525 if (cave_floor_bold(y, x)) return (FALSE);
1527 /* Forget the wall */
1528 c_ptr->info &= ~(CAVE_MARK);
1530 /* Remove the feature */
1531 cave_set_feat(y, x, feat);
1533 /* Update some things */
1534 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1543 * Perform the basic "tunnel" command
1545 * Assumes that the destination is a wall, a vein, a secret
1548 * Assumes that no monster is blocking the destination
1550 * Returns TRUE if repeated commands may continue
1552 static bool do_cmd_tunnel_aux(int y, int x)
1559 /* Verify legality */
1560 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1566 c_ptr = &cave[y][x];
1568 /* Feature code (applying "mimic" field) */
1569 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1575 if ((feat >= FEAT_PERM_EXTRA) &&
1576 (feat <= FEAT_PERM_SOLID))
1579 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1581 msg_print("This seems to be permanent rock.");
1586 /* No tunnelling through mountains */
1587 else if (feat == FEAT_MOUNTAIN)
1590 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1592 msg_print("You can't tunnel through that!");
1597 else if (feat == FEAT_TREES) /* -KMW- */
1600 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1603 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1605 msg_print("You have cleared away the trees.");
1607 chg_virtue(V_DILIGENCE, 1);
1608 chg_virtue(V_NATURE, -1);
1614 /* We may continue chopping */
1616 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1618 msg_print("You chop away at the tree.");
1623 /* Occasional Search XXX XXX */
1624 if (randint0(100) < 25) search();
1630 else if ((feat >= FEAT_WALL_EXTRA) &&
1631 (feat <= FEAT_WALL_SOLID))
1634 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1637 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1639 msg_print("You have finished the tunnel.");
1641 chg_virtue(V_DILIGENCE, 1);
1642 chg_virtue(V_NATURE, -1);
1648 /* We may continue tunelling */
1650 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1652 msg_print("You tunnel into the granite wall.");
1660 /* Quartz / Magma */
1661 else if ((feat >= FEAT_MAGMA) &&
1662 (feat <= FEAT_QUARTZ_K))
1669 if (feat >= FEAT_MAGMA_H) gold = TRUE;
1671 /* Extract "quartz" flag XXX XXX XXX */
1672 if ((feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1677 okay = (p_ptr->skill_dig > 20 + randint0(800));
1683 okay = (p_ptr->skill_dig > 10 + randint0(400));
1687 if (okay && twall(y, x, floor_type[randint0(100)]))
1689 /* Found treasure */
1692 /* Place some gold */
1697 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1699 msg_print("You have found something!");
1709 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1711 msg_print("You have finished the tunnel.");
1713 chg_virtue(V_DILIGENCE, 1);
1714 chg_virtue(V_NATURE, -1);
1718 /* Failure (quartz) */
1721 /* Message, continue digging */
1723 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1725 msg_print("You tunnel into the quartz vein.");
1731 /* Failure (magma) */
1734 /* Message, continue digging */
1736 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1738 msg_print("You tunnel into the magma vein.");
1746 else if (feat == FEAT_RUBBLE)
1748 /* Remove the rubble */
1749 if ((p_ptr->skill_dig > randint0(200)) && twall(y, x, floor_type[randint0(100)]))
1753 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1755 msg_print("You have removed the rubble.");
1758 /* Hack -- place an object */
1759 if (randint0(100) < (15 - dun_level/2))
1761 /* Create a simple object */
1762 place_object(y, x, FALSE, FALSE);
1764 /* Observe new object */
1765 if (player_can_see_bold(y, x))
1768 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1770 msg_print("You have found something!");
1779 /* Message, keep digging */
1781 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1783 msg_print("You dig in the rubble.");
1794 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint1(100)]))
1797 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1799 msg_print("You have finished the tunnel.");
1807 /* We may continue tunelling */
1809 msg_print("¥É¥¢¤Ë·ê¤ò³«¤±¤Æ¤¤¤ë¡£");
1811 msg_print("You tunnel into the door.");
1818 if (is_hidden_door(c_ptr))
1820 /* Occasional Search XXX XXX */
1821 if (randint0(100) < 25) search();
1824 /* Notice new floor grids */
1825 if (!cave_floor_bold(y, x))
1827 /* Update some things */
1828 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1837 * Tunnels through "walls" (including rubble and closed doors)
1839 * Note that you must tunnel in order to hit invisible monsters
1840 * in walls, though moving into walls still takes a turn anyway.
1842 * Digging is very difficult without a "digger" weapon, but can be
1843 * accomplished by strong players using heavy weapons.
1845 void do_cmd_tunnel(void)
1855 if (p_ptr->special_defense & KATA_MUSOU)
1857 set_action(ACTION_NONE);
1860 /* Allow repeated command */
1863 /* Set repeat count */
1864 command_rep = command_arg - 1;
1866 /* Redraw the state */
1867 p_ptr->redraw |= (PR_STATE);
1869 /* Cancel the arg */
1873 /* Get a direction to tunnel, or Abort */
1874 if (get_rep_dir(&dir,FALSE))
1881 c_ptr = &cave[y][x];
1883 /* Feature code (applying "mimic" field) */
1884 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1886 /* No tunnelling through doors */
1887 if (((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL)) ||
1888 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
1889 ((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
1890 (feat == FEAT_MUSEUM))
1894 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1896 msg_print("You cannot tunnel through doors.");
1901 /* No tunnelling through air */
1902 else if (cave_floor_grid(c_ptr) || ((feat >= FEAT_MINOR_GLYPH) &&
1903 (feat <= FEAT_PATTERN_XTRA2)))
1907 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1909 msg_print("You cannot tunnel through air.");
1914 /* No tunnelling through mountains */
1915 else if (feat == FEAT_MOUNTAIN)
1918 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1920 msg_print("You can't tunnel through that!");
1925 /* A monster is in the way */
1926 else if (c_ptr->m_idx)
1933 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1935 msg_print("There is a monster in the way!");
1946 /* Tunnel through walls */
1947 more = do_cmd_tunnel_aux(y, x);
1951 /* Cancel repetition unless we can continue */
1952 if (!more) disturb(0, 0);
1956 #ifdef ALLOW_EASY_OPEN /* TNB */
1961 * If there is a jammed/closed/locked door at the given location,
1962 * then attempt to unlock/open it. Return TRUE if an attempt was
1963 * made (successful or not), otherwise return FALSE.
1965 * The code here should be nearly identical to that in
1966 * do_cmd_open_test() and do_cmd_open_aux().
1968 bool easy_open_door(int y, int x)
1972 cave_type *c_ptr = &cave[y][x];
1974 /* Must be a closed door */
1975 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1976 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1983 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1987 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1989 msg_print("The door appears to be stuck.");
1995 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1998 i = p_ptr->skill_dis;
2000 /* Penalize some conditions */
2001 if (p_ptr->blind || no_lite()) i = i / 10;
2002 if (p_ptr->confused || p_ptr->image) i = i / 10;
2004 /* Extract the lock power */
2005 j = c_ptr->feat - FEAT_DOOR_HEAD;
2007 /* Extract the difficulty XXX XXX XXX */
2010 /* Always have a small chance of success */
2014 if (randint0(100) < j)
2018 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
2020 msg_print("You have picked the lock.");
2025 cave_set_feat(y, x, FEAT_OPEN);
2027 /* Update some things */
2028 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2031 sound(SOUND_OPENDOOR);
2041 if (flush_failure) flush();
2045 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2047 msg_print("You failed to pick the lock.");
2057 cave_set_feat(y, x, FEAT_OPEN);
2059 /* Update some things */
2060 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2063 sound(SOUND_OPENDOOR);
2070 #endif /* ALLOW_EASY_OPEN -- TNB */
2074 * Perform the basic "disarm" command
2076 * Assume destination is a visible trap
2078 * Assume there is no monster blocking the destination
2080 * Returns TRUE if repeated commands may continue
2082 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2088 object_type *o_ptr = &o_list[o_idx];
2094 /* Get the "disarm" factor */
2095 i = p_ptr->skill_dis;
2097 /* Penalize some conditions */
2098 if (p_ptr->blind || no_lite()) i = i / 10;
2099 if (p_ptr->confused || p_ptr->image) i = i / 10;
2101 /* Extract the difficulty */
2102 j = i - o_ptr->pval;
2104 /* Always have a small chance of success */
2107 /* Must find the trap first. */
2108 if (!object_known_p(o_ptr))
2111 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2113 msg_print("I don't see any traps.");
2118 /* Already disarmed/unlocked */
2119 else if (o_ptr->pval <= 0)
2122 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2124 msg_print("The chest is not trapped.");
2129 /* No traps to find. */
2130 else if (!chest_traps[o_ptr->pval])
2133 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2135 msg_print("The chest is not trapped.");
2140 /* Success (get a lot of experience) */
2141 else if (randint0(100) < j)
2144 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2146 msg_print("You have disarmed the chest.");
2149 gain_exp(o_ptr->pval);
2150 o_ptr->pval = (0 - o_ptr->pval);
2153 /* Failure -- Keep trying */
2154 else if ((i > 5) && (randint1(i) > 5))
2156 /* We may keep trying */
2158 if (flush_failure) flush();
2160 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2162 msg_print("You failed to disarm the chest.");
2167 /* Failure -- Set off the trap */
2171 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2173 msg_print("You set off a trap!");
2177 chest_trap(y, x, o_idx);
2186 * Perform the basic "disarm" command
2188 * Assume destination is a visible trap
2190 * Assume there is no monster blocking the destination
2192 * Returns TRUE if repeated commands may continue
2194 #ifdef ALLOW_EASY_DISARM /* TNB */
2196 bool do_cmd_disarm_aux(int y, int x, int dir)
2198 #else /* ALLOW_EASY_DISARM -- TNB */
2200 static bool do_cmd_disarm_aux(int y, int x, int dir)
2202 #endif /* ALLOW_EASY_DISARM -- TNB */
2216 /* Get grid and contents */
2217 c_ptr = &cave[y][x];
2219 /* Access trap name */
2220 name = (f_name + f_info[c_ptr->feat].name);
2222 /* Get the "disarm" factor */
2223 i = p_ptr->skill_dis;
2225 /* Penalize some conditions */
2226 if (p_ptr->blind || no_lite()) i = i / 10;
2227 if (p_ptr->confused || p_ptr->image) i = i / 10;
2229 /* XXX XXX XXX Variable power? */
2231 /* Extract trap "power" */
2234 /* Extract the difficulty */
2237 /* Always have a small chance of success */
2241 if (randint0(100) < j)
2245 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2247 msg_format("You have disarmed the %s.", name);
2254 /* Forget the trap */
2255 c_ptr->info &= ~(CAVE_MARK);
2257 /* Remove the trap */
2258 cave_set_feat(y, x, floor_type[randint0(100)]);
2260 #ifdef ALLOW_EASY_DISARM /* TNB */
2262 /* Move the player onto the trap */
2263 move_player(dir, easy_disarm, FALSE);
2265 #else /* ALLOW_EASY_DISARM -- TNB */
2267 /* move the player onto the trap grid */
2268 move_player(dir, FALSE, FALSE);
2270 #endif /* ALLOW_EASY_DISARM -- TNB */
2273 /* Failure -- Keep trying */
2274 else if ((i > 5) && (randint1(i) > 5))
2277 if (flush_failure) flush();
2281 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2283 msg_format("You failed to disarm the %s.", name);
2287 /* We may keep trying */
2291 /* Failure -- Set off the trap */
2296 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2298 msg_format("You set off the %s!", name);
2302 #ifdef ALLOW_EASY_DISARM /* TNB */
2304 /* Move the player onto the trap */
2305 move_player(dir, easy_disarm, FALSE);
2307 #else /* ALLOW_EASY_DISARM -- TNB */
2309 /* Move the player onto the trap */
2310 move_player(dir, FALSE, FALSE);
2312 #endif /* ALLOW_EASY_DISARM -- TNB */
2321 * Disarms a trap, or chest
2323 void do_cmd_disarm(void)
2331 if (p_ptr->special_defense & KATA_MUSOU)
2333 set_action(ACTION_NONE);
2336 #ifdef ALLOW_EASY_DISARM /* TNB */
2338 /* Option: Pick a direction */
2341 int num_traps, num_chests;
2343 /* Count visible traps */
2344 num_traps = count_dt(&y, &x, is_trap, TRUE);
2346 /* Count chests (trapped) */
2347 num_chests = count_chests(&y, &x, TRUE);
2349 /* See if only one target */
2350 if (num_traps || num_chests)
2352 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2354 if (!too_many) command_dir = coords_to_dir(y, x);
2358 #endif /* ALLOW_EASY_DISARM -- TNB */
2360 /* Allow repeated command */
2363 /* Set repeat count */
2364 command_rep = command_arg - 1;
2366 /* Redraw the state */
2367 p_ptr->redraw |= (PR_STATE);
2369 /* Cancel the arg */
2373 /* Get a direction (or abort) */
2374 if (get_rep_dir(&dir,TRUE))
2383 /* Get grid and contents */
2384 c_ptr = &cave[y][x];
2386 /* Feature code (applying "mimic" field) */
2387 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2389 /* Check for chests */
2390 o_idx = chest_check(y, x);
2393 if (!is_trap(feat) && !o_idx)
2397 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2399 msg_print("You see nothing there to disarm.");
2404 /* Monster in the way */
2405 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2409 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2411 msg_print("There is a monster in the way!");
2422 /* Disarm the chest */
2423 more = do_cmd_disarm_chest(y, x, o_idx);
2429 /* Disarm the trap */
2430 more = do_cmd_disarm_aux(y, x, dir);
2434 /* Cancel repeat unless told not to */
2435 if (!more) disturb(0, 0);
2440 * Perform the basic "bash" command
2442 * Assume destination is a closed/locked/jammed door
2444 * Assume there is no monster blocking the destination
2446 * Returns TRUE if repeated commands may continue
2448 static bool do_cmd_bash_aux(int y, int x, int dir)
2461 c_ptr = &cave[y][x];
2465 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2467 msg_print("You smash into the door!");
2471 /* Hack -- Bash power based on strength */
2472 /* (Ranges from 3 to 20 to 100 to 200) */
2473 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2475 /* Extract door power */
2476 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2478 /* Compare bash power to door power XXX XXX XXX */
2479 temp = (bash - (temp * 10));
2481 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2483 /* Hack -- always have a chance */
2484 if (temp < 1) temp = 1;
2486 /* Hack -- attempt to bash down the door */
2487 if (randint0(100) < temp)
2491 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2493 msg_print("The door crashes open!");
2497 /* Break down the door */
2498 if (randint0(100) < 50)
2500 cave_set_feat(y, x, FEAT_BROKEN);
2506 cave_set_feat(y, x, FEAT_OPEN);
2510 sound(SOUND_OPENDOOR);
2512 /* Hack -- Fall through the door */
2513 move_player(dir, FALSE, FALSE);
2515 /* Update some things */
2516 p_ptr->update |= (PU_VIEW | PU_LITE);
2517 p_ptr->update |= (PU_DISTANCE);
2520 /* Saving throw against stun */
2521 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2526 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2528 msg_print("The door holds firm.");
2532 /* Allow repeated bashing */
2536 /* High dexterity yields coolness */
2541 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2543 msg_print("You are off-balance.");
2547 /* Hack -- Lose balance ala paralysis */
2548 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2557 * Bash open a door, success based on character strength
2559 * For a closed door, pval is positive if locked; negative if stuck.
2561 * For an open door, pval is positive for a broken door.
2563 * A closed door can be opened - harder if locked. Any door might be
2564 * bashed open (and thereby broken). Bashing a door is (potentially)
2565 * faster! You move into the door way. To open a stuck door, it must
2566 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2568 * Creatures can also open or bash doors, see elsewhere.
2570 void do_cmd_bash(void)
2579 if (p_ptr->special_defense & KATA_MUSOU)
2581 set_action(ACTION_NONE);
2584 /* Allow repeated command */
2587 /* Set repeat count */
2588 command_rep = command_arg - 1;
2590 /* Redraw the state */
2591 p_ptr->redraw |= (PR_STATE);
2593 /* Cancel the arg */
2597 /* Get a "repeated" direction */
2598 if (get_rep_dir(&dir,FALSE))
2607 c_ptr = &cave[y][x];
2609 /* Feature code (applying "mimic" field) */
2610 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2612 /* Nothing useful */
2613 if (!((feat >= FEAT_DOOR_HEAD) &&
2614 (feat <= FEAT_DOOR_TAIL)))
2618 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2620 msg_print("You see nothing there to bash.");
2625 /* Monster in the way */
2626 else if (c_ptr->m_idx)
2633 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2635 msg_print("There is a monster in the way!");
2643 /* Bash a closed door */
2647 more = do_cmd_bash_aux(y, x, dir);
2651 /* Unless valid action taken, cancel bash */
2652 if (!more) disturb(0, 0);
2657 * Manipulate an adjacent grid in some way
2659 * Attack monsters, tunnel through walls, disarm traps, open doors.
2661 * Consider confusion XXX XXX XXX
2663 * This command must always take a turn, to prevent free detection
2664 * of invisible monsters.
2666 void do_cmd_alter(void)
2675 if (p_ptr->special_defense & KATA_MUSOU)
2677 set_action(ACTION_NONE);
2680 /* Allow repeated command */
2683 /* Set repeat count */
2684 command_rep = command_arg - 1;
2686 /* Redraw the state */
2687 p_ptr->redraw |= (PR_STATE);
2689 /* Cancel the arg */
2693 /* Get a direction */
2694 if (get_rep_dir(&dir,TRUE))
2703 c_ptr = &cave[y][x];
2705 /* Feature code (applying "mimic" field) */
2706 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2711 /* Attack monsters */
2718 /* Tunnel through walls */
2719 else if (((feat >= FEAT_RUBBLE) &&
2720 (feat < FEAT_MINOR_GLYPH)) ||
2721 ((feat == FEAT_TREES) ||
2722 (feat == FEAT_MOUNTAIN)))
2724 more = do_cmd_tunnel_aux(y, x);
2727 else if (is_closed_door(feat))
2729 /* Bash jammed doors */
2730 if (feat >= FEAT_DOOR_HEAD + 0x08)
2732 more = do_cmd_bash_aux(y, x, dir);
2738 more = do_cmd_open_aux(y, x);
2742 /* Close open doors */
2743 else if ((feat == FEAT_OPEN) ||
2744 (feat == FEAT_BROKEN))
2746 more = do_cmd_close_aux(y, x);
2750 else if (is_trap(feat))
2752 more = do_cmd_disarm_aux(y, x, dir);
2760 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2762 msg_print("You attack the empty air.");
2768 /* Cancel repetition unless we can continue */
2769 if (!more) disturb(0, 0);
2774 * Find the index of some "spikes", if possible.
2776 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2778 static bool get_spike(int *ip)
2782 /* Check every item in the pack */
2783 for (i = 0; i < INVEN_PACK; i++)
2785 object_type *o_ptr = &inventory[i];
2787 /* Skip non-objects */
2788 if (!o_ptr->k_idx) continue;
2790 /* Check the "tval" code */
2791 if (o_ptr->tval == TV_SPIKE)
2793 /* Save the spike index */
2807 * Jam a closed door with a spike
2809 * This command may NOT be repeated
2811 void do_cmd_spike(void)
2815 if (p_ptr->special_defense & KATA_MUSOU)
2817 set_action(ACTION_NONE);
2820 /* Get a "repeated" direction */
2821 if (get_rep_dir(&dir,FALSE))
2831 /* Get grid and contents */
2832 c_ptr = &cave[y][x];
2834 /* Feature code (applying "mimic" field) */
2835 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2837 /* Require closed door */
2838 if (!((feat >= FEAT_DOOR_HEAD) &&
2839 (feat <= FEAT_DOOR_TAIL)))
2843 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2845 msg_print("You see nothing there to spike.");
2851 else if (!get_spike(&item))
2855 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2857 msg_print("You have no spikes!");
2862 /* Is a monster in the way? */
2863 else if (c_ptr->m_idx)
2870 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2872 msg_print("There is a monster in the way!");
2886 /* Successful jamming */
2888 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2890 msg_print("You jam the door with a spike.");
2894 /* Convert "locked" to "stuck" XXX XXX XXX */
2895 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2897 /* Add one spike to the door */
2898 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2900 /* Use up, and describe, a single spike, from the bottom */
2901 inven_item_increase(item, -1);
2902 inven_item_describe(item);
2903 inven_item_optimize(item);
2911 * Support code for the "Walk" and "Jump" commands
2913 void do_cmd_walk(int pickup)
2920 /* Allow repeated command */
2923 /* Set repeat count */
2924 command_rep = command_arg - 1;
2926 /* Redraw the state */
2927 p_ptr->redraw |= (PR_STATE);
2929 /* Cancel the arg */
2933 /* Get a "repeated" direction */
2934 if (get_rep_dir(&dir,FALSE))
2939 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2941 set_action(ACTION_NONE);
2944 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2945 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2946 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2948 /* Actually move the character */
2949 move_player(dir, pickup, FALSE);
2951 /* Allow more walking */
2955 /* Hack again -- Is there a special encounter ??? */
2956 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2958 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2961 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2963 /* Inform the player of his horrible fate :=) */
2965 msg_print("½±·â¤À¡ª");
2967 msg_print("You are ambushed !");
2970 /* Go into large wilderness view */
2971 p_ptr->wilderness_x = px;
2972 p_ptr->wilderness_y = py;
2973 p_ptr->oldpy = randint1(MAX_HGT-2);
2974 p_ptr->oldpx = randint1(MAX_WID-2);
2978 /* HACk -- set the encouter flag for the wilderness generation */
2979 generate_encounter = TRUE;
2983 /* Cancel repeat unless we may continue */
2984 if (!more) disturb(0, 0);
2992 void do_cmd_run(void)
2996 /* Hack -- no running when confused */
2997 if (p_ptr->confused)
3000 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
3002 msg_print("You are too confused!");
3008 if (p_ptr->special_defense & KATA_MUSOU)
3010 set_action(ACTION_NONE);
3013 /* Get a "repeated" direction */
3014 if (get_rep_dir(&dir,FALSE))
3016 /* Hack -- Set the run counter */
3017 running = (command_arg ? command_arg : 1000);
3027 * Stay still. Search. Enter stores.
3028 * Pick up treasure if "pickup" is true.
3030 void do_cmd_stay(int pickup)
3032 cave_type *c_ptr = &cave[py][px];
3035 /* Allow repeated command */
3038 /* Set repeat count */
3039 command_rep = command_arg - 1;
3041 /* Redraw the state */
3042 p_ptr->redraw |= (PR_STATE);
3044 /* Cancel the arg */
3053 /* Spontaneous Searching */
3054 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3059 /* Continuous Searching */
3060 if (p_ptr->action == ACTION_SEARCH)
3066 /* Handle "objects" */
3070 /* Hack -- enter a store if we are on one */
3071 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3072 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3073 (c_ptr->feat == FEAT_MUSEUM))
3079 /* Hack -- enter store */
3080 command_new = SPECIAL_KEY_STORE;
3083 /* Hack -- enter a building if we are on one -KMW- */
3084 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3085 (c_ptr->feat <= FEAT_BLDG_TAIL))
3091 /* Hack -- enter building */
3092 command_new = SPECIAL_KEY_BUILDING;
3095 /* Exit a quest if reach the quest exit */
3096 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3098 int q_index = p_ptr->inside_quest;
3100 /* Was quest completed? */
3101 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3103 quest[q_index].status = QUEST_STATUS_COMPLETED;
3104 quest[q_index].complev = (byte)p_ptr->lev;
3106 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3108 msg_print("You accomplished your quest!");
3114 leave_quest_check();
3116 p_ptr->inside_quest = cave[py][px].special;
3120 p_ptr->leaving = TRUE;
3127 * Resting allows a player to safely restore his hp -RAK-
3129 void do_cmd_rest(void)
3132 set_action(ACTION_NONE);
3134 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3139 /* Prompt for time if needed */
3140 if (command_arg <= 0)
3143 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3145 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3152 strcpy(out_val, "&");
3154 /* Ask for duration */
3155 if (!get_string(p, out_val, 4)) return;
3157 /* Rest until done */
3158 if (out_val[0] == '&')
3164 else if (out_val[0] == '*')
3172 command_arg = atoi(out_val);
3173 if (command_arg <= 0) return;
3179 if (command_arg > 9999) command_arg = 9999;
3181 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3183 /* Take a turn XXX XXX XXX (?) */
3186 /* The sin of sloth */
3187 if (command_arg > 100)
3188 chg_virtue(V_DILIGENCE, -1);
3190 /* Why are you sleeping when there's no need? WAKE UP!*/
3191 if ((p_ptr->chp == p_ptr->mhp) &&
3192 (p_ptr->csp == p_ptr->msp) &&
3193 !p_ptr->blind && !p_ptr->confused &&
3194 !p_ptr->poisoned && !p_ptr->afraid &&
3195 !p_ptr->stun && !p_ptr->cut &&
3196 !p_ptr->slow && !p_ptr->paralyzed &&
3197 !p_ptr->image && !p_ptr->word_recall)
3198 chg_virtue(V_DILIGENCE, -1);
3200 /* Save the rest code */
3201 resting = command_arg;
3202 p_ptr->action = ACTION_REST;
3204 /* Recalculate bonuses */
3205 p_ptr->update |= (PU_BONUS);
3207 /* Redraw the state */
3208 p_ptr->redraw |= (PR_STATE);
3219 * Determines the odds of an object breaking when thrown at a monster
3221 * Note that artifacts never break, see the "drop_near()" function.
3223 static int breakage_chance(object_type *o_ptr)
3225 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3227 /* Examine the item type */
3228 switch (o_ptr->tval)
3244 /* Sometimes break */
3249 return (20 - archer_bonus * 2);
3254 return (10 - archer_bonus);
3261 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3265 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3267 u32b flgs[TR_FLAG_SIZE];
3269 /* Extract the flags */
3270 object_flags(o_ptr, flgs);
3272 /* Some "weapons" and "ammo" do extra damage */
3273 switch (o_ptr->tval)
3280 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3281 (r_ptr->flags3 & RF3_ANIMAL))
3285 r_ptr->r_flags3 |= RF3_ANIMAL;
3288 if (mult < 17) mult = 17;
3292 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3293 (r_ptr->flags3 & RF3_ANIMAL))
3297 r_ptr->r_flags3 |= RF3_ANIMAL;
3300 if (mult < 27) mult = 27;
3304 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3305 (r_ptr->flags3 & RF3_EVIL))
3309 r_ptr->r_flags3 |= RF3_EVIL;
3312 if (mult < 15) mult = 15;
3316 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3317 (r_ptr->flags3 & RF3_EVIL))
3321 r_ptr->r_flags3 |= RF3_EVIL;
3324 if (mult < 25) mult = 25;
3328 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3329 (r_ptr->flags2 & RF2_HUMAN))
3333 r_ptr->r_flags2 |= RF2_HUMAN;
3336 if (mult < 17) mult = 17;
3340 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3341 (r_ptr->flags2 & RF2_HUMAN))
3345 r_ptr->r_flags2 |= RF2_HUMAN;
3348 if (mult < 27) mult = 27;
3352 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3353 (r_ptr->flags3 & RF3_UNDEAD))
3357 r_ptr->r_flags3 |= RF3_UNDEAD;
3360 if (mult < 20) mult = 20;
3364 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3365 (r_ptr->flags3 & RF3_UNDEAD))
3369 r_ptr->r_flags3 |= RF3_UNDEAD;
3372 if (mult < 30) mult = 30;
3376 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3377 (r_ptr->flags3 & RF3_DEMON))
3381 r_ptr->r_flags3 |= RF3_DEMON;
3384 if (mult < 20) mult = 20;
3388 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3389 (r_ptr->flags3 & RF3_DEMON))
3393 r_ptr->r_flags3 |= RF3_DEMON;
3396 if (mult < 30) mult = 30;
3400 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3401 (r_ptr->flags3 & RF3_ORC))
3405 r_ptr->r_flags3 |= RF3_ORC;
3408 if (mult < 20) mult = 20;
3412 if ((have_flag(flgs, TR_KILL_ORC)) &&
3413 (r_ptr->flags3 & RF3_ORC))
3417 r_ptr->r_flags3 |= RF3_ORC;
3420 if (mult < 30) mult = 30;
3424 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3425 (r_ptr->flags3 & RF3_TROLL))
3429 r_ptr->r_flags3 |= RF3_TROLL;
3432 if (mult < 20) mult = 20;
3436 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3437 (r_ptr->flags3 & RF3_TROLL))
3441 r_ptr->r_flags3 |= RF3_TROLL;
3444 if (mult < 30) mult = 30;
3448 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3449 (r_ptr->flags3 & RF3_GIANT))
3453 r_ptr->r_flags3 |= RF3_GIANT;
3456 if (mult < 20) mult = 20;
3460 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3461 (r_ptr->flags3 & RF3_GIANT))
3465 r_ptr->r_flags3 |= RF3_GIANT;
3468 if (mult < 30) mult = 30;
3472 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3473 (r_ptr->flags3 & RF3_DRAGON))
3477 r_ptr->r_flags3 |= RF3_DRAGON;
3480 if (mult < 20) mult = 20;
3483 /* Execute Dragon */
3484 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3485 (r_ptr->flags3 & RF3_DRAGON))
3489 r_ptr->r_flags3 |= RF3_DRAGON;
3492 if (mult < 30) mult = 30;
3494 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3495 (m_ptr->r_idx == MON_SMAUG) &&
3496 (inventory[INVEN_BOW].name1 == ART_BARD))
3501 if ((have_flag(flgs, TR_BRAND_ACID)) || (p_ptr->special_attack & (ATTACK_ACID)))
3503 /* Notice immunity */
3504 if (r_ptr->flags3 & RF3_IM_ACID)
3508 r_ptr->r_flags3 |= RF3_IM_ACID;
3512 /* Otherwise, take the damage */
3515 if (mult < 17) mult = 17;
3520 if ((have_flag(flgs, TR_BRAND_ELEC)) || (p_ptr->special_attack & (ATTACK_ELEC)))
3522 /* Notice immunity */
3523 if (r_ptr->flags3 & RF3_IM_ELEC)
3527 r_ptr->r_flags3 |= RF3_IM_ELEC;
3531 /* Otherwise, take the damage */
3534 if (mult < 17) mult = 17;
3539 if ((have_flag(flgs, TR_BRAND_FIRE)) || (p_ptr->special_attack & (ATTACK_FIRE)))
3541 /* Notice immunity */
3542 if (r_ptr->flags3 & RF3_IM_FIRE)
3546 r_ptr->r_flags3 |= RF3_IM_FIRE;
3550 /* Otherwise, take the damage */
3553 if (mult < 17) mult = 17;
3558 if ((have_flag(flgs, TR_BRAND_COLD)) || (p_ptr->special_attack & (ATTACK_COLD)))
3560 /* Notice immunity */
3561 if (r_ptr->flags3 & RF3_IM_COLD)
3565 r_ptr->r_flags3 |= RF3_IM_COLD;
3568 /* Otherwise, take the damage */
3571 if (mult < 17) mult = 17;
3575 /* Brand (Poison) */
3576 if ((have_flag(flgs, TR_BRAND_POIS)) || (p_ptr->special_attack & (ATTACK_POIS)))
3578 /* Notice immunity */
3579 if (r_ptr->flags3 & RF3_IM_POIS)
3583 r_ptr->r_flags3 |= RF3_IM_POIS;
3587 /* Otherwise, take the damage */
3590 if (mult < 17) mult = 17;
3594 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3596 p_ptr->csp -= (1+(p_ptr->msp / 30));
3597 p_ptr->redraw |= (PR_MANA);
3598 mult = mult * 5 / 2;
3604 /* Return the total damage */
3605 return (tdam * mult / 10);
3610 * Fire an object from the pack or floor.
3612 * You may only fire items that "match" your missile launcher.
3614 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3616 * See "calc_bonuses()" for more calculations and such.
3618 * Note that "firing" a missile is MUCH better than "throwing" it.
3620 * Note: "unseen" monsters are very hard to hit.
3622 * Objects are more likely to break if they "attempt" to hit a monster.
3624 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3626 * The "extra shot" code works by decreasing the amount of energy
3627 * required to make each shot, spreading the shots out over time.
3629 * Note that when firing missiles, the launcher multiplier is applied
3630 * after all the bonuses are added in, making multipliers very useful.
3632 * Note that Bows of "Extra Might" get extra range and an extra bonus
3633 * for the damage multiplier.
3635 * Note that Bows of "Extra Shots" give an extra shot.
3637 void do_cmd_fire_aux(int item, object_type *j_ptr)
3640 int j, y, x, ny, nx, ty, tx;
3641 int tdam, tdis, thits, tmul;
3643 int cur_dis, visible;
3650 bool hit_body = FALSE;
3652 char o_name[MAX_NLEN];
3654 int msec = delay_factor * delay_factor * delay_factor;
3657 bool stick_to = FALSE;
3659 /* Access the item (if in the pack) */
3662 o_ptr = &inventory[item];
3666 o_ptr = &o_list[0 - item];
3669 /* Describe the object */
3670 object_desc(o_name, o_ptr, FALSE, 3);
3673 /* Use the proper number of shots */
3674 thits = p_ptr->num_fire;
3676 /* Use a base distance */
3679 /* Base damage from thrown object plus launcher bonus */
3680 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3682 /* Actually "fire" the object */
3683 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3684 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3685 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval])/400 + bonus) * BTH_PLUS_ADJ);
3687 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3689 energy_use = bow_energy(j_ptr->sval);
3690 tmul = bow_tmul(j_ptr->sval);
3692 /* Get extra "power" from "extra might" */
3693 if (p_ptr->xtra_might) tmul++;
3695 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3697 /* Boost the damage */
3702 tdis = 10 + tmul/40;
3703 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3706 project_length = tdis + 1;
3708 /* Get a direction (or cancel) */
3709 if (!get_aim_dir(&dir))
3713 /* need not to reset project_length (already did)*/
3717 project_length = 0; /* reset to default */
3719 /* Get local object */
3722 /* Obtain a local object */
3723 object_copy(q_ptr, o_ptr);
3728 /* Reduce and describe inventory */
3731 inven_item_increase(item, -1);
3732 inven_item_describe(item);
3733 inven_item_optimize(item);
3736 /* Reduce and describe floor item */
3739 floor_item_increase(0 - item, -1);
3740 floor_item_optimize(0 - item);
3748 /* Take a (partial) turn */
3749 energy_use = (energy_use / thits);
3752 /* Start at the player */
3756 /* Predict the "target" location */
3757 tx = px + 99 * ddx[dir];
3758 ty = py + 99 * ddy[dir];
3760 /* Check for "target request" */
3761 if ((dir == 5) && target_okay())
3768 /* Hack -- Handle stuff */
3772 /* Travel until stopped */
3773 for (cur_dis = 0; cur_dis <= tdis; )
3775 /* Hack -- Stop at the target */
3776 if ((y == ty) && (x == tx)) break;
3778 /* Calculate the new location (see "project()") */
3781 mmove2(&ny, &nx, py, px, ty, tx);
3783 /* Stopped by walls/doors */
3784 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3786 /* Advance the distance */
3790 /* The player can see the (on screen) missile */
3791 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3793 char c = object_char(q_ptr);
3794 byte a = object_attr(q_ptr);
3796 /* Draw, Hilite, Fresh, Pause, Erase */
3797 print_rel(c, a, ny, nx);
3798 move_cursor_relative(ny, nx);
3800 Term_xtra(TERM_XTRA_DELAY, msec);
3805 /* The player cannot see the missile */
3808 /* Pause anyway, for consistancy */
3809 Term_xtra(TERM_XTRA_DELAY, msec);
3812 /* Save the new location */
3817 /* Monster here, Try to hit it */
3818 if (cave[y][x].m_idx)
3820 cave_type *c_ptr = &cave[y][x];
3822 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3823 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3825 /* Check the visibility */
3826 visible = m_ptr->ml;
3828 /* Note the collision */
3833 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3834 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3837 if ((r_ptr->level + 10) > p_ptr->lev)
3839 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3840 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3843 if (now_exp < 4000) amount = 80;
3844 else if (now_exp < 6000) amount = 25;
3845 else if ((now_exp < 7000) && (p_ptr->lev > 19)) amount = 10;
3846 else if (p_ptr->lev > 34) amount = 2;
3847 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3848 p_ptr->update |= (PU_BONUS);
3854 if (p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING] && ((p_ptr->skill_exp[GINOU_RIDING] - 1000) / 200 < r_info[m_list[p_ptr->riding].r_idx].level) && one_in_(2))
3856 p_ptr->skill_exp[GINOU_RIDING]+=1;
3857 p_ptr->update |= (PU_BONUS);
3861 /* Did we hit it (penalize range) */
3862 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3866 /* Assume a default death */
3868 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3870 cptr note_dies = " dies.";
3873 /* Some monsters get "destroyed" */
3874 if (!monster_living(r_ptr))
3877 bool explode = FALSE;
3879 for (i = 0; i < 4; i++)
3881 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3884 /* Special note at death */
3887 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3889 note_dies = " explodes into tiny shreds.";
3893 note_dies = "¤òÅݤ·¤¿¡£";
3895 note_dies = " is destroyed.";
3900 /* Handle unseen monster */
3903 /* Invisible monster */
3905 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3907 msg_format("The %s finds a mark.", o_name);
3912 /* Handle visible monster */
3917 /* Get "the monster" or "it" */
3918 monster_desc(m_name, m_ptr, 0);
3922 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3924 msg_format("The %s hits %s.", o_name, m_name);
3928 /* Hack -- Track this monster race */
3929 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3931 /* Hack -- Track this monster */
3932 if (m_ptr->ml) health_track(c_ptr->m_idx);
3935 /* Apply special damage XXX XXX XXX */
3936 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3937 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3939 /* No negative damage */
3940 if (tdam < 0) tdam = 0;
3942 /* Modify the damage */
3943 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3945 /* Complex message */
3946 if (p_ptr->wizard || cheat_xtra)
3949 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3952 msg_format("You do %d (out of %d) damage.",
3958 /* Hit the monster, check for death */
3959 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3972 monster_desc(m_name, m_ptr, 0);
3976 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3978 msg_format("%^s have stuck into %s!",o_name, m_name);
3983 message_pain(c_ptr->m_idx, tdam);
3985 /* Anger the monster */
3986 if (tdam > 0) anger_monster(m_ptr);
3989 if (fear && m_ptr->ml)
3996 /* Get the monster name (or "it") */
3997 monster_desc(m_name, m_ptr, 0);
4001 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4003 msg_format("%^s flees in terror!", m_name);
4007 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
4009 set_target(m_ptr, py, px);
4019 /* Chance of breakage (during attacks) */
4020 j = (hit_body ? breakage_chance(q_ptr) : 0);
4024 int m_idx = cave[y][x].m_idx;
4025 monster_type *m_ptr = &m_list[m_idx];
4026 int o_idx = o_pop();
4031 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
4033 msg_format("The %s have gone to somewhere.", o_name);
4037 a_info[j_ptr->name1].cur_num = 0;
4042 o_ptr = &o_list[ o_idx ];
4043 object_copy(o_ptr, q_ptr);
4048 /* Forget location */
4049 o_ptr->iy = o_ptr->ix = 0;
4051 /* Memorize monster */
4052 o_ptr->held_m_idx = m_idx;
4055 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4058 m_ptr->hold_o_idx = o_idx;
4062 /* Drop (or break) near that location */
4063 (void)drop_near(q_ptr, j, y, x);
4067 void do_cmd_fire(void)
4073 /* Get the "bow" (if any) */
4074 j_ptr = &inventory[INVEN_BOW];
4076 /* Require a launcher */
4080 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4082 msg_print("You have nothing to fire with.");
4088 if (j_ptr->sval == SV_CRIMSON)
4091 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4093 msg_print("Do activate.");
4100 if (p_ptr->special_defense & KATA_MUSOU)
4102 set_action(ACTION_NONE);
4105 /* Require proper missile */
4106 item_tester_tval = p_ptr->tval_ammo;
4110 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4111 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4113 q = "Fire which item? ";
4114 s = "You have nothing to fire.";
4117 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4124 do_cmd_fire_aux(item, j_ptr);
4128 static bool item_tester_hook_boomerang(object_type *o_ptr)
4130 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4138 * Throw an object from the pack or floor.
4140 * Note: "unseen" monsters are very hard to hit.
4142 * Should throwing a weapon do full damage? Should it allow the magic
4143 * to hit bonus of the weapon to have an effect? Should it ever cause
4144 * the item to be destroyed? Should it do any damage at all?
4146 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4149 int i, j, y, x, ty, tx;
4151 int chance, tdam, tdis;
4153 int cur_dis, visible;
4160 bool hit_body = FALSE;
4161 bool hit_wall = FALSE;
4162 bool equiped_item = FALSE;
4163 bool return_when_thrown = FALSE;
4165 char o_name[MAX_NLEN];
4167 int msec = delay_factor * delay_factor * delay_factor;
4169 u32b flgs[TR_FLAG_SIZE];
4171 bool come_back = FALSE;
4172 bool do_drop = TRUE;
4175 if (p_ptr->special_defense & KATA_MUSOU)
4177 set_action(ACTION_NONE);
4186 if (buki_motteruka(INVEN_LARM))
4188 item_tester_hook = item_tester_hook_boomerang;
4190 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4191 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4193 q = "Throw which item? ";
4194 s = "You have nothing to throw.";
4197 if (!get_item(&item, q, s, (USE_EQUIP)))
4212 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4213 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4215 q = "Throw which item? ";
4216 s = "You have nothing to throw.";
4219 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4226 /* Access the item (if in the pack) */
4229 o_ptr = &inventory[item];
4233 o_ptr = &o_list[0 - item];
4237 /* Item is cursed */
4238 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4242 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4244 msg_print("Hmmm, it seems to be cursed.");
4251 if (p_ptr->inside_arena)
4253 if (o_ptr->tval != 5)
4256 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4258 msg_print("You're in the arena now. This is hand-to-hand!");
4267 /* Get local object */
4270 /* Obtain a local object */
4271 object_copy(q_ptr, o_ptr);
4273 /* Extract the thrown object's flags. */
4274 object_flags(q_ptr, flgs);
4276 /* Distribute the charges of rods/wands between the stacks */
4277 distribute_charges(o_ptr, q_ptr, 1);
4283 object_desc(o_name, q_ptr, FALSE, 3);
4285 if (p_ptr->mighty_throw) mult += 3;
4287 /* Extract a "distance multiplier" */
4288 /* Changed for 'launcher' mutation */
4289 mul = 10 + 2 * (mult - 1);
4291 /* Enforce a minimum "weight" of one pound */
4292 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4293 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4295 /* Hack -- Distance -- Reward strength, penalize weight */
4296 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4298 /* Max distance of 10-18 */
4299 if (tdis > mul) tdis = mul;
4303 ty = randint0(101)-50+py;
4304 tx = randint0(101)-50+px;
4308 project_length = tdis + 1;
4310 /* Get a direction (or cancel) */
4311 if (!get_aim_dir(&dir)) return FALSE;
4313 project_length = 0; /* reset to default */
4315 /* Predict the "target" location */
4316 tx = px + 99 * ddx[dir];
4317 ty = py + 99 * ddy[dir];
4319 /* Check for "target request" */
4320 if ((dir == 5) && target_okay())
4327 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4328 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4329 return_when_thrown = TRUE;
4331 /* Reduce and describe inventory */
4334 inven_item_increase(item, -1);
4335 if (!return_when_thrown)
4336 inven_item_describe(item);
4337 inven_item_optimize(item);
4340 /* Reduce and describe floor item */
4343 floor_item_increase(0 - item, -1);
4344 floor_item_optimize(0 - item);
4346 if (item >= INVEN_RARM)
4348 equiped_item = TRUE;
4349 p_ptr->redraw |= (PR_EQUIPPY);
4355 /* Rogue and Ninja gets bonus */
4356 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4357 energy_use -= p_ptr->lev;
4359 /* Start at the player */
4364 /* Hack -- Handle stuff */
4367 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4368 else shuriken = FALSE;
4370 /* Chance of hitting */
4371 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4372 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4373 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4375 if (shuriken) chance *= 2;
4377 /* Travel until stopped */
4378 for (cur_dis = 0; cur_dis <= tdis; )
4380 /* Hack -- Stop at the target */
4381 if ((y == ty) && (x == tx)) break;
4383 /* Calculate the new location (see "project()") */
4386 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4388 /* Stopped by walls/doors */
4389 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4395 /* Advance the distance */
4398 /* The player can see the (on screen) missile */
4399 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4401 char c = object_char(q_ptr);
4402 byte a = object_attr(q_ptr);
4404 /* Draw, Hilite, Fresh, Pause, Erase */
4405 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4406 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4408 Term_xtra(TERM_XTRA_DELAY, msec);
4409 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4413 /* The player cannot see the missile */
4416 /* Pause anyway, for consistancy */
4417 Term_xtra(TERM_XTRA_DELAY, msec);
4420 /* Save the new location */
4425 /* Monster here, Try to hit it */
4426 if (cave[y][x].m_idx)
4428 cave_type *c_ptr = &cave[y][x];
4430 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4431 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4433 /* Check the visibility */
4434 visible = m_ptr->ml;
4436 /* Note the collision */
4439 /* Did we hit it (penalize range) */
4440 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4444 /* Assume a default death */
4446 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4448 cptr note_dies = " dies.";
4452 /* Some monsters get "destroyed" */
4453 if (!monster_living(r_ptr))
4456 bool explode = FALSE;
4458 for (i = 0; i < 4; i++)
4460 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4463 /* Special note at death */
4466 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4468 note_dies = " explodes into tiny shreds.";
4472 note_dies = "¤òÅݤ·¤¿¡£";
4474 note_dies = " is destroyed.";
4480 /* Handle unseen monster */
4483 /* Invisible monster */
4485 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4487 msg_format("The %s finds a mark.", o_name);
4492 /* Handle visible monster */
4497 /* Get "the monster" or "it" */
4498 monster_desc(m_name, m_ptr, 0);
4502 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4504 msg_format("The %s hits %s.", o_name, m_name);
4508 /* Hack -- Track this monster race */
4509 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4511 /* Hack -- Track this monster */
4512 if (m_ptr->ml) health_track(c_ptr->m_idx);
4515 /* Hack -- Base damage from thrown object */
4516 tdam = damroll(q_ptr->dd, q_ptr->ds);
4517 /* Apply special damage XXX XXX XXX */
4518 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4519 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4520 if (q_ptr->to_d > 0)
4521 tdam += q_ptr->to_d;
4523 tdam += -q_ptr->to_d;
4527 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4528 tdam += p_ptr->to_d_m;
4530 else if (have_flag(flgs, TR_THROW))
4533 tdam += p_ptr->to_d_m;
4541 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4544 /* No negative damage */
4545 if (tdam < 0) tdam = 0;
4547 /* Modify the damage */
4548 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4550 /* Complex message */
4554 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4557 msg_format("You do %d (out of %d) damage.",
4563 /* Hit the monster, check for death */
4564 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4573 message_pain(c_ptr->m_idx, tdam);
4575 /* Anger the monster */
4576 if ((tdam > 0) && !object_is_potion(q_ptr))
4577 anger_monster(m_ptr);
4580 if (fear && m_ptr->ml)
4587 /* Get the monster name (or "it") */
4588 monster_desc(m_name, m_ptr, 0);
4592 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4594 msg_format("%^s flees in terror!", m_name);
4606 /* Chance of breakage (during attacks) */
4607 j = (hit_body ? breakage_chance(q_ptr) : 0);
4609 /* Figurines transform */
4610 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4614 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4615 !(cursed_p(q_ptr)) ? PM_FORCE_PET : 0L)))
4617 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4619 msg_print("The Figurine writhes and then shatters.");
4622 else if (cursed_p(q_ptr))
4624 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4626 msg_print("You have a bad feeling about this.");
4632 /* Potions smash open */
4633 if (object_is_potion(q_ptr))
4635 if (hit_body || hit_wall || (randint1(100) < j))
4639 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4641 msg_format("The %s shatters!", o_name);
4645 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4647 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4649 /* ToDo (Robert): fix the invulnerability */
4650 if (cave[y][x].m_idx &&
4651 is_friendly(&m_list[cave[y][x].m_idx]) &&
4655 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4657 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4659 msg_format("%^s gets angry!", m_name);
4662 set_hostile(&m_list[cave[y][x].m_idx]);
4673 if (return_when_thrown)
4675 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4676 char o2_name[MAX_NLEN];
4677 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4680 if (boomerang) back_chance += 4+randint1(5);
4681 if (super_boomerang) back_chance += 100;
4682 object_desc(o2_name, q_ptr, FALSE, 0);
4684 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4686 for (i = cur_dis-1;i>0;i--)
4688 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4690 char c = object_char(q_ptr);
4691 byte a = object_attr(q_ptr);
4693 /* Draw, Hilite, Fresh, Pause, Erase */
4694 print_rel(c, a, ny[i], nx[i]);
4695 move_cursor_relative(ny[i], nx[i]);
4697 Term_xtra(TERM_XTRA_DELAY, msec);
4698 lite_spot(ny[i], nx[i]);
4703 /* Pause anyway, for consistancy */
4704 Term_xtra(TERM_XTRA_DELAY, msec);
4707 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4710 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4712 msg_format("%s comes back to you.", o2_name);
4721 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4723 msg_format("%s backs, but you can't catch!", o2_name);
4729 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4731 msg_format("%s comes back.", o2_name);
4741 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4743 msg_format("%s doesn't back!", o2_name);
4750 if (item == INVEN_RARM || item == INVEN_LARM)
4752 /* Access the wield slot */
4753 o_ptr = &inventory[item];
4755 /* Wear the new stuff */
4756 object_copy(o_ptr, q_ptr);
4758 /* Increase the weight */
4759 p_ptr->total_weight += q_ptr->weight;
4761 /* Increment the equip counter by hand */
4764 /* Recalculate bonuses */
4765 p_ptr->update |= (PU_BONUS);
4767 /* Recalculate torch */
4768 p_ptr->update |= (PU_TORCH);
4770 /* Recalculate mana XXX */
4771 p_ptr->update |= (PU_MANA);
4774 p_ptr->window |= (PW_EQUIP);
4782 else if (equiped_item)
4788 /* Drop (or break) near that location */
4789 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4796 * Throw an object from the pack or floor.
4798 void do_cmd_throw(void)
4800 do_cmd_throw_aux(1, FALSE, 0);