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 /* End the command */
123 go_up = confirm_leave_level(FALSE);
126 /* Cancel the command */
129 /* Hack -- take a turn */
132 if (autosave_l) do_cmd_save_game(TRUE);
134 /* For a random quest */
135 if (p_ptr->inside_quest &&
136 quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
140 p_ptr->inside_quest = 0;
143 /* For a fixed quest */
144 if (p_ptr->inside_quest &&
145 quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
149 p_ptr->inside_quest = c_ptr->special;
154 /* For normal dungeon and random quest */
158 if (have_flag(f_ptr->flags, FF_SHAFT))
160 /* Create a way back */
161 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
167 /* Create a way back */
168 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
173 /* Get out from current dungeon */
174 if (dun_level - up_num < d_info[dungeon_type].mindepth)
179 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
181 if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "climbed up the stairs to");
186 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
187 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
188 else if (up_num == dun_level)
189 msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
191 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
193 if (up_num == dun_level)
194 msg_print("You go back to the surface.");
196 msg_print("You enter a maze of up staircases.");
200 p_ptr->leaving = TRUE;
207 void do_cmd_go_down(void)
210 cave_type *c_ptr = &cave[py][px];
211 feature_type *f_ptr = &f_info[c_ptr->feat];
213 bool fall_trap = FALSE;
216 if (p_ptr->special_defense & KATA_MUSOU)
218 set_action(ACTION_NONE);
222 if (!have_flag(f_ptr->flags, FF_MORE))
225 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
227 msg_print("I see no down staircase here.");
233 if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
236 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
241 /* Quest down stairs */
242 else if (have_flag(f_ptr->flags, FF_QUEST))
244 /* Confirm Leaving */
245 if(!confirm_leave_level(TRUE)) return;
248 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
249 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
251 msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
253 msg_print("You enter the down staircase.");
259 p_ptr->inside_quest = c_ptr->special;
261 /* Activate the quest */
262 if (!quest[p_ptr->inside_quest].status)
264 quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
267 /* Leaving a quest */
268 if (!p_ptr->inside_quest)
274 p_ptr->leaving = TRUE;
282 int target_dungeon = 0;
286 target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
288 if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
291 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
293 msg_print("The entrance of this dungeon is closed!");
297 if (!max_dlv[target_dungeon])
300 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
301 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
303 msg_format("There is the entrance of %s (Danger level: %d)", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
304 if (!get_check("Do you really get in this dungeon? ")) return;
308 /* Save old player position */
311 dungeon_type = (byte)target_dungeon;
314 * Clear all saved floors
315 * and create a first saved floor
317 prepare_change_floor_mode(CFM_FIRST_FLOOR);
320 /* Hack -- take a turn */
323 if (autosave_l) do_cmd_save_game(TRUE);
326 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
331 /* Enter the dungeon just now */
332 p_ptr->enter_dungeon = TRUE;
333 down_num = d_info[dungeon_type].mindepth;
339 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Íî¤È¤·¸Í¤ËÍî¤Á¤¿");
340 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
342 if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fell through a trap door");
343 else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed down the stairs to");
350 msg_print("¤ï¤¶¤ÈÍî¤È¤·¸Í¤ËÍî¤Á¤¿¡£");
352 msg_print("You deliberately jump through the trap door.");
361 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
363 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
369 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
370 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
372 msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤȤòƧ¤ßÆþ¤ì¤¿¡£");
374 msg_print("You enter a maze of down staircases.");
381 p_ptr->leaving = TRUE;
385 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
389 if (have_flag(f_ptr->flags, FF_SHAFT))
391 /* Create a way back */
392 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
396 /* Create a way back */
397 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
406 * Simple command to "search" for one turn
408 void do_cmd_search(void)
410 /* Allow repeated command */
413 /* Set repeat count */
414 command_rep = command_arg - 1;
416 /* Redraw the state */
417 p_ptr->redraw |= (PR_STATE);
432 * Determine if a grid contains a chest
434 static s16b chest_check(int y, int x)
436 cave_type *c_ptr = &cave[y][x];
438 s16b this_o_idx, next_o_idx = 0;
441 /* Scan all objects in the grid */
442 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
447 o_ptr = &o_list[this_o_idx];
449 /* Acquire next object */
450 next_o_idx = o_ptr->next_o_idx;
452 /* Skip unknown chests XXX XXX */
453 /* if (!(o_ptr->marked & OM_FOUND)) continue; */
455 /* Check for chest */
456 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
465 * Allocates objects upon opening a chest -BEN-
467 * Disperse treasures from the given chest, centered at (x,y).
469 * Small chests often contain "gold", while Large chests always contain
470 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
471 * and Steel chests contain 6 items. The "value" of the items in a
472 * chest is based on the "power" of the chest, which is in turn based
473 * on the level on which the chest is generated.
475 static void chest_death(bool scatter, int y, int x, s16b o_idx)
485 object_type *o_ptr = &o_list[o_idx];
488 /* Small chests often hold "gold" */
489 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
491 /* Determine how much to drop (see above) */
492 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
494 if (o_ptr->sval == SV_CHEST_KANDUME)
499 object_level = o_ptr->xtra3;
503 /* Determine the "value" of the items */
504 object_level = ABS(o_ptr->pval) + 10;
507 /* Zero pval means empty chest */
508 if (!o_ptr->pval) number = 0;
510 /* Opening a chest */
511 opening_chest = TRUE;
513 /* Drop some objects (non-chests) */
514 for (; number > 0; --number)
516 /* Get local object */
519 /* Wipe the object */
522 /* Small chests often drop gold */
523 if (small && (randint0(100) < 25))
526 if (!make_gold(q_ptr)) continue;
529 /* Otherwise drop an item */
532 /* Make a good object */
533 if (!make_object(q_ptr, mode)) continue;
536 /* If chest scatters its contents, pick any floor square. */
540 for (i = 0; i < 200; i++)
542 /* Pick a totally random spot. */
543 y = randint0(MAX_HGT);
544 x = randint0(MAX_WID);
546 /* Must be an empty floor. */
547 if (!cave_empty_bold(y, x)) continue;
549 /* Place the object there. */
550 drop_near(q_ptr, -1, y, x);
556 /* Normally, drop object near the chest. */
557 else drop_near(q_ptr, -1, y, x);
560 /* Reset the object level */
561 object_level = base_level;
563 /* No longer opening a chest */
564 opening_chest = FALSE;
575 * Chests have traps too.
577 * Exploding chest destroys contents (and traps).
578 * Note that the chest itself is never destroyed.
580 static void chest_trap(int y, int x, s16b o_idx)
584 object_type *o_ptr = &o_list[o_idx];
586 int mon_level = o_ptr->xtra3;
588 /* Ignore disarmed chests */
589 if (o_ptr->pval <= 0) return;
591 /* Obtain the traps */
592 trap = chest_traps[o_ptr->pval];
595 if (trap & (CHEST_LOSE_STR))
598 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
599 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
601 msg_print("A small needle has pricked you!");
602 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
605 (void)do_dec_stat(A_STR);
608 /* Lose constitution */
609 if (trap & (CHEST_LOSE_CON))
612 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
613 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
615 msg_print("A small needle has pricked you!");
616 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
619 (void)do_dec_stat(A_CON);
623 if (trap & (CHEST_POISON))
626 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
628 msg_print("A puff of green gas surrounds you!");
631 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
633 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
638 if (trap & (CHEST_PARALYZE))
641 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
643 msg_print("A puff of yellow gas surrounds you!");
647 if (!p_ptr->free_act)
649 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
653 /* Summon monsters */
654 if (trap & (CHEST_SUMMON))
656 int num = 2 + randint1(3);
658 msg_print("ÆÍÇ¡¿á¤½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
660 msg_print("You are enveloped in a cloud of smoke!");
664 for (i = 0; i < num; i++)
666 if (randint1(100)<dun_level)
667 activate_hi_summon(py, px, FALSE);
669 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
673 /* Elemental summon. */
674 if (trap & (CHEST_E_SUMMON))
677 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
679 msg_print("Elemental beings appear to protect their treasures!");
681 for (i = 0; i < randint1(3) + 5; i++)
683 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
687 /* Force clouds, then summon birds. */
688 if (trap & (CHEST_BIRD_STORM))
691 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
693 msg_print("A storm of birds swirls around you!");
696 for (i = 0; i < randint1(3) + 3; i++)
697 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
699 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
701 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
705 /* Various colorful summonings. */
706 if (trap & (CHEST_H_SUMMON))
712 msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
714 msg_print("Demons materialize in clouds of fire and brimstone!");
717 for (i = 0; i < randint1(3) + 2; i++)
719 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
720 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
724 /* Summon dragons. */
728 msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
730 msg_print("Draconic forms loom out of the darkness!");
733 for (i = 0; i < randint1(3) + 2; i++)
735 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
739 /* Summon hybrids. */
743 msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
745 msg_print("Creatures strange and twisted assault you!");
748 for (i = 0; i < randint1(5) + 3; i++)
750 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
754 /* Summon vortices (scattered) */
758 msg_print("±²´¬¤¬¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
760 msg_print("Vortices coalesce and wreak destruction!");
763 for (i = 0; i < randint1(3) + 2; i++)
765 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
771 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
773 /* Determine how many nasty tricks can be played. */
774 int nasty_tricks_count = 4 + randint0(3);
778 msg_print("¶²¤í¤·¤¤À¼¤¬¶Á¤¤¤¿: ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
780 msg_print("Hideous voices bid: 'Let the darkness have thee!'");
783 /* This is gonna hurt... */
784 for (; nasty_tricks_count > 0; nasty_tricks_count--)
786 /* ...but a high saving throw does help a little. */
787 if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
790 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
792 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
794 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
797 if (!p_ptr->free_act)
798 (void)set_paralyzed(p_ptr->paralyzed + 2 +
801 (void)set_stun(p_ptr->stun + 10 +
804 else if (one_in_(3)) apply_disenchant(0);
807 (void)do_dec_stat(A_STR);
808 (void)do_dec_stat(A_DEX);
809 (void)do_dec_stat(A_CON);
810 (void)do_dec_stat(A_INT);
811 (void)do_dec_stat(A_WIS);
812 (void)do_dec_stat(A_CHR);
814 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
819 /* Aggravate monsters. */
820 if (trap & (CHEST_ALARM))
823 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
825 msg_print("An alarm sounds!");
827 aggravate_monsters(0);
831 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
834 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
835 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
837 msg_print("There is a sudden explosion!");
838 msg_print("Everything inside the chest is destroyed!");
842 sound(SOUND_EXPLODE);
844 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
846 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
850 /* Scatter contents. */
851 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
854 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
856 msg_print("The contents of the chest scatter all over the dungeon!");
858 chest_death(TRUE, y, x, o_idx);
865 * Attempt to open the given chest at the given location
867 * Assume there is no monster blocking the destination
869 * Returns TRUE if repeated commands may continue
871 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
879 object_type *o_ptr = &o_list[o_idx];
885 /* Attempt to unlock it */
888 /* Assume locked, and thus not open */
891 /* Get the "disarm" factor */
892 i = p_ptr->skill_dis;
894 /* Penalize some conditions */
895 if (p_ptr->blind || no_lite()) i = i / 10;
896 if (p_ptr->confused || p_ptr->image) i = i / 10;
898 /* Extract the difficulty */
901 /* Always have a small chance of success */
904 /* Success -- May still have traps */
905 if (randint0(100) < j)
908 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
910 msg_print("You have picked the lock.");
917 /* Failure -- Keep trying */
920 /* We may continue repeating */
922 if (flush_failure) flush();
924 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
926 msg_print("You failed to pick the lock.");
932 /* Allowed to open */
935 /* Apply chest traps, if any */
936 chest_trap(y, x, o_idx);
938 /* Let the Chest drop items */
939 chest_death(FALSE, y, x, o_idx);
947 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
950 * Return TRUE if the given feature is an open door
952 static bool is_open(int feat)
954 return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
959 * Return the number of features around (or under) the character.
960 * Usually look for doors and floor traps.
962 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
964 int d, count, xx, yy;
966 /* Count how many matches */
969 /* Check around (and under) the character */
970 for (d = 0; d < 9; d++)
975 /* if not searching under player continue */
976 if ((d == 8) && !under) continue;
978 /* Extract adjacent (legal) location */
979 yy = py + ddy_ddd[d];
980 xx = px + ddx_ddd[d];
983 c_ptr = &cave[yy][xx];
985 /* Must have knowledge */
986 if (!(c_ptr->info & (CAVE_MARK))) continue;
988 /* Feature code (applying "mimic" field) */
989 feat = get_feat_mimic(c_ptr);
991 /* Not looking for this feature */
992 if (!((*test)(feat))) continue;
997 /* Remember the location. Only useful if only one match */
1008 * Return the number of chests around (or under) the character.
1009 * If requested, count only trapped chests.
1011 static int count_chests(int *y, int *x, bool trapped)
1013 int d, count, o_idx;
1017 /* Count how many matches */
1020 /* Check around (and under) the character */
1021 for (d = 0; d < 9; d++)
1023 /* Extract adjacent (legal) location */
1024 int yy = py + ddy_ddd[d];
1025 int xx = px + ddx_ddd[d];
1027 /* No (visible) chest is there */
1028 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1030 /* Grab the object */
1031 o_ptr = &o_list[o_idx];
1034 if (o_ptr->pval == 0) continue;
1036 /* No (known) traps here */
1037 if (trapped && (!object_is_known(o_ptr) ||
1038 !chest_traps[o_ptr->pval])) continue;
1043 /* Remember the location. Only useful if only one match */
1054 * Convert an adjacent location to a direction.
1056 static int coords_to_dir(int y, int x)
1058 int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1065 if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1067 return d[dx + 1][dy + 1];
1070 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1074 * Perform the basic "open" command on doors
1076 * Assume destination is a closed/locked/jammed door
1078 * Assume there is no monster blocking the destination
1080 * Returns TRUE if repeated commands may continue
1082 static bool do_cmd_open_aux(int y, int x)
1086 /* Get requested grid */
1087 cave_type *c_ptr = &cave[y][x];
1089 feature_type *f_ptr = &f_info[c_ptr->feat];
1097 /* Seeing true feature code (ignore mimic) */
1100 if (!have_flag(f_ptr->flags, FF_OPEN))
1104 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1106 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1112 else if (f_ptr->power)
1115 i = p_ptr->skill_dis;
1117 /* Penalize some conditions */
1118 if (p_ptr->blind || no_lite()) i = i / 10;
1119 if (p_ptr->confused || p_ptr->image) i = i / 10;
1121 /* Extract the lock power */
1124 /* Extract the difficulty XXX XXX XXX */
1127 /* Always have a small chance of success */
1131 if (randint0(100) < j)
1135 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1137 msg_print("You have picked the lock.");
1141 cave_alter_feat(y, x, FF_OPEN);
1144 sound(SOUND_OPENDOOR);
1154 if (flush_failure) flush();
1158 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1160 msg_print("You failed to pick the lock.");
1164 /* We may keep trying */
1173 cave_alter_feat(y, x, FF_OPEN);
1176 sound(SOUND_OPENDOOR);
1186 * Open a closed/locked/jammed door or a closed/locked chest.
1188 * Unlocking a locked door/chest is worth one experience point.
1190 void do_cmd_open(void)
1198 if (p_ptr->special_defense & KATA_MUSOU)
1200 set_action(ACTION_NONE);
1203 #ifdef ALLOW_EASY_OPEN /* TNB */
1205 /* Option: Pick a direction */
1208 int num_doors, num_chests;
1210 /* Count closed doors (locked or jammed) */
1211 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1213 /* Count chests (locked) */
1214 num_chests = count_chests(&y, &x, FALSE);
1216 /* See if only one target */
1217 if (num_doors || num_chests)
1219 bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1221 if (!too_many) command_dir = coords_to_dir(y, x);
1225 #endif /* ALLOW_EASY_OPEN -- TNB */
1227 /* Allow repeated command */
1230 /* Set repeat count */
1231 command_rep = command_arg - 1;
1233 /* Redraw the state */
1234 p_ptr->redraw |= (PR_STATE);
1236 /* Cancel the arg */
1240 /* Get a "repeated" direction */
1241 if (get_rep_dir(&dir, TRUE))
1246 /* Get requested location */
1250 /* Get requested grid */
1251 c_ptr = &cave[y][x];
1253 /* Feature code (applying "mimic" field) */
1254 feat = get_feat_mimic(c_ptr);
1256 /* Check for chest */
1257 o_idx = chest_check(y, x);
1259 /* Nothing useful */
1260 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
1264 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1266 msg_print("You see nothing there to open.");
1271 /* Monster in the way */
1272 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1279 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1281 msg_print("There is a monster in the way!");
1292 /* Open the chest */
1293 more = do_cmd_open_chest(y, x, o_idx);
1300 more = do_cmd_open_aux(y, x);
1304 /* Cancel repeat unless we may continue */
1305 if (!more) disturb(0, 0);
1311 * Perform the basic "close" command
1313 * Assume destination is an open/broken door
1315 * Assume there is no monster blocking the destination
1317 * Returns TRUE if repeated commands may continue
1319 static bool do_cmd_close_aux(int y, int x)
1321 /* Get grid and contents */
1322 cave_type *c_ptr = &cave[y][x];
1323 s16b old_feat = c_ptr->feat;
1329 /* Seeing true feature code (ignore mimic) */
1332 if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1334 s16b closed_feat = feat_state(old_feat, FF_CLOSE);
1336 /* Hack -- object in the way */
1337 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) &&
1338 (closed_feat != old_feat) && !have_flag(f_info[closed_feat].flags, FF_DROP))
1342 msg_print("²¿¤«¤¬¤Ä¤Ã¤«¤¨¤ÆÊĤޤé¤Ê¤¤¡£");
1344 msg_print("There seems stuck.");
1349 /* Close the door */
1350 cave_alter_feat(y, x, FF_CLOSE);
1353 if (old_feat == c_ptr->feat)
1357 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1359 msg_print("The door appears to be broken.");
1365 sound(SOUND_SHUTDOOR);
1376 * Close an open door.
1378 void do_cmd_close(void)
1384 if (p_ptr->special_defense & KATA_MUSOU)
1386 set_action(ACTION_NONE);
1389 #ifdef ALLOW_EASY_OPEN /* TNB */
1391 /* Option: Pick a direction */
1394 /* Count open doors */
1395 if (count_dt(&y, &x, is_open, FALSE) == 1)
1397 command_dir = coords_to_dir(y, x);
1401 #endif /* ALLOW_EASY_OPEN -- TNB */
1403 /* Allow repeated command */
1406 /* Set repeat count */
1407 command_rep = command_arg - 1;
1409 /* Redraw the state */
1410 p_ptr->redraw |= (PR_STATE);
1412 /* Cancel the arg */
1416 /* Get a "repeated" direction */
1417 if (get_rep_dir(&dir,FALSE))
1422 /* Get requested location */
1426 /* Get grid and contents */
1427 c_ptr = &cave[y][x];
1429 /* Feature code (applying "mimic" field) */
1430 feat = get_feat_mimic(c_ptr);
1432 /* Require open/broken door */
1433 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1437 msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1439 msg_print("You see nothing there to close.");
1443 /* Monster in the way */
1444 else if (c_ptr->m_idx)
1451 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1453 msg_print("There is a monster in the way!");
1460 /* Close the door */
1463 /* Close the door */
1464 more = do_cmd_close_aux(y, x);
1468 /* Cancel repeat unless we may continue */
1469 if (!more) disturb(0, 0);
1474 * Determine if a given grid may be "tunneled"
1476 static bool do_cmd_tunnel_test(int y, int x)
1478 cave_type *c_ptr = &cave[y][x];
1480 /* Must have knowledge */
1481 if (!(c_ptr->info & CAVE_MARK))
1485 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1487 msg_print("You see nothing there.");
1494 /* Must be a wall/door/etc */
1495 if (!cave_have_flag_grid(c_ptr, FF_TUNNEL))
1499 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1501 msg_print("You see nothing there to tunnel.");
1514 * Perform the basic "tunnel" command
1516 * Assumes that no monster is blocking the destination
1518 * Do not use twall anymore
1520 * Returns TRUE if repeated commands may continue
1522 static bool do_cmd_tunnel_aux(int y, int x)
1525 feature_type *f_ptr, *mimic_f_ptr;
1530 /* Verify legality */
1531 if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1537 c_ptr = &cave[y][x];
1538 f_ptr = &f_info[c_ptr->feat];
1539 power = f_ptr->power;
1541 /* Feature code (applying "mimic" field) */
1542 mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1544 name = f_name + mimic_f_ptr->name;
1549 if (have_flag(f_ptr->flags, FF_PERMANENT))
1552 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1555 msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1557 msg_print("This seems to be permanent rock.");
1561 /* Map border (mimiccing Permanent wall) */
1565 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1567 msg_print("You can't tunnel through that!");
1573 else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1576 if (p_ptr->skill_dig > randint0(20 * power))
1580 msg_format("%s¤ò¤¯¤º¤·¤¿¡£", name);
1582 msg_format("You have removed the %s.", name);
1585 /* Remove the feature */
1586 cave_alter_feat(y, x, FF_TUNNEL);
1588 /* Update some things */
1589 p_ptr->update |= (PU_FLOW);
1593 /* Message, keep digging */
1595 msg_format("%s¤ò¤¯¤º¤·¤Æ¤¤¤ë¡£", name);
1597 msg_format("You dig into the %s.", name);
1606 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1609 if (p_ptr->skill_dig > power + randint0(40 * power))
1612 if (tree) msg_format("%s¤òÀÚ¤êʧ¤Ã¤¿¡£", name);
1615 msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1616 p_ptr->update |= (PU_FLOW);
1619 if (tree) msg_format("You have cleared away the %s.", name);
1622 msg_print("You have finished the tunnel.");
1623 p_ptr->update |= (PU_FLOW);
1628 if (have_flag(f_ptr->flags, FF_GLASS)) sound(SOUND_GLASS);
1630 /* Remove the feature */
1631 cave_alter_feat(y, x, FF_TUNNEL);
1633 chg_virtue(V_DILIGENCE, 1);
1634 chg_virtue(V_NATURE, -1);
1642 /* We may continue chopping */
1644 msg_format("%s¤òÀڤäƤ¤¤ë¡£", name);
1646 msg_format("You chop away at the %s.", name);
1648 /* Occasional Search XXX XXX */
1649 if (randint0(100) < 25) search();
1653 /* We may continue tunelling */
1655 msg_format("%s¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£", name);
1657 msg_format("You tunnel into the %s.", name);
1665 if (is_hidden_door(c_ptr))
1667 /* Occasional Search XXX XXX */
1668 if (randint0(100) < 25) search();
1677 * Tunnels through "walls" (including rubble and closed doors)
1679 * Note that you must tunnel in order to hit invisible monsters
1680 * in walls, though moving into walls still takes a turn anyway.
1682 * Digging is very difficult without a "digger" weapon, but can be
1683 * accomplished by strong players using heavy weapons.
1685 void do_cmd_tunnel(void)
1695 if (p_ptr->special_defense & KATA_MUSOU)
1697 set_action(ACTION_NONE);
1700 /* Allow repeated command */
1703 /* Set repeat count */
1704 command_rep = command_arg - 1;
1706 /* Redraw the state */
1707 p_ptr->redraw |= (PR_STATE);
1709 /* Cancel the arg */
1713 /* Get a direction to tunnel, or Abort */
1714 if (get_rep_dir(&dir,FALSE))
1721 c_ptr = &cave[y][x];
1723 /* Feature code (applying "mimic" field) */
1724 feat = get_feat_mimic(c_ptr);
1726 /* No tunnelling through doors */
1727 if (have_flag(f_info[feat].flags, FF_DOOR))
1731 msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1733 msg_print("You cannot tunnel through doors.");
1737 /* No tunnelling through most features */
1738 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1741 msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1743 msg_print("You can't tunnel through that.");
1747 /* A monster is in the way */
1748 else if (c_ptr->m_idx)
1755 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1757 msg_print("There is a monster in the way!");
1767 /* Tunnel through walls */
1768 more = do_cmd_tunnel_aux(y, x);
1772 /* Cancel repetition unless we can continue */
1773 if (!more) disturb(0, 0);
1777 #ifdef ALLOW_EASY_OPEN /* TNB */
1782 * If there is a jammed/closed/locked door at the given location,
1783 * then attempt to unlock/open it. Return TRUE if an attempt was
1784 * made (successful or not), otherwise return FALSE.
1786 * The code here should be nearly identical to that in
1787 * do_cmd_open_test() and do_cmd_open_aux().
1789 bool easy_open_door(int y, int x)
1793 cave_type *c_ptr = &cave[y][x];
1794 feature_type *f_ptr = &f_info[c_ptr->feat];
1796 /* Must be a closed door */
1797 if (!is_closed_door(c_ptr->feat))
1804 if (!have_flag(f_ptr->flags, FF_OPEN))
1808 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1810 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1816 else if (f_ptr->power)
1819 i = p_ptr->skill_dis;
1821 /* Penalize some conditions */
1822 if (p_ptr->blind || no_lite()) i = i / 10;
1823 if (p_ptr->confused || p_ptr->image) i = i / 10;
1825 /* Extract the lock power */
1828 /* Extract the difficulty XXX XXX XXX */
1831 /* Always have a small chance of success */
1835 if (randint0(100) < j)
1839 msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1841 msg_print("You have picked the lock.");
1845 cave_alter_feat(y, x, FF_OPEN);
1848 sound(SOUND_OPENDOOR);
1858 if (flush_failure) flush();
1862 msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1864 msg_print("You failed to pick the lock.");
1874 cave_alter_feat(y, x, FF_OPEN);
1877 sound(SOUND_OPENDOOR);
1884 #endif /* ALLOW_EASY_OPEN -- TNB */
1888 * Perform the basic "disarm" command
1890 * Assume destination is a visible trap
1892 * Assume there is no monster blocking the destination
1894 * Returns TRUE if repeated commands may continue
1896 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1902 object_type *o_ptr = &o_list[o_idx];
1908 /* Get the "disarm" factor */
1909 i = p_ptr->skill_dis;
1911 /* Penalize some conditions */
1912 if (p_ptr->blind || no_lite()) i = i / 10;
1913 if (p_ptr->confused || p_ptr->image) i = i / 10;
1915 /* Extract the difficulty */
1916 j = i - o_ptr->pval;
1918 /* Always have a small chance of success */
1921 /* Must find the trap first. */
1922 if (!object_is_known(o_ptr))
1925 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
1927 msg_print("I don't see any traps.");
1932 /* Already disarmed/unlocked */
1933 else if (o_ptr->pval <= 0)
1936 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1938 msg_print("The chest is not trapped.");
1943 /* No traps to find. */
1944 else if (!chest_traps[o_ptr->pval])
1947 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1949 msg_print("The chest is not trapped.");
1954 /* Success (get a lot of experience) */
1955 else if (randint0(100) < j)
1958 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
1960 msg_print("You have disarmed the chest.");
1963 gain_exp(o_ptr->pval);
1964 o_ptr->pval = (0 - o_ptr->pval);
1967 /* Failure -- Keep trying */
1968 else if ((i > 5) && (randint1(i) > 5))
1970 /* We may keep trying */
1972 if (flush_failure) flush();
1974 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
1976 msg_print("You failed to disarm the chest.");
1981 /* Failure -- Set off the trap */
1985 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
1987 msg_print("You set off a trap!");
1991 chest_trap(y, x, o_idx);
2000 * Perform the basic "disarm" command
2002 * Assume destination is a visible trap
2004 * Assume there is no monster blocking the destination
2006 * Returns TRUE if repeated commands may continue
2008 #ifdef ALLOW_EASY_DISARM /* TNB */
2010 bool do_cmd_disarm_aux(int y, int x, int dir)
2012 #else /* ALLOW_EASY_DISARM -- TNB */
2014 static bool do_cmd_disarm_aux(int y, int x, int dir)
2016 #endif /* ALLOW_EASY_DISARM -- TNB */
2018 /* Get grid and contents */
2019 cave_type *c_ptr = &cave[y][x];
2022 feature_type *f_ptr = &f_info[c_ptr->feat];
2024 /* Access trap name */
2025 cptr name = (f_name + f_ptr->name);
2027 /* Extract trap "power" */
2028 int power = f_ptr->power;
2032 /* Get the "disarm" factor */
2033 int i = p_ptr->skill_dis;
2040 /* Penalize some conditions */
2041 if (p_ptr->blind || no_lite()) i = i / 10;
2042 if (p_ptr->confused || p_ptr->image) i = i / 10;
2044 /* Extract the difficulty */
2047 /* Always have a small chance of success */
2051 if (randint0(100) < j)
2055 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2057 msg_format("You have disarmed the %s.", name);
2063 /* Remove the trap */
2064 cave_alter_feat(y, x, FF_DISARM);
2066 #ifdef ALLOW_EASY_DISARM /* TNB */
2068 /* Move the player onto the trap */
2069 move_player(dir, easy_disarm, FALSE);
2071 #else /* ALLOW_EASY_DISARM -- TNB */
2073 /* move the player onto the trap grid */
2074 move_player(dir, FALSE, FALSE);
2076 #endif /* ALLOW_EASY_DISARM -- TNB */
2079 /* Failure -- Keep trying */
2080 else if ((i > 5) && (randint1(i) > 5))
2083 if (flush_failure) flush();
2087 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2089 msg_format("You failed to disarm the %s.", name);
2092 /* We may keep trying */
2096 /* Failure -- Set off the trap */
2101 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2103 msg_format("You set off the %s!", name);
2106 #ifdef ALLOW_EASY_DISARM /* TNB */
2108 /* Move the player onto the trap */
2109 move_player(dir, easy_disarm, FALSE);
2111 #else /* ALLOW_EASY_DISARM -- TNB */
2113 /* Move the player onto the trap */
2114 move_player(dir, FALSE, FALSE);
2116 #endif /* ALLOW_EASY_DISARM -- TNB */
2125 * Disarms a trap, or chest
2127 void do_cmd_disarm(void)
2135 if (p_ptr->special_defense & KATA_MUSOU)
2137 set_action(ACTION_NONE);
2140 #ifdef ALLOW_EASY_DISARM /* TNB */
2142 /* Option: Pick a direction */
2145 int num_traps, num_chests;
2147 /* Count visible traps */
2148 num_traps = count_dt(&y, &x, is_trap, TRUE);
2150 /* Count chests (trapped) */
2151 num_chests = count_chests(&y, &x, TRUE);
2153 /* See if only one target */
2154 if (num_traps || num_chests)
2156 bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2158 if (!too_many) command_dir = coords_to_dir(y, x);
2162 #endif /* ALLOW_EASY_DISARM -- TNB */
2164 /* Allow repeated command */
2167 /* Set repeat count */
2168 command_rep = command_arg - 1;
2170 /* Redraw the state */
2171 p_ptr->redraw |= (PR_STATE);
2173 /* Cancel the arg */
2177 /* Get a direction (or abort) */
2178 if (get_rep_dir(&dir,TRUE))
2187 /* Get grid and contents */
2188 c_ptr = &cave[y][x];
2190 /* Feature code (applying "mimic" field) */
2191 feat = get_feat_mimic(c_ptr);
2193 /* Check for chests */
2194 o_idx = chest_check(y, x);
2197 if (!is_trap(feat) && !o_idx)
2201 msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2203 msg_print("You see nothing there to disarm.");
2208 /* Monster in the way */
2209 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2213 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2215 msg_print("There is a monster in the way!");
2226 /* Disarm the chest */
2227 more = do_cmd_disarm_chest(y, x, o_idx);
2233 /* Disarm the trap */
2234 more = do_cmd_disarm_aux(y, x, dir);
2238 /* Cancel repeat unless told not to */
2239 if (!more) disturb(0, 0);
2244 * Perform the basic "bash" command
2246 * Assume destination is a closed/locked/jammed door
2248 * Assume there is no monster blocking the destination
2250 * Returns TRUE if repeated commands may continue
2252 static bool do_cmd_bash_aux(int y, int x, int dir)
2255 cave_type *c_ptr = &cave[y][x];
2258 feature_type *f_ptr = &f_info[c_ptr->feat];
2260 /* Hack -- Bash power based on strength */
2261 /* (Ranges from 3 to 20 to 100 to 200) */
2262 int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2264 /* Extract door power */
2265 int temp = f_ptr->power;
2269 cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2276 msg_format("%s¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª", name);
2278 msg_format("You smash into the %s!", name);
2281 /* Compare bash power to door power XXX XXX XXX */
2282 temp = (bash - (temp * 10));
2284 if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2286 /* Hack -- always have a chance */
2287 if (temp < 1) temp = 1;
2289 /* Hack -- attempt to bash down the door */
2290 if (randint0(100) < temp)
2294 msg_format("%s¤ò²õ¤·¤¿¡ª", name);
2296 msg_format("The %s crashes open!", name);
2300 sound(have_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
2302 /* Break down the door */
2303 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat) || have_flag(f_ptr->flags, FF_GLASS))
2305 cave_alter_feat(y, x, FF_BASH);
2311 cave_alter_feat(y, x, FF_OPEN);
2314 /* Hack -- Fall through the door */
2315 move_player(dir, FALSE, FALSE);
2318 /* Saving throw against stun */
2319 else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2324 msg_format("¤³¤Î%s¤Ï´è¾æ¤À¡£", name);
2326 msg_format("The %s holds firm.", name);
2330 /* Allow repeated bashing */
2334 /* High dexterity yields coolness */
2339 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2341 msg_print("You are off-balance.");
2345 /* Hack -- Lose balance ala paralysis */
2346 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2355 * Bash open a door, success based on character strength
2357 * For a closed door, pval is positive if locked; negative if stuck.
2359 * For an open door, pval is positive for a broken door.
2361 * A closed door can be opened - harder if locked. Any door might be
2362 * bashed open (and thereby broken). Bashing a door is (potentially)
2363 * faster! You move into the door way. To open a stuck door, it must
2364 * be bashed. A closed door can be jammed (see do_cmd_spike()).
2366 * Creatures can also open or bash doors, see elsewhere.
2368 void do_cmd_bash(void)
2377 if (p_ptr->special_defense & KATA_MUSOU)
2379 set_action(ACTION_NONE);
2382 /* Allow repeated command */
2385 /* Set repeat count */
2386 command_rep = command_arg - 1;
2388 /* Redraw the state */
2389 p_ptr->redraw |= (PR_STATE);
2391 /* Cancel the arg */
2395 /* Get a "repeated" direction */
2396 if (get_rep_dir(&dir,FALSE))
2405 c_ptr = &cave[y][x];
2407 /* Feature code (applying "mimic" field) */
2408 feat = get_feat_mimic(c_ptr);
2410 /* Nothing useful */
2411 if (!have_flag(f_info[feat].flags, FF_BASH))
2415 msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2417 msg_print("You see nothing there to bash.");
2422 /* Monster in the way */
2423 else if (c_ptr->m_idx)
2430 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2432 msg_print("There is a monster in the way!");
2440 /* Bash a closed door */
2444 more = do_cmd_bash_aux(y, x, dir);
2448 /* Unless valid action taken, cancel bash */
2449 if (!more) disturb(0, 0);
2454 * Manipulate an adjacent grid in some way
2456 * Attack monsters, tunnel through walls, disarm traps, open doors.
2458 * Consider confusion XXX XXX XXX
2460 * This command must always take a turn, to prevent free detection
2461 * of invisible monsters.
2463 void do_cmd_alter(void)
2472 if (p_ptr->special_defense & KATA_MUSOU)
2474 set_action(ACTION_NONE);
2477 /* Allow repeated command */
2480 /* Set repeat count */
2481 command_rep = command_arg - 1;
2483 /* Redraw the state */
2484 p_ptr->redraw |= (PR_STATE);
2486 /* Cancel the arg */
2490 /* Get a direction */
2491 if (get_rep_dir(&dir,TRUE))
2494 feature_type *f_ptr;
2501 c_ptr = &cave[y][x];
2503 /* Feature code (applying "mimic" field) */
2504 feat = get_feat_mimic(c_ptr);
2505 f_ptr = &f_info[feat];
2510 /* Attack monsters */
2518 else if (have_flag(f_ptr->flags, FF_OPEN))
2520 more = do_cmd_open_aux(y, x);
2523 /* Bash jammed doors */
2524 else if (have_flag(f_ptr->flags, FF_BASH))
2526 more = do_cmd_bash_aux(y, x, dir);
2529 /* Tunnel through walls */
2530 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2532 more = do_cmd_tunnel_aux(y, x);
2535 /* Close open doors */
2536 else if (have_flag(f_ptr->flags, FF_CLOSE))
2538 more = do_cmd_close_aux(y, x);
2542 else if (have_flag(f_ptr->flags, FF_DISARM))
2544 more = do_cmd_disarm_aux(y, x, dir);
2552 msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2554 msg_print("You attack the empty air.");
2560 /* Cancel repetition unless we can continue */
2561 if (!more) disturb(0, 0);
2566 * Find the index of some "spikes", if possible.
2568 * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2570 static bool get_spike(int *ip)
2574 /* Check every item in the pack */
2575 for (i = 0; i < INVEN_PACK; i++)
2577 object_type *o_ptr = &inventory[i];
2579 /* Skip non-objects */
2580 if (!o_ptr->k_idx) continue;
2582 /* Check the "tval" code */
2583 if (o_ptr->tval == TV_SPIKE)
2585 /* Save the spike index */
2599 * Jam a closed door with a spike
2601 * This command may NOT be repeated
2603 void do_cmd_spike(void)
2607 if (p_ptr->special_defense & KATA_MUSOU)
2609 set_action(ACTION_NONE);
2612 /* Get a "repeated" direction */
2613 if (get_rep_dir(&dir,FALSE))
2623 /* Get grid and contents */
2624 c_ptr = &cave[y][x];
2626 /* Feature code (applying "mimic" field) */
2627 feat = get_feat_mimic(c_ptr);
2629 /* Require closed door */
2630 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2634 msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2636 msg_print("You see nothing there to spike.");
2642 else if (!get_spike(&item))
2646 msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2648 msg_print("You have no spikes!");
2652 /* Is a monster in the way? */
2653 else if (c_ptr->m_idx)
2660 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2662 msg_print("There is a monster in the way!");
2675 /* Successful jamming */
2677 msg_format("%s¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£", f_name + f_info[feat].name);
2679 msg_format("You jam the %s with a spike.", f_name + f_info[feat].name);
2682 cave_alter_feat(y, x, FF_SPIKE);
2684 /* Use up, and describe, a single spike, from the bottom */
2685 inven_item_increase(item, -1);
2686 inven_item_describe(item);
2687 inven_item_optimize(item);
2695 * Support code for the "Walk" and "Jump" commands
2697 void do_cmd_walk(bool pickup)
2704 /* Allow repeated command */
2707 /* Set repeat count */
2708 command_rep = command_arg - 1;
2710 /* Redraw the state */
2711 p_ptr->redraw |= (PR_STATE);
2713 /* Cancel the arg */
2717 /* Get a "repeated" direction */
2718 if (get_rep_dir(&dir,FALSE))
2723 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2725 set_action(ACTION_NONE);
2728 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2729 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2730 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2732 /* Actually move the character */
2733 move_player(dir, pickup, FALSE);
2735 /* Allow more walking */
2739 /* Hack again -- Is there a special encounter ??? */
2740 if (p_ptr->wild_mode && !cave_have_flag_bold(py, px, FF_TOWN))
2742 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2745 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2747 /* Inform the player of his horrible fate :=) */
2749 msg_print("½±·â¤À¡ª");
2751 msg_print("You are ambushed !");
2754 /* Go into large wilderness view */
2755 p_ptr->oldpy = randint1(MAX_HGT-2);
2756 p_ptr->oldpx = randint1(MAX_WID-2);
2759 /* Give first move to monsters */
2762 /* HACk -- set the encouter flag for the wilderness generation */
2763 generate_encounter = TRUE;
2767 /* Cancel repeat unless we may continue */
2768 if (!more) disturb(0, 0);
2776 void do_cmd_run(void)
2780 /* Hack -- no running when confused */
2781 if (p_ptr->confused)
2784 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2786 msg_print("You are too confused!");
2792 if (p_ptr->special_defense & KATA_MUSOU)
2794 set_action(ACTION_NONE);
2797 /* Get a "repeated" direction */
2798 if (get_rep_dir(&dir,FALSE))
2800 /* Hack -- Set the run counter */
2801 running = (command_arg ? command_arg : 1000);
2811 * Stay still. Search. Enter stores.
2812 * Pick up treasure if "pickup" is true.
2814 void do_cmd_stay(bool pickup)
2816 u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2818 /* Allow repeated command */
2821 /* Set repeat count */
2822 command_rep = command_arg - 1;
2824 /* Redraw the state */
2825 p_ptr->redraw |= (PR_STATE);
2827 /* Cancel the arg */
2834 if (pickup) mpe_mode |= MPE_DO_PICKUP;
2835 (void)move_player_effect(py, px, mpe_mode);
2841 * Resting allows a player to safely restore his hp -RAK-
2843 void do_cmd_rest(void)
2846 set_action(ACTION_NONE);
2848 if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
2854 if (hex_spelling_any()) stop_hex_spell_all();
2856 /* Prompt for time if needed */
2857 if (command_arg <= 0)
2860 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
2862 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
2869 strcpy(out_val, "&");
2871 /* Ask for duration */
2872 if (!get_string(p, out_val, 4)) return;
2874 /* Rest until done */
2875 if (out_val[0] == '&')
2881 else if (out_val[0] == '*')
2889 command_arg = atoi(out_val);
2890 if (command_arg <= 0) return;
2896 if (command_arg > 9999) command_arg = 9999;
2898 if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2900 /* Take a turn XXX XXX XXX (?) */
2903 /* The sin of sloth */
2904 if (command_arg > 100)
2905 chg_virtue(V_DILIGENCE, -1);
2907 /* Why are you sleeping when there's no need? WAKE UP!*/
2908 if ((p_ptr->chp == p_ptr->mhp) &&
2909 (p_ptr->csp == p_ptr->msp) &&
2910 !p_ptr->blind && !p_ptr->confused &&
2911 !p_ptr->poisoned && !p_ptr->afraid &&
2912 !p_ptr->stun && !p_ptr->cut &&
2913 !p_ptr->slow && !p_ptr->paralyzed &&
2914 !p_ptr->image && !p_ptr->word_recall &&
2915 !p_ptr->alter_reality)
2916 chg_virtue(V_DILIGENCE, -1);
2918 /* Save the rest code */
2919 resting = command_arg;
2920 p_ptr->action = ACTION_REST;
2922 /* Recalculate bonuses */
2923 p_ptr->update |= (PU_BONUS);
2925 /* Redraw the state */
2926 p_ptr->redraw |= (PR_STATE);
2937 * Determines the odds of an object breaking when thrown at a monster
2939 * Note that artifacts never break, see the "drop_near()" function.
2941 static int breakage_chance(object_type *o_ptr)
2943 int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2945 /* Examine the snipe type */
2948 if (snipe_type == SP_KILL_WALL) return (100);
2949 if (snipe_type == SP_EXPLODE) return (100);
2950 if (snipe_type == SP_PIERCE) return (100);
2951 if (snipe_type == SP_FINAL) return (100);
2952 if (snipe_type == SP_NEEDLE) return (100);
2953 if (snipe_type == SP_EVILNESS) return (40);
2954 if (snipe_type == SP_HOLYNESS) return (40);
2957 /* Examine the item type */
2958 switch (o_ptr->tval)
2974 /* Sometimes break */
2979 return (20 - archer_bonus * 2);
2984 return (10 - archer_bonus);
2991 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2995 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2997 u32b flgs[TR_FLAG_SIZE];
2999 /* Extract the flags */
3000 object_flags(o_ptr, flgs);
3002 /* Some "weapons" and "ammo" do extra damage */
3003 switch (o_ptr->tval)
3010 if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
3011 (r_ptr->flags3 & RF3_ANIMAL))
3013 if (is_original_ap_and_seen(m_ptr))
3015 r_ptr->r_flags3 |= RF3_ANIMAL;
3018 if (mult < 17) mult = 17;
3022 if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
3023 (r_ptr->flags3 & RF3_ANIMAL))
3025 if (is_original_ap_and_seen(m_ptr))
3027 r_ptr->r_flags3 |= RF3_ANIMAL;
3030 if (mult < 27) mult = 27;
3034 if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3035 (r_ptr->flags3 & RF3_EVIL))
3037 if (is_original_ap_and_seen(m_ptr))
3039 r_ptr->r_flags3 |= RF3_EVIL;
3042 if (mult < 15) mult = 15;
3046 if ((have_flag(flgs, TR_KILL_EVIL)) &&
3047 (r_ptr->flags3 & RF3_EVIL))
3049 if (is_original_ap_and_seen(m_ptr))
3051 r_ptr->r_flags3 |= RF3_EVIL;
3054 if (mult < 25) mult = 25;
3058 if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3059 (r_ptr->flags2 & RF2_HUMAN))
3061 if (is_original_ap_and_seen(m_ptr))
3063 r_ptr->r_flags2 |= RF2_HUMAN;
3066 if (mult < 17) mult = 17;
3070 if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3071 (r_ptr->flags2 & RF2_HUMAN))
3073 if (is_original_ap_and_seen(m_ptr))
3075 r_ptr->r_flags2 |= RF2_HUMAN;
3078 if (mult < 27) mult = 27;
3082 if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3083 (r_ptr->flags3 & RF3_UNDEAD))
3085 if (is_original_ap_and_seen(m_ptr))
3087 r_ptr->r_flags3 |= RF3_UNDEAD;
3090 if (mult < 20) mult = 20;
3094 if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3095 (r_ptr->flags3 & RF3_UNDEAD))
3097 if (is_original_ap_and_seen(m_ptr))
3099 r_ptr->r_flags3 |= RF3_UNDEAD;
3102 if (mult < 30) mult = 30;
3106 if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3107 (r_ptr->flags3 & RF3_DEMON))
3109 if (is_original_ap_and_seen(m_ptr))
3111 r_ptr->r_flags3 |= RF3_DEMON;
3114 if (mult < 20) mult = 20;
3118 if ((have_flag(flgs, TR_KILL_DEMON)) &&
3119 (r_ptr->flags3 & RF3_DEMON))
3121 if (is_original_ap_and_seen(m_ptr))
3123 r_ptr->r_flags3 |= RF3_DEMON;
3126 if (mult < 30) mult = 30;
3130 if ((have_flag(flgs, TR_SLAY_ORC)) &&
3131 (r_ptr->flags3 & RF3_ORC))
3133 if (is_original_ap_and_seen(m_ptr))
3135 r_ptr->r_flags3 |= RF3_ORC;
3138 if (mult < 20) mult = 20;
3142 if ((have_flag(flgs, TR_KILL_ORC)) &&
3143 (r_ptr->flags3 & RF3_ORC))
3145 if (is_original_ap_and_seen(m_ptr))
3147 r_ptr->r_flags3 |= RF3_ORC;
3150 if (mult < 30) mult = 30;
3154 if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3155 (r_ptr->flags3 & RF3_TROLL))
3157 if (is_original_ap_and_seen(m_ptr))
3159 r_ptr->r_flags3 |= RF3_TROLL;
3162 if (mult < 20) mult = 20;
3166 if ((have_flag(flgs, TR_KILL_TROLL)) &&
3167 (r_ptr->flags3 & RF3_TROLL))
3169 if (is_original_ap_and_seen(m_ptr))
3171 r_ptr->r_flags3 |= RF3_TROLL;
3174 if (mult < 30) mult = 30;
3178 if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3179 (r_ptr->flags3 & RF3_GIANT))
3181 if (is_original_ap_and_seen(m_ptr))
3183 r_ptr->r_flags3 |= RF3_GIANT;
3186 if (mult < 20) mult = 20;
3190 if ((have_flag(flgs, TR_KILL_GIANT)) &&
3191 (r_ptr->flags3 & RF3_GIANT))
3193 if (is_original_ap_and_seen(m_ptr))
3195 r_ptr->r_flags3 |= RF3_GIANT;
3198 if (mult < 30) mult = 30;
3202 if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3203 (r_ptr->flags3 & RF3_DRAGON))
3205 if (is_original_ap_and_seen(m_ptr))
3207 r_ptr->r_flags3 |= RF3_DRAGON;
3210 if (mult < 20) mult = 20;
3213 /* Execute Dragon */
3214 if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3215 (r_ptr->flags3 & RF3_DRAGON))
3217 if (is_original_ap_and_seen(m_ptr))
3219 r_ptr->r_flags3 |= RF3_DRAGON;
3222 if (mult < 30) mult = 30;
3224 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3225 (m_ptr->r_idx == MON_SMAUG) &&
3226 (inventory[INVEN_BOW].name1 == ART_BARD))
3231 if (have_flag(flgs, TR_BRAND_ACID))
3233 /* Notice immunity */
3234 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3236 if (is_original_ap_and_seen(m_ptr))
3238 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3242 /* Otherwise, take the damage */
3245 if (mult < 17) mult = 17;
3250 if (have_flag(flgs, TR_BRAND_ELEC))
3252 /* Notice immunity */
3253 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3255 if (is_original_ap_and_seen(m_ptr))
3257 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3261 /* Otherwise, take the damage */
3264 if (mult < 17) mult = 17;
3269 if (have_flag(flgs, TR_BRAND_FIRE))
3271 /* Notice immunity */
3272 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3274 if (is_original_ap_and_seen(m_ptr))
3276 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3280 /* Otherwise, take the damage */
3283 if (r_ptr->flags3 & RF3_HURT_FIRE)
3285 if (mult < 25) mult = 25;
3286 if (is_original_ap_and_seen(m_ptr))
3288 r_ptr->r_flags3 |= RF3_HURT_FIRE;
3291 else if (mult < 17) mult = 17;
3296 if (have_flag(flgs, TR_BRAND_COLD))
3298 /* Notice immunity */
3299 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3301 if (is_original_ap_and_seen(m_ptr))
3303 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3306 /* Otherwise, take the damage */
3309 if (r_ptr->flags3 & RF3_HURT_COLD)
3311 if (mult < 25) mult = 25;
3312 if (is_original_ap_and_seen(m_ptr))
3314 r_ptr->r_flags3 |= RF3_HURT_COLD;
3317 else if (mult < 17) mult = 17;
3321 /* Brand (Poison) */
3322 if (have_flag(flgs, TR_BRAND_POIS))
3324 /* Notice immunity */
3325 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3327 if (is_original_ap_and_seen(m_ptr))
3329 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3333 /* Otherwise, take the damage */
3336 if (mult < 17) mult = 17;
3340 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3342 p_ptr->csp -= (1+(p_ptr->msp / 30));
3343 p_ptr->redraw |= (PR_MANA);
3344 mult = mult * 5 / 2;
3351 if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
3353 /* Return the total damage */
3354 return (tdam * mult / 10);
3359 * Fire an object from the pack or floor.
3361 * You may only fire items that "match" your missile launcher.
3363 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3365 * See "calc_bonuses()" for more calculations and such.
3367 * Note that "firing" a missile is MUCH better than "throwing" it.
3369 * Note: "unseen" monsters are very hard to hit.
3371 * Objects are more likely to break if they "attempt" to hit a monster.
3373 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3375 * The "extra shot" code works by decreasing the amount of energy
3376 * required to make each shot, spreading the shots out over time.
3378 * Note that when firing missiles, the launcher multiplier is applied
3379 * after all the bonuses are added in, making multipliers very useful.
3381 * Note that Bows of "Extra Might" get extra range and an extra bonus
3382 * for the damage multiplier.
3384 * Note that Bows of "Extra Shots" give an extra shot.
3386 void do_cmd_fire_aux(int item, object_type *j_ptr)
3389 int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x;
3390 int tdam_base, tdis, thits, tmul;
3392 int cur_dis, visible;
3399 bool hit_body = FALSE;
3401 char o_name[MAX_NLEN];
3403 u16b path_g[512]; /* For calcuration of path length */
3405 int msec = delay_factor * delay_factor * delay_factor;
3408 bool stick_to = FALSE;
3410 /* Access the item (if in the pack) */
3413 o_ptr = &inventory[item];
3417 o_ptr = &o_list[0 - item];
3420 /* Sniper - Cannot shot a single arrow twice */
3421 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
3423 /* Describe the object */
3424 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3426 /* Use the proper number of shots */
3427 thits = p_ptr->num_fire;
3429 /* Use a base distance */
3432 /* Base damage from thrown object plus launcher bonus */
3433 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3435 /* Actually "fire" the object */
3436 bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3437 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3438 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3440 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3442 energy_use = bow_energy(j_ptr->sval);
3443 tmul = bow_tmul(j_ptr->sval);
3445 /* Get extra "power" from "extra might" */
3446 if (p_ptr->xtra_might) tmul++;
3448 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3450 /* Boost the damage */
3455 tdis = 13 + tmul/80;
3456 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3459 tdis -= (5 - (p_ptr->concent + 1) / 2);
3464 project_length = tdis + 1;
3466 /* Get a direction (or cancel) */
3467 if (!get_aim_dir(&dir))
3471 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
3473 /* need not to reset project_length (already did)*/
3478 /* Predict the "target" location */
3479 tx = px + 99 * ddx[dir];
3480 ty = py + 99 * ddy[dir];
3482 /* Check for "target request" */
3483 if ((dir == 5) && target_okay())
3489 /* Get projection path length */
3490 tdis = project_path(path_g, project_length, py, px, ty, tx, PROJECT_PATH|PROJECT_THRU) - 1;
3492 project_length = 0; /* reset to default */
3494 /* Don't shoot at my feet */
3495 if (tx == px && ty == py)
3499 /* project_length is already reset to 0 */
3505 /* Take a (partial) turn */
3506 energy_use = (energy_use / thits);
3509 /* Sniper - Difficult to shot twice at 1 turn */
3510 if (snipe_type == SP_DOUBLE) p_ptr->concent = (p_ptr->concent + 1) / 2;
3512 /* Sniper - Repeat shooting when double shots */
3513 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
3516 /* Start at the player */
3520 /* Get local object */
3523 /* Obtain a local object */
3524 object_copy(q_ptr, o_ptr);
3529 /* Reduce and describe inventory */
3532 inven_item_increase(item, -1);
3533 inven_item_describe(item);
3534 inven_item_optimize(item);
3537 /* Reduce and describe floor item */
3540 floor_item_increase(0 - item, -1);
3541 floor_item_optimize(0 - item);
3547 /* Hack -- Handle stuff */
3550 /* Save the old location */
3554 /* The shot does not hit yet */
3557 /* Travel until stopped */
3558 for (cur_dis = 0; cur_dis <= tdis; )
3562 /* Hack -- Stop at the target */
3563 if ((y == ty) && (x == tx)) break;
3565 /* Calculate the new location (see "project()") */
3568 mmove2(&ny, &nx, py, px, ty, tx);
3571 if (snipe_type == SP_KILL_WALL)
3573 c_ptr = &cave[ny][nx];
3575 if (cave_have_flag_grid(c_ptr, FF_HURT_ROCK) && !c_ptr->m_idx)
3578 if (c_ptr->info & (CAVE_MARK)) msg_print("´ä¤¬ºÕ¤±»¶¤Ã¤¿¡£");
3580 if (c_ptr->info & (CAVE_MARK)) msg_print("Wall rocks were shattered.");
3582 /* Forget the wall */
3583 c_ptr->info &= ~(CAVE_MARK);
3585 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
3587 /* Destroy the wall */
3588 cave_alter_feat(ny, nx, FF_HURT_ROCK);
3595 /* Stopped by walls/doors */
3596 if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && !cave[ny][nx].m_idx) break;
3598 /* Advance the distance */
3602 if (snipe_type == SP_LITE)
3604 cave[ny][nx].info |= (CAVE_GLOW);
3613 /* The player can see the (on screen) missile */
3614 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3616 char c = object_char(q_ptr);
3617 byte a = object_attr(q_ptr);
3619 /* Draw, Hilite, Fresh, Pause, Erase */
3620 print_rel(c, a, ny, nx);
3621 move_cursor_relative(ny, nx);
3623 Term_xtra(TERM_XTRA_DELAY, msec);
3628 /* The player cannot see the missile */
3631 /* Pause anyway, for consistancy */
3632 Term_xtra(TERM_XTRA_DELAY, msec);
3636 if (snipe_type == SP_KILL_TRAP)
3638 project(0, 0, ny, nx, 0, GF_KILL_TRAP,
3639 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
3643 if (snipe_type == SP_EVILNESS)
3645 cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
3654 /* Save the old location */
3658 /* Save the new location */
3663 /* Monster here, Try to hit it */
3664 if (cave[y][x].m_idx)
3667 cave_type *c_ptr = &cave[y][x];
3669 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3670 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3672 /* Check the visibility */
3673 visible = m_ptr->ml;
3675 /* Note the collision */
3678 if (MON_CSLEEP(m_ptr))
3680 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3681 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3684 if ((r_ptr->level + 10) > p_ptr->lev)
3686 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3687 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3690 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3691 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3692 else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3693 else if (p_ptr->lev > 34) amount = 2;
3694 p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3695 p_ptr->update |= (PU_BONUS);
3701 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3702 && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3705 p_ptr->skill_exp[GINOU_RIDING] += 1;
3706 p_ptr->update |= (PU_BONUS);
3710 /* Some shots have hit bonus */
3714 armour *= (10 - p_ptr->concent);
3718 /* Did we hit it (penalize range) */
3719 if (test_hit_fire(chance - cur_dis, armour, m_ptr->ml))
3722 int tdam = tdam_base;
3724 /* Get extra damage from concentration */
3725 if (p_ptr->concent) tdam = boost_concentration_damage(tdam);
3727 /* Handle unseen monster */
3730 /* Invisible monster */
3732 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3734 msg_format("The %s finds a mark.", o_name);
3739 /* Handle visible monster */
3744 /* Get "the monster" or "it" */
3745 monster_desc(m_name, m_ptr, 0);
3749 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3751 msg_format("The %s hits %s.", o_name, m_name);
3756 /* Hack -- Track this monster race */
3757 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
3759 /* Hack -- Track this monster */
3760 health_track(c_ptr->m_idx);
3764 if (snipe_type == SP_NEEDLE)
3766 if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1)
3767 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3771 /* Get "the monster" or "it" */
3772 monster_desc(m_name, m_ptr, 0);
3774 tdam = m_ptr->hp + 1;
3776 msg_format("%s¤ÎµÞ½ê¤ËÆͤ»É¤µ¤Ã¤¿¡ª", m_name);
3778 msg_format("Your shot sticked on a fatal spot of %s!", m_name);
3785 /* Apply special damage XXX XXX XXX */
3786 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3787 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3789 /* No negative damage */
3790 if (tdam < 0) tdam = 0;
3792 /* Modify the damage */
3793 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3796 /* Complex message */
3797 if (p_ptr->wizard || cheat_xtra)
3800 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3803 msg_format("You do %d (out of %d) damage.",
3810 if (snipe_type == SP_EXPLODE)
3812 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
3814 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
3815 project(0, ((p_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
3820 if (snipe_type == SP_HOLYNESS)
3822 cave[ny][nx].info |= (CAVE_GLOW);
3831 /* Hit the monster, check for death */
3832 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3841 if (object_is_fixed_artifact(q_ptr))
3845 monster_desc(m_name, m_ptr, 0);
3849 msg_format("%s¤Ï%s¤ËÆͤ»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3851 msg_format("%^s have stuck into %s!",o_name, m_name);
3856 message_pain(c_ptr->m_idx, tdam);
3858 /* Anger the monster */
3859 if (tdam > 0) anger_monster(m_ptr);
3862 if (fear && m_ptr->ml)
3869 /* Get the monster name (or "it") */
3870 monster_desc(m_name, m_ptr, 0);
3874 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3876 msg_format("%^s flees in terror!", m_name);
3881 set_target(m_ptr, py, px);
3884 if (snipe_type == SP_RUSH)
3886 int n = randint1(5) + 3;
3887 int m_idx = c_ptr->m_idx;
3889 for ( ; cur_dis <= tdis; )
3896 /* Calculate the new location (see "project()") */
3897 mmove2(&ny, &nx, py, px, ty, tx);
3899 /* Stopped by wilderness boundary */
3900 if (!in_bounds2(ny, nx)) break;
3902 /* Stopped by walls/doors */
3903 if (!player_can_enter(cave[ny][nx].feat, 0)) break;
3905 /* Stopped by monsters */
3906 if (!cave_empty_bold(ny, nx)) break;
3908 cave[ny][nx].m_idx = m_idx;
3909 cave[oy][ox].m_idx = 0;
3914 /* Update the monster (new location) */
3915 update_mon(c_ptr->m_idx, TRUE);
3921 Term_xtra(TERM_XTRA_DELAY, msec);
3933 if (snipe_type == SP_PIERCE)
3935 if(p_ptr->concent < 1) break;
3945 /* Chance of breakage (during attacks) */
3946 j = (hit_body ? breakage_chance(q_ptr) : 0);
3950 int m_idx = cave[y][x].m_idx;
3951 monster_type *m_ptr = &m_list[m_idx];
3952 int o_idx = o_pop();
3957 msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3959 msg_format("The %s have gone to somewhere.", o_name);
3961 if (object_is_fixed_artifact(q_ptr))
3963 a_info[j_ptr->name1].cur_num = 0;
3968 o_ptr = &o_list[o_idx];
3969 object_copy(o_ptr, q_ptr);
3972 o_ptr->marked &= OM_TOUCHED;
3974 /* Forget location */
3975 o_ptr->iy = o_ptr->ix = 0;
3977 /* Memorize monster */
3978 o_ptr->held_m_idx = m_idx;
3981 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3984 m_ptr->hold_o_idx = o_idx;
3986 else if (cave_have_flag_bold(y, x, FF_PROJECT))
3988 /* Drop (or break) near that location */
3989 (void)drop_near(q_ptr, j, y, x);
3993 /* Drop (or break) near that location */
3994 (void)drop_near(q_ptr, j, prev_y, prev_x);
3997 /* Sniper - Repeat shooting when double shots */
4000 /* Sniper - Loose his/her concentration after any shot */
4001 if (p_ptr->concent) reset_concentration(FALSE);
4005 void do_cmd_fire(void)
4011 is_fired = FALSE; /* not fired yet */
4013 /* Get the "bow" (if any) */
4014 j_ptr = &inventory[INVEN_BOW];
4016 /* Require a launcher */
4020 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
4022 msg_print("You have nothing to fire with.");
4028 if (j_ptr->sval == SV_CRIMSON)
4031 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
4033 msg_print("Do activate.");
4040 if (p_ptr->special_defense & KATA_MUSOU)
4042 set_action(ACTION_NONE);
4045 /* Require proper missile */
4046 item_tester_tval = p_ptr->tval_ammo;
4050 q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
4051 s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
4053 q = "Fire which item? ";
4054 s = "You have nothing to fire.";
4057 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
4064 do_cmd_fire_aux(item, j_ptr);
4066 if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
4068 /* Sniper actions after some shootings */
4069 if (snipe_type == SP_AWAY)
4071 teleport_player(10 + (p_ptr->concent * 2), 0L);
4073 if (snipe_type == SP_FINAL)
4076 msg_print("¼Í·â¤ÎÈ¿Æ°¤¬ÂΤò½±¤Ã¤¿¡£");
4078 msg_print("A reactionary of shooting attacked you. ");
4080 (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE);
4081 (void)set_stun(p_ptr->stun + randint1(25));
4086 static bool item_tester_hook_boomerang(object_type *o_ptr)
4088 if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
4096 * Throw an object from the pack or floor.
4098 * Note: "unseen" monsters are very hard to hit.
4100 * Should throwing a weapon do full damage? Should it allow the magic
4101 * to hit bonus of the weapon to have an effect? Should it ever cause
4102 * the item to be destroyed? Should it do any damage at all?
4104 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
4107 int i, j, y, x, ty, tx, prev_y, prev_x;
4109 int chance, tdam, tdis;
4111 int cur_dis, visible;
4118 bool hit_body = FALSE;
4119 bool hit_wall = FALSE;
4120 bool equiped_item = FALSE;
4121 bool return_when_thrown = FALSE;
4123 char o_name[MAX_NLEN];
4125 int msec = delay_factor * delay_factor * delay_factor;
4127 u32b flgs[TR_FLAG_SIZE];
4129 bool come_back = FALSE;
4130 bool do_drop = TRUE;
4133 if (p_ptr->special_defense & KATA_MUSOU)
4135 set_action(ACTION_NONE);
4144 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
4146 item_tester_hook = item_tester_hook_boomerang;
4148 q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
4149 s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
4151 q = "Throw which item? ";
4152 s = "You have nothing to throw.";
4155 if (!get_item(&item, q, s, (USE_EQUIP)))
4161 else if (buki_motteruka(INVEN_LARM)) item = INVEN_LARM;
4162 else item = INVEN_RARM;
4168 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
4169 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
4171 q = "Throw which item? ";
4172 s = "You have nothing to throw.";
4175 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
4182 /* Access the item (if in the pack) */
4185 o_ptr = &inventory[item];
4189 o_ptr = &o_list[0 - item];
4193 /* Item is cursed */
4194 if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
4198 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
4200 msg_print("Hmmm, it seems to be cursed.");
4207 if (p_ptr->inside_arena && !boomerang)
4209 if (o_ptr->tval != TV_SPIKE)
4212 msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
4214 msg_print("You're in the arena now. This is hand-to-hand!");
4223 /* Get local object */
4226 /* Obtain a local object */
4227 object_copy(q_ptr, o_ptr);
4229 /* Extract the thrown object's flags. */
4230 object_flags(q_ptr, flgs);
4232 /* Distribute the charges of rods/wands between the stacks */
4233 distribute_charges(o_ptr, q_ptr, 1);
4239 object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
4241 if (p_ptr->mighty_throw) mult += 3;
4243 /* Extract a "distance multiplier" */
4244 /* Changed for 'launcher' mutation */
4245 mul = 10 + 2 * (mult - 1);
4247 /* Enforce a minimum "weight" of one pound */
4248 div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
4249 if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
4251 /* Hack -- Distance -- Reward strength, penalize weight */
4252 tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
4254 /* Max distance of 10-18 */
4255 if (tdis > mul) tdis = mul;
4259 ty = randint0(101)-50+py;
4260 tx = randint0(101)-50+px;
4264 project_length = tdis + 1;
4266 /* Get a direction (or cancel) */
4267 if (!get_aim_dir(&dir)) return FALSE;
4269 /* Predict the "target" location */
4270 tx = px + 99 * ddx[dir];
4271 ty = py + 99 * ddy[dir];
4273 /* Check for "target request" */
4274 if ((dir == 5) && target_okay())
4280 project_length = 0; /* reset to default */
4283 if ((q_ptr->name1 == ART_MJOLLNIR) ||
4284 (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4285 return_when_thrown = TRUE;
4287 /* Reduce and describe inventory */
4290 inven_item_increase(item, -1);
4291 if (!return_when_thrown)
4292 inven_item_describe(item);
4293 inven_item_optimize(item);
4296 /* Reduce and describe floor item */
4299 floor_item_increase(0 - item, -1);
4300 floor_item_optimize(0 - item);
4302 if (item >= INVEN_RARM)
4304 equiped_item = TRUE;
4305 p_ptr->redraw |= (PR_EQUIPPY);
4311 /* Rogue and Ninja gets bonus */
4312 if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4313 energy_use -= p_ptr->lev;
4315 /* Start at the player */
4320 /* Hack -- Handle stuff */
4323 if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4324 else shuriken = FALSE;
4326 /* Chance of hitting */
4327 if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4328 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4329 else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4331 if (shuriken) chance *= 2;
4333 /* Save the old location */
4337 /* Travel until stopped */
4338 for (cur_dis = 0; cur_dis <= tdis; )
4340 /* Hack -- Stop at the target */
4341 if ((y == ty) && (x == tx)) break;
4343 /* Calculate the new location (see "project()") */
4346 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4348 /* Stopped by walls/doors */
4349 if (!cave_have_flag_bold(ny[cur_dis], nx[cur_dis], FF_PROJECT))
4352 if ((q_ptr->tval == TV_FIGURINE) || object_is_potion(q_ptr) || !cave[ny[cur_dis]][nx[cur_dis]].m_idx) break;
4355 /* The player can see the (on screen) missile */
4356 if (panel_contains(ny[cur_dis], nx[cur_dis]) && player_can_see_bold(ny[cur_dis], nx[cur_dis]))
4358 char c = object_char(q_ptr);
4359 byte a = object_attr(q_ptr);
4361 /* Draw, Hilite, Fresh, Pause, Erase */
4362 print_rel(c, a, ny[cur_dis], nx[cur_dis]);
4363 move_cursor_relative(ny[cur_dis], nx[cur_dis]);
4365 Term_xtra(TERM_XTRA_DELAY, msec);
4366 lite_spot(ny[cur_dis], nx[cur_dis]);
4370 /* The player cannot see the missile */
4373 /* Pause anyway, for consistancy */
4374 Term_xtra(TERM_XTRA_DELAY, msec);
4377 /* Save the old location */
4381 /* Save the new location */
4385 /* Advance the distance */
4388 /* Monster here, Try to hit it */
4389 if (cave[y][x].m_idx)
4391 cave_type *c_ptr = &cave[y][x];
4393 monster_type *m_ptr = &m_list[c_ptr->m_idx];
4394 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4396 /* Check the visibility */
4397 visible = m_ptr->ml;
4399 /* Note the collision */
4402 /* Did we hit it (penalize range) */
4403 if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4407 /* Handle unseen monster */
4410 /* Invisible monster */
4412 msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4414 msg_format("The %s finds a mark.", o_name);
4419 /* Handle visible monster */
4424 /* Get "the monster" or "it" */
4425 monster_desc(m_name, m_ptr, 0);
4429 msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4431 msg_format("The %s hits %s.", o_name, m_name);
4436 /* Hack -- Track this monster race */
4437 if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
4439 /* Hack -- Track this monster */
4440 health_track(c_ptr->m_idx);
4444 /* Hack -- Base damage from thrown object */
4445 tdam = damroll(q_ptr->dd, q_ptr->ds);
4446 /* Apply special damage XXX XXX XXX */
4447 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4448 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4449 if (q_ptr->to_d > 0)
4450 tdam += q_ptr->to_d;
4452 tdam += -q_ptr->to_d;
4456 tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4457 tdam += p_ptr->to_d_m;
4459 else if (have_flag(flgs, TR_THROW))
4462 tdam += p_ptr->to_d_m;
4470 tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4473 /* No negative damage */
4474 if (tdam < 0) tdam = 0;
4476 /* Modify the damage */
4477 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4479 /* Complex message */
4483 msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4486 msg_format("You do %d (out of %d) damage.",
4492 /* Hit the monster, check for death */
4493 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4502 message_pain(c_ptr->m_idx, tdam);
4504 /* Anger the monster */
4505 if ((tdam > 0) && !object_is_potion(q_ptr))
4506 anger_monster(m_ptr);
4509 if (fear && m_ptr->ml)
4516 /* Get the monster name (or "it") */
4517 monster_desc(m_name, m_ptr, 0);
4521 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4523 msg_format("%^s flees in terror!", m_name);
4535 /* Chance of breakage (during attacks) */
4536 j = (hit_body ? breakage_chance(q_ptr) : 0);
4538 /* Figurines transform */
4539 if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4543 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4544 !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
4546 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4548 msg_print("The Figurine writhes and then shatters.");
4551 else if (object_is_cursed(q_ptr))
4553 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4555 msg_print("You have a bad feeling about this.");
4561 /* Potions smash open */
4562 if (object_is_potion(q_ptr))
4564 if (hit_body || hit_wall || (randint1(100) < j))
4568 msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4570 msg_format("The %s shatters!", o_name);
4574 if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4576 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4578 /* ToDo (Robert): fix the invulnerability */
4579 if (cave[y][x].m_idx &&
4580 is_friendly(&m_list[cave[y][x].m_idx]) &&
4581 !MON_INVULNER(m_ptr))
4584 monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4586 msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4588 msg_format("%^s gets angry!", m_name);
4591 set_hostile(&m_list[cave[y][x].m_idx]);
4602 if (return_when_thrown)
4604 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4605 char o2_name[MAX_NLEN];
4606 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4609 if (boomerang) back_chance += 4+randint1(5);
4610 if (super_boomerang) back_chance += 100;
4611 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4613 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4615 for (i = cur_dis - 1; i > 0; i--)
4617 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4619 char c = object_char(q_ptr);
4620 byte a = object_attr(q_ptr);
4622 /* Draw, Hilite, Fresh, Pause, Erase */
4623 print_rel(c, a, ny[i], nx[i]);
4624 move_cursor_relative(ny[i], nx[i]);
4626 Term_xtra(TERM_XTRA_DELAY, msec);
4627 lite_spot(ny[i], nx[i]);
4632 /* Pause anyway, for consistancy */
4633 Term_xtra(TERM_XTRA_DELAY, msec);
4636 if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4639 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ¤¿¡£", o2_name);
4641 msg_format("%s comes back to you.", o2_name);
4650 msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4652 msg_format("%s backs, but you can't catch!", o2_name);
4658 msg_format("%s¤¬Ê֤äƤ¤¿¡£", o2_name);
4660 msg_format("%s comes back.", o2_name);
4670 msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4672 msg_format("%s doesn't back!", o2_name);
4679 if (item == INVEN_RARM || item == INVEN_LARM)
4681 /* Access the wield slot */
4682 o_ptr = &inventory[item];
4684 /* Wear the new stuff */
4685 object_copy(o_ptr, q_ptr);
4687 /* Increase the weight */
4688 p_ptr->total_weight += q_ptr->weight;
4690 /* Increment the equip counter by hand */
4693 /* Recalculate bonuses */
4694 p_ptr->update |= (PU_BONUS);
4696 /* Recalculate torch */
4697 p_ptr->update |= (PU_TORCH);
4699 /* Recalculate mana XXX */
4700 p_ptr->update |= (PU_MANA);
4703 p_ptr->window |= (PW_EQUIP);
4711 else if (equiped_item)
4717 /* Drop (or break) near that location */
4720 if (cave_have_flag_bold(y, x, FF_PROJECT))
4722 /* Drop (or break) near that location */
4723 (void)drop_near(q_ptr, j, y, x);
4727 /* Drop (or break) near that location */
4728 (void)drop_near(q_ptr, j, prev_y, prev_x);
4737 * Throw an object from the pack or floor.
4739 void do_cmd_throw(void)
4741 do_cmd_throw_aux(1, FALSE, -1);
4747 * Hack: travel command
4749 #define TRAVEL_UNABLE 9999
4751 static int flow_head = 0;
4752 static int flow_tail = 0;
4753 static s16b temp2_x[MAX_SHORT];
4754 static s16b temp2_y[MAX_SHORT];
4756 /* Hack: forget the "flow" information */
4757 void forget_travel_flow(void)
4761 /* Check the entire dungeon */
4762 for (y = 0; y < cur_hgt; y++)
4764 for (x = 0; x < cur_wid; x++)
4766 /* Forget the old data */
4767 travel.cost[y][x] = TRAVEL_UNABLE;
4772 static bool travel_flow_aux(int y, int x, int n, bool wall)
4774 cave_type *c_ptr = &cave[y][x];
4775 feature_type *f_ptr = &f_info[c_ptr->feat];
4776 int old_head = flow_head;
4778 n = n % TRAVEL_UNABLE;
4780 /* Ignore out of bounds */
4781 if (!in_bounds(y, x)) return wall;
4783 /* Ignore "pre-stamped" entries */
4784 if (travel.cost[y][x] != TRAVEL_UNABLE) return wall;
4786 /* Ignore "walls" and "rubble" (include "secret doors") */
4787 if (have_flag(f_ptr->flags, FF_WALL) ||
4788 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4789 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic) ||
4790 (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation))
4792 if (!wall) return wall;
4799 /* Save the flow cost */
4800 travel.cost[y][x] = n;
4801 if (wall) travel.cost[y][x] += TRAVEL_UNABLE;
4803 /* Enqueue that entry */
4804 temp2_y[flow_head] = y;
4805 temp2_x[flow_head] = x;
4807 /* Advance the queue */
4808 if (++flow_head == MAX_SHORT) flow_head = 0;
4810 /* Hack -- notice overflow by forgetting new entry */
4811 if (flow_head == flow_tail) flow_head = old_head;
4817 static void travel_flow(int ty, int tx)
4821 feature_type *f_ptr = &f_info[cave[ty][tx].feat];
4823 /* Reset the "queue" */
4824 flow_head = flow_tail = 0;
4826 if (!have_flag(f_ptr->flags, FF_MOVE)) wall = TRUE;
4828 /* Add the player's grid to the queue */
4829 wall = travel_flow_aux(ty, tx, 0, wall);
4831 /* Now process the queue */
4832 while (flow_head != flow_tail)
4834 /* Extract the next entry */
4835 y = temp2_y[flow_tail];
4836 x = temp2_x[flow_tail];
4838 /* Forget that entry */
4839 if (++flow_tail == MAX_SHORT) flow_tail = 0;
4841 /* Add the "children" */
4842 for (d = 0; d < 8; d++)
4844 /* Add that child if "legal" */
4845 wall = travel_flow_aux(y + ddy_ddd[d], x + ddx_ddd[d], travel.cost[y][x] + 1, wall);
4849 /* Forget the flow info */
4850 flow_head = flow_tail = 0;
4853 void do_cmd_travel(void)
4857 feature_type *f_ptr;
4859 if (!tgt_pt(&x, &y)) return;
4861 if ((x == px) && (y == py))
4864 msg_print("¤¹¤Ç¤Ë¤½¤³¤Ë¤¤¤Þ¤¹¡ª");
4866 msg_print("You are already there!!");
4871 f_ptr = &f_info[cave[y][x].feat];
4873 if ((cave[y][x].info & CAVE_MARK) &&
4874 (have_flag(f_ptr->flags, FF_WALL) ||
4875 have_flag(f_ptr->flags, FF_CAN_DIG) ||
4876 (have_flag(f_ptr->flags, FF_DOOR) && cave[y][x].mimic)))
4879 msg_print("¤½¤³¤Ë¤Ï¹Ô¤¯¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª");
4881 msg_print("You cannot travel there!");
4889 forget_travel_flow();
4892 /* Travel till 255 steps */
4898 /* Decides first direction */
4901 sx = ((x == px) || (dx < dy)) ? 0 : ((x > px) ? 1 : -1);
4902 sy = ((y == py) || (dy < dx)) ? 0 : ((y > py) ? 1 : -1);
4904 for (i = 1; i <= 9; i++)
4906 if ((sx == ddx[i]) && (sy == ddy[i])) travel.dir = i;