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 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
101 /* Leaving a quest */
102 if (!p_ptr->inside_quest)
108 p_ptr->leaving = TRUE;
113 /* Hack -- take a turn */
116 /* End the command */
126 go_up = confirm_leave_level(FALSE);
129 /* Cancel the command */
132 /* Hack -- take a turn */
135 if (autosave_l) do_cmd_save_game(TRUE);
137 /* For a random quest */
138 if (p_ptr->inside_quest &&
139 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
143 p_ptr->inside_quest = 0;
146 /* For a fixed quest */
147 if (p_ptr->inside_quest &&
148 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
152 p_ptr->inside_quest = c_ptr->special;
157 /* For normal dungeon and random quest */
161 if (have_flag(f_ptr->flags, FF_SHAFT))
163 /* Create a way back */
164 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
170 /* Create a way back */
171 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
176 /* Get out from current dungeon */
177 if (dun_level - up_num < d_info[dungeon_type].mindepth)
182 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
184 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "climbed up the stairs to");
189 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
190 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
191 else if (up_num == dun_level)
192 msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
194 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
196 if (up_num == dun_level)
197 msg_print("You go back to the surface.");
199 msg_print("You enter a maze of up staircases.");
203 p_ptr->leaving = TRUE;
210 void do_cmd_go_down(void)
213 cave_type *c_ptr = &cave[py][px];
214 feature_type *f_ptr = &f_info[c_ptr->feat];
216 bool fall_trap = FALSE;
219 if (p_ptr->special_defense & KATA_MUSOU)
221 set_action(ACTION_NONE);
225 if (!have_flag(f_ptr->flags, FF_MORE))
228 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
230 msg_print("I see no down staircase here.");
236 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
239 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
244 /* Quest down stairs */
245 else if (have_flag(f_ptr->flags, FF_QUEST))
247 /* Confirm Leaving */
248 if(!confirm_leave_level(TRUE)) return;
251 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
252 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
254 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
256 msg_print("You enter the down staircase.");
262 p_ptr->inside_quest = c_ptr->special;
264 /* Activate the quest */
265 if (!quest[p_ptr->inside_quest].status)
267 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
270 /* Leaving a quest */
271 if (!p_ptr->inside_quest)
277 p_ptr->leaving = TRUE;
283 /* Hack -- take a turn */
289 int target_dungeon = 0;
293 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
295 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
298 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
300 msg_print("The entrance of this dungeon is closed!");
304 if (!max_dlv[target_dungeon])
307 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
308 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
310 msg_format("There is the entrance of %s (Danger level: %d)", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
311 if (!get_check("Do you really get in this dungeon? ")) return;
315 /* Save old player position */
318 dungeon_type = (byte)target_dungeon;
321 * Clear all saved floors
322 * and create a first saved floor
324 prepare_change_floor_mode(CFM_FIRST_FLOOR);
327 /* Hack -- take a turn */
330 if (autosave_l) do_cmd_save_game(TRUE);
333 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
338 /* Enter the dungeon just now */
339 p_ptr->enter_dungeon = TRUE;
340 down_num = d_info[dungeon_type].mindepth;
346 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Íî¤È¤·¸Í¤ËÍî¤Á¤¿");
347 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
349 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fell through a trap door");
350 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed down the stairs to");
357 msg_print("¤ï¤¶¤ÈÍî¤È¤·¸Í¤ËÍî¤Á¤¿¡£");
359 msg_print("You deliberately jump through the trap door.");
368 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
370 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
376 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
377 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
379 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
381 msg_print("You enter a maze of down staircases.");
388 p_ptr->leaving = TRUE;
392 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
396 if (have_flag(f_ptr->flags, FF_SHAFT))
398 /* Create a way back */
399 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
403 /* Create a way back */
404 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
413 * Simple command to "search" for one turn
415 void do_cmd_search(void)
417 /* Allow repeated command */
420 /* Set repeat count */
421 command_rep = command_arg - 1;
423 /* Redraw the state */
424 p_ptr->redraw |= (PR_STATE);
439 * Determine if a grid contains a chest
441 static s16b chest_check(int y, int x)
443 cave_type *c_ptr = &cave[y][x];
445 s16b this_o_idx, next_o_idx = 0;
448 /* Scan all objects in the grid */
449 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
454 o_ptr = &o_list[this_o_idx];
456 /* Acquire next object */
457 next_o_idx = o_ptr->next_o_idx;
459 /* Skip unknown chests XXX XXX */
460 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
462 /* Check for chest */
463 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
472 * Allocates objects upon opening a chest -BEN-
474 * Disperse treasures from the given chest, centered at (x,y).
476 * Small chests often contain "gold", while Large chests always contain
477 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
478 * and Steel chests contain 6 items. The "value" of the items in a
479 * chest is based on the "power" of the chest, which is in turn based
480 * on the level on which the chest is generated.
482 static void chest_death(bool scatter, int y, int x, s16b o_idx)
492 object_type *o_ptr = &o_list[o_idx];
495 /* Small chests often hold "gold" */
496 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
498 /* Determine how much to drop (see above) */
499 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
501 if (o_ptr->sval == SV_CHEST_KANDUME)
506 object_level = o_ptr->xtra3;
510 /* Determine the "value" of the items */
511 object_level = ABS(o_ptr->pval) + 10;
514 /* Zero pval means empty chest */
515 if (!o_ptr->pval) number = 0;
517 /* Opening a chest */
518 opening_chest = TRUE;
520 /* Drop some objects (non-chests) */
521 for (; number > 0; --number)
523 /* Get local object */
526 /* Wipe the object */
529 /* Small chests often drop gold */
530 if (small && (randint0(100) < 25))
533 if (!make_gold(q_ptr)) continue;
536 /* Otherwise drop an item */
539 /* Make a good object */
540 if (!make_object(q_ptr, mode)) continue;
543 /* If chest scatters its contents, pick any floor square. */
547 for (i = 0; i < 200; i++)
549 /* Pick a totally random spot. */
550 y = randint0(MAX_HGT);
551 x = randint0(MAX_WID);
553 /* Must be an empty floor. */
554 if (!cave_empty_bold(y, x)) continue;
556 /* Place the object there. */
557 drop_near(q_ptr, -1, y, x);
563 /* Normally, drop object near the chest. */
564 else drop_near(q_ptr, -1, y, x);
567 /* Reset the object level */
568 object_level = base_level;
570 /* No longer opening a chest */
571 opening_chest = FALSE;
582 * Chests have traps too.
584 * Exploding chest destroys contents (and traps).
585 * Note that the chest itself is never destroyed.
587 static void chest_trap(int y, int x, s16b o_idx)
591 object_type *o_ptr = &o_list[o_idx];
593 int mon_level = o_ptr->xtra3;
595 /* Ignore disarmed chests */
596 if (o_ptr->pval <= 0) return;
598 /* Obtain the traps */
599 trap = chest_traps[o_ptr->pval];
602 if (trap & (CHEST_LOSE_STR))
605 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
606 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
608 msg_print("A small needle has pricked you!");
609 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
612 (void)do_dec_stat(A_STR);
615 /* Lose constitution */
616 if (trap & (CHEST_LOSE_CON))
619 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
620 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
622 msg_print("A small needle has pricked you!");
623 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
626 (void)do_dec_stat(A_CON);
630 if (trap & (CHEST_POISON))
633 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
635 msg_print("A puff of green gas surrounds you!");
638 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
640 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
645 if (trap & (CHEST_PARALYZE))
648 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
650 msg_print("A puff of yellow gas surrounds you!");
654 if (!p_ptr->free_act)
656 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
660 /* Summon monsters */
661 if (trap & (CHEST_SUMMON))
663 int num = 2 + randint1(3);
665 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
667 msg_print("You are enveloped in a cloud of smoke!");
671 for (i = 0; i < num; i++)
673 if (randint1(100)<dun_level)
674 activate_hi_summon(py, px, FALSE);
676 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
680 /* Elemental summon. */
681 if (trap & (CHEST_E_SUMMON))
684 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
686 msg_print("Elemental beings appear to protect their treasures!");
688 for (i = 0; i < randint1(3) + 5; i++)
690 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
694 /* Force clouds, then summon birds. */
695 if (trap & (CHEST_BIRD_STORM))
698 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
700 msg_print("A storm of birds swirls around you!");
703 for (i = 0; i < randint1(3) + 3; i++)
704 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
706 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
708 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
712 /* Various colorful summonings. */
713 if (trap & (CHEST_H_SUMMON))
719 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
721 msg_print("Demons materialize in clouds of fire and brimstone!");
724 for (i = 0; i < randint1(3) + 2; i++)
726 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
727 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
731 /* Summon dragons. */
735 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
737 msg_print("Draconic forms loom out of the darkness!");
740 for (i = 0; i < randint1(3) + 2; i++)
742 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
746 /* Summon hybrids. */
750 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
752 msg_print("Creatures strange and twisted assault you!");
755 for (i = 0; i < randint1(5) + 3; i++)
757 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
761 /* Summon vortices (scattered) */
765 msg_print("±²´¬¤¬¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
767 msg_print("Vortices coalesce and wreak destruction!");
770 for (i = 0; i < randint1(3) + 2; i++)
772 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
778 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
780 /* Determine how many nasty tricks can be played. */
781 int nasty_tricks_count = 4 + randint0(3);
785 msg_print("¶²¤í¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
787 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
790 /* This is gonna hurt... */
791 for (; nasty_tricks_count > 0; nasty_tricks_count--)
793 /* ...but a high saving throw does help a little. */
794 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
797 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
799 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
801 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
804 if (!p_ptr->free_act)
805 (void)set_paralyzed(p_ptr->paralyzed + 2 +
808 (void)set_stun(p_ptr->stun + 10 +
811 else if (one_in_(3)) apply_disenchant(0);
814 (void)do_dec_stat(A_STR);
815 (void)do_dec_stat(A_DEX);
816 (void)do_dec_stat(A_CON);
817 (void)do_dec_stat(A_INT);
818 (void)do_dec_stat(A_WIS);
819 (void)do_dec_stat(A_CHR);
821 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
826 /* Aggravate monsters. */
827 if (trap & (CHEST_ALARM))
830 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
832 msg_print("An alarm sounds!");
834 aggravate_monsters(0);
838 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
841 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
842 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
844 msg_print("There is a sudden explosion!");
845 msg_print("Everything inside the chest is destroyed!");
849 sound(SOUND_EXPLODE);
851 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
853 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
857 /* Scatter contents. */
858 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
861 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
863 msg_print("The contents of the chest scatter all over the dungeon!");
865 chest_death(TRUE, y, x, o_idx);
872 * Attempt to open the given chest at the given location
874 * Assume there is no monster blocking the destination
876 * Returns TRUE if repeated commands may continue
878 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
886 object_type *o_ptr = &o_list[o_idx];
892 /* Attempt to unlock it */
895 /* Assume locked, and thus not open */
898 /* Get the "disarm" factor */
899 i = p_ptr->skill_dis;
901 /* Penalize some conditions */
902 if (p_ptr->blind || no_lite()) i = i / 10;
903 if (p_ptr->confused || p_ptr->image) i = i / 10;
905 /* Extract the difficulty */
908 /* Always have a small chance of success */
911 /* Success -- May still have traps */
912 if (randint0(100) < j)
915 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
917 msg_print("You have picked the lock.");
924 /* Failure -- Keep trying */
927 /* We may continue repeating */
929 if (flush_failure) flush();
931 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
933 msg_print("You failed to pick the lock.");
939 /* Allowed to open */
942 /* Apply chest traps, if any */
943 chest_trap(y, x, o_idx);
945 /* Let the Chest drop items */
946 chest_death(FALSE, y, x, o_idx);
954 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
957 * Return TRUE if the given feature is an open door
959 static bool is_open(int feat)
961 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
966 * Return the number of features around (or under) the character.
967 * Usually look for doors and floor traps.
969 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
971 int d, count, xx, yy;
973 /* Count how many matches */
976 /* Check around (and under) the character */
977 for (d = 0; d < 9; d++)
982 /* if not searching under player continue */
983 if ((d == 8) && !under) continue;
985 /* Extract adjacent (legal) location */
986 yy = py + ddy_ddd[d];
987 xx = px + ddx_ddd[d];
990 c_ptr = &cave[yy][xx];
992 /* Must have knowledge */
993 if (!(c_ptr->info & (CAVE_MARK))) continue;
995 /* Feature code (applying "mimic" field) */
996 feat = get_feat_mimic(c_ptr);
998 /* Not looking for this feature */
999 if (!((*test)(feat))) continue;
1004 /* Remember the location. Only useful if only one match */
1015 * Return the number of chests around (or under) the character.
1016 * If requested, count only trapped chests.
1018 static int count_chests(int *y, int *x, bool trapped)
1020 int d, count, o_idx;
1024 /* Count how many matches */
1027 /* Check around (and under) the character */
1028 for (d = 0; d < 9; d++)
1030 /* Extract adjacent (legal) location */
1031 int yy = py + ddy_ddd[d];
1032 int xx = px + ddx_ddd[d];
1034 /* No (visible) chest is there */
1035 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1037 /* Grab the object */
1038 o_ptr = &o_list[o_idx];
1041 if (o_ptr->pval == 0) continue;
1043 /* No (known) traps here */
1044 if (trapped && (!object_is_known(o_ptr) ||
1045 !chest_traps[o_ptr->pval])) continue;
1050 /* Remember the location. Only useful if only one match */
1061 * Convert an adjacent location to a direction.
1063 static int coords_to_dir(int y, int x)
1065 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1072 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1074 return d[dx + 1][dy + 1];
1077 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1081 * Perform the basic "open" command on doors
1083 * Assume destination is a closed/locked/jammed door
1085 * Assume there is no monster blocking the destination
1087 * Returns TRUE if repeated commands may continue
1089 static bool do_cmd_open_aux(int y, int x)
1093 /* Get requested grid */
1094 cave_type *c_ptr = &cave[y][x];
1096 feature_type *f_ptr = &f_info[c_ptr->feat];
1104 /* Seeing true feature code (ignore mimic) */
1107 if (!have_flag(f_ptr->flags, FF_OPEN))
1111 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1113 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1119 else if (f_ptr->power)
1122 i = p_ptr->skill_dis;
1124 /* Penalize some conditions */
1125 if (p_ptr->blind || no_lite()) i = i / 10;
1126 if (p_ptr->confused || p_ptr->image) i = i / 10;
1128 /* Extract the lock power */
1131 /* Extract the difficulty XXX XXX XXX */
1134 /* Always have a small chance of success */
1138 if (randint0(100) < j)
1142 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1144 msg_print("You have picked the lock.");
1148 cave_alter_feat(y, x, FF_OPEN);
1151 sound(SOUND_OPENDOOR);
1161 if (flush_failure) flush();
1165 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1167 msg_print("You failed to pick the lock.");
1171 /* We may keep trying */
1180 cave_alter_feat(y, x, FF_OPEN);
1183 sound(SOUND_OPENDOOR);
1193 * Open a closed/locked/jammed door or a closed/locked chest.
1195 * Unlocking a locked door/chest is worth one experience point.
1197 void do_cmd_open(void)
1205 if (p_ptr->special_defense & KATA_MUSOU)
1207 set_action(ACTION_NONE);
1210 #ifdef ALLOW_EASY_OPEN /* TNB */
1212 /* Option: Pick a direction */
1215 int num_doors, num_chests;
1217 /* Count closed doors (locked or jammed) */
1218 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1220 /* Count chests (locked) */
1221 num_chests = count_chests(&y, &x, FALSE);
1223 /* See if only one target */
1224 if (num_doors || num_chests)
1226 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1228 if (!too_many) command_dir = coords_to_dir(y, x);
1232 #endif /* ALLOW_EASY_OPEN -- TNB */
1234 /* Allow repeated command */
1237 /* Set repeat count */
1238 command_rep = command_arg - 1;
1240 /* Redraw the state */
1241 p_ptr->redraw |= (PR_STATE);
1243 /* Cancel the arg */
1247 /* Get a "repeated" direction */
1248 if (get_rep_dir(&dir, TRUE))
1253 /* Get requested location */
1257 /* Get requested grid */
1258 c_ptr = &cave[y][x];
1260 /* Feature code (applying "mimic" field) */
1261 feat = get_feat_mimic(c_ptr);
1263 /* Check for chest */
1264 o_idx = chest_check(y, x);
1266 /* Nothing useful */
1267 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
1271 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1273 msg_print("You see nothing there to open.");
1278 /* Monster in the way */
1279 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1286 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1288 msg_print("There is a monster in the way!");
1299 /* Open the chest */
1300 more = do_cmd_open_chest(y, x, o_idx);
1307 more = do_cmd_open_aux(y, x);
1311 /* Cancel repeat unless we may continue */
1312 if (!more) disturb(0, 0);
1318 * Perform the basic "close" command
1320 * Assume destination is an open/broken door
1322 * Assume there is no monster blocking the destination
1324 * Returns TRUE if repeated commands may continue
1326 static bool do_cmd_close_aux(int y, int x)
1328 /* Get grid and contents */
1329 cave_type *c_ptr = &cave[y][x];
1330 s16b old_feat = c_ptr->feat;
1336 /* Seeing true feature code (ignore mimic) */
1339 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1341 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
1343 /* Hack -- object in the way */
1344 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
1345 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
1349 msg_print("²¿¤«¤¬¤Ä¤Ã¤«¤¨¤ÆÊĤޤé¤Ê¤¤¡£");
1351 msg_print("There seems stuck.");
1356 /* Close the door */
1357 cave_alter_feat(y, x, FF_CLOSE);
1360 if (old_feat == c_ptr->feat)
1364 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1366 msg_print("The door appears to be broken.");
1372 sound(SOUND_SHUTDOOR);
1383 * Close an open door.
1385 void do_cmd_close(void)
1391 if (p_ptr->special_defense & KATA_MUSOU)
1393 set_action(ACTION_NONE);
1396 #ifdef ALLOW_EASY_OPEN /* TNB */
1398 /* Option: Pick a direction */
1401 /* Count open doors */
1402 if (count_dt(&y, &x, is_open, FALSE) == 1)
1404 command_dir = coords_to_dir(y, x);
1408 #endif /* ALLOW_EASY_OPEN -- TNB */
1410 /* Allow repeated command */
1413 /* Set repeat count */
1414 command_rep = command_arg - 1;
1416 /* Redraw the state */
1417 p_ptr->redraw |= (PR_STATE);
1419 /* Cancel the arg */
1423 /* Get a "repeated" direction */
1424 if (get_rep_dir(&dir,FALSE))
1429 /* Get requested location */
1433 /* Get grid and contents */
1434 c_ptr = &cave[y][x];
1436 /* Feature code (applying "mimic" field) */
1437 feat = get_feat_mimic(c_ptr);
1439 /* Require open/broken door */
1440 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1444 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1446 msg_print("You see nothing there to close.");
1450 /* Monster in the way */
1451 else if (c_ptr->m_idx)
1458 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1460 msg_print("There is a monster in the way!");
1467 /* Close the door */
1470 /* Close the door */
1471 more = do_cmd_close_aux(y, x);
1475 /* Cancel repeat unless we may continue */
1476 if (!more) disturb(0, 0);
1481 * Determine if a given grid may be "tunneled"
1483 static bool do_cmd_tunnel_test(int y, int x)
1485 cave_type *c_ptr = &cave[y][x];
1487 /* Must have knowledge */
1488 if (!(c_ptr->info & CAVE_MARK))
1492 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1494 msg_print("You see nothing there.");
1501 /* Must be a wall/door/etc */
1502 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1506 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1508 msg_print("You see nothing there to tunnel.");
1521 * Perform the basic "tunnel" command
1523 * Assumes that no monster is blocking the destination
1525 * Do not use twall anymore
1527 * Returns TRUE if repeated commands may continue
1529 static bool do_cmd_tunnel_aux(int y, int x)
1532 feature_type *f_ptr, *mimic_f_ptr;
1537 /* Verify legality */
1538 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1544 c_ptr = &cave[y][x];
1545 f_ptr = &f_info[c_ptr->feat];
1546 power = f_ptr->power;
1548 /* Feature code (applying "mimic" field) */
1549 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1551 name = f_name + mimic_f_ptr->name;
1556 if (have_flag(f_ptr->flags, FF_PERMANENT))
1559 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1562 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1564 msg_print("This seems to be permanent rock.");
1568 /* Map border (mimiccing Permanent wall) */
1572 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1574 msg_print("You can't tunnel through that!");
1580 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1583 if (p_ptr->skill_dig > randint0(20 * power))
1587 msg_format("%s¤ò¤¯¤º¤·¤¿¡£", name);
1589 msg_format("You have removed the %s.", name);
1592 /* Remove the feature */
1593 cave_alter_feat(y, x, FF_TUNNEL);
1595 /* Update some things */
1596 p_ptr->update |= (PU_FLOW);
1600 /* Message, keep digging */
1602 msg_format("%s¤ò¤¯¤º¤·¤Æ¤¤¤ë¡£", name);
1604 msg_format("You dig into the %s.", name);
1613 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1616 if (p_ptr->skill_dig > power + randint0(40 * power))
1619 if (tree) msg_format("%s¤òÀÚ¤êʧ¤Ã¤¿¡£", name);
1622 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1623 p_ptr->update |= (PU_FLOW);
1626 if (tree) msg_format("You have cleared away the %s.", name);
1629 msg_print("You have finished the tunnel.");
1630 p_ptr->update |= (PU_FLOW);
1635 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1637 /* Remove the feature */
1638 cave_alter_feat(y, x, FF_TUNNEL);
1640 chg_virtue(V_DILIGENCE, 1);
1641 chg_virtue(V_NATURE, -1);
1649 /* We may continue chopping */
1651 msg_format("%s¤òÀڤäƤ¤¤ë¡£", name);
1653 msg_format("You chop away at the %s.", name);
1655 /* Occasional Search XXX XXX */
1656 if (randint0(100) < 25) search();
1660 /* We may continue tunelling */
1662 msg_format("%s¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£", name);
1664 msg_format("You tunnel into the %s.", name);
1672 if (is_hidden_door(c_ptr))
1674 /* Occasional Search XXX XXX */
1675 if (randint0(100) < 25) search();
1684 * Tunnels through "walls" (including rubble and closed doors)
1686 * Note that you must tunnel in order to hit invisible monsters
1687 * in walls, though moving into walls still takes a turn anyway.
1689 * Digging is very difficult without a "digger" weapon, but can be
1690 * accomplished by strong players using heavy weapons.
1692 void do_cmd_tunnel(void)
1702 if (p_ptr->special_defense & KATA_MUSOU)
1704 set_action(ACTION_NONE);
1707 /* Allow repeated command */
1710 /* Set repeat count */
1711 command_rep = command_arg - 1;
1713 /* Redraw the state */
1714 p_ptr->redraw |= (PR_STATE);
1716 /* Cancel the arg */
1720 /* Get a direction to tunnel, or Abort */
1721 if (get_rep_dir(&dir,FALSE))
1728 c_ptr = &cave[y][x];
1730 /* Feature code (applying "mimic" field) */
1731 feat = get_feat_mimic(c_ptr);
1733 /* No tunnelling through doors */
1734 if (have_flag(f_info[feat].flags, FF_DOOR))
1738 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1740 msg_print("You cannot tunnel through doors.");
1744 /* No tunnelling through most features */
1745 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1748 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1750 msg_print("You can't tunnel through that.");
1754 /* A monster is in the way */
1755 else if (c_ptr->m_idx)
1762 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1764 msg_print("There is a monster in the way!");
1774 /* Tunnel through walls */
1775 more = do_cmd_tunnel_aux(y, x);
1779 /* Cancel repetition unless we can continue */
1780 if (!more) disturb(0, 0);
1784 #ifdef ALLOW_EASY_OPEN /* TNB */
1789 * If there is a jammed/closed/locked door at the given location,
1790 * then attempt to unlock/open it. Return TRUE if an attempt was
1791 * made (successful or not), otherwise return FALSE.
1793 * The code here should be nearly identical to that in
1794 * do_cmd_open_test() and do_cmd_open_aux().
1796 bool easy_open_door(int y, int x)
1800 cave_type *c_ptr = &cave[y][x];
1801 feature_type *f_ptr = &f_info[c_ptr->feat];
1803 /* Must be a closed door */
1804 if (!is_closed_door(c_ptr->feat))
1811 if (!have_flag(f_ptr->flags, FF_OPEN))
1815 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1817 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1823 else if (f_ptr->power)
1826 i = p_ptr->skill_dis;
1828 /* Penalize some conditions */
1829 if (p_ptr->blind || no_lite()) i = i / 10;
1830 if (p_ptr->confused || p_ptr->image) i = i / 10;
1832 /* Extract the lock power */
1835 /* Extract the difficulty XXX XXX XXX */
1838 /* Always have a small chance of success */
1842 if (randint0(100) < j)
1846 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1848 msg_print("You have picked the lock.");
1852 cave_alter_feat(y, x, FF_OPEN);
1855 sound(SOUND_OPENDOOR);
1865 if (flush_failure) flush();
1869 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1871 msg_print("You failed to pick the lock.");
1881 cave_alter_feat(y, x, FF_OPEN);
1884 sound(SOUND_OPENDOOR);
1891 #endif /* ALLOW_EASY_OPEN -- TNB */
1895 * Perform the basic "disarm" command
1897 * Assume destination is a visible trap
1899 * Assume there is no monster blocking the destination
1901 * Returns TRUE if repeated commands may continue
1903 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1909 object_type *o_ptr = &o_list[o_idx];
1915 /* Get the "disarm" factor */
1916 i = p_ptr->skill_dis;
1918 /* Penalize some conditions */
1919 if (p_ptr->blind || no_lite()) i = i / 10;
1920 if (p_ptr->confused || p_ptr->image) i = i / 10;
1922 /* Extract the difficulty */
1923 j = i - o_ptr->pval;
1925 /* Always have a small chance of success */
1928 /* Must find the trap first. */
1929 if (!object_is_known(o_ptr))
1932 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
1934 msg_print("I don't see any traps.");
1939 /* Already disarmed/unlocked */
1940 else if (o_ptr->pval <= 0)
1943 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1945 msg_print("The chest is not trapped.");
1950 /* No traps to find. */
1951 else if (!chest_traps[o_ptr->pval])
1954 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1956 msg_print("The chest is not trapped.");
1961 /* Success (get a lot of experience) */
1962 else if (randint0(100) < j)
1965 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
1967 msg_print("You have disarmed the chest.");
1970 gain_exp(o_ptr->pval);
1971 o_ptr->pval = (0 - o_ptr->pval);
1974 /* Failure -- Keep trying */
1975 else if ((i > 5) && (randint1(i) > 5))
1977 /* We may keep trying */
1979 if (flush_failure) flush();
1981 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
1983 msg_print("You failed to disarm the chest.");
1988 /* Failure -- Set off the trap */
1992 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
1994 msg_print("You set off a trap!");
1998 chest_trap(y, x, o_idx);
2007 * Perform the basic "disarm" command
2009 * Assume destination is a visible trap
2011 * Assume there is no monster blocking the destination
2013 * Returns TRUE if repeated commands may continue
2015 #ifdef ALLOW_EASY_DISARM /* TNB */
2017 bool do_cmd_disarm_aux(int y, int x, int dir)
2019 #else /* ALLOW_EASY_DISARM -- TNB */
2021 static bool do_cmd_disarm_aux(int y, int x, int dir)
2023 #endif /* ALLOW_EASY_DISARM -- TNB */
2025 /* Get grid and contents */
2026 cave_type *c_ptr = &cave[y][x];
2029 feature_type *f_ptr = &f_info[c_ptr->feat];
2031 /* Access trap name */
2032 cptr name = (f_name + f_ptr->name);
2034 /* Extract trap "power" */
2035 int power = f_ptr->power;
2039 /* Get the "disarm" factor */
2040 int i = p_ptr->skill_dis;
2047 /* Penalize some conditions */
2048 if (p_ptr->blind || no_lite()) i = i / 10;
2049 if (p_ptr->confused || p_ptr->image) i = i / 10;
2051 /* Extract the difficulty */
2054 /* Always have a small chance of success */
2058 if (randint0(100) < j)
2062 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2064 msg_format("You have disarmed the %s.", name);
2070 /* Remove the trap */
2071 cave_alter_feat(y, x, FF_DISARM);
2073 #ifdef ALLOW_EASY_DISARM /* TNB */
2075 /* Move the player onto the trap */
2076 move_player(dir, easy_disarm, FALSE);
2078 #else /* ALLOW_EASY_DISARM -- TNB */
2080 /* move the player onto the trap grid */
2081 move_player(dir, FALSE, FALSE);
2083 #endif /* ALLOW_EASY_DISARM -- TNB */
2086 /* Failure -- Keep trying */
2087 else if ((i > 5) && (randint1(i) > 5))
2090 if (flush_failure) flush();
2094 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2096 msg_format("You failed to disarm the %s.", name);
2099 /* We may keep trying */
2103 /* Failure -- Set off the trap */
2108 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2110 msg_format("You set off the %s!", name);
2113 #ifdef ALLOW_EASY_DISARM /* TNB */
2115 /* Move the player onto the trap */
2116 move_player(dir, easy_disarm, FALSE);
2118 #else /* ALLOW_EASY_DISARM -- TNB */
2120 /* Move the player onto the trap */
2121 move_player(dir, FALSE, FALSE);
2123 #endif /* ALLOW_EASY_DISARM -- TNB */
2132 * Disarms a trap, or chest
2134 void do_cmd_disarm(void)
2142 if (p_ptr->special_defense & KATA_MUSOU)
2144 set_action(ACTION_NONE);
2147 #ifdef ALLOW_EASY_DISARM /* TNB */
2149 /* Option: Pick a direction */
2152 int num_traps, num_chests;
2154 /* Count visible traps */
2155 num_traps = count_dt(&y, &x, is_trap, TRUE);
2157 /* Count chests (trapped) */
2158 num_chests = count_chests(&y, &x, TRUE);
2160 /* See if only one target */
2161 if (num_traps || num_chests)
2163 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2165 if (!too_many) command_dir = coords_to_dir(y, x);
2169 #endif /* ALLOW_EASY_DISARM -- TNB */
2171 /* Allow repeated command */
2174 /* Set repeat count */
2175 command_rep = command_arg - 1;
2177 /* Redraw the state */
2178 p_ptr->redraw |= (PR_STATE);
2180 /* Cancel the arg */
2184 /* Get a direction (or abort) */
2185 if (get_rep_dir(&dir,TRUE))
2194 /* Get grid and contents */
2195 c_ptr = &cave[y][x];
2197 /* Feature code (applying "mimic" field) */
2198 feat = get_feat_mimic(c_ptr);
2200 /* Check for chests */
2201 o_idx = chest_check(y, x);
2204 if (!is_trap(feat) && !o_idx)
2208 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2210 msg_print("You see nothing there to disarm.");
2215 /* Monster in the way */
2216 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2220 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2222 msg_print("There is a monster in the way!");
2233 /* Disarm the chest */
2234 more = do_cmd_disarm_chest(y, x, o_idx);
2240 /* Disarm the trap */
2241 more = do_cmd_disarm_aux(y, x, dir);
2245 /* Cancel repeat unless told not to */
2246 if (!more) disturb(0, 0);
2251 * Perform the basic "bash" command
2253 * Assume destination is a closed/locked/jammed door
2255 * Assume there is no monster blocking the destination
2257 * Returns TRUE if repeated commands may continue
2259 static bool do_cmd_bash_aux(int y, int x, int dir)
2262 cave_type *c_ptr = &cave[y][x];
2265 feature_type *f_ptr = &f_info[c_ptr->feat];
2267 /* Hack -- Bash power based on strength */
2268 /* (Ranges from 3 to 20 to 100 to 200) */
2269 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2271 /* Extract door power */
2272 int temp = f_ptr->power;
2276 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2283 msg_format("%s¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª", name);
2285 msg_format("You smash into the %s!", name);
2288 /* Compare bash power to door power XXX XXX XXX */
2289 temp = (bash - (temp * 10));
2291 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2293 /* Hack -- always have a chance */
2294 if (temp < 1) temp = 1;
2296 /* Hack -- attempt to bash down the door */
2297 if (randint0(100) < temp)
2301 msg_format("%s¤ò²õ¤·¤¿¡ª", name);
2303 msg_format("The %s crashes open!", name);
2307 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
2309 /* Break down the door */
2310 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
2312 cave_alter_feat(y, x, FF_BASH);
2318 cave_alter_feat(y, x, FF_OPEN);
2321 /* Hack -- Fall through the door */
2322 move_player(dir, FALSE, FALSE);
2325 /* Saving throw against stun */
2326 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2331 msg_format("¤³¤Î%s¤Ï´è¾æ¤À¡£", name);
2333 msg_format("The %s holds firm.", name);
2337 /* Allow repeated bashing */
2341 /* High dexterity yields coolness */
2346 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2348 msg_print("You are off-balance.");
2352 /* Hack -- Lose balance ala paralysis */
2353 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2362 * Bash open a door, success based on character strength
2364 * For a closed door, pval is positive if locked; negative if stuck.
2366 * For an open door, pval is positive for a broken door.
2368 * A closed door can be opened - harder if locked. Any door might be
2369 * bashed open (and thereby broken). Bashing a door is (potentially)
2370 * faster! You move into the door way. To open a stuck door, it must
2371 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2373 * Creatures can also open or bash doors, see elsewhere.
2375 void do_cmd_bash(void)
2384 if (p_ptr->special_defense & KATA_MUSOU)
2386 set_action(ACTION_NONE);
2389 /* Allow repeated command */
2392 /* Set repeat count */
2393 command_rep = command_arg - 1;
2395 /* Redraw the state */
2396 p_ptr->redraw |= (PR_STATE);
2398 /* Cancel the arg */
2402 /* Get a "repeated" direction */
2403 if (get_rep_dir(&dir,FALSE))
2412 c_ptr = &cave[y][x];
2414 /* Feature code (applying "mimic" field) */
2415 feat = get_feat_mimic(c_ptr);
2417 /* Nothing useful */
2418 if (!have_flag(f_info[feat].flags, FF_BASH))
2422 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2424 msg_print("You see nothing there to bash.");
2429 /* Monster in the way */
2430 else if (c_ptr->m_idx)
2437 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2439 msg_print("There is a monster in the way!");
2447 /* Bash a closed door */
2451 more = do_cmd_bash_aux(y, x, dir);
2455 /* Unless valid action taken, cancel bash */
2456 if (!more) disturb(0, 0);
2461 * Manipulate an adjacent grid in some way
2463 * Attack monsters, tunnel through walls, disarm traps, open doors.
2465 * Consider confusion XXX XXX XXX
2467 * This command must always take a turn, to prevent free detection
2468 * of invisible monsters.
2470 void do_cmd_alter(void)
2479 if (p_ptr->special_defense & KATA_MUSOU)
2481 set_action(ACTION_NONE);
2484 /* Allow repeated command */
2487 /* Set repeat count */
2488 command_rep = command_arg - 1;
2490 /* Redraw the state */
2491 p_ptr->redraw |= (PR_STATE);
2493 /* Cancel the arg */
2497 /* Get a direction */
2498 if (get_rep_dir(&dir,TRUE))
2501 feature_type *f_ptr;
2508 c_ptr = &cave[y][x];
2510 /* Feature code (applying "mimic" field) */
2511 feat = get_feat_mimic(c_ptr);
2512 f_ptr = &f_info[feat];
2517 /* Attack monsters */
2525 else if (have_flag(f_ptr->flags, FF_OPEN))
2527 more = do_cmd_open_aux(y, x);
2530 /* Bash jammed doors */
2531 else if (have_flag(f_ptr->flags, FF_BASH))
2533 more = do_cmd_bash_aux(y, x, dir);
2536 /* Tunnel through walls */
2537 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2539 more = do_cmd_tunnel_aux(y, x);
2542 /* Close open doors */
2543 else if (have_flag(f_ptr->flags, FF_CLOSE))
2545 more = do_cmd_close_aux(y, x);
2549 else if (have_flag(f_ptr->flags, FF_DISARM))
2551 more = do_cmd_disarm_aux(y, x, dir);
2559 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2561 msg_print("You attack the empty air.");
2567 /* Cancel repetition unless we can continue */
2568 if (!more) disturb(0, 0);
2573 * Find the index of some "spikes", if possible.
2575 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2577 static bool get_spike(int *ip)
2581 /* Check every item in the pack */
2582 for (i = 0; i < INVEN_PACK; i++)
2584 object_type *o_ptr = &inventory[i];
2586 /* Skip non-objects */
2587 if (!o_ptr->k_idx) continue;
2589 /* Check the "tval" code */
2590 if (o_ptr->tval == TV_SPIKE)
2592 /* Save the spike index */
2606 * Jam a closed door with a spike
2608 * This command may NOT be repeated
2610 void do_cmd_spike(void)
2614 if (p_ptr->special_defense & KATA_MUSOU)
2616 set_action(ACTION_NONE);
2619 /* Get a "repeated" direction */
2620 if (get_rep_dir(&dir,FALSE))
2630 /* Get grid and contents */
2631 c_ptr = &cave[y][x];
2633 /* Feature code (applying "mimic" field) */
2634 feat = get_feat_mimic(c_ptr);
2636 /* Require closed door */
2637 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2641 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2643 msg_print("You see nothing there to spike.");
2649 else if (!get_spike(&item))
2653 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2655 msg_print("You have no spikes!");
2659 /* Is a monster in the way? */
2660 else if (c_ptr->m_idx)
2667 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2669 msg_print("There is a monster in the way!");
2682 /* Successful jamming */
2684 msg_format("%s¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£", f_name + f_info[feat].name);
2686 msg_format("You jam the %s with a spike.", f_name + f_info[feat].name);
2689 cave_alter_feat(y, x, FF_SPIKE);
2691 /* Use up, and describe, a single spike, from the bottom */
2692 inven_item_increase(item, -1);
2693 inven_item_describe(item);
2694 inven_item_optimize(item);
2702 * Support code for the "Walk" and "Jump" commands
2704 void do_cmd_walk(bool pickup)
2711 /* Allow repeated command */
2714 /* Set repeat count */
2715 command_rep = command_arg - 1;
2717 /* Redraw the state */
2718 p_ptr->redraw |= (PR_STATE);
2720 /* Cancel the arg */
2724 /* Get a "repeated" direction */
2725 if (get_rep_dir(&dir,FALSE))
2730 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2732 set_action(ACTION_NONE);
2735 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2736 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2737 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2739 /* Actually move the character */
2740 move_player(dir, pickup, FALSE);
2742 /* Allow more walking */
2746 /* Hack again -- Is there a special encounter ??? */
2747 if (p_ptr->wild_mode && !cave_have_flag_bold(py, px, FF_TOWN))
2749 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2752 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2754 /* Inform the player of his horrible fate :=) */
2756 msg_print("½±·â¤À¡ª");
2758 msg_print("You are ambushed !");
2761 /* Go into large wilderness view */
2762 p_ptr->oldpy = randint1(MAX_HGT-2);
2763 p_ptr->oldpx = randint1(MAX_WID-2);
2766 /* Give first move to monsters */
2769 /* HACk -- set the encouter flag for the wilderness generation */
2770 generate_encounter = TRUE;
2774 /* Cancel repeat unless we may continue */
2775 if (!more) disturb(0, 0);
2783 void do_cmd_run(void)
2787 /* Hack -- no running when confused */
2788 if (p_ptr->confused)
2791 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2793 msg_print("You are too confused!");
2799 if (p_ptr->special_defense & KATA_MUSOU)
2801 set_action(ACTION_NONE);
2804 /* Get a "repeated" direction */
2805 if (get_rep_dir(&dir,FALSE))
2807 /* Hack -- Set the run counter */
2808 running = (command_arg ? command_arg : 1000);
2818 * Stay still. Search. Enter stores.
2819 * Pick up treasure if "pickup" is true.
2821 void do_cmd_stay(bool pickup)
2823 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2825 /* Allow repeated command */
2828 /* Set repeat count */
2829 command_rep = command_arg - 1;
2831 /* Redraw the state */
2832 p_ptr->redraw |= (PR_STATE);
2834 /* Cancel the arg */
2841 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2842 (void)move_player_effect(py, px, mpe_mode);
2848 * Resting allows a player to safely restore his hp -RAK-
2850 void do_cmd_rest(void)
2853 set_action(ACTION_NONE);
2855 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
2861 if (hex_spelling_any()) stop_hex_spell_all();
2863 /* Prompt for time if needed */
2864 if (command_arg <= 0)
2867 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
2869 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
2876 strcpy(out_val, "&");
2878 /* Ask for duration */
2879 if (!get_string(p, out_val, 4)) return;
2881 /* Rest until done */
2882 if (out_val[0] == '&')
2888 else if (out_val[0] == '*')
2896 command_arg = atoi(out_val);
2897 if (command_arg <= 0) return;
2903 if (command_arg > 9999) command_arg = 9999;
2905 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2907 /* Take a turn XXX XXX XXX (?) */
2910 /* The sin of sloth */
2911 if (command_arg > 100)
2912 chg_virtue(V_DILIGENCE, -1);
2914 /* Why are you sleeping when there's no need? WAKE UP!*/
2915 if ((p_ptr->chp == p_ptr->mhp) &&
2916 (p_ptr->csp == p_ptr->msp) &&
2917 !p_ptr->blind && !p_ptr->confused &&
2918 !p_ptr->poisoned && !p_ptr->afraid &&
2919 !p_ptr->stun && !p_ptr->cut &&
2920 !p_ptr->slow && !p_ptr->paralyzed &&
2921 !p_ptr->image && !p_ptr->word_recall &&
2922 !p_ptr->alter_reality)
2923 chg_virtue(V_DILIGENCE, -1);
2925 /* Save the rest code */
2926 resting = command_arg;
2927 p_ptr->action = ACTION_REST;
2929 /* Recalculate bonuses */
2930 p_ptr->update |= (PU_BONUS);
2932 /* Redraw the state */
2933 p_ptr->redraw |= (PR_STATE);
2944 * Determines the odds of an object breaking when thrown at a monster
2946 * Note that artifacts never break, see the "drop_near()" function.
2948 static int breakage_chance(object_type *o_ptr)
2950 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2952 /* Examine the snipe type */
2955 if (snipe_type == SP_KILL_WALL) return (100);
2956 if (snipe_type == SP_EXPLODE) return (100);
2957 if (snipe_type == SP_PIERCE) return (100);
2958 if (snipe_type == SP_FINAL) return (100);
2959 if (snipe_type == SP_NEEDLE) return (100);
2960 if (snipe_type == SP_EVILNESS) return (40);
2961 if (snipe_type == SP_HOLYNESS) return (40);
2964 /* Examine the item type */
2965 switch (o_ptr->tval)
2981 /* Sometimes break */
2986 return (20 - archer_bonus * 2);
2991 return (10 - archer_bonus);
2998 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
3002 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3004 u32b flgs[TR_FLAG_SIZE];
3006 /* Extract the flags */
3007 object_flags(o_ptr, flgs);
3009 /* Some "weapons" and "ammo" do extra damage */
3010 switch (o_ptr->tval)
3017 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3018 (r_ptr->flags3 & RF3_ANIMAL))
3020 if (is_original_ap_and_seen(m_ptr))
3022 r_ptr->r_flags3 |= RF3_ANIMAL;
3025 if (mult < 17) mult = 17;
3029 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3030 (r_ptr->flags3 & RF3_ANIMAL))
3032 if (is_original_ap_and_seen(m_ptr))
3034 r_ptr->r_flags3 |= RF3_ANIMAL;
3037 if (mult < 27) mult = 27;
3041 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3042 (r_ptr->flags3 & RF3_EVIL))
3044 if (is_original_ap_and_seen(m_ptr))
3046 r_ptr->r_flags3 |= RF3_EVIL;
3049 if (mult < 15) mult = 15;
3053 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3054 (r_ptr->flags3 & RF3_EVIL))
3056 if (is_original_ap_and_seen(m_ptr))
3058 r_ptr->r_flags3 |= RF3_EVIL;
3061 if (mult < 25) mult = 25;
3065 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3066 (r_ptr->flags2 & RF2_HUMAN))
3068 if (is_original_ap_and_seen(m_ptr))
3070 r_ptr->r_flags2 |= RF2_HUMAN;
3073 if (mult < 17) mult = 17;
3077 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3078 (r_ptr->flags2 & RF2_HUMAN))
3080 if (is_original_ap_and_seen(m_ptr))
3082 r_ptr->r_flags2 |= RF2_HUMAN;
3085 if (mult < 27) mult = 27;
3089 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3090 (r_ptr->flags3 & RF3_UNDEAD))
3092 if (is_original_ap_and_seen(m_ptr))
3094 r_ptr->r_flags3 |= RF3_UNDEAD;
3097 if (mult < 20) mult = 20;
3101 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3102 (r_ptr->flags3 & RF3_UNDEAD))
3104 if (is_original_ap_and_seen(m_ptr))
3106 r_ptr->r_flags3 |= RF3_UNDEAD;
3109 if (mult < 30) mult = 30;
3113 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3114 (r_ptr->flags3 & RF3_DEMON))
3116 if (is_original_ap_and_seen(m_ptr))
3118 r_ptr->r_flags3 |= RF3_DEMON;
3121 if (mult < 20) mult = 20;
3125 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3126 (r_ptr->flags3 & RF3_DEMON))
3128 if (is_original_ap_and_seen(m_ptr))
3130 r_ptr->r_flags3 |= RF3_DEMON;
3133 if (mult < 30) mult = 30;
3137 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3138 (r_ptr->flags3 & RF3_ORC))
3140 if (is_original_ap_and_seen(m_ptr))
3142 r_ptr->r_flags3 |= RF3_ORC;
3145 if (mult < 20) mult = 20;
3149 if ((have_flag(flgs, TR_KILL_ORC)) &&
3150 (r_ptr->flags3 & RF3_ORC))
3152 if (is_original_ap_and_seen(m_ptr))
3154 r_ptr->r_flags3 |= RF3_ORC;
3157 if (mult < 30) mult = 30;
3161 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3162 (r_ptr->flags3 & RF3_TROLL))
3164 if (is_original_ap_and_seen(m_ptr))
3166 r_ptr->r_flags3 |= RF3_TROLL;
3169 if (mult < 20) mult = 20;
3173 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3174 (r_ptr->flags3 & RF3_TROLL))
3176 if (is_original_ap_and_seen(m_ptr))
3178 r_ptr->r_flags3 |= RF3_TROLL;
3181 if (mult < 30) mult = 30;
3185 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3186 (r_ptr->flags3 & RF3_GIANT))
3188 if (is_original_ap_and_seen(m_ptr))
3190 r_ptr->r_flags3 |= RF3_GIANT;
3193 if (mult < 20) mult = 20;
3197 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3198 (r_ptr->flags3 & RF3_GIANT))
3200 if (is_original_ap_and_seen(m_ptr))
3202 r_ptr->r_flags3 |= RF3_GIANT;
3205 if (mult < 30) mult = 30;
3209 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3210 (r_ptr->flags3 & RF3_DRAGON))
3212 if (is_original_ap_and_seen(m_ptr))
3214 r_ptr->r_flags3 |= RF3_DRAGON;
3217 if (mult < 20) mult = 20;
3220 /* Execute Dragon */
3221 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3222 (r_ptr->flags3 & RF3_DRAGON))
3224 if (is_original_ap_and_seen(m_ptr))
3226 r_ptr->r_flags3 |= RF3_DRAGON;
3229 if (mult < 30) mult = 30;
3231 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3232 (m_ptr->r_idx == MON_SMAUG) &&
3233 (inventory[INVEN_BOW].name1 == ART_BARD))
3238 if (have_flag(flgs, TR_BRAND_ACID))
3240 /* Notice immunity */
3241 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3243 if (is_original_ap_and_seen(m_ptr))
3245 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3249 /* Otherwise, take the damage */
3252 if (mult < 17) mult = 17;
3257 if (have_flag(flgs, TR_BRAND_ELEC))
3259 /* Notice immunity */
3260 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3262 if (is_original_ap_and_seen(m_ptr))
3264 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3268 /* Otherwise, take the damage */
3271 if (mult < 17) mult = 17;
3276 if (have_flag(flgs, TR_BRAND_FIRE))
3278 /* Notice immunity */
3279 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3281 if (is_original_ap_and_seen(m_ptr))
3283 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3287 /* Otherwise, take the damage */
3290 if (r_ptr->flags3 & RF3_HURT_FIRE)
3292 if (mult < 25) mult = 25;
3293 if (is_original_ap_and_seen(m_ptr))
3295 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3298 else if (mult < 17) mult = 17;
3303 if (have_flag(flgs, TR_BRAND_COLD))
3305 /* Notice immunity */
3306 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3308 if (is_original_ap_and_seen(m_ptr))
3310 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3313 /* Otherwise, take the damage */
3316 if (r_ptr->flags3 & RF3_HURT_COLD)
3318 if (mult < 25) mult = 25;
3319 if (is_original_ap_and_seen(m_ptr))
3321 r_ptr->r_flags3 |= RF3_HURT_COLD;
3324 else if (mult < 17) mult = 17;
3328 /* Brand (Poison) */
3329 if (have_flag(flgs, TR_BRAND_POIS))
3331 /* Notice immunity */
3332 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3334 if (is_original_ap_and_seen(m_ptr))
3336 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3340 /* Otherwise, take the damage */
3343 if (mult < 17) mult = 17;
3347 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3349 p_ptr->csp -= (1+(p_ptr->msp / 30));
3350 p_ptr->redraw |= (PR_MANA);
3351 mult = mult * 5 / 2;
3358 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
3360 /* Return the total damage */
3361 return (tdam * mult / 10);
3366 * Fire an object from the pack or floor.
3368 * You may only fire items that "match" your missile launcher.
3370 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3372 * See "calc_bonuses()" for more calculations and such.
3374 * Note that "firing" a missile is MUCH better than "throwing" it.
3376 * Note: "unseen" monsters are very hard to hit.
3378 * Objects are more likely to break if they "attempt" to hit a monster.
3380 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3382 * The "extra shot" code works by decreasing the amount of energy
3383 * required to make each shot, spreading the shots out over time.
3385 * Note that when firing missiles, the launcher multiplier is applied
3386 * after all the bonuses are added in, making multipliers very useful.
3388 * Note that Bows of "Extra Might" get extra range and an extra bonus
3389 * for the damage multiplier.
3391 * Note that Bows of "Extra Shots" give an extra shot.
3393 void do_cmd_fire_aux(int item, object_type *j_ptr)
3396 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
3397 int tdam_base, tdis, thits, tmul;
3399 int cur_dis, visible;
3406 bool hit_body = FALSE;
3408 char o_name[MAX_NLEN];
3410 u16b path_g[512]; /* For calcuration of path length */
3412 int msec = delay_factor * delay_factor * delay_factor;
3415 bool stick_to = FALSE;
3417 /* Access the item (if in the pack) */
3420 o_ptr = &inventory[item];
3424 o_ptr = &o_list[0 - item];
3427 /* Sniper - Cannot shot a single arrow twice */
3428 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
3430 /* Describe the object */
3431 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3433 /* Use the proper number of shots */
3434 thits = p_ptr->num_fire;
3436 /* Use a base distance */
3439 /* Base damage from thrown object plus launcher bonus */
3440 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3442 /* Actually "fire" the object */
3443 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3444 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3445 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3447 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3449 energy_use = bow_energy(j_ptr->sval);
3450 tmul = bow_tmul(j_ptr->sval);
3452 /* Get extra "power" from "extra might" */
3453 if (p_ptr->xtra_might) tmul++;
3455 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3457 /* Boost the damage */
3462 tdis = 13 + tmul/80;
3463 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3466 tdis -= (5 - (p_ptr->concent + 1) / 2);
3471 project_length = tdis + 1;
3473 /* Get a direction (or cancel) */
3474 if (!get_aim_dir(&dir))
3478 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
3480 /* need not to reset project_length (already did)*/
3485 /* Predict the "target" location */
3486 tx = px + 99 * ddx[dir];
3487 ty = py + 99 * ddy[dir];
3489 /* Check for "target request" */
3490 if ((dir == 5) && target_okay())
3496 /* Get projection path length */
3497 tdis = project_path(path_g, project_length, py, px, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
3499 project_length = 0; /* reset to default */
3501 /* Don't shoot at my feet */
3502 if (tx == px && ty == py)
3506 /* project_length is already reset to 0 */
3512 /* Take a (partial) turn */
3513 energy_use = (energy_use / thits);
3516 /* Sniper - Difficult to shot twice at 1 turn */
3517 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
3519 /* Sniper - Repeat shooting when double shots */
3520 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
3523 /* Start at the player */
3527 /* Get local object */
3530 /* Obtain a local object */
3531 object_copy(q_ptr, o_ptr);
3536 /* Reduce and describe inventory */
3539 inven_item_increase(item, -1);
3540 inven_item_describe(item);
3541 inven_item_optimize(item);
3544 /* Reduce and describe floor item */
3547 floor_item_increase(0 - item, -1);
3548 floor_item_optimize(0 - item);
3554 /* Hack -- Handle stuff */
3557 /* Save the old location */
3561 /* The shot does not hit yet */
3564 /* Travel until stopped */
3565 for (cur_dis = 0; cur_dis <= tdis; )
3569 /* Hack -- Stop at the target */
3570 if ((y == ty) && (x == tx)) break;
3572 /* Calculate the new location (see "project()") */
3575 mmove2(&ny, &nx, py, px, ty, tx);
3578 if (snipe_type == SP_KILL_WALL)
3580 c_ptr = &cave[ny][nx];
3582 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3585 if (c_ptr->info & (CAVE_MARK)) msg_print("´ä¤¬ºÕ¤±»¶¤Ã¤¿¡£");
3587 if (c_ptr->info & (CAVE_MARK)) msg_print("Wall rocks were shattered.");
3589 /* Forget the wall */
3590 c_ptr->info &= ~(CAVE_MARK);
3592 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3594 /* Destroy the wall */
3595 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3602 /* Stopped by walls/doors */
3603 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3605 /* Advance the distance */
3609 if (snipe_type == SP_LITE)
3611 cave[ny][nx].info |= (CAVE_GLOW);
3620 /* The player can see the (on screen) missile */
3621 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3623 char c = object_char(q_ptr);
3624 byte a = object_attr(q_ptr);
3626 /* Draw, Hilite, Fresh, Pause, Erase */
3627 print_rel(c, a, ny, nx);
3628 move_cursor_relative(ny, nx);
3630 Term_xtra(TERM_XTRA_DELAY, msec);
3635 /* The player cannot see the missile */
3638 /* Pause anyway, for consistancy */
3639 Term_xtra(TERM_XTRA_DELAY, msec);
3643 if (snipe_type == SP_KILL_TRAP)
3645 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3646 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3650 if (snipe_type == SP_EVILNESS)
3652 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3661 /* Save the old location */
3665 /* Save the new location */
3670 /* Monster here, Try to hit it */
3671 if (cave[y][x].m_idx)
3674 cave_type *c_ptr = &cave[y][x];
3676 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3677 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3679 /* Check the visibility */
3680 visible = m_ptr->ml;
3682 /* Note the collision */
3685 if (MON_CSLEEP(m_ptr))
3687 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3688 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3691 if ((r_ptr->level + 10) > p_ptr->lev)
3693 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3694 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3697 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3698 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3699 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3700 else if (p_ptr->lev > 34) amount = 2;
3701 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3702 p_ptr->update |= (PU_BONUS);
3708 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3709 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3712 p_ptr->skill_exp[GINOU_RIDING] += 1;
3713 p_ptr->update |= (PU_BONUS);
3717 /* Some shots have hit bonus */
3721 armour *= (10 - p_ptr->concent);
3725 /* Did we hit it (penalize range) */
3726 if (test_hit_fire(chance - cur_dis, armour, m_ptr->ml))
3729 int tdam = tdam_base;
3731 /* Get extra damage from concentration */
3732 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3734 /* Handle unseen monster */
3737 /* Invisible monster */
3739 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3741 msg_format("The %s finds a mark.", o_name);
3746 /* Handle visible monster */
3751 /* Get "the monster" or "it" */
3752 monster_desc(m_name, m_ptr, 0);
3756 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3758 msg_format("The %s hits %s.", o_name, m_name);
3763 /* Hack -- Track this monster race */
3764 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3766 /* Hack -- Track this monster */
3767 health_track(c_ptr->m_idx);
3771 if (snipe_type == SP_NEEDLE)
3773 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3774 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3778 /* Get "the monster" or "it" */
3779 monster_desc(m_name, m_ptr, 0);
3781 tdam = m_ptr->hp + 1;
3783 msg_format("%s¤ÎµÞ½ê¤ËÆͤ»É¤µ¤Ã¤¿¡ª", m_name);
3785 msg_format("Your shot sticked on a fatal spot of %s!", m_name);
3792 /* Apply special damage XXX XXX XXX */
3793 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3794 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3796 /* No negative damage */
3797 if (tdam < 0) tdam = 0;
3799 /* Modify the damage */
3800 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3803 /* Complex message */
3804 if (p_ptr->wizard || cheat_xtra)
3807 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3810 msg_format("You do %d (out of %d) damage.",
3817 if (snipe_type == SP_EXPLODE)
3819 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3821 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3822 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3827 if (snipe_type == SP_HOLYNESS)
3829 cave[ny][nx].info |= (CAVE_GLOW);
3838 /* Hit the monster, check for death */
3839 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3848 if (object_is_fixed_artifact(q_ptr))
3852 monster_desc(m_name, m_ptr, 0);
3856 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3858 msg_format("%^s have stuck into %s!",o_name, m_name);
3863 message_pain(c_ptr->m_idx, tdam);
3865 /* Anger the monster */
3866 if (tdam > 0) anger_monster(m_ptr);
3869 if (fear && m_ptr->ml)
3876 /* Get the monster name (or "it") */
3877 monster_desc(m_name, m_ptr, 0);
3881 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3883 msg_format("%^s flees in terror!", m_name);
3888 set_target(m_ptr, py, px);
3891 if (snipe_type == SP_RUSH)
3893 int n = randint1(5) + 3;
3894 int m_idx = c_ptr->m_idx;
3896 for ( ; cur_dis <= tdis; )
3903 /* Calculate the new location (see "project()") */
3904 mmove2(&ny, &nx, py, px, ty, tx);
3906 /* Stopped by wilderness boundary */
3907 if (!in_bounds2(ny, nx)) break;
3909 /* Stopped by walls/doors */
3910 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3912 /* Stopped by monsters */
3913 if (!cave_empty_bold(ny, nx)) break;
3915 cave[ny][nx].m_idx = m_idx;
3916 cave[oy][ox].m_idx = 0;
3921 /* Update the monster (new location) */
3922 update_mon(c_ptr->m_idx, TRUE);
3928 Term_xtra(TERM_XTRA_DELAY, msec);
3940 if (snipe_type == SP_PIERCE)
3942 if(p_ptr->concent < 1) break;
3952 /* Chance of breakage (during attacks) */
3953 j = (hit_body ? breakage_chance(q_ptr) : 0);
3957 int m_idx = cave[y][x].m_idx;
3958 monster_type *m_ptr = &m_list[m_idx];
3959 int o_idx = o_pop();
3964 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3966 msg_format("The %s have gone to somewhere.", o_name);
3968 if (object_is_fixed_artifact(q_ptr))
3970 a_info[j_ptr->name1].cur_num = 0;
3975 o_ptr = &o_list[o_idx];
3976 object_copy(o_ptr, q_ptr);
3979 o_ptr->marked &= OM_TOUCHED;
3981 /* Forget location */
3982 o_ptr->iy = o_ptr->ix = 0;
3984 /* Memorize monster */
3985 o_ptr->held_m_idx = m_idx;
3988 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3991 m_ptr->hold_o_idx = o_idx;
3993 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3995 /* Drop (or break) near that location */
3996 (void)drop_near(q_ptr, j, y, x);
4000 /* Drop (or break) near that location */
4001 (void)drop_near(q_ptr, j, prev_y, prev_x);
4004 /* Sniper - Repeat shooting when double shots */
4007 /* Sniper - Loose his/her concentration after any shot */
4008 if (p_ptr->concent) reset_concentration(FALSE);
4012 void do_cmd_fire(void)
4018 is_fired = FALSE; /* not fired yet */
4020 /* Get the "bow" (if any) */
4021 j_ptr = &inventory[INVEN_BOW];
4023 /* Require a launcher */
4027 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4029 msg_print("You have nothing to fire with.");
4035 if (j_ptr->sval == SV_CRIMSON)
4038 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4040 msg_print("Do activate.");
4047 if (p_ptr->special_defense & KATA_MUSOU)
4049 set_action(ACTION_NONE);
4052 /* Require proper missile */
4053 item_tester_tval = p_ptr->tval_ammo;
4057 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4058 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4060 q = "Fire which item? ";
4061 s = "You have nothing to fire.";
4064 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4071 do_cmd_fire_aux(item, j_ptr);
4073 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
4075 /* Sniper actions after some shootings */
4076 if (snipe_type == SP_AWAY)
4078 teleport_player(10 + (p_ptr->concent * 2), 0L);
4080 if (snipe_type == SP_FINAL)
4083 msg_print("¼Í·â¤ÎÈ¿Æ°¤¬ÂΤò½±¤Ã¤¿¡£");
4085 msg_print("A reactionary of shooting attacked you. ");
4087 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
4088 (void)set_stun(p_ptr->stun + randint1(25));
4093 static bool item_tester_hook_boomerang(object_type *o_ptr)
4095 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4103 * Throw an object from the pack or floor.
4105 * Note: "unseen" monsters are very hard to hit.
4107 * Should throwing a weapon do full damage? Should it allow the magic
4108 * to hit bonus of the weapon to have an effect? Should it ever cause
4109 * the item to be destroyed? Should it do any damage at all?
4111 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4114 int i, j, y, x, ty, tx, prev_y, prev_x;
4116 int chance, tdam, tdis;
4118 int cur_dis, visible;
4125 bool hit_body = FALSE;
4126 bool hit_wall = FALSE;
4127 bool equiped_item = FALSE;
4128 bool return_when_thrown = FALSE;
4130 char o_name[MAX_NLEN];
4132 int msec = delay_factor * delay_factor * delay_factor;
4134 u32b flgs[TR_FLAG_SIZE];
4136 bool come_back = FALSE;
4137 bool do_drop = TRUE;
4140 if (p_ptr->special_defense & KATA_MUSOU)
4142 set_action(ACTION_NONE);
4151 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
4153 item_tester_hook = item_tester_hook_boomerang;
4155 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4156 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4158 q = "Throw which item? ";
4159 s = "You have nothing to throw.";
4162 if (!get_item(&item, q, s, (USE_EQUIP)))
4168 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
4169 else item = INVEN_RARM;
4175 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4176 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4178 q = "Throw which item? ";
4179 s = "You have nothing to throw.";
4182 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4189 /* Access the item (if in the pack) */
4192 o_ptr = &inventory[item];
4196 o_ptr = &o_list[0 - item];
4200 /* Item is cursed */
4201 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
4205 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4207 msg_print("Hmmm, it seems to be cursed.");
4214 if (p_ptr->inside_arena && !boomerang)
4216 if (o_ptr->tval != TV_SPIKE)
4219 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4221 msg_print("You're in the arena now. This is hand-to-hand!");
4230 /* Get local object */
4233 /* Obtain a local object */
4234 object_copy(q_ptr, o_ptr);
4236 /* Extract the thrown object's flags. */
4237 object_flags(q_ptr, flgs);
4239 /* Distribute the charges of rods/wands between the stacks */
4240 distribute_charges(o_ptr, q_ptr, 1);
4246 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
4248 if (p_ptr->mighty_throw) mult += 3;
4250 /* Extract a "distance multiplier" */
4251 /* Changed for 'launcher' mutation */
4252 mul = 10 + 2 * (mult - 1);
4254 /* Enforce a minimum "weight" of one pound */
4255 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4256 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4258 /* Hack -- Distance -- Reward strength, penalize weight */
4259 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4261 /* Max distance of 10-18 */
4262 if (tdis > mul) tdis = mul;
4266 ty = randint0(101)-50+py;
4267 tx = randint0(101)-50+px;
4271 project_length = tdis + 1;
4273 /* Get a direction (or cancel) */
4274 if (!get_aim_dir(&dir)) return FALSE;
4276 /* Predict the "target" location */
4277 tx = px + 99 * ddx[dir];
4278 ty = py + 99 * ddy[dir];
4280 /* Check for "target request" */
4281 if ((dir == 5) && target_okay())
4287 project_length = 0; /* reset to default */
4290 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4291 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4292 return_when_thrown = TRUE;
4294 /* Reduce and describe inventory */
4297 inven_item_increase(item, -1);
4298 if (!return_when_thrown)
4299 inven_item_describe(item);
4300 inven_item_optimize(item);
4303 /* Reduce and describe floor item */
4306 floor_item_increase(0 - item, -1);
4307 floor_item_optimize(0 - item);
4309 if (item >= INVEN_RARM)
4311 equiped_item = TRUE;
4312 p_ptr->redraw |= (PR_EQUIPPY);
4318 /* Rogue and Ninja gets bonus */
4319 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4320 energy_use -= p_ptr->lev;
4322 /* Start at the player */
4327 /* Hack -- Handle stuff */
4330 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4331 else shuriken = FALSE;
4333 /* Chance of hitting */
4334 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4335 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4336 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4338 if (shuriken) chance *= 2;
4340 /* Save the old location */
4344 /* Travel until stopped */
4345 for (cur_dis = 0; cur_dis <= tdis; )
4347 /* Hack -- Stop at the target */
4348 if ((y == ty) && (x == tx)) break;
4350 /* Calculate the new location (see "project()") */
4353 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4355 /* Stopped by walls/doors */
4356 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
4359 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
4362 /* The player can see the (on screen) missile */
4363 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
4365 char c = object_char(q_ptr);
4366 byte a = object_attr(q_ptr);
4368 /* Draw, Hilite, Fresh, Pause, Erase */
4369 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
4370 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
4372 Term_xtra(TERM_XTRA_DELAY, msec);
4373 lite_spot(ny[cur_dis], nx[cur_dis]);
4377 /* The player cannot see the missile */
4380 /* Pause anyway, for consistancy */
4381 Term_xtra(TERM_XTRA_DELAY, msec);
4384 /* Save the old location */
4388 /* Save the new location */
4392 /* Advance the distance */
4395 /* Monster here, Try to hit it */
4396 if (cave[y][x].m_idx)
4398 cave_type *c_ptr = &cave[y][x];
4400 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4401 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4403 /* Check the visibility */
4404 visible = m_ptr->ml;
4406 /* Note the collision */
4409 /* Did we hit it (penalize range) */
4410 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4414 /* Handle unseen monster */
4417 /* Invisible monster */
4419 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4421 msg_format("The %s finds a mark.", o_name);
4426 /* Handle visible monster */
4431 /* Get "the monster" or "it" */
4432 monster_desc(m_name, m_ptr, 0);
4436 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4438 msg_format("The %s hits %s.", o_name, m_name);
4443 /* Hack -- Track this monster race */
4444 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
4446 /* Hack -- Track this monster */
4447 health_track(c_ptr->m_idx);
4451 /* Hack -- Base damage from thrown object */
4452 tdam = damroll(q_ptr->dd, q_ptr->ds);
4453 /* Apply special damage XXX XXX XXX */
4454 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4455 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4456 if (q_ptr->to_d > 0)
4457 tdam += q_ptr->to_d;
4459 tdam += -q_ptr->to_d;
4463 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4464 tdam += p_ptr->to_d_m;
4466 else if (have_flag(flgs, TR_THROW))
4469 tdam += p_ptr->to_d_m;
4477 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4480 /* No negative damage */
4481 if (tdam < 0) tdam = 0;
4483 /* Modify the damage */
4484 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4486 /* Complex message */
4490 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4493 msg_format("You do %d (out of %d) damage.",
4499 /* Hit the monster, check for death */
4500 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4509 message_pain(c_ptr->m_idx, tdam);
4511 /* Anger the monster */
4512 if ((tdam > 0) && !object_is_potion(q_ptr))
4513 anger_monster(m_ptr);
4516 if (fear && m_ptr->ml)
4523 /* Get the monster name (or "it") */
4524 monster_desc(m_name, m_ptr, 0);
4528 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4530 msg_format("%^s flees in terror!", m_name);
4542 /* Chance of breakage (during attacks) */
4543 j = (hit_body ? breakage_chance(q_ptr) : 0);
4545 /* Figurines transform */
4546 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4550 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4551 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
4553 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4555 msg_print("The Figurine writhes and then shatters.");
4558 else if (object_is_cursed(q_ptr))
4560 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4562 msg_print("You have a bad feeling about this.");
4568 /* Potions smash open */
4569 if (object_is_potion(q_ptr))
4571 if (hit_body || hit_wall || (randint1(100) < j))
4575 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4577 msg_format("The %s shatters!", o_name);
4581 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4583 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4585 /* ToDo (Robert): fix the invulnerability */
4586 if (cave[y][x].m_idx &&
4587 is_friendly(&m_list[cave[y][x].m_idx]) &&
4588 !MON_INVULNER(m_ptr))
4591 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4593 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4595 msg_format("%^s gets angry!", m_name);
4598 set_hostile(&m_list[cave[y][x].m_idx]);
4609 if (return_when_thrown)
4611 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4612 char o2_name[MAX_NLEN];
4613 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4616 if (boomerang) back_chance += 4+randint1(5);
4617 if (super_boomerang) back_chance += 100;
4618 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4620 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4622 for (i = cur_dis - 1; i > 0; i--)
4624 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4626 char c = object_char(q_ptr);
4627 byte a = object_attr(q_ptr);
4629 /* Draw, Hilite, Fresh, Pause, Erase */
4630 print_rel(c, a, ny[i], nx[i]);
4631 move_cursor_relative(ny[i], nx[i]);
4633 Term_xtra(TERM_XTRA_DELAY, msec);
4634 lite_spot(ny[i], nx[i]);
4639 /* Pause anyway, for consistancy */
4640 Term_xtra(TERM_XTRA_DELAY, msec);
4643 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4646 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4648 msg_format("%s comes back to you.", o2_name);
4657 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4659 msg_format("%s backs, but you can't catch!", o2_name);
4665 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4667 msg_format("%s comes back.", o2_name);
4677 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4679 msg_format("%s doesn't back!", o2_name);
4686 if (item == INVEN_RARM || item == INVEN_LARM)
4688 /* Access the wield slot */
4689 o_ptr = &inventory[item];
4691 /* Wear the new stuff */
4692 object_copy(o_ptr, q_ptr);
4694 /* Increase the weight */
4695 p_ptr->total_weight += q_ptr->weight;
4697 /* Increment the equip counter by hand */
4700 /* Recalculate bonuses */
4701 p_ptr->update |= (PU_BONUS);
4703 /* Recalculate torch */
4704 p_ptr->update |= (PU_TORCH);
4706 /* Recalculate mana XXX */
4707 p_ptr->update |= (PU_MANA);
4710 p_ptr->window |= (PW_EQUIP);
4718 else if (equiped_item)
4724 /* Drop (or break) near that location */
4727 if (cave_have_flag_bold(y, x, FF_PROJECT))
4729 /* Drop (or break) near that location */
4730 (void)drop_near(q_ptr, j, y, x);
4734 /* Drop (or break) near that location */
4735 (void)drop_near(q_ptr, j, prev_y, prev_x);
4744 * Throw an object from the pack or floor.
4746 void do_cmd_throw(void)
4748 do_cmd_throw_aux(1, FALSE, -1);
4754 * Hack: travel command
4756 #define TRAVEL_UNABLE 9999
4758 static int flow_head = 0;
4759 static int flow_tail = 0;
4760 static s16b temp2_x[MAX_SHORT];
4761 static s16b temp2_y[MAX_SHORT];
4763 /* Hack: forget the "flow" information */
4764 void forget_travel_flow(void)
4768 /* Check the entire dungeon */
4769 for (y = 0; y < cur_hgt; y++)
4771 for (x = 0; x < cur_wid; x++)
4773 /* Forget the old data */
4774 travel.cost[y][x] = TRAVEL_UNABLE;
4779 static bool travel_flow_aux(int y, int x, int n, bool wall)
4781 cave_type *c_ptr = &cave[y][x];
4782 feature_type *f_ptr = &f_info[c_ptr->feat];
4783 int old_head = flow_head;
4785 n = n % TRAVEL_UNABLE;
4787 /* Ignore out of bounds */
4788 if (!in_bounds(y, x)) return wall;
4790 /* Ignore "pre-stamped" entries */
4791 if (travel.cost[y][x] != TRAVEL_UNABLE) return wall;
4793 /* Ignore "walls" and "rubble" (include "secret doors") */
4794 if (have_flag(f_ptr->flags, FF_WALL) ||
4795 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4796 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4797 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4799 if (!wall) return wall;
4806 /* Save the flow cost */
4807 travel.cost[y][x] = n;
4808 if (wall) travel.cost[y][x] += TRAVEL_UNABLE;
4810 /* Enqueue that entry */
4811 temp2_y[flow_head] = y;
4812 temp2_x[flow_head] = x;
4814 /* Advance the queue */
4815 if (++flow_head == MAX_SHORT) flow_head = 0;
4817 /* Hack -- notice overflow by forgetting new entry */
4818 if (flow_head == flow_tail) flow_head = old_head;
4824 static void travel_flow(int ty, int tx)
4828 feature_type *f_ptr = &f_info[cave[ty][tx].feat];
4830 /* Reset the "queue" */
4831 flow_head = flow_tail = 0;
4833 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4835 /* Add the player's grid to the queue */
4836 wall = travel_flow_aux(ty, tx, 0, wall);
4838 /* Now process the queue */
4839 while (flow_head != flow_tail)
4841 /* Extract the next entry */
4842 y = temp2_y[flow_tail];
4843 x = temp2_x[flow_tail];
4845 /* Forget that entry */
4846 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4848 /* Add the "children" */
4849 for (d = 0; d < 8; d++)
4851 /* Add that child if "legal" */
4852 wall = travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x] + 1, wall);
4856 /* Forget the flow info */
4857 flow_head = flow_tail = 0;
4860 void do_cmd_travel(void)
4864 feature_type *f_ptr;
4866 if (!tgt_pt(&x, &y)) return;
4868 if ((x == px) && (y == py))
4871 msg_print("¤¹¤Ç¤Ë¤½¤³¤Ë¤¤¤Þ¤¹¡ª");
4873 msg_print("You are already there!!");
4878 f_ptr = &f_info[cave[y][x].feat];
4880 if ((cave[y][x].info & CAVE_MARK) &&
4881 (have_flag(f_ptr->flags, FF_WALL) ||
4882 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4883 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4886 msg_print("¤½¤³¤Ë¤Ï¹Ô¤¯¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
4888 msg_print("You cannot travel there!");
4896 forget_travel_flow();
4899 /* Travel till 255 steps */
4905 /* Decides first direction */
4908 sx = ((x == px) || (dx < dy)) ? 0 : ((x > px) ? 1 : -1);
4909 sy = ((y == py) || (dy < dx)) ? 0 : ((y > py) ? 1 : -1);
4911 for (i = 1; i <= 9; i++)
4913 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;