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 = (byte)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 = (byte)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 = (byte)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 = (byte)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 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
3015 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && rand_int(tmp) < (21-p_ptr->skill_stl))
3017 /* Inform the player of his horrible fate :=) */
3019 msg_print("½±·â¤À¡ª");
3021 msg_print("You are ambushed !");
3024 /* Go into large wilderness view */
3025 p_ptr->wilderness_x = px;
3026 p_ptr->wilderness_y = py;
3027 p_ptr->oldpy = randint(MAX_HGT-2);
3028 p_ptr->oldpx = randint(MAX_WID-2);
3032 /* HACk -- set the encouter flag for the wilderness generation */
3033 generate_encounter = TRUE;
3037 /* Cancel repeat unless we may continue */
3038 if (!more) disturb(0, 0);
3046 void do_cmd_run(void)
3050 /* Hack -- no running when confused */
3051 if (p_ptr->confused)
3054 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
3056 msg_print("You are too confused!");
3062 if (p_ptr->special_defense & KATA_MUSOU)
3064 set_action(ACTION_NONE);
3067 /* Get a "repeated" direction */
3068 if (get_rep_dir(&dir,FALSE))
3070 /* Hack -- Set the run counter */
3071 running = (command_arg ? command_arg : 1000);
3081 * Stay still. Search. Enter stores.
3082 * Pick up treasure if "pickup" is true.
3084 void do_cmd_stay(int pickup)
3086 cave_type *c_ptr = &cave[py][px];
3089 /* Allow repeated command */
3092 /* Set repeat count */
3093 command_rep = command_arg - 1;
3095 /* Redraw the state */
3096 p_ptr->redraw |= (PR_STATE);
3098 /* Cancel the arg */
3107 /* Spontaneous Searching */
3108 if ((p_ptr->skill_fos >= 50) || (0 == rand_int(50 - p_ptr->skill_fos)))
3113 /* Continuous Searching */
3114 if (p_ptr->action == ACTION_SEARCH)
3120 /* Handle "objects" */
3124 /* Hack -- enter a store if we are on one */
3125 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3126 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3127 (c_ptr->feat == FEAT_MUSEUM))
3133 /* Hack -- enter store */
3137 /* Hack -- enter a building if we are on one -KMW- */
3138 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3139 (c_ptr->feat <= FEAT_BLDG_TAIL))
3145 /* Hack -- enter building */
3149 /* Exit a quest if reach the quest exit */
3150 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3152 int q_index = p_ptr->inside_quest;
3154 /* Was quest completed? */
3155 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3157 quest[q_index].status = QUEST_STATUS_COMPLETED;
3158 quest[q_index].complev = (byte)p_ptr->lev;
3160 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3162 msg_print("You accomplished your quest!");
3168 leaving_quest = p_ptr->inside_quest;
3170 /* Leaving an 'only once' quest marks it as failed */
3171 if (leaving_quest &&
3172 ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
3173 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
3175 quest[leaving_quest].status = QUEST_STATUS_FAILED;
3176 quest[leaving_quest].complev = (byte)p_ptr->lev;
3177 if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
3179 r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
3180 if (record_rand_quest)
3181 do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
3183 else if (record_fix_quest)
3184 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
3187 p_ptr->inside_quest = cave[py][px].special;
3191 p_ptr->leaving = TRUE;
3198 * Resting allows a player to safely restore his hp -RAK-
3200 void do_cmd_rest(void)
3203 set_action(ACTION_NONE);
3205 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3210 /* Prompt for time if needed */
3211 if (command_arg <= 0)
3214 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3216 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3223 strcpy(out_val, "&");
3225 /* Ask for duration */
3226 if (!get_string(p, out_val, 4)) return;
3228 /* Rest until done */
3229 if (out_val[0] == '&')
3235 else if (out_val[0] == '*')
3243 command_arg = atoi(out_val);
3244 if (command_arg <= 0) return;
3250 if (command_arg > 9999) command_arg = 9999;
3252 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3254 /* Take a turn XXX XXX XXX (?) */
3257 /* The sin of sloth */
3258 if (command_arg > 100)
3259 chg_virtue(V_DILIGENCE, -1);
3261 /* Why are you sleeping when there's no need? WAKE UP!*/
3262 if ((p_ptr->chp == p_ptr->mhp) &&
3263 (p_ptr->csp == p_ptr->msp) &&
3264 !p_ptr->blind && !p_ptr->confused &&
3265 !p_ptr->poisoned && !p_ptr->afraid &&
3266 !p_ptr->stun && !p_ptr->cut &&
3267 !p_ptr->slow && !p_ptr->paralyzed &&
3268 !p_ptr->image && !p_ptr->word_recall)
3269 chg_virtue(V_DILIGENCE, -1);
3271 /* Save the rest code */
3272 resting = command_arg;
3273 p_ptr->action = ACTION_REST;
3275 /* Recalculate bonuses */
3276 p_ptr->update |= (PU_BONUS);
3278 /* Redraw the state */
3279 p_ptr->redraw |= (PR_STATE);
3290 * Determines the odds of an object breaking when thrown at a monster
3292 * Note that artifacts never break, see the "drop_near()" function.
3294 static int breakage_chance(object_type *o_ptr)
3296 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3298 /* Examine the item type */
3299 switch (o_ptr->tval)
3315 /* Sometimes break */
3320 return (20 - archer_bonus * 2);
3325 return (10 - archer_bonus);
3332 s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3336 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3340 /* Extract the flags */
3341 object_flags(o_ptr, &f1, &f2, &f3);
3343 /* Some "weapons" and "ammo" do extra damage */
3344 switch (o_ptr->tval)
3351 if ((f1 & TR1_SLAY_ANIMAL) &&
3352 (r_ptr->flags3 & RF3_ANIMAL))
3356 r_ptr->r_flags3 |= RF3_ANIMAL;
3359 if (mult < 17) mult = 17;
3363 if ((f1 & TR1_SLAY_EVIL) &&
3364 (r_ptr->flags3 & RF3_EVIL))
3368 r_ptr->r_flags3 |= RF3_EVIL;
3371 if (mult < 15) mult = 15;
3375 if ((f1 & TR1_SLAY_UNDEAD) &&
3376 (r_ptr->flags3 & RF3_UNDEAD))
3380 r_ptr->r_flags3 |= RF3_UNDEAD;
3383 if (mult < 20) mult = 20;
3387 if ((f1 & TR1_SLAY_DEMON) &&
3388 (r_ptr->flags3 & RF3_DEMON))
3392 r_ptr->r_flags3 |= RF3_DEMON;
3395 if (mult < 20) mult = 20;
3399 if ((f1 & TR1_SLAY_ORC) &&
3400 (r_ptr->flags3 & RF3_ORC))
3404 r_ptr->r_flags3 |= RF3_ORC;
3407 if (mult < 20) mult = 20;
3411 if ((f1 & TR1_SLAY_TROLL) &&
3412 (r_ptr->flags3 & RF3_TROLL))
3416 r_ptr->r_flags3 |= RF3_TROLL;
3419 if (mult < 20) mult = 20;
3423 if ((f1 & TR1_SLAY_GIANT) &&
3424 (r_ptr->flags3 & RF3_GIANT))
3428 r_ptr->r_flags3 |= RF3_GIANT;
3431 if (mult < 20) mult = 20;
3435 if ((f1 & TR1_SLAY_DRAGON) &&
3436 (r_ptr->flags3 & RF3_DRAGON))
3440 r_ptr->r_flags3 |= RF3_DRAGON;
3443 if (mult < 20) mult = 20;
3446 /* Execute Dragon */
3447 if ((f1 & TR1_KILL_DRAGON) &&
3448 (r_ptr->flags3 & RF3_DRAGON))
3452 r_ptr->r_flags3 |= RF3_DRAGON;
3455 if (mult < 30) mult = 30;
3457 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3458 (m_ptr->r_idx == MON_SMAUG) &&
3459 (inventory[INVEN_BOW].name1 == ART_BARD))
3464 if ((f1 & TR1_BRAND_ACID) || (p_ptr->special_attack & (ATTACK_ACID)))
3466 /* Notice immunity */
3467 if (r_ptr->flags3 & RF3_IM_ACID)
3471 r_ptr->r_flags3 |= RF3_IM_ACID;
3475 /* Otherwise, take the damage */
3478 if (mult < 17) mult = 17;
3483 if ((f1 & TR1_BRAND_ELEC) || (p_ptr->special_attack & (ATTACK_ELEC)))
3485 /* Notice immunity */
3486 if (r_ptr->flags3 & RF3_IM_ELEC)
3490 r_ptr->r_flags3 |= RF3_IM_ELEC;
3494 /* Otherwise, take the damage */
3497 if (mult < 17) mult = 17;
3502 if ((f1 & TR1_BRAND_FIRE) || (p_ptr->special_attack & (ATTACK_FIRE)))
3504 /* Notice immunity */
3505 if (r_ptr->flags3 & RF3_IM_FIRE)
3509 r_ptr->r_flags3 |= RF3_IM_FIRE;
3513 /* Otherwise, take the damage */
3516 if (mult < 17) mult = 17;
3521 if ((f1 & TR1_BRAND_COLD) || (p_ptr->special_attack & (ATTACK_COLD)))
3523 /* Notice immunity */
3524 if (r_ptr->flags3 & RF3_IM_COLD)
3528 r_ptr->r_flags3 |= RF3_IM_COLD;
3531 /* Otherwise, take the damage */
3534 if (mult < 17) mult = 17;
3538 /* Brand (Poison) */
3539 if ((f1 & TR1_BRAND_POIS) || (p_ptr->special_attack & (ATTACK_POIS)))
3541 /* Notice immunity */
3542 if (r_ptr->flags3 & RF3_IM_POIS)
3546 r_ptr->r_flags3 |= RF3_IM_POIS;
3550 /* Otherwise, take the damage */
3553 if (mult < 17) mult = 17;
3557 if ((f1 & TR1_FORCE_WEPON) && (p_ptr->csp > (p_ptr->msp / 30)))
3559 p_ptr->csp -= (1+(p_ptr->msp / 30));
3560 p_ptr->redraw |= (PR_MANA);
3561 mult = mult * 5 / 2;
3567 /* Return the total damage */
3568 return (tdam * mult / 10);
3573 * Fire an object from the pack or floor.
3575 * You may only fire items that "match" your missile launcher.
3577 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3579 * See "calc_bonuses()" for more calculations and such.
3581 * Note that "firing" a missile is MUCH better than "throwing" it.
3583 * Note: "unseen" monsters are very hard to hit.
3585 * Objects are more likely to break if they "attempt" to hit a monster.
3587 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3589 * The "extra shot" code works by decreasing the amount of energy
3590 * required to make each shot, spreading the shots out over time.
3592 * Note that when firing missiles, the launcher multiplier is applied
3593 * after all the bonuses are added in, making multipliers very useful.
3595 * Note that Bows of "Extra Might" get extra range and an extra bonus
3596 * for the damage multiplier.
3598 * Note that Bows of "Extra Shots" give an extra shot.
3600 void do_cmd_fire_aux(int item, object_type *j_ptr)
3603 int j, y, x, ny, nx, ty, tx;
3604 int tdam, tdis, thits, tmul;
3606 int cur_dis, visible;
3613 bool hit_body = FALSE;
3615 char o_name[MAX_NLEN];
3617 int msec = delay_factor * delay_factor * delay_factor;
3620 bool stick_to = FALSE;
3622 /* Access the item (if in the pack) */
3625 o_ptr = &inventory[item];
3629 o_ptr = &o_list[0 - item];
3632 /* Describe the object */
3633 object_desc(o_name, o_ptr, FALSE, 3);
3636 /* Use the proper number of shots */
3637 thits = p_ptr->num_fire;
3639 /* Use a base distance */
3642 /* Base damage from thrown object plus launcher bonus */
3643 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3645 /* Actually "fire" the object */
3646 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3647 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3649 energy_use = bow_energy(j_ptr->sval);
3650 tmul = bow_tmul(j_ptr->sval);
3652 /* Get extra "power" from "extra might" */
3653 if (p_ptr->xtra_might) tmul++;
3655 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3657 /* Boost the damage */
3662 tdis = 10 + tmul/40;
3663 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3666 project_length = tdis + 1;
3668 /* Get a direction (or cancel) */
3669 if (!get_aim_dir(&dir))
3673 /* need not to reset project_length (already did)*/
3677 project_length = 0; /* reset to default */
3679 /* Get local object */
3682 /* Obtain a local object */
3683 object_copy(q_ptr, o_ptr);
3688 /* Reduce and describe inventory */
3691 inven_item_increase(item, -1);
3692 inven_item_describe(item);
3693 inven_item_optimize(item);
3696 /* Reduce and describe floor item */
3699 floor_item_increase(0 - item, -1);
3700 floor_item_optimize(0 - item);
3708 /* Take a (partial) turn */
3709 energy_use = (energy_use / thits);
3712 /* Start at the player */
3716 /* Predict the "target" location */
3717 tx = px + 99 * ddx[dir];
3718 ty = py + 99 * ddy[dir];
3720 /* Check for "target request" */
3721 if ((dir == 5) && target_okay())
3728 /* Hack -- Handle stuff */
3732 /* Travel until stopped */
3733 for (cur_dis = 0; cur_dis <= tdis; )
3735 /* Hack -- Stop at the target */
3736 if ((y == ty) && (x == tx)) break;
3738 /* Calculate the new location (see "project()") */
3741 mmove2(&ny, &nx, py, px, ty, tx);
3743 /* Stopped by walls/doors */
3744 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3746 /* Advance the distance */
3750 /* The player can see the (on screen) missile */
3751 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3753 char c = object_char(q_ptr);
3754 byte a = object_attr(q_ptr);
3756 /* Draw, Hilite, Fresh, Pause, Erase */
3757 print_rel(c, a, ny, nx);
3758 move_cursor_relative(ny, nx);
3760 Term_xtra(TERM_XTRA_DELAY, msec);
3765 /* The player cannot see the missile */
3768 /* Pause anyway, for consistancy */
3769 Term_xtra(TERM_XTRA_DELAY, msec);
3772 /* Save the new location */
3777 /* Monster here, Try to hit it */
3778 if (cave[y][x].m_idx)
3780 cave_type *c_ptr = &cave[y][x];
3782 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3783 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3785 /* Check the visibility */
3786 visible = m_ptr->ml;
3788 /* Note the collision */
3793 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3794 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3797 if ((r_ptr->level + 10) > p_ptr->lev)
3799 if (weapon_exp[0][j_ptr->sval] < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3801 if (weapon_exp[0][j_ptr->sval] < 4000)
3802 weapon_exp[0][j_ptr->sval]+=80;
3803 else if ((weapon_exp[0][j_ptr->sval] < 6000))
3804 weapon_exp[0][j_ptr->sval]+=25;
3805 else if ((weapon_exp[0][j_ptr->sval] < 7000) && (p_ptr->lev > 19))
3806 weapon_exp[0][j_ptr->sval]+=10;
3807 else if ((weapon_exp[0][j_ptr->sval] < 8000) && (p_ptr->lev > 34))
3808 weapon_exp[0][j_ptr->sval]+=2;
3814 if (skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING] && ((skill_exp[GINOU_RIDING] - 1000) / 200 < r_info[m_list[p_ptr->riding].r_idx].level) && one_in_(2))
3816 skill_exp[GINOU_RIDING]+=1;
3817 p_ptr->update |= (PU_BONUS);
3821 /* Did we hit it (penalize range) */
3822 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3826 /* Assume a default death */
3828 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3830 cptr note_dies = " dies.";
3833 /* Some monsters get "destroyed" */
3834 if (!monster_living(r_ptr))
3837 bool explode = FALSE;
3839 for (i = 0; i < 4; i++)
3841 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3844 /* Special note at death */
3847 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3849 note_dies = " explodes into tiny shreds.";
3853 note_dies = "¤òÅݤ·¤¿¡£";
3855 note_dies = " is destroyed.";
3860 /* Handle unseen monster */
3863 /* Invisible monster */
3865 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3867 msg_format("The %s finds a mark.", o_name);
3872 /* Handle visible monster */
3877 /* Get "the monster" or "it" */
3878 monster_desc(m_name, m_ptr, 0);
3882 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3884 msg_format("The %s hits %s.", o_name, m_name);
3888 /* Hack -- Track this monster race */
3889 if (m_ptr->ml) monster_race_track((bool)(m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
3891 /* Hack -- Track this monster */
3892 if (m_ptr->ml) health_track(c_ptr->m_idx);
3895 /* Apply special damage XXX XXX XXX */
3896 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3897 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3899 /* No negative damage */
3900 if (tdam < 0) tdam = 0;
3902 /* Modify the damage */
3903 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3905 /* Complex message */
3906 if (wizard || cheat_xtra)
3909 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3912 msg_format("You do %d (out of %d) damage.",
3918 /* Hit the monster, check for death */
3919 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3932 monster_desc(m_name, m_ptr, 0);
3936 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3938 msg_format("%^s have stuck into %s!",o_name, m_name);
3943 message_pain(c_ptr->m_idx, tdam);
3945 /* Anger the monster */
3946 if (tdam > 0) anger_monster(m_ptr);
3949 if (fear && m_ptr->ml)
3956 /* Get the monster name (or "it") */
3957 monster_desc(m_name, m_ptr, 0);
3961 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3963 msg_format("%^s flees in terror!", m_name);
3967 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3969 m_ptr->target_y = py;
3970 m_ptr->target_x = px;
3980 /* Chance of breakage (during attacks) */
3981 j = (hit_body ? breakage_chance(q_ptr) : 0);
3985 int m_idx = cave[y][x].m_idx;
3986 monster_type *m_ptr = &m_list[m_idx];
3987 int o_idx = o_pop();
3992 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3994 msg_format("The %s have gone to somewhere.", o_name);
3998 a_info[j_ptr->name1].cur_num = 0;
4003 o_ptr = &o_list[ o_idx ];
4004 object_copy(o_ptr, q_ptr);
4007 o_ptr->marked = FALSE;
4009 /* Forget location */
4010 o_ptr->iy = o_ptr->ix = 0;
4012 /* Memorize monster */
4013 o_ptr->held_m_idx = m_idx;
4016 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4019 m_ptr->hold_o_idx = o_idx;
4023 /* Drop (or break) near that location */
4024 (void)drop_near(q_ptr, j, y, x);
4028 void do_cmd_fire(void)
4034 /* Get the "bow" (if any) */
4035 j_ptr = &inventory[INVEN_BOW];
4037 /* Require a launcher */
4041 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4043 msg_print("You have nothing to fire with.");
4049 if (j_ptr->sval == SV_CRIMSON)
4052 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4054 msg_print("Do activate.");
4061 if (p_ptr->special_defense & KATA_MUSOU)
4063 set_action(ACTION_NONE);
4066 /* Require proper missile */
4067 item_tester_tval = p_ptr->tval_ammo;
4071 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4072 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4074 q = "Fire which item? ";
4075 s = "You have nothing to fire.";
4078 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4085 do_cmd_fire_aux(item, j_ptr);
4089 static bool item_tester_hook_boomerang(object_type *o_ptr)
4091 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4099 * Throw an object from the pack or floor.
4101 * Note: "unseen" monsters are very hard to hit.
4103 * Should throwing a weapon do full damage? Should it allow the magic
4104 * to hit bonus of the weapon to have an effect? Should it ever cause
4105 * the item to be destroyed? Should it do any damage at all?
4107 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4110 int i, j, y, x, ty, tx;
4112 int chance, tdam, tdis;
4114 int cur_dis, visible;
4121 bool hit_body = FALSE;
4122 bool hit_wall = FALSE;
4123 bool equiped_item = FALSE;
4124 bool return_when_thrown = FALSE;
4126 char o_name[MAX_NLEN];
4128 int msec = delay_factor * delay_factor * delay_factor;
4132 bool come_back = FALSE;
4133 bool do_drop = TRUE;
4136 if (p_ptr->special_defense & KATA_MUSOU)
4138 set_action(ACTION_NONE);
4147 if (buki_motteruka(INVEN_LARM))
4149 item_tester_hook = item_tester_hook_boomerang;
4151 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4152 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4154 q = "Throw which item? ";
4155 s = "You have nothing to throw.";
4158 if (!get_item(&item, q, s, (USE_EQUIP)))
4173 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4174 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4176 q = "Throw which item? ";
4177 s = "You have nothing to throw.";
4180 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4187 /* Access the item (if in the pack) */
4190 o_ptr = &inventory[item];
4194 o_ptr = &o_list[0 - item];
4198 /* Item is cursed */
4199 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4203 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4205 msg_print("Hmmm, it seems to be cursed.");
4214 /* Get local object */
4217 /* Obtain a local object */
4218 object_copy(q_ptr, o_ptr);
4220 /* Extract the thrown object's flags. */
4221 object_flags(q_ptr, &f1, &f2, &f3);
4223 /* Distribute the charges of rods/wands between the stacks */
4224 distribute_charges(o_ptr, q_ptr, 1);
4230 object_desc(o_name, q_ptr, FALSE, 3);
4232 if (p_ptr->mighty_throw) mult += 3;
4234 /* Extract a "distance multiplier" */
4235 /* Changed for 'launcher' mutation */
4236 mul = 10 + 2 * (mult - 1);
4238 /* Enforce a minimum "weight" of one pound */
4239 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4240 if ((f2 & (TR2_THROW)) || boomerang) div /= 2;
4242 /* Hack -- Distance -- Reward strength, penalize weight */
4243 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4245 /* Max distance of 10-18 */
4246 if (tdis > mul) tdis = mul;
4250 ty = rand_int(101)-50+py;
4251 tx = rand_int(101)-50+px;
4255 project_length = tdis + 1;
4257 /* Get a direction (or cancel) */
4258 if (!get_aim_dir(&dir)) return FALSE;
4260 project_length = 0; /* reset to default */
4262 /* Predict the "target" location */
4263 tx = px + 99 * ddx[dir];
4264 ty = py + 99 * ddy[dir];
4266 /* Check for "target request" */
4267 if ((dir == 5) && target_okay())
4274 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4275 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4276 return_when_thrown = TRUE;
4278 /* Reduce and describe inventory */
4281 inven_item_increase(item, -1);
4282 if (!return_when_thrown)
4283 inven_item_describe(item);
4284 inven_item_optimize(item);
4287 /* Reduce and describe floor item */
4290 floor_item_increase(0 - item, -1);
4291 floor_item_optimize(0 - item);
4293 if (item >= INVEN_RARM)
4295 equiped_item = TRUE;
4296 p_ptr->redraw |= (PR_EQUIPPY);
4302 /* Rogue and Ninja gets bonus */
4303 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4304 energy_use -= p_ptr->lev;
4306 /* Start at the player */
4311 /* Hack -- Handle stuff */
4314 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((f2 & TR2_THROW) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4315 else shuriken = FALSE;
4317 /* Chance of hitting */
4318 if (f2 & (TR2_THROW)) chance = ((p_ptr->skill_tht) +
4319 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4320 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4322 if (shuriken) chance *= 2;
4324 /* Travel until stopped */
4325 for (cur_dis = 0; cur_dis <= tdis; )
4327 /* Hack -- Stop at the target */
4328 if ((y == ty) && (x == tx)) break;
4330 /* Calculate the new location (see "project()") */
4333 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4335 /* Stopped by walls/doors */
4336 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4342 /* Advance the distance */
4345 /* The player can see the (on screen) missile */
4346 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4348 char c = object_char(q_ptr);
4349 byte a = object_attr(q_ptr);
4351 /* Draw, Hilite, Fresh, Pause, Erase */
4352 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4353 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4355 Term_xtra(TERM_XTRA_DELAY, msec);
4356 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4360 /* The player cannot see the missile */
4363 /* Pause anyway, for consistancy */
4364 Term_xtra(TERM_XTRA_DELAY, msec);
4367 /* Save the new location */
4372 /* Monster here, Try to hit it */
4373 if (cave[y][x].m_idx)
4375 cave_type *c_ptr = &cave[y][x];
4377 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4378 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4380 /* Check the visibility */
4381 visible = m_ptr->ml;
4383 /* Note the collision */
4386 /* Did we hit it (penalize range) */
4387 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4391 /* Assume a default death */
4393 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4395 cptr note_dies = " dies.";
4399 /* Some monsters get "destroyed" */
4400 if (!monster_living(r_ptr))
4403 bool explode = FALSE;
4405 for (i = 0; i < 4; i++)
4407 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4410 /* Special note at death */
4413 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4415 note_dies = " explodes into tiny shreds.";
4419 note_dies = "¤òÅݤ·¤¿¡£";
4421 note_dies = " is destroyed.";
4427 /* Handle unseen monster */
4430 /* Invisible monster */
4432 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4434 msg_format("The %s finds a mark.", o_name);
4439 /* Handle visible monster */
4444 /* Get "the monster" or "it" */
4445 monster_desc(m_name, m_ptr, 0);
4449 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4451 msg_format("The %s hits %s.", o_name, m_name);
4455 /* Hack -- Track this monster race */
4456 if (m_ptr->ml) monster_race_track((bool)(m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
4458 /* Hack -- Track this monster */
4459 if (m_ptr->ml) health_track(c_ptr->m_idx);
4462 /* Hack -- Base damage from thrown object */
4463 tdam = damroll(q_ptr->dd, q_ptr->ds);
4464 /* Apply special damage XXX XXX XXX */
4465 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4466 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4467 tdam += q_ptr->to_d;
4471 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4472 tdam += p_ptr->to_d_m;
4474 else if (f2 & (TR2_THROW))
4477 tdam += p_ptr->to_d_m;
4485 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4488 /* No negative damage */
4489 if (tdam < 0) tdam = 0;
4491 /* Modify the damage */
4492 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4494 /* Complex message */
4498 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4501 msg_format("You do %d (out of %d) damage.",
4507 /* Hit the monster, check for death */
4508 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4517 message_pain(c_ptr->m_idx, tdam);
4519 /* Anger the monster */
4520 if ((tdam > 0) && !object_is_potion(q_ptr))
4521 anger_monster(m_ptr);
4524 if (fear && m_ptr->ml)
4531 /* Get the monster name (or "it") */
4532 monster_desc(m_name, m_ptr, 0);
4536 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4538 msg_format("%^s flees in terror!", m_name);
4550 /* Chance of breakage (during attacks) */
4551 j = (hit_body ? breakage_chance(q_ptr) : 0);
4553 /* Figurines transform */
4554 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4558 if (!(summon_named_creature(y, x, q_ptr->pval, FALSE, FALSE, FALSE,
4559 (bool)!(q_ptr->ident & IDENT_CURSED))))
4561 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4563 msg_print("The Figurine writhes and then shatters.");
4566 else if (q_ptr->ident & IDENT_CURSED)
4568 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4570 msg_print("You have a bad feeling about this.");
4576 /* Potions smash open */
4577 if (object_is_potion(q_ptr))
4579 if (hit_body || hit_wall || (randint(100) < j))
4583 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4585 msg_format("The %s shatters!", o_name);
4589 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4591 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4593 /* ToDo (Robert): fix the invulnerability */
4594 if (cave[y][x].m_idx &&
4595 is_friendly(&m_list[cave[y][x].m_idx]) &&
4599 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4601 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4603 msg_format("%^s gets angry!", m_name);
4606 set_hostile(&m_list[cave[y][x].m_idx]);
4617 if (return_when_thrown)
4619 int back_chance = randint(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4620 char o2_name[MAX_NLEN];
4621 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4624 if (boomerang) back_chance += 4+randint(5);
4625 if (super_boomerang) back_chance += 100;
4626 object_desc(o2_name, q_ptr, FALSE, 0);
4628 if((back_chance > 30) && ((randint(100) != 1) || super_boomerang))
4630 for (i = cur_dis-1;i>0;i--)
4632 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4634 char c = object_char(q_ptr);
4635 byte a = object_attr(q_ptr);
4637 /* Draw, Hilite, Fresh, Pause, Erase */
4638 print_rel(c, a, ny[i], nx[i]);
4639 move_cursor_relative(ny[i], nx[i]);
4641 Term_xtra(TERM_XTRA_DELAY, msec);
4642 lite_spot(ny[i], nx[i]);
4647 /* Pause anyway, for consistancy */
4648 Term_xtra(TERM_XTRA_DELAY, msec);
4651 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4654 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4656 msg_format("%s comes back to you.", o2_name);
4665 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4667 msg_format("%s backs, but you can't catch!", o2_name);
4673 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4675 msg_format("%s comes back.", o2_name);
4685 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4687 msg_format("%s doesn't back!", o2_name);
4694 if (item == INVEN_RARM || item == INVEN_LARM)
4696 /* Access the wield slot */
4697 o_ptr = &inventory[item];
4699 /* Wear the new stuff */
4700 object_copy(o_ptr, q_ptr);
4702 /* Increase the weight */
4703 p_ptr->total_weight += q_ptr->weight;
4705 /* Increment the equip counter by hand */
4708 /* Recalculate bonuses */
4709 p_ptr->update |= (PU_BONUS);
4711 /* Recalculate torch */
4712 p_ptr->update |= (PU_TORCH);
4714 /* Recalculate mana XXX */
4715 p_ptr->update |= (PU_MANA);
4718 p_ptr->window |= (PW_EQUIP);
4726 else if (equiped_item)
4732 /* Drop (or break) near that location */
4733 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4740 * Throw an object from the pack or floor.
4742 void do_cmd_throw(void)
4744 do_cmd_throw_aux(1, FALSE, 0);