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)
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, TRUE, FALSE, FALSE, TRUE, TRUE);
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, TRUE, FALSE, FALSE, TRUE, TRUE);
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, TRUE, FALSE, FALSE, TRUE, TRUE);
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, TRUE, FALSE, FALSE, TRUE, TRUE);
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, TRUE, FALSE, FALSE, TRUE, TRUE);
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, TRUE, FALSE, FALSE, TRUE, TRUE);
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, TRUE, FALSE, FALSE, TRUE, TRUE);
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);
810 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
813 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
814 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
816 msg_print("There is a sudden explosion!");
817 msg_print("Everything inside the chest is destroyed!");
821 sound(SOUND_EXPLODE);
823 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
825 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
829 /* Scatter contents. */
830 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
833 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
835 msg_print("The contents of the chest scatter all over the dungeon!");
837 chest_death(TRUE, y, x, o_idx);
844 * Attempt to open the given chest at the given location
846 * Assume there is no monster blocking the destination
848 * Returns TRUE if repeated commands may continue
850 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
858 object_type *o_ptr = &o_list[o_idx];
864 /* Attempt to unlock it */
867 /* Assume locked, and thus not open */
870 /* Get the "disarm" factor */
871 i = p_ptr->skill_dis;
873 /* Penalize some conditions */
874 if (p_ptr->blind || no_lite()) i = i / 10;
875 if (p_ptr->confused || p_ptr->image) i = i / 10;
877 /* Extract the difficulty */
880 /* Always have a small chance of success */
883 /* Success -- May still have traps */
884 if (randint0(100) < j)
887 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
889 msg_print("You have picked the lock.");
896 /* Failure -- Keep trying */
899 /* We may continue repeating */
901 if (flush_failure) flush();
903 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
905 msg_print("You failed to pick the lock.");
911 /* Allowed to open */
914 /* Apply chest traps, if any */
915 chest_trap(y, x, o_idx);
917 /* Let the Chest drop items */
918 chest_death(FALSE, y, x, o_idx);
926 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
929 * Return TRUE if the given feature is an open door
931 static bool is_open(int feat)
933 return (feat == FEAT_OPEN);
936 static bool is_closed(int feat)
938 return ((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL));
942 * Return the number of features around (or under) the character.
943 * Usually look for doors and floor traps.
945 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
947 int d, count, xx, yy;
949 /* Count how many matches */
952 /* Check around (and under) the character */
953 for (d = 0; d < 9; d++)
955 /* if not searching under player continue */
956 if ((d == 8) && !under) continue;
958 /* Extract adjacent (legal) location */
959 yy = py + ddy_ddd[d];
960 xx = px + ddx_ddd[d];
962 /* Must have knowledge */
963 if (!(cave[yy][xx].info & (CAVE_MARK))) continue;
965 /* Not looking for this feature */
966 if (!((*test)(cave[yy][xx].feat))) continue;
971 /* Remember the location. Only useful if only one match */
982 * Return the number of chests around (or under) the character.
983 * If requested, count only trapped chests.
985 static int count_chests(int *y, int *x, bool trapped)
991 /* Count how many matches */
994 /* Check around (and under) the character */
995 for (d = 0; d < 9; d++)
997 /* Extract adjacent (legal) location */
998 int yy = py + ddy_ddd[d];
999 int xx = px + ddx_ddd[d];
1001 /* No (visible) chest is there */
1002 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1004 /* Grab the object */
1005 o_ptr = &o_list[o_idx];
1008 if (o_ptr->pval == 0) continue;
1010 /* No (known) traps here */
1011 if (trapped && (!object_known_p(o_ptr) ||
1012 !chest_traps[o_ptr->pval])) continue;
1017 /* Remember the location. Only useful if only one match */
1028 * Convert an adjacent location to a direction.
1030 static int coords_to_dir(int y, int x)
1032 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1039 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1041 return d[dx + 1][dy + 1];
1044 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1048 * Perform the basic "open" command on doors
1050 * Assume destination is a closed/locked/jammed door
1052 * Assume there is no monster blocking the destination
1054 * Returns TRUE if repeated commands may continue
1056 static bool do_cmd_open_aux(int y, int x, int dir)
1068 /* Get requested grid */
1069 c_ptr = &cave[y][x];
1072 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1076 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1078 msg_print("The door appears to be stuck.");
1084 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1087 i = p_ptr->skill_dis;
1089 /* Penalize some conditions */
1090 if (p_ptr->blind || no_lite()) i = i / 10;
1091 if (p_ptr->confused || p_ptr->image) i = i / 10;
1093 /* Extract the lock power */
1094 j = c_ptr->feat - FEAT_DOOR_HEAD;
1096 /* Extract the difficulty XXX XXX XXX */
1099 /* Always have a small chance of success */
1103 if (randint0(100) < j)
1107 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1109 msg_print("You have picked the lock.");
1114 cave_set_feat(y, x, FEAT_OPEN);
1116 /* Update some things */
1117 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1120 sound(SOUND_OPENDOOR);
1130 if (flush_failure) flush();
1134 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1136 msg_print("You failed to pick the lock.");
1140 /* We may keep trying */
1149 cave_set_feat(y, x, FEAT_OPEN);
1151 /* Update some things */
1152 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1155 sound(SOUND_OPENDOOR);
1165 * Open a closed/locked/jammed door or a closed/locked chest.
1167 * Unlocking a locked door/chest is worth one experience point.
1169 void do_cmd_open(void)
1179 if (p_ptr->special_defense & KATA_MUSOU)
1181 set_action(ACTION_NONE);
1184 #ifdef ALLOW_EASY_OPEN /* TNB */
1186 /* Option: Pick a direction */
1189 int num_doors, num_chests;
1191 /* Count closed doors (locked or jammed) */
1192 num_doors = count_dt(&y, &x, is_closed, FALSE);
1194 /* Count chests (locked) */
1195 num_chests = count_chests(&y, &x, FALSE);
1197 /* See if only one target */
1198 if (num_doors || num_chests)
1200 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1202 if (!too_many) command_dir = coords_to_dir(y, x);
1206 #endif /* ALLOW_EASY_OPEN -- TNB */
1208 /* Allow repeated command */
1211 /* Set repeat count */
1212 command_rep = command_arg - 1;
1214 /* Redraw the state */
1215 p_ptr->redraw |= (PR_STATE);
1217 /* Cancel the arg */
1221 /* Get a "repeated" direction */
1222 if (get_rep_dir(&dir, TRUE))
1224 /* Get requested location */
1228 /* Get requested grid */
1229 c_ptr = &cave[y][x];
1231 /* Check for chest */
1232 o_idx = chest_check(y, x);
1234 /* Nothing useful */
1235 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1236 (c_ptr->feat <= FEAT_DOOR_TAIL)) &&
1241 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1243 msg_print("You see nothing there to open.");
1248 /* Monster in the way */
1249 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1256 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1258 msg_print("There is a monster in the way!");
1269 /* Open the chest */
1270 more = do_cmd_open_chest(y, x, o_idx);
1277 more = do_cmd_open_aux(y, x, dir);
1281 /* Cancel repeat unless we may continue */
1282 if (!more) disturb(0, 0);
1288 * Perform the basic "close" command
1290 * Assume destination is an open/broken door
1292 * Assume there is no monster blocking the destination
1294 * Returns TRUE if repeated commands may continue
1296 static bool do_cmd_close_aux(int y, int x, int dir)
1306 /* Get grid and contents */
1307 c_ptr = &cave[y][x];
1310 if (c_ptr->feat == FEAT_BROKEN)
1314 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1316 msg_print("The door appears to be broken.");
1324 /* Close the door */
1325 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1327 /* Update some things */
1328 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1331 sound(SOUND_SHUTDOOR);
1340 * Close an open door.
1342 void do_cmd_close(void)
1350 if (p_ptr->special_defense & KATA_MUSOU)
1352 set_action(ACTION_NONE);
1355 #ifdef ALLOW_EASY_OPEN /* TNB */
1357 /* Option: Pick a direction */
1360 /* Count open doors */
1361 if (count_dt(&y, &x, is_open, FALSE) == 1)
1363 command_dir = coords_to_dir(y, x);
1367 #endif /* ALLOW_EASY_OPEN -- TNB */
1369 /* Allow repeated command */
1372 /* Set repeat count */
1373 command_rep = command_arg - 1;
1375 /* Redraw the state */
1376 p_ptr->redraw |= (PR_STATE);
1378 /* Cancel the arg */
1382 /* Get a "repeated" direction */
1383 if (get_rep_dir(&dir,FALSE))
1385 /* Get requested location */
1389 /* Get grid and contents */
1390 c_ptr = &cave[y][x];
1392 /* Require open/broken door */
1393 if ((c_ptr->feat != FEAT_OPEN) && (c_ptr->feat != FEAT_BROKEN))
1397 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1399 msg_print("You see nothing there to close.");
1404 /* Monster in the way */
1405 else if (c_ptr->m_idx)
1412 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1414 msg_print("There is a monster in the way!");
1422 /* Close the door */
1425 /* Close the door */
1426 more = do_cmd_close_aux(y, x, dir);
1430 /* Cancel repeat unless we may continue */
1431 if (!more) disturb(0, 0);
1436 * Determine if a given grid may be "tunneled"
1438 static bool do_cmd_tunnel_test(int y, int x)
1440 /* Must have knowledge */
1441 if (!(cave[y][x].info & (CAVE_MARK)))
1445 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1447 msg_print("You see nothing there.");
1455 /* Must be a wall/door/etc */
1456 if (cave_floor_bold(y, x))
1460 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1462 msg_print("You see nothing there to tunnel.");
1477 * Tunnel through wall. Assumes valid location.
1479 * Note that it is impossible to "extend" rooms past their
1480 * outer walls (which are actually part of the room).
1482 * This will, however, produce grids which are NOT illuminated
1483 * (or darkened) along with the rest of the room.
1485 static bool twall(int y, int x, byte feat)
1487 cave_type *c_ptr = &cave[y][x];
1489 /* Paranoia -- Require a wall or door or some such */
1490 if (cave_floor_bold(y, x)) return (FALSE);
1492 /* Forget the wall */
1493 c_ptr->info &= ~(CAVE_MARK);
1494 c_ptr->info &= ~(CAVE_MASK);
1495 c_ptr->info |= (CAVE_FLOOR);
1497 /* Remove the feature */
1498 cave_set_feat(y, x, feat);
1500 /* Update some things */
1501 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1510 * Perform the basic "tunnel" command
1512 * Assumes that the destination is a wall, a vein, a secret
1515 * Assumes that no monster is blocking the destination
1517 * Returns TRUE if repeated commands may continue
1519 static bool do_cmd_tunnel_aux(int y, int x, int dir)
1525 /* Verify legality */
1526 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1532 c_ptr = &cave[y][x];
1538 if ((c_ptr->feat >= FEAT_PERM_EXTRA) &&
1539 (c_ptr->feat <= FEAT_PERM_SOLID))
1542 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1544 msg_print("This seems to be permanent rock.");
1549 /* No tunnelling through mountains */
1550 else if (c_ptr->feat == FEAT_MOUNTAIN)
1553 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1555 msg_print("You can't tunnel through that!");
1560 else if (c_ptr->feat == FEAT_TREES) /* -KMW- */
1563 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1566 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1568 msg_print("You have cleared away the trees.");
1570 chg_virtue(V_DILIGENCE, 1);
1571 chg_virtue(V_NATURE, -1);
1577 /* We may continue chopping */
1579 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1581 msg_print("You chop away at the tree.");
1586 /* Occasional Search XXX XXX */
1587 if (randint0(100) < 25) search();
1593 else if ((c_ptr->feat >= FEAT_WALL_EXTRA) &&
1594 (c_ptr->feat <= FEAT_WALL_SOLID))
1597 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1600 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1602 msg_print("You have finished the tunnel.");
1604 chg_virtue(V_DILIGENCE, 1);
1605 chg_virtue(V_NATURE, -1);
1611 /* We may continue tunelling */
1613 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1615 msg_print("You tunnel into the granite wall.");
1623 /* Quartz / Magma */
1624 else if ((c_ptr->feat >= FEAT_MAGMA) &&
1625 (c_ptr->feat <= FEAT_QUARTZ_K))
1632 if (c_ptr->feat >= FEAT_MAGMA_H) gold = TRUE;
1634 /* Extract "quartz" flag XXX XXX XXX */
1635 if ((c_ptr->feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1640 okay = (p_ptr->skill_dig > 20 + randint0(800));
1646 okay = (p_ptr->skill_dig > 10 + randint0(400));
1650 if (okay && twall(y, x, floor_type[randint0(100)]))
1652 /* Found treasure */
1655 /* Place some gold */
1660 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1662 msg_print("You have found something!");
1672 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1674 msg_print("You have finished the tunnel.");
1676 chg_virtue(V_DILIGENCE, 1);
1677 chg_virtue(V_NATURE, -1);
1681 /* Failure (quartz) */
1684 /* Message, continue digging */
1686 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1688 msg_print("You tunnel into the quartz vein.");
1694 /* Failure (magma) */
1697 /* Message, continue digging */
1699 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1701 msg_print("You tunnel into the magma vein.");
1709 else if (c_ptr->feat == FEAT_RUBBLE)
1711 /* Remove the rubble */
1712 if ((p_ptr->skill_dig > randint0(200)) && twall(y, x, floor_type[randint0(100)]))
1716 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1718 msg_print("You have removed the rubble.");
1721 /* Hack -- place an object */
1722 if (randint0(100) < (15 - dun_level/2))
1724 /* Create a simple object */
1725 place_object(y, x, FALSE, FALSE);
1727 /* Observe new object */
1728 if (player_can_see_bold(y, x))
1731 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1733 msg_print("You have found something!");
1742 /* Message, keep digging */
1744 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1746 msg_print("You dig in the rubble.");
1754 else if (c_ptr->feat >= FEAT_SECRET)
1757 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint0(100)]))
1760 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1762 msg_print("You have finished the tunnel.");
1770 /* We may continue tunelling */
1772 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1774 msg_print("You tunnel into the granite wall.");
1779 /* Occasional Search XXX XXX */
1780 if (randint0(100) < 25) search();
1788 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint1(100)]))
1791 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1793 msg_print("You have finished the tunnel.");
1801 /* We may continue tunelling */
1803 msg_print("¥É¥¢¤Ë·ê¤ò³«¤±¤Æ¤¤¤ë¡£");
1805 msg_print("You tunnel into the door.");
1812 /* Notice new floor grids */
1813 if (!cave_floor_bold(y, x))
1815 /* Update some things */
1816 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1825 * Tunnels through "walls" (including rubble and closed doors)
1827 * Note that you must tunnel in order to hit invisible monsters
1828 * in walls, though moving into walls still takes a turn anyway.
1830 * Digging is very difficult without a "digger" weapon, but can be
1831 * accomplished by strong players using heavy weapons.
1833 void do_cmd_tunnel(void)
1842 if (p_ptr->special_defense & KATA_MUSOU)
1844 set_action(ACTION_NONE);
1847 /* Allow repeated command */
1850 /* Set repeat count */
1851 command_rep = command_arg - 1;
1853 /* Redraw the state */
1854 p_ptr->redraw |= (PR_STATE);
1856 /* Cancel the arg */
1860 /* Get a direction to tunnel, or Abort */
1861 if (get_rep_dir(&dir,FALSE))
1868 c_ptr = &cave[y][x];
1870 /* No tunnelling through doors */
1871 if (((c_ptr->feat >= FEAT_DOOR_HEAD) && (c_ptr->feat <= FEAT_DOOR_TAIL)) ||
1872 ((c_ptr->feat >= FEAT_BLDG_HEAD) && (c_ptr->feat <= FEAT_BLDG_TAIL)) ||
1873 ((c_ptr->feat >= FEAT_SHOP_HEAD) && (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
1874 (c_ptr->feat == FEAT_MUSEUM))
1878 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1880 msg_print("You cannot tunnel through doors.");
1885 /* No tunnelling through air */
1886 else if (cave_floor_grid(c_ptr) || ((c_ptr->feat >= FEAT_MINOR_GLYPH) &&
1887 (c_ptr->feat <= FEAT_PATTERN_XTRA2)))
1891 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1893 msg_print("You cannot tunnel through air.");
1898 /* No tunnelling through mountains */
1899 else if (c_ptr->feat == FEAT_MOUNTAIN)
1902 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1904 msg_print("You can't tunnel through that!");
1909 /* A monster is in the way */
1910 else if (c_ptr->m_idx)
1917 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1919 msg_print("There is a monster in the way!");
1930 /* Tunnel through walls */
1931 more = do_cmd_tunnel_aux(y, x, dir);
1935 /* Cancel repetition unless we can continue */
1936 if (!more) disturb(0, 0);
1940 #ifdef ALLOW_EASY_OPEN /* TNB */
1945 * If there is a jammed/closed/locked door at the given location,
1946 * then attempt to unlock/open it. Return TRUE if an attempt was
1947 * made (successful or not), otherwise return FALSE.
1949 * The code here should be nearly identical to that in
1950 * do_cmd_open_test() and do_cmd_open_aux().
1952 bool easy_open_door(int y, int x)
1956 cave_type *c_ptr = &cave[y][x];
1958 /* Must be a closed door */
1959 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1960 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1967 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1971 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1973 msg_print("The door appears to be stuck.");
1979 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1982 i = p_ptr->skill_dis;
1984 /* Penalize some conditions */
1985 if (p_ptr->blind || no_lite()) i = i / 10;
1986 if (p_ptr->confused || p_ptr->image) i = i / 10;
1988 /* Extract the lock power */
1989 j = c_ptr->feat - FEAT_DOOR_HEAD;
1991 /* Extract the difficulty XXX XXX XXX */
1994 /* Always have a small chance of success */
1998 if (randint0(100) < j)
2002 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
2004 msg_print("You have picked the lock.");
2009 cave_set_feat(y, x, FEAT_OPEN);
2011 /* Update some things */
2012 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2015 sound(SOUND_OPENDOOR);
2025 if (flush_failure) flush();
2029 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2031 msg_print("You failed to pick the lock.");
2041 cave_set_feat(y, x, FEAT_OPEN);
2043 /* Update some things */
2044 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2047 sound(SOUND_OPENDOOR);
2054 #endif /* ALLOW_EASY_OPEN -- TNB */
2058 * Perform the basic "disarm" command
2060 * Assume destination is a visible trap
2062 * Assume there is no monster blocking the destination
2064 * Returns TRUE if repeated commands may continue
2066 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2072 object_type *o_ptr = &o_list[o_idx];
2078 /* Get the "disarm" factor */
2079 i = p_ptr->skill_dis;
2081 /* Penalize some conditions */
2082 if (p_ptr->blind || no_lite()) i = i / 10;
2083 if (p_ptr->confused || p_ptr->image) i = i / 10;
2085 /* Extract the difficulty */
2086 j = i - o_ptr->pval;
2088 /* Always have a small chance of success */
2091 /* Must find the trap first. */
2092 if (!object_known_p(o_ptr))
2095 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2097 msg_print("I don't see any traps.");
2102 /* Already disarmed/unlocked */
2103 else if (o_ptr->pval <= 0)
2106 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2108 msg_print("The chest is not trapped.");
2113 /* No traps to find. */
2114 else if (!chest_traps[o_ptr->pval])
2117 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2119 msg_print("The chest is not trapped.");
2124 /* Success (get a lot of experience) */
2125 else if (randint0(100) < j)
2128 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2130 msg_print("You have disarmed the chest.");
2133 gain_exp(o_ptr->pval);
2134 o_ptr->pval = (0 - o_ptr->pval);
2137 /* Failure -- Keep trying */
2138 else if ((i > 5) && (randint1(i) > 5))
2140 /* We may keep trying */
2142 if (flush_failure) flush();
2144 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2146 msg_print("You failed to disarm the chest.");
2151 /* Failure -- Set off the trap */
2155 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2157 msg_print("You set off a trap!");
2161 chest_trap(y, x, o_idx);
2170 * Perform the basic "disarm" command
2172 * Assume destination is a visible trap
2174 * Assume there is no monster blocking the destination
2176 * Returns TRUE if repeated commands may continue
2178 #ifdef ALLOW_EASY_DISARM /* TNB */
2180 bool do_cmd_disarm_aux(int y, int x, int dir)
2182 #else /* ALLOW_EASY_DISARM -- TNB */
2184 static bool do_cmd_disarm_aux(int y, int x, int dir)
2186 #endif /* ALLOW_EASY_DISARM -- TNB */
2200 /* Get grid and contents */
2201 c_ptr = &cave[y][x];
2203 /* Access trap name */
2204 name = (f_name + f_info[c_ptr->feat].name);
2206 /* Get the "disarm" factor */
2207 i = p_ptr->skill_dis;
2209 /* Penalize some conditions */
2210 if (p_ptr->blind || no_lite()) i = i / 10;
2211 if (p_ptr->confused || p_ptr->image) i = i / 10;
2213 /* XXX XXX XXX Variable power? */
2215 /* Extract trap "power" */
2218 /* Extract the difficulty */
2221 /* Always have a small chance of success */
2225 if (randint0(100) < j)
2229 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2231 msg_format("You have disarmed the %s.", name);
2238 /* Forget the trap */
2239 c_ptr->info &= ~(CAVE_MARK);
2241 /* Remove the trap */
2242 c_ptr->feat = floor_type[randint0(100)];
2243 c_ptr->info &= ~(CAVE_MASK);
2244 c_ptr->info |= CAVE_FLOOR;
2248 #ifdef ALLOW_EASY_DISARM /* TNB */
2250 /* Move the player onto the trap */
2251 move_player(dir, easy_disarm, FALSE);
2253 #else /* ALLOW_EASY_DISARM -- TNB */
2255 /* move the player onto the trap grid */
2256 move_player(dir, FALSE, FALSE);
2258 #endif /* ALLOW_EASY_DISARM -- TNB */
2261 /* Failure -- Keep trying */
2262 else if ((i > 5) && (randint1(i) > 5))
2265 if (flush_failure) flush();
2269 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2271 msg_format("You failed to disarm the %s.", name);
2275 /* We may keep trying */
2279 /* Failure -- Set off the trap */
2284 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2286 msg_format("You set off the %s!", name);
2290 #ifdef ALLOW_EASY_DISARM /* TNB */
2292 /* Move the player onto the trap */
2293 move_player(dir, easy_disarm, FALSE);
2295 #else /* ALLOW_EASY_DISARM -- TNB */
2297 /* Move the player onto the trap */
2298 move_player(dir, FALSE, FALSE);
2300 #endif /* ALLOW_EASY_DISARM -- TNB */
2309 * Disarms a trap, or chest
2311 void do_cmd_disarm(void)
2321 if (p_ptr->special_defense & KATA_MUSOU)
2323 set_action(ACTION_NONE);
2326 #ifdef ALLOW_EASY_DISARM /* TNB */
2328 /* Option: Pick a direction */
2331 int num_traps, num_chests;
2333 /* Count visible traps */
2334 num_traps = count_dt(&y, &x, is_trap, TRUE);
2336 /* Count chests (trapped) */
2337 num_chests = count_chests(&y, &x, TRUE);
2339 /* See if only one target */
2340 if (num_traps || num_chests)
2342 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2344 if (!too_many) command_dir = coords_to_dir(y, x);
2348 #endif /* ALLOW_EASY_DISARM -- TNB */
2350 /* Allow repeated command */
2353 /* Set repeat count */
2354 command_rep = command_arg - 1;
2356 /* Redraw the state */
2357 p_ptr->redraw |= (PR_STATE);
2359 /* Cancel the arg */
2363 /* Get a direction (or abort) */
2364 if (get_rep_dir(&dir,TRUE))
2370 /* Get grid and contents */
2371 c_ptr = &cave[y][x];
2373 /* Check for chests */
2374 o_idx = chest_check(y, x);
2377 if (!is_trap(c_ptr->feat) && !o_idx)
2381 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2383 msg_print("You see nothing there to disarm.");
2388 /* Monster in the way */
2389 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2393 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2395 msg_print("There is a monster in the way!");
2406 /* Disarm the chest */
2407 more = do_cmd_disarm_chest(y, x, o_idx);
2413 /* Disarm the trap */
2414 more = do_cmd_disarm_aux(y, x, dir);
2418 /* Cancel repeat unless told not to */
2419 if (!more) disturb(0, 0);
2424 * Perform the basic "bash" command
2426 * Assume destination is a closed/locked/jammed door
2428 * Assume there is no monster blocking the destination
2430 * Returns TRUE if repeated commands may continue
2432 static bool do_cmd_bash_aux(int y, int x, int dir)
2445 c_ptr = &cave[y][x];
2449 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2451 msg_print("You smash into the door!");
2455 /* Hack -- Bash power based on strength */
2456 /* (Ranges from 3 to 20 to 100 to 200) */
2457 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2459 /* Extract door power */
2460 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2462 /* Compare bash power to door power XXX XXX XXX */
2463 temp = (bash - (temp * 10));
2465 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2467 /* Hack -- always have a chance */
2468 if (temp < 1) temp = 1;
2470 /* Hack -- attempt to bash down the door */
2471 if (randint0(100) < temp)
2475 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2477 msg_print("The door crashes open!");
2481 /* Break down the door */
2482 if (randint0(100) < 50)
2484 cave_set_feat(y, x, FEAT_BROKEN);
2490 cave_set_feat(y, x, FEAT_OPEN);
2494 sound(SOUND_OPENDOOR);
2496 /* Hack -- Fall through the door */
2497 move_player(dir, FALSE, FALSE);
2499 /* Update some things */
2500 p_ptr->update |= (PU_VIEW | PU_LITE);
2501 p_ptr->update |= (PU_DISTANCE);
2504 /* Saving throw against stun */
2505 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2510 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2512 msg_print("The door holds firm.");
2516 /* Allow repeated bashing */
2520 /* High dexterity yields coolness */
2525 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2527 msg_print("You are off-balance.");
2531 /* Hack -- Lose balance ala paralysis */
2532 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2541 * Bash open a door, success based on character strength
2543 * For a closed door, pval is positive if locked; negative if stuck.
2545 * For an open door, pval is positive for a broken door.
2547 * A closed door can be opened - harder if locked. Any door might be
2548 * bashed open (and thereby broken). Bashing a door is (potentially)
2549 * faster! You move into the door way. To open a stuck door, it must
2550 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2552 * Creatures can also open or bash doors, see elsewhere.
2554 void do_cmd_bash(void)
2563 if (p_ptr->special_defense & KATA_MUSOU)
2565 set_action(ACTION_NONE);
2568 /* Allow repeated command */
2571 /* Set repeat count */
2572 command_rep = command_arg - 1;
2574 /* Redraw the state */
2575 p_ptr->redraw |= (PR_STATE);
2577 /* Cancel the arg */
2581 /* Get a "repeated" direction */
2582 if (get_rep_dir(&dir,FALSE))
2589 c_ptr = &cave[y][x];
2591 /* Nothing useful */
2592 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2593 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2597 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2599 msg_print("You see nothing there to bash.");
2604 /* Monster in the way */
2605 else if (c_ptr->m_idx)
2612 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2614 msg_print("There is a monster in the way!");
2622 /* Bash a closed door */
2626 more = do_cmd_bash_aux(y, x, dir);
2630 /* Unless valid action taken, cancel bash */
2631 if (!more) disturb(0, 0);
2636 * Manipulate an adjacent grid in some way
2638 * Attack monsters, tunnel through walls, disarm traps, open doors.
2640 * Consider confusion XXX XXX XXX
2642 * This command must always take a turn, to prevent free detection
2643 * of invisible monsters.
2645 void do_cmd_alter(void)
2654 if (p_ptr->special_defense & KATA_MUSOU)
2656 set_action(ACTION_NONE);
2659 /* Allow repeated command */
2662 /* Set repeat count */
2663 command_rep = command_arg - 1;
2665 /* Redraw the state */
2666 p_ptr->redraw |= (PR_STATE);
2668 /* Cancel the arg */
2672 /* Get a direction */
2673 if (get_rep_dir(&dir,TRUE))
2680 c_ptr = &cave[y][x];
2685 /* Attack monsters */
2692 /* Tunnel through walls */
2693 else if (((c_ptr->feat >= FEAT_SECRET) &&
2694 (c_ptr->feat < FEAT_MINOR_GLYPH)) ||
2695 ((c_ptr->feat == FEAT_TREES) ||
2696 (c_ptr->feat == FEAT_MOUNTAIN)))
2699 more = do_cmd_tunnel_aux(y, x, dir);
2702 /* Bash jammed doors */
2703 else if ((c_ptr->feat >= FEAT_DOOR_HEAD + 0x08) &&
2704 (c_ptr->feat < FEAT_MINOR_GLYPH))
2707 more = do_cmd_bash_aux(y, x, dir);
2710 /* Open closed doors */
2711 else if ((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2712 (c_ptr->feat < FEAT_MINOR_GLYPH))
2715 more = do_cmd_open_aux(y, x, dir);
2718 /* Close open doors */
2719 else if ((c_ptr->feat == FEAT_OPEN) ||
2720 (c_ptr->feat == FEAT_BROKEN))
2723 more = do_cmd_close_aux(y, x, dir);
2727 else if (is_trap(c_ptr->feat))
2730 more = do_cmd_disarm_aux(y, x, dir);
2738 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2740 msg_print("You attack the empty air.");
2746 /* Cancel repetition unless we can continue */
2747 if (!more) disturb(0, 0);
2752 * Find the index of some "spikes", if possible.
2754 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2756 static bool get_spike(int *ip)
2760 /* Check every item in the pack */
2761 for (i = 0; i < INVEN_PACK; i++)
2763 object_type *o_ptr = &inventory[i];
2765 /* Skip non-objects */
2766 if (!o_ptr->k_idx) continue;
2768 /* Check the "tval" code */
2769 if (o_ptr->tval == TV_SPIKE)
2771 /* Save the spike index */
2785 * Jam a closed door with a spike
2787 * This command may NOT be repeated
2789 void do_cmd_spike(void)
2791 int y, x, dir, item;
2796 if (p_ptr->special_defense & KATA_MUSOU)
2798 set_action(ACTION_NONE);
2801 /* Get a "repeated" direction */
2802 if (get_rep_dir(&dir,FALSE))
2808 /* Get grid and contents */
2809 c_ptr = &cave[y][x];
2811 /* Require closed door */
2812 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2813 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2817 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2819 msg_print("You see nothing there to spike.");
2825 else if (!get_spike(&item))
2829 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2831 msg_print("You have no spikes!");
2836 /* Is a monster in the way? */
2837 else if (c_ptr->m_idx)
2844 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2846 msg_print("There is a monster in the way!");
2860 /* Successful jamming */
2862 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2864 msg_print("You jam the door with a spike.");
2868 /* Convert "locked" to "stuck" XXX XXX XXX */
2869 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2871 /* Add one spike to the door */
2872 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2874 /* Use up, and describe, a single spike, from the bottom */
2875 inven_item_increase(item, -1);
2876 inven_item_describe(item);
2877 inven_item_optimize(item);
2885 * Support code for the "Walk" and "Jump" commands
2887 void do_cmd_walk(int pickup)
2894 /* Allow repeated command */
2897 /* Set repeat count */
2898 command_rep = command_arg - 1;
2900 /* Redraw the state */
2901 p_ptr->redraw |= (PR_STATE);
2903 /* Cancel the arg */
2907 /* Get a "repeated" direction */
2908 if (get_rep_dir(&dir,FALSE))
2913 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2915 set_action(ACTION_NONE);
2918 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2919 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2920 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2922 /* Actually move the character */
2923 move_player(dir, pickup, FALSE);
2925 /* Allow more walking */
2929 /* Hack again -- Is there a special encounter ??? */
2930 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2932 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2935 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2937 /* Inform the player of his horrible fate :=) */
2939 msg_print("½±·â¤À¡ª");
2941 msg_print("You are ambushed !");
2944 /* Go into large wilderness view */
2945 p_ptr->wilderness_x = px;
2946 p_ptr->wilderness_y = py;
2947 p_ptr->oldpy = randint1(MAX_HGT-2);
2948 p_ptr->oldpx = randint1(MAX_WID-2);
2952 /* HACk -- set the encouter flag for the wilderness generation */
2953 generate_encounter = TRUE;
2957 /* Cancel repeat unless we may continue */
2958 if (!more) disturb(0, 0);
2966 void do_cmd_run(void)
2970 /* Hack -- no running when confused */
2971 if (p_ptr->confused)
2974 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2976 msg_print("You are too confused!");
2982 if (p_ptr->special_defense & KATA_MUSOU)
2984 set_action(ACTION_NONE);
2987 /* Get a "repeated" direction */
2988 if (get_rep_dir(&dir,FALSE))
2990 /* Hack -- Set the run counter */
2991 running = (command_arg ? command_arg : 1000);
3001 * Stay still. Search. Enter stores.
3002 * Pick up treasure if "pickup" is true.
3004 void do_cmd_stay(int pickup)
3006 cave_type *c_ptr = &cave[py][px];
3009 /* Allow repeated command */
3012 /* Set repeat count */
3013 command_rep = command_arg - 1;
3015 /* Redraw the state */
3016 p_ptr->redraw |= (PR_STATE);
3018 /* Cancel the arg */
3027 /* Spontaneous Searching */
3028 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3033 /* Continuous Searching */
3034 if (p_ptr->action == ACTION_SEARCH)
3040 /* Handle "objects" */
3044 /* Hack -- enter a store if we are on one */
3045 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3046 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3047 (c_ptr->feat == FEAT_MUSEUM))
3053 /* Hack -- enter store */
3057 /* Hack -- enter a building if we are on one -KMW- */
3058 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3059 (c_ptr->feat <= FEAT_BLDG_TAIL))
3065 /* Hack -- enter building */
3069 /* Exit a quest if reach the quest exit */
3070 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3072 int q_index = p_ptr->inside_quest;
3074 /* Was quest completed? */
3075 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3077 quest[q_index].status = QUEST_STATUS_COMPLETED;
3078 quest[q_index].complev = (byte)p_ptr->lev;
3080 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3082 msg_print("You accomplished your quest!");
3088 leave_quest_check();
3090 p_ptr->inside_quest = cave[py][px].special;
3094 p_ptr->leaving = TRUE;
3101 * Resting allows a player to safely restore his hp -RAK-
3103 void do_cmd_rest(void)
3106 set_action(ACTION_NONE);
3108 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3113 /* Prompt for time if needed */
3114 if (command_arg <= 0)
3117 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3119 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3126 strcpy(out_val, "&");
3128 /* Ask for duration */
3129 if (!get_string(p, out_val, 4)) return;
3131 /* Rest until done */
3132 if (out_val[0] == '&')
3138 else if (out_val[0] == '*')
3146 command_arg = atoi(out_val);
3147 if (command_arg <= 0) return;
3153 if (command_arg > 9999) command_arg = 9999;
3155 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3157 /* Take a turn XXX XXX XXX (?) */
3160 /* The sin of sloth */
3161 if (command_arg > 100)
3162 chg_virtue(V_DILIGENCE, -1);
3164 /* Why are you sleeping when there's no need? WAKE UP!*/
3165 if ((p_ptr->chp == p_ptr->mhp) &&
3166 (p_ptr->csp == p_ptr->msp) &&
3167 !p_ptr->blind && !p_ptr->confused &&
3168 !p_ptr->poisoned && !p_ptr->afraid &&
3169 !p_ptr->stun && !p_ptr->cut &&
3170 !p_ptr->slow && !p_ptr->paralyzed &&
3171 !p_ptr->image && !p_ptr->word_recall)
3172 chg_virtue(V_DILIGENCE, -1);
3174 /* Save the rest code */
3175 resting = command_arg;
3176 p_ptr->action = ACTION_REST;
3178 /* Recalculate bonuses */
3179 p_ptr->update |= (PU_BONUS);
3181 /* Redraw the state */
3182 p_ptr->redraw |= (PR_STATE);
3193 * Determines the odds of an object breaking when thrown at a monster
3195 * Note that artifacts never break, see the "drop_near()" function.
3197 static int breakage_chance(object_type *o_ptr)
3199 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3201 /* Examine the item type */
3202 switch (o_ptr->tval)
3218 /* Sometimes break */
3223 return (20 - archer_bonus * 2);
3228 return (10 - archer_bonus);
3235 s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3239 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3243 /* Extract the flags */
3244 object_flags(o_ptr, &f1, &f2, &f3);
3246 /* Some "weapons" and "ammo" do extra damage */
3247 switch (o_ptr->tval)
3254 if ((f1 & TR1_SLAY_ANIMAL) &&
3255 (r_ptr->flags3 & RF3_ANIMAL))
3259 r_ptr->r_flags3 |= RF3_ANIMAL;
3262 if (mult < 17) mult = 17;
3266 if ((f1 & TR1_SLAY_EVIL) &&
3267 (r_ptr->flags3 & RF3_EVIL))
3271 r_ptr->r_flags3 |= RF3_EVIL;
3274 if (mult < 15) mult = 15;
3278 if ((f1 & TR1_SLAY_UNDEAD) &&
3279 (r_ptr->flags3 & RF3_UNDEAD))
3283 r_ptr->r_flags3 |= RF3_UNDEAD;
3286 if (mult < 20) mult = 20;
3290 if ((f1 & TR1_SLAY_DEMON) &&
3291 (r_ptr->flags3 & RF3_DEMON))
3295 r_ptr->r_flags3 |= RF3_DEMON;
3298 if (mult < 20) mult = 20;
3302 if ((f1 & TR1_SLAY_ORC) &&
3303 (r_ptr->flags3 & RF3_ORC))
3307 r_ptr->r_flags3 |= RF3_ORC;
3310 if (mult < 20) mult = 20;
3314 if ((f1 & TR1_SLAY_TROLL) &&
3315 (r_ptr->flags3 & RF3_TROLL))
3319 r_ptr->r_flags3 |= RF3_TROLL;
3322 if (mult < 20) mult = 20;
3326 if ((f1 & TR1_SLAY_GIANT) &&
3327 (r_ptr->flags3 & RF3_GIANT))
3331 r_ptr->r_flags3 |= RF3_GIANT;
3334 if (mult < 20) mult = 20;
3338 if ((f1 & TR1_SLAY_DRAGON) &&
3339 (r_ptr->flags3 & RF3_DRAGON))
3343 r_ptr->r_flags3 |= RF3_DRAGON;
3346 if (mult < 20) mult = 20;
3349 /* Execute Dragon */
3350 if ((f1 & TR1_KILL_DRAGON) &&
3351 (r_ptr->flags3 & RF3_DRAGON))
3355 r_ptr->r_flags3 |= RF3_DRAGON;
3358 if (mult < 30) mult = 30;
3360 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3361 (m_ptr->r_idx == MON_SMAUG) &&
3362 (inventory[INVEN_BOW].name1 == ART_BARD))
3367 if ((f1 & TR1_BRAND_ACID) || (p_ptr->special_attack & (ATTACK_ACID)))
3369 /* Notice immunity */
3370 if (r_ptr->flags3 & RF3_IM_ACID)
3374 r_ptr->r_flags3 |= RF3_IM_ACID;
3378 /* Otherwise, take the damage */
3381 if (mult < 17) mult = 17;
3386 if ((f1 & TR1_BRAND_ELEC) || (p_ptr->special_attack & (ATTACK_ELEC)))
3388 /* Notice immunity */
3389 if (r_ptr->flags3 & RF3_IM_ELEC)
3393 r_ptr->r_flags3 |= RF3_IM_ELEC;
3397 /* Otherwise, take the damage */
3400 if (mult < 17) mult = 17;
3405 if ((f1 & TR1_BRAND_FIRE) || (p_ptr->special_attack & (ATTACK_FIRE)))
3407 /* Notice immunity */
3408 if (r_ptr->flags3 & RF3_IM_FIRE)
3412 r_ptr->r_flags3 |= RF3_IM_FIRE;
3416 /* Otherwise, take the damage */
3419 if (mult < 17) mult = 17;
3424 if ((f1 & TR1_BRAND_COLD) || (p_ptr->special_attack & (ATTACK_COLD)))
3426 /* Notice immunity */
3427 if (r_ptr->flags3 & RF3_IM_COLD)
3431 r_ptr->r_flags3 |= RF3_IM_COLD;
3434 /* Otherwise, take the damage */
3437 if (mult < 17) mult = 17;
3441 /* Brand (Poison) */
3442 if ((f1 & TR1_BRAND_POIS) || (p_ptr->special_attack & (ATTACK_POIS)))
3444 /* Notice immunity */
3445 if (r_ptr->flags3 & RF3_IM_POIS)
3449 r_ptr->r_flags3 |= RF3_IM_POIS;
3453 /* Otherwise, take the damage */
3456 if (mult < 17) mult = 17;
3460 if ((f1 & TR1_FORCE_WEAPON) && (p_ptr->csp > (p_ptr->msp / 30)))
3462 p_ptr->csp -= (1+(p_ptr->msp / 30));
3463 p_ptr->redraw |= (PR_MANA);
3464 mult = mult * 5 / 2;
3470 /* Return the total damage */
3471 return (tdam * mult / 10);
3476 * Fire an object from the pack or floor.
3478 * You may only fire items that "match" your missile launcher.
3480 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3482 * See "calc_bonuses()" for more calculations and such.
3484 * Note that "firing" a missile is MUCH better than "throwing" it.
3486 * Note: "unseen" monsters are very hard to hit.
3488 * Objects are more likely to break if they "attempt" to hit a monster.
3490 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3492 * The "extra shot" code works by decreasing the amount of energy
3493 * required to make each shot, spreading the shots out over time.
3495 * Note that when firing missiles, the launcher multiplier is applied
3496 * after all the bonuses are added in, making multipliers very useful.
3498 * Note that Bows of "Extra Might" get extra range and an extra bonus
3499 * for the damage multiplier.
3501 * Note that Bows of "Extra Shots" give an extra shot.
3503 void do_cmd_fire_aux(int item, object_type *j_ptr)
3506 int j, y, x, ny, nx, ty, tx;
3507 int tdam, tdis, thits, tmul;
3509 int cur_dis, visible;
3516 bool hit_body = FALSE;
3518 char o_name[MAX_NLEN];
3520 int msec = delay_factor * delay_factor * delay_factor;
3523 bool stick_to = FALSE;
3525 /* Access the item (if in the pack) */
3528 o_ptr = &inventory[item];
3532 o_ptr = &o_list[0 - item];
3535 /* Describe the object */
3536 object_desc(o_name, o_ptr, FALSE, 3);
3539 /* Use the proper number of shots */
3540 thits = p_ptr->num_fire;
3542 /* Use a base distance */
3545 /* Base damage from thrown object plus launcher bonus */
3546 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3548 /* Actually "fire" the object */
3549 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3550 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3551 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval])/400 + bonus) * BTH_PLUS_ADJ);
3553 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3555 energy_use = bow_energy(j_ptr->sval);
3556 tmul = bow_tmul(j_ptr->sval);
3558 /* Get extra "power" from "extra might" */
3559 if (p_ptr->xtra_might) tmul++;
3561 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3563 /* Boost the damage */
3568 tdis = 10 + tmul/40;
3569 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3572 project_length = tdis + 1;
3574 /* Get a direction (or cancel) */
3575 if (!get_aim_dir(&dir))
3579 /* need not to reset project_length (already did)*/
3583 project_length = 0; /* reset to default */
3585 /* Get local object */
3588 /* Obtain a local object */
3589 object_copy(q_ptr, o_ptr);
3594 /* Reduce and describe inventory */
3597 inven_item_increase(item, -1);
3598 inven_item_describe(item);
3599 inven_item_optimize(item);
3602 /* Reduce and describe floor item */
3605 floor_item_increase(0 - item, -1);
3606 floor_item_optimize(0 - item);
3614 /* Take a (partial) turn */
3615 energy_use = (energy_use / thits);
3618 /* Start at the player */
3622 /* Predict the "target" location */
3623 tx = px + 99 * ddx[dir];
3624 ty = py + 99 * ddy[dir];
3626 /* Check for "target request" */
3627 if ((dir == 5) && target_okay())
3634 /* Hack -- Handle stuff */
3638 /* Travel until stopped */
3639 for (cur_dis = 0; cur_dis <= tdis; )
3641 /* Hack -- Stop at the target */
3642 if ((y == ty) && (x == tx)) break;
3644 /* Calculate the new location (see "project()") */
3647 mmove2(&ny, &nx, py, px, ty, tx);
3649 /* Stopped by walls/doors */
3650 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3652 /* Advance the distance */
3656 /* The player can see the (on screen) missile */
3657 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3659 char c = object_char(q_ptr);
3660 byte a = object_attr(q_ptr);
3662 /* Draw, Hilite, Fresh, Pause, Erase */
3663 print_rel(c, a, ny, nx);
3664 move_cursor_relative(ny, nx);
3666 Term_xtra(TERM_XTRA_DELAY, msec);
3671 /* The player cannot see the missile */
3674 /* Pause anyway, for consistancy */
3675 Term_xtra(TERM_XTRA_DELAY, msec);
3678 /* Save the new location */
3683 /* Monster here, Try to hit it */
3684 if (cave[y][x].m_idx)
3686 cave_type *c_ptr = &cave[y][x];
3688 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3689 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3691 /* Check the visibility */
3692 visible = m_ptr->ml;
3694 /* Note the collision */
3699 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3700 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3703 if ((r_ptr->level + 10) > p_ptr->lev)
3705 int now_exp = weapon_exp[0][j_ptr->sval];
3706 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3709 if (now_exp < 4000) amount = 80;
3710 else if (now_exp < 6000) amount = 25;
3711 else if ((now_exp < 7000) && (p_ptr->lev > 19)) amount = 10;
3712 else if (p_ptr->lev > 34) amount = 2;
3713 weapon_exp[0][j_ptr->sval] += amount;
3714 p_ptr->update |= (PU_BONUS);
3720 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))
3722 skill_exp[GINOU_RIDING]+=1;
3723 p_ptr->update |= (PU_BONUS);
3727 /* Did we hit it (penalize range) */
3728 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3732 /* Assume a default death */
3734 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3736 cptr note_dies = " dies.";
3739 /* Some monsters get "destroyed" */
3740 if (!monster_living(r_ptr))
3743 bool explode = FALSE;
3745 for (i = 0; i < 4; i++)
3747 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3750 /* Special note at death */
3753 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3755 note_dies = " explodes into tiny shreds.";
3759 note_dies = "¤òÅݤ·¤¿¡£";
3761 note_dies = " is destroyed.";
3766 /* Handle unseen monster */
3769 /* Invisible monster */
3771 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3773 msg_format("The %s finds a mark.", o_name);
3778 /* Handle visible monster */
3783 /* Get "the monster" or "it" */
3784 monster_desc(m_name, m_ptr, 0);
3788 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3790 msg_format("The %s hits %s.", o_name, m_name);
3794 /* Hack -- Track this monster race */
3795 if (m_ptr->ml) monster_race_track((bool)(m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
3797 /* Hack -- Track this monster */
3798 if (m_ptr->ml) health_track(c_ptr->m_idx);
3801 /* Apply special damage XXX XXX XXX */
3802 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3803 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3805 /* No negative damage */
3806 if (tdam < 0) tdam = 0;
3808 /* Modify the damage */
3809 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3811 /* Complex message */
3812 if (wizard || cheat_xtra)
3815 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3818 msg_format("You do %d (out of %d) damage.",
3824 /* Hit the monster, check for death */
3825 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3838 monster_desc(m_name, m_ptr, 0);
3842 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3844 msg_format("%^s have stuck into %s!",o_name, m_name);
3849 message_pain(c_ptr->m_idx, tdam);
3851 /* Anger the monster */
3852 if (tdam > 0) anger_monster(m_ptr);
3855 if (fear && m_ptr->ml)
3862 /* Get the monster name (or "it") */
3863 monster_desc(m_name, m_ptr, 0);
3867 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3869 msg_format("%^s flees in terror!", m_name);
3873 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3875 set_target(m_ptr, py, px);
3885 /* Chance of breakage (during attacks) */
3886 j = (hit_body ? breakage_chance(q_ptr) : 0);
3890 int m_idx = cave[y][x].m_idx;
3891 monster_type *m_ptr = &m_list[m_idx];
3892 int o_idx = o_pop();
3897 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3899 msg_format("The %s have gone to somewhere.", o_name);
3903 a_info[j_ptr->name1].cur_num = 0;
3908 o_ptr = &o_list[ o_idx ];
3909 object_copy(o_ptr, q_ptr);
3912 o_ptr->marked = FALSE;
3914 /* Forget location */
3915 o_ptr->iy = o_ptr->ix = 0;
3917 /* Memorize monster */
3918 o_ptr->held_m_idx = m_idx;
3921 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3924 m_ptr->hold_o_idx = o_idx;
3928 /* Drop (or break) near that location */
3929 (void)drop_near(q_ptr, j, y, x);
3933 void do_cmd_fire(void)
3939 /* Get the "bow" (if any) */
3940 j_ptr = &inventory[INVEN_BOW];
3942 /* Require a launcher */
3946 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
3948 msg_print("You have nothing to fire with.");
3954 if (j_ptr->sval == SV_CRIMSON)
3957 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
3959 msg_print("Do activate.");
3966 if (p_ptr->special_defense & KATA_MUSOU)
3968 set_action(ACTION_NONE);
3971 /* Require proper missile */
3972 item_tester_tval = p_ptr->tval_ammo;
3976 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
3977 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3979 q = "Fire which item? ";
3980 s = "You have nothing to fire.";
3983 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3990 do_cmd_fire_aux(item, j_ptr);
3994 static bool item_tester_hook_boomerang(object_type *o_ptr)
3996 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4004 * Throw an object from the pack or floor.
4006 * Note: "unseen" monsters are very hard to hit.
4008 * Should throwing a weapon do full damage? Should it allow the magic
4009 * to hit bonus of the weapon to have an effect? Should it ever cause
4010 * the item to be destroyed? Should it do any damage at all?
4012 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4015 int i, j, y, x, ty, tx;
4017 int chance, tdam, tdis;
4019 int cur_dis, visible;
4026 bool hit_body = FALSE;
4027 bool hit_wall = FALSE;
4028 bool equiped_item = FALSE;
4029 bool return_when_thrown = FALSE;
4031 char o_name[MAX_NLEN];
4033 int msec = delay_factor * delay_factor * delay_factor;
4037 bool come_back = FALSE;
4038 bool do_drop = TRUE;
4041 if (p_ptr->special_defense & KATA_MUSOU)
4043 set_action(ACTION_NONE);
4052 if (buki_motteruka(INVEN_LARM))
4054 item_tester_hook = item_tester_hook_boomerang;
4056 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4057 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4059 q = "Throw which item? ";
4060 s = "You have nothing to throw.";
4063 if (!get_item(&item, q, s, (USE_EQUIP)))
4078 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4079 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4081 q = "Throw which item? ";
4082 s = "You have nothing to throw.";
4085 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4092 /* Access the item (if in the pack) */
4095 o_ptr = &inventory[item];
4099 o_ptr = &o_list[0 - item];
4103 /* Item is cursed */
4104 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4108 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4110 msg_print("Hmmm, it seems to be cursed.");
4119 /* Get local object */
4122 /* Obtain a local object */
4123 object_copy(q_ptr, o_ptr);
4125 /* Extract the thrown object's flags. */
4126 object_flags(q_ptr, &f1, &f2, &f3);
4128 /* Distribute the charges of rods/wands between the stacks */
4129 distribute_charges(o_ptr, q_ptr, 1);
4135 object_desc(o_name, q_ptr, FALSE, 3);
4137 if (p_ptr->mighty_throw) mult += 3;
4139 /* Extract a "distance multiplier" */
4140 /* Changed for 'launcher' mutation */
4141 mul = 10 + 2 * (mult - 1);
4143 /* Enforce a minimum "weight" of one pound */
4144 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4145 if ((f2 & (TR2_THROW)) || boomerang) div /= 2;
4147 /* Hack -- Distance -- Reward strength, penalize weight */
4148 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4150 /* Max distance of 10-18 */
4151 if (tdis > mul) tdis = mul;
4155 ty = randint0(101)-50+py;
4156 tx = randint0(101)-50+px;
4160 project_length = tdis + 1;
4162 /* Get a direction (or cancel) */
4163 if (!get_aim_dir(&dir)) return FALSE;
4165 project_length = 0; /* reset to default */
4167 /* Predict the "target" location */
4168 tx = px + 99 * ddx[dir];
4169 ty = py + 99 * ddy[dir];
4171 /* Check for "target request" */
4172 if ((dir == 5) && target_okay())
4179 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4180 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4181 return_when_thrown = TRUE;
4183 /* Reduce and describe inventory */
4186 inven_item_increase(item, -1);
4187 if (!return_when_thrown)
4188 inven_item_describe(item);
4189 inven_item_optimize(item);
4192 /* Reduce and describe floor item */
4195 floor_item_increase(0 - item, -1);
4196 floor_item_optimize(0 - item);
4198 if (item >= INVEN_RARM)
4200 equiped_item = TRUE;
4201 p_ptr->redraw |= (PR_EQUIPPY);
4207 /* Rogue and Ninja gets bonus */
4208 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4209 energy_use -= p_ptr->lev;
4211 /* Start at the player */
4216 /* Hack -- Handle stuff */
4219 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((f2 & TR2_THROW) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4220 else shuriken = FALSE;
4222 /* Chance of hitting */
4223 if (f2 & (TR2_THROW)) chance = ((p_ptr->skill_tht) +
4224 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4225 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4227 if (shuriken) chance *= 2;
4229 /* Travel until stopped */
4230 for (cur_dis = 0; cur_dis <= tdis; )
4232 /* Hack -- Stop at the target */
4233 if ((y == ty) && (x == tx)) break;
4235 /* Calculate the new location (see "project()") */
4238 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4240 /* Stopped by walls/doors */
4241 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4247 /* Advance the distance */
4250 /* The player can see the (on screen) missile */
4251 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4253 char c = object_char(q_ptr);
4254 byte a = object_attr(q_ptr);
4256 /* Draw, Hilite, Fresh, Pause, Erase */
4257 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4258 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4260 Term_xtra(TERM_XTRA_DELAY, msec);
4261 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4265 /* The player cannot see the missile */
4268 /* Pause anyway, for consistancy */
4269 Term_xtra(TERM_XTRA_DELAY, msec);
4272 /* Save the new location */
4277 /* Monster here, Try to hit it */
4278 if (cave[y][x].m_idx)
4280 cave_type *c_ptr = &cave[y][x];
4282 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4283 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4285 /* Check the visibility */
4286 visible = m_ptr->ml;
4288 /* Note the collision */
4291 /* Did we hit it (penalize range) */
4292 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4296 /* Assume a default death */
4298 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4300 cptr note_dies = " dies.";
4304 /* Some monsters get "destroyed" */
4305 if (!monster_living(r_ptr))
4308 bool explode = FALSE;
4310 for (i = 0; i < 4; i++)
4312 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4315 /* Special note at death */
4318 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4320 note_dies = " explodes into tiny shreds.";
4324 note_dies = "¤òÅݤ·¤¿¡£";
4326 note_dies = " is destroyed.";
4332 /* Handle unseen monster */
4335 /* Invisible monster */
4337 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4339 msg_format("The %s finds a mark.", o_name);
4344 /* Handle visible monster */
4349 /* Get "the monster" or "it" */
4350 monster_desc(m_name, m_ptr, 0);
4354 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4356 msg_format("The %s hits %s.", o_name, m_name);
4360 /* Hack -- Track this monster race */
4361 if (m_ptr->ml) monster_race_track((bool)(m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
4363 /* Hack -- Track this monster */
4364 if (m_ptr->ml) health_track(c_ptr->m_idx);
4367 /* Hack -- Base damage from thrown object */
4368 tdam = damroll(q_ptr->dd, q_ptr->ds);
4369 /* Apply special damage XXX XXX XXX */
4370 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4371 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4372 if (q_ptr->to_d > 0)
4373 tdam += q_ptr->to_d;
4375 tdam += -q_ptr->to_d;
4379 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4380 tdam += p_ptr->to_d_m;
4382 else if (f2 & (TR2_THROW))
4385 tdam += p_ptr->to_d_m;
4393 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4396 /* No negative damage */
4397 if (tdam < 0) tdam = 0;
4399 /* Modify the damage */
4400 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4402 /* Complex message */
4406 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4409 msg_format("You do %d (out of %d) damage.",
4415 /* Hit the monster, check for death */
4416 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4425 message_pain(c_ptr->m_idx, tdam);
4427 /* Anger the monster */
4428 if ((tdam > 0) && !object_is_potion(q_ptr))
4429 anger_monster(m_ptr);
4432 if (fear && m_ptr->ml)
4439 /* Get the monster name (or "it") */
4440 monster_desc(m_name, m_ptr, 0);
4444 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4446 msg_format("%^s flees in terror!", m_name);
4458 /* Chance of breakage (during attacks) */
4459 j = (hit_body ? breakage_chance(q_ptr) : 0);
4461 /* Figurines transform */
4462 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4466 if (!(summon_named_creature(y, x, q_ptr->pval, FALSE, FALSE, FALSE,
4467 (bool)!(q_ptr->ident & IDENT_CURSED))))
4469 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4471 msg_print("The Figurine writhes and then shatters.");
4474 else if (q_ptr->ident & IDENT_CURSED)
4476 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4478 msg_print("You have a bad feeling about this.");
4484 /* Potions smash open */
4485 if (object_is_potion(q_ptr))
4487 if (hit_body || hit_wall || (randint1(100) < j))
4491 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4493 msg_format("The %s shatters!", o_name);
4497 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4499 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4501 /* ToDo (Robert): fix the invulnerability */
4502 if (cave[y][x].m_idx &&
4503 is_friendly(&m_list[cave[y][x].m_idx]) &&
4507 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4509 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4511 msg_format("%^s gets angry!", m_name);
4514 set_hostile(&m_list[cave[y][x].m_idx]);
4525 if (return_when_thrown)
4527 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4528 char o2_name[MAX_NLEN];
4529 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4532 if (boomerang) back_chance += 4+randint1(5);
4533 if (super_boomerang) back_chance += 100;
4534 object_desc(o2_name, q_ptr, FALSE, 0);
4536 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4538 for (i = cur_dis-1;i>0;i--)
4540 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4542 char c = object_char(q_ptr);
4543 byte a = object_attr(q_ptr);
4545 /* Draw, Hilite, Fresh, Pause, Erase */
4546 print_rel(c, a, ny[i], nx[i]);
4547 move_cursor_relative(ny[i], nx[i]);
4549 Term_xtra(TERM_XTRA_DELAY, msec);
4550 lite_spot(ny[i], nx[i]);
4555 /* Pause anyway, for consistancy */
4556 Term_xtra(TERM_XTRA_DELAY, msec);
4559 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4562 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4564 msg_format("%s comes back to you.", o2_name);
4573 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4575 msg_format("%s backs, but you can't catch!", o2_name);
4581 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4583 msg_format("%s comes back.", o2_name);
4593 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4595 msg_format("%s doesn't back!", o2_name);
4602 if (item == INVEN_RARM || item == INVEN_LARM)
4604 /* Access the wield slot */
4605 o_ptr = &inventory[item];
4607 /* Wear the new stuff */
4608 object_copy(o_ptr, q_ptr);
4610 /* Increase the weight */
4611 p_ptr->total_weight += q_ptr->weight;
4613 /* Increment the equip counter by hand */
4616 /* Recalculate bonuses */
4617 p_ptr->update |= (PU_BONUS);
4619 /* Recalculate torch */
4620 p_ptr->update |= (PU_TORCH);
4622 /* Recalculate mana XXX */
4623 p_ptr->update |= (PU_MANA);
4626 p_ptr->window |= (PW_EQUIP);
4634 else if (equiped_item)
4640 /* Drop (or break) near that location */
4641 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4648 * Throw an object from the pack or floor.
4650 void do_cmd_throw(void)
4652 do_cmd_throw_aux(1, FALSE, 0);