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.");
265 if (ironman_downward && (c_ptr->special != DUNGEON_ANGBAND))
268 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
270 msg_print("The entrance of this dungeon is closed!");
274 if (!max_dlv[c_ptr->special])
277 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[c_ptr->special].name, d_info[c_ptr->special].mindepth);
278 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
280 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);
281 if (!get_check("Do you really get in this dungeon? ")) return;
285 /* Save old player position */
288 dungeon_type = (byte)c_ptr->special;
291 /* Hack -- take a turn */
294 if (autosave_l) do_cmd_save_game(TRUE);
297 if (c_ptr->feat == FEAT_MORE_MORE) down_num += 2;
303 /* Enter the dungeon just now */
304 p_ptr->enter_dungeon = TRUE;
305 down_num = d_info[c_ptr->special].mindepth;
311 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
312 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
314 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fell through a trap door");
315 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed down the stairs to");
322 msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
324 msg_print("You deliberately jump through the trap door.");
330 if(c_ptr->feat == FEAT_ENTRANCE)
333 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
335 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
341 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
342 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
344 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
346 msg_print("You enter a maze of down staircases.");
353 p_ptr->leaving = TRUE;
357 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
361 if (c_ptr->feat == FEAT_MORE_MORE)
363 /* Create a way back */
364 prepare_change_floor_mode(CFM_DOWN | CFM_SHAFT);
368 /* Create a way back */
369 prepare_change_floor_mode(CFM_DOWN);
378 * Simple command to "search" for one turn
380 void do_cmd_search(void)
382 /* Allow repeated command */
385 /* Set repeat count */
386 command_rep = command_arg - 1;
388 /* Redraw the state */
389 p_ptr->redraw |= (PR_STATE);
404 * Determine if a grid contains a chest
406 static s16b chest_check(int y, int x)
408 cave_type *c_ptr = &cave[y][x];
410 s16b this_o_idx, next_o_idx = 0;
413 /* Scan all objects in the grid */
414 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
419 o_ptr = &o_list[this_o_idx];
421 /* Acquire next object */
422 next_o_idx = o_ptr->next_o_idx;
424 /* Skip unknown chests XXX XXX */
425 /* if (!o_ptr->marked) continue; */
427 /* Check for chest */
428 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
437 * Allocates objects upon opening a chest -BEN-
439 * Disperse treasures from the given chest, centered at (x,y).
441 * Small chests often contain "gold", while Large chests always contain
442 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
443 * and Steel chests contain 6 items. The "value" of the items in a
444 * chest is based on the "power" of the chest, which is in turn based
445 * on the level on which the chest is generated.
447 static void chest_death(bool scatter, int y, int x, s16b o_idx)
457 object_type *o_ptr = &o_list[o_idx];
460 /* Small chests often hold "gold" */
461 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
463 /* Determine how much to drop (see above) */
464 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
466 if (o_ptr->sval == SV_CHEST_KANDUME)
471 object_level = o_ptr->xtra3;
475 /* Determine the "value" of the items */
476 object_level = ABS(o_ptr->pval) + 10;
479 /* Zero pval means empty chest */
480 if (!o_ptr->pval) number = 0;
482 /* Opening a chest */
483 opening_chest = TRUE;
485 /* Drop some objects (non-chests) */
486 for (; number > 0; --number)
488 /* Get local object */
491 /* Wipe the object */
494 /* Small chests often drop gold */
495 if (small && (randint0(100) < 25))
498 if (!make_gold(q_ptr)) continue;
501 /* Otherwise drop an item */
504 /* Make a good object */
505 if (!make_object(q_ptr, mode)) continue;
508 /* If chest scatters its contents, pick any floor square. */
512 for (i = 0; i < 200; i++)
514 /* Pick a totally random spot. */
515 y = randint0(MAX_HGT);
516 x = randint0(MAX_WID);
518 /* Must be an empty floor. */
519 if (!cave_empty_bold(y, x)) continue;
521 /* Place the object there. */
522 drop_near(q_ptr, -1, y, x);
528 /* Normally, drop object near the chest. */
529 else drop_near(q_ptr, -1, y, x);
532 /* Reset the object level */
533 object_level = base_level;
535 /* No longer opening a chest */
536 opening_chest = FALSE;
547 * Chests have traps too.
549 * Exploding chest destroys contents (and traps).
550 * Note that the chest itself is never destroyed.
552 static void chest_trap(int y, int x, s16b o_idx)
556 object_type *o_ptr = &o_list[o_idx];
558 int mon_level = o_ptr->xtra3;
560 /* Ignore disarmed chests */
561 if (o_ptr->pval <= 0) return;
563 /* Obtain the traps */
564 trap = chest_traps[o_ptr->pval];
567 if (trap & (CHEST_LOSE_STR))
570 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
571 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
573 msg_print("A small needle has pricked you!");
574 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
577 (void)do_dec_stat(A_STR);
580 /* Lose constitution */
581 if (trap & (CHEST_LOSE_CON))
584 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
585 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
587 msg_print("A small needle has pricked you!");
588 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
591 (void)do_dec_stat(A_CON);
595 if (trap & (CHEST_POISON))
598 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
600 msg_print("A puff of green gas surrounds you!");
603 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
605 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
610 if (trap & (CHEST_PARALYZE))
613 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
615 msg_print("A puff of yellow gas surrounds you!");
619 if (!p_ptr->free_act)
621 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
625 /* Summon monsters */
626 if (trap & (CHEST_SUMMON))
628 int num = 2 + randint1(3);
630 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
632 msg_print("You are enveloped in a cloud of smoke!");
636 for (i = 0; i < num; i++)
638 if (randint1(100)<dun_level)
639 activate_hi_summon(py, px, FALSE);
641 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
645 /* Elemental summon. */
646 if (trap & (CHEST_E_SUMMON))
649 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
651 msg_print("Elemental beings appear to protect their treasures!");
653 for (i = 0; i < randint1(3) + 5; i++)
655 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
659 /* Force clouds, then summon birds. */
660 if (trap & (CHEST_BIRD_STORM))
663 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
665 msg_print("A storm of birds swirls around you!");
668 for (i = 0; i < randint1(3) + 3; i++)
669 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
671 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
673 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
677 /* Various colorful summonings. */
678 if (trap & (CHEST_H_SUMMON))
684 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
686 msg_print("Demons materialize in clouds of fire and brimstone!");
689 for (i = 0; i < randint1(3) + 2; i++)
691 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
692 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
696 /* Summon dragons. */
700 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
702 msg_print("Draconic forms loom out of the darkness!");
705 for (i = 0; i < randint1(3) + 2; i++)
707 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
711 /* Summon hybrids. */
715 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
717 msg_print("Creatures strange and twisted assault you!");
720 for (i = 0; i < randint1(5) + 3; i++)
722 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
726 /* Summon vortices (scattered) */
730 msg_print("±²´¬¤«¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
732 msg_print("Vortices coalesce and wreak destruction!");
735 for (i = 0; i < randint1(3) + 2; i++)
737 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
743 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
745 /* Determine how many nasty tricks can be played. */
746 int nasty_tricks_count = 4 + randint0(3);
750 msg_print("¶²¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
752 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
755 /* This is gonna hurt... */
756 for (; nasty_tricks_count > 0; nasty_tricks_count--)
758 /* ...but a high saving throw does help a little. */
759 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
762 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
764 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
766 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
769 if (!p_ptr->free_act)
770 (void)set_paralyzed(p_ptr->paralyzed + 2 +
773 (void)set_stun(p_ptr->stun + 10 +
776 else if (one_in_(3)) apply_disenchant(0);
779 (void)do_dec_stat(A_STR);
780 (void)do_dec_stat(A_DEX);
781 (void)do_dec_stat(A_CON);
782 (void)do_dec_stat(A_INT);
783 (void)do_dec_stat(A_WIS);
784 (void)do_dec_stat(A_CHR);
786 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
791 /* Aggravate monsters. */
792 if (trap & (CHEST_ALARM))
795 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
797 msg_print("An alarm sounds!");
799 aggravate_monsters(0);
803 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
806 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
807 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
809 msg_print("There is a sudden explosion!");
810 msg_print("Everything inside the chest is destroyed!");
814 sound(SOUND_EXPLODE);
816 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
818 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
822 /* Scatter contents. */
823 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
826 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
828 msg_print("The contents of the chest scatter all over the dungeon!");
830 chest_death(TRUE, y, x, o_idx);
837 * Attempt to open the given chest at the given location
839 * Assume there is no monster blocking the destination
841 * Returns TRUE if repeated commands may continue
843 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
851 object_type *o_ptr = &o_list[o_idx];
857 /* Attempt to unlock it */
860 /* Assume locked, and thus not open */
863 /* Get the "disarm" factor */
864 i = p_ptr->skill_dis;
866 /* Penalize some conditions */
867 if (p_ptr->blind || no_lite()) i = i / 10;
868 if (p_ptr->confused || p_ptr->image) i = i / 10;
870 /* Extract the difficulty */
873 /* Always have a small chance of success */
876 /* Success -- May still have traps */
877 if (randint0(100) < j)
880 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
882 msg_print("You have picked the lock.");
889 /* Failure -- Keep trying */
892 /* We may continue repeating */
894 if (flush_failure) flush();
896 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
898 msg_print("You failed to pick the lock.");
904 /* Allowed to open */
907 /* Apply chest traps, if any */
908 chest_trap(y, x, o_idx);
910 /* Let the Chest drop items */
911 chest_death(FALSE, y, x, o_idx);
919 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
922 * Return TRUE if the given feature is an open door
924 static bool is_open(int feat)
926 return (feat == FEAT_OPEN);
931 * Return the number of features around (or under) the character.
932 * Usually look for doors and floor traps.
934 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
936 int d, count, xx, yy;
938 /* Count how many matches */
941 /* Check around (and under) the character */
942 for (d = 0; d < 9; d++)
947 /* if not searching under player continue */
948 if ((d == 8) && !under) continue;
950 /* Extract adjacent (legal) location */
951 yy = py + ddy_ddd[d];
952 xx = px + ddx_ddd[d];
955 c_ptr = &cave[yy][xx];
957 /* Must have knowledge */
958 if (!(c_ptr->info & (CAVE_MARK))) continue;
960 /* Feature code (applying "mimic" field) */
961 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
963 /* Not looking for this feature */
964 if (!((*test)(feat))) continue;
969 /* Remember the location. Only useful if only one match */
980 * Return the number of chests around (or under) the character.
981 * If requested, count only trapped chests.
983 static int count_chests(int *y, int *x, bool trapped)
989 /* Count how many matches */
992 /* Check around (and under) the character */
993 for (d = 0; d < 9; d++)
995 /* Extract adjacent (legal) location */
996 int yy = py + ddy_ddd[d];
997 int xx = px + ddx_ddd[d];
999 /* No (visible) chest is there */
1000 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1002 /* Grab the object */
1003 o_ptr = &o_list[o_idx];
1006 if (o_ptr->pval == 0) continue;
1008 /* No (known) traps here */
1009 if (trapped && (!object_known_p(o_ptr) ||
1010 !chest_traps[o_ptr->pval])) continue;
1015 /* Remember the location. Only useful if only one match */
1026 * Convert an adjacent location to a direction.
1028 static int coords_to_dir(int y, int x)
1030 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1037 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1039 return d[dx + 1][dy + 1];
1042 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1046 * Perform the basic "open" command on doors
1048 * Assume destination is a closed/locked/jammed door
1050 * Assume there is no monster blocking the destination
1052 * Returns TRUE if repeated commands may continue
1054 static bool do_cmd_open_aux(int y, int x)
1066 /* Get requested grid */
1067 c_ptr = &cave[y][x];
1069 /* Seeing true feature code (ignore mimic) */
1072 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1076 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1078 msg_print("The door appears to be stuck.");
1084 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1087 i = p_ptr->skill_dis;
1089 /* Penalize some conditions */
1090 if (p_ptr->blind || no_lite()) i = i / 10;
1091 if (p_ptr->confused || p_ptr->image) i = i / 10;
1093 /* Extract the lock power */
1094 j = c_ptr->feat - FEAT_DOOR_HEAD;
1096 /* Extract the difficulty XXX XXX XXX */
1099 /* Always have a small chance of success */
1103 if (randint0(100) < j)
1107 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1109 msg_print("You have picked the lock.");
1114 cave_set_feat(y, x, FEAT_OPEN);
1116 /* Update some things */
1117 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1120 sound(SOUND_OPENDOOR);
1130 if (flush_failure) flush();
1134 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1136 msg_print("You failed to pick the lock.");
1140 /* We may keep trying */
1146 else if (c_ptr->feat == FEAT_DOOR_HEAD)
1149 cave_set_feat(y, x, FEAT_OPEN);
1151 /* Update some things */
1152 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1155 sound(SOUND_OPENDOOR);
1165 * Open a closed/locked/jammed door or a closed/locked chest.
1167 * Unlocking a locked door/chest is worth one experience point.
1169 void do_cmd_open(void)
1177 if (p_ptr->special_defense & KATA_MUSOU)
1179 set_action(ACTION_NONE);
1182 #ifdef ALLOW_EASY_OPEN /* TNB */
1184 /* Option: Pick a direction */
1187 int num_doors, num_chests;
1189 /* Count closed doors (locked or jammed) */
1190 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1192 /* Count chests (locked) */
1193 num_chests = count_chests(&y, &x, FALSE);
1195 /* See if only one target */
1196 if (num_doors || num_chests)
1198 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1200 if (!too_many) command_dir = coords_to_dir(y, x);
1204 #endif /* ALLOW_EASY_OPEN -- TNB */
1206 /* Allow repeated command */
1209 /* Set repeat count */
1210 command_rep = command_arg - 1;
1212 /* Redraw the state */
1213 p_ptr->redraw |= (PR_STATE);
1215 /* Cancel the arg */
1219 /* Get a "repeated" direction */
1220 if (get_rep_dir(&dir, TRUE))
1225 /* Get requested location */
1229 /* Get requested grid */
1230 c_ptr = &cave[y][x];
1232 /* Feature code (applying "mimic" field) */
1233 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
1235 /* Check for chest */
1236 o_idx = chest_check(y, x);
1238 /* Nothing useful */
1239 if (!is_closed_door(feat) && !o_idx)
1243 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1245 msg_print("You see nothing there to open.");
1250 /* Monster in the way */
1251 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1258 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1260 msg_print("There is a monster in the way!");
1271 /* Open the chest */
1272 more = do_cmd_open_chest(y, x, o_idx);
1279 more = do_cmd_open_aux(y, x);
1283 /* Cancel repeat unless we may continue */
1284 if (!more) disturb(0, 0);
1290 * Perform the basic "close" command
1292 * Assume destination is an open/broken door
1294 * Assume there is no monster blocking the destination
1296 * Returns TRUE if repeated commands may continue
1298 static bool do_cmd_close_aux(int y, int x)
1306 /* Get grid and contents */
1307 c_ptr = &cave[y][x];
1309 /* Seeing true feature code (ignore mimic) */
1312 if (c_ptr->feat == FEAT_BROKEN)
1316 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1318 msg_print("The door appears to be broken.");
1324 else if (c_ptr->feat == FEAT_OPEN)
1326 /* Close the door */
1327 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1329 /* Update some things */
1330 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1333 sound(SOUND_SHUTDOOR);
1342 * Close an open door.
1344 void do_cmd_close(void)
1350 if (p_ptr->special_defense & KATA_MUSOU)
1352 set_action(ACTION_NONE);
1355 #ifdef ALLOW_EASY_OPEN /* TNB */
1357 /* Option: Pick a direction */
1360 /* Count open doors */
1361 if (count_dt(&y, &x, is_open, FALSE) == 1)
1363 command_dir = coords_to_dir(y, x);
1367 #endif /* ALLOW_EASY_OPEN -- TNB */
1369 /* Allow repeated command */
1372 /* Set repeat count */
1373 command_rep = command_arg - 1;
1375 /* Redraw the state */
1376 p_ptr->redraw |= (PR_STATE);
1378 /* Cancel the arg */
1382 /* Get a "repeated" direction */
1383 if (get_rep_dir(&dir,FALSE))
1388 /* Get requested location */
1392 /* Get grid and contents */
1393 c_ptr = &cave[y][x];
1395 /* Feature code (applying "mimic" field) */
1396 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
1398 /* Require open/broken door */
1399 if ((feat != FEAT_OPEN) && (feat != FEAT_BROKEN))
1403 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1405 msg_print("You see nothing there to close.");
1410 /* Monster in the way */
1411 else if (c_ptr->m_idx)
1418 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1420 msg_print("There is a monster in the way!");
1428 /* Close the door */
1431 /* Close the door */
1432 more = do_cmd_close_aux(y, x);
1436 /* Cancel repeat unless we may continue */
1437 if (!more) disturb(0, 0);
1442 * Determine if a given grid may be "tunneled"
1444 static bool do_cmd_tunnel_test(int y, int x)
1446 /* Must have knowledge */
1447 if (!(cave[y][x].info & (CAVE_MARK)))
1451 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1453 msg_print("You see nothing there.");
1461 /* Must be a wall/door/etc */
1462 if (cave_floor_bold(y, x))
1466 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1468 msg_print("You see nothing there to tunnel.");
1483 * Tunnel through wall. Assumes valid location.
1485 * Note that it is impossible to "extend" rooms past their
1486 * outer walls (which are actually part of the room).
1488 * This will, however, produce grids which are NOT illuminated
1489 * (or darkened) along with the rest of the room.
1491 static bool twall(int y, int x, byte feat)
1493 cave_type *c_ptr = &cave[y][x];
1495 /* Paranoia -- Require a wall or door or some such */
1496 if (cave_floor_bold(y, x)) return (FALSE);
1498 /* Forget the wall */
1499 c_ptr->info &= ~(CAVE_MARK);
1501 /* Remove the feature */
1502 cave_set_feat(y, x, feat);
1504 /* Update some things */
1505 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1514 * Perform the basic "tunnel" command
1516 * Assumes that the destination is a wall, a vein, a secret
1519 * Assumes that no monster is blocking the destination
1521 * Returns TRUE if repeated commands may continue
1523 static bool do_cmd_tunnel_aux(int y, int x)
1530 /* Verify legality */
1531 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1537 c_ptr = &cave[y][x];
1539 /* Feature code (applying "mimic" field) */
1540 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
1546 if ((feat >= FEAT_PERM_EXTRA) &&
1547 (feat <= FEAT_PERM_SOLID))
1550 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1552 msg_print("This seems to be permanent rock.");
1557 /* Map border (mimiccing Permanent wall) */
1558 else if ((c_ptr->feat >= FEAT_PERM_EXTRA &&
1559 c_ptr->feat <= FEAT_PERM_SOLID) ||
1560 c_ptr->feat == FEAT_MOUNTAIN)
1563 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1565 msg_print("You can't tunnel through that!");
1570 else if (feat == FEAT_TREES) /* -KMW- */
1573 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1576 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1578 msg_print("You have cleared away the trees.");
1580 chg_virtue(V_DILIGENCE, 1);
1581 chg_virtue(V_NATURE, -1);
1587 /* We may continue chopping */
1589 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1591 msg_print("You chop away at the tree.");
1596 /* Occasional Search XXX XXX */
1597 if (randint0(100) < 25) search();
1603 else if ((feat >= FEAT_WALL_EXTRA) &&
1604 (feat <= FEAT_WALL_SOLID))
1607 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1610 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1612 msg_print("You have finished the tunnel.");
1614 chg_virtue(V_DILIGENCE, 1);
1615 chg_virtue(V_NATURE, -1);
1621 /* We may continue tunelling */
1623 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1625 msg_print("You tunnel into the granite wall.");
1633 /* Quartz / Magma */
1634 else if ((feat >= FEAT_MAGMA) &&
1635 (feat <= FEAT_QUARTZ_K))
1641 /* Found gold (ignore mimic; maybe a hidden treasure) */
1642 if (c_ptr->feat >= FEAT_MAGMA_H &&
1643 c_ptr->feat <= FEAT_QUARTZ_K) gold = TRUE;
1645 /* Extract "quartz" flag XXX XXX XXX */
1646 if ((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 (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, 0L);
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.");
1768 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint1(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 door.");
1792 if (is_hidden_door(c_ptr))
1794 /* Occasional Search XXX XXX */
1795 if (randint0(100) < 25) search();
1804 * Tunnels through "walls" (including rubble and closed doors)
1806 * Note that you must tunnel in order to hit invisible monsters
1807 * in walls, though moving into walls still takes a turn anyway.
1809 * Digging is very difficult without a "digger" weapon, but can be
1810 * accomplished by strong players using heavy weapons.
1812 void do_cmd_tunnel(void)
1822 if (p_ptr->special_defense & KATA_MUSOU)
1824 set_action(ACTION_NONE);
1827 /* Allow repeated command */
1830 /* Set repeat count */
1831 command_rep = command_arg - 1;
1833 /* Redraw the state */
1834 p_ptr->redraw |= (PR_STATE);
1836 /* Cancel the arg */
1840 /* Get a direction to tunnel, or Abort */
1841 if (get_rep_dir(&dir,FALSE))
1848 c_ptr = &cave[y][x];
1850 /* Feature code (applying "mimic" field) */
1851 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
1853 /* No tunnelling through doors */
1854 if (((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL)) ||
1855 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
1856 ((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
1857 (feat == FEAT_MUSEUM))
1861 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1863 msg_print("You cannot tunnel through doors.");
1868 /* No tunnelling through air */
1869 else if (cave_floor_grid(c_ptr) || ((feat >= FEAT_MINOR_GLYPH) &&
1870 (feat <= FEAT_PATTERN_XTRA2)))
1874 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1876 msg_print("You cannot tunnel through air.");
1881 /* No tunnelling through mountains */
1882 else if (feat == FEAT_MOUNTAIN)
1885 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1887 msg_print("You can't tunnel through that!");
1892 /* A monster is in the way */
1893 else if (c_ptr->m_idx)
1900 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1902 msg_print("There is a monster in the way!");
1913 /* Tunnel through walls */
1914 more = do_cmd_tunnel_aux(y, x);
1918 /* Cancel repetition unless we can continue */
1919 if (!more) disturb(0, 0);
1923 #ifdef ALLOW_EASY_OPEN /* TNB */
1928 * If there is a jammed/closed/locked door at the given location,
1929 * then attempt to unlock/open it. Return TRUE if an attempt was
1930 * made (successful or not), otherwise return FALSE.
1932 * The code here should be nearly identical to that in
1933 * do_cmd_open_test() and do_cmd_open_aux().
1935 bool easy_open_door(int y, int x)
1939 cave_type *c_ptr = &cave[y][x];
1941 /* Must be a closed door */
1942 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1943 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1950 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1954 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1956 msg_print("The door appears to be stuck.");
1962 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1965 i = p_ptr->skill_dis;
1967 /* Penalize some conditions */
1968 if (p_ptr->blind || no_lite()) i = i / 10;
1969 if (p_ptr->confused || p_ptr->image) i = i / 10;
1971 /* Extract the lock power */
1972 j = c_ptr->feat - FEAT_DOOR_HEAD;
1974 /* Extract the difficulty XXX XXX XXX */
1977 /* Always have a small chance of success */
1981 if (randint0(100) < j)
1985 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1987 msg_print("You have picked the lock.");
1992 cave_set_feat(y, x, FEAT_OPEN);
1994 /* Update some things */
1995 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1998 sound(SOUND_OPENDOOR);
2008 if (flush_failure) flush();
2012 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2014 msg_print("You failed to pick the lock.");
2024 cave_set_feat(y, x, FEAT_OPEN);
2026 /* Update some things */
2027 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
2030 sound(SOUND_OPENDOOR);
2037 #endif /* ALLOW_EASY_OPEN -- TNB */
2041 * Perform the basic "disarm" command
2043 * Assume destination is a visible trap
2045 * Assume there is no monster blocking the destination
2047 * Returns TRUE if repeated commands may continue
2049 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2055 object_type *o_ptr = &o_list[o_idx];
2061 /* Get the "disarm" factor */
2062 i = p_ptr->skill_dis;
2064 /* Penalize some conditions */
2065 if (p_ptr->blind || no_lite()) i = i / 10;
2066 if (p_ptr->confused || p_ptr->image) i = i / 10;
2068 /* Extract the difficulty */
2069 j = i - o_ptr->pval;
2071 /* Always have a small chance of success */
2074 /* Must find the trap first. */
2075 if (!object_known_p(o_ptr))
2078 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2080 msg_print("I don't see any traps.");
2085 /* Already disarmed/unlocked */
2086 else if (o_ptr->pval <= 0)
2089 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2091 msg_print("The chest is not trapped.");
2096 /* No traps to find. */
2097 else if (!chest_traps[o_ptr->pval])
2100 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2102 msg_print("The chest is not trapped.");
2107 /* Success (get a lot of experience) */
2108 else if (randint0(100) < j)
2111 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2113 msg_print("You have disarmed the chest.");
2116 gain_exp(o_ptr->pval);
2117 o_ptr->pval = (0 - o_ptr->pval);
2120 /* Failure -- Keep trying */
2121 else if ((i > 5) && (randint1(i) > 5))
2123 /* We may keep trying */
2125 if (flush_failure) flush();
2127 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2129 msg_print("You failed to disarm the chest.");
2134 /* Failure -- Set off the trap */
2138 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2140 msg_print("You set off a trap!");
2144 chest_trap(y, x, o_idx);
2153 * Perform the basic "disarm" command
2155 * Assume destination is a visible trap
2157 * Assume there is no monster blocking the destination
2159 * Returns TRUE if repeated commands may continue
2161 #ifdef ALLOW_EASY_DISARM /* TNB */
2163 bool do_cmd_disarm_aux(int y, int x, int dir)
2165 #else /* ALLOW_EASY_DISARM -- TNB */
2167 static bool do_cmd_disarm_aux(int y, int x, int dir)
2169 #endif /* ALLOW_EASY_DISARM -- TNB */
2183 /* Get grid and contents */
2184 c_ptr = &cave[y][x];
2186 /* Access trap name */
2187 name = (f_name + f_info[c_ptr->feat].name);
2189 /* Get the "disarm" factor */
2190 i = p_ptr->skill_dis;
2192 /* Penalize some conditions */
2193 if (p_ptr->blind || no_lite()) i = i / 10;
2194 if (p_ptr->confused || p_ptr->image) i = i / 10;
2196 /* Variable power! */
2198 /* Extract trap "power" */
2199 switch (c_ptr->feat)
2201 case FEAT_TRAP_OPEN:
2202 case FEAT_TRAP_ARMAGEDDON:
2203 case FEAT_TRAP_PIRANHA:
2204 /* Special traps are very difficult to disarm */
2212 /* Extract the difficulty */
2215 /* Always have a small chance of success */
2219 if (randint0(100) < j)
2223 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2225 msg_format("You have disarmed the %s.", name);
2232 /* Forget the trap */
2233 c_ptr->info &= ~(CAVE_MARK);
2235 /* Remove the trap */
2236 cave_set_feat(y, x, floor_type[randint0(100)]);
2238 #ifdef ALLOW_EASY_DISARM /* TNB */
2240 /* Move the player onto the trap */
2241 move_player(dir, easy_disarm, FALSE);
2243 #else /* ALLOW_EASY_DISARM -- TNB */
2245 /* move the player onto the trap grid */
2246 move_player(dir, FALSE, FALSE);
2248 #endif /* ALLOW_EASY_DISARM -- TNB */
2251 /* Failure -- Keep trying */
2252 else if ((i > 5) && (randint1(i) > 5))
2255 if (flush_failure) flush();
2259 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2261 msg_format("You failed to disarm the %s.", name);
2265 /* We may keep trying */
2269 /* Failure -- Set off the trap */
2274 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2276 msg_format("You set off the %s!", name);
2280 #ifdef ALLOW_EASY_DISARM /* TNB */
2282 /* Move the player onto the trap */
2283 move_player(dir, easy_disarm, FALSE);
2285 #else /* ALLOW_EASY_DISARM -- TNB */
2287 /* Move the player onto the trap */
2288 move_player(dir, FALSE, FALSE);
2290 #endif /* ALLOW_EASY_DISARM -- TNB */
2299 * Disarms a trap, or chest
2301 void do_cmd_disarm(void)
2309 if (p_ptr->special_defense & KATA_MUSOU)
2311 set_action(ACTION_NONE);
2314 #ifdef ALLOW_EASY_DISARM /* TNB */
2316 /* Option: Pick a direction */
2319 int num_traps, num_chests;
2321 /* Count visible traps */
2322 num_traps = count_dt(&y, &x, is_trap, TRUE);
2324 /* Count chests (trapped) */
2325 num_chests = count_chests(&y, &x, TRUE);
2327 /* See if only one target */
2328 if (num_traps || num_chests)
2330 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2332 if (!too_many) command_dir = coords_to_dir(y, x);
2336 #endif /* ALLOW_EASY_DISARM -- TNB */
2338 /* Allow repeated command */
2341 /* Set repeat count */
2342 command_rep = command_arg - 1;
2344 /* Redraw the state */
2345 p_ptr->redraw |= (PR_STATE);
2347 /* Cancel the arg */
2351 /* Get a direction (or abort) */
2352 if (get_rep_dir(&dir,TRUE))
2361 /* Get grid and contents */
2362 c_ptr = &cave[y][x];
2364 /* Feature code (applying "mimic" field) */
2365 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
2367 /* Check for chests */
2368 o_idx = chest_check(y, x);
2371 if (!is_trap(feat) && !o_idx)
2375 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2377 msg_print("You see nothing there to disarm.");
2382 /* Monster in the way */
2383 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2387 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2389 msg_print("There is a monster in the way!");
2400 /* Disarm the chest */
2401 more = do_cmd_disarm_chest(y, x, o_idx);
2407 /* Disarm the trap */
2408 more = do_cmd_disarm_aux(y, x, dir);
2412 /* Cancel repeat unless told not to */
2413 if (!more) disturb(0, 0);
2418 * Perform the basic "bash" command
2420 * Assume destination is a closed/locked/jammed door
2422 * Assume there is no monster blocking the destination
2424 * Returns TRUE if repeated commands may continue
2426 static bool do_cmd_bash_aux(int y, int x, int dir)
2439 c_ptr = &cave[y][x];
2443 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2445 msg_print("You smash into the door!");
2449 /* Hack -- Bash power based on strength */
2450 /* (Ranges from 3 to 20 to 100 to 200) */
2451 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2453 /* Extract door power */
2454 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2456 /* Compare bash power to door power XXX XXX XXX */
2457 temp = (bash - (temp * 10));
2459 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2461 /* Hack -- always have a chance */
2462 if (temp < 1) temp = 1;
2464 /* Hack -- attempt to bash down the door */
2465 if (randint0(100) < temp)
2469 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2471 msg_print("The door crashes open!");
2475 /* Break down the door */
2476 if (randint0(100) < 50)
2478 cave_set_feat(y, x, FEAT_BROKEN);
2484 cave_set_feat(y, x, FEAT_OPEN);
2488 sound(SOUND_OPENDOOR);
2490 /* Hack -- Fall through the door */
2491 move_player(dir, FALSE, FALSE);
2493 /* Update some things */
2494 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2495 p_ptr->update |= (PU_DISTANCE);
2498 /* Saving throw against stun */
2499 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2504 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2506 msg_print("The door holds firm.");
2510 /* Allow repeated bashing */
2514 /* High dexterity yields coolness */
2519 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2521 msg_print("You are off-balance.");
2525 /* Hack -- Lose balance ala paralysis */
2526 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2535 * Bash open a door, success based on character strength
2537 * For a closed door, pval is positive if locked; negative if stuck.
2539 * For an open door, pval is positive for a broken door.
2541 * A closed door can be opened - harder if locked. Any door might be
2542 * bashed open (and thereby broken). Bashing a door is (potentially)
2543 * faster! You move into the door way. To open a stuck door, it must
2544 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2546 * Creatures can also open or bash doors, see elsewhere.
2548 void do_cmd_bash(void)
2557 if (p_ptr->special_defense & KATA_MUSOU)
2559 set_action(ACTION_NONE);
2562 /* Allow repeated command */
2565 /* Set repeat count */
2566 command_rep = command_arg - 1;
2568 /* Redraw the state */
2569 p_ptr->redraw |= (PR_STATE);
2571 /* Cancel the arg */
2575 /* Get a "repeated" direction */
2576 if (get_rep_dir(&dir,FALSE))
2585 c_ptr = &cave[y][x];
2587 /* Feature code (applying "mimic" field) */
2588 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
2590 /* Nothing useful */
2591 if (!((feat >= FEAT_DOOR_HEAD) &&
2592 (feat <= FEAT_DOOR_TAIL)))
2596 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2598 msg_print("You see nothing there to bash.");
2603 /* Monster in the way */
2604 else if (c_ptr->m_idx)
2611 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2613 msg_print("There is a monster in the way!");
2621 /* Bash a closed door */
2625 more = do_cmd_bash_aux(y, x, dir);
2629 /* Unless valid action taken, cancel bash */
2630 if (!more) disturb(0, 0);
2635 * Manipulate an adjacent grid in some way
2637 * Attack monsters, tunnel through walls, disarm traps, open doors.
2639 * Consider confusion XXX XXX XXX
2641 * This command must always take a turn, to prevent free detection
2642 * of invisible monsters.
2644 void do_cmd_alter(void)
2653 if (p_ptr->special_defense & KATA_MUSOU)
2655 set_action(ACTION_NONE);
2658 /* Allow repeated command */
2661 /* Set repeat count */
2662 command_rep = command_arg - 1;
2664 /* Redraw the state */
2665 p_ptr->redraw |= (PR_STATE);
2667 /* Cancel the arg */
2671 /* Get a direction */
2672 if (get_rep_dir(&dir,TRUE))
2681 c_ptr = &cave[y][x];
2683 /* Feature code (applying "mimic" field) */
2684 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
2689 /* Attack monsters */
2696 /* Tunnel through walls */
2697 else if (((feat >= FEAT_RUBBLE) &&
2698 (feat < FEAT_MINOR_GLYPH)) ||
2699 ((feat == FEAT_TREES) ||
2700 (feat == FEAT_MOUNTAIN)))
2702 more = do_cmd_tunnel_aux(y, x);
2705 else if (is_closed_door(feat))
2707 /* Bash jammed doors */
2708 if (feat >= FEAT_DOOR_HEAD + 0x08)
2710 more = do_cmd_bash_aux(y, x, dir);
2716 more = do_cmd_open_aux(y, x);
2720 /* Close open doors */
2721 else if ((feat == FEAT_OPEN) ||
2722 (feat == FEAT_BROKEN))
2724 more = do_cmd_close_aux(y, x);
2728 else if (is_trap(feat))
2730 more = do_cmd_disarm_aux(y, x, dir);
2738 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2740 msg_print("You attack the empty air.");
2746 /* Cancel repetition unless we can continue */
2747 if (!more) disturb(0, 0);
2752 * Find the index of some "spikes", if possible.
2754 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2756 static bool get_spike(int *ip)
2760 /* Check every item in the pack */
2761 for (i = 0; i < INVEN_PACK; i++)
2763 object_type *o_ptr = &inventory[i];
2765 /* Skip non-objects */
2766 if (!o_ptr->k_idx) continue;
2768 /* Check the "tval" code */
2769 if (o_ptr->tval == TV_SPIKE)
2771 /* Save the spike index */
2785 * Jam a closed door with a spike
2787 * This command may NOT be repeated
2789 void do_cmd_spike(void)
2793 if (p_ptr->special_defense & KATA_MUSOU)
2795 set_action(ACTION_NONE);
2798 /* Get a "repeated" direction */
2799 if (get_rep_dir(&dir,FALSE))
2809 /* Get grid and contents */
2810 c_ptr = &cave[y][x];
2812 /* Feature code (applying "mimic" field) */
2813 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
2815 /* Require closed door */
2816 if (!((feat >= FEAT_DOOR_HEAD) &&
2817 (feat <= FEAT_DOOR_TAIL)))
2821 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2823 msg_print("You see nothing there to spike.");
2829 else if (!get_spike(&item))
2833 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2835 msg_print("You have no spikes!");
2840 /* Is a monster in the way? */
2841 else if (c_ptr->m_idx)
2848 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2850 msg_print("There is a monster in the way!");
2864 /* Successful jamming */
2866 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2868 msg_print("You jam the door with a spike.");
2872 /* Convert "locked" to "stuck" XXX XXX XXX */
2873 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2875 /* Add one spike to the door */
2876 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2878 /* Use up, and describe, a single spike, from the bottom */
2879 inven_item_increase(item, -1);
2880 inven_item_describe(item);
2881 inven_item_optimize(item);
2889 * Support code for the "Walk" and "Jump" commands
2891 void do_cmd_walk(int pickup)
2898 /* Allow repeated command */
2901 /* Set repeat count */
2902 command_rep = command_arg - 1;
2904 /* Redraw the state */
2905 p_ptr->redraw |= (PR_STATE);
2907 /* Cancel the arg */
2911 /* Get a "repeated" direction */
2912 if (get_rep_dir(&dir,FALSE))
2917 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2919 set_action(ACTION_NONE);
2922 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2923 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2924 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2926 /* Actually move the character */
2927 move_player(dir, pickup, FALSE);
2929 /* Allow more walking */
2933 /* Hack again -- Is there a special encounter ??? */
2934 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2936 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2939 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2941 /* Inform the player of his horrible fate :=) */
2943 msg_print("½±·â¤À¡ª");
2945 msg_print("You are ambushed !");
2948 /* Go into large wilderness view */
2949 p_ptr->wilderness_x = px;
2950 p_ptr->wilderness_y = py;
2951 p_ptr->oldpy = randint1(MAX_HGT-2);
2952 p_ptr->oldpx = randint1(MAX_WID-2);
2956 /* HACk -- set the encouter flag for the wilderness generation */
2957 generate_encounter = TRUE;
2961 /* Cancel repeat unless we may continue */
2962 if (!more) disturb(0, 0);
2970 void do_cmd_run(void)
2974 /* Hack -- no running when confused */
2975 if (p_ptr->confused)
2978 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2980 msg_print("You are too confused!");
2986 if (p_ptr->special_defense & KATA_MUSOU)
2988 set_action(ACTION_NONE);
2991 /* Get a "repeated" direction */
2992 if (get_rep_dir(&dir,FALSE))
2994 /* Hack -- Set the run counter */
2995 running = (command_arg ? command_arg : 1000);
3005 * Stay still. Search. Enter stores.
3006 * Pick up treasure if "pickup" is true.
3008 void do_cmd_stay(int pickup)
3010 cave_type *c_ptr = &cave[py][px];
3013 /* Allow repeated command */
3016 /* Set repeat count */
3017 command_rep = command_arg - 1;
3019 /* Redraw the state */
3020 p_ptr->redraw |= (PR_STATE);
3022 /* Cancel the arg */
3031 /* Spontaneous Searching */
3032 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3037 /* Continuous Searching */
3038 if (p_ptr->action == ACTION_SEARCH)
3044 /* Handle "objects" */
3048 /* Hack -- enter a store if we are on one */
3049 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3050 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3051 (c_ptr->feat == FEAT_MUSEUM))
3057 /* Hack -- enter store */
3058 command_new = SPECIAL_KEY_STORE;
3061 /* Hack -- enter a building if we are on one -KMW- */
3062 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3063 (c_ptr->feat <= FEAT_BLDG_TAIL))
3069 /* Hack -- enter building */
3070 command_new = SPECIAL_KEY_BUILDING;
3073 /* Exit a quest if reach the quest exit */
3074 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3076 int q_index = p_ptr->inside_quest;
3078 /* Was quest completed? */
3079 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3081 quest[q_index].status = QUEST_STATUS_COMPLETED;
3082 quest[q_index].complev = (byte)p_ptr->lev;
3084 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3086 msg_print("You accomplished your quest!");
3092 leave_quest_check();
3094 p_ptr->inside_quest = cave[py][px].special;
3099 /* Clear all saved floors */
3100 prepare_change_floor_mode(CFM_CLEAR_ALL);
3102 p_ptr->leaving = TRUE;
3109 * Resting allows a player to safely restore his hp -RAK-
3111 void do_cmd_rest(void)
3114 set_action(ACTION_NONE);
3116 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3121 /* Prompt for time if needed */
3122 if (command_arg <= 0)
3125 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3127 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3134 strcpy(out_val, "&");
3136 /* Ask for duration */
3137 if (!get_string(p, out_val, 4)) return;
3139 /* Rest until done */
3140 if (out_val[0] == '&')
3146 else if (out_val[0] == '*')
3154 command_arg = atoi(out_val);
3155 if (command_arg <= 0) return;
3161 if (command_arg > 9999) command_arg = 9999;
3163 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3165 /* Take a turn XXX XXX XXX (?) */
3168 /* The sin of sloth */
3169 if (command_arg > 100)
3170 chg_virtue(V_DILIGENCE, -1);
3172 /* Why are you sleeping when there's no need? WAKE UP!*/
3173 if ((p_ptr->chp == p_ptr->mhp) &&
3174 (p_ptr->csp == p_ptr->msp) &&
3175 !p_ptr->blind && !p_ptr->confused &&
3176 !p_ptr->poisoned && !p_ptr->afraid &&
3177 !p_ptr->stun && !p_ptr->cut &&
3178 !p_ptr->slow && !p_ptr->paralyzed &&
3179 !p_ptr->image && !p_ptr->word_recall &&
3180 !p_ptr->alter_reality)
3181 chg_virtue(V_DILIGENCE, -1);
3183 /* Save the rest code */
3184 resting = command_arg;
3185 p_ptr->action = ACTION_REST;
3187 /* Recalculate bonuses */
3188 p_ptr->update |= (PU_BONUS);
3190 /* Redraw the state */
3191 p_ptr->redraw |= (PR_STATE);
3202 * Determines the odds of an object breaking when thrown at a monster
3204 * Note that artifacts never break, see the "drop_near()" function.
3206 static int breakage_chance(object_type *o_ptr)
3208 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3210 /* Examine the item type */
3211 switch (o_ptr->tval)
3227 /* Sometimes break */
3232 return (20 - archer_bonus * 2);
3237 return (10 - archer_bonus);
3244 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3248 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3250 u32b flgs[TR_FLAG_SIZE];
3252 /* Extract the flags */
3253 object_flags(o_ptr, flgs);
3255 /* Some "weapons" and "ammo" do extra damage */
3256 switch (o_ptr->tval)
3263 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3264 (r_ptr->flags3 & RF3_ANIMAL))
3266 if (m_ptr->ml && is_original_ap(m_ptr))
3268 r_ptr->r_flags3 |= RF3_ANIMAL;
3271 if (mult < 17) mult = 17;
3275 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3276 (r_ptr->flags3 & RF3_ANIMAL))
3278 if (m_ptr->ml && is_original_ap(m_ptr))
3280 r_ptr->r_flags3 |= RF3_ANIMAL;
3283 if (mult < 27) mult = 27;
3287 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3288 (r_ptr->flags3 & RF3_EVIL))
3290 if (m_ptr->ml && is_original_ap(m_ptr))
3292 r_ptr->r_flags3 |= RF3_EVIL;
3295 if (mult < 15) mult = 15;
3299 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3300 (r_ptr->flags3 & RF3_EVIL))
3302 if (m_ptr->ml && is_original_ap(m_ptr))
3304 r_ptr->r_flags3 |= RF3_EVIL;
3307 if (mult < 25) mult = 25;
3311 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3312 (r_ptr->flags2 & RF2_HUMAN))
3314 if (m_ptr->ml && is_original_ap(m_ptr))
3316 r_ptr->r_flags2 |= RF2_HUMAN;
3319 if (mult < 17) mult = 17;
3323 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3324 (r_ptr->flags2 & RF2_HUMAN))
3326 if (m_ptr->ml && is_original_ap(m_ptr))
3328 r_ptr->r_flags2 |= RF2_HUMAN;
3331 if (mult < 27) mult = 27;
3335 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3336 (r_ptr->flags3 & RF3_UNDEAD))
3338 if (m_ptr->ml && is_original_ap(m_ptr))
3340 r_ptr->r_flags3 |= RF3_UNDEAD;
3343 if (mult < 20) mult = 20;
3347 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3348 (r_ptr->flags3 & RF3_UNDEAD))
3350 if (m_ptr->ml && is_original_ap(m_ptr))
3352 r_ptr->r_flags3 |= RF3_UNDEAD;
3355 if (mult < 30) mult = 30;
3359 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3360 (r_ptr->flags3 & RF3_DEMON))
3362 if (m_ptr->ml && is_original_ap(m_ptr))
3364 r_ptr->r_flags3 |= RF3_DEMON;
3367 if (mult < 20) mult = 20;
3371 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3372 (r_ptr->flags3 & RF3_DEMON))
3374 if (m_ptr->ml && is_original_ap(m_ptr))
3376 r_ptr->r_flags3 |= RF3_DEMON;
3379 if (mult < 30) mult = 30;
3383 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3384 (r_ptr->flags3 & RF3_ORC))
3386 if (m_ptr->ml && is_original_ap(m_ptr))
3388 r_ptr->r_flags3 |= RF3_ORC;
3391 if (mult < 20) mult = 20;
3395 if ((have_flag(flgs, TR_KILL_ORC)) &&
3396 (r_ptr->flags3 & RF3_ORC))
3398 if (m_ptr->ml && is_original_ap(m_ptr))
3400 r_ptr->r_flags3 |= RF3_ORC;
3403 if (mult < 30) mult = 30;
3407 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3408 (r_ptr->flags3 & RF3_TROLL))
3410 if (m_ptr->ml && is_original_ap(m_ptr))
3412 r_ptr->r_flags3 |= RF3_TROLL;
3415 if (mult < 20) mult = 20;
3419 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3420 (r_ptr->flags3 & RF3_TROLL))
3422 if (m_ptr->ml && is_original_ap(m_ptr))
3424 r_ptr->r_flags3 |= RF3_TROLL;
3427 if (mult < 30) mult = 30;
3431 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3432 (r_ptr->flags3 & RF3_GIANT))
3434 if (m_ptr->ml && is_original_ap(m_ptr))
3436 r_ptr->r_flags3 |= RF3_GIANT;
3439 if (mult < 20) mult = 20;
3443 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3444 (r_ptr->flags3 & RF3_GIANT))
3446 if (m_ptr->ml && is_original_ap(m_ptr))
3448 r_ptr->r_flags3 |= RF3_GIANT;
3451 if (mult < 30) mult = 30;
3455 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3456 (r_ptr->flags3 & RF3_DRAGON))
3458 if (m_ptr->ml && is_original_ap(m_ptr))
3460 r_ptr->r_flags3 |= RF3_DRAGON;
3463 if (mult < 20) mult = 20;
3466 /* Execute Dragon */
3467 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3468 (r_ptr->flags3 & RF3_DRAGON))
3470 if (m_ptr->ml && is_original_ap(m_ptr))
3472 r_ptr->r_flags3 |= RF3_DRAGON;
3475 if (mult < 30) mult = 30;
3477 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3478 (m_ptr->r_idx == MON_SMAUG) &&
3479 (inventory[INVEN_BOW].name1 == ART_BARD))
3484 if (have_flag(flgs, TR_BRAND_ACID))
3486 /* Notice immunity */
3487 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3489 if (m_ptr->ml && is_original_ap(m_ptr))
3491 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3495 /* Otherwise, take the damage */
3498 if (mult < 17) mult = 17;
3503 if (have_flag(flgs, TR_BRAND_ELEC))
3505 /* Notice immunity */
3506 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3508 if (m_ptr->ml && is_original_ap(m_ptr))
3510 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3514 /* Otherwise, take the damage */
3517 if (mult < 17) mult = 17;
3522 if (have_flag(flgs, TR_BRAND_FIRE))
3524 /* Notice immunity */
3525 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3527 if (m_ptr->ml && is_original_ap(m_ptr))
3529 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3533 /* Otherwise, take the damage */
3536 if (r_ptr->flags3 & RF3_HURT_FIRE)
3538 if (mult < 25) mult = 25;
3539 if (m_ptr->ml && is_original_ap(m_ptr))
3541 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3544 else if (mult < 17) mult = 17;
3549 if (have_flag(flgs, TR_BRAND_COLD))
3551 /* Notice immunity */
3552 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3554 if (m_ptr->ml && is_original_ap(m_ptr))
3556 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3559 /* Otherwise, take the damage */
3562 if (r_ptr->flags3 & RF3_HURT_COLD)
3564 if (mult < 25) mult = 25;
3565 if (m_ptr->ml && is_original_ap(m_ptr))
3567 r_ptr->r_flags3 |= RF3_HURT_COLD;
3570 else if (mult < 17) mult = 17;
3574 /* Brand (Poison) */
3575 if (have_flag(flgs, TR_BRAND_POIS))
3577 /* Notice immunity */
3578 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3580 if (m_ptr->ml && is_original_ap(m_ptr))
3582 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3586 /* Otherwise, take the damage */
3589 if (mult < 17) mult = 17;
3593 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3595 p_ptr->csp -= (1+(p_ptr->msp / 30));
3596 p_ptr->redraw |= (PR_MANA);
3597 mult = mult * 5 / 2;
3603 /* Return the total damage */
3604 return (tdam * mult / 10);
3609 * Fire an object from the pack or floor.
3611 * You may only fire items that "match" your missile launcher.
3613 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3615 * See "calc_bonuses()" for more calculations and such.
3617 * Note that "firing" a missile is MUCH better than "throwing" it.
3619 * Note: "unseen" monsters are very hard to hit.
3621 * Objects are more likely to break if they "attempt" to hit a monster.
3623 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3625 * The "extra shot" code works by decreasing the amount of energy
3626 * required to make each shot, spreading the shots out over time.
3628 * Note that when firing missiles, the launcher multiplier is applied
3629 * after all the bonuses are added in, making multipliers very useful.
3631 * Note that Bows of "Extra Might" get extra range and an extra bonus
3632 * for the damage multiplier.
3634 * Note that Bows of "Extra Shots" give an extra shot.
3636 void do_cmd_fire_aux(int item, object_type *j_ptr)
3639 int j, y, x, ny, nx, ty, tx;
3640 int tdam, tdis, thits, tmul;
3642 int cur_dis, visible;
3649 bool hit_body = FALSE;
3651 char o_name[MAX_NLEN];
3653 int msec = delay_factor * delay_factor * delay_factor;
3656 bool stick_to = FALSE;
3658 /* Access the item (if in the pack) */
3661 o_ptr = &inventory[item];
3665 o_ptr = &o_list[0 - item];
3668 /* Describe the object */
3669 object_desc(o_name, o_ptr, FALSE, 3);
3672 /* Use the proper number of shots */
3673 thits = p_ptr->num_fire;
3675 /* Use a base distance */
3678 /* Base damage from thrown object plus launcher bonus */
3679 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3681 /* Actually "fire" the object */
3682 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3683 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3684 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3686 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3688 energy_use = bow_energy(j_ptr->sval);
3689 tmul = bow_tmul(j_ptr->sval);
3691 /* Get extra "power" from "extra might" */
3692 if (p_ptr->xtra_might) tmul++;
3694 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3696 /* Boost the damage */
3701 tdis = 10 + tmul/40;
3702 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3705 project_length = tdis + 1;
3707 /* Get a direction (or cancel) */
3708 if (!get_aim_dir(&dir))
3712 /* need not to reset project_length (already did)*/
3717 /* Get local object */
3720 /* Obtain a local object */
3721 object_copy(q_ptr, o_ptr);
3726 /* Reduce and describe inventory */
3729 inven_item_increase(item, -1);
3730 inven_item_describe(item);
3731 inven_item_optimize(item);
3734 /* Reduce and describe floor item */
3737 floor_item_increase(0 - item, -1);
3738 floor_item_optimize(0 - item);
3746 /* Take a (partial) turn */
3747 energy_use = (energy_use / thits);
3750 /* Start at the player */
3754 /* Predict the "target" location */
3755 tx = px + 99 * ddx[dir];
3756 ty = py + 99 * ddy[dir];
3758 /* Check for "target request" */
3759 if ((dir == 5) && target_okay())
3765 project_length = 0; /* reset to default */
3767 /* Hack -- Handle stuff */
3771 /* Travel until stopped */
3772 for (cur_dis = 0; cur_dis <= tdis; )
3774 /* Hack -- Stop at the target */
3775 if ((y == ty) && (x == tx)) break;
3777 /* Calculate the new location (see "project()") */
3780 mmove2(&ny, &nx, py, px, ty, tx);
3782 /* Stopped by walls/doors */
3783 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3785 /* Advance the distance */
3789 /* The player can see the (on screen) missile */
3790 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3792 char c = object_char(q_ptr);
3793 byte a = object_attr(q_ptr);
3795 /* Draw, Hilite, Fresh, Pause, Erase */
3796 print_rel(c, a, ny, nx);
3797 move_cursor_relative(ny, nx);
3799 Term_xtra(TERM_XTRA_DELAY, msec);
3804 /* The player cannot see the missile */
3807 /* Pause anyway, for consistancy */
3808 Term_xtra(TERM_XTRA_DELAY, msec);
3811 /* Save the new location */
3816 /* Monster here, Try to hit it */
3817 if (cave[y][x].m_idx)
3819 cave_type *c_ptr = &cave[y][x];
3821 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3822 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3824 /* Check the visibility */
3825 visible = m_ptr->ml;
3827 /* Note the collision */
3832 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3833 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3836 if ((r_ptr->level + 10) > p_ptr->lev)
3838 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3839 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3842 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3843 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3844 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3845 else if (p_ptr->lev > 34) amount = 2;
3846 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3847 p_ptr->update |= (PU_BONUS);
3853 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3854 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3857 p_ptr->skill_exp[GINOU_RIDING] += 1;
3858 p_ptr->update |= (PU_BONUS);
3862 /* Did we hit it (penalize range) */
3863 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3867 /* Handle unseen monster */
3870 /* Invisible monster */
3872 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3874 msg_format("The %s finds a mark.", o_name);
3879 /* Handle visible monster */
3884 /* Get "the monster" or "it" */
3885 monster_desc(m_name, m_ptr, 0);
3889 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3891 msg_format("The %s hits %s.", o_name, m_name);
3895 /* Hack -- Track this monster race */
3896 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3898 /* Hack -- Track this monster */
3899 if (m_ptr->ml) health_track(c_ptr->m_idx);
3902 /* Apply special damage XXX XXX XXX */
3903 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3904 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3906 /* No negative damage */
3907 if (tdam < 0) tdam = 0;
3909 /* Modify the damage */
3910 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3912 /* Complex message */
3913 if (p_ptr->wizard || cheat_xtra)
3916 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3919 msg_format("You do %d (out of %d) damage.",
3925 /* Hit the monster, check for death */
3926 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3939 monster_desc(m_name, m_ptr, 0);
3943 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3945 msg_format("%^s have stuck into %s!",o_name, m_name);
3950 message_pain(c_ptr->m_idx, tdam);
3952 /* Anger the monster */
3953 if (tdam > 0) anger_monster(m_ptr);
3956 if (fear && m_ptr->ml)
3963 /* Get the monster name (or "it") */
3964 monster_desc(m_name, m_ptr, 0);
3968 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3970 msg_format("%^s flees in terror!", m_name);
3974 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3976 set_target(m_ptr, py, px);
3986 /* Chance of breakage (during attacks) */
3987 j = (hit_body ? breakage_chance(q_ptr) : 0);
3991 int m_idx = cave[y][x].m_idx;
3992 monster_type *m_ptr = &m_list[m_idx];
3993 int o_idx = o_pop();
3998 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
4000 msg_format("The %s have gone to somewhere.", o_name);
4004 a_info[j_ptr->name1].cur_num = 0;
4009 o_ptr = &o_list[ o_idx ];
4010 object_copy(o_ptr, q_ptr);
4015 /* Forget location */
4016 o_ptr->iy = o_ptr->ix = 0;
4018 /* Memorize monster */
4019 o_ptr->held_m_idx = m_idx;
4022 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4025 m_ptr->hold_o_idx = o_idx;
4029 /* Drop (or break) near that location */
4030 (void)drop_near(q_ptr, j, y, x);
4034 void do_cmd_fire(void)
4040 /* Get the "bow" (if any) */
4041 j_ptr = &inventory[INVEN_BOW];
4043 /* Require a launcher */
4047 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4049 msg_print("You have nothing to fire with.");
4055 if (j_ptr->sval == SV_CRIMSON)
4058 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4060 msg_print("Do activate.");
4067 if (p_ptr->special_defense & KATA_MUSOU)
4069 set_action(ACTION_NONE);
4072 /* Require proper missile */
4073 item_tester_tval = p_ptr->tval_ammo;
4077 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4078 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4080 q = "Fire which item? ";
4081 s = "You have nothing to fire.";
4084 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4091 do_cmd_fire_aux(item, j_ptr);
4095 static bool item_tester_hook_boomerang(object_type *o_ptr)
4097 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4105 * Throw an object from the pack or floor.
4107 * Note: "unseen" monsters are very hard to hit.
4109 * Should throwing a weapon do full damage? Should it allow the magic
4110 * to hit bonus of the weapon to have an effect? Should it ever cause
4111 * the item to be destroyed? Should it do any damage at all?
4113 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4116 int i, j, y, x, ty, tx;
4118 int chance, tdam, tdis;
4120 int cur_dis, visible;
4127 bool hit_body = FALSE;
4128 bool hit_wall = FALSE;
4129 bool equiped_item = FALSE;
4130 bool return_when_thrown = FALSE;
4132 char o_name[MAX_NLEN];
4134 int msec = delay_factor * delay_factor * delay_factor;
4136 u32b flgs[TR_FLAG_SIZE];
4138 bool come_back = FALSE;
4139 bool do_drop = TRUE;
4142 if (p_ptr->special_defense & KATA_MUSOU)
4144 set_action(ACTION_NONE);
4153 if (buki_motteruka(INVEN_LARM))
4155 item_tester_hook = item_tester_hook_boomerang;
4157 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4158 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4160 q = "Throw which item? ";
4161 s = "You have nothing to throw.";
4164 if (!get_item(&item, q, s, (USE_EQUIP)))
4179 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4180 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4182 q = "Throw which item? ";
4183 s = "You have nothing to throw.";
4186 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4193 /* Access the item (if in the pack) */
4196 o_ptr = &inventory[item];
4200 o_ptr = &o_list[0 - item];
4204 /* Item is cursed */
4205 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4209 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4211 msg_print("Hmmm, it seems to be cursed.");
4218 if (p_ptr->inside_arena && !boomerang)
4220 if (o_ptr->tval != TV_SPIKE)
4223 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4225 msg_print("You're in the arena now. This is hand-to-hand!");
4234 /* Get local object */
4237 /* Obtain a local object */
4238 object_copy(q_ptr, o_ptr);
4240 /* Extract the thrown object's flags. */
4241 object_flags(q_ptr, flgs);
4243 /* Distribute the charges of rods/wands between the stacks */
4244 distribute_charges(o_ptr, q_ptr, 1);
4250 object_desc(o_name, q_ptr, FALSE, 3);
4252 if (p_ptr->mighty_throw) mult += 3;
4254 /* Extract a "distance multiplier" */
4255 /* Changed for 'launcher' mutation */
4256 mul = 10 + 2 * (mult - 1);
4258 /* Enforce a minimum "weight" of one pound */
4259 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4260 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4262 /* Hack -- Distance -- Reward strength, penalize weight */
4263 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4265 /* Max distance of 10-18 */
4266 if (tdis > mul) tdis = mul;
4270 ty = randint0(101)-50+py;
4271 tx = randint0(101)-50+px;
4275 project_length = tdis + 1;
4277 /* Get a direction (or cancel) */
4278 if (!get_aim_dir(&dir)) return FALSE;
4280 /* Predict the "target" location */
4281 tx = px + 99 * ddx[dir];
4282 ty = py + 99 * ddy[dir];
4284 /* Check for "target request" */
4285 if ((dir == 5) && target_okay())
4291 project_length = 0; /* reset to default */
4294 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4295 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4296 return_when_thrown = TRUE;
4298 /* Reduce and describe inventory */
4301 inven_item_increase(item, -1);
4302 if (!return_when_thrown)
4303 inven_item_describe(item);
4304 inven_item_optimize(item);
4307 /* Reduce and describe floor item */
4310 floor_item_increase(0 - item, -1);
4311 floor_item_optimize(0 - item);
4313 if (item >= INVEN_RARM)
4315 equiped_item = TRUE;
4316 p_ptr->redraw |= (PR_EQUIPPY);
4322 /* Rogue and Ninja gets bonus */
4323 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4324 energy_use -= p_ptr->lev;
4326 /* Start at the player */
4331 /* Hack -- Handle stuff */
4334 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4335 else shuriken = FALSE;
4337 /* Chance of hitting */
4338 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4339 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4340 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4342 if (shuriken) chance *= 2;
4344 /* Travel until stopped */
4345 for (cur_dis = 0; cur_dis <= tdis; )
4347 /* Hack -- Stop at the target */
4348 if ((y == ty) && (x == tx)) break;
4350 /* Calculate the new location (see "project()") */
4353 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4355 /* Stopped by walls/doors */
4356 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4362 /* Advance the distance */
4365 /* The player can see the (on screen) missile */
4366 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4368 char c = object_char(q_ptr);
4369 byte a = object_attr(q_ptr);
4371 /* Draw, Hilite, Fresh, Pause, Erase */
4372 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4373 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4375 Term_xtra(TERM_XTRA_DELAY, msec);
4376 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4380 /* The player cannot see the missile */
4383 /* Pause anyway, for consistancy */
4384 Term_xtra(TERM_XTRA_DELAY, msec);
4387 /* Save the new location */
4392 /* Monster here, Try to hit it */
4393 if (cave[y][x].m_idx)
4395 cave_type *c_ptr = &cave[y][x];
4397 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4398 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4400 /* Check the visibility */
4401 visible = m_ptr->ml;
4403 /* Note the collision */
4406 /* Did we hit it (penalize range) */
4407 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4411 /* Handle unseen monster */
4414 /* Invisible monster */
4416 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4418 msg_format("The %s finds a mark.", o_name);
4423 /* Handle visible monster */
4428 /* Get "the monster" or "it" */
4429 monster_desc(m_name, m_ptr, 0);
4433 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4435 msg_format("The %s hits %s.", o_name, m_name);
4439 /* Hack -- Track this monster race */
4440 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4442 /* Hack -- Track this monster */
4443 if (m_ptr->ml) health_track(c_ptr->m_idx);
4446 /* Hack -- Base damage from thrown object */
4447 tdam = damroll(q_ptr->dd, q_ptr->ds);
4448 /* Apply special damage XXX XXX XXX */
4449 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4450 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4451 if (q_ptr->to_d > 0)
4452 tdam += q_ptr->to_d;
4454 tdam += -q_ptr->to_d;
4458 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4459 tdam += p_ptr->to_d_m;
4461 else if (have_flag(flgs, TR_THROW))
4464 tdam += p_ptr->to_d_m;
4472 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4475 /* No negative damage */
4476 if (tdam < 0) tdam = 0;
4478 /* Modify the damage */
4479 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4481 /* Complex message */
4485 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4488 msg_format("You do %d (out of %d) damage.",
4494 /* Hit the monster, check for death */
4495 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4504 message_pain(c_ptr->m_idx, tdam);
4506 /* Anger the monster */
4507 if ((tdam > 0) && !object_is_potion(q_ptr))
4508 anger_monster(m_ptr);
4511 if (fear && m_ptr->ml)
4518 /* Get the monster name (or "it") */
4519 monster_desc(m_name, m_ptr, 0);
4523 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4525 msg_format("%^s flees in terror!", m_name);
4537 /* Chance of breakage (during attacks) */
4538 j = (hit_body ? breakage_chance(q_ptr) : 0);
4540 /* Figurines transform */
4541 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4545 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4546 !(cursed_p(q_ptr)) ? PM_FORCE_PET : 0L)))
4548 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4550 msg_print("The Figurine writhes and then shatters.");
4553 else if (cursed_p(q_ptr))
4555 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4557 msg_print("You have a bad feeling about this.");
4563 /* Potions smash open */
4564 if (object_is_potion(q_ptr))
4566 if (hit_body || hit_wall || (randint1(100) < j))
4570 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4572 msg_format("The %s shatters!", o_name);
4576 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4578 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4580 /* ToDo (Robert): fix the invulnerability */
4581 if (cave[y][x].m_idx &&
4582 is_friendly(&m_list[cave[y][x].m_idx]) &&
4586 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4588 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4590 msg_format("%^s gets angry!", m_name);
4593 set_hostile(&m_list[cave[y][x].m_idx]);
4604 if (return_when_thrown)
4606 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4607 char o2_name[MAX_NLEN];
4608 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4611 if (boomerang) back_chance += 4+randint1(5);
4612 if (super_boomerang) back_chance += 100;
4613 object_desc(o2_name, q_ptr, FALSE, 0);
4615 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4617 for (i = cur_dis-1;i>0;i--)
4619 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4621 char c = object_char(q_ptr);
4622 byte a = object_attr(q_ptr);
4624 /* Draw, Hilite, Fresh, Pause, Erase */
4625 print_rel(c, a, ny[i], nx[i]);
4626 move_cursor_relative(ny[i], nx[i]);
4628 Term_xtra(TERM_XTRA_DELAY, msec);
4629 lite_spot(ny[i], nx[i]);
4634 /* Pause anyway, for consistancy */
4635 Term_xtra(TERM_XTRA_DELAY, msec);
4638 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4641 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4643 msg_format("%s comes back to you.", o2_name);
4652 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4654 msg_format("%s backs, but you can't catch!", o2_name);
4660 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4662 msg_format("%s comes back.", o2_name);
4672 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4674 msg_format("%s doesn't back!", o2_name);
4681 if (item == INVEN_RARM || item == INVEN_LARM)
4683 /* Access the wield slot */
4684 o_ptr = &inventory[item];
4686 /* Wear the new stuff */
4687 object_copy(o_ptr, q_ptr);
4689 /* Increase the weight */
4690 p_ptr->total_weight += q_ptr->weight;
4692 /* Increment the equip counter by hand */
4695 /* Recalculate bonuses */
4696 p_ptr->update |= (PU_BONUS);
4698 /* Recalculate torch */
4699 p_ptr->update |= (PU_TORCH);
4701 /* Recalculate mana XXX */
4702 p_ptr->update |= (PU_MANA);
4705 p_ptr->window |= (PW_EQUIP);
4713 else if (equiped_item)
4719 /* Drop (or break) near that location */
4720 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4727 * Throw an object from the pack or floor.
4729 void do_cmd_throw(void)
4731 do_cmd_throw_aux(1, FALSE, 0);