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 & OM_FOUND)) 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_is_known(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);
1128 sound(SOUND_OPENDOOR);
1138 if (flush_failure) flush();
1142 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1144 msg_print("You failed to pick the lock.");
1148 /* We may keep trying */
1157 cave_alter_feat(y, x, FF_OPEN);
1160 sound(SOUND_OPENDOOR);
1170 * Open a closed/locked/jammed door or a closed/locked chest.
1172 * Unlocking a locked door/chest is worth one experience point.
1174 void do_cmd_open(void)
1182 if (p_ptr->special_defense & KATA_MUSOU)
1184 set_action(ACTION_NONE);
1187 #ifdef ALLOW_EASY_OPEN /* TNB */
1189 /* Option: Pick a direction */
1192 int num_doors, num_chests;
1194 /* Count closed doors (locked or jammed) */
1195 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1197 /* Count chests (locked) */
1198 num_chests = count_chests(&y, &x, FALSE);
1200 /* See if only one target */
1201 if (num_doors || num_chests)
1203 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1205 if (!too_many) command_dir = coords_to_dir(y, x);
1209 #endif /* ALLOW_EASY_OPEN -- TNB */
1211 /* Allow repeated command */
1214 /* Set repeat count */
1215 command_rep = command_arg - 1;
1217 /* Redraw the state */
1218 p_ptr->redraw |= (PR_STATE);
1220 /* Cancel the arg */
1224 /* Get a "repeated" direction */
1225 if (get_rep_dir(&dir, TRUE))
1230 /* Get requested location */
1234 /* Get requested grid */
1235 c_ptr = &cave[y][x];
1237 /* Feature code (applying "mimic" field) */
1238 feat = get_feat_mimic(c_ptr);
1240 /* Check for chest */
1241 o_idx = chest_check(y, x);
1243 /* Nothing useful */
1244 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
1248 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1250 msg_print("You see nothing there to open.");
1255 /* Monster in the way */
1256 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1263 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1265 msg_print("There is a monster in the way!");
1276 /* Open the chest */
1277 more = do_cmd_open_chest(y, x, o_idx);
1284 more = do_cmd_open_aux(y, x);
1288 /* Cancel repeat unless we may continue */
1289 if (!more) disturb(0, 0);
1295 * Perform the basic "close" command
1297 * Assume destination is an open/broken door
1299 * Assume there is no monster blocking the destination
1301 * Returns TRUE if repeated commands may continue
1303 static bool do_cmd_close_aux(int y, int x)
1305 /* Get grid and contents */
1306 cave_type *c_ptr = &cave[y][x];
1307 s16b old_feat = c_ptr->feat;
1313 /* Seeing true feature code (ignore mimic) */
1316 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1318 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
1320 /* Hack -- object in the way */
1321 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
1322 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
1326 msg_print("²¿¤«¤¬¤Ä¤Ã¤«¤¨¤ÆÊĤޤé¤Ê¤¤¡£");
1328 msg_print("There seems stuck.");
1333 /* Close the door */
1334 cave_alter_feat(y, x, FF_CLOSE);
1337 if (old_feat == c_ptr->feat)
1341 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1343 msg_print("The door appears to be broken.");
1349 sound(SOUND_SHUTDOOR);
1360 * Close an open door.
1362 void do_cmd_close(void)
1368 if (p_ptr->special_defense & KATA_MUSOU)
1370 set_action(ACTION_NONE);
1373 #ifdef ALLOW_EASY_OPEN /* TNB */
1375 /* Option: Pick a direction */
1378 /* Count open doors */
1379 if (count_dt(&y, &x, is_open, FALSE) == 1)
1381 command_dir = coords_to_dir(y, x);
1385 #endif /* ALLOW_EASY_OPEN -- TNB */
1387 /* Allow repeated command */
1390 /* Set repeat count */
1391 command_rep = command_arg - 1;
1393 /* Redraw the state */
1394 p_ptr->redraw |= (PR_STATE);
1396 /* Cancel the arg */
1400 /* Get a "repeated" direction */
1401 if (get_rep_dir(&dir,FALSE))
1406 /* Get requested location */
1410 /* Get grid and contents */
1411 c_ptr = &cave[y][x];
1413 /* Feature code (applying "mimic" field) */
1414 feat = get_feat_mimic(c_ptr);
1416 /* Require open/broken door */
1417 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1421 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1423 msg_print("You see nothing there to close.");
1427 /* Monster in the way */
1428 else if (c_ptr->m_idx)
1435 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1437 msg_print("There is a monster in the way!");
1444 /* Close the door */
1447 /* Close the door */
1448 more = do_cmd_close_aux(y, x);
1452 /* Cancel repeat unless we may continue */
1453 if (!more) disturb(0, 0);
1458 * Determine if a given grid may be "tunneled"
1460 static bool do_cmd_tunnel_test(int y, int x)
1462 cave_type *c_ptr = &cave[y][x];
1464 /* Must have knowledge */
1465 if (!(c_ptr->info & CAVE_MARK))
1469 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1471 msg_print("You see nothing there.");
1478 /* Must be a wall/door/etc */
1479 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1483 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1485 msg_print("You see nothing there to tunnel.");
1498 * Perform the basic "tunnel" command
1500 * Assumes that no monster is blocking the destination
1502 * Do not use twall anymore
1504 * Returns TRUE if repeated commands may continue
1506 static bool do_cmd_tunnel_aux(int y, int x)
1509 feature_type *f_ptr, *mimic_f_ptr;
1514 /* Verify legality */
1515 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1521 c_ptr = &cave[y][x];
1522 f_ptr = &f_info[c_ptr->feat];
1523 power = f_ptr->power;
1525 /* Feature code (applying "mimic" field) */
1526 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1528 name = f_name + mimic_f_ptr->name;
1533 if (have_flag(f_ptr->flags, FF_PERMANENT))
1536 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1539 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1541 msg_print("This seems to be permanent rock.");
1545 /* Map border (mimiccing Permanent wall) */
1549 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1551 msg_print("You can't tunnel through that!");
1557 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1560 if (p_ptr->skill_dig > randint0(20 * power))
1564 msg_format("%s¤ò¤¯¤º¤·¤¿¡£", name);
1566 msg_format("You have removed the %s.", name);
1569 /* Remove the feature */
1570 cave_alter_feat(y, x, FF_TUNNEL);
1572 /* Update some things */
1573 p_ptr->update |= (PU_FLOW);
1577 /* Message, keep digging */
1579 msg_format("%s¤ò¤¯¤º¤·¤Æ¤¤¤ë¡£", name);
1581 msg_format("You dig into the %s.", name);
1590 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1593 if (p_ptr->skill_dig > power + randint0(40 * power))
1596 if (tree) msg_format("%s¤òÀÚ¤êʧ¤Ã¤¿¡£", name);
1599 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1600 p_ptr->update |= (PU_FLOW);
1603 if (tree) msg_format("You have cleared away the %s.", name);
1606 msg_print("You have finished the tunnel.");
1607 p_ptr->update |= (PU_FLOW);
1612 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1614 /* Remove the feature */
1615 cave_alter_feat(y, x, FF_TUNNEL);
1617 chg_virtue(V_DILIGENCE, 1);
1618 chg_virtue(V_NATURE, -1);
1626 /* We may continue chopping */
1628 msg_format("%s¤òÀڤäƤ¤¤ë¡£", name);
1630 msg_format("You chop away at the %s.", name);
1632 /* Occasional Search XXX XXX */
1633 if (randint0(100) < 25) search();
1637 /* We may continue tunelling */
1639 msg_format("%s¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£", name);
1641 msg_format("You tunnel into the %s.", name);
1649 if (is_hidden_door(c_ptr))
1651 /* Occasional Search XXX XXX */
1652 if (randint0(100) < 25) search();
1661 * Tunnels through "walls" (including rubble and closed doors)
1663 * Note that you must tunnel in order to hit invisible monsters
1664 * in walls, though moving into walls still takes a turn anyway.
1666 * Digging is very difficult without a "digger" weapon, but can be
1667 * accomplished by strong players using heavy weapons.
1669 void do_cmd_tunnel(void)
1679 if (p_ptr->special_defense & KATA_MUSOU)
1681 set_action(ACTION_NONE);
1684 /* Allow repeated command */
1687 /* Set repeat count */
1688 command_rep = command_arg - 1;
1690 /* Redraw the state */
1691 p_ptr->redraw |= (PR_STATE);
1693 /* Cancel the arg */
1697 /* Get a direction to tunnel, or Abort */
1698 if (get_rep_dir(&dir,FALSE))
1705 c_ptr = &cave[y][x];
1707 /* Feature code (applying "mimic" field) */
1708 feat = get_feat_mimic(c_ptr);
1710 /* No tunnelling through doors */
1711 if (have_flag(f_info[feat].flags, FF_DOOR))
1715 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1717 msg_print("You cannot tunnel through doors.");
1721 /* No tunnelling through most features */
1722 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1725 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1727 msg_print("You can't tunnel through that.");
1731 /* A monster is in the way */
1732 else if (c_ptr->m_idx)
1739 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1741 msg_print("There is a monster in the way!");
1751 /* Tunnel through walls */
1752 more = do_cmd_tunnel_aux(y, x);
1756 /* Cancel repetition unless we can continue */
1757 if (!more) disturb(0, 0);
1761 #ifdef ALLOW_EASY_OPEN /* TNB */
1766 * If there is a jammed/closed/locked door at the given location,
1767 * then attempt to unlock/open it. Return TRUE if an attempt was
1768 * made (successful or not), otherwise return FALSE.
1770 * The code here should be nearly identical to that in
1771 * do_cmd_open_test() and do_cmd_open_aux().
1773 bool easy_open_door(int y, int x)
1777 cave_type *c_ptr = &cave[y][x];
1778 feature_type *f_ptr = &f_info[c_ptr->feat];
1780 /* Must be a closed door */
1781 if (!is_closed_door(c_ptr->feat))
1788 if (!have_flag(f_ptr->flags, FF_OPEN))
1792 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1794 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1800 else if (f_ptr->power)
1803 i = p_ptr->skill_dis;
1805 /* Penalize some conditions */
1806 if (p_ptr->blind || no_lite()) i = i / 10;
1807 if (p_ptr->confused || p_ptr->image) i = i / 10;
1809 /* Extract the lock power */
1812 /* Extract the difficulty XXX XXX XXX */
1815 /* Always have a small chance of success */
1819 if (randint0(100) < j)
1823 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1825 msg_print("You have picked the lock.");
1829 cave_alter_feat(y, x, FF_OPEN);
1832 sound(SOUND_OPENDOOR);
1842 if (flush_failure) flush();
1846 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1848 msg_print("You failed to pick the lock.");
1858 cave_alter_feat(y, x, FF_OPEN);
1861 sound(SOUND_OPENDOOR);
1868 #endif /* ALLOW_EASY_OPEN -- TNB */
1872 * Perform the basic "disarm" command
1874 * Assume destination is a visible trap
1876 * Assume there is no monster blocking the destination
1878 * Returns TRUE if repeated commands may continue
1880 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1886 object_type *o_ptr = &o_list[o_idx];
1892 /* Get the "disarm" factor */
1893 i = p_ptr->skill_dis;
1895 /* Penalize some conditions */
1896 if (p_ptr->blind || no_lite()) i = i / 10;
1897 if (p_ptr->confused || p_ptr->image) i = i / 10;
1899 /* Extract the difficulty */
1900 j = i - o_ptr->pval;
1902 /* Always have a small chance of success */
1905 /* Must find the trap first. */
1906 if (!object_is_known(o_ptr))
1909 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
1911 msg_print("I don't see any traps.");
1916 /* Already disarmed/unlocked */
1917 else if (o_ptr->pval <= 0)
1920 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1922 msg_print("The chest is not trapped.");
1927 /* No traps to find. */
1928 else if (!chest_traps[o_ptr->pval])
1931 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1933 msg_print("The chest is not trapped.");
1938 /* Success (get a lot of experience) */
1939 else if (randint0(100) < j)
1942 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
1944 msg_print("You have disarmed the chest.");
1947 gain_exp(o_ptr->pval);
1948 o_ptr->pval = (0 - o_ptr->pval);
1951 /* Failure -- Keep trying */
1952 else if ((i > 5) && (randint1(i) > 5))
1954 /* We may keep trying */
1956 if (flush_failure) flush();
1958 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
1960 msg_print("You failed to disarm the chest.");
1965 /* Failure -- Set off the trap */
1969 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
1971 msg_print("You set off a trap!");
1975 chest_trap(y, x, o_idx);
1984 * Perform the basic "disarm" command
1986 * Assume destination is a visible trap
1988 * Assume there is no monster blocking the destination
1990 * Returns TRUE if repeated commands may continue
1992 #ifdef ALLOW_EASY_DISARM /* TNB */
1994 bool do_cmd_disarm_aux(int y, int x, int dir)
1996 #else /* ALLOW_EASY_DISARM -- TNB */
1998 static bool do_cmd_disarm_aux(int y, int x, int dir)
2000 #endif /* ALLOW_EASY_DISARM -- TNB */
2002 /* Get grid and contents */
2003 cave_type *c_ptr = &cave[y][x];
2006 feature_type *f_ptr = &f_info[c_ptr->feat];
2008 /* Access trap name */
2009 cptr name = (f_name + f_ptr->name);
2011 /* Extract trap "power" */
2012 int power = f_ptr->power;
2016 /* Get the "disarm" factor */
2017 int i = p_ptr->skill_dis;
2024 /* Penalize some conditions */
2025 if (p_ptr->blind || no_lite()) i = i / 10;
2026 if (p_ptr->confused || p_ptr->image) i = i / 10;
2028 /* Extract the difficulty */
2031 /* Always have a small chance of success */
2035 if (randint0(100) < j)
2039 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2041 msg_format("You have disarmed the %s.", name);
2047 /* Remove the trap */
2048 cave_alter_feat(y, x, FF_DISARM);
2050 #ifdef ALLOW_EASY_DISARM /* TNB */
2052 /* Move the player onto the trap */
2053 move_player(dir, easy_disarm, FALSE);
2055 #else /* ALLOW_EASY_DISARM -- TNB */
2057 /* move the player onto the trap grid */
2058 move_player(dir, FALSE, FALSE);
2060 #endif /* ALLOW_EASY_DISARM -- TNB */
2063 /* Failure -- Keep trying */
2064 else if ((i > 5) && (randint1(i) > 5))
2067 if (flush_failure) flush();
2071 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2073 msg_format("You failed to disarm the %s.", name);
2076 /* We may keep trying */
2080 /* Failure -- Set off the trap */
2085 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2087 msg_format("You set off the %s!", name);
2090 #ifdef ALLOW_EASY_DISARM /* TNB */
2092 /* Move the player onto the trap */
2093 move_player(dir, easy_disarm, FALSE);
2095 #else /* ALLOW_EASY_DISARM -- TNB */
2097 /* Move the player onto the trap */
2098 move_player(dir, FALSE, FALSE);
2100 #endif /* ALLOW_EASY_DISARM -- TNB */
2109 * Disarms a trap, or chest
2111 void do_cmd_disarm(void)
2119 if (p_ptr->special_defense & KATA_MUSOU)
2121 set_action(ACTION_NONE);
2124 #ifdef ALLOW_EASY_DISARM /* TNB */
2126 /* Option: Pick a direction */
2129 int num_traps, num_chests;
2131 /* Count visible traps */
2132 num_traps = count_dt(&y, &x, is_trap, TRUE);
2134 /* Count chests (trapped) */
2135 num_chests = count_chests(&y, &x, TRUE);
2137 /* See if only one target */
2138 if (num_traps || num_chests)
2140 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2142 if (!too_many) command_dir = coords_to_dir(y, x);
2146 #endif /* ALLOW_EASY_DISARM -- TNB */
2148 /* Allow repeated command */
2151 /* Set repeat count */
2152 command_rep = command_arg - 1;
2154 /* Redraw the state */
2155 p_ptr->redraw |= (PR_STATE);
2157 /* Cancel the arg */
2161 /* Get a direction (or abort) */
2162 if (get_rep_dir(&dir,TRUE))
2171 /* Get grid and contents */
2172 c_ptr = &cave[y][x];
2174 /* Feature code (applying "mimic" field) */
2175 feat = get_feat_mimic(c_ptr);
2177 /* Check for chests */
2178 o_idx = chest_check(y, x);
2181 if (!is_trap(feat) && !o_idx)
2185 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2187 msg_print("You see nothing there to disarm.");
2192 /* Monster in the way */
2193 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2197 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2199 msg_print("There is a monster in the way!");
2210 /* Disarm the chest */
2211 more = do_cmd_disarm_chest(y, x, o_idx);
2217 /* Disarm the trap */
2218 more = do_cmd_disarm_aux(y, x, dir);
2222 /* Cancel repeat unless told not to */
2223 if (!more) disturb(0, 0);
2228 * Perform the basic "bash" command
2230 * Assume destination is a closed/locked/jammed door
2232 * Assume there is no monster blocking the destination
2234 * Returns TRUE if repeated commands may continue
2236 static bool do_cmd_bash_aux(int y, int x, int dir)
2239 cave_type *c_ptr = &cave[y][x];
2242 feature_type *f_ptr = &f_info[c_ptr->feat];
2244 /* Hack -- Bash power based on strength */
2245 /* (Ranges from 3 to 20 to 100 to 200) */
2246 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2248 /* Extract door power */
2249 int temp = f_ptr->power;
2253 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2260 msg_format("%s¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª", name);
2262 msg_format("You smash into the %s!", name);
2265 /* Compare bash power to door power XXX XXX XXX */
2266 temp = (bash - (temp * 10));
2268 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2270 /* Hack -- always have a chance */
2271 if (temp < 1) temp = 1;
2273 /* Hack -- attempt to bash down the door */
2274 if (randint0(100) < temp)
2278 msg_format("%s¤ò²õ¤·¤¿¡ª", name);
2280 msg_format("The %s crashes open!", name);
2284 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
2286 /* Break down the door */
2287 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
2289 cave_alter_feat(y, x, FF_BASH);
2295 cave_alter_feat(y, x, FF_OPEN);
2298 /* Hack -- Fall through the door */
2299 move_player(dir, FALSE, FALSE);
2302 /* Saving throw against stun */
2303 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2308 msg_format("¤³¤Î%s¤Ï´è¾æ¤À¡£", name);
2310 msg_format("The %s holds firm.", name);
2314 /* Allow repeated bashing */
2318 /* High dexterity yields coolness */
2323 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2325 msg_print("You are off-balance.");
2329 /* Hack -- Lose balance ala paralysis */
2330 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2339 * Bash open a door, success based on character strength
2341 * For a closed door, pval is positive if locked; negative if stuck.
2343 * For an open door, pval is positive for a broken door.
2345 * A closed door can be opened - harder if locked. Any door might be
2346 * bashed open (and thereby broken). Bashing a door is (potentially)
2347 * faster! You move into the door way. To open a stuck door, it must
2348 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2350 * Creatures can also open or bash doors, see elsewhere.
2352 void do_cmd_bash(void)
2361 if (p_ptr->special_defense & KATA_MUSOU)
2363 set_action(ACTION_NONE);
2366 /* Allow repeated command */
2369 /* Set repeat count */
2370 command_rep = command_arg - 1;
2372 /* Redraw the state */
2373 p_ptr->redraw |= (PR_STATE);
2375 /* Cancel the arg */
2379 /* Get a "repeated" direction */
2380 if (get_rep_dir(&dir,FALSE))
2389 c_ptr = &cave[y][x];
2391 /* Feature code (applying "mimic" field) */
2392 feat = get_feat_mimic(c_ptr);
2394 /* Nothing useful */
2395 if (!have_flag(f_info[feat].flags, FF_BASH))
2399 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2401 msg_print("You see nothing there to bash.");
2406 /* Monster in the way */
2407 else if (c_ptr->m_idx)
2414 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2416 msg_print("There is a monster in the way!");
2424 /* Bash a closed door */
2428 more = do_cmd_bash_aux(y, x, dir);
2432 /* Unless valid action taken, cancel bash */
2433 if (!more) disturb(0, 0);
2438 * Manipulate an adjacent grid in some way
2440 * Attack monsters, tunnel through walls, disarm traps, open doors.
2442 * Consider confusion XXX XXX XXX
2444 * This command must always take a turn, to prevent free detection
2445 * of invisible monsters.
2447 void do_cmd_alter(void)
2456 if (p_ptr->special_defense & KATA_MUSOU)
2458 set_action(ACTION_NONE);
2461 /* Allow repeated command */
2464 /* Set repeat count */
2465 command_rep = command_arg - 1;
2467 /* Redraw the state */
2468 p_ptr->redraw |= (PR_STATE);
2470 /* Cancel the arg */
2474 /* Get a direction */
2475 if (get_rep_dir(&dir,TRUE))
2478 feature_type *f_ptr;
2485 c_ptr = &cave[y][x];
2487 /* Feature code (applying "mimic" field) */
2488 feat = get_feat_mimic(c_ptr);
2489 f_ptr = &f_info[feat];
2494 /* Attack monsters */
2502 else if (have_flag(f_ptr->flags, FF_OPEN))
2504 more = do_cmd_open_aux(y, x);
2507 /* Bash jammed doors */
2508 else if (have_flag(f_ptr->flags, FF_BASH))
2510 more = do_cmd_bash_aux(y, x, dir);
2513 /* Tunnel through walls */
2514 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2516 more = do_cmd_tunnel_aux(y, x);
2519 /* Close open doors */
2520 else if (have_flag(f_ptr->flags, FF_CLOSE))
2522 more = do_cmd_close_aux(y, x);
2526 else if (have_flag(f_ptr->flags, FF_DISARM))
2528 more = do_cmd_disarm_aux(y, x, dir);
2536 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2538 msg_print("You attack the empty air.");
2544 /* Cancel repetition unless we can continue */
2545 if (!more) disturb(0, 0);
2550 * Find the index of some "spikes", if possible.
2552 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2554 static bool get_spike(int *ip)
2558 /* Check every item in the pack */
2559 for (i = 0; i < INVEN_PACK; i++)
2561 object_type *o_ptr = &inventory[i];
2563 /* Skip non-objects */
2564 if (!o_ptr->k_idx) continue;
2566 /* Check the "tval" code */
2567 if (o_ptr->tval == TV_SPIKE)
2569 /* Save the spike index */
2583 * Jam a closed door with a spike
2585 * This command may NOT be repeated
2587 void do_cmd_spike(void)
2591 if (p_ptr->special_defense & KATA_MUSOU)
2593 set_action(ACTION_NONE);
2596 /* Get a "repeated" direction */
2597 if (get_rep_dir(&dir,FALSE))
2607 /* Get grid and contents */
2608 c_ptr = &cave[y][x];
2610 /* Feature code (applying "mimic" field) */
2611 feat = get_feat_mimic(c_ptr);
2613 /* Require closed door */
2614 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2618 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2620 msg_print("You see nothing there to spike.");
2626 else if (!get_spike(&item))
2630 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2632 msg_print("You have no spikes!");
2636 /* Is a monster in the way? */
2637 else if (c_ptr->m_idx)
2644 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2646 msg_print("There is a monster in the way!");
2659 /* Successful jamming */
2661 msg_format("%s¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£", f_name + f_info[feat].name);
2663 msg_format("You jam the %s with a spike.", f_name + f_info[feat].name);
2666 cave_alter_feat(y, x, FF_SPIKE);
2668 /* Use up, and describe, a single spike, from the bottom */
2669 inven_item_increase(item, -1);
2670 inven_item_describe(item);
2671 inven_item_optimize(item);
2679 * Support code for the "Walk" and "Jump" commands
2681 void do_cmd_walk(bool pickup)
2688 /* Allow repeated command */
2691 /* Set repeat count */
2692 command_rep = command_arg - 1;
2694 /* Redraw the state */
2695 p_ptr->redraw |= (PR_STATE);
2697 /* Cancel the arg */
2701 /* Get a "repeated" direction */
2702 if (get_rep_dir(&dir,FALSE))
2707 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2709 set_action(ACTION_NONE);
2712 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2713 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2714 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2716 /* Actually move the character */
2717 move_player(dir, pickup, FALSE);
2719 /* Allow more walking */
2723 /* Hack again -- Is there a special encounter ??? */
2724 if (p_ptr->wild_mode && !cave_have_flag_bold(py, px, FF_TOWN))
2726 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2729 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2731 /* Inform the player of his horrible fate :=) */
2733 msg_print("½±·â¤À¡ª");
2735 msg_print("You are ambushed !");
2738 /* Go into large wilderness view */
2739 p_ptr->oldpy = randint1(MAX_HGT-2);
2740 p_ptr->oldpx = randint1(MAX_WID-2);
2743 /* Give first move to monsters */
2746 /* HACk -- set the encouter flag for the wilderness generation */
2747 generate_encounter = TRUE;
2751 /* Cancel repeat unless we may continue */
2752 if (!more) disturb(0, 0);
2760 void do_cmd_run(void)
2764 /* Hack -- no running when confused */
2765 if (p_ptr->confused)
2768 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2770 msg_print("You are too confused!");
2776 if (p_ptr->special_defense & KATA_MUSOU)
2778 set_action(ACTION_NONE);
2781 /* Get a "repeated" direction */
2782 if (get_rep_dir(&dir,FALSE))
2784 /* Hack -- Set the run counter */
2785 running = (command_arg ? command_arg : 1000);
2795 * Stay still. Search. Enter stores.
2796 * Pick up treasure if "pickup" is true.
2798 void do_cmd_stay(bool pickup)
2800 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2802 /* Allow repeated command */
2805 /* Set repeat count */
2806 command_rep = command_arg - 1;
2808 /* Redraw the state */
2809 p_ptr->redraw |= (PR_STATE);
2811 /* Cancel the arg */
2818 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2819 (void)move_player_effect(py, px, mpe_mode);
2825 * Resting allows a player to safely restore his hp -RAK-
2827 void do_cmd_rest(void)
2830 set_action(ACTION_NONE);
2832 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
2838 if (hex_spelling_any()) stop_hex_spell_all();
2840 /* Prompt for time if needed */
2841 if (command_arg <= 0)
2844 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
2846 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
2853 strcpy(out_val, "&");
2855 /* Ask for duration */
2856 if (!get_string(p, out_val, 4)) return;
2858 /* Rest until done */
2859 if (out_val[0] == '&')
2865 else if (out_val[0] == '*')
2873 command_arg = atoi(out_val);
2874 if (command_arg <= 0) return;
2880 if (command_arg > 9999) command_arg = 9999;
2882 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2884 /* Take a turn XXX XXX XXX (?) */
2887 /* The sin of sloth */
2888 if (command_arg > 100)
2889 chg_virtue(V_DILIGENCE, -1);
2891 /* Why are you sleeping when there's no need? WAKE UP!*/
2892 if ((p_ptr->chp == p_ptr->mhp) &&
2893 (p_ptr->csp == p_ptr->msp) &&
2894 !p_ptr->blind && !p_ptr->confused &&
2895 !p_ptr->poisoned && !p_ptr->afraid &&
2896 !p_ptr->stun && !p_ptr->cut &&
2897 !p_ptr->slow && !p_ptr->paralyzed &&
2898 !p_ptr->image && !p_ptr->word_recall &&
2899 !p_ptr->alter_reality)
2900 chg_virtue(V_DILIGENCE, -1);
2902 /* Save the rest code */
2903 resting = command_arg;
2904 p_ptr->action = ACTION_REST;
2906 /* Recalculate bonuses */
2907 p_ptr->update |= (PU_BONUS);
2909 /* Redraw the state */
2910 p_ptr->redraw |= (PR_STATE);
2921 * Determines the odds of an object breaking when thrown at a monster
2923 * Note that artifacts never break, see the "drop_near()" function.
2925 static int breakage_chance(object_type *o_ptr)
2927 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2929 /* Examine the snipe type */
2932 if (snipe_type == SP_KILL_WALL) return (100);
2933 if (snipe_type == SP_EXPLODE) return (100);
2934 if (snipe_type == SP_PIERCE) return (100);
2935 if (snipe_type == SP_FINAL) return (100);
2936 if (snipe_type == SP_NEEDLE) return (100);
2937 if (snipe_type == SP_EVILNESS) return (40);
2938 if (snipe_type == SP_HOLYNESS) return (40);
2941 /* Examine the item type */
2942 switch (o_ptr->tval)
2958 /* Sometimes break */
2963 return (20 - archer_bonus * 2);
2968 return (10 - archer_bonus);
2975 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2979 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2981 u32b flgs[TR_FLAG_SIZE];
2983 /* Extract the flags */
2984 object_flags(o_ptr, flgs);
2986 /* Some "weapons" and "ammo" do extra damage */
2987 switch (o_ptr->tval)
2994 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2995 (r_ptr->flags3 & RF3_ANIMAL))
2997 if (is_original_ap_and_seen(m_ptr))
2999 r_ptr->r_flags3 |= RF3_ANIMAL;
3002 if (mult < 17) mult = 17;
3006 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3007 (r_ptr->flags3 & RF3_ANIMAL))
3009 if (is_original_ap_and_seen(m_ptr))
3011 r_ptr->r_flags3 |= RF3_ANIMAL;
3014 if (mult < 27) mult = 27;
3018 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3019 (r_ptr->flags3 & RF3_EVIL))
3021 if (is_original_ap_and_seen(m_ptr))
3023 r_ptr->r_flags3 |= RF3_EVIL;
3026 if (mult < 15) mult = 15;
3030 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3031 (r_ptr->flags3 & RF3_EVIL))
3033 if (is_original_ap_and_seen(m_ptr))
3035 r_ptr->r_flags3 |= RF3_EVIL;
3038 if (mult < 25) mult = 25;
3042 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3043 (r_ptr->flags2 & RF2_HUMAN))
3045 if (is_original_ap_and_seen(m_ptr))
3047 r_ptr->r_flags2 |= RF2_HUMAN;
3050 if (mult < 17) mult = 17;
3054 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3055 (r_ptr->flags2 & RF2_HUMAN))
3057 if (is_original_ap_and_seen(m_ptr))
3059 r_ptr->r_flags2 |= RF2_HUMAN;
3062 if (mult < 27) mult = 27;
3066 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3067 (r_ptr->flags3 & RF3_UNDEAD))
3069 if (is_original_ap_and_seen(m_ptr))
3071 r_ptr->r_flags3 |= RF3_UNDEAD;
3074 if (mult < 20) mult = 20;
3078 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3079 (r_ptr->flags3 & RF3_UNDEAD))
3081 if (is_original_ap_and_seen(m_ptr))
3083 r_ptr->r_flags3 |= RF3_UNDEAD;
3086 if (mult < 30) mult = 30;
3090 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3091 (r_ptr->flags3 & RF3_DEMON))
3093 if (is_original_ap_and_seen(m_ptr))
3095 r_ptr->r_flags3 |= RF3_DEMON;
3098 if (mult < 20) mult = 20;
3102 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3103 (r_ptr->flags3 & RF3_DEMON))
3105 if (is_original_ap_and_seen(m_ptr))
3107 r_ptr->r_flags3 |= RF3_DEMON;
3110 if (mult < 30) mult = 30;
3114 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3115 (r_ptr->flags3 & RF3_ORC))
3117 if (is_original_ap_and_seen(m_ptr))
3119 r_ptr->r_flags3 |= RF3_ORC;
3122 if (mult < 20) mult = 20;
3126 if ((have_flag(flgs, TR_KILL_ORC)) &&
3127 (r_ptr->flags3 & RF3_ORC))
3129 if (is_original_ap_and_seen(m_ptr))
3131 r_ptr->r_flags3 |= RF3_ORC;
3134 if (mult < 30) mult = 30;
3138 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3139 (r_ptr->flags3 & RF3_TROLL))
3141 if (is_original_ap_and_seen(m_ptr))
3143 r_ptr->r_flags3 |= RF3_TROLL;
3146 if (mult < 20) mult = 20;
3150 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3151 (r_ptr->flags3 & RF3_TROLL))
3153 if (is_original_ap_and_seen(m_ptr))
3155 r_ptr->r_flags3 |= RF3_TROLL;
3158 if (mult < 30) mult = 30;
3162 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3163 (r_ptr->flags3 & RF3_GIANT))
3165 if (is_original_ap_and_seen(m_ptr))
3167 r_ptr->r_flags3 |= RF3_GIANT;
3170 if (mult < 20) mult = 20;
3174 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3175 (r_ptr->flags3 & RF3_GIANT))
3177 if (is_original_ap_and_seen(m_ptr))
3179 r_ptr->r_flags3 |= RF3_GIANT;
3182 if (mult < 30) mult = 30;
3186 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3187 (r_ptr->flags3 & RF3_DRAGON))
3189 if (is_original_ap_and_seen(m_ptr))
3191 r_ptr->r_flags3 |= RF3_DRAGON;
3194 if (mult < 20) mult = 20;
3197 /* Execute Dragon */
3198 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3199 (r_ptr->flags3 & RF3_DRAGON))
3201 if (is_original_ap_and_seen(m_ptr))
3203 r_ptr->r_flags3 |= RF3_DRAGON;
3206 if (mult < 30) mult = 30;
3208 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3209 (m_ptr->r_idx == MON_SMAUG) &&
3210 (inventory[INVEN_BOW].name1 == ART_BARD))
3215 if (have_flag(flgs, TR_BRAND_ACID))
3217 /* Notice immunity */
3218 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3220 if (is_original_ap_and_seen(m_ptr))
3222 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3226 /* Otherwise, take the damage */
3229 if (mult < 17) mult = 17;
3234 if (have_flag(flgs, TR_BRAND_ELEC))
3236 /* Notice immunity */
3237 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3239 if (is_original_ap_and_seen(m_ptr))
3241 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3245 /* Otherwise, take the damage */
3248 if (mult < 17) mult = 17;
3253 if (have_flag(flgs, TR_BRAND_FIRE))
3255 /* Notice immunity */
3256 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3258 if (is_original_ap_and_seen(m_ptr))
3260 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3264 /* Otherwise, take the damage */
3267 if (r_ptr->flags3 & RF3_HURT_FIRE)
3269 if (mult < 25) mult = 25;
3270 if (is_original_ap_and_seen(m_ptr))
3272 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3275 else if (mult < 17) mult = 17;
3280 if (have_flag(flgs, TR_BRAND_COLD))
3282 /* Notice immunity */
3283 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3285 if (is_original_ap_and_seen(m_ptr))
3287 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3290 /* Otherwise, take the damage */
3293 if (r_ptr->flags3 & RF3_HURT_COLD)
3295 if (mult < 25) mult = 25;
3296 if (is_original_ap_and_seen(m_ptr))
3298 r_ptr->r_flags3 |= RF3_HURT_COLD;
3301 else if (mult < 17) mult = 17;
3305 /* Brand (Poison) */
3306 if (have_flag(flgs, TR_BRAND_POIS))
3308 /* Notice immunity */
3309 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3311 if (is_original_ap_and_seen(m_ptr))
3313 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3317 /* Otherwise, take the damage */
3320 if (mult < 17) mult = 17;
3324 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3326 p_ptr->csp -= (1+(p_ptr->msp / 30));
3327 p_ptr->redraw |= (PR_MANA);
3328 mult = mult * 5 / 2;
3335 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
3337 /* Return the total damage */
3338 return (tdam * mult / 10);
3343 * Fire an object from the pack or floor.
3345 * You may only fire items that "match" your missile launcher.
3347 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3349 * See "calc_bonuses()" for more calculations and such.
3351 * Note that "firing" a missile is MUCH better than "throwing" it.
3353 * Note: "unseen" monsters are very hard to hit.
3355 * Objects are more likely to break if they "attempt" to hit a monster.
3357 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3359 * The "extra shot" code works by decreasing the amount of energy
3360 * required to make each shot, spreading the shots out over time.
3362 * Note that when firing missiles, the launcher multiplier is applied
3363 * after all the bonuses are added in, making multipliers very useful.
3365 * Note that Bows of "Extra Might" get extra range and an extra bonus
3366 * for the damage multiplier.
3368 * Note that Bows of "Extra Shots" give an extra shot.
3370 void do_cmd_fire_aux(int item, object_type *j_ptr)
3373 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
3374 int tdam_base, tdis, thits, tmul;
3376 int cur_dis, visible;
3383 bool hit_body = FALSE;
3385 char o_name[MAX_NLEN];
3387 u16b path_g[512]; /* For calcuration of path length */
3389 int msec = delay_factor * delay_factor * delay_factor;
3392 bool stick_to = FALSE;
3394 /* Access the item (if in the pack) */
3397 o_ptr = &inventory[item];
3401 o_ptr = &o_list[0 - item];
3404 /* Sniper - Cannot shot a single arrow twice */
3405 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
3407 /* Describe the object */
3408 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3410 /* Use the proper number of shots */
3411 thits = p_ptr->num_fire;
3413 /* Use a base distance */
3416 /* Base damage from thrown object plus launcher bonus */
3417 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3419 /* Actually "fire" the object */
3420 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3421 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3422 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3424 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3426 energy_use = bow_energy(j_ptr->sval);
3427 tmul = bow_tmul(j_ptr->sval);
3429 /* Get extra "power" from "extra might" */
3430 if (p_ptr->xtra_might) tmul++;
3432 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3434 /* Boost the damage */
3439 tdis = 13 + tmul/80;
3440 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3443 tdis -= (5 - (p_ptr->concent + 1) / 2);
3448 project_length = tdis + 1;
3450 /* Get a direction (or cancel) */
3451 if (!get_aim_dir(&dir))
3455 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
3457 /* need not to reset project_length (already did)*/
3462 /* Predict the "target" location */
3463 tx = px + 99 * ddx[dir];
3464 ty = py + 99 * ddy[dir];
3466 /* Check for "target request" */
3467 if ((dir == 5) && target_okay())
3473 /* Get projection path length */
3474 tdis = project_path(path_g, project_length, py, px, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
3476 project_length = 0; /* reset to default */
3478 /* Don't shoot at my feet */
3479 if (tx == px && ty == py)
3483 /* project_length is already reset to 0 */
3489 /* Take a (partial) turn */
3490 energy_use = (energy_use / thits);
3493 /* Sniper - Difficult to shot twice at 1 turn */
3494 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
3496 /* Sniper - Repeat shooting when double shots */
3497 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
3500 /* Start at the player */
3504 /* Get local object */
3507 /* Obtain a local object */
3508 object_copy(q_ptr, o_ptr);
3513 /* Reduce and describe inventory */
3516 inven_item_increase(item, -1);
3517 inven_item_describe(item);
3518 inven_item_optimize(item);
3521 /* Reduce and describe floor item */
3524 floor_item_increase(0 - item, -1);
3525 floor_item_optimize(0 - item);
3531 /* Hack -- Handle stuff */
3534 /* Save the old location */
3538 /* The shot does not hit yet */
3541 /* Travel until stopped */
3542 for (cur_dis = 0; cur_dis <= tdis; )
3546 /* Hack -- Stop at the target */
3547 if ((y == ty) && (x == tx)) break;
3549 /* Calculate the new location (see "project()") */
3552 mmove2(&ny, &nx, py, px, ty, tx);
3555 if (snipe_type == SP_KILL_WALL)
3557 c_ptr = &cave[ny][nx];
3559 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3562 if (c_ptr->info & (CAVE_MARK)) msg_print("´ä¤¬ºÕ¤±»¶¤Ã¤¿¡£");
3564 if (c_ptr->info & (CAVE_MARK)) msg_print("Wall rocks were shattered.");
3566 /* Forget the wall */
3567 c_ptr->info &= ~(CAVE_MARK);
3569 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3571 /* Destroy the wall */
3572 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3579 /* Stopped by walls/doors */
3580 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3582 /* Advance the distance */
3586 if (snipe_type == SP_LITE)
3588 cave[ny][nx].info |= (CAVE_GLOW);
3597 /* The player can see the (on screen) missile */
3598 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3600 char c = object_char(q_ptr);
3601 byte a = object_attr(q_ptr);
3603 /* Draw, Hilite, Fresh, Pause, Erase */
3604 print_rel(c, a, ny, nx);
3605 move_cursor_relative(ny, nx);
3607 Term_xtra(TERM_XTRA_DELAY, msec);
3612 /* The player cannot see the missile */
3615 /* Pause anyway, for consistancy */
3616 Term_xtra(TERM_XTRA_DELAY, msec);
3620 if (snipe_type == SP_KILL_TRAP)
3622 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3623 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3627 if (snipe_type == SP_EVILNESS)
3629 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3638 /* Save the old location */
3642 /* Save the new location */
3647 /* Monster here, Try to hit it */
3648 if (cave[y][x].m_idx)
3651 cave_type *c_ptr = &cave[y][x];
3653 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3654 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3656 /* Check the visibility */
3657 visible = m_ptr->ml;
3659 /* Note the collision */
3662 if (MON_CSLEEP(m_ptr))
3664 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3665 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3668 if ((r_ptr->level + 10) > p_ptr->lev)
3670 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3671 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3674 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3675 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3676 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3677 else if (p_ptr->lev > 34) amount = 2;
3678 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3679 p_ptr->update |= (PU_BONUS);
3685 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3686 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3689 p_ptr->skill_exp[GINOU_RIDING] += 1;
3690 p_ptr->update |= (PU_BONUS);
3694 /* Some shots have hit bonus */
3698 armour *= (10 - p_ptr->concent);
3702 /* Did we hit it (penalize range) */
3703 if (test_hit_fire(chance - cur_dis, armour, m_ptr->ml))
3706 int tdam = tdam_base;
3708 /* Get extra damage from concentration */
3709 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3711 /* Handle unseen monster */
3714 /* Invisible monster */
3716 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3718 msg_format("The %s finds a mark.", o_name);
3723 /* Handle visible monster */
3728 /* Get "the monster" or "it" */
3729 monster_desc(m_name, m_ptr, 0);
3733 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3735 msg_format("The %s hits %s.", o_name, m_name);
3740 /* Hack -- Track this monster race */
3741 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3743 /* Hack -- Track this monster */
3744 health_track(c_ptr->m_idx);
3748 if (snipe_type == SP_NEEDLE)
3750 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3751 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3755 /* Get "the monster" or "it" */
3756 monster_desc(m_name, m_ptr, 0);
3758 tdam = m_ptr->hp + 1;
3760 msg_format("%s¤ÎµÞ½ê¤ËÆͤ»É¤µ¤Ã¤¿¡ª", m_name);
3762 msg_format("Your shot sticked on a fatal spot of %s!", m_name);
3769 /* Apply special damage XXX XXX XXX */
3770 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3771 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3773 /* No negative damage */
3774 if (tdam < 0) tdam = 0;
3776 /* Modify the damage */
3777 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3780 /* Complex message */
3781 if (p_ptr->wizard || cheat_xtra)
3784 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3787 msg_format("You do %d (out of %d) damage.",
3794 if (snipe_type == SP_EXPLODE)
3796 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3798 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3799 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3804 if (snipe_type == SP_HOLYNESS)
3806 cave[ny][nx].info |= (CAVE_GLOW);
3815 /* Hit the monster, check for death */
3816 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3825 if (object_is_fixed_artifact(q_ptr))
3829 monster_desc(m_name, m_ptr, 0);
3833 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3835 msg_format("%^s have stuck into %s!",o_name, m_name);
3840 message_pain(c_ptr->m_idx, tdam);
3842 /* Anger the monster */
3843 if (tdam > 0) anger_monster(m_ptr);
3846 if (fear && m_ptr->ml)
3853 /* Get the monster name (or "it") */
3854 monster_desc(m_name, m_ptr, 0);
3858 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3860 msg_format("%^s flees in terror!", m_name);
3865 set_target(m_ptr, py, px);
3868 if (snipe_type == SP_RUSH)
3870 int n = randint1(5) + 3;
3871 int m_idx = c_ptr->m_idx;
3873 for ( ; cur_dis <= tdis; )
3880 /* Calculate the new location (see "project()") */
3881 mmove2(&ny, &nx, py, px, ty, tx);
3883 /* Stopped by wilderness boundary */
3884 if (!in_bounds2(ny, nx)) break;
3886 /* Stopped by walls/doors */
3887 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3889 /* Stopped by monsters */
3890 if (!cave_empty_bold(ny, nx)) break;
3892 cave[ny][nx].m_idx = m_idx;
3893 cave[oy][ox].m_idx = 0;
3898 /* Update the monster (new location) */
3899 update_mon(c_ptr->m_idx, TRUE);
3905 Term_xtra(TERM_XTRA_DELAY, msec);
3917 if (snipe_type == SP_PIERCE)
3919 if(p_ptr->concent < 1) break;
3929 /* Chance of breakage (during attacks) */
3930 j = (hit_body ? breakage_chance(q_ptr) : 0);
3934 int m_idx = cave[y][x].m_idx;
3935 monster_type *m_ptr = &m_list[m_idx];
3936 int o_idx = o_pop();
3941 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3943 msg_format("The %s have gone to somewhere.", o_name);
3945 if (object_is_fixed_artifact(q_ptr))
3947 a_info[j_ptr->name1].cur_num = 0;
3952 o_ptr = &o_list[o_idx];
3953 object_copy(o_ptr, q_ptr);
3956 o_ptr->marked &= OM_TOUCHED;
3958 /* Forget location */
3959 o_ptr->iy = o_ptr->ix = 0;
3961 /* Memorize monster */
3962 o_ptr->held_m_idx = m_idx;
3965 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3968 m_ptr->hold_o_idx = o_idx;
3970 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3972 /* Drop (or break) near that location */
3973 (void)drop_near(q_ptr, j, y, x);
3977 /* Drop (or break) near that location */
3978 (void)drop_near(q_ptr, j, prev_y, prev_x);
3981 /* Sniper - Repeat shooting when double shots */
3984 /* Sniper - Loose his/her concentration after any shot */
3985 if (p_ptr->concent) reset_concentration(FALSE);
3989 void do_cmd_fire(void)
3995 is_fired = FALSE; /* not fired yet */
3997 /* Get the "bow" (if any) */
3998 j_ptr = &inventory[INVEN_BOW];
4000 /* Require a launcher */
4004 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4006 msg_print("You have nothing to fire with.");
4012 if (j_ptr->sval == SV_CRIMSON)
4015 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4017 msg_print("Do activate.");
4024 if (p_ptr->special_defense & KATA_MUSOU)
4026 set_action(ACTION_NONE);
4029 /* Require proper missile */
4030 item_tester_tval = p_ptr->tval_ammo;
4034 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4035 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4037 q = "Fire which item? ";
4038 s = "You have nothing to fire.";
4041 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4048 do_cmd_fire_aux(item, j_ptr);
4050 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
4052 /* Sniper actions after some shootings */
4053 if (snipe_type == SP_AWAY)
4055 teleport_player(10 + (p_ptr->concent * 2), 0L);
4057 if (snipe_type == SP_FINAL)
4060 msg_print("¼Í·â¤ÎÈ¿Æ°¤¬ÂΤò½±¤Ã¤¿¡£");
4062 msg_print("A reactionary of shooting attacked you. ");
4064 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
4065 (void)set_stun(p_ptr->stun + randint1(25));
4070 static bool item_tester_hook_boomerang(object_type *o_ptr)
4072 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4080 * Throw an object from the pack or floor.
4082 * Note: "unseen" monsters are very hard to hit.
4084 * Should throwing a weapon do full damage? Should it allow the magic
4085 * to hit bonus of the weapon to have an effect? Should it ever cause
4086 * the item to be destroyed? Should it do any damage at all?
4088 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4091 int i, j, y, x, ty, tx, prev_y, prev_x;
4093 int chance, tdam, tdis;
4095 int cur_dis, visible;
4102 bool hit_body = FALSE;
4103 bool hit_wall = FALSE;
4104 bool equiped_item = FALSE;
4105 bool return_when_thrown = FALSE;
4107 char o_name[MAX_NLEN];
4109 int msec = delay_factor * delay_factor * delay_factor;
4111 u32b flgs[TR_FLAG_SIZE];
4113 bool come_back = FALSE;
4114 bool do_drop = TRUE;
4117 if (p_ptr->special_defense & KATA_MUSOU)
4119 set_action(ACTION_NONE);
4128 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
4130 item_tester_hook = item_tester_hook_boomerang;
4132 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4133 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4135 q = "Throw which item? ";
4136 s = "You have nothing to throw.";
4139 if (!get_item(&item, q, s, (USE_EQUIP)))
4145 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
4146 else item = INVEN_RARM;
4152 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4153 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4155 q = "Throw which item? ";
4156 s = "You have nothing to throw.";
4159 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4166 /* Access the item (if in the pack) */
4169 o_ptr = &inventory[item];
4173 o_ptr = &o_list[0 - item];
4177 /* Item is cursed */
4178 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
4182 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4184 msg_print("Hmmm, it seems to be cursed.");
4191 if (p_ptr->inside_arena && !boomerang)
4193 if (o_ptr->tval != TV_SPIKE)
4196 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4198 msg_print("You're in the arena now. This is hand-to-hand!");
4207 /* Get local object */
4210 /* Obtain a local object */
4211 object_copy(q_ptr, o_ptr);
4213 /* Extract the thrown object's flags. */
4214 object_flags(q_ptr, flgs);
4216 /* Distribute the charges of rods/wands between the stacks */
4217 distribute_charges(o_ptr, q_ptr, 1);
4223 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
4225 if (p_ptr->mighty_throw) mult += 3;
4227 /* Extract a "distance multiplier" */
4228 /* Changed for 'launcher' mutation */
4229 mul = 10 + 2 * (mult - 1);
4231 /* Enforce a minimum "weight" of one pound */
4232 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4233 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4235 /* Hack -- Distance -- Reward strength, penalize weight */
4236 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4238 /* Max distance of 10-18 */
4239 if (tdis > mul) tdis = mul;
4243 ty = randint0(101)-50+py;
4244 tx = randint0(101)-50+px;
4248 project_length = tdis + 1;
4250 /* Get a direction (or cancel) */
4251 if (!get_aim_dir(&dir)) return FALSE;
4253 /* Predict the "target" location */
4254 tx = px + 99 * ddx[dir];
4255 ty = py + 99 * ddy[dir];
4257 /* Check for "target request" */
4258 if ((dir == 5) && target_okay())
4264 project_length = 0; /* reset to default */
4267 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4268 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4269 return_when_thrown = TRUE;
4271 /* Reduce and describe inventory */
4274 inven_item_increase(item, -1);
4275 if (!return_when_thrown)
4276 inven_item_describe(item);
4277 inven_item_optimize(item);
4280 /* Reduce and describe floor item */
4283 floor_item_increase(0 - item, -1);
4284 floor_item_optimize(0 - item);
4286 if (item >= INVEN_RARM)
4288 equiped_item = TRUE;
4289 p_ptr->redraw |= (PR_EQUIPPY);
4295 /* Rogue and Ninja gets bonus */
4296 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4297 energy_use -= p_ptr->lev;
4299 /* Start at the player */
4304 /* Hack -- Handle stuff */
4307 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4308 else shuriken = FALSE;
4310 /* Chance of hitting */
4311 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4312 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4313 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4315 if (shuriken) chance *= 2;
4317 /* Save the old location */
4321 /* Travel until stopped */
4322 for (cur_dis = 0; cur_dis <= tdis; )
4324 /* Hack -- Stop at the target */
4325 if ((y == ty) && (x == tx)) break;
4327 /* Calculate the new location (see "project()") */
4330 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4332 /* Stopped by walls/doors */
4333 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
4336 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
4339 /* The player can see the (on screen) missile */
4340 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
4342 char c = object_char(q_ptr);
4343 byte a = object_attr(q_ptr);
4345 /* Draw, Hilite, Fresh, Pause, Erase */
4346 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
4347 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
4349 Term_xtra(TERM_XTRA_DELAY, msec);
4350 lite_spot(ny[cur_dis], nx[cur_dis]);
4354 /* The player cannot see the missile */
4357 /* Pause anyway, for consistancy */
4358 Term_xtra(TERM_XTRA_DELAY, msec);
4361 /* Save the old location */
4365 /* Save the new location */
4369 /* Advance the distance */
4372 /* Monster here, Try to hit it */
4373 if (cave[y][x].m_idx)
4375 cave_type *c_ptr = &cave[y][x];
4377 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4378 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4380 /* Check the visibility */
4381 visible = m_ptr->ml;
4383 /* Note the collision */
4386 /* Did we hit it (penalize range) */
4387 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4391 /* Handle unseen monster */
4394 /* Invisible monster */
4396 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4398 msg_format("The %s finds a mark.", o_name);
4403 /* Handle visible monster */
4408 /* Get "the monster" or "it" */
4409 monster_desc(m_name, m_ptr, 0);
4413 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4415 msg_format("The %s hits %s.", o_name, m_name);
4420 /* Hack -- Track this monster race */
4421 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
4423 /* Hack -- Track this monster */
4424 health_track(c_ptr->m_idx);
4428 /* Hack -- Base damage from thrown object */
4429 tdam = damroll(q_ptr->dd, q_ptr->ds);
4430 /* Apply special damage XXX XXX XXX */
4431 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4432 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4433 if (q_ptr->to_d > 0)
4434 tdam += q_ptr->to_d;
4436 tdam += -q_ptr->to_d;
4440 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4441 tdam += p_ptr->to_d_m;
4443 else if (have_flag(flgs, TR_THROW))
4446 tdam += p_ptr->to_d_m;
4454 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4457 /* No negative damage */
4458 if (tdam < 0) tdam = 0;
4460 /* Modify the damage */
4461 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4463 /* Complex message */
4467 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4470 msg_format("You do %d (out of %d) damage.",
4476 /* Hit the monster, check for death */
4477 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4486 message_pain(c_ptr->m_idx, tdam);
4488 /* Anger the monster */
4489 if ((tdam > 0) && !object_is_potion(q_ptr))
4490 anger_monster(m_ptr);
4493 if (fear && m_ptr->ml)
4500 /* Get the monster name (or "it") */
4501 monster_desc(m_name, m_ptr, 0);
4505 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4507 msg_format("%^s flees in terror!", m_name);
4519 /* Chance of breakage (during attacks) */
4520 j = (hit_body ? breakage_chance(q_ptr) : 0);
4522 /* Figurines transform */
4523 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4527 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4528 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
4530 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4532 msg_print("The Figurine writhes and then shatters.");
4535 else if (object_is_cursed(q_ptr))
4537 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4539 msg_print("You have a bad feeling about this.");
4545 /* Potions smash open */
4546 if (object_is_potion(q_ptr))
4548 if (hit_body || hit_wall || (randint1(100) < j))
4552 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4554 msg_format("The %s shatters!", o_name);
4558 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4560 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4562 /* ToDo (Robert): fix the invulnerability */
4563 if (cave[y][x].m_idx &&
4564 is_friendly(&m_list[cave[y][x].m_idx]) &&
4565 !MON_INVULNER(m_ptr))
4568 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4570 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4572 msg_format("%^s gets angry!", m_name);
4575 set_hostile(&m_list[cave[y][x].m_idx]);
4586 if (return_when_thrown)
4588 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4589 char o2_name[MAX_NLEN];
4590 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4593 if (boomerang) back_chance += 4+randint1(5);
4594 if (super_boomerang) back_chance += 100;
4595 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4597 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4599 for (i = cur_dis - 1; i > 0; i--)
4601 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4603 char c = object_char(q_ptr);
4604 byte a = object_attr(q_ptr);
4606 /* Draw, Hilite, Fresh, Pause, Erase */
4607 print_rel(c, a, ny[i], nx[i]);
4608 move_cursor_relative(ny[i], nx[i]);
4610 Term_xtra(TERM_XTRA_DELAY, msec);
4611 lite_spot(ny[i], nx[i]);
4616 /* Pause anyway, for consistancy */
4617 Term_xtra(TERM_XTRA_DELAY, msec);
4620 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4623 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4625 msg_format("%s comes back to you.", o2_name);
4634 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4636 msg_format("%s backs, but you can't catch!", o2_name);
4642 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4644 msg_format("%s comes back.", o2_name);
4654 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4656 msg_format("%s doesn't back!", o2_name);
4663 if (item == INVEN_RARM || item == INVEN_LARM)
4665 /* Access the wield slot */
4666 o_ptr = &inventory[item];
4668 /* Wear the new stuff */
4669 object_copy(o_ptr, q_ptr);
4671 /* Increase the weight */
4672 p_ptr->total_weight += q_ptr->weight;
4674 /* Increment the equip counter by hand */
4677 /* Recalculate bonuses */
4678 p_ptr->update |= (PU_BONUS);
4680 /* Recalculate torch */
4681 p_ptr->update |= (PU_TORCH);
4683 /* Recalculate mana XXX */
4684 p_ptr->update |= (PU_MANA);
4687 p_ptr->window |= (PW_EQUIP);
4695 else if (equiped_item)
4701 /* Drop (or break) near that location */
4704 if (cave_have_flag_bold(y, x, FF_PROJECT))
4706 /* Drop (or break) near that location */
4707 (void)drop_near(q_ptr, j, y, x);
4711 /* Drop (or break) near that location */
4712 (void)drop_near(q_ptr, j, prev_y, prev_x);
4721 * Throw an object from the pack or floor.
4723 void do_cmd_throw(void)
4725 do_cmd_throw_aux(1, FALSE, 0);
4731 * Hack: travel command
4733 #define TRAVEL_UNABLE 9999
4735 static int flow_head = 0;
4736 static int flow_tail = 0;
4737 static s16b temp2_x[MAX_SHORT];
4738 static s16b temp2_y[MAX_SHORT];
4740 /* Hack: forget the "flow" information */
4741 void forget_travel_flow(void)
4745 /* Check the entire dungeon */
4746 for (y = 0; y < cur_hgt; y++)
4748 for (x = 0; x < cur_wid; x++)
4750 /* Forget the old data */
4751 travel.cost[y][x] = TRAVEL_UNABLE;
4756 static bool travel_flow_aux(int y, int x, int n, bool wall)
4758 cave_type *c_ptr = &cave[y][x];
4759 feature_type *f_ptr = &f_info[c_ptr->feat];
4760 int old_head = flow_head;
4762 n = n % TRAVEL_UNABLE;
4764 /* Ignore out of bounds */
4765 if (!in_bounds(y, x)) return wall;
4767 /* Ignore "pre-stamped" entries */
4768 if (travel.cost[y][x] != TRAVEL_UNABLE) return wall;
4770 /* Ignore "walls" and "rubble" (include "secret doors") */
4771 if (have_flag(f_ptr->flags, FF_WALL) ||
4772 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4773 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4774 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4776 if (!wall) return wall;
4783 /* Save the flow cost */
4784 travel.cost[y][x] = n;
4785 if (wall) travel.cost[y][x] += TRAVEL_UNABLE;
4787 /* Enqueue that entry */
4788 temp2_y[flow_head] = y;
4789 temp2_x[flow_head] = x;
4791 /* Advance the queue */
4792 if (++flow_head == MAX_SHORT) flow_head = 0;
4794 /* Hack -- notice overflow by forgetting new entry */
4795 if (flow_head == flow_tail) flow_head = old_head;
4801 static void travel_flow(int ty, int tx)
4805 feature_type *f_ptr = &f_info[cave[ty][tx].feat];
4807 /* Reset the "queue" */
4808 flow_head = flow_tail = 0;
4810 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4812 /* Add the player's grid to the queue */
4813 wall = travel_flow_aux(ty, tx, 0, wall);
4815 /* Now process the queue */
4816 while (flow_head != flow_tail)
4818 /* Extract the next entry */
4819 y = temp2_y[flow_tail];
4820 x = temp2_x[flow_tail];
4822 /* Forget that entry */
4823 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4825 /* Add the "children" */
4826 for (d = 0; d < 8; d++)
4828 /* Add that child if "legal" */
4829 wall = travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x] + 1, wall);
4833 /* Forget the flow info */
4834 flow_head = flow_tail = 0;
4837 void do_cmd_travel(void)
4841 feature_type *f_ptr;
4843 if (!tgt_pt(&x, &y)) return;
4845 if ((x == px) && (y == py))
4848 msg_print("¤¹¤Ç¤Ë¤½¤³¤Ë¤¤¤Þ¤¹¡ª");
4850 msg_print("You are already there!!");
4855 f_ptr = &f_info[cave[y][x].feat];
4857 if ((cave[y][x].info & CAVE_MARK) &&
4858 (have_flag(f_ptr->flags, FF_WALL) ||
4859 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4860 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4863 msg_print("¤½¤³¤Ë¤Ï¹Ô¤¯¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
4865 msg_print("You cannot travel there!");
4873 forget_travel_flow();
4876 /* Travel till 255 steps */
4882 /* Decides first direction */
4885 sx = ((x == px) || (dx < dy)) ? 0 : ((x > px) ? 1 : -1);
4886 sy = ((y == py) || (dy < dx)) ? 0 : ((y > py) ? 1 : -1);
4888 for (i = 1; i <= 9; i++)
4890 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;