4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Movement commands (part 2) */
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.");
48 p_ptr->inside_quest = c_ptr->special;
50 /* Activate the quest */
51 if (!quest[p_ptr->inside_quest].status)
53 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
57 if (!p_ptr->inside_quest)
62 /* Clear all saved floors */
63 prepare_change_floor_mode(CFM_CLEAR_ALL);
66 p_ptr->leaving = TRUE;
75 /* Normal up stairs? */
76 if (c_ptr->feat != FEAT_LESS && c_ptr->feat != FEAT_LESS_LESS)
79 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
81 msg_print("I see no up staircase here.");
93 quest_type *q_ptr = &quest[p_ptr->inside_quest];
95 /* Confirm leaving from once only quest */
96 if (confirm_quest && p_ptr->inside_quest &&
97 (q_ptr->type == QUEST_TYPE_RANDOM ||
98 (q_ptr->flags & QUEST_FLAG_ONCE &&
99 q_ptr->status != QUEST_STATUS_COMPLETED)))
102 msg_print("¤³¤Î³¬¤ò°ìÅÙµî¤ë¤ÈÆóÅÙ¤ÈÌá¤Ã¤ÆÍè¤é¤ì¤Þ¤»¤ó¡£");
103 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©")) go_up = TRUE;
105 msg_print("You can't come back here once you leave this floor.");
106 if (get_check("Really leave this floor? ")) go_up = TRUE;
115 /* Cancel the command */
118 /* Hack -- take a turn */
121 if (autosave_l) do_cmd_save_game(TRUE);
123 /* For a random quest */
124 if (p_ptr->inside_quest &&
125 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
129 p_ptr->inside_quest = 0;
132 /* For a fixed quest */
133 if (p_ptr->inside_quest &&
134 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
138 p_ptr->inside_quest = c_ptr->special;
143 /* For normal dungeon and random quest */
147 if (c_ptr->feat == FEAT_LESS_LESS)
149 /* Create a way back */
150 prepare_change_floor_mode(CFM_UP | CFM_SHAFT);
156 /* Create a way back */
157 prepare_change_floor_mode(CFM_UP);
162 /* Get out from current dungeon */
163 if (dun_level - up_num < d_info[dungeon_type].mindepth)
168 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
170 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "climbed up the stairs to");
175 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
176 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
177 else if (up_num == dun_level)
178 msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
180 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
182 if (up_num == dun_level)
183 msg_print("You go back to the surface.");
185 msg_print("You enter a maze of up staircases.");
189 p_ptr->leaving = TRUE;
196 void do_cmd_go_down(void)
199 bool fall_trap = FALSE;
202 if (p_ptr->special_defense & KATA_MUSOU)
204 set_action(ACTION_NONE);
208 c_ptr = &cave[py][px];
210 if (c_ptr->feat == (FEAT_TRAP_TRAPDOOR)) fall_trap = TRUE;
212 /* Quest down stairs */
213 if (c_ptr->feat == FEAT_QUEST_DOWN)
216 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
217 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
219 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
221 msg_print("You enter the down staircase.");
227 p_ptr->inside_quest = c_ptr->special;
229 /* Activate the quest */
230 if (!quest[p_ptr->inside_quest].status)
232 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
235 /* Leaving a quest */
236 if (!p_ptr->inside_quest)
241 /* Clear all saved floors */
242 prepare_change_floor_mode(CFM_CLEAR_ALL);
245 p_ptr->leaving = TRUE;
251 else if ((c_ptr->feat != FEAT_MORE) && (c_ptr->feat != FEAT_MORE_MORE) && (c_ptr->feat != FEAT_ENTRANCE) && !fall_trap)
254 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
256 msg_print("I see no down staircase here.");
263 int target_dungeon = 0;
267 target_dungeon = (c_ptr->feat == FEAT_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
269 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
272 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
274 msg_print("The entrance of this dungeon is closed!");
278 if (!max_dlv[target_dungeon])
281 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
282 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
284 msg_format("There is the entrance of %s (Danger level: %d)", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
285 if (!get_check("Do you really get in this dungeon? ")) return;
289 /* Save old player position */
292 dungeon_type = (byte)target_dungeon;
295 /* Hack -- take a turn */
298 if (autosave_l) do_cmd_save_game(TRUE);
301 if (c_ptr->feat == FEAT_MORE_MORE) down_num += 2;
306 /* Enter the dungeon just now */
307 p_ptr->enter_dungeon = TRUE;
308 down_num = d_info[dungeon_type].mindepth;
314 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
315 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
317 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fell through a trap door");
318 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed down the stairs to");
325 msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
327 msg_print("You deliberately jump through the trap door.");
336 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
338 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
344 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
345 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
347 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
349 msg_print("You enter a maze of down staircases.");
356 p_ptr->leaving = TRUE;
360 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
364 if (c_ptr->feat == FEAT_MORE_MORE)
366 /* Create a way back */
367 prepare_change_floor_mode(CFM_DOWN | CFM_SHAFT);
371 /* Create a way back */
372 prepare_change_floor_mode(CFM_DOWN);
381 * Simple command to "search" for one turn
383 void do_cmd_search(void)
385 /* Allow repeated command */
388 /* Set repeat count */
389 command_rep = command_arg - 1;
391 /* Redraw the state */
392 p_ptr->redraw |= (PR_STATE);
407 * Determine if a grid contains a chest
409 static s16b chest_check(int y, int x)
411 cave_type *c_ptr = &cave[y][x];
413 s16b this_o_idx, next_o_idx = 0;
416 /* Scan all objects in the grid */
417 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
422 o_ptr = &o_list[this_o_idx];
424 /* Acquire next object */
425 next_o_idx = o_ptr->next_o_idx;
427 /* Skip unknown chests XXX XXX */
428 /* if (!o_ptr->marked) continue; */
430 /* Check for chest */
431 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
440 * Allocates objects upon opening a chest -BEN-
442 * Disperse treasures from the given chest, centered at (x,y).
444 * Small chests often contain "gold", while Large chests always contain
445 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
446 * and Steel chests contain 6 items. The "value" of the items in a
447 * chest is based on the "power" of the chest, which is in turn based
448 * on the level on which the chest is generated.
450 static void chest_death(bool scatter, int y, int x, s16b o_idx)
460 object_type *o_ptr = &o_list[o_idx];
463 /* Small chests often hold "gold" */
464 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
466 /* Determine how much to drop (see above) */
467 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
469 if (o_ptr->sval == SV_CHEST_KANDUME)
474 object_level = o_ptr->xtra3;
478 /* Determine the "value" of the items */
479 object_level = ABS(o_ptr->pval) + 10;
482 /* Zero pval means empty chest */
483 if (!o_ptr->pval) number = 0;
485 /* Opening a chest */
486 opening_chest = TRUE;
488 /* Drop some objects (non-chests) */
489 for (; number > 0; --number)
491 /* Get local object */
494 /* Wipe the object */
497 /* Small chests often drop gold */
498 if (small && (randint0(100) < 25))
501 if (!make_gold(q_ptr)) continue;
504 /* Otherwise drop an item */
507 /* Make a good object */
508 if (!make_object(q_ptr, mode)) continue;
511 /* If chest scatters its contents, pick any floor square. */
515 for (i = 0; i < 200; i++)
517 /* Pick a totally random spot. */
518 y = randint0(MAX_HGT);
519 x = randint0(MAX_WID);
521 /* Must be an empty floor. */
522 if (!cave_empty_bold(y, x)) continue;
524 /* Place the object there. */
525 drop_near(q_ptr, -1, y, x);
531 /* Normally, drop object near the chest. */
532 else drop_near(q_ptr, -1, y, x);
535 /* Reset the object level */
536 object_level = base_level;
538 /* No longer opening a chest */
539 opening_chest = FALSE;
550 * Chests have traps too.
552 * Exploding chest destroys contents (and traps).
553 * Note that the chest itself is never destroyed.
555 static void chest_trap(int y, int x, s16b o_idx)
559 object_type *o_ptr = &o_list[o_idx];
561 int mon_level = o_ptr->xtra3;
563 /* Ignore disarmed chests */
564 if (o_ptr->pval <= 0) return;
566 /* Obtain the traps */
567 trap = chest_traps[o_ptr->pval];
570 if (trap & (CHEST_LOSE_STR))
573 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
574 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
576 msg_print("A small needle has pricked you!");
577 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
580 (void)do_dec_stat(A_STR);
583 /* Lose constitution */
584 if (trap & (CHEST_LOSE_CON))
587 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
588 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
590 msg_print("A small needle has pricked you!");
591 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
594 (void)do_dec_stat(A_CON);
598 if (trap & (CHEST_POISON))
601 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
603 msg_print("A puff of green gas surrounds you!");
606 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
608 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
613 if (trap & (CHEST_PARALYZE))
616 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
618 msg_print("A puff of yellow gas surrounds you!");
622 if (!p_ptr->free_act)
624 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
628 /* Summon monsters */
629 if (trap & (CHEST_SUMMON))
631 int num = 2 + randint1(3);
633 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
635 msg_print("You are enveloped in a cloud of smoke!");
639 for (i = 0; i < num; i++)
641 if (randint1(100)<dun_level)
642 activate_hi_summon(py, px, FALSE);
644 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
648 /* Elemental summon. */
649 if (trap & (CHEST_E_SUMMON))
652 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
654 msg_print("Elemental beings appear to protect their treasures!");
656 for (i = 0; i < randint1(3) + 5; i++)
658 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
662 /* Force clouds, then summon birds. */
663 if (trap & (CHEST_BIRD_STORM))
666 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
668 msg_print("A storm of birds swirls around you!");
671 for (i = 0; i < randint1(3) + 3; i++)
672 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
674 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
676 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
680 /* Various colorful summonings. */
681 if (trap & (CHEST_H_SUMMON))
687 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
689 msg_print("Demons materialize in clouds of fire and brimstone!");
692 for (i = 0; i < randint1(3) + 2; i++)
694 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
695 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
699 /* Summon dragons. */
703 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
705 msg_print("Draconic forms loom out of the darkness!");
708 for (i = 0; i < randint1(3) + 2; i++)
710 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
714 /* Summon hybrids. */
718 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
720 msg_print("Creatures strange and twisted assault you!");
723 for (i = 0; i < randint1(5) + 3; i++)
725 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
729 /* Summon vortices (scattered) */
733 msg_print("±²´¬¤«¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
735 msg_print("Vortices coalesce and wreak destruction!");
738 for (i = 0; i < randint1(3) + 2; i++)
740 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
746 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
748 /* Determine how many nasty tricks can be played. */
749 int nasty_tricks_count = 4 + randint0(3);
753 msg_print("¶²¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
755 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
758 /* This is gonna hurt... */
759 for (; nasty_tricks_count > 0; nasty_tricks_count--)
761 /* ...but a high saving throw does help a little. */
762 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
765 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
767 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
769 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
772 if (!p_ptr->free_act)
773 (void)set_paralyzed(p_ptr->paralyzed + 2 +
776 (void)set_stun(p_ptr->stun + 10 +
779 else if (one_in_(3)) apply_disenchant(0);
782 (void)do_dec_stat(A_STR);
783 (void)do_dec_stat(A_DEX);
784 (void)do_dec_stat(A_CON);
785 (void)do_dec_stat(A_INT);
786 (void)do_dec_stat(A_WIS);
787 (void)do_dec_stat(A_CHR);
789 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
794 /* Aggravate monsters. */
795 if (trap & (CHEST_ALARM))
798 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
800 msg_print("An alarm sounds!");
802 aggravate_monsters(0);
806 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
809 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
810 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
812 msg_print("There is a sudden explosion!");
813 msg_print("Everything inside the chest is destroyed!");
817 sound(SOUND_EXPLODE);
819 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
821 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
825 /* Scatter contents. */
826 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
829 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
831 msg_print("The contents of the chest scatter all over the dungeon!");
833 chest_death(TRUE, y, x, o_idx);
840 * Attempt to open the given chest at the given location
842 * Assume there is no monster blocking the destination
844 * Returns TRUE if repeated commands may continue
846 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
854 object_type *o_ptr = &o_list[o_idx];
860 /* Attempt to unlock it */
863 /* Assume locked, and thus not open */
866 /* Get the "disarm" factor */
867 i = p_ptr->skill_dis;
869 /* Penalize some conditions */
870 if (p_ptr->blind || no_lite()) i = i / 10;
871 if (p_ptr->confused || p_ptr->image) i = i / 10;
873 /* Extract the difficulty */
876 /* Always have a small chance of success */
879 /* Success -- May still have traps */
880 if (randint0(100) < j)
883 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
885 msg_print("You have picked the lock.");
892 /* Failure -- Keep trying */
895 /* We may continue repeating */
897 if (flush_failure) flush();
899 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
901 msg_print("You failed to pick the lock.");
907 /* Allowed to open */
910 /* Apply chest traps, if any */
911 chest_trap(y, x, o_idx);
913 /* Let the Chest drop items */
914 chest_death(FALSE, y, x, o_idx);
922 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
925 * Return TRUE if the given feature is an open door
927 static bool is_open(int feat)
929 return (feat == FEAT_OPEN);
934 * Return the number of features around (or under) the character.
935 * Usually look for doors and floor traps.
937 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
939 int d, count, xx, yy;
941 /* Count how many matches */
944 /* Check around (and under) the character */
945 for (d = 0; d < 9; d++)
950 /* if not searching under player continue */
951 if ((d == 8) && !under) continue;
953 /* Extract adjacent (legal) location */
954 yy = py + ddy_ddd[d];
955 xx = px + ddx_ddd[d];
958 c_ptr = &cave[yy][xx];
960 /* Must have knowledge */
961 if (!(c_ptr->info & (CAVE_MARK))) continue;
963 /* Feature code (applying "mimic" field) */
964 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
966 /* Not looking for this feature */
967 if (!((*test)(feat))) continue;
972 /* Remember the location. Only useful if only one match */
983 * Return the number of chests around (or under) the character.
984 * If requested, count only trapped chests.
986 static int count_chests(int *y, int *x, bool trapped)
992 /* Count how many matches */
995 /* Check around (and under) the character */
996 for (d = 0; d < 9; d++)
998 /* Extract adjacent (legal) location */
999 int yy = py + ddy_ddd[d];
1000 int xx = px + ddx_ddd[d];
1002 /* No (visible) chest is there */
1003 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1005 /* Grab the object */
1006 o_ptr = &o_list[o_idx];
1009 if (o_ptr->pval == 0) continue;
1011 /* No (known) traps here */
1012 if (trapped && (!object_known_p(o_ptr) ||
1013 !chest_traps[o_ptr->pval])) continue;
1018 /* Remember the location. Only useful if only one match */
1029 * Convert an adjacent location to a direction.
1031 static int coords_to_dir(int y, int x)
1033 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1040 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1042 return d[dx + 1][dy + 1];
1045 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1049 * Perform the basic "open" command on doors
1051 * Assume destination is a closed/locked/jammed door
1053 * Assume there is no monster blocking the destination
1055 * Returns TRUE if repeated commands may continue
1057 static bool do_cmd_open_aux(int y, int x)
1069 /* Get requested grid */
1070 c_ptr = &cave[y][x];
1072 /* Seeing true feature code (ignore mimic) */
1075 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1079 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1081 msg_print("The door appears to be stuck.");
1087 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1090 i = p_ptr->skill_dis;
1092 /* Penalize some conditions */
1093 if (p_ptr->blind || no_lite()) i = i / 10;
1094 if (p_ptr->confused || p_ptr->image) i = i / 10;
1096 /* Extract the lock power */
1097 j = c_ptr->feat - FEAT_DOOR_HEAD;
1099 /* Extract the difficulty XXX XXX XXX */
1102 /* Always have a small chance of success */
1106 if (randint0(100) < j)
1110 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1112 msg_print("You have picked the lock.");
1117 cave_set_feat(y, x, FEAT_OPEN);
1119 /* Update some things */
1120 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1123 sound(SOUND_OPENDOOR);
1133 if (flush_failure) flush();
1137 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1139 msg_print("You failed to pick the lock.");
1143 /* We may keep trying */
1149 else if (c_ptr->feat == FEAT_DOOR_HEAD)
1152 cave_set_feat(y, x, FEAT_OPEN);
1154 /* Update some things */
1155 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1158 sound(SOUND_OPENDOOR);
1168 * Open a closed/locked/jammed door or a closed/locked chest.
1170 * Unlocking a locked door/chest is worth one experience point.
1172 void do_cmd_open(void)
1180 if (p_ptr->special_defense & KATA_MUSOU)
1182 set_action(ACTION_NONE);
1185 #ifdef ALLOW_EASY_OPEN /* TNB */
1187 /* Option: Pick a direction */
1190 int num_doors, num_chests;
1192 /* Count closed doors (locked or jammed) */
1193 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1195 /* Count chests (locked) */
1196 num_chests = count_chests(&y, &x, FALSE);
1198 /* See if only one target */
1199 if (num_doors || num_chests)
1201 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1203 if (!too_many) command_dir = coords_to_dir(y, x);
1207 #endif /* ALLOW_EASY_OPEN -- TNB */
1209 /* Allow repeated command */
1212 /* Set repeat count */
1213 command_rep = command_arg - 1;
1215 /* Redraw the state */
1216 p_ptr->redraw |= (PR_STATE);
1218 /* Cancel the arg */
1222 /* Get a "repeated" direction */
1223 if (get_rep_dir(&dir, TRUE))
1228 /* Get requested location */
1232 /* Get requested grid */
1233 c_ptr = &cave[y][x];
1235 /* Feature code (applying "mimic" field) */
1236 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
1238 /* Check for chest */
1239 o_idx = chest_check(y, x);
1241 /* Nothing useful */
1242 if (!is_closed_door(feat) && !o_idx)
1246 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1248 msg_print("You see nothing there to open.");
1253 /* Monster in the way */
1254 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1261 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1263 msg_print("There is a monster in the way!");
1274 /* Open the chest */
1275 more = do_cmd_open_chest(y, x, o_idx);
1282 more = do_cmd_open_aux(y, x);
1286 /* Cancel repeat unless we may continue */
1287 if (!more) disturb(0, 0);
1293 * Perform the basic "close" command
1295 * Assume destination is an open/broken door
1297 * Assume there is no monster blocking the destination
1299 * Returns TRUE if repeated commands may continue
1301 static bool do_cmd_close_aux(int y, int x)
1309 /* Get grid and contents */
1310 c_ptr = &cave[y][x];
1312 /* Seeing true feature code (ignore mimic) */
1315 if (c_ptr->feat == FEAT_BROKEN)
1319 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1321 msg_print("The door appears to be broken.");
1327 else if (c_ptr->feat == FEAT_OPEN)
1329 /* Close the door */
1330 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1332 /* Update some things */
1333 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1336 sound(SOUND_SHUTDOOR);
1345 * Close an open door.
1347 void do_cmd_close(void)
1353 if (p_ptr->special_defense & KATA_MUSOU)
1355 set_action(ACTION_NONE);
1358 #ifdef ALLOW_EASY_OPEN /* TNB */
1360 /* Option: Pick a direction */
1363 /* Count open doors */
1364 if (count_dt(&y, &x, is_open, FALSE) == 1)
1366 command_dir = coords_to_dir(y, x);
1370 #endif /* ALLOW_EASY_OPEN -- TNB */
1372 /* Allow repeated command */
1375 /* Set repeat count */
1376 command_rep = command_arg - 1;
1378 /* Redraw the state */
1379 p_ptr->redraw |= (PR_STATE);
1381 /* Cancel the arg */
1385 /* Get a "repeated" direction */
1386 if (get_rep_dir(&dir,FALSE))
1391 /* Get requested location */
1395 /* Get grid and contents */
1396 c_ptr = &cave[y][x];
1398 /* Feature code (applying "mimic" field) */
1399 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
1401 /* Require open/broken door */
1402 if ((feat != FEAT_OPEN) && (feat != FEAT_BROKEN))
1406 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1408 msg_print("You see nothing there to close.");
1413 /* Monster in the way */
1414 else if (c_ptr->m_idx)
1421 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1423 msg_print("There is a monster in the way!");
1431 /* Close the door */
1434 /* Close the door */
1435 more = do_cmd_close_aux(y, x);
1439 /* Cancel repeat unless we may continue */
1440 if (!more) disturb(0, 0);
1445 * Determine if a given grid may be "tunneled"
1447 static bool do_cmd_tunnel_test(int y, int x)
1449 /* Must have knowledge */
1450 if (!(cave[y][x].info & (CAVE_MARK)))
1454 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1456 msg_print("You see nothing there.");
1464 /* Must be a wall/door/etc */
1465 if (cave_floor_bold(y, x))
1469 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1471 msg_print("You see nothing there to tunnel.");
1486 * Tunnel through wall. Assumes valid location.
1488 * Note that it is impossible to "extend" rooms past their
1489 * outer walls (which are actually part of the room).
1491 * This will, however, produce grids which are NOT illuminated
1492 * (or darkened) along with the rest of the room.
1494 static bool twall(int y, int x, byte feat)
1496 cave_type *c_ptr = &cave[y][x];
1498 /* Paranoia -- Require a wall or door or some such */
1499 if (cave_floor_bold(y, x)) return (FALSE);
1501 /* Forget the wall */
1502 c_ptr->info &= ~(CAVE_MARK);
1504 /* Remove the feature */
1505 cave_set_feat(y, x, feat);
1507 /* Update some things */
1508 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1517 * Perform the basic "tunnel" command
1519 * Assumes that the destination is a wall, a vein, a secret
1522 * Assumes that no monster is blocking the destination
1524 * Returns TRUE if repeated commands may continue
1526 static bool do_cmd_tunnel_aux(int y, int x)
1533 /* Verify legality */
1534 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1540 c_ptr = &cave[y][x];
1542 /* Feature code (applying "mimic" field) */
1543 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
1549 if ((feat >= FEAT_PERM_EXTRA) &&
1550 (feat <= FEAT_PERM_SOLID))
1553 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1555 msg_print("This seems to be permanent rock.");
1560 /* Map border (mimiccing Permanent wall) */
1561 else if ((c_ptr->feat >= FEAT_PERM_EXTRA &&
1562 c_ptr->feat <= FEAT_PERM_SOLID) ||
1563 c_ptr->feat == FEAT_MOUNTAIN)
1566 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1568 msg_print("You can't tunnel through that!");
1573 else if (feat == FEAT_TREES) /* -KMW- */
1576 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1579 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1581 msg_print("You have cleared away the trees.");
1583 chg_virtue(V_DILIGENCE, 1);
1584 chg_virtue(V_NATURE, -1);
1590 /* We may continue chopping */
1592 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1594 msg_print("You chop away at the tree.");
1599 /* Occasional Search XXX XXX */
1600 if (randint0(100) < 25) search();
1606 else if ((feat >= FEAT_WALL_EXTRA) &&
1607 (feat <= FEAT_WALL_SOLID))
1610 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1613 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1615 msg_print("You have finished the tunnel.");
1617 chg_virtue(V_DILIGENCE, 1);
1618 chg_virtue(V_NATURE, -1);
1624 /* We may continue tunelling */
1626 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1628 msg_print("You tunnel into the granite wall.");
1636 /* Quartz / Magma */
1637 else if ((feat >= FEAT_MAGMA) &&
1638 (feat <= FEAT_QUARTZ_K))
1644 /* Found gold (ignore mimic; maybe a hidden treasure) */
1645 if (c_ptr->feat >= FEAT_MAGMA_H &&
1646 c_ptr->feat <= FEAT_QUARTZ_K) gold = TRUE;
1648 /* Extract "quartz" flag XXX XXX XXX */
1649 if ((feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1654 okay = (p_ptr->skill_dig > 20 + randint0(800));
1660 okay = (p_ptr->skill_dig > 10 + randint0(400));
1664 if (okay && twall(y, x, floor_type[randint0(100)]))
1666 /* Found treasure */
1669 /* Place some gold */
1674 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1676 msg_print("You have found something!");
1686 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1688 msg_print("You have finished the tunnel.");
1690 chg_virtue(V_DILIGENCE, 1);
1691 chg_virtue(V_NATURE, -1);
1695 /* Failure (quartz) */
1698 /* Message, continue digging */
1700 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1702 msg_print("You tunnel into the quartz vein.");
1708 /* Failure (magma) */
1711 /* Message, continue digging */
1713 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1715 msg_print("You tunnel into the magma vein.");
1723 else if (feat == FEAT_RUBBLE)
1725 /* Remove the rubble */
1726 if ((p_ptr->skill_dig > randint0(200)) && twall(y, x, floor_type[randint0(100)]))
1730 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1732 msg_print("You have removed the rubble.");
1735 /* Hack -- place an object */
1736 if (randint0(100) < (15 - dun_level/2))
1738 /* Create a simple object */
1739 place_object(y, x, 0L);
1741 /* Observe new object */
1742 if (player_can_see_bold(y, x))
1745 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1747 msg_print("You have found something!");
1756 /* Message, keep digging */
1758 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1760 msg_print("You dig in the rubble.");
1771 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint1(100)]))
1774 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1776 msg_print("You have finished the tunnel.");
1784 /* We may continue tunelling */
1786 msg_print("¥É¥¢¤Ë·ê¤ò³«¤±¤Æ¤¤¤ë¡£");
1788 msg_print("You tunnel into the door.");
1795 if (is_hidden_door(c_ptr))
1797 /* Occasional Search XXX XXX */
1798 if (randint0(100) < 25) search();
1807 * Tunnels through "walls" (including rubble and closed doors)
1809 * Note that you must tunnel in order to hit invisible monsters
1810 * in walls, though moving into walls still takes a turn anyway.
1812 * Digging is very difficult without a "digger" weapon, but can be
1813 * accomplished by strong players using heavy weapons.
1815 void do_cmd_tunnel(void)
1825 if (p_ptr->special_defense & KATA_MUSOU)
1827 set_action(ACTION_NONE);
1830 /* Allow repeated command */
1833 /* Set repeat count */
1834 command_rep = command_arg - 1;
1836 /* Redraw the state */
1837 p_ptr->redraw |= (PR_STATE);
1839 /* Cancel the arg */
1843 /* Get a direction to tunnel, or Abort */
1844 if (get_rep_dir(&dir,FALSE))
1851 c_ptr = &cave[y][x];
1853 /* Feature code (applying "mimic" field) */
1854 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
1856 /* No tunnelling through doors */
1857 if (((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL)) ||
1858 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
1859 ((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
1860 (feat == FEAT_MUSEUM))
1864 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1866 msg_print("You cannot tunnel through doors.");
1871 /* No tunnelling through air */
1872 else if (cave_floor_grid(c_ptr) || ((feat >= FEAT_MINOR_GLYPH) &&
1873 (feat <= FEAT_PATTERN_XTRA2)))
1877 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1879 msg_print("You cannot tunnel through air.");
1884 /* No tunnelling through mountains */
1885 else if (feat == FEAT_MOUNTAIN)
1888 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1890 msg_print("You can't tunnel through that!");
1895 /* A monster is in the way */
1896 else if (c_ptr->m_idx)
1903 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1905 msg_print("There is a monster in the way!");
1916 /* Tunnel through walls */
1917 more = do_cmd_tunnel_aux(y, x);
1921 /* Cancel repetition unless we can continue */
1922 if (!more) disturb(0, 0);
1926 #ifdef ALLOW_EASY_OPEN /* TNB */
1931 * If there is a jammed/closed/locked door at the given location,
1932 * then attempt to unlock/open it. Return TRUE if an attempt was
1933 * made (successful or not), otherwise return FALSE.
1935 * The code here should be nearly identical to that in
1936 * do_cmd_open_test() and do_cmd_open_aux().
1938 bool easy_open_door(int y, int x)
1942 cave_type *c_ptr = &cave[y][x];
1944 /* Must be a closed door */
1945 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1946 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1953 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1957 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1959 msg_print("The door appears to be stuck.");
1965 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1968 i = p_ptr->skill_dis;
1970 /* Penalize some conditions */
1971 if (p_ptr->blind || no_lite()) i = i / 10;
1972 if (p_ptr->confused || p_ptr->image) i = i / 10;
1974 /* Extract the lock power */
1975 j = c_ptr->feat - FEAT_DOOR_HEAD;
1977 /* Extract the difficulty XXX XXX XXX */
1980 /* Always have a small chance of success */
1984 if (randint0(100) < j)
1988 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1990 msg_print("You have picked the lock.");
1995 cave_set_feat(y, x, FEAT_OPEN);
1997 /* Update some things */
1998 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
2001 sound(SOUND_OPENDOOR);
2011 if (flush_failure) flush();
2015 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2017 msg_print("You failed to pick the lock.");
2027 cave_set_feat(y, x, FEAT_OPEN);
2029 /* Update some things */
2030 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
2033 sound(SOUND_OPENDOOR);
2040 #endif /* ALLOW_EASY_OPEN -- TNB */
2044 * Perform the basic "disarm" command
2046 * Assume destination is a visible trap
2048 * Assume there is no monster blocking the destination
2050 * Returns TRUE if repeated commands may continue
2052 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2058 object_type *o_ptr = &o_list[o_idx];
2064 /* Get the "disarm" factor */
2065 i = p_ptr->skill_dis;
2067 /* Penalize some conditions */
2068 if (p_ptr->blind || no_lite()) i = i / 10;
2069 if (p_ptr->confused || p_ptr->image) i = i / 10;
2071 /* Extract the difficulty */
2072 j = i - o_ptr->pval;
2074 /* Always have a small chance of success */
2077 /* Must find the trap first. */
2078 if (!object_known_p(o_ptr))
2081 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2083 msg_print("I don't see any traps.");
2088 /* Already disarmed/unlocked */
2089 else if (o_ptr->pval <= 0)
2092 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2094 msg_print("The chest is not trapped.");
2099 /* No traps to find. */
2100 else if (!chest_traps[o_ptr->pval])
2103 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2105 msg_print("The chest is not trapped.");
2110 /* Success (get a lot of experience) */
2111 else if (randint0(100) < j)
2114 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2116 msg_print("You have disarmed the chest.");
2119 gain_exp(o_ptr->pval);
2120 o_ptr->pval = (0 - o_ptr->pval);
2123 /* Failure -- Keep trying */
2124 else if ((i > 5) && (randint1(i) > 5))
2126 /* We may keep trying */
2128 if (flush_failure) flush();
2130 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2132 msg_print("You failed to disarm the chest.");
2137 /* Failure -- Set off the trap */
2141 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2143 msg_print("You set off a trap!");
2147 chest_trap(y, x, o_idx);
2156 * Perform the basic "disarm" command
2158 * Assume destination is a visible trap
2160 * Assume there is no monster blocking the destination
2162 * Returns TRUE if repeated commands may continue
2164 #ifdef ALLOW_EASY_DISARM /* TNB */
2166 bool do_cmd_disarm_aux(int y, int x, int dir)
2168 #else /* ALLOW_EASY_DISARM -- TNB */
2170 static bool do_cmd_disarm_aux(int y, int x, int dir)
2172 #endif /* ALLOW_EASY_DISARM -- TNB */
2186 /* Get grid and contents */
2187 c_ptr = &cave[y][x];
2189 /* Access trap name */
2190 name = (f_name + f_info[c_ptr->feat].name);
2192 /* Get the "disarm" factor */
2193 i = p_ptr->skill_dis;
2195 /* Penalize some conditions */
2196 if (p_ptr->blind || no_lite()) i = i / 10;
2197 if (p_ptr->confused || p_ptr->image) i = i / 10;
2199 /* Variable power! */
2201 /* Extract trap "power" */
2202 switch (c_ptr->feat)
2204 case FEAT_TRAP_OPEN:
2205 case FEAT_TRAP_ARMAGEDDON:
2206 case FEAT_TRAP_PIRANHA:
2207 /* Special traps are very difficult to disarm */
2215 /* Extract the difficulty */
2218 /* Always have a small chance of success */
2222 if (randint0(100) < j)
2226 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2228 msg_format("You have disarmed the %s.", name);
2235 /* Forget the trap */
2236 c_ptr->info &= ~(CAVE_MARK);
2238 /* Remove the trap */
2239 cave_set_feat(y, x, floor_type[randint0(100)]);
2241 #ifdef ALLOW_EASY_DISARM /* TNB */
2243 /* Move the player onto the trap */
2244 move_player(dir, easy_disarm, FALSE);
2246 #else /* ALLOW_EASY_DISARM -- TNB */
2248 /* move the player onto the trap grid */
2249 move_player(dir, FALSE, FALSE);
2251 #endif /* ALLOW_EASY_DISARM -- TNB */
2254 /* Failure -- Keep trying */
2255 else if ((i > 5) && (randint1(i) > 5))
2258 if (flush_failure) flush();
2262 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2264 msg_format("You failed to disarm the %s.", name);
2268 /* We may keep trying */
2272 /* Failure -- Set off the trap */
2277 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2279 msg_format("You set off the %s!", name);
2283 #ifdef ALLOW_EASY_DISARM /* TNB */
2285 /* Move the player onto the trap */
2286 move_player(dir, easy_disarm, FALSE);
2288 #else /* ALLOW_EASY_DISARM -- TNB */
2290 /* Move the player onto the trap */
2291 move_player(dir, FALSE, FALSE);
2293 #endif /* ALLOW_EASY_DISARM -- TNB */
2302 * Disarms a trap, or chest
2304 void do_cmd_disarm(void)
2312 if (p_ptr->special_defense & KATA_MUSOU)
2314 set_action(ACTION_NONE);
2317 #ifdef ALLOW_EASY_DISARM /* TNB */
2319 /* Option: Pick a direction */
2322 int num_traps, num_chests;
2324 /* Count visible traps */
2325 num_traps = count_dt(&y, &x, is_trap, TRUE);
2327 /* Count chests (trapped) */
2328 num_chests = count_chests(&y, &x, TRUE);
2330 /* See if only one target */
2331 if (num_traps || num_chests)
2333 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2335 if (!too_many) command_dir = coords_to_dir(y, x);
2339 #endif /* ALLOW_EASY_DISARM -- TNB */
2341 /* Allow repeated command */
2344 /* Set repeat count */
2345 command_rep = command_arg - 1;
2347 /* Redraw the state */
2348 p_ptr->redraw |= (PR_STATE);
2350 /* Cancel the arg */
2354 /* Get a direction (or abort) */
2355 if (get_rep_dir(&dir,TRUE))
2364 /* Get grid and contents */
2365 c_ptr = &cave[y][x];
2367 /* Feature code (applying "mimic" field) */
2368 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
2370 /* Check for chests */
2371 o_idx = chest_check(y, x);
2374 if (!is_trap(feat) && !o_idx)
2378 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2380 msg_print("You see nothing there to disarm.");
2385 /* Monster in the way */
2386 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2390 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2392 msg_print("There is a monster in the way!");
2403 /* Disarm the chest */
2404 more = do_cmd_disarm_chest(y, x, o_idx);
2410 /* Disarm the trap */
2411 more = do_cmd_disarm_aux(y, x, dir);
2415 /* Cancel repeat unless told not to */
2416 if (!more) disturb(0, 0);
2421 * Perform the basic "bash" command
2423 * Assume destination is a closed/locked/jammed door
2425 * Assume there is no monster blocking the destination
2427 * Returns TRUE if repeated commands may continue
2429 static bool do_cmd_bash_aux(int y, int x, int dir)
2442 c_ptr = &cave[y][x];
2446 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2448 msg_print("You smash into the door!");
2452 /* Hack -- Bash power based on strength */
2453 /* (Ranges from 3 to 20 to 100 to 200) */
2454 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2456 /* Extract door power */
2457 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2459 /* Compare bash power to door power XXX XXX XXX */
2460 temp = (bash - (temp * 10));
2462 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2464 /* Hack -- always have a chance */
2465 if (temp < 1) temp = 1;
2467 /* Hack -- attempt to bash down the door */
2468 if (randint0(100) < temp)
2472 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2474 msg_print("The door crashes open!");
2478 /* Break down the door */
2479 if (randint0(100) < 50)
2481 cave_set_feat(y, x, FEAT_BROKEN);
2487 cave_set_feat(y, x, FEAT_OPEN);
2491 sound(SOUND_OPENDOOR);
2493 /* Hack -- Fall through the door */
2494 move_player(dir, FALSE, FALSE);
2496 /* Update some things */
2497 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2498 p_ptr->update |= (PU_DISTANCE);
2501 /* Saving throw against stun */
2502 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2507 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2509 msg_print("The door holds firm.");
2513 /* Allow repeated bashing */
2517 /* High dexterity yields coolness */
2522 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2524 msg_print("You are off-balance.");
2528 /* Hack -- Lose balance ala paralysis */
2529 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2538 * Bash open a door, success based on character strength
2540 * For a closed door, pval is positive if locked; negative if stuck.
2542 * For an open door, pval is positive for a broken door.
2544 * A closed door can be opened - harder if locked. Any door might be
2545 * bashed open (and thereby broken). Bashing a door is (potentially)
2546 * faster! You move into the door way. To open a stuck door, it must
2547 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2549 * Creatures can also open or bash doors, see elsewhere.
2551 void do_cmd_bash(void)
2560 if (p_ptr->special_defense & KATA_MUSOU)
2562 set_action(ACTION_NONE);
2565 /* Allow repeated command */
2568 /* Set repeat count */
2569 command_rep = command_arg - 1;
2571 /* Redraw the state */
2572 p_ptr->redraw |= (PR_STATE);
2574 /* Cancel the arg */
2578 /* Get a "repeated" direction */
2579 if (get_rep_dir(&dir,FALSE))
2588 c_ptr = &cave[y][x];
2590 /* Feature code (applying "mimic" field) */
2591 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
2593 /* Nothing useful */
2594 if (!((feat >= FEAT_DOOR_HEAD) &&
2595 (feat <= FEAT_DOOR_TAIL)))
2599 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2601 msg_print("You see nothing there to bash.");
2606 /* Monster in the way */
2607 else if (c_ptr->m_idx)
2614 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2616 msg_print("There is a monster in the way!");
2624 /* Bash a closed door */
2628 more = do_cmd_bash_aux(y, x, dir);
2632 /* Unless valid action taken, cancel bash */
2633 if (!more) disturb(0, 0);
2638 * Manipulate an adjacent grid in some way
2640 * Attack monsters, tunnel through walls, disarm traps, open doors.
2642 * Consider confusion XXX XXX XXX
2644 * This command must always take a turn, to prevent free detection
2645 * of invisible monsters.
2647 void do_cmd_alter(void)
2656 if (p_ptr->special_defense & KATA_MUSOU)
2658 set_action(ACTION_NONE);
2661 /* Allow repeated command */
2664 /* Set repeat count */
2665 command_rep = command_arg - 1;
2667 /* Redraw the state */
2668 p_ptr->redraw |= (PR_STATE);
2670 /* Cancel the arg */
2674 /* Get a direction */
2675 if (get_rep_dir(&dir,TRUE))
2684 c_ptr = &cave[y][x];
2686 /* Feature code (applying "mimic" field) */
2687 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
2692 /* Attack monsters */
2699 /* Tunnel through walls */
2700 else if (((feat >= FEAT_RUBBLE) &&
2701 (feat < FEAT_MINOR_GLYPH)) ||
2702 ((feat == FEAT_TREES) ||
2703 (feat == FEAT_MOUNTAIN)))
2705 more = do_cmd_tunnel_aux(y, x);
2708 else if (is_closed_door(feat))
2710 /* Bash jammed doors */
2711 if (feat >= FEAT_DOOR_HEAD + 0x08)
2713 more = do_cmd_bash_aux(y, x, dir);
2719 more = do_cmd_open_aux(y, x);
2723 /* Close open doors */
2724 else if ((feat == FEAT_OPEN) ||
2725 (feat == FEAT_BROKEN))
2727 more = do_cmd_close_aux(y, x);
2731 else if (is_trap(feat))
2733 more = do_cmd_disarm_aux(y, x, dir);
2741 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2743 msg_print("You attack the empty air.");
2749 /* Cancel repetition unless we can continue */
2750 if (!more) disturb(0, 0);
2755 * Find the index of some "spikes", if possible.
2757 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2759 static bool get_spike(int *ip)
2763 /* Check every item in the pack */
2764 for (i = 0; i < INVEN_PACK; i++)
2766 object_type *o_ptr = &inventory[i];
2768 /* Skip non-objects */
2769 if (!o_ptr->k_idx) continue;
2771 /* Check the "tval" code */
2772 if (o_ptr->tval == TV_SPIKE)
2774 /* Save the spike index */
2788 * Jam a closed door with a spike
2790 * This command may NOT be repeated
2792 void do_cmd_spike(void)
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))
2812 /* Get grid and contents */
2813 c_ptr = &cave[y][x];
2815 /* Feature code (applying "mimic" field) */
2816 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
2818 /* Require closed door */
2819 if (!((feat >= FEAT_DOOR_HEAD) &&
2820 (feat <= FEAT_DOOR_TAIL)))
2824 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2826 msg_print("You see nothing there to spike.");
2832 else if (!get_spike(&item))
2836 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2838 msg_print("You have no spikes!");
2843 /* Is a monster in the way? */
2844 else if (c_ptr->m_idx)
2851 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2853 msg_print("There is a monster in the way!");
2867 /* Successful jamming */
2869 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2871 msg_print("You jam the door with a spike.");
2875 /* Convert "locked" to "stuck" XXX XXX XXX */
2876 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2878 /* Add one spike to the door */
2879 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2881 /* Use up, and describe, a single spike, from the bottom */
2882 inven_item_increase(item, -1);
2883 inven_item_describe(item);
2884 inven_item_optimize(item);
2892 * Support code for the "Walk" and "Jump" commands
2894 void do_cmd_walk(int pickup)
2901 /* Allow repeated command */
2904 /* Set repeat count */
2905 command_rep = command_arg - 1;
2907 /* Redraw the state */
2908 p_ptr->redraw |= (PR_STATE);
2910 /* Cancel the arg */
2914 /* Get a "repeated" direction */
2915 if (get_rep_dir(&dir,FALSE))
2920 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2922 set_action(ACTION_NONE);
2925 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2926 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2927 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2929 /* Actually move the character */
2930 move_player(dir, pickup, FALSE);
2932 /* Allow more walking */
2936 /* Hack again -- Is there a special encounter ??? */
2937 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2939 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2942 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2944 /* Inform the player of his horrible fate :=) */
2946 msg_print("½±·â¤À¡ª");
2948 msg_print("You are ambushed !");
2951 /* Go into large wilderness view */
2952 p_ptr->wilderness_x = px;
2953 p_ptr->wilderness_y = py;
2954 p_ptr->oldpy = randint1(MAX_HGT-2);
2955 p_ptr->oldpx = randint1(MAX_WID-2);
2959 /* HACk -- set the encouter flag for the wilderness generation */
2960 generate_encounter = TRUE;
2964 /* Cancel repeat unless we may continue */
2965 if (!more) disturb(0, 0);
2973 void do_cmd_run(void)
2977 /* Hack -- no running when confused */
2978 if (p_ptr->confused)
2981 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2983 msg_print("You are too confused!");
2989 if (p_ptr->special_defense & KATA_MUSOU)
2991 set_action(ACTION_NONE);
2994 /* Get a "repeated" direction */
2995 if (get_rep_dir(&dir,FALSE))
2997 /* Hack -- Set the run counter */
2998 running = (command_arg ? command_arg : 1000);
3008 * Stay still. Search. Enter stores.
3009 * Pick up treasure if "pickup" is true.
3011 void do_cmd_stay(int pickup)
3013 cave_type *c_ptr = &cave[py][px];
3016 /* Allow repeated command */
3019 /* Set repeat count */
3020 command_rep = command_arg - 1;
3022 /* Redraw the state */
3023 p_ptr->redraw |= (PR_STATE);
3025 /* Cancel the arg */
3034 /* Spontaneous Searching */
3035 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3040 /* Continuous Searching */
3041 if (p_ptr->action == ACTION_SEARCH)
3047 /* Handle "objects" */
3051 /* Hack -- enter a store if we are on one */
3052 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3053 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3054 (c_ptr->feat == FEAT_MUSEUM))
3060 /* Hack -- enter store */
3061 command_new = SPECIAL_KEY_STORE;
3064 /* Hack -- enter a building if we are on one -KMW- */
3065 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3066 (c_ptr->feat <= FEAT_BLDG_TAIL))
3072 /* Hack -- enter building */
3073 command_new = SPECIAL_KEY_BUILDING;
3076 /* Exit a quest if reach the quest exit */
3077 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3079 int q_index = p_ptr->inside_quest;
3081 /* Was quest completed? */
3082 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3084 quest[q_index].status = QUEST_STATUS_COMPLETED;
3085 quest[q_index].complev = (byte)p_ptr->lev;
3087 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3089 msg_print("You accomplished your quest!");
3095 leave_quest_check();
3097 p_ptr->inside_quest = cave[py][px].special;
3102 /* Clear all saved floors */
3103 prepare_change_floor_mode(CFM_CLEAR_ALL);
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 !p_ptr->alter_reality)
3184 chg_virtue(V_DILIGENCE, -1);
3186 /* Save the rest code */
3187 resting = command_arg;
3188 p_ptr->action = ACTION_REST;
3190 /* Recalculate bonuses */
3191 p_ptr->update |= (PU_BONUS);
3193 /* Redraw the state */
3194 p_ptr->redraw |= (PR_STATE);
3205 * Determines the odds of an object breaking when thrown at a monster
3207 * Note that artifacts never break, see the "drop_near()" function.
3209 static int breakage_chance(object_type *o_ptr)
3211 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3213 /* Examine the item type */
3214 switch (o_ptr->tval)
3230 /* Sometimes break */
3235 return (20 - archer_bonus * 2);
3240 return (10 - archer_bonus);
3247 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3251 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3253 u32b flgs[TR_FLAG_SIZE];
3255 /* Extract the flags */
3256 object_flags(o_ptr, flgs);
3258 /* Some "weapons" and "ammo" do extra damage */
3259 switch (o_ptr->tval)
3266 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3267 (r_ptr->flags3 & RF3_ANIMAL))
3269 if (m_ptr->ml && is_original_ap(m_ptr))
3271 r_ptr->r_flags3 |= RF3_ANIMAL;
3274 if (mult < 17) mult = 17;
3278 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3279 (r_ptr->flags3 & RF3_ANIMAL))
3281 if (m_ptr->ml && is_original_ap(m_ptr))
3283 r_ptr->r_flags3 |= RF3_ANIMAL;
3286 if (mult < 27) mult = 27;
3290 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3291 (r_ptr->flags3 & RF3_EVIL))
3293 if (m_ptr->ml && is_original_ap(m_ptr))
3295 r_ptr->r_flags3 |= RF3_EVIL;
3298 if (mult < 15) mult = 15;
3302 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3303 (r_ptr->flags3 & RF3_EVIL))
3305 if (m_ptr->ml && is_original_ap(m_ptr))
3307 r_ptr->r_flags3 |= RF3_EVIL;
3310 if (mult < 25) mult = 25;
3314 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3315 (r_ptr->flags2 & RF2_HUMAN))
3317 if (m_ptr->ml && is_original_ap(m_ptr))
3319 r_ptr->r_flags2 |= RF2_HUMAN;
3322 if (mult < 17) mult = 17;
3326 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3327 (r_ptr->flags2 & RF2_HUMAN))
3329 if (m_ptr->ml && is_original_ap(m_ptr))
3331 r_ptr->r_flags2 |= RF2_HUMAN;
3334 if (mult < 27) mult = 27;
3338 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3339 (r_ptr->flags3 & RF3_UNDEAD))
3341 if (m_ptr->ml && is_original_ap(m_ptr))
3343 r_ptr->r_flags3 |= RF3_UNDEAD;
3346 if (mult < 20) mult = 20;
3350 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3351 (r_ptr->flags3 & RF3_UNDEAD))
3353 if (m_ptr->ml && is_original_ap(m_ptr))
3355 r_ptr->r_flags3 |= RF3_UNDEAD;
3358 if (mult < 30) mult = 30;
3362 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3363 (r_ptr->flags3 & RF3_DEMON))
3365 if (m_ptr->ml && is_original_ap(m_ptr))
3367 r_ptr->r_flags3 |= RF3_DEMON;
3370 if (mult < 20) mult = 20;
3374 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3375 (r_ptr->flags3 & RF3_DEMON))
3377 if (m_ptr->ml && is_original_ap(m_ptr))
3379 r_ptr->r_flags3 |= RF3_DEMON;
3382 if (mult < 30) mult = 30;
3386 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3387 (r_ptr->flags3 & RF3_ORC))
3389 if (m_ptr->ml && is_original_ap(m_ptr))
3391 r_ptr->r_flags3 |= RF3_ORC;
3394 if (mult < 20) mult = 20;
3398 if ((have_flag(flgs, TR_KILL_ORC)) &&
3399 (r_ptr->flags3 & RF3_ORC))
3401 if (m_ptr->ml && is_original_ap(m_ptr))
3403 r_ptr->r_flags3 |= RF3_ORC;
3406 if (mult < 30) mult = 30;
3410 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3411 (r_ptr->flags3 & RF3_TROLL))
3413 if (m_ptr->ml && is_original_ap(m_ptr))
3415 r_ptr->r_flags3 |= RF3_TROLL;
3418 if (mult < 20) mult = 20;
3422 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3423 (r_ptr->flags3 & RF3_TROLL))
3425 if (m_ptr->ml && is_original_ap(m_ptr))
3427 r_ptr->r_flags3 |= RF3_TROLL;
3430 if (mult < 30) mult = 30;
3434 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3435 (r_ptr->flags3 & RF3_GIANT))
3437 if (m_ptr->ml && is_original_ap(m_ptr))
3439 r_ptr->r_flags3 |= RF3_GIANT;
3442 if (mult < 20) mult = 20;
3446 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3447 (r_ptr->flags3 & RF3_GIANT))
3449 if (m_ptr->ml && is_original_ap(m_ptr))
3451 r_ptr->r_flags3 |= RF3_GIANT;
3454 if (mult < 30) mult = 30;
3458 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3459 (r_ptr->flags3 & RF3_DRAGON))
3461 if (m_ptr->ml && is_original_ap(m_ptr))
3463 r_ptr->r_flags3 |= RF3_DRAGON;
3466 if (mult < 20) mult = 20;
3469 /* Execute Dragon */
3470 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3471 (r_ptr->flags3 & RF3_DRAGON))
3473 if (m_ptr->ml && is_original_ap(m_ptr))
3475 r_ptr->r_flags3 |= RF3_DRAGON;
3478 if (mult < 30) mult = 30;
3480 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3481 (m_ptr->r_idx == MON_SMAUG) &&
3482 (inventory[INVEN_BOW].name1 == ART_BARD))
3487 if (have_flag(flgs, TR_BRAND_ACID))
3489 /* Notice immunity */
3490 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3492 if (m_ptr->ml && is_original_ap(m_ptr))
3494 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3498 /* Otherwise, take the damage */
3501 if (mult < 17) mult = 17;
3506 if (have_flag(flgs, TR_BRAND_ELEC))
3508 /* Notice immunity */
3509 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3511 if (m_ptr->ml && is_original_ap(m_ptr))
3513 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3517 /* Otherwise, take the damage */
3520 if (mult < 17) mult = 17;
3525 if (have_flag(flgs, TR_BRAND_FIRE))
3527 /* Notice immunity */
3528 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3530 if (m_ptr->ml && is_original_ap(m_ptr))
3532 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3536 /* Otherwise, take the damage */
3539 if (r_ptr->flags3 & RF3_HURT_FIRE)
3541 if (mult < 25) mult = 25;
3542 if (m_ptr->ml && is_original_ap(m_ptr))
3544 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3547 else if (mult < 17) mult = 17;
3552 if (have_flag(flgs, TR_BRAND_COLD))
3554 /* Notice immunity */
3555 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3557 if (m_ptr->ml && is_original_ap(m_ptr))
3559 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3562 /* Otherwise, take the damage */
3565 if (r_ptr->flags3 & RF3_HURT_COLD)
3567 if (mult < 25) mult = 25;
3568 if (m_ptr->ml && is_original_ap(m_ptr))
3570 r_ptr->r_flags3 |= RF3_HURT_COLD;
3573 else if (mult < 17) mult = 17;
3577 /* Brand (Poison) */
3578 if (have_flag(flgs, TR_BRAND_POIS))
3580 /* Notice immunity */
3581 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3583 if (m_ptr->ml && is_original_ap(m_ptr))
3585 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3589 /* Otherwise, take the damage */
3592 if (mult < 17) mult = 17;
3596 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3598 p_ptr->csp -= (1+(p_ptr->msp / 30));
3599 p_ptr->redraw |= (PR_MANA);
3600 mult = mult * 5 / 2;
3606 /* Return the total damage */
3607 return (tdam * mult / 10);
3612 * Fire an object from the pack or floor.
3614 * You may only fire items that "match" your missile launcher.
3616 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3618 * See "calc_bonuses()" for more calculations and such.
3620 * Note that "firing" a missile is MUCH better than "throwing" it.
3622 * Note: "unseen" monsters are very hard to hit.
3624 * Objects are more likely to break if they "attempt" to hit a monster.
3626 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3628 * The "extra shot" code works by decreasing the amount of energy
3629 * required to make each shot, spreading the shots out over time.
3631 * Note that when firing missiles, the launcher multiplier is applied
3632 * after all the bonuses are added in, making multipliers very useful.
3634 * Note that Bows of "Extra Might" get extra range and an extra bonus
3635 * for the damage multiplier.
3637 * Note that Bows of "Extra Shots" give an extra shot.
3639 void do_cmd_fire_aux(int item, object_type *j_ptr)
3642 int j, y, x, ny, nx, ty, tx;
3643 int tdam, tdis, thits, tmul;
3645 int cur_dis, visible;
3652 bool hit_body = FALSE;
3654 char o_name[MAX_NLEN];
3656 int msec = delay_factor * delay_factor * delay_factor;
3659 bool stick_to = FALSE;
3661 /* Access the item (if in the pack) */
3664 o_ptr = &inventory[item];
3668 o_ptr = &o_list[0 - item];
3671 /* Describe the object */
3672 object_desc(o_name, o_ptr, FALSE, 3);
3675 /* Use the proper number of shots */
3676 thits = p_ptr->num_fire;
3678 /* Use a base distance */
3681 /* Base damage from thrown object plus launcher bonus */
3682 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3684 /* Actually "fire" the object */
3685 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3686 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3687 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3689 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3691 energy_use = bow_energy(j_ptr->sval);
3692 tmul = bow_tmul(j_ptr->sval);
3694 /* Get extra "power" from "extra might" */
3695 if (p_ptr->xtra_might) tmul++;
3697 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3699 /* Boost the damage */
3704 tdis = 10 + tmul/40;
3705 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3708 project_length = tdis + 1;
3710 /* Get a direction (or cancel) */
3711 if (!get_aim_dir(&dir))
3715 /* need not to reset project_length (already did)*/
3720 /* Get local object */
3723 /* Obtain a local object */
3724 object_copy(q_ptr, o_ptr);
3729 /* Reduce and describe inventory */
3732 inven_item_increase(item, -1);
3733 inven_item_describe(item);
3734 inven_item_optimize(item);
3737 /* Reduce and describe floor item */
3740 floor_item_increase(0 - item, -1);
3741 floor_item_optimize(0 - item);
3749 /* Take a (partial) turn */
3750 energy_use = (energy_use / thits);
3753 /* Start at the player */
3757 /* Predict the "target" location */
3758 tx = px + 99 * ddx[dir];
3759 ty = py + 99 * ddy[dir];
3761 /* Check for "target request" */
3762 if ((dir == 5) && target_okay())
3768 project_length = 0; /* reset to default */
3770 /* Hack -- Handle stuff */
3774 /* Travel until stopped */
3775 for (cur_dis = 0; cur_dis <= tdis; )
3777 /* Hack -- Stop at the target */
3778 if ((y == ty) && (x == tx)) break;
3780 /* Calculate the new location (see "project()") */
3783 mmove2(&ny, &nx, py, px, ty, tx);
3785 /* Stopped by walls/doors */
3786 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3788 /* Advance the distance */
3792 /* The player can see the (on screen) missile */
3793 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3795 char c = object_char(q_ptr);
3796 byte a = object_attr(q_ptr);
3798 /* Draw, Hilite, Fresh, Pause, Erase */
3799 print_rel(c, a, ny, nx);
3800 move_cursor_relative(ny, nx);
3802 Term_xtra(TERM_XTRA_DELAY, msec);
3807 /* The player cannot see the missile */
3810 /* Pause anyway, for consistancy */
3811 Term_xtra(TERM_XTRA_DELAY, msec);
3814 /* Save the new location */
3819 /* Monster here, Try to hit it */
3820 if (cave[y][x].m_idx)
3822 cave_type *c_ptr = &cave[y][x];
3824 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3825 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3827 /* Check the visibility */
3828 visible = m_ptr->ml;
3830 /* Note the collision */
3835 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3836 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3839 if ((r_ptr->level + 10) > p_ptr->lev)
3841 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3842 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3845 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3846 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3847 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3848 else if (p_ptr->lev > 34) amount = 2;
3849 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3850 p_ptr->update |= (PU_BONUS);
3856 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3857 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3860 p_ptr->skill_exp[GINOU_RIDING] += 1;
3861 p_ptr->update |= (PU_BONUS);
3865 /* Did we hit it (penalize range) */
3866 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3870 /* Handle unseen monster */
3873 /* Invisible monster */
3875 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3877 msg_format("The %s finds a mark.", o_name);
3882 /* Handle visible monster */
3887 /* Get "the monster" or "it" */
3888 monster_desc(m_name, m_ptr, 0);
3892 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3894 msg_format("The %s hits %s.", o_name, m_name);
3898 /* Hack -- Track this monster race */
3899 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3901 /* Hack -- Track this monster */
3902 if (m_ptr->ml) health_track(c_ptr->m_idx);
3905 /* Apply special damage XXX XXX XXX */
3906 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3907 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3909 /* No negative damage */
3910 if (tdam < 0) tdam = 0;
3912 /* Modify the damage */
3913 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3915 /* Complex message */
3916 if (p_ptr->wizard || cheat_xtra)
3919 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3922 msg_format("You do %d (out of %d) damage.",
3928 /* Hit the monster, check for death */
3929 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3942 monster_desc(m_name, m_ptr, 0);
3946 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3948 msg_format("%^s have stuck into %s!",o_name, m_name);
3953 message_pain(c_ptr->m_idx, tdam);
3955 /* Anger the monster */
3956 if (tdam > 0) anger_monster(m_ptr);
3959 if (fear && m_ptr->ml)
3966 /* Get the monster name (or "it") */
3967 monster_desc(m_name, m_ptr, 0);
3971 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3973 msg_format("%^s flees in terror!", m_name);
3977 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3979 set_target(m_ptr, py, px);
3989 /* Chance of breakage (during attacks) */
3990 j = (hit_body ? breakage_chance(q_ptr) : 0);
3994 int m_idx = cave[y][x].m_idx;
3995 monster_type *m_ptr = &m_list[m_idx];
3996 int o_idx = o_pop();
4001 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
4003 msg_format("The %s have gone to somewhere.", o_name);
4007 a_info[j_ptr->name1].cur_num = 0;
4012 o_ptr = &o_list[ o_idx ];
4013 object_copy(o_ptr, q_ptr);
4018 /* Forget location */
4019 o_ptr->iy = o_ptr->ix = 0;
4021 /* Memorize monster */
4022 o_ptr->held_m_idx = m_idx;
4025 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4028 m_ptr->hold_o_idx = o_idx;
4032 /* Drop (or break) near that location */
4033 (void)drop_near(q_ptr, j, y, x);
4037 void do_cmd_fire(void)
4043 /* Get the "bow" (if any) */
4044 j_ptr = &inventory[INVEN_BOW];
4046 /* Require a launcher */
4050 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4052 msg_print("You have nothing to fire with.");
4058 if (j_ptr->sval == SV_CRIMSON)
4061 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4063 msg_print("Do activate.");
4070 if (p_ptr->special_defense & KATA_MUSOU)
4072 set_action(ACTION_NONE);
4075 /* Require proper missile */
4076 item_tester_tval = p_ptr->tval_ammo;
4080 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4081 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4083 q = "Fire which item? ";
4084 s = "You have nothing to fire.";
4087 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4094 do_cmd_fire_aux(item, j_ptr);
4098 static bool item_tester_hook_boomerang(object_type *o_ptr)
4100 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4108 * Throw an object from the pack or floor.
4110 * Note: "unseen" monsters are very hard to hit.
4112 * Should throwing a weapon do full damage? Should it allow the magic
4113 * to hit bonus of the weapon to have an effect? Should it ever cause
4114 * the item to be destroyed? Should it do any damage at all?
4116 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4119 int i, j, y, x, ty, tx;
4121 int chance, tdam, tdis;
4123 int cur_dis, visible;
4130 bool hit_body = FALSE;
4131 bool hit_wall = FALSE;
4132 bool equiped_item = FALSE;
4133 bool return_when_thrown = FALSE;
4135 char o_name[MAX_NLEN];
4137 int msec = delay_factor * delay_factor * delay_factor;
4139 u32b flgs[TR_FLAG_SIZE];
4141 bool come_back = FALSE;
4142 bool do_drop = TRUE;
4145 if (p_ptr->special_defense & KATA_MUSOU)
4147 set_action(ACTION_NONE);
4156 if (buki_motteruka(INVEN_LARM))
4158 item_tester_hook = item_tester_hook_boomerang;
4160 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4161 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4163 q = "Throw which item? ";
4164 s = "You have nothing to throw.";
4167 if (!get_item(&item, q, s, (USE_EQUIP)))
4182 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4183 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4185 q = "Throw which item? ";
4186 s = "You have nothing to throw.";
4189 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4196 /* Access the item (if in the pack) */
4199 o_ptr = &inventory[item];
4203 o_ptr = &o_list[0 - item];
4207 /* Item is cursed */
4208 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4212 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4214 msg_print("Hmmm, it seems to be cursed.");
4221 if (p_ptr->inside_arena && !boomerang)
4223 if (o_ptr->tval != TV_SPIKE)
4226 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4228 msg_print("You're in the arena now. This is hand-to-hand!");
4237 /* Get local object */
4240 /* Obtain a local object */
4241 object_copy(q_ptr, o_ptr);
4243 /* Extract the thrown object's flags. */
4244 object_flags(q_ptr, flgs);
4246 /* Distribute the charges of rods/wands between the stacks */
4247 distribute_charges(o_ptr, q_ptr, 1);
4253 object_desc(o_name, q_ptr, FALSE, 3);
4255 if (p_ptr->mighty_throw) mult += 3;
4257 /* Extract a "distance multiplier" */
4258 /* Changed for 'launcher' mutation */
4259 mul = 10 + 2 * (mult - 1);
4261 /* Enforce a minimum "weight" of one pound */
4262 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4263 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4265 /* Hack -- Distance -- Reward strength, penalize weight */
4266 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4268 /* Max distance of 10-18 */
4269 if (tdis > mul) tdis = mul;
4273 ty = randint0(101)-50+py;
4274 tx = randint0(101)-50+px;
4278 project_length = tdis + 1;
4280 /* Get a direction (or cancel) */
4281 if (!get_aim_dir(&dir)) return FALSE;
4283 /* Predict the "target" location */
4284 tx = px + 99 * ddx[dir];
4285 ty = py + 99 * ddy[dir];
4287 /* Check for "target request" */
4288 if ((dir == 5) && target_okay())
4294 project_length = 0; /* reset to default */
4297 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4298 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4299 return_when_thrown = TRUE;
4301 /* Reduce and describe inventory */
4304 inven_item_increase(item, -1);
4305 if (!return_when_thrown)
4306 inven_item_describe(item);
4307 inven_item_optimize(item);
4310 /* Reduce and describe floor item */
4313 floor_item_increase(0 - item, -1);
4314 floor_item_optimize(0 - item);
4316 if (item >= INVEN_RARM)
4318 equiped_item = TRUE;
4319 p_ptr->redraw |= (PR_EQUIPPY);
4325 /* Rogue and Ninja gets bonus */
4326 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4327 energy_use -= p_ptr->lev;
4329 /* Start at the player */
4334 /* Hack -- Handle stuff */
4337 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4338 else shuriken = FALSE;
4340 /* Chance of hitting */
4341 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4342 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4343 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4345 if (shuriken) chance *= 2;
4347 /* Travel until stopped */
4348 for (cur_dis = 0; cur_dis <= tdis; )
4350 /* Hack -- Stop at the target */
4351 if ((y == ty) && (x == tx)) break;
4353 /* Calculate the new location (see "project()") */
4356 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4358 /* Stopped by walls/doors */
4359 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4365 /* Advance the distance */
4368 /* The player can see the (on screen) missile */
4369 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4371 char c = object_char(q_ptr);
4372 byte a = object_attr(q_ptr);
4374 /* Draw, Hilite, Fresh, Pause, Erase */
4375 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4376 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4378 Term_xtra(TERM_XTRA_DELAY, msec);
4379 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4383 /* The player cannot see the missile */
4386 /* Pause anyway, for consistancy */
4387 Term_xtra(TERM_XTRA_DELAY, msec);
4390 /* Save the new location */
4395 /* Monster here, Try to hit it */
4396 if (cave[y][x].m_idx)
4398 cave_type *c_ptr = &cave[y][x];
4400 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4401 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4403 /* Check the visibility */
4404 visible = m_ptr->ml;
4406 /* Note the collision */
4409 /* Did we hit it (penalize range) */
4410 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4414 /* Handle unseen monster */
4417 /* Invisible monster */
4419 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4421 msg_format("The %s finds a mark.", o_name);
4426 /* Handle visible monster */
4431 /* Get "the monster" or "it" */
4432 monster_desc(m_name, m_ptr, 0);
4436 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4438 msg_format("The %s hits %s.", o_name, m_name);
4442 /* Hack -- Track this monster race */
4443 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4445 /* Hack -- Track this monster */
4446 if (m_ptr->ml) health_track(c_ptr->m_idx);
4449 /* Hack -- Base damage from thrown object */
4450 tdam = damroll(q_ptr->dd, q_ptr->ds);
4451 /* Apply special damage XXX XXX XXX */
4452 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4453 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4454 if (q_ptr->to_d > 0)
4455 tdam += q_ptr->to_d;
4457 tdam += -q_ptr->to_d;
4461 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4462 tdam += p_ptr->to_d_m;
4464 else if (have_flag(flgs, TR_THROW))
4467 tdam += p_ptr->to_d_m;
4475 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4478 /* No negative damage */
4479 if (tdam < 0) tdam = 0;
4481 /* Modify the damage */
4482 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4484 /* Complex message */
4488 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4491 msg_format("You do %d (out of %d) damage.",
4497 /* Hit the monster, check for death */
4498 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4507 message_pain(c_ptr->m_idx, tdam);
4509 /* Anger the monster */
4510 if ((tdam > 0) && !object_is_potion(q_ptr))
4511 anger_monster(m_ptr);
4514 if (fear && m_ptr->ml)
4521 /* Get the monster name (or "it") */
4522 monster_desc(m_name, m_ptr, 0);
4526 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4528 msg_format("%^s flees in terror!", m_name);
4540 /* Chance of breakage (during attacks) */
4541 j = (hit_body ? breakage_chance(q_ptr) : 0);
4543 /* Figurines transform */
4544 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4548 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4549 !(cursed_p(q_ptr)) ? PM_FORCE_PET : 0L)))
4551 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4553 msg_print("The Figurine writhes and then shatters.");
4556 else if (cursed_p(q_ptr))
4558 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4560 msg_print("You have a bad feeling about this.");
4566 /* Potions smash open */
4567 if (object_is_potion(q_ptr))
4569 if (hit_body || hit_wall || (randint1(100) < j))
4573 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4575 msg_format("The %s shatters!", o_name);
4579 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4581 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4583 /* ToDo (Robert): fix the invulnerability */
4584 if (cave[y][x].m_idx &&
4585 is_friendly(&m_list[cave[y][x].m_idx]) &&
4589 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4591 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4593 msg_format("%^s gets angry!", m_name);
4596 set_hostile(&m_list[cave[y][x].m_idx]);
4607 if (return_when_thrown)
4609 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4610 char o2_name[MAX_NLEN];
4611 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4614 if (boomerang) back_chance += 4+randint1(5);
4615 if (super_boomerang) back_chance += 100;
4616 object_desc(o2_name, q_ptr, FALSE, 0);
4618 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4620 for (i = cur_dis-1;i>0;i--)
4622 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4624 char c = object_char(q_ptr);
4625 byte a = object_attr(q_ptr);
4627 /* Draw, Hilite, Fresh, Pause, Erase */
4628 print_rel(c, a, ny[i], nx[i]);
4629 move_cursor_relative(ny[i], nx[i]);
4631 Term_xtra(TERM_XTRA_DELAY, msec);
4632 lite_spot(ny[i], nx[i]);
4637 /* Pause anyway, for consistancy */
4638 Term_xtra(TERM_XTRA_DELAY, msec);
4641 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4644 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4646 msg_format("%s comes back to you.", o2_name);
4655 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4657 msg_format("%s backs, but you can't catch!", o2_name);
4663 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4665 msg_format("%s comes back.", o2_name);
4675 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4677 msg_format("%s doesn't back!", o2_name);
4684 if (item == INVEN_RARM || item == INVEN_LARM)
4686 /* Access the wield slot */
4687 o_ptr = &inventory[item];
4689 /* Wear the new stuff */
4690 object_copy(o_ptr, q_ptr);
4692 /* Increase the weight */
4693 p_ptr->total_weight += q_ptr->weight;
4695 /* Increment the equip counter by hand */
4698 /* Recalculate bonuses */
4699 p_ptr->update |= (PU_BONUS);
4701 /* Recalculate torch */
4702 p_ptr->update |= (PU_TORCH);
4704 /* Recalculate mana XXX */
4705 p_ptr->update |= (PU_MANA);
4708 p_ptr->window |= (PW_EQUIP);
4716 else if (equiped_item)
4722 /* Drop (or break) near that location */
4723 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4730 * Throw an object from the pack or floor.
4732 void do_cmd_throw(void)
4734 do_cmd_throw_aux(1, FALSE, 0);