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.");
47 leaving_quest = p_ptr->inside_quest;
48 p_ptr->inside_quest = c_ptr->special;
50 /* Leaving an 'only once' quest marks it as failed */
52 ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
53 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
55 quest[leaving_quest].status = QUEST_STATUS_FAILED;
56 quest[leaving_quest].complev = p_ptr->lev;
57 if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
59 r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
60 if (record_rand_quest)
61 do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
63 else if (record_fix_quest)
64 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
68 if (cmd_go_up_callback()) return;
69 #endif /* USE_SCRIPT */
71 /* Activate the quest */
72 if (!quest[p_ptr->inside_quest].status)
74 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
78 if (!p_ptr->inside_quest)
84 p_ptr->leaving = TRUE;
85 p_ptr->leftbldg = TRUE;
90 /* Normal up stairs */
91 else if ((c_ptr->feat == FEAT_LESS) || (c_ptr->feat == FEAT_LESS_LESS))
102 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
104 if (get_check("Really leave the level? "))
118 /* Hack -- take a turn */
121 if (autosave_l) do_cmd_save_game(TRUE);
124 if (cmd_go_up_callback()) return;
125 #endif /* USE_SCRIPT */
127 if (p_ptr->inside_quest)
129 leaving_quest = p_ptr->inside_quest;
130 if (quest[leaving_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
132 /* Leaving an 'only once' quest marks it as failed */
134 ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
135 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
137 quest[leaving_quest].status = QUEST_STATUS_FAILED;
138 quest[leaving_quest].complev = p_ptr->lev;
139 if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
141 r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
142 if (record_rand_quest)
143 do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
145 else if (record_fix_quest)
146 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
149 p_ptr->inside_quest = c_ptr->special;
153 if (c_ptr->feat == FEAT_LESS_LESS)
155 /* Create a way back */
156 create_down_stair = 2;
162 /* Create a way back */
163 create_down_stair = 1;
167 if (!c_ptr->special && dungeon_type && ((dun_level - up_num + 1) > d_info[dungeon_type].mindepth) && one_in_(13))
171 if (c_ptr->feat == FEAT_LESS_LESS) msg_print("Ť¤¹£Æ»¤ò¾å¤Ã¤¿¡£");
172 else msg_print("Ť¤³¬Ãʤò¾å¤Ã¤¿¡£");
174 msg_print("These were very long stairs.");
178 if (dun_level-up_num+1 == d_info[dungeon_type].mindepth) up_num = dun_level;
180 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
182 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "go up the stairs to");
188 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
189 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
191 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
193 msg_print("You enter a maze of up staircases.");
197 /* Leaving the dungeon to town */
198 if (!dun_level && dungeon_type)
200 p_ptr->leaving_dungeon = TRUE;
201 if (!vanilla_town && !lite_town)
203 p_ptr->wilderness_y = d_info[dungeon_type].dy;
204 p_ptr->wilderness_x = d_info[dungeon_type].dx;
206 p_ptr->recall_dungeon = dungeon_type;
209 if (!dun_level) dungeon_type = 0;
212 p_ptr->leaving = TRUE;
218 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
220 msg_print("I see no up staircase here.");
231 void do_cmd_go_down(void)
234 bool go_down = FALSE;
235 bool fall_trap = FALSE;
238 if (p_ptr->special_defense & KATA_MUSOU)
240 set_action(ACTION_NONE);
244 c_ptr = &cave[py][px];
246 if (c_ptr->feat == (FEAT_TRAP_TRAPDOOR)) fall_trap = TRUE;
248 /* Quest down stairs */
249 if (c_ptr->feat == FEAT_QUEST_DOWN)
252 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
253 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
255 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
257 msg_print("You enter the down staircase.");
261 leaving_quest = p_ptr->inside_quest;
263 /* Leaving an 'only once' quest marks it as failed */
265 ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
266 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
268 quest[leaving_quest].status = QUEST_STATUS_FAILED;
269 quest[leaving_quest].complev = p_ptr->lev;
270 if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
272 r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
273 if (record_rand_quest)
274 do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
276 else if (record_fix_quest)
277 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
280 p_ptr->inside_quest = c_ptr->special;
282 /* Activate the quest */
283 if (!quest[p_ptr->inside_quest].status)
285 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
288 /* Leaving a quest */
289 if (!p_ptr->inside_quest)
295 p_ptr->leaving = TRUE;
296 p_ptr->leftbldg = TRUE;
302 else if ((c_ptr->feat != FEAT_MORE) && (c_ptr->feat != FEAT_MORE_MORE) && (c_ptr->feat != FEAT_ENTRANCE) && !fall_trap)
305 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
307 msg_print("I see no down staircase here.");
316 if (ironman_downward && (c_ptr->special != DUNGEON_ANGBAND))
319 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
321 msg_print("The entrance of this dungeon is closed!");
325 if (!max_dlv[c_ptr->special])
328 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[c_ptr->special].name, d_info[c_ptr->special].mindepth);
329 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
331 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);
332 if (!get_check("Do you really get in this dungeon? ")) return;
337 /* Save old player position */
340 dungeon_type = c_ptr->special;
347 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
349 if (get_check("Really leave the level? "))
363 /* Hack -- take a turn */
366 if (autosave_l) do_cmd_save_game(TRUE);
369 if (c_ptr->feat == FEAT_MORE_MORE) down_num += 2;
371 if (!quest_number(dun_level+down_num) && (dun_level < d_info[dungeon_type].maxdepth - 1 - down_num) && one_in_(13) && !fall_trap && dun_level)
375 if (c_ptr->feat == FEAT_MORE_MORE) msg_print("Ť¤¹£Æ»¤ò²¼¤ê¤¿¡£");
376 else msg_print("Ť¤³¬Ãʤò²¼¤ê¤¿¡£");
378 msg_print("These were very long stairs.");
382 else if (!dun_level) down_num = d_info[c_ptr->special].mindepth;
386 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
387 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
389 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fall from trap door");
390 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "go down the stairs to");
396 dun_level += down_num;
398 msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
400 msg_print("You deliberately jump through the trap door.");
406 if(c_ptr->feat == FEAT_ENTRANCE)
408 dun_level = d_info[c_ptr->special].mindepth;
410 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
412 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
417 dun_level += down_num;
419 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
420 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
422 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
424 msg_print("You enter a maze of down staircases.");
431 p_ptr->leaving = TRUE;
435 if (c_ptr->feat == FEAT_MORE_MORE)
437 /* Create a way back */
442 /* Create a way back */
453 * Simple command to "search" for one turn
455 void do_cmd_search(void)
457 /* Allow repeated command */
460 /* Set repeat count */
461 command_rep = command_arg - 1;
463 /* Redraw the state */
464 p_ptr->redraw |= (PR_STATE);
474 if (cmd_search_callback(py, px))
481 #endif /* USE_SCRIPT */
489 * Determine if a grid contains a chest
491 static s16b chest_check(int y, int x)
493 cave_type *c_ptr = &cave[y][x];
495 s16b this_o_idx, next_o_idx = 0;
498 /* Scan all objects in the grid */
499 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
504 o_ptr = &o_list[this_o_idx];
506 /* Acquire next object */
507 next_o_idx = o_ptr->next_o_idx;
509 /* Skip unknown chests XXX XXX */
510 /* if (!o_ptr->marked) continue; */
512 /* Check for chest */
513 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
522 * Allocates objects upon opening a chest -BEN-
524 * Disperse treasures from the given chest, centered at (x,y).
526 * Small chests often contain "gold", while Large chests always contain
527 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
528 * and Steel chests contain 6 items. The "value" of the items in a
529 * chest is based on the "power" of the chest, which is in turn based
530 * on the level on which the chest is generated.
532 static void chest_death(bool scatter, int y, int x, s16b o_idx)
542 object_type *o_ptr = &o_list[o_idx];
545 /* Small chests often hold "gold" */
546 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
548 /* Determine how much to drop (see above) */
549 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
551 if (o_ptr->sval == SV_CHEST_KANDUME)
556 object_level = o_ptr->xtra3;
560 /* Determine the "value" of the items */
561 object_level = ABS(o_ptr->pval) + 10;
564 /* Zero pval means empty chest */
565 if (!o_ptr->pval) number = 0;
567 /* Opening a chest */
568 opening_chest = TRUE;
570 /* Drop some objects (non-chests) */
571 for (; number > 0; --number)
573 /* Get local object */
576 /* Wipe the object */
579 /* Small chests often drop gold */
580 if (small && (rand_int(100) < 25))
583 if (!make_gold(q_ptr)) continue;
586 /* Otherwise drop an item */
589 /* Make a good object */
590 if (!make_object(q_ptr, TRUE, great)) continue;
594 q_ptr->python = object_create_callback(q_ptr);
595 #endif /* USE_SCRIPT */
597 /* If chest scatters its contents, pick any floor square. */
601 for (i = 0; i < 200; i++)
603 /* Pick a totally random spot. */
604 y = rand_int(MAX_HGT);
605 x = rand_int(MAX_WID);
607 /* Must be an empty floor. */
608 if (!cave_empty_bold(y, x)) continue;
610 /* Place the object there. */
611 drop_near(q_ptr, -1, y, x);
617 /* Normally, drop object near the chest. */
618 else drop_near(q_ptr, -1, y, x);
621 /* Reset the object level */
622 object_level = base_level;
624 /* No longer opening a chest */
625 opening_chest = FALSE;
636 * Chests have traps too.
638 * Exploding chest destroys contents (and traps).
639 * Note that the chest itself is never destroyed.
641 static void chest_trap(int y, int x, s16b o_idx)
645 object_type *o_ptr = &o_list[o_idx];
647 int mon_level = o_ptr->xtra3;
649 /* Ignore disarmed chests */
650 if (o_ptr->pval <= 0) return;
652 /* Obtain the traps */
653 trap = chest_traps[o_ptr->pval];
656 if (trap & (CHEST_LOSE_STR))
659 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
660 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
662 msg_print("A small needle has pricked you!");
663 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
666 (void)do_dec_stat(A_STR);
669 /* Lose constitution */
670 if (trap & (CHEST_LOSE_CON))
673 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
674 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
676 msg_print("A small needle has pricked you!");
677 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
680 (void)do_dec_stat(A_CON);
684 if (trap & (CHEST_POISON))
687 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
689 msg_print("A puff of green gas surrounds you!");
692 if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
694 (void)set_poisoned(p_ptr->poisoned + 10 + randint(20));
699 if (trap & (CHEST_PARALYZE))
702 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
704 msg_print("A puff of yellow gas surrounds you!");
708 if (!p_ptr->free_act)
710 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint(20));
714 /* Summon monsters */
715 if (trap & (CHEST_SUMMON))
717 int num = 2 + randint(3);
719 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
721 msg_print("You are enveloped in a cloud of smoke!");
725 for (i = 0; i < num; i++)
727 if (randint(100)<dun_level)
728 activate_hi_summon(py, px, FALSE);
730 (void)summon_specific(0, y, x, mon_level, 0, TRUE, FALSE, FALSE, TRUE, TRUE);
734 /* Elemental summon. */
735 if (trap & (CHEST_E_SUMMON))
738 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
740 msg_print("Elemental beings appear to protect their treasures!");
742 for (i = 0; i < randint(3) + 5; i++)
744 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, TRUE, FALSE, FALSE, TRUE, TRUE);
748 /* Force clouds, then summon birds. */
749 if (trap & (CHEST_BIRD_STORM))
752 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
754 msg_print("A storm of birds swirls around you!");
757 for (i = 0; i < randint(3) + 3; i++)
758 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
760 for (i = 0; i < randint(5) + o_ptr->pval / 5; i++)
762 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, TRUE, FALSE, FALSE, TRUE, TRUE);
766 /* Various colorful summonings. */
767 if (trap & (CHEST_H_SUMMON))
770 if (rand_int(4) == 0)
773 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
775 msg_print("Demons materialize in clouds of fire and brimstone!");
778 for (i = 0; i < randint(3) + 2; i++)
780 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
781 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, TRUE, FALSE, FALSE, TRUE, TRUE);
785 /* Summon dragons. */
786 else if (rand_int(3) == 0)
789 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
791 msg_print("Draconic forms loom out of the darkness!");
794 for (i = 0; i < randint(3) + 2; i++)
796 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, TRUE, FALSE, FALSE, TRUE, TRUE);
800 /* Summon hybrids. */
801 else if (rand_int(2) == 0)
804 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
806 msg_print("Creatures strange and twisted assault you!");
809 for (i = 0; i < randint(5) + 3; i++)
811 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, TRUE, FALSE, FALSE, TRUE, TRUE);
815 /* Summon vortices (scattered) */
819 msg_print("±²´¬¤«¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
821 msg_print("Vortices coalesce and wreak destruction!");
824 for (i = 0; i < randint(3) + 2; i++)
826 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, TRUE, FALSE, FALSE, TRUE, TRUE);
832 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
834 /* Determine how many nasty tricks can be played. */
835 int nasty_tricks_count = 4 + rand_int(3);
839 msg_print("¶²¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
841 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
844 /* This is gonna hurt... */
845 for (; nasty_tricks_count > 0; nasty_tricks_count--)
847 /* ...but a high saving throw does help a little. */
848 if (randint(100+o_ptr->pval*2) > p_ptr->skill_sav)
851 if (rand_int(6) == 0) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
853 if (rand_int(6) == 0) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
855 else if (rand_int(5) == 0) (void)set_cut(p_ptr->cut + 200);
856 else if (rand_int(4) == 0)
858 if (!p_ptr->free_act)
859 (void)set_paralyzed(p_ptr->paralyzed + 2 +
862 (void)set_stun(p_ptr->stun + 10 +
865 else if (rand_int(3) == 0) apply_disenchant(0);
866 else if (rand_int(2) == 0)
868 (void)do_dec_stat(A_STR);
869 (void)do_dec_stat(A_DEX);
870 (void)do_dec_stat(A_CON);
871 (void)do_dec_stat(A_INT);
872 (void)do_dec_stat(A_WIS);
873 (void)do_dec_stat(A_CHR);
875 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
881 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
884 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
885 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
887 msg_print("There is a sudden explosion!");
888 msg_print("Everything inside the chest is destroyed!");
892 sound(SOUND_EXPLODE);
894 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
896 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
900 /* Scatter contents. */
901 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
904 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
906 msg_print("The contents of the chest scatter all over the dungeon!");
908 chest_death(TRUE, y, x, o_idx);
915 * Attempt to open the given chest at the given location
917 * Assume there is no monster blocking the destination
919 * Returns TRUE if repeated commands may continue
921 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
929 object_type *o_ptr = &o_list[o_idx];
935 /* Attempt to unlock it */
938 /* Assume locked, and thus not open */
941 /* Get the "disarm" factor */
942 i = p_ptr->skill_dis;
944 /* Penalize some conditions */
945 if (p_ptr->blind || no_lite()) i = i / 10;
946 if (p_ptr->confused || p_ptr->image) i = i / 10;
948 /* Extract the difficulty */
951 /* Always have a small chance of success */
954 /* Success -- May still have traps */
955 if (rand_int(100) < j)
958 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
960 msg_print("You have picked the lock.");
967 /* Failure -- Keep trying */
970 /* We may continue repeating */
972 if (flush_failure) flush();
974 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
976 msg_print("You failed to pick the lock.");
982 /* Allowed to open */
985 /* Apply chest traps, if any */
986 chest_trap(y, x, o_idx);
988 /* Let the Chest drop items */
989 chest_death(FALSE, y, x, o_idx);
997 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
1000 * Return TRUE if the given feature is an open door
1002 static bool is_open(int feat)
1004 return (feat == FEAT_OPEN);
1007 static bool is_closed(int feat)
1009 return ((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL));
1013 * Return the number of features around (or under) the character.
1014 * Usually look for doors and floor traps.
1016 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
1018 int d, count, xx, yy;
1020 /* Count how many matches */
1023 /* Check around (and under) the character */
1024 for (d = 0; d < 9; d++)
1026 /* if not searching under player continue */
1027 if ((d == 8) && !under) continue;
1029 /* Extract adjacent (legal) location */
1030 yy = py + ddy_ddd[d];
1031 xx = px + ddx_ddd[d];
1033 /* Must have knowledge */
1034 if (!(cave[yy][xx].info & (CAVE_MARK))) continue;
1036 /* Not looking for this feature */
1037 if (!((*test)(cave[yy][xx].feat))) continue;
1042 /* Remember the location. Only useful if only one match */
1053 * Return the number of chests around (or under) the character.
1054 * If requested, count only trapped chests.
1056 static int count_chests(int *y, int *x, bool trapped)
1058 int d, count, o_idx;
1062 /* Count how many matches */
1065 /* Check around (and under) the character */
1066 for (d = 0; d < 9; d++)
1068 /* Extract adjacent (legal) location */
1069 int yy = py + ddy_ddd[d];
1070 int xx = px + ddx_ddd[d];
1072 /* No (visible) chest is there */
1073 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1075 /* Grab the object */
1076 o_ptr = &o_list[o_idx];
1079 if (o_ptr->pval == 0) continue;
1081 /* No (known) traps here */
1082 if (trapped && (!object_known_p(o_ptr) ||
1083 !chest_traps[o_ptr->pval])) continue;
1088 /* Remember the location. Only useful if only one match */
1099 * Convert an adjacent location to a direction.
1101 static int coords_to_dir(int y, int x)
1103 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1110 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1112 return d[dx + 1][dy + 1];
1115 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1119 * Perform the basic "open" command on doors
1121 * Assume destination is a closed/locked/jammed door
1123 * Assume there is no monster blocking the destination
1125 * Returns TRUE if repeated commands may continue
1127 static bool do_cmd_open_aux(int y, int x, int dir)
1139 /* Get requested grid */
1140 c_ptr = &cave[y][x];
1143 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1147 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1149 msg_print("The door appears to be stuck.");
1155 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1158 i = p_ptr->skill_dis;
1160 /* Penalize some conditions */
1161 if (p_ptr->blind || no_lite()) i = i / 10;
1162 if (p_ptr->confused || p_ptr->image) i = i / 10;
1164 /* Extract the lock power */
1165 j = c_ptr->feat - FEAT_DOOR_HEAD;
1167 /* Extract the difficulty XXX XXX XXX */
1170 /* Always have a small chance of success */
1174 if (rand_int(100) < j)
1178 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1180 msg_print("You have picked the lock.");
1185 cave_set_feat(y, x, FEAT_OPEN);
1187 /* Update some things */
1188 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1191 sound(SOUND_OPENDOOR);
1201 if (flush_failure) flush();
1205 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1207 msg_print("You failed to pick the lock.");
1211 /* We may keep trying */
1220 cave_set_feat(y, x, FEAT_OPEN);
1222 /* Update some things */
1223 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1226 sound(SOUND_OPENDOOR);
1236 * Open a closed/locked/jammed door or a closed/locked chest.
1238 * Unlocking a locked door/chest is worth one experience point.
1240 void do_cmd_open(void)
1250 if (p_ptr->special_defense & KATA_MUSOU)
1252 set_action(ACTION_NONE);
1255 #ifdef ALLOW_EASY_OPEN /* TNB */
1257 /* Option: Pick a direction */
1260 int num_doors, num_chests;
1262 /* Count closed doors (locked or jammed) */
1263 num_doors = count_dt(&y, &x, is_closed, FALSE);
1265 /* Count chests (locked) */
1266 num_chests = count_chests(&y, &x, FALSE);
1268 /* See if only one target */
1269 if (num_doors || num_chests)
1271 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1273 if (!too_many) command_dir = coords_to_dir(y, x);
1277 #endif /* ALLOW_EASY_OPEN -- TNB */
1279 /* Allow repeated command */
1282 /* Set repeat count */
1283 command_rep = command_arg - 1;
1285 /* Redraw the state */
1286 p_ptr->redraw |= (PR_STATE);
1288 /* Cancel the arg */
1292 /* Get a "repeated" direction */
1293 if (get_rep_dir(&dir, TRUE))
1295 /* Get requested location */
1300 if (cmd_open_callback(y, x))
1302 /* Don't repeat the action */
1306 #endif /* USE_SCRIPT */
1308 /* Get requested grid */
1309 c_ptr = &cave[y][x];
1311 /* Check for chest */
1312 o_idx = chest_check(y, x);
1314 /* Nothing useful */
1315 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1316 (c_ptr->feat <= FEAT_DOOR_TAIL)) &&
1321 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1323 msg_print("You see nothing there to open.");
1328 /* Monster in the way */
1329 else if (c_ptr->m_idx)
1336 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1338 msg_print("There is a monster in the way!");
1349 /* Open the chest */
1350 more = do_cmd_open_chest(y, x, o_idx);
1357 more = do_cmd_open_aux(y, x, dir);
1361 /* Cancel repeat unless we may continue */
1362 if (!more) disturb(0, 0);
1368 * Perform the basic "close" command
1370 * Assume destination is an open/broken door
1372 * Assume there is no monster blocking the destination
1374 * Returns TRUE if repeated commands may continue
1376 static bool do_cmd_close_aux(int y, int x, int dir)
1386 /* Get grid and contents */
1387 c_ptr = &cave[y][x];
1390 if (c_ptr->feat == FEAT_BROKEN)
1394 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1396 msg_print("The door appears to be broken.");
1404 /* Close the door */
1405 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1407 /* Update some things */
1408 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1411 sound(SOUND_SHUTDOOR);
1420 * Close an open door.
1422 void do_cmd_close(void)
1430 if (p_ptr->special_defense & KATA_MUSOU)
1432 set_action(ACTION_NONE);
1435 #ifdef ALLOW_EASY_OPEN /* TNB */
1437 /* Option: Pick a direction */
1440 /* Count open doors */
1441 if (count_dt(&y, &x, is_open, FALSE) == 1)
1443 command_dir = coords_to_dir(y, x);
1447 #endif /* ALLOW_EASY_OPEN -- TNB */
1449 /* Allow repeated command */
1452 /* Set repeat count */
1453 command_rep = command_arg - 1;
1455 /* Redraw the state */
1456 p_ptr->redraw |= (PR_STATE);
1458 /* Cancel the arg */
1462 /* Get a "repeated" direction */
1463 if (get_rep_dir(&dir,FALSE))
1465 /* Get requested location */
1469 /* Get grid and contents */
1470 c_ptr = &cave[y][x];
1472 /* Require open/broken door */
1473 if ((c_ptr->feat != FEAT_OPEN) && (c_ptr->feat != FEAT_BROKEN))
1477 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1479 msg_print("You see nothing there to close.");
1484 /* Monster in the way */
1485 else if (c_ptr->m_idx)
1492 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1494 msg_print("There is a monster in the way!");
1502 /* Close the door */
1505 /* Close the door */
1506 more = do_cmd_close_aux(y, x, dir);
1510 /* Cancel repeat unless we may continue */
1511 if (!more) disturb(0, 0);
1516 * Determine if a given grid may be "tunneled"
1518 static bool do_cmd_tunnel_test(int y, int x)
1520 /* Must have knowledge */
1521 if (!(cave[y][x].info & (CAVE_MARK)))
1525 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1527 msg_print("You see nothing there.");
1535 /* Must be a wall/door/etc */
1536 if (cave_floor_bold(y, x))
1540 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1542 msg_print("You see nothing there to tunnel.");
1557 * Tunnel through wall. Assumes valid location.
1559 * Note that it is impossible to "extend" rooms past their
1560 * outer walls (which are actually part of the room).
1562 * This will, however, produce grids which are NOT illuminated
1563 * (or darkened) along with the rest of the room.
1565 static bool twall(int y, int x, byte feat)
1567 cave_type *c_ptr = &cave[y][x];
1569 /* Paranoia -- Require a wall or door or some such */
1570 if (cave_floor_bold(y, x)) return (FALSE);
1572 /* Forget the wall */
1573 c_ptr->info &= ~(CAVE_MARK);
1574 c_ptr->info &= ~(CAVE_MASK);
1575 c_ptr->info |= (CAVE_FLOOR);
1577 /* Remove the feature */
1578 cave_set_feat(y, x, feat);
1580 /* Update some things */
1581 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1590 * Perform the basic "tunnel" command
1592 * Assumes that the destination is a wall, a vein, a secret
1595 * Assumes that no monster is blocking the destination
1597 * Returns TRUE if repeated commands may continue
1599 static bool do_cmd_tunnel_aux(int y, int x, int dir)
1605 /* Verify legality */
1606 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1612 c_ptr = &cave[y][x];
1618 if ((c_ptr->feat >= FEAT_PERM_EXTRA) &&
1619 (c_ptr->feat <= FEAT_PERM_SOLID))
1622 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1624 msg_print("This seems to be permanent rock.");
1629 /* No tunnelling through mountains */
1630 else if (c_ptr->feat == FEAT_MOUNTAIN)
1633 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1635 msg_print("You can't tunnel through that!");
1640 else if (c_ptr->feat == FEAT_TREES) /* -KMW- */
1643 if ((p_ptr->skill_dig > 10 + rand_int(400)) && twall(y, x, FEAT_GRASS))
1646 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1648 msg_print("You have cleared away the trees.");
1650 chg_virtue(V_DILIGENCE, 1);
1651 chg_virtue(V_NATURE, -1);
1657 /* We may continue chopping */
1659 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1661 msg_print("You chop away at the tree.");
1666 /* Occasional Search XXX XXX */
1667 if (rand_int(100) < 25) search();
1673 else if ((c_ptr->feat >= FEAT_WALL_EXTRA) &&
1674 (c_ptr->feat <= FEAT_WALL_SOLID))
1677 if ((p_ptr->skill_dig > 40 + rand_int(1600)) && twall(y, x, floor_type[rand_int(100)]))
1680 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1682 msg_print("You have finished the tunnel.");
1684 chg_virtue(V_DILIGENCE, 1);
1685 chg_virtue(V_NATURE, -1);
1691 /* We may continue tunelling */
1693 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1695 msg_print("You tunnel into the granite wall.");
1703 /* Quartz / Magma */
1704 else if ((c_ptr->feat >= FEAT_MAGMA) &&
1705 (c_ptr->feat <= FEAT_QUARTZ_K))
1712 if (c_ptr->feat >= FEAT_MAGMA_H) gold = TRUE;
1714 /* Extract "quartz" flag XXX XXX XXX */
1715 if ((c_ptr->feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1720 okay = (p_ptr->skill_dig > 20 + rand_int(800));
1726 okay = (p_ptr->skill_dig > 10 + rand_int(400));
1730 if (okay && twall(y, x, floor_type[rand_int(100)]))
1732 /* Found treasure */
1735 /* Place some gold */
1740 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1742 msg_print("You have found something!");
1752 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1754 msg_print("You have finished the tunnel.");
1756 chg_virtue(V_DILIGENCE, 1);
1757 chg_virtue(V_NATURE, -1);
1761 /* Failure (quartz) */
1764 /* Message, continue digging */
1766 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1768 msg_print("You tunnel into the quartz vein.");
1774 /* Failure (magma) */
1777 /* Message, continue digging */
1779 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1781 msg_print("You tunnel into the magma vein.");
1789 else if (c_ptr->feat == FEAT_RUBBLE)
1791 /* Remove the rubble */
1792 if ((p_ptr->skill_dig > rand_int(200)) && twall(y, x, floor_type[rand_int(100)]))
1796 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1798 msg_print("You have removed the rubble.");
1801 /* Hack -- place an object */
1802 if (rand_int(100) < (15 - dun_level/2))
1804 /* Create a simple object */
1805 place_object(y, x, FALSE, FALSE);
1807 /* Observe new object */
1808 if (player_can_see_bold(y, x))
1811 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1813 msg_print("You have found something!");
1822 /* Message, keep digging */
1824 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1826 msg_print("You dig in the rubble.");
1834 else if (c_ptr->feat >= FEAT_SECRET)
1837 if ((p_ptr->skill_dig > 30 + rand_int(1200)) && twall(y, x, floor_type[rand_int(100)]))
1840 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1842 msg_print("You have finished the tunnel.");
1850 /* We may continue tunelling */
1852 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1854 msg_print("You tunnel into the granite wall.");
1859 /* Occasional Search XXX XXX */
1860 if (rand_int(100) < 25) search();
1868 if ((p_ptr->skill_dig > 30 + rand_int(1200)) && twall(y, x, floor_type[randint(100)]))
1871 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1873 msg_print("You have finished the tunnel.");
1881 /* We may continue tunelling */
1883 msg_print("¥É¥¢¤Ë·ê¤ò³«¤±¤Æ¤¤¤ë¡£");
1885 msg_print("You tunnel into the door.");
1892 /* Notice new floor grids */
1893 if (!cave_floor_bold(y, x))
1895 /* Update some things */
1896 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1905 * Tunnels through "walls" (including rubble and closed doors)
1907 * Note that you must tunnel in order to hit invisible monsters
1908 * in walls, though moving into walls still takes a turn anyway.
1910 * Digging is very difficult without a "digger" weapon, but can be
1911 * accomplished by strong players using heavy weapons.
1913 void do_cmd_tunnel(void)
1922 if (p_ptr->special_defense & KATA_MUSOU)
1924 set_action(ACTION_NONE);
1927 /* Allow repeated command */
1930 /* Set repeat count */
1931 command_rep = command_arg - 1;
1933 /* Redraw the state */
1934 p_ptr->redraw |= (PR_STATE);
1936 /* Cancel the arg */
1940 /* Get a direction to tunnel, or Abort */
1941 if (get_rep_dir(&dir,FALSE))
1948 c_ptr = &cave[y][x];
1950 /* No tunnelling through doors */
1951 if (((c_ptr->feat >= FEAT_DOOR_HEAD) && (c_ptr->feat <= FEAT_DOOR_TAIL)) ||
1952 ((c_ptr->feat >= FEAT_BLDG_HEAD) && (c_ptr->feat <= FEAT_BLDG_TAIL)) ||
1953 ((c_ptr->feat >= FEAT_SHOP_HEAD) && (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
1954 (c_ptr->feat == FEAT_MUSEUM))
1958 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1960 msg_print("You cannot tunnel through doors.");
1965 /* No tunnelling through air */
1966 else if (cave_floor_grid(c_ptr) || ((c_ptr->feat >= FEAT_MINOR_GLYPH) &&
1967 (c_ptr->feat <= FEAT_PATTERN_XTRA2)))
1971 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1973 msg_print("You cannot tunnel through air.");
1978 /* No tunnelling through mountains */
1979 else if (c_ptr->feat == FEAT_MOUNTAIN)
1982 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1984 msg_print("You can't tunnel through that!");
1989 /* A monster is in the way */
1990 else if (c_ptr->m_idx)
1997 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1999 msg_print("There is a monster in the way!");
2010 /* Tunnel through walls */
2011 more = do_cmd_tunnel_aux(y, x, dir);
2015 /* Cancel repetition unless we can continue */
2016 if (!more) disturb(0, 0);
2020 #ifdef ALLOW_EASY_OPEN /* TNB */
2025 * If there is a jammed/closed/locked door at the given location,
2026 * then attempt to unlock/open it. Return TRUE if an attempt was
2027 * made (successful or not), otherwise return FALSE.
2029 * The code here should be nearly identical to that in
2030 * do_cmd_open_test() and do_cmd_open_aux().
2032 bool easy_open_door(int y, int x)
2036 cave_type *c_ptr = &cave[y][x];
2038 /* Must be a closed door */
2039 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2040 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2047 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
2051 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
2053 msg_print("The door appears to be stuck.");
2059 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
2062 i = p_ptr->skill_dis;
2064 /* Penalize some conditions */
2065 if (p_ptr->blind || no_lite()) i = i / 10;
2066 if (p_ptr->confused || p_ptr->image) i = i / 10;
2068 /* Extract the lock power */
2069 j = c_ptr->feat - FEAT_DOOR_HEAD;
2071 /* Extract the difficulty XXX XXX XXX */
2074 /* Always have a small chance of success */
2078 if (rand_int(100) < j)
2082 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
2084 msg_print("You have picked the lock.");
2089 cave_set_feat(y, x, FEAT_OPEN);
2091 /* Update some things */
2092 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2095 sound(SOUND_OPENDOOR);
2105 if (flush_failure) flush();
2109 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2111 msg_print("You failed to pick the lock.");
2121 cave_set_feat(y, x, FEAT_OPEN);
2123 /* Update some things */
2124 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2127 sound(SOUND_OPENDOOR);
2134 #endif /* ALLOW_EASY_OPEN -- TNB */
2138 * Perform the basic "disarm" command
2140 * Assume destination is a visible trap
2142 * Assume there is no monster blocking the destination
2144 * Returns TRUE if repeated commands may continue
2146 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2152 object_type *o_ptr = &o_list[o_idx];
2158 /* Get the "disarm" factor */
2159 i = p_ptr->skill_dis;
2161 /* Penalize some conditions */
2162 if (p_ptr->blind || no_lite()) i = i / 10;
2163 if (p_ptr->confused || p_ptr->image) i = i / 10;
2165 /* Extract the difficulty */
2166 j = i - o_ptr->pval;
2168 /* Always have a small chance of success */
2171 /* Must find the trap first. */
2172 if (!object_known_p(o_ptr))
2175 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2177 msg_print("I don't see any traps.");
2182 /* Already disarmed/unlocked */
2183 else if (o_ptr->pval <= 0)
2186 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2188 msg_print("The chest is not trapped.");
2193 /* No traps to find. */
2194 else if (!chest_traps[o_ptr->pval])
2197 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2199 msg_print("The chest is not trapped.");
2204 /* Success (get a lot of experience) */
2205 else if (rand_int(100) < j)
2208 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2210 msg_print("You have disarmed the chest.");
2213 gain_exp(o_ptr->pval);
2214 o_ptr->pval = (0 - o_ptr->pval);
2217 /* Failure -- Keep trying */
2218 else if ((i > 5) && (randint(i) > 5))
2220 /* We may keep trying */
2222 if (flush_failure) flush();
2224 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2226 msg_print("You failed to disarm the chest.");
2231 /* Failure -- Set off the trap */
2235 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2237 msg_print("You set off a trap!");
2241 chest_trap(y, x, o_idx);
2250 * Perform the basic "disarm" command
2252 * Assume destination is a visible trap
2254 * Assume there is no monster blocking the destination
2256 * Returns TRUE if repeated commands may continue
2258 #ifdef ALLOW_EASY_DISARM /* TNB */
2260 bool do_cmd_disarm_aux(int y, int x, int dir)
2262 #else /* ALLOW_EASY_DISARM -- TNB */
2264 static bool do_cmd_disarm_aux(int y, int x, int dir)
2266 #endif /* ALLOW_EASY_DISARM -- TNB */
2280 /* Get grid and contents */
2281 c_ptr = &cave[y][x];
2283 /* Access trap name */
2284 name = (f_name + f_info[c_ptr->feat].name);
2286 /* Get the "disarm" factor */
2287 i = p_ptr->skill_dis;
2289 /* Penalize some conditions */
2290 if (p_ptr->blind || no_lite()) i = i / 10;
2291 if (p_ptr->confused || p_ptr->image) i = i / 10;
2293 /* XXX XXX XXX Variable power? */
2295 /* Extract trap "power" */
2298 /* Extract the difficulty */
2301 /* Always have a small chance of success */
2305 if (rand_int(100) < j)
2309 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2311 msg_format("You have disarmed the %s.", name);
2318 /* Forget the trap */
2319 c_ptr->info &= ~(CAVE_MARK);
2321 /* Remove the trap */
2322 c_ptr->feat = floor_type[rand_int(100)];
2323 c_ptr->info &= ~(CAVE_MASK);
2324 c_ptr->info |= CAVE_FLOOR;
2328 #ifdef ALLOW_EASY_DISARM /* TNB */
2330 /* Move the player onto the trap */
2331 move_player(dir, easy_disarm, FALSE);
2333 #else /* ALLOW_EASY_DISARM -- TNB */
2335 /* move the player onto the trap grid */
2336 move_player(dir, FALSE, FALSE);
2338 #endif /* ALLOW_EASY_DISARM -- TNB */
2341 /* Failure -- Keep trying */
2342 else if ((i > 5) && (randint(i) > 5))
2345 if (flush_failure) flush();
2349 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2351 msg_format("You failed to disarm the %s.", name);
2355 /* We may keep trying */
2359 /* Failure -- Set off the trap */
2364 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2366 msg_format("You set off the %s!", name);
2370 #ifdef ALLOW_EASY_DISARM /* TNB */
2372 /* Move the player onto the trap */
2373 move_player(dir, easy_disarm, FALSE);
2375 #else /* ALLOW_EASY_DISARM -- TNB */
2377 /* Move the player onto the trap */
2378 move_player(dir, FALSE, FALSE);
2380 #endif /* ALLOW_EASY_DISARM -- TNB */
2389 * Disarms a trap, or chest
2391 void do_cmd_disarm(void)
2401 if (p_ptr->special_defense & KATA_MUSOU)
2403 set_action(ACTION_NONE);
2406 #ifdef ALLOW_EASY_DISARM /* TNB */
2408 /* Option: Pick a direction */
2411 int num_traps, num_chests;
2413 /* Count visible traps */
2414 num_traps = count_dt(&y, &x, is_trap, TRUE);
2416 /* Count chests (trapped) */
2417 num_chests = count_chests(&y, &x, TRUE);
2419 /* See if only one target */
2420 if (num_traps || num_chests)
2422 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2424 if (!too_many) command_dir = coords_to_dir(y, x);
2428 #endif /* ALLOW_EASY_DISARM -- TNB */
2430 /* Allow repeated command */
2433 /* Set repeat count */
2434 command_rep = command_arg - 1;
2436 /* Redraw the state */
2437 p_ptr->redraw |= (PR_STATE);
2439 /* Cancel the arg */
2443 /* Get a direction (or abort) */
2444 if (get_rep_dir(&dir,TRUE))
2450 /* Get grid and contents */
2451 c_ptr = &cave[y][x];
2453 /* Check for chests */
2454 o_idx = chest_check(y, x);
2457 if (!is_trap(c_ptr->feat) && !o_idx)
2461 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2463 msg_print("You see nothing there to disarm.");
2468 /* Monster in the way */
2469 else if (c_ptr->m_idx)
2473 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2475 msg_print("There is a monster in the way!");
2486 /* Disarm the chest */
2487 more = do_cmd_disarm_chest(y, x, o_idx);
2493 /* Disarm the trap */
2494 more = do_cmd_disarm_aux(y, x, dir);
2498 /* Cancel repeat unless told not to */
2499 if (!more) disturb(0, 0);
2504 * Perform the basic "bash" command
2506 * Assume destination is a closed/locked/jammed door
2508 * Assume there is no monster blocking the destination
2510 * Returns TRUE if repeated commands may continue
2512 static bool do_cmd_bash_aux(int y, int x, int dir)
2525 c_ptr = &cave[y][x];
2529 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2531 msg_print("You smash into the door!");
2535 /* Hack -- Bash power based on strength */
2536 /* (Ranges from 3 to 20 to 100 to 200) */
2537 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2539 /* Extract door power */
2540 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2542 /* Compare bash power to door power XXX XXX XXX */
2543 temp = (bash - (temp * 10));
2545 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2547 /* Hack -- always have a chance */
2548 if (temp < 1) temp = 1;
2550 /* Hack -- attempt to bash down the door */
2551 if (rand_int(100) < temp)
2555 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2557 msg_print("The door crashes open!");
2561 /* Break down the door */
2562 if (rand_int(100) < 50)
2564 cave_set_feat(y, x, FEAT_BROKEN);
2570 cave_set_feat(y, x, FEAT_OPEN);
2574 sound(SOUND_OPENDOOR);
2576 /* Hack -- Fall through the door */
2577 move_player(dir, FALSE, FALSE);
2579 /* Update some things */
2580 p_ptr->update |= (PU_VIEW | PU_LITE);
2581 p_ptr->update |= (PU_DISTANCE);
2584 /* Saving throw against stun */
2585 else if (rand_int(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2590 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2592 msg_print("The door holds firm.");
2596 /* Allow repeated bashing */
2600 /* High dexterity yields coolness */
2605 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2607 msg_print("You are off-balance.");
2611 /* Hack -- Lose balance ala paralysis */
2612 (void)set_paralyzed(p_ptr->paralyzed + 2 + rand_int(2));
2621 * Bash open a door, success based on character strength
2623 * For a closed door, pval is positive if locked; negative if stuck.
2625 * For an open door, pval is positive for a broken door.
2627 * A closed door can be opened - harder if locked. Any door might be
2628 * bashed open (and thereby broken). Bashing a door is (potentially)
2629 * faster! You move into the door way. To open a stuck door, it must
2630 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2632 * Creatures can also open or bash doors, see elsewhere.
2634 void do_cmd_bash(void)
2643 if (p_ptr->special_defense & KATA_MUSOU)
2645 set_action(ACTION_NONE);
2648 /* Allow repeated command */
2651 /* Set repeat count */
2652 command_rep = command_arg - 1;
2654 /* Redraw the state */
2655 p_ptr->redraw |= (PR_STATE);
2657 /* Cancel the arg */
2661 /* Get a "repeated" direction */
2662 if (get_rep_dir(&dir,FALSE))
2669 c_ptr = &cave[y][x];
2671 /* Nothing useful */
2672 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2673 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2677 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2679 msg_print("You see nothing there to bash.");
2684 /* Monster in the way */
2685 else if (c_ptr->m_idx)
2692 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2694 msg_print("There is a monster in the way!");
2702 /* Bash a closed door */
2706 more = do_cmd_bash_aux(y, x, dir);
2710 /* Unless valid action taken, cancel bash */
2711 if (!more) disturb(0, 0);
2716 * Manipulate an adjacent grid in some way
2718 * Attack monsters, tunnel through walls, disarm traps, open doors.
2720 * Consider confusion XXX XXX XXX
2722 * This command must always take a turn, to prevent free detection
2723 * of invisible monsters.
2725 void do_cmd_alter(void)
2734 if (p_ptr->special_defense & KATA_MUSOU)
2736 set_action(ACTION_NONE);
2739 /* Allow repeated command */
2742 /* Set repeat count */
2743 command_rep = command_arg - 1;
2745 /* Redraw the state */
2746 p_ptr->redraw |= (PR_STATE);
2748 /* Cancel the arg */
2752 /* Get a direction */
2753 if (get_rep_dir(&dir,TRUE))
2760 c_ptr = &cave[y][x];
2765 /* Attack monsters */
2772 /* Tunnel through walls */
2773 else if (((c_ptr->feat >= FEAT_SECRET) &&
2774 (c_ptr->feat < FEAT_MINOR_GLYPH)) ||
2775 ((c_ptr->feat == FEAT_TREES) ||
2776 (c_ptr->feat == FEAT_MOUNTAIN)))
2779 more = do_cmd_tunnel_aux(y, x, dir);
2782 /* Bash jammed doors */
2783 else if ((c_ptr->feat >= FEAT_DOOR_HEAD + 0x08) &&
2784 (c_ptr->feat < FEAT_MINOR_GLYPH))
2787 more = do_cmd_bash_aux(y, x, dir);
2790 /* Open closed doors */
2791 else if ((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2792 (c_ptr->feat < FEAT_MINOR_GLYPH))
2795 more = do_cmd_open_aux(y, x, dir);
2798 /* Close open doors */
2799 else if ((c_ptr->feat == FEAT_OPEN) ||
2800 (c_ptr->feat == FEAT_BROKEN))
2803 more = do_cmd_close_aux(y, x, dir);
2807 else if (is_trap(c_ptr->feat))
2810 more = do_cmd_disarm_aux(y, x, dir);
2818 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2820 msg_print("You attack the empty air.");
2826 /* Cancel repetition unless we can continue */
2827 if (!more) disturb(0, 0);
2832 * Find the index of some "spikes", if possible.
2834 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2836 static bool get_spike(int *ip)
2840 /* Check every item in the pack */
2841 for (i = 0; i < INVEN_PACK; i++)
2843 object_type *o_ptr = &inventory[i];
2845 /* Skip non-objects */
2846 if (!o_ptr->k_idx) continue;
2848 /* Check the "tval" code */
2849 if (o_ptr->tval == TV_SPIKE)
2851 /* Save the spike index */
2865 * Jam a closed door with a spike
2867 * This command may NOT be repeated
2869 void do_cmd_spike(void)
2871 int y, x, dir, item;
2876 if (p_ptr->special_defense & KATA_MUSOU)
2878 set_action(ACTION_NONE);
2881 /* Get a "repeated" direction */
2882 if (get_rep_dir(&dir,FALSE))
2888 /* Get grid and contents */
2889 c_ptr = &cave[y][x];
2891 /* Require closed door */
2892 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2893 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2897 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2899 msg_print("You see nothing there to spike.");
2905 else if (!get_spike(&item))
2909 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2911 msg_print("You have no spikes!");
2916 /* Is a monster in the way? */
2917 else if (c_ptr->m_idx)
2924 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2926 msg_print("There is a monster in the way!");
2940 /* Successful jamming */
2942 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2944 msg_print("You jam the door with a spike.");
2948 /* Convert "locked" to "stuck" XXX XXX XXX */
2949 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2951 /* Add one spike to the door */
2952 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2954 /* Use up, and describe, a single spike, from the bottom */
2955 inven_item_increase(item, -1);
2956 inven_item_describe(item);
2957 inven_item_optimize(item);
2965 * Support code for the "Walk" and "Jump" commands
2967 void do_cmd_walk(int pickup)
2974 /* Allow repeated command */
2977 /* Set repeat count */
2978 command_rep = command_arg - 1;
2980 /* Redraw the state */
2981 p_ptr->redraw |= (PR_STATE);
2983 /* Cancel the arg */
2987 /* Get a "repeated" direction */
2988 if (get_rep_dir(&dir,FALSE))
2993 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2995 set_action(ACTION_NONE);
2998 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2999 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
3000 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
3002 /* Actually move the character */
3003 move_player(dir, pickup, FALSE);
3005 /* Allow more walking */
3009 /* Hack again -- Is there a special encounter ??? */
3010 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
3012 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && rand_int(120+p_ptr->lev*10 - wilderness[py][px].level+5) < (21-p_ptr->skill_stl))
3014 /* Inform the player of his horrible fate :=) */
3016 msg_print("½±·â¤À¡ª");
3018 msg_print("You are ambushed !");
3021 /* Go into large wilderness view */
3022 p_ptr->wilderness_x = px;
3023 p_ptr->wilderness_y = py;
3024 p_ptr->oldpy = randint(MAX_HGT-2);
3025 p_ptr->oldpx = randint(MAX_WID-2);
3029 /* HACk -- set the encouter flag for the wilderness generation */
3030 generate_encounter = TRUE;
3034 /* Cancel repeat unless we may continue */
3035 if (!more) disturb(0, 0);
3043 void do_cmd_run(void)
3047 /* Hack -- no running when confused */
3048 if (p_ptr->confused)
3051 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
3053 msg_print("You are too confused!");
3059 if (p_ptr->special_defense & KATA_MUSOU)
3061 set_action(ACTION_NONE);
3064 /* Get a "repeated" direction */
3065 if (get_rep_dir(&dir,FALSE))
3067 /* Hack -- Set the run counter */
3068 running = (command_arg ? command_arg : 1000);
3078 * Stay still. Search. Enter stores.
3079 * Pick up treasure if "pickup" is true.
3081 void do_cmd_stay(int pickup)
3083 cave_type *c_ptr = &cave[py][px];
3086 /* Allow repeated command */
3089 /* Set repeat count */
3090 command_rep = command_arg - 1;
3092 /* Redraw the state */
3093 p_ptr->redraw |= (PR_STATE);
3095 /* Cancel the arg */
3104 /* Spontaneous Searching */
3105 if ((p_ptr->skill_fos >= 50) || (0 == rand_int(50 - p_ptr->skill_fos)))
3110 /* Continuous Searching */
3111 if (p_ptr->action == ACTION_SEARCH)
3117 /* Handle "objects" */
3121 /* Hack -- enter a store if we are on one */
3122 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3123 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3124 (c_ptr->feat == FEAT_MUSEUM))
3130 /* Hack -- enter store */
3134 /* Hack -- enter a building if we are on one -KMW- */
3135 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3136 (c_ptr->feat <= FEAT_BLDG_TAIL))
3142 /* Hack -- enter building */
3146 /* Exit a quest if reach the quest exit */
3147 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3149 int q_index = p_ptr->inside_quest;
3151 /* Was quest completed? */
3152 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3154 quest[q_index].status = QUEST_STATUS_COMPLETED;
3155 quest[q_index].complev = p_ptr->lev;
3157 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3159 msg_print("You accomplished your quest!");
3165 leaving_quest = p_ptr->inside_quest;
3167 /* Leaving an 'only once' quest marks it as failed */
3168 if (leaving_quest &&
3169 ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
3170 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
3172 quest[leaving_quest].status = QUEST_STATUS_FAILED;
3173 quest[leaving_quest].complev = p_ptr->lev;
3174 if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
3176 r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
3177 if (record_rand_quest)
3178 do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
3180 else if (record_fix_quest)
3181 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
3184 p_ptr->inside_quest = cave[py][px].special;
3188 p_ptr->leaving = TRUE;
3195 * Resting allows a player to safely restore his hp -RAK-
3197 void do_cmd_rest(void)
3200 set_action(ACTION_NONE);
3202 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3207 /* Prompt for time if needed */
3208 if (command_arg <= 0)
3211 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3213 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3220 strcpy(out_val, "&");
3222 /* Ask for duration */
3223 if (!get_string(p, out_val, 4)) return;
3225 /* Rest until done */
3226 if (out_val[0] == '&')
3232 else if (out_val[0] == '*')
3240 command_arg = atoi(out_val);
3241 if (command_arg <= 0) return;
3247 if (command_arg > 9999) command_arg = 9999;
3249 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3251 /* Take a turn XXX XXX XXX (?) */
3254 /* The sin of sloth */
3255 if (command_arg > 100)
3256 chg_virtue(V_DILIGENCE, -1);
3258 /* Why are you sleeping when there's no need? WAKE UP!*/
3259 if ((p_ptr->chp == p_ptr->mhp) &&
3260 (p_ptr->csp == p_ptr->msp) &&
3261 !p_ptr->blind && !p_ptr->confused &&
3262 !p_ptr->poisoned && !p_ptr->afraid &&
3263 !p_ptr->stun && !p_ptr->cut &&
3264 !p_ptr->slow && !p_ptr->paralyzed &&
3265 !p_ptr->image && !p_ptr->word_recall)
3266 chg_virtue(V_DILIGENCE, -1);
3268 /* Save the rest code */
3269 resting = command_arg;
3270 p_ptr->action = ACTION_REST;
3272 /* Recalculate bonuses */
3273 p_ptr->update |= (PU_BONUS);
3275 /* Redraw the state */
3276 p_ptr->redraw |= (PR_STATE);
3287 * Determines the odds of an object breaking when thrown at a monster
3289 * Note that artifacts never break, see the "drop_near()" function.
3291 static int breakage_chance(object_type *o_ptr)
3293 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3295 /* Examine the item type */
3296 switch (o_ptr->tval)
3312 /* Sometimes break */
3317 return (20 - archer_bonus * 2);
3322 return (10 - archer_bonus);
3329 s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3333 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3337 /* Extract the flags */
3338 object_flags(o_ptr, &f1, &f2, &f3);
3340 /* Some "weapons" and "ammo" do extra damage */
3341 switch (o_ptr->tval)
3348 if ((f1 & TR1_SLAY_ANIMAL) &&
3349 (r_ptr->flags3 & RF3_ANIMAL))
3353 r_ptr->r_flags3 |= RF3_ANIMAL;
3356 if (mult < 17) mult = 17;
3360 if ((f1 & TR1_SLAY_EVIL) &&
3361 (r_ptr->flags3 & RF3_EVIL))
3365 r_ptr->r_flags3 |= RF3_EVIL;
3368 if (mult < 15) mult = 15;
3372 if ((f1 & TR1_SLAY_UNDEAD) &&
3373 (r_ptr->flags3 & RF3_UNDEAD))
3377 r_ptr->r_flags3 |= RF3_UNDEAD;
3380 if (mult < 20) mult = 20;
3384 if ((f1 & TR1_SLAY_DEMON) &&
3385 (r_ptr->flags3 & RF3_DEMON))
3389 r_ptr->r_flags3 |= RF3_DEMON;
3392 if (mult < 20) mult = 20;
3396 if ((f1 & TR1_SLAY_ORC) &&
3397 (r_ptr->flags3 & RF3_ORC))
3401 r_ptr->r_flags3 |= RF3_ORC;
3404 if (mult < 20) mult = 20;
3408 if ((f1 & TR1_SLAY_TROLL) &&
3409 (r_ptr->flags3 & RF3_TROLL))
3413 r_ptr->r_flags3 |= RF3_TROLL;
3416 if (mult < 20) mult = 20;
3420 if ((f1 & TR1_SLAY_GIANT) &&
3421 (r_ptr->flags3 & RF3_GIANT))
3425 r_ptr->r_flags3 |= RF3_GIANT;
3428 if (mult < 20) mult = 20;
3432 if ((f1 & TR1_SLAY_DRAGON) &&
3433 (r_ptr->flags3 & RF3_DRAGON))
3437 r_ptr->r_flags3 |= RF3_DRAGON;
3440 if (mult < 20) mult = 20;
3443 /* Execute Dragon */
3444 if ((f1 & TR1_KILL_DRAGON) &&
3445 (r_ptr->flags3 & RF3_DRAGON))
3449 r_ptr->r_flags3 |= RF3_DRAGON;
3452 if (mult < 30) mult = 30;
3454 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3455 (m_ptr->r_idx == MON_SMAUG) &&
3456 (inventory[INVEN_BOW].name1 == ART_BARD))
3461 if ((f1 & TR1_BRAND_ACID) || (p_ptr->special_attack & (ATTACK_ACID)))
3463 /* Notice immunity */
3464 if (r_ptr->flags3 & RF3_IM_ACID)
3468 r_ptr->r_flags3 |= RF3_IM_ACID;
3472 /* Otherwise, take the damage */
3475 if (mult < 17) mult = 17;
3480 if ((f1 & TR1_BRAND_ELEC) || (p_ptr->special_attack & (ATTACK_ELEC)))
3482 /* Notice immunity */
3483 if (r_ptr->flags3 & RF3_IM_ELEC)
3487 r_ptr->r_flags3 |= RF3_IM_ELEC;
3491 /* Otherwise, take the damage */
3494 if (mult < 17) mult = 17;
3499 if ((f1 & TR1_BRAND_FIRE) || (p_ptr->special_attack & (ATTACK_FIRE)))
3501 /* Notice immunity */
3502 if (r_ptr->flags3 & RF3_IM_FIRE)
3506 r_ptr->r_flags3 |= RF3_IM_FIRE;
3510 /* Otherwise, take the damage */
3513 if (mult < 17) mult = 17;
3518 if ((f1 & TR1_BRAND_COLD) || (p_ptr->special_attack & (ATTACK_COLD)))
3520 /* Notice immunity */
3521 if (r_ptr->flags3 & RF3_IM_COLD)
3525 r_ptr->r_flags3 |= RF3_IM_COLD;
3528 /* Otherwise, take the damage */
3531 if (mult < 17) mult = 17;
3535 /* Brand (Poison) */
3536 if ((f1 & TR1_BRAND_POIS) || (p_ptr->special_attack & (ATTACK_POIS)))
3538 /* Notice immunity */
3539 if (r_ptr->flags3 & RF3_IM_POIS)
3543 r_ptr->r_flags3 |= RF3_IM_POIS;
3547 /* Otherwise, take the damage */
3550 if (mult < 17) mult = 17;
3554 if ((f1 & TR1_FORCE_WEPON) && (p_ptr->csp > (p_ptr->msp / 30)))
3556 p_ptr->csp -= (1+(p_ptr->msp / 30));
3557 p_ptr->redraw |= (PR_MANA);
3558 mult = mult * 5 / 2;
3564 /* Return the total damage */
3565 return (tdam * mult / 10);
3570 * Fire an object from the pack or floor.
3572 * You may only fire items that "match" your missile launcher.
3574 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3576 * See "calc_bonuses()" for more calculations and such.
3578 * Note that "firing" a missile is MUCH better than "throwing" it.
3580 * Note: "unseen" monsters are very hard to hit.
3582 * Objects are more likely to break if they "attempt" to hit a monster.
3584 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3586 * The "extra shot" code works by decreasing the amount of energy
3587 * required to make each shot, spreading the shots out over time.
3589 * Note that when firing missiles, the launcher multiplier is applied
3590 * after all the bonuses are added in, making multipliers very useful.
3592 * Note that Bows of "Extra Might" get extra range and an extra bonus
3593 * for the damage multiplier.
3595 * Note that Bows of "Extra Shots" give an extra shot.
3597 void do_cmd_fire_aux(int item, object_type *j_ptr)
3600 int j, y, x, ny, nx, ty, tx;
3601 int tdam, tdis, thits, tmul;
3603 int cur_dis, visible;
3610 bool hit_body = FALSE;
3612 char o_name[MAX_NLEN];
3614 int msec = delay_factor * delay_factor * delay_factor;
3617 bool stick_to = FALSE;
3619 /* Access the item (if in the pack) */
3622 o_ptr = &inventory[item];
3626 o_ptr = &o_list[0 - item];
3629 /* Describe the object */
3630 object_desc(o_name, o_ptr, FALSE, 3);
3633 /* Use the proper number of shots */
3634 thits = p_ptr->num_fire;
3636 /* Use a base distance */
3639 /* Base damage from thrown object plus launcher bonus */
3640 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3642 /* Actually "fire" the object */
3643 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3644 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3646 /* Assume a base multiplier */
3649 /* Analyze the launcher */
3650 switch (j_ptr->sval)
3652 /* Sling and ammo */
3660 /* Short Bow and Arrow */
3668 /* Long Bow and Arrow */
3683 /* Light Crossbow and Bolt */
3691 /* Heavy Crossbow and Bolt */
3700 /* Get extra "power" from "extra might" */
3701 if (p_ptr->xtra_might) tmul++;
3703 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3705 /* Boost the damage */
3710 tdis = 10 + tmul/40;
3711 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3714 project_length = tdis + 1;
3716 /* Get a direction (or cancel) */
3717 if (!get_aim_dir(&dir))
3721 /* need not to reset project_length (already did)*/
3725 project_length = 0; /* reset to default */
3727 /* Get local object */
3730 /* Obtain a local object */
3731 object_copy(q_ptr, o_ptr);
3736 /* Reduce and describe inventory */
3739 inven_item_increase(item, -1);
3740 inven_item_describe(item);
3741 inven_item_optimize(item);
3744 /* Reduce and describe floor item */
3747 floor_item_increase(0 - item, -1);
3748 floor_item_optimize(0 - item);
3756 /* Take a (partial) turn */
3757 energy_use = (energy_use / thits);
3760 /* Start at the player */
3764 /* Predict the "target" location */
3765 tx = px + 99 * ddx[dir];
3766 ty = py + 99 * ddy[dir];
3768 /* Check for "target request" */
3769 if ((dir == 5) && target_okay())
3776 /* Hack -- Handle stuff */
3780 /* Travel until stopped */
3781 for (cur_dis = 0; cur_dis <= tdis; )
3783 /* Hack -- Stop at the target */
3784 if ((y == ty) && (x == tx)) break;
3786 /* Calculate the new location (see "project()") */
3789 mmove2(&ny, &nx, py, px, ty, tx);
3791 /* Stopped by walls/doors */
3792 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3794 /* Advance the distance */
3798 /* The player can see the (on screen) missile */
3799 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3801 char c = object_char(q_ptr);
3802 byte a = object_attr(q_ptr);
3804 /* Draw, Hilite, Fresh, Pause, Erase */
3805 print_rel(c, a, ny, nx);
3806 move_cursor_relative(ny, nx);
3808 Term_xtra(TERM_XTRA_DELAY, msec);
3813 /* The player cannot see the missile */
3816 /* Pause anyway, for consistancy */
3817 Term_xtra(TERM_XTRA_DELAY, msec);
3820 /* Save the new location */
3825 /* Monster here, Try to hit it */
3826 if (cave[y][x].m_idx)
3828 cave_type *c_ptr = &cave[y][x];
3830 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3831 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3833 /* Check the visibility */
3834 visible = m_ptr->ml;
3836 /* Note the collision */
3841 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3842 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3845 if ((r_ptr->level + 10) > p_ptr->lev)
3847 if (weapon_exp[0][j_ptr->sval] < weapon_exp_settei[p_ptr->pclass][0][j_ptr->sval][1])
3849 if (weapon_exp[0][j_ptr->sval] < 4000)
3850 weapon_exp[0][j_ptr->sval]+=80;
3851 else if ((weapon_exp[0][j_ptr->sval] < 6000))
3852 weapon_exp[0][j_ptr->sval]+=25;
3853 else if ((weapon_exp[0][j_ptr->sval] < 7000) && (p_ptr->lev > 19))
3854 weapon_exp[0][j_ptr->sval]+=10;
3855 else if ((weapon_exp[0][j_ptr->sval] < 8000) && (p_ptr->lev > 34))
3856 weapon_exp[0][j_ptr->sval]+=2;
3862 if (skill_exp[GINOU_RIDING] < skill_exp_settei[p_ptr->pclass][GINOU_RIDING][1] && ((skill_exp[GINOU_RIDING] - 1000) / 200 < r_info[m_list[p_ptr->riding].r_idx].level) && one_in_(2))
3864 skill_exp[GINOU_RIDING]+=1;
3865 p_ptr->update |= (PU_BONUS);
3869 /* Did we hit it (penalize range) */
3870 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3874 /* Assume a default death */
3876 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3878 cptr note_dies = " dies.";
3881 /* Some monsters get "destroyed" */
3882 if (!monster_living(r_ptr))
3885 bool explode = FALSE;
3887 for (i = 0; i < 4; i++)
3889 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3892 /* Special note at death */
3895 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3897 note_dies = " explodes into tiny shreds.";
3901 note_dies = "¤òÅݤ·¤¿¡£";
3903 note_dies = " is destroyed.";
3908 /* Handle unseen monster */
3911 /* Invisible monster */
3913 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3915 msg_format("The %s finds a mark.", o_name);
3920 /* Handle visible monster */
3925 /* Get "the monster" or "it" */
3926 monster_desc(m_name, m_ptr, 0);
3930 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3932 msg_format("The %s hits %s.", o_name, m_name);
3936 /* Hack -- Track this monster race */
3937 if (m_ptr->ml) monster_race_track((m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
3939 /* Hack -- Track this monster */
3940 if (m_ptr->ml) health_track(c_ptr->m_idx);
3943 /* Apply special damage XXX XXX XXX */
3944 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3945 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3947 /* No negative damage */
3948 if (tdam < 0) tdam = 0;
3950 /* Modify the damage */
3951 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3953 /* Complex message */
3954 if (wizard || cheat_xtra)
3957 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3960 msg_format("You do %d (out of %d) damage.",
3966 /* Hit the monster, check for death */
3967 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3980 monster_desc(m_name, m_ptr, 0);
3984 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3986 msg_format("%^s have stuck into %s!",o_name, m_name);
3991 message_pain(c_ptr->m_idx, tdam);
3993 /* Anger the monster */
3994 if (tdam > 0) anger_monster(m_ptr);
3997 if (fear && m_ptr->ml)
4004 /* Get the monster name (or "it") */
4005 monster_desc(m_name, m_ptr, 0);
4009 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4011 msg_format("%^s flees in terror!", m_name);
4015 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
4017 m_ptr->target_y = py;
4018 m_ptr->target_x = px;
4028 /* Chance of breakage (during attacks) */
4029 j = (hit_body ? breakage_chance(q_ptr) : 0);
4033 int m_idx = cave[y][x].m_idx;
4034 monster_type *m_ptr = &m_list[m_idx];
4035 int o_idx = o_pop();
4039 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
4042 a_info[j_ptr->name1].cur_num = 0;
4047 o_ptr = &o_list[ o_idx ];
4048 object_copy(o_ptr, q_ptr);
4051 o_ptr->marked = FALSE;
4053 /* Forget location */
4054 o_ptr->iy = o_ptr->ix = 0;
4056 /* Memorize monster */
4057 o_ptr->held_m_idx = m_idx;
4060 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4063 m_ptr->hold_o_idx = o_idx;
4067 /* Drop (or break) near that location */
4068 (void)drop_near(q_ptr, j, y, x);
4072 void do_cmd_fire(void)
4078 /* Get the "bow" (if any) */
4079 j_ptr = &inventory[INVEN_BOW];
4081 /* Require a launcher */
4085 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4087 msg_print("You have nothing to fire with.");
4093 if (j_ptr->sval == SV_CRIMSON)
4096 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4098 msg_print("Do activate.");
4105 if (p_ptr->special_defense & KATA_MUSOU)
4107 set_action(ACTION_NONE);
4110 /* Require proper missile */
4111 item_tester_tval = p_ptr->tval_ammo;
4115 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4116 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4118 q = "Fire which item? ";
4119 s = "You have nothing to fire.";
4122 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4129 do_cmd_fire_aux(item, j_ptr);
4133 static bool item_tester_hook_boomerang(object_type *o_ptr)
4135 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4143 * Throw an object from the pack or floor.
4145 * Note: "unseen" monsters are very hard to hit.
4147 * Should throwing a weapon do full damage? Should it allow the magic
4148 * to hit bonus of the weapon to have an effect? Should it ever cause
4149 * the item to be destroyed? Should it do any damage at all?
4151 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4154 int i, j, y, x, ty, tx;
4156 int chance, tdam, tdis;
4158 int cur_dis, visible;
4165 bool hit_body = FALSE;
4166 bool hit_wall = FALSE;
4167 bool equiped_item = FALSE;
4168 bool return_when_thrown = FALSE;
4170 char o_name[MAX_NLEN];
4172 int msec = delay_factor * delay_factor * delay_factor;
4176 bool come_back = FALSE;
4177 bool do_drop = TRUE;
4180 if (p_ptr->special_defense & KATA_MUSOU)
4182 set_action(ACTION_NONE);
4191 if (buki_motteruka(INVEN_LARM))
4193 item_tester_hook = item_tester_hook_boomerang;
4195 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4196 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4198 q = "Throw which item? ";
4199 s = "You have nothing to throw.";
4202 if (!get_item(&item, q, s, (USE_EQUIP)))
4217 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4218 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4220 q = "Throw which item? ";
4221 s = "You have nothing to throw.";
4224 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4231 /* Access the item (if in the pack) */
4234 o_ptr = &inventory[item];
4238 o_ptr = &o_list[0 - item];
4242 /* Item is cursed */
4243 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4247 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4249 msg_print("Hmmm, it seems to be cursed.");
4258 /* Get local object */
4261 /* Obtain a local object */
4262 object_copy(q_ptr, o_ptr);
4264 /* Extract the thrown object's flags. */
4265 object_flags(q_ptr, &f1, &f2, &f3);
4267 /* Distribute the charges of rods/wands between the stacks */
4268 distribute_charges(o_ptr, q_ptr, 1);
4274 object_desc(o_name, q_ptr, FALSE, 3);
4276 if (p_ptr->mighty_throw) mult += 3;
4278 /* Extract a "distance multiplier" */
4279 /* Changed for 'launcher' mutation */
4280 mul = 10 + 2 * (mult - 1);
4282 /* Enforce a minimum "weight" of one pound */
4283 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4284 if ((f2 & (TR2_THROW)) || boomerang) div /= 2;
4286 /* Hack -- Distance -- Reward strength, penalize weight */
4287 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4289 /* Max distance of 10-18 */
4290 if (tdis > mul) tdis = mul;
4294 ty = rand_int(101)-50+py;
4295 tx = rand_int(101)-50+px;
4299 project_length = tdis + 1;
4301 /* Get a direction (or cancel) */
4302 if (!get_aim_dir(&dir)) return FALSE;
4304 project_length = 0; /* reset to default */
4306 /* Predict the "target" location */
4307 tx = px + 99 * ddx[dir];
4308 ty = py + 99 * ddy[dir];
4310 /* Check for "target request" */
4311 if ((dir == 5) && target_okay())
4318 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4319 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4320 return_when_thrown = TRUE;
4322 /* Reduce and describe inventory */
4325 inven_item_increase(item, -1);
4326 if (!return_when_thrown)
4327 inven_item_describe(item);
4328 inven_item_optimize(item);
4331 /* Reduce and describe floor item */
4334 floor_item_increase(0 - item, -1);
4335 floor_item_optimize(0 - item);
4337 if (item >= INVEN_RARM)
4339 equiped_item = TRUE;
4340 p_ptr->redraw |= (PR_EQUIPPY);
4344 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4345 energy_use = 100-p_ptr->lev;
4349 /* Start at the player */
4354 /* Hack -- Handle stuff */
4357 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((f2 & TR2_THROW) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4358 else shuriken = FALSE;
4360 /* Chance of hitting */
4361 if (f2 & (TR2_THROW)) chance = ((p_ptr->skill_tht) +
4362 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4363 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4365 if (shuriken) chance *= 2;
4367 /* Travel until stopped */
4368 for (cur_dis = 0; cur_dis <= tdis; )
4370 /* Hack -- Stop at the target */
4371 if ((y == ty) && (x == tx)) break;
4373 /* Calculate the new location (see "project()") */
4376 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4378 /* Stopped by walls/doors */
4379 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4385 /* Advance the distance */
4388 /* The player can see the (on screen) missile */
4389 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4391 char c = object_char(q_ptr);
4392 byte a = object_attr(q_ptr);
4394 /* Draw, Hilite, Fresh, Pause, Erase */
4395 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4396 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4398 Term_xtra(TERM_XTRA_DELAY, msec);
4399 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4403 /* The player cannot see the missile */
4406 /* Pause anyway, for consistancy */
4407 Term_xtra(TERM_XTRA_DELAY, msec);
4410 /* Save the new location */
4415 /* Monster here, Try to hit it */
4416 if (cave[y][x].m_idx)
4418 cave_type *c_ptr = &cave[y][x];
4420 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4421 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4423 /* Check the visibility */
4424 visible = m_ptr->ml;
4426 /* Note the collision */
4429 /* Did we hit it (penalize range) */
4430 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4434 /* Assume a default death */
4436 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4438 cptr note_dies = " dies.";
4442 /* Some monsters get "destroyed" */
4443 if (!monster_living(r_ptr))
4446 bool explode = FALSE;
4448 for (i = 0; i < 4; i++)
4450 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4453 /* Special note at death */
4456 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4458 note_dies = " explodes into tiny shreds.";
4462 note_dies = "¤òÅݤ·¤¿¡£";
4464 note_dies = " is destroyed.";
4470 /* Handle unseen monster */
4473 /* Invisible monster */
4475 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4477 msg_format("The %s finds a mark.", o_name);
4482 /* Handle visible monster */
4487 /* Get "the monster" or "it" */
4488 monster_desc(m_name, m_ptr, 0);
4492 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4494 msg_format("The %s hits %s.", o_name, m_name);
4498 /* Hack -- Track this monster race */
4499 if (m_ptr->ml) monster_race_track((m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
4501 /* Hack -- Track this monster */
4502 if (m_ptr->ml) health_track(c_ptr->m_idx);
4505 /* Hack -- Base damage from thrown object */
4506 tdam = damroll(q_ptr->dd, q_ptr->ds);
4507 /* Apply special damage XXX XXX XXX */
4508 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4509 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4510 tdam += q_ptr->to_d;
4514 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4515 tdam += p_ptr->to_d_m;
4517 else if (f2 & (TR2_THROW))
4520 tdam += p_ptr->to_d_m;
4528 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4531 /* No negative damage */
4532 if (tdam < 0) tdam = 0;
4534 /* Modify the damage */
4535 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4537 /* Complex message */
4541 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4544 msg_format("You do %d (out of %d) damage.",
4550 /* Hit the monster, check for death */
4551 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4560 message_pain(c_ptr->m_idx, tdam);
4562 /* Anger the monster */
4563 if ((tdam > 0) && !object_is_potion(q_ptr))
4564 anger_monster(m_ptr);
4567 if (fear && m_ptr->ml)
4574 /* Get the monster name (or "it") */
4575 monster_desc(m_name, m_ptr, 0);
4579 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4581 msg_format("%^s flees in terror!", m_name);
4593 /* Chance of breakage (during attacks) */
4594 j = (hit_body ? breakage_chance(q_ptr) : 0);
4596 /* Figurines transform */
4597 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4601 if (!(summon_named_creature(y, x, q_ptr->pval, FALSE, FALSE, FALSE,
4602 (bool)!(q_ptr->ident & IDENT_CURSED))))
4604 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4606 msg_print("The Figurine writhes and then shatters.");
4609 else if (q_ptr->ident & IDENT_CURSED)
4611 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4613 msg_print("You have a bad feeling about this.");
4619 /* Potions smash open */
4620 if (object_is_potion(q_ptr))
4622 if (hit_body || hit_wall || (randint(100) < j))
4626 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4628 msg_format("The %s shatters!", o_name);
4632 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4634 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4636 /* ToDo (Robert): fix the invulnerability */
4637 if (cave[y][x].m_idx &&
4638 is_friendly(&m_list[cave[y][x].m_idx]) &&
4642 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4644 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4646 msg_format("%^s gets angry!", m_name);
4649 set_hostile(&m_list[cave[y][x].m_idx]);
4660 if (return_when_thrown)
4662 int back_chance = randint(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4663 char o2_name[MAX_NLEN];
4664 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4667 if (boomerang) back_chance += 4+randint(5);
4668 if (super_boomerang) back_chance += 100;
4669 object_desc(o2_name, q_ptr, FALSE, 0);
4671 if((back_chance > 30) && ((randint(100) != 1) || super_boomerang))
4673 for (i = cur_dis-1;i>0;i--)
4675 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4677 char c = object_char(q_ptr);
4678 byte a = object_attr(q_ptr);
4680 /* Draw, Hilite, Fresh, Pause, Erase */
4681 print_rel(c, a, ny[i], nx[i]);
4682 move_cursor_relative(ny[i], nx[i]);
4684 Term_xtra(TERM_XTRA_DELAY, msec);
4685 lite_spot(ny[i], nx[i]);
4690 /* Pause anyway, for consistancy */
4691 Term_xtra(TERM_XTRA_DELAY, msec);
4694 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4697 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4699 msg_format("%s comes back to you.", o2_name);
4708 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4710 msg_format("%s backs, but you can't catch!", o2_name);
4716 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4718 msg_format("%s comes back.", o2_name);
4728 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4730 msg_format("%s doesn't back!", o2_name);
4737 if (item == INVEN_RARM || item == INVEN_LARM)
4739 /* Access the wield slot */
4740 o_ptr = &inventory[item];
4742 /* Wear the new stuff */
4743 object_copy(o_ptr, q_ptr);
4745 /* Increase the weight */
4746 p_ptr->total_weight += q_ptr->weight;
4748 /* Increment the equip counter by hand */
4751 /* Recalculate bonuses */
4752 p_ptr->update |= (PU_BONUS);
4754 /* Recalculate torch */
4755 p_ptr->update |= (PU_TORCH);
4757 /* Recalculate mana XXX */
4758 p_ptr->update |= (PU_MANA);
4761 p_ptr->window |= (PW_EQUIP);
4769 else if (equiped_item)
4775 /* Drop (or break) near that location */
4776 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4783 * Throw an object from the pack or floor.
4785 void do_cmd_throw(void)
4787 do_cmd_throw_aux(1, FALSE, 0);