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);
67 /* Activate the quest */
68 if (!quest[p_ptr->inside_quest].status)
70 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
74 if (!p_ptr->inside_quest)
80 p_ptr->leaving = TRUE;
81 p_ptr->leftbldg = TRUE;
86 /* Normal up stairs */
87 else if ((c_ptr->feat == FEAT_LESS) || (c_ptr->feat == FEAT_LESS_LESS))
98 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
100 if (get_check("Really leave the level? "))
114 /* Hack -- take a turn */
117 if (autosave_l) do_cmd_save_game(TRUE);
119 if (p_ptr->inside_quest)
121 leaving_quest = p_ptr->inside_quest;
122 if (quest[leaving_quest].type != QUEST_TYPE_RANDOM) dun_level = 1;
124 /* Leaving an 'only once' quest marks it as failed */
126 ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
127 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
129 quest[leaving_quest].status = QUEST_STATUS_FAILED;
130 quest[leaving_quest].complev = (byte)p_ptr->lev;
131 if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
133 r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
134 if (record_rand_quest)
135 do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
137 else if (record_fix_quest)
138 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
141 p_ptr->inside_quest = c_ptr->special;
145 if (c_ptr->feat == FEAT_LESS_LESS)
147 /* Create a way back */
148 create_down_stair = 2;
154 /* Create a way back */
155 create_down_stair = 1;
159 if (!c_ptr->special && dungeon_type && ((dun_level - up_num + 1) > d_info[dungeon_type].mindepth) && one_in_(13))
163 if (c_ptr->feat == FEAT_LESS_LESS) msg_print("Ť¤¹£Æ»¤ò¾å¤Ã¤¿¡£");
164 else msg_print("Ť¤³¬Ãʤò¾å¤Ã¤¿¡£");
166 msg_print("These were very long stairs.");
170 if (dun_level-up_num+1 == d_info[dungeon_type].mindepth) up_num = dun_level;
172 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
174 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "go up the stairs to");
180 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
181 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
183 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
185 msg_print("You enter a maze of up staircases.");
189 /* Leaving the dungeon to town */
190 if (!dun_level && dungeon_type)
192 p_ptr->leaving_dungeon = TRUE;
193 if (!vanilla_town && !lite_town)
195 p_ptr->wilderness_y = d_info[dungeon_type].dy;
196 p_ptr->wilderness_x = d_info[dungeon_type].dx;
198 p_ptr->recall_dungeon = dungeon_type;
201 if (!dun_level) dungeon_type = 0;
204 p_ptr->leaving = TRUE;
210 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
212 msg_print("I see no up staircase here.");
223 void do_cmd_go_down(void)
226 bool go_down = FALSE;
227 bool fall_trap = FALSE;
230 if (p_ptr->special_defense & KATA_MUSOU)
232 set_action(ACTION_NONE);
236 c_ptr = &cave[py][px];
238 if (c_ptr->feat == (FEAT_TRAP_TRAPDOOR)) fall_trap = TRUE;
240 /* Quest down stairs */
241 if (c_ptr->feat == FEAT_QUEST_DOWN)
244 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
245 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
247 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
249 msg_print("You enter the down staircase.");
253 leaving_quest = p_ptr->inside_quest;
255 /* Leaving an 'only once' quest marks it as failed */
257 ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
258 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
260 quest[leaving_quest].status = QUEST_STATUS_FAILED;
261 quest[leaving_quest].complev = (byte)p_ptr->lev;
262 if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
264 r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
265 if (record_rand_quest)
266 do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
268 else if (record_fix_quest)
269 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
272 p_ptr->inside_quest = c_ptr->special;
274 /* Activate the quest */
275 if (!quest[p_ptr->inside_quest].status)
277 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
280 /* Leaving a quest */
281 if (!p_ptr->inside_quest)
287 p_ptr->leaving = TRUE;
288 p_ptr->leftbldg = TRUE;
294 else if ((c_ptr->feat != FEAT_MORE) && (c_ptr->feat != FEAT_MORE_MORE) && (c_ptr->feat != FEAT_ENTRANCE) && !fall_trap)
297 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
299 msg_print("I see no down staircase here.");
308 if (ironman_downward && (c_ptr->special != DUNGEON_ANGBAND))
311 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
313 msg_print("The entrance of this dungeon is closed!");
317 if (!max_dlv[c_ptr->special])
320 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[c_ptr->special].name, d_info[c_ptr->special].mindepth);
321 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
323 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);
324 if (!get_check("Do you really get in this dungeon? ")) return;
329 /* Save old player position */
332 dungeon_type = (byte)c_ptr->special;
339 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
341 if (get_check("Really leave the level? "))
355 /* Hack -- take a turn */
358 if (autosave_l) do_cmd_save_game(TRUE);
361 if (c_ptr->feat == FEAT_MORE_MORE) down_num += 2;
363 if (!quest_number(dun_level+down_num) && (dun_level < d_info[dungeon_type].maxdepth - 1 - down_num) && one_in_(13) && !fall_trap && dun_level)
367 if (c_ptr->feat == FEAT_MORE_MORE) msg_print("Ť¤¹£Æ»¤ò²¼¤ê¤¿¡£");
368 else msg_print("Ť¤³¬Ãʤò²¼¤ê¤¿¡£");
370 msg_print("These were very long stairs.");
374 else if (!dun_level) down_num = d_info[c_ptr->special].mindepth;
378 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
379 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
381 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fall from trap door");
382 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "go down the stairs to");
388 dun_level += down_num;
390 msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
392 msg_print("You deliberately jump through the trap door.");
398 if(c_ptr->feat == FEAT_ENTRANCE)
400 dun_level = d_info[c_ptr->special].mindepth;
402 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
404 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
409 dun_level += down_num;
411 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
412 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
414 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
416 msg_print("You enter a maze of down staircases.");
423 p_ptr->leaving = TRUE;
427 if (c_ptr->feat == FEAT_MORE_MORE)
429 /* Create a way back */
434 /* Create a way back */
445 * Simple command to "search" for one turn
447 void do_cmd_search(void)
449 /* Allow repeated command */
452 /* Set repeat count */
453 command_rep = command_arg - 1;
455 /* Redraw the state */
456 p_ptr->redraw |= (PR_STATE);
471 * Determine if a grid contains a chest
473 static s16b chest_check(int y, int x)
475 cave_type *c_ptr = &cave[y][x];
477 s16b this_o_idx, next_o_idx = 0;
480 /* Scan all objects in the grid */
481 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
486 o_ptr = &o_list[this_o_idx];
488 /* Acquire next object */
489 next_o_idx = o_ptr->next_o_idx;
491 /* Skip unknown chests XXX XXX */
492 /* if (!o_ptr->marked) continue; */
494 /* Check for chest */
495 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
504 * Allocates objects upon opening a chest -BEN-
506 * Disperse treasures from the given chest, centered at (x,y).
508 * Small chests often contain "gold", while Large chests always contain
509 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
510 * and Steel chests contain 6 items. The "value" of the items in a
511 * chest is based on the "power" of the chest, which is in turn based
512 * on the level on which the chest is generated.
514 static void chest_death(bool scatter, int y, int x, s16b o_idx)
524 object_type *o_ptr = &o_list[o_idx];
527 /* Small chests often hold "gold" */
528 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
530 /* Determine how much to drop (see above) */
531 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
533 if (o_ptr->sval == SV_CHEST_KANDUME)
538 object_level = o_ptr->xtra3;
542 /* Determine the "value" of the items */
543 object_level = ABS(o_ptr->pval) + 10;
546 /* Zero pval means empty chest */
547 if (!o_ptr->pval) number = 0;
549 /* Opening a chest */
550 opening_chest = TRUE;
552 /* Drop some objects (non-chests) */
553 for (; number > 0; --number)
555 /* Get local object */
558 /* Wipe the object */
561 /* Small chests often drop gold */
562 if (small && (rand_int(100) < 25))
565 if (!make_gold(q_ptr)) continue;
568 /* Otherwise drop an item */
571 /* Make a good object */
572 if (!make_object(q_ptr, TRUE, great)) continue;
575 /* If chest scatters its contents, pick any floor square. */
579 for (i = 0; i < 200; i++)
581 /* Pick a totally random spot. */
582 y = rand_int(MAX_HGT);
583 x = rand_int(MAX_WID);
585 /* Must be an empty floor. */
586 if (!cave_empty_bold(y, x)) continue;
588 /* Place the object there. */
589 drop_near(q_ptr, -1, y, x);
595 /* Normally, drop object near the chest. */
596 else drop_near(q_ptr, -1, y, x);
599 /* Reset the object level */
600 object_level = base_level;
602 /* No longer opening a chest */
603 opening_chest = FALSE;
614 * Chests have traps too.
616 * Exploding chest destroys contents (and traps).
617 * Note that the chest itself is never destroyed.
619 static void chest_trap(int y, int x, s16b o_idx)
623 object_type *o_ptr = &o_list[o_idx];
625 int mon_level = o_ptr->xtra3;
627 /* Ignore disarmed chests */
628 if (o_ptr->pval <= 0) return;
630 /* Obtain the traps */
631 trap = chest_traps[o_ptr->pval];
634 if (trap & (CHEST_LOSE_STR))
637 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
638 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
640 msg_print("A small needle has pricked you!");
641 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
644 (void)do_dec_stat(A_STR);
647 /* Lose constitution */
648 if (trap & (CHEST_LOSE_CON))
651 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
652 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
654 msg_print("A small needle has pricked you!");
655 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
658 (void)do_dec_stat(A_CON);
662 if (trap & (CHEST_POISON))
665 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
667 msg_print("A puff of green gas surrounds you!");
670 if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
672 (void)set_poisoned(p_ptr->poisoned + 10 + randint(20));
677 if (trap & (CHEST_PARALYZE))
680 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
682 msg_print("A puff of yellow gas surrounds you!");
686 if (!p_ptr->free_act)
688 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint(20));
692 /* Summon monsters */
693 if (trap & (CHEST_SUMMON))
695 int num = 2 + randint(3);
697 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
699 msg_print("You are enveloped in a cloud of smoke!");
703 for (i = 0; i < num; i++)
705 if (randint(100)<dun_level)
706 activate_hi_summon(py, px, FALSE);
708 (void)summon_specific(0, y, x, mon_level, 0, TRUE, FALSE, FALSE, TRUE, TRUE);
712 /* Elemental summon. */
713 if (trap & (CHEST_E_SUMMON))
716 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
718 msg_print("Elemental beings appear to protect their treasures!");
720 for (i = 0; i < randint(3) + 5; i++)
722 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, TRUE, FALSE, FALSE, TRUE, TRUE);
726 /* Force clouds, then summon birds. */
727 if (trap & (CHEST_BIRD_STORM))
730 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
732 msg_print("A storm of birds swirls around you!");
735 for (i = 0; i < randint(3) + 3; i++)
736 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
738 for (i = 0; i < randint(5) + o_ptr->pval / 5; i++)
740 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, TRUE, FALSE, FALSE, TRUE, TRUE);
744 /* Various colorful summonings. */
745 if (trap & (CHEST_H_SUMMON))
751 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
753 msg_print("Demons materialize in clouds of fire and brimstone!");
756 for (i = 0; i < randint(3) + 2; i++)
758 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
759 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, TRUE, FALSE, FALSE, TRUE, TRUE);
763 /* Summon dragons. */
767 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
769 msg_print("Draconic forms loom out of the darkness!");
772 for (i = 0; i < randint(3) + 2; i++)
774 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, TRUE, FALSE, FALSE, TRUE, TRUE);
778 /* Summon hybrids. */
782 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
784 msg_print("Creatures strange and twisted assault you!");
787 for (i = 0; i < randint(5) + 3; i++)
789 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, TRUE, FALSE, FALSE, TRUE, TRUE);
793 /* Summon vortices (scattered) */
797 msg_print("±²´¬¤«¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
799 msg_print("Vortices coalesce and wreak destruction!");
802 for (i = 0; i < randint(3) + 2; i++)
804 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, TRUE, FALSE, FALSE, TRUE, TRUE);
810 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
812 /* Determine how many nasty tricks can be played. */
813 int nasty_tricks_count = 4 + rand_int(3);
817 msg_print("¶²¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
819 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
822 /* This is gonna hurt... */
823 for (; nasty_tricks_count > 0; nasty_tricks_count--)
825 /* ...but a high saving throw does help a little. */
826 if (randint(100+o_ptr->pval*2) > p_ptr->skill_sav)
829 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
831 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
833 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
836 if (!p_ptr->free_act)
837 (void)set_paralyzed(p_ptr->paralyzed + 2 +
840 (void)set_stun(p_ptr->stun + 10 +
843 else if (one_in_(3)) apply_disenchant(0);
846 (void)do_dec_stat(A_STR);
847 (void)do_dec_stat(A_DEX);
848 (void)do_dec_stat(A_CON);
849 (void)do_dec_stat(A_INT);
850 (void)do_dec_stat(A_WIS);
851 (void)do_dec_stat(A_CHR);
853 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
859 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
862 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
863 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
865 msg_print("There is a sudden explosion!");
866 msg_print("Everything inside the chest is destroyed!");
870 sound(SOUND_EXPLODE);
872 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
874 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
878 /* Scatter contents. */
879 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
882 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
884 msg_print("The contents of the chest scatter all over the dungeon!");
886 chest_death(TRUE, y, x, o_idx);
893 * Attempt to open the given chest at the given location
895 * Assume there is no monster blocking the destination
897 * Returns TRUE if repeated commands may continue
899 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
907 object_type *o_ptr = &o_list[o_idx];
913 /* Attempt to unlock it */
916 /* Assume locked, and thus not open */
919 /* Get the "disarm" factor */
920 i = p_ptr->skill_dis;
922 /* Penalize some conditions */
923 if (p_ptr->blind || no_lite()) i = i / 10;
924 if (p_ptr->confused || p_ptr->image) i = i / 10;
926 /* Extract the difficulty */
929 /* Always have a small chance of success */
932 /* Success -- May still have traps */
933 if (rand_int(100) < j)
936 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
938 msg_print("You have picked the lock.");
945 /* Failure -- Keep trying */
948 /* We may continue repeating */
950 if (flush_failure) flush();
952 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
954 msg_print("You failed to pick the lock.");
960 /* Allowed to open */
963 /* Apply chest traps, if any */
964 chest_trap(y, x, o_idx);
966 /* Let the Chest drop items */
967 chest_death(FALSE, y, x, o_idx);
975 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
978 * Return TRUE if the given feature is an open door
980 static bool is_open(int feat)
982 return (feat == FEAT_OPEN);
985 static bool is_closed(int feat)
987 return ((feat >= FEAT_DOOR_HEAD) && (feat <= FEAT_DOOR_TAIL));
991 * Return the number of features around (or under) the character.
992 * Usually look for doors and floor traps.
994 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
996 int d, count, xx, yy;
998 /* Count how many matches */
1001 /* Check around (and under) the character */
1002 for (d = 0; d < 9; d++)
1004 /* if not searching under player continue */
1005 if ((d == 8) && !under) continue;
1007 /* Extract adjacent (legal) location */
1008 yy = py + ddy_ddd[d];
1009 xx = px + ddx_ddd[d];
1011 /* Must have knowledge */
1012 if (!(cave[yy][xx].info & (CAVE_MARK))) continue;
1014 /* Not looking for this feature */
1015 if (!((*test)(cave[yy][xx].feat))) continue;
1020 /* Remember the location. Only useful if only one match */
1031 * Return the number of chests around (or under) the character.
1032 * If requested, count only trapped chests.
1034 static int count_chests(int *y, int *x, bool trapped)
1036 int d, count, o_idx;
1040 /* Count how many matches */
1043 /* Check around (and under) the character */
1044 for (d = 0; d < 9; d++)
1046 /* Extract adjacent (legal) location */
1047 int yy = py + ddy_ddd[d];
1048 int xx = px + ddx_ddd[d];
1050 /* No (visible) chest is there */
1051 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1053 /* Grab the object */
1054 o_ptr = &o_list[o_idx];
1057 if (o_ptr->pval == 0) continue;
1059 /* No (known) traps here */
1060 if (trapped && (!object_known_p(o_ptr) ||
1061 !chest_traps[o_ptr->pval])) continue;
1066 /* Remember the location. Only useful if only one match */
1077 * Convert an adjacent location to a direction.
1079 static int coords_to_dir(int y, int x)
1081 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1088 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1090 return d[dx + 1][dy + 1];
1093 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1097 * Perform the basic "open" command on doors
1099 * Assume destination is a closed/locked/jammed door
1101 * Assume there is no monster blocking the destination
1103 * Returns TRUE if repeated commands may continue
1105 static bool do_cmd_open_aux(int y, int x, int dir)
1117 /* Get requested grid */
1118 c_ptr = &cave[y][x];
1121 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
1125 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
1127 msg_print("The door appears to be stuck.");
1133 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
1136 i = p_ptr->skill_dis;
1138 /* Penalize some conditions */
1139 if (p_ptr->blind || no_lite()) i = i / 10;
1140 if (p_ptr->confused || p_ptr->image) i = i / 10;
1142 /* Extract the lock power */
1143 j = c_ptr->feat - FEAT_DOOR_HEAD;
1145 /* Extract the difficulty XXX XXX XXX */
1148 /* Always have a small chance of success */
1152 if (rand_int(100) < j)
1156 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1158 msg_print("You have picked the lock.");
1163 cave_set_feat(y, x, FEAT_OPEN);
1165 /* Update some things */
1166 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1169 sound(SOUND_OPENDOOR);
1179 if (flush_failure) flush();
1183 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1185 msg_print("You failed to pick the lock.");
1189 /* We may keep trying */
1198 cave_set_feat(y, x, FEAT_OPEN);
1200 /* Update some things */
1201 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1204 sound(SOUND_OPENDOOR);
1214 * Open a closed/locked/jammed door or a closed/locked chest.
1216 * Unlocking a locked door/chest is worth one experience point.
1218 void do_cmd_open(void)
1228 if (p_ptr->special_defense & KATA_MUSOU)
1230 set_action(ACTION_NONE);
1233 #ifdef ALLOW_EASY_OPEN /* TNB */
1235 /* Option: Pick a direction */
1238 int num_doors, num_chests;
1240 /* Count closed doors (locked or jammed) */
1241 num_doors = count_dt(&y, &x, is_closed, FALSE);
1243 /* Count chests (locked) */
1244 num_chests = count_chests(&y, &x, FALSE);
1246 /* See if only one target */
1247 if (num_doors || num_chests)
1249 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1251 if (!too_many) command_dir = coords_to_dir(y, x);
1255 #endif /* ALLOW_EASY_OPEN -- TNB */
1257 /* Allow repeated command */
1260 /* Set repeat count */
1261 command_rep = command_arg - 1;
1263 /* Redraw the state */
1264 p_ptr->redraw |= (PR_STATE);
1266 /* Cancel the arg */
1270 /* Get a "repeated" direction */
1271 if (get_rep_dir(&dir, TRUE))
1273 /* Get requested location */
1277 /* Get requested grid */
1278 c_ptr = &cave[y][x];
1280 /* Check for chest */
1281 o_idx = chest_check(y, x);
1283 /* Nothing useful */
1284 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
1285 (c_ptr->feat <= FEAT_DOOR_TAIL)) &&
1290 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1292 msg_print("You see nothing there to open.");
1297 /* Monster in the way */
1298 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1305 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1307 msg_print("There is a monster in the way!");
1318 /* Open the chest */
1319 more = do_cmd_open_chest(y, x, o_idx);
1326 more = do_cmd_open_aux(y, x, dir);
1330 /* Cancel repeat unless we may continue */
1331 if (!more) disturb(0, 0);
1337 * Perform the basic "close" command
1339 * Assume destination is an open/broken door
1341 * Assume there is no monster blocking the destination
1343 * Returns TRUE if repeated commands may continue
1345 static bool do_cmd_close_aux(int y, int x, int dir)
1355 /* Get grid and contents */
1356 c_ptr = &cave[y][x];
1359 if (c_ptr->feat == FEAT_BROKEN)
1363 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1365 msg_print("The door appears to be broken.");
1373 /* Close the door */
1374 cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x00);
1376 /* Update some things */
1377 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1380 sound(SOUND_SHUTDOOR);
1389 * Close an open door.
1391 void do_cmd_close(void)
1399 if (p_ptr->special_defense & KATA_MUSOU)
1401 set_action(ACTION_NONE);
1404 #ifdef ALLOW_EASY_OPEN /* TNB */
1406 /* Option: Pick a direction */
1409 /* Count open doors */
1410 if (count_dt(&y, &x, is_open, FALSE) == 1)
1412 command_dir = coords_to_dir(y, x);
1416 #endif /* ALLOW_EASY_OPEN -- TNB */
1418 /* Allow repeated command */
1421 /* Set repeat count */
1422 command_rep = command_arg - 1;
1424 /* Redraw the state */
1425 p_ptr->redraw |= (PR_STATE);
1427 /* Cancel the arg */
1431 /* Get a "repeated" direction */
1432 if (get_rep_dir(&dir,FALSE))
1434 /* Get requested location */
1438 /* Get grid and contents */
1439 c_ptr = &cave[y][x];
1441 /* Require open/broken door */
1442 if ((c_ptr->feat != FEAT_OPEN) && (c_ptr->feat != FEAT_BROKEN))
1446 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1448 msg_print("You see nothing there to close.");
1453 /* Monster in the way */
1454 else if (c_ptr->m_idx)
1461 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1463 msg_print("There is a monster in the way!");
1471 /* Close the door */
1474 /* Close the door */
1475 more = do_cmd_close_aux(y, x, dir);
1479 /* Cancel repeat unless we may continue */
1480 if (!more) disturb(0, 0);
1485 * Determine if a given grid may be "tunneled"
1487 static bool do_cmd_tunnel_test(int y, int x)
1489 /* Must have knowledge */
1490 if (!(cave[y][x].info & (CAVE_MARK)))
1494 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1496 msg_print("You see nothing there.");
1504 /* Must be a wall/door/etc */
1505 if (cave_floor_bold(y, x))
1509 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1511 msg_print("You see nothing there to tunnel.");
1526 * Tunnel through wall. Assumes valid location.
1528 * Note that it is impossible to "extend" rooms past their
1529 * outer walls (which are actually part of the room).
1531 * This will, however, produce grids which are NOT illuminated
1532 * (or darkened) along with the rest of the room.
1534 static bool twall(int y, int x, byte feat)
1536 cave_type *c_ptr = &cave[y][x];
1538 /* Paranoia -- Require a wall or door or some such */
1539 if (cave_floor_bold(y, x)) return (FALSE);
1541 /* Forget the wall */
1542 c_ptr->info &= ~(CAVE_MARK);
1543 c_ptr->info &= ~(CAVE_MASK);
1544 c_ptr->info |= (CAVE_FLOOR);
1546 /* Remove the feature */
1547 cave_set_feat(y, x, feat);
1549 /* Update some things */
1550 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1559 * Perform the basic "tunnel" command
1561 * Assumes that the destination is a wall, a vein, a secret
1564 * Assumes that no monster is blocking the destination
1566 * Returns TRUE if repeated commands may continue
1568 static bool do_cmd_tunnel_aux(int y, int x, int dir)
1574 /* Verify legality */
1575 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1581 c_ptr = &cave[y][x];
1587 if ((c_ptr->feat >= FEAT_PERM_EXTRA) &&
1588 (c_ptr->feat <= FEAT_PERM_SOLID))
1591 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1593 msg_print("This seems to be permanent rock.");
1598 /* No tunnelling through mountains */
1599 else if (c_ptr->feat == FEAT_MOUNTAIN)
1602 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1604 msg_print("You can't tunnel through that!");
1609 else if (c_ptr->feat == FEAT_TREES) /* -KMW- */
1612 if ((p_ptr->skill_dig > 10 + rand_int(400)) && twall(y, x, FEAT_GRASS))
1615 msg_print("ÌÚ¤òÀÚ¤êʧ¤Ã¤¿¡£");
1617 msg_print("You have cleared away the trees.");
1619 chg_virtue(V_DILIGENCE, 1);
1620 chg_virtue(V_NATURE, -1);
1626 /* We may continue chopping */
1628 msg_print("ÌÚ¤òÀڤäƤ¤¤ë¡£");
1630 msg_print("You chop away at the tree.");
1635 /* Occasional Search XXX XXX */
1636 if (rand_int(100) < 25) search();
1642 else if ((c_ptr->feat >= FEAT_WALL_EXTRA) &&
1643 (c_ptr->feat <= FEAT_WALL_SOLID))
1646 if ((p_ptr->skill_dig > 40 + rand_int(1600)) && twall(y, x, floor_type[rand_int(100)]))
1649 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1651 msg_print("You have finished the tunnel.");
1653 chg_virtue(V_DILIGENCE, 1);
1654 chg_virtue(V_NATURE, -1);
1660 /* We may continue tunelling */
1662 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1664 msg_print("You tunnel into the granite wall.");
1672 /* Quartz / Magma */
1673 else if ((c_ptr->feat >= FEAT_MAGMA) &&
1674 (c_ptr->feat <= FEAT_QUARTZ_K))
1681 if (c_ptr->feat >= FEAT_MAGMA_H) gold = TRUE;
1683 /* Extract "quartz" flag XXX XXX XXX */
1684 if ((c_ptr->feat - FEAT_MAGMA) & 0x01) hard = TRUE;
1689 okay = (p_ptr->skill_dig > 20 + rand_int(800));
1695 okay = (p_ptr->skill_dig > 10 + rand_int(400));
1699 if (okay && twall(y, x, floor_type[rand_int(100)]))
1701 /* Found treasure */
1704 /* Place some gold */
1709 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1711 msg_print("You have found something!");
1721 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1723 msg_print("You have finished the tunnel.");
1725 chg_virtue(V_DILIGENCE, 1);
1726 chg_virtue(V_NATURE, -1);
1730 /* Failure (quartz) */
1733 /* Message, continue digging */
1735 msg_print("ÀбѤιÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1737 msg_print("You tunnel into the quartz vein.");
1743 /* Failure (magma) */
1746 /* Message, continue digging */
1748 msg_print("ÍÏ´ä¤Î¹ÛÌ®¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1750 msg_print("You tunnel into the magma vein.");
1758 else if (c_ptr->feat == FEAT_RUBBLE)
1760 /* Remove the rubble */
1761 if ((p_ptr->skill_dig > rand_int(200)) && twall(y, x, floor_type[rand_int(100)]))
1765 msg_print("´äÀФò¤¯¤º¤·¤¿¡£");
1767 msg_print("You have removed the rubble.");
1770 /* Hack -- place an object */
1771 if (rand_int(100) < (15 - dun_level/2))
1773 /* Create a simple object */
1774 place_object(y, x, FALSE, FALSE);
1776 /* Observe new object */
1777 if (player_can_see_bold(y, x))
1780 msg_print("²¿¤«¤òȯ¸«¤·¤¿¡ª");
1782 msg_print("You have found something!");
1791 /* Message, keep digging */
1793 msg_print("´äÀФò¤¯¤º¤·¤Æ¤¤¤ë¡£");
1795 msg_print("You dig in the rubble.");
1803 else if (c_ptr->feat >= FEAT_SECRET)
1806 if ((p_ptr->skill_dig > 30 + rand_int(1200)) && twall(y, x, floor_type[rand_int(100)]))
1809 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1811 msg_print("You have finished the tunnel.");
1819 /* We may continue tunelling */
1821 msg_print("²ÖÖ¾´ä¤ÎÊɤ˷ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£");
1823 msg_print("You tunnel into the granite wall.");
1828 /* Occasional Search XXX XXX */
1829 if (rand_int(100) < 25) search();
1837 if ((p_ptr->skill_dig > 30 + rand_int(1200)) && twall(y, x, floor_type[randint(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 door.");
1861 /* Notice new floor grids */
1862 if (!cave_floor_bold(y, x))
1864 /* Update some things */
1865 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1874 * Tunnels through "walls" (including rubble and closed doors)
1876 * Note that you must tunnel in order to hit invisible monsters
1877 * in walls, though moving into walls still takes a turn anyway.
1879 * Digging is very difficult without a "digger" weapon, but can be
1880 * accomplished by strong players using heavy weapons.
1882 void do_cmd_tunnel(void)
1891 if (p_ptr->special_defense & KATA_MUSOU)
1893 set_action(ACTION_NONE);
1896 /* Allow repeated command */
1899 /* Set repeat count */
1900 command_rep = command_arg - 1;
1902 /* Redraw the state */
1903 p_ptr->redraw |= (PR_STATE);
1905 /* Cancel the arg */
1909 /* Get a direction to tunnel, or Abort */
1910 if (get_rep_dir(&dir,FALSE))
1917 c_ptr = &cave[y][x];
1919 /* No tunnelling through doors */
1920 if (((c_ptr->feat >= FEAT_DOOR_HEAD) && (c_ptr->feat <= FEAT_DOOR_TAIL)) ||
1921 ((c_ptr->feat >= FEAT_BLDG_HEAD) && (c_ptr->feat <= FEAT_BLDG_TAIL)) ||
1922 ((c_ptr->feat >= FEAT_SHOP_HEAD) && (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
1923 (c_ptr->feat == FEAT_MUSEUM))
1927 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1929 msg_print("You cannot tunnel through doors.");
1934 /* No tunnelling through air */
1935 else if (cave_floor_grid(c_ptr) || ((c_ptr->feat >= FEAT_MINOR_GLYPH) &&
1936 (c_ptr->feat <= FEAT_PATTERN_XTRA2)))
1940 msg_print("¶õµ¤¤Ï·¡¤ì¤Ê¤¤¡£");
1942 msg_print("You cannot tunnel through air.");
1947 /* No tunnelling through mountains */
1948 else if (c_ptr->feat == FEAT_MOUNTAIN)
1951 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1953 msg_print("You can't tunnel through that!");
1958 /* A monster is in the way */
1959 else if (c_ptr->m_idx)
1966 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1968 msg_print("There is a monster in the way!");
1979 /* Tunnel through walls */
1980 more = do_cmd_tunnel_aux(y, x, dir);
1984 /* Cancel repetition unless we can continue */
1985 if (!more) disturb(0, 0);
1989 #ifdef ALLOW_EASY_OPEN /* TNB */
1994 * If there is a jammed/closed/locked door at the given location,
1995 * then attempt to unlock/open it. Return TRUE if an attempt was
1996 * made (successful or not), otherwise return FALSE.
1998 * The code here should be nearly identical to that in
1999 * do_cmd_open_test() and do_cmd_open_aux().
2001 bool easy_open_door(int y, int x)
2005 cave_type *c_ptr = &cave[y][x];
2007 /* Must be a closed door */
2008 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2009 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2016 if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x08)
2020 msg_print("¥É¥¢¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
2022 msg_print("The door appears to be stuck.");
2028 else if (c_ptr->feat >= FEAT_DOOR_HEAD + 0x01)
2031 i = p_ptr->skill_dis;
2033 /* Penalize some conditions */
2034 if (p_ptr->blind || no_lite()) i = i / 10;
2035 if (p_ptr->confused || p_ptr->image) i = i / 10;
2037 /* Extract the lock power */
2038 j = c_ptr->feat - FEAT_DOOR_HEAD;
2040 /* Extract the difficulty XXX XXX XXX */
2043 /* Always have a small chance of success */
2047 if (rand_int(100) < j)
2051 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
2053 msg_print("You have picked the lock.");
2058 cave_set_feat(y, x, FEAT_OPEN);
2060 /* Update some things */
2061 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2064 sound(SOUND_OPENDOOR);
2074 if (flush_failure) flush();
2078 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
2080 msg_print("You failed to pick the lock.");
2090 cave_set_feat(y, x, FEAT_OPEN);
2092 /* Update some things */
2093 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS);
2096 sound(SOUND_OPENDOOR);
2103 #endif /* ALLOW_EASY_OPEN -- TNB */
2107 * Perform the basic "disarm" command
2109 * Assume destination is a visible trap
2111 * Assume there is no monster blocking the destination
2113 * Returns TRUE if repeated commands may continue
2115 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
2121 object_type *o_ptr = &o_list[o_idx];
2127 /* Get the "disarm" factor */
2128 i = p_ptr->skill_dis;
2130 /* Penalize some conditions */
2131 if (p_ptr->blind || no_lite()) i = i / 10;
2132 if (p_ptr->confused || p_ptr->image) i = i / 10;
2134 /* Extract the difficulty */
2135 j = i - o_ptr->pval;
2137 /* Always have a small chance of success */
2140 /* Must find the trap first. */
2141 if (!object_known_p(o_ptr))
2144 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
2146 msg_print("I don't see any traps.");
2151 /* Already disarmed/unlocked */
2152 else if (o_ptr->pval <= 0)
2155 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2157 msg_print("The chest is not trapped.");
2162 /* No traps to find. */
2163 else if (!chest_traps[o_ptr->pval])
2166 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
2168 msg_print("The chest is not trapped.");
2173 /* Success (get a lot of experience) */
2174 else if (rand_int(100) < j)
2177 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
2179 msg_print("You have disarmed the chest.");
2182 gain_exp(o_ptr->pval);
2183 o_ptr->pval = (0 - o_ptr->pval);
2186 /* Failure -- Keep trying */
2187 else if ((i > 5) && (randint(i) > 5))
2189 /* We may keep trying */
2191 if (flush_failure) flush();
2193 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
2195 msg_print("You failed to disarm the chest.");
2200 /* Failure -- Set off the trap */
2204 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2206 msg_print("You set off a trap!");
2210 chest_trap(y, x, o_idx);
2219 * Perform the basic "disarm" command
2221 * Assume destination is a visible trap
2223 * Assume there is no monster blocking the destination
2225 * Returns TRUE if repeated commands may continue
2227 #ifdef ALLOW_EASY_DISARM /* TNB */
2229 bool do_cmd_disarm_aux(int y, int x, int dir)
2231 #else /* ALLOW_EASY_DISARM -- TNB */
2233 static bool do_cmd_disarm_aux(int y, int x, int dir)
2235 #endif /* ALLOW_EASY_DISARM -- TNB */
2249 /* Get grid and contents */
2250 c_ptr = &cave[y][x];
2252 /* Access trap name */
2253 name = (f_name + f_info[c_ptr->feat].name);
2255 /* Get the "disarm" factor */
2256 i = p_ptr->skill_dis;
2258 /* Penalize some conditions */
2259 if (p_ptr->blind || no_lite()) i = i / 10;
2260 if (p_ptr->confused || p_ptr->image) i = i / 10;
2262 /* XXX XXX XXX Variable power? */
2264 /* Extract trap "power" */
2267 /* Extract the difficulty */
2270 /* Always have a small chance of success */
2274 if (rand_int(100) < j)
2278 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2280 msg_format("You have disarmed the %s.", name);
2287 /* Forget the trap */
2288 c_ptr->info &= ~(CAVE_MARK);
2290 /* Remove the trap */
2291 c_ptr->feat = floor_type[rand_int(100)];
2292 c_ptr->info &= ~(CAVE_MASK);
2293 c_ptr->info |= CAVE_FLOOR;
2297 #ifdef ALLOW_EASY_DISARM /* TNB */
2299 /* Move the player onto the trap */
2300 move_player(dir, easy_disarm, FALSE);
2302 #else /* ALLOW_EASY_DISARM -- TNB */
2304 /* move the player onto the trap grid */
2305 move_player(dir, FALSE, FALSE);
2307 #endif /* ALLOW_EASY_DISARM -- TNB */
2310 /* Failure -- Keep trying */
2311 else if ((i > 5) && (randint(i) > 5))
2314 if (flush_failure) flush();
2318 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2320 msg_format("You failed to disarm the %s.", name);
2324 /* We may keep trying */
2328 /* Failure -- Set off the trap */
2333 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2335 msg_format("You set off the %s!", name);
2339 #ifdef ALLOW_EASY_DISARM /* TNB */
2341 /* Move the player onto the trap */
2342 move_player(dir, easy_disarm, FALSE);
2344 #else /* ALLOW_EASY_DISARM -- TNB */
2346 /* Move the player onto the trap */
2347 move_player(dir, FALSE, FALSE);
2349 #endif /* ALLOW_EASY_DISARM -- TNB */
2358 * Disarms a trap, or chest
2360 void do_cmd_disarm(void)
2370 if (p_ptr->special_defense & KATA_MUSOU)
2372 set_action(ACTION_NONE);
2375 #ifdef ALLOW_EASY_DISARM /* TNB */
2377 /* Option: Pick a direction */
2380 int num_traps, num_chests;
2382 /* Count visible traps */
2383 num_traps = count_dt(&y, &x, is_trap, TRUE);
2385 /* Count chests (trapped) */
2386 num_chests = count_chests(&y, &x, TRUE);
2388 /* See if only one target */
2389 if (num_traps || num_chests)
2391 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2393 if (!too_many) command_dir = coords_to_dir(y, x);
2397 #endif /* ALLOW_EASY_DISARM -- TNB */
2399 /* Allow repeated command */
2402 /* Set repeat count */
2403 command_rep = command_arg - 1;
2405 /* Redraw the state */
2406 p_ptr->redraw |= (PR_STATE);
2408 /* Cancel the arg */
2412 /* Get a direction (or abort) */
2413 if (get_rep_dir(&dir,TRUE))
2419 /* Get grid and contents */
2420 c_ptr = &cave[y][x];
2422 /* Check for chests */
2423 o_idx = chest_check(y, x);
2426 if (!is_trap(c_ptr->feat) && !o_idx)
2430 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2432 msg_print("You see nothing there to disarm.");
2437 /* Monster in the way */
2438 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2442 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2444 msg_print("There is a monster in the way!");
2455 /* Disarm the chest */
2456 more = do_cmd_disarm_chest(y, x, o_idx);
2462 /* Disarm the trap */
2463 more = do_cmd_disarm_aux(y, x, dir);
2467 /* Cancel repeat unless told not to */
2468 if (!more) disturb(0, 0);
2473 * Perform the basic "bash" command
2475 * Assume destination is a closed/locked/jammed door
2477 * Assume there is no monster blocking the destination
2479 * Returns TRUE if repeated commands may continue
2481 static bool do_cmd_bash_aux(int y, int x, int dir)
2494 c_ptr = &cave[y][x];
2498 msg_print("¥É¥¢¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª");
2500 msg_print("You smash into the door!");
2504 /* Hack -- Bash power based on strength */
2505 /* (Ranges from 3 to 20 to 100 to 200) */
2506 bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2508 /* Extract door power */
2509 temp = ((c_ptr->feat - FEAT_DOOR_HEAD) & 0x07);
2511 /* Compare bash power to door power XXX XXX XXX */
2512 temp = (bash - (temp * 10));
2514 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2516 /* Hack -- always have a chance */
2517 if (temp < 1) temp = 1;
2519 /* Hack -- attempt to bash down the door */
2520 if (rand_int(100) < temp)
2524 msg_print("¥É¥¢¤ò²õ¤·¤¿¡ª");
2526 msg_print("The door crashes open!");
2530 /* Break down the door */
2531 if (rand_int(100) < 50)
2533 cave_set_feat(y, x, FEAT_BROKEN);
2539 cave_set_feat(y, x, FEAT_OPEN);
2543 sound(SOUND_OPENDOOR);
2545 /* Hack -- Fall through the door */
2546 move_player(dir, FALSE, FALSE);
2548 /* Update some things */
2549 p_ptr->update |= (PU_VIEW | PU_LITE);
2550 p_ptr->update |= (PU_DISTANCE);
2553 /* Saving throw against stun */
2554 else if (rand_int(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2559 msg_print("¤³¤Î¥É¥¢¤Ï´è¾æ¤À¡£");
2561 msg_print("The door holds firm.");
2565 /* Allow repeated bashing */
2569 /* High dexterity yields coolness */
2574 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2576 msg_print("You are off-balance.");
2580 /* Hack -- Lose balance ala paralysis */
2581 (void)set_paralyzed(p_ptr->paralyzed + 2 + rand_int(2));
2590 * Bash open a door, success based on character strength
2592 * For a closed door, pval is positive if locked; negative if stuck.
2594 * For an open door, pval is positive for a broken door.
2596 * A closed door can be opened - harder if locked. Any door might be
2597 * bashed open (and thereby broken). Bashing a door is (potentially)
2598 * faster! You move into the door way. To open a stuck door, it must
2599 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2601 * Creatures can also open or bash doors, see elsewhere.
2603 void do_cmd_bash(void)
2612 if (p_ptr->special_defense & KATA_MUSOU)
2614 set_action(ACTION_NONE);
2617 /* Allow repeated command */
2620 /* Set repeat count */
2621 command_rep = command_arg - 1;
2623 /* Redraw the state */
2624 p_ptr->redraw |= (PR_STATE);
2626 /* Cancel the arg */
2630 /* Get a "repeated" direction */
2631 if (get_rep_dir(&dir,FALSE))
2638 c_ptr = &cave[y][x];
2640 /* Nothing useful */
2641 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2642 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2646 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2648 msg_print("You see nothing there to bash.");
2653 /* Monster in the way */
2654 else if (c_ptr->m_idx)
2661 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2663 msg_print("There is a monster in the way!");
2671 /* Bash a closed door */
2675 more = do_cmd_bash_aux(y, x, dir);
2679 /* Unless valid action taken, cancel bash */
2680 if (!more) disturb(0, 0);
2685 * Manipulate an adjacent grid in some way
2687 * Attack monsters, tunnel through walls, disarm traps, open doors.
2689 * Consider confusion XXX XXX XXX
2691 * This command must always take a turn, to prevent free detection
2692 * of invisible monsters.
2694 void do_cmd_alter(void)
2703 if (p_ptr->special_defense & KATA_MUSOU)
2705 set_action(ACTION_NONE);
2708 /* Allow repeated command */
2711 /* Set repeat count */
2712 command_rep = command_arg - 1;
2714 /* Redraw the state */
2715 p_ptr->redraw |= (PR_STATE);
2717 /* Cancel the arg */
2721 /* Get a direction */
2722 if (get_rep_dir(&dir,TRUE))
2729 c_ptr = &cave[y][x];
2734 /* Attack monsters */
2741 /* Tunnel through walls */
2742 else if (((c_ptr->feat >= FEAT_SECRET) &&
2743 (c_ptr->feat < FEAT_MINOR_GLYPH)) ||
2744 ((c_ptr->feat == FEAT_TREES) ||
2745 (c_ptr->feat == FEAT_MOUNTAIN)))
2748 more = do_cmd_tunnel_aux(y, x, dir);
2751 /* Bash jammed doors */
2752 else if ((c_ptr->feat >= FEAT_DOOR_HEAD + 0x08) &&
2753 (c_ptr->feat < FEAT_MINOR_GLYPH))
2756 more = do_cmd_bash_aux(y, x, dir);
2759 /* Open closed doors */
2760 else if ((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2761 (c_ptr->feat < FEAT_MINOR_GLYPH))
2764 more = do_cmd_open_aux(y, x, dir);
2767 /* Close open doors */
2768 else if ((c_ptr->feat == FEAT_OPEN) ||
2769 (c_ptr->feat == FEAT_BROKEN))
2772 more = do_cmd_close_aux(y, x, dir);
2776 else if (is_trap(c_ptr->feat))
2779 more = do_cmd_disarm_aux(y, x, dir);
2787 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2789 msg_print("You attack the empty air.");
2795 /* Cancel repetition unless we can continue */
2796 if (!more) disturb(0, 0);
2801 * Find the index of some "spikes", if possible.
2803 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2805 static bool get_spike(int *ip)
2809 /* Check every item in the pack */
2810 for (i = 0; i < INVEN_PACK; i++)
2812 object_type *o_ptr = &inventory[i];
2814 /* Skip non-objects */
2815 if (!o_ptr->k_idx) continue;
2817 /* Check the "tval" code */
2818 if (o_ptr->tval == TV_SPIKE)
2820 /* Save the spike index */
2834 * Jam a closed door with a spike
2836 * This command may NOT be repeated
2838 void do_cmd_spike(void)
2840 int y, x, dir, item;
2845 if (p_ptr->special_defense & KATA_MUSOU)
2847 set_action(ACTION_NONE);
2850 /* Get a "repeated" direction */
2851 if (get_rep_dir(&dir,FALSE))
2857 /* Get grid and contents */
2858 c_ptr = &cave[y][x];
2860 /* Require closed door */
2861 if (!((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2862 (c_ptr->feat <= FEAT_DOOR_TAIL)))
2866 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2868 msg_print("You see nothing there to spike.");
2874 else if (!get_spike(&item))
2878 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2880 msg_print("You have no spikes!");
2885 /* Is a monster in the way? */
2886 else if (c_ptr->m_idx)
2893 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2895 msg_print("There is a monster in the way!");
2909 /* Successful jamming */
2911 msg_print("¥É¥¢¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£");
2913 msg_print("You jam the door with a spike.");
2917 /* Convert "locked" to "stuck" XXX XXX XXX */
2918 if (c_ptr->feat < FEAT_DOOR_HEAD + 0x08) c_ptr->feat += 0x08;
2920 /* Add one spike to the door */
2921 if (c_ptr->feat < FEAT_DOOR_TAIL) c_ptr->feat++;
2923 /* Use up, and describe, a single spike, from the bottom */
2924 inven_item_increase(item, -1);
2925 inven_item_describe(item);
2926 inven_item_optimize(item);
2934 * Support code for the "Walk" and "Jump" commands
2936 void do_cmd_walk(int pickup)
2943 /* Allow repeated command */
2946 /* Set repeat count */
2947 command_rep = command_arg - 1;
2949 /* Redraw the state */
2950 p_ptr->redraw |= (PR_STATE);
2952 /* Cancel the arg */
2956 /* Get a "repeated" direction */
2957 if (get_rep_dir(&dir,FALSE))
2962 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2964 set_action(ACTION_NONE);
2967 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2968 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2969 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2971 /* Actually move the character */
2972 move_player(dir, pickup, FALSE);
2974 /* Allow more walking */
2978 /* Hack again -- Is there a special encounter ??? */
2979 if(p_ptr->wild_mode && (cave[py][px].feat != FEAT_TOWN))
2981 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2984 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && rand_int(tmp) < (21-p_ptr->skill_stl))
2986 /* Inform the player of his horrible fate :=) */
2988 msg_print("½±·â¤À¡ª");
2990 msg_print("You are ambushed !");
2993 /* Go into large wilderness view */
2994 p_ptr->wilderness_x = px;
2995 p_ptr->wilderness_y = py;
2996 p_ptr->oldpy = randint(MAX_HGT-2);
2997 p_ptr->oldpx = randint(MAX_WID-2);
3001 /* HACk -- set the encouter flag for the wilderness generation */
3002 generate_encounter = TRUE;
3006 /* Cancel repeat unless we may continue */
3007 if (!more) disturb(0, 0);
3015 void do_cmd_run(void)
3019 /* Hack -- no running when confused */
3020 if (p_ptr->confused)
3023 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
3025 msg_print("You are too confused!");
3031 if (p_ptr->special_defense & KATA_MUSOU)
3033 set_action(ACTION_NONE);
3036 /* Get a "repeated" direction */
3037 if (get_rep_dir(&dir,FALSE))
3039 /* Hack -- Set the run counter */
3040 running = (command_arg ? command_arg : 1000);
3050 * Stay still. Search. Enter stores.
3051 * Pick up treasure if "pickup" is true.
3053 void do_cmd_stay(int pickup)
3055 cave_type *c_ptr = &cave[py][px];
3058 /* Allow repeated command */
3061 /* Set repeat count */
3062 command_rep = command_arg - 1;
3064 /* Redraw the state */
3065 p_ptr->redraw |= (PR_STATE);
3067 /* Cancel the arg */
3076 /* Spontaneous Searching */
3077 if ((p_ptr->skill_fos >= 50) || (0 == rand_int(50 - p_ptr->skill_fos)))
3082 /* Continuous Searching */
3083 if (p_ptr->action == ACTION_SEARCH)
3089 /* Handle "objects" */
3093 /* Hack -- enter a store if we are on one */
3094 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
3095 (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
3096 (c_ptr->feat == FEAT_MUSEUM))
3102 /* Hack -- enter store */
3106 /* Hack -- enter a building if we are on one -KMW- */
3107 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
3108 (c_ptr->feat <= FEAT_BLDG_TAIL))
3114 /* Hack -- enter building */
3118 /* Exit a quest if reach the quest exit */
3119 else if (c_ptr->feat == FEAT_QUEST_EXIT)
3121 int q_index = p_ptr->inside_quest;
3123 /* Was quest completed? */
3124 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
3126 quest[q_index].status = QUEST_STATUS_COMPLETED;
3127 quest[q_index].complev = (byte)p_ptr->lev;
3129 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
3131 msg_print("You accomplished your quest!");
3137 leaving_quest = p_ptr->inside_quest;
3139 /* Leaving an 'only once' quest marks it as failed */
3140 if (leaving_quest &&
3141 ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
3142 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
3144 quest[leaving_quest].status = QUEST_STATUS_FAILED;
3145 quest[leaving_quest].complev = (byte)p_ptr->lev;
3146 if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
3148 r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
3149 if (record_rand_quest)
3150 do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
3152 else if (record_fix_quest)
3153 do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
3156 p_ptr->inside_quest = cave[py][px].special;
3160 p_ptr->leaving = TRUE;
3167 * Resting allows a player to safely restore his hp -RAK-
3169 void do_cmd_rest(void)
3172 set_action(ACTION_NONE);
3174 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
3179 /* Prompt for time if needed */
3180 if (command_arg <= 0)
3183 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
3185 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
3192 strcpy(out_val, "&");
3194 /* Ask for duration */
3195 if (!get_string(p, out_val, 4)) return;
3197 /* Rest until done */
3198 if (out_val[0] == '&')
3204 else if (out_val[0] == '*')
3212 command_arg = atoi(out_val);
3213 if (command_arg <= 0) return;
3219 if (command_arg > 9999) command_arg = 9999;
3221 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
3223 /* Take a turn XXX XXX XXX (?) */
3226 /* The sin of sloth */
3227 if (command_arg > 100)
3228 chg_virtue(V_DILIGENCE, -1);
3230 /* Why are you sleeping when there's no need? WAKE UP!*/
3231 if ((p_ptr->chp == p_ptr->mhp) &&
3232 (p_ptr->csp == p_ptr->msp) &&
3233 !p_ptr->blind && !p_ptr->confused &&
3234 !p_ptr->poisoned && !p_ptr->afraid &&
3235 !p_ptr->stun && !p_ptr->cut &&
3236 !p_ptr->slow && !p_ptr->paralyzed &&
3237 !p_ptr->image && !p_ptr->word_recall)
3238 chg_virtue(V_DILIGENCE, -1);
3240 /* Save the rest code */
3241 resting = command_arg;
3242 p_ptr->action = ACTION_REST;
3244 /* Recalculate bonuses */
3245 p_ptr->update |= (PU_BONUS);
3247 /* Redraw the state */
3248 p_ptr->redraw |= (PR_STATE);
3259 * Determines the odds of an object breaking when thrown at a monster
3261 * Note that artifacts never break, see the "drop_near()" function.
3263 static int breakage_chance(object_type *o_ptr)
3265 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3267 /* Examine the item type */
3268 switch (o_ptr->tval)
3284 /* Sometimes break */
3289 return (20 - archer_bonus * 2);
3294 return (10 - archer_bonus);
3301 s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3305 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3309 /* Extract the flags */
3310 object_flags(o_ptr, &f1, &f2, &f3);
3312 /* Some "weapons" and "ammo" do extra damage */
3313 switch (o_ptr->tval)
3320 if ((f1 & TR1_SLAY_ANIMAL) &&
3321 (r_ptr->flags3 & RF3_ANIMAL))
3325 r_ptr->r_flags3 |= RF3_ANIMAL;
3328 if (mult < 17) mult = 17;
3332 if ((f1 & TR1_SLAY_EVIL) &&
3333 (r_ptr->flags3 & RF3_EVIL))
3337 r_ptr->r_flags3 |= RF3_EVIL;
3340 if (mult < 15) mult = 15;
3344 if ((f1 & TR1_SLAY_UNDEAD) &&
3345 (r_ptr->flags3 & RF3_UNDEAD))
3349 r_ptr->r_flags3 |= RF3_UNDEAD;
3352 if (mult < 20) mult = 20;
3356 if ((f1 & TR1_SLAY_DEMON) &&
3357 (r_ptr->flags3 & RF3_DEMON))
3361 r_ptr->r_flags3 |= RF3_DEMON;
3364 if (mult < 20) mult = 20;
3368 if ((f1 & TR1_SLAY_ORC) &&
3369 (r_ptr->flags3 & RF3_ORC))
3373 r_ptr->r_flags3 |= RF3_ORC;
3376 if (mult < 20) mult = 20;
3380 if ((f1 & TR1_SLAY_TROLL) &&
3381 (r_ptr->flags3 & RF3_TROLL))
3385 r_ptr->r_flags3 |= RF3_TROLL;
3388 if (mult < 20) mult = 20;
3392 if ((f1 & TR1_SLAY_GIANT) &&
3393 (r_ptr->flags3 & RF3_GIANT))
3397 r_ptr->r_flags3 |= RF3_GIANT;
3400 if (mult < 20) mult = 20;
3404 if ((f1 & TR1_SLAY_DRAGON) &&
3405 (r_ptr->flags3 & RF3_DRAGON))
3409 r_ptr->r_flags3 |= RF3_DRAGON;
3412 if (mult < 20) mult = 20;
3415 /* Execute Dragon */
3416 if ((f1 & TR1_KILL_DRAGON) &&
3417 (r_ptr->flags3 & RF3_DRAGON))
3421 r_ptr->r_flags3 |= RF3_DRAGON;
3424 if (mult < 30) mult = 30;
3426 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3427 (m_ptr->r_idx == MON_SMAUG) &&
3428 (inventory[INVEN_BOW].name1 == ART_BARD))
3433 if ((f1 & TR1_BRAND_ACID) || (p_ptr->special_attack & (ATTACK_ACID)))
3435 /* Notice immunity */
3436 if (r_ptr->flags3 & RF3_IM_ACID)
3440 r_ptr->r_flags3 |= RF3_IM_ACID;
3444 /* Otherwise, take the damage */
3447 if (mult < 17) mult = 17;
3452 if ((f1 & TR1_BRAND_ELEC) || (p_ptr->special_attack & (ATTACK_ELEC)))
3454 /* Notice immunity */
3455 if (r_ptr->flags3 & RF3_IM_ELEC)
3459 r_ptr->r_flags3 |= RF3_IM_ELEC;
3463 /* Otherwise, take the damage */
3466 if (mult < 17) mult = 17;
3471 if ((f1 & TR1_BRAND_FIRE) || (p_ptr->special_attack & (ATTACK_FIRE)))
3473 /* Notice immunity */
3474 if (r_ptr->flags3 & RF3_IM_FIRE)
3478 r_ptr->r_flags3 |= RF3_IM_FIRE;
3482 /* Otherwise, take the damage */
3485 if (mult < 17) mult = 17;
3490 if ((f1 & TR1_BRAND_COLD) || (p_ptr->special_attack & (ATTACK_COLD)))
3492 /* Notice immunity */
3493 if (r_ptr->flags3 & RF3_IM_COLD)
3497 r_ptr->r_flags3 |= RF3_IM_COLD;
3500 /* Otherwise, take the damage */
3503 if (mult < 17) mult = 17;
3507 /* Brand (Poison) */
3508 if ((f1 & TR1_BRAND_POIS) || (p_ptr->special_attack & (ATTACK_POIS)))
3510 /* Notice immunity */
3511 if (r_ptr->flags3 & RF3_IM_POIS)
3515 r_ptr->r_flags3 |= RF3_IM_POIS;
3519 /* Otherwise, take the damage */
3522 if (mult < 17) mult = 17;
3526 if ((f1 & TR1_FORCE_WEPON) && (p_ptr->csp > (p_ptr->msp / 30)))
3528 p_ptr->csp -= (1+(p_ptr->msp / 30));
3529 p_ptr->redraw |= (PR_MANA);
3530 mult = mult * 5 / 2;
3536 /* Return the total damage */
3537 return (tdam * mult / 10);
3542 * Fire an object from the pack or floor.
3544 * You may only fire items that "match" your missile launcher.
3546 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3548 * See "calc_bonuses()" for more calculations and such.
3550 * Note that "firing" a missile is MUCH better than "throwing" it.
3552 * Note: "unseen" monsters are very hard to hit.
3554 * Objects are more likely to break if they "attempt" to hit a monster.
3556 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3558 * The "extra shot" code works by decreasing the amount of energy
3559 * required to make each shot, spreading the shots out over time.
3561 * Note that when firing missiles, the launcher multiplier is applied
3562 * after all the bonuses are added in, making multipliers very useful.
3564 * Note that Bows of "Extra Might" get extra range and an extra bonus
3565 * for the damage multiplier.
3567 * Note that Bows of "Extra Shots" give an extra shot.
3569 void do_cmd_fire_aux(int item, object_type *j_ptr)
3572 int j, y, x, ny, nx, ty, tx;
3573 int tdam, tdis, thits, tmul;
3575 int cur_dis, visible;
3582 bool hit_body = FALSE;
3584 char o_name[MAX_NLEN];
3586 int msec = delay_factor * delay_factor * delay_factor;
3589 bool stick_to = FALSE;
3591 /* Access the item (if in the pack) */
3594 o_ptr = &inventory[item];
3598 o_ptr = &o_list[0 - item];
3601 /* Describe the object */
3602 object_desc(o_name, o_ptr, FALSE, 3);
3605 /* Use the proper number of shots */
3606 thits = p_ptr->num_fire;
3608 /* Use a base distance */
3611 /* Base damage from thrown object plus launcher bonus */
3612 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3614 /* Actually "fire" the object */
3615 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3616 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3617 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval])/400 + bonus) * BTH_PLUS_ADJ);
3619 chance = (p_ptr->skill_thb + ((weapon_exp[0][j_ptr->sval]-4000)/200 + bonus) * BTH_PLUS_ADJ);
3621 energy_use = bow_energy(j_ptr->sval);
3622 tmul = bow_tmul(j_ptr->sval);
3624 /* Get extra "power" from "extra might" */
3625 if (p_ptr->xtra_might) tmul++;
3627 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3629 /* Boost the damage */
3634 tdis = 10 + tmul/40;
3635 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3638 project_length = tdis + 1;
3640 /* Get a direction (or cancel) */
3641 if (!get_aim_dir(&dir))
3645 /* need not to reset project_length (already did)*/
3649 project_length = 0; /* reset to default */
3651 /* Get local object */
3654 /* Obtain a local object */
3655 object_copy(q_ptr, o_ptr);
3660 /* Reduce and describe inventory */
3663 inven_item_increase(item, -1);
3664 inven_item_describe(item);
3665 inven_item_optimize(item);
3668 /* Reduce and describe floor item */
3671 floor_item_increase(0 - item, -1);
3672 floor_item_optimize(0 - item);
3680 /* Take a (partial) turn */
3681 energy_use = (energy_use / thits);
3684 /* Start at the player */
3688 /* Predict the "target" location */
3689 tx = px + 99 * ddx[dir];
3690 ty = py + 99 * ddy[dir];
3692 /* Check for "target request" */
3693 if ((dir == 5) && target_okay())
3700 /* Hack -- Handle stuff */
3704 /* Travel until stopped */
3705 for (cur_dis = 0; cur_dis <= tdis; )
3707 /* Hack -- Stop at the target */
3708 if ((y == ty) && (x == tx)) break;
3710 /* Calculate the new location (see "project()") */
3713 mmove2(&ny, &nx, py, px, ty, tx);
3715 /* Stopped by walls/doors */
3716 if (!cave_floor_bold(ny, nx) && !cave[ny][nx].m_idx) break;
3718 /* Advance the distance */
3722 /* The player can see the (on screen) missile */
3723 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3725 char c = object_char(q_ptr);
3726 byte a = object_attr(q_ptr);
3728 /* Draw, Hilite, Fresh, Pause, Erase */
3729 print_rel(c, a, ny, nx);
3730 move_cursor_relative(ny, nx);
3732 Term_xtra(TERM_XTRA_DELAY, msec);
3737 /* The player cannot see the missile */
3740 /* Pause anyway, for consistancy */
3741 Term_xtra(TERM_XTRA_DELAY, msec);
3744 /* Save the new location */
3749 /* Monster here, Try to hit it */
3750 if (cave[y][x].m_idx)
3752 cave_type *c_ptr = &cave[y][x];
3754 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3755 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3757 /* Check the visibility */
3758 visible = m_ptr->ml;
3760 /* Note the collision */
3765 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3766 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3769 if ((r_ptr->level + 10) > p_ptr->lev)
3771 int now_exp = weapon_exp[0][j_ptr->sval];
3772 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3775 if (now_exp < 4000) amount = 80;
3776 else if (now_exp < 6000) amount = 25;
3777 else if ((now_exp < 7000) && (p_ptr->lev > 19)) amount = 10;
3778 else if (p_ptr->lev > 34) amount = 2;
3779 weapon_exp[0][j_ptr->sval] += amount;
3780 p_ptr->update |= (PU_BONUS);
3786 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))
3788 skill_exp[GINOU_RIDING]+=1;
3789 p_ptr->update |= (PU_BONUS);
3793 /* Did we hit it (penalize range) */
3794 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3798 /* Assume a default death */
3800 cptr note_dies = "¤Ï»à¤ó¤À¡£";
3802 cptr note_dies = " dies.";
3805 /* Some monsters get "destroyed" */
3806 if (!monster_living(r_ptr))
3809 bool explode = FALSE;
3811 for (i = 0; i < 4; i++)
3813 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
3816 /* Special note at death */
3819 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
3821 note_dies = " explodes into tiny shreds.";
3825 note_dies = "¤òÅݤ·¤¿¡£";
3827 note_dies = " is destroyed.";
3832 /* Handle unseen monster */
3835 /* Invisible monster */
3837 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3839 msg_format("The %s finds a mark.", o_name);
3844 /* Handle visible monster */
3849 /* Get "the monster" or "it" */
3850 monster_desc(m_name, m_ptr, 0);
3854 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3856 msg_format("The %s hits %s.", o_name, m_name);
3860 /* Hack -- Track this monster race */
3861 if (m_ptr->ml) monster_race_track((bool)(m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
3863 /* Hack -- Track this monster */
3864 if (m_ptr->ml) health_track(c_ptr->m_idx);
3867 /* Apply special damage XXX XXX XXX */
3868 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3869 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3871 /* No negative damage */
3872 if (tdam < 0) tdam = 0;
3874 /* Modify the damage */
3875 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3877 /* Complex message */
3878 if (wizard || cheat_xtra)
3881 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3884 msg_format("You do %d (out of %d) damage.",
3890 /* Hit the monster, check for death */
3891 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
3904 monster_desc(m_name, m_ptr, 0);
3908 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3910 msg_format("%^s have stuck into %s!",o_name, m_name);
3915 message_pain(c_ptr->m_idx, tdam);
3917 /* Anger the monster */
3918 if (tdam > 0) anger_monster(m_ptr);
3921 if (fear && m_ptr->ml)
3928 /* Get the monster name (or "it") */
3929 monster_desc(m_name, m_ptr, 0);
3933 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3935 msg_format("%^s flees in terror!", m_name);
3939 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3941 set_target(m_ptr, py, px);
3951 /* Chance of breakage (during attacks) */
3952 j = (hit_body ? breakage_chance(q_ptr) : 0);
3956 int m_idx = cave[y][x].m_idx;
3957 monster_type *m_ptr = &m_list[m_idx];
3958 int o_idx = o_pop();
3963 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3965 msg_format("The %s have gone to somewhere.", o_name);
3969 a_info[j_ptr->name1].cur_num = 0;
3974 o_ptr = &o_list[ o_idx ];
3975 object_copy(o_ptr, q_ptr);
3978 o_ptr->marked = FALSE;
3980 /* Forget location */
3981 o_ptr->iy = o_ptr->ix = 0;
3983 /* Memorize monster */
3984 o_ptr->held_m_idx = m_idx;
3987 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3990 m_ptr->hold_o_idx = o_idx;
3994 /* Drop (or break) near that location */
3995 (void)drop_near(q_ptr, j, y, x);
3999 void do_cmd_fire(void)
4005 /* Get the "bow" (if any) */
4006 j_ptr = &inventory[INVEN_BOW];
4008 /* Require a launcher */
4012 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4014 msg_print("You have nothing to fire with.");
4020 if (j_ptr->sval == SV_CRIMSON)
4023 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4025 msg_print("Do activate.");
4032 if (p_ptr->special_defense & KATA_MUSOU)
4034 set_action(ACTION_NONE);
4037 /* Require proper missile */
4038 item_tester_tval = p_ptr->tval_ammo;
4042 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4043 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4045 q = "Fire which item? ";
4046 s = "You have nothing to fire.";
4049 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4056 do_cmd_fire_aux(item, j_ptr);
4060 static bool item_tester_hook_boomerang(object_type *o_ptr)
4062 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4070 * Throw an object from the pack or floor.
4072 * Note: "unseen" monsters are very hard to hit.
4074 * Should throwing a weapon do full damage? Should it allow the magic
4075 * to hit bonus of the weapon to have an effect? Should it ever cause
4076 * the item to be destroyed? Should it do any damage at all?
4078 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4081 int i, j, y, x, ty, tx;
4083 int chance, tdam, tdis;
4085 int cur_dis, visible;
4092 bool hit_body = FALSE;
4093 bool hit_wall = FALSE;
4094 bool equiped_item = FALSE;
4095 bool return_when_thrown = FALSE;
4097 char o_name[MAX_NLEN];
4099 int msec = delay_factor * delay_factor * delay_factor;
4103 bool come_back = FALSE;
4104 bool do_drop = TRUE;
4107 if (p_ptr->special_defense & KATA_MUSOU)
4109 set_action(ACTION_NONE);
4118 if (buki_motteruka(INVEN_LARM))
4120 item_tester_hook = item_tester_hook_boomerang;
4122 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4123 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4125 q = "Throw which item? ";
4126 s = "You have nothing to throw.";
4129 if (!get_item(&item, q, s, (USE_EQUIP)))
4144 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4145 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4147 q = "Throw which item? ";
4148 s = "You have nothing to throw.";
4151 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4158 /* Access the item (if in the pack) */
4161 o_ptr = &inventory[item];
4165 o_ptr = &o_list[0 - item];
4169 /* Item is cursed */
4170 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4174 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4176 msg_print("Hmmm, it seems to be cursed.");
4185 /* Get local object */
4188 /* Obtain a local object */
4189 object_copy(q_ptr, o_ptr);
4191 /* Extract the thrown object's flags. */
4192 object_flags(q_ptr, &f1, &f2, &f3);
4194 /* Distribute the charges of rods/wands between the stacks */
4195 distribute_charges(o_ptr, q_ptr, 1);
4201 object_desc(o_name, q_ptr, FALSE, 3);
4203 if (p_ptr->mighty_throw) mult += 3;
4205 /* Extract a "distance multiplier" */
4206 /* Changed for 'launcher' mutation */
4207 mul = 10 + 2 * (mult - 1);
4209 /* Enforce a minimum "weight" of one pound */
4210 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4211 if ((f2 & (TR2_THROW)) || boomerang) div /= 2;
4213 /* Hack -- Distance -- Reward strength, penalize weight */
4214 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4216 /* Max distance of 10-18 */
4217 if (tdis > mul) tdis = mul;
4221 ty = rand_int(101)-50+py;
4222 tx = rand_int(101)-50+px;
4226 project_length = tdis + 1;
4228 /* Get a direction (or cancel) */
4229 if (!get_aim_dir(&dir)) return FALSE;
4231 project_length = 0; /* reset to default */
4233 /* Predict the "target" location */
4234 tx = px + 99 * ddx[dir];
4235 ty = py + 99 * ddy[dir];
4237 /* Check for "target request" */
4238 if ((dir == 5) && target_okay())
4245 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4246 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4247 return_when_thrown = TRUE;
4249 /* Reduce and describe inventory */
4252 inven_item_increase(item, -1);
4253 if (!return_when_thrown)
4254 inven_item_describe(item);
4255 inven_item_optimize(item);
4258 /* Reduce and describe floor item */
4261 floor_item_increase(0 - item, -1);
4262 floor_item_optimize(0 - item);
4264 if (item >= INVEN_RARM)
4266 equiped_item = TRUE;
4267 p_ptr->redraw |= (PR_EQUIPPY);
4273 /* Rogue and Ninja gets bonus */
4274 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4275 energy_use -= p_ptr->lev;
4277 /* Start at the player */
4282 /* Hack -- Handle stuff */
4285 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((f2 & TR2_THROW) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4286 else shuriken = FALSE;
4288 /* Chance of hitting */
4289 if (f2 & (TR2_THROW)) chance = ((p_ptr->skill_tht) +
4290 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4291 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4293 if (shuriken) chance *= 2;
4295 /* Travel until stopped */
4296 for (cur_dis = 0; cur_dis <= tdis; )
4298 /* Hack -- Stop at the target */
4299 if ((y == ty) && (x == tx)) break;
4301 /* Calculate the new location (see "project()") */
4304 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4306 /* Stopped by walls/doors */
4307 if (!cave_floor_bold(ny[cur_dis], nx[cur_dis]))
4313 /* Advance the distance */
4316 /* The player can see the (on screen) missile */
4317 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4319 char c = object_char(q_ptr);
4320 byte a = object_attr(q_ptr);
4322 /* Draw, Hilite, Fresh, Pause, Erase */
4323 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4324 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4326 Term_xtra(TERM_XTRA_DELAY, msec);
4327 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4331 /* The player cannot see the missile */
4334 /* Pause anyway, for consistancy */
4335 Term_xtra(TERM_XTRA_DELAY, msec);
4338 /* Save the new location */
4343 /* Monster here, Try to hit it */
4344 if (cave[y][x].m_idx)
4346 cave_type *c_ptr = &cave[y][x];
4348 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4349 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4351 /* Check the visibility */
4352 visible = m_ptr->ml;
4354 /* Note the collision */
4357 /* Did we hit it (penalize range) */
4358 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4362 /* Assume a default death */
4364 cptr note_dies = "¤Ï»à¤ó¤À¡£";
4366 cptr note_dies = " dies.";
4370 /* Some monsters get "destroyed" */
4371 if (!monster_living(r_ptr))
4374 bool explode = FALSE;
4376 for (i = 0; i < 4; i++)
4378 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
4381 /* Special note at death */
4384 note_dies = "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
4386 note_dies = " explodes into tiny shreds.";
4390 note_dies = "¤òÅݤ·¤¿¡£";
4392 note_dies = " is destroyed.";
4398 /* Handle unseen monster */
4401 /* Invisible monster */
4403 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4405 msg_format("The %s finds a mark.", o_name);
4410 /* Handle visible monster */
4415 /* Get "the monster" or "it" */
4416 monster_desc(m_name, m_ptr, 0);
4420 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4422 msg_format("The %s hits %s.", o_name, m_name);
4426 /* Hack -- Track this monster race */
4427 if (m_ptr->ml) monster_race_track((bool)(m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
4429 /* Hack -- Track this monster */
4430 if (m_ptr->ml) health_track(c_ptr->m_idx);
4433 /* Hack -- Base damage from thrown object */
4434 tdam = damroll(q_ptr->dd, q_ptr->ds);
4435 /* Apply special damage XXX XXX XXX */
4436 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0);
4437 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4438 tdam += q_ptr->to_d;
4442 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4443 tdam += p_ptr->to_d_m;
4445 else if (f2 & (TR2_THROW))
4448 tdam += p_ptr->to_d_m;
4456 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4459 /* No negative damage */
4460 if (tdam < 0) tdam = 0;
4462 /* Modify the damage */
4463 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4465 /* Complex message */
4469 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4472 msg_format("You do %d (out of %d) damage.",
4478 /* Hit the monster, check for death */
4479 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, note_dies))
4488 message_pain(c_ptr->m_idx, tdam);
4490 /* Anger the monster */
4491 if ((tdam > 0) && !object_is_potion(q_ptr))
4492 anger_monster(m_ptr);
4495 if (fear && m_ptr->ml)
4502 /* Get the monster name (or "it") */
4503 monster_desc(m_name, m_ptr, 0);
4507 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4509 msg_format("%^s flees in terror!", m_name);
4521 /* Chance of breakage (during attacks) */
4522 j = (hit_body ? breakage_chance(q_ptr) : 0);
4524 /* Figurines transform */
4525 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4529 if (!(summon_named_creature(y, x, q_ptr->pval, FALSE, FALSE, FALSE,
4530 (bool)!(q_ptr->ident & IDENT_CURSED))))
4532 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4534 msg_print("The Figurine writhes and then shatters.");
4537 else if (q_ptr->ident & IDENT_CURSED)
4539 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4541 msg_print("You have a bad feeling about this.");
4547 /* Potions smash open */
4548 if (object_is_potion(q_ptr))
4550 if (hit_body || hit_wall || (randint(100) < j))
4554 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4556 msg_format("The %s shatters!", o_name);
4560 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4562 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4564 /* ToDo (Robert): fix the invulnerability */
4565 if (cave[y][x].m_idx &&
4566 is_friendly(&m_list[cave[y][x].m_idx]) &&
4570 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4572 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4574 msg_format("%^s gets angry!", m_name);
4577 set_hostile(&m_list[cave[y][x].m_idx]);
4588 if (return_when_thrown)
4590 int back_chance = randint(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4591 char o2_name[MAX_NLEN];
4592 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4595 if (boomerang) back_chance += 4+randint(5);
4596 if (super_boomerang) back_chance += 100;
4597 object_desc(o2_name, q_ptr, FALSE, 0);
4599 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4601 for (i = cur_dis-1;i>0;i--)
4603 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4605 char c = object_char(q_ptr);
4606 byte a = object_attr(q_ptr);
4608 /* Draw, Hilite, Fresh, Pause, Erase */
4609 print_rel(c, a, ny[i], nx[i]);
4610 move_cursor_relative(ny[i], nx[i]);
4612 Term_xtra(TERM_XTRA_DELAY, msec);
4613 lite_spot(ny[i], nx[i]);
4618 /* Pause anyway, for consistancy */
4619 Term_xtra(TERM_XTRA_DELAY, msec);
4622 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4625 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4627 msg_format("%s comes back to you.", o2_name);
4636 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4638 msg_format("%s backs, but you can't catch!", o2_name);
4644 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4646 msg_format("%s comes back.", o2_name);
4656 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4658 msg_format("%s doesn't back!", o2_name);
4665 if (item == INVEN_RARM || item == INVEN_LARM)
4667 /* Access the wield slot */
4668 o_ptr = &inventory[item];
4670 /* Wear the new stuff */
4671 object_copy(o_ptr, q_ptr);
4673 /* Increase the weight */
4674 p_ptr->total_weight += q_ptr->weight;
4676 /* Increment the equip counter by hand */
4679 /* Recalculate bonuses */
4680 p_ptr->update |= (PU_BONUS);
4682 /* Recalculate torch */
4683 p_ptr->update |= (PU_TORCH);
4685 /* Recalculate mana XXX */
4686 p_ptr->update |= (PU_MANA);
4689 p_ptr->window |= (PW_EQUIP);
4697 else if (equiped_item)
4703 /* Drop (or break) near that location */
4704 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4711 * Throw an object from the pack or floor.
4713 void do_cmd_throw(void)
4715 do_cmd_throw_aux(1, FALSE, 0);