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)
1089 /* Get requested grid */
1090 c_ptr = &cave[y][x];
1092 /* Seeing true feature code (ignore mimic) */
1095 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1099 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1101 msg_print("The door appears to be stuck.");
1107 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1110 i = p_ptr->skill_dis;
1112 /* Penalize some conditions */
1113 if (p_ptr->blind || no_lite()) i = i / 10;
1114 if (p_ptr->confused || p_ptr->image) i = i / 10;
1116 /* Extract the lock power */
1117 j = c_ptr->feat - FEAT_DOOR_HEAD;
1119 /* Extract the difficulty XXX XXX XXX */
1122 /* Always have a small chance of success */
1126 if (randint0(100) < j)
1130 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1132 msg_print("You have picked the lock.");
1137 cave_set_feat(y, x, FEAT_OPEN);
1139 /* Update some things */
1140 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1143 sound(SOUND_OPENDOOR);
1153 if (flush_failure) flush();
1157 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1159 msg_print("You failed to pick the lock.");
1163 /* We may keep trying */
1169 else if (c_ptr->feat == FEAT_DOOR_HEAD)
1172 cave_set_feat(y, x, FEAT_OPEN);
1174 /* Update some things */
1175 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1178 sound(SOUND_OPENDOOR);
1188 * Open a closed/locked/jammed door or a closed/locked chest.
1190 * Unlocking a locked door/chest is worth one experience point.
1192 void do_cmd_open(void)
1200 if (p_ptr->special_defense & KATA_MUSOU)
1202 set_action(ACTION_NONE);
1205 #ifdef ALLOW_EASY_OPEN /* TNB */
1207 /* Option: Pick a direction */
1210 int num_doors, num_chests;
1212 /* Count closed doors (locked or jammed) */
1213 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1215 /* Count chests (locked) */
1216 num_chests = count_chests(&y, &x, FALSE);
1218 /* See if only one target */
1219 if (num_doors || num_chests)
1221 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1223 if (!too_many) command_dir = coords_to_dir(y, x);
1227 #endif /* ALLOW_EASY_OPEN -- TNB */
1229 /* Allow repeated command */
1232 /* Set repeat count */
1233 command_rep = command_arg - 1;
1235 /* Redraw the state */
1236 p_ptr->redraw |= (PR_STATE);
1238 /* Cancel the arg */
1242 /* Get a "repeated" direction */
1243 if (get_rep_dir(&dir, TRUE))
1248 /* Get requested location */
1252 /* Get requested grid */
1253 c_ptr = &cave[y][x];
1255 /* Feature code (applying "mimic" field) */
1256 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1258 /* Check for chest */
1259 o_idx = chest_check(y, x);
1261 /* Nothing useful */
1262 if (!is_closed_door(feat) && !o_idx)
1266 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1268 msg_print("You see nothing there to open.");
1273 /* Monster in the way */
1274 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1281 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1283 msg_print("There is a monster in the way!");
1294 /* Open the chest */
1295 more = do_cmd_open_chest(y, x, o_idx);
1302 more = do_cmd_open_aux(y, x);
1306 /* Cancel repeat unless we may continue */
1307 if (!more) disturb(0, 0);
1313 * Perform the basic "close" command
1315 * Assume destination is an open/broken door
1317 * Assume there is no monster blocking the destination
1319 * Returns TRUE if repeated commands may continue
1321 static bool do_cmd_close_aux(int y, int x)
1329 /* Get grid and contents */
1330 c_ptr = &cave[y][x];
1332 /* Seeing true feature code (ignore mimic) */
1335 if (c_ptr->feat == FEAT_BROKEN)
1339 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1341 msg_print("The door appears to be broken.");
1347 else if (c_ptr->feat == FEAT_OPEN)
1349 /* Close the door */
1350 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1352 /* Update some things */
1353 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1356 sound(SOUND_SHUTDOOR);
1365 * Close an open door.
1367 void do_cmd_close(void)
1373 if (p_ptr->special_defense & KATA_MUSOU)
1375 set_action(ACTION_NONE);
1378 #ifdef ALLOW_EASY_OPEN /* TNB */
1380 /* Option: Pick a direction */
1383 /* Count open doors */
1384 if (count_dt(&y, &x, is_open, FALSE) == 1)
1386 command_dir = coords_to_dir(y, x);
1390 #endif /* ALLOW_EASY_OPEN -- TNB */
1392 /* Allow repeated command */
1395 /* Set repeat count */
1396 command_rep = command_arg - 1;
1398 /* Redraw the state */
1399 p_ptr->redraw |= (PR_STATE);
1401 /* Cancel the arg */
1405 /* Get a "repeated" direction */
1406 if (get_rep_dir(&dir,FALSE))
1411 /* Get requested location */
1415 /* Get grid and contents */
1416 c_ptr = &cave[y][x];
1418 /* Feature code (applying "mimic" field) */
1419 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1421 /* Require open/broken door */
1422 if ((feat != FEAT_OPEN) && (feat != FEAT_BROKEN))
1426 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1428 msg_print("You see nothing there to close.");
1433 /* Monster in the way */
1434 else if (c_ptr->m_idx)
1441 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1443 msg_print("There is a monster in the way!");
1451 /* Close the door */
1454 /* Close the door */
1455 more = do_cmd_close_aux(y, x);
1459 /* Cancel repeat unless we may continue */
1460 if (!more) disturb(0, 0);
1465 * Determine if a given grid may be "tunneled"
1467 static bool do_cmd_tunnel_test(int y, int x)
1469 /* Must have knowledge */
1470 if (!(cave[y][x].info & (CAVE_MARK)))
1474 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1476 msg_print("You see nothing there.");
1484 /* Must be a wall/door/etc */
1485 if (cave_floor_bold(y, x))
1489 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1491 msg_print("You see nothing there to tunnel.");
1506 * Tunnel through wall. Assumes valid location.
1508 * Note that it is impossible to "extend" rooms past their
1509 * outer walls (which are actually part of the room).
1511 * This will, however, produce grids which are NOT illuminated
1512 * (or darkened) along with the rest of the room.
1514 static bool twall(int y, int x, byte feat)
1516 cave_type *c_ptr = &cave[y][x];
1518 /* Paranoia -- Require a wall or door or some such */
1519 if (cave_floor_bold(y, x)) return (FALSE);
1521 /* Forget the wall */
1522 c_ptr->info &= ~(CAVE_MARK);
1524 /* Remove the feature */
1525 cave_set_feat(y, x, feat);
1527 /* Update some things */
1528 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1537 * Perform the basic "tunnel" command
1539 * Assumes that the destination is a wall, a vein, a secret
1542 * Assumes that no monster is blocking the destination
1544 * Returns TRUE if repeated commands may continue
1546 static bool do_cmd_tunnel_aux(int y, int x)
1553 /* Verify legality */
1554 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1560 c_ptr = &cave[y][x];
1562 /* Feature code (applying "mimic" field) */
1563 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1569 if ((feat >= FEAT_PERM_EXTRA) &&
1570 (feat <= FEAT_PERM_SOLID))
1573 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1575 msg_print("This seems to be permanent rock.");
1580 /* No tunnelling through mountains */
1581 else if (feat == FEAT_MOUNTAIN)
1584 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1586 msg_print("You can't tunnel through that!");
1591 /* Map border (mimiccing Permanent wall) */
1592 else if ((c_ptr->feat >= FEAT_PERM_EXTRA &&
1593 c_ptr->feat <= FEAT_PERM_SOLID) ||
1594 c_ptr->feat == FEAT_MOUNTAIN)
1597 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1599 msg_print("You can't tunnel through that!");
1604 else if (feat == FEAT_TREES) /* -KMW- */
1607 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1610 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1612 msg_print("You have cleared away the trees.");
1614 chg_virtue(V_DILIGENCE, 1);
1615 chg_virtue(V_NATURE, -1);
1621 /* We may continue chopping */
1623 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1625 msg_print("You chop away at the tree.");
1630 /* Occasional Search XXX XXX */
1631 if (randint0(100) < 25) search();
1637 else if ((feat >= FEAT_WALL_EXTRA) &&
1638 (feat <= FEAT_WALL_SOLID))
1641 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1644 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1646 msg_print("You have finished the tunnel.");
1648 chg_virtue(V_DILIGENCE, 1);
1649 chg_virtue(V_NATURE, -1);
1655 /* We may continue tunelling */
1657 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1659 msg_print("You tunnel into the granite wall.");
1667 /* Quartz / Magma */
1668 else if ((feat >= FEAT_MAGMA) &&
1669 (feat <= FEAT_QUARTZ_K))
1675 /* Found gold (ignore mimic; maybe a hidden treasure) */
1676 if (c_ptr->feat >= FEAT_MAGMA_H &&
1677 c_ptr->feat <= FEAT_QUARTZ_K) gold = TRUE;
1679 /* Extract "quartz" flag XXX XXX XXX */
1680 if ((feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1685 okay = (p_ptr->skill_dig > 20 + randint0(800));
1691 okay = (p_ptr->skill_dig > 10 + randint0(400));
1695 if (okay && twall(y, x, floor_type[randint0(100)]))
1697 /* Found treasure */
1700 /* Place some gold */
1705 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1707 msg_print("You have found something!");
1717 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1719 msg_print("You have finished the tunnel.");
1721 chg_virtue(V_DILIGENCE, 1);
1722 chg_virtue(V_NATURE, -1);
1726 /* Failure (quartz) */
1729 /* Message, continue digging */
1731 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1733 msg_print("You tunnel into the quartz vein.");
1739 /* Failure (magma) */
1742 /* Message, continue digging */
1744 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1746 msg_print("You tunnel into the magma vein.");
1754 else if (feat == FEAT_RUBBLE)
1756 /* Remove the rubble */
1757 if ((p_ptr->skill_dig > randint0(200)) && twall(y, x, floor_type[randint0(100)]))
1761 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1763 msg_print("You have removed the rubble.");
1766 /* Hack -- place an object */
1767 if (randint0(100) < (15 - dun_level/2))
1769 /* Create a simple object */
1770 place_object(y, x, FALSE, FALSE);
1772 /* Observe new object */
1773 if (player_can_see_bold(y, x))
1776 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1778 msg_print("You have found something!");
1787 /* Message, keep digging */
1789 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1791 msg_print("You dig in the rubble.");
1802 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint1(100)]))
1805 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1807 msg_print("You have finished the tunnel.");
1815 /* We may continue tunelling */
1817 msg_print("¥É¥¢¤Ë·ê¤ò³«¤±¤Æ¤¤¤ë¡£");
1819 msg_print("You tunnel into the door.");
1826 if (is_hidden_door(c_ptr))
1828 /* Occasional Search XXX XXX */
1829 if (randint0(100) < 25) search();
1838 * Tunnels through "walls" (including rubble and closed doors)
1840 * Note that you must tunnel in order to hit invisible monsters
1841 * in walls, though moving into walls still takes a turn anyway.
1843 * Digging is very difficult without a "digger" weapon, but can be
1844 * accomplished by strong players using heavy weapons.
1846 void do_cmd_tunnel(void)
1856 if (p_ptr->special_defense & KATA_MUSOU)
1858 set_action(ACTION_NONE);
1861 /* Allow repeated command */
1864 /* Set repeat count */
1865 command_rep = command_arg - 1;
1867 /* Redraw the state */
1868 p_ptr->redraw |= (PR_STATE);
1870 /* Cancel the arg */
1874 /* Get a direction to tunnel, or Abort */
1875 if (get_rep_dir(&dir,FALSE))
1882 c_ptr = &cave[y][x];
1884 /* Feature code (applying "mimic" field) */
1885 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1887 /* No tunnelling through doors */
1888 if (((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL)) ||
1889 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
1890 ((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
1891 (feat == FEAT_MUSEUM))
1895 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1897 msg_print("You cannot tunnel through doors.");
1902 /* No tunnelling through air */
1903 else if (cave_floor_grid(c_ptr) || ((feat >= FEAT_MINOR_GLYPH) &&
1904 (feat <= FEAT_PATTERN_XTRA2)))
1908 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1910 msg_print("You cannot tunnel through air.");
1915 /* No tunnelling through mountains */
1916 else if (feat == FEAT_MOUNTAIN)
1919 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1921 msg_print("You can't tunnel through that!");
1926 /* A monster is in the way */
1927 else if (c_ptr->m_idx)
1934 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1936 msg_print("There is a monster in the way!");
1947 /* Tunnel through walls */
1948 more = do_cmd_tunnel_aux(y, x);
1952 /* Cancel repetition unless we can continue */
1953 if (!more) disturb(0, 0);
1957 #ifdef ALLOW_EASY_OPEN /* TNB */
1962 * If there is a jammed/closed/locked door at the given location,
1963 * then attempt to unlock/open it. Return TRUE if an attempt was
1964 * made (successful or not), otherwise return FALSE.
1966 * The code here should be nearly identical to that in
1967 * do_cmd_open_test() and do_cmd_open_aux().
1969 bool easy_open_door(int y, int x)
1973 cave_type *c_ptr = &cave[y][x];
1975 /* Must be a closed door */
1976 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1977 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1984 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1988 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1990 msg_print("The door appears to be stuck.");
1996 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1999 i = p_ptr->skill_dis;
2001 /* Penalize some conditions */
2002 if (p_ptr->blind || no_lite()) i = i / 10;
2003 if (p_ptr->confused || p_ptr->image) i = i / 10;
2005 /* Extract the lock power */
2006 j = c_ptr->feat - FEAT_DOOR_HEAD;
2008 /* Extract the difficulty XXX XXX XXX */
2011 /* Always have a small chance of success */
2015 if (randint0(100) < j)
2019 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
2021 msg_print("You have picked the lock.");
2026 cave_set_feat(y, x, FEAT_OPEN);
2028 /* Update some things */
2029 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2032 sound(SOUND_OPENDOOR);
2042 if (flush_failure) flush();
2046 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2048 msg_print("You failed to pick the lock.");
2058 cave_set_feat(y, x, FEAT_OPEN);
2060 /* Update some things */
2061 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2064 sound(SOUND_OPENDOOR);
2071 #endif /* ALLOW_EASY_OPEN -- TNB */
2075 * Perform the basic "disarm" command
2077 * Assume destination is a visible trap
2079 * Assume there is no monster blocking the destination
2081 * Returns TRUE if repeated commands may continue
2083 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2089 object_type *o_ptr = &o_list[o_idx];
2095 /* Get the "disarm" factor */
2096 i = p_ptr->skill_dis;
2098 /* Penalize some conditions */
2099 if (p_ptr->blind || no_lite()) i = i / 10;
2100 if (p_ptr->confused || p_ptr->image) i = i / 10;
2102 /* Extract the difficulty */
2103 j = i - o_ptr->pval;
2105 /* Always have a small chance of success */
2108 /* Must find the trap first. */
2109 if (!object_known_p(o_ptr))
2112 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2114 msg_print("I don't see any traps.");
2119 /* Already disarmed/unlocked */
2120 else if (o_ptr->pval <= 0)
2123 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2125 msg_print("The chest is not trapped.");
2130 /* No traps to find. */
2131 else if (!chest_traps[o_ptr->pval])
2134 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2136 msg_print("The chest is not trapped.");
2141 /* Success (get a lot of experience) */
2142 else if (randint0(100) < j)
2145 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2147 msg_print("You have disarmed the chest.");
2150 gain_exp(o_ptr->pval);
2151 o_ptr->pval = (0 - o_ptr->pval);
2154 /* Failure -- Keep trying */
2155 else if ((i > 5) && (randint1(i) > 5))
2157 /* We may keep trying */
2159 if (flush_failure) flush();
2161 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2163 msg_print("You failed to disarm the chest.");
2168 /* Failure -- Set off the trap */
2172 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2174 msg_print("You set off a trap!");
2178 chest_trap(y, x, o_idx);
2187 * Perform the basic "disarm" command
2189 * Assume destination is a visible trap
2191 * Assume there is no monster blocking the destination
2193 * Returns TRUE if repeated commands may continue
2195 #ifdef ALLOW_EASY_DISARM /* TNB */
2197 bool do_cmd_disarm_aux(int y, int x, int dir)
2199 #else /* ALLOW_EASY_DISARM -- TNB */
2201 static bool do_cmd_disarm_aux(int y, int x, int dir)
2203 #endif /* ALLOW_EASY_DISARM -- TNB */
2217 /* Get grid and contents */
2218 c_ptr = &cave[y][x];
2220 /* Access trap name */
2221 name = (f_name + f_info[c_ptr->feat].name);
2223 /* Get the "disarm" factor */
2224 i = p_ptr->skill_dis;
2226 /* Penalize some conditions */
2227 if (p_ptr->blind || no_lite()) i = i / 10;
2228 if (p_ptr->confused || p_ptr->image) i = i / 10;
2230 /* Variable power! */
2232 /* Extract trap "power" */
2233 switch (c_ptr->feat)
2235 case FEAT_TRAP_OPEN:
2236 case FEAT_TRAP_ARMAGEDDON:
2237 case FEAT_TRAP_PIRANHA:
2238 /* Special traps are very difficult to disarm */
2246 /* Extract the difficulty */
2249 /* Always have a small chance of success */
2253 if (randint0(100) < j)
2257 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2259 msg_format("You have disarmed the %s.", name);
2266 /* Forget the trap */
2267 c_ptr->info &= ~(CAVE_MARK);
2269 /* Remove the trap */
2270 cave_set_feat(y, x, floor_type[randint0(100)]);
2272 #ifdef ALLOW_EASY_DISARM /* TNB */
2274 /* Move the player onto the trap */
2275 move_player(dir, easy_disarm, FALSE);
2277 #else /* ALLOW_EASY_DISARM -- TNB */
2279 /* move the player onto the trap grid */
2280 move_player(dir, FALSE, FALSE);
2282 #endif /* ALLOW_EASY_DISARM -- TNB */
2285 /* Failure -- Keep trying */
2286 else if ((i > 5) && (randint1(i) > 5))
2289 if (flush_failure) flush();
2293 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2295 msg_format("You failed to disarm the %s.", name);
2299 /* We may keep trying */
2303 /* Failure -- Set off the trap */
2308 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2310 msg_format("You set off the %s!", name);
2314 #ifdef ALLOW_EASY_DISARM /* TNB */
2316 /* Move the player onto the trap */
2317 move_player(dir, easy_disarm, FALSE);
2319 #else /* ALLOW_EASY_DISARM -- TNB */
2321 /* Move the player onto the trap */
2322 move_player(dir, FALSE, FALSE);
2324 #endif /* ALLOW_EASY_DISARM -- TNB */
2333 * Disarms a trap, or chest
2335 void do_cmd_disarm(void)
2343 if (p_ptr->special_defense & KATA_MUSOU)
2345 set_action(ACTION_NONE);
2348 #ifdef ALLOW_EASY_DISARM /* TNB */
2350 /* Option: Pick a direction */
2353 int num_traps, num_chests;
2355 /* Count visible traps */
2356 num_traps = count_dt(&y, &x, is_trap, TRUE);
2358 /* Count chests (trapped) */
2359 num_chests = count_chests(&y, &x, TRUE);
2361 /* See if only one target */
2362 if (num_traps || num_chests)
2364 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2366 if (!too_many) command_dir = coords_to_dir(y, x);
2370 #endif /* ALLOW_EASY_DISARM -- TNB */
2372 /* Allow repeated command */
2375 /* Set repeat count */
2376 command_rep = command_arg - 1;
2378 /* Redraw the state */
2379 p_ptr->redraw |= (PR_STATE);
2381 /* Cancel the arg */
2385 /* Get a direction (or abort) */
2386 if (get_rep_dir(&dir,TRUE))
2395 /* Get grid and contents */
2396 c_ptr = &cave[y][x];
2398 /* Feature code (applying "mimic" field) */
2399 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2401 /* Check for chests */
2402 o_idx = chest_check(y, x);
2405 if (!is_trap(feat) && !o_idx)
2409 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2411 msg_print("You see nothing there to disarm.");
2416 /* Monster in the way */
2417 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2421 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2423 msg_print("There is a monster in the way!");
2434 /* Disarm the chest */
2435 more = do_cmd_disarm_chest(y, x, o_idx);
2441 /* Disarm the trap */
2442 more = do_cmd_disarm_aux(y, x, dir);
2446 /* Cancel repeat unless told not to */
2447 if (!more) disturb(0, 0);
2452 * Perform the basic "bash" command
2454 * Assume destination is a closed/locked/jammed door
2456 * Assume there is no monster blocking the destination
2458 * Returns TRUE if repeated commands may continue
2460 static bool do_cmd_bash_aux(int y, int x, int dir)
2473 c_ptr = &cave[y][x];
2477 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2479 msg_print("You smash into the door!");
2483 /* Hack -- Bash power based on strength */
2484 /* (Ranges from 3 to 20 to 100 to 200) */
2485 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2487 /* Extract door power */
2488 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2490 /* Compare bash power to door power XXX XXX XXX */
2491 temp = (bash - (temp * 10));
2493 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2495 /* Hack -- always have a chance */
2496 if (temp < 1) temp = 1;
2498 /* Hack -- attempt to bash down the door */
2499 if (randint0(100) < temp)
2503 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2505 msg_print("The door crashes open!");
2509 /* Break down the door */
2510 if (randint0(100) < 50)
2512 cave_set_feat(y, x, FEAT_BROKEN);
2518 cave_set_feat(y, x, FEAT_OPEN);
2522 sound(SOUND_OPENDOOR);
2524 /* Hack -- Fall through the door */
2525 move_player(dir, FALSE, FALSE);
2527 /* Update some things */
2528 p_ptr->update |= (PU_VIEW | PU_LITE);
2529 p_ptr->update |= (PU_DISTANCE);
2532 /* Saving throw against stun */
2533 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2538 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2540 msg_print("The door holds firm.");
2544 /* Allow repeated bashing */
2548 /* High dexterity yields coolness */
2553 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2555 msg_print("You are off-balance.");
2559 /* Hack -- Lose balance ala paralysis */
2560 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2569 * Bash open a door, success based on character strength
2571 * For a closed door, pval is positive if locked; negative if stuck.
2573 * For an open door, pval is positive for a broken door.
2575 * A closed door can be opened - harder if locked. Any door might be
2576 * bashed open (and thereby broken). Bashing a door is (potentially)
2577 * faster! You move into the door way. To open a stuck door, it must
2578 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2580 * Creatures can also open or bash doors, see elsewhere.
2582 void do_cmd_bash(void)
2591 if (p_ptr->special_defense & KATA_MUSOU)
2593 set_action(ACTION_NONE);
2596 /* Allow repeated command */
2599 /* Set repeat count */
2600 command_rep = command_arg - 1;
2602 /* Redraw the state */
2603 p_ptr->redraw |= (PR_STATE);
2605 /* Cancel the arg */
2609 /* Get a "repeated" direction */
2610 if (get_rep_dir(&dir,FALSE))
2619 c_ptr = &cave[y][x];
2621 /* Feature code (applying "mimic" field) */
2622 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2624 /* Nothing useful */
2625 if (!((feat >= FEAT_DOOR_HEAD) &&
2626 (feat <= FEAT_DOOR_TAIL)))
2630 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2632 msg_print("You see nothing there to bash.");
2637 /* Monster in the way */
2638 else if (c_ptr->m_idx)
2645 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2647 msg_print("There is a monster in the way!");
2655 /* Bash a closed door */
2659 more = do_cmd_bash_aux(y, x, dir);
2663 /* Unless valid action taken, cancel bash */
2664 if (!more) disturb(0, 0);
2669 * Manipulate an adjacent grid in some way
2671 * Attack monsters, tunnel through walls, disarm traps, open doors.
2673 * Consider confusion XXX XXX XXX
2675 * This command must always take a turn, to prevent free detection
2676 * of invisible monsters.
2678 void do_cmd_alter(void)
2687 if (p_ptr->special_defense & KATA_MUSOU)
2689 set_action(ACTION_NONE);
2692 /* Allow repeated command */
2695 /* Set repeat count */
2696 command_rep = command_arg - 1;
2698 /* Redraw the state */
2699 p_ptr->redraw |= (PR_STATE);
2701 /* Cancel the arg */
2705 /* Get a direction */
2706 if (get_rep_dir(&dir,TRUE))
2715 c_ptr = &cave[y][x];
2717 /* Feature code (applying "mimic" field) */
2718 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2723 /* Attack monsters */
2730 /* Tunnel through walls */
2731 else if (((feat >= FEAT_RUBBLE) &&
2732 (feat < FEAT_MINOR_GLYPH)) ||
2733 ((feat == FEAT_TREES) ||
2734 (feat == FEAT_MOUNTAIN)))
2736 more = do_cmd_tunnel_aux(y, x);
2739 else if (is_closed_door(feat))
2741 /* Bash jammed doors */
2742 if (feat >= FEAT_DOOR_HEAD + 0x08)
2744 more = do_cmd_bash_aux(y, x, dir);
2750 more = do_cmd_open_aux(y, x);
2754 /* Close open doors */
2755 else if ((feat == FEAT_OPEN) ||
2756 (feat == FEAT_BROKEN))
2758 more = do_cmd_close_aux(y, x);
2762 else if (is_trap(feat))
2764 more = do_cmd_disarm_aux(y, x, dir);
2772 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2774 msg_print("You attack the empty air.");
2780 /* Cancel repetition unless we can continue */
2781 if (!more) disturb(0, 0);
2786 * Find the index of some "spikes", if possible.
2788 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2790 static bool get_spike(int *ip)
2794 /* Check every item in the pack */
2795 for (i = 0; i < INVEN_PACK; i++)
2797 object_type *o_ptr = &inventory[i];
2799 /* Skip non-objects */
2800 if (!o_ptr->k_idx) continue;
2802 /* Check the "tval" code */
2803 if (o_ptr->tval == TV_SPIKE)
2805 /* Save the spike index */
2819 * Jam a closed door with a spike
2821 * This command may NOT be repeated
2823 void do_cmd_spike(void)
2827 if (p_ptr->special_defense & KATA_MUSOU)
2829 set_action(ACTION_NONE);
2832 /* Get a "repeated" direction */
2833 if (get_rep_dir(&dir,FALSE))
2843 /* Get grid and contents */
2844 c_ptr = &cave[y][x];
2846 /* Feature code (applying "mimic" field) */
2847 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2849 /* Require closed door */
2850 if (!((feat >= FEAT_DOOR_HEAD) &&
2851 (feat <= FEAT_DOOR_TAIL)))
2855 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2857 msg_print("You see nothing there to spike.");
2863 else if (!get_spike(&item))
2867 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2869 msg_print("You have no spikes!");
2874 /* Is a monster in the way? */
2875 else if (c_ptr->m_idx)
2882 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2884 msg_print("There is a monster in the way!");
2898 /* Successful jamming */
2900 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2902 msg_print("You jam the door with a spike.");
2906 /* Convert "locked" to "stuck" XXX XXX XXX */
2907 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2909 /* Add one spike to the door */
2910 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2912 /* Use up, and describe, a single spike, from the bottom */
2913 inven_item_increase(item, -1);
2914 inven_item_describe(item);
2915 inven_item_optimize(item);
2923 * Support code for the "Walk" and "Jump" commands
2925 void do_cmd_walk(int pickup)
2932 /* Allow repeated command */
2935 /* Set repeat count */
2936 command_rep = command_arg - 1;
2938 /* Redraw the state */
2939 p_ptr->redraw |= (PR_STATE);
2941 /* Cancel the arg */
2945 /* Get a "repeated" direction */
2946 if (get_rep_dir(&dir,FALSE))
2951 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2953 set_action(ACTION_NONE);
2956 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2957 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2958 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2960 /* Actually move the character */
2961 move_player(dir, pickup, FALSE);
2963 /* Allow more walking */
2967 /* Hack again -- Is there a special encounter ??? */
2968 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2970 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2973 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2975 /* Inform the player of his horrible fate :=) */
2977 msg_print("½±·â¤À¡ª");
2979 msg_print("You are ambushed !");
2982 /* Go into large wilderness view */
2983 p_ptr->wilderness_x = px;
2984 p_ptr->wilderness_y = py;
2985 p_ptr->oldpy = randint1(MAX_HGT-2);
2986 p_ptr->oldpx = randint1(MAX_WID-2);
2990 /* HACk -- set the encouter flag for the wilderness generation */
2991 generate_encounter = TRUE;
2995 /* Cancel repeat unless we may continue */
2996 if (!more) disturb(0, 0);
3004 void do_cmd_run(void)
3008 /* Hack -- no running when confused */
3009 if (p_ptr->confused)
3012 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
3014 msg_print("You are too confused!");
3020 if (p_ptr->special_defense & KATA_MUSOU)
3022 set_action(ACTION_NONE);
3025 /* Get a "repeated" direction */
3026 if (get_rep_dir(&dir,FALSE))
3028 /* Hack -- Set the run counter */
3029 running = (command_arg ? command_arg : 1000);
3039 * Stay still. Search. Enter stores.
3040 * Pick up treasure if "pickup" is true.
3042 void do_cmd_stay(int pickup)
3044 cave_type *c_ptr = &cave[py][px];
3047 /* Allow repeated command */
3050 /* Set repeat count */
3051 command_rep = command_arg - 1;
3053 /* Redraw the state */
3054 p_ptr->redraw |= (PR_STATE);
3056 /* Cancel the arg */
3065 /* Spontaneous Searching */
3066 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3071 /* Continuous Searching */
3072 if (p_ptr->action == ACTION_SEARCH)
3078 /* Handle "objects" */
3082 /* Hack -- enter a store if we are on one */
3083 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3084 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3085 (c_ptr->feat == FEAT_MUSEUM))
3091 /* Hack -- enter store */
3092 command_new = SPECIAL_KEY_STORE;
3095 /* Hack -- enter a building if we are on one -KMW- */
3096 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3097 (c_ptr->feat <= FEAT_BLDG_TAIL))
3103 /* Hack -- enter building */
3104 command_new = SPECIAL_KEY_BUILDING;
3107 /* Exit a quest if reach the quest exit */
3108 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3110 int q_index = p_ptr->inside_quest;
3112 /* Was quest completed? */
3113 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3115 quest[q_index].status = QUEST_STATUS_COMPLETED;
3116 quest[q_index].complev = (byte)p_ptr->lev;
3118 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3120 msg_print("You accomplished your quest!");
3126 leave_quest_check();
3128 p_ptr->inside_quest = cave[py][px].special;
3132 p_ptr->leaving = TRUE;
3139 * Resting allows a player to safely restore his hp -RAK-
3141 void do_cmd_rest(void)
3144 set_action(ACTION_NONE);
3146 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3151 /* Prompt for time if needed */
3152 if (command_arg <= 0)
3155 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3157 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3164 strcpy(out_val, "&");
3166 /* Ask for duration */
3167 if (!get_string(p, out_val, 4)) return;
3169 /* Rest until done */
3170 if (out_val[0] == '&')
3176 else if (out_val[0] == '*')
3184 command_arg = atoi(out_val);
3185 if (command_arg <= 0) return;
3191 if (command_arg > 9999) command_arg = 9999;
3193 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3195 /* Take a turn XXX XXX XXX (?) */
3198 /* The sin of sloth */
3199 if (command_arg > 100)
3200 chg_virtue(V_DILIGENCE, -1);
3202 /* Why are you sleeping when there's no need? WAKE UP!*/
3203 if ((p_ptr->chp == p_ptr->mhp) &&
3204 (p_ptr->csp == p_ptr->msp) &&
3205 !p_ptr->blind && !p_ptr->confused &&
3206 !p_ptr->poisoned && !p_ptr->afraid &&
3207 !p_ptr->stun && !p_ptr->cut &&
3208 !p_ptr->slow && !p_ptr->paralyzed &&
3209 !p_ptr->image && !p_ptr->word_recall)
3210 chg_virtue(V_DILIGENCE, -1);
3212 /* Save the rest code */
3213 resting = command_arg;
3214 p_ptr->action = ACTION_REST;
3216 /* Recalculate bonuses */
3217 p_ptr->update |= (PU_BONUS);
3219 /* Redraw the state */
3220 p_ptr->redraw |= (PR_STATE);
3231 * Determines the odds of an object breaking when thrown at a monster
3233 * Note that artifacts never break, see the "drop_near()" function.
3235 static int breakage_chance(object_type *o_ptr)
3237 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3239 /* Examine the item type */
3240 switch (o_ptr->tval)
3256 /* Sometimes break */
3261 return (20 - archer_bonus * 2);
3266 return (10 - archer_bonus);
3273 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3277 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3279 u32b flgs[TR_FLAG_SIZE];
3281 /* Extract the flags */
3282 object_flags(o_ptr, flgs);
3284 /* Some "weapons" and "ammo" do extra damage */
3285 switch (o_ptr->tval)
3292 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3293 (r_ptr->flags3 & RF3_ANIMAL))
3297 r_ptr->r_flags3 |= RF3_ANIMAL;
3300 if (mult < 17) mult = 17;
3304 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3305 (r_ptr->flags3 & RF3_ANIMAL))
3309 r_ptr->r_flags3 |= RF3_ANIMAL;
3312 if (mult < 27) mult = 27;
3316 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3317 (r_ptr->flags3 & RF3_EVIL))
3321 r_ptr->r_flags3 |= RF3_EVIL;
3324 if (mult < 15) mult = 15;
3328 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3329 (r_ptr->flags3 & RF3_EVIL))
3333 r_ptr->r_flags3 |= RF3_EVIL;
3336 if (mult < 25) mult = 25;
3340 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3341 (r_ptr->flags2 & RF2_HUMAN))
3345 r_ptr->r_flags2 |= RF2_HUMAN;
3348 if (mult < 17) mult = 17;
3352 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3353 (r_ptr->flags2 & RF2_HUMAN))
3357 r_ptr->r_flags2 |= RF2_HUMAN;
3360 if (mult < 27) mult = 27;
3364 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3365 (r_ptr->flags3 & RF3_UNDEAD))
3369 r_ptr->r_flags3 |= RF3_UNDEAD;
3372 if (mult < 20) mult = 20;
3376 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3377 (r_ptr->flags3 & RF3_UNDEAD))
3381 r_ptr->r_flags3 |= RF3_UNDEAD;
3384 if (mult < 30) mult = 30;
3388 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3389 (r_ptr->flags3 & RF3_DEMON))
3393 r_ptr->r_flags3 |= RF3_DEMON;
3396 if (mult < 20) mult = 20;
3400 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3401 (r_ptr->flags3 & RF3_DEMON))
3405 r_ptr->r_flags3 |= RF3_DEMON;
3408 if (mult < 30) mult = 30;
3412 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3413 (r_ptr->flags3 & RF3_ORC))
3417 r_ptr->r_flags3 |= RF3_ORC;
3420 if (mult < 20) mult = 20;
3424 if ((have_flag(flgs, TR_KILL_ORC)) &&
3425 (r_ptr->flags3 & RF3_ORC))
3429 r_ptr->r_flags3 |= RF3_ORC;
3432 if (mult < 30) mult = 30;
3436 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3437 (r_ptr->flags3 & RF3_TROLL))
3441 r_ptr->r_flags3 |= RF3_TROLL;
3444 if (mult < 20) mult = 20;
3448 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3449 (r_ptr->flags3 & RF3_TROLL))
3453 r_ptr->r_flags3 |= RF3_TROLL;
3456 if (mult < 30) mult = 30;
3460 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3461 (r_ptr->flags3 & RF3_GIANT))
3465 r_ptr->r_flags3 |= RF3_GIANT;
3468 if (mult < 20) mult = 20;
3472 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3473 (r_ptr->flags3 & RF3_GIANT))
3477 r_ptr->r_flags3 |= RF3_GIANT;
3480 if (mult < 30) mult = 30;
3484 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3485 (r_ptr->flags3 & RF3_DRAGON))
3489 r_ptr->r_flags3 |= RF3_DRAGON;
3492 if (mult < 20) mult = 20;
3495 /* Execute Dragon */
3496 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3497 (r_ptr->flags3 & RF3_DRAGON))
3501 r_ptr->r_flags3 |= RF3_DRAGON;
3504 if (mult < 30) mult = 30;
3506 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3507 (m_ptr->r_idx == MON_SMAUG) &&
3508 (inventory[INVEN_BOW].name1 == ART_BARD))
3513 if ((have_flag(flgs, TR_BRAND_ACID)) || (p_ptr->special_attack & (ATTACK_ACID)))
3515 /* Notice immunity */
3516 if (r_ptr->flags3 & RF3_IM_ACID)
3520 r_ptr->r_flags3 |= RF3_IM_ACID;
3524 /* Otherwise, take the damage */
3527 if (mult < 17) mult = 17;
3532 if ((have_flag(flgs, TR_BRAND_ELEC)) || (p_ptr->special_attack & (ATTACK_ELEC)))
3534 /* Notice immunity */
3535 if (r_ptr->flags3 & RF3_IM_ELEC)
3539 r_ptr->r_flags3 |= RF3_IM_ELEC;
3543 /* Otherwise, take the damage */
3546 if (mult < 17) mult = 17;
3551 if ((have_flag(flgs, TR_BRAND_FIRE)) || (p_ptr->special_attack & (ATTACK_FIRE)))
3553 /* Notice immunity */
3554 if (r_ptr->flags3 & RF3_IM_FIRE)
3558 r_ptr->r_flags3 |= RF3_IM_FIRE;
3562 /* Otherwise, take the damage */
3565 if (mult < 17) mult = 17;
3570 if ((have_flag(flgs, TR_BRAND_COLD)) || (p_ptr->special_attack & (ATTACK_COLD)))
3572 /* Notice immunity */
3573 if (r_ptr->flags3 & RF3_IM_COLD)
3577 r_ptr->r_flags3 |= RF3_IM_COLD;
3580 /* Otherwise, take the damage */
3583 if (mult < 17) mult = 17;
3587 /* Brand (Poison) */
3588 if ((have_flag(flgs, TR_BRAND_POIS)) || (p_ptr->special_attack & (ATTACK_POIS)))
3590 /* Notice immunity */
3591 if (r_ptr->flags3 & RF3_IM_POIS)
3595 r_ptr->r_flags3 |= RF3_IM_POIS;
3599 /* Otherwise, take the damage */
3602 if (mult < 17) mult = 17;
3606 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3608 p_ptr->csp -= (1+(p_ptr->msp / 30));
3609 p_ptr->redraw |= (PR_MANA);
3610 mult = mult * 5 / 2;
3616 /* Return the total damage */
3617 return (tdam * mult / 10);
3622 * Fire an object from the pack or floor.
3624 * You may only fire items that "match" your missile launcher.
3626 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3628 * See "calc_bonuses()" for more calculations and such.
3630 * Note that "firing" a missile is MUCH better than "throwing" it.
3632 * Note: "unseen" monsters are very hard to hit.
3634 * Objects are more likely to break if they "attempt" to hit a monster.
3636 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3638 * The "extra shot" code works by decreasing the amount of energy
3639 * required to make each shot, spreading the shots out over time.
3641 * Note that when firing missiles, the launcher multiplier is applied
3642 * after all the bonuses are added in, making multipliers very useful.
3644 * Note that Bows of "Extra Might" get extra range and an extra bonus
3645 * for the damage multiplier.
3647 * Note that Bows of "Extra Shots" give an extra shot.
3649 void do_cmd_fire_aux(int item, object_type *j_ptr)
3652 int j, y, x, ny, nx, ty, tx;
3653 int tdam, tdis, thits, tmul;
3655 int cur_dis, visible;
3662 bool hit_body = FALSE;
3664 char o_name[MAX_NLEN];
3666 int msec = delay_factor * delay_factor * delay_factor;
3669 bool stick_to = FALSE;
3671 /* Access the item (if in the pack) */
3674 o_ptr = &inventory[item];
3678 o_ptr = &o_list[0 - item];
3681 /* Describe the object */
3682 object_desc(o_name, o_ptr, FALSE, 3);
3685 /* Use the proper number of shots */
3686 thits = p_ptr->num_fire;
3688 /* Use a base distance */
3691 /* Base damage from thrown object plus launcher bonus */
3692 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3694 /* Actually "fire" the object */
3695 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3696 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3697 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval])/400 + bonus) * BTH_PLUS_ADJ);
3699 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3701 energy_use = bow_energy(j_ptr->sval);
3702 tmul = bow_tmul(j_ptr->sval);
3704 /* Get extra "power" from "extra might" */
3705 if (p_ptr->xtra_might) tmul++;
3707 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3709 /* Boost the damage */
3714 tdis = 10 + tmul/40;
3715 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3718 project_length = tdis + 1;
3720 /* Get a direction (or cancel) */
3721 if (!get_aim_dir(&dir))
3725 /* need not to reset project_length (already did)*/
3729 project_length = 0; /* reset to default */
3731 /* Get local object */
3734 /* Obtain a local object */
3735 object_copy(q_ptr, o_ptr);
3740 /* Reduce and describe inventory */
3743 inven_item_increase(item, -1);
3744 inven_item_describe(item);
3745 inven_item_optimize(item);
3748 /* Reduce and describe floor item */
3751 floor_item_increase(0 - item, -1);
3752 floor_item_optimize(0 - item);
3760 /* Take a (partial) turn */
3761 energy_use = (energy_use / thits);
3764 /* Start at the player */
3768 /* Predict the "target" location */
3769 tx = px + 99 * ddx[dir];
3770 ty = py + 99 * ddy[dir];
3772 /* Check for "target request" */
3773 if ((dir == 5) && target_okay())
3780 /* Hack -- Handle stuff */
3784 /* Travel until stopped */
3785 for (cur_dis = 0; cur_dis <= tdis; )
3787 /* Hack -- Stop at the target */
3788 if ((y == ty) && (x == tx)) break;
3790 /* Calculate the new location (see "project()") */
3793 mmove2(&ny, &nx, py, px, ty, tx);
3795 /* Stopped by walls/doors */
3796 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3798 /* Advance the distance */
3802 /* The player can see the (on screen) missile */
3803 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3805 char c = object_char(q_ptr);
3806 byte a = object_attr(q_ptr);
3808 /* Draw, Hilite, Fresh, Pause, Erase */
3809 print_rel(c, a, ny, nx);
3810 move_cursor_relative(ny, nx);
3812 Term_xtra(TERM_XTRA_DELAY, msec);
3817 /* The player cannot see the missile */
3820 /* Pause anyway, for consistancy */
3821 Term_xtra(TERM_XTRA_DELAY, msec);
3824 /* Save the new location */
3829 /* Monster here, Try to hit it */
3830 if (cave[y][x].m_idx)
3832 cave_type *c_ptr = &cave[y][x];
3834 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3835 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3837 /* Check the visibility */
3838 visible = m_ptr->ml;
3840 /* Note the collision */
3845 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3846 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3849 if ((r_ptr->level + 10) > p_ptr->lev)
3851 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3852 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3855 if (now_exp < 4000) amount = 80;
3856 else if (now_exp < 6000) amount = 25;
3857 else if ((now_exp < 7000) && (p_ptr->lev > 19)) amount = 10;
3858 else if (p_ptr->lev > 34) amount = 2;
3859 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3860 p_ptr->update |= (PU_BONUS);
3866 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))
3868 p_ptr->skill_exp[GINOU_RIDING]+=1;
3869 p_ptr->update |= (PU_BONUS);
3873 /* Did we hit it (penalize range) */
3874 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3878 /* Assume a default death */
3880 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3882 cptr note_dies = " dies.";
3885 /* Some monsters get "destroyed" */
3886 if (!monster_living(r_ptr))
3889 bool explode = FALSE;
3891 for (i = 0; i < 4; i++)
3893 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3896 /* Special note at death */
3899 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3901 note_dies = " explodes into tiny shreds.";
3905 note_dies = "¤òÅݤ·¤¿¡£";
3907 note_dies = " is destroyed.";
3912 /* Handle unseen monster */
3915 /* Invisible monster */
3917 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3919 msg_format("The %s finds a mark.", o_name);
3924 /* Handle visible monster */
3929 /* Get "the monster" or "it" */
3930 monster_desc(m_name, m_ptr, 0);
3934 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3936 msg_format("The %s hits %s.", o_name, m_name);
3940 /* Hack -- Track this monster race */
3941 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3943 /* Hack -- Track this monster */
3944 if (m_ptr->ml) health_track(c_ptr->m_idx);
3947 /* Apply special damage XXX XXX XXX */
3948 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3949 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3951 /* No negative damage */
3952 if (tdam < 0) tdam = 0;
3954 /* Modify the damage */
3955 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3957 /* Complex message */
3958 if (p_ptr->wizard || cheat_xtra)
3961 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3964 msg_format("You do %d (out of %d) damage.",
3970 /* Hit the monster, check for death */
3971 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3984 monster_desc(m_name, m_ptr, 0);
3988 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3990 msg_format("%^s have stuck into %s!",o_name, m_name);
3995 message_pain(c_ptr->m_idx, tdam);
3997 /* Anger the monster */
3998 if (tdam > 0) anger_monster(m_ptr);
4001 if (fear && m_ptr->ml)
4008 /* Get the monster name (or "it") */
4009 monster_desc(m_name, m_ptr, 0);
4013 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4015 msg_format("%^s flees in terror!", m_name);
4019 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
4021 set_target(m_ptr, py, px);
4031 /* Chance of breakage (during attacks) */
4032 j = (hit_body ? breakage_chance(q_ptr) : 0);
4036 int m_idx = cave[y][x].m_idx;
4037 monster_type *m_ptr = &m_list[m_idx];
4038 int o_idx = o_pop();
4043 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
4045 msg_format("The %s have gone to somewhere.", o_name);
4049 a_info[j_ptr->name1].cur_num = 0;
4054 o_ptr = &o_list[ o_idx ];
4055 object_copy(o_ptr, q_ptr);
4060 /* Forget location */
4061 o_ptr->iy = o_ptr->ix = 0;
4063 /* Memorize monster */
4064 o_ptr->held_m_idx = m_idx;
4067 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4070 m_ptr->hold_o_idx = o_idx;
4074 /* Drop (or break) near that location */
4075 (void)drop_near(q_ptr, j, y, x);
4079 void do_cmd_fire(void)
4085 /* Get the "bow" (if any) */
4086 j_ptr = &inventory[INVEN_BOW];
4088 /* Require a launcher */
4092 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4094 msg_print("You have nothing to fire with.");
4100 if (j_ptr->sval == SV_CRIMSON)
4103 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4105 msg_print("Do activate.");
4112 if (p_ptr->special_defense & KATA_MUSOU)
4114 set_action(ACTION_NONE);
4117 /* Require proper missile */
4118 item_tester_tval = p_ptr->tval_ammo;
4122 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4123 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4125 q = "Fire which item? ";
4126 s = "You have nothing to fire.";
4129 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4136 do_cmd_fire_aux(item, j_ptr);
4140 static bool item_tester_hook_boomerang(object_type *o_ptr)
4142 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4150 * Throw an object from the pack or floor.
4152 * Note: "unseen" monsters are very hard to hit.
4154 * Should throwing a weapon do full damage? Should it allow the magic
4155 * to hit bonus of the weapon to have an effect? Should it ever cause
4156 * the item to be destroyed? Should it do any damage at all?
4158 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4161 int i, j, y, x, ty, tx;
4163 int chance, tdam, tdis;
4165 int cur_dis, visible;
4172 bool hit_body = FALSE;
4173 bool hit_wall = FALSE;
4174 bool equiped_item = FALSE;
4175 bool return_when_thrown = FALSE;
4177 char o_name[MAX_NLEN];
4179 int msec = delay_factor * delay_factor * delay_factor;
4181 u32b flgs[TR_FLAG_SIZE];
4183 bool come_back = FALSE;
4184 bool do_drop = TRUE;
4187 if (p_ptr->special_defense & KATA_MUSOU)
4189 set_action(ACTION_NONE);
4198 if (buki_motteruka(INVEN_LARM))
4200 item_tester_hook = item_tester_hook_boomerang;
4202 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4203 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4205 q = "Throw which item? ";
4206 s = "You have nothing to throw.";
4209 if (!get_item(&item, q, s, (USE_EQUIP)))
4224 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4225 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4227 q = "Throw which item? ";
4228 s = "You have nothing to throw.";
4231 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4238 /* Access the item (if in the pack) */
4241 o_ptr = &inventory[item];
4245 o_ptr = &o_list[0 - item];
4249 /* Item is cursed */
4250 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4254 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4256 msg_print("Hmmm, it seems to be cursed.");
4263 if (p_ptr->inside_arena)
4265 if (o_ptr->tval != 5)
4268 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4270 msg_print("You're in the arena now. This is hand-to-hand!");
4279 /* Get local object */
4282 /* Obtain a local object */
4283 object_copy(q_ptr, o_ptr);
4285 /* Extract the thrown object's flags. */
4286 object_flags(q_ptr, flgs);
4288 /* Distribute the charges of rods/wands between the stacks */
4289 distribute_charges(o_ptr, q_ptr, 1);
4295 object_desc(o_name, q_ptr, FALSE, 3);
4297 if (p_ptr->mighty_throw) mult += 3;
4299 /* Extract a "distance multiplier" */
4300 /* Changed for 'launcher' mutation */
4301 mul = 10 + 2 * (mult - 1);
4303 /* Enforce a minimum "weight" of one pound */
4304 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4305 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4307 /* Hack -- Distance -- Reward strength, penalize weight */
4308 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4310 /* Max distance of 10-18 */
4311 if (tdis > mul) tdis = mul;
4315 ty = randint0(101)-50+py;
4316 tx = randint0(101)-50+px;
4320 project_length = tdis + 1;
4322 /* Get a direction (or cancel) */
4323 if (!get_aim_dir(&dir)) return FALSE;
4325 project_length = 0; /* reset to default */
4327 /* Predict the "target" location */
4328 tx = px + 99 * ddx[dir];
4329 ty = py + 99 * ddy[dir];
4331 /* Check for "target request" */
4332 if ((dir == 5) && target_okay())
4339 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4340 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4341 return_when_thrown = TRUE;
4343 /* Reduce and describe inventory */
4346 inven_item_increase(item, -1);
4347 if (!return_when_thrown)
4348 inven_item_describe(item);
4349 inven_item_optimize(item);
4352 /* Reduce and describe floor item */
4355 floor_item_increase(0 - item, -1);
4356 floor_item_optimize(0 - item);
4358 if (item >= INVEN_RARM)
4360 equiped_item = TRUE;
4361 p_ptr->redraw |= (PR_EQUIPPY);
4367 /* Rogue and Ninja gets bonus */
4368 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4369 energy_use -= p_ptr->lev;
4371 /* Start at the player */
4376 /* Hack -- Handle stuff */
4379 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4380 else shuriken = FALSE;
4382 /* Chance of hitting */
4383 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4384 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4385 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4387 if (shuriken) chance *= 2;
4389 /* Travel until stopped */
4390 for (cur_dis = 0; cur_dis <= tdis; )
4392 /* Hack -- Stop at the target */
4393 if ((y == ty) && (x == tx)) break;
4395 /* Calculate the new location (see "project()") */
4398 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4400 /* Stopped by walls/doors */
4401 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4407 /* Advance the distance */
4410 /* The player can see the (on screen) missile */
4411 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4413 char c = object_char(q_ptr);
4414 byte a = object_attr(q_ptr);
4416 /* Draw, Hilite, Fresh, Pause, Erase */
4417 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4418 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4420 Term_xtra(TERM_XTRA_DELAY, msec);
4421 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4425 /* The player cannot see the missile */
4428 /* Pause anyway, for consistancy */
4429 Term_xtra(TERM_XTRA_DELAY, msec);
4432 /* Save the new location */
4437 /* Monster here, Try to hit it */
4438 if (cave[y][x].m_idx)
4440 cave_type *c_ptr = &cave[y][x];
4442 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4443 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4445 /* Check the visibility */
4446 visible = m_ptr->ml;
4448 /* Note the collision */
4451 /* Did we hit it (penalize range) */
4452 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4456 /* Assume a default death */
4458 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4460 cptr note_dies = " dies.";
4464 /* Some monsters get "destroyed" */
4465 if (!monster_living(r_ptr))
4468 bool explode = FALSE;
4470 for (i = 0; i < 4; i++)
4472 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4475 /* Special note at death */
4478 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4480 note_dies = " explodes into tiny shreds.";
4484 note_dies = "¤òÅݤ·¤¿¡£";
4486 note_dies = " is destroyed.";
4492 /* Handle unseen monster */
4495 /* Invisible monster */
4497 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4499 msg_format("The %s finds a mark.", o_name);
4504 /* Handle visible monster */
4509 /* Get "the monster" or "it" */
4510 monster_desc(m_name, m_ptr, 0);
4514 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4516 msg_format("The %s hits %s.", o_name, m_name);
4520 /* Hack -- Track this monster race */
4521 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4523 /* Hack -- Track this monster */
4524 if (m_ptr->ml) health_track(c_ptr->m_idx);
4527 /* Hack -- Base damage from thrown object */
4528 tdam = damroll(q_ptr->dd, q_ptr->ds);
4529 /* Apply special damage XXX XXX XXX */
4530 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4531 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4532 if (q_ptr->to_d > 0)
4533 tdam += q_ptr->to_d;
4535 tdam += -q_ptr->to_d;
4539 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4540 tdam += p_ptr->to_d_m;
4542 else if (have_flag(flgs, TR_THROW))
4545 tdam += p_ptr->to_d_m;
4553 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4556 /* No negative damage */
4557 if (tdam < 0) tdam = 0;
4559 /* Modify the damage */
4560 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4562 /* Complex message */
4566 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4569 msg_format("You do %d (out of %d) damage.",
4575 /* Hit the monster, check for death */
4576 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4585 message_pain(c_ptr->m_idx, tdam);
4587 /* Anger the monster */
4588 if ((tdam > 0) && !object_is_potion(q_ptr))
4589 anger_monster(m_ptr);
4592 if (fear && m_ptr->ml)
4599 /* Get the monster name (or "it") */
4600 monster_desc(m_name, m_ptr, 0);
4604 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4606 msg_format("%^s flees in terror!", m_name);
4618 /* Chance of breakage (during attacks) */
4619 j = (hit_body ? breakage_chance(q_ptr) : 0);
4621 /* Figurines transform */
4622 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4626 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4627 !(cursed_p(q_ptr)) ? PM_FORCE_PET : 0L)))
4629 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4631 msg_print("The Figurine writhes and then shatters.");
4634 else if (cursed_p(q_ptr))
4636 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4638 msg_print("You have a bad feeling about this.");
4644 /* Potions smash open */
4645 if (object_is_potion(q_ptr))
4647 if (hit_body || hit_wall || (randint1(100) < j))
4651 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4653 msg_format("The %s shatters!", o_name);
4657 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4659 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4661 /* ToDo (Robert): fix the invulnerability */
4662 if (cave[y][x].m_idx &&
4663 is_friendly(&m_list[cave[y][x].m_idx]) &&
4667 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4669 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4671 msg_format("%^s gets angry!", m_name);
4674 set_hostile(&m_list[cave[y][x].m_idx]);
4685 if (return_when_thrown)
4687 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4688 char o2_name[MAX_NLEN];
4689 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4692 if (boomerang) back_chance += 4+randint1(5);
4693 if (super_boomerang) back_chance += 100;
4694 object_desc(o2_name, q_ptr, FALSE, 0);
4696 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4698 for (i = cur_dis-1;i>0;i--)
4700 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4702 char c = object_char(q_ptr);
4703 byte a = object_attr(q_ptr);
4705 /* Draw, Hilite, Fresh, Pause, Erase */
4706 print_rel(c, a, ny[i], nx[i]);
4707 move_cursor_relative(ny[i], nx[i]);
4709 Term_xtra(TERM_XTRA_DELAY, msec);
4710 lite_spot(ny[i], nx[i]);
4715 /* Pause anyway, for consistancy */
4716 Term_xtra(TERM_XTRA_DELAY, msec);
4719 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4722 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4724 msg_format("%s comes back to you.", o2_name);
4733 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4735 msg_format("%s backs, but you can't catch!", o2_name);
4741 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4743 msg_format("%s comes back.", o2_name);
4753 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4755 msg_format("%s doesn't back!", o2_name);
4762 if (item == INVEN_RARM || item == INVEN_LARM)
4764 /* Access the wield slot */
4765 o_ptr = &inventory[item];
4767 /* Wear the new stuff */
4768 object_copy(o_ptr, q_ptr);
4770 /* Increase the weight */
4771 p_ptr->total_weight += q_ptr->weight;
4773 /* Increment the equip counter by hand */
4776 /* Recalculate bonuses */
4777 p_ptr->update |= (PU_BONUS);
4779 /* Recalculate torch */
4780 p_ptr->update |= (PU_TORCH);
4782 /* Recalculate mana XXX */
4783 p_ptr->update |= (PU_MANA);
4786 p_ptr->window |= (PW_EQUIP);
4794 else if (equiped_item)
4800 /* Drop (or break) near that location */
4801 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4808 * Throw an object from the pack or floor.
4810 void do_cmd_throw(void)
4812 do_cmd_throw_aux(1, FALSE, 0);