4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Movement commands (part 2) */
19 void do_cmd_go_up(void)
24 cave_type *c_ptr = &cave[py][px];
25 feature_type *f_ptr = &f_info[c_ptr->feat];
29 if (p_ptr->special_defense & KATA_MUSOU)
31 set_action(ACTION_NONE);
35 if (!have_flag(f_ptr->flags, FF_LESS))
38 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
40 msg_print("I see no up staircase here.");
47 if (have_flag(f_ptr->flags, FF_QUEST))
51 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
52 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
54 msg_print("¾å¤Î³¬¤ËÅФä¿¡£");
56 msg_print("You enter the up staircase.");
61 p_ptr->inside_quest = c_ptr->special;
63 /* Activate the quest */
64 if (!quest[p_ptr->inside_quest].status)
66 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
70 if (!p_ptr->inside_quest)
76 p_ptr->leaving = TRUE;
91 quest_type *q_ptr = &quest[p_ptr->inside_quest];
93 /* Confirm leaving from once only quest */
94 if (confirm_quest && p_ptr->inside_quest &&
95 (q_ptr->type == QUEST_TYPE_RANDOM ||
96 (q_ptr->flags & QUEST_FLAG_ONCE &&
97 q_ptr->status != QUEST_STATUS_COMPLETED)))
100 msg_print("¤³¤Î³¬¤ò°ìÅÙµî¤ë¤ÈÆóÅÙ¤ÈÌá¤Ã¤ÆÍè¤é¤ì¤Þ¤»¤ó¡£");
101 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©")) go_up = TRUE;
103 msg_print("You can't come back here once you leave this floor.");
104 if (get_check("Really leave this floor? ")) go_up = TRUE;
113 /* Cancel the command */
116 /* Hack -- take a turn */
119 if (autosave_l) do_cmd_save_game(TRUE);
121 /* For a random quest */
122 if (p_ptr->inside_quest &&
123 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
127 p_ptr->inside_quest = 0;
130 /* For a fixed quest */
131 if (p_ptr->inside_quest &&
132 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
136 p_ptr->inside_quest = c_ptr->special;
141 /* For normal dungeon and random quest */
145 if (have_flag(f_ptr->flags, FF_SHAFT))
147 /* Create a way back */
148 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
154 /* Create a way back */
155 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
160 /* Get out from current dungeon */
161 if (dun_level - up_num < d_info[dungeon_type].mindepth)
166 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
168 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "climbed up the stairs to");
173 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
174 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
175 else if (up_num == dun_level)
176 msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
178 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
180 if (up_num == dun_level)
181 msg_print("You go back to the surface.");
183 msg_print("You enter a maze of up staircases.");
187 p_ptr->leaving = TRUE;
194 void do_cmd_go_down(void)
197 cave_type *c_ptr = &cave[py][px];
198 feature_type *f_ptr = &f_info[c_ptr->feat];
200 bool fall_trap = FALSE;
203 if (p_ptr->special_defense & KATA_MUSOU)
205 set_action(ACTION_NONE);
209 if (!have_flag(f_ptr->flags, FF_MORE))
212 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
214 msg_print("I see no down staircase here.");
220 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
223 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
228 /* Quest down stairs */
229 else if (have_flag(f_ptr->flags, FF_QUEST))
232 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
233 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
235 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
237 msg_print("You enter the down staircase.");
243 p_ptr->inside_quest = c_ptr->special;
245 /* Activate the quest */
246 if (!quest[p_ptr->inside_quest].status)
248 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
251 /* Leaving a quest */
252 if (!p_ptr->inside_quest)
258 p_ptr->leaving = TRUE;
266 int target_dungeon = 0;
270 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
272 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
275 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
277 msg_print("The entrance of this dungeon is closed!");
281 if (!max_dlv[target_dungeon])
284 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
285 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
287 msg_format("There is the entrance of %s (Danger level: %d)", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
288 if (!get_check("Do you really get in this dungeon? ")) return;
292 /* Save old player position */
295 dungeon_type = (byte)target_dungeon;
298 * Clear all saved floors
299 * and create a first saved floor
301 prepare_change_floor_mode(CFM_FIRST_FLOOR);
304 /* Hack -- take a turn */
307 if (autosave_l) do_cmd_save_game(TRUE);
310 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
315 /* Enter the dungeon just now */
316 p_ptr->enter_dungeon = TRUE;
317 down_num = d_info[dungeon_type].mindepth;
323 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
324 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
326 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fell through a trap door");
327 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed down the stairs to");
334 msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
336 msg_print("You deliberately jump through the trap door.");
345 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
347 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
353 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
354 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
356 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
358 msg_print("You enter a maze of down staircases.");
365 p_ptr->leaving = TRUE;
369 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
373 if (have_flag(f_ptr->flags, FF_SHAFT))
375 /* Create a way back */
376 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
380 /* Create a way back */
381 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
390 * Simple command to "search" for one turn
392 void do_cmd_search(void)
394 /* Allow repeated command */
397 /* Set repeat count */
398 command_rep = command_arg - 1;
400 /* Redraw the state */
401 p_ptr->redraw |= (PR_STATE);
416 * Determine if a grid contains a chest
418 static s16b chest_check(int y, int x)
420 cave_type *c_ptr = &cave[y][x];
422 s16b this_o_idx, next_o_idx = 0;
425 /* Scan all objects in the grid */
426 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
431 o_ptr = &o_list[this_o_idx];
433 /* Acquire next object */
434 next_o_idx = o_ptr->next_o_idx;
436 /* Skip unknown chests XXX XXX */
437 /* if (!o_ptr->marked) continue; */
439 /* Check for chest */
440 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
449 * Allocates objects upon opening a chest -BEN-
451 * Disperse treasures from the given chest, centered at (x,y).
453 * Small chests often contain "gold", while Large chests always contain
454 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
455 * and Steel chests contain 6 items. The "value" of the items in a
456 * chest is based on the "power" of the chest, which is in turn based
457 * on the level on which the chest is generated.
459 static void chest_death(bool scatter, int y, int x, s16b o_idx)
469 object_type *o_ptr = &o_list[o_idx];
472 /* Small chests often hold "gold" */
473 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
475 /* Determine how much to drop (see above) */
476 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
478 if (o_ptr->sval == SV_CHEST_KANDUME)
483 object_level = o_ptr->xtra3;
487 /* Determine the "value" of the items */
488 object_level = ABS(o_ptr->pval) + 10;
491 /* Zero pval means empty chest */
492 if (!o_ptr->pval) number = 0;
494 /* Opening a chest */
495 opening_chest = TRUE;
497 /* Drop some objects (non-chests) */
498 for (; number > 0; --number)
500 /* Get local object */
503 /* Wipe the object */
506 /* Small chests often drop gold */
507 if (small && (randint0(100) < 25))
510 if (!make_gold(q_ptr)) continue;
513 /* Otherwise drop an item */
516 /* Make a good object */
517 if (!make_object(q_ptr, mode)) continue;
520 /* If chest scatters its contents, pick any floor square. */
524 for (i = 0; i < 200; i++)
526 /* Pick a totally random spot. */
527 y = randint0(MAX_HGT);
528 x = randint0(MAX_WID);
530 /* Must be an empty floor. */
531 if (!cave_empty_bold(y, x)) continue;
533 /* Place the object there. */
534 drop_near(q_ptr, -1, y, x);
540 /* Normally, drop object near the chest. */
541 else drop_near(q_ptr, -1, y, x);
544 /* Reset the object level */
545 object_level = base_level;
547 /* No longer opening a chest */
548 opening_chest = FALSE;
559 * Chests have traps too.
561 * Exploding chest destroys contents (and traps).
562 * Note that the chest itself is never destroyed.
564 static void chest_trap(int y, int x, s16b o_idx)
568 object_type *o_ptr = &o_list[o_idx];
570 int mon_level = o_ptr->xtra3;
572 /* Ignore disarmed chests */
573 if (o_ptr->pval <= 0) return;
575 /* Obtain the traps */
576 trap = chest_traps[o_ptr->pval];
579 if (trap & (CHEST_LOSE_STR))
582 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
583 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
585 msg_print("A small needle has pricked you!");
586 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
589 (void)do_dec_stat(A_STR);
592 /* Lose constitution */
593 if (trap & (CHEST_LOSE_CON))
596 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
597 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
599 msg_print("A small needle has pricked you!");
600 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
603 (void)do_dec_stat(A_CON);
607 if (trap & (CHEST_POISON))
610 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
612 msg_print("A puff of green gas surrounds you!");
615 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
617 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
622 if (trap & (CHEST_PARALYZE))
625 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
627 msg_print("A puff of yellow gas surrounds you!");
631 if (!p_ptr->free_act)
633 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
637 /* Summon monsters */
638 if (trap & (CHEST_SUMMON))
640 int num = 2 + randint1(3);
642 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
644 msg_print("You are enveloped in a cloud of smoke!");
648 for (i = 0; i < num; i++)
650 if (randint1(100)<dun_level)
651 activate_hi_summon(py, px, FALSE);
653 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
657 /* Elemental summon. */
658 if (trap & (CHEST_E_SUMMON))
661 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
663 msg_print("Elemental beings appear to protect their treasures!");
665 for (i = 0; i < randint1(3) + 5; i++)
667 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
671 /* Force clouds, then summon birds. */
672 if (trap & (CHEST_BIRD_STORM))
675 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
677 msg_print("A storm of birds swirls around you!");
680 for (i = 0; i < randint1(3) + 3; i++)
681 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
683 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
685 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
689 /* Various colorful summonings. */
690 if (trap & (CHEST_H_SUMMON))
696 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
698 msg_print("Demons materialize in clouds of fire and brimstone!");
701 for (i = 0; i < randint1(3) + 2; i++)
703 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
704 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
708 /* Summon dragons. */
712 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
714 msg_print("Draconic forms loom out of the darkness!");
717 for (i = 0; i < randint1(3) + 2; i++)
719 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
723 /* Summon hybrids. */
727 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
729 msg_print("Creatures strange and twisted assault you!");
732 for (i = 0; i < randint1(5) + 3; i++)
734 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
738 /* Summon vortices (scattered) */
742 msg_print("±²´¬¤«¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
744 msg_print("Vortices coalesce and wreak destruction!");
747 for (i = 0; i < randint1(3) + 2; i++)
749 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
755 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
757 /* Determine how many nasty tricks can be played. */
758 int nasty_tricks_count = 4 + randint0(3);
762 msg_print("¶²¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
764 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
767 /* This is gonna hurt... */
768 for (; nasty_tricks_count > 0; nasty_tricks_count--)
770 /* ...but a high saving throw does help a little. */
771 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
774 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
776 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
778 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
781 if (!p_ptr->free_act)
782 (void)set_paralyzed(p_ptr->paralyzed + 2 +
785 (void)set_stun(p_ptr->stun + 10 +
788 else if (one_in_(3)) apply_disenchant(0);
791 (void)do_dec_stat(A_STR);
792 (void)do_dec_stat(A_DEX);
793 (void)do_dec_stat(A_CON);
794 (void)do_dec_stat(A_INT);
795 (void)do_dec_stat(A_WIS);
796 (void)do_dec_stat(A_CHR);
798 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
803 /* Aggravate monsters. */
804 if (trap & (CHEST_ALARM))
807 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
809 msg_print("An alarm sounds!");
811 aggravate_monsters(0);
815 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
818 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
819 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
821 msg_print("There is a sudden explosion!");
822 msg_print("Everything inside the chest is destroyed!");
826 sound(SOUND_EXPLODE);
828 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
830 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
834 /* Scatter contents. */
835 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
838 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
840 msg_print("The contents of the chest scatter all over the dungeon!");
842 chest_death(TRUE, y, x, o_idx);
849 * Attempt to open the given chest at the given location
851 * Assume there is no monster blocking the destination
853 * Returns TRUE if repeated commands may continue
855 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
863 object_type *o_ptr = &o_list[o_idx];
869 /* Attempt to unlock it */
872 /* Assume locked, and thus not open */
875 /* Get the "disarm" factor */
876 i = p_ptr->skill_dis;
878 /* Penalize some conditions */
879 if (p_ptr->blind || no_lite()) i = i / 10;
880 if (p_ptr->confused || p_ptr->image) i = i / 10;
882 /* Extract the difficulty */
885 /* Always have a small chance of success */
888 /* Success -- May still have traps */
889 if (randint0(100) < j)
892 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
894 msg_print("You have picked the lock.");
901 /* Failure -- Keep trying */
904 /* We may continue repeating */
906 if (flush_failure) flush();
908 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
910 msg_print("You failed to pick the lock.");
916 /* Allowed to open */
919 /* Apply chest traps, if any */
920 chest_trap(y, x, o_idx);
922 /* Let the Chest drop items */
923 chest_death(FALSE, y, x, o_idx);
931 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
934 * Return TRUE if the given feature is an open door
936 static bool is_open(int feat)
938 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
943 * Return the number of features around (or under) the character.
944 * Usually look for doors and floor traps.
946 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
948 int d, count, xx, yy;
950 /* Count how many matches */
953 /* Check around (and under) the character */
954 for (d = 0; d < 9; d++)
959 /* if not searching under player continue */
960 if ((d == 8) && !under) continue;
962 /* Extract adjacent (legal) location */
963 yy = py + ddy_ddd[d];
964 xx = px + ddx_ddd[d];
967 c_ptr = &cave[yy][xx];
969 /* Must have knowledge */
970 if (!(c_ptr->info & (CAVE_MARK))) continue;
972 /* Feature code (applying "mimic" field) */
973 feat = get_feat_mimic(c_ptr);
975 /* Not looking for this feature */
976 if (!((*test)(feat))) continue;
981 /* Remember the location. Only useful if only one match */
992 * Return the number of chests around (or under) the character.
993 * If requested, count only trapped chests.
995 static int count_chests(int *y, int *x, bool trapped)
1001 /* Count how many matches */
1004 /* Check around (and under) the character */
1005 for (d = 0; d < 9; d++)
1007 /* Extract adjacent (legal) location */
1008 int yy = py + ddy_ddd[d];
1009 int xx = px + ddx_ddd[d];
1011 /* No (visible) chest is there */
1012 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1014 /* Grab the object */
1015 o_ptr = &o_list[o_idx];
1018 if (o_ptr->pval == 0) continue;
1020 /* No (known) traps here */
1021 if (trapped && (!object_known_p(o_ptr) ||
1022 !chest_traps[o_ptr->pval])) continue;
1027 /* Remember the location. Only useful if only one match */
1038 * Convert an adjacent location to a direction.
1040 static int coords_to_dir(int y, int x)
1042 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1049 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1051 return d[dx + 1][dy + 1];
1054 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1058 * Perform the basic "open" command on doors
1060 * Assume destination is a closed/locked/jammed door
1062 * Assume there is no monster blocking the destination
1064 * Returns TRUE if repeated commands may continue
1066 static bool do_cmd_open_aux(int y, int x)
1070 /* Get requested grid */
1071 cave_type *c_ptr = &cave[y][x];
1073 feature_type *f_ptr = &f_info[c_ptr->feat];
1081 /* Seeing true feature code (ignore mimic) */
1084 if (!have_flag(f_ptr->flags, FF_OPEN))
1088 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1090 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1096 else if (f_ptr->power)
1099 i = p_ptr->skill_dis;
1101 /* Penalize some conditions */
1102 if (p_ptr->blind || no_lite()) i = i / 10;
1103 if (p_ptr->confused || p_ptr->image) i = i / 10;
1105 /* Extract the lock power */
1108 /* Extract the difficulty XXX XXX XXX */
1111 /* Always have a small chance of success */
1115 if (randint0(100) < j)
1119 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1121 msg_print("You have picked the lock.");
1125 cave_alter_feat(y, x, FF_OPEN);
1127 /* Update some things */
1128 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1131 sound(SOUND_OPENDOOR);
1141 if (flush_failure) flush();
1145 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1147 msg_print("You failed to pick the lock.");
1151 /* We may keep trying */
1160 cave_alter_feat(y, x, FF_OPEN);
1162 /* Update some things */
1163 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1166 sound(SOUND_OPENDOOR);
1176 * Open a closed/locked/jammed door or a closed/locked chest.
1178 * Unlocking a locked door/chest is worth one experience point.
1180 void do_cmd_open(void)
1188 if (p_ptr->special_defense & KATA_MUSOU)
1190 set_action(ACTION_NONE);
1193 #ifdef ALLOW_EASY_OPEN /* TNB */
1195 /* Option: Pick a direction */
1198 int num_doors, num_chests;
1200 /* Count closed doors (locked or jammed) */
1201 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1203 /* Count chests (locked) */
1204 num_chests = count_chests(&y, &x, FALSE);
1206 /* See if only one target */
1207 if (num_doors || num_chests)
1209 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1211 if (!too_many) command_dir = coords_to_dir(y, x);
1215 #endif /* ALLOW_EASY_OPEN -- TNB */
1217 /* Allow repeated command */
1220 /* Set repeat count */
1221 command_rep = command_arg - 1;
1223 /* Redraw the state */
1224 p_ptr->redraw |= (PR_STATE);
1226 /* Cancel the arg */
1230 /* Get a "repeated" direction */
1231 if (get_rep_dir(&dir, TRUE))
1236 /* Get requested location */
1240 /* Get requested grid */
1241 c_ptr = &cave[y][x];
1243 /* Feature code (applying "mimic" field) */
1244 feat = get_feat_mimic(c_ptr);
1246 /* Check for chest */
1247 o_idx = chest_check(y, x);
1249 /* Nothing useful */
1250 if (!is_closed_door(feat) && !o_idx)
1254 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1256 msg_print("You see nothing there to open.");
1261 /* Monster in the way */
1262 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1269 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1271 msg_print("There is a monster in the way!");
1282 /* Open the chest */
1283 more = do_cmd_open_chest(y, x, o_idx);
1290 more = do_cmd_open_aux(y, x);
1294 /* Cancel repeat unless we may continue */
1295 if (!more) disturb(0, 0);
1301 * Perform the basic "close" command
1303 * Assume destination is an open/broken door
1305 * Assume there is no monster blocking the destination
1307 * Returns TRUE if repeated commands may continue
1309 static bool do_cmd_close_aux(int y, int x)
1311 /* Get grid and contents */
1312 cave_type *c_ptr = &cave[y][x];
1313 s16b old_feat = c_ptr->feat;
1319 /* Seeing true feature code (ignore mimic) */
1322 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1324 /* Hack -- object in the way */
1325 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) && (feat_state(old_feat, FF_CLOSE) != old_feat))
1329 msg_print("²¿¤«¤¬¤Ä¤Ã¤«¤¨¤ÆÊĤޤé¤Ê¤¤¡£");
1331 msg_print("There seems stuck.");
1336 /* Close the door */
1337 cave_alter_feat(y, x, FF_CLOSE);
1340 if (old_feat == c_ptr->feat)
1344 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1346 msg_print("The door appears to be broken.");
1351 /* Update some things */
1352 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1355 sound(SOUND_SHUTDOOR);
1366 * Close an open door.
1368 void do_cmd_close(void)
1374 if (p_ptr->special_defense & KATA_MUSOU)
1376 set_action(ACTION_NONE);
1379 #ifdef ALLOW_EASY_OPEN /* TNB */
1381 /* Option: Pick a direction */
1384 /* Count open doors */
1385 if (count_dt(&y, &x, is_open, FALSE) == 1)
1387 command_dir = coords_to_dir(y, x);
1391 #endif /* ALLOW_EASY_OPEN -- TNB */
1393 /* Allow repeated command */
1396 /* Set repeat count */
1397 command_rep = command_arg - 1;
1399 /* Redraw the state */
1400 p_ptr->redraw |= (PR_STATE);
1402 /* Cancel the arg */
1406 /* Get a "repeated" direction */
1407 if (get_rep_dir(&dir,FALSE))
1412 /* Get requested location */
1416 /* Get grid and contents */
1417 c_ptr = &cave[y][x];
1419 /* Feature code (applying "mimic" field) */
1420 feat = get_feat_mimic(c_ptr);
1422 /* Require open/broken door */
1423 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1427 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1429 msg_print("You see nothing there to close.");
1433 /* Monster in the way */
1434 else if (c_ptr->m_idx)
1441 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1443 msg_print("There is a monster in the way!");
1450 /* Close the door */
1453 /* Close the door */
1454 more = do_cmd_close_aux(y, x);
1458 /* Cancel repeat unless we may continue */
1459 if (!more) disturb(0, 0);
1464 * Determine if a given grid may be "tunneled"
1466 static bool do_cmd_tunnel_test(int y, int x)
1468 cave_type *c_ptr = &cave[y][x];
1470 /* Must have knowledge */
1471 if (!(c_ptr->info & CAVE_MARK))
1475 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1477 msg_print("You see nothing there.");
1484 /* Must be a wall/door/etc */
1485 if (!have_flag(f_flags_grid(c_ptr), FF_TUNNEL))
1489 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1491 msg_print("You see nothing there to tunnel.");
1504 * Perform the basic "tunnel" command
1506 * Assumes that no monster is blocking the destination
1508 * Do not use twall anymore
1510 * Returns TRUE if repeated commands may continue
1512 static bool do_cmd_tunnel_aux(int y, int x)
1515 feature_type *f_ptr, *mimic_f_ptr;
1520 /* Verify legality */
1521 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1527 c_ptr = &cave[y][x];
1528 f_ptr = &f_info[c_ptr->feat];
1529 power = f_ptr->power;
1531 /* Feature code (applying "mimic" field) */
1532 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1534 name = f_name + mimic_f_ptr->name;
1539 if (have_flag(f_ptr->flags, FF_PERMANENT))
1542 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1545 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1547 msg_print("This seems to be permanent rock.");
1551 /* Map border (mimiccing Permanent wall) */
1555 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1557 msg_print("You can't tunnel through that!");
1563 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1566 if (p_ptr->skill_dig > randint0(20 * power))
1570 msg_format("%s¤ò¤¯¤º¤·¤¿¡£", name);
1572 msg_format("You have removed the %s.", name);
1575 /* Remove the feature */
1576 cave_alter_feat(y, x, FF_TUNNEL);
1578 /* Update some things */
1579 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1583 /* Message, keep digging */
1585 msg_format("%s¤ò¤¯¤º¤·¤Æ¤¤¤ë¡£", name);
1587 msg_format("You dig into the %s.", name);
1596 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1599 if (p_ptr->skill_dig > power + randint0(40 * power))
1602 if (tree) msg_format("%s¤òÀÚ¤êʧ¤Ã¤¿¡£", name);
1603 else msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1605 if (tree) msg_format("You have cleared away the %s.", name);
1606 else msg_print("You have finished the tunnel.");
1609 /* Remove the feature */
1610 cave_alter_feat(y, x, FF_TUNNEL);
1612 /* Update some things */
1613 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1615 chg_virtue(V_DILIGENCE, 1);
1616 chg_virtue(V_NATURE, -1);
1624 /* We may continue chopping */
1626 msg_format("%s¤òÀڤäƤ¤¤ë¡£", name);
1628 msg_format("You chop away at the %s.", name);
1630 /* Occasional Search XXX XXX */
1631 if (randint0(100) < 25) search();
1635 /* We may continue tunelling */
1637 msg_format("%s¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£", name);
1639 msg_format("You tunnel into the %s.", name);
1647 if (is_hidden_door(c_ptr))
1649 /* Occasional Search XXX XXX */
1650 if (randint0(100) < 25) search();
1659 * Tunnels through "walls" (including rubble and closed doors)
1661 * Note that you must tunnel in order to hit invisible monsters
1662 * in walls, though moving into walls still takes a turn anyway.
1664 * Digging is very difficult without a "digger" weapon, but can be
1665 * accomplished by strong players using heavy weapons.
1667 void do_cmd_tunnel(void)
1677 if (p_ptr->special_defense & KATA_MUSOU)
1679 set_action(ACTION_NONE);
1682 /* Allow repeated command */
1685 /* Set repeat count */
1686 command_rep = command_arg - 1;
1688 /* Redraw the state */
1689 p_ptr->redraw |= (PR_STATE);
1691 /* Cancel the arg */
1695 /* Get a direction to tunnel, or Abort */
1696 if (get_rep_dir(&dir,FALSE))
1703 c_ptr = &cave[y][x];
1705 /* Feature code (applying "mimic" field) */
1706 feat = get_feat_mimic(c_ptr);
1708 /* No tunnelling through doors */
1709 if (have_flag(f_info[feat].flags, FF_DOOR))
1713 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1715 msg_print("You cannot tunnel through doors.");
1719 /* No tunnelling through most features */
1720 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1723 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1725 msg_print("You can't tunnel through that.");
1729 /* A monster is in the way */
1730 else if (c_ptr->m_idx)
1737 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1739 msg_print("There is a monster in the way!");
1749 /* Tunnel through walls */
1750 more = do_cmd_tunnel_aux(y, x);
1754 /* Cancel repetition unless we can continue */
1755 if (!more) disturb(0, 0);
1759 #ifdef ALLOW_EASY_OPEN /* TNB */
1764 * If there is a jammed/closed/locked door at the given location,
1765 * then attempt to unlock/open it. Return TRUE if an attempt was
1766 * made (successful or not), otherwise return FALSE.
1768 * The code here should be nearly identical to that in
1769 * do_cmd_open_test() and do_cmd_open_aux().
1771 bool easy_open_door(int y, int x)
1775 cave_type *c_ptr = &cave[y][x];
1776 feature_type *f_ptr = &f_info[c_ptr->feat];
1778 /* Must be a closed door */
1779 if (!is_closed_door(c_ptr->feat))
1786 if (!have_flag(f_ptr->flags, FF_OPEN))
1790 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1792 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1798 else if (f_ptr->power)
1801 i = p_ptr->skill_dis;
1803 /* Penalize some conditions */
1804 if (p_ptr->blind || no_lite()) i = i / 10;
1805 if (p_ptr->confused || p_ptr->image) i = i / 10;
1807 /* Extract the lock power */
1810 /* Extract the difficulty XXX XXX XXX */
1813 /* Always have a small chance of success */
1817 if (randint0(100) < j)
1821 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1823 msg_print("You have picked the lock.");
1828 cave_alter_feat(y, x, FF_OPEN);
1830 /* Update some things */
1831 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1834 sound(SOUND_OPENDOOR);
1844 if (flush_failure) flush();
1848 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1850 msg_print("You failed to pick the lock.");
1860 cave_alter_feat(y, x, FF_OPEN);
1862 /* Update some things */
1863 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1866 sound(SOUND_OPENDOOR);
1873 #endif /* ALLOW_EASY_OPEN -- TNB */
1877 * Perform the basic "disarm" command
1879 * Assume destination is a visible trap
1881 * Assume there is no monster blocking the destination
1883 * Returns TRUE if repeated commands may continue
1885 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1891 object_type *o_ptr = &o_list[o_idx];
1897 /* Get the "disarm" factor */
1898 i = p_ptr->skill_dis;
1900 /* Penalize some conditions */
1901 if (p_ptr->blind || no_lite()) i = i / 10;
1902 if (p_ptr->confused || p_ptr->image) i = i / 10;
1904 /* Extract the difficulty */
1905 j = i - o_ptr->pval;
1907 /* Always have a small chance of success */
1910 /* Must find the trap first. */
1911 if (!object_known_p(o_ptr))
1914 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
1916 msg_print("I don't see any traps.");
1921 /* Already disarmed/unlocked */
1922 else if (o_ptr->pval <= 0)
1925 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1927 msg_print("The chest is not trapped.");
1932 /* No traps to find. */
1933 else if (!chest_traps[o_ptr->pval])
1936 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1938 msg_print("The chest is not trapped.");
1943 /* Success (get a lot of experience) */
1944 else if (randint0(100) < j)
1947 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
1949 msg_print("You have disarmed the chest.");
1952 gain_exp(o_ptr->pval);
1953 o_ptr->pval = (0 - o_ptr->pval);
1956 /* Failure -- Keep trying */
1957 else if ((i > 5) && (randint1(i) > 5))
1959 /* We may keep trying */
1961 if (flush_failure) flush();
1963 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
1965 msg_print("You failed to disarm the chest.");
1970 /* Failure -- Set off the trap */
1974 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
1976 msg_print("You set off a trap!");
1980 chest_trap(y, x, o_idx);
1989 * Perform the basic "disarm" command
1991 * Assume destination is a visible trap
1993 * Assume there is no monster blocking the destination
1995 * Returns TRUE if repeated commands may continue
1997 #ifdef ALLOW_EASY_DISARM /* TNB */
1999 bool do_cmd_disarm_aux(int y, int x, int dir)
2001 #else /* ALLOW_EASY_DISARM -- TNB */
2003 static bool do_cmd_disarm_aux(int y, int x, int dir)
2005 #endif /* ALLOW_EASY_DISARM -- TNB */
2007 /* Get grid and contents */
2008 cave_type *c_ptr = &cave[y][x];
2011 feature_type *f_ptr = &f_info[c_ptr->feat];
2013 /* Access trap name */
2014 cptr name = (f_name + f_ptr->name);
2016 /* Extract trap "power" */
2017 int power = f_ptr->power;
2021 /* Get the "disarm" factor */
2022 int i = p_ptr->skill_dis;
2029 /* Penalize some conditions */
2030 if (p_ptr->blind || no_lite()) i = i / 10;
2031 if (p_ptr->confused || p_ptr->image) i = i / 10;
2033 /* Extract the difficulty */
2036 /* Always have a small chance of success */
2040 if (randint0(100) < j)
2044 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2046 msg_format("You have disarmed the %s.", name);
2052 /* Remove the trap */
2053 cave_alter_feat(y, x, FF_DISARM);
2055 #ifdef ALLOW_EASY_DISARM /* TNB */
2057 /* Move the player onto the trap */
2058 move_player(dir, easy_disarm, FALSE);
2060 #else /* ALLOW_EASY_DISARM -- TNB */
2062 /* move the player onto the trap grid */
2063 move_player(dir, FALSE, FALSE);
2065 #endif /* ALLOW_EASY_DISARM -- TNB */
2068 /* Failure -- Keep trying */
2069 else if ((i > 5) && (randint1(i) > 5))
2072 if (flush_failure) flush();
2076 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2078 msg_format("You failed to disarm the %s.", name);
2081 /* We may keep trying */
2085 /* Failure -- Set off the trap */
2090 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2092 msg_format("You set off the %s!", name);
2095 #ifdef ALLOW_EASY_DISARM /* TNB */
2097 /* Move the player onto the trap */
2098 move_player(dir, easy_disarm, FALSE);
2100 #else /* ALLOW_EASY_DISARM -- TNB */
2102 /* Move the player onto the trap */
2103 move_player(dir, FALSE, FALSE);
2105 #endif /* ALLOW_EASY_DISARM -- TNB */
2114 * Disarms a trap, or chest
2116 void do_cmd_disarm(void)
2124 if (p_ptr->special_defense & KATA_MUSOU)
2126 set_action(ACTION_NONE);
2129 #ifdef ALLOW_EASY_DISARM /* TNB */
2131 /* Option: Pick a direction */
2134 int num_traps, num_chests;
2136 /* Count visible traps */
2137 num_traps = count_dt(&y, &x, is_trap, TRUE);
2139 /* Count chests (trapped) */
2140 num_chests = count_chests(&y, &x, TRUE);
2142 /* See if only one target */
2143 if (num_traps || num_chests)
2145 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2147 if (!too_many) command_dir = coords_to_dir(y, x);
2151 #endif /* ALLOW_EASY_DISARM -- TNB */
2153 /* Allow repeated command */
2156 /* Set repeat count */
2157 command_rep = command_arg - 1;
2159 /* Redraw the state */
2160 p_ptr->redraw |= (PR_STATE);
2162 /* Cancel the arg */
2166 /* Get a direction (or abort) */
2167 if (get_rep_dir(&dir,TRUE))
2176 /* Get grid and contents */
2177 c_ptr = &cave[y][x];
2179 /* Feature code (applying "mimic" field) */
2180 feat = get_feat_mimic(c_ptr);
2182 /* Check for chests */
2183 o_idx = chest_check(y, x);
2186 if (!is_trap(feat) && !o_idx)
2190 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2192 msg_print("You see nothing there to disarm.");
2197 /* Monster in the way */
2198 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2202 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2204 msg_print("There is a monster in the way!");
2215 /* Disarm the chest */
2216 more = do_cmd_disarm_chest(y, x, o_idx);
2222 /* Disarm the trap */
2223 more = do_cmd_disarm_aux(y, x, dir);
2227 /* Cancel repeat unless told not to */
2228 if (!more) disturb(0, 0);
2233 * Perform the basic "bash" command
2235 * Assume destination is a closed/locked/jammed door
2237 * Assume there is no monster blocking the destination
2239 * Returns TRUE if repeated commands may continue
2241 static bool do_cmd_bash_aux(int y, int x, int dir)
2244 cave_type *c_ptr = &cave[y][x];
2246 /* Hack -- Bash power based on strength */
2247 /* (Ranges from 3 to 20 to 100 to 200) */
2248 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2250 /* Extract door power */
2251 int temp = f_info[c_ptr->feat].power;
2255 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2262 msg_format("%s¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª", name);
2264 msg_format("You smash into the %s!", name);
2267 /* Compare bash power to door power XXX XXX XXX */
2268 temp = (bash - (temp * 10));
2270 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2272 /* Hack -- always have a chance */
2273 if (temp < 1) temp = 1;
2275 /* Hack -- attempt to bash down the door */
2276 if (randint0(100) < temp)
2280 msg_format("%s¤ò²õ¤·¤¿¡ª", name);
2282 msg_format("The %s crashes open!", name);
2286 /* Break down the door */
2287 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat))
2289 cave_alter_feat(y, x, FF_BASH);
2295 cave_alter_feat(y, x, FF_OPEN);
2299 sound(SOUND_OPENDOOR);
2301 /* Hack -- Fall through the door */
2302 move_player(dir, FALSE, FALSE);
2304 /* Update some things */
2305 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2306 p_ptr->update |= (PU_DISTANCE);
2309 /* Saving throw against stun */
2310 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2315 msg_format("¤³¤Î%s¤Ï´è¾æ¤À¡£", name);
2317 msg_format("The %s holds firm.", name);
2321 /* Allow repeated bashing */
2325 /* High dexterity yields coolness */
2330 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2332 msg_print("You are off-balance.");
2336 /* Hack -- Lose balance ala paralysis */
2337 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2346 * Bash open a door, success based on character strength
2348 * For a closed door, pval is positive if locked; negative if stuck.
2350 * For an open door, pval is positive for a broken door.
2352 * A closed door can be opened - harder if locked. Any door might be
2353 * bashed open (and thereby broken). Bashing a door is (potentially)
2354 * faster! You move into the door way. To open a stuck door, it must
2355 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2357 * Creatures can also open or bash doors, see elsewhere.
2359 void do_cmd_bash(void)
2368 if (p_ptr->special_defense & KATA_MUSOU)
2370 set_action(ACTION_NONE);
2373 /* Allow repeated command */
2376 /* Set repeat count */
2377 command_rep = command_arg - 1;
2379 /* Redraw the state */
2380 p_ptr->redraw |= (PR_STATE);
2382 /* Cancel the arg */
2386 /* Get a "repeated" direction */
2387 if (get_rep_dir(&dir,FALSE))
2396 c_ptr = &cave[y][x];
2398 /* Feature code (applying "mimic" field) */
2399 feat = get_feat_mimic(c_ptr);
2401 /* Nothing useful */
2402 if (!have_flag(f_info[feat].flags, FF_BASH))
2406 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2408 msg_print("You see nothing there to bash.");
2413 /* Monster in the way */
2414 else if (c_ptr->m_idx)
2421 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2423 msg_print("There is a monster in the way!");
2431 /* Bash a closed door */
2435 more = do_cmd_bash_aux(y, x, dir);
2439 /* Unless valid action taken, cancel bash */
2440 if (!more) disturb(0, 0);
2445 * Manipulate an adjacent grid in some way
2447 * Attack monsters, tunnel through walls, disarm traps, open doors.
2449 * Consider confusion XXX XXX XXX
2451 * This command must always take a turn, to prevent free detection
2452 * of invisible monsters.
2454 void do_cmd_alter(void)
2463 if (p_ptr->special_defense & KATA_MUSOU)
2465 set_action(ACTION_NONE);
2468 /* Allow repeated command */
2471 /* Set repeat count */
2472 command_rep = command_arg - 1;
2474 /* Redraw the state */
2475 p_ptr->redraw |= (PR_STATE);
2477 /* Cancel the arg */
2481 /* Get a direction */
2482 if (get_rep_dir(&dir,TRUE))
2485 feature_type *f_ptr;
2492 c_ptr = &cave[y][x];
2494 /* Feature code (applying "mimic" field) */
2495 feat = get_feat_mimic(c_ptr);
2496 f_ptr = &f_info[feat];
2501 /* Attack monsters */
2509 else if (have_flag(f_ptr->flags, FF_OPEN))
2511 more = do_cmd_open_aux(y, x);
2514 /* Bash jammed doors */
2515 else if (have_flag(f_ptr->flags, FF_BASH))
2517 more = do_cmd_bash_aux(y, x, dir);
2520 /* Tunnel through walls */
2521 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2523 more = do_cmd_tunnel_aux(y, x);
2526 /* Close open doors */
2527 else if (have_flag(f_ptr->flags, FF_CLOSE))
2529 more = do_cmd_close_aux(y, x);
2533 else if (have_flag(f_ptr->flags, FF_DISARM))
2535 more = do_cmd_disarm_aux(y, x, dir);
2543 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2545 msg_print("You attack the empty air.");
2551 /* Cancel repetition unless we can continue */
2552 if (!more) disturb(0, 0);
2557 * Find the index of some "spikes", if possible.
2559 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2561 static bool get_spike(int *ip)
2565 /* Check every item in the pack */
2566 for (i = 0; i < INVEN_PACK; i++)
2568 object_type *o_ptr = &inventory[i];
2570 /* Skip non-objects */
2571 if (!o_ptr->k_idx) continue;
2573 /* Check the "tval" code */
2574 if (o_ptr->tval == TV_SPIKE)
2576 /* Save the spike index */
2590 * Jam a closed door with a spike
2592 * This command may NOT be repeated
2594 void do_cmd_spike(void)
2598 if (p_ptr->special_defense & KATA_MUSOU)
2600 set_action(ACTION_NONE);
2603 /* Get a "repeated" direction */
2604 if (get_rep_dir(&dir,FALSE))
2614 /* Get grid and contents */
2615 c_ptr = &cave[y][x];
2617 /* Feature code (applying "mimic" field) */
2618 feat = get_feat_mimic(c_ptr);
2620 /* Require closed door */
2621 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2625 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2627 msg_print("You see nothing there to spike.");
2633 else if (!get_spike(&item))
2637 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2639 msg_print("You have no spikes!");
2643 /* Is a monster in the way? */
2644 else if (c_ptr->m_idx)
2651 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2653 msg_print("There is a monster in the way!");
2666 /* Successful jamming */
2668 msg_format("%s¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£", f_name + f_info[feat].name);
2670 msg_format("You jam the %s with a spike.", f_name + f_info[feat].name);
2673 cave_alter_feat(y, x, FF_SPIKE);
2675 /* Use up, and describe, a single spike, from the bottom */
2676 inven_item_increase(item, -1);
2677 inven_item_describe(item);
2678 inven_item_optimize(item);
2686 * Support code for the "Walk" and "Jump" commands
2688 void do_cmd_walk(int pickup)
2695 /* Allow repeated command */
2698 /* Set repeat count */
2699 command_rep = command_arg - 1;
2701 /* Redraw the state */
2702 p_ptr->redraw |= (PR_STATE);
2704 /* Cancel the arg */
2708 /* Get a "repeated" direction */
2709 if (get_rep_dir(&dir,FALSE))
2714 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2716 set_action(ACTION_NONE);
2719 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2720 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2721 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2723 /* Actually move the character */
2724 move_player(dir, pickup, FALSE);
2726 /* Allow more walking */
2730 /* Hack again -- Is there a special encounter ??? */
2731 if (p_ptr->wild_mode && !have_flag(f_flags_bold(py, px), FF_TOWN))
2733 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2736 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2738 /* Inform the player of his horrible fate :=) */
2740 msg_print("½±·â¤À¡ª");
2742 msg_print("You are ambushed !");
2745 /* Go into large wilderness view */
2746 p_ptr->oldpy = randint1(MAX_HGT-2);
2747 p_ptr->oldpx = randint1(MAX_WID-2);
2750 /* Give first move to monsters */
2753 /* HACk -- set the encouter flag for the wilderness generation */
2754 generate_encounter = TRUE;
2758 /* Cancel repeat unless we may continue */
2759 if (!more) disturb(0, 0);
2767 void do_cmd_run(void)
2771 /* Hack -- no running when confused */
2772 if (p_ptr->confused)
2775 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2777 msg_print("You are too confused!");
2783 if (p_ptr->special_defense & KATA_MUSOU)
2785 set_action(ACTION_NONE);
2788 /* Get a "repeated" direction */
2789 if (get_rep_dir(&dir,FALSE))
2791 /* Hack -- Set the run counter */
2792 running = (command_arg ? command_arg : 1000);
2802 * Stay still. Search. Enter stores.
2803 * Pick up treasure if "pickup" is true.
2805 void do_cmd_stay(int pickup)
2807 cave_type *c_ptr = &cave[py][px];
2808 feature_type *f_ptr = &f_info[c_ptr->feat];
2810 /* Allow repeated command */
2813 /* Set repeat count */
2814 command_rep = command_arg - 1;
2816 /* Redraw the state */
2817 p_ptr->redraw |= (PR_STATE);
2819 /* Cancel the arg */
2828 /* Spontaneous Searching */
2829 if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
2834 /* Continuous Searching */
2835 if (p_ptr->action == ACTION_SEARCH)
2841 /* Handle "objects" */
2845 /* Hack -- enter a store if we are on one */
2846 if (have_flag(f_ptr->flags, FF_STORE))
2852 /* Hack -- enter store */
2853 command_new = SPECIAL_KEY_STORE;
2856 /* Hack -- enter a building if we are on one -KMW- */
2857 else if (have_flag(f_ptr->flags, FF_BLDG))
2863 /* Hack -- enter building */
2864 command_new = SPECIAL_KEY_BUILDING;
2867 /* Exit a quest if reach the quest exit */
2868 else if (have_flag(f_ptr->flags, FF_QUEST_EXIT))
2870 int q_index = p_ptr->inside_quest;
2872 /* Was quest completed? */
2873 if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
2875 quest[q_index].status = QUEST_STATUS_COMPLETED;
2876 quest[q_index].complev = (byte)p_ptr->lev;
2878 msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
2880 msg_print("You accomplished your quest!");
2886 leave_quest_check();
2888 p_ptr->inside_quest = cave[py][px].special;
2893 p_ptr->leaving = TRUE;
2900 * Resting allows a player to safely restore his hp -RAK-
2902 void do_cmd_rest(void)
2905 set_action(ACTION_NONE);
2907 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
2912 /* Prompt for time if needed */
2913 if (command_arg <= 0)
2916 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
2918 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
2925 strcpy(out_val, "&");
2927 /* Ask for duration */
2928 if (!get_string(p, out_val, 4)) return;
2930 /* Rest until done */
2931 if (out_val[0] == '&')
2937 else if (out_val[0] == '*')
2945 command_arg = atoi(out_val);
2946 if (command_arg <= 0) return;
2952 if (command_arg > 9999) command_arg = 9999;
2954 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2956 /* Take a turn XXX XXX XXX (?) */
2959 /* The sin of sloth */
2960 if (command_arg > 100)
2961 chg_virtue(V_DILIGENCE, -1);
2963 /* Why are you sleeping when there's no need? WAKE UP!*/
2964 if ((p_ptr->chp == p_ptr->mhp) &&
2965 (p_ptr->csp == p_ptr->msp) &&
2966 !p_ptr->blind && !p_ptr->confused &&
2967 !p_ptr->poisoned && !p_ptr->afraid &&
2968 !p_ptr->stun && !p_ptr->cut &&
2969 !p_ptr->slow && !p_ptr->paralyzed &&
2970 !p_ptr->image && !p_ptr->word_recall &&
2971 !p_ptr->alter_reality)
2972 chg_virtue(V_DILIGENCE, -1);
2974 /* Save the rest code */
2975 resting = command_arg;
2976 p_ptr->action = ACTION_REST;
2978 /* Recalculate bonuses */
2979 p_ptr->update |= (PU_BONUS);
2981 /* Redraw the state */
2982 p_ptr->redraw |= (PR_STATE);
2993 * Determines the odds of an object breaking when thrown at a monster
2995 * Note that artifacts never break, see the "drop_near()" function.
2997 static int breakage_chance(object_type *o_ptr)
2999 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
3001 /* Examine the item type */
3002 switch (o_ptr->tval)
3018 /* Sometimes break */
3023 return (20 - archer_bonus * 2);
3028 return (10 - archer_bonus);
3035 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3039 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3041 u32b flgs[TR_FLAG_SIZE];
3043 /* Extract the flags */
3044 object_flags(o_ptr, flgs);
3046 /* Some "weapons" and "ammo" do extra damage */
3047 switch (o_ptr->tval)
3054 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3055 (r_ptr->flags3 & RF3_ANIMAL))
3057 if (m_ptr->ml && is_original_ap(m_ptr))
3059 r_ptr->r_flags3 |= RF3_ANIMAL;
3062 if (mult < 17) mult = 17;
3066 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3067 (r_ptr->flags3 & RF3_ANIMAL))
3069 if (m_ptr->ml && is_original_ap(m_ptr))
3071 r_ptr->r_flags3 |= RF3_ANIMAL;
3074 if (mult < 27) mult = 27;
3078 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3079 (r_ptr->flags3 & RF3_EVIL))
3081 if (m_ptr->ml && is_original_ap(m_ptr))
3083 r_ptr->r_flags3 |= RF3_EVIL;
3086 if (mult < 15) mult = 15;
3090 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3091 (r_ptr->flags3 & RF3_EVIL))
3093 if (m_ptr->ml && is_original_ap(m_ptr))
3095 r_ptr->r_flags3 |= RF3_EVIL;
3098 if (mult < 25) mult = 25;
3102 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3103 (r_ptr->flags2 & RF2_HUMAN))
3105 if (m_ptr->ml && is_original_ap(m_ptr))
3107 r_ptr->r_flags2 |= RF2_HUMAN;
3110 if (mult < 17) mult = 17;
3114 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3115 (r_ptr->flags2 & RF2_HUMAN))
3117 if (m_ptr->ml && is_original_ap(m_ptr))
3119 r_ptr->r_flags2 |= RF2_HUMAN;
3122 if (mult < 27) mult = 27;
3126 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3127 (r_ptr->flags3 & RF3_UNDEAD))
3129 if (m_ptr->ml && is_original_ap(m_ptr))
3131 r_ptr->r_flags3 |= RF3_UNDEAD;
3134 if (mult < 20) mult = 20;
3138 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3139 (r_ptr->flags3 & RF3_UNDEAD))
3141 if (m_ptr->ml && is_original_ap(m_ptr))
3143 r_ptr->r_flags3 |= RF3_UNDEAD;
3146 if (mult < 30) mult = 30;
3150 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3151 (r_ptr->flags3 & RF3_DEMON))
3153 if (m_ptr->ml && is_original_ap(m_ptr))
3155 r_ptr->r_flags3 |= RF3_DEMON;
3158 if (mult < 20) mult = 20;
3162 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3163 (r_ptr->flags3 & RF3_DEMON))
3165 if (m_ptr->ml && is_original_ap(m_ptr))
3167 r_ptr->r_flags3 |= RF3_DEMON;
3170 if (mult < 30) mult = 30;
3174 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3175 (r_ptr->flags3 & RF3_ORC))
3177 if (m_ptr->ml && is_original_ap(m_ptr))
3179 r_ptr->r_flags3 |= RF3_ORC;
3182 if (mult < 20) mult = 20;
3186 if ((have_flag(flgs, TR_KILL_ORC)) &&
3187 (r_ptr->flags3 & RF3_ORC))
3189 if (m_ptr->ml && is_original_ap(m_ptr))
3191 r_ptr->r_flags3 |= RF3_ORC;
3194 if (mult < 30) mult = 30;
3198 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3199 (r_ptr->flags3 & RF3_TROLL))
3201 if (m_ptr->ml && is_original_ap(m_ptr))
3203 r_ptr->r_flags3 |= RF3_TROLL;
3206 if (mult < 20) mult = 20;
3210 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3211 (r_ptr->flags3 & RF3_TROLL))
3213 if (m_ptr->ml && is_original_ap(m_ptr))
3215 r_ptr->r_flags3 |= RF3_TROLL;
3218 if (mult < 30) mult = 30;
3222 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3223 (r_ptr->flags3 & RF3_GIANT))
3225 if (m_ptr->ml && is_original_ap(m_ptr))
3227 r_ptr->r_flags3 |= RF3_GIANT;
3230 if (mult < 20) mult = 20;
3234 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3235 (r_ptr->flags3 & RF3_GIANT))
3237 if (m_ptr->ml && is_original_ap(m_ptr))
3239 r_ptr->r_flags3 |= RF3_GIANT;
3242 if (mult < 30) mult = 30;
3246 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3247 (r_ptr->flags3 & RF3_DRAGON))
3249 if (m_ptr->ml && is_original_ap(m_ptr))
3251 r_ptr->r_flags3 |= RF3_DRAGON;
3254 if (mult < 20) mult = 20;
3257 /* Execute Dragon */
3258 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3259 (r_ptr->flags3 & RF3_DRAGON))
3261 if (m_ptr->ml && is_original_ap(m_ptr))
3263 r_ptr->r_flags3 |= RF3_DRAGON;
3266 if (mult < 30) mult = 30;
3268 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3269 (m_ptr->r_idx == MON_SMAUG) &&
3270 (inventory[INVEN_BOW].name1 == ART_BARD))
3275 if (have_flag(flgs, TR_BRAND_ACID))
3277 /* Notice immunity */
3278 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3280 if (m_ptr->ml && is_original_ap(m_ptr))
3282 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3286 /* Otherwise, take the damage */
3289 if (mult < 17) mult = 17;
3294 if (have_flag(flgs, TR_BRAND_ELEC))
3296 /* Notice immunity */
3297 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3299 if (m_ptr->ml && is_original_ap(m_ptr))
3301 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3305 /* Otherwise, take the damage */
3308 if (mult < 17) mult = 17;
3313 if (have_flag(flgs, TR_BRAND_FIRE))
3315 /* Notice immunity */
3316 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3318 if (m_ptr->ml && is_original_ap(m_ptr))
3320 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3324 /* Otherwise, take the damage */
3327 if (r_ptr->flags3 & RF3_HURT_FIRE)
3329 if (mult < 25) mult = 25;
3330 if (m_ptr->ml && is_original_ap(m_ptr))
3332 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3335 else if (mult < 17) mult = 17;
3340 if (have_flag(flgs, TR_BRAND_COLD))
3342 /* Notice immunity */
3343 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3345 if (m_ptr->ml && is_original_ap(m_ptr))
3347 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3350 /* Otherwise, take the damage */
3353 if (r_ptr->flags3 & RF3_HURT_COLD)
3355 if (mult < 25) mult = 25;
3356 if (m_ptr->ml && is_original_ap(m_ptr))
3358 r_ptr->r_flags3 |= RF3_HURT_COLD;
3361 else if (mult < 17) mult = 17;
3365 /* Brand (Poison) */
3366 if (have_flag(flgs, TR_BRAND_POIS))
3368 /* Notice immunity */
3369 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3371 if (m_ptr->ml && is_original_ap(m_ptr))
3373 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3377 /* Otherwise, take the damage */
3380 if (mult < 17) mult = 17;
3384 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3386 p_ptr->csp -= (1+(p_ptr->msp / 30));
3387 p_ptr->redraw |= (PR_MANA);
3388 mult = mult * 5 / 2;
3394 /* Return the total damage */
3395 return (tdam * mult / 10);
3400 * Fire an object from the pack or floor.
3402 * You may only fire items that "match" your missile launcher.
3404 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3406 * See "calc_bonuses()" for more calculations and such.
3408 * Note that "firing" a missile is MUCH better than "throwing" it.
3410 * Note: "unseen" monsters are very hard to hit.
3412 * Objects are more likely to break if they "attempt" to hit a monster.
3414 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3416 * The "extra shot" code works by decreasing the amount of energy
3417 * required to make each shot, spreading the shots out over time.
3419 * Note that when firing missiles, the launcher multiplier is applied
3420 * after all the bonuses are added in, making multipliers very useful.
3422 * Note that Bows of "Extra Might" get extra range and an extra bonus
3423 * for the damage multiplier.
3425 * Note that Bows of "Extra Shots" give an extra shot.
3427 void do_cmd_fire_aux(int item, object_type *j_ptr)
3430 int j, y, x, ny, nx, ty, tx;
3431 int tdam, tdis, thits, tmul;
3433 int cur_dis, visible;
3440 bool hit_body = FALSE;
3442 char o_name[MAX_NLEN];
3444 int msec = delay_factor * delay_factor * delay_factor;
3447 bool stick_to = FALSE;
3449 /* Access the item (if in the pack) */
3452 o_ptr = &inventory[item];
3456 o_ptr = &o_list[0 - item];
3459 /* Describe the object */
3460 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3463 /* Use the proper number of shots */
3464 thits = p_ptr->num_fire;
3466 /* Use a base distance */
3469 /* Base damage from thrown object plus launcher bonus */
3470 tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3472 /* Actually "fire" the object */
3473 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3474 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3475 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3477 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3479 energy_use = bow_energy(j_ptr->sval);
3480 tmul = bow_tmul(j_ptr->sval);
3482 /* Get extra "power" from "extra might" */
3483 if (p_ptr->xtra_might) tmul++;
3485 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3487 /* Boost the damage */
3492 tdis = 10 + tmul/40;
3493 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3496 project_length = tdis + 1;
3498 /* Get a direction (or cancel) */
3499 if (!get_aim_dir(&dir))
3503 /* need not to reset project_length (already did)*/
3508 /* Get local object */
3511 /* Obtain a local object */
3512 object_copy(q_ptr, o_ptr);
3517 /* Reduce and describe inventory */
3520 inven_item_increase(item, -1);
3521 inven_item_describe(item);
3522 inven_item_optimize(item);
3525 /* Reduce and describe floor item */
3528 floor_item_increase(0 - item, -1);
3529 floor_item_optimize(0 - item);
3537 /* Take a (partial) turn */
3538 energy_use = (energy_use / thits);
3541 /* Start at the player */
3545 /* Predict the "target" location */
3546 tx = px + 99 * ddx[dir];
3547 ty = py + 99 * ddy[dir];
3549 /* Check for "target request" */
3550 if ((dir == 5) && target_okay())
3556 project_length = 0; /* reset to default */
3558 /* Hack -- Handle stuff */
3562 /* Travel until stopped */
3563 for (cur_dis = 0; cur_dis <= tdis; )
3565 /* Hack -- Stop at the target */
3566 if ((y == ty) && (x == tx)) break;
3568 /* Calculate the new location (see "project()") */
3571 mmove2(&ny, &nx, py, px, ty, tx);
3573 /* Stopped by walls/doors */
3574 if (!have_flag(f_flags_bold(ny, nx), FF_PROJECT) && !cave[ny][nx].m_idx) break;
3576 /* Advance the distance */
3580 /* The player can see the (on screen) missile */
3581 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3583 char c = object_char(q_ptr);
3584 byte a = object_attr(q_ptr);
3586 /* Draw, Hilite, Fresh, Pause, Erase */
3587 print_rel(c, a, ny, nx);
3588 move_cursor_relative(ny, nx);
3590 Term_xtra(TERM_XTRA_DELAY, msec);
3595 /* The player cannot see the missile */
3598 /* Pause anyway, for consistancy */
3599 Term_xtra(TERM_XTRA_DELAY, msec);
3602 /* Save the new location */
3607 /* Monster here, Try to hit it */
3608 if (cave[y][x].m_idx)
3610 cave_type *c_ptr = &cave[y][x];
3612 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3613 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3615 /* Check the visibility */
3616 visible = m_ptr->ml;
3618 /* Note the collision */
3623 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3624 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3627 if ((r_ptr->level + 10) > p_ptr->lev)
3629 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3630 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3633 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3634 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3635 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3636 else if (p_ptr->lev > 34) amount = 2;
3637 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3638 p_ptr->update |= (PU_BONUS);
3644 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3645 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3648 p_ptr->skill_exp[GINOU_RIDING] += 1;
3649 p_ptr->update |= (PU_BONUS);
3653 /* Did we hit it (penalize range) */
3654 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3658 /* Handle unseen monster */
3661 /* Invisible monster */
3663 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3665 msg_format("The %s finds a mark.", o_name);
3670 /* Handle visible monster */
3675 /* Get "the monster" or "it" */
3676 monster_desc(m_name, m_ptr, 0);
3680 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3682 msg_format("The %s hits %s.", o_name, m_name);
3686 /* Hack -- Track this monster race */
3687 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3689 /* Hack -- Track this monster */
3690 if (m_ptr->ml) health_track(c_ptr->m_idx);
3693 /* Apply special damage XXX XXX XXX */
3694 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3695 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3697 /* No negative damage */
3698 if (tdam < 0) tdam = 0;
3700 /* Modify the damage */
3701 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3703 /* Complex message */
3704 if (p_ptr->wizard || cheat_xtra)
3707 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3710 msg_format("You do %d (out of %d) damage.",
3716 /* Hit the monster, check for death */
3717 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3730 monster_desc(m_name, m_ptr, 0);
3734 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3736 msg_format("%^s have stuck into %s!",o_name, m_name);
3741 message_pain(c_ptr->m_idx, tdam);
3743 /* Anger the monster */
3744 if (tdam > 0) anger_monster(m_ptr);
3747 if (fear && m_ptr->ml)
3754 /* Get the monster name (or "it") */
3755 monster_desc(m_name, m_ptr, 0);
3759 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3761 msg_format("%^s flees in terror!", m_name);
3765 if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3767 set_target(m_ptr, py, px);
3777 /* Chance of breakage (during attacks) */
3778 j = (hit_body ? breakage_chance(q_ptr) : 0);
3782 int m_idx = cave[y][x].m_idx;
3783 monster_type *m_ptr = &m_list[m_idx];
3784 int o_idx = o_pop();
3789 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3791 msg_format("The %s have gone to somewhere.", o_name);
3795 a_info[j_ptr->name1].cur_num = 0;
3800 o_ptr = &o_list[ o_idx ];
3801 object_copy(o_ptr, q_ptr);
3806 /* Forget location */
3807 o_ptr->iy = o_ptr->ix = 0;
3809 /* Memorize monster */
3810 o_ptr->held_m_idx = m_idx;
3813 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3816 m_ptr->hold_o_idx = o_idx;
3820 /* Drop (or break) near that location */
3821 (void)drop_near(q_ptr, j, y, x);
3825 void do_cmd_fire(void)
3831 /* Get the "bow" (if any) */
3832 j_ptr = &inventory[INVEN_BOW];
3834 /* Require a launcher */
3838 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
3840 msg_print("You have nothing to fire with.");
3846 if (j_ptr->sval == SV_CRIMSON)
3849 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
3851 msg_print("Do activate.");
3858 if (p_ptr->special_defense & KATA_MUSOU)
3860 set_action(ACTION_NONE);
3863 /* Require proper missile */
3864 item_tester_tval = p_ptr->tval_ammo;
3868 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
3869 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3871 q = "Fire which item? ";
3872 s = "You have nothing to fire.";
3875 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3882 do_cmd_fire_aux(item, j_ptr);
3886 static bool item_tester_hook_boomerang(object_type *o_ptr)
3888 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
3896 * Throw an object from the pack or floor.
3898 * Note: "unseen" monsters are very hard to hit.
3900 * Should throwing a weapon do full damage? Should it allow the magic
3901 * to hit bonus of the weapon to have an effect? Should it ever cause
3902 * the item to be destroyed? Should it do any damage at all?
3904 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
3907 int i, j, y, x, ty, tx;
3909 int chance, tdam, tdis;
3911 int cur_dis, visible;
3918 bool hit_body = FALSE;
3919 bool hit_wall = FALSE;
3920 bool equiped_item = FALSE;
3921 bool return_when_thrown = FALSE;
3923 char o_name[MAX_NLEN];
3925 int msec = delay_factor * delay_factor * delay_factor;
3927 u32b flgs[TR_FLAG_SIZE];
3929 bool come_back = FALSE;
3930 bool do_drop = TRUE;
3933 if (p_ptr->special_defense & KATA_MUSOU)
3935 set_action(ACTION_NONE);
3944 if (buki_motteruka(INVEN_LARM))
3946 item_tester_hook = item_tester_hook_boomerang;
3948 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
3949 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
3951 q = "Throw which item? ";
3952 s = "You have nothing to throw.";
3955 if (!get_item(&item, q, s, (USE_EQUIP)))
3970 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
3971 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3973 q = "Throw which item? ";
3974 s = "You have nothing to throw.";
3977 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3984 /* Access the item (if in the pack) */
3987 o_ptr = &inventory[item];
3991 o_ptr = &o_list[0 - item];
3995 /* Item is cursed */
3996 if (cursed_p(o_ptr) && (item >= INVEN_RARM))
4000 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4002 msg_print("Hmmm, it seems to be cursed.");
4009 if (p_ptr->inside_arena && !boomerang)
4011 if (o_ptr->tval != TV_SPIKE)
4014 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4016 msg_print("You're in the arena now. This is hand-to-hand!");
4025 /* Get local object */
4028 /* Obtain a local object */
4029 object_copy(q_ptr, o_ptr);
4031 /* Extract the thrown object's flags. */
4032 object_flags(q_ptr, flgs);
4034 /* Distribute the charges of rods/wands between the stacks */
4035 distribute_charges(o_ptr, q_ptr, 1);
4041 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
4043 if (p_ptr->mighty_throw) mult += 3;
4045 /* Extract a "distance multiplier" */
4046 /* Changed for 'launcher' mutation */
4047 mul = 10 + 2 * (mult - 1);
4049 /* Enforce a minimum "weight" of one pound */
4050 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4051 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4053 /* Hack -- Distance -- Reward strength, penalize weight */
4054 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4056 /* Max distance of 10-18 */
4057 if (tdis > mul) tdis = mul;
4061 ty = randint0(101)-50+py;
4062 tx = randint0(101)-50+px;
4066 project_length = tdis + 1;
4068 /* Get a direction (or cancel) */
4069 if (!get_aim_dir(&dir)) return FALSE;
4071 /* Predict the "target" location */
4072 tx = px + 99 * ddx[dir];
4073 ty = py + 99 * ddy[dir];
4075 /* Check for "target request" */
4076 if ((dir == 5) && target_okay())
4082 project_length = 0; /* reset to default */
4085 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4086 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4087 return_when_thrown = TRUE;
4089 /* Reduce and describe inventory */
4092 inven_item_increase(item, -1);
4093 if (!return_when_thrown)
4094 inven_item_describe(item);
4095 inven_item_optimize(item);
4098 /* Reduce and describe floor item */
4101 floor_item_increase(0 - item, -1);
4102 floor_item_optimize(0 - item);
4104 if (item >= INVEN_RARM)
4106 equiped_item = TRUE;
4107 p_ptr->redraw |= (PR_EQUIPPY);
4113 /* Rogue and Ninja gets bonus */
4114 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4115 energy_use -= p_ptr->lev;
4117 /* Start at the player */
4122 /* Hack -- Handle stuff */
4125 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4126 else shuriken = FALSE;
4128 /* Chance of hitting */
4129 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4130 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4131 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4133 if (shuriken) chance *= 2;
4135 /* Travel until stopped */
4136 for (cur_dis = 0; cur_dis <= tdis; )
4138 /* Hack -- Stop at the target */
4139 if ((y == ty) && (x == tx)) break;
4141 /* Calculate the new location (see "project()") */
4144 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4146 /* Stopped by walls/doors */
4147 if (!have_flag(f_flags_bold(ny[cur_dis], nx[cur_dis]), FF_PROJECT))
4153 /* Advance the distance */
4156 /* The player can see the (on screen) missile */
4157 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4159 char c = object_char(q_ptr);
4160 byte a = object_attr(q_ptr);
4162 /* Draw, Hilite, Fresh, Pause, Erase */
4163 print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4164 move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4166 Term_xtra(TERM_XTRA_DELAY, msec);
4167 lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4171 /* The player cannot see the missile */
4174 /* Pause anyway, for consistancy */
4175 Term_xtra(TERM_XTRA_DELAY, msec);
4178 /* Save the new location */
4183 /* Monster here, Try to hit it */
4184 if (cave[y][x].m_idx)
4186 cave_type *c_ptr = &cave[y][x];
4188 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4189 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4191 /* Check the visibility */
4192 visible = m_ptr->ml;
4194 /* Note the collision */
4197 /* Did we hit it (penalize range) */
4198 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4202 /* Handle unseen monster */
4205 /* Invisible monster */
4207 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4209 msg_format("The %s finds a mark.", o_name);
4214 /* Handle visible monster */
4219 /* Get "the monster" or "it" */
4220 monster_desc(m_name, m_ptr, 0);
4224 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4226 msg_format("The %s hits %s.", o_name, m_name);
4230 /* Hack -- Track this monster race */
4231 if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4233 /* Hack -- Track this monster */
4234 if (m_ptr->ml) health_track(c_ptr->m_idx);
4237 /* Hack -- Base damage from thrown object */
4238 tdam = damroll(q_ptr->dd, q_ptr->ds);
4239 /* Apply special damage XXX XXX XXX */
4240 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4241 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4242 if (q_ptr->to_d > 0)
4243 tdam += q_ptr->to_d;
4245 tdam += -q_ptr->to_d;
4249 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4250 tdam += p_ptr->to_d_m;
4252 else if (have_flag(flgs, TR_THROW))
4255 tdam += p_ptr->to_d_m;
4263 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4266 /* No negative damage */
4267 if (tdam < 0) tdam = 0;
4269 /* Modify the damage */
4270 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4272 /* Complex message */
4276 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4279 msg_format("You do %d (out of %d) damage.",
4285 /* Hit the monster, check for death */
4286 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4295 message_pain(c_ptr->m_idx, tdam);
4297 /* Anger the monster */
4298 if ((tdam > 0) && !object_is_potion(q_ptr))
4299 anger_monster(m_ptr);
4302 if (fear && m_ptr->ml)
4309 /* Get the monster name (or "it") */
4310 monster_desc(m_name, m_ptr, 0);
4314 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4316 msg_format("%^s flees in terror!", m_name);
4328 /* Chance of breakage (during attacks) */
4329 j = (hit_body ? breakage_chance(q_ptr) : 0);
4331 /* Figurines transform */
4332 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4336 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4337 !(cursed_p(q_ptr)) ? PM_FORCE_PET : 0L)))
4339 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4341 msg_print("The Figurine writhes and then shatters.");
4344 else if (cursed_p(q_ptr))
4346 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4348 msg_print("You have a bad feeling about this.");
4354 /* Potions smash open */
4355 if (object_is_potion(q_ptr))
4357 if (hit_body || hit_wall || (randint1(100) < j))
4361 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4363 msg_format("The %s shatters!", o_name);
4367 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4369 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4371 /* ToDo (Robert): fix the invulnerability */
4372 if (cave[y][x].m_idx &&
4373 is_friendly(&m_list[cave[y][x].m_idx]) &&
4377 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4379 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4381 msg_format("%^s gets angry!", m_name);
4384 set_hostile(&m_list[cave[y][x].m_idx]);
4395 if (return_when_thrown)
4397 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4398 char o2_name[MAX_NLEN];
4399 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4402 if (boomerang) back_chance += 4+randint1(5);
4403 if (super_boomerang) back_chance += 100;
4404 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4406 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4408 for (i = cur_dis-1;i>0;i--)
4410 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4412 char c = object_char(q_ptr);
4413 byte a = object_attr(q_ptr);
4415 /* Draw, Hilite, Fresh, Pause, Erase */
4416 print_rel(c, a, ny[i], nx[i]);
4417 move_cursor_relative(ny[i], nx[i]);
4419 Term_xtra(TERM_XTRA_DELAY, msec);
4420 lite_spot(ny[i], nx[i]);
4425 /* Pause anyway, for consistancy */
4426 Term_xtra(TERM_XTRA_DELAY, msec);
4429 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4432 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4434 msg_format("%s comes back to you.", o2_name);
4443 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4445 msg_format("%s backs, but you can't catch!", o2_name);
4451 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4453 msg_format("%s comes back.", o2_name);
4463 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4465 msg_format("%s doesn't back!", o2_name);
4472 if (item == INVEN_RARM || item == INVEN_LARM)
4474 /* Access the wield slot */
4475 o_ptr = &inventory[item];
4477 /* Wear the new stuff */
4478 object_copy(o_ptr, q_ptr);
4480 /* Increase the weight */
4481 p_ptr->total_weight += q_ptr->weight;
4483 /* Increment the equip counter by hand */
4486 /* Recalculate bonuses */
4487 p_ptr->update |= (PU_BONUS);
4489 /* Recalculate torch */
4490 p_ptr->update |= (PU_TORCH);
4492 /* Recalculate mana XXX */
4493 p_ptr->update |= (PU_MANA);
4496 p_ptr->window |= (PW_EQUIP);
4504 else if (equiped_item)
4510 /* Drop (or break) near that location */
4511 if (do_drop) (void)drop_near(q_ptr, j, y, x);
4518 * Throw an object from the pack or floor.
4520 void do_cmd_throw(void)
4522 do_cmd_throw_aux(1, FALSE, 0);