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);
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);
1505 c_ptr->info &= ~(CAVE_MASK);
1506 c_ptr->info |= (CAVE_FLOOR);
1508 /* Remove the feature */
1509 cave_set_feat(y, x, feat);
1511 /* Update some things */
1512 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1521 * Perform the basic "tunnel" command
1523 * Assumes that the destination is a wall, a vein, a secret
1526 * Assumes that no monster is blocking the destination
1528 * Returns TRUE if repeated commands may continue
1530 static bool do_cmd_tunnel_aux(int y, int x, int dir)
1536 /* Verify legality */
1537 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1543 c_ptr = &cave[y][x];
1549 if ((c_ptr->feat >= FEAT_PERM_EXTRA) &&
1550 (c_ptr->feat <= FEAT_PERM_SOLID))
1553 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1555 msg_print("This seems to be permanent rock.");
1560 /* No tunnelling through mountains */
1561 else if (c_ptr->feat == FEAT_MOUNTAIN)
1564 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1566 msg_print("You can't tunnel through that!");
1571 else if (c_ptr->feat == FEAT_TREES) /* -KMW- */
1574 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1577 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1579 msg_print("You have cleared away the trees.");
1581 chg_virtue(V_DILIGENCE, 1);
1582 chg_virtue(V_NATURE, -1);
1588 /* We may continue chopping */
1590 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1592 msg_print("You chop away at the tree.");
1597 /* Occasional Search XXX XXX */
1598 if (randint0(100) < 25) search();
1604 else if ((c_ptr->feat >= FEAT_WALL_EXTRA) &&
1605 (c_ptr->feat <= FEAT_WALL_SOLID))
1608 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1611 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1613 msg_print("You have finished the tunnel.");
1615 chg_virtue(V_DILIGENCE, 1);
1616 chg_virtue(V_NATURE, -1);
1622 /* We may continue tunelling */
1624 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1626 msg_print("You tunnel into the granite wall.");
1634 /* Quartz / Magma */
1635 else if ((c_ptr->feat >= FEAT_MAGMA) &&
1636 (c_ptr->feat <= FEAT_QUARTZ_K))
1643 if (c_ptr->feat >= FEAT_MAGMA_H) gold = TRUE;
1645 /* Extract "quartz" flag XXX XXX XXX */
1646 if ((c_ptr->feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1651 okay = (p_ptr->skill_dig > 20 + randint0(800));
1657 okay = (p_ptr->skill_dig > 10 + randint0(400));
1661 if (okay && twall(y, x, floor_type[randint0(100)]))
1663 /* Found treasure */
1666 /* Place some gold */
1671 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1673 msg_print("You have found something!");
1683 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1685 msg_print("You have finished the tunnel.");
1687 chg_virtue(V_DILIGENCE, 1);
1688 chg_virtue(V_NATURE, -1);
1692 /* Failure (quartz) */
1695 /* Message, continue digging */
1697 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1699 msg_print("You tunnel into the quartz vein.");
1705 /* Failure (magma) */
1708 /* Message, continue digging */
1710 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1712 msg_print("You tunnel into the magma vein.");
1720 else if (c_ptr->feat == FEAT_RUBBLE)
1722 /* Remove the rubble */
1723 if ((p_ptr->skill_dig > randint0(200)) && twall(y, x, floor_type[randint0(100)]))
1727 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1729 msg_print("You have removed the rubble.");
1732 /* Hack -- place an object */
1733 if (randint0(100) < (15 - dun_level/2))
1735 /* Create a simple object */
1736 place_object(y, x, FALSE, FALSE);
1738 /* Observe new object */
1739 if (player_can_see_bold(y, x))
1742 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1744 msg_print("You have found something!");
1753 /* Message, keep digging */
1755 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1757 msg_print("You dig in the rubble.");
1765 else if (c_ptr->feat >= FEAT_SECRET)
1768 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint0(100)]))
1771 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1773 msg_print("You have finished the tunnel.");
1781 /* We may continue tunelling */
1783 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1785 msg_print("You tunnel into the granite wall.");
1790 /* Occasional Search XXX XXX */
1791 if (randint0(100) < 25) search();
1799 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint1(100)]))
1802 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1804 msg_print("You have finished the tunnel.");
1812 /* We may continue tunelling */
1814 msg_print("¥É¥¢¤Ë·ê¤ò³«¤±¤Æ¤¤¤ë¡£");
1816 msg_print("You tunnel into the door.");
1823 /* Notice new floor grids */
1824 if (!cave_floor_bold(y, x))
1826 /* Update some things */
1827 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1836 * Tunnels through "walls" (including rubble and closed doors)
1838 * Note that you must tunnel in order to hit invisible monsters
1839 * in walls, though moving into walls still takes a turn anyway.
1841 * Digging is very difficult without a "digger" weapon, but can be
1842 * accomplished by strong players using heavy weapons.
1844 void do_cmd_tunnel(void)
1853 if (p_ptr->special_defense & KATA_MUSOU)
1855 set_action(ACTION_NONE);
1858 /* Allow repeated command */
1861 /* Set repeat count */
1862 command_rep = command_arg - 1;
1864 /* Redraw the state */
1865 p_ptr->redraw |= (PR_STATE);
1867 /* Cancel the arg */
1871 /* Get a direction to tunnel, or Abort */
1872 if (get_rep_dir(&dir,FALSE))
1879 c_ptr = &cave[y][x];
1881 /* No tunnelling through doors */
1882 if (((c_ptr->feat >= FEAT_DOOR_HEAD) && (c_ptr->feat <= FEAT_DOOR_TAIL)) ||
1883 ((c_ptr->feat >= FEAT_BLDG_HEAD) && (c_ptr->feat <= FEAT_BLDG_TAIL)) ||
1884 ((c_ptr->feat >= FEAT_SHOP_HEAD) && (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
1885 (c_ptr->feat == FEAT_MUSEUM))
1889 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1891 msg_print("You cannot tunnel through doors.");
1896 /* No tunnelling through air */
1897 else if (cave_floor_grid(c_ptr) || ((c_ptr->feat >= FEAT_MINOR_GLYPH) &&
1898 (c_ptr->feat <= FEAT_PATTERN_XTRA2)))
1902 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1904 msg_print("You cannot tunnel through air.");
1909 /* No tunnelling through mountains */
1910 else if (c_ptr->feat == FEAT_MOUNTAIN)
1913 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1915 msg_print("You can't tunnel through that!");
1920 /* A monster is in the way */
1921 else if (c_ptr->m_idx)
1928 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1930 msg_print("There is a monster in the way!");
1941 /* Tunnel through walls */
1942 more = do_cmd_tunnel_aux(y, x, dir);
1946 /* Cancel repetition unless we can continue */
1947 if (!more) disturb(0, 0);
1951 #ifdef ALLOW_EASY_OPEN /* TNB */
1956 * If there is a jammed/closed/locked door at the given location,
1957 * then attempt to unlock/open it. Return TRUE if an attempt was
1958 * made (successful or not), otherwise return FALSE.
1960 * The code here should be nearly identical to that in
1961 * do_cmd_open_test() and do_cmd_open_aux().
1963 bool easy_open_door(int y, int x)
1967 cave_type *c_ptr = &cave[y][x];
1969 /* Must be a closed door */
1970 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1971 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1978 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1982 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1984 msg_print("The door appears to be stuck.");
1990 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1993 i = p_ptr->skill_dis;
1995 /* Penalize some conditions */
1996 if (p_ptr->blind || no_lite()) i = i / 10;
1997 if (p_ptr->confused || p_ptr->image) i = i / 10;
1999 /* Extract the lock power */
2000 j = c_ptr->feat - FEAT_DOOR_HEAD;
2002 /* Extract the difficulty XXX XXX XXX */
2005 /* Always have a small chance of success */
2009 if (randint0(100) < j)
2013 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
2015 msg_print("You have picked the lock.");
2020 cave_set_feat(y, x, FEAT_OPEN);
2022 /* Update some things */
2023 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2026 sound(SOUND_OPENDOOR);
2036 if (flush_failure) flush();
2040 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2042 msg_print("You failed to pick the lock.");
2052 cave_set_feat(y, x, FEAT_OPEN);
2054 /* Update some things */
2055 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2058 sound(SOUND_OPENDOOR);
2065 #endif /* ALLOW_EASY_OPEN -- TNB */
2069 * Perform the basic "disarm" command
2071 * Assume destination is a visible trap
2073 * Assume there is no monster blocking the destination
2075 * Returns TRUE if repeated commands may continue
2077 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2083 object_type *o_ptr = &o_list[o_idx];
2089 /* Get the "disarm" factor */
2090 i = p_ptr->skill_dis;
2092 /* Penalize some conditions */
2093 if (p_ptr->blind || no_lite()) i = i / 10;
2094 if (p_ptr->confused || p_ptr->image) i = i / 10;
2096 /* Extract the difficulty */
2097 j = i - o_ptr->pval;
2099 /* Always have a small chance of success */
2102 /* Must find the trap first. */
2103 if (!object_known_p(o_ptr))
2106 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2108 msg_print("I don't see any traps.");
2113 /* Already disarmed/unlocked */
2114 else if (o_ptr->pval <= 0)
2117 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2119 msg_print("The chest is not trapped.");
2124 /* No traps to find. */
2125 else if (!chest_traps[o_ptr->pval])
2128 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2130 msg_print("The chest is not trapped.");
2135 /* Success (get a lot of experience) */
2136 else if (randint0(100) < j)
2139 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2141 msg_print("You have disarmed the chest.");
2144 gain_exp(o_ptr->pval);
2145 o_ptr->pval = (0 - o_ptr->pval);
2148 /* Failure -- Keep trying */
2149 else if ((i > 5) && (randint1(i) > 5))
2151 /* We may keep trying */
2153 if (flush_failure) flush();
2155 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2157 msg_print("You failed to disarm the chest.");
2162 /* Failure -- Set off the trap */
2166 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2168 msg_print("You set off a trap!");
2172 chest_trap(y, x, o_idx);
2181 * Perform the basic "disarm" command
2183 * Assume destination is a visible trap
2185 * Assume there is no monster blocking the destination
2187 * Returns TRUE if repeated commands may continue
2189 #ifdef ALLOW_EASY_DISARM /* TNB */
2191 bool do_cmd_disarm_aux(int y, int x, int dir)
2193 #else /* ALLOW_EASY_DISARM -- TNB */
2195 static bool do_cmd_disarm_aux(int y, int x, int dir)
2197 #endif /* ALLOW_EASY_DISARM -- TNB */
2211 /* Get grid and contents */
2212 c_ptr = &cave[y][x];
2214 /* Access trap name */
2215 name = (f_name + f_info[c_ptr->feat].name);
2217 /* Get the "disarm" factor */
2218 i = p_ptr->skill_dis;
2220 /* Penalize some conditions */
2221 if (p_ptr->blind || no_lite()) i = i / 10;
2222 if (p_ptr->confused || p_ptr->image) i = i / 10;
2224 /* XXX XXX XXX Variable power? */
2226 /* Extract trap "power" */
2229 /* Extract the difficulty */
2232 /* Always have a small chance of success */
2236 if (randint0(100) < j)
2240 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2242 msg_format("You have disarmed the %s.", name);
2249 /* Forget the trap */
2250 c_ptr->info &= ~(CAVE_MARK);
2252 /* Remove the trap */
2253 c_ptr->feat = floor_type[randint0(100)];
2254 c_ptr->info &= ~(CAVE_MASK);
2255 c_ptr->info |= CAVE_FLOOR;
2259 #ifdef ALLOW_EASY_DISARM /* TNB */
2261 /* Move the player onto the trap */
2262 move_player(dir, easy_disarm, FALSE);
2264 #else /* ALLOW_EASY_DISARM -- TNB */
2266 /* move the player onto the trap grid */
2267 move_player(dir, FALSE, FALSE);
2269 #endif /* ALLOW_EASY_DISARM -- TNB */
2272 /* Failure -- Keep trying */
2273 else if ((i > 5) && (randint1(i) > 5))
2276 if (flush_failure) flush();
2280 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2282 msg_format("You failed to disarm the %s.", name);
2286 /* We may keep trying */
2290 /* Failure -- Set off the trap */
2295 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2297 msg_format("You set off the %s!", name);
2301 #ifdef ALLOW_EASY_DISARM /* TNB */
2303 /* Move the player onto the trap */
2304 move_player(dir, easy_disarm, FALSE);
2306 #else /* ALLOW_EASY_DISARM -- TNB */
2308 /* Move the player onto the trap */
2309 move_player(dir, FALSE, FALSE);
2311 #endif /* ALLOW_EASY_DISARM -- TNB */
2320 * Disarms a trap, or chest
2322 void do_cmd_disarm(void)
2332 if (p_ptr->special_defense & KATA_MUSOU)
2334 set_action(ACTION_NONE);
2337 #ifdef ALLOW_EASY_DISARM /* TNB */
2339 /* Option: Pick a direction */
2342 int num_traps, num_chests;
2344 /* Count visible traps */
2345 num_traps = count_dt(&y, &x, is_trap, TRUE);
2347 /* Count chests (trapped) */
2348 num_chests = count_chests(&y, &x, TRUE);
2350 /* See if only one target */
2351 if (num_traps || num_chests)
2353 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2355 if (!too_many) command_dir = coords_to_dir(y, x);
2359 #endif /* ALLOW_EASY_DISARM -- TNB */
2361 /* Allow repeated command */
2364 /* Set repeat count */
2365 command_rep = command_arg - 1;
2367 /* Redraw the state */
2368 p_ptr->redraw |= (PR_STATE);
2370 /* Cancel the arg */
2374 /* Get a direction (or abort) */
2375 if (get_rep_dir(&dir,TRUE))
2381 /* Get grid and contents */
2382 c_ptr = &cave[y][x];
2384 /* Check for chests */
2385 o_idx = chest_check(y, x);
2388 if (!is_trap(c_ptr->feat) && !o_idx)
2392 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2394 msg_print("You see nothing there to disarm.");
2399 /* Monster in the way */
2400 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2404 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2406 msg_print("There is a monster in the way!");
2417 /* Disarm the chest */
2418 more = do_cmd_disarm_chest(y, x, o_idx);
2424 /* Disarm the trap */
2425 more = do_cmd_disarm_aux(y, x, dir);
2429 /* Cancel repeat unless told not to */
2430 if (!more) disturb(0, 0);
2435 * Perform the basic "bash" command
2437 * Assume destination is a closed/locked/jammed door
2439 * Assume there is no monster blocking the destination
2441 * Returns TRUE if repeated commands may continue
2443 static bool do_cmd_bash_aux(int y, int x, int dir)
2456 c_ptr = &cave[y][x];
2460 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2462 msg_print("You smash into the door!");
2466 /* Hack -- Bash power based on strength */
2467 /* (Ranges from 3 to 20 to 100 to 200) */
2468 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2470 /* Extract door power */
2471 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2473 /* Compare bash power to door power XXX XXX XXX */
2474 temp = (bash - (temp * 10));
2476 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2478 /* Hack -- always have a chance */
2479 if (temp < 1) temp = 1;
2481 /* Hack -- attempt to bash down the door */
2482 if (randint0(100) < temp)
2486 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2488 msg_print("The door crashes open!");
2492 /* Break down the door */
2493 if (randint0(100) < 50)
2495 cave_set_feat(y, x, FEAT_BROKEN);
2501 cave_set_feat(y, x, FEAT_OPEN);
2505 sound(SOUND_OPENDOOR);
2507 /* Hack -- Fall through the door */
2508 move_player(dir, FALSE, FALSE);
2510 /* Update some things */
2511 p_ptr->update |= (PU_VIEW | PU_LITE);
2512 p_ptr->update |= (PU_DISTANCE);
2515 /* Saving throw against stun */
2516 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2521 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2523 msg_print("The door holds firm.");
2527 /* Allow repeated bashing */
2531 /* High dexterity yields coolness */
2536 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2538 msg_print("You are off-balance.");
2542 /* Hack -- Lose balance ala paralysis */
2543 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2552 * Bash open a door, success based on character strength
2554 * For a closed door, pval is positive if locked; negative if stuck.
2556 * For an open door, pval is positive for a broken door.
2558 * A closed door can be opened - harder if locked. Any door might be
2559 * bashed open (and thereby broken). Bashing a door is (potentially)
2560 * faster! You move into the door way. To open a stuck door, it must
2561 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2563 * Creatures can also open or bash doors, see elsewhere.
2565 void do_cmd_bash(void)
2574 if (p_ptr->special_defense & KATA_MUSOU)
2576 set_action(ACTION_NONE);
2579 /* Allow repeated command */
2582 /* Set repeat count */
2583 command_rep = command_arg - 1;
2585 /* Redraw the state */
2586 p_ptr->redraw |= (PR_STATE);
2588 /* Cancel the arg */
2592 /* Get a "repeated" direction */
2593 if (get_rep_dir(&dir,FALSE))
2600 c_ptr = &cave[y][x];
2602 /* Nothing useful */
2603 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2604 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2608 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2610 msg_print("You see nothing there to bash.");
2615 /* Monster in the way */
2616 else if (c_ptr->m_idx)
2623 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2625 msg_print("There is a monster in the way!");
2633 /* Bash a closed door */
2637 more = do_cmd_bash_aux(y, x, dir);
2641 /* Unless valid action taken, cancel bash */
2642 if (!more) disturb(0, 0);
2647 * Manipulate an adjacent grid in some way
2649 * Attack monsters, tunnel through walls, disarm traps, open doors.
2651 * Consider confusion XXX XXX XXX
2653 * This command must always take a turn, to prevent free detection
2654 * of invisible monsters.
2656 void do_cmd_alter(void)
2665 if (p_ptr->special_defense & KATA_MUSOU)
2667 set_action(ACTION_NONE);
2670 /* Allow repeated command */
2673 /* Set repeat count */
2674 command_rep = command_arg - 1;
2676 /* Redraw the state */
2677 p_ptr->redraw |= (PR_STATE);
2679 /* Cancel the arg */
2683 /* Get a direction */
2684 if (get_rep_dir(&dir,TRUE))
2691 c_ptr = &cave[y][x];
2696 /* Attack monsters */
2703 /* Tunnel through walls */
2704 else if (((c_ptr->feat >= FEAT_SECRET) &&
2705 (c_ptr->feat < FEAT_MINOR_GLYPH)) ||
2706 ((c_ptr->feat == FEAT_TREES) ||
2707 (c_ptr->feat == FEAT_MOUNTAIN)))
2710 more = do_cmd_tunnel_aux(y, x, dir);
2713 /* Bash jammed doors */
2714 else if ((c_ptr->feat >= FEAT_DOOR_HEAD + 0x08) &&
2715 (c_ptr->feat < FEAT_MINOR_GLYPH))
2718 more = do_cmd_bash_aux(y, x, dir);
2721 /* Open closed doors */
2722 else if ((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2723 (c_ptr->feat < FEAT_MINOR_GLYPH))
2726 more = do_cmd_open_aux(y, x, dir);
2729 /* Close open doors */
2730 else if ((c_ptr->feat == FEAT_OPEN) ||
2731 (c_ptr->feat == FEAT_BROKEN))
2734 more = do_cmd_close_aux(y, x, dir);
2738 else if (is_trap(c_ptr->feat))
2741 more = do_cmd_disarm_aux(y, x, dir);
2749 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2751 msg_print("You attack the empty air.");
2757 /* Cancel repetition unless we can continue */
2758 if (!more) disturb(0, 0);
2763 * Find the index of some "spikes", if possible.
2765 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2767 static bool get_spike(int *ip)
2771 /* Check every item in the pack */
2772 for (i = 0; i < INVEN_PACK; i++)
2774 object_type *o_ptr = &inventory[i];
2776 /* Skip non-objects */
2777 if (!o_ptr->k_idx) continue;
2779 /* Check the "tval" code */
2780 if (o_ptr->tval == TV_SPIKE)
2782 /* Save the spike index */
2796 * Jam a closed door with a spike
2798 * This command may NOT be repeated
2800 void do_cmd_spike(void)
2802 int y, x, dir, item;
2807 if (p_ptr->special_defense & KATA_MUSOU)
2809 set_action(ACTION_NONE);
2812 /* Get a "repeated" direction */
2813 if (get_rep_dir(&dir,FALSE))
2819 /* Get grid and contents */
2820 c_ptr = &cave[y][x];
2822 /* Require closed door */
2823 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2824 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2828 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2830 msg_print("You see nothing there to spike.");
2836 else if (!get_spike(&item))
2840 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2842 msg_print("You have no spikes!");
2847 /* Is a monster in the way? */
2848 else if (c_ptr->m_idx)
2855 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2857 msg_print("There is a monster in the way!");
2871 /* Successful jamming */
2873 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2875 msg_print("You jam the door with a spike.");
2879 /* Convert "locked" to "stuck" XXX XXX XXX */
2880 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2882 /* Add one spike to the door */
2883 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2885 /* Use up, and describe, a single spike, from the bottom */
2886 inven_item_increase(item, -1);
2887 inven_item_describe(item);
2888 inven_item_optimize(item);
2896 * Support code for the "Walk" and "Jump" commands
2898 void do_cmd_walk(int pickup)
2905 /* Allow repeated command */
2908 /* Set repeat count */
2909 command_rep = command_arg - 1;
2911 /* Redraw the state */
2912 p_ptr->redraw |= (PR_STATE);
2914 /* Cancel the arg */
2918 /* Get a "repeated" direction */
2919 if (get_rep_dir(&dir,FALSE))
2924 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2926 set_action(ACTION_NONE);
2929 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2930 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2931 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2933 /* Actually move the character */
2934 move_player(dir, pickup, FALSE);
2936 /* Allow more walking */
2940 /* Hack again -- Is there a special encounter ??? */
2941 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2943 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2946 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2948 /* Inform the player of his horrible fate :=) */
2950 msg_print("½±·â¤À¡ª");
2952 msg_print("You are ambushed !");
2955 /* Go into large wilderness view */
2956 p_ptr->wilderness_x = px;
2957 p_ptr->wilderness_y = py;
2958 p_ptr->oldpy = randint1(MAX_HGT-2);
2959 p_ptr->oldpx = randint1(MAX_WID-2);
2963 /* HACk -- set the encouter flag for the wilderness generation */
2964 generate_encounter = TRUE;
2968 /* Cancel repeat unless we may continue */
2969 if (!more) disturb(0, 0);
2977 void do_cmd_run(void)
2981 /* Hack -- no running when confused */
2982 if (p_ptr->confused)
2985 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2987 msg_print("You are too confused!");
2993 if (p_ptr->special_defense & KATA_MUSOU)
2995 set_action(ACTION_NONE);
2998 /* Get a "repeated" direction */
2999 if (get_rep_dir(&dir,FALSE))
3001 /* Hack -- Set the run counter */
3002 running = (command_arg ? command_arg : 1000);
3012 * Stay still. Search. Enter stores.
3013 * Pick up treasure if "pickup" is true.
3015 void do_cmd_stay(int pickup)
3017 cave_type *c_ptr = &cave[py][px];
3020 /* Allow repeated command */
3023 /* Set repeat count */
3024 command_rep = command_arg - 1;
3026 /* Redraw the state */
3027 p_ptr->redraw |= (PR_STATE);
3029 /* Cancel the arg */
3038 /* Spontaneous Searching */
3039 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3044 /* Continuous Searching */
3045 if (p_ptr->action == ACTION_SEARCH)
3051 /* Handle "objects" */
3055 /* Hack -- enter a store if we are on one */
3056 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3057 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3058 (c_ptr->feat == FEAT_MUSEUM))
3064 /* Hack -- enter store */
3068 /* Hack -- enter a building if we are on one -KMW- */
3069 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3070 (c_ptr->feat <= FEAT_BLDG_TAIL))
3076 /* Hack -- enter building */
3080 /* Exit a quest if reach the quest exit */
3081 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3083 int q_index = p_ptr->inside_quest;
3085 /* Was quest completed? */
3086 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3088 quest[q_index].status = QUEST_STATUS_COMPLETED;
3089 quest[q_index].complev = (byte)p_ptr->lev;
3091 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3093 msg_print("You accomplished your quest!");
3099 leave_quest_check();
3101 p_ptr->inside_quest = cave[py][px].special;
3105 p_ptr->leaving = TRUE;
3112 * Resting allows a player to safely restore his hp -RAK-
3114 void do_cmd_rest(void)
3117 set_action(ACTION_NONE);
3119 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3124 /* Prompt for time if needed */
3125 if (command_arg <= 0)
3128 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3130 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3137 strcpy(out_val, "&");
3139 /* Ask for duration */
3140 if (!get_string(p, out_val, 4)) return;
3142 /* Rest until done */
3143 if (out_val[0] == '&')
3149 else if (out_val[0] == '*')
3157 command_arg = atoi(out_val);
3158 if (command_arg <= 0) return;
3164 if (command_arg > 9999) command_arg = 9999;
3166 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3168 /* Take a turn XXX XXX XXX (?) */
3171 /* The sin of sloth */
3172 if (command_arg > 100)
3173 chg_virtue(V_DILIGENCE, -1);
3175 /* Why are you sleeping when there's no need? WAKE UP!*/
3176 if ((p_ptr->chp == p_ptr->mhp) &&
3177 (p_ptr->csp == p_ptr->msp) &&
3178 !p_ptr->blind && !p_ptr->confused &&
3179 !p_ptr->poisoned && !p_ptr->afraid &&
3180 !p_ptr->stun && !p_ptr->cut &&
3181 !p_ptr->slow && !p_ptr->paralyzed &&
3182 !p_ptr->image && !p_ptr->word_recall)
3183 chg_virtue(V_DILIGENCE, -1);
3185 /* Save the rest code */
3186 resting = command_arg;
3187 p_ptr->action = ACTION_REST;
3189 /* Recalculate bonuses */
3190 p_ptr->update |= (PU_BONUS);
3192 /* Redraw the state */
3193 p_ptr->redraw |= (PR_STATE);
3204 * Determines the odds of an object breaking when thrown at a monster
3206 * Note that artifacts never break, see the "drop_near()" function.
3208 static int breakage_chance(object_type *o_ptr)
3210 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3212 /* Examine the item type */
3213 switch (o_ptr->tval)
3229 /* Sometimes break */
3234 return (20 - archer_bonus * 2);
3239 return (10 - archer_bonus);
3246 s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3250 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3254 /* Extract the flags */
3255 object_flags(o_ptr, &f1, &f2, &f3);
3257 /* Some "weapons" and "ammo" do extra damage */
3258 switch (o_ptr->tval)
3265 if ((f1 & TR1_SLAY_ANIMAL) &&
3266 (r_ptr->flags3 & RF3_ANIMAL))
3270 r_ptr->r_flags3 |= RF3_ANIMAL;
3273 if (mult < 17) mult = 17;
3277 if ((f1 & TR1_SLAY_EVIL) &&
3278 (r_ptr->flags3 & RF3_EVIL))
3282 r_ptr->r_flags3 |= RF3_EVIL;
3285 if (mult < 15) mult = 15;
3289 if ((f3 & TR3_SLAY_HUMAN) &&
3290 (r_ptr->flags2 & RF2_HUMAN))
3294 r_ptr->r_flags2 |= RF2_HUMAN;
3297 if (mult < 17) mult = 17;
3301 if ((f1 & TR1_SLAY_UNDEAD) &&
3302 (r_ptr->flags3 & RF3_UNDEAD))
3306 r_ptr->r_flags3 |= RF3_UNDEAD;
3309 if (mult < 20) mult = 20;
3313 if ((f1 & TR1_SLAY_DEMON) &&
3314 (r_ptr->flags3 & RF3_DEMON))
3318 r_ptr->r_flags3 |= RF3_DEMON;
3321 if (mult < 20) mult = 20;
3325 if ((f1 & TR1_SLAY_ORC) &&
3326 (r_ptr->flags3 & RF3_ORC))
3330 r_ptr->r_flags3 |= RF3_ORC;
3333 if (mult < 20) mult = 20;
3337 if ((f1 & TR1_SLAY_TROLL) &&
3338 (r_ptr->flags3 & RF3_TROLL))
3342 r_ptr->r_flags3 |= RF3_TROLL;
3345 if (mult < 20) mult = 20;
3349 if ((f1 & TR1_SLAY_GIANT) &&
3350 (r_ptr->flags3 & RF3_GIANT))
3354 r_ptr->r_flags3 |= RF3_GIANT;
3357 if (mult < 20) mult = 20;
3361 if ((f1 & TR1_SLAY_DRAGON) &&
3362 (r_ptr->flags3 & RF3_DRAGON))
3366 r_ptr->r_flags3 |= RF3_DRAGON;
3369 if (mult < 20) mult = 20;
3372 /* Execute Dragon */
3373 if ((f1 & TR1_KILL_DRAGON) &&
3374 (r_ptr->flags3 & RF3_DRAGON))
3378 r_ptr->r_flags3 |= RF3_DRAGON;
3381 if (mult < 30) mult = 30;
3383 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3384 (m_ptr->r_idx == MON_SMAUG) &&
3385 (inventory[INVEN_BOW].name1 == ART_BARD))
3390 if ((f1 & TR1_BRAND_ACID) || (p_ptr->special_attack & (ATTACK_ACID)))
3392 /* Notice immunity */
3393 if (r_ptr->flags3 & RF3_IM_ACID)
3397 r_ptr->r_flags3 |= RF3_IM_ACID;
3401 /* Otherwise, take the damage */
3404 if (mult < 17) mult = 17;
3409 if ((f1 & TR1_BRAND_ELEC) || (p_ptr->special_attack & (ATTACK_ELEC)))
3411 /* Notice immunity */
3412 if (r_ptr->flags3 & RF3_IM_ELEC)
3416 r_ptr->r_flags3 |= RF3_IM_ELEC;
3420 /* Otherwise, take the damage */
3423 if (mult < 17) mult = 17;
3428 if ((f1 & TR1_BRAND_FIRE) || (p_ptr->special_attack & (ATTACK_FIRE)))
3430 /* Notice immunity */
3431 if (r_ptr->flags3 & RF3_IM_FIRE)
3435 r_ptr->r_flags3 |= RF3_IM_FIRE;
3439 /* Otherwise, take the damage */
3442 if (mult < 17) mult = 17;
3447 if ((f1 & TR1_BRAND_COLD) || (p_ptr->special_attack & (ATTACK_COLD)))
3449 /* Notice immunity */
3450 if (r_ptr->flags3 & RF3_IM_COLD)
3454 r_ptr->r_flags3 |= RF3_IM_COLD;
3457 /* Otherwise, take the damage */
3460 if (mult < 17) mult = 17;
3464 /* Brand (Poison) */
3465 if ((f1 & TR1_BRAND_POIS) || (p_ptr->special_attack & (ATTACK_POIS)))
3467 /* Notice immunity */
3468 if (r_ptr->flags3 & RF3_IM_POIS)
3472 r_ptr->r_flags3 |= RF3_IM_POIS;
3476 /* Otherwise, take the damage */
3479 if (mult < 17) mult = 17;
3483 if ((f1 & TR1_FORCE_WEAPON) && (p_ptr->csp > (p_ptr->msp / 30)))
3485 p_ptr->csp -= (1+(p_ptr->msp / 30));
3486 p_ptr->redraw |= (PR_MANA);
3487 mult = mult * 5 / 2;
3493 /* Return the total damage */
3494 return (tdam * mult / 10);
3499 * Fire an object from the pack or floor.
3501 * You may only fire items that "match" your missile launcher.
3503 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3505 * See "calc_bonuses()" for more calculations and such.
3507 * Note that "firing" a missile is MUCH better than "throwing" it.
3509 * Note: "unseen" monsters are very hard to hit.
3511 * Objects are more likely to break if they "attempt" to hit a monster.
3513 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3515 * The "extra shot" code works by decreasing the amount of energy
3516 * required to make each shot, spreading the shots out over time.
3518 * Note that when firing missiles, the launcher multiplier is applied
3519 * after all the bonuses are added in, making multipliers very useful.
3521 * Note that Bows of "Extra Might" get extra range and an extra bonus
3522 * for the damage multiplier.
3524 * Note that Bows of "Extra Shots" give an extra shot.
3526 void do_cmd_fire_aux(int item, object_type *j_ptr)
3529 int j, y, x, ny, nx, ty, tx;
3530 int tdam, tdis, thits, tmul;
3532 int cur_dis, visible;
3539 bool hit_body = FALSE;
3541 char o_name[MAX_NLEN];
3543 int msec = delay_factor * delay_factor * delay_factor;
3546 bool stick_to = FALSE;
3548 /* Access the item (if in the pack) */
3551 o_ptr = &inventory[item];
3555 o_ptr = &o_list[0 - item];
3558 /* Describe the object */
3559 object_desc(o_name, o_ptr, FALSE, 3);
3562 /* Use the proper number of shots */
3563 thits = p_ptr->num_fire;
3565 /* Use a base distance */
3568 /* Base damage from thrown object plus launcher bonus */
3569 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3571 /* Actually "fire" the object */
3572 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3573 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3574 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval])/400 + bonus) * BTH_PLUS_ADJ);
3576 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3578 energy_use = bow_energy(j_ptr->sval);
3579 tmul = bow_tmul(j_ptr->sval);
3581 /* Get extra "power" from "extra might" */
3582 if (p_ptr->xtra_might) tmul++;
3584 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3586 /* Boost the damage */
3591 tdis = 10 + tmul/40;
3592 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3595 project_length = tdis + 1;
3597 /* Get a direction (or cancel) */
3598 if (!get_aim_dir(&dir))
3602 /* need not to reset project_length (already did)*/
3606 project_length = 0; /* reset to default */
3608 /* Get local object */
3611 /* Obtain a local object */
3612 object_copy(q_ptr, o_ptr);
3617 /* Reduce and describe inventory */
3620 inven_item_increase(item, -1);
3621 inven_item_describe(item);
3622 inven_item_optimize(item);
3625 /* Reduce and describe floor item */
3628 floor_item_increase(0 - item, -1);
3629 floor_item_optimize(0 - item);
3637 /* Take a (partial) turn */
3638 energy_use = (energy_use / thits);
3641 /* Start at the player */
3645 /* Predict the "target" location */
3646 tx = px + 99 * ddx[dir];
3647 ty = py + 99 * ddy[dir];
3649 /* Check for "target request" */
3650 if ((dir == 5) && target_okay())
3657 /* Hack -- Handle stuff */
3661 /* Travel until stopped */
3662 for (cur_dis = 0; cur_dis <= tdis; )
3664 /* Hack -- Stop at the target */
3665 if ((y == ty) && (x == tx)) break;
3667 /* Calculate the new location (see "project()") */
3670 mmove2(&ny, &nx, py, px, ty, tx);
3672 /* Stopped by walls/doors */
3673 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3675 /* Advance the distance */
3679 /* The player can see the (on screen) missile */
3680 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3682 char c = object_char(q_ptr);
3683 byte a = object_attr(q_ptr);
3685 /* Draw, Hilite, Fresh, Pause, Erase */
3686 print_rel(c, a, ny, nx);
3687 move_cursor_relative(ny, nx);
3689 Term_xtra(TERM_XTRA_DELAY, msec);
3694 /* The player cannot see the missile */
3697 /* Pause anyway, for consistancy */
3698 Term_xtra(TERM_XTRA_DELAY, msec);
3701 /* Save the new location */
3706 /* Monster here, Try to hit it */
3707 if (cave[y][x].m_idx)
3709 cave_type *c_ptr = &cave[y][x];
3711 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3712 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3714 /* Check the visibility */
3715 visible = m_ptr->ml;
3717 /* Note the collision */
3722 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3723 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3726 if ((r_ptr->level + 10) > p_ptr->lev)
3728 int now_exp = weapon_exp[0][j_ptr->sval];
3729 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3732 if (now_exp < 4000) amount = 80;
3733 else if (now_exp < 6000) amount = 25;
3734 else if ((now_exp < 7000) && (p_ptr->lev > 19)) amount = 10;
3735 else if (p_ptr->lev > 34) amount = 2;
3736 weapon_exp[0][j_ptr->sval] += amount;
3737 p_ptr->update |= (PU_BONUS);
3743 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))
3745 skill_exp[GINOU_RIDING]+=1;
3746 p_ptr->update |= (PU_BONUS);
3750 /* Did we hit it (penalize range) */
3751 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3755 /* Assume a default death */
3757 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3759 cptr note_dies = " dies.";
3762 /* Some monsters get "destroyed" */
3763 if (!monster_living(r_ptr))
3766 bool explode = FALSE;
3768 for (i = 0; i < 4; i++)
3770 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3773 /* Special note at death */
3776 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3778 note_dies = " explodes into tiny shreds.";
3782 note_dies = "¤òÅݤ·¤¿¡£";
3784 note_dies = " is destroyed.";
3789 /* Handle unseen monster */
3792 /* Invisible monster */
3794 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3796 msg_format("The %s finds a mark.", o_name);
3801 /* Handle visible monster */
3806 /* Get "the monster" or "it" */
3807 monster_desc(m_name, m_ptr, 0);
3811 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3813 msg_format("The %s hits %s.", o_name, m_name);
3817 /* Hack -- Track this monster race */
3818 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3820 /* Hack -- Track this monster */
3821 if (m_ptr->ml) health_track(c_ptr->m_idx);
3824 /* Apply special damage XXX XXX XXX */
3825 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3826 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3828 /* No negative damage */
3829 if (tdam < 0) tdam = 0;
3831 /* Modify the damage */
3832 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3834 /* Complex message */
3835 if (wizard || cheat_xtra)
3838 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3841 msg_format("You do %d (out of %d) damage.",
3847 /* Hit the monster, check for death */
3848 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3861 monster_desc(m_name, m_ptr, 0);
3865 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3867 msg_format("%^s have stuck into %s!",o_name, m_name);
3872 message_pain(c_ptr->m_idx, tdam);
3874 /* Anger the monster */
3875 if (tdam > 0) anger_monster(m_ptr);
3878 if (fear && m_ptr->ml)
3885 /* Get the monster name (or "it") */
3886 monster_desc(m_name, m_ptr, 0);
3890 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3892 msg_format("%^s flees in terror!", m_name);
3896 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3898 set_target(m_ptr, py, px);
3908 /* Chance of breakage (during attacks) */
3909 j = (hit_body ? breakage_chance(q_ptr) : 0);
3913 int m_idx = cave[y][x].m_idx;
3914 monster_type *m_ptr = &m_list[m_idx];
3915 int o_idx = o_pop();
3920 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3922 msg_format("The %s have gone to somewhere.", o_name);
3926 a_info[j_ptr->name1].cur_num = 0;
3931 o_ptr = &o_list[ o_idx ];
3932 object_copy(o_ptr, q_ptr);
3935 o_ptr->marked = FALSE;
3937 /* Forget location */
3938 o_ptr->iy = o_ptr->ix = 0;
3940 /* Memorize monster */
3941 o_ptr->held_m_idx = m_idx;
3944 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3947 m_ptr->hold_o_idx = o_idx;
3951 /* Drop (or break) near that location */
3952 (void)drop_near(q_ptr, j, y, x);
3956 void do_cmd_fire(void)
3962 /* Get the "bow" (if any) */
3963 j_ptr = &inventory[INVEN_BOW];
3965 /* Require a launcher */
3969 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
3971 msg_print("You have nothing to fire with.");
3977 if (j_ptr->sval == SV_CRIMSON)
3980 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
3982 msg_print("Do activate.");
3989 if (p_ptr->special_defense & KATA_MUSOU)
3991 set_action(ACTION_NONE);
3994 /* Require proper missile */
3995 item_tester_tval = p_ptr->tval_ammo;
3999 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4000 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4002 q = "Fire which item? ";
4003 s = "You have nothing to fire.";
4006 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4013 do_cmd_fire_aux(item, j_ptr);
4017 static bool item_tester_hook_boomerang(object_type *o_ptr)
4019 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4027 * Throw an object from the pack or floor.
4029 * Note: "unseen" monsters are very hard to hit.
4031 * Should throwing a weapon do full damage? Should it allow the magic
4032 * to hit bonus of the weapon to have an effect? Should it ever cause
4033 * the item to be destroyed? Should it do any damage at all?
4035 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4038 int i, j, y, x, ty, tx;
4040 int chance, tdam, tdis;
4042 int cur_dis, visible;
4049 bool hit_body = FALSE;
4050 bool hit_wall = FALSE;
4051 bool equiped_item = FALSE;
4052 bool return_when_thrown = FALSE;
4054 char o_name[MAX_NLEN];
4056 int msec = delay_factor * delay_factor * delay_factor;
4060 bool come_back = FALSE;
4061 bool do_drop = TRUE;
4064 if (p_ptr->special_defense & KATA_MUSOU)
4066 set_action(ACTION_NONE);
4075 if (buki_motteruka(INVEN_LARM))
4077 item_tester_hook = item_tester_hook_boomerang;
4079 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4080 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4082 q = "Throw which item? ";
4083 s = "You have nothing to throw.";
4086 if (!get_item(&item, q, s, (USE_EQUIP)))
4101 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4102 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4104 q = "Throw which item? ";
4105 s = "You have nothing to throw.";
4108 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4115 /* Access the item (if in the pack) */
4118 o_ptr = &inventory[item];
4122 o_ptr = &o_list[0 - item];
4126 /* Item is cursed */
4127 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4131 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4133 msg_print("Hmmm, it seems to be cursed.");
4142 /* Get local object */
4145 /* Obtain a local object */
4146 object_copy(q_ptr, o_ptr);
4148 /* Extract the thrown object's flags. */
4149 object_flags(q_ptr, &f1, &f2, &f3);
4151 /* Distribute the charges of rods/wands between the stacks */
4152 distribute_charges(o_ptr, q_ptr, 1);
4158 object_desc(o_name, q_ptr, FALSE, 3);
4160 if (p_ptr->mighty_throw) mult += 3;
4162 /* Extract a "distance multiplier" */
4163 /* Changed for 'launcher' mutation */
4164 mul = 10 + 2 * (mult - 1);
4166 /* Enforce a minimum "weight" of one pound */
4167 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4168 if ((f2 & (TR2_THROW)) || boomerang) div /= 2;
4170 /* Hack -- Distance -- Reward strength, penalize weight */
4171 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4173 /* Max distance of 10-18 */
4174 if (tdis > mul) tdis = mul;
4178 ty = randint0(101)-50+py;
4179 tx = randint0(101)-50+px;
4183 project_length = tdis + 1;
4185 /* Get a direction (or cancel) */
4186 if (!get_aim_dir(&dir)) return FALSE;
4188 project_length = 0; /* reset to default */
4190 /* Predict the "target" location */
4191 tx = px + 99 * ddx[dir];
4192 ty = py + 99 * ddy[dir];
4194 /* Check for "target request" */
4195 if ((dir == 5) && target_okay())
4202 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4203 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4204 return_when_thrown = TRUE;
4206 /* Reduce and describe inventory */
4209 inven_item_increase(item, -1);
4210 if (!return_when_thrown)
4211 inven_item_describe(item);
4212 inven_item_optimize(item);
4215 /* Reduce and describe floor item */
4218 floor_item_increase(0 - item, -1);
4219 floor_item_optimize(0 - item);
4221 if (item >= INVEN_RARM)
4223 equiped_item = TRUE;
4224 p_ptr->redraw |= (PR_EQUIPPY);
4230 /* Rogue and Ninja gets bonus */
4231 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4232 energy_use -= p_ptr->lev;
4234 /* Start at the player */
4239 /* Hack -- Handle stuff */
4242 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((f2 & TR2_THROW) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4243 else shuriken = FALSE;
4245 /* Chance of hitting */
4246 if (f2 & (TR2_THROW)) chance = ((p_ptr->skill_tht) +
4247 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4248 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4250 if (shuriken) chance *= 2;
4252 /* Travel until stopped */
4253 for (cur_dis = 0; cur_dis <= tdis; )
4255 /* Hack -- Stop at the target */
4256 if ((y == ty) && (x == tx)) break;
4258 /* Calculate the new location (see "project()") */
4261 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4263 /* Stopped by walls/doors */
4264 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4270 /* Advance the distance */
4273 /* The player can see the (on screen) missile */
4274 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4276 char c = object_char(q_ptr);
4277 byte a = object_attr(q_ptr);
4279 /* Draw, Hilite, Fresh, Pause, Erase */
4280 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4281 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4283 Term_xtra(TERM_XTRA_DELAY, msec);
4284 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4288 /* The player cannot see the missile */
4291 /* Pause anyway, for consistancy */
4292 Term_xtra(TERM_XTRA_DELAY, msec);
4295 /* Save the new location */
4300 /* Monster here, Try to hit it */
4301 if (cave[y][x].m_idx)
4303 cave_type *c_ptr = &cave[y][x];
4305 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4306 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4308 /* Check the visibility */
4309 visible = m_ptr->ml;
4311 /* Note the collision */
4314 /* Did we hit it (penalize range) */
4315 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4319 /* Assume a default death */
4321 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4323 cptr note_dies = " dies.";
4327 /* Some monsters get "destroyed" */
4328 if (!monster_living(r_ptr))
4331 bool explode = FALSE;
4333 for (i = 0; i < 4; i++)
4335 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4338 /* Special note at death */
4341 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4343 note_dies = " explodes into tiny shreds.";
4347 note_dies = "¤òÅݤ·¤¿¡£";
4349 note_dies = " is destroyed.";
4355 /* Handle unseen monster */
4358 /* Invisible monster */
4360 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4362 msg_format("The %s finds a mark.", o_name);
4367 /* Handle visible monster */
4372 /* Get "the monster" or "it" */
4373 monster_desc(m_name, m_ptr, 0);
4377 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4379 msg_format("The %s hits %s.", o_name, m_name);
4383 /* Hack -- Track this monster race */
4384 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4386 /* Hack -- Track this monster */
4387 if (m_ptr->ml) health_track(c_ptr->m_idx);
4390 /* Hack -- Base damage from thrown object */
4391 tdam = damroll(q_ptr->dd, q_ptr->ds);
4392 /* Apply special damage XXX XXX XXX */
4393 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4394 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4395 if (q_ptr->to_d > 0)
4396 tdam += q_ptr->to_d;
4398 tdam += -q_ptr->to_d;
4402 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4403 tdam += p_ptr->to_d_m;
4405 else if (f2 & (TR2_THROW))
4408 tdam += p_ptr->to_d_m;
4416 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4419 /* No negative damage */
4420 if (tdam < 0) tdam = 0;
4422 /* Modify the damage */
4423 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4425 /* Complex message */
4429 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4432 msg_format("You do %d (out of %d) damage.",
4438 /* Hit the monster, check for death */
4439 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4448 message_pain(c_ptr->m_idx, tdam);
4450 /* Anger the monster */
4451 if ((tdam > 0) && !object_is_potion(q_ptr))
4452 anger_monster(m_ptr);
4455 if (fear && m_ptr->ml)
4462 /* Get the monster name (or "it") */
4463 monster_desc(m_name, m_ptr, 0);
4467 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4469 msg_format("%^s flees in terror!", m_name);
4481 /* Chance of breakage (during attacks) */
4482 j = (hit_body ? breakage_chance(q_ptr) : 0);
4484 /* Figurines transform */
4485 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4489 if (!(summon_named_creature(y, x, q_ptr->pval, FALSE, FALSE, FALSE,
4490 (bool)!(cursed_p(q_ptr)))))
4492 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4494 msg_print("The Figurine writhes and then shatters.");
4497 else if (cursed_p(q_ptr))
4499 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4501 msg_print("You have a bad feeling about this.");
4507 /* Potions smash open */
4508 if (object_is_potion(q_ptr))
4510 if (hit_body || hit_wall || (randint1(100) < j))
4514 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4516 msg_format("The %s shatters!", o_name);
4520 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4522 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4524 /* ToDo (Robert): fix the invulnerability */
4525 if (cave[y][x].m_idx &&
4526 is_friendly(&m_list[cave[y][x].m_idx]) &&
4530 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4532 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4534 msg_format("%^s gets angry!", m_name);
4537 set_hostile(&m_list[cave[y][x].m_idx]);
4548 if (return_when_thrown)
4550 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4551 char o2_name[MAX_NLEN];
4552 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4555 if (boomerang) back_chance += 4+randint1(5);
4556 if (super_boomerang) back_chance += 100;
4557 object_desc(o2_name, q_ptr, FALSE, 0);
4559 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4561 for (i = cur_dis-1;i>0;i--)
4563 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4565 char c = object_char(q_ptr);
4566 byte a = object_attr(q_ptr);
4568 /* Draw, Hilite, Fresh, Pause, Erase */
4569 print_rel(c, a, ny[i], nx[i]);
4570 move_cursor_relative(ny[i], nx[i]);
4572 Term_xtra(TERM_XTRA_DELAY, msec);
4573 lite_spot(ny[i], nx[i]);
4578 /* Pause anyway, for consistancy */
4579 Term_xtra(TERM_XTRA_DELAY, msec);
4582 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4585 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4587 msg_format("%s comes back to you.", o2_name);
4596 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4598 msg_format("%s backs, but you can't catch!", o2_name);
4604 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4606 msg_format("%s comes back.", o2_name);
4616 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4618 msg_format("%s doesn't back!", o2_name);
4625 if (item == INVEN_RARM || item == INVEN_LARM)
4627 /* Access the wield slot */
4628 o_ptr = &inventory[item];
4630 /* Wear the new stuff */
4631 object_copy(o_ptr, q_ptr);
4633 /* Increase the weight */
4634 p_ptr->total_weight += q_ptr->weight;
4636 /* Increment the equip counter by hand */
4639 /* Recalculate bonuses */
4640 p_ptr->update |= (PU_BONUS);
4642 /* Recalculate torch */
4643 p_ptr->update |= (PU_TORCH);
4645 /* Recalculate mana XXX */
4646 p_ptr->update |= (PU_MANA);
4649 p_ptr->window |= (PW_EQUIP);
4657 else if (equiped_item)
4663 /* Drop (or break) near that location */
4664 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4671 * Throw an object from the pack or floor.
4673 void do_cmd_throw(void)
4675 do_cmd_throw_aux(1, FALSE, 0);