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("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
151 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
153 msg_print("You enter a maze of up staircases.");
157 /* Leaving the dungeon to town */
158 if (!dun_level && dungeon_type)
160 p_ptr->leaving_dungeon = TRUE;
161 if (!vanilla_town && !lite_town)
163 p_ptr->wilderness_y = d_info[dungeon_type].dy;
164 p_ptr->wilderness_x = d_info[dungeon_type].dx;
166 p_ptr->recall_dungeon = dungeon_type;
169 if (!dun_level) dungeon_type = 0;
172 p_ptr->leaving = TRUE;
178 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
180 msg_print("I see no up staircase here.");
191 void do_cmd_go_down(void)
194 bool go_down = FALSE;
195 bool fall_trap = FALSE;
198 if (p_ptr->special_defense & KATA_MUSOU)
200 set_action(ACTION_NONE);
204 c_ptr = &cave[py][px];
206 if (c_ptr->feat == (FEAT_TRAP_TRAPDOOR)) fall_trap = TRUE;
208 /* Quest down stairs */
209 if (c_ptr->feat == FEAT_QUEST_DOWN)
212 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
213 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
215 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
217 msg_print("You enter the down staircase.");
223 p_ptr->inside_quest = c_ptr->special;
225 /* Activate the quest */
226 if (!quest[p_ptr->inside_quest].status)
228 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
231 /* Leaving a quest */
232 if (!p_ptr->inside_quest)
238 p_ptr->leaving = TRUE;
239 p_ptr->leftbldg = TRUE;
245 else if ((c_ptr->feat != FEAT_MORE) && (c_ptr->feat != FEAT_MORE_MORE) && (c_ptr->feat != FEAT_ENTRANCE) && !fall_trap)
248 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
250 msg_print("I see no down staircase here.");
259 if (ironman_downward && (c_ptr->special != DUNGEON_ANGBAND))
262 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
264 msg_print("The entrance of this dungeon is closed!");
268 if (!max_dlv[c_ptr->special])
271 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[c_ptr->special].name, d_info[c_ptr->special].mindepth);
272 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
274 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);
275 if (!get_check("Do you really get in this dungeon? ")) return;
280 /* Save old player position */
283 dungeon_type = (byte)c_ptr->special;
290 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
292 if (get_check("Really leave the level? "))
306 /* Hack -- take a turn */
309 if (autosave_l) do_cmd_save_game(TRUE);
312 if (c_ptr->feat == FEAT_MORE_MORE) down_num += 2;
314 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)
318 if (c_ptr->feat == FEAT_MORE_MORE) msg_print("Ť¤¹£Æ»¤ò²¼¤ê¤¿¡£");
319 else msg_print("Ť¤³¬Ãʤò²¼¤ê¤¿¡£");
321 msg_print("These were very long stairs.");
325 else if (!dun_level) down_num = d_info[c_ptr->special].mindepth;
329 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
330 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
332 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fall from trap door");
333 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "go down the stairs to");
339 dun_level += down_num;
341 msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
343 msg_print("You deliberately jump through the trap door.");
349 if(c_ptr->feat == FEAT_ENTRANCE)
351 dun_level = d_info[c_ptr->special].mindepth;
353 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
355 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
360 dun_level += down_num;
362 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
363 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
365 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
367 msg_print("You enter a maze of down staircases.");
374 p_ptr->leaving = TRUE;
378 if (c_ptr->feat == FEAT_MORE_MORE)
380 /* Create a way back */
385 /* Create a way back */
396 * Simple command to "search" for one turn
398 void do_cmd_search(void)
400 /* Allow repeated command */
403 /* Set repeat count */
404 command_rep = command_arg - 1;
406 /* Redraw the state */
407 p_ptr->redraw |= (PR_STATE);
422 * Determine if a grid contains a chest
424 static s16b chest_check(int y, int x)
426 cave_type *c_ptr = &cave[y][x];
428 s16b this_o_idx, next_o_idx = 0;
431 /* Scan all objects in the grid */
432 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
437 o_ptr = &o_list[this_o_idx];
439 /* Acquire next object */
440 next_o_idx = o_ptr->next_o_idx;
442 /* Skip unknown chests XXX XXX */
443 /* if (!o_ptr->marked) continue; */
445 /* Check for chest */
446 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
455 * Allocates objects upon opening a chest -BEN-
457 * Disperse treasures from the given chest, centered at (x,y).
459 * Small chests often contain "gold", while Large chests always contain
460 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
461 * and Steel chests contain 6 items. The "value" of the items in a
462 * chest is based on the "power" of the chest, which is in turn based
463 * on the level on which the chest is generated.
465 static void chest_death(bool scatter, int y, int x, s16b o_idx)
475 object_type *o_ptr = &o_list[o_idx];
478 /* Small chests often hold "gold" */
479 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
481 /* Determine how much to drop (see above) */
482 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
484 if (o_ptr->sval == SV_CHEST_KANDUME)
489 object_level = o_ptr->xtra3;
493 /* Determine the "value" of the items */
494 object_level = ABS(o_ptr->pval) + 10;
497 /* Zero pval means empty chest */
498 if (!o_ptr->pval) number = 0;
500 /* Opening a chest */
501 opening_chest = TRUE;
503 /* Drop some objects (non-chests) */
504 for (; number > 0; --number)
506 /* Get local object */
509 /* Wipe the object */
512 /* Small chests often drop gold */
513 if (small && (randint0(100) < 25))
516 if (!make_gold(q_ptr)) continue;
519 /* Otherwise drop an item */
522 /* Make a good object */
523 if (!make_object(q_ptr, TRUE, great)) continue;
526 /* If chest scatters its contents, pick any floor square. */
530 for (i = 0; i < 200; i++)
532 /* Pick a totally random spot. */
533 y = randint0(MAX_HGT);
534 x = randint0(MAX_WID);
536 /* Must be an empty floor. */
537 if (!cave_empty_bold(y, x)) continue;
539 /* Place the object there. */
540 drop_near(q_ptr, -1, y, x);
546 /* Normally, drop object near the chest. */
547 else drop_near(q_ptr, -1, y, x);
550 /* Reset the object level */
551 object_level = base_level;
553 /* No longer opening a chest */
554 opening_chest = FALSE;
565 * Chests have traps too.
567 * Exploding chest destroys contents (and traps).
568 * Note that the chest itself is never destroyed.
570 static void chest_trap(int y, int x, s16b o_idx)
574 object_type *o_ptr = &o_list[o_idx];
576 int mon_level = o_ptr->xtra3;
578 /* Ignore disarmed chests */
579 if (o_ptr->pval <= 0) return;
581 /* Obtain the traps */
582 trap = chest_traps[o_ptr->pval];
585 if (trap & (CHEST_LOSE_STR))
588 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
589 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
591 msg_print("A small needle has pricked you!");
592 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
595 (void)do_dec_stat(A_STR);
598 /* Lose constitution */
599 if (trap & (CHEST_LOSE_CON))
602 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
603 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
605 msg_print("A small needle has pricked you!");
606 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
609 (void)do_dec_stat(A_CON);
613 if (trap & (CHEST_POISON))
616 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
618 msg_print("A puff of green gas surrounds you!");
621 if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
623 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
628 if (trap & (CHEST_PARALYZE))
631 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
633 msg_print("A puff of yellow gas surrounds you!");
637 if (!p_ptr->free_act)
639 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
643 /* Summon monsters */
644 if (trap & (CHEST_SUMMON))
646 int num = 2 + randint1(3);
648 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
650 msg_print("You are enveloped in a cloud of smoke!");
654 for (i = 0; i < num; i++)
656 if (randint1(100)<dun_level)
657 activate_hi_summon(py, px, FALSE);
659 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
663 /* Elemental summon. */
664 if (trap & (CHEST_E_SUMMON))
667 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
669 msg_print("Elemental beings appear to protect their treasures!");
671 for (i = 0; i < randint1(3) + 5; i++)
673 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
677 /* Force clouds, then summon birds. */
678 if (trap & (CHEST_BIRD_STORM))
681 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
683 msg_print("A storm of birds swirls around you!");
686 for (i = 0; i < randint1(3) + 3; i++)
687 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
689 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
691 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
695 /* Various colorful summonings. */
696 if (trap & (CHEST_H_SUMMON))
702 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
704 msg_print("Demons materialize in clouds of fire and brimstone!");
707 for (i = 0; i < randint1(3) + 2; i++)
709 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
710 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
714 /* Summon dragons. */
718 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
720 msg_print("Draconic forms loom out of the darkness!");
723 for (i = 0; i < randint1(3) + 2; i++)
725 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
729 /* Summon hybrids. */
733 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
735 msg_print("Creatures strange and twisted assault you!");
738 for (i = 0; i < randint1(5) + 3; i++)
740 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
744 /* Summon vortices (scattered) */
748 msg_print("±²´¬¤«¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
750 msg_print("Vortices coalesce and wreak destruction!");
753 for (i = 0; i < randint1(3) + 2; i++)
755 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
761 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
763 /* Determine how many nasty tricks can be played. */
764 int nasty_tricks_count = 4 + randint0(3);
768 msg_print("¶²¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
770 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
773 /* This is gonna hurt... */
774 for (; nasty_tricks_count > 0; nasty_tricks_count--)
776 /* ...but a high saving throw does help a little. */
777 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
780 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
782 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
784 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
787 if (!p_ptr->free_act)
788 (void)set_paralyzed(p_ptr->paralyzed + 2 +
791 (void)set_stun(p_ptr->stun + 10 +
794 else if (one_in_(3)) apply_disenchant(0);
797 (void)do_dec_stat(A_STR);
798 (void)do_dec_stat(A_DEX);
799 (void)do_dec_stat(A_CON);
800 (void)do_dec_stat(A_INT);
801 (void)do_dec_stat(A_WIS);
802 (void)do_dec_stat(A_CHR);
804 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
809 /* Aggravate monsters. */
810 if (trap & (CHEST_ALARM))
813 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
815 msg_print("An alarm sounds!");
817 aggravate_monsters(0);
821 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
824 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
825 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
827 msg_print("There is a sudden explosion!");
828 msg_print("Everything inside the chest is destroyed!");
832 sound(SOUND_EXPLODE);
834 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
836 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
840 /* Scatter contents. */
841 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
844 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
846 msg_print("The contents of the chest scatter all over the dungeon!");
848 chest_death(TRUE, y, x, o_idx);
855 * Attempt to open the given chest at the given location
857 * Assume there is no monster blocking the destination
859 * Returns TRUE if repeated commands may continue
861 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
869 object_type *o_ptr = &o_list[o_idx];
875 /* Attempt to unlock it */
878 /* Assume locked, and thus not open */
881 /* Get the "disarm" factor */
882 i = p_ptr->skill_dis;
884 /* Penalize some conditions */
885 if (p_ptr->blind || no_lite()) i = i / 10;
886 if (p_ptr->confused || p_ptr->image) i = i / 10;
888 /* Extract the difficulty */
891 /* Always have a small chance of success */
894 /* Success -- May still have traps */
895 if (randint0(100) < j)
898 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
900 msg_print("You have picked the lock.");
907 /* Failure -- Keep trying */
910 /* We may continue repeating */
912 if (flush_failure) flush();
914 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
916 msg_print("You failed to pick the lock.");
922 /* Allowed to open */
925 /* Apply chest traps, if any */
926 chest_trap(y, x, o_idx);
928 /* Let the Chest drop items */
929 chest_death(FALSE, y, x, o_idx);
937 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
940 * Return TRUE if the given feature is an open door
942 static bool is_open(int feat)
944 return (feat == FEAT_OPEN);
947 static bool is_closed(int feat)
949 return ((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL));
953 * Return the number of features around (or under) the character.
954 * Usually look for doors and floor traps.
956 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
958 int d, count, xx, yy;
960 /* Count how many matches */
963 /* Check around (and under) the character */
964 for (d = 0; d < 9; d++)
966 /* if not searching under player continue */
967 if ((d == 8) && !under) continue;
969 /* Extract adjacent (legal) location */
970 yy = py + ddy_ddd[d];
971 xx = px + ddx_ddd[d];
973 /* Must have knowledge */
974 if (!(cave[yy][xx].info & (CAVE_MARK))) continue;
976 /* Not looking for this feature */
977 if (!((*test)(cave[yy][xx].feat))) continue;
982 /* Remember the location. Only useful if only one match */
993 * Return the number of chests around (or under) the character.
994 * If requested, count only trapped chests.
996 static int count_chests(int *y, int *x, bool trapped)
1002 /* Count how many matches */
1005 /* Check around (and under) the character */
1006 for (d = 0; d < 9; d++)
1008 /* Extract adjacent (legal) location */
1009 int yy = py + ddy_ddd[d];
1010 int xx = px + ddx_ddd[d];
1012 /* No (visible) chest is there */
1013 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1015 /* Grab the object */
1016 o_ptr = &o_list[o_idx];
1019 if (o_ptr->pval == 0) continue;
1021 /* No (known) traps here */
1022 if (trapped && (!object_known_p(o_ptr) ||
1023 !chest_traps[o_ptr->pval])) continue;
1028 /* Remember the location. Only useful if only one match */
1039 * Convert an adjacent location to a direction.
1041 static int coords_to_dir(int y, int x)
1043 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1050 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1052 return d[dx + 1][dy + 1];
1055 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1059 * Perform the basic "open" command on doors
1061 * Assume destination is a closed/locked/jammed door
1063 * Assume there is no monster blocking the destination
1065 * Returns TRUE if repeated commands may continue
1067 static bool do_cmd_open_aux(int y, int x, int dir)
1079 /* Get requested grid */
1080 c_ptr = &cave[y][x];
1083 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1087 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1089 msg_print("The door appears to be stuck.");
1095 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1098 i = p_ptr->skill_dis;
1100 /* Penalize some conditions */
1101 if (p_ptr->blind || no_lite()) i = i / 10;
1102 if (p_ptr->confused || p_ptr->image) i = i / 10;
1104 /* Extract the lock power */
1105 j = c_ptr->feat - FEAT_DOOR_HEAD;
1107 /* Extract the difficulty XXX XXX XXX */
1110 /* Always have a small chance of success */
1114 if (randint0(100) < j)
1118 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1120 msg_print("You have picked the lock.");
1125 cave_set_feat(y, x, FEAT_OPEN);
1127 /* Update some things */
1128 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1131 sound(SOUND_OPENDOOR);
1141 if (flush_failure) flush();
1145 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1147 msg_print("You failed to pick the lock.");
1151 /* We may keep trying */
1160 cave_set_feat(y, x, FEAT_OPEN);
1162 /* Update some things */
1163 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1166 sound(SOUND_OPENDOOR);
1176 * Open a closed/locked/jammed door or a closed/locked chest.
1178 * Unlocking a locked door/chest is worth one experience point.
1180 void do_cmd_open(void)
1190 if (p_ptr->special_defense & KATA_MUSOU)
1192 set_action(ACTION_NONE);
1195 #ifdef ALLOW_EASY_OPEN /* TNB */
1197 /* Option: Pick a direction */
1200 int num_doors, num_chests;
1202 /* Count closed doors (locked or jammed) */
1203 num_doors = count_dt(&y, &x, is_closed, FALSE);
1205 /* Count chests (locked) */
1206 num_chests = count_chests(&y, &x, FALSE);
1208 /* See if only one target */
1209 if (num_doors || num_chests)
1211 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1213 if (!too_many) command_dir = coords_to_dir(y, x);
1217 #endif /* ALLOW_EASY_OPEN -- TNB */
1219 /* Allow repeated command */
1222 /* Set repeat count */
1223 command_rep = command_arg - 1;
1225 /* Redraw the state */
1226 p_ptr->redraw |= (PR_STATE);
1228 /* Cancel the arg */
1232 /* Get a "repeated" direction */
1233 if (get_rep_dir(&dir, TRUE))
1235 /* Get requested location */
1239 /* Get requested grid */
1240 c_ptr = &cave[y][x];
1242 /* Check for chest */
1243 o_idx = chest_check(y, x);
1245 /* Nothing useful */
1246 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1247 (c_ptr->feat <= FEAT_DOOR_TAIL)) &&
1252 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1254 msg_print("You see nothing there to open.");
1259 /* Monster in the way */
1260 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1267 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1269 msg_print("There is a monster in the way!");
1280 /* Open the chest */
1281 more = do_cmd_open_chest(y, x, o_idx);
1288 more = do_cmd_open_aux(y, x, dir);
1292 /* Cancel repeat unless we may continue */
1293 if (!more) disturb(0, 0);
1299 * Perform the basic "close" command
1301 * Assume destination is an open/broken door
1303 * Assume there is no monster blocking the destination
1305 * Returns TRUE if repeated commands may continue
1307 static bool do_cmd_close_aux(int y, int x, int dir)
1317 /* Get grid and contents */
1318 c_ptr = &cave[y][x];
1321 if (c_ptr->feat == FEAT_BROKEN)
1325 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1327 msg_print("The door appears to be broken.");
1335 /* Close the door */
1336 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1338 /* Update some things */
1339 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1342 sound(SOUND_SHUTDOOR);
1351 * Close an open door.
1353 void do_cmd_close(void)
1361 if (p_ptr->special_defense & KATA_MUSOU)
1363 set_action(ACTION_NONE);
1366 #ifdef ALLOW_EASY_OPEN /* TNB */
1368 /* Option: Pick a direction */
1371 /* Count open doors */
1372 if (count_dt(&y, &x, is_open, FALSE) == 1)
1374 command_dir = coords_to_dir(y, x);
1378 #endif /* ALLOW_EASY_OPEN -- TNB */
1380 /* Allow repeated command */
1383 /* Set repeat count */
1384 command_rep = command_arg - 1;
1386 /* Redraw the state */
1387 p_ptr->redraw |= (PR_STATE);
1389 /* Cancel the arg */
1393 /* Get a "repeated" direction */
1394 if (get_rep_dir(&dir,FALSE))
1396 /* Get requested location */
1400 /* Get grid and contents */
1401 c_ptr = &cave[y][x];
1403 /* Require open/broken door */
1404 if ((c_ptr->feat != FEAT_OPEN) && (c_ptr->feat != FEAT_BROKEN))
1408 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1410 msg_print("You see nothing there to close.");
1415 /* Monster in the way */
1416 else if (c_ptr->m_idx)
1423 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1425 msg_print("There is a monster in the way!");
1433 /* Close the door */
1436 /* Close the door */
1437 more = do_cmd_close_aux(y, x, dir);
1441 /* Cancel repeat unless we may continue */
1442 if (!more) disturb(0, 0);
1447 * Determine if a given grid may be "tunneled"
1449 static bool do_cmd_tunnel_test(int y, int x)
1451 /* Must have knowledge */
1452 if (!(cave[y][x].info & (CAVE_MARK)))
1456 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1458 msg_print("You see nothing there.");
1466 /* Must be a wall/door/etc */
1467 if (cave_floor_bold(y, x))
1471 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1473 msg_print("You see nothing there to tunnel.");
1488 * Tunnel through wall. Assumes valid location.
1490 * Note that it is impossible to "extend" rooms past their
1491 * outer walls (which are actually part of the room).
1493 * This will, however, produce grids which are NOT illuminated
1494 * (or darkened) along with the rest of the room.
1496 static bool twall(int y, int x, byte feat)
1498 cave_type *c_ptr = &cave[y][x];
1500 /* Paranoia -- Require a wall or door or some such */
1501 if (cave_floor_bold(y, x)) return (FALSE);
1503 /* Forget the wall */
1504 c_ptr->info &= ~(CAVE_MARK);
1506 /* Remove the feature */
1507 cave_set_feat(y, x, feat);
1509 /* Update some things */
1510 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1519 * Perform the basic "tunnel" command
1521 * Assumes that the destination is a wall, a vein, a secret
1524 * Assumes that no monster is blocking the destination
1526 * Returns TRUE if repeated commands may continue
1528 static bool do_cmd_tunnel_aux(int y, int x, int dir)
1534 /* Verify legality */
1535 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1541 c_ptr = &cave[y][x];
1547 if ((c_ptr->feat >= FEAT_PERM_EXTRA) &&
1548 (c_ptr->feat <= FEAT_PERM_SOLID))
1551 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1553 msg_print("This seems to be permanent rock.");
1558 /* No tunnelling through mountains */
1559 else if (c_ptr->feat == FEAT_MOUNTAIN)
1562 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1564 msg_print("You can't tunnel through that!");
1569 else if (c_ptr->feat == FEAT_TREES) /* -KMW- */
1572 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1575 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1577 msg_print("You have cleared away the trees.");
1579 chg_virtue(V_DILIGENCE, 1);
1580 chg_virtue(V_NATURE, -1);
1586 /* We may continue chopping */
1588 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1590 msg_print("You chop away at the tree.");
1595 /* Occasional Search XXX XXX */
1596 if (randint0(100) < 25) search();
1602 else if ((c_ptr->feat >= FEAT_WALL_EXTRA) &&
1603 (c_ptr->feat <= FEAT_WALL_SOLID))
1606 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1609 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1611 msg_print("You have finished the tunnel.");
1613 chg_virtue(V_DILIGENCE, 1);
1614 chg_virtue(V_NATURE, -1);
1620 /* We may continue tunelling */
1622 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1624 msg_print("You tunnel into the granite wall.");
1632 /* Quartz / Magma */
1633 else if ((c_ptr->feat >= FEAT_MAGMA) &&
1634 (c_ptr->feat <= FEAT_QUARTZ_K))
1641 if (c_ptr->feat >= FEAT_MAGMA_H) gold = TRUE;
1643 /* Extract "quartz" flag XXX XXX XXX */
1644 if ((c_ptr->feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1649 okay = (p_ptr->skill_dig > 20 + randint0(800));
1655 okay = (p_ptr->skill_dig > 10 + randint0(400));
1659 if (okay && twall(y, x, floor_type[randint0(100)]))
1661 /* Found treasure */
1664 /* Place some gold */
1669 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1671 msg_print("You have found something!");
1681 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1683 msg_print("You have finished the tunnel.");
1685 chg_virtue(V_DILIGENCE, 1);
1686 chg_virtue(V_NATURE, -1);
1690 /* Failure (quartz) */
1693 /* Message, continue digging */
1695 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1697 msg_print("You tunnel into the quartz vein.");
1703 /* Failure (magma) */
1706 /* Message, continue digging */
1708 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1710 msg_print("You tunnel into the magma vein.");
1718 else if (c_ptr->feat == FEAT_RUBBLE)
1720 /* Remove the rubble */
1721 if ((p_ptr->skill_dig > randint0(200)) && twall(y, x, floor_type[randint0(100)]))
1725 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1727 msg_print("You have removed the rubble.");
1730 /* Hack -- place an object */
1731 if (randint0(100) < (15 - dun_level/2))
1733 /* Create a simple object */
1734 place_object(y, x, FALSE, FALSE);
1736 /* Observe new object */
1737 if (player_can_see_bold(y, x))
1740 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1742 msg_print("You have found something!");
1751 /* Message, keep digging */
1753 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1755 msg_print("You dig in the rubble.");
1763 else if (c_ptr->feat >= FEAT_SECRET)
1766 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint0(100)]))
1769 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1771 msg_print("You have finished the tunnel.");
1779 /* We may continue tunelling */
1781 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1783 msg_print("You tunnel into the granite wall.");
1788 /* Occasional Search XXX XXX */
1789 if (randint0(100) < 25) search();
1797 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint1(100)]))
1800 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1802 msg_print("You have finished the tunnel.");
1810 /* We may continue tunelling */
1812 msg_print("¥É¥¢¤Ë·ê¤ò³«¤±¤Æ¤¤¤ë¡£");
1814 msg_print("You tunnel into the door.");
1821 /* Notice new floor grids */
1822 if (!cave_floor_bold(y, x))
1824 /* Update some things */
1825 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1834 * Tunnels through "walls" (including rubble and closed doors)
1836 * Note that you must tunnel in order to hit invisible monsters
1837 * in walls, though moving into walls still takes a turn anyway.
1839 * Digging is very difficult without a "digger" weapon, but can be
1840 * accomplished by strong players using heavy weapons.
1842 void do_cmd_tunnel(void)
1851 if (p_ptr->special_defense & KATA_MUSOU)
1853 set_action(ACTION_NONE);
1856 /* Allow repeated command */
1859 /* Set repeat count */
1860 command_rep = command_arg - 1;
1862 /* Redraw the state */
1863 p_ptr->redraw |= (PR_STATE);
1865 /* Cancel the arg */
1869 /* Get a direction to tunnel, or Abort */
1870 if (get_rep_dir(&dir,FALSE))
1877 c_ptr = &cave[y][x];
1879 /* No tunnelling through doors */
1880 if (((c_ptr->feat >= FEAT_DOOR_HEAD) && (c_ptr->feat <= FEAT_DOOR_TAIL)) ||
1881 ((c_ptr->feat >= FEAT_BLDG_HEAD) && (c_ptr->feat <= FEAT_BLDG_TAIL)) ||
1882 ((c_ptr->feat >= FEAT_SHOP_HEAD) && (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
1883 (c_ptr->feat == FEAT_MUSEUM))
1887 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1889 msg_print("You cannot tunnel through doors.");
1894 /* No tunnelling through air */
1895 else if (cave_floor_grid(c_ptr) || ((c_ptr->feat >= FEAT_MINOR_GLYPH) &&
1896 (c_ptr->feat <= FEAT_PATTERN_XTRA2)))
1900 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1902 msg_print("You cannot tunnel through air.");
1907 /* No tunnelling through mountains */
1908 else if (c_ptr->feat == FEAT_MOUNTAIN)
1911 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1913 msg_print("You can't tunnel through that!");
1918 /* A monster is in the way */
1919 else if (c_ptr->m_idx)
1926 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1928 msg_print("There is a monster in the way!");
1939 /* Tunnel through walls */
1940 more = do_cmd_tunnel_aux(y, x, dir);
1944 /* Cancel repetition unless we can continue */
1945 if (!more) disturb(0, 0);
1949 #ifdef ALLOW_EASY_OPEN /* TNB */
1954 * If there is a jammed/closed/locked door at the given location,
1955 * then attempt to unlock/open it. Return TRUE if an attempt was
1956 * made (successful or not), otherwise return FALSE.
1958 * The code here should be nearly identical to that in
1959 * do_cmd_open_test() and do_cmd_open_aux().
1961 bool easy_open_door(int y, int x)
1965 cave_type *c_ptr = &cave[y][x];
1967 /* Must be a closed door */
1968 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1969 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1976 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1980 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1982 msg_print("The door appears to be stuck.");
1988 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1991 i = p_ptr->skill_dis;
1993 /* Penalize some conditions */
1994 if (p_ptr->blind || no_lite()) i = i / 10;
1995 if (p_ptr->confused || p_ptr->image) i = i / 10;
1997 /* Extract the lock power */
1998 j = c_ptr->feat - FEAT_DOOR_HEAD;
2000 /* Extract the difficulty XXX XXX XXX */
2003 /* Always have a small chance of success */
2007 if (randint0(100) < j)
2011 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
2013 msg_print("You have picked the lock.");
2018 cave_set_feat(y, x, FEAT_OPEN);
2020 /* Update some things */
2021 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2024 sound(SOUND_OPENDOOR);
2034 if (flush_failure) flush();
2038 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2040 msg_print("You failed to pick the lock.");
2050 cave_set_feat(y, x, FEAT_OPEN);
2052 /* Update some things */
2053 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2056 sound(SOUND_OPENDOOR);
2063 #endif /* ALLOW_EASY_OPEN -- TNB */
2067 * Perform the basic "disarm" command
2069 * Assume destination is a visible trap
2071 * Assume there is no monster blocking the destination
2073 * Returns TRUE if repeated commands may continue
2075 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2081 object_type *o_ptr = &o_list[o_idx];
2087 /* Get the "disarm" factor */
2088 i = p_ptr->skill_dis;
2090 /* Penalize some conditions */
2091 if (p_ptr->blind || no_lite()) i = i / 10;
2092 if (p_ptr->confused || p_ptr->image) i = i / 10;
2094 /* Extract the difficulty */
2095 j = i - o_ptr->pval;
2097 /* Always have a small chance of success */
2100 /* Must find the trap first. */
2101 if (!object_known_p(o_ptr))
2104 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2106 msg_print("I don't see any traps.");
2111 /* Already disarmed/unlocked */
2112 else if (o_ptr->pval <= 0)
2115 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2117 msg_print("The chest is not trapped.");
2122 /* No traps to find. */
2123 else if (!chest_traps[o_ptr->pval])
2126 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2128 msg_print("The chest is not trapped.");
2133 /* Success (get a lot of experience) */
2134 else if (randint0(100) < j)
2137 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2139 msg_print("You have disarmed the chest.");
2142 gain_exp(o_ptr->pval);
2143 o_ptr->pval = (0 - o_ptr->pval);
2146 /* Failure -- Keep trying */
2147 else if ((i > 5) && (randint1(i) > 5))
2149 /* We may keep trying */
2151 if (flush_failure) flush();
2153 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2155 msg_print("You failed to disarm the chest.");
2160 /* Failure -- Set off the trap */
2164 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2166 msg_print("You set off a trap!");
2170 chest_trap(y, x, o_idx);
2179 * Perform the basic "disarm" command
2181 * Assume destination is a visible trap
2183 * Assume there is no monster blocking the destination
2185 * Returns TRUE if repeated commands may continue
2187 #ifdef ALLOW_EASY_DISARM /* TNB */
2189 bool do_cmd_disarm_aux(int y, int x, int dir)
2191 #else /* ALLOW_EASY_DISARM -- TNB */
2193 static bool do_cmd_disarm_aux(int y, int x, int dir)
2195 #endif /* ALLOW_EASY_DISARM -- TNB */
2209 /* Get grid and contents */
2210 c_ptr = &cave[y][x];
2212 /* Access trap name */
2213 name = (f_name + f_info[c_ptr->feat].name);
2215 /* Get the "disarm" factor */
2216 i = p_ptr->skill_dis;
2218 /* Penalize some conditions */
2219 if (p_ptr->blind || no_lite()) i = i / 10;
2220 if (p_ptr->confused || p_ptr->image) i = i / 10;
2222 /* XXX XXX XXX Variable power? */
2224 /* Extract trap "power" */
2227 /* Extract the difficulty */
2230 /* Always have a small chance of success */
2234 if (randint0(100) < j)
2238 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2240 msg_format("You have disarmed the %s.", name);
2247 /* Forget the trap */
2248 c_ptr->info &= ~(CAVE_MARK);
2250 /* Remove the trap */
2251 c_ptr->feat = floor_type[randint0(100)];
2255 #ifdef ALLOW_EASY_DISARM /* TNB */
2257 /* Move the player onto the trap */
2258 move_player(dir, easy_disarm, FALSE);
2260 #else /* ALLOW_EASY_DISARM -- TNB */
2262 /* move the player onto the trap grid */
2263 move_player(dir, FALSE, FALSE);
2265 #endif /* ALLOW_EASY_DISARM -- TNB */
2268 /* Failure -- Keep trying */
2269 else if ((i > 5) && (randint1(i) > 5))
2272 if (flush_failure) flush();
2276 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2278 msg_format("You failed to disarm the %s.", name);
2282 /* We may keep trying */
2286 /* Failure -- Set off the trap */
2291 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2293 msg_format("You set off the %s!", name);
2297 #ifdef ALLOW_EASY_DISARM /* TNB */
2299 /* Move the player onto the trap */
2300 move_player(dir, easy_disarm, FALSE);
2302 #else /* ALLOW_EASY_DISARM -- TNB */
2304 /* Move the player onto the trap */
2305 move_player(dir, FALSE, FALSE);
2307 #endif /* ALLOW_EASY_DISARM -- TNB */
2316 * Disarms a trap, or chest
2318 void do_cmd_disarm(void)
2328 if (p_ptr->special_defense & KATA_MUSOU)
2330 set_action(ACTION_NONE);
2333 #ifdef ALLOW_EASY_DISARM /* TNB */
2335 /* Option: Pick a direction */
2338 int num_traps, num_chests;
2340 /* Count visible traps */
2341 num_traps = count_dt(&y, &x, is_trap, TRUE);
2343 /* Count chests (trapped) */
2344 num_chests = count_chests(&y, &x, TRUE);
2346 /* See if only one target */
2347 if (num_traps || num_chests)
2349 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2351 if (!too_many) command_dir = coords_to_dir(y, x);
2355 #endif /* ALLOW_EASY_DISARM -- TNB */
2357 /* Allow repeated command */
2360 /* Set repeat count */
2361 command_rep = command_arg - 1;
2363 /* Redraw the state */
2364 p_ptr->redraw |= (PR_STATE);
2366 /* Cancel the arg */
2370 /* Get a direction (or abort) */
2371 if (get_rep_dir(&dir,TRUE))
2377 /* Get grid and contents */
2378 c_ptr = &cave[y][x];
2380 /* Check for chests */
2381 o_idx = chest_check(y, x);
2384 if (!is_trap(c_ptr->feat) && !o_idx)
2388 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2390 msg_print("You see nothing there to disarm.");
2395 /* Monster in the way */
2396 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2400 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2402 msg_print("There is a monster in the way!");
2413 /* Disarm the chest */
2414 more = do_cmd_disarm_chest(y, x, o_idx);
2420 /* Disarm the trap */
2421 more = do_cmd_disarm_aux(y, x, dir);
2425 /* Cancel repeat unless told not to */
2426 if (!more) disturb(0, 0);
2431 * Perform the basic "bash" command
2433 * Assume destination is a closed/locked/jammed door
2435 * Assume there is no monster blocking the destination
2437 * Returns TRUE if repeated commands may continue
2439 static bool do_cmd_bash_aux(int y, int x, int dir)
2452 c_ptr = &cave[y][x];
2456 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2458 msg_print("You smash into the door!");
2462 /* Hack -- Bash power based on strength */
2463 /* (Ranges from 3 to 20 to 100 to 200) */
2464 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2466 /* Extract door power */
2467 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2469 /* Compare bash power to door power XXX XXX XXX */
2470 temp = (bash - (temp * 10));
2472 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2474 /* Hack -- always have a chance */
2475 if (temp < 1) temp = 1;
2477 /* Hack -- attempt to bash down the door */
2478 if (randint0(100) < temp)
2482 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2484 msg_print("The door crashes open!");
2488 /* Break down the door */
2489 if (randint0(100) < 50)
2491 cave_set_feat(y, x, FEAT_BROKEN);
2497 cave_set_feat(y, x, FEAT_OPEN);
2501 sound(SOUND_OPENDOOR);
2503 /* Hack -- Fall through the door */
2504 move_player(dir, FALSE, FALSE);
2506 /* Update some things */
2507 p_ptr->update |= (PU_VIEW | PU_LITE);
2508 p_ptr->update |= (PU_DISTANCE);
2511 /* Saving throw against stun */
2512 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2517 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2519 msg_print("The door holds firm.");
2523 /* Allow repeated bashing */
2527 /* High dexterity yields coolness */
2532 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2534 msg_print("You are off-balance.");
2538 /* Hack -- Lose balance ala paralysis */
2539 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2548 * Bash open a door, success based on character strength
2550 * For a closed door, pval is positive if locked; negative if stuck.
2552 * For an open door, pval is positive for a broken door.
2554 * A closed door can be opened - harder if locked. Any door might be
2555 * bashed open (and thereby broken). Bashing a door is (potentially)
2556 * faster! You move into the door way. To open a stuck door, it must
2557 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2559 * Creatures can also open or bash doors, see elsewhere.
2561 void do_cmd_bash(void)
2570 if (p_ptr->special_defense & KATA_MUSOU)
2572 set_action(ACTION_NONE);
2575 /* Allow repeated command */
2578 /* Set repeat count */
2579 command_rep = command_arg - 1;
2581 /* Redraw the state */
2582 p_ptr->redraw |= (PR_STATE);
2584 /* Cancel the arg */
2588 /* Get a "repeated" direction */
2589 if (get_rep_dir(&dir,FALSE))
2596 c_ptr = &cave[y][x];
2598 /* Nothing useful */
2599 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2600 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2604 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2606 msg_print("You see nothing there to bash.");
2611 /* Monster in the way */
2612 else if (c_ptr->m_idx)
2619 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2621 msg_print("There is a monster in the way!");
2629 /* Bash a closed door */
2633 more = do_cmd_bash_aux(y, x, dir);
2637 /* Unless valid action taken, cancel bash */
2638 if (!more) disturb(0, 0);
2643 * Manipulate an adjacent grid in some way
2645 * Attack monsters, tunnel through walls, disarm traps, open doors.
2647 * Consider confusion XXX XXX XXX
2649 * This command must always take a turn, to prevent free detection
2650 * of invisible monsters.
2652 void do_cmd_alter(void)
2661 if (p_ptr->special_defense & KATA_MUSOU)
2663 set_action(ACTION_NONE);
2666 /* Allow repeated command */
2669 /* Set repeat count */
2670 command_rep = command_arg - 1;
2672 /* Redraw the state */
2673 p_ptr->redraw |= (PR_STATE);
2675 /* Cancel the arg */
2679 /* Get a direction */
2680 if (get_rep_dir(&dir,TRUE))
2687 c_ptr = &cave[y][x];
2692 /* Attack monsters */
2699 /* Tunnel through walls */
2700 else if (((c_ptr->feat >= FEAT_SECRET) &&
2701 (c_ptr->feat < FEAT_MINOR_GLYPH)) ||
2702 ((c_ptr->feat == FEAT_TREES) ||
2703 (c_ptr->feat == FEAT_MOUNTAIN)))
2706 more = do_cmd_tunnel_aux(y, x, dir);
2709 /* Bash jammed doors */
2710 else if ((c_ptr->feat >= FEAT_DOOR_HEAD + 0x08) &&
2711 (c_ptr->feat < FEAT_MINOR_GLYPH))
2714 more = do_cmd_bash_aux(y, x, dir);
2717 /* Open closed doors */
2718 else if ((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2719 (c_ptr->feat < FEAT_MINOR_GLYPH))
2722 more = do_cmd_open_aux(y, x, dir);
2725 /* Close open doors */
2726 else if ((c_ptr->feat == FEAT_OPEN) ||
2727 (c_ptr->feat == FEAT_BROKEN))
2730 more = do_cmd_close_aux(y, x, dir);
2734 else if (is_trap(c_ptr->feat))
2737 more = do_cmd_disarm_aux(y, x, dir);
2745 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2747 msg_print("You attack the empty air.");
2753 /* Cancel repetition unless we can continue */
2754 if (!more) disturb(0, 0);
2759 * Find the index of some "spikes", if possible.
2761 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2763 static bool get_spike(int *ip)
2767 /* Check every item in the pack */
2768 for (i = 0; i < INVEN_PACK; i++)
2770 object_type *o_ptr = &inventory[i];
2772 /* Skip non-objects */
2773 if (!o_ptr->k_idx) continue;
2775 /* Check the "tval" code */
2776 if (o_ptr->tval == TV_SPIKE)
2778 /* Save the spike index */
2792 * Jam a closed door with a spike
2794 * This command may NOT be repeated
2796 void do_cmd_spike(void)
2798 int y, x, dir, item;
2803 if (p_ptr->special_defense & KATA_MUSOU)
2805 set_action(ACTION_NONE);
2808 /* Get a "repeated" direction */
2809 if (get_rep_dir(&dir,FALSE))
2815 /* Get grid and contents */
2816 c_ptr = &cave[y][x];
2818 /* Require closed door */
2819 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2820 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2824 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2826 msg_print("You see nothing there to spike.");
2832 else if (!get_spike(&item))
2836 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2838 msg_print("You have no spikes!");
2843 /* Is a monster in the way? */
2844 else if (c_ptr->m_idx)
2851 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2853 msg_print("There is a monster in the way!");
2867 /* Successful jamming */
2869 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2871 msg_print("You jam the door with a spike.");
2875 /* Convert "locked" to "stuck" XXX XXX XXX */
2876 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2878 /* Add one spike to the door */
2879 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2881 /* Use up, and describe, a single spike, from the bottom */
2882 inven_item_increase(item, -1);
2883 inven_item_describe(item);
2884 inven_item_optimize(item);
2892 * Support code for the "Walk" and "Jump" commands
2894 void do_cmd_walk(int pickup)
2901 /* Allow repeated command */
2904 /* Set repeat count */
2905 command_rep = command_arg - 1;
2907 /* Redraw the state */
2908 p_ptr->redraw |= (PR_STATE);
2910 /* Cancel the arg */
2914 /* Get a "repeated" direction */
2915 if (get_rep_dir(&dir,FALSE))
2920 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2922 set_action(ACTION_NONE);
2925 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2926 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2927 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2929 /* Actually move the character */
2930 move_player(dir, pickup, FALSE);
2932 /* Allow more walking */
2936 /* Hack again -- Is there a special encounter ??? */
2937 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2939 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2942 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2944 /* Inform the player of his horrible fate :=) */
2946 msg_print("½±·â¤À¡ª");
2948 msg_print("You are ambushed !");
2951 /* Go into large wilderness view */
2952 p_ptr->wilderness_x = px;
2953 p_ptr->wilderness_y = py;
2954 p_ptr->oldpy = randint1(MAX_HGT-2);
2955 p_ptr->oldpx = randint1(MAX_WID-2);
2959 /* HACk -- set the encouter flag for the wilderness generation */
2960 generate_encounter = TRUE;
2964 /* Cancel repeat unless we may continue */
2965 if (!more) disturb(0, 0);
2973 void do_cmd_run(void)
2977 /* Hack -- no running when confused */
2978 if (p_ptr->confused)
2981 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2983 msg_print("You are too confused!");
2989 if (p_ptr->special_defense & KATA_MUSOU)
2991 set_action(ACTION_NONE);
2994 /* Get a "repeated" direction */
2995 if (get_rep_dir(&dir,FALSE))
2997 /* Hack -- Set the run counter */
2998 running = (command_arg ? command_arg : 1000);
3008 * Stay still. Search. Enter stores.
3009 * Pick up treasure if "pickup" is true.
3011 void do_cmd_stay(int pickup)
3013 cave_type *c_ptr = &cave[py][px];
3016 /* Allow repeated command */
3019 /* Set repeat count */
3020 command_rep = command_arg - 1;
3022 /* Redraw the state */
3023 p_ptr->redraw |= (PR_STATE);
3025 /* Cancel the arg */
3034 /* Spontaneous Searching */
3035 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3040 /* Continuous Searching */
3041 if (p_ptr->action == ACTION_SEARCH)
3047 /* Handle "objects" */
3051 /* Hack -- enter a store if we are on one */
3052 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3053 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3054 (c_ptr->feat == FEAT_MUSEUM))
3060 /* Hack -- enter store */
3061 command_new = SPECIAL_KEY_STORE;
3064 /* Hack -- enter a building if we are on one -KMW- */
3065 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3066 (c_ptr->feat <= FEAT_BLDG_TAIL))
3072 /* Hack -- enter building */
3073 command_new = SPECIAL_KEY_BUILDING;
3076 /* Exit a quest if reach the quest exit */
3077 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3079 int q_index = p_ptr->inside_quest;
3081 /* Was quest completed? */
3082 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3084 quest[q_index].status = QUEST_STATUS_COMPLETED;
3085 quest[q_index].complev = (byte)p_ptr->lev;
3087 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3089 msg_print("You accomplished your quest!");
3095 leave_quest_check();
3097 p_ptr->inside_quest = cave[py][px].special;
3101 p_ptr->leaving = TRUE;
3108 * Resting allows a player to safely restore his hp -RAK-
3110 void do_cmd_rest(void)
3113 set_action(ACTION_NONE);
3115 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3120 /* Prompt for time if needed */
3121 if (command_arg <= 0)
3124 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3126 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3133 strcpy(out_val, "&");
3135 /* Ask for duration */
3136 if (!get_string(p, out_val, 4)) return;
3138 /* Rest until done */
3139 if (out_val[0] == '&')
3145 else if (out_val[0] == '*')
3153 command_arg = atoi(out_val);
3154 if (command_arg <= 0) return;
3160 if (command_arg > 9999) command_arg = 9999;
3162 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3164 /* Take a turn XXX XXX XXX (?) */
3167 /* The sin of sloth */
3168 if (command_arg > 100)
3169 chg_virtue(V_DILIGENCE, -1);
3171 /* Why are you sleeping when there's no need? WAKE UP!*/
3172 if ((p_ptr->chp == p_ptr->mhp) &&
3173 (p_ptr->csp == p_ptr->msp) &&
3174 !p_ptr->blind && !p_ptr->confused &&
3175 !p_ptr->poisoned && !p_ptr->afraid &&
3176 !p_ptr->stun && !p_ptr->cut &&
3177 !p_ptr->slow && !p_ptr->paralyzed &&
3178 !p_ptr->image && !p_ptr->word_recall)
3179 chg_virtue(V_DILIGENCE, -1);
3181 /* Save the rest code */
3182 resting = command_arg;
3183 p_ptr->action = ACTION_REST;
3185 /* Recalculate bonuses */
3186 p_ptr->update |= (PU_BONUS);
3188 /* Redraw the state */
3189 p_ptr->redraw |= (PR_STATE);
3200 * Determines the odds of an object breaking when thrown at a monster
3202 * Note that artifacts never break, see the "drop_near()" function.
3204 static int breakage_chance(object_type *o_ptr)
3206 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3208 /* Examine the item type */
3209 switch (o_ptr->tval)
3225 /* Sometimes break */
3230 return (20 - archer_bonus * 2);
3235 return (10 - archer_bonus);
3242 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3246 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3250 /* Extract the flags */
3251 object_flags(o_ptr, &f1, &f2, &f3);
3253 /* Some "weapons" and "ammo" do extra damage */
3254 switch (o_ptr->tval)
3261 if ((f1 & TR1_SLAY_ANIMAL) &&
3262 (r_ptr->flags3 & RF3_ANIMAL))
3266 r_ptr->r_flags3 |= RF3_ANIMAL;
3269 if (mult < 17) mult = 17;
3273 if ((f1 & TR1_SLAY_EVIL) &&
3274 (r_ptr->flags3 & RF3_EVIL))
3278 r_ptr->r_flags3 |= RF3_EVIL;
3281 if (mult < 15) mult = 15;
3285 if ((f3 & TR3_SLAY_HUMAN) &&
3286 (r_ptr->flags2 & RF2_HUMAN))
3290 r_ptr->r_flags2 |= RF2_HUMAN;
3293 if (mult < 17) mult = 17;
3297 if ((f1 & TR1_SLAY_UNDEAD) &&
3298 (r_ptr->flags3 & RF3_UNDEAD))
3302 r_ptr->r_flags3 |= RF3_UNDEAD;
3305 if (mult < 20) mult = 20;
3309 if ((f1 & TR1_SLAY_DEMON) &&
3310 (r_ptr->flags3 & RF3_DEMON))
3314 r_ptr->r_flags3 |= RF3_DEMON;
3317 if (mult < 20) mult = 20;
3321 if ((f1 & TR1_SLAY_ORC) &&
3322 (r_ptr->flags3 & RF3_ORC))
3326 r_ptr->r_flags3 |= RF3_ORC;
3329 if (mult < 20) mult = 20;
3333 if ((f1 & TR1_SLAY_TROLL) &&
3334 (r_ptr->flags3 & RF3_TROLL))
3338 r_ptr->r_flags3 |= RF3_TROLL;
3341 if (mult < 20) mult = 20;
3345 if ((f1 & TR1_SLAY_GIANT) &&
3346 (r_ptr->flags3 & RF3_GIANT))
3350 r_ptr->r_flags3 |= RF3_GIANT;
3353 if (mult < 20) mult = 20;
3357 if ((f1 & TR1_SLAY_DRAGON) &&
3358 (r_ptr->flags3 & RF3_DRAGON))
3362 r_ptr->r_flags3 |= RF3_DRAGON;
3365 if (mult < 20) mult = 20;
3368 /* Execute Dragon */
3369 if ((f1 & TR1_KILL_DRAGON) &&
3370 (r_ptr->flags3 & RF3_DRAGON))
3374 r_ptr->r_flags3 |= RF3_DRAGON;
3377 if (mult < 30) mult = 30;
3379 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3380 (m_ptr->r_idx == MON_SMAUG) &&
3381 (inventory[INVEN_BOW].name1 == ART_BARD))
3386 if ((f1 & TR1_BRAND_ACID) || (p_ptr->special_attack & (ATTACK_ACID)))
3388 /* Notice immunity */
3389 if (r_ptr->flags3 & RF3_IM_ACID)
3393 r_ptr->r_flags3 |= RF3_IM_ACID;
3397 /* Otherwise, take the damage */
3400 if (mult < 17) mult = 17;
3405 if ((f1 & TR1_BRAND_ELEC) || (p_ptr->special_attack & (ATTACK_ELEC)))
3407 /* Notice immunity */
3408 if (r_ptr->flags3 & RF3_IM_ELEC)
3412 r_ptr->r_flags3 |= RF3_IM_ELEC;
3416 /* Otherwise, take the damage */
3419 if (mult < 17) mult = 17;
3424 if ((f1 & TR1_BRAND_FIRE) || (p_ptr->special_attack & (ATTACK_FIRE)))
3426 /* Notice immunity */
3427 if (r_ptr->flags3 & RF3_IM_FIRE)
3431 r_ptr->r_flags3 |= RF3_IM_FIRE;
3435 /* Otherwise, take the damage */
3438 if (mult < 17) mult = 17;
3443 if ((f1 & TR1_BRAND_COLD) || (p_ptr->special_attack & (ATTACK_COLD)))
3445 /* Notice immunity */
3446 if (r_ptr->flags3 & RF3_IM_COLD)
3450 r_ptr->r_flags3 |= RF3_IM_COLD;
3453 /* Otherwise, take the damage */
3456 if (mult < 17) mult = 17;
3460 /* Brand (Poison) */
3461 if ((f1 & TR1_BRAND_POIS) || (p_ptr->special_attack & (ATTACK_POIS)))
3463 /* Notice immunity */
3464 if (r_ptr->flags3 & RF3_IM_POIS)
3468 r_ptr->r_flags3 |= RF3_IM_POIS;
3472 /* Otherwise, take the damage */
3475 if (mult < 17) mult = 17;
3479 if ((f1 & TR1_FORCE_WEAPON) && (p_ptr->csp > (p_ptr->msp / 30)))
3481 p_ptr->csp -= (1+(p_ptr->msp / 30));
3482 p_ptr->redraw |= (PR_MANA);
3483 mult = mult * 5 / 2;
3489 /* Return the total damage */
3490 return (tdam * mult / 10);
3495 * Fire an object from the pack or floor.
3497 * You may only fire items that "match" your missile launcher.
3499 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3501 * See "calc_bonuses()" for more calculations and such.
3503 * Note that "firing" a missile is MUCH better than "throwing" it.
3505 * Note: "unseen" monsters are very hard to hit.
3507 * Objects are more likely to break if they "attempt" to hit a monster.
3509 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3511 * The "extra shot" code works by decreasing the amount of energy
3512 * required to make each shot, spreading the shots out over time.
3514 * Note that when firing missiles, the launcher multiplier is applied
3515 * after all the bonuses are added in, making multipliers very useful.
3517 * Note that Bows of "Extra Might" get extra range and an extra bonus
3518 * for the damage multiplier.
3520 * Note that Bows of "Extra Shots" give an extra shot.
3522 void do_cmd_fire_aux(int item, object_type *j_ptr)
3525 int j, y, x, ny, nx, ty, tx;
3526 int tdam, tdis, thits, tmul;
3528 int cur_dis, visible;
3535 bool hit_body = FALSE;
3537 char o_name[MAX_NLEN];
3539 int msec = delay_factor * delay_factor * delay_factor;
3542 bool stick_to = FALSE;
3544 /* Access the item (if in the pack) */
3547 o_ptr = &inventory[item];
3551 o_ptr = &o_list[0 - item];
3554 /* Describe the object */
3555 object_desc(o_name, o_ptr, FALSE, 3);
3558 /* Use the proper number of shots */
3559 thits = p_ptr->num_fire;
3561 /* Use a base distance */
3564 /* Base damage from thrown object plus launcher bonus */
3565 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3567 /* Actually "fire" the object */
3568 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3569 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3570 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval])/400 + bonus) * BTH_PLUS_ADJ);
3572 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3574 energy_use = bow_energy(j_ptr->sval);
3575 tmul = bow_tmul(j_ptr->sval);
3577 /* Get extra "power" from "extra might" */
3578 if (p_ptr->xtra_might) tmul++;
3580 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3582 /* Boost the damage */
3587 tdis = 10 + tmul/40;
3588 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3591 project_length = tdis + 1;
3593 /* Get a direction (or cancel) */
3594 if (!get_aim_dir(&dir))
3598 /* need not to reset project_length (already did)*/
3602 project_length = 0; /* reset to default */
3604 /* Get local object */
3607 /* Obtain a local object */
3608 object_copy(q_ptr, o_ptr);
3613 /* Reduce and describe inventory */
3616 inven_item_increase(item, -1);
3617 inven_item_describe(item);
3618 inven_item_optimize(item);
3621 /* Reduce and describe floor item */
3624 floor_item_increase(0 - item, -1);
3625 floor_item_optimize(0 - item);
3633 /* Take a (partial) turn */
3634 energy_use = (energy_use / thits);
3637 /* Start at the player */
3641 /* Predict the "target" location */
3642 tx = px + 99 * ddx[dir];
3643 ty = py + 99 * ddy[dir];
3645 /* Check for "target request" */
3646 if ((dir == 5) && target_okay())
3653 /* Hack -- Handle stuff */
3657 /* Travel until stopped */
3658 for (cur_dis = 0; cur_dis <= tdis; )
3660 /* Hack -- Stop at the target */
3661 if ((y == ty) && (x == tx)) break;
3663 /* Calculate the new location (see "project()") */
3666 mmove2(&ny, &nx, py, px, ty, tx);
3668 /* Stopped by walls/doors */
3669 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3671 /* Advance the distance */
3675 /* The player can see the (on screen) missile */
3676 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3678 char c = object_char(q_ptr);
3679 byte a = object_attr(q_ptr);
3681 /* Draw, Hilite, Fresh, Pause, Erase */
3682 print_rel(c, a, ny, nx);
3683 move_cursor_relative(ny, nx);
3685 Term_xtra(TERM_XTRA_DELAY, msec);
3690 /* The player cannot see the missile */
3693 /* Pause anyway, for consistancy */
3694 Term_xtra(TERM_XTRA_DELAY, msec);
3697 /* Save the new location */
3702 /* Monster here, Try to hit it */
3703 if (cave[y][x].m_idx)
3705 cave_type *c_ptr = &cave[y][x];
3707 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3708 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3710 /* Check the visibility */
3711 visible = m_ptr->ml;
3713 /* Note the collision */
3718 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3719 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3722 if ((r_ptr->level + 10) > p_ptr->lev)
3724 int now_exp = weapon_exp[0][j_ptr->sval];
3725 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3728 if (now_exp < 4000) amount = 80;
3729 else if (now_exp < 6000) amount = 25;
3730 else if ((now_exp < 7000) && (p_ptr->lev > 19)) amount = 10;
3731 else if (p_ptr->lev > 34) amount = 2;
3732 weapon_exp[0][j_ptr->sval] += amount;
3733 p_ptr->update |= (PU_BONUS);
3739 if (skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING] && ((skill_exp[GINOU_RIDING] - 1000) / 200 < r_info[m_list[p_ptr->riding].r_idx].level) && one_in_(2))
3741 skill_exp[GINOU_RIDING]+=1;
3742 p_ptr->update |= (PU_BONUS);
3746 /* Did we hit it (penalize range) */
3747 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3751 /* Assume a default death */
3753 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3755 cptr note_dies = " dies.";
3758 /* Some monsters get "destroyed" */
3759 if (!monster_living(r_ptr))
3762 bool explode = FALSE;
3764 for (i = 0; i < 4; i++)
3766 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3769 /* Special note at death */
3772 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3774 note_dies = " explodes into tiny shreds.";
3778 note_dies = "¤òÅݤ·¤¿¡£";
3780 note_dies = " is destroyed.";
3785 /* Handle unseen monster */
3788 /* Invisible monster */
3790 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3792 msg_format("The %s finds a mark.", o_name);
3797 /* Handle visible monster */
3802 /* Get "the monster" or "it" */
3803 monster_desc(m_name, m_ptr, 0);
3807 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3809 msg_format("The %s hits %s.", o_name, m_name);
3813 /* Hack -- Track this monster race */
3814 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3816 /* Hack -- Track this monster */
3817 if (m_ptr->ml) health_track(c_ptr->m_idx);
3820 /* Apply special damage XXX XXX XXX */
3821 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3822 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3824 /* No negative damage */
3825 if (tdam < 0) tdam = 0;
3827 /* Modify the damage */
3828 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3830 /* Complex message */
3831 if (wizard || cheat_xtra)
3834 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3837 msg_format("You do %d (out of %d) damage.",
3843 /* Hit the monster, check for death */
3844 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3857 monster_desc(m_name, m_ptr, 0);
3861 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3863 msg_format("%^s have stuck into %s!",o_name, m_name);
3868 message_pain(c_ptr->m_idx, tdam);
3870 /* Anger the monster */
3871 if (tdam > 0) anger_monster(m_ptr);
3874 if (fear && m_ptr->ml)
3881 /* Get the monster name (or "it") */
3882 monster_desc(m_name, m_ptr, 0);
3886 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3888 msg_format("%^s flees in terror!", m_name);
3892 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3894 set_target(m_ptr, py, px);
3904 /* Chance of breakage (during attacks) */
3905 j = (hit_body ? breakage_chance(q_ptr) : 0);
3909 int m_idx = cave[y][x].m_idx;
3910 monster_type *m_ptr = &m_list[m_idx];
3911 int o_idx = o_pop();
3916 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3918 msg_format("The %s have gone to somewhere.", o_name);
3922 a_info[j_ptr->name1].cur_num = 0;
3927 o_ptr = &o_list[ o_idx ];
3928 object_copy(o_ptr, q_ptr);
3931 o_ptr->marked = FALSE;
3933 /* Forget location */
3934 o_ptr->iy = o_ptr->ix = 0;
3936 /* Memorize monster */
3937 o_ptr->held_m_idx = m_idx;
3940 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3943 m_ptr->hold_o_idx = o_idx;
3947 /* Drop (or break) near that location */
3948 (void)drop_near(q_ptr, j, y, x);
3952 void do_cmd_fire(void)
3958 /* Get the "bow" (if any) */
3959 j_ptr = &inventory[INVEN_BOW];
3961 /* Require a launcher */
3965 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
3967 msg_print("You have nothing to fire with.");
3973 if (j_ptr->sval == SV_CRIMSON)
3976 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
3978 msg_print("Do activate.");
3985 if (p_ptr->special_defense & KATA_MUSOU)
3987 set_action(ACTION_NONE);
3990 /* Require proper missile */
3991 item_tester_tval = p_ptr->tval_ammo;
3995 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
3996 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3998 q = "Fire which item? ";
3999 s = "You have nothing to fire.";
4002 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4009 do_cmd_fire_aux(item, j_ptr);
4013 static bool item_tester_hook_boomerang(object_type *o_ptr)
4015 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4023 * Throw an object from the pack or floor.
4025 * Note: "unseen" monsters are very hard to hit.
4027 * Should throwing a weapon do full damage? Should it allow the magic
4028 * to hit bonus of the weapon to have an effect? Should it ever cause
4029 * the item to be destroyed? Should it do any damage at all?
4031 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4034 int i, j, y, x, ty, tx;
4036 int chance, tdam, tdis;
4038 int cur_dis, visible;
4045 bool hit_body = FALSE;
4046 bool hit_wall = FALSE;
4047 bool equiped_item = FALSE;
4048 bool return_when_thrown = FALSE;
4050 char o_name[MAX_NLEN];
4052 int msec = delay_factor * delay_factor * delay_factor;
4056 bool come_back = FALSE;
4057 bool do_drop = TRUE;
4060 if (p_ptr->special_defense & KATA_MUSOU)
4062 set_action(ACTION_NONE);
4071 if (buki_motteruka(INVEN_LARM))
4073 item_tester_hook = item_tester_hook_boomerang;
4075 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4076 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4078 q = "Throw which item? ";
4079 s = "You have nothing to throw.";
4082 if (!get_item(&item, q, s, (USE_EQUIP)))
4097 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4098 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4100 q = "Throw which item? ";
4101 s = "You have nothing to throw.";
4104 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4111 /* Access the item (if in the pack) */
4114 o_ptr = &inventory[item];
4118 o_ptr = &o_list[0 - item];
4122 /* Item is cursed */
4123 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4127 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4129 msg_print("Hmmm, it seems to be cursed.");
4136 if (p_ptr->inside_arena)
4138 if (o_ptr->tval != 5)
4141 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4143 msg_print("You're in the arena now. This is hand-to-hand!");
4152 /* Get local object */
4155 /* Obtain a local object */
4156 object_copy(q_ptr, o_ptr);
4158 /* Extract the thrown object's flags. */
4159 object_flags(q_ptr, &f1, &f2, &f3);
4161 /* Distribute the charges of rods/wands between the stacks */
4162 distribute_charges(o_ptr, q_ptr, 1);
4168 object_desc(o_name, q_ptr, FALSE, 3);
4170 if (p_ptr->mighty_throw) mult += 3;
4172 /* Extract a "distance multiplier" */
4173 /* Changed for 'launcher' mutation */
4174 mul = 10 + 2 * (mult - 1);
4176 /* Enforce a minimum "weight" of one pound */
4177 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4178 if ((f2 & (TR2_THROW)) || boomerang) div /= 2;
4180 /* Hack -- Distance -- Reward strength, penalize weight */
4181 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4183 /* Max distance of 10-18 */
4184 if (tdis > mul) tdis = mul;
4188 ty = randint0(101)-50+py;
4189 tx = randint0(101)-50+px;
4193 project_length = tdis + 1;
4195 /* Get a direction (or cancel) */
4196 if (!get_aim_dir(&dir)) return FALSE;
4198 project_length = 0; /* reset to default */
4200 /* Predict the "target" location */
4201 tx = px + 99 * ddx[dir];
4202 ty = py + 99 * ddy[dir];
4204 /* Check for "target request" */
4205 if ((dir == 5) && target_okay())
4212 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4213 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4214 return_when_thrown = TRUE;
4216 /* Reduce and describe inventory */
4219 inven_item_increase(item, -1);
4220 if (!return_when_thrown)
4221 inven_item_describe(item);
4222 inven_item_optimize(item);
4225 /* Reduce and describe floor item */
4228 floor_item_increase(0 - item, -1);
4229 floor_item_optimize(0 - item);
4231 if (item >= INVEN_RARM)
4233 equiped_item = TRUE;
4234 p_ptr->redraw |= (PR_EQUIPPY);
4240 /* Rogue and Ninja gets bonus */
4241 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4242 energy_use -= p_ptr->lev;
4244 /* Start at the player */
4249 /* Hack -- Handle stuff */
4252 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((f2 & TR2_THROW) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4253 else shuriken = FALSE;
4255 /* Chance of hitting */
4256 if (f2 & (TR2_THROW)) chance = ((p_ptr->skill_tht) +
4257 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4258 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4260 if (shuriken) chance *= 2;
4262 /* Travel until stopped */
4263 for (cur_dis = 0; cur_dis <= tdis; )
4265 /* Hack -- Stop at the target */
4266 if ((y == ty) && (x == tx)) break;
4268 /* Calculate the new location (see "project()") */
4271 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4273 /* Stopped by walls/doors */
4274 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4280 /* Advance the distance */
4283 /* The player can see the (on screen) missile */
4284 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4286 char c = object_char(q_ptr);
4287 byte a = object_attr(q_ptr);
4289 /* Draw, Hilite, Fresh, Pause, Erase */
4290 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4291 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4293 Term_xtra(TERM_XTRA_DELAY, msec);
4294 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4298 /* The player cannot see the missile */
4301 /* Pause anyway, for consistancy */
4302 Term_xtra(TERM_XTRA_DELAY, msec);
4305 /* Save the new location */
4310 /* Monster here, Try to hit it */
4311 if (cave[y][x].m_idx)
4313 cave_type *c_ptr = &cave[y][x];
4315 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4316 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4318 /* Check the visibility */
4319 visible = m_ptr->ml;
4321 /* Note the collision */
4324 /* Did we hit it (penalize range) */
4325 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4329 /* Assume a default death */
4331 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4333 cptr note_dies = " dies.";
4337 /* Some monsters get "destroyed" */
4338 if (!monster_living(r_ptr))
4341 bool explode = FALSE;
4343 for (i = 0; i < 4; i++)
4345 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4348 /* Special note at death */
4351 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4353 note_dies = " explodes into tiny shreds.";
4357 note_dies = "¤òÅݤ·¤¿¡£";
4359 note_dies = " is destroyed.";
4365 /* Handle unseen monster */
4368 /* Invisible monster */
4370 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4372 msg_format("The %s finds a mark.", o_name);
4377 /* Handle visible monster */
4382 /* Get "the monster" or "it" */
4383 monster_desc(m_name, m_ptr, 0);
4387 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4389 msg_format("The %s hits %s.", o_name, m_name);
4393 /* Hack -- Track this monster race */
4394 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4396 /* Hack -- Track this monster */
4397 if (m_ptr->ml) health_track(c_ptr->m_idx);
4400 /* Hack -- Base damage from thrown object */
4401 tdam = damroll(q_ptr->dd, q_ptr->ds);
4402 /* Apply special damage XXX XXX XXX */
4403 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4404 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4405 if (q_ptr->to_d > 0)
4406 tdam += q_ptr->to_d;
4408 tdam += -q_ptr->to_d;
4412 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4413 tdam += p_ptr->to_d_m;
4415 else if (f2 & (TR2_THROW))
4418 tdam += p_ptr->to_d_m;
4426 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4429 /* No negative damage */
4430 if (tdam < 0) tdam = 0;
4432 /* Modify the damage */
4433 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4435 /* Complex message */
4439 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4442 msg_format("You do %d (out of %d) damage.",
4448 /* Hit the monster, check for death */
4449 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4458 message_pain(c_ptr->m_idx, tdam);
4460 /* Anger the monster */
4461 if ((tdam > 0) && !object_is_potion(q_ptr))
4462 anger_monster(m_ptr);
4465 if (fear && m_ptr->ml)
4472 /* Get the monster name (or "it") */
4473 monster_desc(m_name, m_ptr, 0);
4477 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4479 msg_format("%^s flees in terror!", m_name);
4491 /* Chance of breakage (during attacks) */
4492 j = (hit_body ? breakage_chance(q_ptr) : 0);
4494 /* Figurines transform */
4495 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4499 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4500 !(cursed_p(q_ptr)) ? PM_FORCE_PET : 0L)))
4502 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4504 msg_print("The Figurine writhes and then shatters.");
4507 else if (cursed_p(q_ptr))
4509 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4511 msg_print("You have a bad feeling about this.");
4517 /* Potions smash open */
4518 if (object_is_potion(q_ptr))
4520 if (hit_body || hit_wall || (randint1(100) < j))
4524 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4526 msg_format("The %s shatters!", o_name);
4530 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4532 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4534 /* ToDo (Robert): fix the invulnerability */
4535 if (cave[y][x].m_idx &&
4536 is_friendly(&m_list[cave[y][x].m_idx]) &&
4540 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4542 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4544 msg_format("%^s gets angry!", m_name);
4547 set_hostile(&m_list[cave[y][x].m_idx]);
4558 if (return_when_thrown)
4560 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4561 char o2_name[MAX_NLEN];
4562 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4565 if (boomerang) back_chance += 4+randint1(5);
4566 if (super_boomerang) back_chance += 100;
4567 object_desc(o2_name, q_ptr, FALSE, 0);
4569 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4571 for (i = cur_dis-1;i>0;i--)
4573 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4575 char c = object_char(q_ptr);
4576 byte a = object_attr(q_ptr);
4578 /* Draw, Hilite, Fresh, Pause, Erase */
4579 print_rel(c, a, ny[i], nx[i]);
4580 move_cursor_relative(ny[i], nx[i]);
4582 Term_xtra(TERM_XTRA_DELAY, msec);
4583 lite_spot(ny[i], nx[i]);
4588 /* Pause anyway, for consistancy */
4589 Term_xtra(TERM_XTRA_DELAY, msec);
4592 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4595 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4597 msg_format("%s comes back to you.", o2_name);
4606 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4608 msg_format("%s backs, but you can't catch!", o2_name);
4614 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4616 msg_format("%s comes back.", o2_name);
4626 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4628 msg_format("%s doesn't back!", o2_name);
4635 if (item == INVEN_RARM || item == INVEN_LARM)
4637 /* Access the wield slot */
4638 o_ptr = &inventory[item];
4640 /* Wear the new stuff */
4641 object_copy(o_ptr, q_ptr);
4643 /* Increase the weight */
4644 p_ptr->total_weight += q_ptr->weight;
4646 /* Increment the equip counter by hand */
4649 /* Recalculate bonuses */
4650 p_ptr->update |= (PU_BONUS);
4652 /* Recalculate torch */
4653 p_ptr->update |= (PU_TORCH);
4655 /* Recalculate mana XXX */
4656 p_ptr->update |= (PU_MANA);
4659 p_ptr->window |= (PW_EQUIP);
4667 else if (equiped_item)
4673 /* Drop (or break) near that location */
4674 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4681 * Throw an object from the pack or floor.
4683 void do_cmd_throw(void)
4685 do_cmd_throw_aux(1, FALSE, 0);