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)
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, "climbed 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, "fell through a trap door");
306 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed 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, mode)) 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 || IS_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 /* Map border (mimiccing Permanent wall) */
1549 else if ((c_ptr->feat >= FEAT_PERM_EXTRA &&
1550 c_ptr->feat <= FEAT_PERM_SOLID) ||
1551 c_ptr->feat == FEAT_MOUNTAIN)
1554 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1556 msg_print("You can't tunnel through that!");
1561 else if (feat == FEAT_TREES) /* -KMW- */
1564 if ((p_ptr->skill_dig > 10 + randint0(400)) && twall(y, x, FEAT_GRASS))
1567 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1569 msg_print("You have cleared away the trees.");
1571 chg_virtue(V_DILIGENCE, 1);
1572 chg_virtue(V_NATURE, -1);
1578 /* We may continue chopping */
1580 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1582 msg_print("You chop away at the tree.");
1587 /* Occasional Search XXX XXX */
1588 if (randint0(100) < 25) search();
1594 else if ((feat >= FEAT_WALL_EXTRA) &&
1595 (feat <= FEAT_WALL_SOLID))
1598 if ((p_ptr->skill_dig > 40 + randint0(1600)) && twall(y, x, floor_type[randint0(100)]))
1601 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1603 msg_print("You have finished the tunnel.");
1605 chg_virtue(V_DILIGENCE, 1);
1606 chg_virtue(V_NATURE, -1);
1612 /* We may continue tunelling */
1614 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1616 msg_print("You tunnel into the granite wall.");
1624 /* Quartz / Magma */
1625 else if ((feat >= FEAT_MAGMA) &&
1626 (feat <= FEAT_QUARTZ_K))
1632 /* Found gold (ignore mimic; maybe a hidden treasure) */
1633 if (c_ptr->feat >= FEAT_MAGMA_H &&
1634 c_ptr->feat <= FEAT_QUARTZ_K) gold = TRUE;
1636 /* Extract "quartz" flag XXX XXX XXX */
1637 if ((feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1642 okay = (p_ptr->skill_dig > 20 + randint0(800));
1648 okay = (p_ptr->skill_dig > 10 + randint0(400));
1652 if (okay && twall(y, x, floor_type[randint0(100)]))
1654 /* Found treasure */
1657 /* Place some gold */
1662 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1664 msg_print("You have found something!");
1674 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1676 msg_print("You have finished the tunnel.");
1678 chg_virtue(V_DILIGENCE, 1);
1679 chg_virtue(V_NATURE, -1);
1683 /* Failure (quartz) */
1686 /* Message, continue digging */
1688 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1690 msg_print("You tunnel into the quartz vein.");
1696 /* Failure (magma) */
1699 /* Message, continue digging */
1701 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1703 msg_print("You tunnel into the magma vein.");
1711 else if (feat == FEAT_RUBBLE)
1713 /* Remove the rubble */
1714 if ((p_ptr->skill_dig > randint0(200)) && twall(y, x, floor_type[randint0(100)]))
1718 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1720 msg_print("You have removed the rubble.");
1723 /* Hack -- place an object */
1724 if (randint0(100) < (15 - dun_level/2))
1726 /* Create a simple object */
1727 place_object(y, x, 0L);
1729 /* Observe new object */
1730 if (player_can_see_bold(y, x))
1733 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1735 msg_print("You have found something!");
1744 /* Message, keep digging */
1746 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1748 msg_print("You dig in the rubble.");
1759 if ((p_ptr->skill_dig > 30 + randint0(1200)) && twall(y, x, floor_type[randint1(100)]))
1762 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1764 msg_print("You have finished the tunnel.");
1772 /* We may continue tunelling */
1774 msg_print("¥É¥¢¤Ë·ê¤ò³«¤±¤Æ¤¤¤ë¡£");
1776 msg_print("You tunnel into the door.");
1783 if (is_hidden_door(c_ptr))
1785 /* Occasional Search XXX XXX */
1786 if (randint0(100) < 25) search();
1795 * Tunnels through "walls" (including rubble and closed doors)
1797 * Note that you must tunnel in order to hit invisible monsters
1798 * in walls, though moving into walls still takes a turn anyway.
1800 * Digging is very difficult without a "digger" weapon, but can be
1801 * accomplished by strong players using heavy weapons.
1803 void do_cmd_tunnel(void)
1813 if (p_ptr->special_defense & KATA_MUSOU)
1815 set_action(ACTION_NONE);
1818 /* Allow repeated command */
1821 /* Set repeat count */
1822 command_rep = command_arg - 1;
1824 /* Redraw the state */
1825 p_ptr->redraw |= (PR_STATE);
1827 /* Cancel the arg */
1831 /* Get a direction to tunnel, or Abort */
1832 if (get_rep_dir(&dir,FALSE))
1839 c_ptr = &cave[y][x];
1841 /* Feature code (applying "mimic" field) */
1842 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1844 /* No tunnelling through doors */
1845 if (((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL)) ||
1846 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
1847 ((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
1848 (feat == FEAT_MUSEUM))
1852 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1854 msg_print("You cannot tunnel through doors.");
1859 /* No tunnelling through air */
1860 else if (cave_floor_grid(c_ptr) || ((feat >= FEAT_MINOR_GLYPH) &&
1861 (feat <= FEAT_PATTERN_XTRA2)))
1865 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1867 msg_print("You cannot tunnel through air.");
1872 /* No tunnelling through mountains */
1873 else if (feat == FEAT_MOUNTAIN)
1876 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1878 msg_print("You can't tunnel through that!");
1883 /* A monster is in the way */
1884 else if (c_ptr->m_idx)
1891 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1893 msg_print("There is a monster in the way!");
1904 /* Tunnel through walls */
1905 more = do_cmd_tunnel_aux(y, x);
1909 /* Cancel repetition unless we can continue */
1910 if (!more) disturb(0, 0);
1914 #ifdef ALLOW_EASY_OPEN /* TNB */
1919 * If there is a jammed/closed/locked door at the given location,
1920 * then attempt to unlock/open it. Return TRUE if an attempt was
1921 * made (successful or not), otherwise return FALSE.
1923 * The code here should be nearly identical to that in
1924 * do_cmd_open_test() and do_cmd_open_aux().
1926 bool easy_open_door(int y, int x)
1930 cave_type *c_ptr = &cave[y][x];
1932 /* Must be a closed door */
1933 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1934 (c_ptr->feat <= FEAT_DOOR_TAIL)))
1941 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1945 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1947 msg_print("The door appears to be stuck.");
1953 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1956 i = p_ptr->skill_dis;
1958 /* Penalize some conditions */
1959 if (p_ptr->blind || no_lite()) i = i / 10;
1960 if (p_ptr->confused || p_ptr->image) i = i / 10;
1962 /* Extract the lock power */
1963 j = c_ptr->feat - FEAT_DOOR_HEAD;
1965 /* Extract the difficulty XXX XXX XXX */
1968 /* Always have a small chance of success */
1972 if (randint0(100) < j)
1976 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1978 msg_print("You have picked the lock.");
1983 cave_set_feat(y, x, FEAT_OPEN);
1985 /* Update some things */
1986 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1989 sound(SOUND_OPENDOOR);
1999 if (flush_failure) flush();
2003 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2005 msg_print("You failed to pick the lock.");
2015 cave_set_feat(y, x, FEAT_OPEN);
2017 /* Update some things */
2018 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
2021 sound(SOUND_OPENDOOR);
2028 #endif /* ALLOW_EASY_OPEN -- TNB */
2032 * Perform the basic "disarm" command
2034 * Assume destination is a visible trap
2036 * Assume there is no monster blocking the destination
2038 * Returns TRUE if repeated commands may continue
2040 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2046 object_type *o_ptr = &o_list[o_idx];
2052 /* Get the "disarm" factor */
2053 i = p_ptr->skill_dis;
2055 /* Penalize some conditions */
2056 if (p_ptr->blind || no_lite()) i = i / 10;
2057 if (p_ptr->confused || p_ptr->image) i = i / 10;
2059 /* Extract the difficulty */
2060 j = i - o_ptr->pval;
2062 /* Always have a small chance of success */
2065 /* Must find the trap first. */
2066 if (!object_known_p(o_ptr))
2069 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2071 msg_print("I don't see any traps.");
2076 /* Already disarmed/unlocked */
2077 else if (o_ptr->pval <= 0)
2080 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2082 msg_print("The chest is not trapped.");
2087 /* No traps to find. */
2088 else if (!chest_traps[o_ptr->pval])
2091 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2093 msg_print("The chest is not trapped.");
2098 /* Success (get a lot of experience) */
2099 else if (randint0(100) < j)
2102 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2104 msg_print("You have disarmed the chest.");
2107 gain_exp(o_ptr->pval);
2108 o_ptr->pval = (0 - o_ptr->pval);
2111 /* Failure -- Keep trying */
2112 else if ((i > 5) && (randint1(i) > 5))
2114 /* We may keep trying */
2116 if (flush_failure) flush();
2118 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2120 msg_print("You failed to disarm the chest.");
2125 /* Failure -- Set off the trap */
2129 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2131 msg_print("You set off a trap!");
2135 chest_trap(y, x, o_idx);
2144 * Perform the basic "disarm" command
2146 * Assume destination is a visible trap
2148 * Assume there is no monster blocking the destination
2150 * Returns TRUE if repeated commands may continue
2152 #ifdef ALLOW_EASY_DISARM /* TNB */
2154 bool do_cmd_disarm_aux(int y, int x, int dir)
2156 #else /* ALLOW_EASY_DISARM -- TNB */
2158 static bool do_cmd_disarm_aux(int y, int x, int dir)
2160 #endif /* ALLOW_EASY_DISARM -- TNB */
2174 /* Get grid and contents */
2175 c_ptr = &cave[y][x];
2177 /* Access trap name */
2178 name = (f_name + f_info[c_ptr->feat].name);
2180 /* Get the "disarm" factor */
2181 i = p_ptr->skill_dis;
2183 /* Penalize some conditions */
2184 if (p_ptr->blind || no_lite()) i = i / 10;
2185 if (p_ptr->confused || p_ptr->image) i = i / 10;
2187 /* Variable power! */
2189 /* Extract trap "power" */
2190 switch (c_ptr->feat)
2192 case FEAT_TRAP_OPEN:
2193 case FEAT_TRAP_ARMAGEDDON:
2194 case FEAT_TRAP_PIRANHA:
2195 /* Special traps are very difficult to disarm */
2203 /* Extract the difficulty */
2206 /* Always have a small chance of success */
2210 if (randint0(100) < j)
2214 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2216 msg_format("You have disarmed the %s.", name);
2223 /* Forget the trap */
2224 c_ptr->info &= ~(CAVE_MARK);
2226 /* Remove the trap */
2227 cave_set_feat(y, x, floor_type[randint0(100)]);
2229 #ifdef ALLOW_EASY_DISARM /* TNB */
2231 /* Move the player onto the trap */
2232 move_player(dir, easy_disarm, FALSE);
2234 #else /* ALLOW_EASY_DISARM -- TNB */
2236 /* move the player onto the trap grid */
2237 move_player(dir, FALSE, FALSE);
2239 #endif /* ALLOW_EASY_DISARM -- TNB */
2242 /* Failure -- Keep trying */
2243 else if ((i > 5) && (randint1(i) > 5))
2246 if (flush_failure) flush();
2250 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2252 msg_format("You failed to disarm the %s.", name);
2256 /* We may keep trying */
2260 /* Failure -- Set off the trap */
2265 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2267 msg_format("You set off the %s!", name);
2271 #ifdef ALLOW_EASY_DISARM /* TNB */
2273 /* Move the player onto the trap */
2274 move_player(dir, easy_disarm, FALSE);
2276 #else /* ALLOW_EASY_DISARM -- TNB */
2278 /* Move the player onto the trap */
2279 move_player(dir, FALSE, FALSE);
2281 #endif /* ALLOW_EASY_DISARM -- TNB */
2290 * Disarms a trap, or chest
2292 void do_cmd_disarm(void)
2300 if (p_ptr->special_defense & KATA_MUSOU)
2302 set_action(ACTION_NONE);
2305 #ifdef ALLOW_EASY_DISARM /* TNB */
2307 /* Option: Pick a direction */
2310 int num_traps, num_chests;
2312 /* Count visible traps */
2313 num_traps = count_dt(&y, &x, is_trap, TRUE);
2315 /* Count chests (trapped) */
2316 num_chests = count_chests(&y, &x, TRUE);
2318 /* See if only one target */
2319 if (num_traps || num_chests)
2321 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2323 if (!too_many) command_dir = coords_to_dir(y, x);
2327 #endif /* ALLOW_EASY_DISARM -- TNB */
2329 /* Allow repeated command */
2332 /* Set repeat count */
2333 command_rep = command_arg - 1;
2335 /* Redraw the state */
2336 p_ptr->redraw |= (PR_STATE);
2338 /* Cancel the arg */
2342 /* Get a direction (or abort) */
2343 if (get_rep_dir(&dir,TRUE))
2352 /* Get grid and contents */
2353 c_ptr = &cave[y][x];
2355 /* Feature code (applying "mimic" field) */
2356 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2358 /* Check for chests */
2359 o_idx = chest_check(y, x);
2362 if (!is_trap(feat) && !o_idx)
2366 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2368 msg_print("You see nothing there to disarm.");
2373 /* Monster in the way */
2374 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2378 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2380 msg_print("There is a monster in the way!");
2391 /* Disarm the chest */
2392 more = do_cmd_disarm_chest(y, x, o_idx);
2398 /* Disarm the trap */
2399 more = do_cmd_disarm_aux(y, x, dir);
2403 /* Cancel repeat unless told not to */
2404 if (!more) disturb(0, 0);
2409 * Perform the basic "bash" command
2411 * Assume destination is a closed/locked/jammed door
2413 * Assume there is no monster blocking the destination
2415 * Returns TRUE if repeated commands may continue
2417 static bool do_cmd_bash_aux(int y, int x, int dir)
2430 c_ptr = &cave[y][x];
2434 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2436 msg_print("You smash into the door!");
2440 /* Hack -- Bash power based on strength */
2441 /* (Ranges from 3 to 20 to 100 to 200) */
2442 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2444 /* Extract door power */
2445 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2447 /* Compare bash power to door power XXX XXX XXX */
2448 temp = (bash - (temp * 10));
2450 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2452 /* Hack -- always have a chance */
2453 if (temp < 1) temp = 1;
2455 /* Hack -- attempt to bash down the door */
2456 if (randint0(100) < temp)
2460 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2462 msg_print("The door crashes open!");
2466 /* Break down the door */
2467 if (randint0(100) < 50)
2469 cave_set_feat(y, x, FEAT_BROKEN);
2475 cave_set_feat(y, x, FEAT_OPEN);
2479 sound(SOUND_OPENDOOR);
2481 /* Hack -- Fall through the door */
2482 move_player(dir, FALSE, FALSE);
2484 /* Update some things */
2485 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2486 p_ptr->update |= (PU_DISTANCE);
2489 /* Saving throw against stun */
2490 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2495 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2497 msg_print("The door holds firm.");
2501 /* Allow repeated bashing */
2505 /* High dexterity yields coolness */
2510 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2512 msg_print("You are off-balance.");
2516 /* Hack -- Lose balance ala paralysis */
2517 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2526 * Bash open a door, success based on character strength
2528 * For a closed door, pval is positive if locked; negative if stuck.
2530 * For an open door, pval is positive for a broken door.
2532 * A closed door can be opened - harder if locked. Any door might be
2533 * bashed open (and thereby broken). Bashing a door is (potentially)
2534 * faster! You move into the door way. To open a stuck door, it must
2535 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2537 * Creatures can also open or bash doors, see elsewhere.
2539 void do_cmd_bash(void)
2548 if (p_ptr->special_defense & KATA_MUSOU)
2550 set_action(ACTION_NONE);
2553 /* Allow repeated command */
2556 /* Set repeat count */
2557 command_rep = command_arg - 1;
2559 /* Redraw the state */
2560 p_ptr->redraw |= (PR_STATE);
2562 /* Cancel the arg */
2566 /* Get a "repeated" direction */
2567 if (get_rep_dir(&dir,FALSE))
2576 c_ptr = &cave[y][x];
2578 /* Feature code (applying "mimic" field) */
2579 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2581 /* Nothing useful */
2582 if (!((feat >= FEAT_DOOR_HEAD) &&
2583 (feat <= FEAT_DOOR_TAIL)))
2587 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2589 msg_print("You see nothing there to bash.");
2594 /* Monster in the way */
2595 else if (c_ptr->m_idx)
2602 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2604 msg_print("There is a monster in the way!");
2612 /* Bash a closed door */
2616 more = do_cmd_bash_aux(y, x, dir);
2620 /* Unless valid action taken, cancel bash */
2621 if (!more) disturb(0, 0);
2626 * Manipulate an adjacent grid in some way
2628 * Attack monsters, tunnel through walls, disarm traps, open doors.
2630 * Consider confusion XXX XXX XXX
2632 * This command must always take a turn, to prevent free detection
2633 * of invisible monsters.
2635 void do_cmd_alter(void)
2644 if (p_ptr->special_defense & KATA_MUSOU)
2646 set_action(ACTION_NONE);
2649 /* Allow repeated command */
2652 /* Set repeat count */
2653 command_rep = command_arg - 1;
2655 /* Redraw the state */
2656 p_ptr->redraw |= (PR_STATE);
2658 /* Cancel the arg */
2662 /* Get a direction */
2663 if (get_rep_dir(&dir,TRUE))
2672 c_ptr = &cave[y][x];
2674 /* Feature code (applying "mimic" field) */
2675 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2680 /* Attack monsters */
2687 /* Tunnel through walls */
2688 else if (((feat >= FEAT_RUBBLE) &&
2689 (feat < FEAT_MINOR_GLYPH)) ||
2690 ((feat == FEAT_TREES) ||
2691 (feat == FEAT_MOUNTAIN)))
2693 more = do_cmd_tunnel_aux(y, x);
2696 else if (is_closed_door(feat))
2698 /* Bash jammed doors */
2699 if (feat >= FEAT_DOOR_HEAD + 0x08)
2701 more = do_cmd_bash_aux(y, x, dir);
2707 more = do_cmd_open_aux(y, x);
2711 /* Close open doors */
2712 else if ((feat == FEAT_OPEN) ||
2713 (feat == FEAT_BROKEN))
2715 more = do_cmd_close_aux(y, x);
2719 else if (is_trap(feat))
2721 more = do_cmd_disarm_aux(y, x, dir);
2729 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2731 msg_print("You attack the empty air.");
2737 /* Cancel repetition unless we can continue */
2738 if (!more) disturb(0, 0);
2743 * Find the index of some "spikes", if possible.
2745 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2747 static bool get_spike(int *ip)
2751 /* Check every item in the pack */
2752 for (i = 0; i < INVEN_PACK; i++)
2754 object_type *o_ptr = &inventory[i];
2756 /* Skip non-objects */
2757 if (!o_ptr->k_idx) continue;
2759 /* Check the "tval" code */
2760 if (o_ptr->tval == TV_SPIKE)
2762 /* Save the spike index */
2776 * Jam a closed door with a spike
2778 * This command may NOT be repeated
2780 void do_cmd_spike(void)
2784 if (p_ptr->special_defense & KATA_MUSOU)
2786 set_action(ACTION_NONE);
2789 /* Get a "repeated" direction */
2790 if (get_rep_dir(&dir,FALSE))
2800 /* Get grid and contents */
2801 c_ptr = &cave[y][x];
2803 /* Feature code (applying "mimic" field) */
2804 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2806 /* Require closed door */
2807 if (!((feat >= FEAT_DOOR_HEAD) &&
2808 (feat <= FEAT_DOOR_TAIL)))
2812 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2814 msg_print("You see nothing there to spike.");
2820 else if (!get_spike(&item))
2824 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2826 msg_print("You have no spikes!");
2831 /* Is a monster in the way? */
2832 else if (c_ptr->m_idx)
2839 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2841 msg_print("There is a monster in the way!");
2855 /* Successful jamming */
2857 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2859 msg_print("You jam the door with a spike.");
2863 /* Convert "locked" to "stuck" XXX XXX XXX */
2864 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2866 /* Add one spike to the door */
2867 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2869 /* Use up, and describe, a single spike, from the bottom */
2870 inven_item_increase(item, -1);
2871 inven_item_describe(item);
2872 inven_item_optimize(item);
2880 * Support code for the "Walk" and "Jump" commands
2882 void do_cmd_walk(int pickup)
2889 /* Allow repeated command */
2892 /* Set repeat count */
2893 command_rep = command_arg - 1;
2895 /* Redraw the state */
2896 p_ptr->redraw |= (PR_STATE);
2898 /* Cancel the arg */
2902 /* Get a "repeated" direction */
2903 if (get_rep_dir(&dir,FALSE))
2908 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2910 set_action(ACTION_NONE);
2913 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2914 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2915 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2917 /* Actually move the character */
2918 move_player(dir, pickup, FALSE);
2920 /* Allow more walking */
2924 /* Hack again -- Is there a special encounter ??? */
2925 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2927 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2930 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2932 /* Inform the player of his horrible fate :=) */
2934 msg_print("½±·â¤À¡ª");
2936 msg_print("You are ambushed !");
2939 /* Go into large wilderness view */
2940 p_ptr->wilderness_x = px;
2941 p_ptr->wilderness_y = py;
2942 p_ptr->oldpy = randint1(MAX_HGT-2);
2943 p_ptr->oldpx = randint1(MAX_WID-2);
2947 /* HACk -- set the encouter flag for the wilderness generation */
2948 generate_encounter = TRUE;
2952 /* Cancel repeat unless we may continue */
2953 if (!more) disturb(0, 0);
2961 void do_cmd_run(void)
2965 /* Hack -- no running when confused */
2966 if (p_ptr->confused)
2969 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2971 msg_print("You are too confused!");
2977 if (p_ptr->special_defense & KATA_MUSOU)
2979 set_action(ACTION_NONE);
2982 /* Get a "repeated" direction */
2983 if (get_rep_dir(&dir,FALSE))
2985 /* Hack -- Set the run counter */
2986 running = (command_arg ? command_arg : 1000);
2996 * Stay still. Search. Enter stores.
2997 * Pick up treasure if "pickup" is true.
2999 void do_cmd_stay(int pickup)
3001 cave_type *c_ptr = &cave[py][px];
3004 /* Allow repeated command */
3007 /* Set repeat count */
3008 command_rep = command_arg - 1;
3010 /* Redraw the state */
3011 p_ptr->redraw |= (PR_STATE);
3013 /* Cancel the arg */
3022 /* Spontaneous Searching */
3023 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
3028 /* Continuous Searching */
3029 if (p_ptr->action == ACTION_SEARCH)
3035 /* Handle "objects" */
3039 /* Hack -- enter a store if we are on one */
3040 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3041 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3042 (c_ptr->feat == FEAT_MUSEUM))
3048 /* Hack -- enter store */
3049 command_new = SPECIAL_KEY_STORE;
3052 /* Hack -- enter a building if we are on one -KMW- */
3053 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3054 (c_ptr->feat <= FEAT_BLDG_TAIL))
3060 /* Hack -- enter building */
3061 command_new = SPECIAL_KEY_BUILDING;
3064 /* Exit a quest if reach the quest exit */
3065 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3067 int q_index = p_ptr->inside_quest;
3069 /* Was quest completed? */
3070 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3072 quest[q_index].status = QUEST_STATUS_COMPLETED;
3073 quest[q_index].complev = (byte)p_ptr->lev;
3075 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3077 msg_print("You accomplished your quest!");
3083 leave_quest_check();
3085 p_ptr->inside_quest = cave[py][px].special;
3089 p_ptr->leaving = TRUE;
3096 * Resting allows a player to safely restore his hp -RAK-
3098 void do_cmd_rest(void)
3101 set_action(ACTION_NONE);
3103 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3108 /* Prompt for time if needed */
3109 if (command_arg <= 0)
3112 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3114 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3121 strcpy(out_val, "&");
3123 /* Ask for duration */
3124 if (!get_string(p, out_val, 4)) return;
3126 /* Rest until done */
3127 if (out_val[0] == '&')
3133 else if (out_val[0] == '*')
3141 command_arg = atoi(out_val);
3142 if (command_arg <= 0) return;
3148 if (command_arg > 9999) command_arg = 9999;
3150 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3152 /* Take a turn XXX XXX XXX (?) */
3155 /* The sin of sloth */
3156 if (command_arg > 100)
3157 chg_virtue(V_DILIGENCE, -1);
3159 /* Why are you sleeping when there's no need? WAKE UP!*/
3160 if ((p_ptr->chp == p_ptr->mhp) &&
3161 (p_ptr->csp == p_ptr->msp) &&
3162 !p_ptr->blind && !p_ptr->confused &&
3163 !p_ptr->poisoned && !p_ptr->afraid &&
3164 !p_ptr->stun && !p_ptr->cut &&
3165 !p_ptr->slow && !p_ptr->paralyzed &&
3166 !p_ptr->image && !p_ptr->word_recall &&
3167 !p_ptr->alter_reality)
3168 chg_virtue(V_DILIGENCE, -1);
3170 /* Save the rest code */
3171 resting = command_arg;
3172 p_ptr->action = ACTION_REST;
3174 /* Recalculate bonuses */
3175 p_ptr->update |= (PU_BONUS);
3177 /* Redraw the state */
3178 p_ptr->redraw |= (PR_STATE);
3189 * Determines the odds of an object breaking when thrown at a monster
3191 * Note that artifacts never break, see the "drop_near()" function.
3193 static int breakage_chance(object_type *o_ptr)
3195 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3197 /* Examine the item type */
3198 switch (o_ptr->tval)
3214 /* Sometimes break */
3219 return (20 - archer_bonus * 2);
3224 return (10 - archer_bonus);
3231 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3235 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3237 u32b flgs[TR_FLAG_SIZE];
3239 /* Extract the flags */
3240 object_flags(o_ptr, flgs);
3242 /* Some "weapons" and "ammo" do extra damage */
3243 switch (o_ptr->tval)
3250 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3251 (r_ptr->flags3 & RF3_ANIMAL))
3253 if (m_ptr->ml && is_original_ap(m_ptr))
3255 r_ptr->r_flags3 |= RF3_ANIMAL;
3258 if (mult < 17) mult = 17;
3262 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3263 (r_ptr->flags3 & RF3_ANIMAL))
3265 if (m_ptr->ml && is_original_ap(m_ptr))
3267 r_ptr->r_flags3 |= RF3_ANIMAL;
3270 if (mult < 27) mult = 27;
3274 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3275 (r_ptr->flags3 & RF3_EVIL))
3277 if (m_ptr->ml && is_original_ap(m_ptr))
3279 r_ptr->r_flags3 |= RF3_EVIL;
3282 if (mult < 15) mult = 15;
3286 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3287 (r_ptr->flags3 & RF3_EVIL))
3289 if (m_ptr->ml && is_original_ap(m_ptr))
3291 r_ptr->r_flags3 |= RF3_EVIL;
3294 if (mult < 25) mult = 25;
3298 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3299 (r_ptr->flags2 & RF2_HUMAN))
3301 if (m_ptr->ml && is_original_ap(m_ptr))
3303 r_ptr->r_flags2 |= RF2_HUMAN;
3306 if (mult < 17) mult = 17;
3310 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3311 (r_ptr->flags2 & RF2_HUMAN))
3313 if (m_ptr->ml && is_original_ap(m_ptr))
3315 r_ptr->r_flags2 |= RF2_HUMAN;
3318 if (mult < 27) mult = 27;
3322 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3323 (r_ptr->flags3 & RF3_UNDEAD))
3325 if (m_ptr->ml && is_original_ap(m_ptr))
3327 r_ptr->r_flags3 |= RF3_UNDEAD;
3330 if (mult < 20) mult = 20;
3334 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3335 (r_ptr->flags3 & RF3_UNDEAD))
3337 if (m_ptr->ml && is_original_ap(m_ptr))
3339 r_ptr->r_flags3 |= RF3_UNDEAD;
3342 if (mult < 30) mult = 30;
3346 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3347 (r_ptr->flags3 & RF3_DEMON))
3349 if (m_ptr->ml && is_original_ap(m_ptr))
3351 r_ptr->r_flags3 |= RF3_DEMON;
3354 if (mult < 20) mult = 20;
3358 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3359 (r_ptr->flags3 & RF3_DEMON))
3361 if (m_ptr->ml && is_original_ap(m_ptr))
3363 r_ptr->r_flags3 |= RF3_DEMON;
3366 if (mult < 30) mult = 30;
3370 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3371 (r_ptr->flags3 & RF3_ORC))
3373 if (m_ptr->ml && is_original_ap(m_ptr))
3375 r_ptr->r_flags3 |= RF3_ORC;
3378 if (mult < 20) mult = 20;
3382 if ((have_flag(flgs, TR_KILL_ORC)) &&
3383 (r_ptr->flags3 & RF3_ORC))
3385 if (m_ptr->ml && is_original_ap(m_ptr))
3387 r_ptr->r_flags3 |= RF3_ORC;
3390 if (mult < 30) mult = 30;
3394 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3395 (r_ptr->flags3 & RF3_TROLL))
3397 if (m_ptr->ml && is_original_ap(m_ptr))
3399 r_ptr->r_flags3 |= RF3_TROLL;
3402 if (mult < 20) mult = 20;
3406 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3407 (r_ptr->flags3 & RF3_TROLL))
3409 if (m_ptr->ml && is_original_ap(m_ptr))
3411 r_ptr->r_flags3 |= RF3_TROLL;
3414 if (mult < 30) mult = 30;
3418 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3419 (r_ptr->flags3 & RF3_GIANT))
3421 if (m_ptr->ml && is_original_ap(m_ptr))
3423 r_ptr->r_flags3 |= RF3_GIANT;
3426 if (mult < 20) mult = 20;
3430 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3431 (r_ptr->flags3 & RF3_GIANT))
3433 if (m_ptr->ml && is_original_ap(m_ptr))
3435 r_ptr->r_flags3 |= RF3_GIANT;
3438 if (mult < 30) mult = 30;
3442 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3443 (r_ptr->flags3 & RF3_DRAGON))
3445 if (m_ptr->ml && is_original_ap(m_ptr))
3447 r_ptr->r_flags3 |= RF3_DRAGON;
3450 if (mult < 20) mult = 20;
3453 /* Execute Dragon */
3454 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3455 (r_ptr->flags3 & RF3_DRAGON))
3457 if (m_ptr->ml && is_original_ap(m_ptr))
3459 r_ptr->r_flags3 |= RF3_DRAGON;
3462 if (mult < 30) mult = 30;
3464 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3465 (m_ptr->r_idx == MON_SMAUG) &&
3466 (inventory[INVEN_BOW].name1 == ART_BARD))
3471 if (have_flag(flgs, TR_BRAND_ACID))
3473 /* Notice immunity */
3474 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3476 if (m_ptr->ml && is_original_ap(m_ptr))
3478 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3482 /* Otherwise, take the damage */
3485 if (mult < 17) mult = 17;
3490 if (have_flag(flgs, TR_BRAND_ELEC))
3492 /* Notice immunity */
3493 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3495 if (m_ptr->ml && is_original_ap(m_ptr))
3497 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3501 /* Otherwise, take the damage */
3504 if (mult < 17) mult = 17;
3509 if (have_flag(flgs, TR_BRAND_FIRE))
3511 /* Notice immunity */
3512 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3514 if (m_ptr->ml && is_original_ap(m_ptr))
3516 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3520 /* Otherwise, take the damage */
3523 if (r_ptr->flags3 & RF3_HURT_FIRE)
3525 if (mult < 25) mult = 25;
3526 if (m_ptr->ml && is_original_ap(m_ptr))
3528 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3531 else if (mult < 17) mult = 17;
3536 if (have_flag(flgs, TR_BRAND_COLD))
3538 /* Notice immunity */
3539 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3541 if (m_ptr->ml && is_original_ap(m_ptr))
3543 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3546 /* Otherwise, take the damage */
3549 if (r_ptr->flags3 & RF3_HURT_COLD)
3551 if (mult < 25) mult = 25;
3552 if (m_ptr->ml && is_original_ap(m_ptr))
3554 r_ptr->r_flags3 |= RF3_HURT_COLD;
3557 else if (mult < 17) mult = 17;
3561 /* Brand (Poison) */
3562 if (have_flag(flgs, TR_BRAND_POIS))
3564 /* Notice immunity */
3565 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3567 if (m_ptr->ml && is_original_ap(m_ptr))
3569 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3573 /* Otherwise, take the damage */
3576 if (mult < 17) mult = 17;
3580 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3582 p_ptr->csp -= (1+(p_ptr->msp / 30));
3583 p_ptr->redraw |= (PR_MANA);
3584 mult = mult * 5 / 2;
3590 /* Return the total damage */
3591 return (tdam * mult / 10);
3596 * Fire an object from the pack or floor.
3598 * You may only fire items that "match" your missile launcher.
3600 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3602 * See "calc_bonuses()" for more calculations and such.
3604 * Note that "firing" a missile is MUCH better than "throwing" it.
3606 * Note: "unseen" monsters are very hard to hit.
3608 * Objects are more likely to break if they "attempt" to hit a monster.
3610 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3612 * The "extra shot" code works by decreasing the amount of energy
3613 * required to make each shot, spreading the shots out over time.
3615 * Note that when firing missiles, the launcher multiplier is applied
3616 * after all the bonuses are added in, making multipliers very useful.
3618 * Note that Bows of "Extra Might" get extra range and an extra bonus
3619 * for the damage multiplier.
3621 * Note that Bows of "Extra Shots" give an extra shot.
3623 void do_cmd_fire_aux(int item, object_type *j_ptr)
3626 int j, y, x, ny, nx, ty, tx;
3627 int tdam, tdis, thits, tmul;
3629 int cur_dis, visible;
3636 bool hit_body = FALSE;
3638 char o_name[MAX_NLEN];
3640 int msec = delay_factor * delay_factor * delay_factor;
3643 bool stick_to = FALSE;
3645 /* Access the item (if in the pack) */
3648 o_ptr = &inventory[item];
3652 o_ptr = &o_list[0 - item];
3655 /* Describe the object */
3656 object_desc(o_name, o_ptr, FALSE, 3);
3659 /* Use the proper number of shots */
3660 thits = p_ptr->num_fire;
3662 /* Use a base distance */
3665 /* Base damage from thrown object plus launcher bonus */
3666 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3668 /* Actually "fire" the object */
3669 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3670 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3671 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3673 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3675 energy_use = bow_energy(j_ptr->sval);
3676 tmul = bow_tmul(j_ptr->sval);
3678 /* Get extra "power" from "extra might" */
3679 if (p_ptr->xtra_might) tmul++;
3681 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3683 /* Boost the damage */
3688 tdis = 10 + tmul/40;
3689 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3692 project_length = tdis + 1;
3694 /* Get a direction (or cancel) */
3695 if (!get_aim_dir(&dir))
3699 /* need not to reset project_length (already did)*/
3704 /* Get local object */
3707 /* Obtain a local object */
3708 object_copy(q_ptr, o_ptr);
3713 /* Reduce and describe inventory */
3716 inven_item_increase(item, -1);
3717 inven_item_describe(item);
3718 inven_item_optimize(item);
3721 /* Reduce and describe floor item */
3724 floor_item_increase(0 - item, -1);
3725 floor_item_optimize(0 - item);
3733 /* Take a (partial) turn */
3734 energy_use = (energy_use / thits);
3737 /* Start at the player */
3741 /* Predict the "target" location */
3742 tx = px + 99 * ddx[dir];
3743 ty = py + 99 * ddy[dir];
3745 /* Check for "target request" */
3746 if ((dir == 5) && target_okay())
3752 project_length = 0; /* reset to default */
3754 /* Hack -- Handle stuff */
3758 /* Travel until stopped */
3759 for (cur_dis = 0; cur_dis <= tdis; )
3761 /* Hack -- Stop at the target */
3762 if ((y == ty) && (x == tx)) break;
3764 /* Calculate the new location (see "project()") */
3767 mmove2(&ny, &nx, py, px, ty, tx);
3769 /* Stopped by walls/doors */
3770 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3772 /* Advance the distance */
3776 /* The player can see the (on screen) missile */
3777 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3779 char c = object_char(q_ptr);
3780 byte a = object_attr(q_ptr);
3782 /* Draw, Hilite, Fresh, Pause, Erase */
3783 print_rel(c, a, ny, nx);
3784 move_cursor_relative(ny, nx);
3786 Term_xtra(TERM_XTRA_DELAY, msec);
3791 /* The player cannot see the missile */
3794 /* Pause anyway, for consistancy */
3795 Term_xtra(TERM_XTRA_DELAY, msec);
3798 /* Save the new location */
3803 /* Monster here, Try to hit it */
3804 if (cave[y][x].m_idx)
3806 cave_type *c_ptr = &cave[y][x];
3808 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3809 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3811 /* Check the visibility */
3812 visible = m_ptr->ml;
3814 /* Note the collision */
3819 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3820 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3823 if ((r_ptr->level + 10) > p_ptr->lev)
3825 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3826 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3829 if (now_exp < SPELL_EXP_BEGINNER) amount = 80;
3830 else if (now_exp < SPELL_EXP_SKILLED) amount = 25;
3831 else if ((now_exp < SPELL_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3832 else if (p_ptr->lev > 34) amount = 2;
3833 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3834 p_ptr->update |= (PU_BONUS);
3840 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3841 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3844 p_ptr->skill_exp[GINOU_RIDING] += 1;
3845 p_ptr->update |= (PU_BONUS);
3849 /* Did we hit it (penalize range) */
3850 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3854 /* Handle unseen monster */
3857 /* Invisible monster */
3859 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3861 msg_format("The %s finds a mark.", o_name);
3866 /* Handle visible monster */
3871 /* Get "the monster" or "it" */
3872 monster_desc(m_name, m_ptr, 0);
3876 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3878 msg_format("The %s hits %s.", o_name, m_name);
3882 /* Hack -- Track this monster race */
3883 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3885 /* Hack -- Track this monster */
3886 if (m_ptr->ml) health_track(c_ptr->m_idx);
3889 /* Apply special damage XXX XXX XXX */
3890 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3891 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3893 /* No negative damage */
3894 if (tdam < 0) tdam = 0;
3896 /* Modify the damage */
3897 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3899 /* Complex message */
3900 if (p_ptr->wizard || cheat_xtra)
3903 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3906 msg_format("You do %d (out of %d) damage.",
3912 /* Hit the monster, check for death */
3913 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3926 monster_desc(m_name, m_ptr, 0);
3930 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3932 msg_format("%^s have stuck into %s!",o_name, m_name);
3937 message_pain(c_ptr->m_idx, tdam);
3939 /* Anger the monster */
3940 if (tdam > 0) anger_monster(m_ptr);
3943 if (fear && m_ptr->ml)
3950 /* Get the monster name (or "it") */
3951 monster_desc(m_name, m_ptr, 0);
3955 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3957 msg_format("%^s flees in terror!", m_name);
3961 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3963 set_target(m_ptr, py, px);
3973 /* Chance of breakage (during attacks) */
3974 j = (hit_body ? breakage_chance(q_ptr) : 0);
3978 int m_idx = cave[y][x].m_idx;
3979 monster_type *m_ptr = &m_list[m_idx];
3980 int o_idx = o_pop();
3985 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3987 msg_format("The %s have gone to somewhere.", o_name);
3991 a_info[j_ptr->name1].cur_num = 0;
3996 o_ptr = &o_list[ o_idx ];
3997 object_copy(o_ptr, q_ptr);
4002 /* Forget location */
4003 o_ptr->iy = o_ptr->ix = 0;
4005 /* Memorize monster */
4006 o_ptr->held_m_idx = m_idx;
4009 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4012 m_ptr->hold_o_idx = o_idx;
4016 /* Drop (or break) near that location */
4017 (void)drop_near(q_ptr, j, y, x);
4021 void do_cmd_fire(void)
4027 /* Get the "bow" (if any) */
4028 j_ptr = &inventory[INVEN_BOW];
4030 /* Require a launcher */
4034 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4036 msg_print("You have nothing to fire with.");
4042 if (j_ptr->sval == SV_CRIMSON)
4045 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4047 msg_print("Do activate.");
4054 if (p_ptr->special_defense & KATA_MUSOU)
4056 set_action(ACTION_NONE);
4059 /* Require proper missile */
4060 item_tester_tval = p_ptr->tval_ammo;
4064 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4065 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4067 q = "Fire which item? ";
4068 s = "You have nothing to fire.";
4071 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4078 do_cmd_fire_aux(item, j_ptr);
4082 static bool item_tester_hook_boomerang(object_type *o_ptr)
4084 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4092 * Throw an object from the pack or floor.
4094 * Note: "unseen" monsters are very hard to hit.
4096 * Should throwing a weapon do full damage? Should it allow the magic
4097 * to hit bonus of the weapon to have an effect? Should it ever cause
4098 * the item to be destroyed? Should it do any damage at all?
4100 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4103 int i, j, y, x, ty, tx;
4105 int chance, tdam, tdis;
4107 int cur_dis, visible;
4114 bool hit_body = FALSE;
4115 bool hit_wall = FALSE;
4116 bool equiped_item = FALSE;
4117 bool return_when_thrown = FALSE;
4119 char o_name[MAX_NLEN];
4121 int msec = delay_factor * delay_factor * delay_factor;
4123 u32b flgs[TR_FLAG_SIZE];
4125 bool come_back = FALSE;
4126 bool do_drop = TRUE;
4129 if (p_ptr->special_defense & KATA_MUSOU)
4131 set_action(ACTION_NONE);
4140 if (buki_motteruka(INVEN_LARM))
4142 item_tester_hook = item_tester_hook_boomerang;
4144 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4145 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4147 q = "Throw which item? ";
4148 s = "You have nothing to throw.";
4151 if (!get_item(&item, q, s, (USE_EQUIP)))
4166 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4167 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4169 q = "Throw which item? ";
4170 s = "You have nothing to throw.";
4173 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4180 /* Access the item (if in the pack) */
4183 o_ptr = &inventory[item];
4187 o_ptr = &o_list[0 - item];
4191 /* Item is cursed */
4192 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4196 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4198 msg_print("Hmmm, it seems to be cursed.");
4205 if (p_ptr->inside_arena)
4207 if (o_ptr->tval != 5)
4210 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4212 msg_print("You're in the arena now. This is hand-to-hand!");
4221 /* Get local object */
4224 /* Obtain a local object */
4225 object_copy(q_ptr, o_ptr);
4227 /* Extract the thrown object's flags. */
4228 object_flags(q_ptr, flgs);
4230 /* Distribute the charges of rods/wands between the stacks */
4231 distribute_charges(o_ptr, q_ptr, 1);
4237 object_desc(o_name, q_ptr, FALSE, 3);
4239 if (p_ptr->mighty_throw) mult += 3;
4241 /* Extract a "distance multiplier" */
4242 /* Changed for 'launcher' mutation */
4243 mul = 10 + 2 * (mult - 1);
4245 /* Enforce a minimum "weight" of one pound */
4246 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4247 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4249 /* Hack -- Distance -- Reward strength, penalize weight */
4250 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4252 /* Max distance of 10-18 */
4253 if (tdis > mul) tdis = mul;
4257 ty = randint0(101)-50+py;
4258 tx = randint0(101)-50+px;
4262 project_length = tdis + 1;
4264 /* Get a direction (or cancel) */
4265 if (!get_aim_dir(&dir)) return FALSE;
4267 /* Predict the "target" location */
4268 tx = px + 99 * ddx[dir];
4269 ty = py + 99 * ddy[dir];
4271 /* Check for "target request" */
4272 if ((dir == 5) && target_okay())
4278 project_length = 0; /* reset to default */
4281 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4282 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4283 return_when_thrown = TRUE;
4285 /* Reduce and describe inventory */
4288 inven_item_increase(item, -1);
4289 if (!return_when_thrown)
4290 inven_item_describe(item);
4291 inven_item_optimize(item);
4294 /* Reduce and describe floor item */
4297 floor_item_increase(0 - item, -1);
4298 floor_item_optimize(0 - item);
4300 if (item >= INVEN_RARM)
4302 equiped_item = TRUE;
4303 p_ptr->redraw |= (PR_EQUIPPY);
4309 /* Rogue and Ninja gets bonus */
4310 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4311 energy_use -= p_ptr->lev;
4313 /* Start at the player */
4318 /* Hack -- Handle stuff */
4321 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4322 else shuriken = FALSE;
4324 /* Chance of hitting */
4325 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4326 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4327 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4329 if (shuriken) chance *= 2;
4331 /* Travel until stopped */
4332 for (cur_dis = 0; cur_dis <= tdis; )
4334 /* Hack -- Stop at the target */
4335 if ((y == ty) && (x == tx)) break;
4337 /* Calculate the new location (see "project()") */
4340 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4342 /* Stopped by walls/doors */
4343 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4349 /* Advance the distance */
4352 /* The player can see the (on screen) missile */
4353 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4355 char c = object_char(q_ptr);
4356 byte a = object_attr(q_ptr);
4358 /* Draw, Hilite, Fresh, Pause, Erase */
4359 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4360 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4362 Term_xtra(TERM_XTRA_DELAY, msec);
4363 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4367 /* The player cannot see the missile */
4370 /* Pause anyway, for consistancy */
4371 Term_xtra(TERM_XTRA_DELAY, msec);
4374 /* Save the new location */
4379 /* Monster here, Try to hit it */
4380 if (cave[y][x].m_idx)
4382 cave_type *c_ptr = &cave[y][x];
4384 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4385 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4387 /* Check the visibility */
4388 visible = m_ptr->ml;
4390 /* Note the collision */
4393 /* Did we hit it (penalize range) */
4394 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4398 /* Handle unseen monster */
4401 /* Invisible monster */
4403 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4405 msg_format("The %s finds a mark.", o_name);
4410 /* Handle visible monster */
4415 /* Get "the monster" or "it" */
4416 monster_desc(m_name, m_ptr, 0);
4420 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4422 msg_format("The %s hits %s.", o_name, m_name);
4426 /* Hack -- Track this monster race */
4427 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4429 /* Hack -- Track this monster */
4430 if (m_ptr->ml) health_track(c_ptr->m_idx);
4433 /* Hack -- Base damage from thrown object */
4434 tdam = damroll(q_ptr->dd, q_ptr->ds);
4435 /* Apply special damage XXX XXX XXX */
4436 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4437 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4438 if (q_ptr->to_d > 0)
4439 tdam += q_ptr->to_d;
4441 tdam += -q_ptr->to_d;
4445 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4446 tdam += p_ptr->to_d_m;
4448 else if (have_flag(flgs, TR_THROW))
4451 tdam += p_ptr->to_d_m;
4459 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4462 /* No negative damage */
4463 if (tdam < 0) tdam = 0;
4465 /* Modify the damage */
4466 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4468 /* Complex message */
4472 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4475 msg_format("You do %d (out of %d) damage.",
4481 /* Hit the monster, check for death */
4482 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4491 message_pain(c_ptr->m_idx, tdam);
4493 /* Anger the monster */
4494 if ((tdam > 0) && !object_is_potion(q_ptr))
4495 anger_monster(m_ptr);
4498 if (fear && m_ptr->ml)
4505 /* Get the monster name (or "it") */
4506 monster_desc(m_name, m_ptr, 0);
4510 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4512 msg_format("%^s flees in terror!", m_name);
4524 /* Chance of breakage (during attacks) */
4525 j = (hit_body ? breakage_chance(q_ptr) : 0);
4527 /* Figurines transform */
4528 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4532 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4533 !(cursed_p(q_ptr)) ? PM_FORCE_PET : 0L)))
4535 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4537 msg_print("The Figurine writhes and then shatters.");
4540 else if (cursed_p(q_ptr))
4542 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4544 msg_print("You have a bad feeling about this.");
4550 /* Potions smash open */
4551 if (object_is_potion(q_ptr))
4553 if (hit_body || hit_wall || (randint1(100) < j))
4557 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4559 msg_format("The %s shatters!", o_name);
4563 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4565 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4567 /* ToDo (Robert): fix the invulnerability */
4568 if (cave[y][x].m_idx &&
4569 is_friendly(&m_list[cave[y][x].m_idx]) &&
4573 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4575 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4577 msg_format("%^s gets angry!", m_name);
4580 set_hostile(&m_list[cave[y][x].m_idx]);
4591 if (return_when_thrown)
4593 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4594 char o2_name[MAX_NLEN];
4595 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4598 if (boomerang) back_chance += 4+randint1(5);
4599 if (super_boomerang) back_chance += 100;
4600 object_desc(o2_name, q_ptr, FALSE, 0);
4602 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4604 for (i = cur_dis-1;i>0;i--)
4606 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4608 char c = object_char(q_ptr);
4609 byte a = object_attr(q_ptr);
4611 /* Draw, Hilite, Fresh, Pause, Erase */
4612 print_rel(c, a, ny[i], nx[i]);
4613 move_cursor_relative(ny[i], nx[i]);
4615 Term_xtra(TERM_XTRA_DELAY, msec);
4616 lite_spot(ny[i], nx[i]);
4621 /* Pause anyway, for consistancy */
4622 Term_xtra(TERM_XTRA_DELAY, msec);
4625 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4628 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4630 msg_format("%s comes back to you.", o2_name);
4639 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4641 msg_format("%s backs, but you can't catch!", o2_name);
4647 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4649 msg_format("%s comes back.", o2_name);
4659 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4661 msg_format("%s doesn't back!", o2_name);
4668 if (item == INVEN_RARM || item == INVEN_LARM)
4670 /* Access the wield slot */
4671 o_ptr = &inventory[item];
4673 /* Wear the new stuff */
4674 object_copy(o_ptr, q_ptr);
4676 /* Increase the weight */
4677 p_ptr->total_weight += q_ptr->weight;
4679 /* Increment the equip counter by hand */
4682 /* Recalculate bonuses */
4683 p_ptr->update |= (PU_BONUS);
4685 /* Recalculate torch */
4686 p_ptr->update |= (PU_TORCH);
4688 /* Recalculate mana XXX */
4689 p_ptr->update |= (PU_MANA);
4692 p_ptr->window |= (PW_EQUIP);
4700 else if (equiped_item)
4706 /* Drop (or break) near that location */
4707 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4714 * Throw an object from the pack or floor.
4716 void do_cmd_throw(void)
4718 do_cmd_throw_aux(1, FALSE, 0);