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);
952 static bool is_closed(int feat)
954 return ((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL));
958 * Return the number of features around (or under) the character.
959 * Usually look for doors and floor traps.
961 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
963 int d, count, xx, yy;
965 /* Count how many matches */
968 /* Check around (and under) the character */
969 for (d = 0; d < 9; d++)
971 /* if not searching under player continue */
972 if ((d == 8) && !under) continue;
974 /* Extract adjacent (legal) location */
975 yy = py + ddy_ddd[d];
976 xx = px + ddx_ddd[d];
978 /* Must have knowledge */
979 if (!(cave[yy][xx].info & (CAVE_MARK))) continue;
981 /* Not looking for this feature */
982 if (!((*test)(cave[yy][xx].feat))) continue;
987 /* Remember the location. Only useful if only one match */
998 * Return the number of chests around (or under) the character.
999 * If requested, count only trapped chests.
1001 static int count_chests(int *y, int *x, bool trapped)
1003 int d, count, o_idx;
1007 /* Count how many matches */
1010 /* Check around (and under) the character */
1011 for (d = 0; d < 9; d++)
1013 /* Extract adjacent (legal) location */
1014 int yy = py + ddy_ddd[d];
1015 int xx = px + ddx_ddd[d];
1017 /* No (visible) chest is there */
1018 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1020 /* Grab the object */
1021 o_ptr = &o_list[o_idx];
1024 if (o_ptr->pval == 0) continue;
1026 /* No (known) traps here */
1027 if (trapped && (!object_known_p(o_ptr) ||
1028 !chest_traps[o_ptr->pval])) continue;
1033 /* Remember the location. Only useful if only one match */
1044 * Convert an adjacent location to a direction.
1046 static int coords_to_dir(int y, int x)
1048 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1055 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1057 return d[dx + 1][dy + 1];
1060 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1064 * Perform the basic "open" command on doors
1066 * Assume destination is a closed/locked/jammed door
1068 * Assume there is no monster blocking the destination
1070 * Returns TRUE if repeated commands may continue
1072 static bool do_cmd_open_aux(int y, int x, int dir)
1084 /* Get requested grid */
1085 c_ptr = &cave[y][x];
1088 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1092 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1094 msg_print("The door appears to be stuck.");
1100 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1103 i = p_ptr->skill_dis;
1105 /* Penalize some conditions */
1106 if (p_ptr->blind || no_lite()) i = i / 10;
1107 if (p_ptr->confused || p_ptr->image) i = i / 10;
1109 /* Extract the lock power */
1110 j = c_ptr->feat - FEAT_DOOR_HEAD;
1112 /* Extract the difficulty XXX XXX XXX */
1115 /* Always have a small chance of success */
1119 if (randint0(100) < j)
1123 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1125 msg_print("You have picked the lock.");
1130 cave_set_feat(y, x, FEAT_OPEN);
1132 /* Update some things */
1133 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1136 sound(SOUND_OPENDOOR);
1146 if (flush_failure) flush();
1150 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1152 msg_print("You failed to pick the lock.");
1156 /* We may keep trying */
1165 cave_set_feat(y, x, FEAT_OPEN);
1167 /* Update some things */
1168 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1171 sound(SOUND_OPENDOOR);
1181 * Open a closed/locked/jammed door or a closed/locked chest.
1183 * Unlocking a locked door/chest is worth one experience point.
1185 void do_cmd_open(void)
1195 if (p_ptr->special_defense & KATA_MUSOU)
1197 set_action(ACTION_NONE);
1200 #ifdef ALLOW_EASY_OPEN /* TNB */
1202 /* Option: Pick a direction */
1205 int num_doors, num_chests;
1207 /* Count closed doors (locked or jammed) */
1208 num_doors = count_dt(&y, &x, is_closed, FALSE);
1210 /* Count chests (locked) */
1211 num_chests = count_chests(&y, &x, FALSE);
1213 /* See if only one target */
1214 if (num_doors || num_chests)
1216 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1218 if (!too_many) command_dir = coords_to_dir(y, x);
1222 #endif /* ALLOW_EASY_OPEN -- TNB */
1224 /* Allow repeated command */
1227 /* Set repeat count */
1228 command_rep = command_arg - 1;
1230 /* Redraw the state */
1231 p_ptr->redraw |= (PR_STATE);
1233 /* Cancel the arg */
1237 /* Get a "repeated" direction */
1238 if (get_rep_dir(&dir, TRUE))
1240 /* Get requested location */
1244 /* Get requested grid */
1245 c_ptr = &cave[y][x];
1247 /* Check for chest */
1248 o_idx = chest_check(y, x);
1250 /* Nothing useful */
1251 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1252 (c_ptr->feat <= FEAT_DOOR_TAIL)) &&
1257 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1259 msg_print("You see nothing there to open.");
1264 /* Monster in the way */
1265 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1272 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1274 msg_print("There is a monster in the way!");
1285 /* Open the chest */
1286 more = do_cmd_open_chest(y, x, o_idx);
1293 more = do_cmd_open_aux(y, x, dir);
1297 /* Cancel repeat unless we may continue */
1298 if (!more) disturb(0, 0);
1304 * Perform the basic "close" command
1306 * Assume destination is an open/broken door
1308 * Assume there is no monster blocking the destination
1310 * Returns TRUE if repeated commands may continue
1312 static bool do_cmd_close_aux(int y, int x, int dir)
1322 /* Get grid and contents */
1323 c_ptr = &cave[y][x];
1326 if (c_ptr->feat == FEAT_BROKEN)
1330 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1332 msg_print("The door appears to be broken.");
1340 /* Close the door */
1341 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1343 /* Update some things */
1344 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1347 sound(SOUND_SHUTDOOR);
1356 * Close an open door.
1358 void do_cmd_close(void)
1366 if (p_ptr->special_defense & KATA_MUSOU)
1368 set_action(ACTION_NONE);
1371 #ifdef ALLOW_EASY_OPEN /* TNB */
1373 /* Option: Pick a direction */
1376 /* Count open doors */
1377 if (count_dt(&y, &x, is_open, FALSE) == 1)
1379 command_dir = coords_to_dir(y, x);
1383 #endif /* ALLOW_EASY_OPEN -- TNB */
1385 /* Allow repeated command */
1388 /* Set repeat count */
1389 command_rep = command_arg - 1;
1391 /* Redraw the state */
1392 p_ptr->redraw |= (PR_STATE);
1394 /* Cancel the arg */
1398 /* Get a "repeated" direction */
1399 if (get_rep_dir(&dir,FALSE))
1401 /* Get requested location */
1405 /* Get grid and contents */
1406 c_ptr = &cave[y][x];
1408 /* Require open/broken door */
1409 if ((c_ptr->feat != FEAT_OPEN) && (c_ptr->feat != FEAT_BROKEN))
1413 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1415 msg_print("You see nothing there to close.");
1420 /* Monster in the way */
1421 else if (c_ptr->m_idx)
1428 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1430 msg_print("There is a monster in the way!");
1438 /* Close the door */
1441 /* Close the door */
1442 more = do_cmd_close_aux(y, x, dir);
1446 /* Cancel repeat unless we may continue */
1447 if (!more) disturb(0, 0);
1452 * Determine if a given grid may be "tunneled"
1454 static bool do_cmd_tunnel_test(int y, int x)
1456 /* Must have knowledge */
1457 if (!(cave[y][x].info & (CAVE_MARK)))
1461 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1463 msg_print("You see nothing there.");
1471 /* Must be a wall/door/etc */
1472 if (cave_floor_bold(y, x))
1476 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1478 msg_print("You see nothing there to tunnel.");
1493 * Tunnel through wall. Assumes valid location.
1495 * Note that it is impossible to "extend" rooms past their
1496 * outer walls (which are actually part of the room).
1498 * This will, however, produce grids which are NOT illuminated
1499 * (or darkened) along with the rest of the room.
1501 static bool twall(int y, int x, byte feat)
1503 cave_type *c_ptr = &cave[y][x];
1505 /* Paranoia -- Require a wall or door or some such */
1506 if (cave_floor_bold(y, x)) return (FALSE);
1508 /* Forget the wall */
1509 c_ptr->info &= ~(CAVE_MARK);
1511 /* Remove the feature */
1512 cave_set_feat(y, x, feat);
1514 /* Update some things */
1515 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1524 * Perform the basic "tunnel" command
1526 * Assumes that the destination is a wall, a vein, a secret
1529 * Assumes that no monster is blocking the destination
1531 * Returns TRUE if repeated commands may continue
1533 static bool do_cmd_tunnel_aux(int y, int x, int dir)
1539 /* Verify legality */
1540 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1546 c_ptr = &cave[y][x];
1552 if ((c_ptr->feat >= FEAT_PERM_EXTRA) &&
1553 (c_ptr->feat <= FEAT_PERM_SOLID))
1556 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1558 msg_print("This seems to be permanent rock.");
1563 /* No tunnelling through mountains */
1564 else if (c_ptr->feat == FEAT_MOUNTAIN)
1567 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1569 msg_print("You can't tunnel through that!");
1574 else if (c_ptr->feat == FEAT_TREES) /* -KMW- */
1577 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1580 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1582 msg_print("You have cleared away the trees.");
1584 chg_virtue(V_DILIGENCE, 1);
1585 chg_virtue(V_NATURE, -1);
1591 /* We may continue chopping */
1593 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1595 msg_print("You chop away at the tree.");
1600 /* Occasional Search XXX XXX */
1601 if (randint0(100) < 25) search();
1607 else if ((c_ptr->feat >= FEAT_WALL_EXTRA) &&
1608 (c_ptr->feat <= FEAT_WALL_SOLID))
1611 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1614 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1616 msg_print("You have finished the tunnel.");
1618 chg_virtue(V_DILIGENCE, 1);
1619 chg_virtue(V_NATURE, -1);
1625 /* We may continue tunelling */
1627 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1629 msg_print("You tunnel into the granite wall.");
1637 /* Quartz / Magma */
1638 else if ((c_ptr->feat >= FEAT_MAGMA) &&
1639 (c_ptr->feat <= FEAT_QUARTZ_K))
1646 if (c_ptr->feat >= FEAT_MAGMA_H) gold = TRUE;
1648 /* Extract "quartz" flag XXX XXX XXX */
1649 if ((c_ptr->feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1654 okay = (p_ptr->skill_dig > 20 + randint0(800));
1660 okay = (p_ptr->skill_dig > 10 + randint0(400));
1664 if (okay && twall(y, x, floor_type[randint0(100)]))
1666 /* Found treasure */
1669 /* Place some gold */
1674 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1676 msg_print("You have found something!");
1686 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1688 msg_print("You have finished the tunnel.");
1690 chg_virtue(V_DILIGENCE, 1);
1691 chg_virtue(V_NATURE, -1);
1695 /* Failure (quartz) */
1698 /* Message, continue digging */
1700 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1702 msg_print("You tunnel into the quartz vein.");
1708 /* Failure (magma) */
1711 /* Message, continue digging */
1713 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1715 msg_print("You tunnel into the magma vein.");
1723 else if (c_ptr->feat == FEAT_RUBBLE)
1725 /* Remove the rubble */
1726 if ((p_ptr->skill_dig > randint0(200)) && twall(y, x, floor_type[randint0(100)]))
1730 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1732 msg_print("You have removed the rubble.");
1735 /* Hack -- place an object */
1736 if (randint0(100) < (15 - dun_level/2))
1738 /* Create a simple object */
1739 place_object(y, x, FALSE, FALSE);
1741 /* Observe new object */
1742 if (player_can_see_bold(y, x))
1745 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1747 msg_print("You have found something!");
1756 /* Message, keep digging */
1758 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1760 msg_print("You dig in the rubble.");
1768 else if (c_ptr->feat >= FEAT_SECRET)
1771 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint0(100)]))
1774 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1776 msg_print("You have finished the tunnel.");
1784 /* We may continue tunelling */
1786 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1788 msg_print("You tunnel into the granite wall.");
1793 /* Occasional Search XXX XXX */
1794 if (randint0(100) < 25) search();
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 /* Notice new floor grids */
1827 if (!cave_floor_bold(y, x))
1829 /* Update some things */
1830 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1839 * Tunnels through "walls" (including rubble and closed doors)
1841 * Note that you must tunnel in order to hit invisible monsters
1842 * in walls, though moving into walls still takes a turn anyway.
1844 * Digging is very difficult without a "digger" weapon, but can be
1845 * accomplished by strong players using heavy weapons.
1847 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 /* No tunnelling through doors */
1885 if (((c_ptr->feat >= FEAT_DOOR_HEAD) && (c_ptr->feat <= FEAT_DOOR_TAIL)) ||
1886 ((c_ptr->feat >= FEAT_BLDG_HEAD) && (c_ptr->feat <= FEAT_BLDG_TAIL)) ||
1887 ((c_ptr->feat >= FEAT_SHOP_HEAD) && (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
1888 (c_ptr->feat == FEAT_MUSEUM))
1892 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1894 msg_print("You cannot tunnel through doors.");
1899 /* No tunnelling through air */
1900 else if (cave_floor_grid(c_ptr) || ((c_ptr->feat >= FEAT_MINOR_GLYPH) &&
1901 (c_ptr->feat <= FEAT_PATTERN_XTRA2)))
1905 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1907 msg_print("You cannot tunnel through air.");
1912 /* No tunnelling through mountains */
1913 else if (c_ptr->feat == FEAT_MOUNTAIN)
1916 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1918 msg_print("You can't tunnel through that!");
1923 /* A monster is in the way */
1924 else if (c_ptr->m_idx)
1931 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1933 msg_print("There is a monster in the way!");
1944 /* Tunnel through walls */
1945 more = do_cmd_tunnel_aux(y, x, dir);
1949 /* Cancel repetition unless we can continue */
1950 if (!more) disturb(0, 0);
1954 #ifdef ALLOW_EASY_OPEN /* TNB */
1959 * If there is a jammed/closed/locked door at the given location,
1960 * then attempt to unlock/open it. Return TRUE if an attempt was
1961 * made (successful or not), otherwise return FALSE.
1963 * The code here should be nearly identical to that in
1964 * do_cmd_open_test() and do_cmd_open_aux().
1966 bool easy_open_door(int y, int x)
1970 cave_type *c_ptr = &cave[y][x];
1972 /* Must be a closed door */
1973 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1974 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1981 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1985 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1987 msg_print("The door appears to be stuck.");
1993 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1996 i = p_ptr->skill_dis;
1998 /* Penalize some conditions */
1999 if (p_ptr->blind || no_lite()) i = i / 10;
2000 if (p_ptr->confused || p_ptr->image) i = i / 10;
2002 /* Extract the lock power */
2003 j = c_ptr->feat - FEAT_DOOR_HEAD;
2005 /* Extract the difficulty XXX XXX XXX */
2008 /* Always have a small chance of success */
2012 if (randint0(100) < j)
2016 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
2018 msg_print("You have picked the lock.");
2023 cave_set_feat(y, x, FEAT_OPEN);
2025 /* Update some things */
2026 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2029 sound(SOUND_OPENDOOR);
2039 if (flush_failure) flush();
2043 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2045 msg_print("You failed to pick the lock.");
2055 cave_set_feat(y, x, FEAT_OPEN);
2057 /* Update some things */
2058 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2061 sound(SOUND_OPENDOOR);
2068 #endif /* ALLOW_EASY_OPEN -- TNB */
2072 * Perform the basic "disarm" command
2074 * Assume destination is a visible trap
2076 * Assume there is no monster blocking the destination
2078 * Returns TRUE if repeated commands may continue
2080 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2086 object_type *o_ptr = &o_list[o_idx];
2092 /* Get the "disarm" factor */
2093 i = p_ptr->skill_dis;
2095 /* Penalize some conditions */
2096 if (p_ptr->blind || no_lite()) i = i / 10;
2097 if (p_ptr->confused || p_ptr->image) i = i / 10;
2099 /* Extract the difficulty */
2100 j = i - o_ptr->pval;
2102 /* Always have a small chance of success */
2105 /* Must find the trap first. */
2106 if (!object_known_p(o_ptr))
2109 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2111 msg_print("I don't see any traps.");
2116 /* Already disarmed/unlocked */
2117 else if (o_ptr->pval <= 0)
2120 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2122 msg_print("The chest is not trapped.");
2127 /* No traps to find. */
2128 else if (!chest_traps[o_ptr->pval])
2131 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2133 msg_print("The chest is not trapped.");
2138 /* Success (get a lot of experience) */
2139 else if (randint0(100) < j)
2142 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2144 msg_print("You have disarmed the chest.");
2147 gain_exp(o_ptr->pval);
2148 o_ptr->pval = (0 - o_ptr->pval);
2151 /* Failure -- Keep trying */
2152 else if ((i > 5) && (randint1(i) > 5))
2154 /* We may keep trying */
2156 if (flush_failure) flush();
2158 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2160 msg_print("You failed to disarm the chest.");
2165 /* Failure -- Set off the trap */
2169 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2171 msg_print("You set off a trap!");
2175 chest_trap(y, x, o_idx);
2184 * Perform the basic "disarm" command
2186 * Assume destination is a visible trap
2188 * Assume there is no monster blocking the destination
2190 * Returns TRUE if repeated commands may continue
2192 #ifdef ALLOW_EASY_DISARM /* TNB */
2194 bool do_cmd_disarm_aux(int y, int x, int dir)
2196 #else /* ALLOW_EASY_DISARM -- TNB */
2198 static bool do_cmd_disarm_aux(int y, int x, int dir)
2200 #endif /* ALLOW_EASY_DISARM -- TNB */
2214 /* Get grid and contents */
2215 c_ptr = &cave[y][x];
2217 /* Access trap name */
2218 name = (f_name + f_info[c_ptr->feat].name);
2220 /* Get the "disarm" factor */
2221 i = p_ptr->skill_dis;
2223 /* Penalize some conditions */
2224 if (p_ptr->blind || no_lite()) i = i / 10;
2225 if (p_ptr->confused || p_ptr->image) i = i / 10;
2227 /* XXX XXX XXX Variable power? */
2229 /* Extract trap "power" */
2232 /* Extract the difficulty */
2235 /* Always have a small chance of success */
2239 if (randint0(100) < j)
2243 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2245 msg_format("You have disarmed the %s.", name);
2252 /* Forget the trap */
2253 c_ptr->info &= ~(CAVE_MARK);
2255 /* Remove the trap */
2256 c_ptr->feat = 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)
2333 if (p_ptr->special_defense & KATA_MUSOU)
2335 set_action(ACTION_NONE);
2338 #ifdef ALLOW_EASY_DISARM /* TNB */
2340 /* Option: Pick a direction */
2343 int num_traps, num_chests;
2345 /* Count visible traps */
2346 num_traps = count_dt(&y, &x, is_trap, TRUE);
2348 /* Count chests (trapped) */
2349 num_chests = count_chests(&y, &x, TRUE);
2351 /* See if only one target */
2352 if (num_traps || num_chests)
2354 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2356 if (!too_many) command_dir = coords_to_dir(y, x);
2360 #endif /* ALLOW_EASY_DISARM -- TNB */
2362 /* Allow repeated command */
2365 /* Set repeat count */
2366 command_rep = command_arg - 1;
2368 /* Redraw the state */
2369 p_ptr->redraw |= (PR_STATE);
2371 /* Cancel the arg */
2375 /* Get a direction (or abort) */
2376 if (get_rep_dir(&dir,TRUE))
2382 /* Get grid and contents */
2383 c_ptr = &cave[y][x];
2385 /* Check for chests */
2386 o_idx = chest_check(y, x);
2389 if (!is_trap(c_ptr->feat) && !o_idx)
2393 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2395 msg_print("You see nothing there to disarm.");
2400 /* Monster in the way */
2401 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2405 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2407 msg_print("There is a monster in the way!");
2418 /* Disarm the chest */
2419 more = do_cmd_disarm_chest(y, x, o_idx);
2425 /* Disarm the trap */
2426 more = do_cmd_disarm_aux(y, x, dir);
2430 /* Cancel repeat unless told not to */
2431 if (!more) disturb(0, 0);
2436 * Perform the basic "bash" command
2438 * Assume destination is a closed/locked/jammed door
2440 * Assume there is no monster blocking the destination
2442 * Returns TRUE if repeated commands may continue
2444 static bool do_cmd_bash_aux(int y, int x, int dir)
2457 c_ptr = &cave[y][x];
2461 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2463 msg_print("You smash into the door!");
2467 /* Hack -- Bash power based on strength */
2468 /* (Ranges from 3 to 20 to 100 to 200) */
2469 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2471 /* Extract door power */
2472 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2474 /* Compare bash power to door power XXX XXX XXX */
2475 temp = (bash - (temp * 10));
2477 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2479 /* Hack -- always have a chance */
2480 if (temp < 1) temp = 1;
2482 /* Hack -- attempt to bash down the door */
2483 if (randint0(100) < temp)
2487 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2489 msg_print("The door crashes open!");
2493 /* Break down the door */
2494 if (randint0(100) < 50)
2496 cave_set_feat(y, x, FEAT_BROKEN);
2502 cave_set_feat(y, x, FEAT_OPEN);
2506 sound(SOUND_OPENDOOR);
2508 /* Hack -- Fall through the door */
2509 move_player(dir, FALSE, FALSE);
2511 /* Update some things */
2512 p_ptr->update |= (PU_VIEW | PU_LITE);
2513 p_ptr->update |= (PU_DISTANCE);
2516 /* Saving throw against stun */
2517 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2522 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2524 msg_print("The door holds firm.");
2528 /* Allow repeated bashing */
2532 /* High dexterity yields coolness */
2537 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2539 msg_print("You are off-balance.");
2543 /* Hack -- Lose balance ala paralysis */
2544 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2553 * Bash open a door, success based on character strength
2555 * For a closed door, pval is positive if locked; negative if stuck.
2557 * For an open door, pval is positive for a broken door.
2559 * A closed door can be opened - harder if locked. Any door might be
2560 * bashed open (and thereby broken). Bashing a door is (potentially)
2561 * faster! You move into the door way. To open a stuck door, it must
2562 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2564 * Creatures can also open or bash doors, see elsewhere.
2566 void do_cmd_bash(void)
2575 if (p_ptr->special_defense & KATA_MUSOU)
2577 set_action(ACTION_NONE);
2580 /* Allow repeated command */
2583 /* Set repeat count */
2584 command_rep = command_arg - 1;
2586 /* Redraw the state */
2587 p_ptr->redraw |= (PR_STATE);
2589 /* Cancel the arg */
2593 /* Get a "repeated" direction */
2594 if (get_rep_dir(&dir,FALSE))
2601 c_ptr = &cave[y][x];
2603 /* Nothing useful */
2604 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2605 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2609 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2611 msg_print("You see nothing there to bash.");
2616 /* Monster in the way */
2617 else if (c_ptr->m_idx)
2624 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2626 msg_print("There is a monster in the way!");
2634 /* Bash a closed door */
2638 more = do_cmd_bash_aux(y, x, dir);
2642 /* Unless valid action taken, cancel bash */
2643 if (!more) disturb(0, 0);
2648 * Manipulate an adjacent grid in some way
2650 * Attack monsters, tunnel through walls, disarm traps, open doors.
2652 * Consider confusion XXX XXX XXX
2654 * This command must always take a turn, to prevent free detection
2655 * of invisible monsters.
2657 void do_cmd_alter(void)
2666 if (p_ptr->special_defense & KATA_MUSOU)
2668 set_action(ACTION_NONE);
2671 /* Allow repeated command */
2674 /* Set repeat count */
2675 command_rep = command_arg - 1;
2677 /* Redraw the state */
2678 p_ptr->redraw |= (PR_STATE);
2680 /* Cancel the arg */
2684 /* Get a direction */
2685 if (get_rep_dir(&dir,TRUE))
2692 c_ptr = &cave[y][x];
2697 /* Attack monsters */
2704 /* Tunnel through walls */
2705 else if (((c_ptr->feat >= FEAT_SECRET) &&
2706 (c_ptr->feat < FEAT_MINOR_GLYPH)) ||
2707 ((c_ptr->feat == FEAT_TREES) ||
2708 (c_ptr->feat == FEAT_MOUNTAIN)))
2711 more = do_cmd_tunnel_aux(y, x, dir);
2714 /* Bash jammed doors */
2715 else if ((c_ptr->feat >= FEAT_DOOR_HEAD + 0x08) &&
2716 (c_ptr->feat < FEAT_MINOR_GLYPH))
2719 more = do_cmd_bash_aux(y, x, dir);
2722 /* Open closed doors */
2723 else if ((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2724 (c_ptr->feat < FEAT_MINOR_GLYPH))
2727 more = do_cmd_open_aux(y, x, dir);
2730 /* Close open doors */
2731 else if ((c_ptr->feat == FEAT_OPEN) ||
2732 (c_ptr->feat == FEAT_BROKEN))
2735 more = do_cmd_close_aux(y, x, dir);
2739 else if (is_trap(c_ptr->feat))
2742 more = do_cmd_disarm_aux(y, x, dir);
2750 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2752 msg_print("You attack the empty air.");
2758 /* Cancel repetition unless we can continue */
2759 if (!more) disturb(0, 0);
2764 * Find the index of some "spikes", if possible.
2766 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2768 static bool get_spike(int *ip)
2772 /* Check every item in the pack */
2773 for (i = 0; i < INVEN_PACK; i++)
2775 object_type *o_ptr = &inventory[i];
2777 /* Skip non-objects */
2778 if (!o_ptr->k_idx) continue;
2780 /* Check the "tval" code */
2781 if (o_ptr->tval == TV_SPIKE)
2783 /* Save the spike index */
2797 * Jam a closed door with a spike
2799 * This command may NOT be repeated
2801 void do_cmd_spike(void)
2803 int y, x, dir, item;
2808 if (p_ptr->special_defense & KATA_MUSOU)
2810 set_action(ACTION_NONE);
2813 /* Get a "repeated" direction */
2814 if (get_rep_dir(&dir,FALSE))
2820 /* Get grid and contents */
2821 c_ptr = &cave[y][x];
2823 /* Require closed door */
2824 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2825 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2829 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2831 msg_print("You see nothing there to spike.");
2837 else if (!get_spike(&item))
2841 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2843 msg_print("You have no spikes!");
2848 /* Is a monster in the way? */
2849 else if (c_ptr->m_idx)
2856 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2858 msg_print("There is a monster in the way!");
2872 /* Successful jamming */
2874 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2876 msg_print("You jam the door with a spike.");
2880 /* Convert "locked" to "stuck" XXX XXX XXX */
2881 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2883 /* Add one spike to the door */
2884 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2886 /* Use up, and describe, a single spike, from the bottom */
2887 inven_item_increase(item, -1);
2888 inven_item_describe(item);
2889 inven_item_optimize(item);
2897 * Support code for the "Walk" and "Jump" commands
2899 void do_cmd_walk(int pickup)
2906 /* Allow repeated command */
2909 /* Set repeat count */
2910 command_rep = command_arg - 1;
2912 /* Redraw the state */
2913 p_ptr->redraw |= (PR_STATE);
2915 /* Cancel the arg */
2919 /* Get a "repeated" direction */
2920 if (get_rep_dir(&dir,FALSE))
2925 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2927 set_action(ACTION_NONE);
2930 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2931 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2932 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2934 /* Actually move the character */
2935 move_player(dir, pickup, FALSE);
2937 /* Allow more walking */
2941 /* Hack again -- Is there a special encounter ??? */
2942 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2944 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2947 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2949 /* Inform the player of his horrible fate :=) */
2951 msg_print("½±·â¤À¡ª");
2953 msg_print("You are ambushed !");
2956 /* Go into large wilderness view */
2957 p_ptr->wilderness_x = px;
2958 p_ptr->wilderness_y = py;
2959 p_ptr->oldpy = randint1(MAX_HGT-2);
2960 p_ptr->oldpx = randint1(MAX_WID-2);
2964 /* HACk -- set the encouter flag for the wilderness generation */
2965 generate_encounter = TRUE;
2969 /* Cancel repeat unless we may continue */
2970 if (!more) disturb(0, 0);
2978 void do_cmd_run(void)
2982 /* Hack -- no running when confused */
2983 if (p_ptr->confused)
2986 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2988 msg_print("You are too confused!");
2994 if (p_ptr->special_defense & KATA_MUSOU)
2996 set_action(ACTION_NONE);
2999 /* Get a "repeated" direction */
3000 if (get_rep_dir(&dir,FALSE))
3002 /* Hack -- Set the run counter */
3003 running = (command_arg ? command_arg : 1000);
3013 * Stay still. Search. Enter stores.
3014 * Pick up treasure if "pickup" is true.
3016 void do_cmd_stay(int pickup)
3018 cave_type *c_ptr = &cave[py][px];
3021 /* Allow repeated command */
3024 /* Set repeat count */
3025 command_rep = command_arg - 1;
3027 /* Redraw the state */
3028 p_ptr->redraw |= (PR_STATE);
3030 /* Cancel the arg */
3039 /* Spontaneous Searching */
3040 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3045 /* Continuous Searching */
3046 if (p_ptr->action == ACTION_SEARCH)
3052 /* Handle "objects" */
3056 /* Hack -- enter a store if we are on one */
3057 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3058 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3059 (c_ptr->feat == FEAT_MUSEUM))
3065 /* Hack -- enter store */
3066 command_new = SPECIAL_KEY_STORE;
3069 /* Hack -- enter a building if we are on one -KMW- */
3070 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3071 (c_ptr->feat <= FEAT_BLDG_TAIL))
3077 /* Hack -- enter building */
3078 command_new = SPECIAL_KEY_BUILDING;
3081 /* Exit a quest if reach the quest exit */
3082 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3084 int q_index = p_ptr->inside_quest;
3086 /* Was quest completed? */
3087 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3089 quest[q_index].status = QUEST_STATUS_COMPLETED;
3090 quest[q_index].complev = (byte)p_ptr->lev;
3092 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3094 msg_print("You accomplished your quest!");
3100 leave_quest_check();
3102 p_ptr->inside_quest = cave[py][px].special;
3106 p_ptr->leaving = TRUE;
3113 * Resting allows a player to safely restore his hp -RAK-
3115 void do_cmd_rest(void)
3118 set_action(ACTION_NONE);
3120 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3125 /* Prompt for time if needed */
3126 if (command_arg <= 0)
3129 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3131 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3138 strcpy(out_val, "&");
3140 /* Ask for duration */
3141 if (!get_string(p, out_val, 4)) return;
3143 /* Rest until done */
3144 if (out_val[0] == '&')
3150 else if (out_val[0] == '*')
3158 command_arg = atoi(out_val);
3159 if (command_arg <= 0) return;
3165 if (command_arg > 9999) command_arg = 9999;
3167 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3169 /* Take a turn XXX XXX XXX (?) */
3172 /* The sin of sloth */
3173 if (command_arg > 100)
3174 chg_virtue(V_DILIGENCE, -1);
3176 /* Why are you sleeping when there's no need? WAKE UP!*/
3177 if ((p_ptr->chp == p_ptr->mhp) &&
3178 (p_ptr->csp == p_ptr->msp) &&
3179 !p_ptr->blind && !p_ptr->confused &&
3180 !p_ptr->poisoned && !p_ptr->afraid &&
3181 !p_ptr->stun && !p_ptr->cut &&
3182 !p_ptr->slow && !p_ptr->paralyzed &&
3183 !p_ptr->image && !p_ptr->word_recall)
3184 chg_virtue(V_DILIGENCE, -1);
3186 /* Save the rest code */
3187 resting = command_arg;
3188 p_ptr->action = ACTION_REST;
3190 /* Recalculate bonuses */
3191 p_ptr->update |= (PU_BONUS);
3193 /* Redraw the state */
3194 p_ptr->redraw |= (PR_STATE);
3205 * Determines the odds of an object breaking when thrown at a monster
3207 * Note that artifacts never break, see the "drop_near()" function.
3209 static int breakage_chance(object_type *o_ptr)
3211 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3213 /* Examine the item type */
3214 switch (o_ptr->tval)
3230 /* Sometimes break */
3235 return (20 - archer_bonus * 2);
3240 return (10 - archer_bonus);
3247 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3251 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3253 u32b flgs[TR_FLAG_SIZE];
3255 /* Extract the flags */
3256 object_flags(o_ptr, flgs);
3258 /* Some "weapons" and "ammo" do extra damage */
3259 switch (o_ptr->tval)
3266 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3267 (r_ptr->flags3 & RF3_ANIMAL))
3271 r_ptr->r_flags3 |= RF3_ANIMAL;
3274 if (mult < 17) mult = 17;
3278 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3279 (r_ptr->flags3 & RF3_EVIL))
3283 r_ptr->r_flags3 |= RF3_EVIL;
3286 if (mult < 15) mult = 15;
3290 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3291 (r_ptr->flags2 & RF2_HUMAN))
3295 r_ptr->r_flags2 |= RF2_HUMAN;
3298 if (mult < 17) mult = 17;
3302 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3303 (r_ptr->flags3 & RF3_UNDEAD))
3307 r_ptr->r_flags3 |= RF3_UNDEAD;
3310 if (mult < 20) mult = 20;
3314 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3315 (r_ptr->flags3 & RF3_DEMON))
3319 r_ptr->r_flags3 |= RF3_DEMON;
3322 if (mult < 20) mult = 20;
3326 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3327 (r_ptr->flags3 & RF3_ORC))
3331 r_ptr->r_flags3 |= RF3_ORC;
3334 if (mult < 20) mult = 20;
3338 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3339 (r_ptr->flags3 & RF3_TROLL))
3343 r_ptr->r_flags3 |= RF3_TROLL;
3346 if (mult < 20) mult = 20;
3350 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3351 (r_ptr->flags3 & RF3_GIANT))
3355 r_ptr->r_flags3 |= RF3_GIANT;
3358 if (mult < 20) mult = 20;
3362 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3363 (r_ptr->flags3 & RF3_DRAGON))
3367 r_ptr->r_flags3 |= RF3_DRAGON;
3370 if (mult < 20) mult = 20;
3373 /* Execute Dragon */
3374 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3375 (r_ptr->flags3 & RF3_DRAGON))
3379 r_ptr->r_flags3 |= RF3_DRAGON;
3382 if (mult < 30) mult = 30;
3384 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3385 (m_ptr->r_idx == MON_SMAUG) &&
3386 (inventory[INVEN_BOW].name1 == ART_BARD))
3391 if ((have_flag(flgs, TR_BRAND_ACID)) || (p_ptr->special_attack & (ATTACK_ACID)))
3393 /* Notice immunity */
3394 if (r_ptr->flags3 & RF3_IM_ACID)
3398 r_ptr->r_flags3 |= RF3_IM_ACID;
3402 /* Otherwise, take the damage */
3405 if (mult < 17) mult = 17;
3410 if ((have_flag(flgs, TR_BRAND_ELEC)) || (p_ptr->special_attack & (ATTACK_ELEC)))
3412 /* Notice immunity */
3413 if (r_ptr->flags3 & RF3_IM_ELEC)
3417 r_ptr->r_flags3 |= RF3_IM_ELEC;
3421 /* Otherwise, take the damage */
3424 if (mult < 17) mult = 17;
3429 if ((have_flag(flgs, TR_BRAND_FIRE)) || (p_ptr->special_attack & (ATTACK_FIRE)))
3431 /* Notice immunity */
3432 if (r_ptr->flags3 & RF3_IM_FIRE)
3436 r_ptr->r_flags3 |= RF3_IM_FIRE;
3440 /* Otherwise, take the damage */
3443 if (mult < 17) mult = 17;
3448 if ((have_flag(flgs, TR_BRAND_COLD)) || (p_ptr->special_attack & (ATTACK_COLD)))
3450 /* Notice immunity */
3451 if (r_ptr->flags3 & RF3_IM_COLD)
3455 r_ptr->r_flags3 |= RF3_IM_COLD;
3458 /* Otherwise, take the damage */
3461 if (mult < 17) mult = 17;
3465 /* Brand (Poison) */
3466 if ((have_flag(flgs, TR_BRAND_POIS)) || (p_ptr->special_attack & (ATTACK_POIS)))
3468 /* Notice immunity */
3469 if (r_ptr->flags3 & RF3_IM_POIS)
3473 r_ptr->r_flags3 |= RF3_IM_POIS;
3477 /* Otherwise, take the damage */
3480 if (mult < 17) mult = 17;
3484 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3486 p_ptr->csp -= (1+(p_ptr->msp / 30));
3487 p_ptr->redraw |= (PR_MANA);
3488 mult = mult * 5 / 2;
3494 /* Return the total damage */
3495 return (tdam * mult / 10);
3500 * Fire an object from the pack or floor.
3502 * You may only fire items that "match" your missile launcher.
3504 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3506 * See "calc_bonuses()" for more calculations and such.
3508 * Note that "firing" a missile is MUCH better than "throwing" it.
3510 * Note: "unseen" monsters are very hard to hit.
3512 * Objects are more likely to break if they "attempt" to hit a monster.
3514 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3516 * The "extra shot" code works by decreasing the amount of energy
3517 * required to make each shot, spreading the shots out over time.
3519 * Note that when firing missiles, the launcher multiplier is applied
3520 * after all the bonuses are added in, making multipliers very useful.
3522 * Note that Bows of "Extra Might" get extra range and an extra bonus
3523 * for the damage multiplier.
3525 * Note that Bows of "Extra Shots" give an extra shot.
3527 void do_cmd_fire_aux(int item, object_type *j_ptr)
3530 int j, y, x, ny, nx, ty, tx;
3531 int tdam, tdis, thits, tmul;
3533 int cur_dis, visible;
3540 bool hit_body = FALSE;
3542 char o_name[MAX_NLEN];
3544 int msec = delay_factor * delay_factor * delay_factor;
3547 bool stick_to = FALSE;
3549 /* Access the item (if in the pack) */
3552 o_ptr = &inventory[item];
3556 o_ptr = &o_list[0 - item];
3559 /* Describe the object */
3560 object_desc(o_name, o_ptr, FALSE, 3);
3563 /* Use the proper number of shots */
3564 thits = p_ptr->num_fire;
3566 /* Use a base distance */
3569 /* Base damage from thrown object plus launcher bonus */
3570 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3572 /* Actually "fire" the object */
3573 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3574 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3575 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval])/400 + bonus) * BTH_PLUS_ADJ);
3577 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3579 energy_use = bow_energy(j_ptr->sval);
3580 tmul = bow_tmul(j_ptr->sval);
3582 /* Get extra "power" from "extra might" */
3583 if (p_ptr->xtra_might) tmul++;
3585 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3587 /* Boost the damage */
3592 tdis = 10 + tmul/40;
3593 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3596 project_length = tdis + 1;
3598 /* Get a direction (or cancel) */
3599 if (!get_aim_dir(&dir))
3603 /* need not to reset project_length (already did)*/
3607 project_length = 0; /* reset to default */
3609 /* Get local object */
3612 /* Obtain a local object */
3613 object_copy(q_ptr, o_ptr);
3618 /* Reduce and describe inventory */
3621 inven_item_increase(item, -1);
3622 inven_item_describe(item);
3623 inven_item_optimize(item);
3626 /* Reduce and describe floor item */
3629 floor_item_increase(0 - item, -1);
3630 floor_item_optimize(0 - item);
3638 /* Take a (partial) turn */
3639 energy_use = (energy_use / thits);
3642 /* Start at the player */
3646 /* Predict the "target" location */
3647 tx = px + 99 * ddx[dir];
3648 ty = py + 99 * ddy[dir];
3650 /* Check for "target request" */
3651 if ((dir == 5) && target_okay())
3658 /* Hack -- Handle stuff */
3662 /* Travel until stopped */
3663 for (cur_dis = 0; cur_dis <= tdis; )
3665 /* Hack -- Stop at the target */
3666 if ((y == ty) && (x == tx)) break;
3668 /* Calculate the new location (see "project()") */
3671 mmove2(&ny, &nx, py, px, ty, tx);
3673 /* Stopped by walls/doors */
3674 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3676 /* Advance the distance */
3680 /* The player can see the (on screen) missile */
3681 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3683 char c = object_char(q_ptr);
3684 byte a = object_attr(q_ptr);
3686 /* Draw, Hilite, Fresh, Pause, Erase */
3687 print_rel(c, a, ny, nx);
3688 move_cursor_relative(ny, nx);
3690 Term_xtra(TERM_XTRA_DELAY, msec);
3695 /* The player cannot see the missile */
3698 /* Pause anyway, for consistancy */
3699 Term_xtra(TERM_XTRA_DELAY, msec);
3702 /* Save the new location */
3707 /* Monster here, Try to hit it */
3708 if (cave[y][x].m_idx)
3710 cave_type *c_ptr = &cave[y][x];
3712 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3713 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3715 /* Check the visibility */
3716 visible = m_ptr->ml;
3718 /* Note the collision */
3723 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3724 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3727 if ((r_ptr->level + 10) > p_ptr->lev)
3729 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3730 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3733 if (now_exp < 4000) amount = 80;
3734 else if (now_exp < 6000) amount = 25;
3735 else if ((now_exp < 7000) && (p_ptr->lev > 19)) amount = 10;
3736 else if (p_ptr->lev > 34) amount = 2;
3737 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3738 p_ptr->update |= (PU_BONUS);
3744 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))
3746 p_ptr->skill_exp[GINOU_RIDING]+=1;
3747 p_ptr->update |= (PU_BONUS);
3751 /* Did we hit it (penalize range) */
3752 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3756 /* Assume a default death */
3758 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3760 cptr note_dies = " dies.";
3763 /* Some monsters get "destroyed" */
3764 if (!monster_living(r_ptr))
3767 bool explode = FALSE;
3769 for (i = 0; i < 4; i++)
3771 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3774 /* Special note at death */
3777 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3779 note_dies = " explodes into tiny shreds.";
3783 note_dies = "¤òÅݤ·¤¿¡£";
3785 note_dies = " is destroyed.";
3790 /* Handle unseen monster */
3793 /* Invisible monster */
3795 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3797 msg_format("The %s finds a mark.", o_name);
3802 /* Handle visible monster */
3807 /* Get "the monster" or "it" */
3808 monster_desc(m_name, m_ptr, 0);
3812 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3814 msg_format("The %s hits %s.", o_name, m_name);
3818 /* Hack -- Track this monster race */
3819 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3821 /* Hack -- Track this monster */
3822 if (m_ptr->ml) health_track(c_ptr->m_idx);
3825 /* Apply special damage XXX XXX XXX */
3826 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3827 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3829 /* No negative damage */
3830 if (tdam < 0) tdam = 0;
3832 /* Modify the damage */
3833 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3835 /* Complex message */
3836 if (p_ptr->wizard || cheat_xtra)
3839 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3842 msg_format("You do %d (out of %d) damage.",
3848 /* Hit the monster, check for death */
3849 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3862 monster_desc(m_name, m_ptr, 0);
3866 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3868 msg_format("%^s have stuck into %s!",o_name, m_name);
3873 message_pain(c_ptr->m_idx, tdam);
3875 /* Anger the monster */
3876 if (tdam > 0) anger_monster(m_ptr);
3879 if (fear && m_ptr->ml)
3886 /* Get the monster name (or "it") */
3887 monster_desc(m_name, m_ptr, 0);
3891 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3893 msg_format("%^s flees in terror!", m_name);
3897 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3899 set_target(m_ptr, py, px);
3909 /* Chance of breakage (during attacks) */
3910 j = (hit_body ? breakage_chance(q_ptr) : 0);
3914 int m_idx = cave[y][x].m_idx;
3915 monster_type *m_ptr = &m_list[m_idx];
3916 int o_idx = o_pop();
3921 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3923 msg_format("The %s have gone to somewhere.", o_name);
3927 a_info[j_ptr->name1].cur_num = 0;
3932 o_ptr = &o_list[ o_idx ];
3933 object_copy(o_ptr, q_ptr);
3936 o_ptr->marked = FALSE;
3938 /* Forget location */
3939 o_ptr->iy = o_ptr->ix = 0;
3941 /* Memorize monster */
3942 o_ptr->held_m_idx = m_idx;
3945 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3948 m_ptr->hold_o_idx = o_idx;
3952 /* Drop (or break) near that location */
3953 (void)drop_near(q_ptr, j, y, x);
3957 void do_cmd_fire(void)
3963 /* Get the "bow" (if any) */
3964 j_ptr = &inventory[INVEN_BOW];
3966 /* Require a launcher */
3970 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
3972 msg_print("You have nothing to fire with.");
3978 if (j_ptr->sval == SV_CRIMSON)
3981 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
3983 msg_print("Do activate.");
3990 if (p_ptr->special_defense & KATA_MUSOU)
3992 set_action(ACTION_NONE);
3995 /* Require proper missile */
3996 item_tester_tval = p_ptr->tval_ammo;
4000 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4001 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4003 q = "Fire which item? ";
4004 s = "You have nothing to fire.";
4007 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4014 do_cmd_fire_aux(item, j_ptr);
4018 static bool item_tester_hook_boomerang(object_type *o_ptr)
4020 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4028 * Throw an object from the pack or floor.
4030 * Note: "unseen" monsters are very hard to hit.
4032 * Should throwing a weapon do full damage? Should it allow the magic
4033 * to hit bonus of the weapon to have an effect? Should it ever cause
4034 * the item to be destroyed? Should it do any damage at all?
4036 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4039 int i, j, y, x, ty, tx;
4041 int chance, tdam, tdis;
4043 int cur_dis, visible;
4050 bool hit_body = FALSE;
4051 bool hit_wall = FALSE;
4052 bool equiped_item = FALSE;
4053 bool return_when_thrown = FALSE;
4055 char o_name[MAX_NLEN];
4057 int msec = delay_factor * delay_factor * delay_factor;
4059 u32b flgs[TR_FLAG_SIZE];
4061 bool come_back = FALSE;
4062 bool do_drop = TRUE;
4065 if (p_ptr->special_defense & KATA_MUSOU)
4067 set_action(ACTION_NONE);
4076 if (buki_motteruka(INVEN_LARM))
4078 item_tester_hook = item_tester_hook_boomerang;
4080 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4081 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4083 q = "Throw which item? ";
4084 s = "You have nothing to throw.";
4087 if (!get_item(&item, q, s, (USE_EQUIP)))
4102 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4103 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4105 q = "Throw which item? ";
4106 s = "You have nothing to throw.";
4109 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4116 /* Access the item (if in the pack) */
4119 o_ptr = &inventory[item];
4123 o_ptr = &o_list[0 - item];
4127 /* Item is cursed */
4128 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4132 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4134 msg_print("Hmmm, it seems to be cursed.");
4141 if (p_ptr->inside_arena)
4143 if (o_ptr->tval != 5)
4146 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4148 msg_print("You're in the arena now. This is hand-to-hand!");
4157 /* Get local object */
4160 /* Obtain a local object */
4161 object_copy(q_ptr, o_ptr);
4163 /* Extract the thrown object's flags. */
4164 object_flags(q_ptr, flgs);
4166 /* Distribute the charges of rods/wands between the stacks */
4167 distribute_charges(o_ptr, q_ptr, 1);
4173 object_desc(o_name, q_ptr, FALSE, 3);
4175 if (p_ptr->mighty_throw) mult += 3;
4177 /* Extract a "distance multiplier" */
4178 /* Changed for 'launcher' mutation */
4179 mul = 10 + 2 * (mult - 1);
4181 /* Enforce a minimum "weight" of one pound */
4182 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4183 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4185 /* Hack -- Distance -- Reward strength, penalize weight */
4186 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4188 /* Max distance of 10-18 */
4189 if (tdis > mul) tdis = mul;
4193 ty = randint0(101)-50+py;
4194 tx = randint0(101)-50+px;
4198 project_length = tdis + 1;
4200 /* Get a direction (or cancel) */
4201 if (!get_aim_dir(&dir)) return FALSE;
4203 project_length = 0; /* reset to default */
4205 /* Predict the "target" location */
4206 tx = px + 99 * ddx[dir];
4207 ty = py + 99 * ddy[dir];
4209 /* Check for "target request" */
4210 if ((dir == 5) && target_okay())
4217 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4218 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4219 return_when_thrown = TRUE;
4221 /* Reduce and describe inventory */
4224 inven_item_increase(item, -1);
4225 if (!return_when_thrown)
4226 inven_item_describe(item);
4227 inven_item_optimize(item);
4230 /* Reduce and describe floor item */
4233 floor_item_increase(0 - item, -1);
4234 floor_item_optimize(0 - item);
4236 if (item >= INVEN_RARM)
4238 equiped_item = TRUE;
4239 p_ptr->redraw |= (PR_EQUIPPY);
4245 /* Rogue and Ninja gets bonus */
4246 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4247 energy_use -= p_ptr->lev;
4249 /* Start at the player */
4254 /* Hack -- Handle stuff */
4257 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4258 else shuriken = FALSE;
4260 /* Chance of hitting */
4261 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4262 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4263 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4265 if (shuriken) chance *= 2;
4267 /* Travel until stopped */
4268 for (cur_dis = 0; cur_dis <= tdis; )
4270 /* Hack -- Stop at the target */
4271 if ((y == ty) && (x == tx)) break;
4273 /* Calculate the new location (see "project()") */
4276 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4278 /* Stopped by walls/doors */
4279 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4285 /* Advance the distance */
4288 /* The player can see the (on screen) missile */
4289 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4291 char c = object_char(q_ptr);
4292 byte a = object_attr(q_ptr);
4294 /* Draw, Hilite, Fresh, Pause, Erase */
4295 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4296 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4298 Term_xtra(TERM_XTRA_DELAY, msec);
4299 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4303 /* The player cannot see the missile */
4306 /* Pause anyway, for consistancy */
4307 Term_xtra(TERM_XTRA_DELAY, msec);
4310 /* Save the new location */
4315 /* Monster here, Try to hit it */
4316 if (cave[y][x].m_idx)
4318 cave_type *c_ptr = &cave[y][x];
4320 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4321 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4323 /* Check the visibility */
4324 visible = m_ptr->ml;
4326 /* Note the collision */
4329 /* Did we hit it (penalize range) */
4330 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4334 /* Assume a default death */
4336 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4338 cptr note_dies = " dies.";
4342 /* Some monsters get "destroyed" */
4343 if (!monster_living(r_ptr))
4346 bool explode = FALSE;
4348 for (i = 0; i < 4; i++)
4350 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4353 /* Special note at death */
4356 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4358 note_dies = " explodes into tiny shreds.";
4362 note_dies = "¤òÅݤ·¤¿¡£";
4364 note_dies = " is destroyed.";
4370 /* Handle unseen monster */
4373 /* Invisible monster */
4375 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4377 msg_format("The %s finds a mark.", o_name);
4382 /* Handle visible monster */
4387 /* Get "the monster" or "it" */
4388 monster_desc(m_name, m_ptr, 0);
4392 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4394 msg_format("The %s hits %s.", o_name, m_name);
4398 /* Hack -- Track this monster race */
4399 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4401 /* Hack -- Track this monster */
4402 if (m_ptr->ml) health_track(c_ptr->m_idx);
4405 /* Hack -- Base damage from thrown object */
4406 tdam = damroll(q_ptr->dd, q_ptr->ds);
4407 /* Apply special damage XXX XXX XXX */
4408 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4409 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4410 if (q_ptr->to_d > 0)
4411 tdam += q_ptr->to_d;
4413 tdam += -q_ptr->to_d;
4417 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4418 tdam += p_ptr->to_d_m;
4420 else if (have_flag(flgs, TR_THROW))
4423 tdam += p_ptr->to_d_m;
4431 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4434 /* No negative damage */
4435 if (tdam < 0) tdam = 0;
4437 /* Modify the damage */
4438 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4440 /* Complex message */
4444 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4447 msg_format("You do %d (out of %d) damage.",
4453 /* Hit the monster, check for death */
4454 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4463 message_pain(c_ptr->m_idx, tdam);
4465 /* Anger the monster */
4466 if ((tdam > 0) && !object_is_potion(q_ptr))
4467 anger_monster(m_ptr);
4470 if (fear && m_ptr->ml)
4477 /* Get the monster name (or "it") */
4478 monster_desc(m_name, m_ptr, 0);
4482 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4484 msg_format("%^s flees in terror!", m_name);
4496 /* Chance of breakage (during attacks) */
4497 j = (hit_body ? breakage_chance(q_ptr) : 0);
4499 /* Figurines transform */
4500 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4504 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4505 !(cursed_p(q_ptr)) ? PM_FORCE_PET : 0L)))
4507 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4509 msg_print("The Figurine writhes and then shatters.");
4512 else if (cursed_p(q_ptr))
4514 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4516 msg_print("You have a bad feeling about this.");
4522 /* Potions smash open */
4523 if (object_is_potion(q_ptr))
4525 if (hit_body || hit_wall || (randint1(100) < j))
4529 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4531 msg_format("The %s shatters!", o_name);
4535 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4537 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4539 /* ToDo (Robert): fix the invulnerability */
4540 if (cave[y][x].m_idx &&
4541 is_friendly(&m_list[cave[y][x].m_idx]) &&
4545 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4547 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4549 msg_format("%^s gets angry!", m_name);
4552 set_hostile(&m_list[cave[y][x].m_idx]);
4563 if (return_when_thrown)
4565 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4566 char o2_name[MAX_NLEN];
4567 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4570 if (boomerang) back_chance += 4+randint1(5);
4571 if (super_boomerang) back_chance += 100;
4572 object_desc(o2_name, q_ptr, FALSE, 0);
4574 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4576 for (i = cur_dis-1;i>0;i--)
4578 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4580 char c = object_char(q_ptr);
4581 byte a = object_attr(q_ptr);
4583 /* Draw, Hilite, Fresh, Pause, Erase */
4584 print_rel(c, a, ny[i], nx[i]);
4585 move_cursor_relative(ny[i], nx[i]);
4587 Term_xtra(TERM_XTRA_DELAY, msec);
4588 lite_spot(ny[i], nx[i]);
4593 /* Pause anyway, for consistancy */
4594 Term_xtra(TERM_XTRA_DELAY, msec);
4597 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4600 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4602 msg_format("%s comes back to you.", o2_name);
4611 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4613 msg_format("%s backs, but you can't catch!", o2_name);
4619 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4621 msg_format("%s comes back.", o2_name);
4631 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4633 msg_format("%s doesn't back!", o2_name);
4640 if (item == INVEN_RARM || item == INVEN_LARM)
4642 /* Access the wield slot */
4643 o_ptr = &inventory[item];
4645 /* Wear the new stuff */
4646 object_copy(o_ptr, q_ptr);
4648 /* Increase the weight */
4649 p_ptr->total_weight += q_ptr->weight;
4651 /* Increment the equip counter by hand */
4654 /* Recalculate bonuses */
4655 p_ptr->update |= (PU_BONUS);
4657 /* Recalculate torch */
4658 p_ptr->update |= (PU_TORCH);
4660 /* Recalculate mana XXX */
4661 p_ptr->update |= (PU_MANA);
4664 p_ptr->window |= (PW_EQUIP);
4672 else if (equiped_item)
4678 /* Drop (or break) near that location */
4679 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4686 * Throw an object from the pack or floor.
4688 void do_cmd_throw(void)
4690 do_cmd_throw_aux(1, FALSE, 0);