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) */
15 bool confirm_leave_level(bool down_stair)
17 quest_type *q_ptr = &quest[p_ptr->inside_quest];
19 /* Confirm leaving from once only quest */
20 if (confirm_quest && p_ptr->inside_quest &&
21 (q_ptr->type == QUEST_TYPE_RANDOM ||
22 (q_ptr->flags & QUEST_FLAG_ONCE &&
23 q_ptr->status != QUEST_STATUS_COMPLETED) ||
24 (q_ptr->flags & QUEST_FLAG_TOWER &&
25 ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) ||
26 (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED))))))
29 msg_print("¤³¤Î³¬¤ò°ìÅÙµî¤ë¤ÈÆóÅÙ¤ÈÌá¤Ã¤ÆÍè¤é¤ì¤Þ¤»¤ó¡£");
30 if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©")) return TRUE;
32 msg_print("You can't come back here once you leave this floor.");
33 if (get_check("Really leave this floor? ")) return TRUE;
47 void do_cmd_go_up(void)
52 cave_type *c_ptr = &cave[py][px];
53 feature_type *f_ptr = &f_info[c_ptr->feat];
57 if (p_ptr->special_defense & KATA_MUSOU)
59 set_action(ACTION_NONE);
63 if (!have_flag(f_ptr->flags, FF_LESS))
66 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
68 msg_print("I see no up staircase here.");
75 if (have_flag(f_ptr->flags, FF_QUEST))
77 /* Cancel the command */
78 if (!confirm_leave_level(FALSE)) return;
83 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
84 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
86 msg_print("¾å¤Î³¬¤ËÅФä¿¡£");
88 msg_print("You enter the up staircase.");
93 p_ptr->inside_quest = c_ptr->special;
95 /* Activate the quest */
96 if (!quest[p_ptr->inside_quest].status)
98 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
100 init_flags = INIT_ASSIGN;
101 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
103 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
106 /* Leaving a quest */
107 if (!p_ptr->inside_quest)
113 p_ptr->leaving = TRUE;
118 /* Hack -- take a turn */
121 /* End the command */
131 go_up = confirm_leave_level(FALSE);
134 /* Cancel the command */
137 /* Hack -- take a turn */
140 if (autosave_l) do_cmd_save_game(TRUE);
142 /* For a random quest */
143 if (p_ptr->inside_quest &&
144 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
148 p_ptr->inside_quest = 0;
151 /* For a fixed quest */
152 if (p_ptr->inside_quest &&
153 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
157 p_ptr->inside_quest = c_ptr->special;
162 /* For normal dungeon and random quest */
166 if (have_flag(f_ptr->flags, FF_SHAFT))
168 /* Create a way back */
169 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
175 /* Create a way back */
176 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
181 /* Get out from current dungeon */
182 if (dun_level - up_num < d_info[dungeon_type].mindepth)
187 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
189 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "climbed up the stairs to");
194 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
195 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
196 else if (up_num == dun_level)
197 msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
199 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
201 if (up_num == dun_level)
202 msg_print("You go back to the surface.");
204 msg_print("You enter a maze of up staircases.");
208 p_ptr->leaving = TRUE;
215 void do_cmd_go_down(void)
218 cave_type *c_ptr = &cave[py][px];
219 feature_type *f_ptr = &f_info[c_ptr->feat];
221 bool fall_trap = FALSE;
224 if (p_ptr->special_defense & KATA_MUSOU)
226 set_action(ACTION_NONE);
230 if (!have_flag(f_ptr->flags, FF_MORE))
233 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
235 msg_print("I see no down staircase here.");
241 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
244 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
249 /* Quest down stairs */
250 else if (have_flag(f_ptr->flags, FF_QUEST))
252 /* Confirm Leaving */
253 if(!confirm_leave_level(TRUE)) return;
256 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
257 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
259 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
261 msg_print("You enter the down staircase.");
267 p_ptr->inside_quest = c_ptr->special;
269 /* Activate the quest */
270 if (!quest[p_ptr->inside_quest].status)
272 if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
274 init_flags = INIT_ASSIGN;
275 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
277 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
280 /* Leaving a quest */
281 if (!p_ptr->inside_quest)
287 p_ptr->leaving = TRUE;
293 /* Hack -- take a turn */
299 int target_dungeon = 0;
303 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
305 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
308 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
310 msg_print("The entrance of this dungeon is closed!");
314 if (!max_dlv[target_dungeon])
317 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
318 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
320 msg_format("There is the entrance of %s (Danger level: %d)", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
321 if (!get_check("Do you really get in this dungeon? ")) return;
325 /* Save old player position */
328 dungeon_type = (byte)target_dungeon;
331 * Clear all saved floors
332 * and create a first saved floor
334 prepare_change_floor_mode(CFM_FIRST_FLOOR);
337 /* Hack -- take a turn */
340 if (autosave_l) do_cmd_save_game(TRUE);
343 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
348 /* Enter the dungeon just now */
349 p_ptr->enter_dungeon = TRUE;
350 down_num = d_info[dungeon_type].mindepth;
356 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Íî¤È¤·¸Í¤ËÍî¤Á¤¿");
357 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
359 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fell through a trap door");
360 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed down the stairs to");
367 msg_print("¤ï¤¶¤ÈÍî¤È¤·¸Í¤ËÍî¤Á¤¿¡£");
369 msg_print("You deliberately jump through the trap door.");
378 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
380 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
386 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
387 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
389 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
391 msg_print("You enter a maze of down staircases.");
398 p_ptr->leaving = TRUE;
402 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
406 if (have_flag(f_ptr->flags, FF_SHAFT))
408 /* Create a way back */
409 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
413 /* Create a way back */
414 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
423 * Simple command to "search" for one turn
425 void do_cmd_search(void)
427 /* Allow repeated command */
430 /* Set repeat count */
431 command_rep = command_arg - 1;
433 /* Redraw the state */
434 p_ptr->redraw |= (PR_STATE);
449 * Determine if a grid contains a chest
451 static s16b chest_check(int y, int x, bool trapped)
453 cave_type *c_ptr = &cave[y][x];
455 s16b this_o_idx, next_o_idx = 0;
458 /* Scan all objects in the grid */
459 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
464 o_ptr = &o_list[this_o_idx];
466 /* Acquire next object */
467 next_o_idx = o_ptr->next_o_idx;
469 /* Skip unknown chests XXX XXX */
470 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
472 /* Check for non empty chest */
473 if ((o_ptr->tval == TV_CHEST) &&
474 (((!trapped) && (o_ptr->pval)) || /* non empty */
475 ((trapped) && (o_ptr->pval > 0)))) /* trapped only */
487 * Allocates objects upon opening a chest -BEN-
489 * Disperse treasures from the given chest, centered at (x,y).
491 * Small chests often contain "gold", while Large chests always contain
492 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
493 * and Steel chests contain 6 items. The "value" of the items in a
494 * chest is based on the "power" of the chest, which is in turn based
495 * on the level on which the chest is generated.
497 static void chest_death(bool scatter, int y, int x, s16b o_idx)
507 object_type *o_ptr = &o_list[o_idx];
510 /* Small chests often hold "gold" */
511 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
513 /* Determine how much to drop (see above) */
514 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
516 if (o_ptr->sval == SV_CHEST_KANDUME)
521 object_level = o_ptr->xtra3;
525 /* Determine the "value" of the items */
526 object_level = ABS(o_ptr->pval) + 10;
529 /* Zero pval means empty chest */
530 if (!o_ptr->pval) number = 0;
532 /* Opening a chest */
533 opening_chest = TRUE;
535 /* Drop some objects (non-chests) */
536 for (; number > 0; --number)
538 /* Get local object */
541 /* Wipe the object */
544 /* Small chests often drop gold */
545 if (small && (randint0(100) < 25))
548 if (!make_gold(q_ptr)) continue;
551 /* Otherwise drop an item */
554 /* Make a good object */
555 if (!make_object(q_ptr, mode)) continue;
558 /* If chest scatters its contents, pick any floor square. */
562 for (i = 0; i < 200; i++)
564 /* Pick a totally random spot. */
565 y = randint0(MAX_HGT);
566 x = randint0(MAX_WID);
568 /* Must be an empty floor. */
569 if (!cave_empty_bold(y, x)) continue;
571 /* Place the object there. */
572 drop_near(q_ptr, -1, y, x);
578 /* Normally, drop object near the chest. */
579 else drop_near(q_ptr, -1, y, x);
582 /* Reset the object level */
583 object_level = base_level;
585 /* No longer opening a chest */
586 opening_chest = FALSE;
597 * Chests have traps too.
599 * Exploding chest destroys contents (and traps).
600 * Note that the chest itself is never destroyed.
602 static void chest_trap(int y, int x, s16b o_idx)
606 object_type *o_ptr = &o_list[o_idx];
608 int mon_level = o_ptr->xtra3;
610 /* Ignore disarmed chests */
611 if (o_ptr->pval <= 0) return;
613 /* Obtain the traps */
614 trap = chest_traps[o_ptr->pval];
617 if (trap & (CHEST_LOSE_STR))
620 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
621 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
623 msg_print("A small needle has pricked you!");
624 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
627 (void)do_dec_stat(A_STR);
630 /* Lose constitution */
631 if (trap & (CHEST_LOSE_CON))
634 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
635 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
637 msg_print("A small needle has pricked you!");
638 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
641 (void)do_dec_stat(A_CON);
645 if (trap & (CHEST_POISON))
648 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
650 msg_print("A puff of green gas surrounds you!");
653 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
655 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
660 if (trap & (CHEST_PARALYZE))
663 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
665 msg_print("A puff of yellow gas surrounds you!");
669 if (!p_ptr->free_act)
671 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
675 /* Summon monsters */
676 if (trap & (CHEST_SUMMON))
678 int num = 2 + randint1(3);
680 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
682 msg_print("You are enveloped in a cloud of smoke!");
686 for (i = 0; i < num; i++)
688 if (randint1(100)<dun_level)
689 activate_hi_summon(py, px, FALSE);
691 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
695 /* Elemental summon. */
696 if (trap & (CHEST_E_SUMMON))
699 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
701 msg_print("Elemental beings appear to protect their treasures!");
703 for (i = 0; i < randint1(3) + 5; i++)
705 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
709 /* Force clouds, then summon birds. */
710 if (trap & (CHEST_BIRD_STORM))
713 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
715 msg_print("A storm of birds swirls around you!");
718 for (i = 0; i < randint1(3) + 3; i++)
719 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
721 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
723 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
727 /* Various colorful summonings. */
728 if (trap & (CHEST_H_SUMMON))
734 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
736 msg_print("Demons materialize in clouds of fire and brimstone!");
739 for (i = 0; i < randint1(3) + 2; i++)
741 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
742 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
746 /* Summon dragons. */
750 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
752 msg_print("Draconic forms loom out of the darkness!");
755 for (i = 0; i < randint1(3) + 2; i++)
757 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
761 /* Summon hybrids. */
765 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
767 msg_print("Creatures strange and twisted assault you!");
770 for (i = 0; i < randint1(5) + 3; i++)
772 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
776 /* Summon vortices (scattered) */
780 msg_print("±²´¬¤¬¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
782 msg_print("Vortices coalesce and wreak destruction!");
785 for (i = 0; i < randint1(3) + 2; i++)
787 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
793 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
795 /* Determine how many nasty tricks can be played. */
796 int nasty_tricks_count = 4 + randint0(3);
800 msg_print("¶²¤í¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
802 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
805 /* This is gonna hurt... */
806 for (; nasty_tricks_count > 0; nasty_tricks_count--)
808 /* ...but a high saving throw does help a little. */
809 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
812 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
814 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
816 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
819 if (!p_ptr->free_act)
820 (void)set_paralyzed(p_ptr->paralyzed + 2 +
823 (void)set_stun(p_ptr->stun + 10 +
826 else if (one_in_(3)) apply_disenchant(0);
829 (void)do_dec_stat(A_STR);
830 (void)do_dec_stat(A_DEX);
831 (void)do_dec_stat(A_CON);
832 (void)do_dec_stat(A_INT);
833 (void)do_dec_stat(A_WIS);
834 (void)do_dec_stat(A_CHR);
836 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
841 /* Aggravate monsters. */
842 if (trap & (CHEST_ALARM))
845 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
847 msg_print("An alarm sounds!");
849 aggravate_monsters(0);
853 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
856 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
857 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
859 msg_print("There is a sudden explosion!");
860 msg_print("Everything inside the chest is destroyed!");
864 sound(SOUND_EXPLODE);
866 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
868 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
872 /* Scatter contents. */
873 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
876 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
878 msg_print("The contents of the chest scatter all over the dungeon!");
880 chest_death(TRUE, y, x, o_idx);
887 * Attempt to open the given chest at the given location
889 * Assume there is no monster blocking the destination
891 * Returns TRUE if repeated commands may continue
893 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
901 object_type *o_ptr = &o_list[o_idx];
907 /* Attempt to unlock it */
910 /* Assume locked, and thus not open */
913 /* Get the "disarm" factor */
914 i = p_ptr->skill_dis;
916 /* Penalize some conditions */
917 if (p_ptr->blind || no_lite()) i = i / 10;
918 if (p_ptr->confused || p_ptr->image) i = i / 10;
920 /* Extract the difficulty */
923 /* Always have a small chance of success */
926 /* Success -- May still have traps */
927 if (randint0(100) < j)
930 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
932 msg_print("You have picked the lock.");
939 /* Failure -- Keep trying */
942 /* We may continue repeating */
944 if (flush_failure) flush();
946 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
948 msg_print("You failed to pick the lock.");
954 /* Allowed to open */
957 /* Apply chest traps, if any */
958 chest_trap(y, x, o_idx);
960 /* Let the Chest drop items */
961 chest_death(FALSE, y, x, o_idx);
969 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
972 * Return TRUE if the given feature is an open door
974 static bool is_open(int feat)
976 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
981 * Return the number of features around (or under) the character.
982 * Usually look for doors and floor traps.
984 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
986 int d, count, xx, yy;
988 /* Count how many matches */
991 /* Check around (and under) the character */
992 for (d = 0; d < 9; d++)
997 /* if not searching under player continue */
998 if ((d == 8) && !under) continue;
1000 /* Extract adjacent (legal) location */
1001 yy = py + ddy_ddd[d];
1002 xx = px + ddx_ddd[d];
1005 c_ptr = &cave[yy][xx];
1007 /* Must have knowledge */
1008 if (!(c_ptr->info & (CAVE_MARK))) continue;
1010 /* Feature code (applying "mimic" field) */
1011 feat = get_feat_mimic(c_ptr);
1013 /* Not looking for this feature */
1014 if (!((*test)(feat))) continue;
1019 /* Remember the location. Only useful if only one match */
1030 * Return the number of chests around (or under) the character.
1031 * If requested, count only trapped chests.
1033 static int count_chests(int *y, int *x, bool trapped)
1035 int d, count, o_idx;
1039 /* Count how many matches */
1042 /* Check around (and under) the character */
1043 for (d = 0; d < 9; d++)
1045 /* Extract adjacent (legal) location */
1046 int yy = py + ddy_ddd[d];
1047 int xx = px + ddx_ddd[d];
1049 /* No (visible) chest is there */
1050 if ((o_idx = chest_check(yy, xx, FALSE)) == 0) continue;
1052 /* Grab the object */
1053 o_ptr = &o_list[o_idx];
1056 if (o_ptr->pval == 0) continue;
1058 /* No (known) traps here */
1059 if (trapped && (!object_is_known(o_ptr) ||
1060 !chest_traps[o_ptr->pval])) continue;
1065 /* Remember the location. Only useful if only one match */
1076 * Convert an adjacent location to a direction.
1078 static int coords_to_dir(int y, int x)
1080 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1087 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1089 return d[dx + 1][dy + 1];
1092 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1096 * Perform the basic "open" command on doors
1098 * Assume destination is a closed/locked/jammed door
1100 * Assume there is no monster blocking the destination
1102 * Returns TRUE if repeated commands may continue
1104 static bool do_cmd_open_aux(int y, int x)
1108 /* Get requested grid */
1109 cave_type *c_ptr = &cave[y][x];
1111 feature_type *f_ptr = &f_info[c_ptr->feat];
1119 /* Seeing true feature code (ignore mimic) */
1122 if (!have_flag(f_ptr->flags, FF_OPEN))
1126 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1128 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1134 else if (f_ptr->power)
1137 i = p_ptr->skill_dis;
1139 /* Penalize some conditions */
1140 if (p_ptr->blind || no_lite()) i = i / 10;
1141 if (p_ptr->confused || p_ptr->image) i = i / 10;
1143 /* Extract the lock power */
1146 /* Extract the difficulty XXX XXX XXX */
1149 /* Always have a small chance of success */
1153 if (randint0(100) < j)
1157 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1159 msg_print("You have picked the lock.");
1163 cave_alter_feat(y, x, FF_OPEN);
1166 sound(SOUND_OPENDOOR);
1176 if (flush_failure) flush();
1180 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1182 msg_print("You failed to pick the lock.");
1186 /* We may keep trying */
1195 cave_alter_feat(y, x, FF_OPEN);
1198 sound(SOUND_OPENDOOR);
1208 * Open a closed/locked/jammed door or a closed/locked chest.
1210 * Unlocking a locked door/chest is worth one experience point.
1212 void do_cmd_open(void)
1220 if (p_ptr->special_defense & KATA_MUSOU)
1222 set_action(ACTION_NONE);
1225 #ifdef ALLOW_EASY_OPEN /* TNB */
1227 /* Option: Pick a direction */
1230 int num_doors, num_chests;
1232 /* Count closed doors (locked or jammed) */
1233 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1235 /* Count chests (locked) */
1236 num_chests = count_chests(&y, &x, FALSE);
1238 /* See if only one target */
1239 if (num_doors || num_chests)
1241 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1243 if (!too_many) command_dir = coords_to_dir(y, x);
1247 #endif /* ALLOW_EASY_OPEN -- TNB */
1249 /* Allow repeated command */
1252 /* Set repeat count */
1253 command_rep = command_arg - 1;
1255 /* Redraw the state */
1256 p_ptr->redraw |= (PR_STATE);
1258 /* Cancel the arg */
1262 /* Get a "repeated" direction */
1263 if (get_rep_dir(&dir, TRUE))
1268 /* Get requested location */
1272 /* Get requested grid */
1273 c_ptr = &cave[y][x];
1275 /* Feature code (applying "mimic" field) */
1276 feat = get_feat_mimic(c_ptr);
1278 /* Check for chest */
1279 o_idx = chest_check(y, x, FALSE);
1281 /* Nothing useful */
1282 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
1286 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1288 msg_print("You see nothing there to open.");
1293 /* Monster in the way */
1294 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1301 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1303 msg_print("There is a monster in the way!");
1314 /* Open the chest */
1315 more = do_cmd_open_chest(y, x, o_idx);
1322 more = do_cmd_open_aux(y, x);
1326 /* Cancel repeat unless we may continue */
1327 if (!more) disturb(0, 0);
1333 * Perform the basic "close" command
1335 * Assume destination is an open/broken door
1337 * Assume there is no monster blocking the destination
1339 * Returns TRUE if repeated commands may continue
1341 static bool do_cmd_close_aux(int y, int x)
1343 /* Get grid and contents */
1344 cave_type *c_ptr = &cave[y][x];
1345 s16b old_feat = c_ptr->feat;
1351 /* Seeing true feature code (ignore mimic) */
1354 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1356 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
1358 /* Hack -- object in the way */
1359 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
1360 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
1364 msg_print("²¿¤«¤¬¤Ä¤Ã¤«¤¨¤ÆÊĤޤé¤Ê¤¤¡£");
1366 msg_print("There seems stuck.");
1371 /* Close the door */
1372 cave_alter_feat(y, x, FF_CLOSE);
1375 if (old_feat == c_ptr->feat)
1379 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1381 msg_print("The door appears to be broken.");
1387 sound(SOUND_SHUTDOOR);
1398 * Close an open door.
1400 void do_cmd_close(void)
1406 if (p_ptr->special_defense & KATA_MUSOU)
1408 set_action(ACTION_NONE);
1411 #ifdef ALLOW_EASY_OPEN /* TNB */
1413 /* Option: Pick a direction */
1416 /* Count open doors */
1417 if (count_dt(&y, &x, is_open, FALSE) == 1)
1419 command_dir = coords_to_dir(y, x);
1423 #endif /* ALLOW_EASY_OPEN -- TNB */
1425 /* Allow repeated command */
1428 /* Set repeat count */
1429 command_rep = command_arg - 1;
1431 /* Redraw the state */
1432 p_ptr->redraw |= (PR_STATE);
1434 /* Cancel the arg */
1438 /* Get a "repeated" direction */
1439 if (get_rep_dir(&dir,FALSE))
1444 /* Get requested location */
1448 /* Get grid and contents */
1449 c_ptr = &cave[y][x];
1451 /* Feature code (applying "mimic" field) */
1452 feat = get_feat_mimic(c_ptr);
1454 /* Require open/broken door */
1455 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1459 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1461 msg_print("You see nothing there to close.");
1465 /* Monster in the way */
1466 else if (c_ptr->m_idx)
1473 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1475 msg_print("There is a monster in the way!");
1482 /* Close the door */
1485 /* Close the door */
1486 more = do_cmd_close_aux(y, x);
1490 /* Cancel repeat unless we may continue */
1491 if (!more) disturb(0, 0);
1496 * Determine if a given grid may be "tunneled"
1498 static bool do_cmd_tunnel_test(int y, int x)
1500 cave_type *c_ptr = &cave[y][x];
1502 /* Must have knowledge */
1503 if (!(c_ptr->info & CAVE_MARK))
1507 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1509 msg_print("You see nothing there.");
1516 /* Must be a wall/door/etc */
1517 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1521 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1523 msg_print("You see nothing there to tunnel.");
1536 * Perform the basic "tunnel" command
1538 * Assumes that no monster is blocking the destination
1540 * Do not use twall anymore
1542 * Returns TRUE if repeated commands may continue
1544 static bool do_cmd_tunnel_aux(int y, int x)
1547 feature_type *f_ptr, *mimic_f_ptr;
1552 /* Verify legality */
1553 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1559 c_ptr = &cave[y][x];
1560 f_ptr = &f_info[c_ptr->feat];
1561 power = f_ptr->power;
1563 /* Feature code (applying "mimic" field) */
1564 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1566 name = f_name + mimic_f_ptr->name;
1571 if (have_flag(f_ptr->flags, FF_PERMANENT))
1574 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1577 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1579 msg_print("This seems to be permanent rock.");
1583 /* Map border (mimiccing Permanent wall) */
1587 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1589 msg_print("You can't tunnel through that!");
1595 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1598 if (p_ptr->skill_dig > randint0(20 * power))
1602 msg_format("%s¤ò¤¯¤º¤·¤¿¡£", name);
1604 msg_format("You have removed the %s.", name);
1607 /* Remove the feature */
1608 cave_alter_feat(y, x, FF_TUNNEL);
1610 /* Update some things */
1611 p_ptr->update |= (PU_FLOW);
1615 /* Message, keep digging */
1617 msg_format("%s¤ò¤¯¤º¤·¤Æ¤¤¤ë¡£", name);
1619 msg_format("You dig into the %s.", name);
1628 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1631 if (p_ptr->skill_dig > power + randint0(40 * power))
1634 if (tree) msg_format("%s¤òÀÚ¤êʧ¤Ã¤¿¡£", name);
1637 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1638 p_ptr->update |= (PU_FLOW);
1641 if (tree) msg_format("You have cleared away the %s.", name);
1644 msg_print("You have finished the tunnel.");
1645 p_ptr->update |= (PU_FLOW);
1650 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1652 /* Remove the feature */
1653 cave_alter_feat(y, x, FF_TUNNEL);
1655 chg_virtue(V_DILIGENCE, 1);
1656 chg_virtue(V_NATURE, -1);
1664 /* We may continue chopping */
1666 msg_format("%s¤òÀڤäƤ¤¤ë¡£", name);
1668 msg_format("You chop away at the %s.", name);
1670 /* Occasional Search XXX XXX */
1671 if (randint0(100) < 25) search();
1675 /* We may continue tunelling */
1677 msg_format("%s¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£", name);
1679 msg_format("You tunnel into the %s.", name);
1687 if (is_hidden_door(c_ptr))
1689 /* Occasional Search XXX XXX */
1690 if (randint0(100) < 25) search();
1699 * Tunnels through "walls" (including rubble and closed doors)
1701 * Note that you must tunnel in order to hit invisible monsters
1702 * in walls, though moving into walls still takes a turn anyway.
1704 * Digging is very difficult without a "digger" weapon, but can be
1705 * accomplished by strong players using heavy weapons.
1707 void do_cmd_tunnel(void)
1717 if (p_ptr->special_defense & KATA_MUSOU)
1719 set_action(ACTION_NONE);
1722 /* Allow repeated command */
1725 /* Set repeat count */
1726 command_rep = command_arg - 1;
1728 /* Redraw the state */
1729 p_ptr->redraw |= (PR_STATE);
1731 /* Cancel the arg */
1735 /* Get a direction to tunnel, or Abort */
1736 if (get_rep_dir(&dir,FALSE))
1743 c_ptr = &cave[y][x];
1745 /* Feature code (applying "mimic" field) */
1746 feat = get_feat_mimic(c_ptr);
1748 /* No tunnelling through doors */
1749 if (have_flag(f_info[feat].flags, FF_DOOR))
1753 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1755 msg_print("You cannot tunnel through doors.");
1759 /* No tunnelling through most features */
1760 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1763 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1765 msg_print("You can't tunnel through that.");
1769 /* A monster is in the way */
1770 else if (c_ptr->m_idx)
1777 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1779 msg_print("There is a monster in the way!");
1789 /* Tunnel through walls */
1790 more = do_cmd_tunnel_aux(y, x);
1794 /* Cancel repetition unless we can continue */
1795 if (!more) disturb(0, 0);
1799 #ifdef ALLOW_EASY_OPEN /* TNB */
1804 * If there is a jammed/closed/locked door at the given location,
1805 * then attempt to unlock/open it. Return TRUE if an attempt was
1806 * made (successful or not), otherwise return FALSE.
1808 * The code here should be nearly identical to that in
1809 * do_cmd_open_test() and do_cmd_open_aux().
1811 bool easy_open_door(int y, int x)
1815 cave_type *c_ptr = &cave[y][x];
1816 feature_type *f_ptr = &f_info[c_ptr->feat];
1818 /* Must be a closed door */
1819 if (!is_closed_door(c_ptr->feat))
1826 if (!have_flag(f_ptr->flags, FF_OPEN))
1830 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1832 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1838 else if (f_ptr->power)
1841 i = p_ptr->skill_dis;
1843 /* Penalize some conditions */
1844 if (p_ptr->blind || no_lite()) i = i / 10;
1845 if (p_ptr->confused || p_ptr->image) i = i / 10;
1847 /* Extract the lock power */
1850 /* Extract the difficulty XXX XXX XXX */
1853 /* Always have a small chance of success */
1857 if (randint0(100) < j)
1861 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1863 msg_print("You have picked the lock.");
1867 cave_alter_feat(y, x, FF_OPEN);
1870 sound(SOUND_OPENDOOR);
1880 if (flush_failure) flush();
1884 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1886 msg_print("You failed to pick the lock.");
1896 cave_alter_feat(y, x, FF_OPEN);
1899 sound(SOUND_OPENDOOR);
1906 #endif /* ALLOW_EASY_OPEN -- TNB */
1910 * Perform the basic "disarm" command
1912 * Assume destination is a visible trap
1914 * Assume there is no monster blocking the destination
1916 * Returns TRUE if repeated commands may continue
1918 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1924 object_type *o_ptr = &o_list[o_idx];
1930 /* Get the "disarm" factor */
1931 i = p_ptr->skill_dis;
1933 /* Penalize some conditions */
1934 if (p_ptr->blind || no_lite()) i = i / 10;
1935 if (p_ptr->confused || p_ptr->image) i = i / 10;
1937 /* Extract the difficulty */
1938 j = i - o_ptr->pval;
1940 /* Always have a small chance of success */
1943 /* Must find the trap first. */
1944 if (!object_is_known(o_ptr))
1947 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
1949 msg_print("I don't see any traps.");
1954 /* Already disarmed/unlocked */
1955 else if (o_ptr->pval <= 0)
1958 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1960 msg_print("The chest is not trapped.");
1965 /* No traps to find. */
1966 else if (!chest_traps[o_ptr->pval])
1969 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1971 msg_print("The chest is not trapped.");
1976 /* Success (get a lot of experience) */
1977 else if (randint0(100) < j)
1980 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
1982 msg_print("You have disarmed the chest.");
1985 gain_exp(o_ptr->pval);
1986 o_ptr->pval = (0 - o_ptr->pval);
1989 /* Failure -- Keep trying */
1990 else if ((i > 5) && (randint1(i) > 5))
1992 /* We may keep trying */
1994 if (flush_failure) flush();
1996 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
1998 msg_print("You failed to disarm the chest.");
2003 /* Failure -- Set off the trap */
2007 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
2009 msg_print("You set off a trap!");
2013 chest_trap(y, x, o_idx);
2022 * Perform the basic "disarm" command
2024 * Assume destination is a visible trap
2026 * Assume there is no monster blocking the destination
2028 * Returns TRUE if repeated commands may continue
2030 #ifdef ALLOW_EASY_DISARM /* TNB */
2032 bool do_cmd_disarm_aux(int y, int x, int dir)
2034 #else /* ALLOW_EASY_DISARM -- TNB */
2036 static bool do_cmd_disarm_aux(int y, int x, int dir)
2038 #endif /* ALLOW_EASY_DISARM -- TNB */
2040 /* Get grid and contents */
2041 cave_type *c_ptr = &cave[y][x];
2044 feature_type *f_ptr = &f_info[c_ptr->feat];
2046 /* Access trap name */
2047 cptr name = (f_name + f_ptr->name);
2049 /* Extract trap "power" */
2050 int power = f_ptr->power;
2054 /* Get the "disarm" factor */
2055 int i = p_ptr->skill_dis;
2062 /* Penalize some conditions */
2063 if (p_ptr->blind || no_lite()) i = i / 10;
2064 if (p_ptr->confused || p_ptr->image) i = i / 10;
2066 /* Extract the difficulty */
2069 /* Always have a small chance of success */
2073 if (randint0(100) < j)
2077 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2079 msg_format("You have disarmed the %s.", name);
2085 /* Remove the trap */
2086 cave_alter_feat(y, x, FF_DISARM);
2088 #ifdef ALLOW_EASY_DISARM /* TNB */
2090 /* Move the player onto the trap */
2091 move_player(dir, easy_disarm, FALSE);
2093 #else /* ALLOW_EASY_DISARM -- TNB */
2095 /* move the player onto the trap grid */
2096 move_player(dir, FALSE, FALSE);
2098 #endif /* ALLOW_EASY_DISARM -- TNB */
2101 /* Failure -- Keep trying */
2102 else if ((i > 5) && (randint1(i) > 5))
2105 if (flush_failure) flush();
2109 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2111 msg_format("You failed to disarm the %s.", name);
2114 /* We may keep trying */
2118 /* Failure -- Set off the trap */
2123 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2125 msg_format("You set off the %s!", name);
2128 #ifdef ALLOW_EASY_DISARM /* TNB */
2130 /* Move the player onto the trap */
2131 move_player(dir, easy_disarm, FALSE);
2133 #else /* ALLOW_EASY_DISARM -- TNB */
2135 /* Move the player onto the trap */
2136 move_player(dir, FALSE, FALSE);
2138 #endif /* ALLOW_EASY_DISARM -- TNB */
2147 * Disarms a trap, or chest
2149 void do_cmd_disarm(void)
2157 if (p_ptr->special_defense & KATA_MUSOU)
2159 set_action(ACTION_NONE);
2162 #ifdef ALLOW_EASY_DISARM /* TNB */
2164 /* Option: Pick a direction */
2167 int num_traps, num_chests;
2169 /* Count visible traps */
2170 num_traps = count_dt(&y, &x, is_trap, TRUE);
2172 /* Count chests (trapped) */
2173 num_chests = count_chests(&y, &x, TRUE);
2175 /* See if only one target */
2176 if (num_traps || num_chests)
2178 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2180 if (!too_many) command_dir = coords_to_dir(y, x);
2184 #endif /* ALLOW_EASY_DISARM -- TNB */
2186 /* Allow repeated command */
2189 /* Set repeat count */
2190 command_rep = command_arg - 1;
2192 /* Redraw the state */
2193 p_ptr->redraw |= (PR_STATE);
2195 /* Cancel the arg */
2199 /* Get a direction (or abort) */
2200 if (get_rep_dir(&dir,TRUE))
2209 /* Get grid and contents */
2210 c_ptr = &cave[y][x];
2212 /* Feature code (applying "mimic" field) */
2213 feat = get_feat_mimic(c_ptr);
2215 /* Check for chests */
2216 o_idx = chest_check(y, x, TRUE);
2219 if (!is_trap(feat) && !o_idx)
2223 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2225 msg_print("You see nothing there to disarm.");
2230 /* Monster in the way */
2231 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2235 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2237 msg_print("There is a monster in the way!");
2248 /* Disarm the chest */
2249 more = do_cmd_disarm_chest(y, x, o_idx);
2255 /* Disarm the trap */
2256 more = do_cmd_disarm_aux(y, x, dir);
2260 /* Cancel repeat unless told not to */
2261 if (!more) disturb(0, 0);
2266 * Perform the basic "bash" command
2268 * Assume destination is a closed/locked/jammed door
2270 * Assume there is no monster blocking the destination
2272 * Returns TRUE if repeated commands may continue
2274 static bool do_cmd_bash_aux(int y, int x, int dir)
2277 cave_type *c_ptr = &cave[y][x];
2280 feature_type *f_ptr = &f_info[c_ptr->feat];
2282 /* Hack -- Bash power based on strength */
2283 /* (Ranges from 3 to 20 to 100 to 200) */
2284 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2286 /* Extract door power */
2287 int temp = f_ptr->power;
2291 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2298 msg_format("%s¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª", name);
2300 msg_format("You smash into the %s!", name);
2303 /* Compare bash power to door power XXX XXX XXX */
2304 temp = (bash - (temp * 10));
2306 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2308 /* Hack -- always have a chance */
2309 if (temp < 1) temp = 1;
2311 /* Hack -- attempt to bash down the door */
2312 if (randint0(100) < temp)
2316 msg_format("%s¤ò²õ¤·¤¿¡ª", name);
2318 msg_format("The %s crashes open!", name);
2322 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
2324 /* Break down the door */
2325 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
2327 cave_alter_feat(y, x, FF_BASH);
2333 cave_alter_feat(y, x, FF_OPEN);
2336 /* Hack -- Fall through the door */
2337 move_player(dir, FALSE, FALSE);
2340 /* Saving throw against stun */
2341 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2346 msg_format("¤³¤Î%s¤Ï´è¾æ¤À¡£", name);
2348 msg_format("The %s holds firm.", name);
2352 /* Allow repeated bashing */
2356 /* High dexterity yields coolness */
2361 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2363 msg_print("You are off-balance.");
2367 /* Hack -- Lose balance ala paralysis */
2368 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2377 * Bash open a door, success based on character strength
2379 * For a closed door, pval is positive if locked; negative if stuck.
2381 * For an open door, pval is positive for a broken door.
2383 * A closed door can be opened - harder if locked. Any door might be
2384 * bashed open (and thereby broken). Bashing a door is (potentially)
2385 * faster! You move into the door way. To open a stuck door, it must
2386 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2388 * Creatures can also open or bash doors, see elsewhere.
2390 void do_cmd_bash(void)
2399 if (p_ptr->special_defense & KATA_MUSOU)
2401 set_action(ACTION_NONE);
2404 /* Allow repeated command */
2407 /* Set repeat count */
2408 command_rep = command_arg - 1;
2410 /* Redraw the state */
2411 p_ptr->redraw |= (PR_STATE);
2413 /* Cancel the arg */
2417 /* Get a "repeated" direction */
2418 if (get_rep_dir(&dir,FALSE))
2427 c_ptr = &cave[y][x];
2429 /* Feature code (applying "mimic" field) */
2430 feat = get_feat_mimic(c_ptr);
2432 /* Nothing useful */
2433 if (!have_flag(f_info[feat].flags, FF_BASH))
2437 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2439 msg_print("You see nothing there to bash.");
2444 /* Monster in the way */
2445 else if (c_ptr->m_idx)
2452 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2454 msg_print("There is a monster in the way!");
2462 /* Bash a closed door */
2466 more = do_cmd_bash_aux(y, x, dir);
2470 /* Unless valid action taken, cancel bash */
2471 if (!more) disturb(0, 0);
2476 * Manipulate an adjacent grid in some way
2478 * Attack monsters, tunnel through walls, disarm traps, open doors.
2480 * Consider confusion XXX XXX XXX
2482 * This command must always take a turn, to prevent free detection
2483 * of invisible monsters.
2485 void do_cmd_alter(void)
2494 if (p_ptr->special_defense & KATA_MUSOU)
2496 set_action(ACTION_NONE);
2499 /* Allow repeated command */
2502 /* Set repeat count */
2503 command_rep = command_arg - 1;
2505 /* Redraw the state */
2506 p_ptr->redraw |= (PR_STATE);
2508 /* Cancel the arg */
2512 /* Get a direction */
2513 if (get_rep_dir(&dir,TRUE))
2516 feature_type *f_ptr;
2523 c_ptr = &cave[y][x];
2525 /* Feature code (applying "mimic" field) */
2526 feat = get_feat_mimic(c_ptr);
2527 f_ptr = &f_info[feat];
2532 /* Attack monsters */
2540 else if (have_flag(f_ptr->flags, FF_OPEN))
2542 more = do_cmd_open_aux(y, x);
2545 /* Bash jammed doors */
2546 else if (have_flag(f_ptr->flags, FF_BASH))
2548 more = do_cmd_bash_aux(y, x, dir);
2551 /* Tunnel through walls */
2552 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2554 more = do_cmd_tunnel_aux(y, x);
2557 /* Close open doors */
2558 else if (have_flag(f_ptr->flags, FF_CLOSE))
2560 more = do_cmd_close_aux(y, x);
2564 else if (have_flag(f_ptr->flags, FF_DISARM))
2566 more = do_cmd_disarm_aux(y, x, dir);
2574 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2576 msg_print("You attack the empty air.");
2582 /* Cancel repetition unless we can continue */
2583 if (!more) disturb(0, 0);
2588 * Find the index of some "spikes", if possible.
2590 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2592 static bool get_spike(int *ip)
2596 /* Check every item in the pack */
2597 for (i = 0; i < INVEN_PACK; i++)
2599 object_type *o_ptr = &inventory[i];
2601 /* Skip non-objects */
2602 if (!o_ptr->k_idx) continue;
2604 /* Check the "tval" code */
2605 if (o_ptr->tval == TV_SPIKE)
2607 /* Save the spike index */
2621 * Jam a closed door with a spike
2623 * This command may NOT be repeated
2625 void do_cmd_spike(void)
2629 if (p_ptr->special_defense & KATA_MUSOU)
2631 set_action(ACTION_NONE);
2634 /* Get a "repeated" direction */
2635 if (get_rep_dir(&dir,FALSE))
2645 /* Get grid and contents */
2646 c_ptr = &cave[y][x];
2648 /* Feature code (applying "mimic" field) */
2649 feat = get_feat_mimic(c_ptr);
2651 /* Require closed door */
2652 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2656 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2658 msg_print("You see nothing there to spike.");
2664 else if (!get_spike(&item))
2668 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2670 msg_print("You have no spikes!");
2674 /* Is a monster in the way? */
2675 else if (c_ptr->m_idx)
2682 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2684 msg_print("There is a monster in the way!");
2697 /* Successful jamming */
2699 msg_format("%s¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£", f_name + f_info[feat].name);
2701 msg_format("You jam the %s with a spike.", f_name + f_info[feat].name);
2704 cave_alter_feat(y, x, FF_SPIKE);
2706 /* Use up, and describe, a single spike, from the bottom */
2707 inven_item_increase(item, -1);
2708 inven_item_describe(item);
2709 inven_item_optimize(item);
2717 * Support code for the "Walk" and "Jump" commands
2719 void do_cmd_walk(bool pickup)
2726 /* Allow repeated command */
2729 /* Set repeat count */
2730 command_rep = command_arg - 1;
2732 /* Redraw the state */
2733 p_ptr->redraw |= (PR_STATE);
2735 /* Cancel the arg */
2739 /* Get a "repeated" direction */
2740 if (get_rep_dir(&dir,FALSE))
2745 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2747 set_action(ACTION_NONE);
2750 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2751 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2752 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2754 /* Actually move the character */
2755 move_player(dir, pickup, FALSE);
2757 /* Allow more walking */
2761 /* Hack again -- Is there a special encounter ??? */
2762 if (p_ptr->wild_mode && !cave_have_flag_bold(py, px, FF_TOWN))
2764 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2767 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2769 /* Inform the player of his horrible fate :=) */
2771 msg_print("½±·â¤À¡ª");
2773 msg_print("You are ambushed !");
2776 /* Go into large wilderness view */
2777 p_ptr->oldpy = randint1(MAX_HGT-2);
2778 p_ptr->oldpx = randint1(MAX_WID-2);
2781 /* Give first move to monsters */
2784 /* HACk -- set the encouter flag for the wilderness generation */
2785 generate_encounter = TRUE;
2789 /* Cancel repeat unless we may continue */
2790 if (!more) disturb(0, 0);
2798 void do_cmd_run(void)
2802 /* Hack -- no running when confused */
2803 if (p_ptr->confused)
2806 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2808 msg_print("You are too confused!");
2814 if (p_ptr->special_defense & KATA_MUSOU)
2816 set_action(ACTION_NONE);
2819 /* Get a "repeated" direction */
2820 if (get_rep_dir(&dir,FALSE))
2822 /* Hack -- Set the run counter */
2823 running = (command_arg ? command_arg : 1000);
2833 * Stay still. Search. Enter stores.
2834 * Pick up treasure if "pickup" is true.
2836 void do_cmd_stay(bool pickup)
2838 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2840 /* Allow repeated command */
2843 /* Set repeat count */
2844 command_rep = command_arg - 1;
2846 /* Redraw the state */
2847 p_ptr->redraw |= (PR_STATE);
2849 /* Cancel the arg */
2856 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2857 (void)move_player_effect(py, px, mpe_mode);
2863 * Resting allows a player to safely restore his hp -RAK-
2865 void do_cmd_rest(void)
2868 set_action(ACTION_NONE);
2870 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
2876 if (hex_spelling_any()) stop_hex_spell_all();
2878 /* Prompt for time if needed */
2879 if (command_arg <= 0)
2882 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
2884 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
2891 strcpy(out_val, "&");
2893 /* Ask for duration */
2894 if (!get_string(p, out_val, 4)) return;
2896 /* Rest until done */
2897 if (out_val[0] == '&')
2903 else if (out_val[0] == '*')
2911 command_arg = atoi(out_val);
2912 if (command_arg <= 0) return;
2918 if (command_arg > 9999) command_arg = 9999;
2920 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2922 /* Take a turn XXX XXX XXX (?) */
2925 /* The sin of sloth */
2926 if (command_arg > 100)
2927 chg_virtue(V_DILIGENCE, -1);
2929 /* Why are you sleeping when there's no need? WAKE UP!*/
2930 if ((p_ptr->chp == p_ptr->mhp) &&
2931 (p_ptr->csp == p_ptr->msp) &&
2932 !p_ptr->blind && !p_ptr->confused &&
2933 !p_ptr->poisoned && !p_ptr->afraid &&
2934 !p_ptr->stun && !p_ptr->cut &&
2935 !p_ptr->slow && !p_ptr->paralyzed &&
2936 !p_ptr->image && !p_ptr->word_recall &&
2937 !p_ptr->alter_reality)
2938 chg_virtue(V_DILIGENCE, -1);
2940 /* Save the rest code */
2941 resting = command_arg;
2942 p_ptr->action = ACTION_REST;
2944 /* Recalculate bonuses */
2945 p_ptr->update |= (PU_BONUS);
2947 /* Redraw the state */
2948 p_ptr->redraw |= (PR_STATE);
2959 * Determines the odds of an object breaking when thrown at a monster
2961 * Note that artifacts never break, see the "drop_near()" function.
2963 static int breakage_chance(object_type *o_ptr)
2965 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2967 /* Examine the snipe type */
2970 if (snipe_type == SP_KILL_WALL) return (100);
2971 if (snipe_type == SP_EXPLODE) return (100);
2972 if (snipe_type == SP_PIERCE) return (100);
2973 if (snipe_type == SP_FINAL) return (100);
2974 if (snipe_type == SP_NEEDLE) return (100);
2975 if (snipe_type == SP_EVILNESS) return (40);
2976 if (snipe_type == SP_HOLYNESS) return (40);
2979 /* Examine the item type */
2980 switch (o_ptr->tval)
2996 /* Sometimes break */
3001 return (20 - archer_bonus * 2);
3006 return (10 - archer_bonus);
3013 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3017 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3019 u32b flgs[TR_FLAG_SIZE];
3021 /* Extract the flags */
3022 object_flags(o_ptr, flgs);
3024 /* Some "weapons" and "ammo" do extra damage */
3025 switch (o_ptr->tval)
3032 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3033 (r_ptr->flags3 & RF3_ANIMAL))
3035 if (is_original_ap_and_seen(m_ptr))
3037 r_ptr->r_flags3 |= RF3_ANIMAL;
3040 if (mult < 17) mult = 17;
3044 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3045 (r_ptr->flags3 & RF3_ANIMAL))
3047 if (is_original_ap_and_seen(m_ptr))
3049 r_ptr->r_flags3 |= RF3_ANIMAL;
3052 if (mult < 27) mult = 27;
3056 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3057 (r_ptr->flags3 & RF3_EVIL))
3059 if (is_original_ap_and_seen(m_ptr))
3061 r_ptr->r_flags3 |= RF3_EVIL;
3064 if (mult < 15) mult = 15;
3068 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3069 (r_ptr->flags3 & RF3_EVIL))
3071 if (is_original_ap_and_seen(m_ptr))
3073 r_ptr->r_flags3 |= RF3_EVIL;
3076 if (mult < 25) mult = 25;
3080 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3081 (r_ptr->flags2 & RF2_HUMAN))
3083 if (is_original_ap_and_seen(m_ptr))
3085 r_ptr->r_flags2 |= RF2_HUMAN;
3088 if (mult < 17) mult = 17;
3092 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3093 (r_ptr->flags2 & RF2_HUMAN))
3095 if (is_original_ap_and_seen(m_ptr))
3097 r_ptr->r_flags2 |= RF2_HUMAN;
3100 if (mult < 27) mult = 27;
3104 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3105 (r_ptr->flags3 & RF3_UNDEAD))
3107 if (is_original_ap_and_seen(m_ptr))
3109 r_ptr->r_flags3 |= RF3_UNDEAD;
3112 if (mult < 20) mult = 20;
3116 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3117 (r_ptr->flags3 & RF3_UNDEAD))
3119 if (is_original_ap_and_seen(m_ptr))
3121 r_ptr->r_flags3 |= RF3_UNDEAD;
3124 if (mult < 30) mult = 30;
3128 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3129 (r_ptr->flags3 & RF3_DEMON))
3131 if (is_original_ap_and_seen(m_ptr))
3133 r_ptr->r_flags3 |= RF3_DEMON;
3136 if (mult < 20) mult = 20;
3140 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3141 (r_ptr->flags3 & RF3_DEMON))
3143 if (is_original_ap_and_seen(m_ptr))
3145 r_ptr->r_flags3 |= RF3_DEMON;
3148 if (mult < 30) mult = 30;
3152 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3153 (r_ptr->flags3 & RF3_ORC))
3155 if (is_original_ap_and_seen(m_ptr))
3157 r_ptr->r_flags3 |= RF3_ORC;
3160 if (mult < 20) mult = 20;
3164 if ((have_flag(flgs, TR_KILL_ORC)) &&
3165 (r_ptr->flags3 & RF3_ORC))
3167 if (is_original_ap_and_seen(m_ptr))
3169 r_ptr->r_flags3 |= RF3_ORC;
3172 if (mult < 30) mult = 30;
3176 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3177 (r_ptr->flags3 & RF3_TROLL))
3179 if (is_original_ap_and_seen(m_ptr))
3181 r_ptr->r_flags3 |= RF3_TROLL;
3184 if (mult < 20) mult = 20;
3188 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3189 (r_ptr->flags3 & RF3_TROLL))
3191 if (is_original_ap_and_seen(m_ptr))
3193 r_ptr->r_flags3 |= RF3_TROLL;
3196 if (mult < 30) mult = 30;
3200 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3201 (r_ptr->flags3 & RF3_GIANT))
3203 if (is_original_ap_and_seen(m_ptr))
3205 r_ptr->r_flags3 |= RF3_GIANT;
3208 if (mult < 20) mult = 20;
3212 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3213 (r_ptr->flags3 & RF3_GIANT))
3215 if (is_original_ap_and_seen(m_ptr))
3217 r_ptr->r_flags3 |= RF3_GIANT;
3220 if (mult < 30) mult = 30;
3224 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3225 (r_ptr->flags3 & RF3_DRAGON))
3227 if (is_original_ap_and_seen(m_ptr))
3229 r_ptr->r_flags3 |= RF3_DRAGON;
3232 if (mult < 20) mult = 20;
3235 /* Execute Dragon */
3236 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3237 (r_ptr->flags3 & RF3_DRAGON))
3239 if (is_original_ap_and_seen(m_ptr))
3241 r_ptr->r_flags3 |= RF3_DRAGON;
3244 if (mult < 30) mult = 30;
3246 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3247 (m_ptr->r_idx == MON_SMAUG) &&
3248 (inventory[INVEN_BOW].name1 == ART_BARD))
3253 if (have_flag(flgs, TR_BRAND_ACID))
3255 /* Notice immunity */
3256 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3258 if (is_original_ap_and_seen(m_ptr))
3260 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3264 /* Otherwise, take the damage */
3267 if (mult < 17) mult = 17;
3272 if (have_flag(flgs, TR_BRAND_ELEC))
3274 /* Notice immunity */
3275 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3277 if (is_original_ap_and_seen(m_ptr))
3279 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3283 /* Otherwise, take the damage */
3286 if (mult < 17) mult = 17;
3291 if (have_flag(flgs, TR_BRAND_FIRE))
3293 /* Notice immunity */
3294 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3296 if (is_original_ap_and_seen(m_ptr))
3298 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3302 /* Otherwise, take the damage */
3305 if (r_ptr->flags3 & RF3_HURT_FIRE)
3307 if (mult < 25) mult = 25;
3308 if (is_original_ap_and_seen(m_ptr))
3310 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3313 else if (mult < 17) mult = 17;
3318 if (have_flag(flgs, TR_BRAND_COLD))
3320 /* Notice immunity */
3321 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3323 if (is_original_ap_and_seen(m_ptr))
3325 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3328 /* Otherwise, take the damage */
3331 if (r_ptr->flags3 & RF3_HURT_COLD)
3333 if (mult < 25) mult = 25;
3334 if (is_original_ap_and_seen(m_ptr))
3336 r_ptr->r_flags3 |= RF3_HURT_COLD;
3339 else if (mult < 17) mult = 17;
3343 /* Brand (Poison) */
3344 if (have_flag(flgs, TR_BRAND_POIS))
3346 /* Notice immunity */
3347 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3349 if (is_original_ap_and_seen(m_ptr))
3351 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3355 /* Otherwise, take the damage */
3358 if (mult < 17) mult = 17;
3362 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3364 p_ptr->csp -= (1+(p_ptr->msp / 30));
3365 p_ptr->redraw |= (PR_MANA);
3366 mult = mult * 5 / 2;
3373 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
3375 /* Return the total damage */
3376 return (tdam * mult / 10);
3381 * Fire an object from the pack or floor.
3383 * You may only fire items that "match" your missile launcher.
3385 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3387 * See "calc_bonuses()" for more calculations and such.
3389 * Note that "firing" a missile is MUCH better than "throwing" it.
3391 * Note: "unseen" monsters are very hard to hit.
3393 * Objects are more likely to break if they "attempt" to hit a monster.
3395 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3397 * The "extra shot" code works by decreasing the amount of energy
3398 * required to make each shot, spreading the shots out over time.
3400 * Note that when firing missiles, the launcher multiplier is applied
3401 * after all the bonuses are added in, making multipliers very useful.
3403 * Note that Bows of "Extra Might" get extra range and an extra bonus
3404 * for the damage multiplier.
3406 * Note that Bows of "Extra Shots" give an extra shot.
3408 void do_cmd_fire_aux(int item, object_type *j_ptr)
3411 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
3412 int tdam_base, tdis, thits, tmul;
3414 int cur_dis, visible;
3421 bool hit_body = FALSE;
3423 char o_name[MAX_NLEN];
3425 u16b path_g[512]; /* For calcuration of path length */
3427 int msec = delay_factor * delay_factor * delay_factor;
3430 bool stick_to = FALSE;
3432 /* Access the item (if in the pack) */
3435 o_ptr = &inventory[item];
3439 o_ptr = &o_list[0 - item];
3442 /* Sniper - Cannot shot a single arrow twice */
3443 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
3445 /* Describe the object */
3446 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3448 /* Use the proper number of shots */
3449 thits = p_ptr->num_fire;
3451 /* Use a base distance */
3454 /* Base damage from thrown object plus launcher bonus */
3455 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3457 /* Actually "fire" the object */
3458 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3459 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3460 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3462 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3464 energy_use = bow_energy(j_ptr->sval);
3465 tmul = bow_tmul(j_ptr->sval);
3467 /* Get extra "power" from "extra might" */
3468 if (p_ptr->xtra_might) tmul++;
3470 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3472 /* Boost the damage */
3477 tdis = 13 + tmul/80;
3478 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3481 tdis -= (5 - (p_ptr->concent + 1) / 2);
3486 project_length = tdis + 1;
3488 /* Get a direction (or cancel) */
3489 if (!get_aim_dir(&dir))
3493 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
3495 /* need not to reset project_length (already did)*/
3500 /* Predict the "target" location */
3501 tx = px + 99 * ddx[dir];
3502 ty = py + 99 * ddy[dir];
3504 /* Check for "target request" */
3505 if ((dir == 5) && target_okay())
3511 /* Get projection path length */
3512 tdis = project_path(path_g, project_length, py, px, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
3514 project_length = 0; /* reset to default */
3516 /* Don't shoot at my feet */
3517 if (tx == px && ty == py)
3521 /* project_length is already reset to 0 */
3527 /* Take a (partial) turn */
3528 energy_use = (energy_use / thits);
3531 /* Sniper - Difficult to shot twice at 1 turn */
3532 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
3534 /* Sniper - Repeat shooting when double shots */
3535 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
3538 /* Start at the player */
3542 /* Get local object */
3545 /* Obtain a local object */
3546 object_copy(q_ptr, o_ptr);
3551 /* Reduce and describe inventory */
3554 inven_item_increase(item, -1);
3555 inven_item_describe(item);
3556 inven_item_optimize(item);
3559 /* Reduce and describe floor item */
3562 floor_item_increase(0 - item, -1);
3563 floor_item_optimize(0 - item);
3569 /* Hack -- Handle stuff */
3572 /* Save the old location */
3576 /* The shot does not hit yet */
3579 /* Travel until stopped */
3580 for (cur_dis = 0; cur_dis <= tdis; )
3584 /* Hack -- Stop at the target */
3585 if ((y == ty) && (x == tx)) break;
3587 /* Calculate the new location (see "project()") */
3590 mmove2(&ny, &nx, py, px, ty, tx);
3593 if (snipe_type == SP_KILL_WALL)
3595 c_ptr = &cave[ny][nx];
3597 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3600 if (c_ptr->info & (CAVE_MARK)) msg_print("´ä¤¬ºÕ¤±»¶¤Ã¤¿¡£");
3602 if (c_ptr->info & (CAVE_MARK)) msg_print("Wall rocks were shattered.");
3604 /* Forget the wall */
3605 c_ptr->info &= ~(CAVE_MARK);
3607 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3609 /* Destroy the wall */
3610 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3617 /* Stopped by walls/doors */
3618 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3620 /* Advance the distance */
3624 if (snipe_type == SP_LITE)
3626 cave[ny][nx].info |= (CAVE_GLOW);
3635 /* The player can see the (on screen) missile */
3636 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3638 char c = object_char(q_ptr);
3639 byte a = object_attr(q_ptr);
3641 /* Draw, Hilite, Fresh, Pause, Erase */
3642 print_rel(c, a, ny, nx);
3643 move_cursor_relative(ny, nx);
3645 Term_xtra(TERM_XTRA_DELAY, msec);
3650 /* The player cannot see the missile */
3653 /* Pause anyway, for consistancy */
3654 Term_xtra(TERM_XTRA_DELAY, msec);
3658 if (snipe_type == SP_KILL_TRAP)
3660 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3661 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3665 if (snipe_type == SP_EVILNESS)
3667 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3676 /* Save the old location */
3680 /* Save the new location */
3685 /* Monster here, Try to hit it */
3686 if (cave[y][x].m_idx)
3689 cave_type *c_ptr = &cave[y][x];
3691 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3692 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3694 /* Check the visibility */
3695 visible = m_ptr->ml;
3697 /* Note the collision */
3700 if (MON_CSLEEP(m_ptr))
3702 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3703 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3706 if ((r_ptr->level + 10) > p_ptr->lev)
3708 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3709 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3712 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3713 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3714 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3715 else if (p_ptr->lev > 34) amount = 2;
3716 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3717 p_ptr->update |= (PU_BONUS);
3723 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3724 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3727 p_ptr->skill_exp[GINOU_RIDING] += 1;
3728 p_ptr->update |= (PU_BONUS);
3732 /* Some shots have hit bonus */
3736 armour *= (10 - p_ptr->concent);
3740 /* Did we hit it (penalize range) */
3741 if (test_hit_fire(chance - cur_dis, armour, m_ptr->ml))
3744 int tdam = tdam_base;
3746 /* Get extra damage from concentration */
3747 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3749 /* Handle unseen monster */
3752 /* Invisible monster */
3754 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3756 msg_format("The %s finds a mark.", o_name);
3761 /* Handle visible monster */
3766 /* Get "the monster" or "it" */
3767 monster_desc(m_name, m_ptr, 0);
3771 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3773 msg_format("The %s hits %s.", o_name, m_name);
3778 /* Hack -- Track this monster race */
3779 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3781 /* Hack -- Track this monster */
3782 health_track(c_ptr->m_idx);
3786 if (snipe_type == SP_NEEDLE)
3788 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3789 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3793 /* Get "the monster" or "it" */
3794 monster_desc(m_name, m_ptr, 0);
3796 tdam = m_ptr->hp + 1;
3798 msg_format("%s¤ÎµÞ½ê¤ËÆͤ»É¤µ¤Ã¤¿¡ª", m_name);
3800 msg_format("Your shot sticked on a fatal spot of %s!", m_name);
3807 /* Apply special damage XXX XXX XXX */
3808 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3809 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3811 /* No negative damage */
3812 if (tdam < 0) tdam = 0;
3814 /* Modify the damage */
3815 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3818 /* Complex message */
3819 if (p_ptr->wizard || cheat_xtra)
3822 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3825 msg_format("You do %d (out of %d) damage.",
3832 if (snipe_type == SP_EXPLODE)
3834 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3836 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3837 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3842 if (snipe_type == SP_HOLYNESS)
3844 cave[ny][nx].info |= (CAVE_GLOW);
3853 /* Hit the monster, check for death */
3854 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3863 if (object_is_fixed_artifact(q_ptr))
3867 monster_desc(m_name, m_ptr, 0);
3871 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3873 msg_format("%^s have stuck into %s!",o_name, m_name);
3878 message_pain(c_ptr->m_idx, tdam);
3880 /* Anger the monster */
3881 if (tdam > 0) anger_monster(m_ptr);
3884 if (fear && m_ptr->ml)
3891 /* Get the monster name (or "it") */
3892 monster_desc(m_name, m_ptr, 0);
3896 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3898 msg_format("%^s flees in terror!", m_name);
3903 set_target(m_ptr, py, px);
3906 if (snipe_type == SP_RUSH)
3908 int n = randint1(5) + 3;
3909 int m_idx = c_ptr->m_idx;
3911 for ( ; cur_dis <= tdis; )
3918 /* Calculate the new location (see "project()") */
3919 mmove2(&ny, &nx, py, px, ty, tx);
3921 /* Stopped by wilderness boundary */
3922 if (!in_bounds2(ny, nx)) break;
3924 /* Stopped by walls/doors */
3925 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3927 /* Stopped by monsters */
3928 if (!cave_empty_bold(ny, nx)) break;
3930 cave[ny][nx].m_idx = m_idx;
3931 cave[oy][ox].m_idx = 0;
3936 /* Update the monster (new location) */
3937 update_mon(c_ptr->m_idx, TRUE);
3943 Term_xtra(TERM_XTRA_DELAY, msec);
3955 if (snipe_type == SP_PIERCE)
3957 if(p_ptr->concent < 1) break;
3967 /* Chance of breakage (during attacks) */
3968 j = (hit_body ? breakage_chance(q_ptr) : 0);
3972 int m_idx = cave[y][x].m_idx;
3973 monster_type *m_ptr = &m_list[m_idx];
3974 int o_idx = o_pop();
3979 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3981 msg_format("The %s have gone to somewhere.", o_name);
3983 if (object_is_fixed_artifact(q_ptr))
3985 a_info[j_ptr->name1].cur_num = 0;
3990 o_ptr = &o_list[o_idx];
3991 object_copy(o_ptr, q_ptr);
3994 o_ptr->marked &= OM_TOUCHED;
3996 /* Forget location */
3997 o_ptr->iy = o_ptr->ix = 0;
3999 /* Memorize monster */
4000 o_ptr->held_m_idx = m_idx;
4003 o_ptr->next_o_idx = m_ptr->hold_o_idx;
4006 m_ptr->hold_o_idx = o_idx;
4008 else if (cave_have_flag_bold(y, x, FF_PROJECT))
4010 /* Drop (or break) near that location */
4011 (void)drop_near(q_ptr, j, y, x);
4015 /* Drop (or break) near that location */
4016 (void)drop_near(q_ptr, j, prev_y, prev_x);
4019 /* Sniper - Repeat shooting when double shots */
4022 /* Sniper - Loose his/her concentration after any shot */
4023 if (p_ptr->concent) reset_concentration(FALSE);
4027 void do_cmd_fire(void)
4033 is_fired = FALSE; /* not fired yet */
4035 /* Get the "bow" (if any) */
4036 j_ptr = &inventory[INVEN_BOW];
4038 /* Require a launcher */
4042 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4044 msg_print("You have nothing to fire with.");
4050 if (j_ptr->sval == SV_CRIMSON)
4053 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4055 msg_print("Do activate.");
4062 if (p_ptr->special_defense & KATA_MUSOU)
4064 set_action(ACTION_NONE);
4067 /* Require proper missile */
4068 item_tester_tval = p_ptr->tval_ammo;
4072 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4073 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4075 q = "Fire which item? ";
4076 s = "You have nothing to fire.";
4079 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4086 do_cmd_fire_aux(item, j_ptr);
4088 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
4090 /* Sniper actions after some shootings */
4091 if (snipe_type == SP_AWAY)
4093 teleport_player(10 + (p_ptr->concent * 2), 0L);
4095 if (snipe_type == SP_FINAL)
4098 msg_print("¼Í·â¤ÎÈ¿Æ°¤¬ÂΤò½±¤Ã¤¿¡£");
4100 msg_print("A reactionary of shooting attacked you. ");
4102 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
4103 (void)set_stun(p_ptr->stun + randint1(25));
4108 static bool item_tester_hook_boomerang(object_type *o_ptr)
4110 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4118 * Throw an object from the pack or floor.
4120 * Note: "unseen" monsters are very hard to hit.
4122 * Should throwing a weapon do full damage? Should it allow the magic
4123 * to hit bonus of the weapon to have an effect? Should it ever cause
4124 * the item to be destroyed? Should it do any damage at all?
4126 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4129 int i, j, y, x, ty, tx, prev_y, prev_x;
4131 int chance, tdam, tdis;
4133 int cur_dis, visible;
4140 bool hit_body = FALSE;
4141 bool hit_wall = FALSE;
4142 bool equiped_item = FALSE;
4143 bool return_when_thrown = FALSE;
4145 char o_name[MAX_NLEN];
4147 int msec = delay_factor * delay_factor * delay_factor;
4149 u32b flgs[TR_FLAG_SIZE];
4151 bool come_back = FALSE;
4152 bool do_drop = TRUE;
4155 if (p_ptr->special_defense & KATA_MUSOU)
4157 set_action(ACTION_NONE);
4166 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
4168 item_tester_hook = item_tester_hook_boomerang;
4170 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4171 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4173 q = "Throw which item? ";
4174 s = "You have nothing to throw.";
4177 if (!get_item(&item, q, s, (USE_EQUIP)))
4183 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
4184 else item = INVEN_RARM;
4190 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4191 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4193 q = "Throw which item? ";
4194 s = "You have nothing to throw.";
4197 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4204 /* Access the item (if in the pack) */
4207 o_ptr = &inventory[item];
4211 o_ptr = &o_list[0 - item];
4215 /* Item is cursed */
4216 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
4220 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4222 msg_print("Hmmm, it seems to be cursed.");
4229 if (p_ptr->inside_arena && !boomerang)
4231 if (o_ptr->tval != TV_SPIKE)
4234 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4236 msg_print("You're in the arena now. This is hand-to-hand!");
4245 /* Get local object */
4248 /* Obtain a local object */
4249 object_copy(q_ptr, o_ptr);
4251 /* Extract the thrown object's flags. */
4252 object_flags(q_ptr, flgs);
4254 /* Distribute the charges of rods/wands between the stacks */
4255 distribute_charges(o_ptr, q_ptr, 1);
4261 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
4263 if (p_ptr->mighty_throw) mult += 3;
4265 /* Extract a "distance multiplier" */
4266 /* Changed for 'launcher' mutation */
4267 mul = 10 + 2 * (mult - 1);
4269 /* Enforce a minimum "weight" of one pound */
4270 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4271 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4273 /* Hack -- Distance -- Reward strength, penalize weight */
4274 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4276 /* Max distance of 10-18 */
4277 if (tdis > mul) tdis = mul;
4281 ty = randint0(101)-50+py;
4282 tx = randint0(101)-50+px;
4286 project_length = tdis + 1;
4288 /* Get a direction (or cancel) */
4289 if (!get_aim_dir(&dir)) return FALSE;
4291 /* Predict the "target" location */
4292 tx = px + 99 * ddx[dir];
4293 ty = py + 99 * ddy[dir];
4295 /* Check for "target request" */
4296 if ((dir == 5) && target_okay())
4302 project_length = 0; /* reset to default */
4305 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4306 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4307 return_when_thrown = TRUE;
4309 /* Reduce and describe inventory */
4312 inven_item_increase(item, -1);
4313 if (!return_when_thrown)
4314 inven_item_describe(item);
4315 inven_item_optimize(item);
4318 /* Reduce and describe floor item */
4321 floor_item_increase(0 - item, -1);
4322 floor_item_optimize(0 - item);
4324 if (item >= INVEN_RARM)
4326 equiped_item = TRUE;
4327 p_ptr->redraw |= (PR_EQUIPPY);
4333 /* Rogue and Ninja gets bonus */
4334 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4335 energy_use -= p_ptr->lev;
4337 /* Start at the player */
4342 /* Hack -- Handle stuff */
4345 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4346 else shuriken = FALSE;
4348 /* Chance of hitting */
4349 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4350 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4351 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4353 if (shuriken) chance *= 2;
4355 /* Save the old location */
4359 /* Travel until stopped */
4360 for (cur_dis = 0; cur_dis <= tdis; )
4362 /* Hack -- Stop at the target */
4363 if ((y == ty) && (x == tx)) break;
4365 /* Calculate the new location (see "project()") */
4368 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4370 /* Stopped by walls/doors */
4371 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
4374 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
4377 /* The player can see the (on screen) missile */
4378 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
4380 char c = object_char(q_ptr);
4381 byte a = object_attr(q_ptr);
4383 /* Draw, Hilite, Fresh, Pause, Erase */
4384 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
4385 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
4387 Term_xtra(TERM_XTRA_DELAY, msec);
4388 lite_spot(ny[cur_dis], nx[cur_dis]);
4392 /* The player cannot see the missile */
4395 /* Pause anyway, for consistancy */
4396 Term_xtra(TERM_XTRA_DELAY, msec);
4399 /* Save the old location */
4403 /* Save the new location */
4407 /* Advance the distance */
4410 /* Monster here, Try to hit it */
4411 if (cave[y][x].m_idx)
4413 cave_type *c_ptr = &cave[y][x];
4415 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4416 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4418 /* Check the visibility */
4419 visible = m_ptr->ml;
4421 /* Note the collision */
4424 /* Did we hit it (penalize range) */
4425 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4429 /* Handle unseen monster */
4432 /* Invisible monster */
4434 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4436 msg_format("The %s finds a mark.", o_name);
4441 /* Handle visible monster */
4446 /* Get "the monster" or "it" */
4447 monster_desc(m_name, m_ptr, 0);
4451 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4453 msg_format("The %s hits %s.", o_name, m_name);
4458 /* Hack -- Track this monster race */
4459 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
4461 /* Hack -- Track this monster */
4462 health_track(c_ptr->m_idx);
4466 /* Hack -- Base damage from thrown object */
4467 tdam = damroll(q_ptr->dd, q_ptr->ds);
4468 /* Apply special damage XXX XXX XXX */
4469 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4470 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4471 if (q_ptr->to_d > 0)
4472 tdam += q_ptr->to_d;
4474 tdam += -q_ptr->to_d;
4478 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4479 tdam += p_ptr->to_d_m;
4481 else if (have_flag(flgs, TR_THROW))
4484 tdam += p_ptr->to_d_m;
4492 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4495 /* No negative damage */
4496 if (tdam < 0) tdam = 0;
4498 /* Modify the damage */
4499 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4501 /* Complex message */
4505 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4508 msg_format("You do %d (out of %d) damage.",
4514 /* Hit the monster, check for death */
4515 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4524 message_pain(c_ptr->m_idx, tdam);
4526 /* Anger the monster */
4527 if ((tdam > 0) && !object_is_potion(q_ptr))
4528 anger_monster(m_ptr);
4531 if (fear && m_ptr->ml)
4538 /* Get the monster name (or "it") */
4539 monster_desc(m_name, m_ptr, 0);
4543 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4545 msg_format("%^s flees in terror!", m_name);
4557 /* Chance of breakage (during attacks) */
4558 j = (hit_body ? breakage_chance(q_ptr) : 0);
4560 /* Figurines transform */
4561 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4565 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4566 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
4568 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4570 msg_print("The Figurine writhes and then shatters.");
4573 else if (object_is_cursed(q_ptr))
4575 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4577 msg_print("You have a bad feeling about this.");
4583 /* Potions smash open */
4584 if (object_is_potion(q_ptr))
4586 if (hit_body || hit_wall || (randint1(100) < j))
4590 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4592 msg_format("The %s shatters!", o_name);
4596 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4598 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4600 /* ToDo (Robert): fix the invulnerability */
4601 if (cave[y][x].m_idx &&
4602 is_friendly(&m_list[cave[y][x].m_idx]) &&
4603 !MON_INVULNER(m_ptr))
4606 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4608 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4610 msg_format("%^s gets angry!", m_name);
4613 set_hostile(&m_list[cave[y][x].m_idx]);
4624 if (return_when_thrown)
4626 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4627 char o2_name[MAX_NLEN];
4628 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4631 if (boomerang) back_chance += 4+randint1(5);
4632 if (super_boomerang) back_chance += 100;
4633 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4635 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4637 for (i = cur_dis - 1; i > 0; i--)
4639 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4641 char c = object_char(q_ptr);
4642 byte a = object_attr(q_ptr);
4644 /* Draw, Hilite, Fresh, Pause, Erase */
4645 print_rel(c, a, ny[i], nx[i]);
4646 move_cursor_relative(ny[i], nx[i]);
4648 Term_xtra(TERM_XTRA_DELAY, msec);
4649 lite_spot(ny[i], nx[i]);
4654 /* Pause anyway, for consistancy */
4655 Term_xtra(TERM_XTRA_DELAY, msec);
4658 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4661 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4663 msg_format("%s comes back to you.", o2_name);
4672 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4674 msg_format("%s backs, but you can't catch!", o2_name);
4680 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4682 msg_format("%s comes back.", o2_name);
4692 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4694 msg_format("%s doesn't back!", o2_name);
4701 if (item == INVEN_RARM || item == INVEN_LARM)
4703 /* Access the wield slot */
4704 o_ptr = &inventory[item];
4706 /* Wear the new stuff */
4707 object_copy(o_ptr, q_ptr);
4709 /* Increase the weight */
4710 p_ptr->total_weight += q_ptr->weight;
4712 /* Increment the equip counter by hand */
4715 /* Recalculate bonuses */
4716 p_ptr->update |= (PU_BONUS);
4718 /* Recalculate torch */
4719 p_ptr->update |= (PU_TORCH);
4721 /* Recalculate mana XXX */
4722 p_ptr->update |= (PU_MANA);
4725 p_ptr->window |= (PW_EQUIP);
4733 else if (equiped_item)
4739 /* Drop (or break) near that location */
4742 if (cave_have_flag_bold(y, x, FF_PROJECT))
4744 /* Drop (or break) near that location */
4745 (void)drop_near(q_ptr, j, y, x);
4749 /* Drop (or break) near that location */
4750 (void)drop_near(q_ptr, j, prev_y, prev_x);
4759 * Throw an object from the pack or floor.
4761 void do_cmd_throw(void)
4763 do_cmd_throw_aux(1, FALSE, -1);
4769 * Hack: travel command
4771 #define TRAVEL_UNABLE 9999
4773 static int flow_head = 0;
4774 static int flow_tail = 0;
4775 static s16b temp2_x[MAX_SHORT];
4776 static s16b temp2_y[MAX_SHORT];
4778 /* Hack: forget the "flow" information */
4779 void forget_travel_flow(void)
4783 /* Check the entire dungeon */
4784 for (y = 0; y < cur_hgt; y++)
4786 for (x = 0; x < cur_wid; x++)
4788 /* Forget the old data */
4789 travel.cost[y][x] = MAX_SHORT;
4794 static int travel_flow_cost(int y, int x)
4796 feature_type *f_ptr = &f_info[cave[y][x].feat];
4799 /* Avoid obstacles (ex. trees) */
4800 if (have_flag(f_ptr->flags, FF_AVOID_RUN)) cost += 1;
4803 if (have_flag(f_ptr->flags, FF_WATER))
4805 if (have_flag(f_ptr->flags, FF_DEEP) && !p_ptr->levitation) cost += 5;
4809 if (have_flag(f_ptr->flags, FF_LAVA))
4812 if (!p_ptr->resist_fire) lava *= 2;
4813 if (!p_ptr->levitation) lava *= 2;
4814 if (have_flag(f_ptr->flags, FF_DEEP)) lava *= 2;
4819 /* Detected traps and doors */
4820 if (cave[y][x].info & (CAVE_MARK))
4822 if (have_flag(f_ptr->flags, FF_DOOR)) cost += 1;
4823 if (have_flag(f_ptr->flags, FF_TRAP)) cost += 10;
4829 static void travel_flow_aux(int y, int x, int n, bool wall)
4831 cave_type *c_ptr = &cave[y][x];
4832 feature_type *f_ptr = &f_info[c_ptr->feat];
4833 int old_head = flow_head;
4835 int base_cost = (n % TRAVEL_UNABLE);
4836 int from_wall = (n / TRAVEL_UNABLE);
4839 /* Ignore out of bounds */
4840 if (!in_bounds(y, x)) return;
4842 /* Ignore unknown grid */
4843 if (!(c_ptr->info & CAVE_KNOWN)) return;
4845 /* Ignore "walls" and "rubble" (include "secret doors") */
4846 if (have_flag(f_ptr->flags, FF_WALL) ||
4847 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4848 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4849 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4851 if (!wall || !from_wall) return;
4852 add_cost += TRAVEL_UNABLE;
4856 add_cost = travel_flow_cost(y, x);
4859 cost = base_cost + add_cost;
4861 /* Ignore lower cost entries */
4862 if (travel.cost[y][x] <= cost) return;
4864 /* Save the flow cost */
4865 travel.cost[y][x] = cost;
4867 /* Enqueue that entry */
4868 temp2_y[flow_head] = y;
4869 temp2_x[flow_head] = x;
4871 /* Advance the queue */
4872 if (++flow_head == MAX_SHORT) flow_head = 0;
4874 /* Hack -- notice overflow by forgetting new entry */
4875 if (flow_head == flow_tail) flow_head = old_head;
4881 static void travel_flow(int ty, int tx)
4885 feature_type *f_ptr = &f_info[cave[py][px].feat];
4887 /* Reset the "queue" */
4888 flow_head = flow_tail = 0;
4890 /* is player in the wall? */
4891 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4893 /* Start at the target grid */
4894 travel_flow_aux(ty, tx, 0, wall);
4896 /* Now process the queue */
4897 while (flow_head != flow_tail)
4899 /* Extract the next entry */
4900 y = temp2_y[flow_tail];
4901 x = temp2_x[flow_tail];
4903 /* Forget that entry */
4904 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4906 /* Ignore too far entries */
4907 //if (distance(ty, tx, y, x) > 100) continue;
4909 /* Add the "children" */
4910 for (d = 0; d < 8; d++)
4912 /* Add that child if "legal" */
4913 travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x], wall);
4917 /* Forget the flow info */
4918 flow_head = flow_tail = 0;
4921 void do_cmd_travel(void)
4925 feature_type *f_ptr;
4927 if (!tgt_pt(&x, &y)) return;
4929 if ((x == px) && (y == py))
4932 msg_print("¤¹¤Ç¤Ë¤½¤³¤Ë¤¤¤Þ¤¹¡ª");
4934 msg_print("You are already there!!");
4939 f_ptr = &f_info[cave[y][x].feat];
4941 if ((cave[y][x].info & CAVE_MARK) &&
4942 (have_flag(f_ptr->flags, FF_WALL) ||
4943 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4944 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4947 msg_print("¤½¤³¤Ë¤Ï¹Ô¤¯¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
4949 msg_print("You cannot travel there!");
4957 forget_travel_flow();
4960 /* Travel till 255 steps */
4966 /* Decides first direction */
4969 sx = ((x == px) || (dx < dy)) ? 0 : ((x > px) ? 1 : -1);
4970 sy = ((y == py) || (dy < dx)) ? 0 : ((y > py) ? 1 : -1);
4972 for (i = 1; i <= 9; i++)
4974 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;