3 /* Purpose: Movement commands (part 2) */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
19 void do_cmd_go_up(void)
25 if (p_ptr->special_defense & KATA_MUSOU)
27 set_action(ACTION_NONE);
31 c_ptr = &cave[py][px];
34 if (c_ptr->feat == FEAT_QUEST_UP)
38 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
39 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
41 msg_print("¾å¤Î³¬¤ËÅФä¿¡£");
43 msg_print("You enter the up staircase.");
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)
63 p_ptr->leaving = TRUE;
64 p_ptr->leftbldg = TRUE;
73 /* Normal up stairs? */
74 if (c_ptr->feat != FEAT_LESS && c_ptr->feat != FEAT_LESS_LESS)
77 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
79 msg_print("I see no up staircase here.");
91 quest_type *q_ptr = &quest[p_ptr->inside_quest];
93 /* Confirm leaving from once only quest */
94 if (confirm_quest && p_ptr->inside_quest &&
95 (q_ptr->type == QUEST_TYPE_RANDOM ||
96 (q_ptr->flags & QUEST_FLAG_ONCE &&
97 q_ptr->status != QUEST_STATUS_COMPLETED)))
100 msg_print("¤³¤Î³¬¤ò°ìÅÙµî¤ë¤ÈÆóÅÙ¤ÈÌá¤Ã¤ÆÍè¤é¤ì¤Þ¤»¤ó¡£");
101 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©")) go_up = TRUE;
103 msg_print("You can't come back here once you leave this floor.");
104 if (get_check("Really leave this floor? ")) go_up = TRUE;
113 /* Cancel the command */
116 /* Hack -- take a turn */
119 if (autosave_l) do_cmd_save_game(TRUE);
121 if (p_ptr->inside_quest)
125 if (quest[leaving_quest].type != QUEST_TYPE_RANDOM)
127 p_ptr->inside_quest = c_ptr->special;
132 p_ptr->inside_quest = 0;
140 if (c_ptr->feat == FEAT_LESS_LESS)
142 /* Create a way back */
143 prepare_change_floor_mode(CFM_UP | CFM_SHAFT);
149 /* Create a way back */
150 prepare_change_floor_mode(CFM_UP);
155 /* Get out from current dungeon */
156 if (dun_level - up_num < d_info[dungeon_type].mindepth)
161 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
163 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "go up the stairs to");
168 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
169 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
170 else if (up_num == dun_level)
171 msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
173 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
175 if (up_num == dun_level)
176 msg_print("You go back to the surface.");
178 msg_print("You enter a maze of up staircases.");
182 p_ptr->leaving = TRUE;
189 void do_cmd_go_down(void)
192 bool fall_trap = FALSE;
195 if (p_ptr->special_defense & KATA_MUSOU)
197 set_action(ACTION_NONE);
201 c_ptr = &cave[py][px];
203 if (c_ptr->feat == (FEAT_TRAP_TRAPDOOR)) fall_trap = TRUE;
205 /* Quest down stairs */
206 if (c_ptr->feat == FEAT_QUEST_DOWN)
209 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
210 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
212 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
214 msg_print("You enter the down staircase.");
220 p_ptr->inside_quest = c_ptr->special;
222 /* Activate the quest */
223 if (!quest[p_ptr->inside_quest].status)
225 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
228 /* Leaving a quest */
229 if (!p_ptr->inside_quest)
235 p_ptr->leaving = TRUE;
236 p_ptr->leftbldg = TRUE;
242 else if ((c_ptr->feat != FEAT_MORE) && (c_ptr->feat != FEAT_MORE_MORE) && (c_ptr->feat != FEAT_ENTRANCE) && !fall_trap)
245 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
247 msg_print("I see no down staircase here.");
256 if (ironman_downward && (c_ptr->special != DUNGEON_ANGBAND))
259 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
261 msg_print("The entrance of this dungeon is closed!");
265 if (!max_dlv[c_ptr->special])
268 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[c_ptr->special].name, d_info[c_ptr->special].mindepth);
269 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
271 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);
272 if (!get_check("Do you really get in this dungeon? ")) return;
276 /* Save old player position */
279 dungeon_type = (byte)c_ptr->special;
282 /* Hack -- take a turn */
285 if (autosave_l) do_cmd_save_game(TRUE);
288 if (c_ptr->feat == FEAT_MORE_MORE) down_num += 2;
294 /* Enter the dungeon just now */
295 p_ptr->enter_dungeon = TRUE;
296 down_num = d_info[c_ptr->special].mindepth;
302 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
303 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
305 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fall from trap door");
306 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "go down the stairs to");
313 msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
315 msg_print("You deliberately jump through the trap door.");
321 if(c_ptr->feat == FEAT_ENTRANCE)
324 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
326 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
332 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
333 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
335 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
337 msg_print("You enter a maze of down staircases.");
344 p_ptr->leaving = TRUE;
348 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
352 if (c_ptr->feat == FEAT_MORE_MORE)
354 /* Create a way back */
355 prepare_change_floor_mode(CFM_DOWN | CFM_SHAFT);
359 /* Create a way back */
360 prepare_change_floor_mode(CFM_DOWN);
369 * Simple command to "search" for one turn
371 void do_cmd_search(void)
373 /* Allow repeated command */
376 /* Set repeat count */
377 command_rep = command_arg - 1;
379 /* Redraw the state */
380 p_ptr->redraw |= (PR_STATE);
395 * Determine if a grid contains a chest
397 static s16b chest_check(int y, int x)
399 cave_type *c_ptr = &cave[y][x];
401 s16b this_o_idx, next_o_idx = 0;
404 /* Scan all objects in the grid */
405 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
410 o_ptr = &o_list[this_o_idx];
412 /* Acquire next object */
413 next_o_idx = o_ptr->next_o_idx;
415 /* Skip unknown chests XXX XXX */
416 /* if (!o_ptr->marked) continue; */
418 /* Check for chest */
419 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
428 * Allocates objects upon opening a chest -BEN-
430 * Disperse treasures from the given chest, centered at (x,y).
432 * Small chests often contain "gold", while Large chests always contain
433 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
434 * and Steel chests contain 6 items. The "value" of the items in a
435 * chest is based on the "power" of the chest, which is in turn based
436 * on the level on which the chest is generated.
438 static void chest_death(bool scatter, int y, int x, s16b o_idx)
448 object_type *o_ptr = &o_list[o_idx];
451 /* Small chests often hold "gold" */
452 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
454 /* Determine how much to drop (see above) */
455 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
457 if (o_ptr->sval == SV_CHEST_KANDUME)
462 object_level = o_ptr->xtra3;
466 /* Determine the "value" of the items */
467 object_level = ABS(o_ptr->pval) + 10;
470 /* Zero pval means empty chest */
471 if (!o_ptr->pval) number = 0;
473 /* Opening a chest */
474 opening_chest = TRUE;
476 /* Drop some objects (non-chests) */
477 for (; number > 0; --number)
479 /* Get local object */
482 /* Wipe the object */
485 /* Small chests often drop gold */
486 if (small && (randint0(100) < 25))
489 if (!make_gold(q_ptr)) continue;
492 /* Otherwise drop an item */
495 /* Make a good object */
496 if (!make_object(q_ptr, TRUE, great)) continue;
499 /* If chest scatters its contents, pick any floor square. */
503 for (i = 0; i < 200; i++)
505 /* Pick a totally random spot. */
506 y = randint0(MAX_HGT);
507 x = randint0(MAX_WID);
509 /* Must be an empty floor. */
510 if (!cave_empty_bold(y, x)) continue;
512 /* Place the object there. */
513 drop_near(q_ptr, -1, y, x);
519 /* Normally, drop object near the chest. */
520 else drop_near(q_ptr, -1, y, x);
523 /* Reset the object level */
524 object_level = base_level;
526 /* No longer opening a chest */
527 opening_chest = FALSE;
538 * Chests have traps too.
540 * Exploding chest destroys contents (and traps).
541 * Note that the chest itself is never destroyed.
543 static void chest_trap(int y, int x, s16b o_idx)
547 object_type *o_ptr = &o_list[o_idx];
549 int mon_level = o_ptr->xtra3;
551 /* Ignore disarmed chests */
552 if (o_ptr->pval <= 0) return;
554 /* Obtain the traps */
555 trap = chest_traps[o_ptr->pval];
558 if (trap & (CHEST_LOSE_STR))
561 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
562 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
564 msg_print("A small needle has pricked you!");
565 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
568 (void)do_dec_stat(A_STR);
571 /* Lose constitution */
572 if (trap & (CHEST_LOSE_CON))
575 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
576 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
578 msg_print("A small needle has pricked you!");
579 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
582 (void)do_dec_stat(A_CON);
586 if (trap & (CHEST_POISON))
589 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
591 msg_print("A puff of green gas surrounds you!");
594 if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
596 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
601 if (trap & (CHEST_PARALYZE))
604 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
606 msg_print("A puff of yellow gas surrounds you!");
610 if (!p_ptr->free_act)
612 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
616 /* Summon monsters */
617 if (trap & (CHEST_SUMMON))
619 int num = 2 + randint1(3);
621 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
623 msg_print("You are enveloped in a cloud of smoke!");
627 for (i = 0; i < num; i++)
629 if (randint1(100)<dun_level)
630 activate_hi_summon(py, px, FALSE);
632 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
636 /* Elemental summon. */
637 if (trap & (CHEST_E_SUMMON))
640 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
642 msg_print("Elemental beings appear to protect their treasures!");
644 for (i = 0; i < randint1(3) + 5; i++)
646 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
650 /* Force clouds, then summon birds. */
651 if (trap & (CHEST_BIRD_STORM))
654 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
656 msg_print("A storm of birds swirls around you!");
659 for (i = 0; i < randint1(3) + 3; i++)
660 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
662 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
664 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
668 /* Various colorful summonings. */
669 if (trap & (CHEST_H_SUMMON))
675 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
677 msg_print("Demons materialize in clouds of fire and brimstone!");
680 for (i = 0; i < randint1(3) + 2; i++)
682 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
683 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
687 /* Summon dragons. */
691 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
693 msg_print("Draconic forms loom out of the darkness!");
696 for (i = 0; i < randint1(3) + 2; i++)
698 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
702 /* Summon hybrids. */
706 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
708 msg_print("Creatures strange and twisted assault you!");
711 for (i = 0; i < randint1(5) + 3; i++)
713 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
717 /* Summon vortices (scattered) */
721 msg_print("±²´¬¤«¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
723 msg_print("Vortices coalesce and wreak destruction!");
726 for (i = 0; i < randint1(3) + 2; i++)
728 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
734 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
736 /* Determine how many nasty tricks can be played. */
737 int nasty_tricks_count = 4 + randint0(3);
741 msg_print("¶²¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
743 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
746 /* This is gonna hurt... */
747 for (; nasty_tricks_count > 0; nasty_tricks_count--)
749 /* ...but a high saving throw does help a little. */
750 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
753 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
755 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
757 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
760 if (!p_ptr->free_act)
761 (void)set_paralyzed(p_ptr->paralyzed + 2 +
764 (void)set_stun(p_ptr->stun + 10 +
767 else if (one_in_(3)) apply_disenchant(0);
770 (void)do_dec_stat(A_STR);
771 (void)do_dec_stat(A_DEX);
772 (void)do_dec_stat(A_CON);
773 (void)do_dec_stat(A_INT);
774 (void)do_dec_stat(A_WIS);
775 (void)do_dec_stat(A_CHR);
777 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
782 /* Aggravate monsters. */
783 if (trap & (CHEST_ALARM))
786 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
788 msg_print("An alarm sounds!");
790 aggravate_monsters(0);
794 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
797 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
798 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
800 msg_print("There is a sudden explosion!");
801 msg_print("Everything inside the chest is destroyed!");
805 sound(SOUND_EXPLODE);
807 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
809 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
813 /* Scatter contents. */
814 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
817 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
819 msg_print("The contents of the chest scatter all over the dungeon!");
821 chest_death(TRUE, y, x, o_idx);
828 * Attempt to open the given chest at the given location
830 * Assume there is no monster blocking the destination
832 * Returns TRUE if repeated commands may continue
834 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
842 object_type *o_ptr = &o_list[o_idx];
848 /* Attempt to unlock it */
851 /* Assume locked, and thus not open */
854 /* Get the "disarm" factor */
855 i = p_ptr->skill_dis;
857 /* Penalize some conditions */
858 if (p_ptr->blind || no_lite()) i = i / 10;
859 if (p_ptr->confused || p_ptr->image) i = i / 10;
861 /* Extract the difficulty */
864 /* Always have a small chance of success */
867 /* Success -- May still have traps */
868 if (randint0(100) < j)
871 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
873 msg_print("You have picked the lock.");
880 /* Failure -- Keep trying */
883 /* We may continue repeating */
885 if (flush_failure) flush();
887 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
889 msg_print("You failed to pick the lock.");
895 /* Allowed to open */
898 /* Apply chest traps, if any */
899 chest_trap(y, x, o_idx);
901 /* Let the Chest drop items */
902 chest_death(FALSE, y, x, o_idx);
910 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
913 * Return TRUE if the given feature is an open door
915 static bool is_open(int feat)
917 return (feat == FEAT_OPEN);
922 * Return the number of features around (or under) the character.
923 * Usually look for doors and floor traps.
925 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
927 int d, count, xx, yy;
929 /* Count how many matches */
932 /* Check around (and under) the character */
933 for (d = 0; d < 9; d++)
938 /* if not searching under player continue */
939 if ((d == 8) && !under) continue;
941 /* Extract adjacent (legal) location */
942 yy = py + ddy_ddd[d];
943 xx = px + ddx_ddd[d];
946 c_ptr = &cave[yy][xx];
948 /* Must have knowledge */
949 if (!(c_ptr->info & (CAVE_MARK))) continue;
951 /* Feature code (applying "mimic" field) */
952 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
954 /* Not looking for this feature */
955 if (!((*test)(feat))) continue;
960 /* Remember the location. Only useful if only one match */
971 * Return the number of chests around (or under) the character.
972 * If requested, count only trapped chests.
974 static int count_chests(int *y, int *x, bool trapped)
980 /* Count how many matches */
983 /* Check around (and under) the character */
984 for (d = 0; d < 9; d++)
986 /* Extract adjacent (legal) location */
987 int yy = py + ddy_ddd[d];
988 int xx = px + ddx_ddd[d];
990 /* No (visible) chest is there */
991 if ((o_idx = chest_check(yy, xx)) == 0) continue;
993 /* Grab the object */
994 o_ptr = &o_list[o_idx];
997 if (o_ptr->pval == 0) continue;
999 /* No (known) traps here */
1000 if (trapped && (!object_known_p(o_ptr) ||
1001 !chest_traps[o_ptr->pval])) continue;
1006 /* Remember the location. Only useful if only one match */
1017 * Convert an adjacent location to a direction.
1019 static int coords_to_dir(int y, int x)
1021 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1028 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1030 return d[dx + 1][dy + 1];
1033 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1037 * Perform the basic "open" command on doors
1039 * Assume destination is a closed/locked/jammed door
1041 * Assume there is no monster blocking the destination
1043 * Returns TRUE if repeated commands may continue
1045 static bool do_cmd_open_aux(int y, int x)
1057 /* Get requested grid */
1058 c_ptr = &cave[y][x];
1060 /* Seeing true feature code (ignore mimic) */
1063 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1067 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1069 msg_print("The door appears to be stuck.");
1075 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1078 i = p_ptr->skill_dis;
1080 /* Penalize some conditions */
1081 if (p_ptr->blind || no_lite()) i = i / 10;
1082 if (p_ptr->confused || p_ptr->image) i = i / 10;
1084 /* Extract the lock power */
1085 j = c_ptr->feat - FEAT_DOOR_HEAD;
1087 /* Extract the difficulty XXX XXX XXX */
1090 /* Always have a small chance of success */
1094 if (randint0(100) < j)
1098 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1100 msg_print("You have picked the lock.");
1105 cave_set_feat(y, x, FEAT_OPEN);
1107 /* Update some things */
1108 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1111 sound(SOUND_OPENDOOR);
1121 if (flush_failure) flush();
1125 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1127 msg_print("You failed to pick the lock.");
1131 /* We may keep trying */
1137 else if (c_ptr->feat == FEAT_DOOR_HEAD)
1140 cave_set_feat(y, x, FEAT_OPEN);
1142 /* Update some things */
1143 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1146 sound(SOUND_OPENDOOR);
1156 * Open a closed/locked/jammed door or a closed/locked chest.
1158 * Unlocking a locked door/chest is worth one experience point.
1160 void do_cmd_open(void)
1168 if (p_ptr->special_defense & KATA_MUSOU)
1170 set_action(ACTION_NONE);
1173 #ifdef ALLOW_EASY_OPEN /* TNB */
1175 /* Option: Pick a direction */
1178 int num_doors, num_chests;
1180 /* Count closed doors (locked or jammed) */
1181 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1183 /* Count chests (locked) */
1184 num_chests = count_chests(&y, &x, FALSE);
1186 /* See if only one target */
1187 if (num_doors || num_chests)
1189 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1191 if (!too_many) command_dir = coords_to_dir(y, x);
1195 #endif /* ALLOW_EASY_OPEN -- TNB */
1197 /* Allow repeated command */
1200 /* Set repeat count */
1201 command_rep = command_arg - 1;
1203 /* Redraw the state */
1204 p_ptr->redraw |= (PR_STATE);
1206 /* Cancel the arg */
1210 /* Get a "repeated" direction */
1211 if (get_rep_dir(&dir, TRUE))
1216 /* Get requested location */
1220 /* Get requested grid */
1221 c_ptr = &cave[y][x];
1223 /* Feature code (applying "mimic" field) */
1224 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1226 /* Check for chest */
1227 o_idx = chest_check(y, x);
1229 /* Nothing useful */
1230 if (!is_closed_door(feat) && !o_idx)
1234 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1236 msg_print("You see nothing there to open.");
1241 /* Monster in the way */
1242 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1249 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1251 msg_print("There is a monster in the way!");
1262 /* Open the chest */
1263 more = do_cmd_open_chest(y, x, o_idx);
1270 more = do_cmd_open_aux(y, x);
1274 /* Cancel repeat unless we may continue */
1275 if (!more) disturb(0, 0);
1281 * Perform the basic "close" command
1283 * Assume destination is an open/broken door
1285 * Assume there is no monster blocking the destination
1287 * Returns TRUE if repeated commands may continue
1289 static bool do_cmd_close_aux(int y, int x)
1297 /* Get grid and contents */
1298 c_ptr = &cave[y][x];
1300 /* Seeing true feature code (ignore mimic) */
1303 if (c_ptr->feat == FEAT_BROKEN)
1307 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1309 msg_print("The door appears to be broken.");
1315 else if (c_ptr->feat == FEAT_OPEN)
1317 /* Close the door */
1318 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1320 /* Update some things */
1321 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1324 sound(SOUND_SHUTDOOR);
1333 * Close an open door.
1335 void do_cmd_close(void)
1341 if (p_ptr->special_defense & KATA_MUSOU)
1343 set_action(ACTION_NONE);
1346 #ifdef ALLOW_EASY_OPEN /* TNB */
1348 /* Option: Pick a direction */
1351 /* Count open doors */
1352 if (count_dt(&y, &x, is_open, FALSE) == 1)
1354 command_dir = coords_to_dir(y, x);
1358 #endif /* ALLOW_EASY_OPEN -- TNB */
1360 /* Allow repeated command */
1363 /* Set repeat count */
1364 command_rep = command_arg - 1;
1366 /* Redraw the state */
1367 p_ptr->redraw |= (PR_STATE);
1369 /* Cancel the arg */
1373 /* Get a "repeated" direction */
1374 if (get_rep_dir(&dir,FALSE))
1379 /* Get requested location */
1383 /* Get grid and contents */
1384 c_ptr = &cave[y][x];
1386 /* Feature code (applying "mimic" field) */
1387 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1389 /* Require open/broken door */
1390 if ((feat != FEAT_OPEN) && (feat != FEAT_BROKEN))
1394 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1396 msg_print("You see nothing there to close.");
1401 /* Monster in the way */
1402 else if (c_ptr->m_idx)
1409 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1411 msg_print("There is a monster in the way!");
1419 /* Close the door */
1422 /* Close the door */
1423 more = do_cmd_close_aux(y, x);
1427 /* Cancel repeat unless we may continue */
1428 if (!more) disturb(0, 0);
1433 * Determine if a given grid may be "tunneled"
1435 static bool do_cmd_tunnel_test(int y, int x)
1437 /* Must have knowledge */
1438 if (!(cave[y][x].info & (CAVE_MARK)))
1442 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1444 msg_print("You see nothing there.");
1452 /* Must be a wall/door/etc */
1453 if (cave_floor_bold(y, x))
1457 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1459 msg_print("You see nothing there to tunnel.");
1474 * Tunnel through wall. Assumes valid location.
1476 * Note that it is impossible to "extend" rooms past their
1477 * outer walls (which are actually part of the room).
1479 * This will, however, produce grids which are NOT illuminated
1480 * (or darkened) along with the rest of the room.
1482 static bool twall(int y, int x, byte feat)
1484 cave_type *c_ptr = &cave[y][x];
1486 /* Paranoia -- Require a wall or door or some such */
1487 if (cave_floor_bold(y, x)) return (FALSE);
1489 /* Forget the wall */
1490 c_ptr->info &= ~(CAVE_MARK);
1492 /* Remove the feature */
1493 cave_set_feat(y, x, feat);
1495 /* Update some things */
1496 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1505 * Perform the basic "tunnel" command
1507 * Assumes that the destination is a wall, a vein, a secret
1510 * Assumes that no monster is blocking the destination
1512 * Returns TRUE if repeated commands may continue
1514 static bool do_cmd_tunnel_aux(int y, int x)
1521 /* Verify legality */
1522 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1528 c_ptr = &cave[y][x];
1530 /* Feature code (applying "mimic" field) */
1531 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1537 if ((feat >= FEAT_PERM_EXTRA) &&
1538 (feat <= FEAT_PERM_SOLID))
1541 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1543 msg_print("This seems to be permanent rock.");
1548 /* No tunnelling through mountains */
1549 else if (feat == FEAT_MOUNTAIN)
1552 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1554 msg_print("You can't tunnel through that!");
1559 /* Map border (mimiccing Permanent wall) */
1560 else if ((c_ptr->feat >= FEAT_PERM_EXTRA &&
1561 c_ptr->feat <= FEAT_PERM_SOLID) ||
1562 c_ptr->feat == FEAT_MOUNTAIN)
1565 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1567 msg_print("You can't tunnel through that!");
1572 else if (feat == FEAT_TREES) /* -KMW- */
1575 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1578 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1580 msg_print("You have cleared away the trees.");
1582 chg_virtue(V_DILIGENCE, 1);
1583 chg_virtue(V_NATURE, -1);
1589 /* We may continue chopping */
1591 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1593 msg_print("You chop away at the tree.");
1598 /* Occasional Search XXX XXX */
1599 if (randint0(100) < 25) search();
1605 else if ((feat >= FEAT_WALL_EXTRA) &&
1606 (feat <= FEAT_WALL_SOLID))
1609 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1612 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1614 msg_print("You have finished the tunnel.");
1616 chg_virtue(V_DILIGENCE, 1);
1617 chg_virtue(V_NATURE, -1);
1623 /* We may continue tunelling */
1625 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1627 msg_print("You tunnel into the granite wall.");
1635 /* Quartz / Magma */
1636 else if ((feat >= FEAT_MAGMA) &&
1637 (feat <= FEAT_QUARTZ_K))
1643 /* Found gold (ignore mimic; maybe a hidden treasure) */
1644 if (c_ptr->feat >= FEAT_MAGMA_H &&
1645 c_ptr->feat <= FEAT_QUARTZ_K) gold = TRUE;
1647 /* Extract "quartz" flag XXX XXX XXX */
1648 if ((feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1653 okay = (p_ptr->skill_dig > 20 + randint0(800));
1659 okay = (p_ptr->skill_dig > 10 + randint0(400));
1663 if (okay && twall(y, x, floor_type[randint0(100)]))
1665 /* Found treasure */
1668 /* Place some gold */
1673 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1675 msg_print("You have found something!");
1685 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1687 msg_print("You have finished the tunnel.");
1689 chg_virtue(V_DILIGENCE, 1);
1690 chg_virtue(V_NATURE, -1);
1694 /* Failure (quartz) */
1697 /* Message, continue digging */
1699 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1701 msg_print("You tunnel into the quartz vein.");
1707 /* Failure (magma) */
1710 /* Message, continue digging */
1712 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1714 msg_print("You tunnel into the magma vein.");
1722 else if (feat == FEAT_RUBBLE)
1724 /* Remove the rubble */
1725 if ((p_ptr->skill_dig > randint0(200)) && twall(y, x, floor_type[randint0(100)]))
1729 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1731 msg_print("You have removed the rubble.");
1734 /* Hack -- place an object */
1735 if (randint0(100) < (15 - dun_level/2))
1737 /* Create a simple object */
1738 place_object(y, x, FALSE, FALSE);
1740 /* Observe new object */
1741 if (player_can_see_bold(y, x))
1744 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1746 msg_print("You have found something!");
1755 /* Message, keep digging */
1757 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1759 msg_print("You dig in the rubble.");
1770 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint1(100)]))
1773 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1775 msg_print("You have finished the tunnel.");
1783 /* We may continue tunelling */
1785 msg_print("¥É¥¢¤Ë·ê¤ò³«¤±¤Æ¤¤¤ë¡£");
1787 msg_print("You tunnel into the door.");
1794 if (is_hidden_door(c_ptr))
1796 /* Occasional Search XXX XXX */
1797 if (randint0(100) < 25) search();
1806 * Tunnels through "walls" (including rubble and closed doors)
1808 * Note that you must tunnel in order to hit invisible monsters
1809 * in walls, though moving into walls still takes a turn anyway.
1811 * Digging is very difficult without a "digger" weapon, but can be
1812 * accomplished by strong players using heavy weapons.
1814 void do_cmd_tunnel(void)
1824 if (p_ptr->special_defense & KATA_MUSOU)
1826 set_action(ACTION_NONE);
1829 /* Allow repeated command */
1832 /* Set repeat count */
1833 command_rep = command_arg - 1;
1835 /* Redraw the state */
1836 p_ptr->redraw |= (PR_STATE);
1838 /* Cancel the arg */
1842 /* Get a direction to tunnel, or Abort */
1843 if (get_rep_dir(&dir,FALSE))
1850 c_ptr = &cave[y][x];
1852 /* Feature code (applying "mimic" field) */
1853 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1855 /* No tunnelling through doors */
1856 if (((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL)) ||
1857 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
1858 ((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
1859 (feat == FEAT_MUSEUM))
1863 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1865 msg_print("You cannot tunnel through doors.");
1870 /* No tunnelling through air */
1871 else if (cave_floor_grid(c_ptr) || ((feat >= FEAT_MINOR_GLYPH) &&
1872 (feat <= FEAT_PATTERN_XTRA2)))
1876 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1878 msg_print("You cannot tunnel through air.");
1883 /* No tunnelling through mountains */
1884 else if (feat == FEAT_MOUNTAIN)
1887 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1889 msg_print("You can't tunnel through that!");
1894 /* A monster is in the way */
1895 else if (c_ptr->m_idx)
1902 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1904 msg_print("There is a monster in the way!");
1915 /* Tunnel through walls */
1916 more = do_cmd_tunnel_aux(y, x);
1920 /* Cancel repetition unless we can continue */
1921 if (!more) disturb(0, 0);
1925 #ifdef ALLOW_EASY_OPEN /* TNB */
1930 * If there is a jammed/closed/locked door at the given location,
1931 * then attempt to unlock/open it. Return TRUE if an attempt was
1932 * made (successful or not), otherwise return FALSE.
1934 * The code here should be nearly identical to that in
1935 * do_cmd_open_test() and do_cmd_open_aux().
1937 bool easy_open_door(int y, int x)
1941 cave_type *c_ptr = &cave[y][x];
1943 /* Must be a closed door */
1944 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1945 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1952 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1956 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1958 msg_print("The door appears to be stuck.");
1964 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1967 i = p_ptr->skill_dis;
1969 /* Penalize some conditions */
1970 if (p_ptr->blind || no_lite()) i = i / 10;
1971 if (p_ptr->confused || p_ptr->image) i = i / 10;
1973 /* Extract the lock power */
1974 j = c_ptr->feat - FEAT_DOOR_HEAD;
1976 /* Extract the difficulty XXX XXX XXX */
1979 /* Always have a small chance of success */
1983 if (randint0(100) < j)
1987 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1989 msg_print("You have picked the lock.");
1994 cave_set_feat(y, x, FEAT_OPEN);
1996 /* Update some things */
1997 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2000 sound(SOUND_OPENDOOR);
2010 if (flush_failure) flush();
2014 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2016 msg_print("You failed to pick the lock.");
2026 cave_set_feat(y, x, FEAT_OPEN);
2028 /* Update some things */
2029 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2032 sound(SOUND_OPENDOOR);
2039 #endif /* ALLOW_EASY_OPEN -- TNB */
2043 * Perform the basic "disarm" command
2045 * Assume destination is a visible trap
2047 * Assume there is no monster blocking the destination
2049 * Returns TRUE if repeated commands may continue
2051 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2057 object_type *o_ptr = &o_list[o_idx];
2063 /* Get the "disarm" factor */
2064 i = p_ptr->skill_dis;
2066 /* Penalize some conditions */
2067 if (p_ptr->blind || no_lite()) i = i / 10;
2068 if (p_ptr->confused || p_ptr->image) i = i / 10;
2070 /* Extract the difficulty */
2071 j = i - o_ptr->pval;
2073 /* Always have a small chance of success */
2076 /* Must find the trap first. */
2077 if (!object_known_p(o_ptr))
2080 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2082 msg_print("I don't see any traps.");
2087 /* Already disarmed/unlocked */
2088 else if (o_ptr->pval <= 0)
2091 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2093 msg_print("The chest is not trapped.");
2098 /* No traps to find. */
2099 else if (!chest_traps[o_ptr->pval])
2102 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2104 msg_print("The chest is not trapped.");
2109 /* Success (get a lot of experience) */
2110 else if (randint0(100) < j)
2113 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2115 msg_print("You have disarmed the chest.");
2118 gain_exp(o_ptr->pval);
2119 o_ptr->pval = (0 - o_ptr->pval);
2122 /* Failure -- Keep trying */
2123 else if ((i > 5) && (randint1(i) > 5))
2125 /* We may keep trying */
2127 if (flush_failure) flush();
2129 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2131 msg_print("You failed to disarm the chest.");
2136 /* Failure -- Set off the trap */
2140 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2142 msg_print("You set off a trap!");
2146 chest_trap(y, x, o_idx);
2155 * Perform the basic "disarm" command
2157 * Assume destination is a visible trap
2159 * Assume there is no monster blocking the destination
2161 * Returns TRUE if repeated commands may continue
2163 #ifdef ALLOW_EASY_DISARM /* TNB */
2165 bool do_cmd_disarm_aux(int y, int x, int dir)
2167 #else /* ALLOW_EASY_DISARM -- TNB */
2169 static bool do_cmd_disarm_aux(int y, int x, int dir)
2171 #endif /* ALLOW_EASY_DISARM -- TNB */
2185 /* Get grid and contents */
2186 c_ptr = &cave[y][x];
2188 /* Access trap name */
2189 name = (f_name + f_info[c_ptr->feat].name);
2191 /* Get the "disarm" factor */
2192 i = p_ptr->skill_dis;
2194 /* Penalize some conditions */
2195 if (p_ptr->blind || no_lite()) i = i / 10;
2196 if (p_ptr->confused || p_ptr->image) i = i / 10;
2198 /* Variable power! */
2200 /* Extract trap "power" */
2201 switch (c_ptr->feat)
2203 case FEAT_TRAP_OPEN:
2204 case FEAT_TRAP_ARMAGEDDON:
2205 case FEAT_TRAP_PIRANHA:
2206 /* Special traps are very difficult to disarm */
2214 /* Extract the difficulty */
2217 /* Always have a small chance of success */
2221 if (randint0(100) < j)
2225 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2227 msg_format("You have disarmed the %s.", name);
2234 /* Forget the trap */
2235 c_ptr->info &= ~(CAVE_MARK);
2237 /* Remove the trap */
2238 cave_set_feat(y, x, floor_type[randint0(100)]);
2240 #ifdef ALLOW_EASY_DISARM /* TNB */
2242 /* Move the player onto the trap */
2243 move_player(dir, easy_disarm, FALSE);
2245 #else /* ALLOW_EASY_DISARM -- TNB */
2247 /* move the player onto the trap grid */
2248 move_player(dir, FALSE, FALSE);
2250 #endif /* ALLOW_EASY_DISARM -- TNB */
2253 /* Failure -- Keep trying */
2254 else if ((i > 5) && (randint1(i) > 5))
2257 if (flush_failure) flush();
2261 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2263 msg_format("You failed to disarm the %s.", name);
2267 /* We may keep trying */
2271 /* Failure -- Set off the trap */
2276 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2278 msg_format("You set off the %s!", name);
2282 #ifdef ALLOW_EASY_DISARM /* TNB */
2284 /* Move the player onto the trap */
2285 move_player(dir, easy_disarm, FALSE);
2287 #else /* ALLOW_EASY_DISARM -- TNB */
2289 /* Move the player onto the trap */
2290 move_player(dir, FALSE, FALSE);
2292 #endif /* ALLOW_EASY_DISARM -- TNB */
2301 * Disarms a trap, or chest
2303 void do_cmd_disarm(void)
2311 if (p_ptr->special_defense & KATA_MUSOU)
2313 set_action(ACTION_NONE);
2316 #ifdef ALLOW_EASY_DISARM /* TNB */
2318 /* Option: Pick a direction */
2321 int num_traps, num_chests;
2323 /* Count visible traps */
2324 num_traps = count_dt(&y, &x, is_trap, TRUE);
2326 /* Count chests (trapped) */
2327 num_chests = count_chests(&y, &x, TRUE);
2329 /* See if only one target */
2330 if (num_traps || num_chests)
2332 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2334 if (!too_many) command_dir = coords_to_dir(y, x);
2338 #endif /* ALLOW_EASY_DISARM -- TNB */
2340 /* Allow repeated command */
2343 /* Set repeat count */
2344 command_rep = command_arg - 1;
2346 /* Redraw the state */
2347 p_ptr->redraw |= (PR_STATE);
2349 /* Cancel the arg */
2353 /* Get a direction (or abort) */
2354 if (get_rep_dir(&dir,TRUE))
2363 /* Get grid and contents */
2364 c_ptr = &cave[y][x];
2366 /* Feature code (applying "mimic" field) */
2367 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2369 /* Check for chests */
2370 o_idx = chest_check(y, x);
2373 if (!is_trap(feat) && !o_idx)
2377 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2379 msg_print("You see nothing there to disarm.");
2384 /* Monster in the way */
2385 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2389 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2391 msg_print("There is a monster in the way!");
2402 /* Disarm the chest */
2403 more = do_cmd_disarm_chest(y, x, o_idx);
2409 /* Disarm the trap */
2410 more = do_cmd_disarm_aux(y, x, dir);
2414 /* Cancel repeat unless told not to */
2415 if (!more) disturb(0, 0);
2420 * Perform the basic "bash" command
2422 * Assume destination is a closed/locked/jammed door
2424 * Assume there is no monster blocking the destination
2426 * Returns TRUE if repeated commands may continue
2428 static bool do_cmd_bash_aux(int y, int x, int dir)
2441 c_ptr = &cave[y][x];
2445 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2447 msg_print("You smash into the door!");
2451 /* Hack -- Bash power based on strength */
2452 /* (Ranges from 3 to 20 to 100 to 200) */
2453 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2455 /* Extract door power */
2456 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2458 /* Compare bash power to door power XXX XXX XXX */
2459 temp = (bash - (temp * 10));
2461 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2463 /* Hack -- always have a chance */
2464 if (temp < 1) temp = 1;
2466 /* Hack -- attempt to bash down the door */
2467 if (randint0(100) < temp)
2471 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2473 msg_print("The door crashes open!");
2477 /* Break down the door */
2478 if (randint0(100) < 50)
2480 cave_set_feat(y, x, FEAT_BROKEN);
2486 cave_set_feat(y, x, FEAT_OPEN);
2490 sound(SOUND_OPENDOOR);
2492 /* Hack -- Fall through the door */
2493 move_player(dir, FALSE, FALSE);
2495 /* Update some things */
2496 p_ptr->update |= (PU_VIEW | PU_LITE);
2497 p_ptr->update |= (PU_DISTANCE);
2500 /* Saving throw against stun */
2501 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2506 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2508 msg_print("The door holds firm.");
2512 /* Allow repeated bashing */
2516 /* High dexterity yields coolness */
2521 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2523 msg_print("You are off-balance.");
2527 /* Hack -- Lose balance ala paralysis */
2528 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2537 * Bash open a door, success based on character strength
2539 * For a closed door, pval is positive if locked; negative if stuck.
2541 * For an open door, pval is positive for a broken door.
2543 * A closed door can be opened - harder if locked. Any door might be
2544 * bashed open (and thereby broken). Bashing a door is (potentially)
2545 * faster! You move into the door way. To open a stuck door, it must
2546 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2548 * Creatures can also open or bash doors, see elsewhere.
2550 void do_cmd_bash(void)
2559 if (p_ptr->special_defense & KATA_MUSOU)
2561 set_action(ACTION_NONE);
2564 /* Allow repeated command */
2567 /* Set repeat count */
2568 command_rep = command_arg - 1;
2570 /* Redraw the state */
2571 p_ptr->redraw |= (PR_STATE);
2573 /* Cancel the arg */
2577 /* Get a "repeated" direction */
2578 if (get_rep_dir(&dir,FALSE))
2587 c_ptr = &cave[y][x];
2589 /* Feature code (applying "mimic" field) */
2590 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2592 /* Nothing useful */
2593 if (!((feat >= FEAT_DOOR_HEAD) &&
2594 (feat <= FEAT_DOOR_TAIL)))
2598 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2600 msg_print("You see nothing there to bash.");
2605 /* Monster in the way */
2606 else if (c_ptr->m_idx)
2613 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2615 msg_print("There is a monster in the way!");
2623 /* Bash a closed door */
2627 more = do_cmd_bash_aux(y, x, dir);
2631 /* Unless valid action taken, cancel bash */
2632 if (!more) disturb(0, 0);
2637 * Manipulate an adjacent grid in some way
2639 * Attack monsters, tunnel through walls, disarm traps, open doors.
2641 * Consider confusion XXX XXX XXX
2643 * This command must always take a turn, to prevent free detection
2644 * of invisible monsters.
2646 void do_cmd_alter(void)
2655 if (p_ptr->special_defense & KATA_MUSOU)
2657 set_action(ACTION_NONE);
2660 /* Allow repeated command */
2663 /* Set repeat count */
2664 command_rep = command_arg - 1;
2666 /* Redraw the state */
2667 p_ptr->redraw |= (PR_STATE);
2669 /* Cancel the arg */
2673 /* Get a direction */
2674 if (get_rep_dir(&dir,TRUE))
2683 c_ptr = &cave[y][x];
2685 /* Feature code (applying "mimic" field) */
2686 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2691 /* Attack monsters */
2698 /* Tunnel through walls */
2699 else if (((feat >= FEAT_RUBBLE) &&
2700 (feat < FEAT_MINOR_GLYPH)) ||
2701 ((feat == FEAT_TREES) ||
2702 (feat == FEAT_MOUNTAIN)))
2704 more = do_cmd_tunnel_aux(y, x);
2707 else if (is_closed_door(feat))
2709 /* Bash jammed doors */
2710 if (feat >= FEAT_DOOR_HEAD + 0x08)
2712 more = do_cmd_bash_aux(y, x, dir);
2718 more = do_cmd_open_aux(y, x);
2722 /* Close open doors */
2723 else if ((feat == FEAT_OPEN) ||
2724 (feat == FEAT_BROKEN))
2726 more = do_cmd_close_aux(y, x);
2730 else if (is_trap(feat))
2732 more = do_cmd_disarm_aux(y, x, dir);
2740 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2742 msg_print("You attack the empty air.");
2748 /* Cancel repetition unless we can continue */
2749 if (!more) disturb(0, 0);
2754 * Find the index of some "spikes", if possible.
2756 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2758 static bool get_spike(int *ip)
2762 /* Check every item in the pack */
2763 for (i = 0; i < INVEN_PACK; i++)
2765 object_type *o_ptr = &inventory[i];
2767 /* Skip non-objects */
2768 if (!o_ptr->k_idx) continue;
2770 /* Check the "tval" code */
2771 if (o_ptr->tval == TV_SPIKE)
2773 /* Save the spike index */
2787 * Jam a closed door with a spike
2789 * This command may NOT be repeated
2791 void do_cmd_spike(void)
2795 if (p_ptr->special_defense & KATA_MUSOU)
2797 set_action(ACTION_NONE);
2800 /* Get a "repeated" direction */
2801 if (get_rep_dir(&dir,FALSE))
2811 /* Get grid and contents */
2812 c_ptr = &cave[y][x];
2814 /* Feature code (applying "mimic" field) */
2815 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2817 /* Require closed door */
2818 if (!((feat >= FEAT_DOOR_HEAD) &&
2819 (feat <= FEAT_DOOR_TAIL)))
2823 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2825 msg_print("You see nothing there to spike.");
2831 else if (!get_spike(&item))
2835 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2837 msg_print("You have no spikes!");
2842 /* Is a monster in the way? */
2843 else if (c_ptr->m_idx)
2850 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2852 msg_print("There is a monster in the way!");
2866 /* Successful jamming */
2868 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2870 msg_print("You jam the door with a spike.");
2874 /* Convert "locked" to "stuck" XXX XXX XXX */
2875 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2877 /* Add one spike to the door */
2878 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2880 /* Use up, and describe, a single spike, from the bottom */
2881 inven_item_increase(item, -1);
2882 inven_item_describe(item);
2883 inven_item_optimize(item);
2891 * Support code for the "Walk" and "Jump" commands
2893 void do_cmd_walk(int pickup)
2900 /* Allow repeated command */
2903 /* Set repeat count */
2904 command_rep = command_arg - 1;
2906 /* Redraw the state */
2907 p_ptr->redraw |= (PR_STATE);
2909 /* Cancel the arg */
2913 /* Get a "repeated" direction */
2914 if (get_rep_dir(&dir,FALSE))
2919 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2921 set_action(ACTION_NONE);
2924 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2925 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2926 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2928 /* Actually move the character */
2929 move_player(dir, pickup, FALSE);
2931 /* Allow more walking */
2935 /* Hack again -- Is there a special encounter ??? */
2936 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2938 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2941 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2943 /* Inform the player of his horrible fate :=) */
2945 msg_print("½±·â¤À¡ª");
2947 msg_print("You are ambushed !");
2950 /* Go into large wilderness view */
2951 p_ptr->wilderness_x = px;
2952 p_ptr->wilderness_y = py;
2953 p_ptr->oldpy = randint1(MAX_HGT-2);
2954 p_ptr->oldpx = randint1(MAX_WID-2);
2958 /* HACk -- set the encouter flag for the wilderness generation */
2959 generate_encounter = TRUE;
2963 /* Cancel repeat unless we may continue */
2964 if (!more) disturb(0, 0);
2972 void do_cmd_run(void)
2976 /* Hack -- no running when confused */
2977 if (p_ptr->confused)
2980 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2982 msg_print("You are too confused!");
2988 if (p_ptr->special_defense & KATA_MUSOU)
2990 set_action(ACTION_NONE);
2993 /* Get a "repeated" direction */
2994 if (get_rep_dir(&dir,FALSE))
2996 /* Hack -- Set the run counter */
2997 running = (command_arg ? command_arg : 1000);
3007 * Stay still. Search. Enter stores.
3008 * Pick up treasure if "pickup" is true.
3010 void do_cmd_stay(int pickup)
3012 cave_type *c_ptr = &cave[py][px];
3015 /* Allow repeated command */
3018 /* Set repeat count */
3019 command_rep = command_arg - 1;
3021 /* Redraw the state */
3022 p_ptr->redraw |= (PR_STATE);
3024 /* Cancel the arg */
3033 /* Spontaneous Searching */
3034 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3039 /* Continuous Searching */
3040 if (p_ptr->action == ACTION_SEARCH)
3046 /* Handle "objects" */
3050 /* Hack -- enter a store if we are on one */
3051 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3052 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3053 (c_ptr->feat == FEAT_MUSEUM))
3059 /* Hack -- enter store */
3060 command_new = SPECIAL_KEY_STORE;
3063 /* Hack -- enter a building if we are on one -KMW- */
3064 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3065 (c_ptr->feat <= FEAT_BLDG_TAIL))
3071 /* Hack -- enter building */
3072 command_new = SPECIAL_KEY_BUILDING;
3075 /* Exit a quest if reach the quest exit */
3076 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3078 int q_index = p_ptr->inside_quest;
3080 /* Was quest completed? */
3081 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3083 quest[q_index].status = QUEST_STATUS_COMPLETED;
3084 quest[q_index].complev = (byte)p_ptr->lev;
3086 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3088 msg_print("You accomplished your quest!");
3094 leave_quest_check();
3096 p_ptr->inside_quest = cave[py][px].special;
3100 p_ptr->leaving = TRUE;
3107 * Resting allows a player to safely restore his hp -RAK-
3109 void do_cmd_rest(void)
3112 set_action(ACTION_NONE);
3114 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3119 /* Prompt for time if needed */
3120 if (command_arg <= 0)
3123 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3125 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3132 strcpy(out_val, "&");
3134 /* Ask for duration */
3135 if (!get_string(p, out_val, 4)) return;
3137 /* Rest until done */
3138 if (out_val[0] == '&')
3144 else if (out_val[0] == '*')
3152 command_arg = atoi(out_val);
3153 if (command_arg <= 0) return;
3159 if (command_arg > 9999) command_arg = 9999;
3161 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3163 /* Take a turn XXX XXX XXX (?) */
3166 /* The sin of sloth */
3167 if (command_arg > 100)
3168 chg_virtue(V_DILIGENCE, -1);
3170 /* Why are you sleeping when there's no need? WAKE UP!*/
3171 if ((p_ptr->chp == p_ptr->mhp) &&
3172 (p_ptr->csp == p_ptr->msp) &&
3173 !p_ptr->blind && !p_ptr->confused &&
3174 !p_ptr->poisoned && !p_ptr->afraid &&
3175 !p_ptr->stun && !p_ptr->cut &&
3176 !p_ptr->slow && !p_ptr->paralyzed &&
3177 !p_ptr->image && !p_ptr->word_recall &&
3178 !p_ptr->alter_reality)
3179 chg_virtue(V_DILIGENCE, -1);
3181 /* Save the rest code */
3182 resting = command_arg;
3183 p_ptr->action = ACTION_REST;
3185 /* Recalculate bonuses */
3186 p_ptr->update |= (PU_BONUS);
3188 /* Redraw the state */
3189 p_ptr->redraw |= (PR_STATE);
3200 * Determines the odds of an object breaking when thrown at a monster
3202 * Note that artifacts never break, see the "drop_near()" function.
3204 static int breakage_chance(object_type *o_ptr)
3206 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3208 /* Examine the item type */
3209 switch (o_ptr->tval)
3225 /* Sometimes break */
3230 return (20 - archer_bonus * 2);
3235 return (10 - archer_bonus);
3242 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3246 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3248 u32b flgs[TR_FLAG_SIZE];
3250 /* Extract the flags */
3251 object_flags(o_ptr, flgs);
3253 /* Some "weapons" and "ammo" do extra damage */
3254 switch (o_ptr->tval)
3261 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3262 (r_ptr->flags3 & RF3_ANIMAL))
3266 r_ptr->r_flags3 |= RF3_ANIMAL;
3269 if (mult < 17) mult = 17;
3273 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3274 (r_ptr->flags3 & RF3_ANIMAL))
3278 r_ptr->r_flags3 |= RF3_ANIMAL;
3281 if (mult < 27) mult = 27;
3285 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3286 (r_ptr->flags3 & RF3_EVIL))
3290 r_ptr->r_flags3 |= RF3_EVIL;
3293 if (mult < 15) mult = 15;
3297 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3298 (r_ptr->flags3 & RF3_EVIL))
3302 r_ptr->r_flags3 |= RF3_EVIL;
3305 if (mult < 25) mult = 25;
3309 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3310 (r_ptr->flags2 & RF2_HUMAN))
3314 r_ptr->r_flags2 |= RF2_HUMAN;
3317 if (mult < 17) mult = 17;
3321 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3322 (r_ptr->flags2 & RF2_HUMAN))
3326 r_ptr->r_flags2 |= RF2_HUMAN;
3329 if (mult < 27) mult = 27;
3333 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3334 (r_ptr->flags3 & RF3_UNDEAD))
3338 r_ptr->r_flags3 |= RF3_UNDEAD;
3341 if (mult < 20) mult = 20;
3345 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3346 (r_ptr->flags3 & RF3_UNDEAD))
3350 r_ptr->r_flags3 |= RF3_UNDEAD;
3353 if (mult < 30) mult = 30;
3357 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3358 (r_ptr->flags3 & RF3_DEMON))
3362 r_ptr->r_flags3 |= RF3_DEMON;
3365 if (mult < 20) mult = 20;
3369 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3370 (r_ptr->flags3 & RF3_DEMON))
3374 r_ptr->r_flags3 |= RF3_DEMON;
3377 if (mult < 30) mult = 30;
3381 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3382 (r_ptr->flags3 & RF3_ORC))
3386 r_ptr->r_flags3 |= RF3_ORC;
3389 if (mult < 20) mult = 20;
3393 if ((have_flag(flgs, TR_KILL_ORC)) &&
3394 (r_ptr->flags3 & RF3_ORC))
3398 r_ptr->r_flags3 |= RF3_ORC;
3401 if (mult < 30) mult = 30;
3405 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3406 (r_ptr->flags3 & RF3_TROLL))
3410 r_ptr->r_flags3 |= RF3_TROLL;
3413 if (mult < 20) mult = 20;
3417 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3418 (r_ptr->flags3 & RF3_TROLL))
3422 r_ptr->r_flags3 |= RF3_TROLL;
3425 if (mult < 30) mult = 30;
3429 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3430 (r_ptr->flags3 & RF3_GIANT))
3434 r_ptr->r_flags3 |= RF3_GIANT;
3437 if (mult < 20) mult = 20;
3441 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3442 (r_ptr->flags3 & RF3_GIANT))
3446 r_ptr->r_flags3 |= RF3_GIANT;
3449 if (mult < 30) mult = 30;
3453 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3454 (r_ptr->flags3 & RF3_DRAGON))
3458 r_ptr->r_flags3 |= RF3_DRAGON;
3461 if (mult < 20) mult = 20;
3464 /* Execute Dragon */
3465 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3466 (r_ptr->flags3 & RF3_DRAGON))
3470 r_ptr->r_flags3 |= RF3_DRAGON;
3473 if (mult < 30) mult = 30;
3475 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3476 (m_ptr->r_idx == MON_SMAUG) &&
3477 (inventory[INVEN_BOW].name1 == ART_BARD))
3482 if ((have_flag(flgs, TR_BRAND_ACID)) || (p_ptr->special_attack & (ATTACK_ACID)))
3484 /* Notice immunity */
3485 if (r_ptr->flags3 & RF3_IM_ACID)
3489 r_ptr->r_flags3 |= RF3_IM_ACID;
3493 /* Otherwise, take the damage */
3496 if (mult < 17) mult = 17;
3501 if ((have_flag(flgs, TR_BRAND_ELEC)) || (p_ptr->special_attack & (ATTACK_ELEC)))
3503 /* Notice immunity */
3504 if (r_ptr->flags3 & RF3_IM_ELEC)
3508 r_ptr->r_flags3 |= RF3_IM_ELEC;
3512 /* Otherwise, take the damage */
3515 if (mult < 17) mult = 17;
3520 if ((have_flag(flgs, TR_BRAND_FIRE)) || (p_ptr->special_attack & (ATTACK_FIRE)))
3522 /* Notice immunity */
3523 if (r_ptr->flags3 & RF3_IM_FIRE)
3527 r_ptr->r_flags3 |= RF3_IM_FIRE;
3531 /* Otherwise, take the damage */
3534 if (mult < 17) mult = 17;
3539 if ((have_flag(flgs, TR_BRAND_COLD)) || (p_ptr->special_attack & (ATTACK_COLD)))
3541 /* Notice immunity */
3542 if (r_ptr->flags3 & RF3_IM_COLD)
3546 r_ptr->r_flags3 |= RF3_IM_COLD;
3549 /* Otherwise, take the damage */
3552 if (mult < 17) mult = 17;
3556 /* Brand (Poison) */
3557 if ((have_flag(flgs, TR_BRAND_POIS)) || (p_ptr->special_attack & (ATTACK_POIS)))
3559 /* Notice immunity */
3560 if (r_ptr->flags3 & RF3_IM_POIS)
3564 r_ptr->r_flags3 |= RF3_IM_POIS;
3568 /* Otherwise, take the damage */
3571 if (mult < 17) mult = 17;
3575 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3577 p_ptr->csp -= (1+(p_ptr->msp / 30));
3578 p_ptr->redraw |= (PR_MANA);
3579 mult = mult * 5 / 2;
3585 /* Return the total damage */
3586 return (tdam * mult / 10);
3591 * Fire an object from the pack or floor.
3593 * You may only fire items that "match" your missile launcher.
3595 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3597 * See "calc_bonuses()" for more calculations and such.
3599 * Note that "firing" a missile is MUCH better than "throwing" it.
3601 * Note: "unseen" monsters are very hard to hit.
3603 * Objects are more likely to break if they "attempt" to hit a monster.
3605 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3607 * The "extra shot" code works by decreasing the amount of energy
3608 * required to make each shot, spreading the shots out over time.
3610 * Note that when firing missiles, the launcher multiplier is applied
3611 * after all the bonuses are added in, making multipliers very useful.
3613 * Note that Bows of "Extra Might" get extra range and an extra bonus
3614 * for the damage multiplier.
3616 * Note that Bows of "Extra Shots" give an extra shot.
3618 void do_cmd_fire_aux(int item, object_type *j_ptr)
3621 int j, y, x, ny, nx, ty, tx;
3622 int tdam, tdis, thits, tmul;
3624 int cur_dis, visible;
3631 bool hit_body = FALSE;
3633 char o_name[MAX_NLEN];
3635 int msec = delay_factor * delay_factor * delay_factor;
3638 bool stick_to = FALSE;
3640 /* Access the item (if in the pack) */
3643 o_ptr = &inventory[item];
3647 o_ptr = &o_list[0 - item];
3650 /* Describe the object */
3651 object_desc(o_name, o_ptr, FALSE, 3);
3654 /* Use the proper number of shots */
3655 thits = p_ptr->num_fire;
3657 /* Use a base distance */
3660 /* Base damage from thrown object plus launcher bonus */
3661 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3663 /* Actually "fire" the object */
3664 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3665 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3666 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval])/400 + bonus) * BTH_PLUS_ADJ);
3668 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3670 energy_use = bow_energy(j_ptr->sval);
3671 tmul = bow_tmul(j_ptr->sval);
3673 /* Get extra "power" from "extra might" */
3674 if (p_ptr->xtra_might) tmul++;
3676 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3678 /* Boost the damage */
3683 tdis = 10 + tmul/40;
3684 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3687 project_length = tdis + 1;
3689 /* Get a direction (or cancel) */
3690 if (!get_aim_dir(&dir))
3694 /* need not to reset project_length (already did)*/
3698 project_length = 0; /* reset to default */
3700 /* Get local object */
3703 /* Obtain a local object */
3704 object_copy(q_ptr, o_ptr);
3709 /* Reduce and describe inventory */
3712 inven_item_increase(item, -1);
3713 inven_item_describe(item);
3714 inven_item_optimize(item);
3717 /* Reduce and describe floor item */
3720 floor_item_increase(0 - item, -1);
3721 floor_item_optimize(0 - item);
3729 /* Take a (partial) turn */
3730 energy_use = (energy_use / thits);
3733 /* Start at the player */
3737 /* Predict the "target" location */
3738 tx = px + 99 * ddx[dir];
3739 ty = py + 99 * ddy[dir];
3741 /* Check for "target request" */
3742 if ((dir == 5) && target_okay())
3749 /* Hack -- Handle stuff */
3753 /* Travel until stopped */
3754 for (cur_dis = 0; cur_dis <= tdis; )
3756 /* Hack -- Stop at the target */
3757 if ((y == ty) && (x == tx)) break;
3759 /* Calculate the new location (see "project()") */
3762 mmove2(&ny, &nx, py, px, ty, tx);
3764 /* Stopped by walls/doors */
3765 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3767 /* Advance the distance */
3771 /* The player can see the (on screen) missile */
3772 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3774 char c = object_char(q_ptr);
3775 byte a = object_attr(q_ptr);
3777 /* Draw, Hilite, Fresh, Pause, Erase */
3778 print_rel(c, a, ny, nx);
3779 move_cursor_relative(ny, nx);
3781 Term_xtra(TERM_XTRA_DELAY, msec);
3786 /* The player cannot see the missile */
3789 /* Pause anyway, for consistancy */
3790 Term_xtra(TERM_XTRA_DELAY, msec);
3793 /* Save the new location */
3798 /* Monster here, Try to hit it */
3799 if (cave[y][x].m_idx)
3801 cave_type *c_ptr = &cave[y][x];
3803 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3804 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3806 /* Check the visibility */
3807 visible = m_ptr->ml;
3809 /* Note the collision */
3814 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3815 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3818 if ((r_ptr->level + 10) > p_ptr->lev)
3820 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3821 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3824 if (now_exp < 4000) amount = 80;
3825 else if (now_exp < 6000) amount = 25;
3826 else if ((now_exp < 7000) && (p_ptr->lev > 19)) amount = 10;
3827 else if (p_ptr->lev > 34) amount = 2;
3828 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3829 p_ptr->update |= (PU_BONUS);
3835 if (p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING] && ((p_ptr->skill_exp[GINOU_RIDING] - 1000) / 200 < r_info[m_list[p_ptr->riding].r_idx].level) && one_in_(2))
3837 p_ptr->skill_exp[GINOU_RIDING]+=1;
3838 p_ptr->update |= (PU_BONUS);
3842 /* Did we hit it (penalize range) */
3843 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3847 /* Assume a default death */
3849 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3851 cptr note_dies = " dies.";
3854 /* Some monsters get "destroyed" */
3855 if (!monster_living(r_ptr))
3858 bool explode = FALSE;
3860 for (i = 0; i < 4; i++)
3862 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3865 /* Special note at death */
3868 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3870 note_dies = " explodes into tiny shreds.";
3874 note_dies = "¤òÅݤ·¤¿¡£";
3876 note_dies = " is destroyed.";
3881 /* Handle unseen monster */
3884 /* Invisible monster */
3886 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3888 msg_format("The %s finds a mark.", o_name);
3893 /* Handle visible monster */
3898 /* Get "the monster" or "it" */
3899 monster_desc(m_name, m_ptr, 0);
3903 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3905 msg_format("The %s hits %s.", o_name, m_name);
3909 /* Hack -- Track this monster race */
3910 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3912 /* Hack -- Track this monster */
3913 if (m_ptr->ml) health_track(c_ptr->m_idx);
3916 /* Apply special damage XXX XXX XXX */
3917 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3918 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3920 /* No negative damage */
3921 if (tdam < 0) tdam = 0;
3923 /* Modify the damage */
3924 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3926 /* Complex message */
3927 if (p_ptr->wizard || cheat_xtra)
3930 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3933 msg_format("You do %d (out of %d) damage.",
3939 /* Hit the monster, check for death */
3940 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3953 monster_desc(m_name, m_ptr, 0);
3957 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3959 msg_format("%^s have stuck into %s!",o_name, m_name);
3964 message_pain(c_ptr->m_idx, tdam);
3966 /* Anger the monster */
3967 if (tdam > 0) anger_monster(m_ptr);
3970 if (fear && m_ptr->ml)
3977 /* Get the monster name (or "it") */
3978 monster_desc(m_name, m_ptr, 0);
3982 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3984 msg_format("%^s flees in terror!", m_name);
3988 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3990 set_target(m_ptr, py, px);
4000 /* Chance of breakage (during attacks) */
4001 j = (hit_body ? breakage_chance(q_ptr) : 0);
4005 int m_idx = cave[y][x].m_idx;
4006 monster_type *m_ptr = &m_list[m_idx];
4007 int o_idx = o_pop();
4012 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
4014 msg_format("The %s have gone to somewhere.", o_name);
4018 a_info[j_ptr->name1].cur_num = 0;
4023 o_ptr = &o_list[ o_idx ];
4024 object_copy(o_ptr, q_ptr);
4029 /* Forget location */
4030 o_ptr->iy = o_ptr->ix = 0;
4032 /* Memorize monster */
4033 o_ptr->held_m_idx = m_idx;
4036 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4039 m_ptr->hold_o_idx = o_idx;
4043 /* Drop (or break) near that location */
4044 (void)drop_near(q_ptr, j, y, x);
4048 void do_cmd_fire(void)
4054 /* Get the "bow" (if any) */
4055 j_ptr = &inventory[INVEN_BOW];
4057 /* Require a launcher */
4061 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4063 msg_print("You have nothing to fire with.");
4069 if (j_ptr->sval == SV_CRIMSON)
4072 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4074 msg_print("Do activate.");
4081 if (p_ptr->special_defense & KATA_MUSOU)
4083 set_action(ACTION_NONE);
4086 /* Require proper missile */
4087 item_tester_tval = p_ptr->tval_ammo;
4091 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4092 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4094 q = "Fire which item? ";
4095 s = "You have nothing to fire.";
4098 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4105 do_cmd_fire_aux(item, j_ptr);
4109 static bool item_tester_hook_boomerang(object_type *o_ptr)
4111 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4119 * Throw an object from the pack or floor.
4121 * Note: "unseen" monsters are very hard to hit.
4123 * Should throwing a weapon do full damage? Should it allow the magic
4124 * to hit bonus of the weapon to have an effect? Should it ever cause
4125 * the item to be destroyed? Should it do any damage at all?
4127 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4130 int i, j, y, x, ty, tx;
4132 int chance, tdam, tdis;
4134 int cur_dis, visible;
4141 bool hit_body = FALSE;
4142 bool hit_wall = FALSE;
4143 bool equiped_item = FALSE;
4144 bool return_when_thrown = FALSE;
4146 char o_name[MAX_NLEN];
4148 int msec = delay_factor * delay_factor * delay_factor;
4150 u32b flgs[TR_FLAG_SIZE];
4152 bool come_back = FALSE;
4153 bool do_drop = TRUE;
4156 if (p_ptr->special_defense & KATA_MUSOU)
4158 set_action(ACTION_NONE);
4167 if (buki_motteruka(INVEN_LARM))
4169 item_tester_hook = item_tester_hook_boomerang;
4171 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4172 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4174 q = "Throw which item? ";
4175 s = "You have nothing to throw.";
4178 if (!get_item(&item, q, s, (USE_EQUIP)))
4193 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4194 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4196 q = "Throw which item? ";
4197 s = "You have nothing to throw.";
4200 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4207 /* Access the item (if in the pack) */
4210 o_ptr = &inventory[item];
4214 o_ptr = &o_list[0 - item];
4218 /* Item is cursed */
4219 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4223 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4225 msg_print("Hmmm, it seems to be cursed.");
4232 if (p_ptr->inside_arena)
4234 if (o_ptr->tval != 5)
4237 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4239 msg_print("You're in the arena now. This is hand-to-hand!");
4248 /* Get local object */
4251 /* Obtain a local object */
4252 object_copy(q_ptr, o_ptr);
4254 /* Extract the thrown object's flags. */
4255 object_flags(q_ptr, flgs);
4257 /* Distribute the charges of rods/wands between the stacks */
4258 distribute_charges(o_ptr, q_ptr, 1);
4264 object_desc(o_name, q_ptr, FALSE, 3);
4266 if (p_ptr->mighty_throw) mult += 3;
4268 /* Extract a "distance multiplier" */
4269 /* Changed for 'launcher' mutation */
4270 mul = 10 + 2 * (mult - 1);
4272 /* Enforce a minimum "weight" of one pound */
4273 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4274 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4276 /* Hack -- Distance -- Reward strength, penalize weight */
4277 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4279 /* Max distance of 10-18 */
4280 if (tdis > mul) tdis = mul;
4284 ty = randint0(101)-50+py;
4285 tx = randint0(101)-50+px;
4289 project_length = tdis + 1;
4291 /* Get a direction (or cancel) */
4292 if (!get_aim_dir(&dir)) return FALSE;
4294 project_length = 0; /* reset to default */
4296 /* Predict the "target" location */
4297 tx = px + 99 * ddx[dir];
4298 ty = py + 99 * ddy[dir];
4300 /* Check for "target request" */
4301 if ((dir == 5) && target_okay())
4308 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4309 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4310 return_when_thrown = TRUE;
4312 /* Reduce and describe inventory */
4315 inven_item_increase(item, -1);
4316 if (!return_when_thrown)
4317 inven_item_describe(item);
4318 inven_item_optimize(item);
4321 /* Reduce and describe floor item */
4324 floor_item_increase(0 - item, -1);
4325 floor_item_optimize(0 - item);
4327 if (item >= INVEN_RARM)
4329 equiped_item = TRUE;
4330 p_ptr->redraw |= (PR_EQUIPPY);
4336 /* Rogue and Ninja gets bonus */
4337 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4338 energy_use -= p_ptr->lev;
4340 /* Start at the player */
4345 /* Hack -- Handle stuff */
4348 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4349 else shuriken = FALSE;
4351 /* Chance of hitting */
4352 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4353 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4354 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4356 if (shuriken) chance *= 2;
4358 /* Travel until stopped */
4359 for (cur_dis = 0; cur_dis <= tdis; )
4361 /* Hack -- Stop at the target */
4362 if ((y == ty) && (x == tx)) break;
4364 /* Calculate the new location (see "project()") */
4367 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4369 /* Stopped by walls/doors */
4370 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4376 /* Advance the distance */
4379 /* The player can see the (on screen) missile */
4380 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4382 char c = object_char(q_ptr);
4383 byte a = object_attr(q_ptr);
4385 /* Draw, Hilite, Fresh, Pause, Erase */
4386 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4387 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4389 Term_xtra(TERM_XTRA_DELAY, msec);
4390 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4394 /* The player cannot see the missile */
4397 /* Pause anyway, for consistancy */
4398 Term_xtra(TERM_XTRA_DELAY, msec);
4401 /* Save the new location */
4406 /* Monster here, Try to hit it */
4407 if (cave[y][x].m_idx)
4409 cave_type *c_ptr = &cave[y][x];
4411 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4412 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4414 /* Check the visibility */
4415 visible = m_ptr->ml;
4417 /* Note the collision */
4420 /* Did we hit it (penalize range) */
4421 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4425 /* Assume a default death */
4427 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4429 cptr note_dies = " dies.";
4433 /* Some monsters get "destroyed" */
4434 if (!monster_living(r_ptr))
4437 bool explode = FALSE;
4439 for (i = 0; i < 4; i++)
4441 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4444 /* Special note at death */
4447 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4449 note_dies = " explodes into tiny shreds.";
4453 note_dies = "¤òÅݤ·¤¿¡£";
4455 note_dies = " is destroyed.";
4461 /* Handle unseen monster */
4464 /* Invisible monster */
4466 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4468 msg_format("The %s finds a mark.", o_name);
4473 /* Handle visible monster */
4478 /* Get "the monster" or "it" */
4479 monster_desc(m_name, m_ptr, 0);
4483 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4485 msg_format("The %s hits %s.", o_name, m_name);
4489 /* Hack -- Track this monster race */
4490 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4492 /* Hack -- Track this monster */
4493 if (m_ptr->ml) health_track(c_ptr->m_idx);
4496 /* Hack -- Base damage from thrown object */
4497 tdam = damroll(q_ptr->dd, q_ptr->ds);
4498 /* Apply special damage XXX XXX XXX */
4499 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4500 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4501 if (q_ptr->to_d > 0)
4502 tdam += q_ptr->to_d;
4504 tdam += -q_ptr->to_d;
4508 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4509 tdam += p_ptr->to_d_m;
4511 else if (have_flag(flgs, TR_THROW))
4514 tdam += p_ptr->to_d_m;
4522 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4525 /* No negative damage */
4526 if (tdam < 0) tdam = 0;
4528 /* Modify the damage */
4529 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4531 /* Complex message */
4535 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4538 msg_format("You do %d (out of %d) damage.",
4544 /* Hit the monster, check for death */
4545 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4554 message_pain(c_ptr->m_idx, tdam);
4556 /* Anger the monster */
4557 if ((tdam > 0) && !object_is_potion(q_ptr))
4558 anger_monster(m_ptr);
4561 if (fear && m_ptr->ml)
4568 /* Get the monster name (or "it") */
4569 monster_desc(m_name, m_ptr, 0);
4573 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4575 msg_format("%^s flees in terror!", m_name);
4587 /* Chance of breakage (during attacks) */
4588 j = (hit_body ? breakage_chance(q_ptr) : 0);
4590 /* Figurines transform */
4591 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4595 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4596 !(cursed_p(q_ptr)) ? PM_FORCE_PET : 0L)))
4598 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4600 msg_print("The Figurine writhes and then shatters.");
4603 else if (cursed_p(q_ptr))
4605 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4607 msg_print("You have a bad feeling about this.");
4613 /* Potions smash open */
4614 if (object_is_potion(q_ptr))
4616 if (hit_body || hit_wall || (randint1(100) < j))
4620 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4622 msg_format("The %s shatters!", o_name);
4626 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4628 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4630 /* ToDo (Robert): fix the invulnerability */
4631 if (cave[y][x].m_idx &&
4632 is_friendly(&m_list[cave[y][x].m_idx]) &&
4636 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4638 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4640 msg_format("%^s gets angry!", m_name);
4643 set_hostile(&m_list[cave[y][x].m_idx]);
4654 if (return_when_thrown)
4656 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4657 char o2_name[MAX_NLEN];
4658 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4661 if (boomerang) back_chance += 4+randint1(5);
4662 if (super_boomerang) back_chance += 100;
4663 object_desc(o2_name, q_ptr, FALSE, 0);
4665 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4667 for (i = cur_dis-1;i>0;i--)
4669 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4671 char c = object_char(q_ptr);
4672 byte a = object_attr(q_ptr);
4674 /* Draw, Hilite, Fresh, Pause, Erase */
4675 print_rel(c, a, ny[i], nx[i]);
4676 move_cursor_relative(ny[i], nx[i]);
4678 Term_xtra(TERM_XTRA_DELAY, msec);
4679 lite_spot(ny[i], nx[i]);
4684 /* Pause anyway, for consistancy */
4685 Term_xtra(TERM_XTRA_DELAY, msec);
4688 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4691 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4693 msg_format("%s comes back to you.", o2_name);
4702 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4704 msg_format("%s backs, but you can't catch!", o2_name);
4710 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4712 msg_format("%s comes back.", o2_name);
4722 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4724 msg_format("%s doesn't back!", o2_name);
4731 if (item == INVEN_RARM || item == INVEN_LARM)
4733 /* Access the wield slot */
4734 o_ptr = &inventory[item];
4736 /* Wear the new stuff */
4737 object_copy(o_ptr, q_ptr);
4739 /* Increase the weight */
4740 p_ptr->total_weight += q_ptr->weight;
4742 /* Increment the equip counter by hand */
4745 /* Recalculate bonuses */
4746 p_ptr->update |= (PU_BONUS);
4748 /* Recalculate torch */
4749 p_ptr->update |= (PU_TORCH);
4751 /* Recalculate mana XXX */
4752 p_ptr->update |= (PU_MANA);
4755 p_ptr->window |= (PW_EQUIP);
4763 else if (equiped_item)
4769 /* Drop (or break) near that location */
4770 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4777 * Throw an object from the pack or floor.
4779 void do_cmd_throw(void)
4781 do_cmd_throw_aux(1, FALSE, 0);